@inkeep/open-knowledge 0.47.0-beta.7 → 0.47.0-beta.8
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-CBeUqCYG.mjs → acp-harness-probe-1hW3PL5n.mjs} +2 -2
- package/dist/cli.mjs +7 -7
- package/dist/config-schema.json +35 -1
- package/dist/config.user.schema.json +35 -1
- package/dist/constants-DIYjBPRr.mjs +2 -0
- package/dist/{fs-traced-D12ehU8a.mjs → fs-traced-ArlA_yTp.mjs} +2 -2
- package/dist/fs-traced-C9U9YUGm.mjs +1 -0
- package/dist/{git-handle-BKNpWc-0.mjs → git-handle-B9cFlvR2.mjs} +2 -2
- package/dist/git-handle-pq-bTXGz.mjs +1 -0
- package/dist/index.d.mts +39 -19
- package/dist/index.mjs +1 -1
- package/dist/init-Bz1EZDov.mjs +1 -0
- package/dist/{init-U57dU1yg.mjs → init-D8sYk3tw.mjs} +3 -3
- package/dist/{launch-json-removal-DqaQa1rL.mjs → launch-json-removal-CEEYc6CX.mjs} +2 -2
- package/dist/{loader-xhoFGDAP.mjs → loader-BKjQIQ-O.mjs} +2 -2
- package/dist/loader-Cb6MWpe2.mjs +1 -0
- package/dist/md-manager-CQwbqiDq.mjs +2 -0
- package/dist/{open-browser-BGPHwSRQ.mjs → open-browser-DtS0SaFA.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-BiUIhZCf.mjs +1 -0
- package/dist/{preview-q8UY5TPk.mjs → preview-GfE2HVUy.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-Cs_G4A2z.js → ActivityModeContent-BSIeX2WL.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-CWfs6hRd.js → AgentDiffPane-u4kU4q9y.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-GaJMQpHN.js → AgentThreadClientBinder-CMHNZB8k.js} +1 -1
- package/dist/public/assets/{ChangedOutsideBadge-DhOK_p1U.js → ChangedOutsideBadge-Byr7iRWr.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DvoNWmdR.js → CodeMirrorPropInput-kJZpOqjB.js} +1 -1
- package/dist/public/assets/{ConsentDialogBody-CB447Y2k.js → ConsentDialogBody-VKhCzQXH.js} +1 -1
- package/dist/public/assets/{DocumentContext-BaYg4CBg.js → DocumentContext-B5qum6Oo.js} +9 -9
- package/dist/public/assets/{EditorModeToggle-C9I-Efpm.js → EditorModeToggle-C7I7X4RS.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-DCen-fKk.js → EnableSyncConfirmDialog-C5lcZQ0m.js} +1 -1
- package/dist/public/assets/FeedbackForm-Bxhb1af-.js +1 -0
- package/dist/public/assets/{GraphPanel-B9HMPssx.js → GraphPanel-BKU-sjWQ.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BjLITatU.js → ImportSkillDialog-eU2Zr5ex.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-D6dnss9h.js → LintConfigEditor-xKBwOmU6.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-BO70pd59.js → ManagedArtifactProperties-C8FxdLXe.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-Ck3gsN1B.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-CZC9r_Ug.js → McpConsentDialogBody-5vUQ_tGC.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-C6SV6GjT.js → MermaidDocEditor-BZ9qREZ6.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-BZrgGB1Z.js → ReportBugDialogBody-rA74DPnv.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-BYBjMHsb.js → SchemaConfigEditor-BzlmoCOH.js} +1 -1
- package/dist/public/assets/{SessionsHost-llsZYWbP.js → SessionsHost-D1cUv-UU.js} +2 -2
- package/dist/public/assets/SettingsDialogBody-Cg9DTpQ7.js +12 -0
- package/dist/public/assets/{ShareBranchSwitchDialog-DUzjoGVJ.js → ShareBranchSwitchDialog-COHEBcfz.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-BQhhG70Y.js → ShareReceiveDialog-DcNIOm6y.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CaI0eq9C.js → ShareReceiveMissDialog-DVZqfzBh.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-WG0cwpb-.js → SkillEditBanner-nlYN__8g.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-8KJ3qbz8.js → SkillOriginInline-BBZCbGv3.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-LDRTNFTx.js → SkillToolbarControls-VrT7GSrm.js} +1 -1
- package/dist/public/assets/{SourceEditor-nYPGo8QU.js → SourceEditor-DQatC6rT.js} +1 -1
- package/dist/public/assets/{TerminalPanel-CkcArSmy.js → TerminalPanel-BHk4hxn3.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-COjq6Uas.js → TerminalWindowApp-C81f0KjQ.js} +1 -1
- package/dist/public/assets/{TextDocEditor-eS5P-G2H.js → TextDocEditor-BSQz8TPb.js} +1 -1
- package/dist/public/assets/{ThreadView-v9Y3Ih_a.js → ThreadView-FpQMMfQp.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-3nkpH5uW.js → TimelineDiffPane-DRAMrTuM.js} +1 -1
- package/dist/public/assets/{agent-diff-store-PJFwSxS1.js → agent-diff-store-BMOeSX25.js} +1 -1
- package/dist/public/assets/{agent-visibility-Cieocxzz.js → agent-visibility-CRJC_Mmi.js} +1 -1
- package/dist/public/assets/auth-state-cache-BUKZaRRr.js +11 -0
- package/dist/public/assets/{client-version-uMlMQx33.js → client-version-NCw3CPbg.js} +1 -1
- package/dist/public/assets/config-context-wTySMMh_.js +1 -0
- package/dist/public/assets/config-provider-BtDy9McS.js +4 -0
- package/dist/public/assets/{dist-CrqBb5y32.js → dist-0V5DS-jp2.js} +163 -163
- package/dist/public/assets/{doc-paths-CCYuGvJq.js → doc-paths-eqs57MlK.js} +1 -1
- package/dist/public/assets/{documents-events-CdU1iFH9.js → documents-events-BtZ7NV1t.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-a1hBKu8z.js → file-tree-adapter-CheEwQMW.js} +1 -1
- package/dist/public/assets/{file-tree-utils-CClHAhYa.js → file-tree-utils-KtcdmJ_g.js} +1 -1
- package/dist/public/assets/{folder-config-api-6QhNU0oa.js → folder-config-api-DT4VLF_M.js} +1 -1
- package/dist/public/assets/{globals-DliH2YSL.js → globals-BlQP66GU.js} +1 -1
- package/dist/public/assets/globals-CqGu_JES.css +1 -0
- package/dist/public/assets/{index-kaTVsIsC.js → index-CcB59-rH.js} +11 -11
- package/dist/public/assets/{lint-config-client-B0H2okzr.js → lint-config-client-CKDOijIM.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-BXGIkBuD.js → markdownlint-rule-browser-P1sDghK_.js} +1 -1
- package/dist/public/assets/{navigation-targets-BwmQHp3k.js → navigation-targets-gc61t_Ad.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BzW5kLR0.js → open-managed-artifact-tab-DnKux2mI.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-B1W7hvut.js → pending-receive-nav-store-VNTolH5C.js} +1 -1
- package/dist/public/assets/{project-paths-DF-eCznB.js → project-paths-B8XPtMMF.js} +1 -1
- package/dist/public/assets/{prop-types-DIaGyPZM.js → prop-types-BdjIW0eY.js} +1 -1
- package/dist/public/assets/{radio-group-MAC3jHHk.js → radio-group-CvYE9US5.js} +1 -1
- package/dist/public/assets/{receive-store-DlIsfkuF.js → receive-store-Cv1sOLk9.js} +1 -1
- package/dist/public/assets/{selection-context-DS--IqEv.js → selection-context-bQG3wbZN.js} +1 -1
- package/dist/public/assets/{skill-actions-DCISbh85.js → skill-actions-BQVwP81Q.js} +1 -1
- package/dist/public/assets/{skill-scope-7fBhGcjl.js → skill-scope-C6bIed6c.js} +1 -1
- package/dist/public/assets/{skills-api-wUsPYcxD.js → skills-api-MKau2YTq.js} +1 -1
- package/dist/public/assets/{src-ScxRfF8q.js → src-CChG2POU.js} +1 -1
- package/dist/public/assets/{tag-pill-input-Bx_oWl-2.js → tag-pill-input-_lxupqbK.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-D2TXEip5.js → target-navigation-intent-BAyNSKBJ.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-B3gBFWc1.js → terminal-launch-events-CwG2wSZB.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-Bv3GE2Aw.js → terminal-telemetry--GWjCDpk.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-lX1cLLkC.js → typing-burst-detector-BPenX-sr.js} +1 -1
- package/dist/public/assets/{uninstall-BILpXTW1.js → uninstall-Dy_6kiW_.js} +1 -1
- package/dist/public/assets/{use-activity-panel-CxtCUEYv.js → use-activity-panel-BsN0fEDd.js} +1 -1
- package/dist/public/assets/{use-collab-url-BjRhUqsT.js → use-collab-url-BPCGWweY.js} +1 -1
- package/dist/public/assets/use-live-xterm-theme-ChdaDRFM.js +1 -0
- package/dist/public/assets/{use-open-skill-BHdzD0v1.js → use-open-skill-Civ_cY4Q.js} +1 -1
- package/dist/public/assets/{use-settings-route-aXWIMVRt.js → use-settings-route-1lmVz-nQ.js} +1 -1
- package/dist/public/assets/{use-skill-directory-BV092Gnw.js → use-skill-directory-DXhI7ilx.js} +1 -1
- package/dist/public/assets/{use-skill-origin-DMt7ay7U.js → use-skill-origin-_K8KHC47.js} +1 -1
- package/dist/public/assets/{use-skills-C7huRzJa.js → use-skills-BfXZuh-E.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-C5zv0ln-.js → use-terminal-enabled-BfSuv1_p.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-EbqHCjsV.js → use-timeline-entry-diff-DDbjjCJ4.js} +1 -1
- package/dist/public/assets/{use-workspace-D80aSSBD.js → use-workspace-BqaxnWdM.js} +1 -1
- package/dist/public/index.html +67 -55
- package/dist/public/uninstall.html +5 -5
- package/dist/{repair-launch-json-DTprea3X.mjs → repair-launch-json-09_4Eq7Q.mjs} +2 -2
- package/dist/{repair-mcp-configs-fLP2d4Sv.mjs → repair-mcp-configs-hOx2UuWW.mjs} +2 -2
- package/dist/{repair-skills-CXOdNyyU.mjs → repair-skills-BXCsRRL9.mjs} +2 -2
- package/dist/repair-skills-xur4yCYG.mjs +1 -0
- package/dist/schemas/v0/config.user.schema.json +35 -1
- package/dist/{server-lock-9wk8At58.mjs → server-lock-B1IPSV1G.mjs} +2 -2
- package/dist/server-lock-BWO8zIgq.mjs +1 -0
- package/dist/{sleep-jUpHbV7f.mjs → sleep-ByqzSHar.mjs} +2 -2
- package/dist/{src-BA6UmYHS.mjs → src-CHGk5YB-.mjs} +6 -6
- package/dist/{src-DHvnHIfx.mjs → src-CxlsTHjS.mjs} +2 -2
- package/dist/{src-7fluFHtm.mjs → src-DjMcdwEK.mjs} +1 -1
- package/dist/{src-Dkrbi5Bh.mjs → src-xqnWcl6h.mjs} +2 -2
- package/dist/start-Xrk-GV7g.mjs +1 -0
- package/dist/{start-DIAtP5MI.mjs → start-hMxYZyqG.mjs} +3 -3
- package/dist/{write-project-skill-D_i5y_ki.mjs → write-project-skill-d8JhYDYY.mjs} +2 -2
- package/package.json +5 -5
- package/dist/constants-DCo5SoGr.mjs +0 -2
- package/dist/fs-traced-C-HqiL6u.mjs +0 -1
- package/dist/git-handle-vAOkZizz.mjs +0 -1
- package/dist/init-DRRq7R14.mjs +0 -1
- package/dist/loader-AwhLQhFP.mjs +0 -1
- package/dist/md-manager-BuZAb56s.mjs +0 -2
- package/dist/preview-AXmnVWXt.mjs +0 -1
- package/dist/public/assets/FeedbackForm-EBcXu2CA.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-BkBzFhn7.js +0 -1
- package/dist/public/assets/SettingsDialogBody-DXaeMFz_.js +0 -12
- package/dist/public/assets/auth-state-cache-B8KE-_17.js +0 -11
- package/dist/public/assets/config-context-BIynQsCe.js +0 -1
- package/dist/public/assets/config-provider-DKj_NBqh.js +0 -4
- package/dist/public/assets/globals-BLjNYywW.css +0 -1
- package/dist/public/assets/use-live-xterm-theme-Cvtrg0j6.js +0 -1
- package/dist/repair-skills-CdFjRSeM.mjs +0 -1
- package/dist/server-lock-DxjYF04b.mjs +0 -1
- package/dist/start-CvmSQeQC.mjs +0 -1
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{In as n,Nn as r,i,xn as a}from"./DocumentContext-BaYg4CBg.js";import{t as o}from"./react-f2sANaYj.js";import{n as s,r as c}from"./dist-Nvb76hAm.js";import{t as l}from"./compiler-runtime-BfE3aGVn.js";import{a as u,c as d,s as f}from"./terminal-input-events-BGPQuYMh.js";import{t as p}from"./utils-CPqDy6Hr.js";import{t as m}from"./use-workspace-D80aSSBD.js";import{c as h,i as g,l as _}from"./ChangedOutsideBadge-DhOK_p1U.js";import{t as v}from"./button-RQ5o7P7w.js";import{i as y,n as b,t as x}from"./tooltip-x7BNUa3s.js";import{a as S,c as C,i as w,n as T,o as E,s as D,t as O}from"./dialog-FGMqkFjm.js";import{a as k,m as A,r as j,t as M}from"./dropdown-menu-AlVJ7dJz.js";import{t as N}from"./label-G0lbYOgL.js";import{n as P,t as F}from"./radio-group-MAC3jHHk.js";import{t as I}from"./switch-BuVbhbtp.js";import{n as L,t as R}from"./toggle-group-Cnezoq-B.js";import{At as z,Dt as B,Eo as ee,Et as V,Fo as H,Ga as U,Lt as W,Ot as G,Tt as K,mt as q,qa as J,wo as te}from"./dist-CrqBb5y32.js";import{t as ne}from"./createLucideIcon-DihYAFEK.js";import{f as re,n as ie,r as ae,t as oe}from"./EnableSyncConfirmDialog-DCen-fKk.js";import{s as se}from"./Mermaid-BePjlqwg.js";import{t as ce}from"./arrow-up-right-CxtRAecj.js";import{t as le}from"./check-BIbL8Vva.js";import{n as ue}from"./CopyButton-D6N3opvE.js";import{s as Y}from"./prop-types-DIaGyPZM.js";import{t as de}from"./download-DlaLrCD-.js";import{a as fe,r as pe,t as me}from"./folder-config-api-6QhNU0oa.js";import{t as he}from"./loader-circle-DJ1nzSAL.js";import{t as ge}from"./refresh-cw-CTfHLdRW.js";import{a as _e,i as ve,n as ye,o as be,r as xe,s as Se,t as Ce}from"./field-CmzMDU7U.js";import{t as we}from"./trash-2-WxyktwvM.js";import{t as Te}from"./triangle-alert-C2yId37R.js";import{t as Ee}from"./x-xV4a4mi6.js";import{n as De}from"./dist-uN7pEWl0.js";import{t as Oe}from"./input-Cm94Cun3.js";import{t as X}from"./dist-CzC3AWOn.js";import{f as ke,n as Ae,u as je}from"./doc-paths-CCYuGvJq.js";import{t as Me}from"./parse-api-error-Dmlzsw8v.js";import{d as Ne,o as Pe,p as Fe}from"./documents-events-CdU1iFH9.js";import"./config-provider-DKj_NBqh.js";import{y as Ie}from"./skills-api-wUsPYcxD.js";import{n as Le}from"./config-context-BIynQsCe.js";import{t as Re}from"./external-link-Dvu-nzFi.js";import{t as ze}from"./textarea-Cl4IJ1LU.js";import{n as Be,t as Ve}from"./clipboard-adapter-Brbch5VX.js";var He=ne(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ue=ne(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),We=ne(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Ge=ne(`move-up-right`,[[`path`,{d:`M13 5H19V11`,key:`1n1gyv`}],[`path`,{d:`M19 5L5 19`,key:`72u4yj`}]]),Ke=ne(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),qe=ne(`user-cog`,[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`,key:`1nfge6`}],[`path`,{d:`m14.305 16.53.923-.382`,key:`1itpsq`}],[`path`,{d:`m15.228 13.852-.923-.383`,key:`eplpkm`}],[`path`,{d:`m16.852 12.228-.383-.923`,key:`13v3q0`}],[`path`,{d:`m16.852 17.772-.383.924`,key:`1i8mnm`}],[`path`,{d:`m19.148 12.228.383-.923`,key:`1q8j1v`}],[`path`,{d:`m19.53 18.696-.382-.924`,key:`vk1qj3`}],[`path`,{d:`m20.772 13.852.924-.383`,key:`n880s0`}],[`path`,{d:`m20.772 16.148.924.383`,key:`1g6xey`}],[`circle`,{cx:`18`,cy:`15`,r:`3`,key:`gjjjvw`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Z=l(),Q=e(o(),1);function Je(e){let t=(0,Z.c)(12),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={status:`idle`},t[0]=n):n=t[0];let[r,i]=(0,Q.useState)(n),[a,o]=(0,Q.useState)(0),s,c;t[1]===e?(s=t[2],c=t[3]):(s=()=>{if(e!==null)return Fe(()=>{o(Qe)})},c=[e],t[1]=e,t[2]=s,t[3]=c),(0,Q.useEffect)(s,c);let l;t[4]===e?l=t[5]:(l=()=>{if(e===null){i({status:`idle`});return}let t=!1;i({status:`loading`});let n=e?`?path=${encodeURIComponent(e)}`:``;return fetch(`/api/folder-config${n}`).then(Xe).then(e=>{if(!t){if(!e||typeof e!=`object`||!e.folder){i({status:`error`,message:`Server returned an incomplete folder response.`});return}i({status:`ready`,data:{folder:e.folder,frontmatterLocal:e.frontmatter_local??null}})}}).catch(e=>{t||i({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},t[4]=e,t[5]=l);let u;t[6]!==e||t[7]!==a?(u=[e,a],t[6]=e,t[7]=a,t[8]=u):u=t[8],(0,Q.useEffect)(l,u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o(Ye),t[9]=d):d=t[9];let f;return t[10]===r?f=t[11]:(f={state:r,refresh:d},t[10]=r,t[11]=f),f}function Ye(e){return e+1}async function Xe(e){if(!e.ok){let t=await e.json().catch(Ze);throw Error(Me(t)??`HTTP ${e.status}`)}return e.json()}function Ze(){return null}function Qe(e){return e+1}function $e(){let e=(0,Z.c)(6),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),[i,a]=(0,Q.useState)(0),o,s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(()=>{a(nt)}),s=[],e[1]=o,e[2]=s):(o=e[1],s=e[2]),(0,Q.useEffect)(o,s);let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=!1;return r({status:`loading`}),fetch(`/api/templates`).then(et).then(t=>{if(e)return;let n=W.safeParse(t);if(!n.success){console.error(`[ok-templates] /api/templates response failed schema validation:`,n.error.issues),r({status:`error`,message:`Server returned an incomplete templates response.`});return}r({status:`ready`,data:n.data.templates})}).catch(t=>{e||r({status:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},e[3]=c):c=e[3];let l;return e[4]===i?l=e[5]:(l=[i],e[4]=i,e[5]=l),(0,Q.useEffect)(c,l),n}async function et(e){if(!e.ok){let t=await e.json().catch(tt);throw Error(Me(t)??`HTTP ${e.status}`)}return e.json()}function tt(){return null}function nt(e){return e+1}async function rt(){try{let e=await fetch(`/api/semantic-status`);return e.ok?await e.json():(console.debug(`[semantic-status] probe returned`,e.status),null)}catch(e){return console.debug(`[semantic-status] probe failed`,e),null}}function it(e){let t=(0,Z.c)(16),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n.enabled??!0,[i,a]=(0,Q.useState)(null),o;t[2]===r?o=t[3]:(o=function(){r&&rt().then(e=>{e&&a(e)})},t[2]=r,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=()=>{s()},t[4]=s,t[5]=c);let l;t[6]===r?l=t[7]:(l=[r],t[6]=r,t[7]=l),(0,Q.useEffect)(c,l);let u;t[8]!==r||t[9]!==s?(u=()=>{if(r)return Ne(e=>{e.includes(`files`)&&s()})},t[8]=r,t[9]=s,t[10]=u):u=t[10];let d;t[11]===r?d=t[12]:(d=[r],t[11]=r,t[12]=d),(0,Q.useEffect)(u,d);let f;return t[13]!==s||t[14]!==i?(f={status:i,refresh:s},t[13]=s,t[14]=i,t[15]=f):f=t[15],f}var $=t(),at=`github.com`,ot=new Map;async function st(e){try{let t=await e.json(),n=q.safeParse(t);if(n.success)return n.data.title}catch{}}async function ct(e,t){return fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})})}async function lt(e){let t=e?.host??at,n=await ct(`/api/local-op/auth/status`,e);if(!n.ok)return{authenticated:!1,host:t,error:await st(n)};let r=await n.json(),i=typeof r.host==`string`?r.host:t,a=r.ghAvailable===!0;if(r.authenticated===!0&&typeof r.login==`string`){let e=r.tier===`A`||r.tier===`B`||r.tier===`C`?r.tier:void 0;return{authenticated:!0,host:i,login:r.login,tier:e,name:typeof r.name==`string`?r.name:void 0,email:typeof r.email==`string`?r.email:void 0,ghAvailable:a}}return{authenticated:!1,host:i,error:typeof r.error==`string`?r.error:void 0,ghAvailable:a}}function ut(e){let t=e?.host??at,n=ot.get(t);if(n)return n;let r=lt(e).finally(()=>{ot.delete(t)});return ot.set(t,r),r}function dt(e){let t=e.split(`
|
|
2
|
-
`);for(let e=t.length-1;e>=0;e--){let n=t[e]?.trim();if(n)try{let e=JSON.parse(n);if(e&&typeof e==`object`)return e}catch{}}return null}function ft(){return{status:ut,async repos(e){let t=e?.host??`github.com`,n=await ct(`/api/local-op/auth/repos`,e);if(!n.ok)return{ok:!1,error:await st(n)??`Failed to fetch repositories`};let r=dt(await n.text());if(r&&r.type===`error`&&r.problem&&typeof r.problem==`object`){let e=r.problem;return{ok:!1,error:e.detail||e.title||`Failed to fetch repositories`}}if(!r||!Array.isArray(r.repos))return{ok:!1,error:`Failed to fetch repositories`};let i=[];for(let e of r.repos){let t=e;typeof t?.full_name==`string`&&typeof t.clone_url==`string`&&i.push({full_name:t.full_name,clone_url:t.clone_url,private:t.private===!0})}return{ok:!0,host:typeof r.host==`string`?r.host:t,repos:i}},async signout(e){let t=await ct(`/api/local-op/auth/signout`,e);return t.ok?{ok:!0}:{ok:!1,error:await st(t)}}}}function pt(e){return{status:t=>e.localOp.authStatus(t),repos:t=>e.localOp.authRepos(t)}}async function mt(e,t){let n=e.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:a}=await n.read();if(e)return i+=r.decode(),!!(i.trim()&&t(i)===`terminal`);i+=r.decode(a,{stream:!0});let o=i.split(`
|
|
3
|
-
`);i=o.pop()??``;for(let e of o)if(e.trim()&&t(e)===`terminal`)return!0}}function ht(e){let t=[],n=[],r=new AbortController,i=!1,a=()=>{for(let e of n.splice(0))e(null)};return e(e=>{i||(n.length>0?n.shift()?.(e):t.push(e),(e.type===`complete`||e.type===`error`)&&(i=!0,r.abort(),a()))},r.signal),{events:{[Symbol.asyncIterator](){return{async next(){if(t.length>0){let e=t.shift();return e===void 0?{value:void 0,done:!0}:{value:e,done:!1}}return i?{value:void 0,done:!0}:new Promise(e=>{n.push(t=>{e(t===null?{value:void 0,done:!0}:{value:t,done:!1})})})}}}},cancel:()=>{i||(i=!0,r.abort(),a())}}}var gt=2e3,_t=1e4;function vt(e,t){return new Promise(n=>{let r=setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);function i(){clearTimeout(r),n()}t.addEventListener(`abort`,i,{once:!0})})}function yt(e){fetch(`/api/local-op/auth/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({channel:e})}).catch(e=>{console.warn(`[auth-transport] Cancel request failed (best-effort):`,e instanceof Error?e.message:e)})}async function bt(e,t,n,r){let i=ft(),a=gt;for(;!t.aborted&&Date.now()<n;){try{let n=await i.status(r?{host:r}:void 0);if(t.aborted)return;if(n.authenticated){e({type:`complete`,host:n.host,login:n.login,name:n.name,email:n.email});return}}catch(e){console.warn(`[auth-transport] Recovery probe failed:`,e instanceof Error?e.message:e)}await vt(a,t),a=Math.min(a*1.5,_t)}t.aborted||e({type:`error`,message:X._({id:`ve8vEM`})})}function xt(e,t,n){let r=!1,i=ht((n,i)=>{let a=e=>{(e.type===`complete`||e.type===`error`)&&(r=!0),n(e)};(async()=>{let n=null;try{let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:i});if(!r.ok){let e=X._({id:`LnVIW4`});try{let t=q.safeParse(await r.json());t.success&&(e=t.data.title)}catch{}a({type:`error`,message:e});return}if(!r.body){a({type:`error`,message:X._({id:`LnVIW4`})});return}if(await mt(r.body,e=>{let t;try{t=JSON.parse(e)}catch{return console.warn(`[auth-transport] Dropped unparseable NDJSON line:`,e.slice(0,100)),`continue`}if(t&&typeof t==`object`&&t.type===`error`&&`problem`in t){let e=t.problem;return a({type:`error`,message:e?.detail||e?.title||X._({id:`29VNqC`})}),`terminal`}if(t.type===`ping`)return`continue`;let r=t;return r.type===`verification`&&(n=Date.now()+r.expires_in*1e3),a(r),r.type===`complete`||r.type===`error`?`terminal`:`continue`})||i.aborted)return;if(n===null){a({type:`error`,message:X._({id:`DskIkK`})});return}await bt(a,i,n,t.host)}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;if(n!==null){await bt(a,i,n,t.host);return}a({type:`error`,message:X._({id:`Q5fqMz`})})}})()});return{events:i.events,cancel:()=>{r||yt(n),i.cancel()}}}function St(){return{start(){return xt(`/api/local-op/auth/login`,{json:!0},`login`)},ghLogin(e){return xt(`/api/local-op/auth/gh-login`,{host:e,json:!0},`gh-login`)},async pat(e,t){try{let n=await fetch(`/api/local-op/auth/pat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({host:e,token:t})});if(n.ok){let e=await n.json();return{ok:!0,login:typeof e.login==`string`?e.login:``}}let r=X._({id:`sNeKjP`});try{let e=q.safeParse(await n.json());e.success&&(r=e.data.detail||e.data.title)}catch{}return{ok:!1,error:r}}catch{return{ok:!1,error:X._({id:`Q5fqMz`})}}}}}function Ct(e){return{start(){return e.localOp.auth.start()}}}async function wt(e){try{await navigator.clipboard.writeText(e)}catch{}}function Tt(e){let t=(0,Z.c)(25),{onSuccess:n,startFlow:r}=e,{_:i}=c(),[a,o]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(`https://github.com/login/device`),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[_,y]=(0,Q.useState)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S;t[0]!==i||t[1]!==n||t[2]!==r?(S=async function(){m(null);try{let e=r();b.current=e.cancel;let t=e.events[Symbol.asyncIterator](),a=!1,s=await t.next();for(;!s.done;){let e=s.value;if(e.type===`verification`)o(e.user_code),u(e.verification_uri),g(Date.now()+e.expires_in*1e3),y(e.expires_in*1e3),wt(e.user_code).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)});else if(e.type===`complete`){a=!0,n({login:e.login,name:e.name,email:e.email,avatarUrl:e.avatarUrl});break}else if(e.type===`error`){a=!0,m(e.message);break}s=await t.next()}a||m(i({id:`DskIkK`}))}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&m(i({id:`Q5fqMz`}))}},t[0]=i,t[1]=n,t[2]=r,t[3]=S):S=t[3];let C=S,w;t[4]===C?w=t[5]:(w=()=>{let e=!1;return queueMicrotask(()=>{e||C()}),()=>{e=!0,b.current?.(),b.current=null,x.current&&clearInterval(x.current)}},t[4]=C,t[5]=w);let T;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[6]=T):T=t[6],(0,Q.useEffect)(w,T);let E,D;t[7]!==i||t[8]!==h?(E=()=>{if(h!==null)return x.current=setInterval(()=>{let e=h-Date.now();e<=0?(y(0),x.current&&clearInterval(x.current),m(i({id:`ve8vEM`}))):y(e)},1e3),()=>{x.current&&clearInterval(x.current)}},D=[h,i],t[7]=i,t[8]=h,t[9]=E,t[10]=D):(E=t[9],D=t[10]),(0,Q.useEffect)(E,D);let O=Math.floor(_/6e4),k=Math.floor(_%6e4/1e3),A;t[11]===k?A=t[12]:(A=k.toString().padStart(2,`0`),t[11]=k,t[12]=A);let j=`${O}:${A}`,M;t[13]!==i||t[14]!==d||t[15]!==p||t[16]!==j||t[17]!==a||t[18]!==l?(M=a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`eVPynQ`,values:{verificationUri:l},components:{0:(0,$.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Re(e,l),onAuxClick:e=>Re(e,l),className:`inline-flex items-center gap-0.5 text-foreground hover:text-primary hover:underline`}),1:(0,$.jsx)(`span`,{}),2:(0,$.jsx)(ce,{className:`inline size-3.5`,"aria-hidden":!0})}})}),(0,$.jsxs)(v,{type:`button`,variant:`outline`,"aria-label":i({id:`nCzR-G`,values:{userCode:a}}),onClick:()=>void wt(a).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}),className:`relative h-auto w-full justify-center rounded-md bg-muted px-12 py-3 hover:bg-muted/80`,children:[(0,$.jsx)(`code`,{className:`font-mono text-2xl font-bold tracking-widest`,children:a}),(0,$.jsx)(`span`,{className:`absolute right-3 text-muted-foreground`,"aria-hidden":`true`,children:d?(0,$.jsx)(le,{className:`size-4`}):(0,$.jsx)(ue,{className:`size-4`})})]}),(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,children:d?(0,$.jsx)(s,{id:`80c4-P`}):null}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500 animate-pulse`}),(0,$.jsx)(s,{id:`5y_9lO`})]}),(0,$.jsx)(`span`,{children:(0,$.jsx)(s,{id:`gYz2ep`,values:{timeLabel:j}})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:p?null:(0,$.jsx)(s,{id:`aWlJai`})}),t[13]=i,t[14]=d,t[15]=p,t[16]=j,t[17]=a,t[18]=l,t[19]=M):M=t[19];let N;t[20]===p?N=t[21]:(N=p&&(0,$.jsx)(`p`,{className:`text-1sm text-destructive`,children:p}),t[20]=p,t[21]=N);let P;return t[22]!==M||t[23]!==N?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[M,N]}),t[22]=M,t[23]=N,t[24]=P):P=t[24],P}function Et(e){let t=(0,Z.c)(30),{login:n,name:r,onNameChange:i,email:a,onEmailChange:o}=e,{_:l}=c(),u;t[0]===n?u=t[1]:(u=(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:(0,$.jsx)(s,{id:`E_tNGD`,values:{login:n}})}),t[0]=n,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`gp3I7-`})}),t[2]=d):d=t[2];let f;t[3]===l?f=t[4]:(f=l({id:`6YtxFj`}),t[3]=l,t[4]=f);let p;t[5]!==l||t[6]!==n?(p=l({id:`J2Mv98`,values:{login:n}}),t[5]=l,t[6]=n,t[7]=p):p=t[7];let m;t[8]===i?m=t[9]:(m=e=>i(e.target.value),t[8]=i,t[9]=m);let h;t[10]!==r||t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsx)(Oe,{"aria-label":f,placeholder:p,value:r,onChange:m}),t[10]=r,t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===l?g=t[16]:(g=l({id:`O3oNi5`}),t[15]=l,t[16]=g);let _;t[17]===l?_=t[18]:(_=l({id:`O3oNi5`}),t[17]=l,t[18]=_);let v;t[19]===o?v=t[20]:(v=e=>o(e.target.value),t[19]=o,t[20]=v);let y;t[21]!==a||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(Oe,{type:`email`,"aria-label":g,placeholder:_,value:a,onChange:v}),t[21]=a,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;return t[26]!==u||t[27]!==y||t[28]!==h?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u,d,h,y]}),t[26]=u,t[27]=y,t[28]=h,t[29]=b):b=t[29],b}function Dt(e){let t=(0,Z.c)(37),{host:n,token:r,onTokenChange:i,error:a,onSubmit:o,showGhOption:l,onGhSignIn:u}=e,{_:d}=c(),f=`https://${n}/settings/tokens/new?scopes=repo,read:user&description=OpenKnowledge`,p;t[0]!==n||t[1]!==u||t[2]!==l?(p=l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(v,{type:`button`,onClick:u,children:(0,$.jsx)(s,{id:`_SDGzH`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,$.jsx)(s,{id:`8L0EPw`}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border`})]})]}):(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`8k6INX`,values:{host:n},components:{0:(0,$.jsx)(`span`,{className:`font-medium text-foreground`})}})}),t[0]=n,t[1]=u,t[2]=l,t[3]=p):p=t[3];let m,h;t[4]===f?(m=t[5],h=t[6]):(m=e=>Re(e,f),h=e=>Re(e,f),t[4]=f,t[5]=m,t[6]=h);let g;t[7]===n?g=t[8]:(g=(0,$.jsx)(s,{id:`6hYjww`,values:{host:n}}),t[7]=n,t[8]=g);let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ce,{className:`inline size-3.5`,"aria-hidden":!0}),t[9]=_):_=t[9];let y;t[10]!==f||t[11]!==m||t[12]!==h||t[13]!==g?(y=(0,$.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,onClick:m,onAuxClick:h,className:`inline-flex w-fit items-center gap-0.5 text-sm text-foreground hover:text-primary hover:underline`,children:[g,_]}),t[10]=f,t[11]=m,t[12]=h,t[13]=g,t[14]=y):y=t[14];let b;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(s,{id:`Xg-Ntj`})}),t[15]=b):b=t[15];let x;t[16]===d?x=t[17]:(x=d({id:`p2LEhJ`}),t[16]=d,t[17]=x);let S;t[18]===i?S=t[19]:(S=e=>i(e.target.value),t[18]=i,t[19]=S);let C;t[20]===o?C=t[21]:(C=e=>{e.key===`Enter`&&o()},t[20]=o,t[21]=C);let w;t[22]!==C||t[23]!==x||t[24]!==S||t[25]!==r?(w=(0,$.jsx)(Oe,{type:`password`,"aria-label":x,placeholder:`ghp_`,value:r,onChange:S,onKeyDown:C}),t[22]=C,t[23]=x,t[24]=S,t[25]=r,t[26]=w):w=t[26];let T;t[27]===a?T=t[28]:(T=a&&(0,$.jsx)(`p`,{className:`text-1sm text-destructive`,children:a}),t[27]=a,t[28]=T);let E;t[29]===l?E=t[30]:(E=!l&&(0,$.jsxs)(`div`,{className:`mt-1 rounded-md border border-border/60 bg-muted/40 p-3 text-sm text-muted-foreground`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(s,{id:`qX-ABr`})}),(0,$.jsxs)(`ol`,{className:`mt-1.5 list-decimal space-y-0.5 pl-5`,children:[(0,$.jsx)(`li`,{children:(0,$.jsx)(s,{id:`jxtXZI`})}),(0,$.jsx)(`li`,{children:(0,$.jsx)(s,{id:`9Vh9Jf`})})]})]}),t[29]=l,t[30]=E);let D;return t[31]!==p||t[32]!==w||t[33]!==T||t[34]!==E||t[35]!==y?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p,y,b,w,T,E]}),t[31]=p,t[32]=w,t[33]=T,t[34]=E,t[35]=y,t[36]=D):D=t[36],D}var Ot=1e4;function kt(e){let t=(0,Z.c)(92),{open:n,onOpenChange:r,onSuccess:i,identityPrompt:a,reauth:o,transport:l,queryTransport:u,host:d,ghAvailable:f}=e,{_:p}=c(),m;t[0]===l?m=t[1]:(m=l??St(),t[0]=l,t[1]=m);let h=m,g;t[2]===u?g=t[3]:(g=u??ft(),t[2]=u,t[3]=g);let _=g,[y,b]=(0,Q.useState)(`auth`),[x,S]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(void 0),[ee,V]=(0,Q.useState)(void 0),H=d??z,U=!!H&&H!==`github.com`&&!!(f??ee)&&typeof h.ghLogin==`function`,W=!a&&d===void 0,G,K;t[4]!==d||t[5]!==a||t[6]!==W||t[7]!==n?(G=()=>{n&&(S(null),A(``),M(``),P(``),I(null),R(!1),B(void 0),V(void 0),b(a||W?`checking`:d&&d!==`github.com`?`pat`:`auth`))},K=[n,a,d,W],t[4]=d,t[5]=a,t[6]=W,t[7]=n,t[8]=G,t[9]=K):(G=t[8],K=t[9]),(0,Q.useLayoutEffect)(G,K);let q;t[10]!==a||t[11]!==n||t[12]!==_?(q=()=>{if(!n||!a)return;let e=!1,t=t=>{e||(e=!0,b(t))},r=setTimeout(()=>t(`auth`),Ot);return _.status().then(n=>{e||(n.authenticated?(S({login:n.login,name:n.name,email:n.email}),A(n.name??``),M(n.email??``),t(`identity`)):t(`auth`))}).catch(()=>{t(`auth`)}),()=>{e=!0,clearTimeout(r)}},t[10]=a,t[11]=n,t[12]=_,t[13]=q):q=t[13];let J;t[14]!==a||t[15]!==n?(J=[n,a],t[14]=a,t[15]=n,t[16]=J):J=t[16],(0,Q.useEffect)(q,J);let te;t[17]!==W||t[18]!==n||t[19]!==_?(te=()=>{if(!n||!W)return;let e=!1,t=t=>{e||(e=!0,b(t))},r=setTimeout(()=>t(`auth`),Ot);return _.status().then(n=>{if(e)return;let r=!!n.host&&n.host!==`github.com`;B(n.host),V(n.ghAvailable),t(r?`pat`:`auth`)}).catch(()=>{t(`auth`)}),()=>{e=!0,clearTimeout(r)}},t[17]=W,t[18]=n,t[19]=_,t[20]=te):te=t[20];let ne;t[21]!==W||t[22]!==n?(ne=[n,W],t[21]=W,t[22]=n,t[23]=ne):ne=t[23],(0,Q.useEffect)(te,ne);let re;t[24]!==p||t[25]!==a||t[26]!==r||t[27]!==i?(re=function(e){if(S(e),a)A(e.name??``),M(e.email??``),b(`identity`);else{b(`done`),i?.(e),r(!1);let t=e.login;De.success(p(t?{id:`E_tNGD`,values:{login:t}}:{id:`cgl-gn`}))}},t[24]=p,t[25]=a,t[26]=r,t[27]=i,t[28]=re):re=t[28];let ie=re,ae;t[29]!==p||t[30]!==H||t[31]!==ie||t[32]!==L||t[33]!==N||t[34]!==h?(ae=async function(){let e=N.trim();if(!e||!H||L)return;if(!h.pat){I(p({id:`iMYFJM`}));return}R(!0),I(null);let t=await h.pat(H,e);R(!1),t.ok?ie({login:t.login??``}):I(t.error??p({id:`sNeKjP`}))},t[29]=p,t[30]=H,t[31]=ie,t[32]=L,t[33]=N,t[34]=h,t[35]=ae):ae=t[35];let oe=ae,se;t[36]!==p||t[37]!==x||t[38]!==r||t[39]!==i?(se=function(e,t){fetch(`/api/local-op/auth/set-identity`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,email:t})}).catch(At);let n={...x??{login:``},name:e,email:t};b(`done`),i?.(n),r(!1);let a=n.login;De.success(p(a?{id:`E_tNGD`,values:{login:a}}:{id:`cgl-gn`}))},t[36]=p,t[37]=x,t[38]=r,t[39]=i,t[40]=se):se=t[40];let ce=se,le;t[41]!==p||t[42]!==x||t[43]!==r||t[44]!==i?(le=function(){if(!x)return;b(`done`),i?.(x),r(!1);let e=x.login;De.success(p(e?{id:`E_tNGD`,values:{login:e}}:{id:`cgl-gn`}))},t[41]=p,t[42]=x,t[43]=r,t[44]=i,t[45]=le):le=t[45];let ue=le,Y;t[46]===r?Y=t[47]:(Y=function(){r(!1)},t[46]=r,t[47]=Y);let de=Y,fe;t[48]!==a||t[49]!==o||t[50]!==y?(fe=(0,$.jsx)(D,{children:(0,$.jsx)(C,{children:o&&(y===`pat`||y===`gh-device`)?(0,$.jsx)(s,{id:`DUWgfT`}):o?(0,$.jsx)(s,{id:`X8kjQX`}):y===`pat`||y===`gh-device`?(0,$.jsx)(s,{id:`tzZ6ha`}):a&&y!==`auth`?(0,$.jsx)(s,{id:`29XZXN`}):(0,$.jsx)(s,{id:`3jod3l`})})}),t[48]=a,t[49]=o,t[50]=y,t[51]=fe):fe=t[51];let pe;t[52]===y?pe=t[53]:(pe=y===`checking`&&(0,$.jsx)(T,{children:(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`gBbxn_`})})}),t[52]=y,t[53]=pe);let me;t[54]!==ie||t[55]!==de||t[56]!==h||t[57]!==y?(me=y===`auth`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:(0,$.jsx)(Tt,{onSuccess:ie,startFlow:()=>h.start()})}),(0,$.jsx)(E,{children:(0,$.jsx)(v,{variant:`outline`,className:`font-mono uppercase`,onClick:de,children:(0,$.jsx)(s,{id:`dEgA5A`})})})]}),t[54]=ie,t[55]=de,t[56]=h,t[57]=y,t[58]=me):me=t[58];let he;t[59]!==U||t[60]!==H||t[61]!==de||t[62]!==oe||t[63]!==F||t[64]!==L||t[65]!==N||t[66]!==y?(he=y===`pat`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:(0,$.jsx)(Dt,{host:H??``,token:N,onTokenChange:P,error:F,onSubmit:oe,showGhOption:U,onGhSignIn:()=>b(`gh-device`)})}),(0,$.jsxs)(E,{children:[(0,$.jsx)(v,{variant:`outline`,className:`font-mono uppercase`,onClick:de,children:(0,$.jsx)(s,{id:`dEgA5A`})}),(0,$.jsx)(v,{onClick:oe,disabled:!N.trim()||L,children:L?(0,$.jsx)(s,{id:`9zb2WA`}):(0,$.jsx)(s,{id:`iSLIjg`})})]})]}),t[59]=U,t[60]=H,t[61]=de,t[62]=oe,t[63]=F,t[64]=L,t[65]=N,t[66]=y,t[67]=he):he=t[67];let ge;t[68]!==H||t[69]!==ie||t[70]!==de||t[71]!==h||t[72]!==y?(ge=y===`gh-device`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:(0,$.jsx)(Tt,{onSuccess:ie,startFlow:()=>h.ghLogin?.(H??``)??h.start()})}),(0,$.jsxs)(E,{children:[(0,$.jsx)(v,{variant:`ghost`,onClick:()=>b(`pat`),children:(0,$.jsx)(s,{id:`hLKfZe`})}),(0,$.jsx)(v,{variant:`outline`,className:`font-mono uppercase`,onClick:de,children:(0,$.jsx)(s,{id:`dEgA5A`})})]})]}),t[68]=H,t[69]=ie,t[70]=de,t[71]=h,t[72]=y,t[73]=ge):ge=t[73];let _e;t[74]!==x||t[75]!==ce||t[76]!==ue||t[77]!==j||t[78]!==k||t[79]!==y?(_e=y===`identity`&&x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:(0,$.jsx)(Et,{login:x.login,name:k,onNameChange:A,email:j,onEmailChange:M})}),(0,$.jsxs)(E,{children:[(0,$.jsx)(v,{variant:`ghost`,onClick:ue,children:(0,$.jsx)(s,{id:`6Uau97`})}),(0,$.jsx)(v,{onClick:()=>ce(k.trim(),j.trim()),disabled:!k.trim()||!j.trim(),children:(0,$.jsx)(s,{id:`tfDRzk`})})]})]}),t[74]=x,t[75]=ce,t[76]=ue,t[77]=j,t[78]=k,t[79]=y,t[80]=_e):_e=t[80];let ve;t[81]!==fe||t[82]!==pe||t[83]!==me||t[84]!==he||t[85]!==ge||t[86]!==_e?(ve=(0,$.jsxs)(w,{className:`sm:max-w-md`,children:[fe,pe,me,he,ge,_e]}),t[81]=fe,t[82]=pe,t[83]=me,t[84]=he,t[85]=ge,t[86]=_e,t[87]=ve):ve=t[87];let ye;return t[88]!==r||t[89]!==n||t[90]!==ve?(ye=(0,$.jsx)(O,{open:n,onOpenChange:r,children:ve}),t[88]=r,t[89]=n,t[90]=ve,t[91]=ye):ye=t[91],ye}function At(){}function jt(e){let t=(0,Z.c)(16),{value:n,onChange:r,disabled:i,placeholder:a,rows:o}=e,c=i===void 0?!1:i,l=o===void 0?12:o,u=(0,Q.useId)(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(s,{id:`3o3tur`}),t[0]=d):d=t[0];let f;t[1]===u?f=t[2]:(f=(0,$.jsx)(be,{htmlFor:u,children:d}),t[1]=u,t[2]=f);let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(xe,{children:(0,$.jsx)(s,{id:`5gr_ev`,values:{dateToken:`{{date}}`,userToken:`{{user}}`},components:{0:(0,$.jsx)(`code`,{className:`font-mono`}),1:(0,$.jsx)(`code`,{className:`font-mono`})}})}),t[3]=p):p=t[3];let m;t[4]===r?m=t[5]:(m=e=>r(e.target.value),t[4]=r,t[5]=m);let h;t[6]!==c||t[7]!==u||t[8]!==a||t[9]!==l||t[10]!==m||t[11]!==n?(h=(0,$.jsx)(ze,{id:u,value:n,onChange:m,disabled:c,rows:l,spellCheck:!1,placeholder:a,className:`font-mono text-xs leading-relaxed min-h-72`}),t[6]=c,t[7]=u,t[8]=a,t[9]=l,t[10]=m,t[11]=n,t[12]=h):h=t[12];let g;return t[13]!==f||t[14]!==h?(g=(0,$.jsxs)(Ce,{children:[f,p,h]}),t[13]=f,t[14]=h,t[15]=g):g=t[15],g}var Mt=/^[A-Za-z0-9_-]+$/;function Nt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function Pt(e){let t={},n=e.title.trim();n&&(t.title=n);let r=e.description.trim();return r&&(t.description=r),t}var Ft=0;function It(){return Ft+=1,`prop-${Ft}`}function Lt(e){let{frontmatter:t,body:n}=U(e);if(t===``)return{type:``,properties:[],markdown:e};let r=[];for(let e of J(t).split(`
|
|
4
|
-
`)){if(e.trim()===``)continue;let t=e.indexOf(`:`);if((/^\s/.test(e)||t===-1)&&r.length>0){let t=r[r.length-1];t&&(t.value+=`\n${e}`);continue}t!==-1&&r.push({key:e.slice(0,t).trim(),value:e.slice(t+1).replace(/^ /,``)})}let i=``,a=[];for(let e of r){if(e.key===`type`&&i===``){i=e.value.trim();continue}a.push({id:It(),key:e.key,value:e.value})}return{type:i,properties:a,markdown:n}}function Rt(e){let t=[],n=e.type.trim();n&&t.push(`type: ${n}`);for(let n of e.properties){let e=n.key.trim();e===``||e===`type`||t.push(n.value===``?`${e}:`:`${e}: ${n.value}`)}if(t.length===0)return e.markdown.replace(/^\n+/,``);let r=e.markdown.startsWith(`
|
|
5
|
-
`)?e.markdown:`\n${e.markdown}`;return`---\n${t.join(`
|
|
6
|
-
`)}\n---\n${r}`}function zt(e){let t=(0,Z.c)(54),{mode:n,folderPath:r,scope:i,initial:a,existingNames:o,onCommitted:s}=e,c=i===void 0?`local`:i,[l,u]=(0,Q.useState)(a.title),[d,f]=(0,Q.useState)(a.name),[p,m]=(0,Q.useState)(a.description),h;t[0]===a.body?h=t[1]:(h=()=>Lt(a.body),t[0]=a.body,t[1]=h);let g=(0,Q.useState)(h)[0],[_,v]=(0,Q.useState)(g.type),[y,b]=(0,Q.useState)(g.properties),[x,S]=(0,Q.useState)(g.markdown),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(k=function(e,t){b(n=>n.map(n=>n.id===e?{...n,...t}:n))},t[2]=k):k=t[2];let A=k,j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){b(Bt)},t[3]=j):j=t[3];let M=j,N;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(N=function(e){b(t=>t.filter(t=>t.id!==e))},t[4]=N):N=t[4];let P=N,F;t[5]!==n||t[6]!==T?(F=function(e){u(e),n===`create`&&!T&&f(Nt(e))},t[5]=n,t[6]=T,t[7]=F):F=t[7];let I=F,L;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(e){f(e),E(!0)},t[8]=L):L=t[8];let R=L,z=n===`edit`&&c===`local`,B=n===`create`||z,ee;t[9]===l?ee=t[10]:(ee=l.trim(),t[9]=l,t[10]=ee);let V=ee,H,U,W,G;t[11]!==o||t[12]!==n||t[13]!==d||t[14]!==B||t[15]!==V?(G=d.trim(),W=V===``,H=B&&(G===``||!Mt.test(G)),U=n===`create`&&!H&&(o?.has(G)??!1),t[11]=o,t[12]=n,t[13]=d,t[14]=B,t[15]=V,t[16]=H,t[17]=U,t[18]=W,t[19]=G):(H=t[16],U=t[17],W=t[18],G=t[19]);let K=U,q=!C&&!W&&!H,J;t[20]!==x||t[21]!==z||t[22]!==q||t[23]!==p||t[24]!==r||t[25]!==a.name||t[26]!==n||t[27]!==s||t[28]!==y||t[29]!==l||t[30]!==G||t[31]!==V||t[32]!==_?(J=async function(){if(!q){O(!0);return}w(!0);let e=Pt({title:l,description:p}),t=Rt({type:_,properties:y,markdown:x}),i=z&&G!==a.name,o=i?await pe({fromFolder:r,fromName:a.name,toFolder:r,toName:G,frontmatter:e,body:t}):await fe({folder:r,name:n===`create`?G:a.name,frontmatter:e,body:t});if(w(!1),!o.ok){let{error:e}=o;De.error(n===`create`?X._({id:`jdGUeI`,values:{error:e}}):X._({id:`rQAQus`,values:{error:e}}));return}i?De.success(X._({id:`YKLP_-`})):`warnings`in o&&o.warnings.length>0?De.warning(o.warnings.join(` `)):n===`create`?De.success(X._({id:`06SZfb`,values:{trimmedTitle:V}})):De.success(X._({id:`GamjcN`})),s(n===`create`||i?G:a.name)},t[20]=x,t[21]=z,t[22]=q,t[23]=p,t[24]=r,t[25]=a.name,t[26]=n,t[27]=s,t[28]=y,t[29]=l,t[30]=G,t[31]=V,t[32]=_,t[33]=J):J=t[33];let te=J,ne;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>O(!0),t[34]=ne):ne=t[34];let re;return t[35]!==x||t[36]!==z||t[37]!==q||t[38]!==p||t[39]!==a.name||t[40]!==n||t[41]!==y||t[42]!==C||t[43]!==I||t[44]!==d||t[45]!==H||t[46]!==K||t[47]!==te||t[48]!==l||t[49]!==W||t[50]!==D||t[51]!==G||t[52]!==_?(re={mode:n,title:l,slug:d,description:p,type:_,properties:y,body:x,setTitle:I,setSlug:R,setDescription:m,setType:v,setProperty:A,addProperty:M,removeProperty:P,setBody:S,markTitleTouched:ne,titleTouched:D,isSaving:C,canSubmit:q,titleInvalid:W,slugInvalid:H,slugShadows:K,trimmedSlug:G,fixedName:a.name,canRename:z,submit:te},t[35]=x,t[36]=z,t[37]=q,t[38]=p,t[39]=a.name,t[40]=n,t[41]=y,t[42]=C,t[43]=I,t[44]=d,t[45]=H,t[46]=K,t[47]=te,t[48]=l,t[49]=W,t[50]=D,t[51]=G,t[52]=_,t[53]=re):re=t[53],re}function Bt(e){return[...e,{id:It(),key:``,value:``}]}function Vt(e){let t=(0,Z.c)(72),{form:n,bodyPlaceholder:r}=e,{_:i}=c(),a=(0,Q.useId)(),o=(0,Q.useId)(),l=(0,Q.useId)(),u=n.titleTouched&&n.titleInvalid,{fixedName:d}=n,f,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(s,{id:`MHrjPM`}),p=(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`}),t[0]=f,t[1]=p):(f=t[0],p=t[1]);let m;t[2]===a?m=t[3]:(m=(0,$.jsxs)(be,{htmlFor:a,children:[f,p]}),t[2]=a,t[3]=m);let h=n.title,g;t[4]===n?g=t[5]:(g=e=>n.setTitle(e.target.value),t[4]=n,t[5]=g);let _=n.markTitleTouched,v;t[6]===i?v=t[7]:(v=i({id:`KWL_Ih`}),t[6]=i,t[7]=v);let y;t[8]!==n.isSaving||t[9]!==n.markTitleTouched||t[10]!==n.title||t[11]!==a||t[12]!==u||t[13]!==g||t[14]!==v?(y=(0,$.jsx)(Oe,{id:a,"data-testid":`template-name-input`,value:h,onChange:g,onBlur:_,placeholder:v,disabled:n.isSaving,"aria-invalid":u}),t[8]=n.isSaving,t[9]=n.markTitleTouched,t[10]=n.title,t[11]=a,t[12]=u,t[13]=g,t[14]=v,t[15]=y):y=t[15];let b;t[16]===u?b=t[17]:(b=u?(0,$.jsx)(ve,{children:(0,$.jsx)(s,{id:`V_wltx`})}):null,t[16]=u,t[17]=b);let x;t[18]!==m||t[19]!==y||t[20]!==b?(x=(0,$.jsxs)(Ce,{children:[m,y,b]}),t[18]=m,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]!==d||t[23]!==n?(S=n.mode===`create`?(0,$.jsx)(Ut,{form:n}):n.canRename?(0,$.jsx)(Wt,{form:n}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(s,{id:`NjrIak`,values:{fixedName:d},components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(s,{id:`jSO1X5`})})]}),t[22]=d,t[23]=n,t[24]=S):S=t[24];let C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(s,{id:`Nu4oKW`}),t[25]=C):C=t[25];let w;t[26]===o?w=t[27]:(w=(0,$.jsx)(be,{htmlFor:o,children:C}),t[26]=o,t[27]=w);let T=n.description,E;t[28]===n?E=t[29]:(E=e=>n.setDescription(e.target.value),t[28]=n,t[29]=E);let D;t[30]===i?D=t[31]:(D=i({id:`3FMvls`}),t[30]=i,t[31]=D);let O;t[32]!==o||t[33]!==n.description||t[34]!==n.isSaving||t[35]!==E||t[36]!==D?(O=(0,$.jsx)(ze,{id:o,value:T,onChange:E,placeholder:D,disabled:n.isSaving,rows:2}),t[32]=o,t[33]=n.description,t[34]=n.isSaving,t[35]=E,t[36]=D,t[37]=O):O=t[37];let k;t[38]!==w||t[39]!==O?(k=(0,$.jsxs)(Ce,{children:[w,O]}),t[38]=w,t[39]=O,t[40]=k):k=t[40];let A;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(s,{id:`-zy2Nq`}),t[41]=A):A=t[41];let j;t[42]===l?j=t[43]:(j=(0,$.jsx)(be,{htmlFor:l,children:A}),t[42]=l,t[43]=j);let M=n.type,N;t[44]===n?N=t[45]:(N=e=>n.setType(e.target.value),t[44]=n,t[45]=N);let P;t[46]===i?P=t[47]:(P=i({id:`o9CrsQ`}),t[46]=i,t[47]=P);let F;t[48]!==n.isSaving||t[49]!==n.type||t[50]!==N||t[51]!==P||t[52]!==l?(F=(0,$.jsx)(Oe,{id:l,value:M,onChange:N,placeholder:P,disabled:n.isSaving,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`font-mono`}),t[48]=n.isSaving,t[49]=n.type,t[50]=N,t[51]=P,t[52]=l,t[53]=F):F=t[53];let I;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(xe,{children:(0,$.jsx)(s,{id:`ipn17C`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`}),1:(0,$.jsx)(`code`,{className:`font-mono`})}})}),t[54]=I):I=t[54];let L;t[55]!==j||t[56]!==F?(L=(0,$.jsxs)(Ce,{children:[j,F,I]}),t[55]=j,t[56]=F,t[57]=L):L=t[57];let R;t[58]===n?R=t[59]:(R=(0,$.jsx)(Ht,{form:n}),t[58]=n,t[59]=R);let z;t[60]!==r||t[61]!==n.body||t[62]!==n.isSaving||t[63]!==n.setBody?(z=(0,$.jsx)(jt,{value:n.body,onChange:n.setBody,disabled:n.isSaving,placeholder:r}),t[60]=r,t[61]=n.body,t[62]=n.isSaving,t[63]=n.setBody,t[64]=z):z=t[64];let B;return t[65]!==x||t[66]!==S||t[67]!==k||t[68]!==L||t[69]!==R||t[70]!==z?(B=(0,$.jsxs)(_e,{children:[x,S,k,L,R,z]}),t[65]=x,t[66]=S,t[67]=k,t[68]=L,t[69]=R,t[70]=z,t[71]=B):B=t[71],B}function Ht(e){let t=(0,Z.c)(12),{form:n}=e,{_:r}=c(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(be,{children:(0,$.jsx)(s,{id:`-WFFG2`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(xe,{children:(0,$.jsx)(s,{id:`zrP8HX`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`}),1:(0,$.jsx)(`code`,{className:`font-mono`})}})}),t[1]=a):a=t[1];let o;t[2]!==r||t[3]!==n?(o=n.properties.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.properties.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Oe,{"aria-label":r({id:`56xUL1`}),value:e.key,onChange:t=>n.setProperty(e.id,{key:t.target.value}),placeholder:r({id:`Aq-O0x`}),disabled:n.isSaving,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`font-mono w-1/3`}),(0,$.jsx)(Oe,{"aria-label":r({id:`iKZkk1`}),value:e.value,onChange:t=>n.setProperty(e.id,{value:t.target.value}),placeholder:r({id:`jEZ6Lf`}),disabled:n.isSaving,spellCheck:!1,className:`font-mono flex-1`}),(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":r({id:`rNifQd`}),onClick:()=>n.removeProperty(e.id),disabled:n.isSaving,children:(0,$.jsx)(Ee,{"aria-hidden":`true`})})]},e.id))}):null,t[2]=r,t[3]=n,t[4]=o):o=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(s,{id:`F-NRCj`}),t[5]=l):l=t[5];let u;t[6]!==n.addProperty||t[7]!==n.isSaving?(u=(0,$.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,onClick:n.addProperty,disabled:n.isSaving,children:l}),t[6]=n.addProperty,t[7]=n.isSaving,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,$.jsxs)(Ce,{children:[i,a,o,u]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}function Ut(e){let t=(0,Z.c)(34),{form:n}=e,{_:r}=c(),i=(0,Q.useId)(),[a,o]=(0,Q.useState)(!1),l=a||n.titleTouched&&(n.slugInvalid||n.slugShadows),{slug:u,trimmedSlug:d}=n;if(!l){if(d===``)return null;let e;t[0]===u?e=t[1]:(e={slug:u},t[0]=u,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=(0,$.jsx)(s,{id:`Pgu10b`,values:e,components:r}),t[3]=e,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>o(!0),t[5]=a):a=t[5];let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(s,{id:`ePK91l`}),t[6]=c):c=t[6];let l;t[7]===n.isSaving?l=t[8]:(l=(0,$.jsx)(v,{type:`button`,variant:`link`,className:`h-auto p-0 align-baseline text-xs font-mono uppercase`,onClick:a,disabled:n.isSaving,children:c}),t[7]=n.isSaving,t[8]=l);let f;return t[9]!==i||t[10]!==l?(f=(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i,` `,l]}),t[9]=i,t[10]=l,t[11]=f):f=t[11],f}let f;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(s,{id:`GN6L5F`}),t[12]=f):f=t[12];let p;t[13]===i?p=t[14]:(p=(0,$.jsx)(be,{htmlFor:i,children:f}),t[13]=i,t[14]=p);let m;t[15]===n?m=t[16]:(m=e=>n.setSlug(e.target.value),t[15]=n,t[16]=m);let h;t[17]===r?h=t[18]:(h=r({id:`tjXez2`}),t[17]=r,t[18]=h);let g;t[19]!==n.isSaving||t[20]!==n.slugInvalid||t[21]!==u||t[22]!==i||t[23]!==m||t[24]!==h?(g=(0,$.jsx)(Oe,{id:i,value:u,onChange:m,placeholder:h,disabled:n.isSaving,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-invalid":n.slugInvalid,className:`font-mono`}),t[19]=n.isSaving,t[20]=n.slugInvalid,t[21]=u,t[22]=i,t[23]=m,t[24]=h,t[25]=g):g=t[25];let _;t[26]!==n.slugInvalid||t[27]!==n.slugShadows||t[28]!==d?(_=n.slugInvalid?(0,$.jsx)(ve,{children:(0,$.jsx)(s,{id:`l_FAT6`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`}),1:(0,$.jsx)(`code`,{className:`font-mono`})}})}):n.slugShadows?(0,$.jsx)(xe,{className:`text-yellow-600 dark:text-yellow-500`,children:(0,$.jsx)(s,{id:`jwnpdM`,values:{trimmedSlug:d},components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})}):(0,$.jsx)(xe,{children:(0,$.jsx)(s,{id:`TsZmgr`})}),t[26]=n.slugInvalid,t[27]=n.slugShadows,t[28]=d,t[29]=_):_=t[29];let y;return t[30]!==p||t[31]!==g||t[32]!==_?(y=(0,$.jsxs)(Ce,{children:[p,g,_]}),t[30]=p,t[31]=g,t[32]=_,t[33]=y):y=t[33],y}function Wt(e){let t=(0,Z.c)(20),{form:n}=e,{_:r}=c(),i=(0,Q.useId)(),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(s,{id:`GN6L5F`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=(0,$.jsx)(be,{htmlFor:i,children:a}),t[1]=i,t[2]=o);let l=n.slug,u;t[3]===n?u=t[4]:(u=e=>n.setSlug(e.target.value),t[3]=n,t[4]=u);let d;t[5]===r?d=t[6]:(d=r({id:`tjXez2`}),t[5]=r,t[6]=d);let f;t[7]!==n.isSaving||t[8]!==n.slug||t[9]!==n.slugInvalid||t[10]!==i||t[11]!==u||t[12]!==d?(f=(0,$.jsx)(Oe,{id:i,value:l,onChange:u,placeholder:d,disabled:n.isSaving,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-invalid":n.slugInvalid,className:`font-mono`}),t[7]=n.isSaving,t[8]=n.slug,t[9]=n.slugInvalid,t[10]=i,t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.slugInvalid?p=t[15]:(p=n.slugInvalid?(0,$.jsx)(ve,{children:(0,$.jsx)(s,{id:`l_FAT6`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`}),1:(0,$.jsx)(`code`,{className:`font-mono`})}})}):(0,$.jsx)(xe,{children:(0,$.jsx)(s,{id:`FvMSms`})}),t[14]=n.slugInvalid,t[15]=p);let m;return t[16]!==o||t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(Ce,{children:[o,f,p]}),t[16]=o,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}var Gt={name:``,title:``,description:``,body:``},Kt=`## Overview
|
|
7
|
-
|
|
8
|
-
(Replace with the starting content for new documents.)
|
|
9
|
-
`;function qt(e){let t=(0,Z.c)(12),{folderPath:n,existingNames:r,open:i,onOpenChange:a,onCreated:o}=e,s;t[0]!==r||t[1]!==n||t[2]!==o||t[3]!==a||t[4]!==i?(s=i?(0,$.jsx)(Jt,{folderPath:n,existingNames:r,onOpenChange:a,onCreated:o}):null,t[0]=r,t[1]=n,t[2]=o,t[3]=a,t[4]=i,t[5]=s):s=t[5];let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(w,{className:`sm:max-w-3xl max-h-[85vh] flex flex-col`,children:s}),t[6]=s,t[7]=c);let l;return t[8]!==a||t[9]!==i||t[10]!==c?(l=(0,$.jsx)(O,{open:i,onOpenChange:a,children:c}),t[8]=a,t[9]=i,t[10]=c,t[11]=l):l=t[11],l}function Jt(e){let t=(0,Z.c)(31),{folderPath:n,existingNames:r,onOpenChange:i,onCreated:a}=e,o;t[0]!==a||t[1]!==i?(o=e=>{a(e),i(!1)},t[0]=a,t[1]=i,t[2]=o):o=t[2];let c;t[3]!==r||t[4]!==n||t[5]!==o?(c={mode:`create`,folderPath:n,initial:Gt,existingNames:r,onCommitted:o},t[3]=r,t[4]=n,t[5]=o,t[6]=c):c=t[6];let l=zt(c),u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(C,{children:(0,$.jsx)(s,{id:`G1Gw0v`})}),t[7]=u):u=t[7];let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(D,{children:[u,(0,$.jsx)(S,{children:(0,$.jsx)(s,{id:`NUr4kz`})})]}),t[8]=d):d=t[8];let f;t[9]===l?f=t[10]:(f=(0,$.jsx)(T,{children:(0,$.jsx)(Vt,{form:l,bodyPlaceholder:Kt})}),t[9]=l,t[10]=f);let p;t[11]===i?p=t[12]:(p=()=>i(!1),t[11]=i,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(s,{id:`dEgA5A`}),t[13]=m):m=t[13];let h;t[14]!==l.isSaving||t[15]!==p?(h=(0,$.jsx)(v,{variant:`outline`,className:`font-mono uppercase`,onMouseDown:Yt,onClick:p,disabled:l.isSaving,children:m}),t[14]=l.isSaving,t[15]=p,t[16]=h):h=t[16];let g;t[17]===l?g=t[18]:(g=()=>void l.submit(),t[17]=l,t[18]=g);let _;t[19]===l.isSaving?_=t[20]:(_=l.isSaving?(0,$.jsx)(s,{id:`E9bKSA`}):(0,$.jsx)(s,{id:`A5hiCy`}),t[19]=l.isSaving,t[20]=_);let y;t[21]!==l.isSaving||t[22]!==_||t[23]!==g?(y=(0,$.jsx)(v,{onClick:g,disabled:l.isSaving,children:_}),t[21]=l.isSaving,t[22]=_,t[23]=g,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==h?(b=(0,$.jsxs)(E,{children:[h,y]}),t[25]=y,t[26]=h,t[27]=b):b=t[27];let x;return t[28]!==b||t[29]!==f?(x=(0,$.jsxs)($.Fragment,{children:[d,f,b]}),t[28]=b,t[29]=f,t[30]=x):x=t[30],x}function Yt(e){return e.preventDefault()}function Xt(e){let t=(0,Z.c)(16),{template:n,onOpenChange:r,onDeleted:i}=e,{_:a}=c(),[o,s]=(0,Q.useState)(!1),l;t[0]!==a||t[1]!==i||t[2]!==r?(l=async function(e){s(!0);let t=await me(e.source_folder,e.name);if(s(!1),!t.ok){let{error:e}=t;De.error(a({id:`36WXSC`,values:{error:e}}));return}let n=e.title??e.name;De.success(a({id:`ErRi6L`,values:{label:n}})),i(),r(!1)},t[0]=a,t[1]=i,t[2]=r,t[3]=l):l=t[3];let u=l,d=n!==null,f;t[4]!==o||t[5]!==r?(f=e=>{!e&&!o&&r(!1)},t[4]=o,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==a||t[8]!==o||t[9]!==u||t[10]!==n?(p=n?(()=>{let{name:e,path:t,scope:r}=n,i=r===`inherited`?`\n\n${a({id:`8uAWix`})}`:``;return(0,$.jsx)(g,{itemName:a({id:`XfzqjK`,values:{name:e}}),isSubmitting:o,onDelete:()=>u(n),customDescription:`${a({id:`5LXwX8`,values:{path:t}})}${i}`})})():null,t[7]=a,t[8]=o,t[9]=u,t[10]=n,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,$.jsx)(O,{open:d,onOpenChange:f,children:p}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function Zt(e){let t=(0,Z.c)(45),{template:n,onEdit:r,onDelete:i,onCreate:o,badge:l}=e,{_:u}=c(),d=n.title??n.name,f=!!(n.title&&n.title!==n.name),p;t[0]===d?p=t[1]:(p=(0,$.jsx)(`span`,{className:`truncate font-medium`,children:d}),t[0]=d,t[1]=p);let m;t[2]!==f||t[3]!==n.name?(m=f?(0,$.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:n.name}):null,t[2]=f,t[3]=n.name,t[4]=m):m=t[4];let g;t[5]===l?g=t[6]:(g=l?(0,$.jsx)(`span`,{className:`ml-auto shrink-0`,children:l}):null,t[5]=l,t[6]=g);let y;t[7]!==p||t[8]!==m||t[9]!==g?(y=(0,$.jsxs)(`span`,{className:`flex w-full items-center gap-2`,children:[p,m,g]}),t[7]=p,t[8]=m,t[9]=g,t[10]=y):y=t[10];let b;t[11]===n.description?b=t[12]:(b=n.description?(0,$.jsx)(`span`,{className:`w-full truncate text-sm text-muted-foreground`,children:n.description}):null,t[11]=n.description,t[12]=b);let x;t[13]!==r||t[14]!==y||t[15]!==b?(x=(0,$.jsxs)(v,{type:`button`,variant:`ghost`,onClick:r,className:`h-auto min-w-0 flex-1 flex-col items-start gap-0.5 px-1.5 py-1 text-left font-normal hover:bg-transparent`,children:[y,b]}),t[13]=r,t[14]=y,t[15]=b,t[16]=x):x=t[16];let S;t[17]!==u||t[18]!==d||t[19]!==o?(S=o?(0,$.jsxs)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`shrink-0 font-mono uppercase opacity-0 group-hover:opacity-100 focus-visible:opacity-100`,onClick:o,"aria-label":u({id:`mZ1r4i`,values:{label:d}}),children:[(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(s,{id:`hYgDIe`})]}):null,t[17]=u,t[18]=d,t[19]=o,t[20]=S):S=t[20];let C;t[21]!==u||t[22]!==d?(C=u({id:`Bx4EXG`,values:{label:d}}),t[21]=u,t[22]=d,t[23]=C):C=t[23];let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(v,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,"aria-label":C,children:w})}),t[25]=C,t[26]=T);let E,D;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(a,{"aria-hidden":!0}),D=(0,$.jsx)(s,{id:`ePK91l`}),t[27]=E,t[28]=D):(E=t[27],D=t[28]);let O;t[29]===r?O=t[30]:(O=(0,$.jsxs)(k,{onSelect:r,children:[E,D]}),t[29]=r,t[30]=O);let N,P;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(we,{"aria-hidden":!0}),P=(0,$.jsx)(s,{id:`cnGeoo`}),t[31]=N,t[32]=P):(N=t[31],P=t[32]);let F;t[33]===i?F=t[34]:(F=(0,$.jsxs)(k,{variant:`destructive`,onSelect:i,children:[N,P]}),t[33]=i,t[34]=F);let I;t[35]!==O||t[36]!==F?(I=(0,$.jsxs)(j,{align:`end`,className:`min-w-52`,children:[O,F]}),t[35]=O,t[36]=F,t[37]=I):I=t[37];let L;t[38]!==T||t[39]!==I?(L=(0,$.jsxs)(M,{modal:!1,children:[T,I]}),t[38]=T,t[39]=I,t[40]=L):L=t[40];let R;return t[41]!==L||t[42]!==x||t[43]!==S?(R=(0,$.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-muted/50`,children:[x,S,L]}),t[41]=L,t[42]=x,t[43]=S,t[44]=R):R=t[44],R}function Qt(){let e=(0,Z.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(!1),c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=!1;return r({status:`loading`}),fetch(`/api/skill-targets`).then(en).then(t=>{if(e)return;let n=z.safeParse(t);if(!n.success){console.error(`[ok-skills] /api/skill-targets response failed schema validation:`,n.error.issues),r({status:`error`,message:`Server returned an incomplete skill-targets response.`});return}r({status:`ready`,data:n.data})}).catch(t=>{e||r({status:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},e[1]=c):c=e[1];let l;e[2]===i?l=e[3]:(l=[i],e[2]=i,e[3]=l),(0,Q.useEffect)(c,l);let u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=async e=>{s(!0);let t=await Ie(e);if(!t.ok)throw s(!1),Error(t.error);Pe(),a($t),s(!1)},e[4]=u):u=e[4];let d=u,f;return e[5]!==o||e[6]!==n?(f={state:n,saving:o,folderAction:d},e[5]=o,e[6]=n,e[7]=f):f=e[7],f}function $t(e){return e+1}async function en(e){if(!e.ok){let t=await e.json().catch(tn);throw Error(Me(t)??`HTTP ${e.status}`)}return e.json()}function tn(){return null}var nn=`claude-cowork`,rn=`ok:skill:cowork:installed:v`,an=250,on=`/api/skill/install-state`,sn=null,cn=new Set,ln=null,un=!1,dn=()=>{Cn(jn())},fn=e=>{e.key?.startsWith(rn)&&Cn(jn())};function pn(){un||typeof window>`u`||(window.addEventListener(`focus`,dn),window.addEventListener(`storage`,fn),un=!0)}function mn(){un&&(typeof window>`u`||(window.removeEventListener(`focus`,dn),window.removeEventListener(`storage`,fn),un=!1))}var hn=!1,gn=!1,_n=!1,vn=!1,yn=!1,bn=!1,xn=!1;async function Sn(e){let t=!0;if(e.detectClaudeDesktop)try{t=await e.detectClaudeDesktop()}catch(e){t=!0,hn||(hn=!0,console.warn(`[claude-desktop-integration] detectClaudeDesktop IPC rejected — falling back to desktopPresent=true`,e))}let n=await e.fetchSnapshot();if(n){let e=n.targets?.[nn]??null;return e?.version?{desktopPresent:t,skillInstalled:!0,skillVersion:e.version}:{desktopPresent:t,skillInstalled:!1,skillVersion:null}}let r=e.readLocalStorageGuard();return{desktopPresent:t,skillInstalled:r.skillInstalled,skillVersion:r.skillVersion}}async function Cn(e){return ln||(ln=(async()=>{try{sn=await Sn(e);for(let e of cn)try{e()}catch(e){console.error(`[claude-desktop-integration] subscriber threw`,e)}}catch(e){console.error(`[claude-desktop-integration] probe rejected unexpectedly`,e)}finally{ln=null}})(),ln)}function wn(e){return cn.size===0&&pn(),cn.add(e),()=>{cn.delete(e),cn.size===0&&mn()}}function Tn(){return sn}function En(){if(typeof window>`u`)return;let e=window.okDesktop?.skill,t=e?.detectClaudeDesktop;if(t)return()=>t.call(e)}function Dn(e){let t=e?.timeoutMs??an,n=e?.fetchImpl??(typeof fetch<`u`?fetch:void 0);return async()=>{if(!n)return null;let e;try{let r=new AbortController,i=setTimeout(()=>r.abort(),t);try{e=await n(on,{method:`GET`,cache:`no-store`,signal:r.signal})}finally{clearTimeout(i)}}catch(e){let n=e instanceof DOMException&&e.name===`AbortError`;return n&&!_n?(_n=!0,console.warn(`[claude-desktop-integration] fetch ${on} timed out (>${t}ms) — falling back to localStorage guard`)):!n&&!gn&&(gn=!0,console.warn(`[claude-desktop-integration] fetch ${on} failed — falling back to localStorage guard`,e)),null}if(!e.ok)return vn||(vn=!0,console.warn(`[claude-desktop-integration] ${on} returned ${e.status} ${e.statusText} — falling back to localStorage guard`)),null;let r;try{r=await e.json()}catch(e){return yn||(yn=!0,console.warn(`[claude-desktop-integration] ${on} returned unparseable JSON — falling back to localStorage guard`,e)),null}return On(r)}}function On(e){if(typeof e!=`object`||!e)return kn(`not an object`);let t=e;if(typeof t.currentVersion!=`string`||t.currentVersion===``)return kn(`currentVersion not a non-empty string`);if(t.targets!==void 0){if(t.targets===null||typeof t.targets!=`object`)return kn(`targets not object`);for(let[,e]of Object.entries(t.targets)){if(e==null)continue;if(typeof e!=`object`)return kn(`target entry not object`);let t=e;if(typeof t.version!=`string`||t.version===``)return kn(`target.version not a non-empty string`)}}return t}function kn(e){return bn||(bn=!0,console.warn(`[claude-desktop-integration] ${on} response failed shape validation (${e}) — falling back to localStorage guard`)),null}function An(){if(typeof localStorage>`u`)return{skillInstalled:!1,skillVersion:null};try{for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(rn))return{skillInstalled:!0,skillVersion:t.slice(27)}}}catch(e){xn||(xn=!0,console.warn(`[claude-desktop-integration] localStorage scan threw — falling back to skillInstalled=false`,e))}return{skillInstalled:!1,skillVersion:null}}function jn(){return{detectClaudeDesktop:En(),fetchSnapshot:Dn(),readLocalStorageGuard:An}}function Mn(){let e=(0,Z.c)(5),t=(0,Q.useSyncExternalStore)(wn,Tn,Tn),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,Q.useEffect)(Pn,n);let r=t?.desktopPresent??!0,i=t?.skillInstalled??!1,a=t?.skillVersion??null,o;return e[1]!==r||e[2]!==i||e[3]!==a?(o={desktopPresent:r,skillInstalled:i,skillVersion:a,refresh:Nn},e[1]=r,e[2]=i,e[3]=a,e[4]=o):o=e[4],o}function Nn(){Cn(jn())}function Pn(){sn||Cn(jn())}var Fn=[{path:[`appearance`,`theme`],label:{id:`FEr96N`},description:{id:`JZ8cO6`},control:`enum-toggle`},{path:[`editor`,`wordWrap`],label:{id:`iKSP5j`},description:{id:`mmpzAq`}},{path:[`editor`,`previewTabs`],label:{id:`drzzZw`},description:{id:`AIC67-`}},{path:[`appearance`,`preview`,`autoOpen`],label:{id:`2XQ8Ww`},description:{id:`bultyE`}},{path:[`telemetry`,`skillInstallReports`,`enabled`],label:{id:`2jUGEP`},description:{id:`Ns0z5o`}}],In=[{path:[`appearance`,`colorTheme`],label:{id:`rFmBG3`},description:{id:`Pck6eI`},control:`theme-tiles`}],Ln=[{sectionId:`preferences`,fields:Fn},{sectionId:`plugin:theme`,fields:In}];async function Rn(){try{let e=await fetch(`/api/sync/conflicts`);return e.ok?{conflicts:(await e.json()).conflicts??[]}:(console.warn(JSON.stringify({event:`conflicts-fetch-failed`,status:e.status})),{conflicts:[],error:`server`})}catch(e){return console.warn(JSON.stringify({event:`conflicts-fetch-failed`,status:null,detail:e instanceof Error?e.message:String(e)})),{conflicts:[],error:`network`}}}function zn(){let e=(0,Z.c)(10),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(0),l;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=function(){let e=c.current+=1;Rn().then(t=>{let{conflicts:n,error:i}=t;e===c.current&&(r(n),s(i??null),a(!1))})},e[1]=l):l=e[1];let u=l,d,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{u()},f=[],e[2]=d,e[3]=f):(d=e[2],f=e[3]),(0,Q.useEffect)(d,f);let p,m;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>Ne(e=>{e.includes(`sync-status`)&&u()}),m=[],e[4]=p,e[5]=m):(p=e[4],m=e[5]),(0,Q.useEffect)(p,m);let h;return e[6]!==n||e[7]!==o||e[8]!==i?(h={conflicts:n,loading:i,error:o},e[6]=n,e[7]=o,e[8]=i,e[9]=h):h=e[9],h}function Bn(e){if(!e)return``;let t=e.replace(/[/\\]+$/g,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?t:t.slice(n+1)}var Vn=`/api/share/construct-url`;function Hn(e){return{kind:`doc`,docName:e}}function Un(e){return{kind:`folder`,folderRelativePath:e}}var Wn=`Could not construct share URL.`,Gn=`Link ready but could not copy to clipboard.`;async function Kn(e,t=fetch){let n=await t(Vn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`construct-url transport ${n.status}`);let r=await n.json(),i=K.safeParse(r);if(!i.success)throw Error(`construct-url response shape mismatch`);return i.data}function qn(e,t){switch(e){case`detached-head`:return`Switch to a branch to share.`;case`branch-not-on-origin`:return t?`Push ${t} to GitHub before sharing.`:`Push this branch to GitHub before sharing.`;case`non-github-remote`:return`Sharing supports GitHub remotes only.`;case`invalid-path`:return`Can't share this path.`;case`no-remote`:return`This project has no GitHub remote.`}}async function Jn(e,t){if(!e.hasRemote)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let n=e.kind===`folder`?{kind:`folder`,folderPath:e.folderRelativePath}:{kind:`doc`,docPath:Ae(e.docName)},r;try{r=await Kn(n,t.fetchFn)}catch{return t.toastError(Wn),{kind:`transport-error`}}if(r.ok){try{await t.clipboardWrite(r.shareUrl)}catch{return t.toastError(Gn),t.logEvent(`[share] action=link-construct result=clipboard-failed`),{kind:`clipboard-failed`,shareUrl:r.shareUrl,freshness:r.freshness}}return t.toastSuccess(e.kind===`folder`?`Folder share link copied.`:`Link copied.`),t.logEvent(`[share] action=link-construct`),{kind:`copied`,shareUrl:r.shareUrl,branch:r.branch,freshness:r.freshness}}if(r.error===`no-remote`)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let i=r.branch;return t.toastError(qn(r.error,i)),{kind:`business-error`,error:r.error,branch:i}}var Yn=`/api/share/publish/owners`,Xn=`/api/share/publish/name-check`,Zn=`/api/share/publish`,Qn=/[A-Za-z0-9._-]/g;function $n(e){return(e.match(Qn)?.join(``)??``).replace(/[-.]{2,}/g,e=>e[0]??`-`).replace(/^[-.]+/,``).replace(/[-.]+$/,``)}function er(e){return e.find(e=>e.kind===`org`)?.login??e[0]?.login??``}function tr(e){return`https://github.com/orgs/${encodeURIComponent(e)}/policies/applications`}function nr(e,t,n){switch(e){case`name-conflict`:return{banner:`${t}/${n} already exists. Pick a different name.`,next:{kind:`edit-name`}};case`saml-sso`:return{banner:`GitHub denied the request. You may need to authorize OpenKnowledge for ${t} in your browser.`,next:{kind:`authorize-org`,authorizeUrl:tr(t)}};case`push-failed`:return{banner:`Created ${t}/${n}, push failed.`,next:{kind:`retry-push`}};case`auth-required`:return{banner:`GitHub connection expired. Connect again to continue.`,next:{kind:`reauth`}};case`init-failed`:return{banner:`Couldn't prepare this project for publish.`,next:{kind:`edit-form`}};case`network`:return{banner:`Couldn't reach GitHub. Try again?`,next:{kind:`edit-form`}};case`no-project`:return{banner:`Open a project first.`,next:{kind:`edit-form`}}}}async function rr(e=fetch){let t=await e(Yn,{method:`GET`});if(!t.ok)throw Error(`owners transport ${t.status}`);let n=await t.json(),r=B.safeParse(n);if(!r.success)throw Error(`owners response shape mismatch`);return r.data}async function ir(e,t,n=fetch){let r=await n(`${Xn}?owner=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{method:`GET`});if(!r.ok)throw Error(`name-check transport ${r.status}`);let i=await r.json(),a=V.safeParse(i);if(!a.success)throw Error(`name-check response shape mismatch`);return a.data}async function ar(e,t=fetch){let n=await t(Zn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`publish transport ${n.status}`);let r=await n.json(),i=G.safeParse(r);if(!i.success)throw Error(`publish response shape mismatch`);return i.data}function or(e,t,n){return e.ok?e.available?{kind:`available`}:{kind:`taken`,owner:t,name:n}:e.error===`auth-required`?{kind:`error`,banner:`GitHub connection expired. Connect again to continue.`}:{kind:`error`,banner:`Couldn't reach GitHub. Try again?`}}function sr(e){return e.submitting||e.owner===null||e.sanitizedName.length===0?!1:e.nameCheck.kind===`available`}var cr=500;function lr(e){let t=(0,Z.c)(69),{open:n,onOpenChange:r}=e,{_:a}=c(),o=m(),{activeDocName:l}=i(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(`private`),[j,M]=(0,Q.useState)(``),I;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(I={kind:`idle`},t[0]=I):I=t[0];let[L,R]=(0,Q.useState)(I),[z,B]=(0,Q.useState)(!1),[ee,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(!1),[W,G]=(0,Q.useState)(null),[K,q]=(0,Q.useState)(!1),[J,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null),ie=(0,Q.useRef)(null),ae=(0,Q.useRef)(null),oe=(0,Q.useRef)(null),se;t[1]===b?se=t[2]:(se=$n(b),t[1]=b,t[2]=se);let ce=se,le=u?.find(e=>e.login===_)??null,ue;t[3]!==a||t[4]!==_?(ue=async function(){p(!0),g(null);try{let e=await rr();if(!e.ok){e.error===`auth-required`?(U(!0),g(a({id:`6cyguR`}))):g(a({id:`UVLlMV`})),p(!1);return}d(e.owners),e.owners.length>0&&_===``&&y(er(e.owners))}catch{g(a({id:`UVLlMV`}))}p(!1)},t[3]=a,t[4]=_,t[5]=ue):ue=t[5];let Y=ue,de;t[6]!==Y||t[7]!==n||t[8]!==u||t[9]!==_||t[10]!==o?.contentDir?(de=()=>{n&&(R({kind:`idle`}),V(null),B(!1),g(null),G(null),q(!1),te(null),re(null),x($n(Bn(o?.contentDir??``))),A(`private`),M(``),u===null?Y():_===``&&u.length>0&&y(er(u)))},t[6]=Y,t[7]=n,t[8]=u,t[9]=_,t[10]=o?.contentDir,t[11]=de):de=t[11];let fe;t[12]===n?fe=t[13]:(fe=[n],t[12]=n,t[13]=fe),(0,Q.useEffect)(de,fe);let pe,me;t[14]!==a||t[15]!==n||t[16]!==ce||t[17]!==_?(pe=()=>{if(n){if(ie.current!==null&&clearTimeout(ie.current),_===``||ce===``){R({kind:`idle`});return}return R({kind:`pending`}),ie.current=setTimeout(async()=>{let e=_,t=ce;ae.current=`${e}|${t}`,R({kind:`checking`});try{let n=await ir(e,t);if(ae.current!==`${e}|${t}`)return;R(or(n,e,t))}catch{if(ae.current!==`${e}|${t}`)return;R({kind:`error`,banner:a({id:`UVLlMV`})})}},cr),()=>{ie.current!==null&&(clearTimeout(ie.current),ie.current=null)}}},me=[n,_,ce,a],t[14]=a,t[15]=n,t[16]=ce,t[17]=_,t[18]=pe,t[19]=me):(pe=t[18],me=t[19]),(0,Q.useEffect)(pe,me);let ge,_e;t[20]!==a||t[21]!==l||t[22]!==W?(ge=()=>{if(!W||!l)return;let e=!1;return(async()=>{try{let t=await Kn({kind:`doc`,docPath:Ae(l)});if(e)return;t.ok?te(t.shareUrl):re(qn(t.error,t.branch))}catch(t){let n=t;if(e)return;console.warn(`[share] action=prefetch-share-url result=failed`,n),re(a({id:`J6N5MX`}))}})(),()=>{e=!0}},_e=[W,l,a],t[20]=a,t[21]=l,t[22]=W,t[23]=ge,t[24]=_e):(ge=t[23],_e=t[24]),(0,Q.useEffect)(ge,_e);let ve;t[25]===Y?ve=t[26]:(ve=function(){U(!1),g(null),Y()},t[25]=Y,t[26]=ve);let we=ve,Te=async function(){if(sr({owner:le,sanitizedName:ce,nameCheck:L,submitting:z})){B(!0),V(null);try{let e=await ar({owner:_,name:ce,visibility:k,description:j.trim().length>0?j.trim():void 0});if(e.ok){G({ownerLogin:e.ownerLogin,repoName:e.repoName}),B(!1);return}let t=nr(e.error,_,ce);V({message:t.banner,next:t.next}),t.next.kind===`edit-name`?(oe.current?.focus(),oe.current?.select()):t.next.kind===`reauth`&&U(!0)}catch{V({message:a({id:`UVLlMV`}),next:{kind:`edit-form`}})}B(!1)}},Ee;t[27]!==a||t[28]!==K||t[29]!==r||t[30]!==J?(Ee=function(){!J||K||(q(!0),Be(J).then(()=>{De.success(a({id:`c1LZZH`})),r(!1)}).catch(e=>{if(console.warn(`[share] action=link-construct result=clipboard-failed`,e),Ve(e)&&window.self!==window.top){De.error(a({id:`Dub54T`}));return}De.error(a({id:`MQIM_Y`}))}).finally(()=>{q(!1)}))},t[27]=a,t[28]=K,t[29]=r,t[30]=J,t[31]=Ee):Ee=t[31];let X=Ee,ke;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(e){let t=window.okDesktop?.shell?.openExternal;t?t(e):window.open(e,`_blank`,`noopener`)},t[32]=ke):ke=t[32];let je=ke,Me;t[33]===r?Me=t[34]:(Me=function(){r(!1)},t[33]=r,t[34]=Me);let Ne=Me,Pe=!sr({owner:le,sanitizedName:ce,nameCheck:L,submitting:z}),Fe;t[35]!==a||t[36]!==l||t[37]!==ee||t[38]!==K||t[39]!==j||t[40]!==je||t[41]!==Ne||t[42]!==X||t[43]!==Te||t[44]!==Y||t[45]!==b||t[46]!==L||t[47]!==u||t[48]!==h||t[49]!==f||t[50]!==W||t[51]!==ce||t[52]!==_||t[53]!==J||t[54]!==ne||t[55]!==Pe||t[56]!==z||t[57]!==k?(Fe=(0,$.jsx)(w,{className:`sm:max-w-lg`,showCloseButton:!1,children:W?(0,$.jsx)(dr,{ownerLogin:W.ownerLogin,repoName:W.repoName,shareUrl:J,shareUrlError:ne,copying:K,canCopy:l!==null,onCopy:X,onClose:Ne}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[(0,$.jsx)(C,{children:(0,$.jsx)(s,{id:`qXsafh`})}),(0,$.jsx)(S,{children:(0,$.jsx)(s,{id:`Z1LF1M`})})]}),(0,$.jsxs)(T,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(N,{id:`publish-owner-label`,children:(0,$.jsx)(s,{id:`LtI9AS`})}),f&&u===null?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(he,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` `,(0,$.jsx)(s,{id:`Z3FXyt`})]}):h?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-destructive`,children:h}),(0,$.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Y(),children:(0,$.jsx)(s,{id:`6gRgw8`})})]}):(0,$.jsx)(F,{value:_,onValueChange:y,"aria-labelledby":`publish-owner-label`,"data-testid":`publish-owner-radio`,children:(u??[]).map(ur)})]}),(0,$.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(N,{htmlFor:`publish-name`,children:(0,$.jsx)(s,{id:`0xnmlQ`})}),(0,$.jsx)(Oe,{id:`publish-name`,ref:oe,"data-testid":`publish-name`,value:b,onChange:e=>x(e.target.value),onBlur:()=>{ae.current=null},placeholder:`my-knowledge-base`,autoComplete:`off`,spellCheck:!1}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-1sm`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:ce?(0,$.jsx)(s,{id:`Nn4GgW`,values:{sanitizedName:ce},components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}}):(0,$.jsx)(s,{id:`Oxyd5f`})}),(0,$.jsx)(gr,{status:L})]})]}),(0,$.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(N,{id:`publish-visibility-label`,children:(0,$.jsx)(s,{id:`2q_Q7x`})}),(0,$.jsxs)(F,{value:k,onValueChange:e=>A(e===`public`?`public`:`private`),className:`sm:flex`,"aria-labelledby":`publish-visibility-label`,children:[(0,$.jsx)(be,{htmlFor:`publish-visibility-private`,children:(0,$.jsxs)(Ce,{orientation:`horizontal`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsx)(Se,{children:(0,$.jsx)(s,{id:`zwBp5t`})}),(0,$.jsx)(xe,{className:`text-1sm`,children:(0,$.jsx)(s,{id:`D8OV7J`})})]}),(0,$.jsx)(P,{value:`private`,id:`publish-visibility-private`,"data-testid":`publish-visibility-private`})]})}),(0,$.jsx)(be,{htmlFor:`publish-visibility-public`,children:(0,$.jsxs)(Ce,{orientation:`horizontal`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsx)(Se,{children:(0,$.jsx)(s,{id:`7d1a0d`})}),(0,$.jsx)(xe,{className:`text-1sm`,children:(0,$.jsx)(s,{id:`4jDd0j`})})]}),(0,$.jsx)(P,{value:`public`,id:`publish-visibility-public`,"data-testid":`publish-visibility-public`})]})})]})]}),(0,$.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(N,{htmlFor:`publish-description`,children:(0,$.jsx)(s,{id:`Fxf4jq`})}),(0,$.jsx)(ze,{id:`publish-description`,"data-testid":`publish-description`,rows:2,value:j,onChange:e=>M(e.target.value),placeholder:a({id:`c5rF4v`})})]}),ee&&(0,$.jsx)(hr,{banner:ee,onAuthorize:je,onRetryPush:Te})]}),(0,$.jsxs)(E,{children:[(0,$.jsx)(v,{type:`button`,variant:`outline`,className:`font-mono uppercase`,onClick:Ne,children:(0,$.jsx)(s,{id:`dEgA5A`})}),(0,$.jsx)(v,{type:`button`,onClick:Te,disabled:Pe,"data-testid":`publish-submit`,children:z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(he,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` `,(0,$.jsx)(s,{id:`Bdha5y`})]}):(0,$.jsx)(s,{id:`EEYbdt`})})]})]})}),t[35]=a,t[36]=l,t[37]=ee,t[38]=K,t[39]=j,t[40]=je,t[41]=Ne,t[42]=X,t[43]=Te,t[44]=Y,t[45]=b,t[46]=L,t[47]=u,t[48]=h,t[49]=f,t[50]=W,t[51]=ce,t[52]=_,t[53]=J,t[54]=ne,t[55]=Pe,t[56]=z,t[57]=k,t[58]=Fe):Fe=t[58];let Ie;t[59]!==r||t[60]!==n||t[61]!==Fe?(Ie=(0,$.jsx)(O,{open:n,onOpenChange:r,children:Fe}),t[59]=r,t[60]=n,t[61]=Fe,t[62]=Ie):Ie=t[62];let Le;t[63]!==H||t[64]!==we?(Le=(0,$.jsx)(kt,{open:H,onOpenChange:U,onSuccess:we}),t[63]=H,t[64]=we,t[65]=Le):Le=t[65];let Re;return t[66]!==Ie||t[67]!==Le?(Re=(0,$.jsxs)($.Fragment,{children:[Ie,Le]}),t[66]=Ie,t[67]=Le,t[68]=Re):Re=t[68],Re}function ur(e){let t=`publish-owner-${e.login}`;return(0,$.jsx)(be,{htmlFor:t,children:(0,$.jsxs)(Ce,{orientation:`horizontal`,children:[(0,$.jsx)(ye,{children:(0,$.jsxs)(Se,{children:[e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:``,"aria-hidden":!0,className:`size-4 rounded-full`}):null,(0,$.jsx)(`span`,{children:e.login})]})}),(0,$.jsx)(P,{value:e.login,id:t,"data-testid":`publish-owner-option-${e.login}`})]})},e.login)}function dr(e){let t=(0,Z.c)(36),{ownerLogin:n,repoName:r,shareUrl:i,shareUrlError:a,copying:o,canCopy:l,onCopy:u,onClose:d}=e,{_:f}=c(),p=(0,Q.useRef)(null),m,h;t[0]===i?(m=t[1],h=t[2]):(m=()=>{!i||!p.current||(p.current.focus(),p.current.select())},h=[i],t[0]=i,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(C,{children:(0,$.jsx)(s,{id:`u3wRF-`})}),t[3]=g):g=t[3];let _;t[4]!==n||t[5]!==r?(_={ownerLogin:n,repoName:r},t[4]=n,t[5]=r,t[6]=_):_=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[7]=y):y=t[7];let b;t[8]===_?b=t[9]:(b=(0,$.jsxs)(D,{children:[g,(0,$.jsx)(S,{children:(0,$.jsx)(s,{id:`r871ed`,values:_,components:y})})]}),t[8]=_,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Y,{className:`mt-0.5 size-4 text-emerald-600`,"aria-hidden":!0}),t[10]=x):x=t[10];let w;t[11]===l?w=t[12]:(w=(0,$.jsxs)(`div`,{role:`status`,"data-testid":`publish-success`,className:`flex items-start gap-3 rounded-md border border-emerald-500/40 bg-emerald-500/5 p-3 text-sm`,children:[x,(0,$.jsx)(`span`,{className:`text-foreground`,children:l?(0,$.jsx)(s,{id:`cOrTMo`}):(0,$.jsx)(s,{id:`nTwL53`})})]}),t[11]=l,t[12]=w);let O;t[13]!==l||t[14]!==i||t[15]!==a?(O=l&&(0,$.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(N,{htmlFor:`publish-share-url`,children:(0,$.jsx)(s,{id:`5-FeN2`})}),a?(0,$.jsx)(`div`,{role:`alert`,"data-testid":`publish-share-url-error`,className:`rounded-md border border-destructive/50 bg-destructive/5 p-2 text-sm text-destructive`,children:a}):i?(0,$.jsx)(Oe,{id:`publish-share-url`,ref:p,"data-testid":`publish-share-url`,readOnly:!0,value:i,onFocus:mr,onClick:pr,onContextMenu:fr,className:`font-mono text-xs`}):(0,$.jsxs)(`div`,{"data-testid":`publish-share-url-loading`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(he,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` `,(0,$.jsx)(s,{id:`M9597s`})]})]}),t[13]=l,t[14]=i,t[15]=a,t[16]=O):O=t[16];let k;t[17]!==w||t[18]!==O?(k=(0,$.jsxs)(T,{className:`flex flex-col gap-4`,children:[w,O]}),t[17]=w,t[18]=O,t[19]=k):k=t[19];let A;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(s,{id:`DPfwMq`}),t[20]=A):A=t[20];let j;t[21]===d?j=t[22]:(j=(0,$.jsx)(v,{type:`button`,variant:`outline`,className:`font-mono uppercase`,onClick:d,"data-testid":`publish-success-done`,children:A}),t[21]=d,t[22]=j);let M;t[23]!==f||t[24]!==l||t[25]!==o||t[26]!==u||t[27]!==i?(M=l&&(0,$.jsx)(v,{type:`button`,onClick:u,disabled:o||!i,"data-testid":`publish-copy-link`,"aria-label":f({id:`RGCCrg`}),children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(he,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` `,(0,$.jsx)(s,{id:`OvEjsP`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),` `,(0,$.jsx)(s,{id:`RGCCrg`})]})}),t[23]=f,t[24]=l,t[25]=o,t[26]=u,t[27]=i,t[28]=M):M=t[28];let P;t[29]!==j||t[30]!==M?(P=(0,$.jsxs)(E,{children:[j,M]}),t[29]=j,t[30]=M,t[31]=P):P=t[31];let F;return t[32]!==k||t[33]!==P||t[34]!==b?(F=(0,$.jsxs)($.Fragment,{children:[b,k,P]}),t[32]=k,t[33]=P,t[34]=b,t[35]=F):F=t[35],F}function fr(e){return e.currentTarget.select()}function pr(e){return e.currentTarget.select()}function mr(e){return e.currentTarget.select()}function hr(e){let t=(0,Z.c)(13),{banner:n,onAuthorize:i,onRetryPush:a}=e,o=n.next,c;t[0]===n.message?c=t[1]:(c=(0,$.jsx)(`span`,{children:n.message}),t[0]=n.message,t[1]=c);let l;t[2]!==o.authorizeUrl||t[3]!==o.kind||t[4]!==i?(l=o.kind===`authorize-org`&&(0,$.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-authorize-org`,onClick:()=>i(o.authorizeUrl),children:[(0,$.jsx)(s,{id:`FyW0WO`}),` `,(0,$.jsx)(r,{className:`ml-1 size-3`,"aria-hidden":!0})]}),t[2]=o.authorizeUrl,t[3]=o.kind,t[4]=i,t[5]=l):l=t[5];let u;t[6]!==o.kind||t[7]!==a?(u=o.kind===`retry-push`&&(0,$.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-retry-push`,onClick:a,children:(0,$.jsx)(s,{id:`NOHyEE`})}),t[6]=o.kind,t[7]=a,t[8]=u):u=t[8];let d;return t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{role:`alert`,"data-testid":`publish-banner`,className:`flex flex-col gap-2 rounded-md border border-destructive/50 bg-destructive/5 p-3 text-sm`,children:[c,l,u]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function gr(e){let t=(0,Z.c)(12),{status:r}=e;if(r.kind===`available`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{className:`size-3.5`,"aria-hidden":!0}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`available`,className:`flex items-center gap-1 text-emerald-600 dark:text-emerald-400`,children:[e,` `,(0,$.jsx)(s,{id:`csDS2L`})]}),t[1]=n):n=t[1],n}if(r.kind===`taken`){let{owner:e,name:i}=r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==e?(o=(0,$.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`taken`,className:`flex items-center gap-1 text-destructive`,children:[a,` `,(0,$.jsx)(s,{id:`LRgZAt`,values:{owner:e,name:i}})]}),t[3]=i,t[4]=e,t[5]=o):o=t[5],o}if(r.kind===`checking`||r.kind===`pending`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(he,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t[6]=e):e=t[6];let n;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(s,{id:`pWT04I`}),t[7]=n):n=t[7];let i;return t[8]===r.kind?i=t[9]:(i=(0,$.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":r.kind,className:`flex items-center gap-1 text-muted-foreground`,children:[e,` `,n]}),t[8]=r.kind,t[9]=i),i}if(r.kind===`error`){let e;return t[10]===r.banner?e=t[11]:(e=(0,$.jsx)(`span`,{"data-testid":`publish-name-check`,"data-status":`error`,className:`text-destructive`,children:r.banner}),t[10]=r.banner,t[11]=e),e}return null}function _r(e=`sync`){ie(e).catch(e=>{console.warn(`[sync-badge] manual sync trigger failed`,e instanceof Error?e.message:e)})}function vr(e){if(!e)return X._({id:`Zul8Ry`});let t=Date.now()-new Date(e).getTime();if(t<6e4)return X._({id:`xOTzt5`});if(t<36e5){let e=Math.floor(t/6e4);return X._({id:`LNum6A`,values:{minutes:e}})}if(t<864e5){let e=Math.floor(t/36e5);return X._({id:`nYeBmY`,values:{hours:e}})}return new Date(e).toLocaleDateString()}function yr(e){return e.syncMode===`follow`}function br(e){return yr(e)&&e.state===`idle`&&e.conflictCount>0?`conflict`:e.state}function xr(e){let t=(0,Z.c)(10),{status:n,paused:r}=e;if(r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ke,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}switch(br(n)){case`dormant`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ue,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ge,{className:`size-3.5 text-muted-foreground`}),t[2]=e):e=t[2],e}let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ue,{className:`size-3.5 text-muted-foreground`}),t[3]=e):e=t[3],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ge,{className:`size-3.5 text-muted-foreground animate-spin`}),t[4]=e):e=t[4],e}case`conflict`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Te,{className:`size-3.5 text-amber-500`}),t[5]=e):e=t[5],e}case`offline`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(He,{className:`size-3.5 text-muted-foreground`}),t[6]=e):e=t[6],e}case`auth-error`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(We,{className:`size-3.5 text-destructive`}),t[7]=e):e=t[7],e}case`disabled`:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Te,{className:`size-3.5 text-amber-500`}),t[8]=e):e=t[8],e}default:{let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ue,{className:`size-3.5 text-muted-foreground`}),t[9]=e):e=t[9],e}}}function Sr(e){switch(br(e)){case`idle`:return!yr(e)&&e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;default:return``}}function Cr(e,t=!1){switch(e){case`dormant`:return X._({id:`RmBY0A`});case`idle`:return t?X._({id:`j5CWO4`}):X._({id:`N2FcBE`});case`fetching`:return t?X._({id:`7IsvrP`}):X._({id:`Wgmlsw`});case`pulling`:return t?X._({id:`JL3si7`}):X._({id:`4uNLmk`});case`pushing`:return X._({id:`iycx_A`});case`conflict`:return X._({id:`IInnZo`});case`offline`:return X._({id:`6Aih4U`});case`auth-error`:return X._({id:`mHVPm5`});case`disabled`:return X._({id:`DrYM2Z`});default:return e}}function wr(e){switch(e){case`external-changes-pending`:return X._({id:`W9_Bub`});case`dirty-tree`:return X._({id:`a5Gha5`});case`non-content-merge-failure`:return X._({id:`sIxSSP`});case`detached-head`:return X._({id:`uQNW00`});case`diverged-local-commits`:return X._({id:`LQsCPn`});case`auth-error`:return X._({id:`mHVPm5`});case`protected-branch`:return X._({id:`8fc_3j`});case`no-push-permission`:return X._({id:`ChAtFg`});default:return e}}function Tr(e){switch(e){case`not-authenticated`:return X._({id:`ycIX5i`});case`no-collaborator`:return X._({id:`ChAtFg`});case`private-no-access`:return X._({id:`07gHun`});case`repo-not-found`:return X._({id:`uksqrP`});default:return X._({id:`ChAtFg`})}}function Er(e){return e?.checkStatus===`denied`&&e.deniedReason===`not-authenticated`}function Dr(e){switch(e){case`auth-403`:return X._({id:`EiVgl5`});case`auth-401`:return X._({id:`-Qw-1t`});case`auth-scope-mismatch`:return X._({id:`Zue_jx`});case`auth-no-credential`:return X._({id:`uCaIdy`});case`semantic-protected-branch`:return X._({id:`T0OVm7`});default:return X._({id:`1AumWo`})}}function Or(e){switch(e){case`auth-403`:return X._({id:`RgbKEe`});case`auth-401`:return X._({id:`-Qw-1t`});case`auth-scope-mismatch`:return X._({id:`Zue_jx`});case`auth-no-credential`:return X._({id:`uCaIdy`});default:return X._({id:`jZ_E5M`})}}function kr(e){switch(e){case`auth-403`:return X._({id:`RgbKEe`});case`auth-401`:return X._({id:`-Qw-1t`});case`auth-scope-mismatch`:return X._({id:`Zue_jx`});case`auth-no-credential`:return X._({id:`uCaIdy`});case`semantic-protected-branch`:return X._({id:`T0OVm7`});default:return X._({id:`cUk6TF`})}}function Ar(e){let t=e.pushErrorCode!=null||e.pushError!=null,n=e.pullErrorCode!=null||e.pullError!=null;if(t&&n&&(e.pushErrorCode==null?e.pullErrorCode==null&&e.pushError===e.pullError:e.pushErrorCode===e.pullErrorCode))return[{key:`sync`,direction:null,message:e.pushErrorCode==null?e.pushError:kr(e.pushErrorCode)}];let r=t&&n,i=[];return t&&i.push({key:`push`,direction:r?`push`:null,message:e.pushErrorCode?Dr(e.pushErrorCode):e.pushError}),n&&i.push({key:`pull`,direction:r?`pull`:null,message:e.pullErrorCode?Or(e.pullErrorCode):e.pullError}),i}function jr(e){return e?.checkStatus===`unknown`&&e.unknownError===`token-invalid`}function Mr(e,t=!1){if(t)return X._({id:`U6wmNc`});let n=yr(e);if(!e.syncEnabled&&!n)return X._({id:`kUn-CN`});let r=br(e);if(r===`conflict`&&e.conflictCount>0){let{conflictCount:t}=e;return X._({id:`cUK8lW`,values:{conflictCount:t}})}if(r===`idle`){let{ahead:t,behind:r}=e;return n?r>0?X._({id:`9o1bIV`,values:{behind:r}}):X._({id:`j5CWO4`}):t>0&&r>0?X._({id:`5F5HYj`,values:{ahead:t,behind:r}}):t>0?X._({id:`PdA9NZ`,values:{ahead:t}}):r>0?X._({id:`9o1bIV`,values:{behind:r}}):X._({id:`N2FcBE`})}return Cr(r,n)}function Nr(e){let t=(0,Z.c)(69),{status:n,onSignIn:r,onSetIdentity:i}=e,{_:a}=c(),{behind:o,conflictCount:l}=n,{projectLocalConfig:u,projectLocalSynced:d}=Le(),f=u?.autoSync,{active:p,paused:m,everEnabled:h,toggleMode:g,confirmOpen:_,setConfirmOpen:y,pendingMode:b,strandedCommitCount:x,onToggleActive:S,onModeSelect:C,onConfirm:w}=ae(f,n.ahead),T=H(f)??`off`,E=yr(n),D=br(n),O=vr(n.lastSyncUtc),k=!(n.pushPermission?.checkStatus===`denied`&&n.pushPermission.deniedReason!==`not-authenticated`),{conflicts:A}=zn(),j=A[0]??null,M=!m&&D===`conflict`&&j!==null,N=!m&&D===`auth-error`,P=h&&!M&&!N&&(m||D!==`dormant`),F=p&&T===`full`?`sync`:`pull`,z;t[0]!==m||t[1]!==n?(z=(0,$.jsx)(xr,{status:n,paused:m}),t[0]=m,t[1]=n,t[2]=z):z=t[2];let B=m?a({id:`U6wmNc`}):Cr(D,E),ee;t[3]===B?ee=t[4]:(ee=(0,$.jsx)(`span`,{className:`text-1sm font-medium truncate`,children:B}),t[3]=B,t[4]=ee);let V;t[5]!==z||t[6]!==ee?(V=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[z,ee]}),t[5]=z,t[6]=ee,t[7]=V):V=t[7];let U=!d,W;t[8]!==a||t[9]!==p?(W=a(p?{id:`MGBNwj`}:{id:`rn7n0G`}),t[8]=a,t[9]=p,t[10]=W):W=t[10];let G;t[11]!==p||t[12]!==S||t[13]!==U||t[14]!==W?(G=(0,$.jsx)(I,{checked:p,disabled:U,onCheckedChange:S,"aria-label":W}),t[11]=p,t[12]=S,t[13]=U,t[14]=W,t[15]=G):G=t[15];let K;t[16]!==V||t[17]!==G?(K=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[V,G]}),t[16]=V,t[17]=G,t[18]=K):K=t[18];let q=b??`full`,J;t[19]!==_||t[20]!==w||t[21]!==y||t[22]!==x||t[23]!==q?(J=(0,$.jsx)(oe,{open:_,onOpenChange:y,onConfirm:w,variant:q,strandedCommitCount:x}),t[19]=_,t[20]=w,t[21]=y,t[22]=x,t[23]=q,t[24]=J):J=t[24];let ne;t[25]!==a||t[26]!==p||t[27]!==E||t[28]!==r||t[29]!==m||t[30]!==n?(ne=m?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sync-popover-paused-line`,children:(0,$.jsx)(s,{id:`PTb1Nx`})}):(0,$.jsxs)($.Fragment,{children:[Ar(n).map(e=>(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:e.direction===`push`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[a({id:`uO9WLl`}),`: `]}),e.message]}):e.direction===`pull`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[a({id:`e4GHWP`}),`: `]}),e.message]}):e.message},e.key)),!E&&Er(n.pushPermission)?(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1 min-w-0`,children:(0,$.jsx)(s,{id:`ycIX5i`})}),r&&(0,$.jsx)(v,{variant:`outline`,size:`xs`,className:`self-start`,onClick:r,children:(0,$.jsx)(s,{id:`5lWFkC`})})]}):n.pausedReason?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:wr(n.pausedReason)}):E?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sync-popover-mode-line`,children:(0,$.jsx)(s,{id:`-imiMK`})}):p?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sync-popover-mode-line`,children:(0,$.jsx)(s,{id:`iy64Li`})}):n.pushPermission?.checkStatus===`denied`?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Tr(n.pushPermission.deniedReason)}):jr(n.pushPermission)?(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1 min-w-0`,children:(0,$.jsx)(s,{id:`C_cPoW`})}),r&&(0,$.jsx)(v,{variant:`outline`,size:`xs`,className:`self-start`,onClick:r,children:(0,$.jsx)(s,{id:`5lWFkC`})})]}):null]}),t[25]=a,t[26]=p,t[27]=E,t[28]=r,t[29]=m,t[30]=n,t[31]=ne):ne=t[31];let re;t[32]!==E||t[33]!==m||t[34]!==D?(re=!m&&D===`conflict`&&(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:E?(0,$.jsx)(s,{id:`ko386X`}):(0,$.jsx)(s,{id:`t2TkQ3`})}),t[32]=E,t[33]=m,t[34]=D,t[35]=re):re=t[35];let ie;t[36]!==a||t[37]!==n.remote?(ie=n.remote&&(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 font-mono uppercase tracking-wide text-2xs`,children:(0,$.jsx)(s,{id:`IreQBq`})}),n.remote.webUrl?(0,$.jsxs)(`a`,{href:n.remote.webUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-w-0 items-center gap-0.5 text-foreground hover:text-primary hover:underline`,"aria-label":a({id:`1nke1r`,values:{0:n.remote.label}}),children:[(0,$.jsx)(`span`,{className:`truncate`,children:n.remote.label}),(0,$.jsx)(ce,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]}):(0,$.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:n.remote.label})]}),t[36]=a,t[37]=n.remote,t[38]=ie):ie=t[38];let se;t[39]!==p||t[40]!==o||t[41]!==E||t[42]!==n.behind?(se=p&&!E&&n.behind>0&&(0,$.jsx)(`div`,{children:(0,$.jsx)(s,{id:`YsEYYS`,values:{behind:o}})}),t[39]=p,t[40]=o,t[41]=E,t[42]=n.behind,t[43]=se):se=t[43];let le;t[44]!==l||t[45]!==n.conflictCount?(le=n.conflictCount>0&&(0,$.jsx)(`div`,{children:(0,$.jsx)(s,{id:`B4_ipX`,values:{conflictCount:l}})}),t[44]=l,t[45]=n.conflictCount,t[46]=le):le=t[46];let ue;t[47]!==a||t[48]!==k||t[49]!==C||t[50]!==g?(ue=k&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-0.5`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 font-mono uppercase tracking-wide text-2xs`,children:(0,$.jsx)(s,{id:`zz_Wd_`})}),(0,$.jsxs)(R,{type:`single`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted p-0.5 data-[size=sm]:rounded-[10px]`,value:g,onValueChange:e=>{te(e)&&C(e)},"aria-label":a({id:`CnOGgs`}),"data-testid":`sync-popover-mode-toggle`,children:[(0,$.jsx)(L,{value:`full`,"data-testid":`sync-popover-mode-full`,children:(0,$.jsx)(s,{id:`g2Tj8R`})}),(0,$.jsx)(L,{value:`follow`,"data-testid":`sync-popover-mode-follow`,children:(0,$.jsx)(s,{id:`MKEPCY`})})]})]}),t[47]=a,t[48]=k,t[49]=C,t[50]=g,t[51]=ue):ue=t[51];let Y;t[52]!==ie||t[53]!==se||t[54]!==le||t[55]!==ue?(Y=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2 border-t pt-3`,children:[ie,se,le,ue]}),t[52]=ie,t[53]=se,t[54]=le,t[55]=ue,t[56]=Y):Y=t[56];let de;t[57]!==i||t[58]!==m||t[59]!==n.identityUnresolved?(de=!m&&n.identityUnresolved&&i&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,$.jsx)(qe,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:(0,$.jsx)(s,{id:`nrGWJ7`})}),(0,$.jsx)(v,{variant:`outline`,size:`xs`,className:`self-start`,onClick:i,children:(0,$.jsx)(s,{id:`keNFEd`})})]})]}),t[57]=i,t[58]=m,t[59]=n.identityUnresolved,t[60]=de):de=t[60];let fe=(P||N||M||p&&D!==`dormant`)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[p&&D!==`dormant`?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`sync-popover-last-sync`,children:a(E?{id:`4DcimZ`,values:{lastSyncedRelative:O}}:{id:`g85bAo`,values:{lastSyncedRelative:O}})}):(0,$.jsx)(`span`,{}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[P&&(0,$.jsx)(v,{variant:`outline`,size:`xs`,onClick:()=>_r(F),children:(0,$.jsx)(s,{id:`Nu4DdT`})}),N&&(0,$.jsx)(v,{variant:`outline`,size:`xs`,onClick:r,children:(0,$.jsx)(s,{id:`5lWFkC`})}),M&&j&&(0,$.jsx)(v,{variant:`outline`,size:`xs`,onClick:()=>{if(typeof window>`u`)return;let e=ke(je(j.file));window.location.hash!==e&&(window.location.hash=e)},children:(0,$.jsx)(s,{id:`0yL--g`})})]})]}),pe;return t[61]!==J||t[62]!==ne||t[63]!==re||t[64]!==Y||t[65]!==de||t[66]!==fe||t[67]!==K?(pe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3.5`,children:[K,J,ne,re,Y,de,fe]}),t[61]=J,t[62]=ne,t[63]=re,t[64]=Y,t[65]=de,t[66]=fe,t[67]=K,t[68]=pe):pe=t[68],pe}function Pr(e){let t=(0,Z.c)(74),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onSetIdentity:i}=n,{_:a}=c(),{status:o,fetchError:l}=re(),{projectLocalConfig:p}=Le(),m=p?.autoSync,h;t[2]===m?h=t[3]:(h=ee(m),t[2]=m,t[3]=h);let g=h,_=te(H(p?.autoSync));if(!o){if(l){let e;t[4]===a?e=t[5]:(e=a({id:`iqIDv4`}),t[4]=a,t[5]=e);let n;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(He,{className:`size-3.5`}),t[6]=n):n=t[6];let r;t[7]===e?r=t[8]:(r=(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(v,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":e,disabled:!0,children:n})}),t[7]=e,t[8]=r);let i;t[9]===l?i=t[10]:(i=(0,$.jsx)(b,{children:l===`network`?(0,$.jsx)(s,{id:`I5AfhE`}):(0,$.jsx)(s,{id:`uKRYiW`})}),t[9]=l,t[10]=i);let o;return t[11]!==r||t[12]!==i?(o=(0,$.jsxs)(x,{children:[r,i]}),t[11]=r,t[12]=i,t[13]=o):o=t[13],o}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason&&o.syncMode!==`follow`&&!g&&!_)return null;let S;t[14]!==g||t[15]!==o?(S=g?``:Sr(o),t[14]=g,t[15]=o,t[16]=S):S=t[16];let C=S,w,T,E,D,O,k,A,j,M,N,P,F;if(t[17]!==a||t[18]!==g||t[19]!==o){let e=g?a({id:`U6wmNc`}):Cr(br(o),yr(o));k=!!o.identityUnresolved,O=u,D=x,E=y,A=!0,T=d,F=!0,w=v,j=`ghost`,M=`icon-sm`,N=`text-muted-foreground relative`,P=a(k?{id:`DFfRbX`,values:{syncStateLabel:e}}:{id:`F4vEsL`,values:{syncStateLabel:e}}),t[17]=a,t[18]=g,t[19]=o,t[20]=w,t[21]=T,t[22]=E,t[23]=D,t[24]=O,t[25]=k,t[26]=A,t[27]=j,t[28]=M,t[29]=N,t[30]=P,t[31]=F}else w=t[20],T=t[21],E=t[22],D=t[23],O=t[24],k=t[25],A=t[26],j=t[27],M=t[28],N=t[29],P=t[30],F=t[31];let I;t[32]!==g||t[33]!==o?(I=(0,$.jsx)(xr,{status:o,paused:g}),t[32]=g,t[33]=o,t[34]=I):I=t[34];let L;t[35]===C?L=t[36]:(L=C&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:C}),t[35]=C,t[36]=L);let R;t[37]!==C||t[38]!==k?(R=!C&&k&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[37]=C,t[38]=k,t[39]=R):R=t[39];let z;t[40]!==w||t[41]!==I||t[42]!==L||t[43]!==R||t[44]!==j||t[45]!==M||t[46]!==N||t[47]!==P?(z=(0,$.jsxs)(w,{variant:j,size:M,className:N,"aria-label":P,children:[I,L,R]}),t[40]=w,t[41]=I,t[42]=L,t[43]=R,t[44]=j,t[45]=M,t[46]=N,t[47]=P,t[48]=z):z=t[48];let B;t[49]!==T||t[50]!==z||t[51]!==F?(B=(0,$.jsx)(T,{asChild:F,children:z}),t[49]=T,t[50]=z,t[51]=F,t[52]=B):B=t[52];let V;t[53]!==E||t[54]!==A||t[55]!==B?(V=(0,$.jsx)(E,{asChild:A,children:B}),t[53]=E,t[54]=A,t[55]=B,t[56]=V):V=t[56];let U;t[57]!==g||t[58]!==o?(U=Mr(o,g),t[57]=g,t[58]=o,t[59]=U):U=t[59];let W;t[60]===U?W=t[61]:(W=(0,$.jsx)(b,{children:U}),t[60]=U,t[61]=W);let G;t[62]!==D||t[63]!==V||t[64]!==W?(G=(0,$.jsxs)(D,{children:[V,W]}),t[62]=D,t[63]=V,t[64]=W,t[65]=G):G=t[65];let K;t[66]!==i||t[67]!==r||t[68]!==o?(K=(0,$.jsx)(f,{align:`end`,className:`w-80 p-3`,children:(0,$.jsx)(Nr,{status:o,onSignIn:r,onSetIdentity:i})}),t[66]=i,t[67]=r,t[68]=o,t[69]=K):K=t[69];let q;return t[70]!==O||t[71]!==G||t[72]!==K?(q=(0,$.jsxs)(O,{children:[G,K]}),t[70]=O,t[71]=G,t[72]=K,t[73]=q):q=t[73],q}function Fr(e){let t=e.trim();return t.length===0?{kind:`blank`,raw:e}:t.startsWith(`#`)?{kind:`comment`,raw:e}:{kind:`pattern`,raw:e,text:t}}function Ir(e){return{lines:e.split(`
|
|
10
|
-
`).map(Fr)}}function Lr(e){return e.lines.map(e=>e.raw).join(`
|
|
11
|
-
`)}function Rr(e){return e.lines.filter(e=>e.kind===`pattern`)}function zr(e,t){let n=t.trim();if(n.length===0)return e;for(let t of e.lines)if(t.kind===`pattern`&&t.text===n)return e;let r={kind:`pattern`,raw:n,text:n},i=e.lines.slice(),a=i[i.length-1];return a&&a.kind===`blank`&&a.raw===``?i.splice(i.length-1,0,r):i.push(r,{kind:`blank`,raw:``}),{lines:i}}function Br(e,t){let n=t.trim();if(n.length===0)return-1;let r=0;for(let t of e.lines)if(t.kind===`pattern`){if(t.text===n)return r;r++}return-1}function Vr(e,t,n){let r=n.trim();if(r.length===0)return Hr(e,t);let i=Wr(e,t);if(i<0)return e;let a=e.lines.slice();return a[i]={kind:`pattern`,raw:r,text:r},{lines:a}}function Hr(e,t){let n=Wr(e,t);if(n<0)return e;let r=e.lines.slice();return r.splice(n,1),{lines:r}}function Ur(e,t,n){if(t===n)return e;let r=[],i=[];if(e.lines.forEach((e,t)=>{e.kind===`pattern`&&(r.push(t),i.push(e))}),t<0||t>=i.length||n<0||n>=i.length)return e;let a=i.slice(),[o]=a.splice(t,1);if(!o)return e;a.splice(n,0,o);let s=e.lines.slice();return r.forEach((e,t)=>{let n=a[t];n&&(s[e]=n)}),{lines:s}}function Wr(e,t){if(t<0)return-1;let n=0;for(let r=0;r<e.lines.length;r++)if(e.lines[r]?.kind===`pattern`){if(n===t)return r;n++}return-1}var Gr=`npx @inkeep/open-knowledge cowork`,Kr=`https://openknowledge.ai/docs/integrations/claude-code`;function qr(){return typeof window<`u`&&typeof window.okDesktop?.skill==`object`}function Jr(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 font-mono text-[0.85em]`,children:n}),t[0]=n,t[1]=r),r}function Yr(e){let t=(0,Z.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=p(`font-mono tracking-wide uppercase text-primary font-medium text-xs`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`p`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Xr(e){let t=(0,Z.c)(4),{n}=e,r;t[0]===n?r=t[1]:(r=n.toString().padStart(2,`0`),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-5 shrink-0 items-center justify-center text-xs font-medium text-muted-foreground font-mono tabular-nums`,children:r}),t[2]=r,t[3]=i),i}function Zr(){let e=(0,Z.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Yr,{children:(0,$.jsx)(s,{id:`cIptmH`})}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Xr,{n:1}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`li`,{className:`flex gap-3`,children:[n,(0,$.jsx)(`span`,{children:(0,$.jsx)(s,{id:`pHYP6v`,components:{0:(0,$.jsx)(`strong`,{className:`font-medium`}),1:(0,$.jsx)(se,{"aria-hidden":`true`,className:`inline h-3 w-3 text-muted-foreground`}),2:(0,$.jsx)(`strong`,{className:`font-medium`})}})})]}),e[2]=r):r=e[2];let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Xr,{n:2}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`li`,{className:`flex gap-3`,children:[i,(0,$.jsx)(`span`,{children:(0,$.jsx)(s,{id:`gGVP4q`,components:{0:(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center font-medium border h-5 w-5 rounded-md text-xs`}),1:(0,$.jsx)(se,{"aria-hidden":`true`,className:`inline h-3 w-3 text-muted-foreground`}),2:(0,$.jsx)(`strong`,{className:`font-medium`}),3:(0,$.jsx)(se,{"aria-hidden":`true`,className:`inline h-3 w-3 text-muted-foreground`}),4:(0,$.jsx)(`strong`,{className:`font-medium`})}})})]}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Xr,{n:3}),e[5]=o):o=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`ol`,{className:`flex flex-col gap-4 text-sm`,children:[r,a,(0,$.jsxs)(`li`,{className:`flex gap-3`,children:[o,(0,$.jsx)(`span`,{children:(0,$.jsx)(s,{id:`COr1Y7`,components:{0:(0,$.jsx)(Jr,{}),1:(0,$.jsx)(`strong`,{className:`font-medium`})}})})]})]}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t,c,(0,$.jsx)(`p`,{className:`text-1sm text-muted-foreground mt-4`,children:(0,$.jsx)(s,{id:`kV2YZv`,components:{0:(0,$.jsx)(`strong`,{className:`font-medium`}),1:(0,$.jsx)(`strong`,{className:`font-medium`}),2:(0,$.jsx)(se,{"aria-hidden":`true`,className:`inline h-3 w-3 text-muted-foreground`}),3:(0,$.jsx)(se,{"aria-hidden":`true`,className:`inline h-3 w-3 text-muted-foreground`})}})})]}),e[7]=l):l=e[7],l}function Qr(e){let t=(0,Z.c)(74),{open:n,onOpenChange:r,reinstall:i}=e,a=i===void 0?!1:i,{_:o}=c(),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={kind:`idle`},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!1),m,h;t[1]===n?(m=t[2],h=t[3]):(m=()=>{n||(d({kind:`idle`}),p(!1))},h=[n],t[1]=n,t[2]=m,t[3]=h),(0,Q.useEffect)(m,h);let g;t[4]===o?g=t[5]:(g=async function(){d({kind:`downloading`});let e=window.okDesktop?.skill;if(!e){d({kind:`error`,message:o({id:`y46m5r`})});return}let t=await e.buildAndOpen();if(t.ok)d({kind:`handed-off`,path:t.path});else{let e=t.message??t.reason;De.error(o({id:`hSySVc`,values:{msg:e}})),d({kind:`error`,message:t.reason===`open-failed`?o({id:`IA1wNb`,values:{msg:e}}):`${t.reason}: ${e}`})}},t[4]=o,t[5]=g);let _=g,y;t[6]===o?y=t[7]:(y=async function(){try{await navigator.clipboard.writeText(Gr),p(!0),setTimeout(()=>p(!1),2e3)}catch(e){let t=e,n=t instanceof Error?t.message:String(t);De.error(o({id:`Uw6ERJ`,values:{detail:n}}))}},t[6]=o,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=qr(),t[8]=x):x=t[8];let k=x,A;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(de,{"aria-hidden":`true`,className:`h-4 w-4`}),t[9]=A):A=t[9];let j;t[10]===a?j=t[11]:(j=(0,$.jsxs)(C,{className:`flex items-center gap-2`,children:[A,a?(0,$.jsx)(s,{id:`xNyj3h`}):(0,$.jsx)(s,{id:`7qRHf0`})]}),t[10]=a,t[11]=j);let M;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(S,{children:(0,$.jsx)(s,{id:`9V0W-R`,components:{0:(0,$.jsx)(`strong`,{className:`font-medium text-foreground`})}})}),t[12]=M):M=t[12];let N;t[13]===j?N=t[14]:(N=(0,$.jsxs)(D,{children:[j,M]}),t[13]=j,t[14]=N);let P;t[15]===u.kind?P=t[16]:(P=u.kind===`idle`&&k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(Yr,{className:`text-muted-foreground`,children:(0,$.jsx)(s,{id:`Dnn2XG`})}),(0,$.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`RN62Q8`,components:{0:(0,$.jsx)(Jr,{}),1:(0,$.jsx)(Jr,{})}})})]}),(0,$.jsx)(Zr,{})]}),t[15]=u.kind,t[16]=P);let F;t[17]!==o||t[18]!==f||t[19]!==b||t[20]!==u.kind?(F=u.kind===`idle`&&!k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(Yr,{children:(0,$.jsx)(s,{id:`L8fKuc`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-muted/40 p-2`,children:[(0,$.jsx)(`code`,{className:`flex-1 font-mono text-xs`,children:Gr}),(0,$.jsx)(v,{variant:`ghost`,size:`sm`,onClick:b,"aria-label":o({id:`Oos8fo`}),className:`h-7 gap-1`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{"aria-hidden":`true`,className:`h-3 w-3`}),(0,$.jsx)(s,{id:`6V3Ea3`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{"aria-hidden":`true`,className:`h-3 w-3`}),(0,$.jsx)(s,{id:`he3ygx`})]})})]}),(0,$.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`z60Lgn`,components:{0:(0,$.jsx)(Jr,{})}})})]}),(0,$.jsx)(Zr,{})]}),t[17]=o,t[18]=f,t[19]=b,t[20]=u.kind,t[21]=F):F=t[21];let I;t[22]===u.kind?I=t[23]:(I=u.kind===`downloading`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(he,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(s,{id:`bwil08`,components:{0:(0,$.jsx)(Jr,{})}})]}),t[22]=u.kind,t[23]=I);let L;t[24]!==u.kind||t[25]!==u.path?(L=u.kind===`handed-off`&&k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[(0,$.jsx)(Y,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 text-primary`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(s,{id:`r51jLC`})}),(0,$.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground`,children:u.path??`~/Downloads/openknowledge.skill`})]})]}),(0,$.jsx)(Zr,{})]}),t[24]=u.kind,t[25]=u.path,t[26]=L):L=t[26];let R;t[27]===u.kind?R=t[28]:(R=u.kind===`handed-off`&&!k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[(0,$.jsx)(Y,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 text-primary`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(s,{id:`hynz2K`})}),(0,$.jsx)(`span`,{className:`text-1sm text-muted-foreground`,children:(0,$.jsx)(s,{id:`qXg5W9`,components:{0:(0,$.jsx)(Jr,{})}})})]})]}),(0,$.jsx)(Zr,{})]}),t[27]=u.kind,t[28]=R);let z;t[29]!==u.kind||t[30]!==u.message?(z=u.kind===`error`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-destructive`,children:u.message}),(0,$.jsx)(`a`,{href:Kr,target:`_blank`,rel:`noopener noreferrer`,onClick:ni,onAuxClick:ti,className:`text-xs underline underline-offset-2 hover:text-foreground`,children:(0,$.jsx)(s,{id:`mGaZwZ`})})]}),t[29]=u.kind,t[30]=u.message,t[31]=z):z=t[31];let B;t[32]!==P||t[33]!==F||t[34]!==I||t[35]!==L||t[36]!==R||t[37]!==z?(B=(0,$.jsx)(T,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 py-2`,children:[P,F,I,L,R,z]})}),t[32]=P,t[33]=F,t[34]=I,t[35]=L,t[36]=R,t[37]=z,t[38]=B):B=t[38];let ee;t[39]===u.kind?ee=t[40]:(ee=u.kind!==`error`&&(0,$.jsxs)(`a`,{href:Kr,target:`_blank`,rel:`noopener noreferrer`,onClick:ei,onAuxClick:$r,className:`inline-flex items-center gap-1 self-center text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground sm:mr-auto font-mono tracking-wide uppercase`,children:[(0,$.jsx)(s,{id:`U3IvM5`}),(0,$.jsx)(Ge,{"aria-hidden":`true`,className:`h-3 w-3`})]}),t[39]=u.kind,t[40]=ee);let V;t[41]!==_||t[42]!==r||t[43]!==u.kind||t[44]!==a?(V=u.kind===`idle`&&k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(v,{className:`uppercase font-mono`,variant:`outline`,onClick:()=>r(!1),children:(0,$.jsx)(s,{id:`dEgA5A`})}),(0,$.jsxs)(v,{onClick:_,children:[(0,$.jsx)(de,{"aria-hidden":`true`,className:`h-4 w-4`}),a?(0,$.jsx)(s,{id:`YGIi_c`}):(0,$.jsx)(s,{id:`TKQ7K-`})]})]}),t[41]=_,t[42]=r,t[43]=u.kind,t[44]=a,t[45]=V):V=t[45];let H;t[46]!==r||t[47]!==u.kind?(H=u.kind===`idle`&&!k&&(0,$.jsx)(v,{className:`uppercase font-mono`,variant:`outline`,onClick:()=>r(!1),children:(0,$.jsx)(s,{id:`yz7wBu`})}),t[46]=r,t[47]=u.kind,t[48]=H):H=t[48];let U;t[49]!==_||t[50]!==r||t[51]!==u.kind?(U=u.kind===`error`&&k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(v,{className:`uppercase font-mono`,variant:`outline`,onClick:()=>r(!1),children:(0,$.jsx)(s,{id:`dEgA5A`})}),(0,$.jsxs)(v,{onClick:_,children:[(0,$.jsx)(de,{"aria-hidden":`true`,className:`h-4 w-4`}),(0,$.jsx)(s,{id:`KDw4GX`})]})]}),t[49]=_,t[50]=r,t[51]=u.kind,t[52]=U):U=t[52];let W;t[53]!==u.kind||t[54]!==a?(W=u.kind===`downloading`&&(0,$.jsxs)(v,{disabled:!0,children:[(0,$.jsx)(he,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),a?(0,$.jsx)(s,{id:`fIgqfQ`}):(0,$.jsx)(s,{id:`Wtw22s`})]}),t[53]=u.kind,t[54]=a,t[55]=W):W=t[55];let G;t[56]!==r||t[57]!==u.kind?(G=u.kind===`handed-off`&&(0,$.jsx)(v,{onClick:()=>r(!1),children:(0,$.jsx)(s,{id:`DPfwMq`})}),t[56]=r,t[57]=u.kind,t[58]=G):G=t[58];let K;t[59]!==ee||t[60]!==V||t[61]!==H||t[62]!==U||t[63]!==W||t[64]!==G?(K=(0,$.jsxs)(E,{children:[ee,V,H,U,W,G]}),t[59]=ee,t[60]=V,t[61]=H,t[62]=U,t[63]=W,t[64]=G,t[65]=K):K=t[65];let q;t[66]!==N||t[67]!==B||t[68]!==K?(q=(0,$.jsxs)(w,{className:`sm:max-w-lg`,"data-ok-layer-spawned":``,children:[N,B,K]}),t[66]=N,t[67]=B,t[68]=K,t[69]=q):q=t[69];let J;return t[70]!==r||t[71]!==n||t[72]!==q?(J=(0,$.jsx)(O,{open:n,onOpenChange:r,children:q}),t[70]=r,t[71]=n,t[72]=q,t[73]=J):J=t[73],J}function $r(e){return Re(e,Kr)}function ei(e){return Re(e,Kr)}function ti(e){return Re(e,Kr)}function ni(e){return Re(e,Kr)}var ri=new Set;function ii(e){for(let t of ri)try{t(e)}catch(e){console.warn(`[config-ignore-nested-error-events] listener threw:`,e)}}function ai(e){return ri.add(e),()=>{ri.delete(e)}}var oi=new Set;function si(e){for(let t of oi)try{t(e)}catch(e){console.warn(`[config-validation-events] listener threw:`,e)}}function ci(e){return oi.add(e),()=>{oi.delete(e)}}var li=null;function ui(){return li}function di(e){li=e}export{Mn as A,it as B,Un as C,In as D,zn as E,kt as F,Je as H,Ct as I,ht as L,Zt as M,Xt as N,Fn as O,qt as P,ft as R,Hn as S,Bn as T,Ue as U,$e as V,wr as _,ii as a,lr as b,zr as c,Rr as d,Ir as f,Pr as g,Lr as h,ci as i,Qt as j,Ln as k,Vr as l,Ur as m,di as n,ai as o,Hr as p,si as r,Qr as s,ui as t,Br as u,Er as v,Jn as w,Gn as x,jr as y,pt as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./react-f2sANaYj.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import{Io as r,Mo as i,No as a,Oo as o,Za as s,bo as c,do as l,h as u,lt as d,m as f}from"./dist-CrqBb5y32.js";var p=e(t(),1),m=n(),h=new Map(d.map(e=>[e.name,e]));function g(e,t){let n=h.get(e);if(!n)throw Error(`color-themes: ${e} is not a generated base-theme token`);return n[t]}function _(e){return{sidebar:e===`dark`?f:u,background:g(`--background`,e),primary:g(`--primary`,e),border:g(`--border`,e),"syntax-string":g(`--chart-2`,e),"syntax-keyword":g(`--chart-4`,e),"syntax-atom":g(`--chart-3`,e)}}var v={name:`Custom`,variant:`dark`,palette:{base00:`#0f172a`,base01:`#1e293b`,base02:`#334155`,base03:`#64748b`,base04:`#94a3b8`,base05:`#e2e8f0`,base06:`#f1f5f9`,base07:`#f8fafc`,base08:`#e5534b`,base09:`#db8d3f`,base0A:`#d29922`,base0B:`#3fb950`,base0C:`#22d3ee`,base0D:`#6366f1`,base0E:`#a78bfa`,base0F:`#c2703f`}},y=[`background`,`surface`,`foreground`,`primary`,`accent`,`border`];function b(e){let{background:t,foreground:n}=e;return{name:`Custom`,variant:i(t)<i(n)?`dark`:`light`,palette:{base00:t,base01:e.surface,base02:e.border,base03:o(t,n,.4),base04:o(t,n,.55),base05:n,base06:o(n,`#ffffff`,.3),base07:o(n,`#ffffff`,.6),base08:`#e5534b`,base09:`#db8d3f`,base0A:`#d29922`,base0B:`#3fb950`,base0C:e.accent,base0D:e.primary,base0E:e.accent,base0F:o(`#e5534b`,t,.35)}}}function x(e){return c(e)}function S(){let e=v.palette;return{background:e.base00,surface:e.base01,foreground:e.base05,primary:e.base0D,accent:e.base0C,border:e.base02}}function C(e){let t=S(),n=!1;for(let r of y){let i=e[r];c(i)&&(t[r]=i,n=!0)}return n?t:null}function w(e){return e?y.some(t=>c(e[t])):!1}function T(e){if(!e)return v;let t=C(e),n={...(t?b(t):v).palette};for(let t of s){let r=e[t];c(r)&&(n[t]=r)}let r=e.variant===`light`||e.variant===`dark`?e.variant:i(n.base00)<i(n.base05)?`dark`:`light`;return{name:typeof e.name==`string`&&e.name.trim()?e.name.trim():`Custom`,author:typeof e.author==`string`?e.author:void 0,variant:r,palette:n}}function E(e){let t={name:e.name,author:e.author??null,variant:e.variant};for(let n of s)t[n]=e.palette[n];for(let e of y)t[e]=null;return t}function D(e){return e.variant}function O(e){return a(`html[data-color-theme="custom"]`,e.variant,l(e))}var k=`ok-color-theme-v1`,A=`ok-custom-theme-v1`,j=`data-color-theme`,M=`ok-custom-theme`;function N(e){let t=document.getElementById(M);t||(t=document.createElement(`style`),t.id=M,document.head.appendChild(t)),t.textContent!==e&&(t.textContent=e)}function P(){document.getElementById(M)?.remove()}function F(e,t,n=!0){if(typeof document>`u`)return;let i=r(n?e:`default`),a=document.documentElement;i.id===`default`?a.removeAttribute(j):a.setAttribute(j,i.id);let o=null;if(i.id===`custom`){let e=T(t),n=O(e);N(n),o=JSON.stringify({css:n,dark:D(e)===`dark`})}else P();try{i.id===`default`?localStorage.removeItem(k):localStorage.setItem(k,i.id),o?localStorage.setItem(A,o):localStorage.removeItem(A)}catch{}}function I(e,t,n){let r=(0,m.c)(12),i=n===void 0?!0:n,a;r[0]!==e||r[1]!==t||r[2]!==i?(a=i&&e===`custom`?JSON.stringify(t??null):``,r[0]=e,r[1]=t,r[2]=i,r[3]=a):a=r[3];let o=a,s;r[4]!==e||r[5]!==t||r[6]!==i?(s=()=>{F(e,t,i)},r[4]=e,r[5]=t,r[6]=i,r[7]=s):s=r[7];let c;r[8]!==e||r[9]!==i||r[10]!==o?(c=[e,o,i],r[8]=e,r[9]=i,r[10]=o,r[11]=c):c=r[11],(0,p.useEffect)(s,c)}var L=(0,p.createContext)(null);function R(){let e=(0,p.use)(L);if(!e)throw Error(`useConfigContext must be used within <ConfigProvider />`);return e}function z(){return(0,p.use)(L)}export{F as a,D as c,w as d,x as f,j as i,E as l,R as n,I as o,T as p,z as r,v as s,L as t,_ as u};
|
|
@@ -1,4 +0,0 @@
|
|
|
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{Or as a,Qt as o,Xt as s,da as c,fa as l,ho as u,ma as d,pa as f}from"./dist-CrqBb5y32.js";import{r as ee}from"./client-version-uMlMQx33.js";import{c as te,o as ne,p as re,t as ie}from"./config-context-BIynQsCe.js";var ae=i(),oe=e(n(),1),p=null,se=new Set;function ce(){return p}function le(e){let t=e!==null&&e.length>0?e:null;if(t!==p){p=t;for(let e of se)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function ue(e){return se.add(e),()=>{se.delete(e)}}function de(){return(0,oe.useSyncExternalStore)(ue,ce,ce)}var m=()=>new Map,h=e=>{let t=m();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},_=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},v=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},y=()=>new Set,fe=e=>e[e.length-1],pe=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},b=Array.from,me=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},he=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ge=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},_e=Array.isArray,ve=class{constructor(){this._observers=m()}on(e,t){return g(this._observers,e,y).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 b((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},ye=class{constructor(){this._observers=m()}on(e,t){g(this._observers,e,y).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 b((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},x=Math.floor,be=Math.abs,xe=(e,t)=>e<t?e:t,S=(e,t)=>e>t?e:t;Number.isNaN;var Se=e=>e===0?1/e<0:e<0,Ce=1<<17,we=1<<18,Te=1<<19,Ee=1<<20,De=1<<21,Oe=1<<22,ke=1<<23,Ae=1<<24,je=1<<25,Me=1<<26,Ne=1<<27,Pe=1<<28,Fe=1<<29;Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1;var Ie=2**53-1,Le=-(2**53-1),Re=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&x(e)===e);Number.isNaN,Number.parseInt;var ze=String.fromCharCode;String.fromCodePoint,ze(65535);var Be=e=>e.toLowerCase(),Ve=/^\s*/g,He=e=>e.replace(Ve,``),Ue=/([A-Z])/g,We=(e,t)=>He(e.replace(Ue,e=>`${t}${Be(e)}`)),Ge=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},Ke=typeof TextEncoder<`u`?new TextEncoder:null,qe=Ke?e=>Ke.encode(e):Ge,Je=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Je&&Je.decode(new Uint8Array).length===1&&(Je=null);var Ye=(e,t)=>ge(t,()=>e).join(``),Xe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ze=()=>new Xe,Qe=e=>{let t=Ze();return e(t),C(t)},$e=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},C=e=>{let t=new Uint8Array($e(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},et=(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(S(n,t)*2),e.cpos=0)},w=(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},tt=w,T=(e,t)=>{for(;t>127;)w(e,128|127&t),t=x(t/128);w(e,127&t)},nt=(e,t)=>{let n=Se(t);for(n&&(t=-t),w(e,(t>63?128:0)|(n?64:0)|63&t),t=x(t/64);t>0;)w(e,(t>127?128:0)|127&t),t=x(t/128)},rt=new Uint8Array(3e4),it=rt.length/3,at=Ke&&Ke.encodeInto?(e,t)=>{if(t.length<it){let n=Ke.encodeInto(t,rt).written||0;T(e,n);for(let t=0;t<n;t++)w(e,rt[t])}else E(e,qe(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;T(e,r);for(let t=0;t<r;t++)w(e,n.codePointAt(t))},ot=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=xe(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(S(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},E=(e,t)=>{T(e,t.byteLength),ot(e,t)},st=(e,t)=>{et(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ct=(e,t)=>st(e,4).setFloat32(0,t,!1),lt=(e,t)=>st(e,8).setFloat64(0,t,!1),ut=(e,t)=>st(e,8).setBigInt64(0,t,!1),dt=new DataView(new ArrayBuffer(4)),ft=e=>(dt.setFloat32(0,e),dt.getFloat32(0)===e),pt=(e,t)=>{switch(typeof t){case`string`:w(e,119),at(e,t);break;case`number`:Re(t)&&be(t)<=2147483647?(w(e,125),nt(e,t)):ft(t)?(w(e,124),ct(e,t)):(w(e,123),lt(e,t));break;case`bigint`:w(e,122),ut(e,t);break;case`object`:if(t===null)w(e,126);else if(_e(t)){w(e,117),T(e,t.length);for(let n=0;n<t.length;n++)pt(e,t[n])}else if(t instanceof Uint8Array)w(e,116),E(e,t);else{w(e,118);let n=Object.keys(t);T(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];at(e,i),pt(e,t[i])}}break;case`boolean`:w(e,t?120:121);break;default:w(e,127)}},mt=class extends Xe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&T(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ht=e=>{e.count>0&&(nt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&T(e.encoder,e.count-2))},gt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ht(this),this.count=1,this.s=e)}toUint8Array(){return ht(this),C(this.encoder)}},_t=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);nt(e.encoder,t),e.count>1&&T(e.encoder,e.count-2)}},vt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(_t(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return _t(this),C(this.encoder)}},yt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new gt}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 Xe;return this.sarr.push(this.s),this.s=``,at(e,this.sarr.join(``)),ot(e,this.lensE.toUint8Array()),C(e)}},D=e=>Error(e),O=()=>{throw D(`Method unimplemented`)},k=()=>{throw D(`Unexpected case`)},bt=D(`Unexpected end of array`),xt=D(`Integer out of Range`),St=class{constructor(e){this.arr=e,this.pos=0}},Ct=e=>new St(e),wt=e=>e.pos!==e.arr.length,Tt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},A=e=>Tt(e,j(e)),Et=e=>e.arr[e.pos++],j=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>Ie)throw xt}throw bt},Dt=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>Ie)throw xt}throw bt},Ot=Je?e=>Je.decode(A(e)):e=>{let t=j(e);if(t===0)return``;{let n=String.fromCodePoint(Et(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Et(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))}},kt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},At=[e=>void 0,e=>null,Dt,e=>kt(e,4).getFloat32(0,!1),e=>kt(e,8).getFloat64(0,!1),e=>kt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Ot,e=>{let t=j(e),n={};for(let r=0;r<t;r++){let t=Ot(e);n[t]=jt(e)}return n},e=>{let t=j(e),n=[];for(let r=0;r<t;r++)n.push(jt(e));return n},A],jt=e=>At[127-Et(e)](e),Mt=class extends St{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),wt(this)?this.count=j(this)+1:this.count=-1),this.count--,this.s}},Nt=class extends St{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Dt(this);let e=Se(this.s);this.count=1,e&&(this.s=-this.s,this.count=j(this)+2)}return this.count--,this.s}},Pt=class extends St{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Dt(this),t=e&1;this.diff=x(e/2),this.count=1,t&&(this.count=j(this)+2)}return this.s+=this.diff,this.count--,this.s}},Ft=class{constructor(e){this.decoder=new Nt(e),this.str=Ot(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 It=crypto.getRandomValues.bind(crypto),Lt=Math.random,Rt=()=>It(new Uint32Array(1))[0],zt=e=>e[x(Lt()*e.length)],Bt=`10000000-1000-4000-8000-100000000000`,Vt=()=>Bt.replace(/[018]/g,e=>(e^Rt()&15>>e/4).toString(16)),Ht=Date.now,Ut=e=>new Promise(e);Promise.all.bind(Promise);var Wt=e=>e===void 0?null:e,Gt=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&&(Gt=localStorage)}catch{}var Kt=Gt,qt=Symbol(`Equality`),Jt=(e,t)=>e===t||!!e?.[qt]?.(t)||!1,Yt=e=>typeof e==`object`,Xt=Object.assign,Zt=Object.keys,Qt=(e,t)=>{for(let n in e)t(e[n],n)},$t=e=>Zt(e).length,en=e=>{for(let t in e)return!1;return!0},tn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),rn=(e,t)=>e===t||$t(e)===$t(t)&&tn(e,(e,n)=>(e!==void 0||nn(t,n))&&Jt(t[n],e)),an=Object.freeze,on=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&on(e[t])}return an(e)},sn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&sn(e,t,n+1)}},cn=e=>e,ln=(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[qt]!=null)return e[qt](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)||!ln(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if($t(e)!==$t(t))return!1;for(let n in e)if(!nn(e,n)||!ln(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(!ln(e[n],t[n]))return!1;break;default:return!1}return!0},un=(e,t)=>t.includes(e),dn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,fn=typeof window<`u`&&typeof document<`u`&&!dn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var M,pn=[],mn=()=>{if(M===void 0)if(dn){M=m();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&M.set(t,``),t=r):t===null?pn.push(r):(M.set(t,r),t=null)}t!==null&&M.set(t,``)}else typeof location==`object`?(M=m(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);M.set(`--${We(t,`-`)}`,n),M.set(`-${We(t,`-`)}`,n)}})):M=m();return M},hn=e=>mn().has(e),gn=e=>Wt(dn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Kt.getItem(e)),_n=e=>hn(`--`+e)||gn(e)!==null,vn=_n(`production`),yn=dn&&un({}.FORCE_COLOR,[`true`,`1`,`2`])||!hn(`--no-colors`)&&!_n(`no-color`)&&(!dn||process.stdout.isTTY)&&(!dn||hn(`--color`)||gn(`COLORTERM`)!==null||(gn(`TERM`)||``).includes(`color`)),bn=e=>new Uint8Array(e),xn=fn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=ze(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Sn=e=>{let t=bn(e.byteLength);return t.set(e),t},Cn=e=>Qe(t=>pt(t,e)),wn=class{constructor(e,t){this.left=e,this.right=t}},N=(e,t)=>new wn(e,t),Tn=(e,t)=>e.forEach(e=>t(e.left,e.right)),En=e=>e.next()>=.5,Dn=(e,t,n)=>x(e.next()*(n+1-t)+t),On=(e,t,n)=>x(e.next()*(n+1-t)+t),kn=(e,t,n)=>On(e,t,n),An=e=>ze(kn(e,97,122)),jn=(e,t=0,n=20)=>{let r=kn(e,t,n),i=``;for(let t=0;t<r;t++)i+=An(e);return i},Mn=(e,t)=>t[kn(e,0,t.length-1)],Nn=Symbol(`0schema`),Pn=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(Ye(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
-
`)}},Fn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[qt]?Jt(e,t):_e(e)?me(e,e=>he(t,t=>Fn(e,t))):Yt(e)?tn(e,(e,n)=>Fn(e,t[n])):!1,P=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Fn(t,n)}equals(e){return this.constructor===e.constructor&&ln(this.shape,e.shape)}[Nn](){return!0}[qt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){O()}get nullable(){return fr(this,Dr)}get optional(){return new Wn(this)}cast(e){return jr(e,this),e}expect(e){return jr(e,this),e}},In=class extends P{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}},F=(e,t=null)=>new In(e,t);F(In);var Ln=class extends P{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}},I=e=>new Ln(e);F(Ln);var Rn=class extends P{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},zn=(...e)=>new Rn(e),Bn=F(Rn),Vn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Hn=e=>{if(Sr.check(e))return[Vn(e)];if(Bn.check(e))return e.shape.map(e=>e+``);if(xr.check(e))return[`[+-]?\\d+.?\\d*`];if(Cr.check(e))return[`.*`];if(pr.check(e))return e.shape.map(Hn).flat(1);k()};F(class extends P{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Hn).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 Un=Symbol(`optional`),Wn=class extends P{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[Un](){return!0}},Gn=F(Wn),Kn=class extends P{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Kn,F(Kn);var qn=class e extends P{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):tn(this.shape,(n,r)=>{let i=this._isPartial&&!nn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Jn=e=>new qn(e),Yn=F(qn),Xn=I(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Zn=class extends P{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&tn(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)})}},Qn=(e,t)=>new Zn(e,t),$n=F(Zn),er=class extends P{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&tn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},tr=(...e)=>new er(e);F(er);var nr=class extends P{constructor(e){super(),this.shape=e.length===1?e[0]:new dr(e)}check(e,t){let n=_e(e)&&me(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},rr=(...e)=>new nr(e),ir=F(nr),ar=I(e=>_e(e)),or=class extends P{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}},sr=(e,t=null)=>new or(e,t);F(or);var cr=sr(P),lr=F(class extends P{constructor(e){super(),this.len=e.length-1,this.args=tr(...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}}),ur=I(e=>typeof e==`function`);F(class extends P{constructor(e){super(),this.shape=e}check(e,t){let n=me(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var dr=class extends P{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=he(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},fr=(...e)=>e.findIndex(e=>pr.check(e))>=0?fr(...e.map(e=>Ar(e)).map(e=>pr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new dr(e),pr=F(dr),mr=()=>!0,hr=I(mr),gr=F(Ln,e=>e.shape===mr),_r=I(e=>typeof e==`bigint`),vr=I(e=>e===_r),yr=I(e=>typeof e==`symbol`);I(e=>e===yr);var br=I(e=>typeof e==`number`),xr=I(e=>e===br),Sr=I(e=>typeof e==`string`),Cr=I(e=>e===Sr),wr=I(e=>typeof e==`boolean`),Tr=I(e=>e===wr),Er=zn(void 0);F(Rn,e=>e.shape.length===1&&e.shape[0]===void 0),zn(void 0);var Dr=zn(null),Or=F(Rn,e=>e.shape.length===1&&e.shape[0]===null);F(Uint8Array),F(In,e=>e.shape===Uint8Array);var kr=fr(br,Sr,Dr,Er,_r,wr,yr);(()=>{let e=rr(hr),t=Qn(Sr,hr),n=fr(br,Sr,Dr,wr,e,t);return e.shape=n,t.shape.values=n,n})();var Ar=e=>{if(cr.check(e))return e;if(Xn.check(e)){let t={};for(let n in e)t[n]=Ar(e[n]);return Jn(t)}else if(ar.check(e))return fr(...e.map(Ar));else if(kr.check(e))return zn(e);else if(ur.check(e))return F(e);k()},jr=vn?()=>{}:(e,t)=>{let n=new Pn;if(!t.check(e,n))throw D(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Mr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Ar(e),h:t}),this}else(e){return this.if(hr,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 D(`Unhandled pattern`)}}},Nr=(e=>new Mr(e))(hr).if(xr,(e,t)=>Dn(t,Le,Ie)).if(Cr,(e,t)=>jn(t)).if(Tr,(e,t)=>En(t)).if(vr,(e,t)=>BigInt(Dn(t,Le,Ie))).if(pr,(e,t)=>Pr(t,Mn(t,e.shape))).if(Yn,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Gn.check(i)){if(En(t))continue;i=i.shape}n[r]=Nr(i,t)}return n}).if(ir,(e,t)=>{let n=[],r=On(t,0,42);for(let i=0;i<r;i++)n.push(Pr(t,e.shape));return n}).if(Bn,(e,t)=>Mn(t,e.shape)).if(Or,(e,t)=>null).if(lr,(e,t)=>{let n=Pr(t,e.res);return()=>n}).if(gr,(e,t)=>Pr(t,Mn(t,[br,Sr,Dr,Er,_r,wr,rr(br),Qn(fr(`a`,`b`,`c`),br)]))).if($n,(e,t)=>{let n={},r=Dn(t,0,3);for(let i=0;i<r;i++){let r=Pr(t,e.shape.keys);n[r]=Pr(t,e.shape.values)}return n}).done(),Pr=(e,t)=>Nr(Ar(t),e),L=typeof document<`u`?document:{},Fr=e=>L.createElement(e),Ir=()=>L.createDocumentFragment();I(e=>e.nodeType===Jr);var Lr=e=>L.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Rr=(e,t)=>(Tn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),zr=e=>{let t=Ir();for(let n=0;n<e.length;n++)Wr(t,e[n]);return t},Br=(e,t)=>(Wr(e,zr(t)),e),Vr=(e,t=[],n=[])=>Br(Rr(Fr(e),t),n);I(e=>e.nodeType===Gr);var Hr=Lr;I(e=>e.nodeType===Kr);var Ur=e=>_(e,(e,t)=>`${t}:${e};`).join(``),Wr=(e,t)=>e.appendChild(t),Gr=L.ELEMENT_NODE,Kr=L.TEXT_NODE;L.CDATA_SECTION_NODE,L.COMMENT_NODE;var qr=L.DOCUMENT_NODE;L.DOCUMENT_TYPE_NODE;var Jr=L.DOCUMENT_FRAGMENT_NODE;I(e=>e.nodeType===qr);var Yr=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Xr=(e,t)=>new Yr(setTimeout(t,e)),R=Symbol,Zr=R(),Qr=R(),$r=R(),ei=R(),ti=R(),ni=R(),ri=R(),ii=R(),ai=R(),oi=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};Ht();var si={[Zr]:N(`font-weight`,`bold`),[Qr]:N(`font-weight`,`normal`),[$r]:N(`color`,`blue`),[ti]:N(`color`,`green`),[ei]:N(`color`,`grey`),[ni]:N(`color`,`red`),[ri]:N(`color`,`purple`),[ii]:N(`color`,`orange`),[ai]:N(`color`,`black`)},ci=yn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=m(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=si[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=Ur(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}:oi,li=(...e)=>{console.log(...ci(e)),di.forEach(t=>t.print(e))},ui=(...e)=>{console.warn(...ci(e)),e.unshift(ii),di.forEach(t=>t.print(e))},di=y(),fi=e=>({[Symbol.iterator](){return this},next:e}),pi=(e,t)=>fi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),mi=(e,t)=>fi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),hi=class{constructor(e,t){this.clock=e,this.len=t}},gi=class{constructor(){this.clients=new Map}},_i=(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])Ma(e,i,o.clock,o.len,n)}}),vi=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=x((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},yi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&vi(n,t.clock)!==null},bi=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 hi(r.clock,S(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},xi=e=>{let t=new gi;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++)pe(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return bi(t),t},Si=(e,t,n,r)=>{g(e.clients,t,()=>[]).push(new hi(n,r))},Ci=()=>new gi,wi=e=>{let t=Ci();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 hi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Ti=(e,t)=>{T(e.restEncoder,t.clients.size),b(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),T(e.restEncoder,t);let r=n.length;T(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ei=e=>{let t=new gi,n=j(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=j(e.restDecoder),r=j(e.restDecoder);if(r>0){let i=g(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new hi(e.readDsClock(),e.readDsLen()))}}return t},Di=(e,t,n)=>{let r=new gi,i=j(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=j(e.restDecoder),a=j(e.restDecoder),o=n.clients.get(i)||[],s=B(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Si(r,i,s,a-s);let e=V(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Gs(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,Gs(t,c,a-c.id.clock)),c.delete(t))}else Si(r,i,n,a-n)}}if(r.clients.size>0){let e=new Li;return T(e.restEncoder,0),Ti(e,r),e.toUint8Array()}return null},Oi=Rt,ki=class e extends ve{constructor({guid:e=Vt(),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=Oi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ta,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=Ut(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Ut(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&&U(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(b(this.subdocs).map(e=>e.guid))}transact(e,t=null){return U(this,e,t)}get(e,t=G){let n=g(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==G&&r!==t)if(r===G){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,Fo)}getText(e=``){return this.get(e,ns)}getMap(e=``){return this.get(e,Ro)}getXmlElement(e=``){return this.get(e,ss)}getXmlFragment(e=``){return this.get(e,as)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,b(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,U(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()}},Ai=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return j(this.restDecoder)}readDsLen(){return j(this.restDecoder)}},ji=class extends Ai{readLeftID(){return z(j(this.restDecoder),j(this.restDecoder))}readRightID(){return z(j(this.restDecoder),j(this.restDecoder))}readClient(){return j(this.restDecoder)}readInfo(){return Et(this.restDecoder)}readString(){return Ot(this.restDecoder)}readParentInfo(){return j(this.restDecoder)===1}readTypeRef(){return j(this.restDecoder)}readLen(){return j(this.restDecoder)}readAny(){return jt(this.restDecoder)}readBuf(){return Sn(A(this.restDecoder))}readJSON(){return JSON.parse(Ot(this.restDecoder))}readKey(){return Ot(this.restDecoder)}},Mi=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=j(this.restDecoder),this.dsCurrVal}readDsLen(){let e=j(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Ni=class extends Mi{constructor(e){super(e),this.keys=[],j(e),this.keyClockDecoder=new Pt(A(e)),this.clientDecoder=new Nt(A(e)),this.leftClockDecoder=new Pt(A(e)),this.rightClockDecoder=new Pt(A(e)),this.infoDecoder=new Mt(A(e),Et),this.stringDecoder=new Ft(A(e)),this.parentInfoDecoder=new Mt(A(e),Et),this.typeRefDecoder=new Nt(A(e)),this.lenDecoder=new Nt(A(e))}readLeftID(){return new oa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new oa(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 jt(this.restDecoder)}readBuf(){return A(this.restDecoder)}readJSON(){return jt(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}}},Pi=class{constructor(){this.restEncoder=Ze()}toUint8Array(){return C(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){T(this.restEncoder,e)}writeDsLen(e){T(this.restEncoder,e)}},Fi=class extends Pi{writeLeftID(e){T(this.restEncoder,e.client),T(this.restEncoder,e.clock)}writeRightID(e){T(this.restEncoder,e.client),T(this.restEncoder,e.clock)}writeClient(e){T(this.restEncoder,e)}writeInfo(e){tt(this.restEncoder,e)}writeString(e){at(this.restEncoder,e)}writeParentInfo(e){T(this.restEncoder,+!!e)}writeTypeRef(e){T(this.restEncoder,e)}writeLen(e){T(this.restEncoder,e)}writeAny(e){pt(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){at(this.restEncoder,JSON.stringify(e))}writeKey(e){at(this.restEncoder,e)}},Ii=class{constructor(){this.restEncoder=Ze(),this.dsCurrVal=0}toUint8Array(){return C(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,T(this.restEncoder,t)}writeDsLen(e){e===0&&k(),T(this.restEncoder,e-1),this.dsCurrVal+=e}},Li=class extends Ii{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new vt,this.clientEncoder=new gt,this.leftClockEncoder=new vt,this.rightClockEncoder=new vt,this.infoEncoder=new mt(tt),this.stringEncoder=new yt,this.parentInfoEncoder=new mt(tt),this.typeRefEncoder=new gt,this.lenEncoder=new gt}toUint8Array(){let e=Ze();return T(e,0),E(e,this.keyClockEncoder.toUint8Array()),E(e,this.clientEncoder.toUint8Array()),E(e,this.leftClockEncoder.toUint8Array()),E(e,this.rightClockEncoder.toUint8Array()),E(e,C(this.infoEncoder)),E(e,this.stringEncoder.toUint8Array()),E(e,C(this.parentInfoEncoder)),E(e,this.typeRefEncoder.toUint8Array()),E(e,this.lenEncoder.toUint8Array()),ot(e,C(this.restEncoder)),C(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){pt(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){pt(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)}},Ri=(e,t,n,r)=>{r=S(r,t[0].id.clock);let i=V(t,r);T(e.restEncoder,t.length-i),e.writeClient(n),T(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},zi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{B(t,n)>e&&r.set(n,e)}),Ea(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),T(e.restEncoder,r.size),b(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Ri(e,t.clients.get(n),n,r)})},Bi=(e,t)=>{let n=m(),r=j(e.restDecoder);for(let i=0;i<r;i++){let r=j(e.restDecoder),i=Array(r),a=e.readClient(),o=j(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 K(z(a,o),t),o+=t;break}case 10:{let t=j(e.restDecoder);i[n]=new Y(z(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(z(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,Js(e,r));i[n]=c,o+=c.length}}}}return n},Vi=(e,t,n)=>{let r=[],i=b(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 Ta,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,()=>B(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,B(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 Li;return zi(e,s,new Map),T(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Hi=(e,t)=>zi(e,t.doc.store,t.beforeState),Ui=(e,t,n,r=new Ni(e))=>U(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Vi(e,i,Bi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<B(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=Ya([o.update,a.update])}}else i.pendingStructs=a;let s=Di(r,e,i);if(i.pendingDs){let t=new Ni(Ct(i.pendingDs));j(t.restDecoder);let n=Di(t,e,i);s&&n?i.pendingDs=Ya([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Wi(e.doc,t)}},n,!1),Wi=(e,t,n,r=Ni)=>{let i=Ct(t);Ui(i,e,n,new r(i))},Gi=(e,t,n)=>Wi(e,t,n,ji),Ki=(e,t,n=new Map)=>{zi(e,t.store,n),Ti(e,wi(t.store))},qi=(e,t=new Uint8Array([0]),n=new Li)=>{Ki(n,e,Xi(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Xa(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Fi)return qa(r.map((e,t)=>t===0?e:to(e)));if(n.constructor===Li)return Ya(r)}return r[0]},Ji=(e,t)=>qi(e,t,new Fi),Yi=e=>{let t=new Map,n=j(e.restDecoder);for(let r=0;r<n;r++){let n=j(e.restDecoder),r=j(e.restDecoder);t.set(n,r)}return t},Xi=e=>Yi(new Ai(Ct(e))),Zi=(e,t)=>(T(e.restEncoder,t.size),b(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{T(e.restEncoder,t),T(e.restEncoder,n)}),e),Qi=(e,t)=>Zi(e,Ea(t.store)),$i=(e,t=new Ii)=>(e instanceof Map?Zi(t,e):Qi(t,e),t.toUint8Array()),ea=e=>$i(e,new Pi),ta=class{constructor(){this.l=[]}},na=()=>new ta,ra=(e,t)=>e.l.push(t),ia=(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.`)},aa=(e,t,n)=>sn(e.l,[t,n]),oa=class{constructor(e,t){this.client=e,this.clock=t}},sa=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,z=(e,t)=>new oa(e,t),ca=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw k()},la=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},ua=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},da=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},fa=e=>new ua(e.type==null?null:z(e.type.client,e.type.clock),e.tname??null,e.item==null?null:z(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),pa=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ma=(e,t,n=0)=>new pa(e,t,n),ha=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ca(e):r=z(e._item.id.client,e._item.id.clock),new ua(r,i,t,n)},ga=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ha(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ha(e,z(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ha(e,r.lastId,n);r=r.right}return ha(e,null,n)},_a=(e,t)=>{let n=Oa(e,t);return{item:n,diff:t.clock-n.id.clock}},va=(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(B(r,i.client)<=i.clock)return null;let e=n?Us(r,i):_a(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(B(r,a.client)<=a.clock)return null;let{item:e}=n?Us(r,a):{item:Oa(r,a)};if(e instanceof J&&e.content instanceof Vs)c=e.content.type;else return null}else throw k();l=s>=0?c._length:0}return ma(c,l,e.assoc)},ya=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&sa(e.item,t.item)&&sa(e.type,t.type)&&e.assoc===t.assoc,ba=class{constructor(e,t){this.ds=e,this.sv=t}},xa=(e,t)=>new ba(e,t);xa(Ci(),new Map);var Sa=e=>xa(wi(e.store),Ea(e.store)),Ca=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!yi(t.ds,e.id),wa=(e,t)=>{let n=g(e.meta,wa,y),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<B(r,n)&&H(e,z(n,t))}),_i(e,t.ds,e=>{}),n.add(t))},Ta=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ea=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},B=(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},Da=(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 k()}n.push(t)},V=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=x(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=x((n+r)/2)}throw k()},Oa=(e,t)=>{let n=e.clients.get(t.client);return n[V(n,t.clock)]},ka=(e,t,n)=>{let r=V(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,Gs(e,i,n-i.id.clock)),r+1):r},H=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[ka(e,n,t.clock)]},Aa=(e,t,n)=>{let r=t.clients.get(n.client),i=V(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==K&&r.splice(i+1,0,Gs(e,a,n.clock-a.id.clock+1)),a},ja=(e,t,n)=>{let r=e.clients.get(t.id.client);r[V(r,t.id.clock)]=n},Ma=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=ka(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&ka(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Na=class{constructor(e,t,n){this.doc=e,this.deleteSet=new gi,this.beforeState=Ea(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}},Pa=(e,t)=>t.deleteSet.clients.size===0&&!v(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(bi(t.deleteSet),Hi(e,t),Ti(e,t.deleteSet),!0),Fa=(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,y).add(n)},Ia=(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},La=(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=V(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)}}}},Ra=(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=xe(r.length-1,1+V(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+Ia(r,e)}})},za=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{bi(a),n.afterState=Ea(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(()=>{aa(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&$o(n)})}),sn(e,[])}finally{r.gc&&La(a,i,r.gcFilter),Ra(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=S(V(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ia(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=V(r,n);a+1<r.length&&Ia(r,a+1)>1||a>0&&Ia(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(li(ii,Zr,`[yjs] `,Qr,ni,`Changed the client-id because another client seems to be using it.`),r.clientID=Oi()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Fi;Pa(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Li;Pa(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):za(e,t+1)}}},U=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Na(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&za(i,0)}}return o},Ba=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Va=(e,t,n)=>{_i(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||la(t,n))&&Ws(n,!1)})},Ha=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;U(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;_i(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=Us(r,e.id);i>0&&(t=H(n,z(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||la(t,e))&&c.push(e)}}),_i(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||la(t,e))&&!yi(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=qs(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},Ua=class extends ve{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=_e(e)?e[0].doc:e instanceof ki?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 gi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Si(i,n,r,a)});let a=Ht(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=xi([t.deletions,e.deleteSet]),t.insertions=xi([t.insertions,i])}else r.push(new Ba(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),_i(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||la(n,t))&&Ws(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=_e(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof G?e.doc!==this.doc:e!==this.doc)&&ui(`[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=>Va(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Va(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=Ha(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ha(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*Wa(e){let t=j(e.restDecoder);for(let n=0;n<t;n++){let t=j(e.restDecoder),n=e.readClient(),r=j(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=j(e.restDecoder);yield new Y(z(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(z(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,Js(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new K(z(n,r),t),r+=t}}}}var Ga=class{constructor(e,t){this.gen=Wa(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}},Ka=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},qa=e=>Ya(e,ji,Fi),Ja=(e,t)=>{if(e.constructor===K){let{client:n,clock:r}=e.id;return new K(z(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(z(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(z(r,i+t),null,z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ya=(e,t=Ni,n=Li)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ct(e))),i=r.map(e=>new Ga(e,!0)),a=null,o=new n,s=new Ka(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)Qa(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{Qa(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(z(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=Ja(n,t)),a.struct.mergeWith(n)||(Qa(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())Qa(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Qa(s,a.struct,a.offset),a=null),$a(s),Ti(o,xi(r.map(e=>Ei(e)))),o.toUint8Array()},Xa=(e,t,n=Ni,r=Li)=>{let i=Xi(t),a=new r,o=new Ka(a),s=new n(Ct(e)),c=new Ga(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(Qa(o,e,S(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Qa(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 $a(o),Ti(a,Ei(s)),a.toUint8Array()},Za=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:C(e.encoder.restEncoder)}),e.encoder.restEncoder=Ze(),e.written=0)},Qa=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Za(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),T(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},$a=e=>{Za(e);let t=e.encoder.restEncoder;T(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];T(t,r.written),ot(t,r.restEncoder)}},eo=(e,t,n,r)=>{let i=new n(Ct(e)),a=new Ga(i,!1),o=new r,s=new Ka(o);for(let e=a.curr;e!==null;e=a.next())Qa(s,t(e),0);return $a(s),Ti(o,Ei(i)),o.toUint8Array()},to=e=>eo(e,cn,Ni,Fi),no=`You must not compute changes after the event-handler fired.`,ro=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||=io(this.currentTarget,this.target)}deletes(e){return yi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw D(no);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=fe(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=fe(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=fe(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 D(no);let t=this.target,n=y(),r=y(),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}},io=(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},W=()=>{ui(`Invalid access: Add Yjs type to a document before reading data.`)},ao=80,oo=0,so=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=oo++}},co=e=>{e.timestamp=oo++},lo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=oo++},uo=(e,t,n)=>{if(e.length>=ao){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return lo(r,t,n),r}else{let r=new so(t,n);return e.push(r),r}},fo=(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)=>be(t-e.index)<be(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,co(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&&be(n.index-i)<r.parent.length/ao?(lo(n,r,i),n):uo(e._searchMarker,r,i)},po=(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=S(t,i.index+n))}},mo=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;g(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;aa(r._eH,n,t)},G=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=na(),this._dEH=na(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw O()}clone(){throw O()}_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){ra(this._eH,e)}observeDeep(e){ra(this._dEH,e)}unobserve(e){ia(this._eH,e)}unobserveDeep(e){ia(this._dEH,e)}toJSON(){}},ho=(e,t,n)=>{e.doc??W(),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},go=e=>{e.doc??W();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},_o=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ca(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},vo=(e,t)=>{let n=0,r=e._start;for(e.doc??W();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}},yo=(e,t)=>{let n=[];return vo(e,(r,i)=>{n.push(t(r,i,e))}),n},bo=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}}}},xo=(e,t)=>{e.doc??W();let n=fo(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}},So=(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(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ks(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(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new gs(new Uint8Array(n))),i.integrate(e,0);break;case ki:i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new xs(n)),i.integrate(e,0);break;default:if(n instanceof G)i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Vs(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Co=()=>D(`Length exceeded!`),wo=(e,t,n,r)=>{if(n>t._length)throw Co();if(n===0)return t._searchMarker&&po(t._searchMarker,n,r.length),So(e,t,null,r);let i=n,a=fo(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&&H(e,z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&po(t._searchMarker,i,r.length),So(e,t,o,r)},To=(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 So(e,t,r,n)},Eo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=fo(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&&H(e,z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&H(e,z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Co();t._searchMarker&&po(t._searchMarker,i,-a+r)},Do=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Oo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new ks([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new ks([r]);break;case Uint8Array:s=new gs(r);break;case ki:s=new xs(r);break;default:if(r instanceof G)s=new Vs(r);else throw Error(`Unexpected content type`)}new J(z(o,B(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},ko=(e,t)=>{e.doc??W();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ao=e=>{let t={};return e.doc??W(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},jo=(e,t)=>{e.doc??W();let n=e._map.get(t);return n!==void 0&&!n.deleted},Mo=(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&&Ca(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},No=e=>(e.doc??W(),pi(e._map.entries(),e=>!e[1].deleted)),Po=class extends ro{},Fo=class e extends G{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 G?e.clone():e)),t}get length(){return this.doc??W(),this._length}_callObserver(e,t){super._callObserver(e,t),mo(this,e,new Po(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):U(this.doc,n=>{wo(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):U(this.doc,t=>{To(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):U(this.doc,n=>{Eo(n,this,e,t)})}get(e){return xo(this,e)}toArray(){return go(this)}slice(e=0,t=this.length){return ho(this,e,t)}toJSON(){return this.map(e=>e instanceof G?e.toJSON():e)}map(e){return yo(this,e)}forEach(e){vo(this,e)}[Symbol.iterator](){return bo(this)}_write(e){e.writeTypeRef(Ps)}},Io=e=>new Fo,Lo=class extends ro{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ro=class e extends G{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 G?e.clone():e)}),t}_callObserver(e,t){mo(this,e,new Lo(this,e,t))}toJSON(){this.doc??W();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof G?r.toJSON():r}}),e}get size(){return[...No(this)].length}keys(){return mi(No(this),e=>e[0])}values(){return mi(No(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return mi(No(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??W(),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):U(this.doc,t=>{Do(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):U(this.doc,n=>{Oo(n,this,e,t)}),t}get(e){return ko(this,e)}has(e){return jo(this,e)}clear(){this.doc===null?this._prelimContent.clear():U(this.doc,e=>{this.forEach(function(t,n,r){Do(e,r,n)})})}_write(e){e.writeTypeRef(Fs)}},zo=e=>new Ro,Bo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&rn(e,t),Vo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&k(),this.right.content.constructor){case q:this.right.deleted||Go(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}},Ho=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case q:t.right.deleted||Go(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&H(e,z(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},Uo=(e,t,n,r)=>{let i=new Map,a=r?fo(t,n):null;return a?Ho(e,new Vo(a.p.left,a.p,a.index,i),n-a.index):Ho(e,new Vo(null,t._start,0,i),n)},Wo=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===q&&Bo(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(z(a,B(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new q(o,r));l.integrate(e,0),n.right=l,n.forward()})},Go=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Ko=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===q&&Bo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},qo=(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(!Bo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(z(a,B(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new q(s,c)),n.right.integrate(e,0),n.forward()}}return o},Jo=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Ko(n,i);let s=qo(e,t,n,i),c=r.constructor===String?new js(r):r instanceof G?new Vs(r):new Cs(r),{left:l,right:u,index:d}=n;t._searchMarker&&po(t._searchMarker,n.index,c.getLength()),u=new J(z(o,B(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(),Wo(e,t,n,s)},Yo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Ko(n,i);let s=qo(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===q));){if(!n.right.deleted)switch(n.right.content.constructor){case q:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Bo(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&&H(e,z(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
|
-
`;n.right=new J(z(o,B(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new js(i)),n.right.integrate(e,0),n.forward()}Wo(e,t,n,s)},Xo=(e,t,n,r,i)=>{let a=t,o=m();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===q){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 q:{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&&Go(i,n);break}}}t=t.right}return s},Zo=(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===q){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Qo=e=>{let t=0;return U(e.doc,n=>{let r=e._start,i=e._start,a=m(),o=h(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case q:Go(o,i.content);break;default:t+=Xo(n,r,i,a,o),a=h(o),r=i;break}i=i.right}}),t},$o=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&&Ma(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===q&&e.constructor!==K&&t.add(e.parent)})}U(n,n=>{_i(e,e.deleteSet,e=>{if(e instanceof K||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===q?t.add(r):Zo(n,e)});for(let e of t)Qo(e)})},es=(e,t,n)=>{let r=n,i=h(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Vs:case Cs:case js:n<t.right.length&&H(e,z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Xo(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&po(o._searchMarker,t.index,-r+n),t},ts=class extends ro{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=[];U(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},en(o)||(e.attributes=Xt({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Vs:case Cs: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 js: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 q:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Bo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Bo(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;Bo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Bo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Go(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}},ns=class e extends G{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??W(),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 ts(this,e,t);mo(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??W();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===js&&(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)):U(this.doc,n=>{let r=new Vo(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
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Jo(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&es(n,r,a.delete):Yo(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??W();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(Ca(s,e)||t!==void 0&&Ca(s,t))switch(s.content.constructor){case js:{let r=i.get(`ychange`);e!==void 0&&!Ca(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&&!Ca(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 Vs:case Cs:{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 q:Ca(s,e)&&(c(),Go(i,s.content));break}s=s.right}c()};return e||t?U(a,n=>{e&&wa(n,e),t&&wa(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)):U(r,r=>{let i=Uo(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Jo(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):U(r,r=>{let i=Uo(r,this,e,!n);Jo(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)):U(n,n=>{es(n,Uo(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)):U(r,r=>{let i=Uo(r,this,e,!1);i.right!==null&&Yo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):U(this.doc,t=>{Do(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):U(this.doc,n=>{Oo(n,this,e,t)})}getAttribute(e){return ko(this,e)}getAttributes(){return Ao(this)}_write(e){e.writeTypeRef(Is)}},rs=e=>new ns,is=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??W()}[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===ss||t.constructor===as)&&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})}},as=class e extends G{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 G?e.clone():e)),t}get length(){return this.doc??W(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new is(this,e)}querySelector(e){e=e.toUpperCase();let t=new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),b(new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){mo(this,e,new ls(this,t,e))}toString(){return yo(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),vo(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):U(this.doc,n=>{wo(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)U(this.doc,n=>{let r=e&&e instanceof G?e._item:e;So(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 D(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):U(this.doc,n=>{Eo(n,this,e,t)})}toArray(){return go(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return xo(this,e)}slice(e=0,t=this.length){return ho(this,e,t)}forEach(e){vo(this,e)}_write(e){e.writeTypeRef(Rs)}},os=e=>new as,ss=class e extends as{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 Qt(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof G?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):U(this.doc,t=>{Do(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):U(this.doc,n=>{Oo(n,this,e,t)})}getAttribute(e){return ko(this,e)}hasAttribute(e){return jo(this,e)}getAttributes(e){return e?Mo(this,e):Ao(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 vo(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ls),e.writeKey(this.nodeName)}},cs=e=>new ss(e.readKey()),ls=class extends ro{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)})}},us=class e extends Ro{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(zs),e.writeKey(this.hookName)}},ds=e=>new us(e.readKey()),fs=class e extends ns{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Bs)}},ps=e=>new fs,ms=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw O()}mergeWith(e){return!1}write(e,t,n){throw O()}integrate(e,t){throw O()}},hs=0,K=class extends ms{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),Da(e.doc.store,this)}write(e,t){e.writeInfo(hs),e.writeLen(this.length-t)}getMissing(e,t){return null}},gs=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 O()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},_s=e=>new gs(e.readBuf()),vs=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){Si(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}},ys=e=>new vs(e.readLen()),bs=(e,t)=>new ki({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),xs=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(bs(this.doc.guid,this.opts))}splice(e){throw O()}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}},Ss=e=>new xs(bs(e.readString(),e.readAny())),Cs=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 O()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},ws=e=>new Cs(e.readJSON()),q=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 O()}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}},Ts=e=>new q(e.readKey(),e.readJSON()),Es=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}},Ds=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 Es(n)},Os=gn(`node_env`)===`development`,ks=class e{constructor(e){this.arr=e,Os&&on(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}},As=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new ks(n)},js=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Ms=e=>new js(e.readString()),Ns=[Io,zo,rs,cs,os,ds,ps],Ps=0,Fs=1,Is=2,Ls=3,Rs=4,zs=5,Bs=6,Vs=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 O()}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}},Hs=e=>new Vs(Ns[e.readTypeRef()](e)),Us=(e,t)=>{let n=t,r=0,i;do r>0&&(n=z(n.client,n.clock+r)),i=Oa(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},Ws=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Gs=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(z(r,i+n),t,z(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=z(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},Ks=(e,t)=>he(e,e=>yi(e.deletions,t)),qs=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return H(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||qs(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=H(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:H(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:H(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||yi(r,d.right.id)||Ks(a.undoStack,d.right.id)||Ks(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=H(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=z(c,B(s,c)),ne=new J(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,Ws(ne,!0),ne.integrate(e,0),ne},J=class e extends ms{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>=B(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=B(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===oa&&this.id.client!==this.parent.client&&this.parent.clock>=B(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Aa(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=H(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===K||this.right&&this.right.constructor===K)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===oa){let e=Oa(n,this.parent);e.constructor===K?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Aa(e,e.doc.store,z(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),sa(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(sa(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Oa(e.doc.store,n.origin)))r.has(Oa(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),Da(e.doc.store,this),this.content.integrate(e,this),Fa(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new K(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:z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&sa(e.origin,this.lastId)&&this.right===e&&sa(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(),Si(e.deleteSet,this.id.client,this.id.clock,this.length),Fa(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw k();this.content.gc(e),t?ja(e,this,new K(this.id,this.length)):this.content=new vs(this.length)}write(e,t){let n=t>0?z(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=ca(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===oa?(e.writeParentInfo(!1),e.writeLeftID(t)):k();i!==null&&e.writeString(i)}this.content.write(e,t)}},Js=(e,t)=>Ys[t&31](e),Ys=[()=>{k()},ys,Ds,_s,Ms,ws,Ts,Hs,As,Ss,()=>{k()}],Xs=10,Y=class extends ms{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){k()}write(e,t){e.writeInfo(Xs),T(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Zs=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Qs=`__ $YJS$ __`;Zs[Qs]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Zs[Qs]=!0;var $s=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),ec=(e,t)=>{T(e,$s.Token),at(e,t)},tc=(e,t,n,r)=>{switch(j(e)){case $s.Token:t();break;case $s.PermissionDenied:n(Ot(e));break;case $s.Authenticated:r(Ot(e));break;default:}},nc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),rc=`\0`;function ic(e,t){return e+rc+t}function ac(e){let t=e.indexOf(rc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var oc=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 sc(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 cc(e){return new Promise(t=>setTimeout(t,e))}function lc(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 uc(e,t){let n=sc(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||lc;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 cc(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 cc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await cc(e)}return a()}var dc=Math.floor,fc=(e,t)=>e<t?e:t,pc=(e,t)=>e>t?e:t;Number.isNaN;var mc=64,hc=128,gc=1<<17,_c=1<<18,vc=1<<19,yc=1<<20,bc=1<<21,xc=1<<22,Sc=1<<23,Cc=1<<24,wc=1<<25,Tc=1<<26,Ec=1<<27,Dc=1<<28,Oc=1<<29,kc=1<<30,Ac=63,jc=127;gc-1,_c-1,vc-1,yc-1,bc-1,xc-1,Sc-1,Cc-1,wc-1,Tc-1,Ec-1,Dc-1,Oc-1,kc-1;var Mc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Nc=()=>new Set,Pc=Array.from;Array.isArray;var Fc=String.fromCharCode;String.fromCodePoint,Fc(65535);var Ic=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},Lc=typeof TextEncoder<`u`?new TextEncoder:null,Rc=Lc?e=>Lc.encode(e):Ic,zc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});zc&&zc.decode(new Uint8Array).length===1&&(zc=null);var Bc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Vc=()=>new Bc,Hc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Uc=e=>{let t=new Uint8Array(Hc(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},Wc=(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>jc;)Wc(e,hc|jc&t),t=dc(t/128);Wc(e,jc&t)},Gc=new Uint8Array(3e4),Kc=Gc.length/3,Z=Lc&&Lc.encodeInto?(e,t)=>{if(t.length<Kc){let n=Lc.encodeInto(t,Gc).written||0;X(e,n);for(let t=0;t<n;t++)Wc(e,Gc[t])}else Jc(e,Rc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)Wc(e,n.codePointAt(t))},qc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=fc(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(pc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Jc=(e,t)=>{X(e,t.byteLength),qc(e,t)},Yc=e=>Error(e),Xc=Yc(`Unexpected end of array`),Zc=Yc(`Integer out of Range`),Qc=class{constructor(e){this.arr=e,this.pos=0}},$c=e=>new Qc(e),el=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},tl=e=>el(e,rl(e)),nl=e=>e.arr[e.pos++],rl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&jc)*n,n*=128,r<hc)return t;if(t>Mc)throw Zc}throw Xc},il=e=>{let t=e.arr[e.pos++],n=t&Ac,r=64,i=(t&mc)>0?-1:1;if((t&hc)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&jc)*r,r*=128,t<hc)return i*n;if(n>Mc)throw Zc}throw Xc},al=zc?e=>zc.decode(tl(e)):e=>{let t=rl(e);if(t===0)return``;{let n=String.fromCodePoint(nl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(nl(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))}},ol=e=>{let t=e.pos,n=al(e);return e.pos=t,n},sl=Date.now,cl=()=>new Map,ll=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ul=class{constructor(){this._observers=cl()}on(e,t){ll(this._observers,e,Nc).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 Pc((this._observers.get(e)||cl()).values()).forEach(e=>e(...t))}destroy(){this._observers=cl()}},dl=Symbol(`Equality`),fl=Object.keys,pl=e=>fl(e).length,ml=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hl=(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[dl]!=null)return e[dl](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)||!hl(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(pl(e)!==pl(t))return!1;for(let n in e)if(!ml(e,n)||!hl(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(!hl(e[n],t[n]))return!1;break;default:return!1}return!0},gl=3e4,_l=class extends ul{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=sl();this.getLocalState()!==null&&gl/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&gl<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&vl(this,t,`timeout`)},dc(gl/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:sl()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),hl(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}},vl=(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:sl()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},yl=(e,t,n=e.states)=>{let r=t.length,i=Vc();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 Uc(i)},bl=(e,t,n)=>{let r=$c(t),i=sl(),a=[],o=[],s=[],c=[],l=rl(r);for(let t=0;t<l;t++){let t=rl(r),n=rl(r),l=JSON.parse(al(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&&(hl(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])},xl=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={}}},Sl=class{constructor(e){this.data=e,this.encoder=Vc(),this.decoder=$c(new Uint8Array(this.data))}peekVarString(){return ol(this.decoder)}readVarUint(){return rl(this.decoder)}readVarString(){return al(this.decoder)}readVarUint8Array(){return tl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return Jc(this.encoder,e)}length(){return Hc(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}({}),Cl=class{constructor(){this.encoder=Vc()}get(e){return e.encoder}toUint8Array(){return Uc(this.encoder)}},wl=class extends Cl{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}},Tl=class e extends xl{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(wl,{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:uc(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=sl();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new Sl(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=Vc();X(e,Q.Pong),this.send(Uc(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>=sl()-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=$c(e);return{documentName:al(t),messageType:rl(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===oc.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()}},El=0,Dl=1,Ol=2,kl=(e,t)=>{X(e,El),Jc(e,ea(t))},Al=(e,t,n)=>{X(e,Dl),Jc(e,Ji(t,n))},jl=(e,t,n)=>Al(t,n,tl(e)),Ml=(e,t,n,r)=>{try{Gi(t,tl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Nl=(e,t)=>{X(e,Ol),Jc(e,t)},Pl=Ml,Fl=(e,t,n,r,i)=>{let a=rl(e);switch(a){case El:jl(e,t,n);break;case Dl:Ml(e,n,r,i);break;case Ol:Pl(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Il=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(al(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,il(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:al(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(Cl,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=Fl(n.decoder,n.encoder,e.document,e);t&&r===Dl&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;bl(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;tc(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(yl(e.awareness,Array.from(e.awareness.getStates().keys())))}},Ll=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Uc(this.encoder)}send(e){e?.send(this.create())}},Rl=`4.0.0-rc.1`,zl=class extends Cl{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),ec(this.encoder,e.token),Z(this.encoder,Rl),this.encoder}},Bl=class extends Cl{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?yl(e.awareness,e.clients):yl(e.awareness,e.clients,e.states),Jc(this.encoder,t),this.encoder}},Vl=class extends Cl{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}},Hl=class extends Cl{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),kl(this.encoder,e.document),this.encoder}},Ul=class extends Cl{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),Nl(this.encoder,e.update),this.encoder}},Wl=class extends Error{constructor(...e){super(...e),this.code=1001}},Gl=class extends xl{get effectiveName(){return this.configuration.sessionAwareness?ic(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 ki,this.configuration.awareness=e.awareness===void 0?new _l(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:nc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:nc(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 Tl(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(Hl,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&vl(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Vl,{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(zl,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Ul,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Bl,{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(Hl,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Bl,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new Ll(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Sl(e.data),{documentName:n}=ac(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Sl(e.data)}),new Il(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&vl(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&&(vl(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 Wl(`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 Kl(e,t,n=null,r=null){let i={...ee()};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 ql(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 Jl(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 Yl(e){return Jl(e)??ql(e)}function Xl(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:Yl(e)}finally{t.remove()}}function Zl(){if(!(typeof document>`u`))try{let e=Xl(`--sidebar`),t=Xl(`--sidebar-foreground`);return!e||!t?void 0:{bg:e,symbol:t}}catch{return}}function Ql(e,t,n){let r=(0,ae.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:Zl()})}),()=>{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,oe.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:Zl()})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},s=[e],r[7]=e,r[8]=o,r[9]=s),(0,oe.useEffect)(o,s)}function $l(e){let t=(0,ae.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,oe.useEffect)(i,a)}var eu=t();function tu(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function nu(e,t,n,r){let i=new ki,a=new Gl({url:e,name:t,document:i,token:Kl(null,r,null),onDisconnect:({event:e})=>tu(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>tu(`config-provider`,t,`close`,e)}),o=s(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function ru(e,t){let n=new ki,r=new Gl({url:e,name:c,document:n,token:Kl(null,t,null),onDisconnect:({event:e})=>tu(`okignore-provider`,c,`disconnect`,e),onClose:({event:e})=>tu(`okignore-provider`,c,`close`,e)}),i=o(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function iu(e){let t=(0,ae.c)(31),{collabUrl:n,children:r}=e,i=de(),[o,s]=(0,oe.useState)(null),[c,ee]=(0,oe.useState)(null),[p,se]=(0,oe.useState)(null),[ce,le]=(0,oe.useState)(null),ue,m;t[0]!==n||t[1]!==i?(ue=()=>{if(n===null)return;let e=nu(n,d,`user`,i),t=nu(n,l,`project`,i),r=nu(n,f,`project-local`,i),a=ru(n,i);s({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),ee({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),se({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),le({binding:a.binding,synced:!1});let o=e.binding.subscribe(t=>{s(n=>n?.binding===e.binding?{...n,config:t}:n)}),c=e.binding.subscribeSynced(()=>{s(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),u=t.binding.subscribe(e=>{ee(n=>n?.binding===t.binding?{...n,config:e}:n)}),te=t.binding.subscribeSynced(()=>{ee(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),ne=r.binding.subscribe(e=>{se(t=>t?.binding===r.binding?{...t,config:e}:t)}),re=r.binding.subscribeSynced(()=>{se(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),ie=()=>{le(e=>e?.binding===a.binding?{...e,synced:!0}:e)};return a.provider.on(`synced`,ie),()=>{o(),c(),u(),te(),ne(),re(),a.provider.off(`synced`,ie);for(let n of[e,t,r,a])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}s(t=>t?.binding===e.binding?null:t),ee(e=>e?.binding===t.binding?null:e),se(e=>e?.binding===r.binding?null:e),le(e=>e?.binding===a.binding?null:e)}},m=[n,i],t[0]=n,t[1]=i,t[2]=ue,t[3]=m):(ue=t[2],m=t[3]),(0,oe.useEffect)(ue,m);let h,g,_,v,y;if(t[4]!==p?.config||t[5]!==c||t[6]!==o){v=o&&c?a(o.config,c.config,p?.config):null;let e=v?.appearance?.theme;g=v?.appearance?.colorTheme,_=v?.appearance?.customTheme,h=v?.appearance?.colorThemeEnabled!==!1,y=h?g===`custom`?te(re(_)):u(g)??e:e,t[4]=p?.config,t[5]=c,t[6]=o,t[7]=h,t[8]=g,t[9]=_,t[10]=v,t[11]=y}else h=t[7],g=t[8],_=t[9],v=t[10],y=t[11];let fe=y;$l(fe),ne(g,_,h);let pe;t[12]!==g||t[13]!==_?(pe=g===`custom`?JSON.stringify(_??null):``,t[12]=g,t[13]=_,t[14]=pe):pe=t[14],Ql(typeof window<`u`?window.okDesktop:void 0,fe??`system`,`${h?g:`default`}:${pe}`);let b=o?.binding??null,me=o?.synced??!1,he=c?.binding??null,ge=p?.binding??null,_e=ce?.binding??null,ve=ce?.synced??!1,ye=o?.config??null,x=c?.config??null,be=c?.synced??!1,xe=p?.config??null,S=p?.synced??!1,Se;t[15]!==v||t[16]!==ve||t[17]!==ye||t[18]!==x||t[19]!==be||t[20]!==xe||t[21]!==S||t[22]!==b||t[23]!==me||t[24]!==he||t[25]!==ge||t[26]!==_e?(Se={userBinding:b,userSynced:me,projectBinding:he,projectLocalBinding:ge,okignoreBinding:_e,okignoreSynced:ve,userConfig:ye,projectConfig:x,projectSynced:be,projectLocalConfig:xe,projectLocalSynced:S,merged:v},t[15]=v,t[16]=ve,t[17]=ye,t[18]=x,t[19]=be,t[20]=xe,t[21]=S,t[22]=b,t[23]=me,t[24]=he,t[25]=ge,t[26]=_e,t[27]=Se):Se=t[27];let Ce=Se,we;return t[28]!==r||t[29]!==Ce?(we=(0,eu.jsx)(ie,{value:Ce,children:r}),t[28]=r,t[29]=Ce,t[30]=we):we=t[30],we}export{S as $,yi as A,Hr as B,ga as C,ea as D,Ji as E,U as F,tn as G,Cn as H,_o as I,zt as J,Zt as K,Xr as L,_i as M,da as N,V as O,Sa as P,Fe as Q,L as R,fa as S,Xi as T,xn as U,N as V,fn as W,O as X,D as Y,k as Z,Wi as _,q as a,le as at,Ci as b,ki as c,ba as d,xe as et,Ua as f,Gi as g,fs as h,Gl as i,g as it,la as j,ca as k,J as l,ss as m,Ql as n,y as nt,js as o,ns as p,Ut as q,Kl as r,m as rt,Vs as s,iu as t,ye as tt,ua as u,ya as v,xa as w,z as x,va as y,Vr as z};
|