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
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// Gemini CLI event adapter
|
|
2
|
-
import { isCliEventRecord } from '../../types/cli-events.js';
|
|
3
|
-
import { syncLiveTools, emitAgentTool, pushTrace, buildPreview, appendAssistantTextSegment, } from './helpers.js';
|
|
4
|
-
function appendGeminiAssistantTextSegment(ctx, text, isDelta) {
|
|
5
|
-
const raw = String(text || '');
|
|
6
|
-
if (!raw)
|
|
7
|
-
return '';
|
|
8
|
-
if (isDelta && ctx.geminiDeltaActive) {
|
|
9
|
-
ctx.fullText += raw;
|
|
10
|
-
return raw;
|
|
11
|
-
}
|
|
12
|
-
const segment = appendAssistantTextSegment(ctx, raw);
|
|
13
|
-
ctx.geminiDeltaActive = isDelta;
|
|
14
|
-
return segment;
|
|
15
|
-
}
|
|
16
|
-
function emitGeminiThought(ctx, agentLabel, empTag, text) {
|
|
17
|
-
const detail = String(text || '').trim();
|
|
18
|
-
if (!detail)
|
|
19
|
-
return;
|
|
20
|
-
const tool = {
|
|
21
|
-
icon: '💭',
|
|
22
|
-
label: buildPreview(detail, 80) || 'thinking...',
|
|
23
|
-
toolType: 'thinking',
|
|
24
|
-
detail,
|
|
25
|
-
};
|
|
26
|
-
ctx.toolLog.push(tool);
|
|
27
|
-
syncLiveTools(ctx);
|
|
28
|
-
emitAgentTool(ctx, agentLabel, tool, empTag);
|
|
29
|
-
}
|
|
30
|
-
function extractGeminiThoughtText(content) {
|
|
31
|
-
if (typeof content === 'string')
|
|
32
|
-
return content;
|
|
33
|
-
if (Array.isArray(content)) {
|
|
34
|
-
return content
|
|
35
|
-
.filter(isCliEventRecord)
|
|
36
|
-
.filter((p) => p.type === 'thought' || p.type === 'thinking')
|
|
37
|
-
.map((p) => String(p.thought || p.text || p.content || ''))
|
|
38
|
-
.join('');
|
|
39
|
-
}
|
|
40
|
-
if (isCliEventRecord(content)) {
|
|
41
|
-
return String(content.thought || content.text || content.content || '');
|
|
42
|
-
}
|
|
43
|
-
return '';
|
|
44
|
-
}
|
|
45
|
-
export function handleGeminiEvent(evt, ctx, agentLabel, empTag) {
|
|
46
|
-
if (evt.type === 'init' && evt.model) {
|
|
47
|
-
ctx.model = evt.model;
|
|
48
|
-
}
|
|
49
|
-
if (evt.type === 'tool_use' || evt.type === 'tool_result') {
|
|
50
|
-
ctx.geminiDeltaActive = false;
|
|
51
|
-
}
|
|
52
|
-
if (evt.type === 'thought' || evt.thought === true) {
|
|
53
|
-
if (ctx.showReasoning) {
|
|
54
|
-
emitGeminiThought(ctx, agentLabel, empTag, evt.content || evt.thought || evt.text);
|
|
55
|
-
pushTrace(ctx, `[${agentLabel}] gemini thought (visible)`);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
pushTrace(ctx, `[${agentLabel}] gemini thought (hidden)`);
|
|
59
|
-
}
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (evt.type === 'message' && evt.role === 'assistant') {
|
|
63
|
-
if (Array.isArray(evt.content)) {
|
|
64
|
-
if (ctx.showReasoning) {
|
|
65
|
-
emitGeminiThought(ctx, agentLabel, empTag, extractGeminiThoughtText(evt.content));
|
|
66
|
-
}
|
|
67
|
-
const textOnly = evt.content
|
|
68
|
-
.filter(isCliEventRecord)
|
|
69
|
-
.filter((p) => p.type === 'text')
|
|
70
|
-
.map((p) => String(p.text || ''))
|
|
71
|
-
.join('');
|
|
72
|
-
if (textOnly) {
|
|
73
|
-
const segment = appendGeminiAssistantTextSegment(ctx, textOnly, !!evt.delta);
|
|
74
|
-
ctx.pendingOutputChunk = (ctx.pendingOutputChunk || '') + segment;
|
|
75
|
-
pushTrace(ctx, `[${agentLabel}] gemini text (filtered)`);
|
|
76
|
-
}
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (evt.delta) {
|
|
80
|
-
pushTrace(ctx, `[${agentLabel}] gemini delta text`);
|
|
81
|
-
}
|
|
82
|
-
const segment = appendGeminiAssistantTextSegment(ctx, evt.content || '', !!evt.delta);
|
|
83
|
-
ctx.pendingOutputChunk = (ctx.pendingOutputChunk || '') + segment;
|
|
84
|
-
}
|
|
85
|
-
else if (evt.type === 'result') {
|
|
86
|
-
ctx.geminiDeltaActive = false;
|
|
87
|
-
ctx.geminiResultSeen = true;
|
|
88
|
-
ctx.duration = evt.stats?.duration_ms ?? null;
|
|
89
|
-
ctx.turns = evt.stats?.tool_calls ?? null;
|
|
90
|
-
if (evt.stats) {
|
|
91
|
-
ctx.tokens = {
|
|
92
|
-
input_tokens: evt.stats.input_tokens ?? evt.stats.inputTokens ?? 0,
|
|
93
|
-
output_tokens: evt.stats.output_tokens ?? evt.stats.outputTokens ?? 0,
|
|
94
|
-
cached_tokens: evt.stats.cached ?? 0,
|
|
95
|
-
total_tokens: evt.stats.total_tokens ?? evt.stats.totalTokens ?? 0,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=gemini.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../../src/agent/events/gemini.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,EACH,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,0BAA0B,GAC7B,MAAM,cAAc,CAAC;AAEtB,SAAS,gCAAgC,CAAC,GAAiB,EAAE,IAAa,EAAE,OAAgB;IACxF,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC/B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,IAAI,OAAO,IAAI,GAAG,CAAC,iBAAiB,EAAE,CAAC;QACnC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC;QACpB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrD,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC;IAChC,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB,CACtB,GAAiB,EACjB,UAAkB,EAClB,MAA+B,EAC/B,IAAa;IAEb,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzC,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,IAAI,GAAG;QACT,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,aAAa;QAChD,QAAQ,EAAE,UAAmB;QAC7B,MAAM;KACT,CAAC;IACF,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,CAAC,GAAG,CAAC,CAAC;IACnB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAgB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO;aACT,MAAM,CAAC,gBAAgB,CAAC;aACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;aAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;aAC1D,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IACD,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC7B,GAAmB,EACnB,GAAiB,EACjB,UAAkB,EAClB,MAA+B;IAE/B,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACnC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAC1B,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QACxD,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC;IAClC,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACjD,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;YACpB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;YACnF,SAAS,CAAC,GAAG,EAAE,IAAI,UAAU,4BAA4B,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACJ,SAAS,CAAC,GAAG,EAAE,IAAI,UAAU,2BAA2B,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO;IACX,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;gBACpB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,wBAAwB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YACtF,CAAC;YACD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO;iBACvB,MAAM,CAAC,gBAAgB,CAAC;iBACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;iBAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;iBAChC,IAAI,CAAC,EAAE,CAAC,CAAC;YACd,IAAI,QAAQ,EAAE,CAAC;gBACX,MAAM,OAAO,GAAG,gCAAgC,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC7E,GAAG,CAAC,kBAAkB,GAAG,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;gBAClE,SAAS,CAAC,GAAG,EAAE,IAAI,UAAU,0BAA0B,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO;QACX,CAAC;QACD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,SAAS,CAAC,GAAG,EAAE,IAAI,UAAU,qBAAqB,CAAC,CAAC;QACxD,CAAC;QACD,MAAM,OAAO,GAAG,gCAAgC,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtF,GAAG,CAAC,kBAAkB,GAAG,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;IACtE,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/B,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC;QAC9B,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC5B,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,KAAK,EAAE,WAAW,IAAI,IAAI,CAAC;QAC9C,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,UAAU,IAAI,IAAI,CAAC;QAC1C,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,GAAG,CAAC,MAAM,GAAG;gBACT,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;gBAClE,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC;gBACrE,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC;gBACpC,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;aACrE,CAAC;QACN,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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{i as c,s as l}from"./fields-MeoSVgIK.js";import{a as u,n as d,o as f}from"./Permissions-Dc5xnPMu.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./agent-meta-DqBTGRRQ.js";import{t as y}from"./path-utils-DX1HplvB.js";var b=e(t(),1),x=n();function S({cli:e,cliOptions:t,provider:n=``,providerOptions:r=[],model:a,modelOptions:o,effort:s,effortOptions:u,workingDir:d,workingDirError:f,onCliChange:p,onProviderChange:g,onModelChange:_,onEffortChange:y,onWorkingDirChange:b}){let S=m(t),C=S.filter(e=>v.includes(e)).length;return(0,x.jsx)(i,{title:`Agent runtime`,hint:`Active CLI, model, effort, and workspace used by this instance.`,children:(0,x.jsxs)(`div`,{className:`settings-agent-runtime-grid`,children:[(0,x.jsx)(c,{id:`agent-cli`,label:`Active CLI`,value:e,options:S.map(e=>({value:e,label:h(e).label||e})),collapsedAfter:C,onChange:p}),r.length>0?(0,x.jsx)(c,{id:`agent-${e}-provider`,label:`Provider`,value:n,options:r.map(e=>({value:e,label:e})),onChange:e=>g?.(e)}):null,(0,x.jsx)(c,{id:`agent-model`,label:`Active model`,value:a,options:o.length>0?o:[{value:``,label:`(default)`}],onChange:_}),(0,x.jsx)(c,{id:`agent-effort`,label:`Effort`,value:s,options:[{value:``,label:`(default)`},...u.map(e=>({value:e,label:e}))],disabled:u.length===0,onChange:y}),(0,x.jsx)(l,{id:`agent-workingDir`,label:`Working directory`,value:d,error:f,placeholder:`/path/to/project`,onChange:b})]})})}var C=[{value:`auto`,label:`Auto`},{value:`custom`,label:`Custom allowlist`}];function ee({value:e,onChange:t}){let n=u(e),r=n.mode===`custom`?`custom`:`auto`,a=n.mode===`custom`?n.tokens:[],o=n.mode===`custom`?`${a.length} explicit token${a.length===1?``:`s`}`:`Runtime resolves allowed capabilities`;return(0,x.jsxs)(i,{title:`Permissions`,hint:`Quick runtime mode. Open Permissions for detailed allowlist editing.`,children:[(0,x.jsx)(c,{id:`agent-permissions-mode`,label:`Mode`,value:r,options:C,onChange:e=>{t(e===`auto`?`auto`:a.length>0&&d(a)?a:f(null))}}),(0,x.jsx)(`p`,{className:`settings-agent-note`,children:o})]})}function te({activeCli:e,flushCli:t,flushModel:n,cliOptions:r,modelOptions:a,loading:o,error:s,onFlushCliChange:l,onFlushModelChange:u}){let d=t||e,f=d?h(d).label||d:`active`;return(0,x.jsx)(i,{title:`Flush Agent`,hint:`Separate summary agent used for context flush and compact work.`,children:(0,x.jsxs)(`details`,{className:`settings-agent-flush`,children:[(0,x.jsxs)(`summary`,{children:[(0,x.jsx)(`span`,{children:`Flush runtime`}),(0,x.jsxs)(`code`,{children:[f,n&&n!==`default`?` / ${n}`:``]})]}),o?(0,x.jsx)(`p`,{className:`settings-agent-note`,children:`Loading flush settings...`}):null,s?(0,x.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:s}):null,(0,x.jsxs)(`div`,{className:`settings-agent-runtime-grid`,children:[(0,x.jsx)(c,{id:`agent-flush-cli`,label:`Flush CLI`,value:t,options:[{value:``,label:`(active CLI)`},...r.map(e=>({value:e,label:h(e).label||e}))],onChange:l}),(0,x.jsx)(c,{id:`agent-flush-model`,label:`Flush model`,value:n,options:[{value:``,label:`(default)`},...a],onChange:u})]})]})})}function w(e){return e.source===`static`||e.id.startsWith(`static:`)}function T(){return`new:${Date.now().toString(36)}:${Math.random().toString(36).slice(2,8)}`}function E(e){let t=e[0]||`claude`;return{id:T(),name:`New Agent`,cli:t,model:`default`,role:``,status:`idle`,source:`db`}}function ne(e){return Array.isArray(e)?e.map(D).filter(Boolean):e.data.map(D).filter(Boolean)}function D(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.id==`string`?t.id:``,r=typeof t.name==`string`?t.name:``;if(!n||!r)return null;let i=t.source===`static`||n.startsWith(`static:`)?`static`:`db`,a={id:n,name:r,cli:typeof t.cli==`string`&&t.cli?t.cli:`claude`,model:typeof t.model==`string`&&t.model?t.model:`default`,role:typeof t.role==`string`?t.role:``,source:i};return typeof t.status==`string`&&(a.status=t.status),a}function O(e){return e.name.trim()?e.cli.trim()?e.model.trim()?null:`Model is required`:`CLI is required`:`Name is required`}function k(e){return e.some(e=>O(e)!==null)}function A(e,t){return JSON.stringify(e.map(I))===JSON.stringify(t.map(I))}function j(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(t.map(e=>e.id)),i=[],a=[],o=[];for(let e of t){let t=n.get(e.id);if(!t||e.id.startsWith(`new:`)){i.push(e);continue}let r=P(t,e);Object.keys(r).length>0&&a.push({before:t,after:e,patch:r})}for(let t of e)!r.has(t.id)&&!w(t)&&o.push(t);return{added:i,updated:a,removed:o}}function M(e,t){let n=j(e,t);return{added:n.added.length,updated:n.updated.length,removed:n.removed.length}}async function N(e,t,n){let r=j(t,n);for(let t of r.removed)await e.delete(`/api/employees/${encodeURIComponent(t.id)}`);for(let t of r.added)await e.post(`/api/employees`,F(t));for(let t of r.updated)await e.put(`/api/employees/${encodeURIComponent(t.after.id)}`,t.patch)}function P(e,t){if(w(t))return e.model===t.model?{}:{model:t.model};let n={};for(let r of[`name`,`cli`,`model`,`role`,`status`])(e[r]||``)!==(t[r]||``)&&(n[r]=t[r]||``);return n}function F(e){return{name:e.name.trim()||`New Agent`,cli:e.cli.trim()||`claude`,model:e.model.trim()||`default`,role:e.role.trim()}}function I(e){let t={id:e.id,name:e.name,cli:e.cli,model:e.model,role:e.role,source:e.source};return e.status!==void 0&&(t.status=e.status),t}function L({employee:e,index:t,cliOptions:n,onChange:r,onRemove:i}){let a=w(e),o=_(h(e.cli).models,e.model),s=O(e),u=Array.from(new Set([...n,e.cli,`claude`])).filter(Boolean);return(0,x.jsxs)(`fieldset`,{className:`settings-runtime-employee-row`,children:[(0,x.jsxs)(`legend`,{children:[e.name||`Employee ${t+1}`,a?(0,x.jsx)(`span`,{children:`static`}):null]}),(0,x.jsxs)(`div`,{className:`settings-runtime-employee-grid`,children:[(0,x.jsx)(l,{id:`runtime-employee-${e.id}-name`,label:`Name`,value:e.name,disabled:a,error:s===`Name is required`?s:null,onChange:e=>r({name:e})}),(0,x.jsx)(c,{id:`runtime-employee-${e.id}-cli`,label:`CLI`,value:e.cli,disabled:a,options:u.map(e=>({value:e,label:h(e).label||e})),onChange:e=>{r({cli:e,model:h(e).models[0]||`default`})}}),(0,x.jsx)(c,{id:`runtime-employee-${e.id}-model`,label:`Model`,value:e.model,options:o.length>0?o:[{value:`default`,label:`default`}],onChange:e=>r({model:e})}),(0,x.jsx)(l,{id:`runtime-employee-${e.id}-role`,label:`Role`,value:e.role,disabled:a,onChange:e=>r({role:e})})]}),(0,x.jsxs)(`div`,{className:`settings-runtime-employee-footer`,children:[(0,x.jsxs)(`span`,{children:[e.source,e.status?` / ${e.status}`:``]}),(0,x.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,disabled:a,onClick:i,"aria-label":`Remove employee ${e.name||t+1}`,children:`Remove`})]})]})}function R({roster:e,original:t,cliOptions:n,loading:r,error:a,onRosterChange:o}){let s=M(t,e),c=k(e);function l(t,n){o(e.map((e,r)=>r===t?{...e,...n}:e))}function u(t){o(e.filter((e,n)=>n!==t))}return(0,x.jsxs)(i,{title:`Employees`,hint:`Runtime dispatch roster. Static employees keep their locked identity; database employees can be edited.`,children:[(0,x.jsxs)(`div`,{className:`settings-runtime-employee-summary`,children:[(0,x.jsxs)(`span`,{children:[`+`,s.added]}),(0,x.jsxs)(`span`,{children:[`~`,s.updated]}),(0,x.jsxs)(`span`,{children:[`-`,s.removed]}),c?(0,x.jsx)(`strong`,{children:`Fix invalid rows before saving.`}):null]}),r?(0,x.jsx)(`p`,{className:`settings-agent-note`,children:`Loading employees...`}):null,a?(0,x.jsx)(`p`,{className:`settings-field-error`,role:`alert`,children:a}):null,e.length===0?(0,x.jsx)(`p`,{className:`settings-empty`,children:`No runtime employees configured.`}):(0,x.jsx)(`div`,{className:`settings-runtime-employee-list`,children:e.map((e,t)=>(0,x.jsx)(L,{employee:e,index:t,cliOptions:n,onChange:e=>l(t,e),onRemove:()=>u(t)},e.id))}),(0,x.jsx)(`div`,{className:`settings-employee-footer-bar`,children:(0,x.jsx)(`button`,{type:`button`,className:`settings-action settings-action-discard`,onClick:()=>o([...e,E(n)]),children:`+ Add employee`})})]})}var z=new Set([`runtimeEmployees`,`flushCli`,`flushModel`]);function B(e){let t={},n=null,r=null;for(let[i,a]of Object.entries(e))i===`runtimeEmployees`?r=a:i===`flushCli`||i===`flushModel`?(n??={},n[i===`flushCli`?`cli`:`model`]=String(a??``)):z.has(i)||(t[i]=a);return{settingsBundle:t,flushPatch:n,runtimeEmployeesNext:r}}async function V(e){let{client:t,bundle:n,employeeDraft:r,employeeOriginal:i}=e;if(k(r))throw Error(`runtime employees: fix invalid rows before saving`);let{settingsBundle:a,flushPatch:o,runtimeEmployeesNext:s}=B(n),c=null;try{if(Object.keys(a).length>0){let e=await t.put(`/api/settings`,y(a));c=e&&typeof e==`object`&&`data`in e?e.data:e}}catch(e){throw Error(`settings save failed: ${e instanceof Error?e.message:String(e)}`)}try{o&&await t.put(`/api/memory-files/settings`,o)}catch(e){throw Error(`flush settings save failed: ${e instanceof Error?e.message:String(e)}`)}try{s&&await N(t,i,s)}catch(e){throw Error(`runtime employees save failed: ${e instanceof Error?e.message:String(e)}`)}return c}function H({port:e,client:t,dirty:n,registerSave:i}){let{state:c,refresh:l,setData:d}=r(t,`/api/settings`),[f,m]=(0,b.useState)({cli:``,provider:``,model:``,effort:``,workingDir:``,permissions:`auto`}),[v,y]=(0,b.useState)({}),[C,w]=(0,b.useState)({}),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)(null),[j,M]=(0,b.useState)([]),[N,P]=(0,b.useState)([]),[F,I]=(0,b.useState)(!0),[L,z]=(0,b.useState)(null),B=(0,b.useCallback)(async()=>{E(!0),O(null);try{let e=await t.get(`/api/memory-files`),n={cli:e.cli||``,model:e.model||``};y(n),w(n)}catch(e){O(e instanceof Error?e.message:String(e))}finally{E(!1)}},[t]),H=(0,b.useCallback)(async()=>{I(!0),z(null);try{let e=ne(await t.get(`/api/employees`));M(e),P(e)}catch(e){z(e instanceof Error?e.message:String(e))}finally{I(!1)}},[t]);(0,b.useEffect)(()=>{B(),H()},[H,B]),(0,b.useEffect)(()=>{if(c.kind!==`ready`)return;let e=Object.keys(c.data.perCli||{}),t=c.data.cli||e[0]||``,n=u(c.data.permissions);m({cli:t,provider:c.data.perCli?.[t]?.provider||h(t).defaultProvider||``,model:g(t,c.data.perCli,c.data.activeOverrides),effort:p(t,c.data.perCli,c.data.activeOverrides),workingDir:c.data.workingDir||``,permissions:n.mode===`custom`?n.tokens:`auto`})},[c]),(0,b.useEffect)(()=>()=>{for(let e of Array.from(n.pending.keys()))(e===`cli`||e===`workingDir`||e===`permissions`||e===`runtimeEmployees`||e===`flushCli`||e===`flushModel`||e.startsWith(`activeOverrides.`))&&n.remove(e)},[n]);let U=(0,b.useCallback)((e,t)=>n.set(e,t),[n]),W=(0,b.useCallback)(async()=>{let e=n.saveBundle();if(Object.keys(e).length===0)return;let r=await V({client:t,bundle:e,employeeDraft:N,employeeOriginal:j});n.clear(),r&&d(r),await l(),await B(),await H()},[t,n,N,j,H,B,l,d]);(0,b.useEffect)(()=>{if(i)return i(W),()=>i(null)},[i,W]);let G=c.kind===`ready`?c.data:{},K=G.perCli||{},q=G.activeOverrides||{},J=(0,b.useMemo)(()=>Object.keys(K),[K]),Y=h(f.cli),X=f.provider||Y.defaultProvider||Y.providers?.[0]||``,Z=f.cli===`pi`,Q=!Z&&(Y.providers?.length??0)>0,re=_(Q&&Y.modelsByProvider?.[X]||Y.models,f.model),ie=Q&&Y.effortsByProvider?.[X]||Y.efforts,ae=f.workingDir.trim()?null:`Required`;if(c.kind===`loading`)return(0,x.jsx)(a,{});if(c.kind===`offline`)return(0,x.jsx)(o,{port:e});if(c.kind===`error`)return(0,x.jsx)(s,{message:c.message});function oe(){for(let e of Array.from(n.pending.keys()))e.startsWith(`activeOverrides.`)&&n.remove(e)}function $(e){m(e)}return(0,x.jsxs)(`form`,{className:`settings-page-form`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,x.jsx)(S,{cli:f.cli,cliOptions:J.length>0?J:[f.cli||`claude`],provider:X,providerOptions:Z?[]:Y.providers||[],model:f.model,modelOptions:re,effort:f.effort,effortOptions:ie,workingDir:f.workingDir,workingDirError:ae,onCliChange:e=>{let t={...f,cli:e,provider:K[e]?.provider||h(e).defaultProvider||``,model:g(e,K,q),effort:p(e,K,q)};oe(),$(t),U(`cli`,{value:e,original:G.cli||``,valid:!0})},onProviderChange:e=>{let t=Y.modelsByProvider?.[e]||[],n=Y.effortsByProvider?.[e]||[],r=t.includes(f.model)?f.model:t[0]||``,i=n.includes(f.effort)?f.effort:``;$({...f,provider:e,model:r,effort:i}),U(`perCli.${f.cli}.provider`,{value:e,original:K[f.cli]?.provider||Y.defaultProvider||``,valid:!0}),U(`activeOverrides.${f.cli}.model`,{value:r,original:g(f.cli,K,q),valid:r.trim().length>0}),U(`activeOverrides.${f.cli}.effort`,{value:i,original:p(f.cli,K,q),valid:!0})},onModelChange:e=>{$({...f,model:e}),U(`activeOverrides.${f.cli}.model`,{value:e,original:g(f.cli,K,q),valid:e.trim().length>0})},onEffortChange:e=>{$({...f,effort:e}),U(`activeOverrides.${f.cli}.effort`,{value:e,original:p(f.cli,K,q),valid:!0})},onWorkingDirChange:e=>{$({...f,workingDir:e}),U(`workingDir`,{value:e,original:G.workingDir||``,valid:e.trim().length>0})}}),(0,x.jsx)(ee,{value:f.permissions,onChange:e=>{$({...f,permissions:e}),U(`permissions`,{value:e,original:G.permissions??`auto`,valid:e===`auto`||e.length>0})}}),(0,x.jsx)(te,{activeCli:f.cli,flushCli:C.cli||``,flushModel:C.model||``,cliOptions:J,modelOptions:_(h(C.cli||f.cli).models,C.model||``),loading:T,error:D,onFlushCliChange:e=>{let t=e&&h(e).models[0]||``;w({cli:e,model:t}),U(`flushCli`,{value:e,original:v.cli||``,valid:!0}),U(`flushModel`,{value:t,original:v.model||``,valid:!0})},onFlushModelChange:e=>{w({...C,model:e}),U(`flushModel`,{value:e,original:v.model||``,valid:!0})}}),(0,x.jsx)(R,{roster:N,original:j,cliOptions:J,loading:F,error:L,onRosterChange:e=>{if(P(e),A(e,j)){n.remove(`runtimeEmployees`);return}n.set(`runtimeEmployees`,{value:e,original:j,valid:!k(e)})}})]})}export{H as default,B as splitAgentSaveBundle};
|
|
@@ -1,3 +0,0 @@
|
|
|
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`,ee=e=>x(e.cwd),w=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||w(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:ee(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 ee(e){return[e.kind,e.optionId,e.id,e.name,e.label].map(e=>String(e??``)).join(` `).trim()}function w(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(ee(e))),a=n??r??i;if(!a)return null;let o=w(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 M(e){return j(e)??k(e)}function te(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:M(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`?M(r):k(r)}))}function P(e){let t=[],n=e.content;if(Array.isArray(n))for(let e of n){let n=te(e);n&&t.push(n)}else{let e=te(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 ne={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`}},F={session:`session`,orchestrate:`workflow`,pabcd:`workflow`,goal:`workflow`,mcp:`utility`,move:`utility`,compact:`utility`,dump:`utility`,help:`utility`};function re(e){return e.trim().replace(/^\/+/,``)}function I(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`:ne[t]||F[t]?`jwc-builtin`:`unknown`}function L(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 R(e){if(!e||typeof e!=`object`)return null;let t=e,n=re(String(t.name??``));if(!n)return null;let r=ne[n],i=r?.category??F[n]??`unknown`,a=I(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=L(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 ie(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t){let t=R(e);!t||n.has(t.name)||(n.add(t.name),r.push(t))}return r}function z(e){return[e.name,e.displayName,e.description??``,e.inputHint??``,e.category,e.source].join(` `).toLowerCase()}function ae(e,t){let n=re(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):z(t).includes(n)&&i.push(t);return[...r,...i]}function oe({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 se(e){return e===`provider`?`Provider`:e===`model`?`Model`:e===`permission`?`Permissions`:e===`session`?`Session`:`Settings`}function B(e){return e===`jwc-cache`?`JWC cache`:`static fallback`}function ce({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),ee=n.providers.find(e=>e.id===r)??n.providers[0],[w,T]=(0,d.useState)(``),[E,D]=(0,d.useState)(`models`),[O,k]=(0,d.useState)(r),[A,j]=(0,d.useState)(i),[M,te]=(0,d.useState)({}),N=n.providers.find(e=>e.id===O)??ee,P=w.trim().toLowerCase(),ne=(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]),F=(0,d.useMemo)(()=>{let e=N?.models??[];return P?e.filter(e=>e.toLowerCase().includes(P)):e},[N?.models,P]),re=se(e),I=(0,d.useMemo)(()=>{let e=n.providers.length;return`${e} authenticated provider${e===1?``:`s`}`},[n.providers.length]),L=!!(l&&O&&A&&!c),R=!!(O&&A&&!c),ie=(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`}te(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:re})]}),(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:I}),(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 · `,B(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)(oe,{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:w,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:ne.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:[F.length,` models · `,B(N?.modelSource)]})]}),F.length===0?(0,m.jsx)(`p`,{className:`code-popup-note`,children:`No models match this search.`}):F.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:!L,onClick:()=>{g(O,A)},children:`Use now`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!R,onClick:()=>{_(O,A)},children:`Use for new sessions`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!R,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=M[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;te(t=>({...t,[e.role]:n}))},children:ie.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 V(e,t,n){return n<=0?0:(e+t+n)%n}function le(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 ue(e){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>ae(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:le(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=>V(e,1,r.length));return}if(t.key===`ArrowUp`){t.preventDefault(),n(e=>V(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 H({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 de=92,fe=6;function pe(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||(()=>de),overscan:fe,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||(()=>de)}),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 me=(0,d.lazy)(()=>t(()=>import(`./MarkdownRenderer-DXKUEE2a.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0])));function he(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 U(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function ge(e){return(e.toolContent?.find(e=>typeof e.text==`string`&&e.text.trim())?.text??e.toolOutput??``).replace(/\s+/g,` `).trim().slice(0,240)}function W(e){return e.split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()??``}function _e(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=W(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=W(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:W(r)}}}return null}function ve(e){let t=W(e.toolName||e.text||`tool`)||`tool`,n=_e(e);return t.includes(`:`)||!n?t:t===`tool`?n.name?`${n.name}: ${n.text}`:n.text:`${t}: ${n.text}`}function G(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 ye(e,t){return`${t}:${e.toolCallId||e.permissionAudit?.permissionId||`${e.role}:${e.text.slice(0,48)}`}`}function K(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){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?ge(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:ve(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(he)}),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:G(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)(me,{markdown:e.text,tableMode:`linear`})}):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}){let i=t&&e[e.length-1]?.role!==`assistant`,a=pe({count:e.length+ +!!i,scrollElementRef:r,getItemKey:(0,d.useCallback)(t=>{let n=e[t];return n?ye(n,t):`sending-${t}`},[e]),estimateSize:(0,d.useCallback)(t=>K(e[t]),[e])});function o(e){if(U(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:o,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:`${a.totalSize}px`},children:a.virtualItems.map(t=>{let n=e[t.index];return(0,m.jsx)(`div`,{ref:a.measureElement,className:`code-transcript-virtual-row`,"data-code-transcript-idx":t.index,style:{transform:`translateY(${t.start}px)`},children:n?q(n,t.index):J()},t.key)})})})}function be(e){return e.split(`/`).filter(Boolean).slice(-2).join(`/`)||e}function xe({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:be(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:be(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 X({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)(X,{label:`Permission`,value:o,options:x,disabled:s,title:S[o],onChange:d}),t.length>0&&(0,m.jsx)(X,{label:`Provider`,value:e,options:t.map(e=>({value:e,label:e})),disabled:s,title:e,onChange:c}),(0,m.jsx)(X,{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)(X,{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)(xe,{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}),(0,m.jsx)(H,{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)(ue,{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)(ce,{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=ie([{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 Q(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 je(e,t){for(let n of t){let t=Q(n,Ae(n.update));t&&e.add(t)}}function Me(e,t,n){let r=Q(t,n);return r?e.has(r)?!0:(e.add(r),!1):!1}function Ne(e,t){let n=e.trim(),r=t.trim();return r.length<80?!1:n===r}var Pe=80,Fe=.7,Ie=.78,Le=32,Re=8;function ze(e){return e.replace(/\s+/g,` `).trim()}function $(e){return e.split(/\r?\n/).map(e=>e.replace(/\s+/g,` `).trim()).filter(e=>e.length>=4)}function Be(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<Pe||r.length<Pe)return!1;if(r.includes(n))return!0;let i=$(e),a=new Set($(t));if(i.length>=4&&Be(i,a)>=Fe)return!0;let o=Ve(n);return o.length<3?!1:Be(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}){let r=(0,d.useMemo)(()=>p(e),[e]),[i,a]=(0,d.useState)(t),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)([]),[ee,w]=(0,d.useState)([]),[T,E]=(0,d.useState)(Te),[D,O]=(0,d.useState)(!1),[k,A]=(0,d.useState)(null),[j,M]=(0,d.useState)(``),[te,N]=(0,d.useState)(``),[ne,F]=(0,d.useState)({}),[re,I]=(0,d.useState)([]),[L,R]=(0,d.useState)(`anthropic`),[z,ae]=(0,d.useState)(`claude-sonnet-4-6`),[oe,se]=(0,d.useState)(`high`),[B,ce]=(0,d.useState)(`always-allow`),[V,le]=(0,d.useState)(we),[ue,H]=(0,d.useState)(null),[de,fe]=(0,d.useState)(null),[pe,me]=(0,d.useState)(null),[he,U]=(0,d.useState)(null),[ge,W]=(0,d.useState)(`connected`),[_e,ve]=(0,d.useState)(null),G=(0,d.useRef)(null),ye=(0,d.useRef)(!1),K=(0,d.useRef)(null),q=(0,d.useRef)(null),J=(0,d.useRef)(new Set),Y=(0,d.useRef)(new Set),be=(0,d.useMemo)(()=>z?_(L,z):``,[L,z]),{transcriptRef:xe,scrollTranscriptToBottom:X}=qe(S,b,!!k);(0,d.useEffect)(()=>{G.current||o||a(t)},[o,t]);let Se=(0,d.useCallback)(e=>{G.current||o||c||(a(e??``),n?.(e))},[o,n,c]),ke=(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 r.pickWorkspace();return t.ok&&t.path?t.path:null},[r]),Q=(0,d.useCallback)(e=>{le(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]??``;R(t?.id??`anthropic`),ae(n);let r=t?.efforts??[];r.length>0&&se(r.includes(`high`)?`high`:r[0]??``)},[]);(0,d.useEffect)(()=>{G.current=o},[o]),(0,d.useEffect)(()=>{if(typeof document>`u`){ve(null);return}return ve(document.getElementById(`code-session-sidebar-host`)),()=>ve(null)},[]);let Pe=(0,d.useCallback)(async()=>{Q(await r.listModelOptions())},[Q,r]),Fe=(0,d.useCallback)(async()=>{H(await r.listModelAssignments())},[r]);(0,d.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,n,i]=await Promise.all([r.listModelOptions(),r.listModelAssignments(),r.listModelPresets()]);if(e)return;Q(t),H(n),fe(i)}catch(t){e||(le({...we,error:t instanceof Error?t.message:String(t)}),H(null),fe(null))}})(),()=>{e=!0}},[Q,r]),(0,d.useEffect)(()=>{if(!i){me(null);return}let e=!1;return r.getGitInfo(i).then(t=>{e||me(t)},()=>{e||me(null)}),()=>{e=!0}},[r,i]),(0,d.useEffect)(()=>{if(ye.current){ye.current=!1;return}s(null),G.current=null,C([]),w([]),I([]),N(``),F({}),x(!1),U(null),Y.current=new Set},[i]),Ye({port:e,sessionId:o,sessionIdRef:G,onEvent:(0,d.useCallback)(e=>{let t=e.update??{},n=e.event;if(!(q.current&&e.sessionId===q.current&&n!==`code_child_exit`)){if(n===`code_agent_message_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Me(Y.current,e,n))return;C(e=>{if(J.current.has(n)&&e[e.length-1]?.role===`user`)return J.current.delete(n),e;let t=e[e.length-1];if(t?.role===`assistant`&&Ne(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(Me(Y.current,e,n))return;C(e=>{if(K.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){K.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(Me(Y.current,e,n))return;C(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);C(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);C(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??{},i=e.options??[];t&&De(r,B,{permissionId:t,toolCall:n,options:i},{appendMessage:e=>C(t=>[...t,e]),enqueuePermission:e=>w(t=>[...t,e])})}else if(n===`code_session_info_update`){let e=t.title;typeof e==`string`&&N(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),F(e)}else if(n===`code_plan`)I((t.entries??[]).filter(e=>e.title).map(e=>({title:String(e.title),status:String(e.status??`pending`)})));else if(n===`code_available_commands_update`)E(Ee(ie(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.`;G.current=null,s(null),x(!1),w([]),U({code:t,message:n}),C(e=>[...e,{role:`assistant`,text:n}])}else n===`code_turn_done`?x(!1):n===`code_session_error`&&(C(t=>[...t,{role:`assistant`,text:`Error: ${e.reason??`unknown`}`}]),x(!1));setTimeout(()=>X(`smooth`),50)}},[r,B,X]),onTransport:W});let Ie=(0,d.useCallback)(async()=>{let e=v.trim();if(!(!e||b)){q.current=null,x(!0),l(!0),U(null),K.current=e,C(t=>[...t,{role:`user`,text:e,transient:`pending-user-echo`}]),y(``);try{let t=o;if(!t){let e=i||`/tmp`;t=(await r.createSession(e,be||void 0)).sessionId,G.current=t,s(t)}await r.sendPrompt(t,e)}catch(e){K.current=null,C(t=>[...t,{role:`assistant`,text:`Error: ${e instanceof Error?e.message:String(e)}`}]),x(!1)}}},[v,b,o,r,i,be]),Le=(0,d.useCallback)(e=>{y(e),O(e===`/`||e.startsWith(`/`)&&!e.includes(` `))},[]),Re=(0,d.useCallback)(e=>{if(!e.disabledReason){if(e.actionType===`popup`&&e.popupKind){M(``),A({kind:e.popupKind,command:e}),O(!1);return}y(`${e.displayName} `),O(!1)}},[]),ze=(0,d.useCallback)(async(e,t)=>{await Oe(r,B,e,t,e=>C(t=>[...t,e]))&&w(t=>t.filter(t=>t.permissionId!==e.permissionId))},[r,B]),$=(0,d.useCallback)(async(e,t,n)=>{M(``),R(e),ae(t);let i=n?.closePopup??!0,a=n?.requireActiveSession??!0;if(!o){a&&M(`Start or load a Code session before applying a live model.`);return}try{await r.setSessionModel(o,_(e,t)),i&&A(null)}catch(e){M(e instanceof Error?e.message:String(e))}},[o,r]),Be=(0,d.useCallback)(async(e,t)=>{M(``);try{Q(await r.setDefaultModel(_(e,t))),Fe()}catch(e){M(e instanceof Error?e.message:String(e))}},[Q,r,Fe]),Ve=(0,d.useCallback)(async(e,t,n,i)=>{M(``);try{H(await r.setModelAssignment(e,{provider:t,model:n,...i===void 0?{}:{thinkingLevel:i}}))}catch(e){M(e instanceof Error?e.message:String(e))}},[r]),He=(0,d.useCallback)(async e=>{M(``);try{H(await r.clearModelAssignment(e))}catch(e){M(e instanceof Error?e.message:String(e))}},[r]),Ke=V.providers.find(e=>e.id===L)??V.providers[0],Je=V.providers.map(e=>e.id),Xe=Ke?.models??[],Ze=Ke?.efforts??[],Qe=e=>{let t=Ge(e.replayEvents??[]);Y.current=new Set,je(Y.current,e.replayEvents??[]),J.current=new Set(t.filter(e=>e.role===`assistant`&&e.text).map(e=>e.text)),G.current=e.sessionId,s(e.sessionId),e.cwd!==i&&(ye.current=!0,a(e.cwd)),C(t),w([]),I([]),N(e.title?.trim()||t.find(e=>e.role===`user`)?.text.split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()||``),F({}),x(!1),U(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 $e=(0,m.jsx)(h,{client:r,activeSessionId:o,workingDir:i,onSelectSession:Qe,onLoadSession:(e,t)=>{(async()=>{q.current=e,G.current=e,s(e),K.current=null,J.current=new Set,Y.current=new Set,C([]),I([]),N(``),x(!1);try{let n=await r.loadSession(e,t);if(G.current!==e)return;n.title&&N(n.title);let i=Ge(n.replayEvents??[]);Y.current=new Set,je(Y.current,n.replayEvents??[]),J.current=new Set(i.filter(e=>e.role===`assistant`&&e.text).map(e=>e.text)),C(i),x(!1)}catch(t){G.current===e&&(G.current=null,s(null)),C(e=>[...e,{role:`assistant`,text:`Failed to load session: ${t instanceof Error?t.message:String(t)}`}])}finally{q.current===e&&(q.current=null)}})()},onNewSession:()=>{G.current=null,q.current=null,K.current=null,J.current=new Set,Y.current=new Set,s(null),C([]),I([]),N(``),x(!1),l(!1)}}),et=e=>{R(e),ae(V.providers.find(t=>t.id===e)?.models[0]??``)},tt=(0,m.jsx)(Ce,{activePopup:k,activeSessionId:o,availableCommands:T,codeWorkingDir:i,currentEffortOptions:Ze,currentModelOptions:Xe,disabled:b,effort:oe,gitInfo:pe,childRecovery:he,transportState:ge,inputText:v,messages:S,model:z,modelAssignments:ue,modelOptions:V,modelPresets:de,permissionMode:B,permissions:ee,planEntries:re,error:j,provider:L,providerOptions:Je,sending:b,sessionTitle:te,showCommands:D,transcriptRef:xe,usage:ne,onClearModelAssignment:He,onClosePopup:()=>{M(``),A(null)},onCommandSelect:Re,onEffortChange:e=>{se(e),o&&r.setSessionConfig(o,`thinking`,e)},onFooterProviderChange:e=>{et(e);let t=V.providers.find(t=>t.id===e),n=t?.models[0]??``;se(t?.efforts.includes(`high`)?`high`:t?.efforts[0]??``),n&&$(e,n,{closePopup:!1,requireActiveSession:!1})},onInputChange:Le,onModelChange:e=>{$(L,e,{closePopup:!1,requireActiveSession:!1})},onPermissionAnswer:ze,onPermissionModeChange:ce,onProviderChange:et,onRefreshProviders:()=>{Pe()},onSetDefaultModel:Be,onSetModelAssignment:Ve,onShowCommandsChange:O,onSubmit:()=>{Ie()},onUseModel:$,onUseForNewSessions:(e,t)=>{$(e,t,{requireActiveSession:!1,closePopup:!1}),A(null)},onWorkingDirChange:Se,workspaceFrozen:c,onPickWorkingDir:ke});return _e?(0,m.jsxs)(m.Fragment,{children:[(0,f.createPortal)((0,m.jsx)(`div`,{className:`code-manager-session-navigator-content`,children:$e}),_e),(0,m.jsx)(`div`,{className:`code-canvas code-canvas-workbench`,children:tt})]}):(0,m.jsxs)(`div`,{className:`code-canvas`,children:[(0,m.jsx)(`div`,{className:`code-canvas-sidebar`,children:$e}),tt]})}export{Xe as CodeCanvas};
|
|
@@ -1 +0,0 @@
|
|
|
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-DcIxpNcX.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`,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(){return i()?.folder??null}function m(e){return!e.startsWith(`/`)&&!/^[a-zA-Z]:[\\/]/.test(e)}function h(e){return e.split(/[\\/]/).pop()||e}function g(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})});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 _(e){let t=p(),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,_]=(0,c.useState)(``),[v,y]=(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){_(``),y(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),_(e.binary||e.truncated?``:e.content),y(null)):y(e.error??`Failed to read file`);return}if(!m(n)){i||y(`Document preview for arbitrary local files requires Electron desktop app`);return}try{let e=await r(n);if(i)return;x(!1),C(!1),_(e.content),y(null)}catch(e){i||y(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?v?(0,l.jsx)(`div`,{className:`doc-panel doc-error`,children:v}):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:h(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)(g,{filePath:e.filePath,content:f,raw:w})})})]}):(0,l.jsx)(`div`,{className:`doc-panel doc-empty`,children:`Open Folders and select a file to preview it here.`})}export{_ as DocPanel};
|
|
@@ -1,3 +0,0 @@
|
|
|
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 A(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 j(e,t=se()){return oe(t)?e.metaKey:e.ctrlKey}function ce(e,t){if(A(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 le(e){window.dispatchEvent(new CustomEvent(`jaw-folder-panel-drag`,{detail:{active:e}}))}function ue(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),le(!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:()=>{le(!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(),le(!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:j(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)(ue,{...e,entries:e.childrenCache.get(t.path),parentPath:t.path,depth:e.depth+1})]},t.path))]})}function de(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 fe(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)(ue,{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)(de,{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 M={selectedPaths:[],focusedPath:null,anchorPath:null};function pe(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 me(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 he(e,t,n,r={}){if(!n.includes(t))return e;if(r.range&&e.anchorPath&&n.includes(e.anchorPath))return{selectedPaths:P(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 N(e,t,n,r){if(t.length===0)return M;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:P(t,n,o),focusedPath:o,anchorPath:n}}return{selectedPaths:[o],focusedPath:o,anchorPath:o}}function ge(e,t){return e.filter(e=>t.has(e.path))}function P(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 _e(e){return Array.from(e.entries())}function ve(e){return new Map(e)}function ye(e,t){return!e||t&&e.rootPath!==t?null:e}function be(e){return{rootPath:e.rootPath,entries:e.entries,expandedPaths:Array.from(e.expanded),childrenCache:_e(e.childrenCache),selection:e.selection}}function F(e){return/not a git repository/i.test(e)}async function xe(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 I(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 xe(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:F(o),error:o}}var L={available:!1,loading:!1,error:null,repoRoot:null,branch:null,head:null,dirty:!1,decorationsByPath:new Map},Se={modified:`M`,added:`A`,deleted:`D`,renamed:`R`,untracked:`?`,ignored:`·`,conflict:`U`,submodule:`S`};function R(e){return{className:`git-${e.kind}`,label:Se[e.kind],title:[e.kind,e.staged?`staged`:``,e.unstaged?`unstaged`:``].filter(Boolean).join(` · `)}}function z(e){let t=e.kinds[0]??`modified`;return{className:`git-${t}`,label:`${Se[t]}${e.changedCount>1?e.changedCount:``}`,title:`${e.changedCount} changed item${e.changedCount===1?``:`s`}`}}function B(e){let t=new Map;for(let n of e.files)t.set(n.path,R(n));for(let n of e.directories)t.set(n.path,z(n));return{available:!0,loading:!1,error:null,repoRoot:e.repoRoot,branch:e.branch,head:e.head,dirty:e.dirty,decorationsByPath:t}}function Ce(e){let{rootPath:t,repoRoot:n,enabled:r,refreshToken:i}=e,[a,o]=(0,c.useState)(L);return(0,c.useEffect)(()=>{if(!r||t===null){o(L);return}let e=!1,i=window.setTimeout(()=>{o(e=>({...e,loading:!0,error:null})),(async()=>{let r=await I(t,{...n?{repoRoot:n}:{},includeIgnored:!0,includeUntracked:!0});if(!e){if(r.ok){o(B(r.status));return}o(r.quiet?L:{...L,error:r.error})}})()},250);return()=>{e=!0,window.clearTimeout(i)}},[r,i,n,t]),a}function V(e){return/not a git repository/i.test(e)}async function H(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 U(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 H(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:V(o)?null:o}}catch(e){let t=e instanceof Error?e.message:`Failed to load git worktrees`;return{ok:!1,repoRoot:null,worktrees:[],error:V(t)?null:t}}}var W={available:!1,loading:!1,error:null,repoRoot:null,worktrees:[]};function we(e){let{folderPanelRoot:t,repoRoot:n,enabled:r,refreshToken:i}=e,[a,o]=(0,c.useState)(0),[s,l]=(0,c.useState)(W),u=(0,c.useCallback)(()=>o(e=>e+1),[]);return(0,c.useEffect)(()=>{if(!r||t===null){l(W);return}let e=!1;return l(e=>({...e,loading:!0,error:null})),(async()=>{let r=await U(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 Te(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 Ee(e){let t=e.onPreviewFile,[n,r]=(0,c.useState)(()=>e.initialSelection??M),i=(0,c.useMemo)(()=>pe(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)(()=>ge(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=>me(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=>he(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}:M)},[a]),resetSelection:(0,c.useCallback)(()=>{r(M)},[]),moveKeyboardSelection:(0,c.useCallback)((e,t)=>{r(n=>N(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 De=120,Oe=80;function G(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 ke(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.useCallback)(()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),b=(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,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});o(),s?.(),l();let u=Math.max(0,n.size-c.length);d(u>0?`${G(e)}; ${u} collapsed/overflow branches skipped`:G(e))}finally{g.current=!1,h(!1);let e=_.current;_.current=null,e&&b(e.reason,e.options)}}},[o,n,a,i,s,l,t]),x=(0,c.useCallback)(async(e=`manual`,t={})=>{await b(e,t)},[b]),S=(0,c.useCallback)(()=>{y(),v.current=window.setTimeout(()=>{v.current=null,b(`watch`)},De)},[y,b]);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(()=>{S()});return()=>{e=!0,y(),n(),r.unwatchDir?.(t)}},[y,t,S,r]),{isRefreshing:m,refreshStatus:u,watchStatus:f,refreshVisibleTree:x}}var Ae=8,K=0;function q(){return K+=1,`folder-git-op-${Date.now()}-${K}`}function J(e){return/dirty|uncommitted|confirmation required|not registered|outside home|symlink/i.test(e)}function Y(e,t){return{id:q(),operation:e,startedAt:new Date().toISOString(),finishedAt:null,operationLabel:t?.label??e.type,commandPreview:t?.command??[],status:`running`,stdout:``,stderr:``,error:null}}function X(e,t){return[t,...e].slice(0,Ae)}function je(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:J(n.error)?`blocked`:`failed`,error:n.error}:e)}function Me(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=Y(e,n),a=!1;g(e=>X(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=>je(t,i.id,{ok:!1,error:e})),a=!0,Error(e)}g(e=>je(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=>je(e,i.id,{ok:!1,error:t})),u(t)}finally{m(!1)}},[s,o,t,l,u,r])}}function Ne(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 Pe(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 Fe(){return i()?.folder??null}function Ie(e,t,n){return!e||!k(t,e)?null:e===t?n:`${n}${e.slice(t.length)}`}function Le(e){let t=Fe(),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)(()=>ye(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?ve(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),[A,j]=(0,c.useState)(null),[le,ue]=(0,c.useState)(!1),[de,M]=(0,c.useState)(!1),[pe,me]=(0,c.useState)(!1),[he,N]=(0,c.useState)(null),[ge,P]=(0,c.useState)(0),_e=(0,c.useRef)(null),{folderChordActive:F,startFolderChord:xe,cancelFolderChord:I}=Te(),L=e.onPreviewFile,Se=e.selectedFilePath,R=Ee({entries:v,childrenCache:C,expanded:b,initialSelection:u?.selection,onPreviewFile:L}),z=R.selectedEntry,B=R.selectedEntries,V=Pe({selectedPaths:R.selectedPaths,selectOnlyPath:R.selectOnlyPath});(0,c.useEffect)(()=>{let t=e.selectedFilePath;!t||!h||k(h,t)&&t!==R.selectedPath&&R.visiblePaths.includes(t)&&R.selectOnlyPath(t)},[R.selectedPath,R.selectOnlyPath,R.visiblePaths,e.selectedFilePath,h]),(0,c.useEffect)(()=>{e.onSessionStateChange?.(be({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}),P(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]),De=(0,c.useCallback)(()=>{P(e=>e+1)},[]),Oe=(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]),G=(0,c.useCallback)(async()=>{if(l.pickRoot)try{let e=await l.pickRoot();e&&await U(e)}catch(e){E(e.message)}},[U,l]),Ae=(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;!t||t===h||U(t)},[U,e.externalRootPath,h]);let K=Ce({rootPath:h,repoRoot:n,enabled:l.kind===`electron-folder`,refreshToken:ge+r}),q=we({folderPanelRoot:h,repoRoot:K.repoRoot??n,enabled:l.kind===`electron-folder`&&K.available,refreshToken:ge+r}),J=ke({rootPath:h,expanded:b,source:l,loadDir:H,loadChildren:W,bumpGitRefresh:De,onGitRefresh:i,refreshWorktrees:q.refresh}),Y=J.refreshVisibleTree,X=Me({rootPath:h,source:l,worktreeState:q,openFolderRoot:U,refreshVisibleTree:Y,bumpGitRefresh:De,setActionStatus:N,setError:E});(0,c.useEffect)(()=>{K.repoRoot&&K.repoRoot!==n&&o?.(K.repoRoot)},[K.repoRoot,o,n]);let je=l.kind===`electron-folder`,Le=!!(l.createFile&&l.createFolder&&l.renamePath),Re=(0,c.useCallback)(async(e,t)=>{if(!h)return;let n=ne(e);w(e=>ie(e,[n,t])),await Y(`move`,{extraPaths:[n,t]})},[Y,h]),ze=(0,c.useCallback)(async(e,t,n=[])=>{h&&(w(t=>ie(t,[e,...n])),await Y(`mutation`,{extraPaths:[e]}),t&&R.selectOnlyPath(t))},[R,Y,h]),Be=(0,c.useCallback)(async e=>{if(l.movePath){ue(!0);try{let t=(await l.movePath(e.source.path,e.target.path)).moved?.to??e.source.path;R.selectOnlyPath(t),N(`Moved ${e.source.name}`),j(null),await Re(e.source.path,e.target.path)}catch(e){E(e.message)}finally{ue(!1)}}},[R,Re,l]),Ve=(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(de){Be(n);return}me(!1),j(n)},[Be,de,l.movePath]),Z=Ne({rootPath:h,selectedEntry:z,selectedFilePath:Se,source:l,folderSelection:R,refreshAfterMutation:ze,renamedPreviewPath:Ie,onPreviewFile:L,closeContextMenu:V.closeContextMenu,setExpanded:S,setActionStatus:N,setError:E}),Q=(0,c.useCallback)((e,t)=>{R.selectEntry(e,t),V.closeContextMenu()},[V,R]),He=(0,c.useCallback)(e=>{e.kind===`file`&&Q(e)},[Q]),Ue=(0,c.useCallback)(e=>{R.selectEntry(e,{preview:!1}),V.closeContextMenu(),e.kind===`directory`&&Oe(e.path)},[V,R,Oe]),We=(0,c.useCallback)(async(e,t)=>{let n=await a(t===`relative`?re(h,e.path):e.path);n.ok?(R.selectOnlyPath(e.path),N(t===`relative`?`Copied relative path`:`Copied path`),E(null)):E(n.error??`Failed to copy path`)},[R,h]),Ge=(0,c.useCallback)(async e=>{if(l.revealPath)try{await l.revealPath(e.path),R.selectOnlyPath(e.path),N(e.kind===`directory`?`Opened folder in Finder`:`Revealed file in Finder`),E(null)}catch(e){E(e.message)}},[R,l]),$=(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?(N(e===`relative`?`Copied relative paths`:`Copied paths`),E(null)):E(t.error??`Failed to copy paths`)},[h,B]),Ke=(0,c.useCallback)(async()=>{z&&await Ge(z)},[Ge,z]),qe=(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=ce(e,{chordActive:F});if(n){e.preventDefault(),e.stopPropagation(),n===`start-chord`&&xe(),n===`cancel-chord`&&I();let r=R.selectedPaths.has(t.path);n===`copy-path`&&(I(),r?$(`absolute`):We(t,`absolute`)),n===`copy-relative-path`&&(I(),r?$(`relative`):We(t,`relative`)),n===`reveal-path`&&(I(),r?Ke():Ge(t));return}if(e.key===`Enter`){e.preventDefault(),t.kind===`directory`?Ue(t):Q(t);return}e.key===` `&&(e.preventDefault(),Q(t))},[I,We,$,F,R,Ge,Ke,Q,xe,Ue]);return(0,c.useEffect)(()=>{let e=R.selection.focusedPath;if(!e)return;let t=_e.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 G(),onRefresh:()=>{h!==null&&Y(`manual`)},gitSummary:l.kind===`electron-folder`?K:void 0,worktreeSummary:l.kind===`electron-folder`?q:void 0,onOpenWorktree:e=>void X.openWorktreeRoot(e),onCopyWorktreePath:e=>void X.copyWorktreePath(e),onRevealWorktreePath:e=>void X.revealWorktreePath(e),onOpenWorktreeOps:()=>X.setOpen(!0)}),h!==null&&(0,p.jsx)(m,{hasSelection:!!z,canReveal:!!l.revealPath,onCopyPath:()=>void $(`absolute`),onCopyRelativePath:()=>void $(`relative`),onReveal:()=>void Ke(),canMutate:Le,onCreateFile:()=>Z.requestCreateEntry(`file`),onCreateFolder:()=>Z.requestCreateEntry(`directory`),onRename:()=>Z.requestRenameSelectedEntry()}),T&&(0,p.jsx)(`div`,{className:`folder-error`,children:T}),J.watchStatus&&!T&&(0,p.jsx)(`div`,{className:`folder-status`,children:J.watchStatus}),J.refreshStatus&&!T&&!J.watchStatus&&(0,p.jsx)(`div`,{className:`folder-status`,children:J.refreshStatus}),he&&!T&&!J.refreshStatus&&!J.watchStatus&&(0,p.jsx)(`div`,{className:`folder-status`,children:he}),F&&(0,p.jsx)(`div`,{className:`folder-shortcut-hint`,children:`Folder shortcut: press P to copy path or R to reveal`}),X.open&&h!==null&&(0,p.jsx)(O,{folderPanelRoot:h,repoRoot:q.repoRoot,worktrees:q.worktrees,busy:X.busy,history:X.history,onRun:(e,t)=>void X.runWorktreeOperation(e,t),onClose:()=>X.setOpen(!1)}),(0,p.jsx)(fe,{treeRef:_e,rootPath:h,error:T,entries:v,expanded:b,childrenCache:C,folderSelection:R,decorationsByPath:K.decorationsByPath,dropTargetPath:oe,dragSelection:te,inlineMutation:Z.inlineMutation,isMutating:Z.isMutating,canUseNativeActions:je,sourceKind:l.kind,unavailableRoot:ee,setDragSelection:ae,setDropTargetPath:se,requestMove:Ve,handleEntryKeyDown:qe,selectEntry:Q,toggleEntryExpansion:Ue,openFileEntry:He,openContextMenu:V.openContextMenu,submitInlineMutation:Z.submitInlineMutation,cancelInlineMutation:Z.cancelInlineMutation,onPickFolder:()=>void G(),onClearUnavailableRoot:Ae}),(0,p.jsx)(_,{pendingMove:A,contextMenu:V.contextMenu,isMoving:le,skipMoveConfirmChecked:pe,canReveal:!!l.revealPath,canRefresh:!!h,canMutate:Le,onSkipMoveConfirmCheckedChange:me,onCancelMove:()=>j(null),onConfirmMove:()=>{A&&(pe&&M(!0),Be(A))},onCopyContextPath:()=>{V.closeContextMenu(),$(`absolute`)},onCopyContextRelativePath:()=>{V.closeContextMenu(),$(`relative`)},onRevealContextPath:()=>{V.closeContextMenu(),Ke()},onRefreshContext:()=>{V.closeContextMenu(),Y(`manual`)},onCreateContextFile:()=>Z.requestCreateEntry(`file`),onCreateContextFolder:()=>Z.requestCreateEntry(`directory`),onRenameContextPath:()=>Z.requestRenameSelectedEntry()})]})}export{Le as FolderPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./MarkdownRenderer-DcIxpNcX.js";export{e as MarkdownRenderer};
|
|
@@ -1,15 +0,0 @@
|
|
|
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 g,T as te,a as ne,b as _,c as v,d as y,f as b,i as x,k as S,l as re,n as ie,o as ae,p as oe,r as se,s as ce,t as le,u as ue,w as de,x as fe,y as pe}from"./wiki-link-resolver-C197VhRP.js";function me(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 he(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var ge=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_e=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ve={};function ye(e,t){return((t||ve).jsx?_e:ge).test(e)}var be=/[ \t\n\f\r]/g;function xe(e){return typeof e==`object`?e.type===`text`?Se(e.value):!1:Se(e)}function Se(e){return e.replace(be,``)===``}var C=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};C.prototype.normal={},C.prototype.property={},C.prototype.space=void 0;function Ce(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new C(n,r,t)}function w(e){return e.toLowerCase()}var T=class{constructor(e,t){this.attribute=t,this.property=e}};T.prototype.attribute=``,T.prototype.booleanish=!1,T.prototype.boolean=!1,T.prototype.commaOrSpaceSeparated=!1,T.prototype.commaSeparated=!1,T.prototype.defined=!1,T.prototype.mustUseProperty=!1,T.prototype.number=!1,T.prototype.overloadedBoolean=!1,T.prototype.property=``,T.prototype.spaceSeparated=!1,T.prototype.space=void 0;var we=e({boolean:()=>E,booleanish:()=>D,commaOrSpaceSeparated:()=>M,commaSeparated:()=>j,number:()=>k,overloadedBoolean:()=>O,spaceSeparated:()=>A}),Te=0,E=N(),D=N(),O=N(),k=N(),A=N(),j=N(),M=N();function N(){return 2**++Te}var Ee=Object.keys(we),De=class extends T{constructor(e,t,n,r){let i=-1;if(super(e,t),Oe(this,`space`,r),typeof n==`number`)for(;++i<Ee.length;){let e=Ee[i];Oe(this,Ee[i],(n&we[e])===we[e])}}};De.prototype.defined=!0;function Oe(e,t,n){n&&(e[t]=n)}function P(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new De(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[w(r)]=r,n[w(a.attribute)]=r}return new C(t,n,e.space)}var ke=P({properties:{ariaActiveDescendant:null,ariaAtomic:D,ariaAutoComplete:null,ariaBusy:D,ariaChecked:D,ariaColCount:k,ariaColIndex:k,ariaColSpan:k,ariaControls:A,ariaCurrent:null,ariaDescribedBy:A,ariaDetails:null,ariaDisabled:D,ariaDropEffect:A,ariaErrorMessage:null,ariaExpanded:D,ariaFlowTo:A,ariaGrabbed:D,ariaHasPopup:null,ariaHidden:D,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:A,ariaLevel:k,ariaLive:null,ariaModal:D,ariaMultiLine:D,ariaMultiSelectable:D,ariaOrientation:null,ariaOwns:A,ariaPlaceholder:null,ariaPosInSet:k,ariaPressed:D,ariaReadOnly:D,ariaRelevant:null,ariaRequired:D,ariaRoleDescription:A,ariaRowCount:k,ariaRowIndex:k,ariaRowSpan:k,ariaSelected:D,ariaSetSize:k,ariaSort:null,ariaValueMax:k,ariaValueMin:k,ariaValueNow:k,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Ae(e,t){return t in e?e[t]:t}function je(e,t){return Ae(e,t.toLowerCase())}var Me=P({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:j,acceptCharset:A,accessKey:A,action:null,allow:null,allowFullScreen:E,allowPaymentRequest:E,allowUserMedia:E,alt:null,as:null,async:E,autoCapitalize:null,autoComplete:A,autoFocus:E,autoPlay:E,blocking:A,capture:null,charSet:null,checked:E,cite:null,className:A,cols:k,colSpan:null,content:null,contentEditable:D,controls:E,controlsList:A,coords:k|j,crossOrigin:null,data:null,dateTime:null,decoding:null,default:E,defer:E,dir:null,dirName:null,disabled:E,download:O,draggable:D,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:E,formTarget:null,headers:A,height:k,hidden:O,high:k,href:null,hrefLang:null,htmlFor:A,httpEquiv:A,id:null,imageSizes:null,imageSrcSet:null,inert:E,inputMode:null,integrity:null,is:null,isMap:E,itemId:null,itemProp:A,itemRef:A,itemScope:E,itemType:A,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:E,low:k,manifest:null,max:null,maxLength:k,media:null,method:null,min:null,minLength:k,multiple:E,muted:E,name:null,nonce:null,noModule:E,noValidate:E,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:E,optimum:k,pattern:null,ping:A,placeholder:null,playsInline:E,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:E,referrerPolicy:null,rel:A,required:E,reversed:E,rows:k,rowSpan:k,sandbox:A,scope:null,scoped:E,seamless:E,selected:E,shadowRootClonable:E,shadowRootDelegatesFocus:E,shadowRootMode:null,shape:null,size:k,sizes:null,slot:null,span:k,spellCheck:D,src:null,srcDoc:null,srcLang:null,srcSet:null,start:k,step:null,style:null,tabIndex:k,target:null,title:null,translate:null,type:null,typeMustMatch:E,useMap:null,value:D,width:k,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:A,axis:null,background:null,bgColor:null,border:k,borderColor:null,bottomMargin:k,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:E,declare:E,event:null,face:null,frame:null,frameBorder:null,hSpace:k,leftMargin:k,link:null,longDesc:null,lowSrc:null,marginHeight:k,marginWidth:k,noResize:E,noHref:E,noShade:E,noWrap:E,object:null,profile:null,prompt:null,rev:null,rightMargin:k,rules:null,scheme:null,scrolling:D,standby:null,summary:null,text:null,topMargin:k,valueType:null,version:null,vAlign:null,vLink:null,vSpace:k,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:E,disableRemotePlayback:E,prefix:null,property:null,results:k,security:null,unselectable:null},space:`html`,transform:je}),Ne=P({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:M,accentHeight:k,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:k,amplitude:k,arabicForm:null,ascent:k,attributeName:null,attributeType:null,azimuth:k,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:k,by:null,calcMode:null,capHeight:k,className:A,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:k,diffuseConstant:k,direction:null,display:null,dur:null,divisor:k,dominantBaseline:null,download:E,dx:null,dy:null,edgeMode:null,editable:null,elevation:k,enableBackground:null,end:null,event:null,exponent:k,externalResourcesRequired:null,fill:null,fillOpacity:k,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:j,g2:j,glyphName:j,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:k,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:k,horizOriginX:k,horizOriginY:k,id:null,ideographic:k,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:k,k,k1:k,k2:k,k3:k,k4:k,kernelMatrix:M,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:k,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:k,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:k,overlineThickness:k,paintOrder:null,panose1:null,path:null,pathLength:k,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:A,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:k,pointsAtY:k,pointsAtZ:k,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:M,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:M,rev:M,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:M,requiredFeatures:M,requiredFonts:M,requiredFormats:M,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:k,specularExponent:k,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:k,strikethroughThickness:k,string:null,stroke:null,strokeDashArray:M,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:k,strokeOpacity:k,strokeWidth:null,style:null,surfaceScale:k,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:M,tabIndex:k,tableValues:null,target:null,targetX:k,targetY:k,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:M,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:k,underlineThickness:k,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:k,values:null,vAlphabetic:k,vMathematical:k,vectorEffect:null,vHanging:k,vIdeographic:k,version:null,vertAdvY:k,vertOriginX:k,vertOriginY:k,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:k,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Ae}),Pe=P({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()}}),Fe=P({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:je}),Ie=P({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Le={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`},Re=/[A-Z]/g,ze=/-[a-z]/g,Be=/^data[-\w.:]+$/i;function Ve(e,t){let n=w(t),r=t,i=T;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Be.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(ze,Ue);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!ze.test(e)){let n=e.replace(Re,He);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=De}return new i(r,t)}function He(e){return`-`+e.toLowerCase()}function Ue(e){return e.charAt(1).toUpperCase()}var We=Ce([ke,Me,Pe,Fe,Ie],`html`),F=Ce([ke,Ne,Pe,Fe,Ie],`svg`);function Ge(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Ke(e){return e.join(` `).trim()}var qe=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 te(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);h=~n?e.length-n:h+e.length}function ne(){var e={line:l,column:h};return function(t){return t.position=new _(e),b(),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 te(r),e=e.slice(r.length),n}}function b(){y(i)}function x(e){var t;for(e||=[];t=S();)t!==!1&&e.push(t);return e}function S(){var t=ne();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,te(r),e=e.slice(n),h+=2,t({type:m,comment:r})}}function re(){var e=ne(),t=y(a);if(t){if(S(),!y(o))return v(`property missing ':'`);var r=y(s),i=e({type:ee,property:g(t[0].replace(n,p)),value:r?g(r[0].replace(n,p)):p});return y(c),i}}function ie(){var e=[];x(e);for(var t;t=re();)t!==!1&&(e.push(t),x(e));return e}return b(),ie()}function g(e){return e?e.replace(l,p):p}t.exports=h})),Je=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(qe());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}})),Ye=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))}})),Xe=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Je()),r=Ye();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})),Ze=$e(`end`),Qe=$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=Qe(e),n=Ze(e);if(t&&n)return{start:t,end:n}}var tt=t(Xe(),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`?F:We,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=F,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`?!xe(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=F,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=Qe(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=Ve(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?he(n):Ke(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?Le[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=ye(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=ye(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&&S(e.charCodeAt(n+1))&&S(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=Qe(t.children[1]),o=Ze(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 fe().use(ee).use(n).use(Cn,r).use(t)}function An(e){let t=e.children||``,n=new g;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=Ve(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?Ge(r):i.commaSeparated?me(r):i.commaOrSpaceSeparated?Ge(me(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===``||w(n)===w(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(We,`div`),Wn=Fn(F,`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){te(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),de})}}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){pe(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 ie(e)}function ri(e,t,n){if(!e)return[e];let r=!!t.notes?.length;if(t.lookup.size===0&&!r)return[e];le.lastIndex=0;let i=[],a=0,o=0,s;for(;(s=le.exec(e))!==null;){let r=s.index,c=r+s[0].length;if(se(e,r))continue;let l=t.lookup.get(s[0])??x(s[0],t.outgoing,t.notes,r);if(!l)continue;r>a&&i.push(e.slice(a,r));let u=ne(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=ae(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=>{};function fi(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=e=>t=>{let{children:r,node:i,className:a,id:o,style:s}=t,c=ii(r,n,e);return(0,J.createElement)(e,{className:a,id:o,style:s},c)},i=e=>t=>{let{children:r,node:i,className:a,style:o,align:s}=t,c=ii(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})},a={a:({href:e,children:t,node:n,...r})=>{let i=typeof e==`string`&&ce(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`?re(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:r(`p`),li:r(`li`),h1:r(`h1`),h2:r(`h2`),h3:r(`h3`),h4:r(`h4`),h5:r(`h5`),h6:r(`h6`),blockquote:r(`blockquote`),td:r(`td`),th:r(`th`),em:r(`em`),strong:r(`strong`),del:r(`del`)};return e.tableMode===`linear`&&(a.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})},a.thead=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-head`,n),style:r,children:e}),a.tbody=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-body`,n),style:r,children:e}),a.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}),a.th=i(`th`),a.td=i(`td`)),(0,q.jsx)(On,{skipHtml:!0,urlTransform:ue,remarkPlugins:[oe,Jr,b],rehypePlugins:[[Gr,v],Ar],components:a,children:t})}export{Yr as n,fi as t};
|