cli-jaw 2.2.3 → 2.2.4-preview.20260703203439
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -4
- package/README.ko.md +1 -4
- package/README.md +4 -7
- package/README.zh-CN.md +1 -4
- package/dist/bin/commands/bgtask.js +3 -1
- package/dist/bin/commands/bgtask.js.map +1 -1
- package/dist/bin/commands/chat.js +2 -2
- package/dist/bin/commands/chat.js.map +1 -1
- package/dist/bin/commands/dispatch.js +10 -3
- package/dist/bin/commands/dispatch.js.map +1 -1
- package/dist/bin/commands/tui/fullscreen-mode.js +44 -11
- package/dist/bin/commands/tui/fullscreen-mode.js.map +1 -1
- package/dist/bin/commands/tui/ws-handler.js +15 -1
- package/dist/bin/commands/tui/ws-handler.js.map +1 -1
- package/dist/scripts/fresh-install-smoke.js +1 -1
- package/dist/scripts/fresh-install-smoke.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/src/agent/agy-bootstrap.js +104 -17
- package/dist/src/agent/agy-bootstrap.js.map +1 -1
- package/dist/src/agent/agy-runtime.js +104 -0
- package/dist/src/agent/agy-runtime.js.map +1 -1
- package/dist/src/agent/agy-transcript-watcher.js +14 -0
- package/dist/src/agent/agy-transcript-watcher.js.map +1 -1
- package/dist/src/agent/args.js +16 -83
- package/dist/src/agent/args.js.map +1 -1
- package/dist/src/agent/error-classifier.js +1 -3
- package/dist/src/agent/error-classifier.js.map +1 -1
- package/dist/src/agent/events/claude.js +60 -3
- package/dist/src/agent/events/claude.js.map +1 -1
- package/dist/src/agent/events/helpers.js +1 -1
- package/dist/src/agent/events/helpers.js.map +1 -1
- package/dist/src/agent/events/index.js +27 -27
- package/dist/src/agent/events/index.js.map +1 -1
- package/dist/src/agent/events/summary.js +0 -21
- package/dist/src/agent/events/summary.js.map +1 -1
- package/dist/src/agent/events/tool-labels.js +0 -28
- package/dist/src/agent/events/tool-labels.js.map +1 -1
- package/dist/src/agent/jwc-event-mapper.js +3 -3
- package/dist/src/agent/jwc-event-mapper.js.map +1 -1
- package/dist/src/agent/jwc-runtime.js +5 -1
- package/dist/src/agent/jwc-runtime.js.map +1 -1
- package/dist/src/agent/kiro-runtime.js +40 -14
- package/dist/src/agent/kiro-runtime.js.map +1 -1
- package/dist/src/agent/lifecycle-handler.js +2 -77
- package/dist/src/agent/lifecycle-handler.js.map +1 -1
- package/dist/src/agent/prompt-context.js +38 -0
- package/dist/src/agent/prompt-context.js.map +1 -0
- package/dist/src/agent/resume-classifier.js +0 -4
- package/dist/src/agent/resume-classifier.js.map +1 -1
- package/dist/src/agent/spawn/resume.js +0 -18
- package/dist/src/agent/spawn/resume.js.map +1 -1
- package/dist/src/agent/spawn-env.js +0 -28
- package/dist/src/agent/spawn-env.js.map +1 -1
- package/dist/src/agent/spawn.js +81 -76
- package/dist/src/agent/spawn.js.map +1 -1
- package/dist/src/bgtask/presets.js +13 -1
- package/dist/src/bgtask/presets.js.map +1 -1
- package/dist/src/cli/employee-handler.js +10 -10
- package/dist/src/cli/employee-handler.js.map +1 -1
- package/dist/src/cli/handlers-completions.js +29 -10
- package/dist/src/cli/handlers-completions.js.map +1 -1
- package/dist/src/cli/handlers-runtime.js +3 -2
- package/dist/src/cli/handlers-runtime.js.map +1 -1
- package/dist/src/cli/opencodex-models.js +118 -0
- package/dist/src/cli/opencodex-models.js.map +1 -0
- package/dist/src/cli/readiness.js +2 -8
- package/dist/src/cli/readiness.js.map +1 -1
- package/dist/src/cli/registry-live.js +21 -1
- package/dist/src/cli/registry-live.js.map +1 -1
- package/dist/src/cli/registry.js +10 -21
- package/dist/src/cli/registry.js.map +1 -1
- package/dist/src/cli/tui/jawcode-bridge.js +15 -13
- package/dist/src/cli/tui/jawcode-bridge.js.map +1 -1
- package/dist/src/cli/tui/jawcode-render.js +26 -0
- package/dist/src/cli/tui/jawcode-render.js.map +1 -1
- package/dist/src/cli/tui/render/frame.js +158 -16
- package/dist/src/cli/tui/render/frame.js.map +1 -1
- package/dist/src/cli/tui/transcript.js +79 -3
- package/dist/src/cli/tui/transcript.js.map +1 -1
- package/dist/src/core/cli-detect.js +1 -1
- package/dist/src/core/cli-detect.js.map +1 -1
- package/dist/src/core/employees.js +12 -7
- package/dist/src/core/employees.js.map +1 -1
- package/dist/src/core/event-bus.js +13 -0
- package/dist/src/core/event-bus.js.map +1 -1
- package/dist/src/goal/heartbeat.js +8 -0
- package/dist/src/goal/heartbeat.js.map +1 -1
- package/dist/src/manager/load-timing.js +29 -0
- package/dist/src/manager/load-timing.js.map +1 -0
- package/dist/src/manager/observability.js.map +1 -1
- package/dist/src/manager/server.js +67 -6
- package/dist/src/manager/server.js.map +1 -1
- package/dist/src/memory/bootstrap.js +43 -1
- package/dist/src/memory/bootstrap.js.map +1 -1
- package/dist/src/orchestrator/distribute.js +5 -1
- package/dist/src/orchestrator/distribute.js.map +1 -1
- package/dist/src/orchestrator/state-machine.js +20 -0
- package/dist/src/orchestrator/state-machine.js.map +1 -1
- package/dist/src/orchestrator/worker-registry.js +2 -1
- package/dist/src/orchestrator/worker-registry.js.map +1 -1
- package/dist/src/prompt/templates/a1-system.md +61 -11
- package/dist/src/prompt/templates/employee.md +13 -0
- package/dist/src/prompt/templates/orchestration.md +14 -0
- package/dist/src/prompt/templates/worker-context.md +4 -4
- package/dist/src/routes/employees.js +8 -8
- package/dist/src/routes/employees.js.map +1 -1
- package/dist/src/routes/events.js +57 -19
- package/dist/src/routes/events.js.map +1 -1
- package/dist/src/routes/orchestrate.js +42 -17
- package/dist/src/routes/orchestrate.js.map +1 -1
- package/dist/src/routes/quota-agy-reverse.js +0 -24
- package/dist/src/routes/quota-agy-reverse.js.map +1 -1
- package/dist/src/routes/quota.js +0 -145
- package/dist/src/routes/quota.js.map +1 -1
- package/dist/src/routes/settings.js +2 -7
- package/dist/src/routes/settings.js.map +1 -1
- package/dist/src/shared/tool-log-sanitize.js +6 -0
- package/dist/src/shared/tool-log-sanitize.js.map +1 -1
- package/dist/src/telegram/forwarder.js +53 -5
- package/dist/src/telegram/forwarder.js.map +1 -1
- package/dist/src/trace/store.js +82 -0
- package/dist/src/trace/store.js.map +1 -1
- package/dist/src/types/cli-engine.js +0 -1
- package/dist/src/types/cli-engine.js.map +1 -1
- package/dist/src/types/cli-events.js +1 -1
- package/dist/src/types/cli-events.js.map +1 -1
- package/package.json +2 -2
- package/public/dist/assets/Agent-CHCXjXSN.js +1 -0
- package/public/dist/assets/CodeCanvas-BzhNLZVF.js +3 -0
- package/public/dist/assets/DocPanel-6Z_RELzd.js +1 -0
- package/public/dist/assets/{DocPanel-D3FYBhMp.css → DocPanel-DZKPTOm8.css} +1 -1
- package/public/dist/assets/FolderPanel-DdlzWAuK.js +3 -0
- package/public/dist/assets/{Heartbeat-D-Rfp094.js → Heartbeat-BblY8Z4a.js} +1 -1
- package/public/dist/assets/MarkdownRenderer-BivJ4hJm.js +1 -0
- package/public/dist/assets/MarkdownRenderer-Cl0oEICj.js +15 -0
- package/public/dist/assets/{Memory-VH4ZJCMW.js → Memory-BWcfxzCz.js} +1 -1
- package/public/dist/assets/ModelProvider-D4LBX7K2.js +1 -0
- package/public/dist/assets/agent-meta-FyI15KAa.js +1 -0
- package/public/dist/assets/{app-DaORcAyD.js → app-DszWzakT.js} +4 -4
- package/public/dist/assets/bgtask-badge-DZEQ5fMl.js +1 -0
- package/public/dist/assets/{bgtask-badge-BtUXEe1T.js → bgtask-badge-b7pj_Dbh.js} +1 -1
- package/public/dist/assets/constants-EMUBd5RQ.js +1 -0
- package/public/dist/assets/{employees-CZSyvJbx.js → employees-DbgFV33i.js} +1 -1
- package/public/dist/assets/{manager-DB5qTw1A.js → manager-CdNOlCyS.js} +4 -4
- package/public/dist/assets/{manager-D3waO_XX.css → manager-rHNwUB4e.css} +1 -1
- package/public/dist/assets/memory-BT-rs3ag.js +1 -0
- package/public/dist/assets/{memory-cWI_Htbn.js → memory-QobGT0Kv.js} +1 -1
- package/public/dist/assets/message-history-BY1UNJAO.js +1 -0
- package/public/dist/assets/message-history-BmP5JKio.js +142 -0
- package/public/dist/assets/{render-Bp8eyqCf.js → render-C3r-9_-J.js} +2 -2
- package/public/dist/assets/settings-CJm8ZSJs.js +1 -0
- package/public/dist/assets/{settings-DLkP7qRV.js → settings-D70uFh8l.js} +1 -1
- package/public/dist/assets/{settings-core-B5XRRNcX.js → settings-core-B2lw2bgO.js} +1 -1
- package/public/dist/assets/settings-core-gdS0lo1b.js +1 -0
- package/public/dist/assets/{sidebar-CsogFOse.js → sidebar-BqWm2XWP.js} +3 -3
- package/public/dist/assets/{skills-Dmf4v9rj.js → skills-CdNOfXlk.js} +1 -1
- package/public/dist/assets/skills-DG_CbTEf.js +1 -0
- package/public/dist/assets/{slash-commands-vcf7FuPD.js → slash-commands-4Ntm5N7h.js} +1 -1
- package/public/dist/assets/slash-commands-B9kOEhJ_.js +1 -0
- package/public/dist/assets/{trace-drawer-DuQQ0SNq.js → trace-drawer-DqAwwHHQ.js} +1 -1
- package/public/dist/assets/ui-Anw2S64o.js +1 -0
- package/public/dist/assets/ui-DsK6r0Xv.js +2 -0
- package/public/dist/index.html +1 -1
- package/public/dist/manager/index.html +2 -2
- package/public/js/constants.ts +7 -7
- package/public/js/features/employees.ts +0 -3
- package/public/js/features/process-block-dom.ts +6 -1
- package/public/js/features/process-block.ts +59 -3
- package/public/js/render/file-links.ts +1 -1
- package/public/js/ui.ts +9 -1
- package/public/js/virtual-scroll.ts +23 -0
- package/public/js/ws.ts +7 -2
- package/public/manager/src/SidebarRailRouter.tsx +15 -10
- package/public/manager/src/code/CodeCanvas.tsx +3 -1
- package/public/manager/src/code/CodeTranscript.tsx +5 -4
- package/public/manager/src/code/CodeWorkbench.tsx +2 -1
- package/public/manager/src/doc-panel/DocPanel.tsx +52 -5
- package/public/manager/src/doc-panel/doc-panel.css +10 -0
- package/public/manager/src/folder-panel/FolderPanel.tsx +14 -16
- package/public/manager/src/folder-panel/use-folder-git-status.ts +15 -0
- package/public/manager/src/folder-panel/use-folder-preview-sync.ts +37 -0
- package/public/manager/src/folder-panel/use-folder-visible-refresh.ts +19 -6
- package/public/manager/src/manager-notes.css +23 -0
- package/public/manager/src/notes/rendering/MarkdownRenderer.tsx +80 -2
- package/public/manager/src/settings/pages/Agent.tsx +30 -8
- package/public/manager/src/settings/pages/ModelProvider.tsx +22 -4
- package/public/manager/src/settings/pages/components/agent/AgentEmployeesSection.tsx +5 -1
- package/public/manager/src/settings/pages/components/agent/FlushAgentSection.tsx +5 -3
- package/public/manager/src/settings/pages/components/agent/RuntimeEmployeeRow.tsx +6 -4
- package/public/manager/src/settings/pages/components/agent/RuntimeHeader.tsx +4 -2
- package/public/manager/src/settings/pages/components/agent/agent-meta.ts +45 -9
- package/public/manager/src/settings/pages/components/agent/runtime-employees-helpers.ts +7 -2
- package/scripts/capture-agy-quota-fixture.mjs +138 -0
- package/scripts/fresh-install-smoke.ts +1 -1
- package/dist/src/agent/events/gemini.js +0 -100
- package/dist/src/agent/events/gemini.js.map +0 -1
- package/public/dist/assets/Agent-Ci12HWhE.js +0 -1
- package/public/dist/assets/CodeCanvas-d1gh0-lY.js +0 -3
- package/public/dist/assets/DocPanel-C6XQ7W6A.js +0 -1
- package/public/dist/assets/FolderPanel-DIFAqajZ.js +0 -3
- package/public/dist/assets/MarkdownRenderer-DXKUEE2a.js +0 -1
- package/public/dist/assets/MarkdownRenderer-DcIxpNcX.js +0 -15
- package/public/dist/assets/ModelProvider-_tUCghOF.js +0 -1
- package/public/dist/assets/agent-meta-DqBTGRRQ.js +0 -1
- package/public/dist/assets/bgtask-badge-B3HLOZae.js +0 -1
- package/public/dist/assets/constants-DkJ3E63Y.js +0 -1
- package/public/dist/assets/memory-BEruUlfu.js +0 -1
- package/public/dist/assets/message-history-DU1V9ZAW.js +0 -142
- package/public/dist/assets/message-history-tjkyOp_K.js +0 -1
- package/public/dist/assets/settings-B-GgyJZI.js +0 -1
- package/public/dist/assets/settings-core-Cw1av-Ox.js +0 -1
- package/public/dist/assets/skills-CLcoop6W.js +0 -1
- package/public/dist/assets/slash-commands-DY6-hzq6.js +0 -1
- package/public/dist/assets/ui-BKYuBdZE.js +0 -2
- package/public/dist/assets/ui-CqlGwgUo.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-render-Bjnw0wQ6.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{t}from"./preload-helper-DFYRRz9w.js";import{a as n,i as r,n as i,r as a,t as o}from"./esm-3SgqVBY5.js";import{n as s,t as c}from"./jsx-runtime-B3ZGMGGg.js";import{t as l}from"./react-dom-CZtrmbYs.js";import{t as u}from"./desktop-bridge-B1whMBS2.js";var d=e(s(),1),f=l();function p(e){let t=typeof window<`u`?window.location.origin:``,n=typeof window<`u`?window.location.port:``,r=t&&n===String(e)?t:`http://127.0.0.1:${e}`;async function i(e,t,n){let i={method:e};n&&(i.headers={"Content-Type":`application/json`},i.body=JSON.stringify(n));let a=await(await fetch(`${r}${t}`,i)).json();if(!a.ok)throw Error(a.error||`${e} ${t} failed`);return a}return{async listSessions(){return(await i(`GET`,`/api/code/sessions`)).sessions},async listStoredSessions(e={}){let t=e.scope??`all`,n=new URLSearchParams({scope:t});return t===`cwd`&&e.cwd&&n.set(`cwd`,e.cwd),(await i(`GET`,`/api/code/sessions/stored${`?${n.toString()}`}`)).sessions},async listModelOptions(){return i(`GET`,`/api/code/models`)},async setDefaultModel(e){return i(`POST`,`/api/code/model-default`,{modelId:e})},async listModelAssignments(){return i(`GET`,`/api/code/model-assignments`)},async setModelAssignment(e,t){let n=typeof t==`string`?{modelId:t}:t;return i(`PUT`,`/api/code/model-assignments/${encodeURIComponent(e)}`,n)},async clearModelAssignment(e){return i(`DELETE`,`/api/code/model-assignments/${encodeURIComponent(e)}`)},async listModelPresets(){return i(`GET`,`/api/code/model-presets`)},async getGitInfo(e){return await i(`GET`,`/api/code/git-info?cwd=${encodeURIComponent(e)}`)},async loadSession(e,t){return(await i(`POST`,`/api/code/sessions/load`,{sessionId:e,cwd:t})).session},async createSession(e,t){return(await i(`POST`,`/api/code/sessions`,{cwd:e,...t?{model:t}:{}})).session},async sendPrompt(e,t){return i(`POST`,`/api/code/sessions/${e}/prompt`,{text:t})},async cancelPrompt(e){await i(`POST`,`/api/code/sessions/${e}/cancel`)},async closeSession(e){await i(`DELETE`,`/api/code/sessions/${e}`)},async answerPermission(e,t){await i(`POST`,`/api/code/permissions/${e}`,{optionId:t})},async setSessionConfig(e,t,n){await i(`POST`,`/api/code/sessions/${e}/config`,{configId:t,valueId:n})},async extMethod(e,t,n){return(await i(`POST`,`/api/code/sessions/${e}/ext`,{method:t,params:n})).result},async forkSession(e,t){return(await i(`POST`,`/api/code/sessions/${e}/fork`,{cwd:t})).session},async setSessionModel(e,t){await i(`POST`,`/api/code/sessions/${e}/model`,{modelId:t})},pickWorkspace(){return i(`POST`,`/api/code/workspace/pick`)}}}var m=c();function h({client:e,activeSessionId:t,workingDir:n,onSelectSession:r,onLoadSession:i,onNewSession:a}){let[o,s]=(0,d.useState)([]),[c,l]=(0,d.useState)([]),[u,f]=(0,d.useState)(!0),[p,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(`all`),b=(0,d.useCallback)(async()=>{f(!0),h(``);let t=e=>e instanceof Error?e.message:String(e),r=v===`cwd`?{scope:`cwd`,cwd:n}:{scope:`all`},[i,a]=await Promise.allSettled([e.listSessions(),e.listStoredSessions(r)]),o=[];if(i.status===`fulfilled`){let e=i.value;s(e.filter(e=>e.status!==`closed`));let n=new Set(e.map(e=>e.sessionId));a.status===`fulfilled`?l(a.value.filter(e=>!n.has(e.sessionId))):(l([]),o.push(`History: ${t(a.reason)}`))}else s([]),o.push(`Live: ${t(i.reason)}`),a.status===`fulfilled`?l(a.value):(l([]),o.push(`History: ${t(a.reason)}`));o.length>0&&h(o.join(` · `)),f(!1)},[e,v,n]);(0,d.useEffect)(()=>{b()},[b]);let x=e=>e.split(`/`).pop()||e,S=e=>{let t=e.replayEvents?.find(e=>e.event===`code_user_message_chunk`)?.update??{},n=t.content;return String(n?.text??t.text??``).split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()||``},C=e=>e.title?.trim()||S(e)||x(e.cwd)||e.sessionId.slice(0,12)||`Untitled session`,w=e=>x(e.cwd),ee=e=>[e.sessionId,e.title??``,S(e),e.cwd].join(` `).toLowerCase(),T=e=>e.title?.trim()||e.firstMessage?.replace(/\s+/g,` `).trim()||e.sessionId.slice(0,12)||`Untitled session`,E=e=>{if(typeof e.lastModified==`number`)return e.lastModified;if(e.updatedAt){let t=Date.parse(e.updatedAt);if(Number.isFinite(t))return t}return 0},D=e=>{let t=[x(e.cwd)];return e.messageCount!==void 0&&t.push(`${e.messageCount} messages`),t.filter(Boolean).join(` · `)},O=e=>[e.sessionId,e.title??``,e.firstMessage??``,e.cwd].join(` `).toLowerCase(),k=c.filter(e=>!g||O(e).includes(g.toLowerCase())).sort((e,t)=>E(t)-E(e)).slice(0,20),A=k.reduce((e,t)=>{let n=e.find(e=>e.cwd===t.cwd);return n?n.sessions.push(t):e.push({cwd:t.cwd,sessions:[t]}),e},[]),j=p?`Session data could not fully load.`:v===`cwd`?`No sessions for this cwd. Switch to All to browse global history.`:`No JWC sessions found.`;return(0,m.jsxs)(`div`,{className:`code-session-list`,children:[(0,m.jsxs)(`div`,{className:`code-session-list-header`,children:[(0,m.jsx)(`span`,{className:`code-session-list-title`,children:`Sessions`}),(0,m.jsx)(`button`,{type:`button`,className:`code-session-new-btn`,onClick:a,"aria-label":`New code session`,children:`+`})]}),(0,m.jsxs)(`div`,{className:`code-session-view-toggle`,"aria-label":`Session view`,children:[(0,m.jsx)(`button`,{type:`button`,className:`code-session-view-btn${v===`all`?` active`:``}`,onClick:()=>y(`all`),children:`All`}),(0,m.jsx)(`button`,{type:`button`,className:`code-session-view-btn${v===`cwd`?` active`:``}`,onClick:()=>y(`cwd`),children:`This cwd`}),(0,m.jsx)(`button`,{type:`button`,className:`code-session-view-btn${v===`grouped`?` active`:``}`,onClick:()=>y(`grouped`),children:`Group`})]}),v===`cwd`&&(0,m.jsx)(`div`,{className:`code-session-view-hint`,children:x(n)}),p&&(0,m.jsx)(`div`,{className:`code-session-list-error`,role:`status`,children:p}),o.length+c.length>3&&(0,m.jsx)(`input`,{className:`code-session-search`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Search sessions...`}),u?(0,m.jsx)(`div`,{className:`code-session-list-loading`,children:`Loading...`}):(0,m.jsxs)(m.Fragment,{children:[o.length>0&&(0,m.jsx)(`ul`,{className:`code-session-list-items`,children:o.filter(e=>!g||ee(e).includes(g.toLowerCase())).map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`code-session-item ${e.sessionId===t?`active`:``}`,onClick:()=>r(e),children:[(0,m.jsx)(`span`,{className:`code-session-cwd`,children:C(e)}),(0,m.jsx)(`span`,{className:`code-session-meta`,children:w(e)}),(0,m.jsx)(`span`,{className:`code-session-status code-session-status-${e.status}`,children:e.status})]})},e.sessionId))}),k.length>0&&v!==`grouped`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`code-session-list-divider`,children:`History`}),(0,m.jsx)(`ul`,{className:`code-session-list-items`,children:k.map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`code-session-item`,onClick:()=>i(e.sessionId,e.cwd),children:[(0,m.jsx)(`span`,{className:`code-session-cwd`,children:T(e)}),(0,m.jsx)(`span`,{className:`code-session-meta`,children:D(e)}),(0,m.jsx)(`span`,{className:`code-session-status`,children:`stored`})]})},e.sessionId))})]}),k.length>0&&v===`grouped`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`code-session-list-divider`,children:`History by cwd`}),A.map(e=>(0,m.jsxs)(`section`,{className:`code-session-group`,children:[(0,m.jsxs)(`div`,{className:`code-session-group-title`,title:e.cwd,children:[x(e.cwd),` `,(0,m.jsx)(`span`,{children:e.sessions.length})]}),(0,m.jsx)(`ul`,{className:`code-session-list-items`,children:e.sessions.map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`code-session-item`,onClick:()=>i(e.sessionId,e.cwd),children:[(0,m.jsx)(`span`,{className:`code-session-cwd`,children:T(e)}),(0,m.jsx)(`span`,{className:`code-session-meta`,children:D(e)}),(0,m.jsx)(`span`,{className:`code-session-status`,children:`stored`})]})},e.sessionId))})]},e.cwd))]}),o.length===0&&k.length===0&&(0,m.jsx)(`div`,{className:`code-session-list-empty`,children:j})]})]})}function g(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r?.role===`tool`&&r.toolCallId===t)return n}return-1}function _(e,t){return e?`${e}/${t}`:t}var v=[`allow_once`,`allow_always`,`reject_once`,`reject_always`],y={allow_once:`Allow once`,allow_always:`Always allow`,reject_once:`Deny once`,reject_always:`Always deny`},b={allow_once:`allow-once`,allow_always:`allow-always`,reject_once:`deny-once`,reject_always:`deny-always`},x=[{value:`always-allow`,label:`Always allow`,detail:`Auto-allow gated tools`,tone:`allow`},{value:`ask`,label:`Ask first`,detail:`Review each gated tool`,tone:`ask`},{value:`always-deny`,label:`Always deny`,detail:`Auto-deny gated tools`,tone:`deny`}],S={ask:`Review each gated tool`,"always-allow":`Auto-allow gated tools`,"always-deny":`Auto-deny gated tools`},C={allow_once:/^(allow[_\s-]?once|allow once)$/i,allow_always:/^(allow[_\s-]?always|always allow|always approve)$/i,reject_once:/^(reject[_\s-]?once|deny[_\s-]?once|reject|deny)$/i,reject_always:/^(reject[_\s-]?always|deny[_\s-]?always|always reject|always deny)$/i};function w(e){return[e.kind,e.optionId,e.id,e.name,e.label].map(e=>String(e??``)).join(` `).trim()}function ee(e){let t=e.optionId??e.id;return t==null||t===``?null:String(t)}function T(e,t){let n=e.name??e.label;return n==null||n===``?y[t]:String(n)}function E(e,t){let n=e.find(e=>e.kind===t),r=e.find(e=>e.optionId===t||e.id===t),i=e.find(e=>C[t].test(w(e))),a=n??r??i;if(!a)return null;let o=ee(a);return o?{kind:t,optionId:o,label:T(a,t),raw:a}:null}function D(e){return String(e.toolName??e.title??e.name??`tool`)}function O(e,t){let n={permissionId:e.permissionId,toolName:D(e.toolCall),...t};return{role:`permission`,text:n.error??n.optionLabel??n.decision,permissionAudit:n}}function k(e){if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function A(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n==`string`){n&&t.push(n);continue}if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=typeof e.type==`string`?e.type.toLowerCase():``,i=e.text;(!r||r===`text`)&&typeof i==`string`&&i&&t.push(i)}return t.length>0?t.join(`
|
|
3
|
+
`):null}function j(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=A(t.content);if(n)return n;let r=t.details;if(r&&typeof r==`object`&&!Array.isArray(r)){let e=r.displayContent;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.text;if(typeof t==`string`&&t)return t}}return null}function te(e){return j(e)??k(e)}function M(e){if(typeof e==`string`)return{type:`text`,text:e};if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.type==`string`?t.type.toLowerCase():``,r=typeof t.label==`string`?t.label:void 0;if(n===`diff`&&typeof t.diff==`string`)return{type:`diff`,diff:t.diff,...r?{label:r}:{}};if(n===`error`)return{type:`error`,text:k(t.text??t.error??t.message??t),...r?{label:r}:{}};if(n===`args`||n===`arguments`||n===`input`)return{type:`args`,json:t.json??t.args??t.arguments??t.input??t,...r?{label:r}:{}};if(n===`output`)return{type:`output`,text:te(t.text??t.output??t),...r?{label:r}:{}};if(n===`json`)return{type:`json`,json:t.json??t.value??t,...r?{label:r}:{}};if(typeof t.diff==`string`)return{type:`diff`,diff:t.diff,...r?{label:r}:{}};if(typeof t.text==`string`)return{type:`text`,text:t.text,...r?{label:r}:{}};let i=j(t);return i?{type:`text`,text:i,...r?{label:r}:{}}:{type:`json`,json:t,...r?{label:r}:{}}}function N(e,t,n,r){r==null||r===``||(t===`args`||t===`json`?e.push({type:t,label:n,json:r}):e.push({type:t,label:n,text:t===`output`?te(r):k(r)}))}function P(e){let t=[],n=e.content;if(Array.isArray(n))for(let e of n){let n=M(e);n&&t.push(n)}else{let e=M(n);e&&t.push(e)}return N(t,`args`,`Args`,e.args??e.arguments??e.input??e.rawInput),N(t,`output`,`Output`,e.rawOutput??e.output),N(t,`error`,`Error`,e.error??e.errorMessage??e.reason),t}var F={settings:{category:`settings`,popupKind:`settings`},theme:{category:`settings`,popupKind:`settings`},identity:{category:`settings`,popupKind:`settings`},"identity-auto":{category:`settings`,popupKind:`settings`},model:{category:`model`,popupKind:`model`},provider:{category:`provider`,popupKind:`provider`},login:{category:`provider`,popupKind:`provider`}},I={session:`session`,orchestrate:`workflow`,pabcd:`workflow`,goal:`workflow`,mcp:`utility`,move:`utility`,compact:`utility`,dump:`utility`,help:`utility`};function L(e){return e.trim().replace(/^\/+/,``)}function ne(e,t){let n=typeof e.source==`string`?e.source:``,r=typeof e.path==`string`?e.path:``;return n.includes(`skill`)||t.includes(`:`)?`jwc-skill`:n.includes(`custom`)?`jwc-custom`:n.includes(`file`)||r?`jwc-file`:F[t]||I[t]?`jwc-builtin`:`unknown`}function R(e){let t=e.input;if(!t||typeof t!=`object`)return;let n=t.hint;return typeof n==`string`&&n.trim()?n:void 0}function z(e){if(!e||typeof e!=`object`)return null;let t=e,n=L(String(t.name??``));if(!n)return null;let r=F[n],i=r?.category??I[n]??`unknown`,a=ne(t,n),o=t.supported!==!1&&t.disabled!==!0?r?`popup`:i===`unknown`?`pass-through`:`insert`:`unsupported`,s=typeof t.description==`string`&&t.description.trim()?t.description:void 0,c=R(t),l={name:n,displayName:`/${n}`,category:i,actionType:o,source:a,raw:t};return s&&(l.description=s),c&&(l.inputHint=c),r&&(l.popupKind=r.popupKind),o===`unsupported`&&(l.disabledReason=typeof t.disabledReason==`string`&&t.disabledReason.trim()?t.disabledReason:`Unsupported in Code mode`),l}function re(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t){let t=z(e);!t||n.has(t.name)||(n.add(t.name),r.push(t))}return r}function ie(e){return[e.name,e.displayName,e.description??``,e.inputHint??``,e.category,e.source].join(` `).toLowerCase()}function B(e,t){let n=L(t.split(/\s+/)[0]??``).toLowerCase();if(!n)return e;let r=[],i=[];for(let t of e)t.name.toLowerCase().startsWith(n)?r.push(t):ie(t).includes(n)&&i.push(t);return[...r,...i]}function ae({value:e,disabled:t,onChange:n}){let r=x.find(t=>t.value===e)??x[0];return(0,m.jsxs)(`div`,{className:`code-permission-mode-field`,children:[(0,m.jsxs)(`div`,{className:`code-permission-mode-label`,children:[(0,m.jsx)(`span`,{children:`Permission mode`}),(0,m.jsx)(`strong`,{children:`Default: Always allow`})]}),(0,m.jsx)(`div`,{className:`code-permission-mode-list`,role:`listbox`,"aria-label":`Permission mode`,children:x.map(r=>(0,m.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r.value===e,disabled:t,className:`code-permission-mode-option is-${r.tone}${r.value===e?` is-selected`:``}`,title:r.detail,onClick:()=>n(r.value),children:[(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.label}),(0,m.jsx)(`small`,{children:r.detail})]}),r.value===e&&(0,m.jsx)(`em`,{"aria-hidden":`true`,children:`✓`})]},r.value))}),(0,m.jsx)(`p`,{className:`code-permission-mode-note is-${r?.tone??`ask`}`,children:`Automatic modes answer with JWC persistent options and write a transcript audit row.`})]})}function oe(e){return e===`provider`?`Provider`:e===`model`?`Model`:e===`permission`?`Permissions`:e===`session`?`Session`:`Settings`}function V(e){return e===`jwc-cache`?`JWC cache`:`static fallback`}function H({popupKind:e,command:t,modelOptions:n,provider:r,model:i,modelAssignments:a,modelPresets:o,permissionMode:s,disabled:c,activeSessionId:l,error:u,onClose:f,onRefreshProviders:p,onProviderChange:h,onUseModel:g,onUseForNewSessions:_,onSetDefaultModel:v,onSetModelAssignment:y,onClearModelAssignment:b,onPermissionModeChange:x}){let S=(0,d.useRef)(null),C=(0,d.useRef)(null),w=n.providers.find(e=>e.id===r)??n.providers[0],[ee,T]=(0,d.useState)(``),[E,D]=(0,d.useState)(`models`),[O,k]=(0,d.useState)(r),[A,j]=(0,d.useState)(i),[te,M]=(0,d.useState)({}),N=n.providers.find(e=>e.id===O)??w,P=ee.trim().toLowerCase(),F=(0,d.useMemo)(()=>n.providers.filter(e=>P?e.id.toLowerCase().includes(P)||e.models.some(e=>e.toLowerCase().includes(P)):!0),[n.providers,P]),I=(0,d.useMemo)(()=>{let e=N?.models??[];return P?e.filter(e=>e.toLowerCase().includes(P)):e},[N?.models,P]),L=oe(e),ne=(0,d.useMemo)(()=>{let e=n.providers.length;return`${e} authenticated provider${e===1?``:`s`}`},[n.providers.length]),R=!!(l&&O&&A&&!c),z=!!(O&&A&&!c),re=(0,d.useMemo)(()=>[`inherit`,...N?.efforts??[]].map(e=>e===`min`?`minimal`:e).filter((e,t,n)=>e&&n.indexOf(e)===t).map(e=>({value:e,label:e===`inherit`?`inherit`:e===`minimal`?`min`:e})),[N?.efforts]);return(0,d.useEffect)(()=>{S.current?.focus()},[e,t.name]),(0,d.useEffect)(()=>{let e=document.activeElement;return()=>{e?.focus?.()}},[]),(0,d.useEffect)(()=>{e===`model`&&(T(``),k(r),j(i))},[i,e,r]),(0,d.useEffect)(()=>{if(e!==`model`)return;let t=N?.models??[];t.length>0&&!t.includes(A)&&j(t[0]??``)},[A,N?.models,e]),(0,d.useEffect)(()=>{if(e!==`model`||!a)return;let t={};for(let e of a.roles){let n=e.thinkingLevel===`min`?`minimal`:e.thinkingLevel;t[e.role]=n||`inherit`}M(t)},[a,e]),(0,d.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),f();return}if(e.key===`Tab`&&C.current){let t=C.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t[0],r=t[t.length-1];if(!n||!r)return;let i=document.activeElement;e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f]),(0,m.jsx)(`div`,{className:`code-popup-backdrop`,role:`presentation`,onMouseDown:e=>{e.target===e.currentTarget&&f()},children:(0,m.jsxs)(`section`,{ref:C,className:`code-popup`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-command-popup-title`,children:[(0,m.jsxs)(`header`,{className:`code-popup-header`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`p`,{className:`code-popup-command`,children:t.displayName}),(0,m.jsx)(`h2`,{id:`code-command-popup-title`,children:L})]}),(0,m.jsx)(`button`,{ref:S,type:`button`,className:`code-popup-close`,onClick:f,"aria-label":`Close popup`,children:`x`})]}),e===`provider`&&(0,m.jsxs)(`div`,{className:`code-popup-section`,children:[(0,m.jsxs)(`div`,{className:`code-popup-section-head`,children:[(0,m.jsx)(`span`,{children:ne}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:c,onClick:p,children:`Refresh`})]}),n.degraded&&(0,m.jsx)(`p`,{className:`code-popup-warning`,children:n.error??`Provider discovery is degraded.`}),u&&(0,m.jsx)(`p`,{className:`code-popup-error`,children:u}),(0,m.jsx)(`div`,{className:`code-provider-list`,role:`list`,children:n.providers.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`code-provider-row${e.id===r?` is-selected`:``}`,onClick:()=>h(e.id),disabled:c,children:[(0,m.jsx)(`span`,{className:`code-provider-name`,children:e.id}),(0,m.jsxs)(`span`,{className:`code-provider-meta`,children:[e.models.length,` models · `,V(e.modelSource)]})]},e.id))}),(0,m.jsxs)(`div`,{className:`code-popup-placeholder-actions`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`code-popup-secondary`,children:`Add provider`}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`code-popup-secondary`,children:`Login`}),(0,m.jsx)(`span`,{children:`Provider add/login execution is next slice.`})]})]}),(e===`settings`||e===`permission`)&&(0,m.jsxs)(`div`,{className:`code-popup-section`,children:[(0,m.jsx)(ae,{value:s,disabled:!!c,onChange:x}),e===`settings`&&(0,m.jsxs)(`div`,{className:`code-popup-summary`,children:[(0,m.jsx)(`span`,{children:`Provider`}),(0,m.jsx)(`strong`,{children:r||`-`}),(0,m.jsx)(`span`,{children:`Model`}),(0,m.jsx)(`strong`,{children:i||`-`})]})]}),e===`model`&&(0,m.jsxs)(`div`,{className:`code-popup-section`,children:[u&&(0,m.jsx)(`p`,{className:`code-popup-error`,children:u}),(0,m.jsx)(`div`,{className:`code-model-tablist`,role:`tablist`,"aria-label":`Model settings tabs`,children:[`models`,`roles`,`profiles`].map(e=>(0,m.jsx)(`button`,{type:`button`,role:`tab`,id:`code-model-tab-${e}`,"aria-selected":E===e,"aria-controls":`code-model-panel-${e}`,tabIndex:E===e?0:-1,className:`code-model-tab${E===e?` is-active`:``}`,onClick:()=>D(e),onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`)return;e.preventDefault();let t=[`models`,`roles`,`profiles`],n=e.key===`ArrowRight`?1:t.length-1;D(t[(t.indexOf(E)+n)%t.length]??`models`)},children:e===`models`?`Models`:e===`roles`?`Roles`:`Profiles`},e))}),E===`models`&&(0,m.jsxs)(`div`,{className:`code-popup-tabpanel`,role:`tabpanel`,id:`code-model-panel-models`,"aria-labelledby":`code-model-tab-models`,children:[(0,m.jsxs)(`label`,{className:`code-popup-field`,children:[(0,m.jsx)(`span`,{children:`Search models`}),(0,m.jsx)(`input`,{type:`search`,className:`code-model-search`,placeholder:`Search provider or model`,value:ee,onChange:e=>T(e.target.value),disabled:c})]}),n.usageOrder&&n.usageOrder.length>0&&(0,m.jsxs)(`div`,{className:`code-model-mru-strip`,"aria-label":`Recently used models`,children:[(0,m.jsx)(`span`,{children:`Recently used`}),n.usageOrder.slice(0,3).map(e=>(0,m.jsx)(`strong`,{children:e},e))]}),(0,m.jsxs)(`div`,{className:`code-model-layout`,children:[(0,m.jsx)(`div`,{className:`code-model-providers`,role:`list`,"aria-label":`Providers`,children:F.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`code-model-provider${e.id===O?` is-selected`:``}`,onClick:()=>{k(e.id),j(e.models[0]??``)},disabled:c,children:[(0,m.jsx)(`span`,{children:e.id}),(0,m.jsx)(`small`,{children:e.models.length})]},e.id))}),(0,m.jsxs)(`div`,{className:`code-model-list`,role:`list`,"aria-label":`Models`,children:[(0,m.jsxs)(`div`,{className:`code-model-list-head`,children:[(0,m.jsx)(`strong`,{children:N?.id??`No provider`}),(0,m.jsxs)(`span`,{children:[I.length,` models · `,V(N?.modelSource)]})]}),I.length===0?(0,m.jsx)(`p`,{className:`code-popup-note`,children:`No models match this search.`}):I.map(e=>{let t=O===r&&e===i,n=e===A;return(0,m.jsxs)(`button`,{type:`button`,className:`code-model-row${t?` is-active`:``}${n?` is-draft`:``}`,onClick:()=>j(e),disabled:c,children:[(0,m.jsx)(`span`,{children:e}),(0,m.jsx)(`small`,{children:t?`Active`:n?`Selected`:`Available`})]},e)})]})]}),(0,m.jsxs)(`div`,{className:`code-popup-action-row`,children:[(0,m.jsxs)(`div`,{className:`code-popup-summary code-popup-summary-compact`,children:[(0,m.jsx)(`span`,{children:`Active`}),(0,m.jsxs)(`strong`,{children:[r||`-`,` / `,i||`-`]}),(0,m.jsx)(`span`,{children:`Selected`}),(0,m.jsxs)(`strong`,{children:[O||`-`,` / `,A||`-`]}),(0,m.jsx)(`span`,{children:`Default`}),(0,m.jsxs)(`strong`,{children:[n.defaultProvider||`-`,` / `,n.defaultModel||`-`]})]}),(0,m.jsxs)(`div`,{className:`code-popup-action-stack`,children:[(0,m.jsx)(`button`,{type:`button`,className:`code-popup-primary`,disabled:!R,onClick:()=>{g(O,A)},children:`Use now`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!z,onClick:()=>{_(O,A)},children:`Use for new sessions`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!z,onClick:()=>{v(O,A)},children:`Set default`})]})]}),!l&&(0,m.jsx)(`p`,{className:`code-popup-note`,children:`Start or load a Code session to apply a live model. Use “Use for new sessions” to set the next session’s model.`})]}),E===`roles`&&(0,m.jsx)(`div`,{className:`code-popup-tabpanel`,role:`tabpanel`,id:`code-model-panel-roles`,"aria-labelledby":`code-model-tab-roles`,children:(0,m.jsxs)(`div`,{className:`code-role-assignment-panel`,"aria-label":`Model role assignments`,children:[(0,m.jsxs)(`div`,{className:`code-role-assignment-head`,children:[(0,m.jsx)(`strong`,{children:`Role assignments`}),(0,m.jsx)(`span`,{children:a?.activeModel.note??`Role assignments do not mutate the active Code session model.`})]}),(0,m.jsx)(`div`,{className:`code-role-assignment-grid`,role:`list`,children:(a?.roles??[]).map(e=>{let t=e.modelId?e.modelId:`Unset`,n=te[e.role]??(e.thinkingLevel===`min`?`minimal`:e.thinkingLevel)??`inherit`,r=!!(O&&A&&!c),i=!!(e.modelId&&!c);return(0,m.jsxs)(`article`,{className:`code-role-card`,role:`listitem`,children:[(0,m.jsxs)(`div`,{className:`code-role-card-head`,children:[(0,m.jsx)(`span`,{className:`code-role-tag`,children:e.tag}),(0,m.jsx)(`strong`,{children:e.name})]}),(0,m.jsx)(`p`,{className:`code-role-path`,children:e.settingsPath}),(0,m.jsx)(`p`,{className:`code-role-model`,title:t,children:t}),(0,m.jsxs)(`label`,{className:`code-role-thinking`,children:[(0,m.jsx)(`span`,{children:`Thinking`}),(0,m.jsx)(`select`,{value:n,disabled:c,onChange:t=>{let n=t.target.value;M(t=>({...t,[e.role]:n}))},children:re.map(e=>(0,m.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,m.jsxs)(`div`,{className:`code-role-actions`,children:[(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!r,onClick:()=>{y(e.role,O,A,n===`inherit`?null:n)},children:`Assign selected`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!i,onClick:()=>{b(e.role)},children:`Clear`})]})]},e.role)})}),!a&&(0,m.jsx)(`p`,{className:`code-popup-note`,children:`Loading role assignments.`})]})}),E===`profiles`&&(0,m.jsx)(`div`,{className:`code-popup-tabpanel`,role:`tabpanel`,id:`code-model-panel-profiles`,"aria-labelledby":`code-model-tab-profiles`,children:(0,m.jsxs)(`div`,{className:`code-model-preset-panel`,"aria-label":`Model profiles and presets`,children:[(0,m.jsxs)(`div`,{className:`code-role-assignment-head`,children:[(0,m.jsx)(`strong`,{children:`Profiles and presets`}),(0,m.jsx)(`span`,{children:o?.applyReason??`Loading JWC profile state.`})]}),(0,m.jsxs)(`div`,{className:`code-model-preset-summary`,children:[(0,m.jsx)(`span`,{children:`Startup profile`}),(0,m.jsx)(`strong`,{children:o?.defaultProfile??`Unset`}),(0,m.jsx)(`span`,{children:`Task presets`}),(0,m.jsx)(`strong`,{children:o?o.taskPresets.length:`-`}),(0,m.jsx)(`span`,{children:`Built-in profiles`}),(0,m.jsx)(`strong`,{children:o?o.builtinProfiles.length:`-`})]}),o&&o.taskPresets.length>0&&(0,m.jsx)(`div`,{className:`code-model-preset-list`,role:`list`,"aria-label":`Task model presets`,children:o.taskPresets.slice(0,4).map(e=>(0,m.jsxs)(`div`,{className:`code-model-preset-row`,role:`listitem`,children:[(0,m.jsx)(`strong`,{children:e.name}),(0,m.jsx)(`span`,{children:e.best?`best ${e.best}`:`best unset`}),(0,m.jsx)(`span`,{children:e.cheap?`cheap ${e.cheap}`:`cheap unset`})]},e.name))}),o&&(0,m.jsx)(`div`,{className:`code-model-profile-chips`,"aria-label":`Built-in profile candidates`,children:o.builtinProfiles.slice(0,8).map(e=>(0,m.jsx)(`span`,{children:e.name},e.name))}),(0,m.jsxs)(`div`,{className:`code-popup-placeholder-actions`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`code-popup-secondary`,children:`Apply profile`}),(0,m.jsx)(`span`,{children:`Profile activation is read-only here; JWC runtime owns credential checks and rollback.`})]})]})})]})]})})}function se(e,t,n){return n<=0?0:(e+t+n)%n}function U(e){return e.disabledReason?`Disabled`:e.actionType===`popup`?e.popupKind?`${e.popupKind} popup`:`Popup`:e.actionType===`pass-through`?`Pass-through`:e.actionType===`unsupported`?`Unsupported`:`Insert`}function ce(e){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>B(e.availableCommands,e.inputText).slice(0,10),[e.availableCommands,e.inputText]),i=r[t],a=i?`code-command-option-${i.name.replace(/[^a-z0-9_-]/gi,`-`)}`:void 0;(0,d.useEffect)(()=>{n(0)},[e.inputText,e.availableCommands]),(0,d.useEffect)(()=>{t>=r.length&&n(Math.max(0,r.length-1))},[t,r.length]);let o=t=>{!t||t.disabledReason||e.onCommandSelect(t)};return(0,m.jsxs)(`div`,{className:`code-composer`,children:[e.showCommands&&r.length>0&&(0,m.jsx)(`div`,{className:`code-command-palette`,role:`listbox`,"aria-label":`Code commands`,id:`code-command-palette`,children:r.map((e,r)=>{let i=r===t;return(0,m.jsxs)(`button`,{id:`code-command-option-${e.name.replace(/[^a-z0-9_-]/gi,`-`)}`,type:`button`,role:`option`,"aria-selected":i,"aria-disabled":e.disabledReason?!0:void 0,className:`code-command-item${i?` is-active`:``}${e.disabledReason?` is-disabled`:``}`,onMouseEnter:()=>n(r),onClick:()=>o(e),children:[(0,m.jsxs)(`span`,{className:`code-command-row-main`,children:[(0,m.jsx)(`span`,{className:`code-command-name`,children:e.displayName}),e.description&&(0,m.jsx)(`span`,{className:`code-command-desc`,children:e.description})]}),(0,m.jsxs)(`span`,{className:`code-command-row-meta`,children:[(0,m.jsx)(`span`,{className:`code-command-chip`,children:e.category}),(0,m.jsx)(`span`,{className:`code-command-chip`,children:e.source}),(0,m.jsx)(`span`,{className:`code-command-chip`,children:U(e)})]})]},e.name)})}),(0,m.jsxs)(`div`,{className:`code-composer-input-shell`,children:[(0,m.jsx)(`textarea`,{className:`code-composer-input`,value:e.inputText,onChange:t=>e.onInputChange(t.target.value),onKeyDown:t=>{if(t.key===`Escape`&&e.showCommands){t.preventDefault(),e.onShowCommandsChange(!1);return}if(e.showCommands&&r.length>0){if(t.key===`ArrowDown`){t.preventDefault(),n(e=>se(e,1,r.length));return}if(t.key===`ArrowUp`){t.preventDefault(),n(e=>se(e,-1,r.length));return}if(t.key===`Enter`&&!t.shiftKey){t.preventDefault(),o(i);return}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.onSubmit())},"aria-controls":e.showCommands?`code-command-palette`:void 0,"aria-activedescendant":e.showCommands?a:void 0,"aria-expanded":e.showCommands,placeholder:`Describe a task or ask a question...`,rows:1,disabled:e.sending}),(0,m.jsx)(`span`,{className:`code-composer-hint`,children:`Enter to send · / for commands`})]}),(0,m.jsx)(`button`,{type:`button`,className:`code-composer-send`,onClick:e.onSubmit,disabled:!e.inputText.trim()||e.sending,"aria-label":`Send prompt`,children:`Send`})]})}function le({permissions:e,onAnswer:t}){return e.length===0?null:(0,m.jsx)(`div`,{className:`code-permissions`,children:e.map(e=>(0,m.jsxs)(`div`,{className:`code-permission-card`,children:[(0,m.jsxs)(`div`,{className:`code-permission-title`,children:[(0,m.jsx)(`span`,{children:`Permission request`}),(0,m.jsx)(`strong`,{children:D(e.toolCall)}),(0,m.jsxs)(`small`,{children:[e.options.length,` JWC options`]})]}),(0,m.jsx)(`div`,{className:`code-permission-actions`,children:v.map(n=>{let r=E(e.options,n),i=b[n];return(0,m.jsx)(`button`,{type:`button`,className:`code-permission-btn is-${i}`,disabled:!r,title:r?r.optionId:`${y[n]} option was not provided by JWC`,onClick:()=>t(e,n),children:r?.label??y[n]},n)})})]},e.permissionId))})}var W=92,ue=6;function de(e){let[{virtualItems:t,totalSize:s},c]=(0,d.useState)({virtualItems:[],totalSize:0}),l=(0,d.useRef)(null);l.current||=new o({count:e.count,getScrollElement:()=>e.scrollElementRef.current,estimateSize:e.estimateSize||(()=>W),overscan:ue,getItemKey:e.getItemKey,indexAttribute:`data-code-transcript-idx`,useAnimationFrameWithResizeObserver:!0,observeElementRect:n,observeElementOffset:r,scrollToFn:i,measureElement:a,onChange:e=>{c({virtualItems:e.getVirtualItems(),totalSize:e.getTotalSize()})}});let u=l.current;return(0,d.useEffect)(()=>u._didMount(),[u]),(0,d.useLayoutEffect)(()=>{u.setOptions({...u.options,count:e.count,getItemKey:e.getItemKey,estimateSize:e.estimateSize||(()=>W)}),u._willUpdate(),c({virtualItems:u.getVirtualItems(),totalSize:u.getTotalSize()})},[e.count,e.estimateSize,e.getItemKey,u]),{measureElement:e=>{e&&u.measureElement(e)},virtualItems:t,totalSize:s}}var fe=(0,d.lazy)(()=>t(()=>import(`./MarkdownRenderer-BivJ4hJm.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0])));function pe(e,t){let n=e.label??(e.type===`args`?`Args`:e.type===`output`?`Output`:e.type===`error`?`Error`:``),r=`code-tool-${e.type}`,i=e.type===`diff`&&e.diff?e.diff:e.type===`json`||e.type===`args`?JSON.stringify(e.json??e,null,2):e.text??JSON.stringify(e,null,2);return n?(0,m.jsxs)(`div`,{className:`code-tool-section`,children:[(0,m.jsx)(`span`,{className:`code-tool-section-label`,children:n}),(0,m.jsx)(`pre`,{className:r,children:i})]},t):e.type===`diff`&&e.diff?(0,m.jsx)(`pre`,{className:`code-tool-diff`,children:e.diff},t):e.text?(0,m.jsx)(`pre`,{className:`code-tool-text`,children:e.text},t):(0,m.jsx)(`pre`,{className:r,children:i},t)}function me(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function G(e){return(e.toolContent?.find(e=>typeof e.text==`string`&&e.text.trim())?.text??e.toolOutput??``).replace(/\s+/g,` `).trim().slice(0,240)}function he(e){return e.split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()??``}function ge(e){let t=e.toolContent?.find(e=>e.type===`args`||e.type===`text`||e.type===`json`);if(!t)return null;if(typeof t.text==`string`){let e=he(t.text);return e?{text:e,...t.type===`args`?{name:`bash`}:/^https?:\/\//.test(e)||e.startsWith(`/`)?{name:`read`}:{}}:null}if(typeof t.json==`string`){let e=he(t.json);return e?{text:e,...t.type===`args`?{name:`bash`}:{}}:null}if(t.json&&typeof t.json==`object`&&!Array.isArray(t.json)){let e=t.json;for(let[t,n]of[[`command`,`bash`],[`cmd`,`bash`],[`path`,`read`],[`url`,`read`],[`file`,`read`],[`query`,`search`]]){let r=e[t];if(typeof r==`string`&&r.trim())return{name:n,text:he(r)}}}return null}function _e(e){let t=he(e.toolName||e.text||`tool`)||`tool`,n=ge(e);return t.includes(`:`)||!n?t:t===`tool`?n.name?`${n.name}: ${n.text}`:n.text:`${t}: ${n.text}`}function ve(e){return e===`pending`?`Pending`:e===`allow_once`?`Allow once`:e===`allow_always`?`Always allow`:e===`reject_once`?`Deny once`:e===`reject_always`?`Always deny`:e===`missing_option`?`Missing JWC option`:e===`answer_error`?`Answer failed`:`Cancelled`}function K(e,t){return`${t}:${e.toolCallId||e.permissionAudit?.permissionId||`${e.role}:${e.text.slice(0,48)}`}`}function ye(e){return e?e.role===`tool`?e.toolStatus===`running`?44:64+Math.min(320,(e.toolOutput?.length??0)/5):e.role===`permission`?72:e.role===`thinking`?48+Math.min(180,e.text.length/8):56+Math.min(420,e.text.length/6):48}function q(e,t,n){return(0,m.jsx)(`div`,{className:`code-message code-message-${e.role}`,children:e.role===`tool`?(()=>{let t=e.toolStatus??`done`,n=t===`failed`||t===`error`,r=n?G(e):``;return(0,m.jsxs)(`details`,{className:`code-tool-card code-tool-${t}`,open:t===`running`||n,children:[(0,m.jsxs)(`summary`,{className:`code-tool-summary`,children:[(0,m.jsx)(`span`,{className:`code-tool-chevron`,children:`>`}),(0,m.jsx)(`span`,{className:`code-tool-name`,children:_e(e)}),(0,m.jsx)(`span`,{className:`code-tool-status`,children:t})]}),r&&(0,m.jsx)(`div`,{className:`code-tool-error-snippet`,children:r}),(e.toolContent?.length??0)>0&&(0,m.jsx)(`div`,{className:`code-tool-content`,children:e.toolContent.map(pe)}),e.toolOutput&&(0,m.jsxs)(`pre`,{className:`code-tool-output`,children:[e.toolOutput.slice(0,2e3),e.toolOutput.length>2e3?`...`:``]})]})})():e.role===`permission`&&e.permissionAudit?(()=>{let t=e.permissionAudit,n=t.decision.startsWith(`allow`)?`is-allow`:t.decision.startsWith(`reject`)?`is-deny`:``;return(0,m.jsxs)(`div`,{className:`code-permission-audit is-${t.decision} ${n}`.trim(),children:[(0,m.jsxs)(`div`,{className:`code-permission-audit-head`,children:[(0,m.jsx)(`span`,{children:`Permission`}),(0,m.jsx)(`strong`,{children:t.toolName}),(0,m.jsx)(`em`,{children:ve(t.decision)})]}),(0,m.jsxs)(`div`,{className:`code-permission-audit-meta`,children:[(0,m.jsxs)(`span`,{children:[`mode `,t.mode]}),(0,m.jsx)(`span`,{children:t.decisionMode}),t.optionId&&(0,m.jsx)(`span`,{children:t.optionId})]}),t.error&&(0,m.jsx)(`div`,{className:`code-permission-audit-error`,children:t.error})]})})():e.role===`thinking`?(0,m.jsxs)(`details`,{className:`code-thinking`,children:[(0,m.jsx)(`summary`,{className:`code-thinking-summary`,children:`Thinking...`}),(0,m.jsx)(`div`,{className:`code-thinking-text`,children:e.text})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`code-message-role`,children:e.role===`user`?`You`:`JWC`}),(0,m.jsx)(`div`,{className:`code-message-text`,children:e.role===`assistant`?(0,m.jsx)(d.Suspense,{fallback:(0,m.jsx)(`span`,{children:e.text}),children:(0,m.jsx)(fe,{markdown:e.text,tableMode:`linear`,onLocalFileOpen:n})}):e.text})]})},t)}function J(){return(0,m.jsxs)(`div`,{className:`code-message code-message-assistant`,children:[(0,m.jsx)(`span`,{className:`code-message-role`,children:`JWC`}),(0,m.jsx)(`div`,{className:`code-message-text code-streaming`,children:`Thinking...`})]})}function Y({messages:e,sending:t,workingDir:n,transcriptRef:r,onOpenLocalFile:i}){let a=t&&e[e.length-1]?.role!==`assistant`,o=de({count:e.length+ +!!a,scrollElementRef:r,getItemKey:(0,d.useCallback)(t=>{let n=e[t];return n?K(n,t):`sending-${t}`},[e]),estimateSize:(0,d.useCallback)(t=>ye(e[t]),[e])});function s(e){if(me(e.target))return;let t=r.current;if(!t)return;let n=e.key.toLowerCase(),i=Math.max(160,Math.floor(t.clientHeight*.78));n===`d`||n===`j`||e.key===`PageDown`?(e.preventDefault(),t.scrollBy({top:i,behavior:`smooth`})):n===`u`||n===`k`||e.key===`PageUp`?(e.preventDefault(),t.scrollBy({top:-i,behavior:`smooth`})):e.key===`End`?(e.preventDefault(),t.scrollTo({top:t.scrollHeight,behavior:`smooth`})):e.key===`Home`&&(e.preventDefault(),t.scrollTo({top:0,behavior:`smooth`}))}return(0,m.jsx)(`div`,{className:`code-transcript`,ref:r,role:`log`,"aria-live":`polite`,tabIndex:0,onKeyDown:s,children:e.length===0?(0,m.jsxs)(`div`,{className:`code-transcript-empty`,children:[(0,m.jsx)(`p`,{children:`Start a Code session by typing a prompt below.`}),(0,m.jsxs)(`p`,{className:`code-transcript-cwd`,children:[`cwd: `,n||`not set`]})]}):(0,m.jsx)(`div`,{className:`code-transcript-virtual-spacer`,style:{height:`${o.totalSize}px`},children:o.virtualItems.map(t=>{let n=e[t.index];return(0,m.jsx)(`div`,{ref:o.measureElement,className:`code-transcript-virtual-row`,"data-code-transcript-idx":t.index,style:{transform:`translateY(${t.start}px)`},children:n?q(n,t.index,i):J()},t.key)})})})}function X(e){return e.split(`/`).filter(Boolean).slice(-2).join(`/`)||e}function be({workingDir:e,gitInfo:t,modelOptions:n,sessionTitle:r,usage:i,planEntries:a,onWorkingDirChange:o,cwdLocked:s=!1,workspaceFrozen:c=!1,onPickWorkingDir:l}){let[u,f]=(0,d.useState)(!1),[p,h]=(0,d.useState)(``),g=t?.status?.dirty,_=t?.worktrees.length??0,v=c||s,y=!!(!v&&l&&o);async function b(){if(!(!y||!l)){f(!0),h(``);try{let e=await l();e&&o?.(e)}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return(0,m.jsxs)(`div`,{className:`code-workspace-header`,children:[(0,m.jsxs)(`div`,{className:`code-workspace-primary`,children:[v?(0,m.jsx)(`span`,{className:`code-workspace-chip`,title:e,"aria-label":`Current Code workspace: ${e}`,children:X(e||`/tmp`)}):(0,m.jsxs)(`button`,{type:`button`,className:`code-workspace-picker`,disabled:!y||u,title:e||`Select Code workspace folder`,"aria-label":`Code workspace: ${e||`not set`}. Choose a folder.`,onClick:()=>void b(),children:[(0,m.jsx)(`span`,{className:`code-workspace-picker-label`,children:X(e||`/tmp`)}),(0,m.jsx)(`span`,{className:`code-workspace-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),!v&&p&&(0,m.jsx)(`span`,{className:`code-workspace-cwd-error`,children:p}),t?.isRepo&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`code-workspace-pill`,children:[t.branch??`detached`,t.head?` · ${t.head}`:``]}),(0,m.jsx)(`span`,{className:`code-workspace-pill ${g?`is-dirty`:``}`,children:g?`${t.status?.changed??0} changed · ${t.status?.untracked??0} untracked`:`clean`}),(0,m.jsxs)(`span`,{className:`code-workspace-pill`,title:t.currentWorktree?.path??void 0,children:[`worktree `,_]})]}),n?.degraded&&(0,m.jsx)(`span`,{className:`code-workspace-pill is-warning`,title:n.error,children:`provider fallback`})]}),(r||i.contextTokens!==void 0||a.length>0)&&(0,m.jsxs)(`div`,{className:`code-session-header`,children:[r&&(0,m.jsx)(`span`,{className:`code-session-title`,children:r}),i.contextTokens!==void 0&&i.contextLimit?(0,m.jsx)(`span`,{className:`code-context-meter`,title:`${i.contextTokens.toLocaleString()} / ${i.contextLimit.toLocaleString()} tokens${i.cost===void 0?``:` · $${i.cost.toFixed(4)}`}`,children:(0,m.jsx)(`span`,{className:`code-context-bar`,style:{width:`${Math.min(100,i.contextTokens/i.contextLimit*100)}%`}})}):null,a.length>0&&(0,m.jsx)(`div`,{className:`code-plan-entries`,children:a.map((e,t)=>(0,m.jsxs)(`span`,{className:`code-plan-entry code-plan-${e.status}`,children:[e.status===`completed`?`✓`:e.status===`in_progress`?`↻`:`○`,` `,e.title]},t))})]})]})}function xe({label:e,value:t,options:n,disabled:r,title:i,className:a=``,onChange:o}){let s=(0,d.useId)(),c=(0,d.useRef)(null),[l,u]=(0,d.useState)(!1),f=n.find(e=>e.value===t)??n[0],p=Math.max(0,n.findIndex(e=>e.value===f?.value));(0,d.useEffect)(()=>{if(!l)return;let e=e=>{c.current?.contains(e.target)||u(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[l]);let h=e=>{o(e),u(!1)};return(0,m.jsxs)(`div`,{ref:c,className:`code-footer-menu ${a}`.trim(),children:[(0,m.jsxs)(`button`,{type:`button`,className:`code-footer-menu-trigger`,disabled:r,title:i,"aria-label":e,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":s,onClick:()=>u(e=>!e),onKeyDown:e=>{if(!r){if(e.key===`Escape`){u(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=n[(p+(e.key===`ArrowDown`?1:-1)+n.length)%n.length];t&&h(t.value);return}(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))}},children:[(0,m.jsx)(`span`,{className:`code-footer-label`,children:e}),(0,m.jsx)(`strong`,{children:f?.label??t}),(0,m.jsx)(`span`,{className:`code-footer-chevron`,"aria-hidden":`true`,children:`⌃`})]}),l&&(0,m.jsx)(`div`,{id:s,className:`code-footer-dropup`,role:`listbox`,"aria-label":e,children:n.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`code-footer-dropup-option${e.value===t?` is-selected`:``}`,role:`option`,"aria-selected":e.value===t,onClick:()=>h(e.value),children:[(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:e.label}),e.detail&&(0,m.jsx)(`small`,{children:e.detail})]}),e.value===t&&(0,m.jsx)(`em`,{"aria-hidden":`true`,children:`✓`})]},e.value))})]})}function Se({provider:e,providerOptions:t,model:n,modelOptions:r,effort:i,effortOptions:a,permissionMode:o,disabled:s,onProviderChange:c,onModelChange:l,onEffortChange:u,onPermissionModeChange:d}){return(0,m.jsxs)(`div`,{className:`code-composer-footer`,children:[(0,m.jsx)(xe,{label:`Permission`,value:o,options:x,disabled:s,title:S[o],onChange:d}),t.length>0&&(0,m.jsx)(xe,{label:`Provider`,value:e,options:t.map(e=>({value:e,label:e})),disabled:s,title:e,onChange:c}),(0,m.jsx)(xe,{label:`Model`,value:n,options:r.map(e=>({value:e,label:e})),disabled:s,title:n,className:`code-footer-field-model`,onChange:l}),a.length>0&&(0,m.jsx)(xe,{label:`Effort`,value:i,options:a.map(e=>({value:e,label:e})),disabled:s,title:i,onChange:u})]})}function Ce(e){return(0,m.jsxs)(`div`,{className:`code-canvas-main`,children:[(0,m.jsx)(be,{gitInfo:e.gitInfo,modelOptions:e.modelOptions,sessionTitle:e.sessionTitle,usage:e.usage,planEntries:e.planEntries,workingDir:e.codeWorkingDir,cwdLocked:!!e.activeSessionId,onWorkingDirChange:e.onWorkingDirChange,workspaceFrozen:e.workspaceFrozen,onPickWorkingDir:e.onPickWorkingDir}),e.childRecovery&&(0,m.jsxs)(`section`,{className:`code-child-recovery`,role:`status`,"aria-live":`polite`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{children:`JWC child recovery`}),(0,m.jsxs)(`strong`,{children:[`ACP child exited: `,e.childRecovery.code]})]}),(0,m.jsx)(`p`,{children:e.childRecovery.message})]}),e.transportState!==`connected`&&(0,m.jsx)(`section`,{className:`code-transport-status is-${e.transportState}`,role:`status`,"aria-live":`polite`,children:e.transportState===`reconnecting`?`Live updates reconnecting…`:`Live updates disconnected — retrying.`}),(0,m.jsx)(Y,{messages:e.messages,sending:e.sending,workingDir:e.codeWorkingDir,transcriptRef:e.transcriptRef,onOpenLocalFile:e.onOpenLocalFile}),(0,m.jsx)(le,{permissions:e.permissions,onAnswer:e.onPermissionAnswer}),(0,m.jsx)(`div`,{className:`code-composer-dock`,children:(0,m.jsxs)(`div`,{className:`code-composer-surface`,"aria-label":`Code composer controls`,children:[(0,m.jsx)(ce,{inputText:e.inputText,sending:e.sending,showCommands:e.showCommands,availableCommands:e.availableCommands,onInputChange:e.onInputChange,onCommandSelect:e.onCommandSelect,onSubmit:e.onSubmit,onShowCommandsChange:e.onShowCommandsChange}),(0,m.jsx)(Se,{provider:e.provider,providerOptions:e.providerOptions,model:e.model,modelOptions:e.currentModelOptions,effort:e.effort,effortOptions:e.currentEffortOptions,permissionMode:e.permissionMode,disabled:e.disabled,onProviderChange:e.onFooterProviderChange,onModelChange:e.onModelChange,onEffortChange:e.onEffortChange,onPermissionModeChange:e.onPermissionModeChange})]})}),e.activePopup&&(0,m.jsx)(H,{popupKind:e.activePopup.kind,command:e.activePopup.command,modelOptions:e.modelOptions,provider:e.provider,model:e.model,modelAssignments:e.modelAssignments,modelPresets:e.modelPresets,permissionMode:e.permissionMode,disabled:e.disabled,activeSessionId:e.activeSessionId,error:e.error,onClose:e.onClosePopup,onRefreshProviders:e.onRefreshProviders,onProviderChange:e.onProviderChange,onUseModel:e.onUseModel,onUseForNewSessions:e.onUseForNewSessions,onSetDefaultModel:e.onSetDefaultModel,onSetModelAssignment:e.onSetModelAssignment,onClearModelAssignment:e.onClearModelAssignment,onPermissionModeChange:e.onPermissionModeChange})]})}var we={providers:[{id:`anthropic`,models:[`claude-sonnet-4-6`,`claude-opus-4-8`,`claude-opus-4-7`,`claude-opus-4-6`,`claude-haiku-4-5`,`claude-fable-5`],efforts:[`off`,`min`,`low`,`medium`,`high`,`xhigh`]}],defaultProvider:`anthropic`,defaultModel:`claude-sonnet-4-6`,degraded:!0},Te=re([{name:`/model`,description:`Choose provider, model, roles, thinking, profiles, and MRU state.`,source:`cli-jaw`},{name:`/provider`,description:`Review authenticated JWC providers.`,source:`cli-jaw`},{name:`/settings`,description:`Adjust Code mode session controls.`,source:`cli-jaw`}]);function Ee(e){let t=new Set,n=[];for(let r of[...e,...Te])t.has(r.name)||(t.add(r.name),n.push(r));return n}function De(e,t,n,r){if(r.appendMessage(O(n,{mode:t,decision:`pending`,decisionMode:t===`ask`?`pending`:`automatic`})),t===`ask`){r.enqueuePermission(n);return}let i=t===`always-allow`?`allow_always`:`reject_always`,a=E(n.options,i);if(!a){r.appendMessage(O(n,{mode:t,decision:`missing_option`,decisionMode:`system`,error:`${i} was not provided by JWC for this request.`})),r.enqueuePermission(n);return}(async()=>{try{await e.answerPermission(n.permissionId,a.optionId),r.appendMessage(O(n,{mode:t,decision:i,decisionMode:`automatic`,optionId:a.optionId,optionLabel:a.label}))}catch(e){r.appendMessage(O(n,{mode:t,decision:`answer_error`,decisionMode:`system`,optionId:a.optionId,optionLabel:a.label,error:e instanceof Error?e.message:String(e)}))}})()}async function Oe(e,t,n,r,i){let a=E(n.options,r);if(!a)return i(O(n,{mode:t,decision:`missing_option`,decisionMode:`system`,error:`${r} was not provided by JWC for this request.`})),!1;try{await e.answerPermission(n.permissionId,a.optionId),i(O(n,{mode:t,decision:r,decisionMode:`manual`,optionId:a.optionId,optionLabel:a.label}))}catch(e){i(O(n,{mode:t,decision:`answer_error`,decisionMode:`system`,optionId:a.optionId,optionLabel:a.label,error:e instanceof Error?e.message:String(e)}))}return!0}var ke=new Set([`code_user_message_chunk`,`code_agent_message_chunk`,`code_agent_thought_chunk`]);function Ae(e){let t=e?.content;return String(t?.text??e?.text??``)}function Z(e){let t=e?.messageId;return typeof t==`string`?t.trim():``}function je(e,t){if(!ke.has(e.event)||!t)return null;let n=Z(e.update??{}),r=typeof e.sseEventId==`string`&&e.sseEventId.trim()?e.sseEventId.trim():``,i=n?`msg:${n}`:r?`sse:${r}`:``;return i?`${e.sessionId??``}:${e.event}:${i}:${t}`:null}function Me(e,t){for(let n of t){let t=je(n,Ae(n.update));t&&e.add(t)}}function Ne(e,t,n){let r=je(t,n);return r?e.has(r)?!0:(e.add(r),!1):!1}function Pe(e,t){let n=e.trim(),r=t.trim();return r.length<80?!1:n===r}var Q=80,Fe=.7,Ie=.78,Le=32,Re=8;function ze(e){return e.replace(/\s+/g,` `).trim()}function Be(e){return e.split(/\r?\n/).map(e=>e.replace(/\s+/g,` `).trim()).filter(e=>e.length>=4)}function $(e,t){if(e.length===0)return 0;let n=0;for(let r of e)t.has(r)&&(n+=1);return n/e.length}function Ve(e){let t=ze(e);if(t.length<Le)return[];let n=[];for(let e=0;e<=t.length-Le;e+=Re)n.push(t.slice(e,e+Le));return n}function He(e,t){let n=ze(e),r=ze(t);if(n.length<Q||r.length<Q)return!1;if(r.includes(n))return!0;let i=Be(e),a=new Set(Be(t));if(i.length>=4&&$(i,a)>=Fe)return!0;let o=Ve(n);return o.length<3?!1:$(o,new Set(Ve(r)))>=Ie}function Ue(e,t){return!e||!t?`append`:e===t?`drop`:t.startsWith(e)?`replace`:e.startsWith(t)?`drop`:t.length>=e.length&&He(e,t)?`replace`:e.length>t.length&&He(t,e)?`drop`:`append`}function We(e){let t=e.toLowerCase();return t===`failed`||t===`error`||t===`errored`?`failed`:t===`completed`||t===`done`||t===`success`?`done`:`running`}function Ge(e){let t=[];for(let n of e){let e=n.update??{};if(n.event===`code_user_message_chunk`){let n=e.content,r=String(n?.text??e.text??``),i=Z(e);r&&t.push({role:`user`,text:r,...i?{messageId:i}:{}})}else if(n.event===`code_agent_message_chunk`){let n=e.content,r=String(n?.text??e.text??``);if(!r)continue;let i=Z(e),a=t[t.length-1];if(a?.role===`assistant`){let e=Ue(a.text,r);if(a.messageId&&i&&a.messageId!==i){if(e===`replace`){a.text=r,a.messageId=i;continue}t.push({role:`assistant`,text:r,messageId:i});continue}if(e===`drop`)continue;a.text=e===`replace`?r:a.text+r,i&&!a.messageId&&(a.messageId=i)}else t.push({role:`assistant`,text:r,...i?{messageId:i}:{}})}else if(n.event===`code_agent_thought_chunk`){let n=e.content,r=String(n?.text??e.text??``);if(!r)continue;let i=Z(e),a=t[t.length-1];a?.role===`thinking`&&(!a.messageId||!i||a.messageId===i)?(a.text+=r,i&&!a.messageId&&(a.messageId=i)):t.push({role:`thinking`,text:r,...i?{messageId:i}:{}})}else if(n.event===`code_tool_call`){let n=String(e.title??e.toolName??`tool`),r=String(e.toolCallId??``),i=String(e.status??`pending`),a=P(e);t.push({role:`tool`,text:n,toolName:n,toolCallId:r,toolContent:a,toolStatus:We(i)})}else if(n.event===`code_tool_call_update`){let n=String(e.toolCallId??``),r=String(e.status??``),i=P(e),a=g(t,n);if(a<0)continue;let o={...t[a]};r&&(o.toolStatus=We(r)),i.length>0&&(o.toolContent=i),t[a]=o}}return t}function Ke(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function qe(e,t,n){let r=(0,d.useRef)(null),i=(0,d.useMemo)(()=>{let t=e[e.length-1];if(!t)return`empty`;let n=t.toolContent?.reduce((e,t)=>e+JSON.stringify(t).length,0)??0;return`${e.length}:${t.role}:${t.text.length}:${t.toolOutput?.length??0}:${n}:${t.toolStatus??``}`},[e]),a=(0,d.useCallback)((e=`smooth`)=>{window.requestAnimationFrame(()=>{let t=r.current;t&&(t.scrollTo({top:t.scrollHeight,behavior:e}),window.setTimeout(()=>{let e=r.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},80))})},[]),o=(0,d.useCallback)((e,t=`smooth`)=>{window.requestAnimationFrame(()=>{let n=r.current;n&&n.scrollBy({top:e,behavior:t})})},[]),s=(0,d.useCallback)((e=`smooth`)=>{window.requestAnimationFrame(()=>{let t=r.current;t&&t.scrollTo({top:0,behavior:e})})},[]);return(0,d.useEffect)(()=>{a(e.length>1?`smooth`:`auto`)},[i,e.length,t,a]),(0,d.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||n||e.metaKey||e.ctrlKey||e.altKey||Ke(e.target))return;let t=r.current;if(!t)return;let i=e.key.toLowerCase(),c=Math.max(160,Math.floor(t.clientHeight*.78));i===`d`||i===`j`||e.key===`PageDown`?(e.preventDefault(),o(c)):i===`u`||i===`k`||e.key===`PageUp`?(e.preventDefault(),o(-c)):e.key===`End`?(e.preventDefault(),a(`smooth`)):e.key===`Home`&&(e.preventDefault(),s(`smooth`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,o,a,s]),{transcriptRef:r,scrollTranscriptToBottom:a}}function Je(e){return typeof window<`u`&&window.location.port===String(e)?`${window.location.origin}/api/events`:`http://127.0.0.1:${e}/api/events`}function Ye({port:e,sessionId:t,sessionIdRef:n,onEvent:r,onTransport:i}){let a=(0,d.useRef)(r);a.current=r;let o=(0,d.useRef)(i);o.current=i;let s=(0,d.useRef)(t);s.current=t,(0,d.useEffect)(()=>{if(!e)return;let t=new EventSource(Je(e));return t.onopen=()=>{o.current?.(`connected`)},t.onmessage=e=>{try{let t={...JSON.parse(e.data),sseEventId:e.lastEventId||void 0};if(t.topic!==`jwc`)return;let r=t.event===`code_child_exit`,i=n?.current??s.current;if(!i&&!r||!r&&t.sessionId&&t.sessionId!==i)return;a.current(t)}catch{}},t.onerror=()=>{o.current?.(t.readyState===EventSource.CLOSED?`disconnected`:`reconnecting`)},()=>t.close()},[e])}function Xe({port:e,workingDir:t,onWorkingDirChange:n,onOpenLocalFile:r}){let i=(0,d.useMemo)(()=>p(e),[e]),[a,o]=(0,d.useState)(t),[s,c]=(0,d.useState)(null),[l,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)([]),[ee,T]=(0,d.useState)([]),[E,D]=(0,d.useState)(Te),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(null),[te,M]=(0,d.useState)(``),[N,F]=(0,d.useState)(``),[I,L]=(0,d.useState)({}),[ne,R]=(0,d.useState)([]),[z,ie]=(0,d.useState)(`anthropic`),[B,ae]=(0,d.useState)(`claude-sonnet-4-6`),[oe,V]=(0,d.useState)(`high`),[H,se]=(0,d.useState)(`always-allow`),[U,ce]=(0,d.useState)(we),[le,W]=(0,d.useState)(null),[ue,de]=(0,d.useState)(null),[fe,pe]=(0,d.useState)(null),[me,G]=(0,d.useState)(null),[he,ge]=(0,d.useState)(`connected`),[_e,ve]=(0,d.useState)(null),K=(0,d.useRef)(null),ye=(0,d.useRef)(!1),q=(0,d.useRef)(null),J=(0,d.useRef)(null),Y=(0,d.useRef)(new Set),X=(0,d.useRef)(new Set),be=(0,d.useMemo)(()=>B?_(z,B):``,[z,B]),{transcriptRef:xe,scrollTranscriptToBottom:Se}=qe(C,x,!!A);(0,d.useEffect)(()=>{K.current||s||o(t)},[s,t]);let ke=(0,d.useCallback)(e=>{K.current||s||l||(o(e??``),n?.(e))},[s,n,l]),je=(0,d.useCallback)(async()=>{let e=u();if(e?.folder?.pickFolder){let t=await e.folder.pickFolder();if(t.ok&&t.path)return t.path;if(t.error&&t.error!==`cancelled`)throw Error(t.error);return null}let t=await i.pickWorkspace();return t.ok&&t.path?t.path:null},[i]),Q=(0,d.useCallback)(e=>{ce(e);let t=e.providers.find(t=>t.id===e.defaultProvider)??e.providers[0],n=t?.models.includes(e.defaultModel)?e.defaultModel:t?.models[0]??``;ie(t?.id??`anthropic`),ae(n);let r=t?.efforts??[];r.length>0&&V(r.includes(`high`)?`high`:r[0]??``)},[]);(0,d.useEffect)(()=>{K.current=s},[s]),(0,d.useEffect)(()=>{if(typeof document>`u`){ve(null);return}return ve(document.getElementById(`code-session-sidebar-host`)),()=>ve(null)},[]);let Fe=(0,d.useCallback)(async()=>{Q(await i.listModelOptions())},[Q,i]),Ie=(0,d.useCallback)(async()=>{W(await i.listModelAssignments())},[i]);(0,d.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,n,r]=await Promise.all([i.listModelOptions(),i.listModelAssignments(),i.listModelPresets()]);if(e)return;Q(t),W(n),de(r)}catch(t){e||(ce({...we,error:t instanceof Error?t.message:String(t)}),W(null),de(null))}})(),()=>{e=!0}},[Q,i]),(0,d.useEffect)(()=>{if(!a){pe(null);return}let e=!1;return i.getGitInfo(a).then(t=>{e||pe(t)},()=>{e||pe(null)}),()=>{e=!0}},[i,a]),(0,d.useEffect)(()=>{if(ye.current){ye.current=!1;return}c(null),K.current=null,w([]),T([]),R([]),F(``),L({}),S(!1),G(null),X.current=new Set},[a]),Ye({port:e,sessionId:s,sessionIdRef:K,onEvent:(0,d.useCallback)(e=>{let t=e.update??{},n=e.event;if(!(J.current&&e.sessionId===J.current&&n!==`code_child_exit`)){if(n===`code_agent_message_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Ne(X.current,e,n))return;w(e=>{if(Y.current.has(n)&&e[e.length-1]?.role===`user`)return Y.current.delete(n),e;let t=e[e.length-1];if(t?.role===`assistant`&&Pe(t.text,n))return e;if(t?.role===`assistant`){let i=Ue(t.text,n);if(t.messageId&&r&&t.messageId!==r)return i===`replace`?[...e.slice(0,-1),{...t,text:n,messageId:r}]:[...e,{role:`assistant`,text:n,messageId:r}];if(i===`drop`)return e;let a=i===`replace`?n:t.text+n;return[...e.slice(0,-1),{...t,text:a,...r&&!t.messageId?{messageId:r}:{}}]}return[...e,{role:`assistant`,text:n,...r?{messageId:r}:{}}]})}else if(n===`code_user_message_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Ne(X.current,e,n))return;w(e=>{if(q.current===n){let t=-1;for(let r=e.length-1;r>=0;--r){let i=e[r];if(i?.role===`user`&&i.text===n&&i.transient===`pending-user-echo`){t=r;break}}if(t>=0){q.current=null;let i=[...e];return i[t]={role:`user`,text:n,...r?{messageId:r}:{}},i}}return[...e,{role:`user`,text:n,...r?{messageId:r}:{}}]})}else if(n===`code_agent_thought_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Ne(X.current,e,n))return;w(e=>{let t=e[e.length-1];return t?.role===`thinking`&&(!t.messageId||!r||t.messageId===r)?[...e.slice(0,-1),{...t,text:t.text+n,...r&&!t.messageId?{messageId:r}:{}}]:[...e,{role:`thinking`,text:n,...r?{messageId:r}:{}}]})}else if(n===`code_tool_call`){let e=String(t.title??t.toolName??`tool`),n=String(t.toolCallId??``),r=String(t.status??`pending`),i=P(t);w(t=>[...t,{role:`tool`,text:e,toolName:e,toolCallId:n,toolContent:i,toolStatus:We(r)}])}else if(n===`code_tool_call_update`){let e=String(t.toolCallId??``),n=String(t.status??``),r=P(t);w(t=>{let i=g(t,e);if(i<0)return t;let a=[...t],o={...a[i]};return n&&(o.toolStatus=We(n)),r.length>0&&(o.toolContent=r),a[i]=o,a})}else if(n===`code_permission_request`){let t=String(e.permissionId??``),n=e.toolCall??{},r=e.options??[];t&&De(i,H,{permissionId:t,toolCall:n,options:r},{appendMessage:e=>w(t=>[...t,e]),enqueuePermission:e=>T(t=>[...t,e])})}else if(n===`code_session_info_update`){let e=t.title;typeof e==`string`&&F(e)}else if(n===`code_usage_update`){let e={};typeof t.contextTokens==`number`&&(e.contextTokens=t.contextTokens),typeof t.contextLimit==`number`&&(e.contextLimit=t.contextLimit),typeof t.totalCost==`number`&&(e.cost=t.totalCost),L(e)}else if(n===`code_plan`)R((t.entries??[]).filter(e=>e.title).map(e=>({title:String(e.title),status:String(e.status??`pending`)})));else if(n===`code_available_commands_update`)D(Ee(re(t.availableCommands)));else if(n===`code_child_exit`){let t=e.code===null||e.code===void 0?`unknown`:String(e.code),n=`JWC ACP child exited (code ${t}). Active Code sessions were closed. Send the prompt again to start a fresh session, or load a stored session from the sidebar.`;K.current=null,c(null),S(!1),T([]),G({code:t,message:n}),w(e=>[...e,{role:`assistant`,text:n}])}else n===`code_turn_done`?S(!1):n===`code_session_error`&&(w(t=>[...t,{role:`assistant`,text:`Error: ${e.reason??`unknown`}`}]),S(!1));setTimeout(()=>Se(`smooth`),50)}},[i,H,Se]),onTransport:ge});let Le=(0,d.useCallback)(async()=>{let e=y.trim();if(!(!e||x)){J.current=null,S(!0),v(!0),G(null),q.current=e,w(t=>[...t,{role:`user`,text:e,transient:`pending-user-echo`}]),b(``);try{let t=s;if(!t){let e=a||`/tmp`;t=(await i.createSession(e,be||void 0)).sessionId,K.current=t,c(t)}await i.sendPrompt(t,e)}catch(e){q.current=null,w(t=>[...t,{role:`assistant`,text:`Error: ${e instanceof Error?e.message:String(e)}`}]),S(!1)}}},[y,x,s,i,a,be]),Re=(0,d.useCallback)(e=>{b(e),k(e===`/`||e.startsWith(`/`)&&!e.includes(` `))},[]),ze=(0,d.useCallback)(e=>{if(!e.disabledReason){if(e.actionType===`popup`&&e.popupKind){M(``),j({kind:e.popupKind,command:e}),k(!1);return}b(`${e.displayName} `),k(!1)}},[]),Be=(0,d.useCallback)(async(e,t)=>{await Oe(i,H,e,t,e=>w(t=>[...t,e]))&&T(t=>t.filter(t=>t.permissionId!==e.permissionId))},[i,H]),$=(0,d.useCallback)(async(e,t,n)=>{M(``),ie(e),ae(t);let r=n?.closePopup??!0,a=n?.requireActiveSession??!0;if(!s){a&&M(`Start or load a Code session before applying a live model.`);return}try{await i.setSessionModel(s,_(e,t)),r&&j(null)}catch(e){M(e instanceof Error?e.message:String(e))}},[s,i]),Ve=(0,d.useCallback)(async(e,t)=>{M(``);try{Q(await i.setDefaultModel(_(e,t))),Ie()}catch(e){M(e instanceof Error?e.message:String(e))}},[Q,i,Ie]),He=(0,d.useCallback)(async(e,t,n,r)=>{M(``);try{W(await i.setModelAssignment(e,{provider:t,model:n,...r===void 0?{}:{thinkingLevel:r}}))}catch(e){M(e instanceof Error?e.message:String(e))}},[i]),Ke=(0,d.useCallback)(async e=>{M(``);try{W(await i.clearModelAssignment(e))}catch(e){M(e instanceof Error?e.message:String(e))}},[i]),Je=U.providers.find(e=>e.id===z)??U.providers[0],Xe=U.providers.map(e=>e.id),Ze=Je?.models??[],Qe=Je?.efforts??[],$e=e=>{let t=Ge(e.replayEvents??[]);X.current=new Set,Me(X.current,e.replayEvents??[]),Y.current=new Set(t.filter(e=>e.role===`assistant`&&e.text).map(e=>e.text)),K.current=e.sessionId,c(e.sessionId),e.cwd!==a&&(ye.current=!0,o(e.cwd)),w(t),T([]),R([]),F(e.title?.trim()||t.find(e=>e.role===`user`)?.text.split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()||``),L({}),S(!1),G(null)};if(!e)return(0,m.jsx)(`div`,{className:`code-canvas`,children:(0,m.jsx)(`div`,{className:`code-transcript-empty`,children:(0,m.jsx)(`p`,{children:`Server not available.`})})});let et=(0,m.jsx)(h,{client:i,activeSessionId:s,workingDir:a,onSelectSession:$e,onLoadSession:(e,t)=>{(async()=>{J.current=e,K.current=e,c(e),q.current=null,Y.current=new Set,X.current=new Set,w([]),R([]),F(``),S(!1);try{let n=await i.loadSession(e,t);if(K.current!==e)return;n.title&&F(n.title);let r=Ge(n.replayEvents??[]);X.current=new Set,Me(X.current,n.replayEvents??[]),Y.current=new Set(r.filter(e=>e.role===`assistant`&&e.text).map(e=>e.text)),w(r),S(!1)}catch(t){K.current===e&&(K.current=null,c(null)),w(e=>[...e,{role:`assistant`,text:`Failed to load session: ${t instanceof Error?t.message:String(t)}`}])}finally{J.current===e&&(J.current=null)}})()},onNewSession:()=>{K.current=null,J.current=null,q.current=null,Y.current=new Set,X.current=new Set,c(null),w([]),R([]),F(``),S(!1),v(!1)}}),tt=e=>{ie(e),ae(U.providers.find(t=>t.id===e)?.models[0]??``)},nt=(0,m.jsx)(Ce,{activePopup:A,activeSessionId:s,availableCommands:E,codeWorkingDir:a,currentEffortOptions:Qe,currentModelOptions:Ze,disabled:x,effort:oe,gitInfo:fe,childRecovery:me,transportState:he,inputText:y,messages:C,model:B,modelAssignments:le,modelOptions:U,modelPresets:ue,permissionMode:H,permissions:ee,planEntries:ne,error:te,provider:z,providerOptions:Xe,sending:x,sessionTitle:N,showCommands:O,transcriptRef:xe,usage:I,onClearModelAssignment:Ke,onClosePopup:()=>{M(``),j(null)},onCommandSelect:ze,onEffortChange:e=>{V(e),s&&i.setSessionConfig(s,`thinking`,e)},onFooterProviderChange:e=>{tt(e);let t=U.providers.find(t=>t.id===e),n=t?.models[0]??``;V(t?.efforts.includes(`high`)?`high`:t?.efforts[0]??``),n&&$(e,n,{closePopup:!1,requireActiveSession:!1})},onInputChange:Re,onModelChange:e=>{$(z,e,{closePopup:!1,requireActiveSession:!1})},onPermissionAnswer:Be,onPermissionModeChange:se,onProviderChange:tt,onRefreshProviders:()=>{Fe()},onSetDefaultModel:Ve,onSetModelAssignment:He,onShowCommandsChange:k,onSubmit:()=>{Le()},onUseModel:$,onUseForNewSessions:(e,t)=>{$(e,t,{requireActiveSession:!1,closePopup:!1}),j(null)},onWorkingDirChange:ke,onOpenLocalFile:r,workspaceFrozen:l,onPickWorkingDir:je});return _e?(0,m.jsxs)(m.Fragment,{children:[(0,f.createPortal)((0,m.jsx)(`div`,{className:`code-manager-session-navigator-content`,children:et}),_e),(0,m.jsx)(`div`,{className:`code-canvas code-canvas-workbench`,children:nt})]}):(0,m.jsxs)(`div`,{className:`code-canvas`,children:[(0,m.jsx)(`div`,{className:`code-canvas-sidebar`,children:et}),nt]})}export{Xe as CodeCanvas};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{n as t,t as n}from"./jsx-runtime-B3ZGMGGg.js";import{c as r}from"./api-DvCd2Uff.js";import{t as i}from"./desktop-bridge-B1whMBS2.js";import{t as a}from"./copy-text-BKruhU_y.js";import{n as o,t as s}from"./MarkdownRenderer-Cl0oEICj.js";var c=e(t(),1),l=n(),u={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,py:`python`,rs:`rust`,go:`go`,java:`java`,cpp:`cpp`,c:`cpp`,css:`css`,html:`html`,htm:`html`,xml:`xml`,json:`json`,yaml:`yaml`,yml:`yaml`,sh:`bash`,bash:`bash`,sql:`sql`};function d(e){let t=e.split(`.`).pop()?.toLowerCase();return t?u[t]??null:null}function f(e){return/\.(md|mdx)$/i.test(e)}function p(e){return/\.html?$/i.test(e)}function m(){return i()?.folder??null}function h(e){return!e.startsWith(`/`)&&!/^[a-zA-Z]:[\\/]/.test(e)}function g(e){return e.split(/[\\/]/).pop()||e}function _(e){return[`<!doctype html>`,`<html>`,`<head>`,`<meta http-equiv="Content-Security-Policy" content="${[`default-src 'none'`,`img-src data: blob:`,`style-src 'unsafe-inline' data:`,`font-src data:`,`script-src 'none'`,`connect-src 'none'`,`object-src 'none'`,`base-uri 'none'`,`form-action 'none'`,`frame-src 'none'`].join(`; `)}">`,`<meta charset="utf-8">`,`<style>html,body{margin:0;min-height:100%;}body{font-family:system-ui,sans-serif;}</style>`,`</head>`,`<body>`,e,`</body>`,`</html>`].join(``)}function v(e){return(0,l.jsx)(`iframe`,{className:`doc-html-preview`,title:e.title,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:_(e.content)})}function y(e){if(e.raw)return(0,l.jsx)(`pre`,{className:`doc-pre`,children:(0,l.jsx)(`code`,{children:e.content})});if(f(e.filePath))return(0,l.jsx)(`article`,{className:`notes-preview doc-markdown`,children:(0,l.jsx)(s,{markdown:e.content,onLocalFileOpen:e.onOpenLocalFile})});if(p(e.filePath))return(0,l.jsx)(v,{content:e.content,title:`Rendered preview of ${g(e.filePath)}`});let t=d(e.filePath);return t?(0,l.jsx)(o,{code:e.content,language:t}):(0,l.jsx)(`pre`,{className:`doc-pre`,children:(0,l.jsx)(`code`,{children:e.content})})}function b(e){let t=m(),n=(0,c.useRef)(null),i=(0,c.useRef)(null),o=(0,c.useRef)(void 0),s=(0,c.useRef)({filePath:``,scrollTop:0}),u=(0,c.useRef)(null),d=(0,c.useRef)(null),[f,p]=(0,c.useState)(``),[_,v]=(0,c.useState)(null),[b,x]=(0,c.useState)(!1),[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(null),O=(0,c.useCallback)(e=>{d.current!==null&&window.clearTimeout(d.current),D(e),d.current=window.setTimeout(()=>{d.current=null,D(t=>t===e?null:t)},1200)},[]),k=(0,c.useCallback)(()=>{let t=e.filePath;t&&a(t).then(e=>{e.ok?O(`path`):console.error(`[doc-panel:path-copy]`,e.error)})},[O,e.filePath]),A=(0,c.useCallback)(()=>{a(f).then(e=>{e.ok?O(`content`):console.error(`[doc-panel:content-copy]`,e.error)})},[f,O]),j=(0,c.useCallback)(e=>{u.current!==null&&cancelAnimationFrame(u.current);let t=s.current.filePath===e?s.current.scrollTop:0;u.current=requestAnimationFrame(()=>{u.current=null;let r=n.current;!r||s.current.filePath!==e||(r.scrollTop=t)})},[]);return(0,c.useEffect)(()=>{if(!e.filePath){p(``),v(null),C(!1),D(null),T(!1);return}let n=e.filePath,i=!1;return D(null),T(!1),(async()=>{if(t){let e=await t.readFile(n);if(!e.ok&&e.error?.includes(`path not allowed`)){if(await t.getDefaultRoot(),i)return;e=await t.readFile(n)}if(i)return;e.ok&&e.content!==void 0?(x(e.binary===!0),C(e.truncated===!0&&e.binary!==!0),p(e.binary||e.truncated?``:e.content),v(null)):v(e.error??`Failed to read file`);return}if(!h(n)){i||v(`Document preview for arbitrary local files requires Electron desktop app`);return}try{let e=await r(n);if(i)return;x(!1),C(!1),p(e.content),v(null)}catch(e){i||v(e.message)}})(),()=>{i=!0}},[t,e.filePath]),(0,c.useLayoutEffect)(()=>{let t=n.current,r=e.filePath;if(!(!t||!r)){if(o.current!==r){o.current=r,t.scrollTop=0,s.current={filePath:r,scrollTop:0};return}j(r)}},[f,e.filePath,j]),(0,c.useEffect)(()=>{let t=i.current,n=e.filePath;if(!t||!n)return;let r=new ResizeObserver(()=>{s.current.filePath===n&&j(n)});return r.observe(t),()=>{r.disconnect()}},[f,e.filePath,j]),(0,c.useEffect)(()=>()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),e.filePath?_?(0,l.jsx)(`div`,{className:`doc-panel doc-error`,children:_}):b?(0,l.jsx)(`div`,{className:`doc-panel doc-binary`,children:`Binary file — cannot preview`}):S?(0,l.jsx)(`div`,{className:`doc-panel doc-binary`,children:`File too large to preview (512KB cap) — open it in an editor instead.`}):(0,l.jsxs)(`div`,{className:`doc-panel`,children:[(0,l.jsxs)(`div`,{className:`doc-toolbar`,children:[(0,l.jsx)(`span`,{className:`doc-file-name`,title:e.filePath,children:g(e.filePath)}),(0,l.jsxs)(`div`,{className:`doc-toolbar-actions`,"aria-label":`Document actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`doc-toolbar-button ${w?`is-active`:``}`,"aria-pressed":w,title:`Show raw source`,onClick:()=>T(e=>!e),children:`Raw`}),(0,l.jsx)(`button`,{type:`button`,className:`doc-toolbar-button`,title:`Copy full path`,onClick:k,children:E===`path`?`Copied`:`Path`}),(0,l.jsx)(`button`,{type:`button`,className:`doc-toolbar-button`,title:`Copy file content`,onClick:A,children:E===`content`?`Copied`:`Copy`})]})]}),(0,l.jsx)(`div`,{className:`doc-content`,ref:n,onScroll:t=>{e.filePath&&(s.current={filePath:e.filePath,scrollTop:t.currentTarget.scrollTop})},children:(0,l.jsx)(`div`,{className:`doc-content-body`,ref:i,children:(0,l.jsx)(y,{filePath:e.filePath,content:f,raw:w,onOpenLocalFile:e.onOpenLocalFile})})})]}):(0,l.jsx)(`div`,{className:`doc-panel doc-empty`,children:`Open Folders and select a file to preview it here.`})}export{b as DocPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.doc-panel{flex-direction:column;min-width:0;height:100%;min-height:0;font-size:12px;display:flex;overflow:hidden}.doc-unavailable,.doc-empty,.doc-error,.doc-binary{color:var(--text-dim);justify-content:center;align-items:center;padding:12px;font-size:11px;display:flex}.doc-error{color:var(--status-error)}.doc-toolbar{border-bottom:1px solid var(--border-subtle);flex-shrink:0;align-items:center;gap:8px;padding:6px 10px;display:flex}.doc-file-name{color:var(--text-base);text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:11px;font-weight:500;overflow:hidden}.doc-toolbar-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.doc-toolbar-button{border:1px solid var(--border-subtle);min-width:34px;color:var(--text-dim);cursor:pointer;background:0 0;border-radius:3px;flex-shrink:0;padding:1px 6px;font-size:10px}.doc-toolbar-button:hover{background:var(--border-subtle);color:var(--text-base)}.doc-toolbar-button.is-active{border-color:var(--accent);color:var(--accent);background:color-mix(in srgb, var(--accent) 10%, transparent)}.doc-content{flex:1;min-height:0;overflow:auto}.doc-content-body{min-width:0}.doc-content .notes-mermaid-block.is-loading{align-items:center;min-height:96px;display:flex}.doc-pre{white-space:pre-wrap;word-break:break-all;margin:0;padding:8px 10px;font-family:SF Mono,Menlo,monospace;font-size:12px;line-height:1.5}.doc-markdown{padding:12px 16px}.doc-content .notes-code-block{border-radius:0;margin:0}.doc-content .notes-code-block pre{max-height:none}
|
|
1
|
+
.doc-panel{flex-direction:column;min-width:0;height:100%;min-height:0;font-size:12px;display:flex;overflow:hidden}.doc-unavailable,.doc-empty,.doc-error,.doc-binary{color:var(--text-dim);justify-content:center;align-items:center;padding:12px;font-size:11px;display:flex}.doc-error{color:var(--status-error)}.doc-toolbar{border-bottom:1px solid var(--border-subtle);flex-shrink:0;align-items:center;gap:8px;padding:6px 10px;display:flex}.doc-file-name{color:var(--text-base);text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:11px;font-weight:500;overflow:hidden}.doc-toolbar-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.doc-toolbar-button{border:1px solid var(--border-subtle);min-width:34px;color:var(--text-dim);cursor:pointer;background:0 0;border-radius:3px;flex-shrink:0;padding:1px 6px;font-size:10px}.doc-toolbar-button:hover{background:var(--border-subtle);color:var(--text-base)}.doc-toolbar-button.is-active{border-color:var(--accent);color:var(--accent);background:color-mix(in srgb, var(--accent) 10%, transparent)}.doc-content{flex:1;min-height:0;overflow:auto}.doc-content-body{min-width:0;height:100%;min-height:100%}.doc-content .notes-mermaid-block.is-loading{align-items:center;min-height:96px;display:flex}.doc-pre{white-space:pre-wrap;word-break:break-all;margin:0;padding:8px 10px;font-family:SF Mono,Menlo,monospace;font-size:12px;line-height:1.5}.doc-markdown{padding:12px 16px}.doc-html-preview{background:#fff;border:0;width:100%;height:100%;min-height:100%;display:block}.doc-content .notes-code-block{border-radius:0;margin:0}.doc-content .notes-code-block pre{max-height:none}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{n as t,t as n}from"./jsx-runtime-B3ZGMGGg.js";import{c as r}from"./api-DvCd2Uff.js";import{t as i}from"./desktop-bridge-B1whMBS2.js";import{t as a}from"./copy-text-BKruhU_y.js";import{n as o,t as s}from"./folder-drag-payload-DE3ZS9PZ.js";var c=e(t(),1);function l(e){return{name:e.name,path:e.path,kind:e.kind===`folder`?`directory`:`file`,size:e.size}}function u(e,t){for(let n of e){if(n.path===t)return n;let e=u(n.children??[],t);if(e)return e}return null}function d(e){return{kind:`electron-folder`,label:`Folder`,canPickRoot:!0,getInitialRoot:async()=>null,pickRoot:async()=>{let t=await e.pickFolder();if(!t.ok&&t.error===`cancelled`)return null;if(!t.ok)throw Error(t.error??`Failed to pick folder`);return t.path??null},registerGitWorktreeRoot:async(t,n,r)=>{let i=await e.registerGitWorktreeRoot?.(t,n,r);if(!i?.ok)throw Error(i?.error??`Failed to register worktree root`)},authorizeRoot:async t=>{let n=await e.authorizeRoot?.(t);if(!n?.ok)throw Error(n?.error??`Failed to authorize folder root`);return n.path??t},listDir:async t=>{let n=await e.listDir(t);if(!n.ok||!n.entries)throw Error(n.error??`Failed to list directory`);return n.entries},readFile:async t=>{let n=await e.readFile(t);if(!n.ok||n.content===void 0)throw Error(n.error??`Failed to read file`);return{content:n.content,...n.binary===void 0?{}:{binary:n.binary}}},movePath:async(t,n)=>{let r=await e.movePath(t,n);if(!r.ok)throw Error(r.error??`Failed to move path`);return r},createFile:async(t,n)=>{let r=await e.createFile(t,n);if(!r.ok)throw Error(r.error??`Failed to create file`);return r},createFolder:async(t,n)=>{let r=await e.createFolder(t,n);if(!r.ok)throw Error(r.error??`Failed to create folder`);return r},renamePath:async(t,n)=>{let r=await e.renamePath(t,n);if(!r.ok)throw Error(r.error??`Failed to rename path`);return r},revealPath:async t=>{let n=await e.revealPath(t);if(!n.ok)throw Error(n.error??`Failed to reveal path`)},watchDir:t=>e.watchDir(t),unwatchDir:t=>e.unwatchDir(t),onDirChange:t=>e.onDirChange(t)}}function f(e,t){return{kind:`notes-vault`,label:t?`Notes: ${t.split(`/`).pop()||t}`:`Notes vault`,canPickRoot:!1,getInitialRoot:async()=>``,listDir:async t=>{if(!t)return e.map(l);let n=u(e,t);return!n||n.kind!==`folder`?[]:(n.children??[]).map(l)},readFile:async e=>({content:(await r(e)).content,binary:!1})}}var p=n();function m(e){return(0,p.jsxs)(`div`,{className:`folder-action-row`,"aria-label":`Folder actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:!e.hasSelection,onClick:e.onCopyPath,children:`Copy`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:!e.hasSelection,onClick:e.onCopyRelativePath,children:`Relative`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:!e.hasSelection||!e.canReveal,onClick:e.onReveal,children:`Finder`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:!e.canMutate,onClick:e.onCreateFile,children:`New File`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:!e.canMutate,onClick:e.onCreateFolder,children:`New Folder`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:!e.hasSelection||!e.canMutate,onClick:e.onRename,children:`Rename`})]})}function h(e){return(0,p.jsxs)(`div`,{className:`folder-context-menu`,role:`menu`,style:{left:e.x,top:e.y},onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:e.onCopyPath,children:`Copy Path`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:e.onCopyRelativePath,children:`Copy Relative Path`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:!e.canReveal,onClick:e.onReveal,children:e.entry.kind===`directory`?`Open Folder`:`Reveal in Finder`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:!e.canMutate,onClick:e.onCreateFile,children:`New File`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:!e.canMutate,onClick:e.onCreateFolder,children:`New Folder`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:!e.canMutate,onClick:e.onRename,children:`Rename`}),e.canRefresh&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:e.onRefresh,children:`Refresh`})]})}function g(e){return(0,p.jsxs)(`div`,{className:`folder-move-confirm`,role:`dialog`,"aria-label":`Confirm folder move`,children:[(0,p.jsxs)(`div`,{className:`folder-move-confirm__title`,children:[`Move "`,e.source.name,`" into "`,e.target.name,`"?`]}),(0,p.jsxs)(`label`,{className:`folder-move-confirm__option`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.skipChecked,onChange:t=>e.onSkipCheckedChange(t.target.checked)}),`Don't ask again for internal moves this session`]}),(0,p.jsxs)(`div`,{className:`folder-move-confirm__actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,disabled:e.busy,onClick:e.onCancel,children:`Cancel`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn is-primary`,disabled:e.busy,onClick:e.onConfirm,children:e.busy?`Moving...`:`Move`})]})]})}function _(e){return(0,p.jsxs)(p.Fragment,{children:[e.pendingMove&&(0,p.jsx)(g,{source:e.pendingMove.source,target:e.pendingMove.target,busy:e.isMoving,skipChecked:e.skipMoveConfirmChecked,onSkipCheckedChange:e.onSkipMoveConfirmCheckedChange,onCancel:e.onCancelMove,onConfirm:e.onConfirmMove}),e.contextMenu&&(0,p.jsx)(h,{entry:e.contextMenu.entry,x:e.contextMenu.x,y:e.contextMenu.y,canReveal:e.canReveal,canRefresh:e.canRefresh,canMutate:e.canMutate,onCopyPath:e.onCopyContextPath,onCopyRelativePath:e.onCopyContextRelativePath,onReveal:e.onRevealContextPath,onRefresh:e.onRefreshContext,onCreateFile:e.onCreateContextFile,onCreateFolder:e.onCreateContextFolder,onRename:e.onRenameContextPath})]})}function v(e){return e===null?`Open Folder`:e.split(`/`).pop()||e}function y(e){return e.split(`/`).filter(Boolean).pop()||e}function b(e){return e.branch?e.branch:e.detached?e.head?`detached ${e.head}`:`detached`:e.head??`worktree`}function x(e){let[t,n]=(0,c.useState)(!1),r=e.gitSummary?.loading?`Git ...`:e.gitSummary?.available?`${e.gitSummary.branch??e.gitSummary.head??`detached`} / ${e.gitSummary.dirty?`dirty`:`clean`}`:e.gitSummary?.error?`Git unavailable`:null,i=e.worktreeSummary?.worktrees??[],a=e.rootPath!==null&&(e.worktreeSummary?.loading||e.worktreeSummary?.error||i.length>0),o=e.worktreeSummary?.loading?`Worktrees ...`:i.length>0?`Worktrees ${i.length}`:`Worktrees`;return(0,p.jsxs)(`div`,{className:`folder-toolbar`,children:[(0,p.jsx)(`button`,{type:`button`,className:`folder-pick-btn`,onClick:e.onPickFolder,disabled:!e.canPickRoot,children:e.canPickRoot?v(e.rootPath):e.label}),r&&(0,p.jsx)(`span`,{className:e.gitSummary?.error?`folder-git-summary is-error`:`folder-git-summary`,title:e.gitSummary?.error??void 0,children:r}),a&&(0,p.jsxs)(`div`,{className:`folder-worktree`,children:[(0,p.jsx)(`button`,{type:`button`,className:`folder-worktree-btn`,onClick:()=>n(e=>!e),disabled:e.worktreeSummary?.loading||i.length===0,title:e.worktreeSummary?.error??void 0,children:o}),t&&i.length>0&&(0,p.jsx)(`div`,{className:`folder-worktree-menu`,role:`menu`,"aria-label":`Git worktrees`,children:i.map(t=>(0,p.jsxs)(`div`,{className:`folder-worktree-row`,role:`group`,"aria-label":t.path,children:[(0,p.jsxs)(`button`,{type:`button`,className:`folder-worktree-open`,onClick:()=>{n(!1),e.onOpenWorktree?.(t.path)},children:[(0,p.jsxs)(`span`,{className:`folder-worktree-title`,children:[y(t.path),t.current&&(0,p.jsx)(`span`,{className:`folder-worktree-current`,children:`Current`})]}),(0,p.jsxs)(`span`,{className:`folder-worktree-meta`,children:[b(t),` · `,t.path]})]}),(0,p.jsxs)(`span`,{className:`folder-worktree-actions`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>e.onCopyWorktreePath?.(t.path),children:`Copy`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>e.onRevealWorktreePath?.(t.path),children:`Finder`})]})]},t.path))})]}),e.rootPath!==null&&e.gitSummary?.available&&e.onOpenWorktreeOps&&(0,p.jsx)(`button`,{type:`button`,className:`folder-worktree-btn`,onClick:e.onOpenWorktreeOps,children:`Ops`}),e.rootPath!==null&&(0,p.jsx)(`button`,{type:`button`,className:`folder-refresh`,onClick:e.onRefresh,"aria-label":`Refresh folder`,children:`↻`})]})}async function S(e,t){return await(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).json()}async function C(e){let t=e.repoRoot??void 0;try{let n=i()?.git,r=n?await n.previewWorktreeOperation(e.folderPanelRoot,t,e.operation):null,a=r?.ok?r:await S(`/api/dashboard/git/worktree-operation-preview`,{folderPanelRoot:e.folderPanelRoot,...t?{repoRoot:t}:{},operation:e.operation});return{ok:a.ok,preview:a.preview??null,error:a.ok?null:a.error??`Failed to preview git operation`}}catch(e){return{ok:!1,preview:null,error:e instanceof Error?e.message:`Failed to preview git operation`}}}async function w(e){let t=e.repoRoot??void 0;try{let n=i()?.git,r=n?await n.runWorktreeOperation(e.folderPanelRoot,t,e.operation,e.confirmed):null,a=r?.ok?r:await S(`/api/dashboard/git/worktree-operation`,{folderPanelRoot:e.folderPanelRoot,...t?{repoRoot:t}:{},operation:e.operation,confirmed:e.confirmed});return{ok:a.ok,repoRoot:a.repoRoot??null,preview:a.preview??null,stdout:a.stdout??``,worktrees:a.worktrees??[],error:a.ok?null:a.error??`Git operation failed`}}catch(e){return{ok:!1,repoRoot:null,preview:null,stdout:``,worktrees:[],error:e instanceof Error?e.message:`Git operation failed`}}}function T(e){return e.length>0?e.join(` `):`Command unavailable`}function E(e){return e.status===`running`?`Running`:e.status===`succeeded`?`Done`:e.status===`blocked`?`Blocked`:e.status===`cancelled`?`Cancelled`:`Failed`}function ee(e){return e.history.length===0?null:(0,p.jsxs)(`div`,{className:`folder-worktree-history`,"aria-label":`Git worktree operation history`,children:[(0,p.jsx)(`div`,{className:`folder-worktree-history__title`,children:`Recent operations`}),e.history.map(t=>(0,p.jsxs)(`div`,{className:`folder-worktree-history__item is-${t.status}`,children:[(0,p.jsxs)(`div`,{className:`folder-worktree-history__main`,children:[(0,p.jsx)(`span`,{className:`folder-worktree-history__label`,children:t.operationLabel}),(0,p.jsx)(`span`,{className:`folder-worktree-history__status`,children:E(t)})]}),(0,p.jsx)(`div`,{className:`folder-worktree-history__command`,title:T(t.commandPreview),children:T(t.commandPreview)}),t.stdout&&(0,p.jsx)(`pre`,{className:`folder-worktree-history__output`,children:t.stdout}),t.stderr&&(0,p.jsx)(`pre`,{className:`folder-worktree-history__output is-error`,children:t.stderr}),t.error&&(0,p.jsx)(`div`,{className:`folder-worktree-history__error`,children:t.error}),(0,p.jsx)(`button`,{type:`button`,className:`folder-worktree-history__retry`,disabled:e.busy||t.status===`running`,onClick:()=>e.onRetry(t.operation),children:`Retry with confirmation`})]},t.id))]})}function D(e){return e.split(`/`).filter(Boolean).pop()||e}function te(e){return e?e.command.join(` `):`Preview unavailable`}function O(e){let[t,n]=(0,c.useState)(`worktree-add`),[r,i]=(0,c.useState)(``),[a,o]=(0,c.useState)(``),[s,l]=(0,c.useState)(!1),[u,d]=(0,c.useState)(e.worktrees.find(e=>!e.current)?.path??e.worktrees[0]?.path??``),[f,m]=(0,c.useState)(!1),[h,g]=(0,c.useState)(!1),[_,v]=(0,c.useState)(!1),[y,b]=(0,c.useState)(null),[x,S]=(0,c.useState)(null),w=(0,c.useCallback)(e=>{n(e.type),g(!1),e.type===`worktree-add`&&(i(e.path),o(e.branch),l(e.createBranch)),e.type===`worktree-remove`&&(d(e.path),m(e.force))},[]),T=(0,c.useMemo)(()=>t===`worktree-add`?{type:t,path:r,branch:a,createBranch:s}:t===`worktree-remove`?{type:t,path:u,force:f}:{type:t},[a,s,f,t,u,r]);(0,c.useEffect)(()=>{let t=!1;return g(!1),v(!0),b(null),S(null),(async()=>{let n=await C({folderPanelRoot:e.folderPanelRoot,repoRoot:e.repoRoot,operation:T});t||(v(!1),S(n.preview),b(n.error))})(),()=>{t=!0}},[T,e.folderPanelRoot,e.repoRoot]);let E=h&&x!==null&&!y&&!_&&!e.busy,O=t===`worktree-remove`;return(0,p.jsx)(`div`,{className:`folder-worktree-ops`,role:`dialog`,"aria-label":`Git worktree operations`,children:(0,p.jsxs)(`div`,{className:`folder-worktree-ops__panel`,children:[(0,p.jsxs)(`div`,{className:`folder-worktree-ops__header`,children:[(0,p.jsx)(`span`,{children:`Worktree Ops`}),(0,p.jsx)(`button`,{type:`button`,onClick:e.onClose,disabled:e.busy,children:`Close`})]}),(0,p.jsx)(`div`,{className:`folder-worktree-ops__row`,children:(0,p.jsxs)(`label`,{children:[`Operation`,(0,p.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),disabled:e.busy,children:[(0,p.jsx)(`option`,{value:`worktree-add`,children:`Add worktree`}),(0,p.jsx)(`option`,{value:`worktree-remove`,children:`Remove worktree`}),(0,p.jsx)(`option`,{value:`worktree-prune`,children:`Prune stale worktrees`})]})]})}),t===`worktree-add`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`folder-worktree-ops__row`,children:(0,p.jsxs)(`label`,{children:[`Path`,(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`/Users/jun/...`,disabled:e.busy})]})}),(0,p.jsxs)(`div`,{className:`folder-worktree-ops__row`,children:[(0,p.jsxs)(`label`,{children:[`Branch / ref`,(0,p.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`feature/name`,disabled:e.busy})]}),(0,p.jsxs)(`label`,{className:`folder-worktree-ops__check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>l(e.target.checked),disabled:e.busy}),`Create branch`]})]})]}),O&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`folder-worktree-ops__row`,children:(0,p.jsxs)(`label`,{children:[`Worktree`,(0,p.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),disabled:e.busy,children:e.worktrees.map(e=>(0,p.jsxs)(`option`,{value:e.path,children:[D(e.path),` - `,e.path]},e.path))})]})}),(0,p.jsxs)(`label`,{className:`folder-worktree-ops__warning`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>m(e.target.checked),disabled:e.busy}),`Force remove dirty worktree`]})]}),(0,p.jsx)(`div`,{className:`folder-worktree-ops__preview`,"aria-busy":_,children:_?`Previewing command...`:te(x)}),y&&(0,p.jsx)(`div`,{className:`folder-worktree-ops__warning`,children:y}),O&&!f&&(0,p.jsx)(`div`,{className:`folder-worktree-ops__hint`,children:`Dirty worktrees are blocked unless force remove is explicitly checked.`}),O&&f&&(0,p.jsx)(`div`,{className:`folder-worktree-ops__hint`,children:`Preview changes to git worktree remove --force for this target.`}),(0,p.jsxs)(`label`,{className:`folder-worktree-ops__check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),disabled:x===null||!!y||e.busy}),`I understand this will run the previewed git command.`]}),(0,p.jsxs)(`div`,{className:`folder-worktree-ops__actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,onClick:e.onClose,disabled:e.busy,children:`Cancel`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn is-primary`,disabled:!E,onClick:()=>e.onRun(T,x),children:e.busy?`Running...`:`Run`})]}),(0,p.jsx)(ee,{history:e.history,busy:e.busy,onRetry:w})]})})}function ne(e){let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):`/`}function k(e,t){return t===e||t.startsWith(`${e}/`)}function re(e,t){if(!e)return t;let n=e.endsWith(`/`)?e:`${e}/`;return t.startsWith(n)?t.slice(n.length):t}function ie(e,t){let n=new Map(e);for(let e of t)n.delete(e);return n}function ae(e){let t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=t.current;e&&(e.focus(),e.select())},[e.initialName]),(0,p.jsx)(`form`,{className:`folder-inline-editor`,"aria-label":e.label,onSubmit:n=>{n.preventDefault();let r=t.current?.value.trim()??``;r&&e.onSubmit(r)},children:(0,p.jsx)(`input`,{ref:t,className:`folder-inline-editor__input`,defaultValue:e.initialName,disabled:e.busy,onBlur:()=>{e.busy||e.onCancel()},onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),e.onCancel()),t.stopPropagation()}})})}function oe(e){return/mac|iphone|ipad|ipod/i.test(e)}function se(){return typeof navigator>`u`?``:navigator.userAgentData?.platform||navigator.platform||navigator.userAgent||``}function ce(e){if(typeof HTMLElement>`u`||!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`?!0:!!e.closest(`[contenteditable="true"], .cm-editor, .ProseMirror, [data-milkdown-root], [role="textbox"]`)}function le(e,t=se()){return oe(t)?e.metaKey:e.ctrlKey}function ue(e,t){if(ce(e.target??null))return null;let n=e.key.toLowerCase(),r=e.code??``,i=oe(t.platform??se())?e.metaKey:e.ctrlKey,a=i&&e.altKey&&!e.shiftKey;return t.chordActive?n===`escape`?`cancel-chord`:i||e.altKey||e.shiftKey?null:n===`p`||r===`KeyP`?`copy-path`:n===`r`||r===`KeyR`?`reveal-path`:`cancel-chord`:i&&!e.altKey&&!e.shiftKey&&(n===`k`||r===`KeyK`)?`start-chord`:a&&(n===`c`||r===`KeyC`)?`copy-path`:a&&(n===`r`||r===`KeyR`)?`reveal-path`:i&&!e.altKey&&n===`c`?e.shiftKey?`copy-path`:`copy-relative-path`:null}function de(e){window.dispatchEvent(new CustomEvent(`jaw-folder-panel-drag`,{detail:{active:e}}))}function fe(e){let t=e.inlineMutation&&e.inlineMutation.kind!==`rename`&&e.inlineMutation.parentDirectory===e.parentPath?e.inlineMutation:null;return(0,p.jsxs)(p.Fragment,{children:[t&&(0,p.jsxs)(`div`,{className:`folder-entry folder-entry-inline`,children:[e.depth>0&&(0,p.jsx)(`span`,{className:`folder-indent`,"aria-hidden":`true`,children:Array.from({length:e.depth},(e,t)=>(0,p.jsx)(`span`,{className:`folder-indent-guide`},t))}),(0,p.jsx)(`span`,{className:`folder-entry-disclosure is-placeholder`,"aria-hidden":`true`,children:`·`}),(0,p.jsx)(ae,{initialName:t.initialName,busy:e.isMutating,label:t.kind===`file`?`New file name`:`New folder name`,onSubmit:e.submitInlineMutation,onCancel:e.cancelInlineMutation})]}),e.entries.map(t=>(0,p.jsxs)(`div`,{children:[(()=>{let n=e.decorationsByPath.get(t.path),r=e.inlineMutation?.kind===`rename`&&e.inlineMutation.targetPath===t.path?e.inlineMutation:null;return(0,p.jsxs)(`div`,{className:[`folder-entry`,`folder-entry-${t.kind}`,n?.className??``,e.selectedPaths.has(t.path)?`is-selected`:``,e.focusedPath===t.path?`is-focused`:``,e.dropTargetPath===t.path?`is-drop-target`:``,e.dragSelection?.primaryEntry.path===t.path?`is-dragging`:``].filter(Boolean).join(` `),role:`treeitem`,"aria-selected":e.selectedPaths.has(t.path),draggable:e.canUseNativeActions,onDragStart:n=>{if(!e.canUseNativeActions)return;let r=e.getDragSelectionFor(t);e.setDragSelection(r),de(!0),n.dataTransfer.effectAllowed=`copyMove`,n.dataTransfer.setData(s,o(r)),n.dataTransfer.setData(`text/plain`,r.entries.map(e=>e.path).join(`
|
|
2
|
+
`))},onDragEnd:()=>{de(!1),e.setDragSelection(null),e.setDropTargetPath(null)},onDragOver:n=>{let r=e.dragSelection?.primaryEntry;!r||t.kind!==`directory`||r.path!==t.path&&(r.kind===`directory`&&k(r.path,t.path)||(n.preventDefault(),n.dataTransfer.dropEffect=`move`,e.setDropTargetPath(t.path)))},onDragLeave:()=>{e.dropTargetPath===t.path&&e.setDropTargetPath(null)},onDrop:n=>{!e.dragSelection||t.kind!==`directory`||(n.preventDefault(),de(!1),e.setDropTargetPath(null),e.requestMove(e.dragSelection.primaryEntry,t))},children:[e.depth>0&&(0,p.jsx)(`span`,{className:`folder-indent`,"aria-hidden":`true`,children:Array.from({length:e.depth},(e,t)=>(0,p.jsx)(`span`,{className:`folder-indent-guide`},t))}),(0,p.jsx)(`button`,{type:`button`,className:t.kind===`directory`?`folder-entry-disclosure`:`folder-entry-disclosure is-placeholder`,"aria-label":t.kind===`directory`?e.expanded.has(t.path)?`Collapse ${t.name}`:`Expand ${t.name}`:void 0,"aria-expanded":t.kind===`directory`?e.expanded.has(t.path):void 0,tabIndex:t.kind===`directory`?0:-1,disabled:t.kind!==`directory`,onClick:n=>{n.stopPropagation(),t.kind===`directory`&&e.toggleEntryExpansion(t)},children:t.kind===`directory`?e.expanded.has(t.path)?`▾`:`▸`:`·`}),r?(0,p.jsx)(ae,{initialName:r.initialName,busy:e.isMutating,label:`Rename`,onSubmit:e.submitInlineMutation,onCancel:e.cancelInlineMutation}):(0,p.jsxs)(`button`,{type:`button`,className:`folder-entry-btn`,"data-folder-path":t.path,onKeyDown:n=>e.handleEntryKeyDown(n,t),onContextMenu:n=>{n.preventDefault(),e.openContextMenu(t,n.clientX,n.clientY)},onClick:n=>e.selectEntry(t,{range:n.shiftKey,toggle:le(n),preview:!1}),onDoubleClick:()=>{t.kind===`directory`?e.toggleEntryExpansion(t):e.openFileEntry(t)},children:[(0,p.jsx)(`span`,{className:`folder-entry-name`,children:t.name}),n?.label&&(0,p.jsx)(`span`,{className:`folder-entry-git-badge`,title:n.title,"aria-label":n.title??n.label,children:n.label})]})]})})(),t.kind===`directory`&&e.expanded.has(t.path)&&e.childrenCache.has(t.path)&&(0,p.jsx)(fe,{...e,entries:e.childrenCache.get(t.path),parentPath:t.path,depth:e.depth+1})]},t.path))]})}function pe(e){return(0,p.jsxs)(`div`,{className:`folder-unavailable`,children:[(0,p.jsx)(`div`,{className:`folder-unavailable__title`,children:`Folder unavailable`}),(0,p.jsx)(`div`,{className:`folder-unavailable__path`,title:e.path,children:e.path}),(0,p.jsx)(`div`,{className:`folder-unavailable__error`,children:e.error}),(0,p.jsxs)(`div`,{className:`folder-unavailable__actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,onClick:e.onOpenFolder,children:`Open Folder`}),(0,p.jsx)(`button`,{type:`button`,className:`folder-action-btn`,onClick:e.onClear,children:`Clear`})]})]})}function me(e){return(0,p.jsxs)(`div`,{ref:e.treeRef,className:e.rootPath===null?`folder-tree folder-empty-root`:`folder-tree`,role:`tree`,"aria-multiselectable":`true`,children:[(0,p.jsx)(fe,{entries:e.entries,parentPath:e.rootPath,depth:0,expanded:e.expanded,childrenCache:e.childrenCache,selectedPaths:e.folderSelection.selectedPaths,focusedPath:e.folderSelection.selection.focusedPath,decorationsByPath:e.decorationsByPath,dropTargetPath:e.dropTargetPath,dragSelection:e.dragSelection,inlineMutation:e.inlineMutation,isMutating:e.isMutating,canUseNativeActions:e.canUseNativeActions,setDragSelection:e.setDragSelection,setDropTargetPath:e.setDropTargetPath,getDragSelectionFor:e.folderSelection.getDragSelectionFor,requestMove:e.requestMove,handleEntryKeyDown:e.handleEntryKeyDown,selectEntry:e.selectEntry,toggleEntryExpansion:e.toggleEntryExpansion,openFileEntry:e.openFileEntry,openContextMenu:e.openContextMenu,submitInlineMutation:e.submitInlineMutation,cancelInlineMutation:e.cancelInlineMutation}),e.rootPath===null&&!e.error&&(0,p.jsx)(`div`,{className:`folder-empty-root__content`,children:`Choose a folder to browse files.`}),e.unavailableRoot&&(0,p.jsx)(pe,{path:e.unavailableRoot.path,error:e.unavailableRoot.error,onOpenFolder:e.onPickFolder,onClear:e.onClearUnavailableRoot}),e.entries.length===0&&!e.inlineMutation&&!e.error&&!e.unavailableRoot&&e.rootPath!==null&&(0,p.jsx)(`div`,{className:`folder-empty`,children:e.sourceKind===`notes-vault`?`No notes in vault`:`Empty directory`})]})}var A={selectedPaths:[],focusedPath:null,anchorPath:null};function he(e,t,n){let r=[],i=e=>{for(let a of e)r.push(a),a.kind===`directory`&&n.has(a.path)&&i(t.get(a.path)??[])};return i(e),r}function ge(e,t){let n=new Set(t),r=e.selectedPaths.filter(e=>n.has(e)),i=e.focusedPath&&n.has(e.focusedPath)?e.focusedPath:r[0]??null;return{selectedPaths:r,focusedPath:i,anchorPath:e.anchorPath&&n.has(e.anchorPath)?e.anchorPath:i}}function _e(e,t,n,r={}){if(!n.includes(t))return e;if(r.range&&e.anchorPath&&n.includes(e.anchorPath))return{selectedPaths:M(n,e.anchorPath,t),focusedPath:t,anchorPath:e.anchorPath};if(r.toggle){let r=new Set(e.selectedPaths);return r.has(t)?r.delete(t):r.add(t),r.size===0&&r.add(t),{selectedPaths:n.filter(e=>r.has(e)),focusedPath:t,anchorPath:t}}return{selectedPaths:[t],focusedPath:t,anchorPath:t}}function j(e,t,n,r){if(t.length===0)return A;let i=e.focusedPath&&t.includes(e.focusedPath)?e.focusedPath:e.selectedPaths.find(e=>t.includes(e))??t[0],a=t.indexOf(i),o=t[Math.max(0,Math.min(t.length-1,a+(n===`down`?1:-1)))];if(r){let n=e.anchorPath&&t.includes(e.anchorPath)?e.anchorPath:i;return{selectedPaths:M(t,n,o),focusedPath:o,anchorPath:n}}return{selectedPaths:[o],focusedPath:o,anchorPath:o}}function ve(e,t){return e.filter(e=>t.has(e.path))}function M(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0)return[n];let a=Math.min(r,i),o=Math.max(r,i);return e.slice(a,o+1)}function ye(e){return Array.from(e.entries())}function be(e){return new Map(e)}function xe(e,t){return!e||t&&e.rootPath!==t?null:e}function Se(e){return{rootPath:e.rootPath,entries:e.entries,expandedPaths:Array.from(e.expanded),childrenCache:ye(e.childrenCache),selection:e.selection}}function N(e){return/not a git repository/i.test(e)}async function P(e,t){return await(await fetch(`/api/dashboard/git/status-map`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folderPanelRoot:e,...t.repoRoot?{repoRoot:t.repoRoot}:{},options:{includeIgnored:t.includeIgnored!==!1,includeUntracked:t.includeUntracked!==!1}})})).json()}async function F(e,t={}){let n=i()?.git,r=n?await n.getStatusMap(e,t.repoRoot,{includeIgnored:t.includeIgnored!==!1,includeUntracked:t.includeUntracked!==!1}):null,a=r?.ok?r:await P(e,t);if(a.ok&&a.status)return{ok:!0,status:a.status};let o=a.error??`Failed to load git status`;return{ok:!1,quiet:N(o),error:o}}var I={available:!1,loading:!1,error:null,repoRoot:null,branch:null,head:null,dirty:!1,decorationsByPath:new Map},L={modified:`M`,added:`A`,deleted:`D`,renamed:`R`,untracked:`?`,ignored:`·`,conflict:`U`,submodule:`S`};function Ce(e){return{className:`git-${e.kind}`,label:L[e.kind],title:[e.kind,e.staged?`staged`:``,e.unstaged?`unstaged`:``].filter(Boolean).join(` · `)}}function R(e){let t=e.kinds[0]??`modified`;return{className:`git-${t}`,label:`${L[t]}${e.changedCount>1?e.changedCount:``}`,title:`${e.changedCount} changed item${e.changedCount===1?``:`s`}`}}function z(e){let t=new Map;for(let n of e.files)t.set(n.path,Ce(n));for(let n of e.directories)t.set(n.path,R(n));return{available:!0,loading:!1,error:null,repoRoot:e.repoRoot,branch:e.branch,head:e.head,dirty:e.dirty,decorationsByPath:t}}function we(e){let{rootPath:t,repoRoot:n,enabled:r,refreshToken:i}=e,[a,o]=(0,c.useState)(I);return(0,c.useEffect)(()=>{if(!r||t===null){o(I);return}let e=!1,i=window.setTimeout(()=>{o(e=>({...e,loading:!0,error:null})),(async()=>{let r=await F(t,{...n?{repoRoot:n}:{},includeIgnored:!0,includeUntracked:!0});if(!e){if(r.ok){o(z(r.status));return}if(n&&/repo root mismatch/i.test(r.error)){let n=await F(t,{includeIgnored:!0,includeUntracked:!0});if(e)return;if(n.ok){o(z(n.status));return}o(n.quiet?I:{...I,error:n.error});return}o(r.quiet?I:{...I,error:r.error})}})()},250);return()=>{e=!0,window.clearTimeout(i)}},[r,i,n,t]),a}function B(e){return/not a git repository/i.test(e)}async function V(e,t){return await(await fetch(`/api/dashboard/git/worktrees`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folderPanelRoot:e,...t?{repoRoot:t}:{}})})).json()}async function H(e,t){let n=t??void 0;try{let t=i()?.git,r=t?await t.getWorktrees(e,n):null,a=r?.ok?r:await V(e,n);if(a.ok)return{ok:!0,repoRoot:a.repoRoot??n??null,worktrees:a.worktrees??[],error:null};let o=a.error??`Failed to load git worktrees`;return{ok:!1,repoRoot:null,worktrees:[],error:B(o)?null:o}}catch(e){let t=e instanceof Error?e.message:`Failed to load git worktrees`;return{ok:!1,repoRoot:null,worktrees:[],error:B(t)?null:t}}}var U={available:!1,loading:!1,error:null,repoRoot:null,worktrees:[]};function Te(e){let{folderPanelRoot:t,repoRoot:n,enabled:r,refreshToken:i}=e,[a,o]=(0,c.useState)(0),[s,l]=(0,c.useState)(U),u=(0,c.useCallback)(()=>o(e=>e+1),[]);return(0,c.useEffect)(()=>{if(!r||t===null){l(U);return}let e=!1;return l(e=>({...e,loading:!0,error:null})),(async()=>{let r=await H(t,n??void 0);e||l({available:r.ok&&r.worktrees.length>0,loading:!1,error:r.error,repoRoot:r.repoRoot,worktrees:r.worktrees})})(),()=>{e=!0}},[r,t,a,i,n]),(0,c.useMemo)(()=>({...s,refresh:u}),[u,s])}function Ee(e=1600){let[t,n]=(0,c.useState)(!1),r=(0,c.useRef)(null),i=(0,c.useCallback)(()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,n(!1)},[]),a=(0,c.useCallback)(()=>{r.current!==null&&window.clearTimeout(r.current),n(!0),r.current=window.setTimeout(()=>{r.current=null,n(!1)},e)},[e]);return(0,c.useEffect)(()=>()=>i(),[i]),{folderChordActive:t,startFolderChord:a,cancelFolderChord:i}}function De(e){let t=e.onPreviewFile,[n,r]=(0,c.useState)(()=>e.initialSelection??A),i=(0,c.useMemo)(()=>he(e.entries,e.childrenCache,e.expanded),[e.childrenCache,e.entries,e.expanded]),a=(0,c.useMemo)(()=>i.map(e=>e.path),[i]),o=(0,c.useMemo)(()=>new Set(n.selectedPaths),[n.selectedPaths]),s=(0,c.useMemo)(()=>ve(i,o),[o,i]),l=n.focusedPath??s[0]?.path??null,u=i.find(e=>e.path===l)??s[0]??null;return(0,c.useEffect)(()=>{r(e=>ge(e,a))},[a]),{selection:n,visibleEntries:i,visiblePaths:a,selectedPaths:o,selectedPath:l,selectedEntries:s,selectedEntry:u,selectEntry:(0,c.useCallback)((e,n={})=>{r(t=>_e(t,e.path,a,n)),e.kind===`file`&&n.preview!==!1&&t?.(e.path)},[t,a]),selectOnlyPath:(0,c.useCallback)(e=>{r(e&&a.includes(e)?{selectedPaths:[e],focusedPath:e,anchorPath:e}:A)},[a]),resetSelection:(0,c.useCallback)(()=>{r(A)},[]),moveKeyboardSelection:(0,c.useCallback)((e,t)=>{r(n=>j(n,a,e,t))},[a]),getDragSelectionFor:(0,c.useCallback)(e=>o.has(e.path)?{primaryEntry:e,entries:s}:{primaryEntry:e,entries:[e]},[s,o])}}var W=120,Oe=80;function ke(e){return e===`watch`?`Updated from file changes`:e===`move`?`Updated after move`:e===`mutation`?`Updated after file change`:e===`git-operation`?`Updated after git operation`:e===`worktree-switch`?`Updated worktree`:e===`root`?`Updated folder root`:`Updated folder`}function Ae(e){let{rootPath:t,expanded:n,source:r,loadDir:i,loadChildren:a,bumpGitRefresh:o,onGitRefresh:s,refreshWorktrees:l}=e,[u,d]=(0,c.useState)(null),[f,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(!1),g=(0,c.useRef)(!1),_=(0,c.useRef)(null),v=(0,c.useRef)(null),y=(0,c.useRef)(async()=>void 0),b=(0,c.useRef)(!0);(0,c.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=(0,c.useCallback)(()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),S=(0,c.useCallback)(async(e,r={})=>{if(t!==null){if(g.current){let t=_.current;_.current=t?{reason:e,options:{extraPaths:Array.from(new Set([...t.options.extraPaths??[],...r.extraPaths??[]]))}}:{reason:e,options:r};return}g.current=!0,b.current&&(h(!0),d(e===`watch`?`Refreshing changed files...`:`Refreshing folder...`));try{let c=Array.from(new Set([...Array.from(n),...r.extraPaths??[]])).slice(0,Oe);await i(t);for(let e of c)await a(e,{force:!0});if(o(),s?.(),l(),!b.current)return;let u=Math.max(0,n.size-c.length);d(u>0?`${ke(e)}; ${u} collapsed/overflow branches skipped`:ke(e))}finally{g.current=!1,b.current&&h(!1);let e=_.current;_.current=null,e&&b.current&&y.current(e.reason,e.options)}}},[o,n,a,i,s,l,t]),C=(0,c.useCallback)(async(e=`manual`,t={})=>{await S(e,t)},[S]);(0,c.useEffect)(()=>{y.current=S},[S]);let w=(0,c.useCallback)(()=>{x(),v.current=window.setTimeout(()=>{v.current=null,y.current(`watch`)},W)},[x]);return(0,c.useEffect)(()=>{if(!r.watchDir||!r.onDirChange||t===null)return;let e=!1;(async()=>{let n=await r.watchDir?.(t);e||(n&&!n.ok?p(`Watch disabled: ${n.error??`failed to watch directory`}`):p(null))})();let n=r.onDirChange(()=>{w()});return()=>{e=!0,x(),n(),r.unwatchDir?.(t)}},[x,t,w,r]),{isRefreshing:m,refreshStatus:u,watchStatus:f,refreshVisibleTree:C}}function je(e){let{selectedFilePath:t,rootPath:n,selectedPath:r,visiblePaths:i,selectOnlyPath:a}=e,o=(0,c.useRef)(null);(0,c.useEffect)(()=>{let e=t??null,s=e!==o.current;s&&(o.current=e),!(!s&&r)&&(!e||!n||k(n,e)&&e!==r&&i.includes(e)&&a(e))},[n,a,t,r,i])}var Me=8,Ne=0;function G(){return Ne+=1,`folder-git-op-${Date.now()}-${Ne}`}function K(e){return/dirty|uncommitted|confirmation required|not registered|outside home|symlink/i.test(e)}function q(e,t){return{id:G(),operation:e,startedAt:new Date().toISOString(),finishedAt:null,operationLabel:t?.label??e.type,commandPreview:t?.command??[],status:`running`,stdout:``,stderr:``,error:null}}function J(e,t){return[t,...e].slice(0,Me)}function Y(e,t,n){return e.map(e=>e.id===t?n.ok?{...e,finishedAt:new Date().toISOString(),status:`succeeded`,stdout:n.stdout,error:null}:{...e,finishedAt:new Date().toISOString(),status:K(n.error)?`blocked`:`failed`,error:n.error}:e)}function Pe(e){let{rootPath:t,source:n,worktreeState:r,openFolderRoot:i,refreshVisibleTree:o,bumpGitRefresh:s,setActionStatus:l,setError:u}=e,[d,f]=(0,c.useState)(!1),[p,m]=(0,c.useState)(!1),[h,g]=(0,c.useState)([]);return{open:d,setOpen:f,busy:p,history:h,openWorktreeRoot:(0,c.useCallback)(async e=>{await i(e,{registerGitWorktree:!0,repoRoot:r.repoRoot})},[i,r.repoRoot]),copyWorktreePath:(0,c.useCallback)(async e=>{let t=await a(e);t.ok?(l(`Copied worktree path`),u(null)):u(t.error??`Failed to copy worktree path`)},[l,u]),revealWorktreePath:(0,c.useCallback)(async e=>{if(!(!t||!n.registerGitWorktreeRoot||!n.revealPath))try{await n.registerGitWorktreeRoot(t,r.repoRoot??void 0,e),await n.revealPath(e),l(`Opened worktree in Finder`),u(null)}catch(e){u(e.message)}},[t,l,u,n,r.repoRoot]),runWorktreeOperation:(0,c.useCallback)(async(e,n)=>{if(!t)return;let i=q(e,n),a=!1;g(e=>J(e,i)),m(!0);try{let n=await w({folderPanelRoot:t,repoRoot:r.repoRoot,operation:e,confirmed:!0});if(!n.ok){let e=n.error??`Git operation failed`;throw g(t=>Y(t,i.id,{ok:!1,error:e})),a=!0,Error(e)}g(e=>Y(e,i.id,{ok:!0,stdout:n.stdout})),a=!0,l(n.preview?.label??`Git worktree operation completed`),u(null),f(!1),r.refresh(),s(),await o(`git-operation`)}catch(e){let t=e.message;a||g(e=>Y(e,i.id,{ok:!1,error:t})),u(t)}finally{m(!1)}},[s,o,t,l,u,r])}}function Fe(e){let[t,n]=(0,c.useState)(null),[r,i]=(0,c.useState)(!1),a=(0,c.useCallback)(()=>e.rootPath?e.selectedEntry?e.selectedEntry.kind===`directory`?e.selectedEntry.path:ne(e.selectedEntry.path):e.rootPath:null,[e.rootPath,e.selectedEntry]),o=(0,c.useCallback)(t=>{let r=a();r&&(t===`file`&&!e.source.createFile||t===`directory`&&!e.source.createFolder||(e.setExpanded(e=>new Set(e).add(r)),n({kind:t,parentDirectory:r,initialName:t===`file`?`untitled.txt`:`untitled`}),e.closeContextMenu()))},[e,a]),s=(0,c.useCallback)(async(t,r,a)=>{let o=t===`file`?e.source.createFile:e.source.createFolder;if(!o)return;let s=t===`file`?`New file name`:`New folder name`;if(!a.trim()){e.setError(`${s} required`);return}i(!0);try{let i=(await o(r,a.trim())).entry;t===`directory`&&e.selectedEntry?.path===r&&e.setExpanded(e=>new Set(e).add(r)),e.setActionStatus(t===`file`?`Created file`:`Created folder`),e.setError(null),n(null),await e.refreshAfterMutation(r,i?.path??null)}catch(t){e.setError(t.message)}finally{i(!1)}},[e]),l=(0,c.useCallback)(()=>{!e.selectedEntry||!e.source.renamePath||(n({kind:`rename`,parentDirectory:ne(e.selectedEntry.path),targetPath:e.selectedEntry.path,initialName:e.selectedEntry.name}),e.closeContextMenu())},[e]),u=(0,c.useCallback)(async(t,r)=>{if(!t.targetPath||!e.source.renamePath)return;let a=r.trim();if(!a||a===t.initialName){n(null);return}i(!0);try{let r=await e.source.renamePath(t.targetPath,a),i=t.parentDirectory,o=r.entry?.path??null,s=o?e.renamedPreviewPath(e.selectedFilePath,t.targetPath,o):null;e.setActionStatus(`Renamed`),e.setError(null),n(null),await e.refreshAfterMutation(i,o,[t.targetPath]),s&&e.onPreviewFile?.(s)}catch(t){e.setError(t.message)}finally{i(!1)}},[e]);return{inlineMutation:t,isMutating:r,requestCreateEntry:o,requestRenameSelectedEntry:l,submitInlineMutation:(0,c.useCallback)(e=>{t&&(t.kind===`rename`?u(t,e):s(t.kind,t.parentDirectory,e))},[t,s,u]),cancelInlineMutation:()=>n(null)}}function Ie(e){let[t,n]=(0,c.useState)(null),r=(0,c.useCallback)(()=>n(null),[]),i=(0,c.useCallback)((t,r,i)=>{e.selectedPaths.has(t.path)||e.selectOnlyPath(t.path),n({entry:t,x:r,y:i})},[e]);return(0,c.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(null)},i=()=>{document.activeElement instanceof HTMLIFrameElement&&n(null)};return window.addEventListener(`pointerdown`,r),window.addEventListener(`keydown`,e),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointerdown`,r),window.removeEventListener(`keydown`,e),window.removeEventListener(`blur`,i)}},[r,t]),{contextMenu:t,closeContextMenu:r,openContextMenu:i}}function Le(){return i()?.folder??null}function Re(e,t,n){return!e||!k(t,e)?null:e===t?n:`${n}${e.slice(t.length)}`}function ze(e){let t=Le(),n=e.repoRootPath??null,r=e.gitRefreshVersion??0,i=e.onGitRefresh,o=e.onRepoRootChange,s=(0,c.useRef)(!1),l=(0,c.useMemo)(()=>t?d(t):f(e.notesTree??[],e.notesRoot??null),[t,e.notesRoot,e.notesTree]),u=(0,c.useMemo)(()=>xe(e.sessionState??null,e.externalRootPath??null),[e.externalRootPath,e.sessionState]),[h,g]=(0,c.useState)(()=>u?.rootPath??null),[v,y]=(0,c.useState)(()=>u?.entries??[]),[b,S]=(0,c.useState)(()=>new Set(u?.expandedPaths??[])),[C,w]=(0,c.useState)(()=>u?be(u.childrenCache):new Map),[T,E]=(0,c.useState)(null),[ee,D]=(0,c.useState)(null),[te,ae]=(0,c.useState)(null),[oe,se]=(0,c.useState)(null),[ce,le]=(0,c.useState)(null),[de,fe]=(0,c.useState)(!1),[pe,A]=(0,c.useState)(!1),[he,ge]=(0,c.useState)(!1),[_e,j]=(0,c.useState)(null),[ve,M]=(0,c.useState)(0),ye=(0,c.useRef)(null),N=(0,c.useRef)(null),{folderChordActive:P,startFolderChord:F,cancelFolderChord:I}=Ee(),L=e.onPreviewFile,Ce=e.selectedFilePath,R=De({entries:v,childrenCache:C,expanded:b,initialSelection:u?.selection,onPreviewFile:L}),z=R.selectedEntry,B=R.selectedEntries,V=Ie({selectedPaths:R.selectedPaths,selectOnlyPath:R.selectOnlyPath});je({selectedFilePath:e.selectedFilePath,rootPath:h,selectedPath:R.selectedPath,visiblePaths:R.visiblePaths,selectOnlyPath:R.selectOnlyPath}),(0,c.useEffect)(()=>{e.onSessionStateChange?.(Se({rootPath:h,entries:v,expanded:b,childrenCache:C,selection:R.selection}))},[C,v,b,R.selection,e.onSessionStateChange,h]);let H=(0,c.useCallback)(async e=>{try{return y(await l.listDir(e)),E(null),D(t=>t?.path===e?null:t),{ok:!0}}catch(e){let t=e.message;return E(t),{ok:!1,error:t}}},[l]),U=(0,c.useCallback)(async(t,n={})=>{try{let r=t;if(n.registerGitWorktree){if(!h)throw Error(`Current folder root required`);await l.registerGitWorktreeRoot?.(h,n.repoRoot??void 0,t)}else l.authorizeRoot&&(r=await l.authorizeRoot(t));h&&l.unwatchDir&&l.unwatchDir(h),e.onRootChange?.(r),g(r),S(new Set),w(new Map),y([]),R.resetSelection(),E(null),D(null);let i=await H(r);i.ok||D({path:r,error:i.error}),M(e=>e+1)}catch(e){E(e.message)}},[R,H,e,h,l]),W=(0,c.useCallback)(async(e,t={})=>{if(!(!t.force&&C.has(e)))try{let t=await l.listDir(e);w(n=>new Map(n).set(e,t))}catch(e){E(e.message)}},[C,l]),Oe=(0,c.useCallback)(()=>{M(e=>e+1)},[]),ke=(0,c.useCallback)(e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),W(e)),n})},[W]),Me=(0,c.useCallback)(async()=>{if(l.pickRoot)try{let e=await l.pickRoot();e&&await U(e)}catch(e){E(e.message)}},[U,l]),Ne=(0,c.useCallback)(()=>{e.onRootChange?.(null),g(null),y([]),R.resetSelection(),D(null),E(null)},[R,e]);(0,c.useEffect)(()=>{if(s.current||h!==null||e.externalRootPath)return;let t=!1;return(async()=>{let e=await l.getInitialRoot();t||(s.current=!0,g(e),e!==null&&await H(e))})(),()=>{t=!0}},[H,e.externalRootPath,h,l]),(0,c.useEffect)(()=>{let t=e.externalRootPath;if(t){if(t===h){if(v.length>0||N.current===t)return;N.current=t}else N.current=null;U(t)}},[v.length,U,e.externalRootPath,h]);let G=we({rootPath:h,enabled:l.kind===`electron-folder`,refreshToken:ve+r}),K=Te({folderPanelRoot:h,repoRoot:G.repoRoot??n,enabled:l.kind===`electron-folder`&&G.available,refreshToken:ve+r}),q=Ae({rootPath:h,expanded:b,source:l,loadDir:H,loadChildren:W,bumpGitRefresh:Oe,onGitRefresh:i,refreshWorktrees:K.refresh}),J=q.refreshVisibleTree,Y=Pe({rootPath:h,source:l,worktreeState:K,openFolderRoot:U,refreshVisibleTree:J,bumpGitRefresh:Oe,setActionStatus:j,setError:E});(0,c.useEffect)(()=>{G.repoRoot&&G.repoRoot!==n&&o?.(G.repoRoot)},[G.repoRoot,o,n]);let ze=l.kind===`electron-folder`,Be=!!(l.createFile&&l.createFolder&&l.renamePath),Ve=(0,c.useCallback)(async(e,t)=>{if(!h)return;let n=ne(e);w(e=>ie(e,[n,t])),await J(`move`,{extraPaths:[n,t]})},[J,h]),He=(0,c.useCallback)(async(e,t,n=[])=>{h&&(w(t=>ie(t,[e,...n])),await J(`mutation`,{extraPaths:[e]}),t&&R.selectOnlyPath(t))},[R,J,h]),Ue=(0,c.useCallback)(async e=>{if(l.movePath){fe(!0);try{let t=(await l.movePath(e.source.path,e.target.path)).moved?.to??e.source.path;R.selectOnlyPath(t),j(`Moved ${e.source.name}`),le(null),await Ve(e.source.path,e.target.path)}catch(e){E(e.message)}finally{fe(!1)}}},[R,Ve,l]),We=(0,c.useCallback)((e,t)=>{if(!l.movePath||e.path===t.path||e.kind===`directory`&&k(e.path,t.path))return;let n={source:e,target:t};if(pe){Ue(n);return}ge(!1),le(n)},[Ue,pe,l.movePath]),X=Fe({rootPath:h,selectedEntry:z,selectedFilePath:Ce,source:l,folderSelection:R,refreshAfterMutation:He,renamedPreviewPath:Re,onPreviewFile:L,closeContextMenu:V.closeContextMenu,setExpanded:S,setActionStatus:j,setError:E}),Z=(0,c.useCallback)((e,t)=>{R.selectEntry(e,t),V.closeContextMenu()},[V,R]),Ge=(0,c.useCallback)(e=>{e.kind===`file`&&Z(e)},[Z]),Ke=(0,c.useCallback)(e=>{R.selectEntry(e,{preview:!1}),V.closeContextMenu(),e.kind===`directory`&&ke(e.path)},[V,R,ke]),qe=(0,c.useCallback)(async(e,t)=>{let n=await a(t===`relative`?re(h,e.path):e.path);n.ok?(R.selectOnlyPath(e.path),j(t===`relative`?`Copied relative path`:`Copied path`),E(null)):E(n.error??`Failed to copy path`)},[R,h]),Je=(0,c.useCallback)(async e=>{if(l.revealPath)try{await l.revealPath(e.path),R.selectOnlyPath(e.path),j(e.kind===`directory`?`Opened folder in Finder`:`Revealed file in Finder`),E(null)}catch(e){E(e.message)}},[R,l]),Q=(0,c.useCallback)(async e=>{if(B.length===0)return;let t=await a(B.map(t=>e===`relative`?re(h,t.path):t.path).join(`
|
|
3
|
+
`));t.ok?(j(e===`relative`?`Copied relative paths`:`Copied paths`),E(null)):E(t.error??`Failed to copy paths`)},[h,B]),$=(0,c.useCallback)(async()=>{z&&await Je(z)},[Je,z]),Ye=(0,c.useCallback)((e,t)=>{if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault(),e.stopPropagation(),R.moveKeyboardSelection(e.key===`ArrowDown`?`down`:`up`,e.shiftKey);return}let n=ue(e,{chordActive:P});if(n){e.preventDefault(),e.stopPropagation(),n===`start-chord`&&F(),n===`cancel-chord`&&I();let r=R.selectedPaths.has(t.path);n===`copy-path`&&(I(),r?Q(`absolute`):qe(t,`absolute`)),n===`copy-relative-path`&&(I(),r?Q(`relative`):qe(t,`relative`)),n===`reveal-path`&&(I(),r?$():Je(t));return}if(e.key===`Enter`){e.preventDefault(),t.kind===`directory`?Ke(t):Z(t);return}e.key===` `&&(e.preventDefault(),Z(t))},[I,qe,Q,P,R,Je,$,Z,F,Ke]);return(0,c.useEffect)(()=>{let e=R.selection.focusedPath;if(!e)return;let t=ye.current?.querySelectorAll(`.folder-entry-btn[data-folder-path]`);Array.from(t??[]).find(t=>t.dataset.folderPath===e)?.focus()},[R.selection.focusedPath]),(0,p.jsxs)(`div`,{className:`folder-panel`,children:[(0,p.jsx)(x,{canPickRoot:l.canPickRoot,label:l.label,rootPath:h,onPickFolder:()=>void Me(),onRefresh:()=>{h!==null&&J(`manual`)},gitSummary:l.kind===`electron-folder`?G:void 0,worktreeSummary:l.kind===`electron-folder`?K:void 0,onOpenWorktree:e=>void Y.openWorktreeRoot(e),onCopyWorktreePath:e=>void Y.copyWorktreePath(e),onRevealWorktreePath:e=>void Y.revealWorktreePath(e),onOpenWorktreeOps:()=>Y.setOpen(!0)}),h!==null&&(0,p.jsx)(m,{hasSelection:!!z,canReveal:!!l.revealPath,onCopyPath:()=>void Q(`absolute`),onCopyRelativePath:()=>void Q(`relative`),onReveal:()=>void $(),canMutate:Be,onCreateFile:()=>X.requestCreateEntry(`file`),onCreateFolder:()=>X.requestCreateEntry(`directory`),onRename:()=>X.requestRenameSelectedEntry()}),T&&(0,p.jsx)(`div`,{className:`folder-error`,children:T}),q.watchStatus&&!T&&(0,p.jsx)(`div`,{className:`folder-status`,children:q.watchStatus}),q.refreshStatus&&!T&&!q.watchStatus&&(0,p.jsx)(`div`,{className:`folder-status`,children:q.refreshStatus}),_e&&!T&&!q.refreshStatus&&!q.watchStatus&&(0,p.jsx)(`div`,{className:`folder-status`,children:_e}),P&&(0,p.jsx)(`div`,{className:`folder-shortcut-hint`,children:`Folder shortcut: press P to copy path or R to reveal`}),Y.open&&h!==null&&(0,p.jsx)(O,{folderPanelRoot:h,repoRoot:K.repoRoot,worktrees:K.worktrees,busy:Y.busy,history:Y.history,onRun:(e,t)=>void Y.runWorktreeOperation(e,t),onClose:()=>Y.setOpen(!1)}),(0,p.jsx)(me,{treeRef:ye,rootPath:h,error:T,entries:v,expanded:b,childrenCache:C,folderSelection:R,decorationsByPath:G.decorationsByPath,dropTargetPath:oe,dragSelection:te,inlineMutation:X.inlineMutation,isMutating:X.isMutating,canUseNativeActions:ze,sourceKind:l.kind,unavailableRoot:ee,setDragSelection:ae,setDropTargetPath:se,requestMove:We,handleEntryKeyDown:Ye,selectEntry:Z,toggleEntryExpansion:Ke,openFileEntry:Ge,openContextMenu:V.openContextMenu,submitInlineMutation:X.submitInlineMutation,cancelInlineMutation:X.cancelInlineMutation,onPickFolder:()=>void Me(),onClearUnavailableRoot:Ne}),(0,p.jsx)(_,{pendingMove:ce,contextMenu:V.contextMenu,isMoving:de,skipMoveConfirmChecked:he,canReveal:!!l.revealPath,canRefresh:!!h,canMutate:Be,onSkipMoveConfirmCheckedChange:ge,onCancelMove:()=>le(null),onConfirmMove:()=>{ce&&(he&&A(!0),Ue(ce))},onCopyContextPath:()=>{V.closeContextMenu(),Q(`absolute`)},onCopyContextRelativePath:()=>{V.closeContextMenu(),Q(`relative`)},onRevealContextPath:()=>{V.closeContextMenu(),$()},onRefreshContext:()=>{V.closeContextMenu(),J(`manual`)},onCreateContextFile:()=>X.requestCreateEntry(`file`),onCreateContextFolder:()=>X.requestCreateEntry(`directory`),onRenameContextPath:()=>X.requestRenameSelectedEntry()})]})}export{ze as FolderPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{n as t,t as n}from"./jsx-runtime-B3ZGMGGg.js";import{a as r,i,n as a,r as o,t as s}from"./page-shell-BeAyKBJW.js";import{a as c,i as l,s as u}from"./fields-MeoSVgIK.js";import{n as d}from"./agent-meta-DqBTGRRQ.js";import{t as f}from"./path-utils-DX1HplvB.js";var p=e(t(),1),m=n(),h=[{value:`every`,label:`every (interval)`},{value:`cron`,label:`cron expression`}];function g({job:e,index:t,bodyError:n,timeZoneError:r,onChange:i,onRemove:a}){let o=(0,p.useId)(),s=e.schedule.kind,d=e.schedule.timeZone??``;return(0,m.jsxs)(`fieldset`,{className:`settings-heartbeat-job`,"aria-label":`Heartbeat job ${t+1}${e.name?` (${e.name})`:``}`,children:[(0,m.jsx)(`legend`,{className:`settings-heartbeat-job-legend`,children:e.name||`Job ${t+1}`}),(0,m.jsx)(c,{id:`${o}-enabled`,label:`Enabled`,value:e.enabled,onChange:e=>i({enabled:e})}),(0,m.jsx)(u,{id:`${o}-name`,label:`Name`,value:e.name,placeholder:`Morning summary`,onChange:e=>i({name:e})}),(0,m.jsx)(l,{id:`${o}-kind`,label:`Schedule kind`,value:s,options:h,onChange:e=>{e===`every`&&s!==`every`?i({schedule:{kind:`every`,minutes:30,...d?{timeZone:d}:{}}}):e===`cron`&&s!==`cron`&&i({schedule:{kind:`cron`,cron:`0 9 * * *`,...d?{timeZone:d}:{}}})}}),s===`every`?(0,m.jsx)(u,{id:`${o}-minutes`,label:`Every (minutes)`,value:String(e.schedule.minutes??``),placeholder:`30`,error:n??null,onChange:e=>{let t=e.trim(),n=Number(t);i({schedule:{kind:`every`,minutes:Number.isFinite(n)?n:NaN,...d?{timeZone:d}:{}}})}}):(0,m.jsx)(u,{id:`${o}-cron`,label:`Cron expression`,value:e.schedule.cron??``,placeholder:`0 9 * * *`,error:n??null,onChange:e=>i({schedule:{kind:`cron`,cron:e,...d?{timeZone:d}:{}}})}),(0,m.jsx)(u,{id:`${o}-tz`,label:`Time zone (optional)`,value:d,placeholder:`Asia/Seoul`,error:r??null,onChange:t=>{let n=t.trim();i(s===`every`?{schedule:{kind:`every`,minutes:e.schedule.minutes,...n?{timeZone:n}:{}}}:{schedule:{kind:`cron`,cron:e.schedule.cron,...n?{timeZone:n}:{}}})}}),(0,m.jsxs)(`label`,{className:`settings-field settings-field-textarea`,htmlFor:`${o}-prompt`,children:[(0,m.jsx)(`span`,{className:`settings-field-label`,children:`Prompt`}),(0,m.jsx)(`textarea`,{id:`${o}-prompt`,rows:3,value:e.prompt,placeholder:`What should this heartbeat do?`,onChange:e=>i({prompt:e.target.value})})]}),(0,m.jsx)(`div`,{className:`settings-heartbeat-job-footer`,children:(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,onClick:a,children:`Remove job`})})]})}var _=/^\d+[smh]$/,v=/^([01]\d|2[0-3]):[0-5]\d$/,y=[`ai-e`,`claude`,`claude-e`,`codex`,`codex-app`,`copilot`,`cursor`,`kiro-code`,`gemini`,`grok`,`opencode`],b=[`heartbeat.enabled`,`heartbeat.every`,`heartbeat.activeHours.start`,`heartbeat.activeHours.end`,`heartbeat.target`],x=[`heartbeat.jobs`,`heartbeat.md`];function S(e){return _.test(e.trim())}function C(e){return v.test(e.trim())}function w(e=Date.now()){return{id:`hb_${e}`,name:``,enabled:!0,schedule:{kind:`every`,minutes:30},prompt:``}}function T(e){return e.startsWith(`heartbeat.`)&&e!==`heartbeat.jobs`&&e!==`heartbeat.md`}function E(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=typeof n.id==`string`&&n.id.trim()?n.id.trim():`hb_unknown_${t}`,i=typeof n.name==`string`?n.name:``,a=n.enabled!==!1,o=typeof n.prompt==`string`?n.prompt:``,s=n.schedule,c;if(s&&typeof s==`object`){let e=s;c=e.kind===`cron`&&typeof e.cron==`string`?{kind:`cron`,cron:e.cron,...typeof e.timeZone==`string`&&e.timeZone?{timeZone:e.timeZone}:{}}:{kind:`every`,minutes:typeof e.minutes==`number`?e.minutes:30,...typeof e.timeZone==`string`&&e.timeZone?{timeZone:e.timeZone}:{}}}else c={kind:`every`,minutes:30};return{id:r,name:i,enabled:a,schedule:c,prompt:o}}function D(e){if(!e||typeof e!=`object`)return[];let t=e.jobs;return Array.isArray(t)?t.map((e,t)=>E(e,t)).filter(e=>e!==null):[]}function O(e){if(e.kind===`every`){let t=e.minutes;return!Number.isFinite(t)||t<=0||!Number.isInteger(t)?`Minutes must be a positive integer`:null}let t=e.cron?.trim()??``;return t?t.split(/\s+/).length<5?`Cron must have at least 5 fields`:null:`Cron expression required`}function k(e){return e.some(e=>O(e.schedule)!==null)}function A({port:e,client:t,dirty:n,snapshot:r}){let[i,a]=(0,p.useState)([]),[c,l]=(0,p.useState)([]),[u,d]=(0,p.useState)(!1),[f,h]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(r.kind!==`ready`)return;let e=D(r.data);a(e),l(e)},[r]),(0,p.useEffect)(()=>{n.set(`heartbeat.jobs`,{value:i,original:c,valid:!k(i)})},[i,c,n]),(0,p.useEffect)(()=>()=>{n.remove(`heartbeat.jobs`)},[n]);let _=(0,p.useCallback)(async()=>{if(k(i)){h(`Fix invalid schedules before saving.`);return}d(!0),h(null);try{let e=D(await t.put(`/api/heartbeat`,{jobs:i}));a(e),l(e),n.remove(`heartbeat.jobs`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{d(!1)}},[t,n,i]);if(r.kind===`loading`)return(0,m.jsx)(`p`,{className:`settings-section-hint`,children:`Loading jobs…`});if(r.kind===`offline`)return(0,m.jsx)(o,{port:e});if(r.kind===`error`)return(0,m.jsx)(s,{message:r.message});let v=n.pending.has(`heartbeat.jobs`),y=k(i);function b(e,t){a(n=>n.map((n,r)=>r===e?{...n,...t}:n))}function x(){a(e=>[...e,w()])}function S(e){a(t=>t.filter((t,n)=>n!==e))}return(0,m.jsxs)(m.Fragment,{children:[i.length===0?(0,m.jsx)(`p`,{className:`settings-section-hint`,children:`No jobs configured. Add one below.`}):(0,m.jsx)(`div`,{className:`settings-heartbeat-jobs-list`,children:i.map((e,t)=>(0,m.jsx)(g,{job:e,index:t,bodyError:O(e.schedule),onChange:e=>b(t,e),onRemove:()=>S(t)},e.id))}),(0,m.jsxs)(`div`,{className:`settings-heartbeat-jobs-footer`,children:[(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,onClick:x,children:`+ Add job`}),(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-save`,onClick:()=>void _(),disabled:u||!v||y,children:u?`Saving…`:`Apply jobs`})]}),f?(0,m.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:f}):null]})}function j({port:e,client:t,dirty:n,snapshot:r}){let[i,a]=(0,p.useState)(``),[c,l]=(0,p.useState)(``),[u,d]=(0,p.useState)(!1),[f,h]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(r.kind!==`ready`)return;let e=r.data.content??``;a(e),l(e)},[r]),(0,p.useEffect)(()=>{n.set(`heartbeat.md`,{value:i,original:c,valid:!0})},[i,c,n]),(0,p.useEffect)(()=>()=>{n.remove(`heartbeat.md`)},[n]);let g=(0,p.useCallback)(async()=>{d(!0),h(null);try{await t.put(`/api/heartbeat-md`,{content:i}),l(i),n.remove(`heartbeat.md`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{d(!1)}},[t,n,i]);if(r.kind===`loading`)return(0,m.jsx)(`p`,{className:`settings-section-hint`,children:`Loading template…`});if(r.kind===`offline`)return(0,m.jsx)(o,{port:e});if(r.kind===`error`)return(0,m.jsx)(s,{message:r.message});let _=n.pending.has(`heartbeat.md`);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`label`,{className:`settings-field settings-field-textarea`,htmlFor:`hb-md`,children:[(0,m.jsx)(`span`,{className:`settings-field-label`,children:`Template`}),(0,m.jsx)(`textarea`,{id:`hb-md`,rows:10,spellCheck:!1,value:i,onChange:e=>a(e.target.value),style:{fontFamily:`ui-monospace, monospace`}})]}),(0,m.jsx)(`div`,{className:`settings-heartbeat-md-footer`,children:(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-save`,onClick:()=>void g(),disabled:u||!_,children:u?`Saving…`:`Save template`})}),f?(0,m.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:f}):null]})}function M({port:e,client:t,dirty:n,registerSave:h}){let g=r(t,`/api/settings`),_=r(t,`/api/heartbeat`),v=r(t,`/api/heartbeat-md`),[x,w]=(0,p.useState)(!1),[E,D]=(0,p.useState)(`30m`),[O,k]=(0,p.useState)(`08:00`),[M,N]=(0,p.useState)(`22:00`),[P,F]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{if(g.state.kind!==`ready`)return;let e=g.state.data.heartbeat||{};w(!!e.enabled),D(typeof e.every==`string`?e.every:`30m`),k(e.activeHours?.start??`08:00`),N(e.activeHours?.end??`22:00`),F(typeof e.target==`string`?e.target:`all`)},[g.state]),(0,p.useEffect)(()=>()=>{for(let e of b)n.remove(e)},[n]);let I=(0,p.useMemo)(()=>g.state.kind===`ready`&&g.state.data.heartbeat||{},[g.state]),L=(0,p.useCallback)((e,t)=>n.set(e,t),[n]),R=(0,p.useRef)(0),z=(0,p.useCallback)(async()=>{let e=n.saveBundle(),r={};for(let[t,n]of Object.entries(e))T(t)&&(r[t]=n);if(Object.keys(r).length===0)return;let i=++R.current,a=f(r),o=await t.put(`/api/settings`,a);if(i!==R.current)return;let s=o&&typeof o==`object`&&`data`in o?o.data:o;for(let e of b)n.remove(e);g.setData(s);let c=s.heartbeat||{};w(!!c.enabled),D(typeof c.every==`string`?c.every:`30m`),k(c.activeHours?.start??`08:00`),N(c.activeHours?.end??`22:00`),F(typeof c.target==`string`?c.target:`all`),await g.refresh()},[t,n,g]);if((0,p.useEffect)(()=>{if(h)return h(z),()=>h(null)},[h,z]),g.state.kind===`loading`)return(0,m.jsx)(a,{});if(g.state.kind===`offline`)return(0,m.jsx)(o,{port:e});if(g.state.kind===`error`)return(0,m.jsx)(s,{message:g.state.message});let B=S(E)?null:"Use the form `<n>s|m|h`, e.g. `30m`",V=C(O)?null:`Use HH:MM (24h)`,H=C(M)?null:`Use HH:MM (24h)`,U=g.state.data.perCli||{},W=Object.keys(U),G=[{value:`all`,label:`all (broadcast)`},...(W.length>0?W:[...y]).map(e=>({value:e,label:d(e).label||e}))];return G.some(e=>e.value===P)||G.push({value:P,label:`${d(P).label||P} (legacy)`}),(0,m.jsxs)(`form`,{className:`settings-page-form`,onSubmit:e=>{e.preventDefault(),z()},children:[(0,m.jsxs)(i,{title:`Heartbeat`,hint:`Background prompts the agent runs on a schedule.`,children:[(0,m.jsx)(c,{id:`hb-enabled`,label:`Heartbeat enabled`,value:x,onChange:e=>{w(e),L(`heartbeat.enabled`,{value:e,original:!!I.enabled,valid:!0})}}),(0,m.jsx)(u,{id:`hb-every`,label:`Default interval`,value:E,placeholder:`30m`,error:B,onChange:e=>{D(e),L(`heartbeat.every`,{value:e,original:I.every??`30m`,valid:S(e)})}}),(0,m.jsx)(u,{id:`hb-start`,label:`Active hours start`,value:O,placeholder:`08:00`,error:V,onChange:e=>{k(e),L(`heartbeat.activeHours.start`,{value:e,original:I.activeHours?.start??`08:00`,valid:C(e)})}}),(0,m.jsx)(u,{id:`hb-end`,label:`Active hours end`,value:M,placeholder:`22:00`,error:H,onChange:e=>{N(e),L(`heartbeat.activeHours.end`,{value:e,original:I.activeHours?.end??`22:00`,valid:C(e)})}}),(0,m.jsx)(l,{id:`hb-target`,label:`Target`,value:P,options:G,onChange:e=>{F(e),L(`heartbeat.target`,{value:e,original:I.target??`all`,valid:!0})}})]}),(0,m.jsx)(i,{title:`Jobs`,hint:`Each job replaces the entire heartbeat.json on save. Concurrent edits from multiple browsers will overwrite — last write wins.`,children:(0,m.jsx)(A,{port:e,client:t,dirty:n,snapshot:_.state})}),(0,m.jsx)(i,{title:`Default heartbeat prompt template`,hint:`Markdown shown to the agent when a heartbeat fires without a job-specific prompt.`,children:(0,m.jsx)(j,{port:e,client:t,dirty:n,snapshot:v.state})})]})}export{x as PAGE_LOCAL_KEYS,b as SECTION_A_KEYS,y as TARGET_FALLBACK,M as default,T as isHeartbeatSettingsKey,O as jobScheduleBodyError,k as jobsHaveErrors,w as makeDefaultJob,D as normalizeJobsResponse,C as validateHHMM,S as validateInterval};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{n as t,t as n}from"./jsx-runtime-B3ZGMGGg.js";import{a as r,i,n as a,r as o,t as s}from"./page-shell-BeAyKBJW.js";import{a as c,i as l,s as u}from"./fields-MeoSVgIK.js";import{n as d}from"./agent-meta-FyI15KAa.js";import{t as f}from"./path-utils-DX1HplvB.js";var p=e(t(),1),m=n(),h=[{value:`every`,label:`every (interval)`},{value:`cron`,label:`cron expression`}];function g({job:e,index:t,bodyError:n,timeZoneError:r,onChange:i,onRemove:a}){let o=(0,p.useId)(),s=e.schedule.kind,d=e.schedule.timeZone??``;return(0,m.jsxs)(`fieldset`,{className:`settings-heartbeat-job`,"aria-label":`Heartbeat job ${t+1}${e.name?` (${e.name})`:``}`,children:[(0,m.jsx)(`legend`,{className:`settings-heartbeat-job-legend`,children:e.name||`Job ${t+1}`}),(0,m.jsx)(c,{id:`${o}-enabled`,label:`Enabled`,value:e.enabled,onChange:e=>i({enabled:e})}),(0,m.jsx)(u,{id:`${o}-name`,label:`Name`,value:e.name,placeholder:`Morning summary`,onChange:e=>i({name:e})}),(0,m.jsx)(l,{id:`${o}-kind`,label:`Schedule kind`,value:s,options:h,onChange:e=>{e===`every`&&s!==`every`?i({schedule:{kind:`every`,minutes:30,...d?{timeZone:d}:{}}}):e===`cron`&&s!==`cron`&&i({schedule:{kind:`cron`,cron:`0 9 * * *`,...d?{timeZone:d}:{}}})}}),s===`every`?(0,m.jsx)(u,{id:`${o}-minutes`,label:`Every (minutes)`,value:String(e.schedule.minutes??``),placeholder:`30`,error:n??null,onChange:e=>{let t=e.trim(),n=Number(t);i({schedule:{kind:`every`,minutes:Number.isFinite(n)?n:NaN,...d?{timeZone:d}:{}}})}}):(0,m.jsx)(u,{id:`${o}-cron`,label:`Cron expression`,value:e.schedule.cron??``,placeholder:`0 9 * * *`,error:n??null,onChange:e=>i({schedule:{kind:`cron`,cron:e,...d?{timeZone:d}:{}}})}),(0,m.jsx)(u,{id:`${o}-tz`,label:`Time zone (optional)`,value:d,placeholder:`Asia/Seoul`,error:r??null,onChange:t=>{let n=t.trim();i(s===`every`?{schedule:{kind:`every`,minutes:e.schedule.minutes,...n?{timeZone:n}:{}}}:{schedule:{kind:`cron`,cron:e.schedule.cron,...n?{timeZone:n}:{}}})}}),(0,m.jsxs)(`label`,{className:`settings-field settings-field-textarea`,htmlFor:`${o}-prompt`,children:[(0,m.jsx)(`span`,{className:`settings-field-label`,children:`Prompt`}),(0,m.jsx)(`textarea`,{id:`${o}-prompt`,rows:3,value:e.prompt,placeholder:`What should this heartbeat do?`,onChange:e=>i({prompt:e.target.value})})]}),(0,m.jsx)(`div`,{className:`settings-heartbeat-job-footer`,children:(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,onClick:a,children:`Remove job`})})]})}var _=/^\d+[smh]$/,v=/^([01]\d|2[0-3]):[0-5]\d$/,y=[`ai-e`,`claude`,`claude-e`,`codex`,`codex-app`,`copilot`,`cursor`,`kiro-code`,`gemini`,`grok`,`opencode`],b=[`heartbeat.enabled`,`heartbeat.every`,`heartbeat.activeHours.start`,`heartbeat.activeHours.end`,`heartbeat.target`],x=[`heartbeat.jobs`,`heartbeat.md`];function S(e){return _.test(e.trim())}function C(e){return v.test(e.trim())}function w(e=Date.now()){return{id:`hb_${e}`,name:``,enabled:!0,schedule:{kind:`every`,minutes:30},prompt:``}}function T(e){return e.startsWith(`heartbeat.`)&&e!==`heartbeat.jobs`&&e!==`heartbeat.md`}function E(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=typeof n.id==`string`&&n.id.trim()?n.id.trim():`hb_unknown_${t}`,i=typeof n.name==`string`?n.name:``,a=n.enabled!==!1,o=typeof n.prompt==`string`?n.prompt:``,s=n.schedule,c;if(s&&typeof s==`object`){let e=s;c=e.kind===`cron`&&typeof e.cron==`string`?{kind:`cron`,cron:e.cron,...typeof e.timeZone==`string`&&e.timeZone?{timeZone:e.timeZone}:{}}:{kind:`every`,minutes:typeof e.minutes==`number`?e.minutes:30,...typeof e.timeZone==`string`&&e.timeZone?{timeZone:e.timeZone}:{}}}else c={kind:`every`,minutes:30};return{id:r,name:i,enabled:a,schedule:c,prompt:o}}function D(e){if(!e||typeof e!=`object`)return[];let t=e.jobs;return Array.isArray(t)?t.map((e,t)=>E(e,t)).filter(e=>e!==null):[]}function O(e){if(e.kind===`every`){let t=e.minutes;return!Number.isFinite(t)||t<=0||!Number.isInteger(t)?`Minutes must be a positive integer`:null}let t=e.cron?.trim()??``;return t?t.split(/\s+/).length<5?`Cron must have at least 5 fields`:null:`Cron expression required`}function k(e){return e.some(e=>O(e.schedule)!==null)}function A({port:e,client:t,dirty:n,snapshot:r}){let[i,a]=(0,p.useState)([]),[c,l]=(0,p.useState)([]),[u,d]=(0,p.useState)(!1),[f,h]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(r.kind!==`ready`)return;let e=D(r.data);a(e),l(e)},[r]),(0,p.useEffect)(()=>{n.set(`heartbeat.jobs`,{value:i,original:c,valid:!k(i)})},[i,c,n]),(0,p.useEffect)(()=>()=>{n.remove(`heartbeat.jobs`)},[n]);let _=(0,p.useCallback)(async()=>{if(k(i)){h(`Fix invalid schedules before saving.`);return}d(!0),h(null);try{let e=D(await t.put(`/api/heartbeat`,{jobs:i}));a(e),l(e),n.remove(`heartbeat.jobs`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{d(!1)}},[t,n,i]);if(r.kind===`loading`)return(0,m.jsx)(`p`,{className:`settings-section-hint`,children:`Loading jobs…`});if(r.kind===`offline`)return(0,m.jsx)(o,{port:e});if(r.kind===`error`)return(0,m.jsx)(s,{message:r.message});let v=n.pending.has(`heartbeat.jobs`),y=k(i);function b(e,t){a(n=>n.map((n,r)=>r===e?{...n,...t}:n))}function x(){a(e=>[...e,w()])}function S(e){a(t=>t.filter((t,n)=>n!==e))}return(0,m.jsxs)(m.Fragment,{children:[i.length===0?(0,m.jsx)(`p`,{className:`settings-section-hint`,children:`No jobs configured. Add one below.`}):(0,m.jsx)(`div`,{className:`settings-heartbeat-jobs-list`,children:i.map((e,t)=>(0,m.jsx)(g,{job:e,index:t,bodyError:O(e.schedule),onChange:e=>b(t,e),onRemove:()=>S(t)},e.id))}),(0,m.jsxs)(`div`,{className:`settings-heartbeat-jobs-footer`,children:[(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,onClick:x,children:`+ Add job`}),(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-save`,onClick:()=>void _(),disabled:u||!v||y,children:u?`Saving…`:`Apply jobs`})]}),f?(0,m.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:f}):null]})}function j({port:e,client:t,dirty:n,snapshot:r}){let[i,a]=(0,p.useState)(``),[c,l]=(0,p.useState)(``),[u,d]=(0,p.useState)(!1),[f,h]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(r.kind!==`ready`)return;let e=r.data.content??``;a(e),l(e)},[r]),(0,p.useEffect)(()=>{n.set(`heartbeat.md`,{value:i,original:c,valid:!0})},[i,c,n]),(0,p.useEffect)(()=>()=>{n.remove(`heartbeat.md`)},[n]);let g=(0,p.useCallback)(async()=>{d(!0),h(null);try{await t.put(`/api/heartbeat-md`,{content:i}),l(i),n.remove(`heartbeat.md`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{d(!1)}},[t,n,i]);if(r.kind===`loading`)return(0,m.jsx)(`p`,{className:`settings-section-hint`,children:`Loading template…`});if(r.kind===`offline`)return(0,m.jsx)(o,{port:e});if(r.kind===`error`)return(0,m.jsx)(s,{message:r.message});let _=n.pending.has(`heartbeat.md`);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`label`,{className:`settings-field settings-field-textarea`,htmlFor:`hb-md`,children:[(0,m.jsx)(`span`,{className:`settings-field-label`,children:`Template`}),(0,m.jsx)(`textarea`,{id:`hb-md`,rows:10,spellCheck:!1,value:i,onChange:e=>a(e.target.value),style:{fontFamily:`ui-monospace, monospace`}})]}),(0,m.jsx)(`div`,{className:`settings-heartbeat-md-footer`,children:(0,m.jsx)(`button`,{type:`button`,className:`settings-action settings-action-save`,onClick:()=>void g(),disabled:u||!_,children:u?`Saving…`:`Save template`})}),f?(0,m.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:f}):null]})}function M({port:e,client:t,dirty:n,registerSave:h}){let g=r(t,`/api/settings`),_=r(t,`/api/heartbeat`),v=r(t,`/api/heartbeat-md`),[x,w]=(0,p.useState)(!1),[E,D]=(0,p.useState)(`30m`),[O,k]=(0,p.useState)(`08:00`),[M,N]=(0,p.useState)(`22:00`),[P,F]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{if(g.state.kind!==`ready`)return;let e=g.state.data.heartbeat||{};w(!!e.enabled),D(typeof e.every==`string`?e.every:`30m`),k(e.activeHours?.start??`08:00`),N(e.activeHours?.end??`22:00`),F(typeof e.target==`string`?e.target:`all`)},[g.state]),(0,p.useEffect)(()=>()=>{for(let e of b)n.remove(e)},[n]);let I=(0,p.useMemo)(()=>g.state.kind===`ready`&&g.state.data.heartbeat||{},[g.state]),L=(0,p.useCallback)((e,t)=>n.set(e,t),[n]),R=(0,p.useRef)(0),z=(0,p.useCallback)(async()=>{let e=n.saveBundle(),r={};for(let[t,n]of Object.entries(e))T(t)&&(r[t]=n);if(Object.keys(r).length===0)return;let i=++R.current,a=f(r),o=await t.put(`/api/settings`,a);if(i!==R.current)return;let s=o&&typeof o==`object`&&`data`in o?o.data:o;for(let e of b)n.remove(e);g.setData(s);let c=s.heartbeat||{};w(!!c.enabled),D(typeof c.every==`string`?c.every:`30m`),k(c.activeHours?.start??`08:00`),N(c.activeHours?.end??`22:00`),F(typeof c.target==`string`?c.target:`all`),await g.refresh()},[t,n,g]);if((0,p.useEffect)(()=>{if(h)return h(z),()=>h(null)},[h,z]),g.state.kind===`loading`)return(0,m.jsx)(a,{});if(g.state.kind===`offline`)return(0,m.jsx)(o,{port:e});if(g.state.kind===`error`)return(0,m.jsx)(s,{message:g.state.message});let B=S(E)?null:"Use the form `<n>s|m|h`, e.g. `30m`",V=C(O)?null:`Use HH:MM (24h)`,H=C(M)?null:`Use HH:MM (24h)`,U=g.state.data.perCli||{},W=Object.keys(U),G=[{value:`all`,label:`all (broadcast)`},...(W.length>0?W:[...y]).map(e=>({value:e,label:d(e).label||e}))];return G.some(e=>e.value===P)||G.push({value:P,label:`${d(P).label||P} (legacy)`}),(0,m.jsxs)(`form`,{className:`settings-page-form`,onSubmit:e=>{e.preventDefault(),z()},children:[(0,m.jsxs)(i,{title:`Heartbeat`,hint:`Background prompts the agent runs on a schedule.`,children:[(0,m.jsx)(c,{id:`hb-enabled`,label:`Heartbeat enabled`,value:x,onChange:e=>{w(e),L(`heartbeat.enabled`,{value:e,original:!!I.enabled,valid:!0})}}),(0,m.jsx)(u,{id:`hb-every`,label:`Default interval`,value:E,placeholder:`30m`,error:B,onChange:e=>{D(e),L(`heartbeat.every`,{value:e,original:I.every??`30m`,valid:S(e)})}}),(0,m.jsx)(u,{id:`hb-start`,label:`Active hours start`,value:O,placeholder:`08:00`,error:V,onChange:e=>{k(e),L(`heartbeat.activeHours.start`,{value:e,original:I.activeHours?.start??`08:00`,valid:C(e)})}}),(0,m.jsx)(u,{id:`hb-end`,label:`Active hours end`,value:M,placeholder:`22:00`,error:H,onChange:e=>{N(e),L(`heartbeat.activeHours.end`,{value:e,original:I.activeHours?.end??`22:00`,valid:C(e)})}}),(0,m.jsx)(l,{id:`hb-target`,label:`Target`,value:P,options:G,onChange:e=>{F(e),L(`heartbeat.target`,{value:e,original:I.target??`all`,valid:!0})}})]}),(0,m.jsx)(i,{title:`Jobs`,hint:`Each job replaces the entire heartbeat.json on save. Concurrent edits from multiple browsers will overwrite — last write wins.`,children:(0,m.jsx)(A,{port:e,client:t,dirty:n,snapshot:_.state})}),(0,m.jsx)(i,{title:`Default heartbeat prompt template`,hint:`Markdown shown to the agent when a heartbeat fires without a job-specific prompt.`,children:(0,m.jsx)(j,{port:e,client:t,dirty:n,snapshot:v.state})})]})}export{x as PAGE_LOCAL_KEYS,b as SECTION_A_KEYS,y as TARGET_FALLBACK,M as default,T as isHeartbeatSettingsKey,O as jobScheduleBodyError,k as jobsHaveErrors,w as makeDefaultJob,D as normalizeJobsResponse,C as validateHHMM,S as validateInterval};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./MarkdownRenderer-Cl0oEICj.js";export{e as MarkdownRenderer};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-render-Bjnw0wQ6.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-XQCOJYun.js";import{A as r}from"./vendor-render-DCb9B75Q.js";import{t as i}from"./preload-helper-DFYRRz9w.js";import{i as a,n as o,o as s,r as c,t as l}from"./mermaid-preprocess-CqOBWYEb.js";import{n as u,t as d}from"./jsx-runtime-B3ZGMGGg.js";import{t as f}from"./copy-text-BKruhU_y.js";import{A as p,C as m,D as ee,E as h,S as te,T as ne,a as g,b as _,c as v,d as y,f as re,i as ie,k as b,l as ae,n as oe,o as se,p as ce,r as le,s as ue,t as de,u as fe,w as pe,x as me,y as he}from"./wiki-link-resolver-C197VhRP.js";function ge(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function _e(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var ve=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ye=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,be={};function xe(e,t){return((t||be).jsx?ye:ve).test(e)}var Se=/[ \t\n\f\r]/g;function Ce(e){return typeof e==`object`?e.type===`text`?we(e.value):!1:we(e)}function we(e){return e.replace(Se,``)===``}var x=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};x.prototype.normal={},x.prototype.property={},x.prototype.space=void 0;function Te(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new x(n,r,t)}function S(e){return e.toLowerCase()}var C=class{constructor(e,t){this.attribute=t,this.property=e}};C.prototype.attribute=``,C.prototype.booleanish=!1,C.prototype.boolean=!1,C.prototype.commaOrSpaceSeparated=!1,C.prototype.commaSeparated=!1,C.prototype.defined=!1,C.prototype.mustUseProperty=!1,C.prototype.number=!1,C.prototype.overloadedBoolean=!1,C.prototype.property=``,C.prototype.spaceSeparated=!1,C.prototype.space=void 0;var w=e({boolean:()=>T,booleanish:()=>E,commaOrSpaceSeparated:()=>A,commaSeparated:()=>k,number:()=>D,overloadedBoolean:()=>De,spaceSeparated:()=>O}),Ee=0,T=j(),E=j(),De=j(),D=j(),O=j(),k=j(),A=j();function j(){return 2**++Ee}var Oe=Object.keys(w),M=class extends C{constructor(e,t,n,r){let i=-1;if(super(e,t),ke(this,`space`,r),typeof n==`number`)for(;++i<Oe.length;){let e=Oe[i];ke(this,Oe[i],(n&w[e])===w[e])}}};M.prototype.defined=!0;function ke(e,t,n){n&&(e[t]=n)}function N(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new M(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[S(r)]=r,n[S(a.attribute)]=r}return new x(t,n,e.space)}var Ae=N({properties:{ariaActiveDescendant:null,ariaAtomic:E,ariaAutoComplete:null,ariaBusy:E,ariaChecked:E,ariaColCount:D,ariaColIndex:D,ariaColSpan:D,ariaControls:O,ariaCurrent:null,ariaDescribedBy:O,ariaDetails:null,ariaDisabled:E,ariaDropEffect:O,ariaErrorMessage:null,ariaExpanded:E,ariaFlowTo:O,ariaGrabbed:E,ariaHasPopup:null,ariaHidden:E,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:O,ariaLevel:D,ariaLive:null,ariaModal:E,ariaMultiLine:E,ariaMultiSelectable:E,ariaOrientation:null,ariaOwns:O,ariaPlaceholder:null,ariaPosInSet:D,ariaPressed:E,ariaReadOnly:E,ariaRelevant:null,ariaRequired:E,ariaRoleDescription:O,ariaRowCount:D,ariaRowIndex:D,ariaRowSpan:D,ariaSelected:E,ariaSetSize:D,ariaSort:null,ariaValueMax:D,ariaValueMin:D,ariaValueNow:D,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function je(e,t){return t in e?e[t]:t}function Me(e,t){return je(e,t.toLowerCase())}var Ne=N({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:k,acceptCharset:O,accessKey:O,action:null,allow:null,allowFullScreen:T,allowPaymentRequest:T,allowUserMedia:T,alt:null,as:null,async:T,autoCapitalize:null,autoComplete:O,autoFocus:T,autoPlay:T,blocking:O,capture:null,charSet:null,checked:T,cite:null,className:O,cols:D,colSpan:null,content:null,contentEditable:E,controls:T,controlsList:O,coords:D|k,crossOrigin:null,data:null,dateTime:null,decoding:null,default:T,defer:T,dir:null,dirName:null,disabled:T,download:De,draggable:E,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:T,formTarget:null,headers:O,height:D,hidden:De,high:D,href:null,hrefLang:null,htmlFor:O,httpEquiv:O,id:null,imageSizes:null,imageSrcSet:null,inert:T,inputMode:null,integrity:null,is:null,isMap:T,itemId:null,itemProp:O,itemRef:O,itemScope:T,itemType:O,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:T,low:D,manifest:null,max:null,maxLength:D,media:null,method:null,min:null,minLength:D,multiple:T,muted:T,name:null,nonce:null,noModule:T,noValidate:T,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:T,optimum:D,pattern:null,ping:O,placeholder:null,playsInline:T,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:T,referrerPolicy:null,rel:O,required:T,reversed:T,rows:D,rowSpan:D,sandbox:O,scope:null,scoped:T,seamless:T,selected:T,shadowRootClonable:T,shadowRootDelegatesFocus:T,shadowRootMode:null,shape:null,size:D,sizes:null,slot:null,span:D,spellCheck:E,src:null,srcDoc:null,srcLang:null,srcSet:null,start:D,step:null,style:null,tabIndex:D,target:null,title:null,translate:null,type:null,typeMustMatch:T,useMap:null,value:E,width:D,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:O,axis:null,background:null,bgColor:null,border:D,borderColor:null,bottomMargin:D,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:T,declare:T,event:null,face:null,frame:null,frameBorder:null,hSpace:D,leftMargin:D,link:null,longDesc:null,lowSrc:null,marginHeight:D,marginWidth:D,noResize:T,noHref:T,noShade:T,noWrap:T,object:null,profile:null,prompt:null,rev:null,rightMargin:D,rules:null,scheme:null,scrolling:E,standby:null,summary:null,text:null,topMargin:D,valueType:null,version:null,vAlign:null,vLink:null,vSpace:D,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:T,disableRemotePlayback:T,prefix:null,property:null,results:D,security:null,unselectable:null},space:`html`,transform:Me}),Pe=N({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:A,accentHeight:D,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:D,amplitude:D,arabicForm:null,ascent:D,attributeName:null,attributeType:null,azimuth:D,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:D,by:null,calcMode:null,capHeight:D,className:O,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:D,diffuseConstant:D,direction:null,display:null,dur:null,divisor:D,dominantBaseline:null,download:T,dx:null,dy:null,edgeMode:null,editable:null,elevation:D,enableBackground:null,end:null,event:null,exponent:D,externalResourcesRequired:null,fill:null,fillOpacity:D,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:k,g2:k,glyphName:k,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:D,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:D,horizOriginX:D,horizOriginY:D,id:null,ideographic:D,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:D,k:D,k1:D,k2:D,k3:D,k4:D,kernelMatrix:A,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:D,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:D,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:D,overlineThickness:D,paintOrder:null,panose1:null,path:null,pathLength:D,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:O,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:D,pointsAtY:D,pointsAtZ:D,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:A,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:A,rev:A,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:A,requiredFeatures:A,requiredFonts:A,requiredFormats:A,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:D,specularExponent:D,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:D,strikethroughThickness:D,string:null,stroke:null,strokeDashArray:A,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:D,strokeOpacity:D,strokeWidth:null,style:null,surfaceScale:D,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:A,tabIndex:D,tableValues:null,target:null,targetX:D,targetY:D,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:A,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:D,underlineThickness:D,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:D,values:null,vAlphabetic:D,vMathematical:D,vectorEffect:null,vHanging:D,vIdeographic:D,version:null,vertAdvY:D,vertOriginX:D,vertOriginY:D,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:D,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:je}),Fe=N({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Ie=N({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Me}),Le=N({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Re={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},ze=/[A-Z]/g,Be=/-[a-z]/g,Ve=/^data[-\w.:]+$/i;function He(e,t){let n=S(t),r=t,i=C;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Ve.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Be,We);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Be.test(e)){let n=e.replace(ze,Ue);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=M}return new i(r,t)}function Ue(e){return`-`+e.toLowerCase()}function We(e){return e.charAt(1).toUpperCase()}var Ge=Te([Ae,Ne,Fe,Ie,Le],`html`),P=Te([Ae,Pe,Fe,Ie,Le],`svg`);function Ke(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function qe(e){return e.join(` `).trim()}var Je=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
3
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,ee=`declaration`;function h(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,h=1;function ne(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);h=~n?e.length-n:h+e.length}function g(){var e={line:l,column:h};return function(t){return t.position=new _(e),re(),t}}function _(e){this.start=e,this.end={line:l,column:h},this.source=t.source}_.prototype.content=e;function v(n){var r=Error(t.source+`:`+l+`:`+h+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=h,r.source=e,!t.silent)throw r}function y(t){var n=t.exec(e);if(n){var r=n[0];return ne(r),e=e.slice(r.length),n}}function re(){y(i)}function ie(e){var t;for(e||=[];t=b();)t!==!1&&e.push(t);return e}function b(){var t=g();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return v(`End of comment missing`);var r=e.slice(2,n-2);return h+=2,ne(r),e=e.slice(n),h+=2,t({type:m,comment:r})}}function ae(){var e=g(),t=y(a);if(t){if(b(),!y(o))return v(`property missing ':'`);var r=y(s),i=e({type:ee,property:te(t[0].replace(n,p)),value:r?te(r[0].replace(n,p)):p});return y(c),i}}function oe(){var e=[];ie(e);for(var t;t=ae();)t!==!1&&(e.push(t),ie(e));return e}return re(),oe()}function te(e){return e?e.replace(l,p):p}t.exports=h})),Ye=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(Je());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Xe=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Ze=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ye()),r=Xe();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Qe=$e(`end`),F=$e(`start`);function $e(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function et(e){let t=F(e),n=Qe(e);if(t&&n)return{start:t,end:n}}var tt=t(Ze(),1),I={}.hasOwnProperty,nt=new Map,rt=/[A-Z]/g,it=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),at=new Set([`td`,`th`]),ot=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function st(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=_t(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=gt(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?P:Ge,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=ct(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function ct(e,t,n){if(t.type===`element`)return lt(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return ut(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return ft(e,t,n);if(t.type===`mdxjsEsm`)return dt(e,t);if(t.type===`root`)return pt(e,t,n);if(t.type===`text`)return mt(e,t)}function lt(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=P,e.schema=i),e.ancestors.push(t);let a=St(e,t.tagName,!1),o=vt(e,t),s=R(e,t);return it.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Ce(e):!0})),ht(e,o,a,t),L(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function ut(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}z(e,t.position)}function dt(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);z(e,t.position)}function ft(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=P,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:St(e,t.name,!0),o=yt(e,t),s=R(e,t);return ht(e,o,a,t),L(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function pt(e,t,n){let r={};return L(r,R(e,t)),e.create(t,e.Fragment,r,n)}function mt(e,t){return t.value}function ht(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function L(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function gt(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function _t(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=F(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function vt(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&I.call(t.properties,i)){let a=bt(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&at.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function yt(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else z(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else z(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function R(e,t){let n=[],r=-1,i=e.passKeys?new Map:nt;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=ct(e,a,o);s!==void 0&&n.push(s)}return n}function bt(e,t,n){let r=He(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?_e(n):qe(n)),r.property===`style`){let t=typeof n==`object`?n:xt(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Ct(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Re[r.property]||r.property:r.attribute,n]}}function xt(e,t){try{return(0,tt.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new p("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=ot+`#cannot-parse-style-attribute`,r}}function St(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=xe(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=xe(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return I.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);z(e)}function z(e,t){let n=new p("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=ot+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Ct(e){let t={},n;for(n in e)I.call(e,n)&&(t[wt(n)]=e[n]);return t}function wt(e){let t=e.replace(rt,Tt);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Tt(e){return`-`+e.toLowerCase()}var B={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]};function V(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&b(e.charCodeAt(n+1))&&b(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Et(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Dt(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
4
|
+
`}]}function Ot(e,t){let n=t.value?t.value+`
|
|
5
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function kt(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function At(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jt(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=V(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function Mt(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nt(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Pt(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function Ft(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pt(e,t);let i={src:V(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function It(e,t){let n={src:V(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Lt(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Rt(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pt(e,t);let i={href:V(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function zt(e,t){let n={href:V(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Bt(e,t,n){let r=e.all(t),i=n?Vt(n):Ht(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
6
|
+
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
7
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Vt(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Ht(n[r])}return t}function Ht(e){return e.spread??e.children.length>1}function Ut(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function Wt(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Gt(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Kt(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qt(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=F(t.children[1]),o=Qe(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Jt(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Yt(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var Xt=9,Zt=32;function Qt(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push($t(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push($t(t.slice(i),i>0,!1)),a.join(``)}function $t(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===Xt||t===Zt;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===Xt||t===Zt;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function en(e,t){let n={type:`text`,value:Qt(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function tn(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var nn={blockquote:Et,break:Dt,code:Ot,delete:kt,emphasis:At,footnoteReference:jt,heading:Mt,html:Nt,imageReference:Ft,image:It,inlineCode:Lt,linkReference:Rt,link:zt,listItem:Bt,list:Ut,paragraph:Wt,root:Gt,strong:Kt,table:qt,tableCell:Yt,tableRow:Jt,text:en,thematicBreak:tn,toml:H,yaml:H,definition:H,footnoteDefinition:H};function H(){}var rn=typeof self==`object`?self:globalThis,an=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new rn[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new rn[a](o),i)};return r},on=e=>an(new Map,e)(0),U=``,{toString:sn}={},{keys:cn}=Object,W=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=sn.call(e).slice(8,-1);switch(n){case`Array`:return[1,U];case`Object`:return[2,U];case`Date`:return[3,U];case`RegExp`:return[4,U];case`Map`:return[5,U];case`Set`:return[6,U];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},G=([e,t])=>e===0&&(t===`function`||t===`symbol`),ln=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=W(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of cn(r))(e||!G(W(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(G(W(n))||G(W(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!G(W(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},un=(e,{json:t,lossy:n}={})=>{let r=[];return ln(!(t||n),!!t,new Map,r)(e),r},K=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?on(un(e,t)):structuredClone(e):(e,t)=>on(un(e,t));function dn(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function fn(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function pn(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||dn,r=e.options.footnoteBackLabel||fn,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=V(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...K(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
8
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
9
|
+
`}]}}var mn={}.hasOwnProperty,hn={};function gn(e,t){let n=t||hn,r=new Map,i=new Map,a={all:s,applyData:vn,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...nn,...n.handlers},one:o,options:n,patch:_n,wrap:bn};return m(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(mn.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=K(n);return r.children=a.all(e),r}return K(e)}return(a.options.unknownHandler||yn)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=xn(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=xn(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function _n(e,t){e.position&&(t.position=et(e))}function vn(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,K(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function yn(e,t){let n=t.data||{},r=`value`in t&&!(mn.call(n,`hProperties`)||mn.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function bn(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
10
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
11
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
12
|
+
`}),n}function xn(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Sn(e,t){let n=gn(e,t),r=n.one(e,void 0),i=pn(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
13
|
+
`},i)),a}function Cn(e,t){return e&&`run`in e?async function(n,r){let i=Sn(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Sn(n,{file:r,...e||t})}}var q=d(),J=t(u(),1),wn=[],Tn={allowDangerousHtml:!0},En=/^(https?|ircs?|mailto|xmpp)$/i,Dn=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function On(e){let t=kn(e),n=An(e);return jn(t.runSync(t.parse(n),n),e)}function kn(e){let t=e.rehypePlugins||wn,n=e.remarkPlugins||wn,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Tn}:Tn;return me().use(ee).use(n).use(Cn,r).use(t)}function An(e){let t=e.children||``,n=new te;return typeof t==`string`?n.value=t:``+t,n}function jn(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Mn;for(let e of Dn)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return m(e,l),st(e,{Fragment:q.Fragment,components:i,ignoreInvalidStyle:!0,jsx:q.jsx,jsxs:q.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in B)if(Object.hasOwn(B,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=B[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Mn(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||En.test(e.slice(0,t))?e:``}var Nn=/[#.]/g;function Pn(e,t){let n=e||``,r={},i=0,a,o;for(;i<n.length;){Nn.lastIndex=i;let e=Nn.exec(n),t=n.slice(i,e?e.index:n.length);t&&(a?a===`#`?r.id=t:Array.isArray(r.className)?r.className.push(t):r.className=[t]:o=t,i+=t.length),e&&(a=e[0],i++)}return{type:`element`,tagName:o||t||`div`,properties:r,children:[]}}function Fn(e,t,n){let r=n?Vn(n):void 0;function i(n,i,...a){let o;if(n==null){o={type:`root`,children:[]};let e=i;a.unshift(e)}else{o=Pn(n,t);let s=o.tagName.toLowerCase(),c=r?r.get(s):void 0;if(o.tagName=c||s,In(i))a.unshift(i);else for(let[t,n]of Object.entries(i))Ln(e,o.properties,t,n)}for(let e of a)Rn(o.children,e);return o.type===`element`&&o.tagName===`template`&&(o.content={type:`root`,children:o.children},o.children=[]),o}return i}function In(e){if(typeof e!=`object`||!e||Array.isArray(e))return!0;if(typeof e.type!=`string`)return!1;let t=e,n=Object.keys(e);for(let e of n){let n=t[e];if(n&&typeof n==`object`){if(!Array.isArray(n))return!0;let e=n;for(let t of e)if(typeof t!=`number`&&typeof t!=`string`)return!0}}return!!(`children`in e&&Array.isArray(e.children))}function Ln(e,t,n,r){let i=He(e,n),a;if(r!=null){if(typeof r==`number`){if(Number.isNaN(r))return;a=r}else a=typeof r==`boolean`?r:typeof r==`string`?i.spaceSeparated?Ke(r):i.commaSeparated?ge(r):i.commaOrSpaceSeparated?Ke(ge(r).join(` `)):zn(i,i.property,r):Array.isArray(r)?[...r]:i.property===`style`?Bn(r):String(r);if(Array.isArray(a)){let e=[];for(let t of a)e.push(zn(i,i.property,t));a=e}i.property===`className`&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}function Rn(e,t){if(t!=null)if(typeof t==`number`||typeof t==`string`)e.push({type:`text`,value:String(t)});else if(Array.isArray(t))for(let n of t)Rn(e,n);else if(typeof t==`object`&&`type`in t)t.type===`root`?Rn(e,t.children):e.push(t);else throw Error("Expected node, nodes, or string, got `"+t+"`")}function zn(e,t,n){if(typeof n==`string`){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===``||S(n)===S(t)))return!0}return n}function Bn(e){let t=[];for(let[n,r]of Object.entries(e))t.push([n,r].join(`: `));return t.join(`; `)}function Vn(e){let t=new Map;for(let n of e)t.set(n.toLowerCase(),n);return t}var Hn=`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.solidColor.textArea.textPath`.split(`.`),Un=Fn(Ge,`div`),Wn=Fn(P,`g`,Hn),Gn={html:`http://www.w3.org/1999/xhtml`,mathml:`http://www.w3.org/1998/Math/MathML`,svg:`http://www.w3.org/2000/svg`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Kn(e,t){return qn(e,t||{})||{type:`root`,children:[]}}function qn(e,t){let n=Jn(e,t);return n&&t.afterTransform&&t.afterTransform(e,n),n}function Jn(e,t){switch(e.nodeType){case 1:return $n(e,t);case 3:return Zn(e);case 8:return Qn(e);case 9:return Yn(e,t);case 10:return Xn();case 11:return Yn(e,t);default:return}}function Yn(e,t){return{type:`root`,children:er(e,t)}}function Xn(){return{type:`doctype`}}function Zn(e){return{type:`text`,value:e.nodeValue||``}}function Qn(e){return{type:`comment`,value:e.nodeValue||``}}function $n(e,t){let n=e.namespaceURI,r=n===Gn.svg?Wn:Un,i=n===Gn.html?e.tagName.toLowerCase():e.tagName,a=n===Gn.html&&i===`template`?e.content:e,o=e.getAttributeNames(),s={},c=-1;for(;++c<o.length;)s[o[c]]=e.getAttribute(o[c])||``;return r(i,s,er(a,t))}function er(e,t){let n=e.childNodes,r=[],i=-1;for(;++i<n.length;){let e=qn(n[i],t);e!==void 0&&r.push(e)}return r}var tr=new DOMParser;function nr(e,t){return Kn(t?.fragment?rr(e):tr.parseFromString(e,`text/html`))}function rr(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}var ir=(function(e,t,n){let r=h(n);if(!e||!e.type||!e.children)throw Error(`Expected parent node`);if(typeof t==`number`){if(t<0||t===1/0)throw Error(`Expected positive finite number as index`)}else if(t=e.children.indexOf(t),t<0)throw Error(`Expected child node or index`);for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Y=(function(e){if(e==null)return cr;if(typeof e==`string`)return or(e);if(typeof e==`object`)return ar(e);if(typeof e==`function`)return sr(e);throw Error("Expected function, string, or array as `test`")});function ar(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Y(e[n]);return sr(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function or(e){return sr(t);function t(t){return t.tagName===e}}function sr(e){return t;function t(t,n,r){return!!(lr(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function cr(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`element`&&`tagName`in e&&typeof e.tagName==`string`)}function lr(e){return typeof e==`object`&&!!e&&`type`in e&&`tagName`in e}var ur=/\n/g,dr=/[\t ]+/g,fr=Y(`br`),pr=Y(Er),mr=Y(`p`),hr=Y(`tr`),gr=Y([`datalist`,`head`,`noembed`,`noframes`,`noscript`,`rp`,`script`,`style`,`template`,`title`,Tr,Dr]),_r=Y(`address.article.aside.blockquote.body.caption.center.dd.dialog.dir.dl.dt.div.figure.figcaption.footer.form,.h1.h2.h3.h4.h5.h6.header.hgroup.hr.html.legend.li.listing.main.menu.nav.ol.p.plaintext.pre.section.ul.xmp`.split(`.`));function vr(e,t){let n=t||{},r=`children`in e?e.children:[],i=_r(e),a=wr(e,{whitespace:n.whitespace||`normal`,breakBefore:!1,breakAfter:!1}),o=[];(e.type===`text`||e.type===`comment`)&&o.push(...xr(e,{whitespace:a,breakBefore:!0,breakAfter:!0}));let s=-1;for(;++s<r.length;)o.push(...yr(r[s],e,{whitespace:a,breakBefore:s?void 0:i,breakAfter:s<r.length-1?fr(r[s+1]):i}));let c=[],l;for(s=-1;++s<o.length;){let e=o[s];typeof e==`number`?l!==void 0&&e>l&&(l=e):e&&(l!==void 0&&l>-1&&c.push(`
|
|
14
|
+
`.repeat(l)||` `),l=-1,c.push(e))}return c.join(``)}function yr(e,t,n){return e.type===`element`?br(e,t,n):e.type===`text`?n.whitespace===`normal`?xr(e,n):Sr(e):[]}function br(e,t,n){let r=wr(e,n),i=e.children||[],a=-1,o=[];if(gr(e))return o;let s,c;for(fr(e)||hr(e)&&ir(t,e,hr)?c=`
|
|
15
|
+
`:mr(e)?(s=2,c=2):_r(e)&&(s=1,c=1);++a<i.length;)o=o.concat(yr(i[a],e,{whitespace:r,breakBefore:a?void 0:s,breakAfter:a<i.length-1?fr(i[a+1]):c}));return pr(e)&&ir(t,e,pr)&&o.push(` `),s&&o.unshift(s),c&&o.push(c),o}function xr(e,t){let n=String(e.value),r=[],i=[],a=0;for(;a<=n.length;){ur.lastIndex=a;let e=ur.exec(n),i=e&&`index`in e?e.index:n.length;r.push(Cr(n.slice(a,i).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,``),a===0?t.breakBefore:!0,i===n.length?t.breakAfter:!0)),a=i+1}let o=-1,s;for(;++o<r.length;)r[o].charCodeAt(r[o].length-1)===8203||o<r.length-1&&r[o+1].charCodeAt(0)===8203?(i.push(r[o]),s=void 0):r[o]?(typeof s==`number`&&i.push(s),i.push(r[o]),s=0):(o===0||o===r.length-1)&&i.push(0);return i}function Sr(e){return[String(e.value)]}function Cr(e,t,n){let r=[],i=0,a;for(;i<e.length;){dr.lastIndex=i;let n=dr.exec(e);a=n?n.index:e.length,!i&&!a&&n&&!t&&r.push(``),i!==a&&r.push(e.slice(i,a)),i=n?a+n[0].length:a}return i!==a&&!n&&r.push(``),r.join(` `)}function wr(e,t){if(e.type===`element`){let n=e.properties||{};switch(e.tagName){case`listing`:case`plaintext`:case`xmp`:return`pre`;case`nobr`:return`nowrap`;case`pre`:return n.wrap?`pre-wrap`:`pre`;case`td`:case`th`:return n.noWrap?`nowrap`:t.whitespace;case`textarea`:return`pre-wrap`;default:}}return t.whitespace}function Tr(e){return!!(e.properties||{}).hidden}function Er(e){return e.tagName===`td`||e.tagName===`th`}function Dr(e){return e.tagName===`dialog`&&!(e.properties||{}).open}var Or={},kr=[];function Ar(e){let t=e||Or;return function(e,n){ne(e,`element`,function(e,i){let a=Array.isArray(e.properties.className)?e.properties.className:kr,o=a.includes(`language-math`),s=a.includes(`math-display`),c=a.includes(`math-inline`),l=s;if(!o&&!s&&!c)return;let u=i[i.length-1],d=e;if(e.tagName===`code`&&o&&u&&u.type===`element`&&u.tagName===`pre`&&(d=u,u=i[i.length-2],l=!0),!u)return;let f=vr(d,{whitespace:`pre`}),p;try{p=r.renderToString(f,{...t,displayMode:l,throwOnError:!0})}catch(a){let o=a,s=o.name.toLowerCase();n.message(`Could not render math with KaTeX`,{ancestors:[...i,e],cause:o,place:e.position,ruleId:s,source:`rehype-katex`});try{p=r.renderToString(f,{...t,displayMode:l,strict:`ignore`,throwOnError:!1})}catch{p=[{type:`element`,tagName:`span`,properties:{className:[`katex-error`],style:`color:`+(t.errorColor||`#cc0000`),title:String(a)},children:[{type:`text`,value:f}]}]}}typeof p==`string`&&(p=nr(p,{fragment:!0}).children);let m=u.children.indexOf(d);return u.children.splice(m,1,...p),pe})}}var X={}.hasOwnProperty;function jr(e,t){let n={type:`root`,children:[]},r=Mr({schema:t?{..._,...t}:_,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function Mr(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return Nr(e,n);case`doctype`:return Pr(e,n);case`element`:return Fr(e,n);case`root`:return Ir(e,n);case`text`:return Lr(e,n);default:}}}function Nr(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return Z(r,t),r}}function Pr(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return Z(e,t),e}}function Fr(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=Rr(e,t.children),i=zr(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&X.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return Z(o,t),o}function Ir(e,t){let n={type:`root`,children:Rr(e,t.children)};return Z(n,t),n}function Lr(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return Z(n,t),n}function Rr(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=Mr(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function zr(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&X.call(r,n)?r[n]:void 0,o=r&&X.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(X.call(s,l)){let t=s[l],n=Br(e,Wr(a,l),l,t);n??=Br(e,Wr(o,l),l,t),n!=null&&(c[l]=n)}if(i&&X.call(i,n)){let e=i[n];for(l in e)X.call(e,l)&&!X.call(c,l)&&(c[l]=e[l])}return c}function Br(e,t,n,r){return t?Array.isArray(r)?Vr(e,t,n,r):Hr(e,t,n,r):void 0}function Vr(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=Hr(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function Hr(e,t,n,r){if(!(typeof r!=`boolean`&&typeof r!=`number`&&typeof r!=`string`)&&Ur(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function Ur(e,t,n){let r=e.schema.protocols&&X.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function Z(e,t){let n=et(t);t.data&&(e.data=K(t.data)),n&&(e.position=n)}function Wr(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function Gr(e){return function(t){return jr(t,e)}}function Kr(e){he(e,[/\r?\n|\r/g,qr])}function qr(){return{type:`break`}}function Jr(){return function(e){Kr(e)}}function Yr(e){let[t,n]=(0,J.useState)(!1),r=y(e.code,e.language),i=r.language||`text`;async function a(){let t=await f(e.code);if(t.ok){n(!0),window.setTimeout(()=>n(!1),1200);return}console.error(`[notes:code-copy]`,t.error)}return(0,q.jsxs)(`div`,{className:`notes-code-block`,children:[(0,q.jsx)(`div`,{className:`notes-code-header`,children:(0,q.jsx)(`button`,{type:`button`,onClick:()=>void a(),children:t?`Copied`:i})}),(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{className:`hljs language-${i}`,"data-highlighted":r.highlighted?`yes`:`no`,dangerouslySetInnerHTML:{__html:r.html}})})]})}var Xr=100,Zr=null,Q=new Map;async function Qr(){return Zr||=(await i(()=>import(`./mermaid.core-CE6des8A.js`),__vite__mapDeps([0]))).default,Zr.initialize(c()),Zr}function $r(){return document.documentElement.getAttribute(`data-theme`)??`default`}function ei(e,t){if(Q.set(e,t),Q.size<=Xr)return;let n=Q.keys().next().value;n&&Q.delete(n)}function ti(e){let t=(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``),n=(0,J.useMemo)(()=>l(e.code),[e.code]),r=$r(),i=(0,J.useMemo)(()=>`${r}\n${n}`,[n,r]),[c,u]=(0,J.useState)(()=>Q.get(i)??{status:`loading`,sourceKey:i});return(0,J.useEffect)(()=>{let e=!1,r=Q.get(i);if(r)return u(r),()=>{e=!0};async function c(){u(e=>e.status===`ready`&&e.sourceKey===i?e:{status:`loading`,sourceKey:i});try{let r=await Qr(),c=`notes-mermaid-${t}`,l;try{({svg:l}=await r.render(c,n))}catch(e){let t=o(n);if(!t)throw e;({svg:l}=await r.render(`${c}-retry`,t))}if(!e){let e={status:`ready`,sourceKey:i,svg:s(l),wide:a(n)};ei(i,e),u(e)}}catch(t){e||u({status:`error`,sourceKey:i,message:t instanceof Error?t.message:`Mermaid render failed`})}}return c(),()=>{e=!0}},[n,t,i]),c.status===`ready`?(0,q.jsx)(`div`,{className:`notes-mermaid-block is-ready${c.wide?` mermaid-type-wide`:``}`,dangerouslySetInnerHTML:{__html:c.svg}}):c.status===`error`?(0,q.jsxs)(`div`,{className:`notes-mermaid-block is-error`,children:[(0,q.jsx)(`strong`,{children:`Mermaid render failed`}),(0,q.jsx)(`span`,{children:c.message}),(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{children:e.code})})]}):(0,q.jsx)(`div`,{className:`notes-mermaid-block is-loading`,role:`status`,"aria-label":`Diagram loading`,children:`Rendering diagram...`})}function ni(e){return oe(e)}function ri(e,t,n){if(!e)return[e];let r=!!t.notes?.length;if(t.lookup.size===0&&!r)return[e];de.lastIndex=0;let i=[],a=0,o=0,s;for(;(s=de.exec(e))!==null;){let r=s.index,c=r+s[0].length;if(le(e,r))continue;let l=t.lookup.get(s[0])??ie(s[0],t.outgoing,t.notes,r);if(!l)continue;r>a&&i.push(e.slice(a,r));let u=g(l,s[0]),d=`${n}-wl-${o++}`;if(l.status===`resolved`&&l.resolvedPath){let e=l.resolvedPath;i.push((0,J.createElement)(`a`,{key:d,className:`notes-wikilink`,href:`#${encodeURIComponent(e)}`,title:e,"data-notes-wiki-status":l.status,onClick:n=>{n.preventDefault(),t.onNavigate(e)}},u))}else{let e=se(l);i.push((0,J.createElement)(`span`,{key:d,className:`notes-wikilink is-broken`,title:e,"data-notes-wiki-status":l.status,"aria-label":`Broken wikilink: ${s[1]}`},u))}a=c}return a===0?[e]:(a<e.length&&i.push(e.slice(a)),i)}function ii(e,t,n){if(t.lookup.size===0&&!t.notes?.length)return e;let r=[],i=0;return J.Children.forEach(e,(e,a)=>{if(typeof e==`string`){let o=ri(e,t,`${n}-${i++}-${a}`);for(let e of o)r.push(e);return}if(typeof e==`number`||typeof e==`boolean`||e==null){r.push(e);return}if((0,J.isValidElement)(e)){r.push(e);return}r.push(e)}),r}var ai=/^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;function oi(e){let t=ai.exec(e);if(!t)return{frontmatterRaw:null,body:e};let n=t[0];return{frontmatterRaw:n,body:e.slice(n.length)}}function $(e,t){return t?`${e} ${t}`:e}function si(e){let t=0,n=e=>{if(Array.isArray(e)){e.forEach(n);return}(0,J.isValidElement)(e)&&(e.props.node?.tagName===`tr`&&(t=Math.max(t,J.Children.count(e.props.children))),J.Children.forEach(e.props.children,n))};return J.Children.forEach(e,n),Math.max(1,t)}function ci(e){return e<=1?`minmax(0, 1fr)`:e===2?`max-content minmax(16rem, 1fr)`:e===3?`max-content minmax(12rem, .45fr) minmax(18rem, 1fr)`:`max-content repeat(${e-1}, minmax(12rem, 1fr))`}function li(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(li).join(``):(0,J.isValidElement)(e)?li(e.props.children):``}function ui(e){return(0,J.isValidElement)(e)?(e.props.className??``).match(/language-([^\s]+)/)?.[1]??`text`:`text`}var di=e=>{},fi=/(?:~\/[^\s)`\]"'<>]+|\/(?:Users|home|tmp|var|opt|private)\/[^\s)`\]"'<>]+)/g,pi=/[.,!?:;]+$/;function mi(e){return e.startsWith(`~/`)||/^\/(?:Users|home|tmp|var|opt|private)\//.test(e)}function hi(e){let t=e.split(`/`).pop()||e;return/\.\w{1,10}$/.test(t)?t:e}function gi(e,t,n){if(!e||!t)return[e];fi.lastIndex=0;let r=[],i=0,a=0,o;for(;(o=fi.exec(e))!==null;){let s=o[0],c=s.replace(pi,``);if(!mi(c))continue;o.index>i&&r.push(e.slice(i,o.index));let l=s.slice(c.length);r.push((0,J.createElement)(`button`,{key:`${n}-lf-${a++}`,type:`button`,className:`markdown-local-file-link`,title:c,onClick:e=>{e.preventDefault(),t(c)}},hi(c))),l&&r.push(l),i=o.index+s.length}return i===0?[e]:(i<e.length&&r.push(e.slice(i)),r)}function _i(e,t,n){if(!t)return e;let r=[],i=0;return J.Children.forEach(e,(e,a)=>{if(typeof e==`string`){let o=gi(e,t,`${n}-${i++}-${a}`);for(let e of o)r.push(e);return}r.push(e)}),r}function vi(e){let t=(0,J.useMemo)(()=>oi(e.markdown).body,[e.markdown]),n=(0,J.useMemo)(()=>({lookup:ni(e.outgoing),outgoing:e.outgoing,notes:e.notes,onNavigate:e.onWikiLinkNavigate??di}),[e.outgoing,e.notes,e.onWikiLinkNavigate]),r=(t,r)=>_i(ii(t,n,r),e.onLocalFileOpen,r),i=e=>t=>{let{children:n,node:i,className:a,id:o,style:s}=t,c=r(n,e);return(0,J.createElement)(e,{className:a,id:o,style:s},c)},a=e=>t=>{let{children:n,node:i,className:a,style:o,align:s}=t,c=r(n,e);return(0,q.jsx)(`span`,{className:$(`markdown-linear-table-cell markdown-linear-table-${e}`,a),style:o,"data-align":s||void 0,children:c})},o={a:({href:e,children:t,node:n,...r})=>{let i=typeof e==`string`&&ue(e)?e:void 0,a=!!(i&&/^https?:\/\//i.test(i));return(0,q.jsx)(`a`,{...r,href:i,target:a?`_blank`:void 0,rel:a?`noreferrer noopener`:void 0,children:t})},code:({className:e,children:t})=>(0,q.jsx)(`code`,{className:e,children:t}),pre:({children:e})=>{let t=ui(e),n=li(e).replace(/\n$/,``);return t===`mermaid`?(0,q.jsx)(ti,{code:n}):(0,q.jsx)(Yr,{code:n,language:t})},img:({src:e,alt:t,...n})=>{let r=typeof e==`string`?ae(e):``;return r?r.endsWith(`.pdf`)?(0,q.jsx)(`iframe`,{src:r,title:t??`PDF embed`,className:`notes-pdf-embed`}):(0,q.jsx)(`img`,{...n,src:r,alt:t??``,loading:`lazy`}):null},p:i(`p`),li:i(`li`),h1:i(`h1`),h2:i(`h2`),h3:i(`h3`),h4:i(`h4`),h5:i(`h5`),h6:i(`h6`),blockquote:i(`blockquote`),td:i(`td`),th:i(`th`),em:i(`em`),strong:i(`strong`),del:i(`del`)};return e.tableMode===`linear`&&(o.table=({children:e,node:t,className:n,style:r})=>{let i={...r,"--markdown-linear-table-grid":ci(si(e))};return(0,q.jsx)(`div`,{className:$(`markdown-linear-table`,n),style:i,role:`list`,children:e})},o.thead=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-head`,n),style:r,children:e}),o.tbody=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-body`,n),style:r,children:e}),o.tr=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-row`,n),style:r,role:`listitem`,children:e}),o.th=a(`th`),o.td=a(`td`)),(0,q.jsx)(On,{skipHtml:!0,urlTransform:fe,remarkPlugins:[ce,Jr,re],rehypePlugins:[[Gr,v],Ar],components:o,children:t})}export{Yr as n,vi as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{n as t,t as n}from"./jsx-runtime-B3ZGMGGg.js";import{a as r,i,n as a,r as o,t as s}from"./page-shell-BeAyKBJW.js";import{a as c,i as l,r as u}from"./fields-MeoSVgIK.js";import{n as d}from"./agent-meta-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{n as t,t as n}from"./jsx-runtime-B3ZGMGGg.js";import{a as r,i,n as a,r as o,t as s}from"./page-shell-BeAyKBJW.js";import{a as c,i as l,r as u}from"./fields-MeoSVgIK.js";import{n as d}from"./agent-meta-FyI15KAa.js";import{t as f}from"./path-utils-DX1HplvB.js";var p=e(t(),1),m=[`memory.enabled`,`memory.flushEvery`,`memory.cli`,`memory.retentionDays`,`memory.autoReflectAfterFlush`,`memory.flushLanguage`],h=[{value:`en`,label:`English (en)`},{value:`ko`,label:`한국어 (ko)`},{value:`ja`,label:`日本語 (ja)`},{value:`zh`,label:`中文 (zh)`}],g=50;function _(e){return m.includes(e)}function v(e){let t=y(e);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=b(e);t&&n.push(t)}return n}function y(e){if(!e||typeof e!=`object`)return e;let t=e;return Array.isArray(t)?t:`data`in t?t.data:e}function b(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.key==`string`?t.key:null;return n?{key:n,value:typeof t.value==`string`?t.value:``,source:typeof t.source==`string`?t.source:`manual`}:null}function x(e,t){return!Number.isFinite(e)||!Number.isInteger(e)||e<=0?`${t} must be a positive integer`:null}function S(e,t,n=50){let r=Math.max(0,Math.floor(t))*n,i=e.slice(r,r+n),a=Math.max(1,Math.ceil(e.length/n));return{slice:i,hasMore:r+n<e.length,pageCount:a}}function C(e,t=80){return e.length<=t?e:`${e.slice(0,t)}…`}var w=n();function T({row:e,onOpen:t}){return(0,w.jsxs)(`tr`,{className:`settings-memory-row`,children:[(0,w.jsx)(`td`,{className:`settings-memory-key`,children:(0,w.jsx)(`button`,{type:`button`,className:`settings-memory-link`,onClick:()=>t(e),"aria-label":`Open memory entry ${e.key}`,children:e.key})}),(0,w.jsx)(`td`,{className:`settings-memory-source`,children:e.source}),(0,w.jsx)(`td`,{className:`settings-memory-length`,children:e.value.length}),(0,w.jsx)(`td`,{className:`settings-memory-preview`,title:e.value,children:C(e.value)})]})}var E={busy:null,notice:null,error:null};function D({port:e,client:t,dirty:n,registerSave:g}){let y=r(t,`/api/settings`),b=r(t,`/api/memory`),[C,D]=(0,p.useState)(!0),[O,k]=(0,p.useState)(10),[A,j]=(0,p.useState)(``),[M,N]=(0,p.useState)(30),[ee,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(`en`),[L,R]=(0,p.useState)(0),[z,B]=(0,p.useState)(null),[V,H]=(0,p.useState)(E);(0,p.useEffect)(()=>{if(y.state.kind!==`ready`)return;let e=y.state.data.memory||{};D(e.enabled!==!1),k(typeof e.flushEvery==`number`?e.flushEvery:10),j(typeof e.cli==`string`?e.cli:``),N(typeof e.retentionDays==`number`?e.retentionDays:30),P(!!e.autoReflectAfterFlush),I(typeof e.flushLanguage==`string`&&e.flushLanguage?e.flushLanguage:`en`)},[y.state]),(0,p.useEffect)(()=>()=>{for(let e of m)n.remove(e)},[n]),(0,p.useEffect)(()=>{if(!z)return;let e=e=>{e.key===`Escape`&&B(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]);let U=(0,p.useCallback)((e,t)=>n.set(e,t),[n]),W=(0,p.useMemo)(()=>y.state.kind===`ready`&&y.state.data.memory||{},[y.state]),G=(0,p.useCallback)(async()=>{let e=n.saveBundle(),r={};for(let[t,n]of Object.entries(e))_(t)&&(r[t]=n);if(Object.keys(r).length===0)return;let i=f(r),a=await t.put(`/api/settings`,i),o=a&&typeof a==`object`&&`data`in a?a.data:a;for(let e of m)n.remove(e);y.setData(o);let s=o.memory||{};D(s.enabled!==!1),k(typeof s.flushEvery==`number`?s.flushEvery:10),j(typeof s.cli==`string`?s.cli:``),N(typeof s.retentionDays==`number`?s.retentionDays:30),P(!!s.autoReflectAfterFlush),I(typeof s.flushLanguage==`string`&&s.flushLanguage?s.flushLanguage:`en`),await y.refresh()},[t,n,y]);(0,p.useEffect)(()=>{if(g)return g(G),()=>g(null)},[g,G]);let K=(0,p.useCallback)(async()=>{H({busy:`flush`,notice:null,error:null});try{await t.post(`/api/jaw-memory/flush`,{}),H({busy:null,notice:`Memory flush queued. Browse refreshes when it completes.`,error:null}),await b.refresh()}catch(e){H({busy:null,notice:null,error:e instanceof Error?e.message:String(e)})}},[t,b]),q=(0,p.useCallback)(async()=>{H({busy:`reflect`,notice:null,error:null});try{await t.post(`/api/jaw-memory/reflect`,{}),H({busy:null,notice:`Reflect complete.`,error:null}),await b.refresh()}catch(e){H({busy:null,notice:null,error:e instanceof Error?e.message:String(e)})}},[t,b]),J=(0,p.useCallback)(()=>{if(b.state.kind!==`ready`)return;let t=v(b.state.data),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`jaw-memory-${e}-${Date.now()}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},[b.state,e]);if(y.state.kind===`loading`)return(0,w.jsx)(a,{});if(y.state.kind===`offline`)return(0,w.jsx)(o,{port:e});if(y.state.kind===`error`)return(0,w.jsx)(s,{message:y.state.message});let Y=x(O,`Flush every`),X=x(M,`Retention days`),Z=y.state.data.perCli||{},Q=[{value:``,label:`(profile default)`},...Object.keys(Z).map(e=>({value:e,label:d(e).label||e}))];A&&!Q.some(e=>e.value===A)&&Q.push({value:A,label:`${d(A).label||A} (legacy)`});let $=b.state.kind===`ready`?v(b.state.data):[],{slice:te,hasMore:ne,pageCount:re}=S($,Math.min(L,Math.max(0,Math.ceil($.length/50)-1)));return(0,w.jsxs)(`form`,{className:`settings-page-form`,onSubmit:e=>{e.preventDefault(),G()},children:[(0,w.jsxs)(i,{title:`Memory engine`,hint:`Background memory flush and reflection cadence.`,children:[(0,w.jsx)(c,{id:`memory-enabled`,label:`Memory enabled`,value:C,onChange:e=>{D(e),U(`memory.enabled`,{value:e,original:W.enabled!==!1,valid:!0})}}),(0,w.jsx)(u,{id:`memory-flush-every`,label:`Flush every (sessions)`,value:O,min:1,error:Y,onChange:e=>{k(e),U(`memory.flushEvery`,{value:e,original:typeof W.flushEvery==`number`?W.flushEvery:10,valid:x(e,`Flush every`)===null})}}),(0,w.jsx)(l,{id:`memory-cli`,label:`Flush CLI`,value:A,options:Q,onChange:e=>{j(e),U(`memory.cli`,{value:e,original:W.cli??``,valid:!0})}}),(0,w.jsx)(u,{id:`memory-retention`,label:`Retention days`,value:M,min:1,error:X,onChange:e=>{N(e),U(`memory.retentionDays`,{value:e,original:typeof W.retentionDays==`number`?W.retentionDays:30,valid:x(e,`Retention days`)===null})}}),(0,w.jsx)(c,{id:`memory-auto-reflect`,label:`Auto-reflect after flush`,value:ee,onChange:e=>{P(e),U(`memory.autoReflectAfterFlush`,{value:e,original:!!W.autoReflectAfterFlush,valid:!0})}}),(0,w.jsx)(l,{id:`memory-flush-language`,label:`Flush language`,value:F,options:[...h],onChange:e=>{I(e),U(`memory.flushLanguage`,{value:e,original:W.flushLanguage??`en`,valid:!0})}})]}),(0,w.jsx)(i,{title:`Stored entries`,hint:`Read-only browse of the key/value memory table (50/page).`,children:b.state.kind===`loading`?(0,w.jsx)(`p`,{className:`settings-section-hint`,children:`Loading entries…`}):b.state.kind===`offline`?(0,w.jsx)(o,{port:e}):b.state.kind===`error`?(0,w.jsx)(s,{message:b.state.message}):$.length===0?(0,w.jsx)(`p`,{className:`settings-section-hint`,children:`No memory entries yet.`}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`table`,{className:`settings-memory-table`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{scope:`col`,children:`Key`}),(0,w.jsx)(`th`,{scope:`col`,children:`Source`}),(0,w.jsx)(`th`,{scope:`col`,children:`Length`}),(0,w.jsx)(`th`,{scope:`col`,children:`Preview`})]})}),(0,w.jsx)(`tbody`,{children:te.map(e=>(0,w.jsx)(T,{row:e,onOpen:B},e.key))})]}),(0,w.jsxs)(`div`,{className:`settings-memory-pagination`,children:[(0,w.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,disabled:L===0,onClick:()=>R(e=>Math.max(0,e-1)),children:`Prev`}),(0,w.jsxs)(`span`,{className:`settings-memory-pageinfo`,children:[`Page `,L+1,` / `,re]}),(0,w.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,disabled:!ne,onClick:()=>R(e=>e+1),children:`Next`})]})]})}),(0,w.jsxs)(i,{title:`Actions`,hint:`Flush runs async — the browse list refreshes when it finishes.`,children:[(0,w.jsxs)(`div`,{className:`settings-memory-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`settings-action settings-action-save`,disabled:V.busy!==null,onClick:()=>void K(),children:V.busy===`flush`?`Queuing…`:`Flush now`}),(0,w.jsx)(`button`,{type:`button`,className:`settings-action settings-action-save`,disabled:V.busy!==null,onClick:()=>void q(),children:V.busy===`reflect`?`Reflecting…`:`Reflect soul`}),(0,w.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,disabled:b.state.kind!==`ready`,onClick:J,children:`Export memory`})]}),V.notice?(0,w.jsx)(`p`,{className:`settings-section-hint`,role:`status`,children:V.notice}):null,V.error?(0,w.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:V.error}):null]}),z?(0,w.jsx)(`div`,{className:`settings-memory-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Memory entry ${z.key}`,onClick:e=>{e.target===e.currentTarget&&B(null)},children:(0,w.jsxs)(`div`,{className:`settings-memory-modal-card`,children:[(0,w.jsxs)(`header`,{className:`settings-memory-modal-header`,children:[(0,w.jsx)(`h3`,{children:z.key}),(0,w.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,onClick:()=>B(null),"aria-label":`Close memory entry`,children:`Close`})]}),(0,w.jsx)(`pre`,{className:`settings-memory-modal-body`,children:z.value})]})}):null]})}export{h as FLUSH_LANGUAGE_OPTIONS,g as MEMORY_PAGE_SIZE,m as MEMORY_SECTION_A_KEYS,D as default,_ as isMemorySettingsKey,v as normalizeMemoryRows,S as paginate,C as previewValue,x as validatePositiveInt};
|