@inkeep/open-knowledge 0.86.4 → 0.86.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-C12h35kn.mjs +1 -0
  3. package/dist/{dist-DWJjwgfW.mjs → dist-MwpAiIp9.mjs} +1 -1
  4. package/dist/{dist-CaSGeKHK.mjs → dist-onFQ_VT3.mjs} +252 -252
  5. package/dist/index.mjs +1 -1
  6. package/dist/{init-Dn4c5P9j.mjs → init-617rYAqg.mjs} +2 -2
  7. package/dist/init-BrlE5cQ7.mjs +1 -0
  8. package/dist/{launch-json-removal-DHj5Eblo.mjs → launch-json-removal-B0sVr9Dq.mjs} +1 -1
  9. package/dist/loader-CMFLWhjj.mjs +1 -0
  10. package/dist/{loader-BZcvfwyW.mjs → loader-l9xPBxIZ.mjs} +1 -1
  11. package/dist/{open-browser-DGAzK5f6.mjs → open-browser-5JSDBckS.mjs} +1 -1
  12. package/dist/{preview-pDq0LZK_.mjs → preview-DWA5cdXy.mjs} +1 -1
  13. package/dist/preview-h4SFKpvl.mjs +1 -0
  14. package/dist/public/assets/{AccountSection-B6ThTUZo.js → AccountSection-I1lz1sc9.js} +1 -1
  15. package/dist/public/assets/{ActivityModeContent-B9sK1mPn.js → ActivityModeContent-DB438E9x.js} +1 -1
  16. package/dist/public/assets/{AddPropertiesButton-BHZjIbUr.js → AddPropertiesButton-D-fypHLd.js} +1 -1
  17. package/dist/public/assets/{AgentDiffPane-CpdjXSHR.js → AgentDiffPane-D_A8uJQS.js} +1 -1
  18. package/dist/public/assets/{AttachmentsSection-HFaKfkxN.js → AttachmentsSection-BrKHi5eH.js} +1 -1
  19. package/dist/public/assets/{CodeMirrorPropInput-BPlEVOkz.js → CodeMirrorPropInput-D58paSY8.js} +1 -1
  20. package/dist/public/assets/{ContentRulesSection-CTPZkBtQ.js → ContentRulesSection-DGbaAG4v.js} +1 -1
  21. package/dist/public/assets/{DocumentContext-DLlcgj4F.js → DocumentContext-CcWANXoG.js} +2 -2
  22. package/dist/public/assets/{EditorModeToggle-Cs1E94Wt.js → EditorModeToggle-DZEYxvsJ.js} +1 -1
  23. package/dist/public/assets/{ExcalidrawDocEditor-D3JPs1T6.js → ExcalidrawDocEditor-DGkr_Lef.js} +1 -1
  24. package/dist/public/assets/FeedbackForm-la-aIWxt.js +1 -0
  25. package/dist/public/assets/{ImportSkillDialog-BHfJhgr0.js → ImportSkillDialog-Rs7z8xYN.js} +1 -1
  26. package/dist/public/assets/{LinkPreviewsSection-29bLTyZ4.js → LinkPreviewsSection-C014Gvhp.js} +1 -1
  27. package/dist/public/assets/{LintConfigEditor-BoekpJBo.js → LintConfigEditor-CBgyxWni.js} +1 -1
  28. package/dist/public/assets/{LintingSection-Bd0OQm1u.js → LintingSection-Cz3BqJN2.js} +1 -1
  29. package/dist/public/assets/{ManagedArtifactProperties-Bo49t5RV.js → ManagedArtifactProperties-C1CmEY9Y.js} +1 -1
  30. package/dist/public/assets/ManagedArtifactProperties-Dq41bGq3.js +1 -0
  31. package/dist/public/assets/{MermaidDocEditor-BVStT6BZ.js → MermaidDocEditor-BUnHheo_.js} +1 -1
  32. package/dist/public/assets/{NetworkAccessSection-023fqlTT.js → NetworkAccessSection-BKzajG2h.js} +1 -1
  33. package/dist/public/assets/{ProjectTemplatesSection-BRi54Op6.js → ProjectTemplatesSection-CVxoKTpG.js} +1 -1
  34. package/dist/public/assets/{PropertyDisplayRow-Br4WnKCN.js → PropertyDisplayRow-Djmu8LsU.js} +1 -1
  35. package/dist/public/assets/{PublishToGitHubDialog-C78FtNAd.js → PublishToGitHubDialog-BlvDK-RM.js} +1 -1
  36. package/dist/public/assets/{SchemaConfigEditor-B7TyfhFZ.js → SchemaConfigEditor-D-Mb59fj.js} +1 -1
  37. package/dist/public/assets/{SearchSection-CMhbq1G8.js → SearchSection-DeAWEEuq.js} +1 -1
  38. package/dist/public/assets/{SessionsHost-Ce92NFeB.js → SessionsHost-_oB76At7.js} +2 -2
  39. package/dist/public/assets/{SettingsDialogBody-ClonIbus.js → SettingsDialogBody-CLSadgKv.js} +2 -2
  40. package/dist/public/assets/{ShareReceiveMissDialog-C9fGL4Db.js → ShareReceiveMissDialog-DlRoic-W.js} +1 -1
  41. package/dist/public/assets/{SkillToolbarControls-C0G7ZYIq.js → SkillToolbarControls-CkRJZZ4c.js} +1 -1
  42. package/dist/public/assets/{SlidesPluginSection-C0qcX7jg.js → SlidesPluginSection-CIIOqcY1.js} +1 -1
  43. package/dist/public/assets/{SourceEditor-PwiiAcdP.js → SourceEditor-BYP1KFew.js} +1 -1
  44. package/dist/public/assets/{SyncSection-D1DsnhKs.js → SyncSection-B_YaMj40.js} +1 -1
  45. package/dist/public/assets/{SyncStatusBadge-CLtVl3Fw.js → SyncStatusBadge-dhIJRXLW.js} +1 -1
  46. package/dist/public/assets/{TerminalSection-BYQp1uqu.js → TerminalSection-BK1FMf2X.js} +1 -1
  47. package/dist/public/assets/{TerminalWindowApp-BmdhlNVa.js → TerminalWindowApp-Biz4iZa7.js} +1 -1
  48. package/dist/public/assets/{TextDocEditor-DhNfvhU-.js → TextDocEditor-BoxS_mGH.js} +1 -1
  49. package/dist/public/assets/{ThreadView-BKF7POzO.js → ThreadView-Cbdh8y3v.js} +1 -1
  50. package/dist/public/assets/{TimelineDiffPane-DKsMDwvJ.js → TimelineDiffPane-BHm_jhSn.js} +1 -1
  51. package/dist/public/assets/{client-version-c1AS_zsU.js → client-version-MowQsqu-.js} +1 -1
  52. package/dist/public/assets/{comment-chips-CfKNCSwa.js → comment-chips-DWKaoqAT.js} +1 -1
  53. package/dist/public/assets/{config-provider-BlhLAetS.js → config-provider-BrKrF82q.js} +1 -1
  54. package/dist/public/assets/{doc-undo-manager-wPJahTpC.js → doc-undo-manager-CjU9csoN.js} +1 -1
  55. package/dist/public/assets/{index-DgLChQvq.js → index-CiXW6pc_.js} +19 -19
  56. package/dist/public/assets/{lint-plugins-TrTEKrZW.js → lint-plugins-ChHbu2xN.js} +1 -1
  57. package/dist/public/assets/{pending-receive-nav-store-CMe_s1kJ.js → pending-receive-nav-store-B19b4nv4.js} +1 -1
  58. package/dist/public/assets/{preferred-session-events-yddsxFaQ.js → preferred-session-events-Drir4ubk.js} +1 -1
  59. package/dist/public/assets/{progress-BvaSWEyq.js → progress-Baks12lW.js} +1 -1
  60. package/dist/public/assets/{selection-context-QRKI3sFf.js → selection-context-C10fxfSP.js} +1 -1
  61. package/dist/public/assets/{src-MzLcycFi.js → src-BUUGqLuJ.js} +1 -1
  62. package/dist/public/assets/{telemetry-impl-DSWZL5YU.js → telemetry-impl-DdvA9pxI.js} +1 -1
  63. package/dist/public/assets/{telemetry-startup-hqbJzUOv.js → telemetry-startup-DJExo2AL.js} +1 -1
  64. package/dist/public/assets/{typing-burst-detector-Degl_LEn.js → typing-burst-detector-uNQcBJe5.js} +1 -1
  65. package/dist/public/assets/{use-activity-panel-DD-3RGnf.js → use-activity-panel-BhM57X6v.js} +1 -1
  66. package/dist/public/assets/{use-open-skill-BVg1adZk.js → use-open-skill-DpZJd61P.js} +1 -1
  67. package/dist/public/assets/use-settings-route-Bj-m9X61.js +1 -0
  68. package/dist/public/assets/{use-terminal-enabled-Dk94suGD.js → use-terminal-enabled-BwmUwMDi.js} +1 -1
  69. package/dist/public/assets/{use-timeline-entry-diff-B40F1U_C.js → use-timeline-entry-diff-CYQHQdQ6.js} +1 -1
  70. package/dist/public/index.html +19 -19
  71. package/dist/{registry-probes-ClOwpE2Z.mjs → registry-probes-D3rS-xfY.mjs} +1 -1
  72. package/dist/{removal-file-path-CTpv-jC6.mjs → removal-file-path-f3cX9TCD.mjs} +1 -1
  73. package/dist/{repair-launch-json-CBhwQ9kI.mjs → repair-launch-json-D9adYtCD.mjs} +1 -1
  74. package/dist/{repair-mcp-configs-D6Owhuk5.mjs → repair-mcp-configs-kYoAwmn1.mjs} +1 -1
  75. package/dist/src-C-NjVbsu.mjs +1 -0
  76. package/dist/{src-D-ze6aYc.mjs → src-uYjCw8Re.mjs} +1 -1
  77. package/dist/{start-D3w5OYYR.mjs → start-BW4Dlp9v.mjs} +3 -3
  78. package/dist/start-BeZ4zbkQ.mjs +1 -0
  79. package/package.json +4 -4
  80. package/dist/constants-CcAfX64q.mjs +0 -1
  81. package/dist/init-D5UCNYQH.mjs +0 -1
  82. package/dist/loader-qht-ygP4.mjs +0 -1
  83. package/dist/preview-BH6fTSse.mjs +0 -1
  84. package/dist/public/assets/FeedbackForm-CasGs83H.js +0 -1
  85. package/dist/public/assets/ManagedArtifactProperties-CM4mf4E2.js +0 -1
  86. package/dist/public/assets/use-settings-route-CikTq5Vq.js +0 -1
  87. package/dist/src-BPwFR0fP.mjs +0 -1
  88. package/dist/start-CUOeOXvf.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1542,6 +1542,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
1542
1542
  `);re(e,o)}function M9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=A9(JSON.parse(n),t),i=n.endsWith(`
1543
1543
  `)?`
1544
1544
  `:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDirSpellings);r!==n&&re(e,r)}}function N9(e,t){let n=S(e,`utf-8`),r=k9(n,t.contentDirSpellings);r!==n&&re(e,r)}function P9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>j(e,t.name))}catch{return[]}}const zNe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function BNe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const VNe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function HNe(e){let t={contentDirSpellings:O9(e.contentDir)};for(let n of VNe)for(let r of P9(j(e.stagingDir,n)))BNe(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(j(e.stagingDir,`state`))){let e=ae(n);n.endsWith(`.jsonl`)?j9(n,t):zNe.has(e)?M9(n,t):N9(n,t)}}const I9=[`.ok`,`local`,`telemetry`],L9=[`.ok`,`local`,`logs`],R9=[`.ok`,`local`,`loss-capture`],z9=`spans-current.jsonl`,B9=`spans-prev.jsonl`,V9=`server-current.jsonl`,H9=`server-prev.jsonl`,U9=`loss-current.jsonl`,W9=`loss-prev.jsonl`;function UNe(e){return j(e,...I9,z9)}function WNe(e){return j(e,...I9,B9)}function GNe(e){return j(e,...L9,V9)}function KNe(e){return j(e,...L9,H9)}function qNe(e){return j(e,...R9,U9)}function JNe(e){return j(e,...R9,W9)}const G9=1e3;async function YNe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function XNe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function ZNe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}function QNe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1545
- `)}\n`:null}catch{return null}}function $Ne(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ePe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function tPe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function nPe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,bs.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function rPe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return rPe(e.maxBytes)}function iPe(e){let t=J9($J(`project`,e)),n=J9($J(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function aPe(e){return Me(`sha256`).update(e).digest(`hex`)}function oPe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const sPe=[`"doc.name"`,`"docName"`];function cPe(e){let t=S(e,`utf-8`),n=0;for(let e of sPe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,t7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const lPe=new Set([`.jsonl`]);function uPe(e){let t=e.lastIndexOf(`.`);return t!==-1&&lPe.has(e.slice(t))}const dPe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fPe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dPe.has(e.slice(t))}function pPe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!fPe(r))continue;let{redacted:i,patterns:a,lineCount:o}=DP(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return M(e,t).split(le).join(`/`)}async function mPe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??YNe,a=r.fetchAgentEffects??XNe,o=r.fetchWatcherRecent??ZNe,s=r.readShadowHead??$Ne,c=r.readCheckpointRefs??ePe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.86.4`),d=r.readDesktopEnv??K9,f=r.readLanguage??D9,p=r.readRuntime??tPe,h=r.isOtlpPushEnabled??nPe,_=y(j(xe(),`ok-bundle-`));try{v(j(_,`telemetry`),{recursive:!0}),v(j(_,`logs`),{recursive:!0}),v(j(_,`state`),{recursive:!0}),Z9(UNe(n),j(_,`telemetry`,z9)),Z9(WNe(n),j(_,`telemetry`,B9)),Z9(GNe(n),j(_,`logs`,V9)),Z9(KNe(n),j(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,j(_,`logs`,ae(t)));for(let t of e.userStateFiles??[])Z9(t,j(_,NJ,ae(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,j(_,`diagnostic-reports`,ae(t)))&&(y+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,j(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(j(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(j(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=QNe(n);e!==null&&re(j(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(j(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(j(_,`state`,`checkpoint-refs.txt`),D),Z9(qNe(n),j(_,`state`,U9)),Z9(JNe(n),j(_,`state`,W9)),Z9(j(b,`last-spawn-error.log`),j(_,`state`,`last-spawn-error.log`)),Z9(j(b,sd),j(_,`state`,sd)),Z9(j(b,cd),j(_,`state`,cd)),Z9(j(b,od),j(_,`state`,od));let ee=p(),ne=d(),ie=f(),k={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(j(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let oe=C===`running`?`running
1545
+ `)}\n`:null}catch{return null}}function $Ne(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ePe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function tPe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function nPe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,bs.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function rPe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return rPe(e.maxBytes)}function iPe(e){let t=J9($J(`project`,e)),n=J9($J(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function aPe(e){return Me(`sha256`).update(e).digest(`hex`)}function oPe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const sPe=[`"doc.name"`,`"docName"`];function cPe(e){let t=S(e,`utf-8`),n=0;for(let e of sPe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,t7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const lPe=new Set([`.jsonl`]);function uPe(e){let t=e.lastIndexOf(`.`);return t!==-1&&lPe.has(e.slice(t))}const dPe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fPe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dPe.has(e.slice(t))}function pPe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!fPe(r))continue;let{redacted:i,patterns:a,lineCount:o}=DP(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return M(e,t).split(le).join(`/`)}async function mPe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??YNe,a=r.fetchAgentEffects??XNe,o=r.fetchWatcherRecent??ZNe,s=r.readShadowHead??$Ne,c=r.readCheckpointRefs??ePe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.86.6`),d=r.readDesktopEnv??K9,f=r.readLanguage??D9,p=r.readRuntime??tPe,h=r.isOtlpPushEnabled??nPe,_=y(j(xe(),`ok-bundle-`));try{v(j(_,`telemetry`),{recursive:!0}),v(j(_,`logs`),{recursive:!0}),v(j(_,`state`),{recursive:!0}),Z9(UNe(n),j(_,`telemetry`,z9)),Z9(WNe(n),j(_,`telemetry`,B9)),Z9(GNe(n),j(_,`logs`,V9)),Z9(KNe(n),j(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,j(_,`logs`,ae(t)));for(let t of e.userStateFiles??[])Z9(t,j(_,NJ,ae(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,j(_,`diagnostic-reports`,ae(t)))&&(y+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,j(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(j(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(j(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=QNe(n);e!==null&&re(j(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(j(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(j(_,`state`,`checkpoint-refs.txt`),D),Z9(qNe(n),j(_,`state`,U9)),Z9(JNe(n),j(_,`state`,W9)),Z9(j(b,`last-spawn-error.log`),j(_,`state`,`last-spawn-error.log`)),Z9(j(b,sd),j(_,`state`,sd)),Z9(j(b,cd),j(_,`state`,cd)),Z9(j(b,od),j(_,`state`,od));let ee=p(),ne=d(),ie=f(),k={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(j(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let oe=C===`running`?`running
1546
1546
  `:`not-running (${w})\n`;re(j(_,`state`,`server-status.txt`),oe);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:e7(e.diagnosticReports,y);if(re(j(_,`state`,`diagnostic-reports-status.txt`),`${A}\n`),re(j(_,i7),S7(e.osTerminationEvidence)),e.processDir&&g(e.processDir)){let t=j(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let se=e.redact===!0;se&&HNe({stagingDir:_,contentDir:t}),e.note&&re(j(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=pPe(_));for(let t of e.extraFiles??[]){let e=t.zipName??ae(t.sourcePath);if(!Z9(t.sourcePath,j(_,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=w7(t,`extra/${e}`);n!==null&&(ce??={redactions:[],redactedLineCount:0},ce.redactions.push(n),ce.redactedLineCount+=n.lineCount)}let M=iPe(n),N=Q9(_),le=[],ue=0,de=0;for(let e of N){let t=$9(_,e),n=te(e).size,r=uPe(t)?oPe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=cPe(e))}let fe={applied:se};ce!==null&&(fe.secretScrub=ce);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:aPe(t),absolutePath:se?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:le};re(j(_,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let pe=O9(t),me=N.some(e=>{try{let t=S(e,`utf-8`);return pe.some(e=>t.includes(e))}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:me,redacted:se},ge=!1;return{stagingDir:_,manifest:P,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function hPe(e){let{collected:t,outputPath:n}=e,r=k(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new WEe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function gPe(e,t){let n=j(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,bs.parse)(S(n,`utf-8`)),r=yY(t)?t.content:void 0,i=yY(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return N(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return N(e)}async function _Pe(e,t,n,r,i,a){let o=T7(t,e.logger),s=await mPe({contentDir:gPe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...EMe(o,e.userLogsDir??j(KJ(),`logs`)),...D7(e.cachesDir??j(_e(),`Library`,`Caches`))],userStateFiles:O7(e.bugReportsDir??C7()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(k(e.outputPath),{recursive:!0}),await hPe({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function vPe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??D9,i=()=>nMe(e.diagnosticReportsDir??j(_e(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return _Pe(e,t,n,r,i(),await x7(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await jMe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:D7(e.cachesDir??j(_e(),`Library`,`Caches`)),bugReportLedgerFiles:O7(e.bugReportsDir??C7()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await x7(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}export{EY as ALL_EDITOR_IDS,DY as EDITOR_LABELS,rX as EDITOR_TARGETS,Zye as HOSTS_WITH_USER_SKILL_DIR,Wje as LAUNCH_CONFIG_NAME,xNe as PATH_SHIM_BEGIN,CNe as PATH_SHIM_BLOCK_RE,SNe as PATH_SHIM_END,m5 as ProjectPathSafetyError,Sje as addOkPathsToGitExclude,h5 as assertProjectPathSafe,zY as buildManagedServerEntry,uNe as buildMcpConfigDeclineEvent,dNe as buildMcpConfigMigrateEvent,Z5 as classifyExistingMcpEntry,vPe as collectReportBundle,ONe as createCliProbeResolver,aY as createTokenStore,CMe as defaultBugReportZipPath,Ke as detectGh,Ye as detectGhAccounts,Jje as detectInstalledEditors,JY as droppedManagedKeys,vbe as editorConfigPathDisplay,_be as editorEntryLocator,$Me as ensurePiBridge,cMe as findJetsamKillSync,k5 as formatTrackedRemediation,Tje as getExcludedOkPaths,D5 as getInstalledSkillProjectionPaths,Xye as getNativeTomlMcpEditor,E5 as getOkArtifactPaths,LY as isEntryUpToDate,BY as isOwnManagedEntry,vNe as loadConfig,Sye as makeLazyProbeTokenStore,C7 as okBugReportsDir,y9 as parseGitHubBlobUrl,yNe as parseGitHubShareUrl,b9 as parseGitHubTreeUrl,v9 as parseGitUrl,wNe as pathInstallMarkerPath,sje as previewContent,Yje as probeOwnManagedEditorMcpEntry,ZMe as probePiBridgeState,O5 as probeTrackedOkPaths,Y5 as readExistingMcpEntry,wje as readSharingMode,DP as redactContent,Cje as removeOkPathsFromGitExclude,oNe as removeOwnMcpEntry,vje as removeProjectSkill,ANe as removeUserGlobalSkillBundle,INe as removeUserSkill,fje as resolveProjectRoot,hNe as runStop,m9 as truncatePriorEntry,T9 as userGlobalSkillBundleTargets,FNe as userSkillPresentAnywhere,bNe as validateLocalFolderForShare,J5 as writeEditorMcpConfig,NNe as writeProjectAiIntegrations,x5 as writeProjectSkill,qje as writeUserMcpConfigs,PNe as writeUserSkill};
1547
1547
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{B as r,Ba as i,Cf as a,Df as o,G as s,Hc as c,R as l,Sf as u,_ as d,_f as f,a as p,af as m,bf as h,cf as g,df as _,et as v,ff as y,gf as b,if as x,pc as S,pd as ee,qu as te,rf as ne,sf as re,ud as ie,yf as C,za as ae}from"./md-manager-BGnqyqi1-CMF2qMhD.mjs";import{Aa as oe,At as se,F as ce,Fr as le,Go as w,Jo as ue,Ko as de,Mo as fe,Po as pe,R as me,U as he,Vi as ge,Vr as _e,Yo as ve,Yr as ye,Zn as be,_a as xe,ci as Se,di as Ce,dn as we,es as T,fa as Te,ir as Ee,it as De,ko as Oe,m as ke,ot as Ae,pa as je,ps as Me,qo as Ne,qr as Pe,ss as Fe,z as Ie}from"./dist-CaSGeKHK.mjs";import{i as E,n as D,o as O,r as Le,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Re}from"./constants-CcAfX64q.mjs";import{t as ze}from"./preview-pDq0LZK_.mjs";import{createRequire as Be}from"node:module";import{execFileSync as Ve}from"node:child_process";import He,{basename as Ue,dirname as M,isAbsolute as We,join as N,posix as Ge,relative as P,resolve as F,sep as I,win32 as Ke}from"node:path";import L from"node:process";import{fileURLToPath as qe}from"node:url";import{cpSync as Je,existsSync as R,lstatSync as Ye,mkdirSync as Xe,readFileSync as z,readdirSync as Ze,readlinkSync as Qe,realpathSync as $e,rmSync as et,statSync as tt,writeFileSync as nt}from"node:fs";import{homedir as B}from"node:os";import{inspect as rt,stripVTControlCharacters as it,styleText as V}from"node:util";import*as at from"node:readline";import{AsyncLocalStorage as ot,AsyncResource as st}from"node:async_hooks";var ct=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),lt=n((e=>{let{InvalidArgumentError:t}=ct();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ut=n((e=>{let{humanReadableArgName:t}=lt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{B as r,Ba as i,Cf as a,Df as o,G as s,Hc as c,R as l,Sf as u,_ as d,_f as f,a as p,af as m,bf as h,cf as g,df as _,et as v,ff as y,gf as b,if as x,pc as S,pd as ee,qu as te,rf as ne,sf as re,ud as ie,yf as C,za as ae}from"./md-manager-BGnqyqi1-CMF2qMhD.mjs";import{Aa as oe,At as se,F as ce,Fr as le,Go as w,Jo as ue,Ko as de,Mo as fe,Po as pe,R as me,U as he,Vi as ge,Vr as _e,Yo as ve,Yr as ye,Zn as be,_a as xe,ci as Se,di as Ce,dn as we,es as T,fa as Te,ir as Ee,it as De,ko as Oe,m as ke,ot as Ae,pa as je,ps as Me,qo as Ne,qr as Pe,ss as Fe,z as Ie}from"./dist-onFQ_VT3.mjs";import{i as E,n as D,o as O,r as Le,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Re}from"./constants-C12h35kn.mjs";import{t as ze}from"./preview-DWA5cdXy.mjs";import{createRequire as Be}from"node:module";import{execFileSync as Ve}from"node:child_process";import He,{basename as Ue,dirname as M,isAbsolute as We,join as N,posix as Ge,relative as P,resolve as F,sep as I,win32 as Ke}from"node:path";import L from"node:process";import{fileURLToPath as qe}from"node:url";import{cpSync as Je,existsSync as R,lstatSync as Ye,mkdirSync as Xe,readFileSync as z,readdirSync as Ze,readlinkSync as Qe,realpathSync as $e,rmSync as et,statSync as tt,writeFileSync as nt}from"node:fs";import{homedir as B}from"node:os";import{inspect as rt,stripVTControlCharacters as it,styleText as V}from"node:util";import*as at from"node:readline";import{AsyncLocalStorage as ot,AsyncResource as st}from"node:async_hooks";var ct=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),lt=n((e=>{let{InvalidArgumentError:t}=ct();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ut=n((e=>{let{humanReadableArgName:t}=lt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),dt=n((e=>{let{InvalidArgumentError:t}=ct();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -689,5 +689,5 @@ export default function okBridge(pi: {
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&T(e,g,{mode:Ia(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const ko=e=>e!==`project`,Ao=e=>e!==`user`;async function jo(){let e=await Ga({message:`Where should the MCP server be configured?
690
690
  `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Mo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??jo)():`both`}async function No(e){return Xa({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Po(e){if(e.sharing!==void 0)return e.sharing;let t=aa(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??No)(t):t}var Fo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Io(e){if(e===void 0||e===!0)return new Set(De);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(se.filter(e=>t.includes(e)))}function Lo(e,t,n){let r=F(n,e),i;try{i=tt(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Fo(`--content-dir path does not exist: ${r}`):new Fo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Fo(`--content-dir must be a directory: ${r}`);let a=Ro(t),o=Ro(r),s=P(a,o);if(s.startsWith(`..`)||We(s))throw new Fo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Ro(e){try{return $e(e)}catch{return e}}const zo=`open-knowledge-ui`;function Bo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function Vo(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function Ho(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Vo(e,t,r);if(!i&&c&&!Bo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{ya(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Wo(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||Xe(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{Fe(`${o}.lock`,()=>{let t=co(o).writePath;if(s||Xe(M(t),{recursive:!0}),e.format===`toml`){let r=To(ti(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Oo(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=wo(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Uo={pi:eo};function Wo(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Uo[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{Xe(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{Fe(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Ia(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function Go(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Ko(e){let t=Qi(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>Ho(t,``,n,e.home))}function qo(e,t,n,r){let i=Yo(e,t,n,r);return i.kind===`present`?i.entry:null}function Jo(e,t,n,r){let i=Co(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Yo(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(tt(i).size>_o)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ma(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ma(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:$a(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ti().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Jo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Hr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Jo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=fo(a);return s?po(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Jo(de(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Xo(e={}){let t=F(e.cwd??process.cwd()),n=ro(t,{homeDir:e.home}),r=n.projectRoot;if(ye(r,e.home??B()))throw new he(r);if(Pe(r))throw new ce(r);let a=!R(N(r,`.ok`)),o=n.gitRootPromoted?P(r,t):void 0,s=e.contentDir===void 0?n.defaultContentDir:Lo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&a&&s===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${o}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${o} in .ok/config.yml.\n`);let c={mode:e.devMcp?`dev`:`published`},l=await Ee(r),u;try{u=le(r,{contentDir:s})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(Re),f=!1;if(l.didInit)try{f=pe(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{Te(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await Mo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??ns(r,e.home),h=e.editors??m,g=Qi(m),_=Qi(h),v=e.mcp===!1||p===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Bo(t,r,e.home)),x=[],S=[],ee=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(ko(p)&&g.includes(t)&&t.scope===`global`&&x.push(Ho(t,r,c,e.home)),Ao(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Ho(t,r,c,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&ee.add(n)}}let te=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||te.has(n)||(te.add(n),S.push(Aa(t,r,{home:e.home})))}let ne=ka(r,_.map(e=>e.id));ne&&S.push(ne);let re=S.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(re.length>0){let t=e.home??B();je({source:i,skills:[ke.project],agents:re,scope:r},{home:t,enabled:oe(t).enabled})}let ie=!v&&p!==null&&Ao(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,C=v?[]:b.map(e=>Go(e,r)).filter(e=>e!==void 0).filter(e=>!ee.has(e.path)),ae=e.installUserSkill??_e,w=e.home??B(),ue=Io(e.skills),de=typeof e.skills!=`string`,me=!1,ve=!1,xe=!1,Se=!1,we=!1,T=!1,De=!1,Oe=[];for(let t of se){if(!ue.has(t))continue;if(me=!0,de){let e=await ge(w,ke[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){Oe.push({bundleId:t,result:`decision-read-failed`}),De=!0;continue}if(e.value===!1){Oe.push({bundleId:t,result:`opted-out`}),T=!0;continue}}await fe(w,ke[t],!0).catch(()=>{});let n=await ae({home:e.home,bundleId:t,force:!0});Oe.push({bundleId:t,result:n}),n===`installed`?ve=!0:n===`failed`?xe=!0:n===`no-hosts`?we=!0:Se=!0}let Ae=xe?`failed`:De?`decision-read-failed`:ve?`installed`:me&&Se?`skip-current`:me&&we?`no-hosts`:T?`opted-out`:`declined`,Me=ve?be(w).map(e=>e.editorId):[],Ne=oe(w).enabled&&!Ce(),Fe=v?`skipped-flag`:`skipped-missing`,Ie=x.find(e=>e.editorId===`claude`)??x[0]??{action:Fe,configPath:$.claude.configPath(r,e.home)},E=await Zo({projectRoot:r,desiredMode:await Po({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:a,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:x,projectSkills:S,legacyProjectConfigs:C,skillInstall:Ae,skillBundles:Oe,skillsRequested:e.skills,skillHosts:Me,skillInstallsCounted:Ne,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDir:d?s:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ie.action,mcpPath:Ie.configPath,mcpError:`error`in Ie?Ie.error:void 0,projectScopeUnsupportedLabels:ie,sharing:E}}async function Zo(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=aa(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ta(t);if(n===`local-only`){let e=ra(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Qo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=ia(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Qo(t,o,`remove`)}function Qo(e,t,n){let r=aa(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function $o(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function es(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let l=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${l}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${l}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===a()?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,s=`${r.label}${o}`,c=` `.repeat(Math.max(1,20-s.length)),l=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${s}${c}${e} ${O(`registered`)}${i}${l}`);break;case`overwritten`:n.push(` ${s}${c}${e} ${O(`updated`)}${i}${l}`);break;case`skipped-missing`:n.push(` ${s}${c}${e} config root missing; skipped`);break;case`failed`:n.push(` ${s}${c}${e} ${Le(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${s}${c}${e} left unchanged (${$o(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${Le(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${se.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>ke[e.bundleId].length));for(let i of t){let t=ke[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${D(`not installed — turned off on this machine; reinstall with ok init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${k(`${t} not installed — could not read whether it is turned off on this machine; rerun ok init once ${c(d)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ok repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(ze(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...as(e.sharing,t));let u=e=>[`${e}- ${E(`ok seed --list-packs`)} — browse the starter packs`,`${e}- ${E(`ok seed`)} — scaffold an empty repo`];if(r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${E(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `)));return n.join(`
691
691
  `)}function ts(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function ns(e,t){let n=[];for(let r of ri)r!==`claude-desktop`&&Bo($[r],e,t)&&n.push(r);return n}function rs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:rt(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function is(){return new xt(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ct(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ct(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ct(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?rs():null;try{let r;try{r=await Xo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Fo||e instanceof he||e instanceof ce){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof me||e instanceof Ie){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof Ae){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
692
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-qht-ygP4.mjs`),{resolveContentDir:s}=await import(`./dist-DWJjwgfW.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-BH6fTSse.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ts(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${es(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function as(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
692
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-CMFLWhjj.mjs`),{resolveContentDir:s}=await import(`./dist-MwpAiIp9.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-h4SFKpvl.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ts(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${es(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function as(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
693
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${E(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${E(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${E(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Mi as $,La as A,ra as B,ro as C,xt as Ct,Ga as D,Xa as E,ya as F,sa as G,oa as H,ba as I,ri as J,aa as K,ja as L,Ma as M,va as N,Ia as O,Sa as P,Z as Q,Ca as R,co as S,Nt as St,Qa as T,Ct as Tt,na as U,da as V,ta as W,$ as X,X as Y,ii as Z,Xo as _,er as _t,ts as a,Fi as at,Ko as b,on as bt,es as c,qi as ct,Bo as d,ti as dt,ji as et,qo as f,Y as ft,Po as g,dr as gt,Lo as h,qr as ht,Zo as i,_i as it,Na as j,Fa as k,as as l,xi as lt,Mo as m,Wr as mt,zo as n,Pi as nt,Yo as o,Q as ot,Io as p,Gr as pt,ia as q,Uo as r,mi as rt,ns as s,Ii as st,Fo as t,Ni as tt,is as u,ni as ut,xo as v,un as vt,eo as w,yt as wt,Vo as x,U as xt,Ho as y,sn as yt,Aa as z};
@@ -0,0 +1 @@
1
+ import"./dist-onFQ_VT3.mjs";import{_ as e}from"./init-617rYAqg.mjs";export{e as runInit};
@@ -1 +1 @@
1
- import{Ko as e,Yo as t,es as n}from"./dist-CaSGeKHK.mjs";import{A as r,M as i,O as a}from"./init-Dn4c5P9j.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-CTpv-jC6.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=t(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=e(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(n(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
1
+ import{Ko as e,Yo as t,es as n}from"./dist-onFQ_VT3.mjs";import{A as r,M as i,O as a}from"./init-617rYAqg.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-f3cX9TCD.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=t(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=e(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(n(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-l9xPBxIZ.mjs";export{e as loadConfig};
@@ -1 +1 @@
1
- import{Ac as e,O as t,Oc as n,Qc as r,Xc as i,nl as a,qu as o}from"./md-manager-BGnqyqi1-CMF2qMhD.mjs";import{as as s,rs as c,x as l}from"./dist-CaSGeKHK.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CcAfX64q.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=r({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...i,source:e}}return i})}function b(r){let o=r??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let o=i({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...o),u.push(e);let s=o.length>0?a(r.value):r.value;return n&&h.push(...t({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=n(_.value,S,C),T=l.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
1
+ import{Ac as e,O as t,Oc as n,Qc as r,Xc as i,nl as a,qu as o}from"./md-manager-BGnqyqi1-CMF2qMhD.mjs";import{as as s,rs as c,x as l}from"./dist-onFQ_VT3.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-C12h35kn.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=r({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...i,source:e}}return i})}function b(r){let o=r??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let o=i({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...o),u.push(e);let s=o.length>0?a(r.value):r.value;return n&&h.push(...t({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=n(_.value,S,C),T=l.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
@@ -1 +1 @@
1
- import{ko as e}from"./dist-CaSGeKHK.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
1
+ import{ko as e}from"./dist-onFQ_VT3.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
@@ -1,2 +1,2 @@
1
- import{Mn as e}from"./dist-CaSGeKHK.mjs";import"./constants-CcAfX64q.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);a.push(``);let c=t(i,`.ok`,`config.yml`);return r(c)?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
1
+ import{Mn as e}from"./dist-onFQ_VT3.mjs";import"./constants-C12h35kn.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);a.push(``);let c=t(i,`.ok`,`config.yml`);return r(c)?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
2
2
  `)}export{c as n,l as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-DWA5cdXy.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +1 @@
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,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./label-CvMpFFbN.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./config-errors-tVoeK4OC.js";import{n as l,r as u}from"./constants-github-B7yhDvQc.js";import{f as d,l as f}from"./SyncStatusBadge-CLtVl3Fw.js";import{t as p}from"./trash-2-CchZ0T47.js";import{t as m}from"./input-C-Qm8YDT.js";import{t as h}from"./use-git-sync-status-bHfYCMeV.js";import{a as g,n as _,t as v}from"./AuthModal-CaYJDCrL.js";import{t as y}from"./skeleton-Dk1iOPND.js";import{n as b}from"./auth-state-cache-yidtz6gx.js";import{t as x}from"./SettingsSectionHeader-DBUjTOcT.js";var S=e(n(),1),C=a(),w=`[a-z0-9](?:[a-z0-9-]*[a-z0-9])?`,T=RegExp(`^${w}(?:\\.${w})*$`),E=/^[a-z][a-z0-9+.-]*:\/\//i;function D(e){if(E.test(e))try{return new URL(e).host}catch{return null}let t=e.split(`/`)[0]??``;return t.slice(t.lastIndexOf(`@`)+1).replace(/:(?!\d+$).*$/,``)}function O(e,t){let n=e.trim();if(n===``)return{ok:!1,reason:`empty`};let r=D(n);if(r===null||r===``)return{ok:!1,reason:`invalid`};let i=u(r);return T.test(i)?i===`github.com`?{ok:!1,reason:`github-com`}:t.has(i)?{ok:!1,reason:`duplicate`}:{ok:!0,host:i}:{ok:!1,reason:`invalid`}}function k(e){let t=e.git?.hosts??{};return Object.entries(t).filter(([,e])=>e?.provider===`github`).map(([e])=>e).sort((e,t)=>e.localeCompare(t))}var A=t();function j(e){let t=(0,C.c)(59),{binding:n}=e,{_:a}=i(),o=(0,S.useId)(),l=(0,S.useId)(),u;t[0]===n?u=t[1]:(u=()=>k(n.current()),t[0]=n,t[1]=u);let[d,f]=(0,S.useState)(u),[h,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(!1),[x,w]=(0,S.useState)(null),T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Map,t[2]=T):T=t[2];let E=(0,S.useRef)(T),D=(0,S.useRef)(null),j,M;t[3]===x?(j=t[4],M=t[5]):(j=()=>{x!==null&&(((x.host===null?null:E.current.get(x.host))??D.current)?.focus(),w(null))},M=[x],t[3]=x,t[4]=j,t[5]=M),(0,S.useEffect)(j,M);let te,N;t[6]===n?(te=t[7],N=t[8]):(te=()=>n.subscribe(e=>f(k(e))),N=[n],t[6]=n,t[7]=te,t[8]=N),(0,S.useEffect)(te,N);let ne;t[9]===a?ne=t[10]:(ne=function(e){switch(e){case`empty`:return a({id:`cFONFy`});case`invalid`:return a({id:`QsnBxE`});case`github-com`:return a({id:`UK3GW4`});case`duplicate`:return a({id:`DEkRZA`})}},t[9]=a,t[10]=ne);let P=ne,F;t[11]!==n||t[12]!==h||t[13]!==d||t[14]!==P?(F=function(e){e.preventDefault();let t=O(h,new Set(d.map(ee)));if(!t.ok){v(P(t.reason));return}let r=n.patch({git:{hosts:{[t.host]:{provider:`github`}}}});if(!r.ok){v(c(r.error));return}f(k(r.effective)),g(``),v(null),b(!0)},t[11]=n,t[12]=h,t[13]=d,t[14]=P,t[15]=F):F=t[15];let I=F,L;t[16]!==n||t[17]!==d?(L=function(e){let t=d.indexOf(e),r=d[t+1]??d[t-1]??null,i=n.patch({git:{hosts:{[e]:null}}});if(!i.ok){v(c(i.error));return}f(k(i.effective)),w({host:r}),v(null),b(!0)},t[16]=n,t[17]=d,t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(`h4`,{id:`settings-enterprise-hosts-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`J2-D_a`})}),t[19]=z):z=t[19];let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,A.jsx)(r,{id:`PgY2nN`}),t[20]=B):B=t[20];let V;t[21]===o?V=t[22]:(V=(0,A.jsxs)(`div`,{children:[z,(0,A.jsx)(`p`,{id:o,className:`text-1sm text-muted-foreground`,children:B})]}),t[21]=o,t[22]=V);let H;t[23]!==a||t[24]!==R||t[25]!==d?(H=d.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,"data-testid":`settings-enterprise-hosts-list`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,A.jsx)(s,{variant:`ghost`,size:`icon`,className:`size-7`,"aria-label":a({id:`xVMoYb`,values:{host:e}}),ref:t=>{t?E.current.set(e,t):E.current.delete(e)},onClick:()=>R(e),children:(0,A.jsx)(p,{"aria-hidden":`true`})})]},e))}):(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-enterprise-hosts-empty`,children:(0,A.jsx)(r,{id:`HK2eIK`})}),t[23]=a,t[24]=R,t[25]=d,t[26]=H):H=t[26];let U;t[27]===a?U=t[28]:(U=a({id:`Qbf7Q4`}),t[27]=a,t[28]=U);let W=_!==null,G=_===null?o:`${o} ${l}`,K;t[29]===_?K=t[30]:(K=e=>{g(e.target.value),_!==null&&v(null)},t[29]=_,t[30]=K);let q;t[31]!==h||t[32]!==U||t[33]!==W||t[34]!==G||t[35]!==K?(q=(0,A.jsx)(m,{ref:D,value:h,"aria-label":U,placeholder:`github.example.com`,autoComplete:`off`,spellCheck:!1,inputMode:`url`,className:`h-7 flex-1 font-mono text-xs`,"aria-invalid":W,"aria-describedby":G,onChange:K}),t[31]=h,t[32]=U,t[33]=W,t[34]=G,t[35]=K,t[36]=q):q=t[36];let re;t[37]===h?re=t[38]:(re=h.trim(),t[37]=h,t[38]=re);let ie=re===``,J;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsx)(r,{id:`ALFlyF`}),t[39]=J):J=t[39];let Y;t[40]===ie?Y=t[41]:(Y=(0,A.jsx)(s,{type:`submit`,size:`sm`,variant:`secondary`,disabled:ie,className:`h-7 px-2 font-normal text-xs`,children:J}),t[40]=ie,t[41]=Y);let X;t[42]!==I||t[43]!==q||t[44]!==Y?(X=(0,A.jsxs)(`form`,{className:`flex items-center gap-2 pt-1`,onSubmit:I,noValidate:!0,children:[q,Y]}),t[42]=I,t[43]=q,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==_||t[47]!==l?(Z=_===null?null:(0,A.jsx)(`p`,{id:l,role:`alert`,className:`text-1sm text-destructive`,children:_}),t[46]=_,t[47]=l,t[48]=Z):Z=t[48];let Q;t[49]===y?Q=t[50]:(Q=y?(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`3LuFP-`})}):null,t[49]=y,t[50]=Q);let $;t[51]!==H||t[52]!==X||t[53]!==Z||t[54]!==Q?($=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border bg-card p-3`,children:[H,X,Z,Q]}),t[51]=H,t[52]=X,t[53]=Z,t[54]=Q,t[55]=$):$=t[55];let ae;return t[56]!==V||t[57]!==$?(ae=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-enterprise-hosts-title`,className:`space-y-4`,"data-field":`section:enterprise-hosts`,"data-testid":`settings-enterprise-hosts`,children:[V,$]}),t[56]=V,t[57]=$,t[58]=ae):ae=t[58],ae}function ee(e){return u(e)}function M(e){let t=(0,C.c)(43),{authQueryTransport:n,authTransport:a,userBinding:o}=e,{_:s}=i(),c;t[0]===n?c=t[1]:(c=n??g(),t[0]=n,t[1]=c);let l=c,u=h()?.remote??null,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={phase:`loading`},t[2]=d):d=t[2];let[f,p]=(0,S.useState)(d),[m,_]=(0,S.useState)(!1),[y,w]=(0,S.useState)(!1),[T,E]=(0,S.useState)(null),D=(0,S.useRef)(!1),O;t[3]===l?O=t[4]:(O=async function(){p({phase:`loading`});try{let e=await l.status();p({phase:`loaded`,result:e}),b(e)}catch(e){console.warn(`[AccountSection] GitHub status check failed`,e),p({phase:`check-failed`})}},t[3]=l,t[4]=O);let k=O,ee;t[5]===k?ee=t[6]:(ee=()=>{k()},t[5]=k,t[6]=ee);let M;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(M=[],t[7]=M):M=t[7],(0,S.useEffect)(ee,M);let N;t[8]!==s||t[9]!==k||t[10]!==l?(N=async function(){if(D.current)return;D.current=!0,_(!1),w(!0),E(null);let e=null;try{let t=l.signout?await l.signout():{ok:!1,error:s({id:`8cpOa8`})};t.ok||(e=t.error??s({id:`8cpOa8`}))}catch(t){console.warn(`[AccountSection] GitHub disconnect failed`,t),e=s({id:`8cpOa8`})}await k(),e&&E(e),w(!1),D.current=!1},t[8]=s,t[9]=k,t[10]=l,t[11]=N):N=t[11];let ne=N,P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,A.jsx)(r,{id:`MpZRQy`}),t[12]=P):P=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,A.jsx)(x,{titleId:`settings-account-title`,title:P,scope:`user`,children:(0,A.jsx)(r,{id:`pd6t3G`})}),t[13]=I):I=t[13];let L;t[14]!==T||t[15]!==y||t[16]!==ne||t[17]!==k||t[18]!==f?(L=f.phase===`loaded`&&f.result.unsupportedOrigin!==void 0?null:(0,A.jsxs)(`section`,{"aria-labelledby":`settings-github-account-title`,className:`space-y-4`,"data-field":`section:github-account`,children:[(0,A.jsx)(`h4`,{id:`settings-github-account-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`RkXlPZ`})}),(0,A.jsx)(te,{status:f,disconnecting:y,disconnectError:T,onRetry:()=>void k(),onConnect:()=>_(!0),onDisconnect:()=>void ne()})]}),t[14]=T,t[15]=y,t[16]=ne,t[17]=k,t[18]=f,t[19]=L):L=t[19];let R;t[20]===o?R=t[21]:(R=(0,A.jsx)(j,{binding:o}),t[20]=o,t[21]=R);let z;t[22]!==a||t[23]!==u?(z=(0,A.jsx)(F,{authTransport:a,remote:u}),t[22]=a,t[23]=u,t[24]=z):z=t[24];let B;t[25]!==R||t[26]!==z||t[27]!==L?(B=(0,A.jsxs)(`div`,{className:`space-y-8`,children:[L,R,z]}),t[25]=R,t[26]=z,t[27]=L,t[28]=B):B=t[28];let V;t[29]===k?V=t[30]:(V=e=>{_(e),e||k()},t[29]=k,t[30]=V);let H=f.phase===`loaded`?f.result.host:void 0,U=f.phase===`loaded`?f.result.ghAvailable:void 0,W;t[31]===k?W=t[32]:(W=()=>{k()},t[31]=k,t[32]=W);let G;t[33]!==m||t[34]!==a||t[35]!==V||t[36]!==H||t[37]!==U||t[38]!==W?(G=(0,A.jsx)(v,{open:m,onOpenChange:V,transport:a,host:H,ghAvailable:U,onSuccess:W}),t[33]=m,t[34]=a,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G):G=t[39];let K;return t[40]!==B||t[41]!==G?(K=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-account-title`,className:`space-y-5`,"data-testid":`settings-account`,children:[I,B,G]}),t[40]=B,t[41]=G,t[42]=K):K=t[42],K}function te(e){let t=(0,C.c)(8),{status:n,disconnecting:i,disconnectError:a,onRetry:o,onConnect:c,onDisconnect:l}=e,u;return t[0]!==a||t[1]!==i||t[2]!==c||t[3]!==l||t[4]!==o||t[5]!==n.phase||t[6]!==n.result?(u=n.phase===`loading`?(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-loading`,children:[(0,A.jsx)(`span`,{className:`sr-only`,children:(0,A.jsx)(r,{id:`IWGfGF`})}),(0,A.jsx)(y,{className:`h-4 w-40`}),(0,A.jsx)(y,{className:`h-8 w-32`})]}):n.phase===`check-failed`?(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-check-failed`,children:[(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`T_wG4n`})}),(0,A.jsx)(s,{variant:`outline`,size:`sm`,onClick:o,children:(0,A.jsx)(r,{id:`KDw4GX`})})]}):n.result.authenticated?n.result.tier===`A`?(0,A.jsx)(L,{login:n.result.login,host:n.result.host}):(0,A.jsx)(I,{login:n.result.login,host:n.result.host,disconnecting:i,error:a,onDisconnect:l}):(0,A.jsx)(R,{onConnect:c}),t[0]=a,t[1]=i,t[2]=c,t[3]=l,t[4]=o,t[5]=n.phase,t[6]=n.result,t[7]=u):u=t[7],u}function N(e){let t=e.split(`/`)[0]??``;return l(t)?t:``}function ne(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a={login:n,host:i},t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={0:(0,A.jsx)(`code`,{translate:`no`})},t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-success`,children:(0,A.jsx)(r,{id:`4p8Baj`,values:a,components:o})}),t[4]=a,t[5]=s),s}var P={"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`};function F(e){let t=(0,C.c)(89),{authTransport:n,remote:a}=e,{_:c}=i(),u;t[0]===n?u=t[1]:(u=n??_(),t[0]=n,t[1]=u);let p=u,h=a?.label??null,g;t[2]===a?g=t[3]:(g=a?f(a):!1,t[2]=a,t[3]=g);let v=g,y;t[4]===a?y=t[5]:(y=d(a),t[4]=a,t[5]=y);let b=y,x=(0,S.useId)(),w=(0,S.useId)(),T=(0,S.useId)(),E=(0,S.useId)(),D=(0,S.useId)(),[O,k]=(0,S.useState)(``),[j,ee]=(0,S.useState)(``),[M,te]=(0,S.useState)(``),[F,I]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),U=(0,S.useRef)(!1),W=(0,S.useRef)(!1),G,K;t[6]!==v||t[7]!==h||t[8]!==b?(G=()=>{if(W.current||h===null||v||!b)return;let e=N(h);e&&(W.current=!0,k(e))},K=[h,v,b],t[6]=v,t[7]=h,t[8]=b,t[9]=G,t[10]=K):(G=t[9],K=t[10]),(0,S.useEffect)(G,K);let q;t[11]!==c||t[12]!==O||t[13]!==p||t[14]!==M||t[15]!==j?(q=async function(){if(U.current)return;let e=O.trim(),t=j.trim(),n=M.trim();if(!e||!t||!n)return;if(!l(e)){H(null),B(!0),R(c({id:`rZFxkH`}));return}if(B(!1),!p.hostToken){R(c({id:`iMYFJM`}));return}U.current=!0,I(!0),R(null),H(null);let r=await p.hostToken(e,t,n).catch(e=>(console.warn(`[AccountSection] storing a host token failed`,e),{ok:!1,login:void 0,error:c({id:`Q5fqMz`})}));I(!1),U.current=!1,r.ok?(te(``),H({login:r.login||t,host:e})):R(r.error??c({id:`sNeKjP`}))},t[11]=c,t[12]=O,t[13]=p,t[14]=M,t[15]=j,t[16]=q):q=t[16];let re=q,ie;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,A.jsx)(`h4`,{id:`settings-host-tokens-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`jbhCDS`})}),t[17]=ie):ie=t[17];let J;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsxs)(`div`,{children:[ie,(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`-nA68n`})})]}),t[18]=J):J=t[18];let Y;t[19]===re?Y=t[20]:(Y=e=>{e.preventDefault(),re()},t[19]=re,t[20]=Y);let X;t[21]!==v||t[22]!==h||t[23]!==b?(X=h!==null&&!v&&!b?(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-not-https`,children:(0,A.jsx)(r,{id:`OWs-8P`})}):null,t[21]=v,t[22]=h,t[23]=b,t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,A.jsx)(r,{id:`Ai2U7L`}),t[25]=Z):Z=t[25];let Q;t[26]===x?Q=t[27]:(Q=(0,A.jsx)(o,{htmlFor:x,children:Z}),t[26]=x,t[27]=Q);let $=z||void 0,ae=z&&L?w:void 0,oe;t[28]===z?oe=t[29]:(oe=e=>{W.current=!0,k(e.target.value),z&&(B(!1),R(null))},t[28]=z,t[29]=oe);let se;t[30]!==O||t[31]!==x||t[32]!==$||t[33]!==ae||t[34]!==oe?(se=(0,A.jsx)(m,{id:x,type:`text`,placeholder:`git.example.com`,autoComplete:`off`,...P,"aria-invalid":$,"aria-describedby":ae,value:O,onChange:oe}),t[30]=O,t[31]=x,t[32]=$,t[33]=ae,t[34]=oe,t[35]=se):se=t[35];let ce;t[36]!==Q||t[37]!==se?(ce=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[Q,se]}),t[36]=Q,t[37]=se,t[38]=ce):ce=t[38];let le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,A.jsx)(r,{id:`7sNhEz`}),t[39]=le):le=t[39];let ue;t[40]===T?ue=t[41]:(ue=(0,A.jsx)(o,{htmlFor:T,children:le}),t[40]=T,t[41]=ue);let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>ee(e.target.value),t[42]=de):de=t[42];let fe;t[43]!==j||t[44]!==E||t[45]!==T?(fe=(0,A.jsx)(m,{id:T,type:`text`,autoComplete:`off`,...P,"aria-describedby":E,value:j,onChange:de}),t[43]=j,t[44]=E,t[45]=T,t[46]=fe):fe=t[46];let pe;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,A.jsx)(r,{id:`azrR7I`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`}),2:(0,A.jsx)(`code`,{translate:`no`})}}),t[47]=pe):pe=t[47];let me;t[48]===E?me=t[49]:(me=(0,A.jsx)(`p`,{id:E,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-username-hint`,children:pe}),t[48]=E,t[49]=me);let he;t[50]!==ue||t[51]!==fe||t[52]!==me?(he=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[ue,fe,me]}),t[50]=ue,t[51]=fe,t[52]=me,t[53]=he):he=t[53];let ge;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,A.jsx)(r,{id:`SkUcEr`}),t[54]=ge):ge=t[54];let _e;t[55]===D?_e=t[56]:(_e=(0,A.jsx)(o,{htmlFor:D,children:ge}),t[55]=D,t[56]=_e);let ve;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>te(e.target.value),t[57]=ve):ve=t[57];let ye;t[58]!==M||t[59]!==D?(ye=(0,A.jsx)(m,{id:D,type:`password`,autoComplete:`off`,...P,value:M,onChange:ve}),t[58]=M,t[59]=D,t[60]=ye):ye=t[60];let be;t[61]!==_e||t[62]!==ye?(be=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[_e,ye]}),t[61]=_e,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==O||t[65]!==F||t[66]!==M||t[67]!==j?(xe=F||!O.trim()||!j.trim()||!M.trim(),t[64]=O,t[65]=F,t[66]=M,t[67]=j,t[68]=xe):xe=t[68];let Se;t[69]===F?Se=t[70]:(Se=F?(0,A.jsx)(r,{id:`1yHVE-`}):(0,A.jsx)(r,{id:`zXZJoN`}),t[69]=F,t[70]=Se);let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,A.jsx)(s,{type:`submit`,"data-testid":`settings-account-host-token-submit`,disabled:xe,children:Se}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;t[74]===V?we=t[75]:(we=V?(0,A.jsx)(ne,{login:V.login,host:V.host}):null,t[74]=V,t[75]=we);let Te;t[76]!==L||t[77]!==w||t[78]!==z?(Te=L?(0,A.jsx)(`p`,{id:z?w:void 0,role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-host-token-error`,children:L}):null,t[76]=L,t[77]=w,t[78]=z,t[79]=Te):Te=t[79];let Ee;return t[80]!==X||t[81]!==ce||t[82]!==he||t[83]!==be||t[84]!==Ce||t[85]!==we||t[86]!==Te||t[87]!==Y?(Ee=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-host-tokens-title`,className:`space-y-4`,"data-field":`section:host-tokens`,children:[J,(0,A.jsxs)(`form`,{className:`space-y-3 rounded-lg border bg-card p-3`,"data-testid":`settings-account-host-token`,"aria-labelledby":`settings-host-tokens-title`,autoComplete:`off`,onSubmit:Y,children:[X,ce,he,be,Ce,we,Te]})]}),t[80]=X,t[81]=ce,t[82]=he,t[83]=be,t[84]=Ce,t[85]=we,t[86]=Te,t[87]=Y,t[88]=Ee):Ee=t[88],Ee}function I(e){let t=(0,C.c)(21),{login:n,host:i,disconnecting:a,error:o,onDisconnect:c}=e,l;t[0]!==i||t[1]!==n?(l=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`nxlOpL`})}),t[3]=u):u=t[3];let d;t[4]===l?d=t[5]:(d=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),t[4]=l,t[5]=d);let f;t[6]===a?f=t[7]:(f=a?(0,A.jsx)(r,{id:`rppgXF`}):(0,A.jsx)(r,{id:`-K0AvT`}),t[6]=a,t[7]=f);let p;t[8]!==a||t[9]!==c||t[10]!==f?(p=(0,A.jsx)(s,{variant:`outline`,onClick:c,disabled:a,"aria-describedby":`settings-account-disconnect-caveat`,"data-testid":`settings-account-disconnect`,children:f}),t[8]=a,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,A.jsx)(`p`,{id:`settings-account-disconnect-caveat`,className:`text-muted-foreground text-1sm`,"data-testid":`settings-account-disconnect-caveat`,children:(0,A.jsx)(r,{id:`msOK6I`})}),t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=o?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-disconnect-error`,children:o}):null,t[16]=o,t[17]=g);let _;return t[18]!==m||t[19]!==g?(_=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-connected`,children:[m,h,g]}),t[18]=m,t[19]=g,t[20]=_):_=t[20],_}function L(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`UcTm1A`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`})}})}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-gh-cli`,children:(0,A.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[a,o]})}),t[4]=a,t[5]=s),s}function R(e){let t=(0,C.c)(5),{onConnect:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`S33tz3`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[i,(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`9djC8C`})})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(r,{id:`5lWFkC`}),t[2]=o):o=t[2];let c;return t[3]===n?c=t[4]:(c=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-disconnected`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,(0,A.jsx)(s,{onClick:n,"data-testid":`settings-account-connect`,children:o})]})}),t[3]=n,t[4]=c),c}export{M as AccountSection};
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,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./label-CvMpFFbN.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./config-errors-tVoeK4OC.js";import{n as l,r as u}from"./constants-github-B7yhDvQc.js";import{f as d,l as f}from"./SyncStatusBadge-dhIJRXLW.js";import{t as p}from"./trash-2-CchZ0T47.js";import{t as m}from"./input-C-Qm8YDT.js";import{t as h}from"./use-git-sync-status-bHfYCMeV.js";import{a as g,n as _,t as v}from"./AuthModal-CaYJDCrL.js";import{t as y}from"./skeleton-Dk1iOPND.js";import{n as b}from"./auth-state-cache-yidtz6gx.js";import{t as x}from"./SettingsSectionHeader-DBUjTOcT.js";var S=e(n(),1),C=a(),w=`[a-z0-9](?:[a-z0-9-]*[a-z0-9])?`,T=RegExp(`^${w}(?:\\.${w})*$`),E=/^[a-z][a-z0-9+.-]*:\/\//i;function D(e){if(E.test(e))try{return new URL(e).host}catch{return null}let t=e.split(`/`)[0]??``;return t.slice(t.lastIndexOf(`@`)+1).replace(/:(?!\d+$).*$/,``)}function O(e,t){let n=e.trim();if(n===``)return{ok:!1,reason:`empty`};let r=D(n);if(r===null||r===``)return{ok:!1,reason:`invalid`};let i=u(r);return T.test(i)?i===`github.com`?{ok:!1,reason:`github-com`}:t.has(i)?{ok:!1,reason:`duplicate`}:{ok:!0,host:i}:{ok:!1,reason:`invalid`}}function k(e){let t=e.git?.hosts??{};return Object.entries(t).filter(([,e])=>e?.provider===`github`).map(([e])=>e).sort((e,t)=>e.localeCompare(t))}var A=t();function j(e){let t=(0,C.c)(59),{binding:n}=e,{_:a}=i(),o=(0,S.useId)(),l=(0,S.useId)(),u;t[0]===n?u=t[1]:(u=()=>k(n.current()),t[0]=n,t[1]=u);let[d,f]=(0,S.useState)(u),[h,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(!1),[x,w]=(0,S.useState)(null),T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Map,t[2]=T):T=t[2];let E=(0,S.useRef)(T),D=(0,S.useRef)(null),j,M;t[3]===x?(j=t[4],M=t[5]):(j=()=>{x!==null&&(((x.host===null?null:E.current.get(x.host))??D.current)?.focus(),w(null))},M=[x],t[3]=x,t[4]=j,t[5]=M),(0,S.useEffect)(j,M);let te,N;t[6]===n?(te=t[7],N=t[8]):(te=()=>n.subscribe(e=>f(k(e))),N=[n],t[6]=n,t[7]=te,t[8]=N),(0,S.useEffect)(te,N);let ne;t[9]===a?ne=t[10]:(ne=function(e){switch(e){case`empty`:return a({id:`cFONFy`});case`invalid`:return a({id:`QsnBxE`});case`github-com`:return a({id:`UK3GW4`});case`duplicate`:return a({id:`DEkRZA`})}},t[9]=a,t[10]=ne);let P=ne,F;t[11]!==n||t[12]!==h||t[13]!==d||t[14]!==P?(F=function(e){e.preventDefault();let t=O(h,new Set(d.map(ee)));if(!t.ok){v(P(t.reason));return}let r=n.patch({git:{hosts:{[t.host]:{provider:`github`}}}});if(!r.ok){v(c(r.error));return}f(k(r.effective)),g(``),v(null),b(!0)},t[11]=n,t[12]=h,t[13]=d,t[14]=P,t[15]=F):F=t[15];let I=F,L;t[16]!==n||t[17]!==d?(L=function(e){let t=d.indexOf(e),r=d[t+1]??d[t-1]??null,i=n.patch({git:{hosts:{[e]:null}}});if(!i.ok){v(c(i.error));return}f(k(i.effective)),w({host:r}),v(null),b(!0)},t[16]=n,t[17]=d,t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(`h4`,{id:`settings-enterprise-hosts-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`J2-D_a`})}),t[19]=z):z=t[19];let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,A.jsx)(r,{id:`PgY2nN`}),t[20]=B):B=t[20];let V;t[21]===o?V=t[22]:(V=(0,A.jsxs)(`div`,{children:[z,(0,A.jsx)(`p`,{id:o,className:`text-1sm text-muted-foreground`,children:B})]}),t[21]=o,t[22]=V);let H;t[23]!==a||t[24]!==R||t[25]!==d?(H=d.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,"data-testid":`settings-enterprise-hosts-list`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,A.jsx)(s,{variant:`ghost`,size:`icon`,className:`size-7`,"aria-label":a({id:`xVMoYb`,values:{host:e}}),ref:t=>{t?E.current.set(e,t):E.current.delete(e)},onClick:()=>R(e),children:(0,A.jsx)(p,{"aria-hidden":`true`})})]},e))}):(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-enterprise-hosts-empty`,children:(0,A.jsx)(r,{id:`HK2eIK`})}),t[23]=a,t[24]=R,t[25]=d,t[26]=H):H=t[26];let U;t[27]===a?U=t[28]:(U=a({id:`Qbf7Q4`}),t[27]=a,t[28]=U);let W=_!==null,G=_===null?o:`${o} ${l}`,K;t[29]===_?K=t[30]:(K=e=>{g(e.target.value),_!==null&&v(null)},t[29]=_,t[30]=K);let q;t[31]!==h||t[32]!==U||t[33]!==W||t[34]!==G||t[35]!==K?(q=(0,A.jsx)(m,{ref:D,value:h,"aria-label":U,placeholder:`github.example.com`,autoComplete:`off`,spellCheck:!1,inputMode:`url`,className:`h-7 flex-1 font-mono text-xs`,"aria-invalid":W,"aria-describedby":G,onChange:K}),t[31]=h,t[32]=U,t[33]=W,t[34]=G,t[35]=K,t[36]=q):q=t[36];let re;t[37]===h?re=t[38]:(re=h.trim(),t[37]=h,t[38]=re);let ie=re===``,J;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsx)(r,{id:`ALFlyF`}),t[39]=J):J=t[39];let Y;t[40]===ie?Y=t[41]:(Y=(0,A.jsx)(s,{type:`submit`,size:`sm`,variant:`secondary`,disabled:ie,className:`h-7 px-2 font-normal text-xs`,children:J}),t[40]=ie,t[41]=Y);let X;t[42]!==I||t[43]!==q||t[44]!==Y?(X=(0,A.jsxs)(`form`,{className:`flex items-center gap-2 pt-1`,onSubmit:I,noValidate:!0,children:[q,Y]}),t[42]=I,t[43]=q,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==_||t[47]!==l?(Z=_===null?null:(0,A.jsx)(`p`,{id:l,role:`alert`,className:`text-1sm text-destructive`,children:_}),t[46]=_,t[47]=l,t[48]=Z):Z=t[48];let Q;t[49]===y?Q=t[50]:(Q=y?(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`3LuFP-`})}):null,t[49]=y,t[50]=Q);let $;t[51]!==H||t[52]!==X||t[53]!==Z||t[54]!==Q?($=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border bg-card p-3`,children:[H,X,Z,Q]}),t[51]=H,t[52]=X,t[53]=Z,t[54]=Q,t[55]=$):$=t[55];let ae;return t[56]!==V||t[57]!==$?(ae=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-enterprise-hosts-title`,className:`space-y-4`,"data-field":`section:enterprise-hosts`,"data-testid":`settings-enterprise-hosts`,children:[V,$]}),t[56]=V,t[57]=$,t[58]=ae):ae=t[58],ae}function ee(e){return u(e)}function M(e){let t=(0,C.c)(43),{authQueryTransport:n,authTransport:a,userBinding:o}=e,{_:s}=i(),c;t[0]===n?c=t[1]:(c=n??g(),t[0]=n,t[1]=c);let l=c,u=h()?.remote??null,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={phase:`loading`},t[2]=d):d=t[2];let[f,p]=(0,S.useState)(d),[m,_]=(0,S.useState)(!1),[y,w]=(0,S.useState)(!1),[T,E]=(0,S.useState)(null),D=(0,S.useRef)(!1),O;t[3]===l?O=t[4]:(O=async function(){p({phase:`loading`});try{let e=await l.status();p({phase:`loaded`,result:e}),b(e)}catch(e){console.warn(`[AccountSection] GitHub status check failed`,e),p({phase:`check-failed`})}},t[3]=l,t[4]=O);let k=O,ee;t[5]===k?ee=t[6]:(ee=()=>{k()},t[5]=k,t[6]=ee);let M;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(M=[],t[7]=M):M=t[7],(0,S.useEffect)(ee,M);let N;t[8]!==s||t[9]!==k||t[10]!==l?(N=async function(){if(D.current)return;D.current=!0,_(!1),w(!0),E(null);let e=null;try{let t=l.signout?await l.signout():{ok:!1,error:s({id:`8cpOa8`})};t.ok||(e=t.error??s({id:`8cpOa8`}))}catch(t){console.warn(`[AccountSection] GitHub disconnect failed`,t),e=s({id:`8cpOa8`})}await k(),e&&E(e),w(!1),D.current=!1},t[8]=s,t[9]=k,t[10]=l,t[11]=N):N=t[11];let ne=N,P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,A.jsx)(r,{id:`MpZRQy`}),t[12]=P):P=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,A.jsx)(x,{titleId:`settings-account-title`,title:P,scope:`user`,children:(0,A.jsx)(r,{id:`pd6t3G`})}),t[13]=I):I=t[13];let L;t[14]!==T||t[15]!==y||t[16]!==ne||t[17]!==k||t[18]!==f?(L=f.phase===`loaded`&&f.result.unsupportedOrigin!==void 0?null:(0,A.jsxs)(`section`,{"aria-labelledby":`settings-github-account-title`,className:`space-y-4`,"data-field":`section:github-account`,children:[(0,A.jsx)(`h4`,{id:`settings-github-account-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`RkXlPZ`})}),(0,A.jsx)(te,{status:f,disconnecting:y,disconnectError:T,onRetry:()=>void k(),onConnect:()=>_(!0),onDisconnect:()=>void ne()})]}),t[14]=T,t[15]=y,t[16]=ne,t[17]=k,t[18]=f,t[19]=L):L=t[19];let R;t[20]===o?R=t[21]:(R=(0,A.jsx)(j,{binding:o}),t[20]=o,t[21]=R);let z;t[22]!==a||t[23]!==u?(z=(0,A.jsx)(F,{authTransport:a,remote:u}),t[22]=a,t[23]=u,t[24]=z):z=t[24];let B;t[25]!==R||t[26]!==z||t[27]!==L?(B=(0,A.jsxs)(`div`,{className:`space-y-8`,children:[L,R,z]}),t[25]=R,t[26]=z,t[27]=L,t[28]=B):B=t[28];let V;t[29]===k?V=t[30]:(V=e=>{_(e),e||k()},t[29]=k,t[30]=V);let H=f.phase===`loaded`?f.result.host:void 0,U=f.phase===`loaded`?f.result.ghAvailable:void 0,W;t[31]===k?W=t[32]:(W=()=>{k()},t[31]=k,t[32]=W);let G;t[33]!==m||t[34]!==a||t[35]!==V||t[36]!==H||t[37]!==U||t[38]!==W?(G=(0,A.jsx)(v,{open:m,onOpenChange:V,transport:a,host:H,ghAvailable:U,onSuccess:W}),t[33]=m,t[34]=a,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G):G=t[39];let K;return t[40]!==B||t[41]!==G?(K=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-account-title`,className:`space-y-5`,"data-testid":`settings-account`,children:[I,B,G]}),t[40]=B,t[41]=G,t[42]=K):K=t[42],K}function te(e){let t=(0,C.c)(8),{status:n,disconnecting:i,disconnectError:a,onRetry:o,onConnect:c,onDisconnect:l}=e,u;return t[0]!==a||t[1]!==i||t[2]!==c||t[3]!==l||t[4]!==o||t[5]!==n.phase||t[6]!==n.result?(u=n.phase===`loading`?(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-loading`,children:[(0,A.jsx)(`span`,{className:`sr-only`,children:(0,A.jsx)(r,{id:`IWGfGF`})}),(0,A.jsx)(y,{className:`h-4 w-40`}),(0,A.jsx)(y,{className:`h-8 w-32`})]}):n.phase===`check-failed`?(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-check-failed`,children:[(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`T_wG4n`})}),(0,A.jsx)(s,{variant:`outline`,size:`sm`,onClick:o,children:(0,A.jsx)(r,{id:`KDw4GX`})})]}):n.result.authenticated?n.result.tier===`A`?(0,A.jsx)(L,{login:n.result.login,host:n.result.host}):(0,A.jsx)(I,{login:n.result.login,host:n.result.host,disconnecting:i,error:a,onDisconnect:l}):(0,A.jsx)(R,{onConnect:c}),t[0]=a,t[1]=i,t[2]=c,t[3]=l,t[4]=o,t[5]=n.phase,t[6]=n.result,t[7]=u):u=t[7],u}function N(e){let t=e.split(`/`)[0]??``;return l(t)?t:``}function ne(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a={login:n,host:i},t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={0:(0,A.jsx)(`code`,{translate:`no`})},t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-success`,children:(0,A.jsx)(r,{id:`4p8Baj`,values:a,components:o})}),t[4]=a,t[5]=s),s}var P={"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`};function F(e){let t=(0,C.c)(89),{authTransport:n,remote:a}=e,{_:c}=i(),u;t[0]===n?u=t[1]:(u=n??_(),t[0]=n,t[1]=u);let p=u,h=a?.label??null,g;t[2]===a?g=t[3]:(g=a?f(a):!1,t[2]=a,t[3]=g);let v=g,y;t[4]===a?y=t[5]:(y=d(a),t[4]=a,t[5]=y);let b=y,x=(0,S.useId)(),w=(0,S.useId)(),T=(0,S.useId)(),E=(0,S.useId)(),D=(0,S.useId)(),[O,k]=(0,S.useState)(``),[j,ee]=(0,S.useState)(``),[M,te]=(0,S.useState)(``),[F,I]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),U=(0,S.useRef)(!1),W=(0,S.useRef)(!1),G,K;t[6]!==v||t[7]!==h||t[8]!==b?(G=()=>{if(W.current||h===null||v||!b)return;let e=N(h);e&&(W.current=!0,k(e))},K=[h,v,b],t[6]=v,t[7]=h,t[8]=b,t[9]=G,t[10]=K):(G=t[9],K=t[10]),(0,S.useEffect)(G,K);let q;t[11]!==c||t[12]!==O||t[13]!==p||t[14]!==M||t[15]!==j?(q=async function(){if(U.current)return;let e=O.trim(),t=j.trim(),n=M.trim();if(!e||!t||!n)return;if(!l(e)){H(null),B(!0),R(c({id:`rZFxkH`}));return}if(B(!1),!p.hostToken){R(c({id:`iMYFJM`}));return}U.current=!0,I(!0),R(null),H(null);let r=await p.hostToken(e,t,n).catch(e=>(console.warn(`[AccountSection] storing a host token failed`,e),{ok:!1,login:void 0,error:c({id:`Q5fqMz`})}));I(!1),U.current=!1,r.ok?(te(``),H({login:r.login||t,host:e})):R(r.error??c({id:`sNeKjP`}))},t[11]=c,t[12]=O,t[13]=p,t[14]=M,t[15]=j,t[16]=q):q=t[16];let re=q,ie;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,A.jsx)(`h4`,{id:`settings-host-tokens-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`jbhCDS`})}),t[17]=ie):ie=t[17];let J;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsxs)(`div`,{children:[ie,(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`-nA68n`})})]}),t[18]=J):J=t[18];let Y;t[19]===re?Y=t[20]:(Y=e=>{e.preventDefault(),re()},t[19]=re,t[20]=Y);let X;t[21]!==v||t[22]!==h||t[23]!==b?(X=h!==null&&!v&&!b?(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-not-https`,children:(0,A.jsx)(r,{id:`OWs-8P`})}):null,t[21]=v,t[22]=h,t[23]=b,t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,A.jsx)(r,{id:`Ai2U7L`}),t[25]=Z):Z=t[25];let Q;t[26]===x?Q=t[27]:(Q=(0,A.jsx)(o,{htmlFor:x,children:Z}),t[26]=x,t[27]=Q);let $=z||void 0,ae=z&&L?w:void 0,oe;t[28]===z?oe=t[29]:(oe=e=>{W.current=!0,k(e.target.value),z&&(B(!1),R(null))},t[28]=z,t[29]=oe);let se;t[30]!==O||t[31]!==x||t[32]!==$||t[33]!==ae||t[34]!==oe?(se=(0,A.jsx)(m,{id:x,type:`text`,placeholder:`git.example.com`,autoComplete:`off`,...P,"aria-invalid":$,"aria-describedby":ae,value:O,onChange:oe}),t[30]=O,t[31]=x,t[32]=$,t[33]=ae,t[34]=oe,t[35]=se):se=t[35];let ce;t[36]!==Q||t[37]!==se?(ce=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[Q,se]}),t[36]=Q,t[37]=se,t[38]=ce):ce=t[38];let le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,A.jsx)(r,{id:`7sNhEz`}),t[39]=le):le=t[39];let ue;t[40]===T?ue=t[41]:(ue=(0,A.jsx)(o,{htmlFor:T,children:le}),t[40]=T,t[41]=ue);let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>ee(e.target.value),t[42]=de):de=t[42];let fe;t[43]!==j||t[44]!==E||t[45]!==T?(fe=(0,A.jsx)(m,{id:T,type:`text`,autoComplete:`off`,...P,"aria-describedby":E,value:j,onChange:de}),t[43]=j,t[44]=E,t[45]=T,t[46]=fe):fe=t[46];let pe;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,A.jsx)(r,{id:`azrR7I`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`}),2:(0,A.jsx)(`code`,{translate:`no`})}}),t[47]=pe):pe=t[47];let me;t[48]===E?me=t[49]:(me=(0,A.jsx)(`p`,{id:E,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-username-hint`,children:pe}),t[48]=E,t[49]=me);let he;t[50]!==ue||t[51]!==fe||t[52]!==me?(he=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[ue,fe,me]}),t[50]=ue,t[51]=fe,t[52]=me,t[53]=he):he=t[53];let ge;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,A.jsx)(r,{id:`SkUcEr`}),t[54]=ge):ge=t[54];let _e;t[55]===D?_e=t[56]:(_e=(0,A.jsx)(o,{htmlFor:D,children:ge}),t[55]=D,t[56]=_e);let ve;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>te(e.target.value),t[57]=ve):ve=t[57];let ye;t[58]!==M||t[59]!==D?(ye=(0,A.jsx)(m,{id:D,type:`password`,autoComplete:`off`,...P,value:M,onChange:ve}),t[58]=M,t[59]=D,t[60]=ye):ye=t[60];let be;t[61]!==_e||t[62]!==ye?(be=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[_e,ye]}),t[61]=_e,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==O||t[65]!==F||t[66]!==M||t[67]!==j?(xe=F||!O.trim()||!j.trim()||!M.trim(),t[64]=O,t[65]=F,t[66]=M,t[67]=j,t[68]=xe):xe=t[68];let Se;t[69]===F?Se=t[70]:(Se=F?(0,A.jsx)(r,{id:`1yHVE-`}):(0,A.jsx)(r,{id:`zXZJoN`}),t[69]=F,t[70]=Se);let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,A.jsx)(s,{type:`submit`,"data-testid":`settings-account-host-token-submit`,disabled:xe,children:Se}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;t[74]===V?we=t[75]:(we=V?(0,A.jsx)(ne,{login:V.login,host:V.host}):null,t[74]=V,t[75]=we);let Te;t[76]!==L||t[77]!==w||t[78]!==z?(Te=L?(0,A.jsx)(`p`,{id:z?w:void 0,role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-host-token-error`,children:L}):null,t[76]=L,t[77]=w,t[78]=z,t[79]=Te):Te=t[79];let Ee;return t[80]!==X||t[81]!==ce||t[82]!==he||t[83]!==be||t[84]!==Ce||t[85]!==we||t[86]!==Te||t[87]!==Y?(Ee=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-host-tokens-title`,className:`space-y-4`,"data-field":`section:host-tokens`,children:[J,(0,A.jsxs)(`form`,{className:`space-y-3 rounded-lg border bg-card p-3`,"data-testid":`settings-account-host-token`,"aria-labelledby":`settings-host-tokens-title`,autoComplete:`off`,onSubmit:Y,children:[X,ce,he,be,Ce,we,Te]})]}),t[80]=X,t[81]=ce,t[82]=he,t[83]=be,t[84]=Ce,t[85]=we,t[86]=Te,t[87]=Y,t[88]=Ee):Ee=t[88],Ee}function I(e){let t=(0,C.c)(21),{login:n,host:i,disconnecting:a,error:o,onDisconnect:c}=e,l;t[0]!==i||t[1]!==n?(l=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`nxlOpL`})}),t[3]=u):u=t[3];let d;t[4]===l?d=t[5]:(d=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),t[4]=l,t[5]=d);let f;t[6]===a?f=t[7]:(f=a?(0,A.jsx)(r,{id:`rppgXF`}):(0,A.jsx)(r,{id:`-K0AvT`}),t[6]=a,t[7]=f);let p;t[8]!==a||t[9]!==c||t[10]!==f?(p=(0,A.jsx)(s,{variant:`outline`,onClick:c,disabled:a,"aria-describedby":`settings-account-disconnect-caveat`,"data-testid":`settings-account-disconnect`,children:f}),t[8]=a,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,A.jsx)(`p`,{id:`settings-account-disconnect-caveat`,className:`text-muted-foreground text-1sm`,"data-testid":`settings-account-disconnect-caveat`,children:(0,A.jsx)(r,{id:`msOK6I`})}),t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=o?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-disconnect-error`,children:o}):null,t[16]=o,t[17]=g);let _;return t[18]!==m||t[19]!==g?(_=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-connected`,children:[m,h,g]}),t[18]=m,t[19]=g,t[20]=_):_=t[20],_}function L(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`UcTm1A`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`})}})}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-gh-cli`,children:(0,A.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[a,o]})}),t[4]=a,t[5]=s),s}function R(e){let t=(0,C.c)(5),{onConnect:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`S33tz3`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[i,(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`9djC8C`})})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(r,{id:`5lWFkC`}),t[2]=o):o=t[2];let c;return t[3]===n?c=t[4]:(c=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-disconnected`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,(0,A.jsx)(s,{onClick:n,"data-testid":`settings-account-connect`,children:o})]})}),t[3]=n,t[4]=c),c}export{M as AccountSection};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-DLlcgj4F.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{i as c,n as l,t as u}from"./tooltip-DBqLYfio.js";import{t as d}from"./button-DzgjsZzC.js";import{n as f}from"./dist-BGzUo_18.js";import{t as p}from"./dist-C_FzPxEX2.js";import{f as m}from"./Mermaid-CbNnoCZo.js";import{t as h}from"./circle-alert-eBm4JPxY.js";import{t as g}from"./spinner-Bx8xD6f8.js";import{t as _}from"./undo-2-xEF_s_Io.js";import{a as v,c as y,i as b,o as x,s as S,t as C}from"./dialog-BJEjKJjL.js";import{l as w}from"./doc-hash-BJkweiX9.js";import{s as T}from"./navigation-targets-CcY2FHJZ.js";import{r as E}from"./PageListContext-B4oUr1KZ.js";import{a as D,i as O,n as k,o as A,t as ee}from"./agent-diff-store-CGW0LZVY.js";import{t as j}from"./timeline-diff-store-CIHRfGoI.js";import{n as M}from"./use-activity-panel-DD-3RGnf.js";var N=s(),P=e(i(),1),F=t();function te(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function I(e){let t=(0,N.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:f,onOpenDiff:p,onRestore:m}=e,{_:h}=o(),[w,T]=(0,P.useState)(ne),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,P.useEffect)(E,O);let[k,A]=(0,P.useState)(!1),ee=D(),j=n.stackIndex+1,M=ee?.docName===r&&ee.keptCount===j,I=i-j,re=!s||f||I<=0,ie;t[2]!==I||t[3]!==m?(ie=function(){A(!1),m(I)},t[2]=I,t[3]=m,t[4]=ie):ie=t[4];let ae=ie,L;t[5]!==n||t[6]!==p?(L=()=>p(n),t[5]=n,t[6]=p,t[7]=L):L=t[7];let R;t[8]!==h||t[9]!==j||t[10]!==r?(R=h({id:`Z79bnE`,values:{burstNumber:j,docName:r}}),t[8]=h,t[9]=j,t[10]=r,t[11]=R):R=t[11];let oe=M?`bg-muted`:`hover:bg-muted/40`,se;t[12]===oe?se=t[13]:(se=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,oe],t[12]=oe,t[13]=se);let ce=se.join(` `),z;t[14]!==n.ts||t[15]!==w?(z=te(n.ts,w),t[14]=n.ts,t[15]=w,t[16]=z):z=t[16];let B;t[17]===z?B=t[18]:(B=(0,F.jsx)(`span`,{className:`font-mono`,children:z}),t[17]=z,t[18]=B);let V;t[19]===n.additions?V=t[20]:(V=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=V);let H;t[21]===n.deletions?H=t[22]:(H=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=H);let U;t[23]!==V||t[24]!==H?(U=(0,F.jsxs)(`span`,{className:`ml-auto font-mono`,children:[V,` `,H]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==M||t[27]!==B||t[28]!==U||t[29]!==L||t[30]!==R||t[31]!==ce?(W=(0,F.jsxs)(`button`,{type:`button`,onClick:L,"aria-pressed":M,"aria-label":R,"data-testid":`activity-panel-burst-open`,className:ce,children:[B,U]}),t[26]=M,t[27]=B,t[28]=U,t[29]=L,t[30]=R,t[31]=ce,t[32]=W):W=t[32];let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=le):le=t[33];let G;t[34]!==h||t[35]!==j||t[36]!==r?(G=h({id:`Zhe80e`,values:{burstNumber:j,docName:r}}),t[34]=h,t[35]=j,t[36]=r,t[37]=G):G=t[37];let ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>A(!0),t[38]=ue):ue=t[38];let K;t[39]===f?K=t[40]:(K=f?(0,F.jsx)(g,{className:`size-3`,"aria-hidden":`true`}):(0,F.jsx)(_,{className:`size-3`,"aria-hidden":`true`}),t[39]=f,t[40]=K);let q;t[41]!==re||t[42]!==G||t[43]!==K?(q=(0,F.jsx)(c,{asChild:!0,children:(0,F.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":G,disabled:re,onClick:ue,children:K})}),t[41]=re,t[42]=G,t[43]=K,t[44]=q):q=t[44];let J;t[45]!==h||t[46]!==I||t[47]!==s?(J=h(s?I>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=h,t[46]=I,t[47]=s,t[48]=J):J=t[48];let Y;t[49]===J?Y=t[50]:(Y=(0,F.jsx)(l,{side:`left`,children:J}),t[49]=J,t[50]=Y);let X;t[51]!==q||t[52]!==Y?(X=(0,F.jsxs)(u,{children:[q,Y]}),t[51]=q,t[52]=Y,t[53]=X):X=t[53];let Z;t[54]!==W||t[55]!==X?(Z=(0,F.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[W,le,X]}),t[54]=W,t[55]=X,t[56]=Z):Z=t[56];let Q;t[57]===f?Q=t[58]:(Q=e=>{!e&&!f?A(!1):e&&A(!0)},t[57]=f,t[58]=Q);let de;t[59]===h?de=t[60]:(de=h({id:`a4FRQv`}),t[59]=h,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,F.jsx)(y,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===I?pe=t[64]:(pe=(0,F.jsx)(v,{children:(0,F.jsx)(a,{id:`LKIPzv`,values:{laterEdits:I}})}),t[63]=I,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,F.jsxs)(S,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(d,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,F.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===f?he=t[70]:(he=f?(0,F.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=f,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,F.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ae||t[73]!==f||t[74]!==he?(_e=(0,F.jsxs)(x,{children:[me,(0,F.jsxs)(d,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:f,onClick:ae,children:[he,ge]})]}),t[72]=ae,t[73]=f,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,F.jsxs)(b,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==Q||t[81]!==ve?(ye=(0,F.jsx)(C,{open:k,onOpenChange:Q,children:ve}),t[79]=k,t[80]=Q,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Z||t[84]!==ye?(be=(0,F.jsxs)(F.Fragment,{children:[Z,ye]}),t[83]=Z,t[84]=ye,t[85]=be):be=t[85],be}function ne(){return Date.now()}function re(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return p._({id:`nYeBmY`,values:{hours:r}})}function ie(e){let t=(0,N.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(ae),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,P.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),ee()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,F.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=re(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,F.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let j;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,F.jsx)(I,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],j=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=j}else j=t[43];let M;t[51]===j?M=t[52]:(M=(0,F.jsx)(`div`,{children:j}),t[51]=j,t[52]=M);let te;return t[53]!==A||t[54]!==M?(te=(0,F.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,M]}),t[53]=A,t[54]=M,t[55]=te):te=t[55],te}function ae(){return Date.now()}async function L(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function R(e){typeof window>`u`||(window.location.hash=w(e))}function oe(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,F.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,F.jsx)(`span`,{className:`text-sm`,children:(0,F.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function se(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,F.jsx)(h,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:(0,F.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,F.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,F.jsx)(a,{id:`6gRgw8`}),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,F.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:c}),t[5]=r,t[6]=l);let u;return t[7]!==s||t[8]!==l?(u=(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,l]}),t[7]=s,t[8]=l,t[9]=u):u=t[9],u}function ce(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,F.jsx)(`p`,{className:`text-sm italic`,children:(0,F.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function z(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,F.jsx)(B,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,F.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,F.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function B(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(m,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,F.jsx)(c,{asChild:!0,children:(0,F.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,F.jsx)(l,{side:`bottom`,children:(0,F.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let h;return t[7]===f?h=t[8]:(h=(0,F.jsxs)(u,{children:[f,p]}),t[7]=f,t[8]=h),h}function V(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(H),i;t[0]!==n||t[1]!==r?(i=n?U(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(`span`,{className:`font-medium`,children:(0,F.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,F.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,F.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,F.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function H(){return Date.now()}function U(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return p._({id:`nYeBmY`,values:{hours:n}})}function W(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,F.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function le(e){let t=(0,N.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,F.jsx)(B,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(W,{agent:n.agent}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,F.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,F.jsx)(a,{id:`F6pfE9`}):m===null?(0,F.jsx)(a,{id:`PMyJ9C`}):(0,F.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,F.jsxs)(F.Fragment,{children:[` · `,(0,F.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,F.jsx)(oe,{}):r===`error`&&i?(0,F.jsx)(se,{error:i,onRetry:s}):n===null?(0,F.jsx)(ce,{}):(0,F.jsxs)(F.Fragment,{children:[!n.sessionAlive&&m!==null?(0,F.jsx)(V,{lastTs:m}):null,n.files.length===0?(0,F.jsx)(ce,{}):n.files.map(e=>(0,F.jsx)(ie,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function G(e){let t=(0,N.c)(30),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a}=i,s=a===void 0?!0:a,{_:c}=o(),{docPanelAgentId:l,closeActivityPanel:u}=r(),{openTargetTransition:d}=n(),{pageMeta:p}=E(),{data:m,status:h,error:g,reload:_}=M(l),v,y;if(t[2]!==m||t[3]!==l?(v=()=>{if(!(!m||l===null))for(let e of m.files)O(l,e.docName,e.bursts.length)},y=[m,l],t[2]=m,t[3]=l,t[4]=v,t[5]=y):(v=t[4],y=t[5]),(0,P.useEffect)(v,y),l===null){let e;return t[6]!==u||t[7]!==s?(e=(0,F.jsx)(z,{onExit:u,showBackButton:s}),t[6]=u,t[7]=s,t[8]=e):e=t[8],e}let b;t[9]!==d||t[10]!==p?(b=e=>{d(T({kind:`doc`,target:e,docName:e},p),{disposition:`permanent`,consumeActiveNewTab:!0}),R(e)},t[9]=d,t[10]=p,t[11]=b):b=t[11];let x=b,S;t[12]!==m||t[13]!==l?(S=(e,t)=>{if(!m?.agent||l===null)return;j();let n=e.bursts.length;k({agentId:l,agentName:m.agent.displayName,agentColor:m.agent.color,agentIcon:m.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[12]=m,t[13]=l,t[14]=S):S=t[14];let C=S,w;t[15]!==c||t[16]!==m||t[17]!==l||t[18]!==_?(w=async(e,t)=>{if(!(t<=0))try{await L({connectionId:l,docName:e,scope:`count`,count:t,agentName:m?.agent?.displayName}),f.success(c(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),_()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);f.error(c({id:`EqrC_R`,values:{message:n}})),_()}},t[15]=c,t[16]=m,t[17]=l,t[18]=_,t[19]=w):w=t[19];let D=w,A;return t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==x||t[24]!==C||t[25]!==D||t[26]!==_||t[27]!==s||t[28]!==h?(A=(0,F.jsx)(le,{data:m,status:h,error:g,reload:_,onExit:u,onNavigate:x,onUndoDrop:D,onSetVersion:C,showBackButton:s}),t[20]=u,t[21]=m,t[22]=g,t[23]=x,t[24]=C,t[25]=D,t[26]=_,t[27]=s,t[28]=h,t[29]=A):A=t[29],A}export{G as ActivityModeContent};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-CcWANXoG.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{i as c,n as l,t as u}from"./tooltip-DBqLYfio.js";import{t as d}from"./button-DzgjsZzC.js";import{n as f}from"./dist-BGzUo_18.js";import{t as p}from"./dist-C_FzPxEX2.js";import{f as m}from"./Mermaid-CbNnoCZo.js";import{t as h}from"./circle-alert-eBm4JPxY.js";import{t as g}from"./spinner-Bx8xD6f8.js";import{t as _}from"./undo-2-xEF_s_Io.js";import{a as v,c as y,i as b,o as x,s as S,t as C}from"./dialog-BJEjKJjL.js";import{l as w}from"./doc-hash-BJkweiX9.js";import{s as T}from"./navigation-targets-CcY2FHJZ.js";import{r as E}from"./PageListContext-B4oUr1KZ.js";import{a as D,i as O,n as k,o as A,t as ee}from"./agent-diff-store-CGW0LZVY.js";import{t as j}from"./timeline-diff-store-CIHRfGoI.js";import{n as M}from"./use-activity-panel-BhM57X6v.js";var N=s(),P=e(i(),1),F=t();function te(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function I(e){let t=(0,N.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:f,onOpenDiff:p,onRestore:m}=e,{_:h}=o(),[w,T]=(0,P.useState)(ne),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,P.useEffect)(E,O);let[k,A]=(0,P.useState)(!1),ee=D(),j=n.stackIndex+1,M=ee?.docName===r&&ee.keptCount===j,I=i-j,re=!s||f||I<=0,ie;t[2]!==I||t[3]!==m?(ie=function(){A(!1),m(I)},t[2]=I,t[3]=m,t[4]=ie):ie=t[4];let ae=ie,L;t[5]!==n||t[6]!==p?(L=()=>p(n),t[5]=n,t[6]=p,t[7]=L):L=t[7];let R;t[8]!==h||t[9]!==j||t[10]!==r?(R=h({id:`Z79bnE`,values:{burstNumber:j,docName:r}}),t[8]=h,t[9]=j,t[10]=r,t[11]=R):R=t[11];let oe=M?`bg-muted`:`hover:bg-muted/40`,se;t[12]===oe?se=t[13]:(se=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,oe],t[12]=oe,t[13]=se);let ce=se.join(` `),z;t[14]!==n.ts||t[15]!==w?(z=te(n.ts,w),t[14]=n.ts,t[15]=w,t[16]=z):z=t[16];let B;t[17]===z?B=t[18]:(B=(0,F.jsx)(`span`,{className:`font-mono`,children:z}),t[17]=z,t[18]=B);let V;t[19]===n.additions?V=t[20]:(V=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=V);let H;t[21]===n.deletions?H=t[22]:(H=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=H);let U;t[23]!==V||t[24]!==H?(U=(0,F.jsxs)(`span`,{className:`ml-auto font-mono`,children:[V,` `,H]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==M||t[27]!==B||t[28]!==U||t[29]!==L||t[30]!==R||t[31]!==ce?(W=(0,F.jsxs)(`button`,{type:`button`,onClick:L,"aria-pressed":M,"aria-label":R,"data-testid":`activity-panel-burst-open`,className:ce,children:[B,U]}),t[26]=M,t[27]=B,t[28]=U,t[29]=L,t[30]=R,t[31]=ce,t[32]=W):W=t[32];let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=le):le=t[33];let G;t[34]!==h||t[35]!==j||t[36]!==r?(G=h({id:`Zhe80e`,values:{burstNumber:j,docName:r}}),t[34]=h,t[35]=j,t[36]=r,t[37]=G):G=t[37];let ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>A(!0),t[38]=ue):ue=t[38];let K;t[39]===f?K=t[40]:(K=f?(0,F.jsx)(g,{className:`size-3`,"aria-hidden":`true`}):(0,F.jsx)(_,{className:`size-3`,"aria-hidden":`true`}),t[39]=f,t[40]=K);let q;t[41]!==re||t[42]!==G||t[43]!==K?(q=(0,F.jsx)(c,{asChild:!0,children:(0,F.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":G,disabled:re,onClick:ue,children:K})}),t[41]=re,t[42]=G,t[43]=K,t[44]=q):q=t[44];let J;t[45]!==h||t[46]!==I||t[47]!==s?(J=h(s?I>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=h,t[46]=I,t[47]=s,t[48]=J):J=t[48];let Y;t[49]===J?Y=t[50]:(Y=(0,F.jsx)(l,{side:`left`,children:J}),t[49]=J,t[50]=Y);let X;t[51]!==q||t[52]!==Y?(X=(0,F.jsxs)(u,{children:[q,Y]}),t[51]=q,t[52]=Y,t[53]=X):X=t[53];let Z;t[54]!==W||t[55]!==X?(Z=(0,F.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[W,le,X]}),t[54]=W,t[55]=X,t[56]=Z):Z=t[56];let Q;t[57]===f?Q=t[58]:(Q=e=>{!e&&!f?A(!1):e&&A(!0)},t[57]=f,t[58]=Q);let de;t[59]===h?de=t[60]:(de=h({id:`a4FRQv`}),t[59]=h,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,F.jsx)(y,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===I?pe=t[64]:(pe=(0,F.jsx)(v,{children:(0,F.jsx)(a,{id:`LKIPzv`,values:{laterEdits:I}})}),t[63]=I,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,F.jsxs)(S,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(d,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,F.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===f?he=t[70]:(he=f?(0,F.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=f,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,F.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ae||t[73]!==f||t[74]!==he?(_e=(0,F.jsxs)(x,{children:[me,(0,F.jsxs)(d,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:f,onClick:ae,children:[he,ge]})]}),t[72]=ae,t[73]=f,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,F.jsxs)(b,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==Q||t[81]!==ve?(ye=(0,F.jsx)(C,{open:k,onOpenChange:Q,children:ve}),t[79]=k,t[80]=Q,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Z||t[84]!==ye?(be=(0,F.jsxs)(F.Fragment,{children:[Z,ye]}),t[83]=Z,t[84]=ye,t[85]=be):be=t[85],be}function ne(){return Date.now()}function re(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return p._({id:`nYeBmY`,values:{hours:r}})}function ie(e){let t=(0,N.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(ae),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,P.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),ee()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,F.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=re(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,F.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let j;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,F.jsx)(I,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],j=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=j}else j=t[43];let M;t[51]===j?M=t[52]:(M=(0,F.jsx)(`div`,{children:j}),t[51]=j,t[52]=M);let te;return t[53]!==A||t[54]!==M?(te=(0,F.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,M]}),t[53]=A,t[54]=M,t[55]=te):te=t[55],te}function ae(){return Date.now()}async function L(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function R(e){typeof window>`u`||(window.location.hash=w(e))}function oe(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,F.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,F.jsx)(`span`,{className:`text-sm`,children:(0,F.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function se(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,F.jsx)(h,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:(0,F.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,F.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,F.jsx)(a,{id:`6gRgw8`}),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,F.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:c}),t[5]=r,t[6]=l);let u;return t[7]!==s||t[8]!==l?(u=(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,l]}),t[7]=s,t[8]=l,t[9]=u):u=t[9],u}function ce(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,F.jsx)(`p`,{className:`text-sm italic`,children:(0,F.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function z(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,F.jsx)(B,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,F.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,F.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function B(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(m,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,F.jsx)(c,{asChild:!0,children:(0,F.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,F.jsx)(l,{side:`bottom`,children:(0,F.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let h;return t[7]===f?h=t[8]:(h=(0,F.jsxs)(u,{children:[f,p]}),t[7]=f,t[8]=h),h}function V(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(H),i;t[0]!==n||t[1]!==r?(i=n?U(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(`span`,{className:`font-medium`,children:(0,F.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,F.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,F.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,F.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function H(){return Date.now()}function U(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return p._({id:`nYeBmY`,values:{hours:n}})}function W(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,F.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function le(e){let t=(0,N.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,F.jsx)(B,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(W,{agent:n.agent}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,F.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,F.jsx)(a,{id:`F6pfE9`}):m===null?(0,F.jsx)(a,{id:`PMyJ9C`}):(0,F.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,F.jsxs)(F.Fragment,{children:[` · `,(0,F.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,F.jsx)(oe,{}):r===`error`&&i?(0,F.jsx)(se,{error:i,onRetry:s}):n===null?(0,F.jsx)(ce,{}):(0,F.jsxs)(F.Fragment,{children:[!n.sessionAlive&&m!==null?(0,F.jsx)(V,{lastTs:m}):null,n.files.length===0?(0,F.jsx)(ce,{}):n.files.map(e=>(0,F.jsx)(ie,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function G(e){let t=(0,N.c)(30),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a}=i,s=a===void 0?!0:a,{_:c}=o(),{docPanelAgentId:l,closeActivityPanel:u}=r(),{openTargetTransition:d}=n(),{pageMeta:p}=E(),{data:m,status:h,error:g,reload:_}=M(l),v,y;if(t[2]!==m||t[3]!==l?(v=()=>{if(!(!m||l===null))for(let e of m.files)O(l,e.docName,e.bursts.length)},y=[m,l],t[2]=m,t[3]=l,t[4]=v,t[5]=y):(v=t[4],y=t[5]),(0,P.useEffect)(v,y),l===null){let e;return t[6]!==u||t[7]!==s?(e=(0,F.jsx)(z,{onExit:u,showBackButton:s}),t[6]=u,t[7]=s,t[8]=e):e=t[8],e}let b;t[9]!==d||t[10]!==p?(b=e=>{d(T({kind:`doc`,target:e,docName:e},p),{disposition:`permanent`,consumeActiveNewTab:!0}),R(e)},t[9]=d,t[10]=p,t[11]=b):b=t[11];let x=b,S;t[12]!==m||t[13]!==l?(S=(e,t)=>{if(!m?.agent||l===null)return;j();let n=e.bursts.length;k({agentId:l,agentName:m.agent.displayName,agentColor:m.agent.color,agentIcon:m.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[12]=m,t[13]=l,t[14]=S):S=t[14];let C=S,w;t[15]!==c||t[16]!==m||t[17]!==l||t[18]!==_?(w=async(e,t)=>{if(!(t<=0))try{await L({connectionId:l,docName:e,scope:`count`,count:t,agentName:m?.agent?.displayName}),f.success(c(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),_()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);f.error(c({id:`EqrC_R`,values:{message:n}})),_()}},t[15]=c,t[16]=m,t[17]=l,t[18]=_,t[19]=w):w=t[19];let D=w,A;return t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==x||t[24]!==C||t[25]!==D||t[26]!==_||t[27]!==s||t[28]!==h?(A=(0,F.jsx)(le,{data:m,status:h,error:g,reload:_,onExit:u,onNavigate:x,onUndoDrop:D,onSetVersion:C,showBackButton:s}),t[20]=u,t[21]=m,t[22]=g,t[23]=x,t[24]=C,t[25]=D,t[26]=_,t[27]=s,t[28]=h,t[29]=A):A=t[29],A}export{G as ActivityModeContent};