From 4024df0e16417fea94482a07aa0d7325c87461f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=98=89=E4=BC=9F?= <202383014@uibe.edu.cn> Date: Wed, 23 Sep 2026 15:11:46 +0800 Subject: [PATCH 1/5] feat(runtime): bound active child executions per session --- README.md | 8 +- SETUP.md | 5 +- docs/design/README.md | 1 + .../SESSION_CHILD_EXECUTION_ADMISSION.md | 50 ++++ extensions/setup/index.ts | 22 ++ .../shared/child-execution-admission.ts | 248 ++++++++++++++++++ extensions/shared/setup-config.ts | 24 ++ extensions/shared/web-observer-registry.ts | 10 +- extensions/subagents/index.ts | 37 ++- extensions/subagents/src/manager.ts | 125 ++++++++- extensions/subagents/src/ui/takeover.ts | 8 +- extensions/workflows/controller.ts | 16 ++ extensions/workflows/index.ts | 19 ++ scripts/check-config-contract.mjs | 16 ++ tests/extensions/setup/index.test.ts | 10 + .../shared/child-execution-admission.test.ts | 202 ++++++++++++++ tests/extensions/shared/setup-config.test.ts | 27 ++ tests/extensions/subagents/manager.test.ts | 134 ++++++++-- tests/extensions/suggestions/config.test.ts | 6 +- tests/extensions/workflows/controller.test.ts | 24 ++ tests/support/subagents-stub.ts | 3 + tests/web/observer-registry.test.ts | 21 ++ web/ui/src/features/activity/ActivityBar.tsx | 13 +- 23 files changed, 992 insertions(+), 37 deletions(-) create mode 100644 docs/design/SESSION_CHILD_EXECUTION_ADMISSION.md create mode 100644 extensions/shared/child-execution-admission.ts create mode 100644 tests/extensions/shared/child-execution-admission.test.ts diff --git a/README.md b/README.md index d12f6a75..a2afb68f 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ subagent_spawn({ - 默认继承父会话的 Provider 与模型;用户可明确指定 Thinking Level,否则模型根据角色建议、任务难度与目标模型实际支持的档位选择; - 继承父会话当前启用且允许委派的工具、Skills 和项目说明;目标目录的项目扩展按其自身 Trust 决策加载; -- 最多 4 个模型发起的 Subagent 并发运行,结束后自动回传; +- 最多 4 个模型发起的 Direct Subagent 并发运行,结束后自动回传;BTW 仍有独立的 2 个本地槽位。可选的 Session child execution limit 会让 Workflow、Direct 与 BTW 在各自本地限制之外共享一个活动执行上限;它不计 dormant child、父 Session、Terminal、Provider 请求或费用; - 可 `check`、`wait`、`cancel`,也可用 `subagent_send` 继续同一子会话; - 输入框下方显示实时摘要,空输入时按 `↓` 聚焦,`Enter` 或 `→` 打开管理界面。 @@ -304,7 +304,7 @@ return agent("Synthesize the verified findings", { | `pipeline()` | 每个 item 完成上阶段后立即进入下一阶段;多阶段 fan-out 的默认选择 | | `parallel()` | 并发 barrier;只在下一阶段确实需要全部结果时使用 | -Workflow 默认并发 8 个 Agent,单次最多 128 次调用;可配置到 64 和 1024。前台运行可实时查看,后台运行完成后自动回传;`/workflows` 展示阶段、Agent、Transcript、Graph、用量与产物。普通子代理和 Workflow 都使用 Pi 原生传输超时与重试,不再用额外的 45 秒无可见输出计时器打断思考、排队或重试。显式取消和 Session 清理仍有界,原生 Provider 错误保留在 Child outcome 中。并发上限不代表账号的服务端速率额度;429 仍按 Pi 原生重试策略处理。 +Workflow 默认并发 8 个 Agent,单次最多 128 次调用;可配置到 64 和 1024。可选的 Session child execution limit 是另一层跨入口的活动 child 槽位:未配置时完全保持原有独立并发行为,配置后 Workflow / Direct / BTW 都先满足各自本地限制,再按 FIFO 竞争同一个顶层 Pi Session 的上限。它不会把 Workflow 默认 8 变成 Session 默认值,也不治理 Terminal、429、费用、token 或内存。前台运行可实时查看,后台运行完成后自动回传;`/workflows` 展示阶段、Agent、Transcript、Graph、用量与产物。普通子代理和 Workflow 都使用 Pi 原生传输超时与重试,不再用额外的 45 秒无可见输出计时器打断思考、排队或重试。显式取消和 Session 清理仍有界,原生 Provider 错误保留在 Child outcome 中。并发上限不代表账号的服务端速率额度;429 仍按 Pi 原生重试策略处理。 --- @@ -444,12 +444,13 @@ macOS/Linux arm64 与 x64 缺少二进制时,OpenPI 会从官方 Release 下 无参数时,OpenPI 展示当前状态并引导修改;带自然语言时只改指定项: - + ```text /openpi-setup 开启下一步预测,选择 Registry 里的轻量模型,minimal 推理 /openpi-setup 让模型在合适时自主发现并采用 OpenPI 能力 /openpi-setup workflow 同时跑 16 个 agent,总调用最多 256 +/openpi-setup 当前 Pi Session 的 Workflow、Direct 和 BTW 最多同时运行 6 个 child /openpi-setup Web 主题跟随系统 /openpi-setup Web 使用深色主题 /openpi-setup Web 使用雾青主题,聊天宽度设为 960px @@ -476,6 +477,7 @@ Footer 布局以 `footerLines` 作为唯一持久化格式。旧版 `footerItems | Capability discovery | `explicit`;`adaptive` 必须显式开启 | | Next-action Suggestion | 关闭;启用时显式选择 Registry 模型与 reasoning | | Workflow 并发 / 总调用 | 8 / 128;硬上限 64 / 1024 | +| Session child execution slots | 关闭;显式设为 1-64 后由 Workflow / Direct / BTW 共享 | | Web 主题 | `system`;另有 `light` / `dark` / `mist` / `rose` / `pine` | | Web 聊天宽度 / 聊天字号 | 820px / 14px;范围 820-2000px / 12-24px | | Web 思考块 | 默认折叠 | diff --git a/SETUP.md b/SETUP.md index 360568d6..c7eed3e0 100644 --- a/SETUP.md +++ b/SETUP.md @@ -55,6 +55,7 @@ Use the single canonical package-owned command. `/my-pi-setup` remains a compati /openpi-setup 开启下一步预测,使用 seal/deepseek-v4-flash,关闭推理 /openpi-setup 关闭下一步预测 /openpi-setup workflow 同时跑 16 个 agent,总任务最多 256 个 +/openpi-setup 当前 Pi Session 的 Workflow、Direct 和 BTW 最多同时运行 6 个 child /openpi-setup Web theme follows the system /openpi-setup use dark theme in OpenPI Web /openpi-setup use the mist theme with 960px chat width @@ -72,7 +73,7 @@ Use the single canonical package-owned command. `/my-pi-setup` remains a compati /openpi-setup 清除 explorer 的模型,让它继承父模型 ``` -Capability discovery defaults to `explicit`, preserving the zero-resident OpenPI tool surface until the user asks for a capability. The case-insensitive English words `subagent` and `workflow` are reserved authorization words: entering either word is sufficient to load its capability group, and the interactive editor shows it in Claude Code-style lavender before submission, with a darker purple fallback for light themes. This makes discussion that contains either English word an intentional opt-in tradeoff; conditional and negated clauses remain inert, while Chinese capability names still require a recognized action request. `adaptive` is an explicit opt-in that keeps only `openpi_load_tools` visible and allows the model to load a useful group on its own; because this can start Subagents, Workflows, or background processes, normal permission and configured concurrency/call limits still apply. Changing the setting updates the current Session immediately, while already loaded groups remain stable for that Session. Accepted Suggestion text is classified only after it becomes real editor input. The visual feedback and runtime activation share one fail-closed intent classifier. Next-action suggestions default to off. Run `/openpi-setup` to explicitly choose an available model and reasoning level. After a fully settled main-agent run, one suggestion may appear as dim inline text on the first row of an empty editor; reserved cells at the row end keep CJK IME preedit from overwriting it. `Right` accepts it into the editor without submitting, while any other editor input dismisses it. Suggestions are ephemeral and never enter session history or model context. Workflows default to 8 concurrent agents and 128 total agent calls per run; configurable hard maxima are 64 and 1024. The large decorative header defaults off and the custom dashboard footer defaults on with a one-line plain layout (`model context |flex| git pr cwd`; `thinking`, `cache`, `cost`, and `throughput` remain opt-in metrics). Footer presets are `powerline`, `powerline-mono`, and `compact`; style can also be set independently to `plain`, `powerline`, or `powerline-mono`. Custom layouts use a 2D `footerLines` array with at most one `flex` per row for left/right alignment. Nerd Font affects powerline separator glyphs (``) and adds Codex-style outline icons to compact read, terminal, edit, search, and directory activity rows; all accompanying text remains readable without it. Footer metrics use one Codicon outline family (`` model, `` context, and `` directory) plus `⎇` for the branch. A Nerd Font containing Codicons renders them as designed; without one, the text labels remain readable even if an icon falls back to an empty box. Footer changes apply immediately in the active TUI session. Subagent results default to a compact status summary; full mode remains available as a per-user setting, and `app.tools.expand` (`Ctrl+O` by default) reveals the available child report. Ordinary `read`, `grep`, `find`, and `ls` operations render as one-line semantic activity summaries. Bash and Write/Edit default to the same activity-row projection, showing the target, running/success/failure state, and useful line or diff counts without replaying stdout or previews. Select full independently for Bash or Write/Edit to keep Pi's native rendering expanded. `app.tools.expand` temporarily restores the native arguments, output, errors, diff, timing, images, truncation notices, and full-output metadata; it never changes Session history or model context. An optional post-edit command is off by default: set one (for example `npm run format`, maximum 500 characters) and it runs once in the background after each interactive-TUI turn with successful Write/Edit operations, with failures reported as a notification. It deliberately does not guess whether arbitrary Bash commands changed files. Built-in Agent roles `explorer`, `implementer`, `reviewer`, and `advisor` are shared by `subagent_spawn.agent_type` and Workflow `agent(..., { agent_type })`; all inherit the parent model and currently active child-eligible tools by default. Explicit custom role `tools` lists narrow that surface; omitted lists inherit it. Built-in investigator roles suggest read-only work but do not impose a read-only tool boundary outside Plan Mode. Existing role files are preserved, so an old global `explorer.md` allowlist continues to exclude Bash/network tools until deliberately edited. `/openpi-setup` may assign a currently available Registry model to any subset; clearing one returns it to inheritance and omitted roles stay unchanged. Model precedence is explicit call > selected role-file model > setup assignment > parent inheritance; effort is explicit call > selected role > parent. A trusted project `.pi/agents/.md` overrides global `~/.pi/agent/agents/.md`, which overrides the complete built-in role definition; overrides are diagnosed. Role-model changes apply to the next spawn or Workflow agent call without reload. Configuration is stored privately at `~/.pi/agent/my-pi-setup.json`. +Capability discovery defaults to `explicit`, preserving the zero-resident OpenPI tool surface until the user asks for a capability. The case-insensitive English words `subagent` and `workflow` are reserved authorization words: entering either word is sufficient to load its capability group, and the interactive editor shows it in Claude Code-style lavender before submission, with a darker purple fallback for light themes. This makes discussion that contains either English word an intentional opt-in tradeoff; conditional and negated clauses remain inert, while Chinese capability names still require a recognized action request. `adaptive` is an explicit opt-in that keeps only `openpi_load_tools` visible and allows the model to load a useful group on its own; because this can start Subagents, Workflows, or background processes, normal permission and configured concurrency/call limits still apply. Changing the setting updates the current Session immediately, while already loaded groups remain stable for that Session. Accepted Suggestion text is classified only after it becomes real editor input. The visual feedback and runtime activation share one fail-closed intent classifier. Next-action suggestions default to off. Run `/openpi-setup` to explicitly choose an available model and reasoning level. After a fully settled main-agent run, one suggestion may appear as dim inline text on the first row of an empty editor; reserved cells at the row end keep CJK IME preedit from overwriting it. `Right` accepts it into the editor without submitting, while any other editor input dismisses it. Suggestions are ephemeral and never enter session history or model context. Workflows default to 8 concurrent agents and 128 total agent calls per run; configurable hard maxima are 64 and 1024. A separate `child_execution_limit` is off by default. When explicitly set to 1-64, it is a FIFO cap on active child executions shared only by Workflow, Direct Subagent, and BTW within one top-level Pi Session; their existing Workflow 8/local call limits, Direct pool 4, and BTW pool 2 remain in force. A dormant child, parent Session, Background Terminal, model request, token, cost, and provider quota do not consume this limit. `/subagents` shows the shared limit, held/queued counts, origin counts, and generic blocking reason without exposing task text. Reducing the configured limit below live held slots is rejected and rolled back; cancellation and shutdown reject queued attempts but do not claim an active child has stopped before its actual terminal lifecycle settles. The large decorative header defaults off and the custom dashboard footer defaults on with a one-line plain layout (`model context |flex| git pr cwd`; `thinking`, `cache`, `cost`, and `throughput` remain opt-in metrics). Footer presets are `powerline`, `powerline-mono`, and `compact`; style can also be set independently to `plain`, `powerline`, or `powerline-mono`. Custom layouts use a 2D `footerLines` array with at most one `flex` per row for left/right alignment. Nerd Font affects powerline separator glyphs (``) and adds Codex-style outline icons to compact read, terminal, edit, search, and directory activity rows; all accompanying text remains readable without it. Footer metrics use one Codicon outline family (`` model, `` context, and `` directory) plus `⎇` for the branch. A Nerd Font containing Codicons renders them as designed; without one, the text labels remain readable even if an icon falls back to an empty box. Footer changes apply immediately in the active TUI session. Subagent results default to a compact status summary; full mode remains available as a per-user setting, and `app.tools.expand` (`Ctrl+O` by default) reveals the available child report. Ordinary `read`, `grep`, `find`, and `ls` operations render as one-line semantic activity summaries. Bash and Write/Edit default to the same activity-row projection, showing the target, running/success/failure state, and useful line or diff counts without replaying stdout or previews. Select full independently for Bash or Write/Edit to keep Pi's native rendering expanded. `app.tools.expand` temporarily restores the native arguments, output, errors, diff, timing, images, truncation notices, and full-output metadata; it never changes Session history or model context. An optional post-edit command is off by default: set one (for example `npm run format`, maximum 500 characters) and it runs once in the background after each interactive-TUI turn with successful Write/Edit operations, with failures reported as a notification. It deliberately does not guess whether arbitrary Bash commands changed files. Built-in Agent roles `explorer`, `implementer`, `reviewer`, and `advisor` are shared by `subagent_spawn.agent_type` and Workflow `agent(..., { agent_type })`; all inherit the parent model and currently active child-eligible tools by default. Explicit custom role `tools` lists narrow that surface; omitted lists inherit it. Built-in investigator roles suggest read-only work but do not impose a read-only tool boundary outside Plan Mode. Existing role files are preserved, so an old global `explorer.md` allowlist continues to exclude Bash/network tools until deliberately edited. `/openpi-setup` may assign a currently available Registry model to any subset; clearing one returns it to inheritance and omitted roles stay unchanged. Model precedence is explicit call > selected role-file model > setup assignment > parent inheritance; effort is explicit call > selected role > parent. A trusted project `.pi/agents/.md` overrides global `~/.pi/agent/agents/.md`, which overrides the complete built-in role definition; overrides are diagnosed. Role-model changes apply to the next spawn or Workflow agent call without reload. Configuration is stored privately at `~/.pi/agent/my-pi-setup.json`. OpenPI Web appearance defaults to the `system` theme, 820px chat width, 14px chat font size, and collapsed thinking blocks. `light`, `dark`, `mist`, `rose`, and `pine` are explicit theme choices. The browser consumes every appearance value from each authoritative snapshot without writing a competing local preference. @@ -83,7 +84,7 @@ native `PI_CLEAR_ON_SHRINK=0` setting remains an explicit opt-out. Legacy `footerItems` is accepted and migrated at the input boundary, but new setup writes persist only canonical `footerLines`. Configurations written by this version are not guaranteed to retain their Footer layout when read by an older OpenPI version. - + ### Post-edit lifecycle diff --git a/docs/design/README.md b/docs/design/README.md index 320b65b3..d72ed267 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -20,5 +20,6 @@ These records predate [`Decision 0001`](../decisions/0001-documentation-and-evid - [`COMPLETION_INBOX.md`](COMPLETION_INBOX.md) — shared owner, epoch, consumption, retry, and receipt contract for background completions - [`WEB_STRUCTURED_QUESTIONS.md`](WEB_STRUCTURED_QUESTIONS.md) — Web `ask_user` ownership, reviewed answers, bounded waits and browser validation - [`WEB_INTERACTION_UI.md`](WEB_INTERACTION_UI.md) — #562 native command feedback, Plan controls, human handoff and streaming/cancellation corrections +- [`SESSION_CHILD_EXECUTION_ADMISSION.md`](SESSION_CHILD_EXECUTION_ADMISSION.md) — #159 session-local admission for active Workflow, Direct Subagent, and BTW executions 开发与热更新流程见 [`docs/development/OPENPI_WEB_DEVELOPMENT.md`](../development/OPENPI_WEB_DEVELOPMENT.md)。 diff --git a/docs/design/SESSION_CHILD_EXECUTION_ADMISSION.md b/docs/design/SESSION_CHILD_EXECUTION_ADMISSION.md new file mode 100644 index 00000000..46cd287a --- /dev/null +++ b/docs/design/SESSION_CHILD_EXECUTION_ADMISSION.md @@ -0,0 +1,50 @@ +# Session child-execution admission + +Issue: [#159](https://github.com/openpi-dev/openpi/issues/159) + +## Scope and decision + +The first implementation phase provides an opt-in, session-local admission +limit for *active child executions*. It applies to Workflow runs, Direct +Subagent executions, and BTW executions that share one top-level Pi +`SessionManager`. The parent Session does not consume a slot. + +This is deliberately not a process-wide scheduler and does not account for +Background Terminal processes, worktrees, artifacts, provider quotas, tokens, +cost, memory, or HTTP 429 responses. It also does not alter model selection, +thinking level, tools, Trust, or child permission intersection. + +## Contract + +`childExecutions.maxActive` is disabled by default. When explicitly configured +to an integer from 1 through 64, it limits only concurrently active child +executions for that top-level Session. Workflow's run-local concurrency and +call limits, Direct Subagent's local pool of four, and BTW's local pool of two +remain in force. + +Each entry first reserves its pre-existing local allowance and then acquires +the shared FIFO admission lease before constructing or restarting an expensive +child execution. The reverse order is never used, avoiding a local/shared +lock cycle. Queuing is bounded, abortable, and reports aggregate origin counts +without exposing task content. + +An active child releases its lease only after terminal evidence. A cancel or +shutdown request alone is not terminal evidence: if the underlying stop times +out, the lease is retained fail-closed rather than allowing an unproven extra +execution. Leases are idempotent and attempt-scoped, so a stale completion +cannot release a later restart. Dormant children hold no lease and acquire one +again when sent new work. + +## Projections + +The same admission snapshot is the runtime fact used by the subagent TUI and +the Web capability projection. It contains the configured limit, held and +queued totals, aggregate origin counts, and a generic blocking reason; it +never includes queued task prompts or result text. + +## Validation boundary + +The implementation is tested with controllable child runtimes, promises, and +abort signals rather than provider calls. Its tests prove admission and +lifecycle behavior; they do not claim performance, cost, token, memory, or +429 improvements. diff --git a/extensions/setup/index.ts b/extensions/setup/index.ts index c09d769e..40efd46b 100644 --- a/extensions/setup/index.ts +++ b/extensions/setup/index.ts @@ -25,6 +25,7 @@ import { inspectSetupConfig, MAX_WEB_CHAT_FONT_SIZE, MAX_WEB_CHAT_WIDTH, + MAX_SESSION_CHILD_EXECUTION_LIMIT, MAX_WORKFLOW_AGENT_CALLS, MAX_WORKFLOW_CONCURRENCY, MIN_WEB_CHAT_FONT_SIZE, @@ -387,6 +388,21 @@ export default function openPiSetup(pi: ExtensionAPI) { "Maximum total agent() calls in each workflow (default 128, hard maximum 1024). Omit to preserve the current value.", }), ), + child_execution_limit: Type.Optional( + Type.Union( + [ + Type.Integer({ + minimum: 1, + maximum: MAX_SESSION_CHILD_EXECUTION_LIMIT, + }), + Type.Null(), + ], + { + description: + "Optional maximum active child executions shared by Workflow, Direct Subagent, and BTW in this top-level Pi Session (1-64). This is off by default and does not change workflow's own concurrency. Set null to disable the shared admission limit. Omit to preserve the current value.", + }, + ), + ), ui_show_header: Type.Optional( Type.Boolean({ description: @@ -564,6 +580,12 @@ export default function openPiSetup(pi: ExtensionAPI) { params.workflow_max_agent_calls ?? current.workflows.maxAgentCalls, }, + childExecutions: + params.child_execution_limit === undefined + ? current.childExecutions + : params.child_execution_limit === null + ? {} + : { maxActive: params.child_execution_limit }, ui: { webTheme: (params.ui_web_theme as WebTheme | undefined) ?? diff --git a/extensions/shared/child-execution-admission.ts b/extensions/shared/child-execution-admission.ts new file mode 100644 index 00000000..48534834 --- /dev/null +++ b/extensions/shared/child-execution-admission.ts @@ -0,0 +1,248 @@ +/** + * Session-local admission for active child executions. + * + * This deliberately counts execution attempts, not child Session objects: + * settled Direct children may remain available for a later `send`, but they do + * not retain a permit. The parent `SessionManager` is the owner identity, so a + * second top-level Pi Session gets an independent pool even though extensions + * share this module instance in one process. + */ + +export const MAX_CHILD_EXECUTION_QUEUE = 256; + +export type ChildExecutionOrigin = "workflow" | "direct" | "btw"; + +export interface ChildExecutionAdmissionOptions { + /** Omit to keep the historical, unbounded behaviour. */ + readonly maxActive?: number; + /** A hard safety bound for waiters; production uses the exported default. */ + readonly maxQueued?: number; +} + +export interface ChildExecutionLease { + readonly origin: ChildExecutionOrigin; + /** Idempotent and scoped to this exact execution attempt. */ + release(): void; +} + +type OriginCounts = Record; + +export interface ChildExecutionAdmissionSnapshot { + readonly enabled: boolean; + readonly limit?: number; + readonly held: number; + readonly queued: number; + readonly heldByOrigin: OriginCounts; + readonly queuedByOrigin: OriginCounts; + /** Never contains a child prompt or other private task content. */ + readonly blockedReason?: string; +} + +export class ChildExecutionAdmissionAbortedError extends Error { + constructor(message = "Waiting for a child execution slot was aborted.") { + super(message); + this.name = "ChildExecutionAdmissionAbortedError"; + } +} + +export class ChildExecutionAdmissionQueueFullError extends Error { + constructor(maxQueued: number) { + super( + `Too many child executions are already waiting (maximum ${maxQueued}).`, + ); + this.name = "ChildExecutionAdmissionQueueFullError"; + } +} + +interface Waiter { + readonly origin: ChildExecutionOrigin; + readonly resolve: (lease: ChildExecutionLease) => void; + readonly reject: (error: Error) => void; + readonly signal?: AbortSignal; + abort?: () => void; +} + +const counts = (): OriginCounts => ({ workflow: 0, direct: 0, btw: 0 }); + +const abortError = (signal?: AbortSignal) => + new ChildExecutionAdmissionAbortedError( + signal?.reason instanceof Error + ? signal.reason.message + : "Waiting for a child execution slot was aborted.", + ); + +/** + * A FIFO semaphore with observable state. JavaScript turns make the check and + * claim atomic; a queued caller can never pass an older waiter. + */ +export class ChildExecutionAdmission { + private limit: number | undefined; + private readonly maxQueued: number; + private readonly held = new Map(); + private readonly waiters: Waiter[] = []; + private readonly listeners = new Set<() => void>(); + private nextAttempt = 0; + private closed = false; + + constructor(options: ChildExecutionAdmissionOptions = {}) { + this.limit = options.maxActive; + this.maxQueued = options.maxQueued ?? MAX_CHILD_EXECUTION_QUEUE; + } + + snapshot(): ChildExecutionAdmissionSnapshot { + const heldByOrigin = counts(); + for (const origin of this.held.values()) heldByOrigin[origin]++; + const queuedByOrigin = counts(); + for (const waiter of this.waiters) queuedByOrigin[waiter.origin]++; + return { + enabled: this.limit !== undefined, + ...(this.limit === undefined ? {} : { limit: this.limit }), + held: this.held.size, + queued: this.waiters.length, + heldByOrigin, + queuedByOrigin, + ...(this.waiters.length > 0 && this.limit !== undefined + ? { + blockedReason: `Waiting for a shared child execution slot (${this.held.size} active / ${this.limit} limit).`, + } + : {}), + }; + } + + subscribe(listener: () => void) { + this.listeners.add(listener); + return () => this.listeners.delete(listener); + } + + /** + * Apply a new package configuration without ever pretending live children + * stopped. Shrinking below currently held permits is rejected so setup's + * transactional rollback can preserve the old, truthful runtime contract. + */ + configure(options: ChildExecutionAdmissionOptions) { + if (options.maxActive !== undefined && options.maxActive < this.held.size) { + throw new Error( + `Cannot lower the session child execution limit below ${this.held.size} active child executions. Wait for them to settle first.`, + ); + } + this.limit = options.maxActive; + this.drain(); + this.notify(); + } + + acquire(origin: ChildExecutionOrigin, signal?: AbortSignal) { + if (signal?.aborted) return Promise.reject(abortError(signal)); + if (this.closed) + return Promise.reject( + new ChildExecutionAdmissionAbortedError( + "The parent Session is shutting down.", + ), + ); + // Disabled means unbounded, not unobserved. Keep an attempt-scoped lease + // for active work so a live setup change cannot enable a lower limit and + // silently ignore children that started while the feature was disabled. + if (this.limit === undefined) return Promise.resolve(this.claim(origin)); + + if (this.waiters.length === 0 && this.held.size < this.limit) { + return Promise.resolve(this.claim(origin)); + } + if (this.waiters.length >= this.maxQueued) { + return Promise.reject( + new ChildExecutionAdmissionQueueFullError(this.maxQueued), + ); + } + + return new Promise((resolve, reject) => { + const waiter: Waiter = { origin, resolve, reject, signal }; + const abort = () => { + const index = this.waiters.indexOf(waiter); + if (index < 0) return; + this.waiters.splice(index, 1); + signal?.removeEventListener("abort", abort); + reject(abortError(signal)); + this.notify(); + }; + waiter.abort = abort; + this.waiters.push(waiter); + signal?.addEventListener("abort", abort, { once: true }); + // A caller can abort between the first check and listener registration. + if (signal?.aborted) abort(); + else this.notify(); + }); + } + + /** Reject queued work; held work remains held until terminal evidence releases it. */ + shutdown() { + if (this.closed) return; + this.closed = true; + for (const waiter of this.waiters.splice(0)) { + waiter.signal?.removeEventListener("abort", waiter.abort!); + waiter.reject( + new ChildExecutionAdmissionAbortedError( + "The parent Session is shutting down.", + ), + ); + } + this.notify(); + } + + private claim(origin: ChildExecutionOrigin): ChildExecutionLease { + const attempt = ++this.nextAttempt; + this.held.set(attempt, origin); + this.notify(); + let released = false; + return { + origin, + release: () => { + if (released) return; + released = true; + // A stale callback has only its own attempt number, never the later + // attempt that happened to reuse the same child Session. + if (!this.held.delete(attempt)) return; + this.drain(); + this.notify(); + }, + }; + } + + private drain() { + if (this.closed) return; + while ( + (this.limit === undefined || this.held.size < this.limit) && + this.waiters.length > 0 + ) { + const waiter = this.waiters.shift()!; + waiter.signal?.removeEventListener("abort", waiter.abort!); + if (waiter.signal?.aborted) { + waiter.reject(abortError(waiter.signal)); + continue; + } + waiter.resolve(this.claim(waiter.origin)); + } + } + + private notify() { + for (const listener of [...this.listeners]) { + try { + listener(); + } catch { + // Read-model observers never own the runtime state machine. + } + } + } +} + +const sessionAdmissions = new WeakMap(); + +/** Return the one admission owner for this top-level Pi Session. */ +export function sessionChildExecutionAdmission( + sessionOwner: object, + options: ChildExecutionAdmissionOptions, +) { + let admission = sessionAdmissions.get(sessionOwner); + if (!admission) { + admission = new ChildExecutionAdmission(options); + sessionAdmissions.set(sessionOwner, admission); + } + return admission; +} diff --git a/extensions/shared/setup-config.ts b/extensions/shared/setup-config.ts index d7d8a05b..012d2618 100644 --- a/extensions/shared/setup-config.ts +++ b/extensions/shared/setup-config.ts @@ -149,6 +149,8 @@ export const DEFAULT_WORKFLOW_CONCURRENCY = 8; export const DEFAULT_WORKFLOW_MAX_AGENT_CALLS = 128; export const MAX_WORKFLOW_CONCURRENCY = 64; export const MAX_WORKFLOW_AGENT_CALLS = 1_024; +/** Opt-in session-wide limit; it deliberately does not inherit Workflow's 8. */ +export const MAX_SESSION_CHILD_EXECUTION_LIMIT = 64; /** Bound on the single post-edit command string. */ export const POST_EDIT_COMMAND_MAX_CHARS = 500; @@ -166,6 +168,10 @@ export interface MyPiSetupConfig { readonly concurrency: number; readonly maxAgentCalls: number; }; + /** Cross-entry runtime admission; omitted means preserve historical behaviour. */ + readonly childExecutions: { + readonly maxActive?: number; + }; readonly ui: { readonly webTheme: WebTheme; readonly webChatWidth: number; @@ -200,6 +206,7 @@ export const DEFAULT_SETUP_CONFIG: MyPiSetupConfig = { concurrency: DEFAULT_WORKFLOW_CONCURRENCY, maxAgentCalls: DEFAULT_WORKFLOW_MAX_AGENT_CALLS, }, + childExecutions: {}, ui: { webTheme: "system", webChatWidth: DEFAULT_WEB_CHAT_WIDTH, @@ -513,6 +520,9 @@ export function parseSetupConfig(value: unknown): MyPiSetupConfig { : undefined; const workflows = isRecord(value.workflows) ? value.workflows : {}; + const childExecutions = isRecord(value.childExecutions) + ? value.childExecutions + : {}; const ui = isRecord(value.ui) ? value.ui : {}; const subagents = isRecord(value.subagents) ? value.subagents : {}; const footer = parseUiFooter(ui); @@ -538,6 +548,14 @@ export function parseSetupConfig(value: unknown): MyPiSetupConfig { MAX_WORKFLOW_AGENT_CALLS, ), }, + childExecutions: { + ...(typeof childExecutions.maxActive === "number" && + Number.isInteger(childExecutions.maxActive) && + childExecutions.maxActive >= 1 && + childExecutions.maxActive <= MAX_SESSION_CHILD_EXECUTION_LIMIT + ? { maxActive: childExecutions.maxActive } + : {}), + }, ui: { webTheme: isWebTheme(ui.webTheme) ? ui.webTheme : "system", webChatWidth: boundedIntegerRange( @@ -627,6 +645,9 @@ const setupShape: ConfigShape = { concurrency: integerBetween(1, MAX_WORKFLOW_CONCURRENCY), maxAgentCalls: integerBetween(1, MAX_WORKFLOW_AGENT_CALLS), }, + childExecutions: { + maxActive: integerBetween(1, MAX_SESSION_CHILD_EXECUTION_LIMIT), + }, ui: { webTheme: isWebTheme, webChatWidth: integerBetween(MIN_WEB_CHAT_WIDTH, MAX_WEB_CHAT_WIDTH), @@ -1355,6 +1376,9 @@ export function formatSetupConfig(config = loadSetupConfig()) { `Capability discovery: ${config.capabilities.discovery}`, suggestions, `Workflows: ${config.workflows.concurrency} concurrent agents · ${config.workflows.maxAgentCalls} total calls`, + config.childExecutions.maxActive === undefined + ? "Session child executions: unbounded (disabled)" + : `Session child executions: ${config.childExecutions.maxActive} active slots shared by Workflow, Direct Subagent, and BTW`, `UI: Web theme ${config.ui.webTheme} · chat ${config.ui.webChatWidth}px / ${config.ui.webChatFontSize}px / thinking ${config.ui.webExpandThinking ? "expanded" : "collapsed"} · large header ${config.ui.showHeader ? "on" : "off"} · custom footer ${footer}`, `Subagent results: ${config.ui.subagentResultDisplay === "full" ? "full by default" : "compact status summary (Ctrl+O expands full output)"}`, `Bash operations: ${config.ui.bashToolDisplay === "full" ? "expanded by default" : "one-line activity summary (Ctrl+O restores native evidence)"}`, diff --git a/extensions/shared/web-observer-registry.ts b/extensions/shared/web-observer-registry.ts index 1d5a637b..2efaf848 100644 --- a/extensions/shared/web-observer-registry.ts +++ b/extensions/shared/web-observer-registry.ts @@ -4,6 +4,7 @@ import type { TranscriptItem, TranscriptPart, } from "../subagents/src/domain.ts"; +import type { ChildExecutionAdmissionSnapshot } from "./child-execution-admission.ts"; export type WebCapabilityKind = | "subagents" @@ -145,6 +146,8 @@ export interface WebCapabilityProjection< readonly omitted: number; /** Records were omitted or a user-visible string was shortened. */ readonly truncated: boolean; + /** Session-local child admission state, never a task prompt or transcript. */ + readonly childExecutionAdmission?: ChildExecutionAdmissionSnapshot; } export interface WebCapabilitySnapshot { @@ -286,8 +289,9 @@ export function projectSubagentCapability( readonly createdAt: number; readonly settledAt?: number; }[], + childExecutionAdmission?: ChildExecutionAdmissionSnapshot, ): WebCapabilityProjection { - return boundedActivityProjection(source, (value) => { + const projection = boundedActivityProjection(source, (value) => { const id = boundedActivityText(value.id); const title = boundedActivityText(value.title); return { @@ -305,6 +309,10 @@ export function projectSubagentCapability( truncated: id.truncated || title.truncated, }; }); + return { + ...projection, + ...(childExecutionAdmission ? { childExecutionAdmission } : {}), + }; } /** Project only manager-owned display data; never load child session files. */ diff --git a/extensions/subagents/index.ts b/extensions/subagents/index.ts index 90d1c0f6..f98c255c 100644 --- a/extensions/subagents/index.ts +++ b/extensions/subagents/index.ts @@ -51,6 +51,10 @@ import { unreadActivityCounts, } from "../shared/activity-status.ts"; import { sanitizeText } from "../shared/agent-transcript.ts"; +import { + sessionChildExecutionAdmission, + type ChildExecutionAdmission, +} from "../shared/child-execution-admission.ts"; import { BelowEditorNavigationEditor, BelowEditorStripState, @@ -60,6 +64,7 @@ import { inheritedChildToolAllowlist, resolveStandaloneChildProjectTrust, } from "../shared/child-session.ts"; +import { onSetupApply } from "../shared/setup-apply.ts"; import { completionOwnerFor } from "../shared/completion-inbox.ts"; import { formatContextUtilization } from "../shared/context-utilization.ts"; import { @@ -511,6 +516,7 @@ export default function ( options.getResultDisplay ?? (() => loadSetupConfig().ui.subagentResultDisplay); let runtime: SubagentRuntime | undefined; + let admission: ChildExecutionAdmission | undefined; let managerPromise: Promise | undefined; let restoredIdCounters: SubagentIdCounters = { modelCounter: 0, @@ -560,8 +566,17 @@ export default function ( (runtime ??= createSubagentRuntime({ initialModelCounter: restoredIdCounters.modelCounter, initialBtwCounter: restoredIdCounters.btwCounter, + ...(admission ? { admission } : {}), })); + if (pi.events) { + onSetupApply(pi, () => { + admission?.configure({ + maxActive: loadSetupConfig().childExecutions.maxActive, + }); + }); + } + const persistId = (id: string) => pi.appendEntry(SUBAGENT_ID_WATERMARK_ENTRY_TYPE, subagentIdWatermark(id)); @@ -577,7 +592,11 @@ export default function ( scope && sessionContext?.sessionManager === scope ? registerWebCapability(scope, { kind: "subagents", - snapshot: () => projectSubagentCapability(manager.view.list()), + snapshot: () => + projectSubagentCapability( + manager.view.list(), + manager.view.childExecutionAdmission?.(), + ), detail: (id) => { const snapshot = manager.view.get(id); return snapshot ? projectSubagentDetail(snapshot) : undefined; @@ -692,7 +711,11 @@ export default function ( let manager: SubagentManagerShape | undefined; try { manager = await getManager(); - if (manager.view.size() === 0) return; + if ( + manager.view.size() === 0 && + !manager.view.childExecutionAdmission?.()?.enabled + ) + return; await openSubagentPicker(ctx, manager.view, initialId); settledAcknowledgedAt = Date.now(); } finally { @@ -786,6 +809,9 @@ export default function ( }; pi.on("session_start", (_event, ctx) => { + admission = sessionChildExecutionAdmission(ctx.sessionManager, { + maxActive: loadSetupConfig().childExecutions.maxActive, + }); restoredIdCounters = restoreSubagentIdCounters( ctx.sessionManager.getBranch(), ); @@ -879,6 +905,8 @@ export default function ( dashboardOpen = false; const closing = runtime; runtime = undefined; + admission?.shutdown(); + admission = undefined; managerPromise = undefined; // Disposing the runtime runs the manager finalizer, which tears down all // subagent scopes (and, later, their real child processes). @@ -1682,7 +1710,10 @@ export default function ( return; } const manager = await getManager(); - if (manager.view.size() === 0) { + if ( + manager.view.size() === 0 && + !manager.view.childExecutionAdmission?.()?.enabled + ) { ctx.ui.notify( "No subagents yet. The agent spawns them with subagent_spawn.", "info", diff --git a/extensions/subagents/src/manager.ts b/extensions/subagents/src/manager.ts index 2ea33dc7..16a598b7 100644 --- a/extensions/subagents/src/manager.ts +++ b/extensions/subagents/src/manager.ts @@ -26,6 +26,11 @@ import { } from "effect"; import type { SubagentBackend, SubagentSession } from "./backend.ts"; import type { AgentToolRenderer } from "../../shared/agent-tool-renderer.ts"; +import type { + ChildExecutionAdmission, + ChildExecutionLease, + ChildExecutionAdmissionSnapshot, +} from "../../shared/child-execution-admission.ts"; import { BackendRegistry } from "./backend.ts"; import type { BackendName, @@ -123,6 +128,10 @@ interface Entry { /** Idle restart dispatched but RunStarted not folded yet; counts as running * so concurrent restarts cannot race past the cap. */ restarting?: boolean; + admissionLease?: ChildExecutionLease; + admissionAbort?: AbortController; + /** A timed-out stop has no trustworthy terminal evidence: retain its lease. */ + admissionUncertain?: boolean; } // --- Read model ---------------------------------------------------------------- @@ -134,6 +143,8 @@ export interface SubagentReadModel { /** Native tool projection retained by the live child session, when present. */ getToolRenderer?(id: string): AgentToolRenderer | undefined; size(): number; + /** Shared Session admission state; no task prompts are exposed here. */ + childExecutionAdmission?(): ChildExecutionAdmissionSnapshot | undefined; /** Any-change notification (footer status, dashboard). */ subscribe(listener: () => void): () => void; /** Per-subagent notification (takeover view). */ @@ -244,6 +255,10 @@ const makeManager = (config: SubagentManagerConfig = {}) => } } }; + // Workflow and Direct/BTW all mutate this one Session-owned fact. Forward + // its changes through the existing view subscription so an already-open + // operator dashboard repaints without a separate counter projection. + const unsubscribeAdmission = config.admission?.subscribe(() => notify()); /** Resolves on the next state change. Interruption unregisters the waiter. */ const nextChange = Effect.callback((resume) => { @@ -326,7 +341,11 @@ const makeManager = (config: SubagentManagerConfig = {}) => } }; - const settle = (entry: Entry, outcome: RunOutcome) => { + const settle = ( + entry: Entry, + outcome: RunOutcome, + releaseAdmission = true, + ) => { const s = entry.snapshot; const wasRestarting = entry.restarting === true; entry.restarting = false; @@ -374,6 +393,11 @@ const makeManager = (config: SubagentManagerConfig = {}) => entry.liveToolMap.clear(); s.liveTools = []; s.queued = []; + entry.admissionAbort = undefined; + if (releaseAdmission) { + entry.admissionLease?.release(); + entry.admissionLease = undefined; + } const consumed = (waitInterest.get(s.id) ?? 0) > 0; notify(s.id); try { @@ -520,6 +544,24 @@ const makeManager = (config: SubagentManagerConfig = {}) => }, ); + let admissionLease: ChildExecutionLease | undefined; + if (config.admission) { + admissionLease = yield* Effect.tryPromise({ + try: (signal) => + config.admission!.acquire( + origin === "btw" ? "btw" : "direct", + signal, + ), + catch: (error) => + new SpawnError({ + message: + error instanceof Error + ? error.message + : "Could not acquire a shared child execution slot.", + }), + }); + } + let leaseTransferred = false; const doSpawn = Effect.gen(function* () { const backend: SubagentBackend | undefined = registry.get(backendName); @@ -567,8 +609,10 @@ const makeManager = (config: SubagentManagerConfig = {}) => session, scope, liveToolMap: new Map(), + ...(admissionLease ? { admissionLease } : {}), }; entries.set(id, entry); + leaseTransferred = true; // Pump: fold the event stream into the snapshot. Tied to the entry // scope, so closing the scope stops it. If the stream ends while the @@ -578,7 +622,7 @@ const makeManager = (config: SubagentManagerConfig = {}) => ).pipe( Effect.ensuring( Effect.sync(() => { - if (entry.snapshot.status === "running") { + if (isBusy(entry)) { settle(entry, { _tag: "Failed", errorText: "Backend event stream ended unexpectedly", @@ -598,6 +642,7 @@ const makeManager = (config: SubagentManagerConfig = {}) => Effect.sync(() => { if (origin === "btw") reservedBtw--; else reservedModel--; + if (!leaseTransferred) admissionLease?.release(); notify(); }), ), @@ -633,8 +678,17 @@ const makeManager = (config: SubagentManagerConfig = {}) => const abortEntry = (entry: Entry) => Effect.gen(function* () { if (!isBusy(entry)) return; + if (entry.restarting && entry.admissionAbort) { + // This restart is only queued at the shared admission boundary; do + // not call into a dormant child Session that has not started again. + entry.admissionAbort.abort(new Error("Subagent restart was aborted")); + entry.admissionAbort = undefined; + entry.restarting = false; + notify(entry.snapshot.id); + return; + } const graceful = yield* entry.session.interrupt.pipe( - Effect.timeout(STOP_TIMEOUT_MS), + Effect.timeout(config.stopTimeoutMs ?? STOP_TIMEOUT_MS), Effect.result, ); if (Result.isFailure(graceful)) { @@ -642,9 +696,14 @@ const makeManager = (config: SubagentManagerConfig = {}) => // fallback ("Backend event stream ended unexpectedly") cannot win // the race and report the wrong terminal reason. yield* Effect.sync(() => { - settle(entry, { _tag: "Interrupted" }); + // The SDK did not produce terminal evidence in time. The legacy + // snapshot remains an error so the user sees the interruption, but + // admission stays held and this dormant Session cannot be revived: + // otherwise a timed-out stop could oversell the shared limit. + entry.admissionUncertain = true; + settle(entry, { _tag: "Interrupted" }, false); entry.snapshot.errorText = - "Abort deadline exceeded; session was force-disposed"; + "Abort deadline exceeded; child termination is uncertain"; notify(entry.snapshot.id); }); // Bound the close like disposeAll does: a stuck backend finalizer @@ -702,6 +761,12 @@ const makeManager = (config: SubagentManagerConfig = {}) => message: `Subagent "${id}" is no longer tracked.`, }); } + if (entry.admissionUncertain) { + return new SendError({ + message: + "Cannot restart this child because its previous termination is uncertain. End the parent Session before starting more child executions.", + }); + } // Restarting a settled subagent occupies a running slot again, so it // must respect the same cap as spawn. Steering an already-running one // does not consume additional capacity. @@ -719,10 +784,46 @@ const makeManager = (config: SubagentManagerConfig = {}) => // both pass the check in that window. Cleared by RunStarted/settle, // or here when the backend rejects the send. entry.restarting = true; - return entry.session.send(text).pipe( + return Effect.gen(function* () { + if (config.admission) { + const admissionAbort = new AbortController(); + entry.admissionAbort = admissionAbort; + const lease = yield* Effect.tryPromise({ + try: (signal) => { + const abortForEffect = () => + admissionAbort.abort(signal.reason); + signal.addEventListener("abort", abortForEffect, { + once: true, + }); + return config + .admission!.acquire( + origin === "btw" ? "btw" : "direct", + admissionAbort.signal, + ) + .finally(() => + signal.removeEventListener("abort", abortForEffect), + ); + }, + catch: (error) => + new SendError({ + message: + error instanceof Error + ? error.message + : "Could not acquire a shared child execution slot.", + }), + }); + entry.admissionAbort = undefined; + entry.admissionLease = lease; + } + return yield* entry.session.send(text); + }).pipe( Effect.onError(() => Effect.sync(() => { entry.restarting = false; + entry.admissionAbort?.abort(); + entry.admissionAbort = undefined; + entry.admissionLease?.release(); + entry.admissionLease = undefined; notify(entry.snapshot.id); }), ), @@ -735,6 +836,7 @@ const makeManager = (config: SubagentManagerConfig = {}) => disposed = true; const all = [...entries.values()]; entries.clear(); + for (const entry of all) entry.admissionAbort?.abort(); yield* Effect.forEach( all, (entry) => @@ -763,6 +865,7 @@ const makeManager = (config: SubagentManagerConfig = {}) => get: (id) => entries.get(id)?.snapshot, getToolRenderer: (id) => entries.get(id)?.session.toolRenderer, size: () => entries.size, + childExecutionAdmission: () => config.admission?.snapshot(), subscribe: (listener) => { listeners.add(listener); return () => listeners.delete(listener); @@ -796,7 +899,11 @@ const makeManager = (config: SubagentManagerConfig = {}) => // Safety net: disposing the ManagedRuntime tears everything down even if // the extension forgot to call disposeAll explicitly. - yield* Effect.addFinalizer(() => disposeAll); + yield* Effect.addFinalizer(() => + Effect.sync(() => unsubscribeAdmission?.()).pipe( + Effect.andThen(disposeAll), + ), + ); return SubagentManager.of({ spawn, @@ -814,6 +921,10 @@ export interface SubagentManagerConfig { /** Session-branch high-water marks restored by the extension host. */ initialModelCounter?: number; initialBtwCounter?: number; + /** Parent-session slot owner, shared with the Workflow extension. */ + admission?: ChildExecutionAdmission; + /** Test-only seam for forced-stop lifecycle coverage. */ + stopTimeoutMs?: number; } export const makeSubagentManagerLayer = (config: SubagentManagerConfig = {}) => diff --git a/extensions/subagents/src/ui/takeover.ts b/extensions/subagents/src/ui/takeover.ts index c9bd9307..4fbd1daf 100644 --- a/extensions/subagents/src/ui/takeover.ts +++ b/extensions/subagents/src/ui/takeover.ts @@ -277,11 +277,17 @@ export class SubagentDashboard implements Component { const running = subs.filter((snap) => snap.status === "running").length; const done = subs.filter((snap) => snap.status === "done").length; const failed = subs.filter((snap) => snap.status === "error").length; + const admission = this.view.childExecutionAdmission?.(); + const admissionSummary = + admission?.enabled && admission.limit !== undefined + ? `${admission.held}/${admission.limit} session slots · ${admission.queued} queued · wf ${admission.heldByOrigin.workflow} / direct ${admission.heldByOrigin.direct} / btw ${admission.heldByOrigin.btw}` + : undefined; const summary = [ running > 0 ? `${running} running` : "", done > 0 ? `${done} done` : "", failed > 0 ? `${failed} failed` : "", + admissionSummary ?? "", ] .filter(Boolean) .join(" · ") || "no agents"; @@ -295,7 +301,7 @@ export class SubagentDashboard implements Component { // One empty row of air between the conversation and the docked panel. "", ...panelFrame(theme, { - label: `Subagents · ${summary}`, + label: `Subagents · ${summary}${admission?.blockedReason ? ` · ${admission.blockedReason}` : ""}`, rows: rowLines, width, height: rowLines.length + 2, diff --git a/extensions/workflows/controller.ts b/extensions/workflows/controller.ts index 3a7d7767..8e9c5254 100644 --- a/extensions/workflows/controller.ts +++ b/extensions/workflows/controller.ts @@ -4,6 +4,10 @@ import { MAX_WORKFLOW_AGENT_CALLS, MAX_WORKFLOW_CONCURRENCY, } from "../shared/setup-config.ts"; +import type { + ChildExecutionAdmission, + ChildExecutionLease, +} from "../shared/child-execution-admission.ts"; export const RUN_SHUTDOWN_TIMEOUT_MS = 8_000; function abortError(signal: AbortSignal) { @@ -84,6 +88,7 @@ export class RunController { private readonly semaphore: Semaphore; private readonly maxAgentCalls: number; private readonly concurrency: number; + private readonly admission: ChildExecutionAdmission | undefined; private readonly tasks = new Set>(); private callCount = 0; private sealed = false; @@ -95,6 +100,7 @@ export class RunController { parentSignal?: AbortSignal, concurrency = DEFAULT_WORKFLOW_CONCURRENCY, maxAgentCalls = DEFAULT_WORKFLOW_MAX_AGENT_CALLS, + admission?: ChildExecutionAdmission, ) { this.concurrency = Math.max( 1, @@ -105,6 +111,7 @@ export class RunController { 1, Math.min(MAX_WORKFLOW_AGENT_CALLS, Math.floor(maxAgentCalls)), ); + this.admission = admission; if (parentSignal) { this.parentSignal = parentSignal; this.parentAbort = () => this.abort("Parent operation was aborted"); @@ -160,16 +167,25 @@ export class RunController { else if (invocationSignal?.aborted) onInvocationAbort(); let acquired = false; + let admissionLease: ChildExecutionLease | undefined; try { await this.semaphore.acquire(taskAbort.signal); acquired = true; if (taskAbort.signal.aborted) throw abortError(taskAbort.signal); + // Every child path takes its existing local capacity first, then this + // shared Session limit. No path takes the inverse order, so no cycle. + admissionLease = await this.admission?.acquire( + "workflow", + taskAbort.signal, + ); + if (taskAbort.signal.aborted) throw abortError(taskAbort.signal); const result = await task(taskAbort.signal); if (invocationSignal?.aborted) throw abortError(invocationSignal); return result; } finally { this.signal.removeEventListener("abort", onRunAbort); invocationSignal?.removeEventListener("abort", onInvocationAbort); + admissionLease?.release(); if (acquired) this.semaphore.release(); } })(); diff --git a/extensions/workflows/index.ts b/extensions/workflows/index.ts index fc4e01a5..1a8e1feb 100644 --- a/extensions/workflows/index.ts +++ b/extensions/workflows/index.ts @@ -53,11 +53,16 @@ import { formatActivityStatus, } from "../shared/activity-status.ts"; import { fitNavigationSides } from "../shared/below-editor-navigation.ts"; +import { + sessionChildExecutionAdmission, + type ChildExecutionAdmission, +} from "../shared/child-execution-admission.ts"; import { inheritedChildToolAllowlist, resolveStandaloneChildProjectTrust, waitBounded, } from "../shared/child-session.ts"; +import { onSetupApply } from "../shared/setup-apply.ts"; import { contextPercent } from "../shared/context-utilization.ts"; import { completionOwnerFor } from "../shared/completion-inbox.ts"; import { @@ -819,10 +824,18 @@ export default function workflows( const activeRuns = new Map(); let unregisterWebCapability: (() => void) | undefined; let webCapabilityScope: WebCapabilityScope | undefined; + let admission: ChildExecutionAdmission | undefined; const activeDetails = () => new Map( [...activeRuns].map(([runId, run]) => [runId, run.details] as const), ); + if (pi.events) { + onSetupApply(pi, () => { + admission?.configure({ + maxActive: loadSetupConfig().childExecutions.maxActive, + }); + }); + } const settledRuns = createWorkflowSettledRunRetention( options.settledRetention, ); @@ -1084,6 +1097,9 @@ export default function workflows( }; pi.on("session_start", (_event, ctx) => { + admission = sessionChildExecutionAdmission(ctx.sessionManager, { + maxActive: loadSetupConfig().childExecutions.maxActive, + }); unregisterWebCapability?.(); const scope = ctx.sessionManager; webCapabilityScope = scope; @@ -1155,6 +1171,8 @@ export default function workflows( navigationLayerRegistered = false; } await shutdownActiveWorkflowRuns([...activeRuns.values()]); + admission?.shutdown(); + admission = undefined; // Give deferred completions one final delivery attempt. Failed sends stay // durably pending; clearing first would discard an envelope whose initial // persistence may have failed. @@ -1345,6 +1363,7 @@ export default function workflows( undefined, workflowConfig.concurrency, workflowConfig.maxAgentCalls, + admission, ); const handoffs = createWorkflowHandoffRegistry(); const operators = new WorkflowOperatorRegistry(); diff --git a/scripts/check-config-contract.mjs b/scripts/check-config-contract.mjs index d98887cd..6409c4cb 100644 --- a/scripts/check-config-contract.mjs +++ b/scripts/check-config-contract.mjs @@ -44,6 +44,22 @@ const CONFIG_FIELD_CONTRACT = [ readmeTerms: ["总调用"], setupTerms: ["total agent calls"], }, + { + path: "childExecutions", + writerTokens: ["childExecutions:"], + statusTokens: ["config.childExecutions"], + readmeTerms: ["Session child execution slots"], + setupTerms: ["child_execution_limit"], + }, + { + path: "childExecutions.maxActive", + optional: true, + configTokens: ["readonly maxActive?: number"], + writerTokens: ["params.child_execution_limit"], + statusTokens: ["config.childExecutions.maxActive"], + readmeTerms: ["Session child execution slots"], + setupTerms: ["child_execution_limit"], + }, { path: "ui.webTheme", writerTokens: ["params.ui_web_theme"], diff --git a/tests/extensions/setup/index.test.ts b/tests/extensions/setup/index.test.ts index a6fe15c4..8bfe0620 100644 --- a/tests/extensions/setup/index.test.ts +++ b/tests/extensions/setup/index.test.ts @@ -256,6 +256,7 @@ test("registers the canonical setup command, legacy alias, and one constrained t assert.equal("ui_web_chat_width" in parameters.properties, true); assert.equal("ui_web_chat_font_size" in parameters.properties, true); assert.equal("ui_web_expand_thinking" in parameters.properties, true); + assert.equal("child_execution_limit" in parameters.properties, true); const postEdit = parameters.properties.post_edit_command as { description?: string; }; @@ -304,6 +305,15 @@ test("post-edit stays off or preserved unless the setup request changes it", asy await apply({ workflow_concurrency: 4 }); assert.equal(loadSetupConfig().postEdit.command, "npm run format"); + await apply({ child_execution_limit: 3 }); + assert.equal(loadSetupConfig().childExecutions.maxActive, 3); + + await apply({ workflow_max_agent_calls: 64 }); + assert.equal(loadSetupConfig().childExecutions.maxActive, 3); + + await apply({ child_execution_limit: null }); + assert.equal(loadSetupConfig().childExecutions.maxActive, undefined); + await apply({ post_edit_command: "" }); assert.equal(loadSetupConfig().postEdit.command, ""); }); diff --git a/tests/extensions/shared/child-execution-admission.test.ts b/tests/extensions/shared/child-execution-admission.test.ts new file mode 100644 index 00000000..ea9b2db3 --- /dev/null +++ b/tests/extensions/shared/child-execution-admission.test.ts @@ -0,0 +1,202 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { + ChildExecutionAdmission, + ChildExecutionAdmissionAbortedError, + ChildExecutionAdmissionQueueFullError, + sessionChildExecutionAdmission, +} from "../../../extensions/shared/child-execution-admission.ts"; + +const deferred = () => { + let resolve!: (value: T | PromiseLike) => void; + let reject!: (reason?: unknown) => void; + const promise = new Promise((resolvePromise, rejectPromise) => { + resolve = resolvePromise; + reject = rejectPromise; + }); + return { promise, resolve, reject }; +}; + +test("FAIL: admission never oversells a same-tick shared limit", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 2 }); + const requests = Array.from({ length: 20 }, () => + admission.acquire("workflow"), + ); + const leases = await Promise.all(requests.slice(0, 2)); + + assert.equal(admission.snapshot().held, 2); + assert.equal(admission.snapshot().queued, 18); + + leases[0]!.release(); + leases[1]!.release(); + await Promise.resolve(); + assert.equal(admission.snapshot().held, 2); + + for (const lease of leases) lease.release(); + for (const request of requests.slice(2)) (await request).release(); + assert.equal(admission.snapshot().held, 0); + assert.equal(admission.snapshot().queued, 0); +}); + +test("FAIL: each top-level Session owner gets an independent admission pool", async () => { + const firstOwner = {}; + const secondOwner = {}; + const first = sessionChildExecutionAdmission(firstOwner, { maxActive: 1 }); + const sameFirst = sessionChildExecutionAdmission(firstOwner, { + maxActive: 4, + }); + const second = sessionChildExecutionAdmission(secondOwner, { maxActive: 1 }); + + assert.equal(first, sameFirst); + assert.notEqual(first, second); + const firstLease = await first.acquire("workflow"); + const secondLease = await second.acquire("workflow"); + assert.equal(first.snapshot().held, 1); + assert.equal(second.snapshot().held, 1); + firstLease.release(); + secondLease.release(); +}); + +test("FAIL: queued acquires are FIFO across workflow, direct, and BTW", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const first = await admission.acquire("workflow"); + const order: string[] = []; + const direct = admission.acquire("direct").then((lease) => { + order.push("direct"); + return lease; + }); + const btw = admission.acquire("btw").then((lease) => { + order.push("btw"); + return lease; + }); + + first.release(); + const directLease = await direct; + assert.deepEqual(order, ["direct"]); + directLease.release(); + const btwLease = await btw; + assert.deepEqual(order, ["direct", "btw"]); + btwLease.release(); +}); + +test("FAIL: a cancelled queued acquire cannot start work after a release", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const held = await admission.acquire("workflow"); + const abort = new AbortController(); + const pending = admission.acquire("direct", abort.signal); + abort.abort(new Error("caller cancelled")); + + await assert.rejects(pending, ChildExecutionAdmissionAbortedError); + assert.equal(admission.snapshot().queued, 0); + held.release(); + assert.equal(admission.snapshot().held, 0); +}); + +test("FAIL: acquire observes an already-aborted signal without claiming", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const abort = new AbortController(); + abort.abort(); + + await assert.rejects( + admission.acquire("workflow", abort.signal), + ChildExecutionAdmissionAbortedError, + ); + assert.equal(admission.snapshot().held, 0); +}); + +test("FAIL: a bounded queue rejects before consuming a slot", async () => { + const admission = new ChildExecutionAdmission({ + maxActive: 1, + maxQueued: 1, + }); + const held = await admission.acquire("workflow"); + const pending = admission.acquire("direct"); + + await assert.rejects( + admission.acquire("btw"), + ChildExecutionAdmissionQueueFullError, + ); + assert.deepEqual(admission.snapshot(), { + enabled: true, + limit: 1, + held: 1, + queued: 1, + heldByOrigin: { workflow: 1, direct: 0, btw: 0 }, + queuedByOrigin: { workflow: 0, direct: 1, btw: 0 }, + blockedReason: + "Waiting for a shared child execution slot (1 active / 1 limit).", + }); + + held.release(); + (await pending).release(); +}); + +test("FAIL: release is idempotent and attempt-scoped", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const first = await admission.acquire("workflow"); + first.release(); + const second = await admission.acquire("workflow"); + + first.release(); + assert.equal(admission.snapshot().held, 1); + second.release(); + assert.equal(admission.snapshot().held, 0); +}); + +test("FAIL: shutdown rejects waiters but does not pretend active children stopped", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const held = await admission.acquire("workflow"); + const pending = admission.acquire("btw"); + + admission.shutdown(); + await assert.rejects(pending, ChildExecutionAdmissionAbortedError); + assert.equal(admission.snapshot().held, 1); + held.release(); + assert.equal(admission.snapshot().held, 0); +}); + +test("FAIL: a live configuration cannot shrink below truthful held state", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 2 }); + const first = await admission.acquire("workflow"); + const second = await admission.acquire("direct"); + + assert.throws(() => admission.configure({ maxActive: 1 }), /2 active/); + assert.equal(admission.snapshot().limit, 2); + second.release(); + admission.configure({ maxActive: 1 }); + assert.equal(admission.snapshot().limit, 1); + first.release(); +}); + +test("FAIL: enabling a limit accounts for children started while disabled", async () => { + const admission = new ChildExecutionAdmission(); + const first = await admission.acquire("workflow"); + const second = await admission.acquire("direct"); + + assert.equal(admission.snapshot().enabled, false); + assert.equal(admission.snapshot().held, 2); + assert.throws(() => admission.configure({ maxActive: 1 })); + assert.doesNotThrow(() => admission.configure({ maxActive: 2 })); + + first.release(); + second.release(); +}); + +test("FAIL: a grant racing cancellation leaves no leaked lease", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const held = await admission.acquire("workflow"); + const abort = new AbortController(); + const gate = deferred(); + const pending = admission.acquire("btw", abort.signal).then(async (lease) => { + await gate.promise; + if (abort.signal.aborted) lease.release(); + return lease; + }); + + held.release(); + abort.abort(); + gate.resolve(); + const lease = await pending; + lease.release(); + assert.equal(admission.snapshot().held, 0); +}); diff --git a/tests/extensions/shared/setup-config.test.ts b/tests/extensions/shared/setup-config.test.ts index 1e144f5a..6b96c1e5 100644 --- a/tests/extensions/shared/setup-config.test.ts +++ b/tests/extensions/shared/setup-config.test.ts @@ -128,6 +128,33 @@ test("capability discovery defaults to explicit and accepts adaptive opt-in", () ); }); +test("FAIL: session child execution admission is opt-in and bounded", () => { + assert.equal(DEFAULT_SETUP_CONFIG.childExecutions.maxActive, undefined); + assert.equal( + parseSetupConfig({ childExecutions: { maxActive: 3 } }).childExecutions + .maxActive, + 3, + ); + assert.equal( + parseSetupConfig({ childExecutions: { maxActive: 0 } }).childExecutions + .maxActive, + undefined, + ); + assert.equal( + parseSetupConfig({ childExecutions: { maxActive: 65 } }).childExecutions + .maxActive, + undefined, + ); + assert.match( + formatSetupConfig(parseSetupConfig({ childExecutions: { maxActive: 3 } })), + /Session child executions: 3 active slots/, + ); + assert.match( + formatSetupConfig(DEFAULT_SETUP_CONFIG), + /Session child executions: unbounded \(disabled\)/, + ); +}); + test("process start-time queries are platform-specific and conservative", () => { const windowsQuery = processStartedAtQuery(123, "win32"); assert.equal(windowsQuery.command, "powershell.exe"); diff --git a/tests/extensions/subagents/manager.test.ts b/tests/extensions/subagents/manager.test.ts index 5e70a9a8..7b5693ec 100644 --- a/tests/extensions/subagents/manager.test.ts +++ b/tests/extensions/subagents/manager.test.ts @@ -28,6 +28,7 @@ import { type SubagentManagerShape, } from "../../../extensions/subagents/src/manager.ts"; import { runTool } from "../../../extensions/subagents/src/runtime.ts"; +import { ChildExecutionAdmission } from "../../../extensions/shared/child-execution-admission.ts"; const STATUS_WAIT_TIMEOUT_MS = 5_000; @@ -100,25 +101,30 @@ function waitForManagerStatus( const isSettledStatus = (status: SubagentStatus | undefined) => status === "done" || status === "error"; -const TestRegistryLive = Layer.sync(BackendRegistry, () => { - const backends: SubagentBackend[] = [ - makeStubBackend({ - backend: "pi", - defaultModelLabel: "stub/sonnet", - contextWindow: 200_000, - toolName: "Bash", - cadenceMs: 40, - }), - ]; - return new Map( - backends.map((backend) => [backend.name, backend]), - ); -}); +const stubBackend = () => + makeStubBackend({ + backend: "pi", + defaultModelLabel: "stub/sonnet", + contextWindow: 200_000, + toolName: "Bash", + cadenceMs: 40, + }); -const createTestRuntime = (managerConfig?: SubagentManagerConfig) => +const createTestRuntime = ( + managerConfig?: SubagentManagerConfig, + backends: readonly SubagentBackend[] = [stubBackend()], +) => ManagedRuntime.make( makeSubagentManagerLayer(managerConfig).pipe( - Layer.provide(TestRegistryLive), + Layer.provide( + Layer.sync( + BackendRegistry, + () => + new Map( + backends.map((backend) => [backend.name, backend]), + ), + ), + ), ), ); @@ -137,8 +143,9 @@ async function withManager( runtime: ReturnType, ) => Promise, managerConfig?: SubagentManagerConfig, + backends?: readonly SubagentBackend[], ) { - const runtime = createTestRuntime(managerConfig); + const runtime = createTestRuntime(managerConfig, backends); try { const manager = await runtime.runPromise(SubagentManager); await run(manager, runtime); @@ -166,6 +173,99 @@ test("status waits fail within their own deadline with diagnostic state", async assert.equal(unsubscribed, true); }); +test("FAIL: Direct and BTW share session admission without weakening their local pools", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + await withManager( + async (manager, runtime) => { + const direct = await runTool( + runtime, + manager.spawn("pi", task("Direct holds the shared slot")), + ); + const abort = new AbortController(); + const btw = runTool( + runtime, + manager.spawn("pi", { ...task("BTW waits"), origin: "btw" }), + { signal: abort.signal }, + ); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(admission.snapshot().heldByOrigin, { + workflow: 0, + direct: 1, + btw: 0, + }); + assert.deepEqual(admission.snapshot().queuedByOrigin, { + workflow: 0, + direct: 0, + btw: 1, + }); + abort.abort(new Error("BTW launch cancelled")); + await assert.rejects(btw, /Operation was aborted/); + await runTool(runtime, manager.waitFor([direct.id])); + assert.equal(admission.snapshot().held, 0); + assert.equal(admission.snapshot().queued, 0); + }, + { admission }, + ); +}); + +test("FAIL: a waiting Direct spawn does not call its child factory", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const base = stubBackend(); + let factoryCalls = 0; + const countingBackend: SubagentBackend = { + ...base, + spawn: (spawnTask) => { + factoryCalls++; + return base.spawn(spawnTask); + }, + }; + await withManager( + async (manager, runtime) => { + const held = await runTool( + runtime, + manager.spawn("pi", task("Direct owns the only slot")), + ); + assert.equal(factoryCalls, 1); + const abort = new AbortController(); + const queued = runTool( + runtime, + manager.spawn("pi", task("must not construct yet")), + { signal: abort.signal }, + ); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.equal(factoryCalls, 1); + abort.abort(); + await assert.rejects(queued, /Operation was aborted/); + await runTool(runtime, manager.waitFor([held.id])); + }, + { admission }, + [countingBackend], + ); +}); + +test("FAIL: an uncertain Direct stop retains its shared slot and cannot restart", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + await withManager( + async (manager, runtime) => { + const snap = await runTool( + runtime, + manager.spawn("pi", task("HANG: STUCKSTOP: stop remains uncertain")), + ); + await runTool(runtime, manager.cancel([snap.id])); + assert.equal(admission.snapshot().held, 1); + assert.match( + manager.view.get(snap.id)?.errorText ?? "", + /termination is uncertain/, + ); + await assert.rejects( + runTool(runtime, manager.send(snap.id, "do not restart")), + /previous termination is uncertain/, + ); + }, + { admission, stopTimeoutMs: 10 }, + ); +}); + test("stub subagent completes and delivers a final result", async () => { await withManager(async (manager, runtime) => { const settled: Array<{ id: string; consumed: boolean }> = []; diff --git a/tests/extensions/suggestions/config.test.ts b/tests/extensions/suggestions/config.test.ts index e0efa6c5..fcef00f9 100644 --- a/tests/extensions/suggestions/config.test.ts +++ b/tests/extensions/suggestions/config.test.ts @@ -31,7 +31,7 @@ test("setup defaults to disabled next-action suggestions", () => { assert.deepEqual(parseSetupConfig(undefined), DEFAULT_SETUP_CONFIG); assert.equal( formatSetupConfig(parseSetupConfig(undefined)), - `Capability discovery: explicit\nNext-action suggestions: disabled\nWorkflows: 8 concurrent agents · 128 total calls\nUI: Web theme system · chat 820px / 14px / thinking collapsed · large header off · custom footer on · plain · ${formatFooterLines(DEFAULT_FOOTER_LINES)}\nSubagent results: compact status summary (Ctrl+O expands full output)\nBash operations: one-line activity summary (Ctrl+O restores native evidence)\nWrite/Edit operations: one-line activity summary (Ctrl+O restores native evidence)\nPost-edit command: off\nAgent role models (Subagents + Workflows): explorer inherit · implementer inherit · reviewer inherit · advisor inherit`, + `Capability discovery: explicit\nNext-action suggestions: disabled\nWorkflows: 8 concurrent agents · 128 total calls\nSession child executions: unbounded (disabled)\nUI: Web theme system · chat 820px / 14px / thinking collapsed · large header off · custom footer on · plain · ${formatFooterLines(DEFAULT_FOOTER_LINES)}\nSubagent results: compact status summary (Ctrl+O expands full output)\nBash operations: one-line activity summary (Ctrl+O restores native evidence)\nWrite/Edit operations: one-line activity summary (Ctrl+O restores native evidence)\nPost-edit command: off\nAgent role models (Subagents + Workflows): explorer inherit · implementer inherit · reviewer inherit · advisor inherit`, ); }); @@ -57,13 +57,14 @@ test("setup config accepts suggestion models and migrates the recap key", () => }, }, workflows: { concurrency: 8, maxAgentCalls: 128 }, + childExecutions: {}, ui: defaultUi, postEdit: { command: "" }, subagents: { roleModels: {} }, }); assert.equal( formatSetupConfig(configured), - `Capability discovery: explicit\nNext-action suggestions: seal/deepseek-v4-flash · off · Right accepts\nWorkflows: 8 concurrent agents · 128 total calls\nUI: Web theme system · chat 820px / 14px / thinking collapsed · large header off · custom footer on · plain · ${formatFooterLines(DEFAULT_FOOTER_LINES)}\nSubagent results: compact status summary (Ctrl+O expands full output)\nBash operations: one-line activity summary (Ctrl+O restores native evidence)\nWrite/Edit operations: one-line activity summary (Ctrl+O restores native evidence)\nPost-edit command: off\nAgent role models (Subagents + Workflows): explorer inherit · implementer inherit · reviewer inherit · advisor inherit`, + `Capability discovery: explicit\nNext-action suggestions: seal/deepseek-v4-flash · off · Right accepts\nWorkflows: 8 concurrent agents · 128 total calls\nSession child executions: unbounded (disabled)\nUI: Web theme system · chat 820px / 14px / thinking collapsed · large header off · custom footer on · plain · ${formatFooterLines(DEFAULT_FOOTER_LINES)}\nSubagent results: compact status summary (Ctrl+O expands full output)\nBash operations: one-line activity summary (Ctrl+O restores native evidence)\nWrite/Edit operations: one-line activity summary (Ctrl+O restores native evidence)\nPost-edit command: off\nAgent role models (Subagents + Workflows): explorer inherit · implementer inherit · reviewer inherit · advisor inherit`, ); assert.deepEqual( @@ -77,6 +78,7 @@ test("setup config accepts suggestion models and migrates the recap key", () => capabilities: { discovery: "explicit" }, suggestions: { enabled: false }, workflows: { concurrency: 8, maxAgentCalls: 128 }, + childExecutions: {}, ui: defaultUi, postEdit: { command: "" }, subagents: { roleModels: {} }, diff --git a/tests/extensions/workflows/controller.test.ts b/tests/extensions/workflows/controller.test.ts index 269441e5..7c5ddbd8 100644 --- a/tests/extensions/workflows/controller.test.ts +++ b/tests/extensions/workflows/controller.test.ts @@ -2,6 +2,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { RunController } from "../../../extensions/workflows/controller.ts"; import { shutdownActiveWorkflowRuns } from "../../../extensions/workflows/index.ts"; +import { ChildExecutionAdmission } from "../../../extensions/shared/child-execution-admission.ts"; const delay = (milliseconds: number) => new Promise((resolve) => setTimeout(resolve, milliseconds)); @@ -27,6 +28,29 @@ test("RunController reserves calls synchronously and caps global fanout", async assert.equal(await controller.settle(), true); }); +test("FAIL: workflow waits for the shared Session slot before creating its child", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const direct = await admission.acquire("direct"); + const controller = new RunController(undefined, 2, 8, admission); + let factoryCalls = 0; + const workflow = controller.schedule(async () => { + factoryCalls++; + return "workflow started"; + }); + + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.equal(factoryCalls, 0); + assert.deepEqual(admission.snapshot().queuedByOrigin, { + workflow: 1, + direct: 0, + btw: 0, + }); + direct.release(); + assert.equal(await workflow, "workflow started"); + assert.equal(factoryCalls, 1); + assert.equal(admission.snapshot().held, 0); +}); + test("RunController propagates invocation cancellation without aborting the run", async () => { const controller = new RunController(undefined, 1); const invocation = new AbortController(); diff --git a/tests/support/subagents-stub.ts b/tests/support/subagents-stub.ts index 7b911e9b..0991a498 100644 --- a/tests/support/subagents-stub.ts +++ b/tests/support/subagents-stub.ts @@ -276,6 +276,9 @@ const makeStubSession = ( events: Stream.fromQueue(events), send: submit, interrupt: Effect.gen(function* () { + // Test-only: model a transport whose stop acknowledgement never + // returns, so manager lifecycle tests can assert fail-closed cleanup. + if (task.prompt.includes("STUCKSTOP:")) return yield* Effect.never; // Drop queued prompts so interrupting cannot immediately start // another turn, then stop the active turn. A prompt may be mid-flight // between the driver dequeuing it and registering its fiber, so wait diff --git a/tests/web/observer-registry.test.ts b/tests/web/observer-registry.test.ts index c0b93545..d5b1a6db 100644 --- a/tests/web/observer-registry.test.ts +++ b/tests/web/observer-registry.test.ts @@ -469,6 +469,27 @@ test("projects bounded canonical activity without private payloads", () => { assert.equal("prompt" in subagents.items[0]!, false); assert.equal("finalText" in subagents.items[0]!, false); + const withAdmission = projectSubagentCapability([], { + enabled: true, + limit: 2, + held: 2, + queued: 1, + heldByOrigin: { workflow: 1, direct: 1, btw: 0 }, + queuedByOrigin: { workflow: 0, direct: 0, btw: 1 }, + blockedReason: + "Waiting for a shared child execution slot (2 active / 2 limit).", + }); + assert.deepEqual(withAdmission.childExecutionAdmission, { + enabled: true, + limit: 2, + held: 2, + queued: 1, + heldByOrigin: { workflow: 1, direct: 1, btw: 0 }, + queuedByOrigin: { workflow: 0, direct: 0, btw: 1 }, + blockedReason: + "Waiting for a shared child execution slot (2 active / 2 limit).", + }); + const workflowSources = [ { runId: "wf-1", diff --git a/web/ui/src/features/activity/ActivityBar.tsx b/web/ui/src/features/activity/ActivityBar.tsx index 16bf7c1a..b795ab1a 100644 --- a/web/ui/src/features/activity/ActivityBar.tsx +++ b/web/ui/src/features/activity/ActivityBar.tsx @@ -84,6 +84,7 @@ export function ActivityBar({ const activeSubagentCount = (liveSubagents?.items ?? []).filter( (item) => item.status === "running", ).length; + const admission = liveSubagents?.childExecutionAdmission; const running = [ ...(capabilities?.workflows?.items ?? []), ...(capabilities?.["background-terminals"]?.items ?? []), @@ -143,7 +144,12 @@ export function ActivityBar({ visible.length + (capabilities?.workflows?.omitted ?? 0) + (capabilities?.["background-terminals"]?.omitted ?? 0); - if (!visible.length && !omitted && !(onInspectSubagent && subagentCount)) + if ( + !visible.length && + !omitted && + !(onInspectSubagent && subagentCount) && + !admission?.enabled + ) return null; return (
@@ -159,6 +165,11 @@ export function ActivityBar({ })} )} + {admission?.enabled && admission.limit !== undefined && ( + + {`${admission.held}/${admission.limit} child slots · ${admission.queued} queued · wf ${admission.heldByOrigin.workflow} / direct ${admission.heldByOrigin.direct} / btw ${admission.heldByOrigin.btw}`} + + )} {visible.map(({ key, ...chip }) => ( ))} From 1f49610219dc9ba256fdd256740af977b6f2bda3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=98=89=E4=BC=9F?= <202383014@uibe.edu.cn> Date: Wed, 23 Sep 2026 15:15:57 +0800 Subject: [PATCH 2/5] build(web): update activity admission bundle --- web/dist/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/dist/app.js b/web/dist/app.js index 817221c4..b2a7c70f 100644 --- a/web/dist/app.js +++ b/web/dist/app.js @@ -82,7 +82,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules" `)}\n}`);let o=``;t.length>0&&(o=`@scope (${r}) to (${i}) {\n${t.join(` `)}\n}`);let s=py(e);return s&&(o=o?`${o}\n\n${s}`:s),{prose:a,component:o}}function gy(e,t=!1){let n=(0,w.useCallback)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[e]),r=(0,w.useCallback)(()=>window.matchMedia(e).matches,[e]),i=(0,w.useCallback)(()=>t,[t]);return(0,w.useSyncExternalStore)(n,r,i)}var _y=(0,w.createContext)(null);_y.displayName=`ThemeContext`;function vy(){return typeof document>`u`?null:document.documentElement.getAttribute(Th(`theme`))}function yy(){return null}function by(){return null}var xy=new Set,Sy=null;function Cy(){for(let e of xy)e()}function wy(e){return xy.add(e),xy.size===1&&typeof MutationObserver<`u`&&(Sy=new MutationObserver(Cy),Sy.observe(document.documentElement,{attributes:!0,attributeFilter:[Th(`theme`)]})),()=>{xy.delete(e),xy.size===0&&Sy&&(Sy.disconnect(),Sy=null)}}function Ty(){return()=>{}}function Ey(e){return(0,w.useSyncExternalStore)(e?Ty:wy,e?by:vy,yy)}function Dy(){let e=(0,w.use)(_y),t=Ey(e!=null);return e?.theme.name??t}var Oy={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,width:`1em`,height:`1em`,"aria-hidden":!0},ky={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,width:`1em`,height:`1em`,"aria-hidden":!0},Ay={close:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M6 6l12 12M6 18L18 6`})}),chevronDown:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M6 9l6 6 6-6`})}),"numberInput:stepperDown":(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M7.5 9.75l4.5 4.5 4.5-4.5`})}),chevronLeft:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M15 6l-6 6 6 6`})}),chevronRight:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M9 6l6 6-6 6`})}),chevronsLeft:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M18 6l-6 6 6 6M11 6l-6 6 6 6`})}),chevronsRight:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M6 6l6 6-6 6M13 6l6 6-6 6`})}),check:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M5 13l4 4L19 7`})}),success:(0,K.jsx)(`svg`,{...ky,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3a9 9 0 100 18 9 9 0 000-18zm4.06 6.56a.75.75 0 00-1.12-1l-3.94 4.4-1.94-1.94a.75.75 0 00-1.06 1.06l2.5 2.5a.75.75 0 001.09-.03l4.47-5z`})}),error:(0,K.jsx)(`svg`,{...ky,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3a9 9 0 100 18 9 9 0 000-18zm-2.47 5.47a.75.75 0 00-1.06 1.06L10.94 12l-2.47 2.47a.75.75 0 101.06 1.06L12 13.06l2.47 2.47a.75.75 0 101.06-1.06L13.06 12l2.47-2.47a.75.75 0 00-1.06-1.06L12 10.94l-2.47-2.47z`})}),warning:(0,K.jsx)(`svg`,{...ky,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.29 3.86L2.07 19.05A2 2 0 003.78 22h16.44a2 2 0 001.71-2.95L13.71 3.86a2 2 0 00-3.42 0zM12 9a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0112 9zm0 9a1 1 0 100-2 1 1 0 000 2z`})}),info:(0,K.jsx)(`svg`,{...ky,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3a9 9 0 100 18 9 9 0 000-18zm0 4a1 1 0 100 2 1 1 0 000-2zm-.75 3.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5z`})}),calendar:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`}),(0,K.jsx)(`path`,{d:`M16 2v4M8 2v4M3 10h18`})]}),clock:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`path`,{d:`M12 7v5l3 3`})]}),externalLink:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`path`,{d:`M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6`}),(0,K.jsx)(`path`,{d:`M15 3h6v6`}),(0,K.jsx)(`path`,{d:`M10 14L21 3`})]}),menu:(0,K.jsx)(`svg`,{...Oy,strokeWidth:2,children:(0,K.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`})}),moreHorizontal:(0,K.jsxs)(`svg`,{...ky,children:[(0,K.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.5`})]}),search:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,K.jsx)(`path`,{d:`M21 21l-4.35-4.35`})]}),arrowUp:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M12 19V5m0 0l-7 7m7-7l7 7`})}),arrowDown:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M12 5v14m0 0l7-7m-7 7l-7-7`})}),arrowsUpDown:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M3 7.5L7.5 3m0 0L12 7.5M7.5 3v13.5m13.5 0L16.5 21m0 0L12 16.5m4.5 4.5V7.5`})}),funnel:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z`})}),eyeSlash:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M3.98 8.223A10.477 10.477 0 001.934 12c1.292 4.338 5.31 7.5 10.066 7.5.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88`})}),viewColumns:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M9 4.5v15m6-15v15m-10.875 0h15.75c.621 0 1.125-.504 1.125-1.125V5.625c0-.621-.504-1.125-1.125-1.125H4.125C3.504 4.5 3 5.004 3 5.625v12.75c0 .621.504 1.125 1.125 1.125z`})}),copy:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`path`,{d:`M8 4v12a2 2 0 002 2h8a2 2 0 002-2V7.242a2 2 0 00-.602-1.43L16.083 2.57A2 2 0 0014.685 2H10a2 2 0 00-2 2z`}),(0,K.jsx)(`path`,{d:`M16 18v2a2 2 0 01-2 2H6a2 2 0 01-2-2V9a2 2 0 012-2h2`})]}),checkDouble:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`path`,{d:`M2 13l4 4L14 7`}),(0,K.jsx)(`path`,{d:`M9 13l4 4L21 7`})]}),wrench:(0,K.jsx)(`svg`,{...Oy,children:(0,K.jsx)(`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`})}),stop:(0,K.jsx)(`svg`,{...ky,children:(0,K.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}),microphone:(0,K.jsxs)(`svg`,{...Oy,children:[(0,K.jsx)(`path`,{d:`M12 2a3 3 0 00-3 3v6a3 3 0 006 0V5a3 3 0 00-3-3z`}),(0,K.jsx)(`path`,{d:`M19 10v1a7 7 0 01-14 0v-1`}),(0,K.jsx)(`path`,{d:`M12 18v4m-4 0h8`})]})},jy={};function My(e){return e==null?null:typeof e==`string`?Uv(e)?.icons??null:e.icons??null}function Ny(e,t){return My(t)?.[e]??jy[e]??Ay[e]}var Py={root:{kmuXW:`x2lah0s`,$$css:!0},span:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,$$css:!0}},Fy={primary:{kMwMTN:`xtbr613`,$$css:!0},secondary:{kMwMTN:`xv9yike`,$$css:!0},tertiary:{kMwMTN:`xv9yike`,$$css:!0},disabled:{kMwMTN:`xqa6c3m`,$$css:!0},accent:{kMwMTN:`xqwr325`,$$css:!0},success:{kMwMTN:`xtjic6`,$$css:!0},error:{kMwMTN:`xjt36v0`,$$css:!0},warning:{kMwMTN:`xs3pv69`,$$css:!0},inherit:{kMwMTN:`x1heor9g`,$$css:!0},blue:{kMwMTN:`x1fns2mt`,$$css:!0},red:{kMwMTN:`xeffzf7`,$$css:!0},green:{kMwMTN:`xmxeech`,$$css:!0},gray:{kMwMTN:`x1eyinzz`,$$css:!0},cyan:{kMwMTN:`x157w0xa`,$$css:!0},teal:{kMwMTN:`x1f3zxcb`,$$css:!0},yellow:{kMwMTN:`x1g6zdft`,$$css:!0},orange:{kMwMTN:`xxu74a4`,$$css:!0},pink:{kMwMTN:`x1kxxfg5`,$$css:!0},purple:{kMwMTN:`xzdw94u`,$$css:!0}},Iy={xsm:{kzqmXN:`x1jw3ynk`,kZKoxP:`xvle69y`,$$css:!0},sm:{kzqmXN:`xcdlrvm`,kZKoxP:`x1l36t39`,$$css:!0},md:{kzqmXN:`xwqq7k2`,kZKoxP:`xmll18r`,$$css:!0},lg:{kzqmXN:`xp8d6y2`,kZKoxP:`xam5rvr`,$$css:!0}},Ly={xsm:{kzqmXN:`x1jw3ynk`,kZKoxP:`xvle69y`,kGuDYH:`xboafo0`,$$css:!0},sm:{kzqmXN:`xcdlrvm`,kZKoxP:`x1l36t39`,kGuDYH:`x1jchvi3`,$$css:!0},md:{kzqmXN:`xwqq7k2`,kZKoxP:`xmll18r`,kGuDYH:`x1603h9y`,$$css:!0},lg:{kzqmXN:`xp8d6y2`,kZKoxP:`xam5rvr`,kGuDYH:`xngnso2`,$$css:!0}};function Ry(e){return e!=null&&e!==``?{role:`img`,"aria-label":e}:{"aria-hidden":`true`}}function zy({icon:e,color:t=`inherit`,size:n=`md`,label:r,ref:i,className:a,style:o,xstyle:s,...c}){let l=Ry(r);return typeof e==`string`?(0,K.jsx)(By,{name:e,color:t,size:n,a11yProps:l,className:a,style:o,xstyle:s,spanProps:c}):(0,K.jsx)(e,{ref:i,...l,...rg(X(`icon`,{size:n,color:t}),Y(Py.root,Fy[t],Iy[n],s),a??void 0,o),...c})}zy.displayName=`Icon`;function By({name:e,color:t,size:n,a11yProps:r,className:i,style:a,xstyle:o,spanProps:s}){let c=Ny(e,Dy());if(c==null)return null;let l=s??{};return(0,K.jsx)(`span`,{...r,...l,...rg(X(`icon`,{size:n,color:t}),Y(Py.span,Fy[t],Ly[n],o),i??void 0,a),children:c})}function Vy(e,t){return typeof e==`string`||typeof e==`function`||typeof e==`object`&&e&&`render`in e?(0,K.jsx)(zy,{icon:e,...t}):e}var Hy=[`noopener`,`noreferrer`];function Uy(e,t){if(e!==`_blank`)return{target:e,rel:t};let n=t?.split(/\s+/).filter(Boolean)??[];for(let e of Hy)n.includes(e)||n.push(e);return{target:e,rel:n.join(` `)}}var Wy=[`button`,`a`,`input`,`select`,`textarea`,`[role="button"]`,`[role="link"]`,`[role="checkbox"]`,`[role="radio"]`,`[role="switch"]`,`[role="tab"]`,`[role="menuitem"]`,`[role="option"]`,`[role="combobox"]`,`[role="listbox"]`,`[role="slider"]`,`[role="spinbutton"]`,`[data-pressable-container]`].join(`,`),Gy=`[aria-readonly="true"]`;function Ky(e,t){let n=e;for(;n!=null&&n!==t&&n!==document.body;){if(n.matches(Wy)&&!n.matches(Gy))return!0;n=n.parentElement}return!1}function qy(e){if(typeof document>`u`||!(`getSelection`in document))return!1;let t=document.getSelection();return t==null||t.isCollapsed?!1:e.contains(t.anchorNode)}function Jy({containerRef:e,interactiveRef:t,onClick:n,href:r,target:i,disabled:a=!1}){return(0,w.useEffect)(()=>{let t=e.current;t&&t.setAttribute(`data-pressable-container`,`true`)},[e]),{onClick:(0,w.useCallback)(o=>{if(a)return;let s=e.current;if(!s||qy(s))return;let c=o.target;if(c instanceof Element&&!(c!==o.currentTarget&&Ky(c,s))&&(n?.(o),!o.defaultPrevented&&(r!=null&&(i===`_blank`||o.ctrlKey||o.metaKey?window.open(r,`_blank`,`noopener`):t?.current?t.current.click():window.location.href=r),r==null&&n==null&&t?.current))){let e=new MouseEvent(`click`,{bubbles:o.bubbles,cancelable:o.cancelable,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey,altKey:o.altKey,button:o.button});t.current.dispatchEvent(e),o.stopPropagation()}},[e,t,n,r,i,a]),onMouseUp:(0,w.useCallback)(t=>{if(a)return;let n=e.current;if(!n)return;let i=t.target;i instanceof Element&&t.button===1&&r!=null&&(i===t.currentTarget||!Ky(i,n))&&window.open(r,`_blank`,`noopener`)},[e,r,a])}}var Yy=new Set([`option`,`tab`,`row`,`gridcell`,`columnheader`,`rowheader`,`treeitem`]),Xy={root:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,kg3NbH:`xf314gf`,kVAEAm:`x1n2onr6`,kB7OPa:`x9f619`,k9WMMc:`x1yc453h`,kaIpWk:`xh6dtrn`,$$css:!0},alignStart:{kGNEyG:`x1cy8zhl`,$$css:!0},interactive:{kkrTdU:`x1ypdohk x16khyan`,k1ekBW:`x15406qy`,kIyJzY:`xkvfbh3`,kAMwcw:`xlr8y92`,$$css:!0},highlighted:{kWkggS:`x1lmrjuc`,$$css:!0},selected:{kWkggS:`xgcxg3y`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,kfzvcC:`x47corl`,$$css:!0},inlineLabel:{kmuXW:`x2lah0s`,$$css:!0},inlineDescription:{kmuXW:`xs83m0k`,k7Eaqz:`xeuugli`,$$css:!0},label:{kMwMTN:`x5tbw38`,kGuDYH:`xjm74w1`,kLWn49:`xw6l6zx`,$$css:!0},labelSingleTruncate:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,$$css:!0},labelMultiTruncate:{kVQacm:`xb3r6kr`,k1xSpc:`x104kibb`,kgKLqz:`x1ua5tub`,$$css:!0},description:{kMwMTN:`x1gb3s7i`,kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,$$css:!0},descriptionSingleTruncate:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,$$css:!0},descriptionMultiTruncate:{kVQacm:`xb3r6kr`,k1xSpc:`x104kibb`,kgKLqz:`x1ua5tub`,$$css:!0}},Zy={lineClamp:e=>[{kJFfOR:e==null?e:`x1yhjpo9`,$$css:!0},{"--x-WebkitLineClamp":e??void 0}]},Qy={compact:{k8WAf4:`xu0wf1k`,$$css:!0},balanced:{k8WAf4:`xce4md1`,$$css:!0},spacious:{k8WAf4:`x8o8v82`,kg3NbH:`xrrkdod`,$$css:!0}};function $y({as:e=`div`,marker:t,startContent:n,label:r,description:i,endContent:a,align:o=`center`,density:s=`balanced`,labelLines:c,descriptionLines:l,layout:u=`stacked`,onClick:d,interactiveRef:f,href:p,target:m,rel:h,isHighlighted:g=!1,isSelected:_=!1,isDisabled:v=!1,xstyle:y,className:b,style:x,ref:S,role:C,...T}){let E=Zg(),D=f!=null,O=(0,w.useRef)(null),{onClick:k}=Jy({containerRef:O,interactiveRef:f??void 0,disabled:v});Fv(`Item`,"`interactiveRef` is mutually exclusive with `onClick`/`href`. In delegation mode the row only forwards clicks to the referenced control, so `onClick`/`href` are ignored. Drop one of them.",D&&(d!=null||p!=null));let A=d!=null||p!=null||D,{target:j,rel:M}=Uy(m,h),N=C!=null,P=C!=null&&Yy.has(C),F=typeof r==`string`,I=typeof i==`string`,L=c==null?F?Xy.labelSingleTruncate:null:c===1?Xy.labelSingleTruncate:Xy.labelMultiTruncate,R=u===`inline`&&i!=null,z=l==null?I||R?Xy.descriptionSingleTruncate:null:l===1?Xy.descriptionSingleTruncate:Xy.descriptionMultiTruncate,B=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{...Y(Xy.label,R&&Xy.inlineLabel,L,c!=null&&c>1&&Zy.lineClamp(c)),children:r}),i!=null&&(0,K.jsx)(`span`,{...Y(Xy.description,R&&Xy.inlineDescription,z,l!=null&&l>1&&Zy.lineClamp(l)),children:i})]}),V=e=>{v||e.target.closest(`button, a, input, select, textarea`)||d?.(e)},H=(0,K.jsxs)(K.Fragment,{children:[t,n!=null&&(0,K.jsx)(`span`,{className:`x3psx0u x78zum5`,children:n}),N||D?(0,K.jsx)(`span`,{...{0:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h`},2:{className:`x78zum5 x98rzlu xeuugli x1yc453h x1q0g3np x6s0dn4 x1lfs0n9`},1:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h xbyyjgo`},3:{className:`x78zum5 x98rzlu xeuugli x1yc453h x1q0g3np x6s0dn4 x1lfs0n9 xbyyjgo`}}[!!R<<1|!!v<<0],children:B}):p==null?d==null?(0,K.jsx)(`span`,{...{0:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h`},2:{className:`x78zum5 x98rzlu xeuugli x1yc453h x1q0g3np x6s0dn4 x1lfs0n9`},1:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h xbyyjgo`},3:{className:`x78zum5 x98rzlu xeuugli x1yc453h x1q0g3np x6s0dn4 x1lfs0n9 xbyyjgo`}}[!!R<<1|!!v<<0],children:B}):(0,K.jsx)(`button`,{type:`button`,onClick:d,disabled:v,...{0:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1a2a7pz`},2:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 x98rzlu xeuugli x1yc453h x1a2a7pz x1q0g3np x6s0dn4 x1lfs0n9`},1:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1a2a7pz xbyyjgo`},3:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 x98rzlu xeuugli x1yc453h x1a2a7pz x1q0g3np x6s0dn4 x1lfs0n9 xbyyjgo`}}[!!R<<1|!!v<<0],children:B}):(0,K.jsx)(E,{href:p,target:j,rel:M,"aria-disabled":v||void 0,tabIndex:v?-1:void 0,...{0:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz`},2:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz x1q0g3np x6s0dn4 x1lfs0n9`},1:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz xbyyjgo`},3:{className:`xmper1u x16khyan xln7xf2 x1heor9g x78zum5 x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz x1q0g3np x6s0dn4 x1lfs0n9 xbyyjgo`}}[!!R<<1|!!v<<0],children:B}),a!=null&&(0,K.jsx)(`span`,{...{0:{className:`x3psx0u x78zum5 xvc5jky`},1:{className:`x3psx0u x78zum5 xvc5jky xbyyjgo`}}[!!v<<0],children:a})]}),U=_g(S,O);return(0,K.jsx)(e,{ref:D?U:S,...T,"aria-selected":P&&_||void 0,"aria-current":T[`aria-current`]??(_&&!P?!0:void 0),"aria-disabled":v||void 0,...rg(X(`item`,{density:s,align:o}),gg.focusWithin(Xy.root,Qy[s],o===`start`&&Xy.alignStart,A&&Xy.interactive,A&&Qg.backgroundColor,g&&Xy.highlighted,_&&Xy.selected,v&&!N&&Xy.disabled,y),b,x),role:C,onClick:D?k:N?d:A?V:void 0,children:H})}$y.displayName=`Item`;var eb=(0,w.createContext)(null);eb.displayName=`DropdownMenuContext`;function tb(){return(0,w.use)(eb)}var nb=(0,w.createContext)(null);nb.displayName=`DropdownMenuRadioGroupContext`;function rb(e,t){if(t||e.pointerType!==`mouse`)return;let n=e.currentTarget;n!==n.ownerDocument.activeElement&&n.focus()}var ib={root:{kB7OPa:`x9f619`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`x1ws5lxm`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz`,kkrTdU:`x1ypdohk x16khyan`,k9WMMc:`x1yc453h`,kI3sdo:`x1a2a7pz`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`xt0e3qv`,$$css:!0},destructive:{kMwMTN:`xjt36v0`,"--_item-label-color":`xufyqxy`,"--_item-description-color":`xqlix59`,$$css:!0}},ab={sm:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},md:{k8WAf4:`x1vofgu7`,$$css:!0},lg:{$$css:!0}};function ob({icon:e,label:t,description:n,onClick:r,isDisabled:i=!1,endContent:a,hasCloseOnSelect:o=!0,variant:s=`default`,xstyle:c,className:l,style:u}){let d=tb(),f=d?.menuSize??`md`,p=(0,w.useCallback)(()=>{i||(r?.(),o&&d?.closeMenu())},[i,r,o,d]),m=(0,w.useCallback)(e=>rb(e,i),[i]),h=s===`destructive`;return(0,K.jsx)($y,{role:`menuitem`,tabIndex:i?void 0:-1,onPointerMove:m,startContent:e?Vy(e,{size:`sm`,color:h?`error`:`secondary`}):void 0,label:t,description:n,endContent:a,onClick:p,isDisabled:i,xstyle:[ib.root,ab[f],h&&ib.destructive,i&&ib.disabled,c],...rg(X(`dropdown-menu-item`,{size:f,variant:h?`destructive`:null}),{className:l,style:u})})}ob.displayName=`DropdownMenuItem`;var sb={horizontal:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kzqmXN:`xh8yej3`,$$css:!0},vertical:{k1xSpc:`x3nfvp2`,kXwgrk:`xdt5ytf`,kGNEyG:`x6s0dn4`,kZKoxP:`x5yr21d`,$$css:!0}},cb={horizontalLine:{kZKoxP:`xsyqizj`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,$$css:!0},verticalLine:{kzqmXN:`xjk4fl7`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,$$css:!0},subtle:{kWkggS:`x1m4xfpy`,$$css:!0},strong:{kWkggS:`x7njt3n`,$$css:!0}},lb={horizontal:{keTefX:`xojxgvx`,k71WvV:`x1fcf3bl`,kzqmXN:`xx6qvi6`,$$css:!0},vertical:{keoZOQ:`x1sa9bsh`,k1K539:`x6h7pi7`,kZKoxP:`x12qplqi`,$$css:!0}};function ub({orientation:e=`horizontal`,label:t,variant:n=`subtle`,isFullBleed:r=!1,xstyle:i,className:a,style:o,ref:s,"aria-label":c,"aria-labelledby":l,...u}){let d=e===`horizontal`,f=(0,w.useId)(),p=l??(t&&c==null?f:void 0);return(0,K.jsxs)(`div`,{ref:s,...u,role:`separator`,"aria-orientation":e,"aria-label":c,"aria-labelledby":p,...rg(X(`divider`,{variant:n,orientation:e}),Y(d?sb.horizontal:sb.vertical,r&&(d?lb.horizontal:lb.vertical),i),a,o),children:[(0,K.jsx)(`div`,{...Y(d?cb.horizontalLine:cb.verticalLine,cb[n])}),t&&(0,K.jsx)(`div`,{id:f,...{0:{className:`x2lah0s xrrkdod x141an7d x1ltkj2j xv1l7n4`},1:{className:`x2lah0s x141an7d x1ltkj2j xv1l7n4 xnjsko4 x8o8v82`}}[!d<<0],children:t}),t&&(0,K.jsx)(`div`,{...Y(d?cb.horizontalLine:cb.verticalLine,cb[n])})]})}ub.displayName=`Divider`;var db={divider:{kqGvvJ:`xsq74q5`,$$css:!0}},fb=X(`dropdown-menu-divider`).className;function pb({xstyle:e,className:t,style:n,ref:r}){return(0,K.jsx)(ub,{ref:r,xstyle:[db.divider,e],className:t?`${fb} ${t}`:fb,style:n})}pb.displayName=`DropdownMenuDivider`;function mb(e){return!e||typeof window>`u`?!1:window.getComputedStyle(e).direction===`rtl`}var hb=typeof window<`u`?w.useLayoutEffect:w.useEffect,gb=new Set([`text`,`search`,`url`,`tel`,`email`,`password`,`number`]);function _b(e){if(e.isContentEditable)return e;let t=e.closest(`[contenteditable]`);return t&&t.getAttribute(`contenteditable`)!==`false`?t:null}function vb(e,t){if(!(e instanceof HTMLElement))return!1;let n=_b(e);if(n){let e=typeof window<`u`?window.getSelection():null;return e&&e.rangeCount>0&&!e.isCollapsed?!0:(n.textContent??``).length>0}let r=e.tagName===`TEXTAREA`,i=e.tagName===`INPUT`&&gb.has(e.type);if(!r&&!i)return!1;let{selectionStart:a,selectionEnd:o,value:s}=e;return a!==o||a==null?!0:t===`ArrowLeft`||t===`ArrowUp`||t===`Home`?a>0:t===`ArrowRight`||t===`ArrowDown`||t===`End`?ae.getAttribute(`aria-disabled`)===`true`||e.disabled===!0||e.hasAttribute(`disabled`),[]),f=(0,w.useCallback)(()=>{let e=u.current;if(!e)return[];let r=Array.from(e.querySelectorAll(t));return n?r.filter(t=>t.closest(n)===e):r},[t,n]),p=(0,w.useCallback)(e=>{let t=u.current;if(!t||!n)return!0;let r=e.target;return!r||r.closest(n)===t},[n]),m=(0,w.useCallback)((e,t,n,r)=>{let i=e.length;if(i===0)return-1;let a=t;for(let t=0;t=i){if(!r)return-1;a=(a+i)%i}let t=e[a];if(t&&!d(t))return a;a+=n}return-1},[d]),h=(0,w.useCallback)(()=>{let e=f(),t=document.activeElement;return e.findIndex(e=>e===t||e.contains(t))},[f]),g=(0,w.useCallback)((e,t)=>{e.getAttribute(`tabindex`)!==String(t)&&e.setAttribute(`tabindex`,String(t))},[]),_=(0,w.useCallback)(()=>{let e=f(),t=e.filter(e=>!d(e));if(t.length===0)return;let n=t.find(e=>e.getAttribute(`tabindex`)===`0`)??t[0];for(let t of e)g(t,t===n?0:-1)},[f,d,g]);hb(()=>{c&&_()});let v=(0,w.useCallback)((e,t)=>{let n=e[t];if(n){if(c)for(let t of e)g(t,t===n?0:-1);n.focus()}},[c,g]),y=(0,w.useCallback)(e=>{let t=f();if(t.length===0)return;let n=Math.max(0,Math.min(e,t.length-1));v(t,n)},[f,v]),b=(0,w.useCallback)(()=>{let e=f(),t=m(e,0,1,!1);return t!==-1&&(v(e,t),!0)},[f,m,v]),x=(0,w.useCallback)(()=>{let e=f(),t=m(e,e.length-1,-1,!1);return t!==-1&&(v(e,t),!0)},[f,m,v]),S=(0,w.useCallback)(()=>{c&&_()},[c,_]);return{listRef:u,handleKeyDown:(0,w.useCallback)(e=>{if(e.ctrlKey||e.metaKey||e.altKey||!p(e))return;if(e.key===`Escape`){i&&(e.preventDefault(),i());return}let t=a===`horizontal`||a===`both`,n=a===`vertical`||a===`both`,c=[],d=[];if(t){let t=e.key===`ArrowLeft`||e.key===`ArrowRight`?s??mb(u.current):!1;c.push(t?`ArrowLeft`:`ArrowRight`),d.push(t?`ArrowRight`:`ArrowLeft`)}n&&(c.push(`ArrowDown`),d.push(`ArrowUp`));let g=c.includes(e.key),_=d.includes(e.key),y=o&&e.key===`Home`,S=o&&e.key===`End`;if(!g&&!_&&!y&&!S||l&&(vb(e.target,e.key)||vb(document.activeElement,e.key)))return;let C=h(),w=f();if(g){let e=C===-1?0:C+1,t=m(w,e,1,r);t!==-1&&v(w,t)}else if(_){let e=C===-1?w.length-1:C-1,t=m(w,e,-1,r);t!==-1&&v(w,t)}else y?b():S&&x();e.preventDefault()},[h,f,r,a,s,o,l,m,v,b,x,i,p]),handleFocus:S,focusItem:y,focusFirst:b,focusLast:x,ownsEvent:p,getItems:f}}var bb=500,xb=300;function Sb(e){let{show:t,hide:n,isOpen:r,isEnabled:i,showDelay:a=150,hideDelay:o=200,clickGuardMs:s=bb,itemSelector:c,popoverId:l,ownsFocus:u=!0}=e,d=gy(`(hover: hover)`),f=(0,w.useRef)(null),p=(0,w.useRef)(null),m=(0,w.useRef)(null),h=(0,w.useRef)(!1),g=(0,w.useRef)(0),_=(0,w.useRef)(0),v=(0,w.useRef)(r);hb(()=>{let e=v.current;v.current=r,e&&!r&&(h.current=!1,_.current=0,g.current=Date.now())},[r]);let y=(0,w.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null),p.current&&=(clearTimeout(p.current),null)},[]),b=(0,w.useRef)(()=>{}),{listRef:x,handleKeyDown:S,focusFirst:C}=yb({itemSelector:c,onEscape:()=>b.current()}),T=(0,w.useCallback)(()=>{let e=x.current?.contains(document.activeElement)??!1;n(),e&&m.current?.focus()},[n,x]);(0,w.useEffect)(()=>{b.current=()=>{y(),T()}},[y,T]),(0,w.useEffect)(()=>()=>y(),[y]);let E=(0,w.useCallback)(()=>{C()||x.current?.focus()},[C,x]),D=(0,w.useCallback)(()=>{if(!u){t();return}t({skipAutoFocus:!0}),E()},[u,t,E]),O=(0,w.useCallback)(()=>s>0&&_.current>0&&Date.now()-_.current{if(l&&e?.preventDefault(),y(),e!=null&&e.detail===0){g.current=0,h.current=!1,_.current=0,r?u&&E():D();return}if(!r){g.current=0,h.current=!1,_.current=0,D();return}if(O()){u&&E();return}T()},[l,y,r,u,O,D,E,T]),A=(0,w.useCallback)(()=>{if(!d||g.current>0&&Date.now()-g.current{_.current=Date.now(),t({skipAutoFocus:!0})};a>0?f.current=setTimeout(e,a):e()},[d,r,y,t,a]),j=(0,w.useCallback)(()=>{g.current=0,h.current&&(y(),p.current=setTimeout(()=>{n()},o))},[y,n,o]),M=(0,w.useCallback)(()=>{y()},[y]),N=(0,w.useCallback)(e=>{m.current=e},[]),P=(0,w.useCallback)(()=>{},[]),F=(0,w.useCallback)(e=>{},[]),I=(0,w.useCallback)(e=>{},[]);return i?{triggerProps:{onClick:k,onMouseEnter:A,onMouseLeave:j,...l?{popoverTarget:l}:null},contentProps:{onMouseEnter:M,onMouseLeave:j,onKeyDown:S},menuRef:x,focusFirst:C,focusMenu:E,confirmHoverOpen:O,close:T,setTriggerEl:N}:{triggerProps:{onClick:P,onMouseEnter:P,onMouseLeave:P},contentProps:{onMouseEnter:P,onMouseLeave:P,onKeyDown:I},menuRef:x,focusFirst:C,focusMenu:E,confirmHoverOpen:O,close:T,setTriggerEl:F}}function Cb(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&e.key!==` `}function wb(e){let{getItemLabels:t,onMatch:n,getCurrentIndex:r,resetMs:i=750,isDisabled:a}=e,o=(0,w.useRef)(``),s=(0,w.useRef)(void 0),c=(0,w.useCallback)(()=>{o.current=``,s.current&&=(clearTimeout(s.current),void 0)},[]),l=(0,w.useCallback)(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o.current=``,s.current=void 0},i)},[i]);return{onKeyDown:(0,w.useCallback)(e=>{let i=e.key===` `&&!e.ctrlKey&&!e.metaKey&&o.current.length>0;if(!Cb(e)&&!i)return!1;let s=t();if(s.length===0)return!1;let c=e.key.toLowerCase(),u=o.current.length>0&&o.current.split(``).every(e=>e===c)?c:o.current+c;o.current=u,l();let d=r?.()??-1,f=s.length,p=d>=0,m=p?d:0,h=p&&u.length===1?1:0;for(let e=0;e`[role="${e}"]:not([aria-disabled="true"])`).join(`,`),Db=`[role="menu"]`,Ob={root:{kB7OPa:`x9f619`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`x1ws5lxm`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz`,kkrTdU:`x1ypdohk x16khyan`,k9WMMc:`x1yc453h`,kI3sdo:`x1a2a7pz`,$$css:!0},open:{kWkggS:`x1lmrjuc`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`xt0e3qv`,$$css:!0}},kb={sm:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},md:{k8WAf4:`x1vofgu7`,$$css:!0},lg:{$$css:!0}},Ab={popover:{k7Eaqz:`x5w4yej`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e==`number`?`${e}px`:e)==null?typeof e==`number`?`${e}px`:e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(typeof e==`number`?`${e}px`:e)}]};function jb(e){let{icon:t,label:n,description:r,isDisabled:i=!1,hasSpinner:a=!1,menuWidth:o,onOpenChange:s,children:c,xstyle:l,className:u,style:d,"data-testid":f,menuDataTestId:p}=e,m=tb(),h=m?.menuSize??`md`,g=!i,_=(0,w.useId)(),v=(0,w.useId)(),y=(0,w.useRef)(null),[b,x]=(0,w.useState)(!1),S=Om({mode:`context`,lightDismiss:!1,onShow:(0,w.useCallback)(()=>{x(!0),s?.(!0)},[s]),onHide:(0,w.useCallback)(()=>{x(!1),s?.(!1)},[s])}),C=(0,w.useCallback)(()=>{g&&S.show()},[g,S]),T=(0,w.useCallback)(()=>{S.hide()},[S]),{listRef:E,handleKeyDown:D,focusFirst:O,focusItem:k,ownsEvent:A,getItems:j}=yb({itemSelector:Eb,boundarySelector:Db,wrap:!1,onEscape:()=>L({focusTrigger:!0})}),M=wb({getItemLabels:()=>j().map(e=>e.textContent),onMatch:k,getCurrentIndex:()=>j().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))}),{triggerProps:N,contentProps:P,confirmHoverOpen:F}=Sb({show:C,hide:T,isOpen:b,isEnabled:g}),I=(0,w.useCallback)(e=>{g&&(S.show(),e?.focusFirst&&(O()||E.current?.focus()))},[g,S,O,E]),L=(0,w.useCallback)(e=>{S.hide(),e?.focusTrigger!==!1&&y.current?.focus()},[S]),R=(0,w.useCallback)(e=>{y.current=e,S.ref(e)},[S]),z=(0,w.useCallback)(()=>{if(!i)if(b){if(F()){O()||E.current?.focus();return}L({focusTrigger:!0})}else I({focusFirst:!0})},[i,b,I,L,F,O,E]),B=(0,w.useCallback)(e=>{if(i)return;let t=typeof window<`u`&&y.current&&window.getComputedStyle(y.current).direction===`rtl`?`ArrowLeft`:`ArrowRight`;(e.key===t||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),I({focusFirst:!0}))},[i,I]),V=(0,w.useCallback)(e=>rb(e,i),[i]),H=(0,w.useCallback)(e=>{if(!A(e))return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),L({focusTrigger:!0});return}if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=document.activeElement;t&&Tb.has(t.getAttribute(`role`)??``)&&t.click();return}let t=typeof window<`u`&&E.current&&window.getComputedStyle(E.current).direction===`rtl`?`ArrowRight`:`ArrowLeft`;if(e.key===t){e.preventDefault(),L({focusTrigger:!0});return}if(M.onKeyDown(e)){e.preventDefault();return}D(e)},[A,L,D,M,E]),U=(0,w.useMemo)(()=>({menuSize:h,closeMenu:()=>{L({focusTrigger:!1}),m?.closeMenu()}}),[h,L,m]),ee=a?(0,K.jsx)(`span`,{className:`x78zum5 x6s0dn4`,children:(0,K.jsx)(Bg,{size:`sm`})}):(0,K.jsx)(`span`,{className:`x78zum5 x6s0dn4`,children:(0,K.jsx)(zy,{icon:`chevronRight`,size:`sm`,color:`secondary`,...X(`dropdown-menu-indicator-icon`)})}),te=o?Ab.popoverCustomWidth(o):Ab.popover;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($y,{ref:e=>R(e),id:v,role:`menuitem`,tabIndex:i?void 0:-1,"aria-haspopup":`menu`,"aria-expanded":b,"aria-controls":b?_:void 0,"aria-disabled":i||void 0,"data-testid":f,onMouseEnter:N.onMouseEnter,onMouseLeave:N.onMouseLeave,onPointerMove:V,startContent:t?Vy(t,{size:`sm`,color:`secondary`}):void 0,label:n,description:r,endContent:ee,onClick:z,onKeyDown:B,isDisabled:i,xstyle:[Ob.root,kb[h],b&&Ob.open,i&&Ob.disabled,l],...rg(X(`dropdown-menu-item`,{size:h}),{className:u,style:d})}),S.render((0,K.jsx)(`div`,{ref:E,id:_,role:`menu`,tabIndex:-1,"aria-labelledby":v,onKeyDown:H,onMouseEnter:P.onMouseEnter,onMouseLeave:P.onMouseLeave,"data-testid":p,...rg(X(`dropdown-menu`),{className:`x9f619 x78zum5 xdt5ytf x1lsbc85 xuyqlj2 x1odjw0f x1fcsqxe xgory14 x9epnlk x1n97fys x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92`}),children:(0,K.jsx)(eb,{value:U,children:c})}),{placement:`end`,alignment:`start`,offset:om[`--spacing-1`],xstyle:[te,yh.end]})]})}jb.displayName=`DropdownMenuSubMenu`;function Mb(e,t){return`item-${e.id??t}`}function Nb(e,t){return`section-${e.id??t}`}function Pb(e,t){let{items:n,id:r,...i}=e;return(0,K.jsx)(ob,{...i},Mb(e,t))}function Fb(e){let t=[];for(let n=0;n0?t.push((0,K.jsx)(jb,{icon:r.icon,label:r.label,isDisabled:r.isDisabled,children:Fb(r.items)},Mb(r,n))):t.push(Pb(r,n)))}return t}var Ib={dropdown:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kskxy:`xuyqlj2`,kORKVm:`x1odjw0f`,"--_dropdown-menu-radius":`x1fcsqxe`,"--_dropdown-menu-padding":`xgory14`,kmVPX3:`x9epnlk`,kaIpWk:`x1n97fys`,kSiTet:`x1hc1fzr`,k1ekBW:`x19991ni`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0},popover:{k7Eaqz:`xrzjruh`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e==`number`?`${e}px`:e)==null?typeof e==`number`?`${e}px`:e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(typeof e==`number`?`${e}px`:e)}]},Lb=`@astryx.dropdownMenu.label`;function Rb({button:e,isMenuOpen:t,onOpenChange:n,menuWidth:r,onClick:i,hasChevron:a=!0,placement:o=`below`,alignment:s=`start`,className:c,style:l,xstyle:u,"data-testid":d,...f}){let p=Tv(),m=e??{label:p(Lb)},h=(`items`in f?f.items:void 0)??[],g=f.children,{items:_,children:v,...y}=f,b=(0,w.useId)(),x=m.size??`md`,S=(0,w.useRef)(null),[C,T]=(0,w.useState)(!1),E=t!==void 0,D=E?t:C,O=(0,w.useCallback)(()=>{n?.(!1),E||T(!1),S.current?.focus()},[E,n]),k=(0,w.useRef)(!1),A=(0,w.useRef)(`keyboard`),j=zv({onHide:O,onShow:(0,w.useCallback)(()=>{n?.(!0),E||T(!0)},[E,n]),hasLightDismiss:!0,hasCloseButton:!1,hasAutoFocus:!1,role:`none`}),M=(0,w.useCallback)(()=>{j.hide()},[j]),{listRef:N,handleKeyDown:P,focusFirst:F,focusItem:I,ownsEvent:L,getItems:R}=yb({itemSelector:Eb,boundarySelector:Db,wrap:!1,onEscape:M}),z=wb({getItemLabels:()=>R().map(e=>e.textContent),onMatch:I,getCurrentIndex:()=>R().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))});(0,w.useEffect)(()=>{E&&(t&&!j.isOpen?(k.current=!0,j.show()):!t&&j.isOpen&&j.hide())},[t,E,j]),(0,w.useEffect)(()=>{!j.isOpen||!k.current||(k.current=!1,requestAnimationFrame(()=>{(A.current===`pointer`||!F())&&N.current?.focus(),A.current=`keyboard`}))},[j.isOpen,F,N]);let B=(0,w.useCallback)(e=>{if(L(e)){if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=document.activeElement;t&&Tb.has(t.getAttribute(`role`)??``)&&t.click();return}if(e.key===`Tab`){M();return}if(z.onKeyDown(e)){e.preventDefault();return}P(e)}},[P,M,z,L]),V=(0,w.useCallback)((e=`keyboard`)=>{A.current=e,k.current=!0,j.show()},[j]),H=(0,w.useCallback)(e=>{if(j.wasJustDismissed())return;i?.();let r=e.detail===0?`keyboard`:`pointer`;E?(t||(A.current=r),n?.(!t)):j.isOpen?j.hide():V(r)},[i,E,n,t,j,V]),U=(0,w.useCallback)(e=>{j.isOpen||(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),V())},[j.isOpen,V]),ee=m.isIconOnly===!0,te=m.endContent??(a&&!ee?(0,K.jsx)(zy,{icon:`chevronDown`,size:`sm`,color:`inherit`}):void 0),ne=r?Ib.popoverCustomWidth(r):Ib.popover,W=(0,w.useMemo)(()=>({closeMenu:M,menuSize:x}),[M,x]),re=f.items===void 0?g:Fb(h);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Pv,{...m,ref:e=>{S.current=e,j.triggerRef(e);let t=m.ref;typeof t==`function`?t(e):t&&(t.current=e)},tooltip:D?void 0:m.tooltip,endContent:te,onClick:H,onKeyDown:U,"aria-haspopup":`menu`,"aria-expanded":D,"aria-controls":b,"data-testid":d}),j.render((0,K.jsx)(`div`,{...y,ref:N,id:b,role:`menu`,tabIndex:-1,"aria-label":m.label,onKeyDown:B,...rg(X(`dropdown-menu`),Y(Ib.dropdown,u),c,l),children:(0,K.jsx)(eb,{value:W,children:re})}),{placement:o,alignment:s,offset:om[`--spacing-1`],xstyle:[ne,yh[o]]})]})}Rb.displayName=`DropdownMenu`;var zb=s({Tooltip:()=>Hb});function Bb(e){return typeof e==`string`||typeof e==`number`}function Vb(...e){let t=e.filter(Boolean);return t.length>0?t.join(` `):void 0}function Hb({children:e,anchorRef:t,content:n,placement:r=`above`,alignment:i=`center`,delay:a=200,hideDelay:o=0,focusTrigger:s=`auto`,touchTrigger:c=`auto`,isEnabled:l=!0,onOpenChange:u,hasHoverIndication:d=`auto`,isOpen:f,isDefaultOpen:p}){let m=(0,w.useRef)(null),h=e!=null&&Bb(e),g=d===!0||d===`auto`&&h,_=Ph({placement:r,alignment:i,delay:a,hideDelay:o,focusTrigger:s,touchTrigger:c,isEnabled:l,isOpen:f,isDefaultOpen:p,onShow:(0,w.useCallback)(()=>{u?.(!0)},[u]),onHide:(0,w.useCallback)(()=>{u?.(!1)},[u])});return hb(()=>{if(!t)return;let e=t.current;if(!e)return;_.ref(e);let n=e.getAttribute(`aria-describedby`);return e.setAttribute(`aria-describedby`,Vb(n,_.describedBy)??``),()=>{_.ref(null),n?e.setAttribute(`aria-describedby`,n):e.removeAttribute(`aria-describedby`)}},[t,_.ref,_.describedBy]),hb(()=>{if(t||h)return;let e=m.current;if(!e)return;let n=e.firstElementChild;if(!n)return;_.ref(n);let r=n.getAttribute(`aria-describedby`);return n.setAttribute(`aria-describedby`,Vb(r,_.describedBy)??``),()=>{_.ref(null),r?n.setAttribute(`aria-describedby`,r):n.removeAttribute(`aria-describedby`)}},[t,h,_.ref,_.describedBy]),t&&e==null?(0,K.jsx)(K.Fragment,{children:_.renderTooltip(n)}):h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{ref:_.ref,tabIndex:0,"aria-describedby":_.describedBy,...{0:{className:`xt0psk2`},1:{className:`xt0psk2 xujl8zx xev0dqp xycaml9 xrys4gj`}}[!!g<<0],children:e}),_.renderTooltip(n)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:m,className:`xjp7ctv`,children:e}),_.renderTooltip(n)]})}Hb.displayName=`Tooltip`;function Ub(e,t){return e.name?.trim()||e.firstMessage?.trim()||t}function Wb(e){return e.split(/[\\/]/u).filter(Boolean).at(-1)||e}function Gb(e,t=2){let n=e.split(/[\\/]/u).filter(Boolean);return n.length<=t?e:`…/${n.slice(-t).join(`/`)}`}function Kb(e,t=96){let n=String(e??``).replace(/\s+/gu,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function qb(e){let t=Date.now()-new Date(e).getTime();return Number.isFinite(t)?t<6e4?`now`:t<36e5?`${Math.floor(t/6e4)}m`:t<864e5?`${Math.floor(t/36e5)}h`:new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`}):``}function Jb(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Yb(e,t=Date.now()){if(typeof e!=`number`)return``;let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/60),i=n%60;return r>0?`${r}m${String(i).padStart(2,`0`)}s`:`${i}s`}function Xb(e){let t=e.split(` -`).map(e=>e.trim()).find(Boolean)??``;return t.length>60?`${t.slice(0,60)}…`:t}function Zb(e){return e&&typeof e==`object`?e:{}}function Qb(e){let t=new Map;for(let n of e){let e=n.role===`toolResult`&&n.toolName===`subagent_spawn`,r=n.role===`toolResult`&&[`subagent_wait`,`subagent_check`].includes(n.toolName??``)||n.customType===`subagent-result`;if(!e&&!r||n.isError)continue;let i=Zb(n.details);for(let r of Array.isArray(i.results)?i.results:[i]){let a=Zb(r);if(typeof a.id!=`string`||!a.id||a.id.length>160||/[\u0000-\u001f\u007f]/u.test(a.id))continue;let o=t.get(a.id),s={...o,id:a.id,title:typeof a.title==`string`?a.title:o?.title??a.id};e?s.receipt=n.content:(s.result=typeof i.displayContent==`string`?i.displayContent:n.content,s.state=a.outcome===`interrupted`?`interrupted`:a.status===`done`||a.status===`error`||a.status===`running`?a.status:void 0),t.delete(a.id),t.set(a.id,s)}}return[...t.values()].slice(-32)}function $b(e){return e===`interrupted`?`interrupted`:e===`running`?`running`:e===`done`||e===`completed`?`done`:[`error`,`failed`,`aborted`,`killed`,`timed_out`].includes(e)?`error`:e===`uncertain`?`warn`:`unknown`}function ex({kind:e,label:t,status:n,onClick:r}){return(0,K.jsxs)(r?`button`:`span`,{className:`activity-chip ${e} ${n}`,type:r?`button`:void 0,onClick:r,children:[n===`running`?(0,K.jsx)(`i`,{className:`activity-chip-dot`}):n===`done`?(0,K.jsx)(B,{}):n===`error`?(0,K.jsx)(mt,{}):n===`interrupted`?(0,K.jsx)(ie,{}):(0,K.jsx)(`span`,{className:`activity-chip-glyph`,children:`?`}),(0,K.jsx)(`span`,{className:`activity-chip-text`,children:t})]})}function tx({snapshot:e,onInspectTerminal:t,onInspectSubagent:n}){let{t:r}=Ln(),[,i]=(0,w.useState)(0),a=e?.runtime.capabilities,o=(0,w.useMemo)(()=>Qb((e?.selectedSession?.entries??[]).flatMap(e=>e.message?[e.message]:[])),[e?.selectedSession?.entries]),s=a?.subagents,c=new Set([...(s?.items??[]).map(e=>e.id),...o.map(e=>e.id)]).size,l=Math.max(c,(s?.items.length??0)+(s?.omitted??0)),u=(s?.items??[]).filter(e=>e.status===`running`).length,d=[...a?.workflows?.items??[],...a?.[`background-terminals`]?.items??[]].some(e=>e.status===`running`);(0,w.useEffect)(()=>{if(!d)return;let e=window.setInterval(()=>i(e=>e+1),1e3);return()=>window.clearInterval(e)},[d]);let f=[];for(let e of a?.workflows?.items??[]){let t=e.agents.total-e.agents.running,n=e.agents.total?` · ${t}/${e.agents.total} agents`:``,r=e.status===`running`&&e.currentPhase?` · ${e.currentPhase}`:``,i=Yb(e.startedAt,e.finishedAt);f.push({key:`workflow-${e.runId}`,kind:`workflow`,label:`${e.name||e.runId}${r}${n}${i?` · ${i}`:``}`,status:$b(e.status)})}for(let e of a?.[`background-terminals`]?.items??[]){let n=Yb(e.createdAt,e.settledAt);f.push({key:`terminal-${e.id}`,onClick:t?()=>t(e.id):void 0,kind:`terminal`,label:`${e.title||e.id}${n?` · ${n}`:``}`,status:$b(e.status)})}f.sort((e,t)=>Number(t.status===`running`)-Number(e.status===`running`));let p=f.slice(0,5),m=f.length-p.length+(a?.workflows?.omitted??0)+(a?.[`background-terminals`]?.omitted??0);return!p.length&&!m&&!(n&&l)?null:(0,K.jsxs)(`div`,{className:`activity-bar`,role:`status`,"aria-label":`Runtime activity`,children:[n&&l>0&&(0,K.jsx)(`button`,{className:`activity-chip subagent-list-trigger`,type:`button`,onClick:()=>n(),children:r(`subagentList`,{count:l,running:u})}),p.map(({key:e,...t})=>(0,K.jsx)(ex,{...t},e)),m>0&&(0,K.jsxs)(`span`,{className:`activity-chip more`,children:[`+`,m]})]})}var nx={settle(){},release(){}};function rx(e){if(typeof window>`u`||typeof document>`u`)return nx;let t=document.documentElement,n=t.clientWidth;if(n===0)return nx;let r=t.style.scrollbarGutter,i=e.style.paddingRight,a=e.getBoundingClientRect().width,o=!1,s=!1,c=!1;return window.innerWidth>n&&(t.style.scrollbarGutter=`stable`,o=!0),{settle(){if(c)return;c=!0;let t=e.getBoundingClientRect().width-a;if(t<=0)return;let n=Number.parseFloat(window.getComputedStyle(e).paddingRight)||0;e.style.paddingRight=`${n+t}px`,s=!0},release(){s&&=(e.style.paddingRight=i,!1),o&&=(t.style.scrollbarGutter=r,!1)}}}var ix=0,ax=null;function ox(e){(0,w.useEffect)(()=>{if(!e)return;let{body:t}=document;if(ix===0){let e=window.scrollX,n=window.scrollY,r=rx(t);ax={scrollX:e,scrollY:n,overflow:t.style.overflow,position:t.style.position,top:t.style.top,left:t.style.left,right:t.style.right,gutter:r},t.style.overflow=`hidden`,t.style.position=`fixed`,t.style.top=`-${n}px`,t.style.left=`0`,t.style.right=`0`,r.settle()}return ix+=1,()=>{if(--ix,ix!==0||ax==null)return;let e=ax;ax=null,t.style.overflow=e.overflow,t.style.position=e.position,t.style.top=e.top,t.style.left=e.left,t.style.right=e.right,e.gutter.release(),window.scrollTo(e.scrollX,e.scrollY)}},[e])}var sx={container:{kB7OPa:`x9f619`,kZCmMZ:`x1c35znw`,kwRFfy:`x64h4k7`,kLKAdn:`x14m0hsi`,kGO01o:`xc1wllq`,$$css:!0}},cx=om[`--spacing-4`],lx=`var(--astryx-card-padding, ${cx})`,ux=`var(--astryx-card-padding-inline, ${lx})`;`${ux}`,`${ux}`,`${lx}`,`${lx}`;var dx=`var(--_section-padding-propagated, ${`var(--astryx-section-padding, ${cx})`})`,fx=`var(--astryx-section-padding-inline, ${dx})`;`${fx}`,`${fx}`,`${dx}`,`${dx}`;var px=`var(--astryx-dialog-padding, ${cx})`,mx=`var(--astryx-dialog-padding-inline, ${px})`;`${mx}`,`${mx}`,`${px}`,`${px}`;var hx={card:{containerPaddingInlineStart:{"--container-padding-inline-start":`xjmlhfd`,$$css:!0},containerPaddingInlineEnd:{"--container-padding-inline-end":`x1ihxwbr`,$$css:!0},containerPaddingBlockStart:{"--container-padding-block-start":`x1rqz8me`,$$css:!0},containerPaddingBlockEnd:{"--container-padding-block-end":`x1omyuck`,$$css:!0},layoutPaddingOuterX:{"--layout-padding-outer-x":`x14rzhog`,$$css:!0},layoutPaddingOuterY:{"--layout-padding-outer-y":`xjej9fs`,$$css:!0},layoutPaddingInnerX:{"--layout-padding-inner-x":`x4poyjn`,$$css:!0},layoutPaddingInnerY:{"--layout-padding-inner-y":`x1u1kw4e`,$$css:!0}},section:{containerPaddingInlineStart:{"--container-padding-inline-start":`x19lemt0`,$$css:!0},containerPaddingInlineEnd:{"--container-padding-inline-end":`xu1wldr`,$$css:!0},containerPaddingBlockStart:{"--container-padding-block-start":`xnw7zt4`,$$css:!0},containerPaddingBlockEnd:{"--container-padding-block-end":`xek4msv`,$$css:!0},layoutPaddingOuterX:{"--layout-padding-outer-x":`x15i0zw9`,$$css:!0},layoutPaddingOuterY:{"--layout-padding-outer-y":`x1vw4zgg`,$$css:!0},layoutPaddingInnerX:{"--layout-padding-inner-x":`x1v3gmnx`,$$css:!0},layoutPaddingInnerY:{"--layout-padding-inner-y":`x15yx5hm`,$$css:!0}},dialog:{containerPaddingInlineStart:{"--container-padding-inline-start":`x1tewnwq`,$$css:!0},containerPaddingInlineEnd:{"--container-padding-inline-end":`x11h1f2o`,$$css:!0},containerPaddingBlockStart:{"--container-padding-block-start":`x1g2kccc`,$$css:!0},containerPaddingBlockEnd:{"--container-padding-block-end":`x1gvthzm`,$$css:!0},layoutPaddingOuterX:{"--layout-padding-outer-x":`x1hsjncj`,$$css:!0},layoutPaddingOuterY:{"--layout-padding-outer-y":`x1pui4bz`,$$css:!0},layoutPaddingInnerX:{"--layout-padding-inner-x":`x2so38`,$$css:!0},layoutPaddingInnerY:{"--layout-padding-inner-y":`xinu7xd`,$$css:!0}}},gx={spacing0:{"--container-padding-inline-start":`x1gu2k80`,$$css:!0},spacing0_5:{"--container-padding-inline-start":`x14ws0sr`,$$css:!0},spacing1:{"--container-padding-inline-start":`x1cvlban`,$$css:!0},spacing1_5:{"--container-padding-inline-start":`x176g23i`,$$css:!0},spacing2:{"--container-padding-inline-start":`x1xlrr2o`,$$css:!0},spacing3:{"--container-padding-inline-start":`xfdwxua`,$$css:!0},spacing4:{"--container-padding-inline-start":`x1dlhslv`,$$css:!0},spacing5:{"--container-padding-inline-start":`x1s81nki`,$$css:!0},spacing6:{"--container-padding-inline-start":`x1ep0dkj`,$$css:!0},spacing7:{"--container-padding-inline-start":`x157xojc`,$$css:!0},spacing8:{"--container-padding-inline-start":`xw1diwv`,$$css:!0},spacing9:{"--container-padding-inline-start":`xraca2a`,$$css:!0},spacing10:{"--container-padding-inline-start":`xserb3f`,$$css:!0},spacing11:{"--container-padding-inline-start":`xziclwo`,$$css:!0},spacing12:{"--container-padding-inline-start":`x1iiwihq`,$$css:!0}},_x={spacing0:{"--container-padding-inline-end":`x91ghl5`,$$css:!0},spacing0_5:{"--container-padding-inline-end":`x1wz3t3y`,$$css:!0},spacing1:{"--container-padding-inline-end":`x2oyxnl`,$$css:!0},spacing1_5:{"--container-padding-inline-end":`xntetml`,$$css:!0},spacing2:{"--container-padding-inline-end":`xcas3b9`,$$css:!0},spacing3:{"--container-padding-inline-end":`xu0ipoa`,$$css:!0},spacing4:{"--container-padding-inline-end":`xs0pscg`,$$css:!0},spacing5:{"--container-padding-inline-end":`xgkj7vj`,$$css:!0},spacing6:{"--container-padding-inline-end":`x94cj42`,$$css:!0},spacing7:{"--container-padding-inline-end":`x11tj35w`,$$css:!0},spacing8:{"--container-padding-inline-end":`x1b9k1pi`,$$css:!0},spacing9:{"--container-padding-inline-end":`x19w02kr`,$$css:!0},spacing10:{"--container-padding-inline-end":`xx5lg5w`,$$css:!0},spacing11:{"--container-padding-inline-end":`x1nmgbqg`,$$css:!0},spacing12:{"--container-padding-inline-end":`x1wsfsk2`,$$css:!0}},vx={spacing0:{"--container-padding-block-start":`x1i3qcxz`,$$css:!0},spacing0_5:{"--container-padding-block-start":`xvdf9ev`,$$css:!0},spacing1:{"--container-padding-block-start":`xnsckjb`,$$css:!0},spacing1_5:{"--container-padding-block-start":`x1kbx601`,$$css:!0},spacing2:{"--container-padding-block-start":`xa8b4fq`,$$css:!0},spacing3:{"--container-padding-block-start":`x11k4f5r`,$$css:!0},spacing4:{"--container-padding-block-start":`xm01sq8`,$$css:!0},spacing5:{"--container-padding-block-start":`xp8wdkl`,$$css:!0},spacing6:{"--container-padding-block-start":`x1hmud4d`,$$css:!0},spacing7:{"--container-padding-block-start":`x1c00sag`,$$css:!0},spacing8:{"--container-padding-block-start":`xfv60at`,$$css:!0},spacing9:{"--container-padding-block-start":`x14fzdu7`,$$css:!0},spacing10:{"--container-padding-block-start":`x17h9kl7`,$$css:!0},spacing11:{"--container-padding-block-start":`x1rdjxae`,$$css:!0},spacing12:{"--container-padding-block-start":`xecwdl6`,$$css:!0}},yx={spacing0:{"--container-padding-block-end":`xkunwnr`,$$css:!0},spacing0_5:{"--container-padding-block-end":`x1cao3zv`,$$css:!0},spacing1:{"--container-padding-block-end":`x57a7ii`,$$css:!0},spacing1_5:{"--container-padding-block-end":`xv53x8y`,$$css:!0},spacing2:{"--container-padding-block-end":`x1lsgcmx`,$$css:!0},spacing3:{"--container-padding-block-end":`x1q3ppug`,$$css:!0},spacing4:{"--container-padding-block-end":`x4hfsld`,$$css:!0},spacing5:{"--container-padding-block-end":`xbib2ws`,$$css:!0},spacing6:{"--container-padding-block-end":`x1q8d17g`,$$css:!0},spacing7:{"--container-padding-block-end":`x1yqogew`,$$css:!0},spacing8:{"--container-padding-block-end":`x8lgq76`,$$css:!0},spacing9:{"--container-padding-block-end":`x1f7f9rt`,$$css:!0},spacing10:{"--container-padding-block-end":`x15vxphk`,$$css:!0},spacing11:{"--container-padding-block-end":`x4bg2x9`,$$css:!0},spacing12:{"--container-padding-block-end":`x186mjxr`,$$css:!0}},bx={spacing0:{"--layout-padding-outer-x":`xswhm3q`,$$css:!0},spacing0_5:{"--layout-padding-outer-x":`xihiwg7`,$$css:!0},spacing1:{"--layout-padding-outer-x":`xc96xmq`,$$css:!0},spacing1_5:{"--layout-padding-outer-x":`x1u93lgd`,$$css:!0},spacing2:{"--layout-padding-outer-x":`x15dxnc0`,$$css:!0},spacing3:{"--layout-padding-outer-x":`xadgj3j`,$$css:!0},spacing4:{"--layout-padding-outer-x":`x1v56qcf`,$$css:!0},spacing5:{"--layout-padding-outer-x":`x1nzs0gl`,$$css:!0},spacing6:{"--layout-padding-outer-x":`x1c3n52a`,$$css:!0},spacing7:{"--layout-padding-outer-x":`x1gfiokx`,$$css:!0},spacing8:{"--layout-padding-outer-x":`x1t3kfz`,$$css:!0},spacing9:{"--layout-padding-outer-x":`xzr4qsh`,$$css:!0},spacing10:{"--layout-padding-outer-x":`x1jdf5a4`,$$css:!0},spacing11:{"--layout-padding-outer-x":`x1hct0t0`,$$css:!0},spacing12:{"--layout-padding-outer-x":`x11cyqoe`,$$css:!0}},xx={spacing0:{"--layout-padding-outer-y":`x1mzf5mb`,$$css:!0},spacing0_5:{"--layout-padding-outer-y":`x1vj96e0`,$$css:!0},spacing1:{"--layout-padding-outer-y":`x1gpfxoh`,$$css:!0},spacing1_5:{"--layout-padding-outer-y":`xd3dqby`,$$css:!0},spacing2:{"--layout-padding-outer-y":`x10pz7y9`,$$css:!0},spacing3:{"--layout-padding-outer-y":`x1p6yq3h`,$$css:!0},spacing4:{"--layout-padding-outer-y":`xx738ci`,$$css:!0},spacing5:{"--layout-padding-outer-y":`x6yxws5`,$$css:!0},spacing6:{"--layout-padding-outer-y":`x180vrwl`,$$css:!0},spacing7:{"--layout-padding-outer-y":`x1q6rme1`,$$css:!0},spacing8:{"--layout-padding-outer-y":`xid7e43`,$$css:!0},spacing9:{"--layout-padding-outer-y":`x1t5kicu`,$$css:!0},spacing10:{"--layout-padding-outer-y":`x26l4wa`,$$css:!0},spacing11:{"--layout-padding-outer-y":`x10zktp0`,$$css:!0},spacing12:{"--layout-padding-outer-y":`x1yz3n6a`,$$css:!0}},Sx={spacing0:{"--layout-padding-inner-x":`xj1bl4l`,$$css:!0},spacing0_5:{"--layout-padding-inner-x":`xlriy2h`,$$css:!0},spacing1:{"--layout-padding-inner-x":`x6uuyak`,$$css:!0},spacing1_5:{"--layout-padding-inner-x":`xd38f90`,$$css:!0},spacing2:{"--layout-padding-inner-x":`xxqksqd`,$$css:!0},spacing3:{"--layout-padding-inner-x":`x1fyui2f`,$$css:!0},spacing4:{"--layout-padding-inner-x":`x1i2ajwi`,$$css:!0},spacing5:{"--layout-padding-inner-x":`x1tac27u`,$$css:!0},spacing6:{"--layout-padding-inner-x":`x1ntgf3t`,$$css:!0},spacing7:{"--layout-padding-inner-x":`xhjd9tl`,$$css:!0},spacing8:{"--layout-padding-inner-x":`xn7c84u`,$$css:!0},spacing9:{"--layout-padding-inner-x":`xeqkbsz`,$$css:!0},spacing10:{"--layout-padding-inner-x":`x1vf4qco`,$$css:!0},spacing11:{"--layout-padding-inner-x":`xsmamsf`,$$css:!0},spacing12:{"--layout-padding-inner-x":`x2xk2xj`,$$css:!0}},Cx={spacing0:{"--layout-padding-inner-y":`xwuefyo`,$$css:!0},spacing0_5:{"--layout-padding-inner-y":`x180h0y5`,$$css:!0},spacing1:{"--layout-padding-inner-y":`xmpug6m`,$$css:!0},spacing1_5:{"--layout-padding-inner-y":`x1g8jpzm`,$$css:!0},spacing2:{"--layout-padding-inner-y":`x1lksgje`,$$css:!0},spacing3:{"--layout-padding-inner-y":`x4j7gld`,$$css:!0},spacing4:{"--layout-padding-inner-y":`x1s3ehtl`,$$css:!0},spacing5:{"--layout-padding-inner-y":`x1rj5eim`,$$css:!0},spacing6:{"--layout-padding-inner-y":`x1ftgg6u`,$$css:!0},spacing7:{"--layout-padding-inner-y":`x1ho74vh`,$$css:!0},spacing8:{"--layout-padding-inner-y":`xm2cs6f`,$$css:!0},spacing9:{"--layout-padding-inner-y":`x1vsq92b`,$$css:!0},spacing10:{"--layout-padding-inner-y":`x18gbwmk`,$$css:!0},spacing11:{"--layout-padding-inner-y":`x14zymzj`,$$css:!0},spacing12:{"--layout-padding-inner-y":`xzfpkx9`,$$css:!0}},wx={containerMaxHeight:e=>[{"--container-max-height":e==null?e:`x18nyedi`,$$css:!0},{"--x---container-max-height":e??void 0}]};function Tx({padding:e=`spacing4`,paddingOuterX:t,paddingOuterY:n,paddingInnerX:r,paddingInnerY:i,useThemeDefault:a,maxHeight:o}){let s=t??e,c=n??e,l=r??e,u=i??e,d=o?wx.containerMaxHeight(o):null;if(a){let e=hx[a];return[sx.container,e.containerPaddingInlineStart,e.containerPaddingInlineEnd,e.containerPaddingBlockStart,e.containerPaddingBlockEnd,e.layoutPaddingOuterX,e.layoutPaddingOuterY,e.layoutPaddingInnerX,e.layoutPaddingInnerY,d]}return[sx.container,gx[s],_x[s],vx[c],yx[c],bx[s],xx[c],Sx[l],Cx[u],d]}var Ex=(0,w.createContext)(null);Ex.displayName=`DialogContext`;function Dx(e,t=16){let n=e.getBoundingClientRect(),r=n.left+n.width/2-window.innerWidth/2,i=n.top+n.height/2-window.innerHeight/2,a=Math.sqrt(r*r+i*i)||1;return{x:Math.round(r/a*t),y:Math.round(i/a*t)}}`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`;var Ox={dialog:{kVAEAm:`xixxii4`,kogj98:`x1bpp3o7`,kmVPX3:`x1717udv`,kWkggS:`x10xzikg`,"--_dialog-radius":`xvuvksw`,kaIpWk:`xuacgfc`,kGVxlE:`x1kcpxr7`,k1xSpc:`x1s85apg`,kXwgrk:`xdt5ytf`,kZKoxP:`xg7h5cd`,kZeWKH:`xish69e`,kSiTet:`xg01cxk`,k44tkh:`xqgcaz`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},open:{k1xSpc:`x78zum5`,kSiTet:`x1hc1fzr`,kKVMdj:`x1ewfqum x1aquc0h`,$$css:!0},backdrop:{kGyWv1:`xnixb3f`,kba3nw:`x1abwkk1`,$$css:!0},fullscreen:{kzqmXN:`x1o6l61p`,kZKoxP:`xtdtrs8`,ks0D6T:`xlbgzzq`,kskxy:`x1wj9ous`,kaIpWk:`x2u8bby`,kogj98:`x1ghz6dp`,kpwlN0:`x10a8y8t`,$$css:!0},fullscreenOpen:{kKVMdj:`xqcmdr3 x1aquc0h`,$$css:!0},fullscreenSafeArea:{kLKAdn:`x15ld1ci`,kGO01o:`x1rgxemn`,kZCmMZ:`xqmdmw x1i7f2ot`,kwRFfy:`x1by8st6 xtjjor6`,$$css:!0},inner:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kUk6DE:`x12lumcd`,kAzted:`x2lwn1j`,kVQacm:`xb3r6kr`,kaIpWk:`x1pjcqnp`,$$css:!0},inlineWrapper:{kmVPX3:`x1717udv`,kWkggS:`x10xzikg`,"--_dialog-radius":`xvuvksw`,kaIpWk:`xuacgfc`,kGVxlE:`x1kcpxr7`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kZKoxP:`xg7h5cd`,kZeWKH:`xish69e`,$$css:!0}},kx=om[`--spacing-4`],Ax=`min(100%, ${`calc(100dvw - ${kx} - ${kx})`})`;function jx(e){return typeof e==`number`?`${e}px`:e}function Mx(e,t){return{width:jx(e),maxWidth:Ax,maxHeight:jx(t)}}var Nx={kogj98:`x1ghz6dp`,$$css:!0},Px={sizing:(e,t,n)=>[{kzqmXN:e==null?e:`x5lhr3w`,ks0D6T:t==null?t:`xf68679`,kskxy:n==null?n:`x1jols5v`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-maxWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(t),"--x-maxHeight":(e=>typeof e==`number`?e+`px`:e??void 0)(n)}],position:(e,t,n,r)=>[Nx,{k87sOh:e==null?e:`xjbys53`,kLqNvP:t==null?t:`x1lxsm33`,kt4wiu:n==null?n:`xqxgn94`,krVfgx:r==null?r:`x1nqzi6q`,$$css:!0},{"--x-top":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-insetInlineStart":(e=>typeof e==`number`?e+`px`:e??void 0)(t),"--x-insetInlineEnd":(e=>typeof e==`number`?e+`px`:e??void 0)(n),"--x-bottom":(e=>typeof e==`number`?e+`px`:e??void 0)(r)}]};function Fx(e){return typeof e==`number`?`${e}px`:e}function Ix(e){let{top:t,bottom:n,start:r,end:i}=e;return{top:t===void 0?`auto`:Fx(t),bottom:n===void 0?`auto`:Fx(n),insetInlineStart:r===void 0?`auto`:Fx(r),insetInlineEnd:i===void 0?`auto`:Fx(i)}}function Lx({isOpen:e,isInline:t=!1,onOpenChange:n,width:r=400,maxHeight:i=`75dvh`,position:a,variant:o=`standard`,purpose:s=`info`,padding:c,children:l,xstyle:u,className:d,style:f,ref:p,...m}){let h=c==null,g=c??4,_=um[g],v=o===`fullscreen`,y=v?null:Mx(r,i),b=(0,w.useId)(),x=(0,w.useMemo)(()=>({isInline:t,titleId:b}),[t,b]),S=m[`aria-label`]!=null||m[`aria-labelledby`]!=null,C=(0,w.useRef)(null),T=_g(p,(0,w.useCallback)(e=>{C.current=e,!(!e||S)&&(e.querySelector(`#${CSS.escape(b)}`)==null?e.removeAttribute(`aria-labelledby`):e.setAttribute(`aria-labelledby`,b))},[b,S])),E=(0,w.useRef)(null),D=s!==`required`,O=s===`info`;(0,w.useEffect)(()=>{if(t)return;let n=C.current;if(n)if(e){E.current=document.activeElement;let e=E.current;if(e&&e!==document.body){let t=Dx(e);n.style.setProperty(`--dialog-dir-x`,`${t.x}px`),n.style.setProperty(`--dialog-dir-y`,`${t.y}px`)}else n.style.setProperty(`--dialog-dir-x`,`0px`),n.style.setProperty(`--dialog-dir-y`,`16px`);if(!n.open){n.showModal();let e=n.querySelector(`[data-autofocus]`);e&&e.focus()}}else n.open&&n.close(),E.current?.focus(),E.current=null},[e,t]),ox(e&&!t);let{shouldDismissOnCloseRequest:k}=eh({isActive:e,isEnabled:!t,escapeBehavior:D?`close`:`block`,onDismiss:()=>{n(!1)}}),A=(0,w.useRef)(!1);(0,w.useEffect)(()=>{let n=C.current?.querySelector(`#${CSS.escape(b)}`)!=null;e&&!t&&!S&&!n&&!A.current&&(A.current=!0)},[e,t,S,b]);let j=e=>{e.target===e.currentTarget&&O&&n(!1)},M=e=>{e.preventDefault(),k()&&D&&n(!1)},N=(0,K.jsx)(`div`,{...Y(Ox.inner,...Tx(h?{useThemeDefault:`dialog`,maxHeight:y?.maxHeight}:{paddingInnerX:_,paddingInnerY:_,paddingOuterX:_,paddingOuterY:_,maxHeight:y?.maxHeight}),!h&&g!==4&&dm[g],!h&&g!==4&&fm[g],!h&&g!==4&&pm[g],!h&&g!==4&&mm[g],v&&h&&Ox.fullscreenSafeArea),children:(0,K.jsx)(Ex,{value:x,children:l})}),P=a!=null&&!v,{open:F,...I}=m;return t?e?(0,K.jsx)(`div`,{...I,...rg(X(`dialog`,{variant:o}),Y(Ox.inlineWrapper,ym.reset,y&&Px.sizing(y.width,y.maxWidth,y.maxHeight),v&&Ox.fullscreen,u),d,f),"data-testid":m[`data-testid`],children:(0,K.jsx)(Nm,{children:N})}):null:(0,K.jsx)(`dialog`,{ref:T,...I,...rg(X(`dialog`,{variant:o}),gg.focusVisible(Ox.dialog,ym.reset,e&&Ox.open,Ox.backdrop,y&&Px.sizing(y.width,y.maxWidth,y.maxHeight),P&&(()=>{let e=Ix(a);return Px.position(e.top,e.insetInlineStart,e.insetInlineEnd,e.bottom)})(),v&&Ox.fullscreen,v&&e&&Ox.fullscreenOpen,u),d,f),onClick:j,onCancel:M,"aria-modal":`true`,...s===`required`?{role:`alertdialog`}:void 0,children:(0,K.jsx)(Nm,{children:N})})}Lx.displayName=`Dialog`;var Rx=`data-astryx-live-region`,zx=`position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;inset-block-start:0;inset-inline-start:0;pointer-events:none;user-select:none;`,Bx=2e3,Vx={polite:null,assertive:null};function Hx(e){let t=Vx[e];t!=null&&(clearTimeout(t),Vx[e]=null)}function Ux(e,t){Hx(e),Vx[e]=setTimeout(()=>{Vx[e]=null,t.textContent=``},Bx)}var Wx=null;function Gx(e){let t=document.createElement(`div`);return t.setAttribute(Rx,e),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(`role`,e===`assertive`?`alert`:`status`),t.style.cssText=zx,document.body.appendChild(t),t}function Kx(){return typeof document>`u`?null:Wx?(Wx.polite.isConnected||document.body.appendChild(Wx.polite),Wx.assertive.isConnected||document.body.appendChild(Wx.assertive),Wx):(Wx={polite:Gx(`polite`),assertive:Gx(`assertive`)},Wx)}function qx(e,t){let n=Kx();if(!n)return;let r=t===`assertive`?n.assertive:n.polite;r.textContent=``,requestAnimationFrame(()=>{r.textContent=e}),Ux(t,r)}function Jx(e){if(Hx(e),!Wx)return;let t=e===`assertive`?Wx.assertive:Wx.polite;t.textContent=``}function Yx(){return(0,w.useCallback)((e,t=`polite`)=>{if(!e){Jx(t);return}qx(e,t)},[])}var Xx=!1;typeof window<`u`&&requestAnimationFrame(()=>{Xx=!0});var Zx={slideDown:{kKVMdj:`x1srr2gu x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},slideUp:{kKVMdj:`x1dvww92 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},fadeIn:{kKVMdj:`xqcmdr3 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},scaleIn:{kKVMdj:`x97zbip x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0}};function Qx(e=`slideDown`){let[t]=(0,w.useState)(()=>Xx);return t?Zx[e]:null}var $x=new Set([`text`,`password`,`email`,`number`,`search`,`tel`,`url`,`date`,`datetime-local`,`month`,`time`,`week`]),eS=new Set([`true`,`menu`,`listbox`,`tree`,`grid`,`dialog`]);function tS(e){if(e.getAttribute(`role`)===`combobox`)return!0;let t=e.getAttribute(`aria-haspopup`);return t!=null&&eS.has(t)}function nS({containerRef:e,inputRef:t,disabled:n=!1}){return Jy({containerRef:e,interactiveRef:t,onClick:(0,w.useCallback)(()=>{let e=t.current;e!=null&&(e instanceof HTMLElement&&tS(e)?e.click():e instanceof HTMLInputElement&&$x.has(e.type)||e instanceof HTMLTextAreaElement?e.focus():e instanceof HTMLElement?e.click():`focus`in e&&e.focus())},[t]),disabled:n})}var rS={warning:`warning`,error:`error`,success:`success`},iS={warning:`@astryx.input.statusButton.warning`,error:`@astryx.input.statusButton.error`,success:`@astryx.input.statusButton.success`},aS={statusButton:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmVPX3:`x1717udv`,kogj98:`x1ghz6dp`,kMwMTN:`x1heor9g`,kkrTdU:`x1ypdohk x16khyan`,kfzvcC:`x67bb7w`,kaIpWk:`xjspbzw`,kInvED:`x7s97pk`,$$css:!0}};function oS({status:e,statusVariant:t=`attached`,isInGroup:n=!1,size:r=`md`}){let i=Tv(),a=t===`tooltip`&&!!e?.message,[o,s]=(0,w.useState)(void 0),c=Ph({placement:`above`,isEnabled:a,isOpen:o}),l=(0,w.useCallback)(()=>{s(void 0)},[]),u=(0,w.useCallback)(()=>{typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(hover: none)`).matches||s(e=>e!==!0)},[]);if((0,w.useEffect)(()=>{if(o!==!0)return;let e=e=>{e.key===`Escape`&&s(void 0)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]),!(e&&!n&&t!==`detached`))return{statusIcon:null,describedBy:void 0};let d=(0,K.jsx)(zy,{icon:rS[e.type],size:r,color:e.type,...X(`input-status-icon`,{size:r,status:e.type})});return a?{statusIcon:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,ref:c.ref,"aria-label":i(iS[e.type]),"aria-describedby":c.describedBy,onClick:u,onBlur:l,...Y(mg.focusVisible,aS.statusButton),children:d}),c.renderTooltip(e.message)]}),describedBy:c.describedBy}:{statusIcon:d,describedBy:void 0}}var sS=(0,w.createContext)({direction:`vertical`});sS.displayName=`FormLayoutContext`;var cS={label:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`xzye2dw`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kLWn49:`x1kq96og`,k63SB2:`x1e4wzip`,kMwMTN:`xv1l7n4`,kkrTdU:`x1ypdohk x16khyan`,$$css:!0},labelDisabled:{kMwMTN:`xnbbluu`,kkrTdU:`xt0e3qv`,$$css:!0},srOnly:{ksu8eU:`xng3xce`,kMcinP:`xzpqnlu`,kZKoxP:`xjm9jq1`,kLqNvP:`x1o0tod`,kogj98:`xkdpibf`,kVQacm:`xb3r6kr`,kmVPX3:`x1717udv`,kfzvcC:`x47corl`,kVAEAm:`x10l6tqk`,k87sOh:`x13vifvy`,kfSwDN:`x87ps6o`,khDVqt:`xuxw1ft`,kzqmXN:`x1i1rx1s`,$$css:!0}};function lS({label:e,inputID:t,labelID:n,isGroupLabel:r=!1,isLabelHidden:i=!1,isDisabled:a=!1,isOptional:o=!1,isRequired:s=!1,labelIcon:c,labelTooltip:l,description:u,descriptionID:d,className:f,style:p,xstyle:m,ref:h,...g}){let _=Tv(),{defaultOptionality:v}=(0,w.use)(sS),y=o&&v!==`optional`?_(`@astryx.field.optional`):s&&v!==`required`?_(`@astryx.field.required`):null,b=r?`span`:`label`,x=!r&&t!=null,S=(0,w.useRef)(null),C=nS({containerRef:S,inputRef:(0,w.useMemo)(()=>({get current(){return t==null?null:S.current?.ownerDocument.getElementById(t)??null},set current(e){}}),[t]),disabled:!x}),T=(0,K.jsxs)(K.Fragment,{children:[c&&Vy(c,{size:`sm`,color:`inherit`}),e,y&&(0,K.jsxs)(`span`,{className:`x1sodnla x141an7d x1ltkj2j xv1l7n4`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:` ∙ `}),y]}),l&&(0,K.jsx)(Hb,{content:l,placement:`above`,children:(0,K.jsx)(zy,{icon:`info`,size:`sm`,color:`inherit`})})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(b,{ref:h,id:n,htmlFor:r?void 0:t,...g,...rg(X(`field-label`),Y(cS.label,a&&cS.labelDisabled,i&&cS.srOnly,m),f,p),children:T}),u&&(0,K.jsx)(`span`,{ref:x?S:void 0,id:d,...x?C:void 0,...{0:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4`},2:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 x1ypdohk x16khyan`},1:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 xng3xce xzpqnlu xjm9jq1 x1o0tod xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s`},3:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 x1ypdohk x16khyan xng3xce xzpqnlu xjm9jq1 x1o0tod xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s`}}[!!x<<1|!!i<<0],children:u})]})}lS.displayName=`FieldLabel`;var uS={warning:`warning`,error:`error`,success:`success`},dS={base:{kMv6JI:`x9ynric`,kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,$$css:!0},attached:{keoZOQ:`x1c40v9y`,kLKAdn:`x1ak3mig`,kGO01o:`x1wesfrj`,kg3NbH:`xf314gf`,kVL7Gh:`xquck67`,kT0f0o:`x14i3lts`,$$css:!0},detached:{keoZOQ:`xcsaf9d`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`xh6dtrn`,$$css:!0}},fS={warning:{kWkggS:`x24i8r5`,kMwMTN:`xdhq94a`,$$css:!0},error:{kWkggS:`x1pritpl`,kMwMTN:`x1joocv1`,$$css:!0},success:{kWkggS:`xu13z74`,kMwMTN:`xltfdvo`,$$css:!0}};function pS({ref:e,type:t,message:n,id:r,variant:i=`attached`,xstyle:a,className:o,style:s,...c}){let l=Qx(`slideDown`),u=Yx();return(0,w.useEffect)(()=>{n&&u(n,t===`error`?`assertive`:`polite`)},[u,n,t]),(0,K.jsx)(`div`,{ref:e,id:r,...c,...rg(X(`field-status`,{type:t,variant:i}),Y(dS.base,l,i===`attached`?dS.attached:dS.detached,fS[t],a),o,s),children:i===`detached`?(0,K.jsxs)(`span`,{className:`x78zum5 x1cy8zhl xzye2dw`,children:[(0,K.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 x14o5nre x2lah0s`,children:(0,K.jsx)(zy,{icon:uS[t],size:`sm`,color:`inherit`,...X(`field-status-icon`,{type:t})})}),(0,K.jsx)(`span`,{children:n})]}):n})}pS.displayName=`FieldStatus`;var mS={container:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,$$css:!0},containerGap:{kOIVth:`xzye2dw`,$$css:!0},horizontalLabels:{k1xSpc:`xjp7ctv`,$$css:!0}},hS={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function gS({label:e,isLabelHidden:t=!1,description:n,inputID:r,labelID:i,isGroupLabel:a=!1,descriptionID:o,isOptional:s=!1,isRequired:c=!1,isDisabled:l=!1,labelIcon:u,status:d,labelTooltip:f,statusVariant:p=`attached`,width:m,xstyle:h,children:g,className:_,style:v,ref:y,...b}){let{direction:x}=(0,w.use)(sS),S=x===`horizontal-labels`,C=o??(n?`${r}-desc`:void 0),T=d?.messageID??(d?.message?`${r}-status`:void 0);Fv(`Field`,`isOptional and isRequired are mutually exclusive. isOptional takes precedence.`,s&&c);let E=(0,K.jsx)(lS,{label:e,inputID:r,labelID:i,isGroupLabel:a,isLabelHidden:t,isDisabled:l,isOptional:s,isRequired:c,labelIcon:u,labelTooltip:f,description:S?void 0:n,descriptionID:S?void 0:C}),D=d?.message&&p!==`tooltip`?(0,K.jsx)(pS,{type:d.type,message:d.message,id:T,variant:p}):null;return S?(0,K.jsxs)(`div`,{ref:y,...rg(X(`field`,{layout:`horizontal-labels`}),Y(mS.horizontalLabels,h),_,v),...b,children:[(0,K.jsx)(`div`,{className:`x1enrzb7`,children:E}),(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf xc8icb0`,children:[n&&(0,K.jsx)(Eg,{type:`supporting`,display:`block`,id:C,children:n}),g,D]})]}):(0,K.jsxs)(`div`,{ref:y,...rg(X(`field`),Y(mS.container,!t&&mS.containerGap,m!=null&&hS.width(m),h),_,v),...b,children:[E,p===`attached`?(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf xc8icb0`,children:[g,D]}):(0,K.jsxs)(K.Fragment,{children:[g,D]})]})}gS.displayName=`Field`;var _S={base:{kB7OPa:`x9f619`,kVAEAm:`x1n2onr6`,kY2c9j:`x1vjfegm`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kVAM5u:`xvy26l8 x6q1khz`,"--_field-radius":`x1832zxr`,kaIpWk:`xvdfih8`,kWkggS:`x10xzikg`,k1ekBW:`x12zzom9`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,kGVxlE:`x1gnnqk1 x1xqjsvb xuihb5h`,kI3sdo:`x1a2a7pz`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,kSiTet:`xbyyjgo`,kVAM5u:`xvy26l8`,kGVxlE:`x1gnnqk1`,$$css:!0}},vS={warning:{kVAM5u:`x8wg1ba`,$$css:!0},error:{kVAM5u:`x1ofxpqo`,$$css:!0},success:{kVAM5u:`x16m2moy`,$$css:!0}},yS={warning:{kGVxlE:`x1gnnqk1 x9156jc`,$$css:!0},error:{kGVxlE:`x1gnnqk1 x1bgmis8`,$$css:!0},success:{kGVxlE:`x1gnnqk1 x8wp45d`,$$css:!0}},bS={warning:{kVAM5u:`x8wg1ba xa1yw2k`,$$css:!0},error:{kVAM5u:`x1ofxpqo xk2sxw7`,$$css:!0},success:{kVAM5u:`x16m2moy xyq33ac`,$$css:!0}},xS={button:{kZKoxP:`x1qx5ct2`,kmuXW:`x2lah0s`,kVAEAm:`x1n2onr6`,"--_input-clear-hit-inset":`xtoycft x181bpwf`,"--_input-clear-hit-content":`xqxtgf4 xp8r40j`,k5JduY:`xh3pasq`,kwXMNM:`x1j6awrg`,kv0HGH:`xht581f`,$$css:!0}};function SS({label:e,onClick:t,onPointerDown:n,onClickCapture:r,xstyle:i,iconClassName:a}){let{className:o}=X(`input-clear-icon`),{className:s}=X(`input-clear-button`);return(0,K.jsx)(Pv,{variant:`ghost`,size:`sm`,label:e,className:s,icon:(0,K.jsx)(zy,{icon:`close`,size:`sm`,color:`secondary`,className:a==null?o:`${o} ${a}`}),onClick:t,onPointerDown:n,onClickCapture:r,isIconOnly:!0,xstyle:[xS.button,i]})}function CS(e){return SS(e)}CS.displayName=`InputClearButton`;var wS={inGroup:{kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,kZKoxP:`x5yr21d`,keTefX:`xd10s4z x1pwwqoy`,krdFHd:`x15mokao x8eehn2`,kVL7Gh:`xbiv7yw x1xrp5p4`,kfmiAY:`x1ga7v0g x1tzxhge`,kT0f0o:`x16uus16 x1rmb4wm`,kXnDq0:`x1rm9qnc`,$$css:!0}};function TS({isRequired:e=!1,isOptional:t=!1}){let{defaultOptionality:n}=(0,w.use)(sS);return!t&&(e||n===`required`)}var ES=(0,w.createContext)(null);ES.displayName=`InputGroupContext`;function DS(){return(0,w.use)(ES)}var OS={sm:{kZKoxP:`x6k0iem`,$$css:!0},md:{kZKoxP:`x1ueg155`,$$css:!0},lg:{kZKoxP:`xssyfek`,$$css:!0}};function kS({type:e=`text`,label:t,isLabelHidden:n=!1,description:r,isOptional:i=!1,isRequired:a=!1,isDisabled:o=!1,isReadOnly:s=!1,disabledMessage:c,startIcon:l,status:u,statusVariant:d=`attached`,size:f,onChange:p,changeAction:m,isLoading:h=!1,value:g,placeholder:_,labelTooltip:v,hasClear:y=!1,hasAutoFocus:b=!1,htmlName:x,onEnter:S,onKeyDown:C,width:T,xstyle:E,className:D,style:O,ref:k,...A}){let j=Tv(),M=TS({isRequired:a,isOptional:i}),N=Kg(f,`md`),P=(0,w.useId)(),F=(0,w.useId)(),I=(0,w.useId)(),L=(0,w.useId)(),R=(0,w.useRef)(null),z=(0,w.useRef)(null),B=DS(),[,V]=(0,w.useTransition)(),[H,U]=(0,w.useOptimistic)(g),ee=h||H!==g,te=o&&!!c,ne=Ph({placement:`above`,focusTrigger:`always`,isEnabled:te}),{statusIcon:W,describedBy:re}=oS({status:u,statusVariant:d,isInGroup:!!B}),{ariaLabelledBy:ie,ariaDescribedBy:ae}=cg(F,[r?I:null,!B&&d!==`tooltip`&&u?.message?L:null,re,te?ne.describedBy:null],B),oe=e=>{if(o||s)return;let t=e.target.value;p?.(t,e),m&&!e.defaultPrevented&&V(async()=>{U(t),await m(t,e)})},se=(0,w.useCallback)(()=>{p?.(``,null),R.current?.focus()},[p]),{onClick:ce,onMouseUp:le}=nS({containerRef:z,inputRef:R,disabled:o}),ue=(0,K.jsxs)(`div`,{ref:e=>{z.current=e,ne.ref(e)},onClick:ce,onMouseUp:le,...rg(X(`text-input`,{size:N,status:u?.type??null,disabled:o?`disabled`:null,readonly:s?`readonly`:null}),Y(_S.base,OS[N],o&&_S.disabled,u&&vS[u.type],u&&!o&&yS[u.type],u&&bS[u.type],B&&wS.inGroup,E),D,O),children:[l&&Vy(l,{size:`sm`,color:`secondary`}),B&&(0,K.jsx)(Vg,{id:F,children:t}),(0,K.jsx)(`input`,{...A,ref:_g(k,R),id:P,name:o?void 0:x,type:e,value:H,onChange:oe,onKeyDown:S||C?e=>{e.key===`Enter`&&S?.(),C?.(e)}:void 0,placeholder:_,disabled:o&&!te,"aria-disabled":te?`true`:void 0,readOnly:s||te||void 0,autoFocus:b,"data-autofocus":b||void 0,"aria-describedby":ae,"aria-required":M?`true`:void 0,"aria-invalid":u?.type===`error`?`true`:void 0,"aria-busy":ee||void 0,"aria-labelledby":ie,...{0:{className:`x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx x1tgivj0 xjbqb8w x1a2a7pz xeyghm5`},1:{className:`x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx x1tgivj0 xjbqb8w x1a2a7pz xeyghm5 xt0e3qv`}}[!!o<<0]}),y&&g!==``&&!o&&!s&&(0,K.jsx)(CS,{label:j(`@astryx.textInput.clearLabel`,{label:t}),onClick:se}),ee&&(0,K.jsx)(Bg,{size:`sm`}),W]});return B?(0,K.jsxs)(K.Fragment,{children:[ue,te&&ne.renderTooltip(c)]}):(0,K.jsxs)(gS,{label:t,isLabelHidden:n,description:r,inputID:P,descriptionID:r?I:void 0,isOptional:i,isRequired:a,isDisabled:o,status:u?{type:u.type,message:u.message,messageID:u.message?L:void 0}:void 0,statusVariant:d,labelTooltip:v,width:T,children:[ue,te&&ne.renderTooltip(c)]})}kS.displayName=`TextInput`;var AS={ARTIFACT_DENIED:`fileReferenceDenied`,ARTIFACT_MISSING:`fileReferenceMissing`,ARTIFACT_UNSUPPORTED:`fileReferenceUnsupported`,ARTIFACT_EXPIRED:`fileReferenceExpired`,ARTIFACT_LIMIT:`fileReferenceBusy`,ARTIFACT_BUSY:`fileReferenceBusy`};function jS({open:e,sessionId:t,onClose:n,onInsert:r}){let{t:i}=Ln(),a=(0,w.useMemo)(()=>new zp,[]),o=(0,w.useRef)(null),[s,c]=(0,w.useState)(``),[l,u]=(0,w.useState)(!1),[d,f]=(0,w.useState)(null);(0,w.useEffect)(()=>{e||(o.current?.abort(),o.current=null,c(``),u(!1),f(null))},[e]);let p=()=>{o.current?.abort(),o.current=null,n()},m=async()=>{let e=s.trim();if(!e||l)return;if(f(null),!t){r(e),n();return}let c=new AbortController;o.current=c,u(!0);let d;try{if(d=(await a.resolveArtifact(t,e,void 0,c.signal)).handle,await a.artifactMetadata(t,d,c.signal),c.signal.aborted)return;r(e),n()}catch(e){if(!c.signal.aborted){let t=e instanceof Lp&&e.code?AS[e.code]:void 0;f(t?i(t):e instanceof Error?e.message:i(`fileReferenceFailed`))}}finally{o.current=null,d&&a.releaseArtifact(t,d).catch(()=>void 0),c.signal.aborted||u(!1)}};return(0,K.jsx)(Lx,{isOpen:e,onOpenChange:e=>!e&&p(),purpose:`form`,width:460,"aria-label":i(`fileReferenceTitle`),children:(0,K.jsxs)(`form`,{className:`openpi-dialog file-reference-dialog`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,K.jsxs)(`div`,{className:`file-reference-heading`,children:[(0,K.jsx)(Ce,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:i(`fileReferenceTitle`)}),(0,K.jsx)(`p`,{children:i(`fileReferenceDetail`)})]})]}),(0,K.jsx)(kS,{label:i(`fileReferenceLabel`),value:s,placeholder:i(`fileReferencePlaceholder`),description:i(t?`fileReferenceValidatedHint`:`fileReferenceDraftHint`),hasAutoFocus:!0,hasClear:!0,isDisabled:l,onChange:e=>{c(e.slice(0,4096)),f(null)}}),d&&(0,K.jsx)(`p`,{className:`file-reference-error`,role:`alert`,children:d}),(0,K.jsxs)(`div`,{className:`dialog-actions`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:l,onClick:p,children:i(`cancel`)}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:l||!s.trim(),children:i(l?`fileReferenceChecking`:`insertReference`)})]})]})})}function MS(e,t){return t.every((t,n)=>e[n]===t)}function NS(e){if(MS(e,[137,80,78,71,13,10,26,10]))return`image/png`;if(MS(e,[255,216,255]))return`image/jpeg`;let t=new TextDecoder(`ascii`).decode(e.subarray(0,12));return t.startsWith(`GIF87a`)||t.startsWith(`GIF89a`)?`image/gif`:t.startsWith(`RIFF`)&&t.slice(8,12)===`WEBP`?`image/webp`:null}function PS(e){let t=``,n=32768;for(let r=0;r3145728)throw Error(`image-size`);let t=new Uint8Array(await e.arrayBuffer()),n=NS(t);if(!n)throw Error(`image-type`);let r=PS(t);return{id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${e.name}`,name:e.name||`image`,size:t.length,mimeType:n,data:r,previewUrl:`data:${n};base64,${r}`}}var IS={triggerContainer:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kOIVth:`x1txdalj`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib xdk3u5w`,kLWn49:`x1kq96og`,kMwMTN:`x1tgivj0`,kkrTdU:`x1ypdohk x16khyan`,$$css:!0},trigger:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kOIVth:`x1txdalj`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,kCS8Yb:`x1r8uery`,k7Eaqz:`xeuugli`,kmVPX3:`x1717udv`,kogj98:`x1ghz6dp`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kWkggS:`xjbqb8w`,kMv6JI:`xjb2p0i`,kGuDYH:`x1qlqyl8`,kLWn49:`x15bjb6t`,kMwMTN:`x1heor9g`,kkrTdU:`x1ypdohk x16khyan`,kI3sdo:`x1a2a7pz`,kaIpWk:`xh6dtrn`,$$css:!0},triggerText:{kzQI83:`x1iyjqo2`,k7Eaqz:`xeuugli`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,k9WMMc:`x1yc453h`,$$css:!0},placeholder:{kMwMTN:`xv1l7n4`,$$css:!0},triggerGhost:{kzqmXN:`x14atkfc`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kGVxlE:`x1gnnqk1 x1s17dad x15ysqaf`,k63SB2:`x1e4wzip`,k1ekBW:`xrafxwg`,k3aq6I:`x3oybdh xk4oym4`,$$css:!0},triggerGhostDisabled:{kKwaWg:`x18o3ruo`,k3aq6I:`x1c071of x1pdlv7q`,$$css:!0},triggerIcon:{kmuXW:`x2lah0s`,$$css:!0},triggerIconRotation:{k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,k3nNDw:`x1g0ag68`,$$css:!0},triggerIconOpen:{k3aq6I:`x19jd1h0`,$$css:!0},popover:{k7Eaqz:`xrzjruh`,$$css:!0},content:{kB7OPa:`x9f619`,kskxy:`xpnbb6b`,kVQacm:`xysyzu8`,kmVPX3:`x1b2ylru`,$$css:!0},sm:{kZKoxP:`x6k0iem`,$$css:!0},md:{kZKoxP:`x1ueg155`,$$css:!0},lg:{kZKoxP:`xssyfek`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,$$css:!0}};function LS({label:e,value:t,onChange:n,changeAction:r,children:i,triggerLabel:a,placeholder:o,isLabelHidden:s=!1,description:c,isOptional:l=!1,isRequired:u=!1,isDisabled:d=!1,isLoading:f=!1,status:p,statusVariant:m=`attached`,labelTooltip:h,size:g=`md`,variant:_=`input`,startIcon:v,width:y,placement:b=`below`,alignment:x=`start`,handleRef:S,onOpenChange:C,contentXstyle:T,xstyle:E,className:D,style:O,"data-testid":k,onClick:A,...j}){let M=Tv(),N=TS({isRequired:u,isOptional:l}),P=o??M(`@astryx.selector.placeholder`),F=_===`ghost`&&m===`attached`?`detached`:m,I=(0,w.useId)(),L=(0,w.useId)(),R=(0,w.useId)(),z=(0,w.useId)(),B=(0,w.useId)(),V=[c?z:null,p?.message?B:null].filter(e=>e!=null).join(` `)||void 0,H=(0,w.useRef)(null),[U,ee]=(0,w.useTransition)(),[te,ne]=(0,w.useOptimistic)(t),W=f||U,re=Rv({dialogLabel:e,hasCloseButton:!1,hasAutoFocus:!0,surfaceTarget:`complex-selector-popup`,onShow:(0,w.useCallback)(()=>{C?.(!0)},[C]),onHide:(0,w.useCallback)(()=>{H.current?.focus(),C?.(!1)},[C])}),ie=re.isOpen,ae=(0,w.useCallback)(()=>{d||(re.isOpen?re.hide():re.show())},[d,re]),oe=(0,w.useCallback)(()=>{re.hide()},[re]);(0,w.useImperativeHandle)(S,()=>({open:()=>{d||re.show()},close:()=>re.hide(),toggle:()=>{d||(re.isOpen?re.hide():re.show())},isOpen:()=>re.isOpen}),[d,re]);let se=(0,w.useCallback)(e=>{n?.(e),r&&ee(async()=>{ne(e),await r(e)})},[r,n,ne,ee]),ce=a??P,le=Vy(v,{size:`sm`,color:`secondary`}),ue=(0,K.jsx)(`div`,{id:R,...Y(IS.content,T),children:i(te,se,oe,{isOpen:ie,isBusy:W,triggerId:I,contentId:R})}),de=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{ref:re.triggerRef,"data-testid":k,...j,onClick:ag(A,ae),...rg(X(`complex-selector`,{variant:_,size:g,status:p?.type??null}),Y(_S.base,IS.triggerContainer,IS[g],mg.focusWithin,_===`ghost`&&IS.triggerGhost,_===`ghost`&&Qg.backgroundImage,d&&_S.disabled,_===`ghost`&&d&&IS.triggerGhostDisabled,d&&IS.disabled,a==null&&IS.placeholder,E),D,O),children:[og(le)&&le,(0,K.jsx)(`button`,{ref:H,id:I,type:`button`,"aria-haspopup":`dialog`,"aria-expanded":ie,"aria-controls":R,"aria-describedby":V,"aria-labelledby":L,"aria-required":N?`true`:void 0,"aria-invalid":p?.type===`error`?`true`:void 0,"aria-busy":W||void 0,disabled:d,onKeyDown:e=>{e.key===`ArrowDown`&&!ie&&!d&&(e.preventDefault(),re.show())},className:`x78zum5 x6s0dn4 x1qughib x1txdalj x1iyjqo2 xs83m0k x1r8uery xeuugli x1717udv x1ghz6dp xc342km xng3xce xjbqb8w xjb2p0i x1qlqyl8 x15bjb6t x1heor9g x1ypdohk x16khyan x1a2a7pz xh6dtrn`,children:(0,K.jsx)(`span`,{className:`x1iyjqo2 xeuugli xb3r6kr xlyipyv xuxw1ft x1yc453h`,children:ce})}),W&&(0,K.jsx)(Bg,{size:`sm`}),(0,K.jsx)(zy,{icon:`chevronDown`,size:`sm`,color:`secondary`,xstyle:[IS.triggerIcon,IS.triggerIconRotation,ie&&IS.triggerIconOpen],...X(`complex-selector-indicator-icon`,{state:ie?`expanded`:`collapsed`})})]}),re.render(ue,{placement:b,alignment:x,offset:om[`--spacing-1`],xstyle:[IS.popover,yh[b]]})]});return(0,K.jsx)(gS,{label:e,isLabelHidden:s,description:c,inputID:I,descriptionID:c?z:void 0,labelID:L,isOptional:l,isRequired:u,isDisabled:d,status:p?{type:p.type,message:p.message,messageID:p.message?B:void 0}:void 0,statusVariant:F,labelTooltip:h,width:y,children:de})}LS.displayName=`ComplexSelector`;function RS(e){let t=`${e.provider}/${e.id}`;return e.label===t?t:`${e.label} (${t})`}var zS=250;function BS(e){let{t}=Ln(),[n,r]=(0,w.useState)(``),i=(0,w.useRef)([]),a=e.draftModel??e.currentModel,o=e.snapshot?.models??[],s=(e.snapshot?.truncation.modelsOmitted??0)>0,c=n.trim(),l=e.modelSearch.query===c,u=!!c&&(!l||e.modelSearch.status===`loading`),d=c?l?e.modelSearch.models:[]:o,f=e.actions.searchModels,p=e.snapshot?.generatedAt;(0,w.useEffect)(()=>{if(!c||!p)return;let e=window.setTimeout(()=>{f(c)},zS);return()=>window.clearTimeout(e)},[c,f,p]);let m=()=>{r(``),e.actions.clearModelSearch()},h=(t,n)=>{e.actions.selectModel(`${t.provider}/${t.id}`),n()},g=a?RS(a):t(`noModels`),_=a?g:t(`selectModel`),v=e.sessionSwitching||e.modelSelectionPending||e.promptAdmissionPending||!e.workspaceDraft&&!!e.snapshot?.selectedSession&&e.snapshot?.selectedSession?.id!==e.snapshot?.currentSessionId||e.liveRunning||!o.length&&!s;return(0,K.jsx)(LS,{className:`model-selector model-picker`,label:_,isLabelHidden:!0,value:a?`${a.provider}/${a.id}`:``,triggerLabel:(0,K.jsx)(`span`,{className:`model-picker-label`,children:g}),placeholder:t(`noModels`),variant:`ghost`,size:`sm`,placement:`above`,alignment:`end`,isDisabled:v,isLoading:e.modelSelectionPending,onOpenChange:e=>{e||m()},children:(f,p,m)=>(0,K.jsxs)(`div`,{className:`model-search-panel ${s?`searchable`:``}`,children:[s&&(0,K.jsx)(`p`,{className:`model-search-truncation`,role:`status`,children:t(`modelsTruncated`,{shown:o.length,omitted:e.snapshot?.truncation.modelsOmitted??0})}),s&&(0,K.jsxs)(`label`,{className:`model-search-input`,children:[(0,K.jsx)($e,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:t(`searchModels`)}),(0,K.jsx)(`input`,{value:n,placeholder:t(`searchModelsPlaceholder`),onChange:t=>{let n=t.currentTarget.value;r(n),n.trim()||e.actions.clearModelSearch()},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),m())}})]}),u&&(0,K.jsx)(`p`,{className:`model-search-status`,role:`status`,children:t(`searchingModels`)}),c&&l&&e.modelSearch.status===`error`&&(0,K.jsx)(`p`,{className:`model-search-status model-search-error`,role:`alert`,children:e.modelSearch.error??t(`modelSearchFailed`)}),c&&l&&e.modelSearch.status===`ready`&&e.modelSearch.totalMatches===0&&(0,K.jsx)(`p`,{className:`model-search-status`,role:`status`,children:t(`noMatchingModels`)}),c&&l&&e.modelSearch.status===`ready`&&e.modelSearch.matchesOmitted>0&&(0,K.jsx)(`p`,{className:`model-search-status`,role:`status`,children:t(`modelSearchTruncated`,{omitted:e.modelSearch.matchesOmitted})}),(0,K.jsx)(`div`,{className:`model-search-options`,role:`listbox`,"aria-label":t(`selectModel`),"aria-busy":u,children:d.map((e,t)=>{let n=a?.provider===e.provider&&a.id===e.id;return(0,K.jsxs)(`button`,{className:`model-search-option`,type:`button`,role:`option`,"aria-selected":n,ref:e=>{i.current[t]=e},onClick:()=>h(e,m),onKeyDownCapture:e=>{let n=e.key===`ArrowDown`?Math.min(t+1,d.length-1):e.key===`ArrowUp`?Math.max(t-1,0):e.key===`Home`?0:e.key===`End`?d.length-1:null;n!==null&&n!==t&&(e.preventDefault(),e.stopPropagation(),i.current[n]?.focus())},children:[(0,K.jsx)(`span`,{className:`model-menu-item-label`,children:RS(e)}),n&&(0,K.jsx)(B,{"aria-hidden":`true`})]},`${e.provider}/${e.id}`)})})]})})}var VS=`openpi-slash-command-list`;function HS(e){return`openpi-slash-command-${e}`}function US(e,t){let n=t.trim().toLocaleLowerCase(),r=n?e.filter(e=>e.name.toLocaleLowerCase().includes(n)):[],i=n?r.length>0?r:e.filter(e=>[e.description,e.source].some(e=>e?.toLocaleLowerCase().includes(n))):[...e];return n?[...i.filter(e=>e.availability===`available`),...i.filter(e=>e.availability===`unsupported`)]:i.filter(e=>e.availability===`available`)}function WS({source:e}){return e===`extension`?(0,K.jsx)(Xe,{}):e===`prompt`?(0,K.jsx)(Ce,{}):(0,K.jsx)(rt,{})}function GS(e){let{t}=Ln(),n=(0,w.useRef)(null);(0,w.useLayoutEffect)(()=>{let t=n.current,r=t?.parentElement;if(!t||!r||!e.preferBelow)return;let i=()=>{let e=window.visualViewport,n=e?.offsetTop??0,i=e?.height??window.innerHeight,a=n+i,o=r.getBoundingClientRect(),s=Math.max(0,a-o.bottom-8-12),c=Math.max(0,o.top-n-8-12),l=s>=Math.min(t.scrollHeight,224,i*.32)||s>=c?`below`:`above`,u=l===`below`?s:c;t.dataset.placement=l,t.style.setProperty(`--slash-command-available-height`,`${Math.floor(u)}px`)};i();let a=new ResizeObserver(i);return a.observe(t),a.observe(r),window.addEventListener(`resize`,i),window.visualViewport?.addEventListener(`resize`,i),window.visualViewport?.addEventListener(`scroll`,i),()=>{a.disconnect(),window.removeEventListener(`resize`,i),window.visualViewport?.removeEventListener(`resize`,i),window.visualViewport?.removeEventListener(`scroll`,i)}},[e.preferBelow]);let r=e.commands[e.activeIndex];if((0,w.useEffect)(()=>{r&&(n.current?.querySelector(`[data-command-index="${e.activeIndex}"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[r,e.activeIndex]),e.draft)return(0,K.jsx)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`status`,children:t(`commandSessionRequired`)});if(e.commandDiscovery.status===`idle`||e.commandDiscovery.status===`loading`)return(0,K.jsx)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`status`,children:t(`commandsLoading`)});if(e.commandDiscovery.status===`error`)return(0,K.jsxs)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:t(`commandsUnavailable`)}),(0,K.jsx)(`span`,{children:e.commandDiscovery.error})]});if(e.commandDiscovery.status===`ready`&&e.commands.length===0){let r=e.showUnavailableSummary&&e.commandDiscovery.commands.length>0&&e.commandDiscovery.commands.every(e=>e.availability===`unsupported`);return(0,K.jsx)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`status`,children:t(r?`commandsNoAvailable`:`commandsNoMatch`)})}return(0,K.jsxs)(`div`,{ref:n,className:`slash-command-menu`,children:[(0,K.jsx)(`div`,{id:VS,role:`listbox`,"aria-label":t(`commands`),children:e.commands.map((n,r)=>{let i=n.availability===`unsupported`;return(0,K.jsxs)(`button`,{id:HS(r),"data-command-index":r,className:`slash-command-option`,type:`button`,role:`option`,"aria-selected":r===e.activeIndex,"aria-disabled":i,disabled:i,onMouseEnter:()=>e.onSelect(r),onMouseDown:e=>e.preventDefault(),onClick:()=>e.onComplete(n),children:[(0,K.jsx)(`span`,{className:`slash-command-icon`,children:(0,K.jsx)(WS,{source:n.source})}),(0,K.jsxs)(`span`,{className:`slash-command-copy`,children:[(0,K.jsxs)(`span`,{className:`slash-command-heading`,children:[(0,K.jsxs)(`strong`,{children:[`/`,n.name]}),(0,K.jsx)(`span`,{children:t(`commandSource_${n.source}`)})]}),n.description&&(0,K.jsx)(`span`,{children:n.description}),n.support&&(0,K.jsx)(`span`,{children:t(`commandSupport_${n.support}`)})]}),(0,K.jsx)(`span`,{className:`slash-command-support`,children:i?t(`commandUnsupported`):n.argumentHint?t(`commandAcceptsArguments`):null})]},`${n.source}:${n.name}`)})}),e.commandDiscovery.commandsOmitted>0&&(0,K.jsx)(`div`,{className:`slash-command-bounded`,role:`status`,children:t(`commandsBounded`,{count:e.commandDiscovery.commandsOmitted})})]})}function KS(e){let{t}=Ln(),[n,r]=(0,w.useState)(``),i=e.modelSearch??{query:``,status:`idle`,models:[],totalMatches:0,matchesOmitted:0,error:null},[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(!1),[d,f]=(0,w.useState)(0),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)([]),[_,v]=(0,w.useState)(!1),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(!1),C=(0,w.useRef)(null),T=(0,w.useRef)(null),E=(0,w.useRef)(!1),D=(0,w.useRef)(!1);(0,w.useLayoutEffect)(()=>{let e=C.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`,e.style.overflowY=e.scrollHeight>220?`auto`:`hidden`)},[n]),(0,w.useEffect)(()=>{if(p||!D.current)return;D.current=!1;let e=window.setTimeout(()=>{C.current?.focus(),C.current?.setSelectionRange(a,a)},0);return()=>window.clearTimeout(e)},[a,p]);let O=(0,w.useRef)(null),k=(0,w.useRef)(!1),A=e.snapshot?.selectedSession,j=e.selectedPath===void 0?A?.path??null:e.selectedPath,M=A?.cwd===e.selectedWorkspace?j:null,N=(e.workspaceDraft?null:M)??(e.selectedWorkspace?`new:${e.selectedWorkspace}`:`none`),P=(0,w.useRef)(N),F=(0,w.useRef)(0),I=(0,w.useRef)(!1),R=(0,w.useRef)(null),z=!!(!e.workspaceDraft&&A?.id&&A.id===e.snapshot?.currentSessionId&&j===A.path),V=!!(e.selectedWorkspace&&(e.workspaceDraft||!A&&!e.snapshot?.currentSessionId)),H=z||V,ee=!e.workspaceDraft&&(e.snapshot?.runtime.status===`running`||e.liveRunning),te=z&&ee&&!!(e.activeTurn??e.snapshot?.runtime.activeTurn),ne=e.sessionSwitching||!H&&!!e.selectedWorkspace,W=e.commandDiscovery??{sessionId:null,status:`idle`,commands:[],totalAvailable:0,commandsOmitted:0,error:null},re=/^\/[^\s/]*$/u.test(n)&&a>0,ie=s&&re&&!l&&H&&!e.sessionSwitching,ae=z?A?.id:null,oe=re?n.slice(1):``,se=(0,w.useMemo)(()=>US(W.commands,oe),[oe,W.commands]),ce=ie&&!e.workspaceDraft&&W.status===`ready`&&se.length>0,le=z&&!n.trim()&&!e.sessionSwitching,ue=H&&!!e.selectedWorkspace&&!e.sessionSwitching,fe=async e=>{if(E.current||!ue)return;let n=[...e];if(n.length!==0){if(h.length+n.length>4){b(t(`imageAttachmentCount`,{count:4}));return}E.current=!0,v(!0),b(null);try{let e=[],t=h.reduce((e,t)=>e+t.size,0);for(let r of n){let n=await FS(r);if(t+=n.size,t>8388608)throw Error(`image-total-size`);e.push(n)}F.current+=1,g(t=>[...t,...e])}catch(e){let n=e instanceof Error?e.message:`image-type`;b(t(n===`image-size`?`imageAttachmentTooLarge`:n===`image-total-size`?`imageAttachmentTotalTooLarge`:`imageAttachmentUnsupported`))}finally{E.current=!1,v(!1),T.current&&(T.current.value=``)}}};(0,w.useEffect)(()=>{let t=ie&&!k.current;k.current=ie,!(!ie||e.workspaceDraft||!ae||W.status!==`idle`&&!(t&&W.status===`error`))&&e.actions.discoverCommands()},[W.status,ie,e.actions,e.workspaceDraft,ae]),(0,w.useEffect)(()=>{let e=se.findIndex(e=>e.availability===`available`);f(e>=0?e:0)},[se]),(0,w.useEffect)(()=>{let t=e.promptAdmissionRecovery,n=t?.commandId??null;O.current!==n&&(O.current=n,t&&r(e=>e||t.content))},[e.promptAdmissionRecovery]),(0,w.useEffect)(()=>{let t=e.promptAdmissionResolution;t&&(n.trim()===t.content&&(r(``),g([])),e.actions.acknowledgePromptAdmissionResolution(t.commandId))},[n,e.actions,e.promptAdmissionResolution]),(0,w.useEffect)(()=>{let t=P.current;if(t===N)return;P.current=N;let n=R.current;if(!e.workspaceDraft&&(I.current||n?.canTransferToCreatedSession&&n.scope===t)&&M&&e.snapshot?.selectedSession?.path===M&&e.snapshot?.selectedSession?.cwd===e.selectedWorkspace){n?.canTransferToCreatedSession&&(n.scope=N),I.current=!1;return}if(e.workspaceDraft&&e.selectedWorkspace&&N===`new:${e.selectedWorkspace}`&&e.snapshot?.selectedSession?.cwd===e.selectedWorkspace){I.current=!0;return}F.current+=1,r(``),g([]),b(null),S(!1),m(!1),n?.scope===t&&(n.canTransferToCreatedSession=!1)},[N,e.snapshot?.selectedSession?.path,e.snapshot?.selectedSession?.cwd,e.selectedWorkspace,e.workspaceDraft,M]);let pe=async t=>{if(R.current||e.planSelectionPending)return;if(!e.selectedWorkspace){await e.actions.chooseWorkspace();return}let i={revision:F.current,scope:P.current,canTransferToCreatedSession:V};R.current=i;try{(h.length>0?await t(n,h):await t(n))&&R.current===i&&P.current===i.scope&&F.current===i.revision&&(F.current+=1,r(``),g([]),b(null))}finally{R.current===i&&(R.current=null)}},me=async t=>{t?.preventDefault(),!(!H||e.sessionSwitching||e.modelSelectionPending||e.thinkingPendingLevel!==null||e.promptAdmissionPending||e.promptAdmissionRecovery||e.promptAdmissionResolution||!n.trim()&&h.length===0)&&await pe(e.actions.sendPrompt)},he=()=>pe(e.actions.sendPromptAsNew),ge=e=>{if(e.availability!==`available`)return;let t=`/${e.name} `;F.current+=1,r(t),o(t.length),u(!0),queueMicrotask(()=>{C.current?.focus(),C.current?.setSelectionRange(t.length,t.length)})},_e=e=>{if(!se.length)return;let t=d;for(let n=0;n{let t=Math.min(a,n.length),i=n.slice(0,t),s=n.slice(t),c=`\`${e.replaceAll("`","\\`")}\``,l=i&&!/\s$/u.test(i)?` `:``,u=`${i}${l}${c}${s&&!/^\s/u.test(s)?` `:``}${s}`,d=i.length+l.length+c.length;F.current+=1,r(u),o(d),D.current=!0},ye=[...(e.snapshot?.workspaces??[]).map(t=>({id:t.path,label:t.name,icon:(0,K.jsx)(De,{}),endContent:t.path===e.selectedWorkspace?(0,K.jsx)(B,{}):void 0,onClick:()=>e.actions.setWorkspace(t.path)})),{type:`divider`},{id:`add`,label:t(`addWorkspaceMenu`),icon:(0,K.jsx)(Ye,{}),onClick:()=>void e.actions.chooseWorkspace()}],be=e.draftModel??e.snapshot?.models.find(e=>e.current)??e.snapshot?.models[0],xe=e.snapshot?.workspaces.find(t=>t.path===e.selectedWorkspace)?.name??(e.selectedWorkspace?Wb(e.selectedWorkspace):t(`selectWorkspace`)),Se=e.snapshot?.sessions.find(e=>e.path===M),we=z?Ub(Se??{},A?.id??t(`untitledSession`)):V?t(`newSession`):A?Ub(Se??{},A.id):t(`newSession`),Te=Kb(we,48),Ee=e.selectedWorkspace?z&&e.snapshot?.runtime.planHasPrompt&&[`planning`,`ready`].includes(e.snapshot.runtime.plan??``)?t(`promptPlanMessage`):e.landing?t(`promptTask`):t(z?`promptMessage`:`promptReadonly`):t(`promptStart`),Oe=e.snapshot?.thinking,ke=Oe?.level??null,Ae=e.thinkingPendingLevel??null,je=Ae??ke,Ne=Oe?.supported??!1,Pe=Oe?!Oe.available.includes(ke??``):!1,Ie=(Oe?.available??[]).map(t=>({id:t,label:t,endContent:t===je?(0,K.jsx)(B,{}):void 0,onClick:()=>void e.actions.selectThinking(t)})),Le=Oe?Ne?e.workspaceDraft?`thinkingDraftHint`:z?ee?`thinkingLockedRunning`:e.modelSelectionPending?`thinkingModelPendingHint`:null:`thinkingInactiveHint`:`thinkingUnsupportedHint`:null,Re=Ne?`${t(`thinkingLevel`)}: ${je??t(`unknownState`)}${Ae===null?``:`. ${t(`thinkingPendingHint`)}`}`:t(`thinkingUnsupported`),ze=Oe?[...Pe?[{id:`thinking-level-mismatch`,label:t(`thinkingLevelMismatch`),isDisabled:!0},{type:`divider`}]:[],{type:`section`,id:`thinking-level`,title:t(`thinkingLevel`),items:Ie}]:[],Be=e.promptAdmissionPending&&!te?t(`promptPending`):e.modelSelectionPending?t(`thinkingModelPendingHint`):e.thinkingPendingLevel===null?e.workspaceDraft?t(`enterHint`):e.turnCancellationPending?t(`stoppingTurn`):e.turnTerminalStatus===`cancelled`?t(`stoppedTurn`):e.pendingFollowUpsReceipt===null?t(H?ee?`queuedHint`:`enterHint`:`activeOnlyHint`):e.pendingFollowUpsReceipt>0?t(`pendingFollowUpsHint`,{count:e.pendingFollowUpsReceipt}):t(`acceptedHint`):t(`thinkingPendingHint`),Ve=e.promptAdmissionPending&&!te||e.modelSelectionPending||e.thinkingPendingLevel!==null||e.turnCancellationPending||e.turnTerminalStatus===`cancelled`||e.pendingFollowUpsReceipt!==null||H&&ee&&!!(n.trim()||h.length);return(0,K.jsxs)(`div`,{className:`composer-dock`,children:[!e.workspaceDraft&&e.snapshot?.selectedSession?.id===e.snapshot?.currentSessionId&&e.snapshot?.runtime.plan&&!e.sessionSwitching&&(0,K.jsxs)(`div`,{className:`plan-mode-bar`,children:[(0,K.jsx)(`span`,{children:t(`planMode_${e.snapshot.runtime.plan}`)}),(0,K.jsx)(`button`,{type:`button`,disabled:ee||e.planSelectionPending||e.promptAdmissionPending||!!e.promptAdmissionRecovery,onClick:()=>void e.actions.selectPlanMode(e.snapshot?.runtime.plan===`inactive`),children:t(e.snapshot.runtime.plan===`inactive`?`planModeEnter`:`planModeExit`)})]}),z&&(0,K.jsx)(tx,{snapshot:e.snapshot,onInspectTerminal:e.onInspect,onInspectSubagent:e.onInspectSubagent}),e.accessory,e.landing&&(0,K.jsx)(`div`,{className:`workspace-picker-row`,children:(0,K.jsx)(Rb,{className:`workspace-picker-menu`,button:{label:e.selectedWorkspace?Wb(e.selectedWorkspace):t(`selectWorkspace`),icon:(0,K.jsx)(De,{}),size:`md`,variant:`ghost`,className:`workspace-picker`},items:ye,menuWidth:240,placement:`above`,alignment:`start`,hasChevron:!0})}),e.promptAdmissionRecovery&&(0,K.jsxs)(`section`,{className:`prompt-recovery`,role:`alert`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:t(`promptAdmissionUnknown`)}),(0,K.jsx)(`span`,{children:e.promptAdmissionRecovery.phase===`checking`?t(`promptAdmissionCheckingDetail`):e.promptAdmissionRecovery.phase===`verification-failed`?t(`promptAdmissionVerificationFailedDetail`):t(`promptAdmissionUnknownDetail`)})]}),(0,K.jsxs)(`div`,{className:`prompt-recovery-actions`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:e.promptAdmissionRecovery.phase===`submitting`,onClick:e.actions.abandonPromptAdmission,children:t(`abandonAdmission`)}),e.promptAdmissionRecovery.phase===`verification-failed`&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>void e.actions.checkPromptAdmissionRecovery(),children:t(`retryAdmissionCheck`)}),(0,K.jsx)(`button`,{type:`button`,className:`primary`,disabled:e.promptAdmissionRecovery.phase!==`ready`||!n.trim()&&h.length===0,onClick:()=>void he(),children:e.promptAdmissionRecovery.phase===`submitting`?t(`sendingAsNew`):t(`sendAsNew`)})]})]}),(0,K.jsxs)(`form`,{className:`composer composer-m02 ${e.selectedWorkspace?``:`dormant`} ${x?`is-dragging`:``}`,onSubmit:e=>void me(e),onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),ue&&S(!0))},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),ue&&(e.dataTransfer.dropEffect=`copy`,S(!0)))},onDragLeave:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||S(!1)},onDrop:e=>{S(!1),e.dataTransfer.files.length!==0&&(e.preventDefault(),ue&&fe(e.dataTransfer.files))},children:[!e.selectedWorkspace&&(0,K.jsx)(`button`,{className:`dormant-overlay`,type:`button`,"aria-label":t(`selectWorkspace`),onClick:()=>void e.actions.chooseWorkspace()}),e.selectedWorkspace&&(0,K.jsxs)(`div`,{className:`composer-target`,title:`${xe} / ${we}`,children:[(0,K.jsx)(De,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:xe}),(0,K.jsx)(U,{"aria-hidden":`true`}),(0,K.jsx)(`strong`,{children:Te})]}),(0,K.jsx)(`input`,{ref:T,className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{e.currentTarget.files&&fe(e.currentTarget.files)}}),h.length>0&&(0,K.jsx)(`section`,{className:`composer-attachments`,"aria-label":t(`imageAttachments`),children:h.map(e=>(0,K.jsxs)(`div`,{className:`composer-attachment`,children:[(0,K.jsx)(`img`,{src:e.previewUrl,alt:``}),(0,K.jsx)(`span`,{title:e.name,children:e.name}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`${t(`removeAttachment`)} ${e.name}`,title:t(`removeAttachment`),onClick:()=>{F.current+=1,g(t=>t.filter(t=>t.id!==e.id)),b(null)},children:(0,K.jsx)(mt,{"aria-hidden":`true`})})]},e.id))}),y&&(0,K.jsx)(`p`,{className:`composer-attachment-error`,role:`alert`,children:y}),x&&(0,K.jsxs)(`div`,{className:`composer-drop-overlay`,"aria-hidden":`true`,children:[(0,K.jsx)(Me,{}),(0,K.jsx)(`span`,{children:t(`dropImagesHere`)})]}),(0,K.jsx)(`textarea`,{ref:C,value:n,rows:1,disabled:ne,readOnly:!e.selectedWorkspace,"aria-label":t(`describeTask`),"aria-autocomplete":`list`,"aria-controls":ce?VS:void 0,"aria-activedescendant":ce&&se[d]?HS(d):void 0,placeholder:Ee,onChange:e=>{F.current+=1,r(e.target.value),o(e.target.selectionStart),u(!1)},onClick:e=>o(e.currentTarget.selectionStart),onSelect:e=>o(e.currentTarget.selectionStart),onFocus:()=>{c(!0),u(!1)},onBlur:()=>c(!1),onPaste:e=>{!ue||e.clipboardData.files.length===0||(e.preventDefault(),fe(e.clipboardData.files))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(ie){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),_e(e.key===`ArrowDown`?1:-1);return}if(e.key===`Escape`){e.preventDefault(),u(!0);return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey){let t=se[d];if(t){e.preventDefault(),ge(t);return}}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),me())}}}),ie&&(0,K.jsx)(GS,{activeIndex:d,commandDiscovery:W,commands:se,draft:!!e.workspaceDraft,preferBelow:e.landing,showUnavailableSummary:!oe,onComplete:ge,onSelect:f}),(0,K.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,K.jsx)(`div`,{className:`composer-toolbar-context`,children:ue?(0,K.jsx)(Rb,{className:`composer-context-menu`,button:{label:t(`addContext`),icon:(0,K.jsx)(Ye,{}),isIconOnly:!0,size:`sm`,variant:`ghost`,className:`composer-context-trigger`},items:[{id:`image-attachment`,label:t(`addImages`),description:t(`imageAttachmentDescription`),icon:(0,K.jsx)(Me,{}),isDisabled:_||h.length>=4,onClick:()=>T.current?.click()},{id:`file-reference`,label:t(`fileReference`),icon:(0,K.jsx)(Ce,{}),onClick:()=>m(!0)},{id:`slash-commands`,label:t(`commands`),description:z?n.trim()?t(`commandsEmptyDraftOnly`):void 0:t(`commandsSessionRequired`),icon:(0,K.jsx)(de,{}),isDisabled:!le,onClick:()=>{F.current+=1,r(`/`),o(1),u(!1),requestAnimationFrame(()=>{C.current?.focus(),C.current?.setSelectionRange(1,1)})}}],menuWidth:200,placement:`above`,alignment:`start`,hasChevron:!1}):(0,K.jsx)(`span`,{className:`composer-context-placeholder`})}),(0,K.jsxs)(`div`,{className:`composer-toolbar-controls`,children:[e.onInspect&&(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":t(`runtimeStatus`),title:t(`runtimeStatus`),disabled:!z||e.sessionSwitching,onClick:()=>e.onInspect?.(),children:(0,K.jsx)(nt,{})}),e.onOpenProviders&&(0,K.jsx)(Hb,{content:t(`providerAvailability`),placement:`above`,children:(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"data-provider-settings-trigger":!0,"aria-label":t(`providerAvailability`),onClick:e.onOpenProviders,children:(0,K.jsx)(Fe,{})})}),(0,K.jsx)(`div`,{className:`model-picker-wrap`,children:(0,K.jsx)(BS,{snapshot:e.snapshot,currentModel:be,draftModel:e.draftModel,modelSearch:i,modelSelectionPending:!!e.modelSelectionPending,promptAdmissionPending:e.promptAdmissionPending,sessionSwitching:e.sessionSwitching,liveRunning:ee,workspaceDraft:!!e.workspaceDraft,actions:e.actions})}),Oe&&(0,K.jsx)(`div`,{className:`thinking-picker-wrap`,"data-level":ke??`none`,"data-pending":Ae!==null,"data-warning":Pe,title:Le?t(Le):void 0,children:(0,K.jsx)(Rb,{className:`thinking-menu`,button:{label:Re,icon:(0,K.jsx)(L,{}),isIconOnly:!0,size:`sm`,variant:`ghost`,className:`thinking-picker`,isDisabled:Le!==null||Ie.length===0},items:ze,menuWidth:220,placement:`above`,alignment:`end`,hasChevron:!1})}),te?(0,K.jsx)(Hb,{content:t(`stopTurn`),placement:`above`,children:(0,K.jsx)(`button`,{className:`send-button`,type:`button`,"aria-label":t(`stopTurn`),disabled:e.turnCancellationPending||e.sessionSwitching,onClick:()=>void e.actions.cancelActiveTurn(),children:(0,K.jsx)(ot,{})})}):(0,K.jsx)(Hb,{content:t(`send`),placement:`above`,children:(0,K.jsx)(`button`,{className:`send-button`,type:`submit`,"aria-label":t(`send`),disabled:e.sessionSwitching||e.modelSelectionPending||e.thinkingPendingLevel!==null||!H||!e.selectedWorkspace||e.promptAdmissionPending||e.planSelectionPending||!!e.promptAdmissionRecovery||!!e.promptAdmissionResolution||!n.trim()&&h.length===0,children:(0,K.jsx)(et,{})})})]})]}),(0,K.jsx)(`div`,{className:`composer-hint`,"data-visible":Ve,"aria-live":`polite`,children:Be})]}),(0,K.jsx)(jS,{open:p,sessionId:z?A?.id:void 0,onClose:()=>m(!1),onInsert:ve})]})}function qS({target:e,onClose:t,onOpenProviders:n}){let{t:r}=Ln(),i=(0,w.useMemo)(()=>new zp,[]),[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),p=e=>{f(null),sp(e).then(e=>f(e?`copied`:`failed`))};(0,w.useEffect)(()=>{let t=new AbortController;return c(null),u(null),f(null),(async()=>{let n={errors:[]};if(e.terminalId)try{let a=await i.terminalDetail(e.sessionId,e.terminalId,t.signal);if(a.sessionId!==e.sessionId||a.detail.id!==e.terminalId)throw Error(r(`inspectionChanged`));n.terminal=a.detail}catch(e){n.errors.push(e instanceof Error?e.message:r(`inspectionUnavailable`))}else{let[a,o]=await Promise.allSettled([i.thinking(e.sessionId,t.signal),i.trust(e.sessionId,t.signal)]);a.status===`fulfilled`&&a.value.sessionId===e.sessionId?n.thinking=a.value:n.errors.push(r(`thinkingUnavailable`)),o.status===`fulfilled`&&(o.value.workspace===void 0||o.value.workspace===e.cwd)?n.trust=o.value:n.errors.push(r(`trustUnavailable`))}t.signal.aborted||(c(n),u(new Date().toLocaleTimeString()))})(),()=>t.abort()},[i,e,a,r]);let m=e.terminalId?r(`terminalDetails`):r(`runtimeStatus`),h=s?.terminal;return(0,K.jsx)(Lx,{isOpen:!0,onOpenChange:e=>!e&&t(),width:640,"aria-label":m,children:(0,K.jsxs)(`section`,{className:`inspection-panel`,children:[(0,K.jsxs)(`header`,{className:`inspection-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:m}),(0,K.jsx)(`p`,{className:`inspection-subtitle`,children:e.cwd})]}),(0,K.jsxs)(`div`,{className:`inspection-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":r(`refreshStatus`),disabled:!s,onClick:()=>o(e=>e+1),children:(0,K.jsx)(Ze,{})}),(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":r(`close`),onClick:t,children:(0,K.jsx)(mt,{})})]})]}),d&&(0,K.jsx)(`p`,{role:`status`,children:r(d===`copied`?`copiedMessage`:`copyFailed`)}),s?(0,K.jsxs)(K.Fragment,{children:[s.errors.map(e=>(0,K.jsx)(`p`,{className:`inspection-warning`,role:`alert`,children:e},e)),h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`inspection-section`,children:[(0,K.jsx)(`h3`,{children:h.title||h.id}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{children:r(`executionState`)}),(0,K.jsx)(`dd`,{children:r(`execution_${h.status}`,{defaultValue:h.status})}),(0,K.jsx)(`dt`,{children:r(`terminalCommand`)}),(0,K.jsxs)(`dd`,{children:[(0,K.jsx)(`code`,{children:h.command}),(0,K.jsx)(`button`,{type:`button`,className:`inspection-copy`,"aria-label":r(`copyTerminalCommand`),title:r(`copyTerminalCommand`),onClick:()=>p(h.command),children:(0,K.jsx)(oe,{"aria-hidden":`true`})})]}),(0,K.jsx)(`dt`,{children:r(`terminalDirectory`)}),(0,K.jsx)(`dd`,{children:h.cwd}),(0,K.jsx)(`dt`,{children:r(`startedAt`)}),(0,K.jsx)(`dd`,{children:new Date(h.createdAt).toLocaleString()}),h.status!==`running`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:r(`exitCode`)}),(0,K.jsx)(`dd`,{children:h.exitCode??r(`unknownState`)})]})]}),h.errorText&&(0,K.jsx)(`p`,{className:`inspection-warning`,children:h.errorText}),h.truncated&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`detailTruncated`)})]}),[`stdout`,`stderr`].map(e=>(0,K.jsxs)(`section`,{className:`inspection-section`,children:[(0,K.jsxs)(`div`,{className:`inspection-stream-heading`,children:[(0,K.jsx)(`h3`,{children:r(e===`stdout`?`standardOutput`:`standardError`)}),(0,K.jsx)(`button`,{type:`button`,className:`inspection-copy`,disabled:!h[e].text,"aria-label":r(`copyVisibleOutput`,{stream:r(e===`stdout`?`standardOutput`:`standardError`)}),title:r(`copyVisibleOutput`,{stream:r(e===`stdout`?`standardOutput`:`standardError`)}),onClick:()=>p(h[e].text),children:(0,K.jsx)(oe,{"aria-hidden":`true`})})]}),(0,K.jsx)(`section`,{className:`terminal-evidence`,tabIndex:0,"aria-label":r(e===`stdout`?`standardOutput`:`standardError`),children:(0,K.jsx)(`pre`,{children:h[e].text||r(`noOutput`)})}),h[e].truncated&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`outputTruncated`,{count:h[e].omittedBytes})}),h[e].recoveryAvailable&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`outputRecovery`)})]},e))]}):!e.terminalId&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{className:`inspection-section`,children:[(0,K.jsx)(`h3`,{children:r(`modelAndThinking`)}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{children:r(`selectedModel`)}),(0,K.jsx)(`dd`,{children:e.model||r(`noModels`)}),(0,K.jsx)(`dt`,{children:r(`thinkingLevel`)}),(0,K.jsx)(`dd`,{children:s.thinking?.supported===!1?r(`thinkingUnsupported`):s.thinking?.level??r(`unknownState`)}),!!s.thinking?.available.length&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:r(`availableThinking`)}),(0,K.jsx)(`dd`,{children:s.thinking?.available.join(` · `)})]})]}),s.thinking?.supported===!1&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`thinkingUnsupportedHint`)}),s.thinking&&s.thinking.supported!==!1&&!s.thinking.available.includes(s.thinking.level)&&(0,K.jsx)(`p`,{className:`inspection-warning`,role:`status`,children:r(`thinkingLevelMismatch`)})]}),(0,K.jsxs)(`section`,{className:`inspection-section`,children:[(0,K.jsx)(`h3`,{children:r(`projectTrust`)}),(0,K.jsx)(`p`,{children:r(`trust_${s.trust?.state??`unknown`}`)}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{children:r(`savedTrustDecision`)}),(0,K.jsx)(`dd`,{children:r(`trustDecision_${s.trust?.decision??`unknown`}`)}),(0,K.jsx)(`dt`,{children:r(`activeSessionTrust`)}),(0,K.jsx)(`dd`,{children:s.trust?.sessionTrusted===!0?r(`trustActiveYes`):s.trust?.sessionTrusted===!1?r(`trustActiveNo`):r(`unknownState`)})]}),s.trust?.refreshRequired===!0&&(0,K.jsx)(`p`,{className:`inspection-warning`,children:r(`trustRefreshNeeded`)})]}),n&&(0,K.jsxs)(`button`,{type:`button`,className:`inspection-provider-link`,"aria-label":r(`openProviderSettings`),onClick:n,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:r(`providerAvailability`)}),(0,K.jsx)(`small`,{children:r(`authNotVerified`)})]}),r(`openProviderSettings`)]}),(0,K.jsxs)(`div`,{className:`inspection-setup`,children:[(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`configurationViaPi`)}),(0,K.jsx)(`code`,{children:`/openpi-setup`}),(0,K.jsx)(`button`,{type:`button`,className:`inspection-copy`,"aria-label":r(`copySetupCommand`),title:r(`copySetupCommand`),onClick:()=>p(`/openpi-setup`),children:(0,K.jsx)(oe,{"aria-hidden":`true`})})]})]}),(0,K.jsx)(`p`,{className:`inspection-updated`,children:r(`statusCaptured`,{time:l})})]}):(0,K.jsx)(`p`,{role:`status`,children:r(`inspectionLoading`)})]})})}function JS(e){return e.split(/[\\/]/u).at(-1)||e}function YS({snapshot:e,onOpenReview:t}){let{t:n}=Ln(),r=(0,w.useRef)(null),i=(0,w.useRef)(null),[a,o]=(0,w.useState)(!1),[s,c]=(0,w.useState)(320);if((0,w.useEffect)(()=>{if(!a)return;let e=()=>{let e=i.current?.getBoundingClientRect().top??340;c(Math.max(160,Math.min(420,e-20)))},t=e=>{r.current?.contains(e.target)||o(!1)},n=e=>{e.key!==`Escape`||e.isComposing||(e.preventDefault(),o(!1),i.current?.focus())};return e(),window.addEventListener(`resize`,e),document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.removeEventListener(`resize`,e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[a]),e.files.length===0)return null;let l=`session-changes-${e.revision.slice(0,12)}`;return(0,K.jsxs)(`div`,{className:`session-changes`,ref:r,children:[a&&(0,K.jsxs)(`section`,{className:`session-changes-popover`,id:l,role:`dialog`,"aria-label":n(`changeEvidence`),style:{maxHeight:s},children:[(0,K.jsx)(`ul`,{children:e.files.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`session-changes-file`,title:e.path,onClick:()=>{o(!1),t(e.path,i.current??void 0)},children:[(0,K.jsx)(`span`,{children:JS(e.path)}),(e.additions>0||e.deletions>0)&&(0,K.jsxs)(`span`,{className:`session-changes-counts`,"aria-hidden":`true`,children:[(0,K.jsxs)(`span`,{className:`review-additions`,children:[`+`,e.additions]}),(0,K.jsxs)(`span`,{className:`review-deletions`,children:[`-`,e.deletions]})]})]})},e.path))}),(0,K.jsx)(`footer`,{className:`session-changes-footer`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),t(void 0,i.current??void 0)},children:n(`reviewChanges`)})})]}),(0,K.jsxs)(`button`,{ref:i,className:`session-changes-trigger`,type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a,"aria-controls":a?l:void 0,onClick:()=>{if(!a){let e=i.current?.getBoundingClientRect().top??340;c(Math.max(160,Math.min(420,e-20)))}o(e=>!e)},children:[(0,K.jsx)(`strong`,{children:n(`filesChanged`,{count:e.files.length})}),(0,K.jsxs)(`span`,{className:`session-changes-counts`,"aria-hidden":`true`,children:[(0,K.jsxs)(`span`,{className:`review-additions`,children:[`+`,e.additions]}),(0,K.jsxs)(`span`,{className:`review-deletions`,children:[`-`,e.deletions]})]}),(0,K.jsx)(V,{"aria-hidden":`true`})]})]})}function XS(e,t){let n=(0,w.useMemo)(()=>new zp,[]),r=(0,w.useRef)(0),i=(0,w.useRef)(null),[a,o]=(0,w.useState)(null),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(null),d=(0,w.useCallback)(async()=>{if(!e)return;let t=++r.current;i.current?.abort();let a=new AbortController;i.current=a,c(!0),u(null);try{let i=await n.gitReview(e.id,e.path,a.signal);r.current===t&&o(i)}catch(e){r.current===t&&u(e instanceof Error?e.message:`Git review unavailable`)}finally{r.current===t&&(i.current=null,c(!1))}},[n,e]);return(0,w.useEffect)(()=>{if(!e){i.current?.abort(),i.current=null,r.current++,o(null),c(!1),u(null);return}let t=window.setTimeout(()=>void d(),200);return()=>{window.clearTimeout(t),i.current?.abort()}},[d,t,e]),(0,w.useEffect)(()=>{if(!e)return;let t=()=>void d();return window.addEventListener(`focus`,t),()=>window.removeEventListener(`focus`,t)},[d,e]),{result:a,loading:s,error:l,refresh:d}}function ZS({items:e,label:t}){return(0,K.jsx)(`span`,{className:`astryx-menu-trigger`,children:(0,K.jsx)(Rb,{button:{label:t,icon:(0,K.jsx)(_e,{}),isIconOnly:!0,size:`sm`,variant:`ghost`,className:`menu-action-button`},items:e,menuWidth:190,placement:`below`,alignment:`end`,hasChevron:!1})})}function QS(e){let{t}=Ln(),[n,r]=(0,w.useState)(null),[i,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(``),c=(0,w.useRef)(null),l=(0,w.useRef)(null),u=(0,w.useRef)(null),d=(0,w.useRef)(null),f=(0,w.useRef)(null),p=e.snapshot,[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(new Set),[v,y]=(0,w.useState)(new Set),b=(0,w.useRef)(new Set),[x,S]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),E=async t=>{if(!b.current.has(t)){b.current.add(t),y(new Set(b.current)),S(!1);try{await e.actions.unarchiveSession(t)||S(!0)}finally{b.current.delete(t),y(new Set(b.current))}}};(0,w.useEffect)(()=>{if(e.searchOpen)return c.current?.focus(),()=>l.current?.focus()},[e.searchOpen]),(0,w.useEffect)(()=>{if(e.mobileOpen)return f.current?.focus(),()=>{let t=e.returnFocusRef?.current;t?.checkVisibility()&&t.focus()}},[e.mobileOpen,e.returnFocusRef]),(0,w.useEffect)(()=>{e.mobileOpen&&document.activeElement===document.body&&!document.querySelector(`dialog:modal`)&&f.current?.focus()}),(0,w.useEffect)(()=>{n&&(u.current?.focus(),u.current?.select())},[n]);let D=(0,w.useMemo)(()=>{let n=e.query.trim().toLowerCase(),r=(e,r)=>(p?.sessions??[]).filter(i=>!!i.archived===m&&(e===`__ungrouped__`?i.ungrouped:i.cwd===e&&!i.ungrouped)&&(!n||r||`${Ub(i,t(`untitledSession`))} ${i.cwd}`.toLowerCase().includes(n))),i=[...p?.workspaces??[]];for(let e of p?.sessions??[])!e.ungrouped&&!i.some(t=>t.path===e.cwd)&&i.push({path:e.cwd,name:e.cwd,current:!1});return[...i.map(e=>{let t=!!n&&`${e.name} ${e.path}`.toLowerCase().includes(n);return{...e,sessions:r(e.path,t),ungrouped:!1,matches:t}}),{path:`__ungrouped__`,name:t(`ungrouped`),current:!1,sessions:r(`__ungrouped__`,!1),ungrouped:!0,matches:!1}].filter(e=>e.sessions.length>0||!m&&!e.ungrouped&&(!n||e.matches))},[m,e.query,p,t]),O=p?.selectedSession?.id===p?.currentSessionId&&p?.selectedSession?.path===e.selectedPath?e.selectedPath:null,j=O?p?.sessions.find(e=>e.path===O)?.cwd:e.selectedPath?null:e.selectedWorkspace,M=!!(p?.truncation.sessionsOmitted||p?.truncation.workspacesOmitted),N=e=>{s(e.name),r(e)},P=async()=>{let t=o.trim();if(!(!n||!t||C)){T(!0);try{n.kind===`workspace`?await e.actions.renameWorkspace(n.path,t):await e.actions.renameSession(n.path,t),r(null)}catch{}finally{T(!1)}}};return(0,K.jsxs)(`div`,{ref:d,id:`session-sidebar`,className:`session-sidebar`,role:e.mobileOpen?`dialog`:`complementary`,"aria-modal":e.mobileOpen||void 0,"aria-label":`Session navigation`,tabIndex:e.mobileOpen?-1:void 0,onKeyDown:t=>{if(!e.mobileOpen||t.defaultPrevented||t.target instanceof Element&&(t.target.closest(`dialog`)||t.key!==`Tab`&&t.target.closest(`[role="menu"]`))||(t.key===`Escape`&&!t.nativeEvent.isComposing&&(t.preventDefault(),e.actions.closeMobileSidebar()),t.key!==`Tab`))return;let n=Array.from(d.current?.querySelectorAll(`button, input, select, textarea, a[href], [tabindex]`)??[]).filter(e=>e.tabIndex>=0&&!e.matches(`:disabled`)&&e.checkVisibility({visibilityProperty:!0})),r=t.shiftKey?n.at(-1):n[0],i=t.shiftKey?n[0]:n.at(-1);(document.activeElement===d.current||document.activeElement===i)&&(t.preventDefault(),r?.focus())},children:[(0,K.jsxs)(`div`,{className:`sidebar-brand`,children:[(0,K.jsx)(Gn,{compact:!0}),(0,K.jsx)(Hb,{content:t(`collapseSidebar`),placement:`end`,children:(0,K.jsx)(`button`,{ref:f,className:`collapse-button`,type:`button`,"aria-label":t(`collapseSidebar`),onClick:()=>e.mobileOpen?e.actions.closeMobileSidebar():e.actions.toggleSidebar(!1),children:(0,K.jsx)(We,{})})})]}),(0,K.jsxs)(`button`,{className:`new-session-button`,type:`button`,"aria-label":t(`newSession`),title:t(`newSession`),onClick:()=>e.selectedWorkspace?void e.actions.createSession(e.selectedWorkspace):void e.actions.chooseWorkspace(),children:[(0,K.jsx)(it,{}),(0,K.jsx)(`span`,{children:t(`newSession`)})]}),(0,K.jsxs)(`div`,{className:`workspace-heading ${e.searchOpen?`is-searching`:``}`,children:[(0,K.jsx)(`span`,{className:`workspace-heading-label`,children:t(`workspaces`)}),(0,K.jsxs)(`div`,{className:`session-search`,children:[(0,K.jsx)($e,{}),(0,K.jsx)(`input`,{ref:c,type:`search`,value:e.query,placeholder:t(`searchPlaceholder`),"aria-label":t(`searchConversations`),onChange:t=>e.actions.setQuery(t.target.value)}),(0,K.jsx)(`button`,{type:`button`,"aria-label":t(`closeSearch`),onClick:()=>e.actions.setSearchOpen(!1),children:(0,K.jsx)(mt,{})})]}),(0,K.jsxs)(`div`,{className:`workspace-actions`,children:[(0,K.jsx)(Hb,{content:t(`searchConversations`),children:(0,K.jsx)(`button`,{ref:l,className:`icon-button`,type:`button`,"aria-label":t(`searchConversations`),onClick:()=>e.actions.setSearchOpen(!0),children:(0,K.jsx)($e,{})})}),(0,K.jsx)(Hb,{content:t(`addWorkspace`),children:(0,K.jsx)(`button`,{className:`icon-button`,type:`button`,"aria-label":t(`addWorkspace`),onClick:()=>void e.actions.chooseWorkspace(),children:(0,K.jsx)(Ye,{})})})]})]}),(0,K.jsxs)(`fieldset`,{className:`session-view-switch`,"aria-label":t(`conversationViews`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!m,onClick:()=>h(!1),children:t(`currentConversations`)}),(0,K.jsx)(`button`,{type:`button`,"aria-pressed":m,onClick:()=>h(!0),children:t(`archivedConversations`)})]}),m&&(0,K.jsx)(`p`,{className:`sidebar-scope-note`,children:t(`loadedArchives`)}),M&&(0,K.jsx)(`p`,{className:`sidebar-scope-note`,children:t(`loadedHistoryBounded`,{sessions:p?.truncation.sessionsOmitted,workspaces:p?.truncation.workspacesOmitted})}),x&&(0,K.jsx)(`p`,{className:`sidebar-scope-note`,role:`alert`,children:t(`restoreFailed`)}),(0,K.jsx)(`div`,{className:`workspace-tree`,children:D.length?D.map(n=>{let r=(m?g:e.collapsed).has(n.path)&&!e.query.trim(),i=!m&&!n.ungrouped&&j===n.path;return(0,K.jsxs)(`section`,{className:`workspace-group ${r?`collapsed`:``} ${i?`is-active-workspace`:``}`,children:[(0,K.jsxs)(`div`,{className:`workspace-button`,children:[(0,K.jsxs)(`button`,{className:`workspace-label`,type:`button`,"aria-expanded":!r,"aria-current":i?`location`:void 0,disabled:!!e.query.trim(),title:n.path===`__ungrouped__`?void 0:n.path,onClick:()=>{m?_(e=>{let t=new Set(e);return t.has(n.path)?t.delete(n.path):t.add(n.path),t}):e.actions.toggleWorkspace(n.path)},children:[(0,K.jsx)(`span`,{className:`workspace-toggle`,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`workspace-chevron`,children:`⌄`})}),(0,K.jsxs)(`span`,{className:`workspace-identity`,children:[(0,K.jsx)(`strong`,{children:n.name}),!n.ungrouped&&(0,K.jsx)(`small`,{children:Gb(n.path)})]})]}),!n.ungrouped&&(0,K.jsxs)(`span`,{className:`workspace-row-actions`,children:[(0,K.jsx)(ZS,{label:`Workspace options`,items:[{id:`rename`,label:t(`renameWorkspace`),icon:(0,K.jsx)(it,{}),onClick:()=>N({kind:`workspace`,path:n.path,name:n.name})},{id:`remove`,label:t(`removeWorkspace`),icon:(0,K.jsx)(lt,{}),variant:`destructive`,onClick:()=>a({path:n.path,name:n.name})}]}),(0,K.jsx)(Hb,{content:t(`newSession`),children:(0,K.jsx)(`button`,{className:`workspace-action`,type:`button`,"aria-label":`${t(`newSession`)} ${n.name}`,onClick:t=>{t.stopPropagation(),e.actions.createSession(n.path)},children:(0,K.jsx)(Ye,{})})})]})]}),!r&&(0,K.jsx)(`div`,{className:`workspace-sessions`,children:n.sessions.length?n.sessions.map(n=>(0,K.jsxs)(`div`,{className:`session-row`,children:[(0,K.jsxs)(`button`,{className:`session ${n.path===O?`active`:``}`,type:`button`,"aria-current":n.path===O?`page`:void 0,"aria-label":`${Ub(n,t(`untitledSession`))} · ${n.path}`,onClick:()=>void e.actions.selectSession(n.path),children:[(0,K.jsx)(`span`,{className:`session-title`,children:Ub(n,t(`untitledSession`))}),(0,K.jsx)(`span`,{className:`session-time`,children:qb(n.modified)})]}),(0,K.jsx)(ZS,{label:t(`conversationOptions`),items:[{id:`rename`,label:t(`renameConversation`),icon:(0,K.jsx)(it,{}),onClick:()=>N({kind:`session`,path:n.path,name:Ub(n,t(`untitledSession`))})},{id:m?`restore`:`archive`,label:v.has(n.path)?t(`restoringConversation`):t(m?`restoreConversation`:`archiveConversation`),icon:m?(0,K.jsx)(k,{}):(0,K.jsx)(A,{}),isDisabled:v.has(n.path),onClick:()=>m?void E(n.path):void e.actions.archiveSession(n.path)}]})]},n.path)):(0,K.jsx)(`div`,{className:`empty`,children:t(`noConversations`)})})]},n.path)}):(0,K.jsx)(`div`,{className:`empty`,children:e.query.trim()?t(M?`noMatchingLoaded`:`noMatching`):t(m?`noLoadedArchives`:`noSessions`)})}),(0,K.jsx)(`div`,{className:`sidebar-footer`,children:(0,K.jsxs)(`button`,{className:`sidebar-settings-button`,type:`button`,"aria-label":t(`settings`),title:t(`settings`),"data-provider-settings-trigger":!0,disabled:e.settingsDisabled,onClick:e.onOpenSettings,children:[(0,K.jsx)(tt,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:t(`settings`)})]})}),(0,K.jsx)(Lx,{isOpen:!!n,onOpenChange:e=>!e&&!C&&r(null),purpose:`form`,width:400,"aria-label":n?.kind===`workspace`?t(`renameWorkspace`):t(`renameConversation`),children:(0,K.jsxs)(`form`,{className:`openpi-dialog`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,K.jsx)(`strong`,{children:n?.kind===`workspace`?t(`renameWorkspace`):t(`renameConversation`)}),(0,K.jsx)(`input`,{ref:u,value:o,maxLength:80,"aria-label":n?.kind===`workspace`?t(`workspaceName`):t(`conversationName`),onChange:e=>s(e.target.value)}),(0,K.jsxs)(`div`,{className:`dialog-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(null),children:t(`cancel`)}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:C,children:t(`save`)})]})]})}),(0,K.jsx)(Lx,{isOpen:!!i,onOpenChange:e=>!e&&a(null),purpose:`form`,width:440,"aria-label":t(`deleteWorkspace`),children:(0,K.jsxs)(`div`,{className:`openpi-dialog`,children:[(0,K.jsx)(`strong`,{children:t(`deleteWorkspace`)}),(0,K.jsxs)(`p`,{children:[i?.name,`:`,t(`workspaceDeleteConfirm`)]}),(0,K.jsxs)(`div`,{className:`dialog-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(null),children:t(`cancel`)}),(0,K.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>{i&&(e.actions.removeWorkspace(i.path),a(null))},children:t(`deleteWorkspace`)})]})]})})]})}function $S({sessionId:e,providerId:t,active:n}){let{t:r}=Ln(),i=(0,w.useMemo)(()=>new zp,[]),[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(null),d=(0,w.useRef)(null);(0,w.useEffect)(()=>{if(!n)return;let t=`${e}:${a}`;if(d.current===t)return;let o=new AbortController;return c(null),u(null),i.providerAuth(e,o.signal).then(e=>{o.signal.aborted||(d.current=t,c(e))},e=>{o.signal.aborted||u(e instanceof Error?e.message:r(`providerLoadFailed`))}),()=>o.abort()},[n,i,a,e,r]);let f=s?.providers.find(e=>e.id===t),p=Array.isArray(f?.authMethods)?f.authMethods:[],m=p.length?p.map(e=>r(`providerAuth_${e}`)).join(` · `):r(`providerAuthUnknown`);return(0,K.jsxs)(`section`,{className:`provider-status-section provider-status-detail`,children:[(0,K.jsxs)(`div`,{className:`provider-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:r(`modelConnection`)}),(0,K.jsx)(`strong`,{children:f?.name||t})]}),(0,K.jsxs)(`button`,{type:`button`,className:`provider-refresh`,"aria-label":r(`refreshStatus`),disabled:!s,onClick:()=>o(e=>e+1),children:[(0,K.jsx)(Ze,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`refreshStatus`)})]})]}),!s&&!l?(0,K.jsx)(`p`,{className:`provider-settings-state`,role:`status`,children:r(`providerLoading`)}):l?(0,K.jsxs)(`div`,{className:`provider-settings-state error`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:r(`providerLoadFailed`)}),(0,K.jsx)(`span`,{children:l}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(e=>e+1),children:r(`retryAdmissionCheck`)})]}):f?(0,K.jsxs)(`article`,{className:`provider-connection-card`,"data-configured":f.configured?`true`:`false`,children:[(0,K.jsxs)(`div`,{className:`provider-connection-state`,children:[(0,K.jsx)(`span`,{className:`provider-state-icon ${f.configured?`configured`:`missing`}`,"aria-hidden":`true`,children:f.configured?(0,K.jsx)(W,{}):(0,K.jsx)(re,{})}),(0,K.jsxs)(`div`,{className:`provider-identity`,children:[(0,K.jsx)(`strong`,{children:f.name||f.id}),f.name!==f.id&&(0,K.jsx)(`span`,{children:f.id})]}),(0,K.jsx)(`span`,{className:`provider-state-label ${f.configured?`configured`:`missing`}`,children:r(f.configured?`credentialConfigured`:`credentialMissing`)})]}),(0,K.jsxs)(`dl`,{className:`provider-connection-facts`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`authentication`)}),(0,K.jsx)(`dd`,{children:m})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`accessType`)}),(0,K.jsx)(`dd`,{children:r(f.subscription?`providerAccessSubscription`:`providerAccessStandard`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`configurationOwner`)}),(0,K.jsx)(`dd`,{children:r(`providerReadOnly`)})]})]})]}):(0,K.jsxs)(`div`,{className:`provider-settings-state`,children:[(0,K.jsx)(`strong`,{children:t}),(0,K.jsx)(`span`,{children:r(`providerStatusUnavailable`)})]}),(0,K.jsxs)(`aside`,{className:`provider-read-only`,children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:r(`providerReadOnly`)}),(0,K.jsx)(`p`,{children:r(`providerReadOnlyDetail`)}),(0,K.jsx)(`small`,{children:r(`authNotVerified`)})]})]})]})}var eC=20,tC={track:{kVAEAm:`x10l6tqk`,kWkggS:`xdsb6cv`,kaIpWk:`xjspbzw`,$$css:!0},trackHorizontal:{kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kZKoxP:`xqu0tyb`,k87sOh:`xwa60dl`,k3aq6I:`x1cb1t30`,$$css:!0},trackVertical:{k87sOh:`x13vifvy`,krVfgx:`x1ey2m1c`,kzqmXN:`x51ohtg`,$$css:!0},filledTrack:{kVAEAm:`x10l6tqk`,kWkggS:`x1ewilqj`,kaIpWk:`xjspbzw`,$$css:!0},filledTrackHorizontal:{kZKoxP:`xqu0tyb`,k87sOh:`xwa60dl`,k3aq6I:`x1cb1t30`,$$css:!0},filledTrackVertical:{kzqmXN:`x51ohtg`,$$css:!0},thumb:{kVAEAm:`x10l6tqk`,kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,kaIpWk:`xjspbzw`,kWkggS:`x1ewilqj`,k3aq6I:`x11lhmoz`,k1ekBW:`x106061f`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,kI3sdo:`x1a2a7pz`,kkrTdU:`x1jm3nie x16khyan`,kY2c9j:`x1vjfegm`,$$css:!0},thumbHorizontal:{k87sOh:`xwa60dl`,k3aq6I:`x11lhmoz xoffwj3`,$$css:!0},thumbHover:{kWkggS:`x1ewilqj xvxo0qp`,$$css:!0},thumbDisabled:{kWkggS:`xwmxj5m`,kkrTdU:`xt0e3qv`,$$css:!0}};function nC(e,t,n){return Math.min(Math.max(e,t),n)}function rC(e){if(Math.abs(e)<1){let t=e.toExponential().split(`e-`);if(t.length===2)return(t[0].split(`.`)[1]?.length??0)+parseInt(t[1],10)}let t=String(e).split(`.`)[1];return t?t.length:0}function iC(e,t,n){if(n<=0)return e;let r=t+Math.round((e-t)/n)*n,i=Math.min(Math.max(rC(t),rC(n)),20);return Number(r.toFixed(i))}function aC(e,t,n){return n===t?0:(e-t)/(n-t)*100}var oC=eC/2;function sC(e){return uC(e,oC-e/100*eC)}function cC(e,t){let n=t-e;return uC(n,-(n/100)*eC)}function lC(e,t){let n=t-eC;return n>0?(e-oC)/n:t>0?e/t:0}function uC(e,t){let n=e=>Number(e.toFixed(3));return`calc(${n(e)}% ${t<0?`-`:`+`} ${Math.abs(n(t))}px)`}function dC({ref:e,...t}){let{label:n,isLabelHidden:r=!1,description:i,isDisabled:a=!1,disabledMessage:o,isOptional:s=!1,isRequired:c=!1,status:l,labelTooltip:u,min:d=0,max:f=100,step:p=1,orientation:m=`horizontal`,formatValue:h,htmlName:g,valueDisplay:_=`tooltip`,marks:v,width:y,xstyle:b,className:x,style:S,"data-testid":C,value:T,onChange:E,onChangeEnd:D}=t,O=Array.isArray(T),k=O&&`minStepsBetweenThumbs`in t?t.minStepsBetweenThumbs??0:0,A=m===`horizontal`,j=(0,w.useId)(),M=(0,w.useId)(),N=(0,w.useId)(),P=(0,w.useId)(),F=(0,w.useId)(),I=(0,w.useRef)(null),L=(0,w.useRef)(null),[R,z]=(0,w.useState)(null),[B,V]=(0,w.useState)(null);(0,w.useEffect)(()=>{fh()},[]);let H=(0,w.useCallback)((e,t)=>{V(!a&&ph()===`keyboard`?e:null)},[a]),U=(0,w.useCallback)(e=>{V(null)},[]),ee=a&&!!o,te=Ph({placement:`above`,focusTrigger:`always`,isEnabled:ee}),ne=c&&!s,W=[];i&&W.push(N),l?.message&&W.push(P),ne&&W.push(F),ee&&W.push(te.describedBy);let re=W.length>0?W.join(` `):void 0,ie=(0,w.useMemo)(()=>(Array.isArray(T)?T:[T??d]).map(e=>nC(e,d,f)),[T,d,f]),ae=(0,w.useRef)(ie);ae.current=ie;let oe=(0,w.useCallback)((e,t)=>{let n=I.current;if(!n)return d;let r=n.getBoundingClientRect(),i;return i=A?lC(mb(n)?r.right-e:e-r.left,r.width):1-lC(t-r.top,r.height),i=nC(i,0,1),nC(iC(d+i*(f-d),d,p),d,f)},[d,f,p,A]),se=(0,w.useCallback)(e=>{if(!O)return 0;let[t,n]=ie;return Math.abs(e-t)<=Math.abs(e-n)?0:1},[O,ie]),ce=(0,w.useCallback)((e,t)=>{if(a)return;let n=nC(iC(t,d,p),d,f);if(O){let t=[...ie];t[e]=n;let r=k*p;e===0?t[0]=Math.min(t[0],t[1]-r):t[1]=Math.max(t[1],t[0]+r),t[0]=nC(t[0],d,f),t[1]=nC(t[1],d,f),E?.(t)}else E?.(n)},[a,O,ie,d,f,p,k,E]),le=(0,w.useRef)(D);le.current=D;let ue=(0,w.useCallback)(e=>{let t=e??ae.current,n=le.current;O?n?.(t):n?.(t[0])},[O]),de=(0,w.useCallback)(e=>{if(a)return;e.preventDefault();let t=e.target.closest(`[data-mark-value]`),n=t?Number(t.dataset.markValue):oe(e.clientX,e.clientY),r=se(n);L.current=r,z(r),ce(r,n);let i=I.current;i&&i.querySelectorAll(`[role="slider"]`)[r]?.focus(),V(null),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId)},[a,oe,se,ce]),fe=(0,w.useCallback)(e=>{if(L.current===null||a)return;let t=oe(e.clientX,e.clientY);ce(L.current,t)},[a,oe,ce]),pe=(0,w.useCallback)(e=>{L.current!==null&&(L.current=null,z(null),ue())},[ue]),me=(0,w.useCallback)((e,t)=>{if(a)return;ph()===`keyboard`&&V(e);let n=ie[e],r;switch(t.key){case`ArrowRight`:case`ArrowUp`:r=n+p;break;case`ArrowLeft`:case`ArrowDown`:r=n-p;break;case`PageUp`:r=n+p*10;break;case`PageDown`:r=n-p*10;break;case`Home`:r=d;break;case`End`:r=f;break;default:return}t.preventDefault();let i=nC(iC(r,d,p),d,f);if(ce(e,r),O){let t=[...ie];t[e]=i;let n=k*p;e===0?t[0]=Math.min(t[0],t[1]-n):t[1]=Math.max(t[1],t[0]+n),t[0]=nC(t[0],d,f),t[1]=nC(t[1],d,f),ue(t)}else ue([i])},[a,O,ie,p,d,f,k,ce,ue]),he=e=>h?h(e):String(e),ge=e=>{let t=ie[e],n=aC(t,d,f),r=A?{insetInlineStart:sC(n)}:{bottom:sC(n),left:`50%`},i=O?e===0?`Minimum value`:`Maximum value`:void 0,o=k*p,s=O&&e===1?nC(ie[0]+o,d,f):d,c=O&&e===0?nC(ie[1]-o,d,f):f,u=_===`tooltip`&&!ee,g=A?`above`:`start`,v=(0,K.jsx)(`div`,{id:O?void 0:j,role:`slider`,tabIndex:a&&!ee?-1:0,"aria-valuemin":s,"aria-valuemax":c,"aria-valuenow":t,"aria-valuetext":h?h(t):void 0,"aria-orientation":m,"aria-disabled":a||void 0,"aria-invalid":l?.type===`error`||void 0,"aria-label":i,"aria-labelledby":O?void 0:M,"aria-describedby":re,onKeyDown:t=>me(e,t),onFocus:t=>H(e,t),onBlur:U,...rg(X(`slider-thumb`,{orientation:m,disabled:a?`disabled`:null}),Y(tC.thumb,A?tC.thumbHorizontal:ug.centerInline(`50%`),!a&&tC.thumbHover,!a&&B===e&&mg.focusVisible,a&&tC.thumbDisabled),void 0,r)},e);return u?(0,K.jsx)(Hb,{content:he(t),placement:g,delay:0,focusTrigger:`always`,isOpen:R===e||void 0,children:v},e):v},_e=(()=>{if(O){let[e,t]=ie,n=aC(e,d,f),r=aC(t,d,f);return A?{insetInlineStart:sC(n),width:cC(n,r)}:{bottom:sC(n),height:cC(n,r)}}let e=aC(ie[0],d,f);return A?{insetInlineStart:`0%`,width:sC(e)}:{bottom:`0%`,height:sC(e)}})(),ve=_===`text`?(0,K.jsx)(`span`,{className:`x9ynric xcr08ib x1tgivj0 xuxw1ft x2lah0s`,children:O?`${he(ie[0])} – ${he(ie[1])}`:he(ie[0])}):null;return(0,K.jsxs)(gS,{"data-testid":C,label:n,isLabelHidden:r,description:i,inputID:j,labelID:M,isGroupLabel:!0,descriptionID:i?N:void 0,isOptional:s,isRequired:c,isDisabled:a,status:l?{type:l.type,message:l.message,messageID:l.message?P:void 0}:void 0,labelTooltip:u,statusVariant:`detached`,width:y,xstyle:b,className:x,style:S,children:[(0,K.jsxs)(`div`,{...rg(X(`slider`,{orientation:m,disabled:a?`disabled`:null}),{className:`x78zum5 x6s0dn4 x1txdalj`}),children:[g!=null&&ie.map((e,t)=>(0,K.jsx)(`input`,{type:`hidden`,name:g,value:String(e),disabled:a},t===0?`start`:`end`)),(0,K.jsxs)(`div`,{ref:_g(e,I,te.ref),...O?{role:`group`,"aria-labelledby":M}:void 0,onPointerDown:de,onPointerMove:fe,onPointerUp:pe,onPointerCancel:pe,...{0:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 xw4jnvo x1ymw6g xkagaj0 xdt5ytf xl56j7k x1ypdohk x16khyan`},2:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 x1qx5ct2 x80b3aj xh8yej3 x1ypdohk x16khyan`},1:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 xw4jnvo x1ymw6g xkagaj0 xdt5ytf xl56j7k xbyyjgo xt0e3qv`},3:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 x1qx5ct2 x80b3aj xh8yej3 xbyyjgo xt0e3qv`}}[!!A<<1|!!a<<0],children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,...rg(X(`slider-track`,{orientation:m}),Y(tC.track,A?tC.trackHorizontal:[tC.trackVertical,ug.centerInline(`0px`)]))}),(0,K.jsx)(`div`,{"aria-hidden":`true`,...rg(Y(tC.filledTrack,A?tC.filledTrackHorizontal:[tC.filledTrackVertical,ug.centerInline(`0px`)]),{style:_e})}),v&&(0,K.jsx)(`div`,{"aria-hidden":`true`,...{0:{className:`x10l6tqk x13vifvy x1ey2m1c xbudbmw`},1:{className:`x10l6tqk x1o0tod xtijo5x xwa60dl`}}[!!A<<0],children:v.map(e=>{let t=aC(e.value,d,f),n=A?{insetInlineStart:sC(t)}:{bottom:sC(t)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{"data-testid":`slider-mark`,"data-mark-value":e.value,...rg({0:{className:`x10l6tqk x7njt3n xjspbzw x36qwtl x1xc55vz x1m9mm8y`},1:{className:`x10l6tqk x7njt3n xjspbzw xfo62xy xdk7pt x11lhmoz xoffwj3`}}[!!A<<0],{style:n})}),e.label&&(0,K.jsx)(`span`,{"data-testid":`slider-mark-label`,"data-mark-value":e.value,...rg({0:{className:`x10l6tqk x9ynric x141an7d xv1l7n4 xuxw1ft x131p8rn x9p6ekw`},1:{className:`x10l6tqk x9ynric x141an7d xv1l7n4 xuxw1ft xuuh30 x1nyx83j xuivejd`}}[!!A<<0],{style:n}),children:e.label})]},e.value)})}),ie.map((e,t)=>ge(t))]}),ve]}),ne&&(0,K.jsx)(Vg,{id:F,children:`Required`}),ee&&te.renderTooltip(o)]})}dC.displayName=`Slider`;var fC={x1iwu4tg:`x1iwu4tg`,$$css:!0},pC={sm:{kzqmXN:`x1td3qas`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`x100vrsf`,kZKoxP:`xxk0z11`,$$css:!0}},mC={sm:{kzqmXN:`x1td3qas`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`x100vrsf`,kZKoxP:`xxk0z11`,$$css:!0}},hC={sm:{kzqmXN:`x1td3qas`,kZKoxP:`x1qx5ct2`,kmVPX3:`x1i3ajwb`,$$css:!0},md:{kzqmXN:`x100vrsf`,kZKoxP:`xxk0z11`,kmVPX3:`xfawy5m`,$$css:!0}},gC={sm:{kzqmXN:`x6jxa94`,kZKoxP:`x1v9usgg`,k3aq6I:`xbryuvx`,$$css:!0},md:{kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,k3aq6I:`xbryuvx`,$$css:!0}},_C={sm:{kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,k3aq6I:`xv5t66b xi9aj42`,$$css:!0},md:{kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,k3aq6I:`x15481yp x12xz5k6`,$$css:!0}},vC={sm:{kAzted:`xisnujt`,$$css:!0},md:{kAzted:`xjwf9q1`,$$css:!0}},yC={container:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,$$css:!0},containerLabelHidden:{kOIVth:`xxhr3t`,$$css:!0},containerSpread:{kjj79g:`x1qughib`,kzqmXN:`xh8yej3`,$$css:!0},statusGap:{keoZOQ:`xtbrsbv`,$$css:!0},switchWrapper:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kmuXW:`x2lah0s`,kHBbk8:`xc8icb0`,$$css:!0},input:{kVAEAm:`x10l6tqk`,kogj98:`x1ghz6dp`,kmVPX3:`x1717udv`,kSiTet:`xg01cxk`,kkrTdU:`x1ypdohk x16khyan`,kY2c9j:`x1vjfegm`,k7Eaqz:`xkagaj0`,kAzted:`x80b3aj`,k87sOh:`xijlfn0`,kLqNvP:`x1hsn8va`,k3aq6I:`x8i4i9p`,$$css:!0},inputDisabled:{kkrTdU:`xt0e3qv`,$$css:!0},inputBusy:{kfzvcC:`x47corl`,$$css:!0},track:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kaIpWk:`xjspbzw`,k1ekBW:`x15406qy`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,kB7OPa:`x9f619`,kMzoRj:`xc342km x13rsnn2`,ksu8eU:`xng3xce xx61lck`,kVAM5u:`x1w1tqly`,$$css:!0},trackFocus:{kI3sdo:`x1a2a7pz xafswnp`,kInvED:`xwz5zln`,$$css:!0},trackOff:{kWkggS:`xspzpui x1a8ae7b x9yvj25`,$$css:!0},trackOn:{kWkggS:`x1ewilqj xcgwt1n x1jzqe4`,$$css:!0},trackDisabled:{kSiTet:`xbyyjgo`,kVAM5u:`xmnqt3w`,$$css:!0},trackDisabledOff:{kWkggS:`xspzpui`,$$css:!0},thumb:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kaIpWk:`xjspbzw`,k1ekBW:`xh3q6i0`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},thumbOff:{kWkggS:`x10xzikg xwvh9j7`,$$css:!0},thumbOn:{kWkggS:`x10xzikg x1sir5s4`,$$css:!0},labelWrapper:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kjj79g:`xl56j7k`,$$css:!0}},bC={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function xC({label:e,isLabelHidden:t=!1,description:n,onChange:r,changeAction:i,isLoading:a=!1,value:o,isDisabled:s=!1,htmlName:c,disabledMessage:l,isOptional:u=!1,isRequired:d=!1,onFocus:f,onBlur:p,labelIcon:m,labelTooltip:h,labelPosition:g=`end`,labelSpacing:_=`hug`,status:v,size:y=`md`,width:b,xstyle:x,className:S,style:C,ref:T,...E}){let D=(0,w.useId)(),O=(0,w.useId)(),k=(0,w.useId)(),A=TS({isRequired:d,isOptional:u}),[,j]=(0,w.useTransition)(),[M,N]=(0,w.useOptimistic)(o),P=a||M!==o,F=M===!0,I=s&&!!l,L=Ph({placement:`above`,focusTrigger:`always`,isEnabled:I}),R=[];n&&R.push(O),v?.message&&R.push(k),I&&R.push(L.describedBy);let z=R.length>0?R.join(` `):void 0,B=(0,K.jsxs)(`div`,{...Y(yC.switchWrapper,pC[y]),children:[(0,K.jsx)(`input`,{ref:_g(T,L.positionRef),id:D,type:`checkbox`,role:`switch`,name:s?void 0:c,checked:F,disabled:s&&!I,"aria-disabled":I?`true`:void 0,form:I?``:void 0,required:d,"aria-required":A?`true`:void 0,onChange:e=>{if(s||P)return;let t=e.target.checked;r?.(t,e),i&&!e.defaultPrevented&&j(async()=>{N(t),await i(t,e)})},onFocus:f,onBlur:p,"aria-describedby":z,"aria-invalid":v?.type===`error`||void 0,"aria-busy":P||void 0,...Y(yC.input,mC[y],s&&yC.inputDisabled,P&&yC.inputBusy)}),(0,K.jsx)(`div`,{"aria-hidden":`true`,...rg(X(`switch`,{checked:F?`checked`:null,disabled:s?`disabled`:null,size:y}),Y(yC.track,hC[y],F?yC.trackOn:yC.trackOff,!s&&yC.trackFocus,s&&yC.trackDisabled,s&&!F&&yC.trackDisabledOff)),children:(0,K.jsx)(`div`,{...rg(X(`switch-thumb`,{checked:F?`checked`:null,size:y}),Y(yC.thumb,F?_C[y]:gC[y],F?yC.thumbOn:yC.thumbOff)),children:P&&(0,K.jsx)(Bg,{size:`sm`})})}),P&&(0,K.jsx)(Vg,{role:`status`,children:`Loading`})]}),V=(0,K.jsx)(`div`,{...Y(yC.labelWrapper,vC[y]),children:(0,K.jsx)(lS,{...X(`switch-label`),label:e,inputID:D,isLabelHidden:t,isDisabled:s,isOptional:u,isRequired:d,labelIcon:m,labelTooltip:h,description:n,descriptionID:O})});return(0,K.jsxs)(`div`,{...rg(X(`switch-field`,{labelPosition:g===`end`?void 0:g,labelSpacing:_===`hug`?void 0:_}),Y(b!=null&&bC.width(b),x),S,C),...E,children:[(0,K.jsxs)(`div`,{ref:e=>{L.interactionRef(e)},...Y(yC.container,t&&yC.containerLabelHidden,_===`spread`&&yC.containerSpread,!s&&fC),children:[` `,g===`start`?(0,K.jsxs)(K.Fragment,{children:[V,B]}):(0,K.jsxs)(K.Fragment,{children:[B,V]})]}),v?.message&&(0,K.jsx)(pS,{type:v.type,message:v.message,id:k,variant:`detached`,xstyle:yC.statusGap}),I&&L.renderTooltip(l)]})}xC.displayName=`Switch`;var SC=[{id:`light`,label:`themeLight`,Icon:st},{id:`dark`,label:`themeDark`,Icon:Ue},{id:`mist`,label:`themeMist`,Icon:ce},{id:`rose`,label:`themeRose`,Icon:we},{id:`pine`,label:`themePine`,Icon:ut},{id:`system`,label:`themeSystem`,Icon:He}],CC=[`explorer`,`implementer`,`reviewer`,`advisor`];function wC({catalog:e,error:t,onRefresh:n}){let{t:r}=Ln();return!t&&!e?(0,K.jsxs)(`div`,{className:`settings-load-state`,role:`status`,children:[(0,K.jsx)(Ze,{className:`settings-spin`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`settingsCatalogLoading`)})]}):t?(0,K.jsxs)(`div`,{className:`settings-load-state error`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:r(`settingsCatalogFailed`)}),(0,K.jsx)(`span`,{children:t}),(0,K.jsx)(`button`,{type:`button`,onClick:n,children:r(`retryAdmissionCheck`)})]}):null}function TC({isPending:e,onConfigure:t,request:n,label:r}){return(0,K.jsx)(Pv,{label:r,variant:`secondary`,size:`sm`,icon:(0,K.jsx)(pt,{"aria-hidden":`true`}),isDisabled:e,isLoading:e,onClick:()=>void t(n)})}function EC({catalog:e,error:t,currentModel:n,thinkingLevel:r,cwd:i,theme:a,setupPending:o,preferencePending:s,onConfigure:c,onUpdatePreferences:l,onOpenRuntimeStatus:u,onRefresh:d}){let{t:f}=Ln(),p=e?.setup,m=p?.ui.webTheme??a,[h,g]=(0,w.useState)(p?.ui.webChatWidth??820),[_,v]=(0,w.useState)(p?.ui.webChatFontSize??14);return(0,w.useEffect)(()=>{p&&(g(p.ui.webChatWidth),v(p.ui.webChatFontSize))},[p]),(0,K.jsxs)(`section`,{className:`settings-general-panel`,children:[(0,K.jsxs)(`div`,{className:`settings-page-heading`,children:[(0,K.jsx)(`div`,{children:(0,K.jsx)(`h1`,{children:f(`generalSettings`)})}),(0,K.jsx)(TC,{isPending:o,onConfigure:c,request:f(`setupRequestReviewAll`),label:f(`configureOpenPi`)})]}),(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`appearance`)}),(0,K.jsx)(`div`,{className:`settings-theme-options`,role:`radiogroup`,"aria-label":f(`appearance`),children:SC.map(({id:e,label:t,Icon:n})=>(0,K.jsxs)(`label`,{className:`settings-theme-option`,"data-selected":m===e?`true`:void 0,children:[(0,K.jsx)(`input`,{type:`radio`,name:`openpi-web-theme`,value:e,checked:m===e,disabled:s,onChange:()=>{l({theme:e})}}),(0,K.jsx)(n,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(t)})]},e))})]}),p&&(0,K.jsxs)(`section`,{className:`settings-section-block settings-chat-controls`,children:[(0,K.jsx)(`h2`,{children:f(`conversationSettings`)}),(0,K.jsx)(xC,{label:f(`expandThinkingByDefault`),value:p.ui.webExpandThinking,size:`sm`,width:`100%`,labelPosition:`start`,labelSpacing:`spread`,isDisabled:s,isLoading:s,onChange:e=>{l({expandThinking:e})}}),(0,K.jsx)(`div`,{className:`settings-slider-control`,children:(0,K.jsx)(dC,{label:f(`chatContentWidth`),value:h,min:820,max:2e3,step:10,width:`100%`,valueDisplay:`text`,formatValue:e=>`${e}px`,isDisabled:s,onChange:e=>g(e),onChangeEnd:e=>{e!==p.ui.webChatWidth&&l({chatWidth:e}).then(e=>{e||g(p.ui.webChatWidth)})}})}),(0,K.jsx)(`div`,{className:`settings-slider-control`,children:(0,K.jsx)(dC,{label:f(`chatFontSize`),value:_,min:12,max:24,step:1,width:`100%`,valueDisplay:`text`,formatValue:e=>`${e}px`,isDisabled:s,onChange:e=>v(e),onChangeEnd:e=>{e!==p.ui.webChatFontSize&&l({chatFontSize:e}).then(e=>{e||v(p.ui.webChatFontSize)})}})})]}),(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:d}),p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`agentBehavior`)}),(0,K.jsxs)(`div`,{className:`settings-fact-grid`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(rt,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`capabilityDiscovery`)}),(0,K.jsx)(`strong`,{children:f(`capabilityDiscovery_${p.capabilities.discovery}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(ke,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`workflowLimits`)}),(0,K.jsx)(`strong`,{children:f(`workflowLimitsValue`,{concurrency:p.workflows.concurrency,calls:p.workflows.maxAgentCalls})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(I,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`nextActionSuggestions`)}),(0,K.jsx)(`strong`,{children:p.suggestions.enabled?p.suggestions.model?`${p.suggestions.model.provider}/${p.suggestions.model.model} · ${p.suggestions.model.reasoning}`:f(`enabled`):f(`disabled`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(le,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`postEditCommand`)}),(0,K.jsx)(`strong`,{children:f(p.postEditConfigured?`configured`:`disabled`)})]})]})]}),(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`resultDisplay`)}),(0,K.jsxs)(`dl`,{className:`settings-summary-list`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`subagentResults`)}),(0,K.jsx)(`dd`,{children:f(`detailDisplay_${p.ui.subagentResultDisplay}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`bashOperations`)}),(0,K.jsx)(`dd`,{children:f(`detailDisplay_${p.ui.bashToolDisplay}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`fileMutations`)}),(0,K.jsx)(`dd`,{children:f(`detailDisplay_${p.ui.fileMutationDisplay}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`footer`)}),(0,K.jsx)(`dd`,{children:p.ui.customFooter?`${f(`enabled`)} · ${p.ui.footerStyle}`:f(`disabled`)})]})]})]})]}),(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`sessionSettings`)}),(0,K.jsxs)(`dl`,{className:`settings-summary-list`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`selectedModel`)}),(0,K.jsx)(`dd`,{children:n?.label??f(`noModels`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`thinkingLevel`)}),(0,K.jsx)(`dd`,{children:r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`currentWorkspace`)}),(0,K.jsx)(`dd`,{title:i,children:i})]})]}),(0,K.jsx)(Pv,{label:f(`openRuntimeDetails`),variant:`secondary`,size:`sm`,icon:(0,K.jsx)(Te,{"aria-hidden":`true`}),className:`settings-runtime-action`,onClick:u})]})]})}function DC(e){return e.split(/[\\/]/u).filter(Boolean).at(-1)||e}function OC({catalog:e,error:t,onRefresh:n}){let{t:r}=Ln(),i=e?.resources.skills??[],a=(0,w.useMemo)(()=>[`project`,`user`,`temporary`].map(e=>({scope:e,skills:i.filter(t=>t.scope===e)})).filter(e=>e.skills.length>0),[i]),[o,s]=(0,w.useState)(``),[c,l]=(0,w.useState)(null),u=i.find(e=>e.id===o)??i[0];(0,w.useEffect)(()=>{i.length&&!i.some(e=>e.id===o)&&s(i[0].id)},[o,i]);let d=e=>{l(null),sp(`/skill:${e.name} `).then(e=>l(e?`copied`:`failed`))};return(0,K.jsxs)(`section`,{className:`settings-split-panel`,children:[(0,K.jsxs)(`aside`,{className:`settings-resource-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-resource-list`,children:[a.map(e=>(0,K.jsxs)(`section`,{className:`settings-resource-group`,children:[(0,K.jsx)(`span`,{className:`settings-sidebar-label`,children:r(`resourceScope_${e.scope}`)}),e.skills.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`settings-resource-item`,"aria-current":e.id===u?.id?`page`:void 0,onClick:()=>{s(e.id),l(null)},children:[(0,K.jsx)(rt,{"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`small`,{children:DC(e.source)})]})]},e.id))]},e.scope)),!e&&!t&&(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}),e&&!i.length&&(0,K.jsx)(`p`,{className:`settings-resource-empty`,children:r(`noSkillsFound`)})]}),(0,K.jsxs)(`div`,{className:`settings-sidebar-footer`,children:[(0,K.jsx)(`span`,{children:r(`skillCount`,{count:i.length})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":r(`refreshStatus`),onClick:n,children:(0,K.jsx)(Ze,{"aria-hidden":`true`})})]})]}),(0,K.jsx)(`div`,{className:`settings-resource-detail`,children:t?(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}):u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:r(`skill`)}),(0,K.jsx)(`h1`,{children:u.name}),(0,K.jsx)(`p`,{children:u.description})]}),(0,K.jsx)(Pv,{label:r(c===`copied`?`copiedMessage`:`copySkillInvocation`),variant:`secondary`,size:`sm`,icon:c===`copied`?(0,K.jsx)(B,{}):(0,K.jsx)(oe,{}),onClick:()=>d(u)})]}),(0,K.jsxs)(`dl`,{className:`settings-detail-metadata`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`source`)}),(0,K.jsx)(`dd`,{children:u.source})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`scope`)}),(0,K.jsx)(`dd`,{children:r(`resourceScope_${u.scope}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`invocation`)}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{children:`/skill:${u.name}`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`modelInvocation`)}),(0,K.jsx)(`dd`,{children:r(u.disableModelInvocation?`explicitOnly`:`availableToModel`)})]})]}),(0,K.jsxs)(`section`,{className:`settings-path-block`,children:[(0,K.jsx)(Ce,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:r(`skillFile`)}),(0,K.jsx)(`code`,{children:u.filePath})]})]}),c===`failed`&&(0,K.jsx)(`p`,{className:`inspection-warning`,children:r(`copyFailed`)})]}):(0,K.jsxs)(`div`,{className:`settings-empty-detail`,children:[(0,K.jsx)(rt,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`selectSkill`)})]})})]})}function kC({catalog:e,error:t,currentModel:n,activity:r,setupPending:i,onConfigure:a,onRefresh:o}){let{t:s}=Ln(),[c,l]=(0,w.useState)(`explorer`),u=e?.setup.subagents.roleModels[c],d=r?.items.filter(e=>e.status===`running`).length??0,f=r?.items.filter(e=>e.status!==`running`).length??0;return(0,K.jsxs)(`section`,{className:`settings-subagents-panel`,children:[(0,K.jsxs)(`header`,{className:`settings-subagent-summary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:s(`subagentConfiguration`)}),(0,K.jsx)(`span`,{children:s(`subagentConfigurationIntro`)})]}),e&&(0,K.jsxs)(`div`,{className:`settings-subagent-metrics`,children:[(0,K.jsx)(`span`,{children:s(`subagentActiveCount`,{count:d})}),(0,K.jsx)(`span`,{children:s(`subagentCompletedCount`,{count:f})}),(0,K.jsx)(`span`,{children:s(`subagentConcurrency`,{count:e.setup.workflows.concurrency})})]})]}),(0,K.jsxs)(`div`,{className:`settings-split-panel settings-subagent-split`,children:[(0,K.jsxs)(`aside`,{className:`settings-resource-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-resource-list`,children:[(0,K.jsx)(`span`,{className:`settings-sidebar-label`,children:s(`builtInRoles`)}),CC.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`settings-resource-item`,"aria-current":e===c?`page`:void 0,onClick:()=>l(e),children:[(0,K.jsx)(I,{"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:s(`subagentRole_${e}`)}),(0,K.jsx)(`small`,{children:s(`subagentRoleShort_${e}`)})]})]},e))]}),(0,K.jsx)(`div`,{className:`settings-sidebar-footer settings-sidebar-footer-action`,children:(0,K.jsx)(TC,{isPending:i,onConfigure:a,request:s(`setupRequestSubagents`),label:s(`configureRoles`)})})]}),(0,K.jsxs)(`div`,{className:`settings-resource-detail`,children:[(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:o}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:s(`builtInRole`)}),(0,K.jsx)(`h1`,{children:s(`subagentRole_${c}`)}),(0,K.jsx)(`p`,{children:s(`subagentRoleDescription_${c}`)})]}),(0,K.jsx)(`span`,{className:`settings-status-badge`,children:s(`builtIn`)})]}),(0,K.jsxs)(`dl`,{className:`settings-detail-metadata settings-detail-metadata-wide`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`modelAssignment`)}),(0,K.jsx)(`dd`,{children:u?`${u.provider}/${u.model}`:s(`inheritParentModel`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`effectiveModel`)}),(0,K.jsx)(`dd`,{children:u?`${u.provider}/${u.model}`:n?.label??s(`unknownState`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`workflowConcurrencyLabel`)}),(0,K.jsx)(`dd`,{children:e.setup.workflows.concurrency})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`workflowCallLimit`)}),(0,K.jsx)(`dd`,{children:e.setup.workflows.maxAgentCalls})]})]}),(0,K.jsxs)(`section`,{className:`settings-role-principles`,children:[(0,K.jsx)(`h2`,{children:s(`runtimeBoundaries`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),(0,K.jsx)(`p`,{children:s(`subagentAuthorityNote`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(pe,{"aria-hidden":`true`}),(0,K.jsx)(`p`,{children:s(`subagentModelNote`)})]})]})]})]})]})]})}function AC(e){return e.extensions.length+e.skills.length+e.prompts.length+e.themes.length}function jC({catalog:e,error:t,onRefresh:n}){let{t:r}=Ln(),i=e?.resources.plugins??[],[a,o]=(0,w.useState)(``),s=i.find(e=>e.id===a)??i[0];return(0,w.useEffect)(()=>{i.length&&!i.some(e=>e.id===a)&&o(i[0].id)},[i,a]),(0,K.jsxs)(`section`,{className:`settings-split-panel`,children:[(0,K.jsxs)(`aside`,{className:`settings-resource-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-resource-list`,children:[i.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`settings-resource-item`,"aria-current":e.id===s?.id?`page`:void 0,onClick:()=>o(e.id),children:[(0,K.jsx)(Je,{"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:DC(e.source)}),(0,K.jsx)(`small`,{children:r(`resourceCount`,{count:AC(e)})})]})]},e.id)),!e&&!t&&(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}),e&&!i.length&&(0,K.jsx)(`p`,{className:`settings-resource-empty`,children:r(`noPluginsFound`)})]}),(0,K.jsxs)(`div`,{className:`settings-sidebar-footer`,children:[(0,K.jsx)(`span`,{children:e?r(`pluginCatalogTotals`,e.resources.totals):r(`settingsCatalogLoading`)}),(0,K.jsx)(`button`,{type:`button`,"aria-label":r(`refreshStatus`),onClick:n,children:(0,K.jsx)(Ze,{"aria-hidden":`true`})})]})]}),(0,K.jsx)(`div`,{className:`settings-resource-detail`,children:t?(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}):s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:r(`resourceScope_${s.scope}`)}),(0,K.jsx)(`h1`,{children:DC(s.source)}),(0,K.jsx)(`code`,{children:s.source})]}),(0,K.jsx)(`span`,{className:`settings-status-badge healthy`,children:r(`loaded`)})]}),(0,K.jsxs)(`dl`,{className:`settings-detail-metadata settings-detail-metadata-wide`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`scope`)}),(0,K.jsx)(`dd`,{children:r(`resourceScope_${s.scope}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`resourceOrigin`)}),(0,K.jsx)(`dd`,{children:r(`resourceOrigin_${s.origin}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`resources`)}),(0,K.jsx)(`dd`,{children:r(`pluginResourceSummary`,{extensions:s.extensions.length,skills:s.skills.length,prompts:s.prompts.length,themes:s.themes.length})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`baseDirectory`)}),(0,K.jsx)(`dd`,{title:s.baseDir,children:s.baseDir??r(`notReported`)})]})]}),(0,K.jsxs)(`section`,{className:`settings-resource-groups`,children:[s.extensions.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`extensions`)}),(0,K.jsx)(`ul`,{children:s.extensions.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`code`,{children:e.path})]}),(0,K.jsx)(`span`,{children:r(`extensionSurfaceCount`,{tools:e.toolCount,commands:e.commandCount})})]},e.path))})]}),s.skills.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`skillsSettings`)}),(0,K.jsx)(`p`,{children:s.skills.join(` · `)})]}),s.prompts.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`prompts`)}),(0,K.jsx)(`p`,{children:s.prompts.join(` · `)})]}),s.themes.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`themes`)}),(0,K.jsx)(`p`,{children:s.themes.join(` · `)})]})]}),(0,K.jsxs)(`aside`,{className:`provider-read-only`,children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:r(`providerReadOnly`)}),(0,K.jsx)(`p`,{children:r(`pluginsManagedByPi`)})]})]})]}):(0,K.jsxs)(`div`,{className:`settings-empty-detail`,children:[(0,K.jsx)(Je,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`selectPlugin`)})]})})]})}function MC(e){let t=(0,w.useMemo)(()=>new zp,[]),[n,r]=(0,w.useState)(0),[i,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(null),c=(0,w.useCallback)(()=>r(e=>e+1),[]);return(0,w.useEffect)(()=>{let n=new AbortController;return a(null),s(null),t.settingsCatalog(e,n.signal).then(a,e=>{n.signal.aborted||s(e instanceof Error?e.message:String(e))}),()=>n.abort()},[t,n,e]),{catalog:i,error:o,refresh:c}}var NC=[{id:`general`,label:`generalSettings`,Icon:nt},{id:`models`,label:`modelSettings`,Icon:pe},{id:`skills`,label:`skillsSettings`,Icon:Ie},{id:`subagents`,label:`subagentsSettings`,Icon:I},{id:`plugins`,label:`pluginsSettings`,Icon:Je}];function PC(e){return`${e.provider}/${e.id}`}function FC({sessionId:e,cwd:t,models:n,currentModel:r,thinkingLevel:i,theme:a,capabilities:o,setupBusy:s,modelSelectionPending:c,onSelectModel:l,onConfigureOpenPi:u,interaction:d,onPreferencesChanged:f,onOpenRuntimeStatus:p,onClose:m}){let{t:h}=Ln(),g=(0,w.useRef)(null),[_,v]=(0,w.useState)(`general`),[y,b]=(0,w.useState)(!1),[x,S]=(0,w.useState)(!1),C=(0,w.useRef)(!1),T=(0,w.useRef)(!1),E=(0,w.useRef)(0),[D,O]=(0,w.useState)(!1),[k,A]=(0,w.useState)(null),{catalog:j,error:M,refresh:N}=MC(e),[P,F]=(0,w.useState)(r?PC(r):n[0]?PC(n[0]):``),I=(0,w.useMemo)(()=>{let e=new Map;for(let t of n){let n=e.get(t.provider)??[];n.push(t),e.set(t.provider,n)}return[...e.entries()]},[n]),L=n.find(e=>PC(e)===P)??r??n[0];(0,w.useEffect)(()=>{g.current?.focus()},[]),(0,w.useEffect)(()=>{if(!n.length){F(``);return}n.some(e=>PC(e)===P)||F(PC(r??n[0]))},[r,n,P]),(0,w.useEffect)(()=>{if(x){if(s){T.current=!0;return}!T.current||!C.current||(C.current=!1,T.current=!1,window.clearTimeout(E.current),N(),f())}},[f,N,s,x]),(0,w.useEffect)(()=>()=>window.clearTimeout(E.current),[]);let R=async e=>{if(y)return!1;b(!0),S(!1),C.current=!1,T.current=!1,window.clearTimeout(E.current),A(null);try{let t=await u(e);return t?(S(!0),C.current=!0,E.current=window.setTimeout(()=>{!C.current||T.current||(C.current=!1,T.current=!1,N(),f())},2e3)):A(h(`setupRequestFailed`)),t}catch(e){return b(!1),A(e instanceof Error?e.message:h(`setupRequestFailed`)),!1}finally{b(!1)}},z=e=>e.theme===void 0?e.chatWidth===void 0?e.chatFontSize===void 0?e.expandThinking===void 0?h(`setupRequestReviewAll`):h(e.expandThinking?`setupRequestEnableExpandedThinking`:`setupRequestDisableExpandedThinking`):h(`setupRequestSetChatFontSize`,{value:e.chatFontSize}):h(`setupRequestSetChatWidth`,{value:e.chatWidth}):h(`setupRequestSetTheme`,{value:e.theme});return(0,K.jsx)(Lx,{isOpen:!0,purpose:`info`,padding:0,width:1080,maxHeight:`calc(100dvh - 16px)`,className:`provider-settings-dialog`,"aria-label":h(`settings`),onOpenChange:e=>!e&&m(),children:(0,K.jsxs)(`section`,{className:`provider-settings-surface`,children:[(0,K.jsxs)(`header`,{className:`provider-settings-header`,children:[(0,K.jsx)(`strong`,{className:`provider-settings-title`,children:h(`settings`)}),(0,K.jsx)(`div`,{className:`provider-settings-navigation`,"aria-label":h(`settingsNavigation`),role:`tablist`,children:NC.map(({id:e,label:t,Icon:n})=>(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":_===e,"aria-controls":`settings-panel-${e}`,className:`provider-settings-tab`,title:h(t),onClick:()=>{v(e),A(null)},children:[(0,K.jsx)(n,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:h(t)})]},e))}),(0,K.jsx)(`button`,{ref:g,type:`button`,className:`icon-button provider-settings-close`,"aria-label":h(`close`),onClick:m,children:(0,K.jsx)(mt,{})})]}),(0,K.jsxs)(`div`,{className:`provider-settings-main`,children:[(0,K.jsx)(`div`,{id:`settings-panel-general`,role:`tabpanel`,hidden:_!==`general`,children:(0,K.jsx)(EC,{catalog:j,error:M,currentModel:r,thinkingLevel:i,cwd:t,theme:a,setupPending:y||s,preferencePending:D,onConfigure:R,onUpdatePreferences:async e=>{if(D)return!1;O(!0),A(null);try{return await R(z(e))}catch(e){return A(e instanceof Error?e.message:h(`settingsUpdateFailed`)),!1}finally{O(!1)}},onOpenRuntimeStatus:p,onRefresh:N})}),(0,K.jsxs)(`section`,{id:`settings-panel-models`,className:`settings-models`,role:`tabpanel`,hidden:_!==`models`,children:[(0,K.jsxs)(`aside`,{className:`settings-model-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-model-list`,children:[I.map(([e,t])=>(0,K.jsxs)(`section`,{className:`settings-model-group`,children:[(0,K.jsxs)(`h2`,{children:[(0,K.jsx)(pe,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`small`,{children:t.length})]}),t.map(e=>{let t=PC(e);return(0,K.jsxs)(`button`,{type:`button`,"aria-current":t===P?`page`:void 0,className:`settings-model-item`,onClick:()=>F(t),children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:e.name||e.id}),e.name!==e.id&&(0,K.jsx)(`small`,{children:e.id})]}),e.current&&(0,K.jsx)(B,{"aria-label":h(`currentModel`)})]},t)})]},e)),!n.length&&(0,K.jsx)(`p`,{className:`settings-model-empty`,children:h(`noModels`)})]}),(0,K.jsxs)(`div`,{className:`settings-model-provider-link`,children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),` `,h(`providerReadOnly`)]})]}),(0,K.jsx)(`div`,{className:`settings-model-detail`,children:L?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-model-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:h(`model`)}),(0,K.jsx)(`h1`,{children:L.name||L.id}),(0,K.jsx)(`code`,{children:PC(L)})]}),(0,K.jsx)(Pv,{label:L.current?h(`currentModel`):h(`useThisModel`),variant:L.current?`secondary`:`primary`,size:`sm`,icon:L.current?(0,K.jsx)(B,{"aria-hidden":`true`}):void 0,isDisabled:L.current||c,isLoading:c,onClick:()=>l(PC(L))})]}),(0,K.jsxs)(`dl`,{className:`settings-model-metadata`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:h(`provider`)}),(0,K.jsx)(`dd`,{children:L.provider})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:h(`modelId`)}),(0,K.jsx)(`dd`,{children:L.id})]})]}),(0,K.jsx)($S,{sessionId:e,providerId:L.provider,active:_===`models`})]}):(0,K.jsx)(`div`,{className:`provider-settings-state`,children:(0,K.jsx)(`strong`,{children:h(`noModels`)})})})]}),(0,K.jsx)(`div`,{id:`settings-panel-skills`,role:`tabpanel`,hidden:_!==`skills`,children:(0,K.jsx)(OC,{catalog:j,error:M,onRefresh:N})}),(0,K.jsx)(`div`,{id:`settings-panel-subagents`,role:`tabpanel`,hidden:_!==`subagents`,children:(0,K.jsx)(kC,{catalog:j,error:M,currentModel:r,activity:o?.subagents,setupPending:y||s,onConfigure:R,onRefresh:N})}),(0,K.jsx)(`div`,{id:`settings-panel-plugins`,role:`tabpanel`,hidden:_!==`plugins`,children:(0,K.jsx)(jC,{catalog:j,error:M,onRefresh:N})})]}),d,k&&(0,K.jsx)(`div`,{className:`settings-global-error`,role:`alert`,children:k}),x&&!k&&(0,K.jsx)(`div`,{className:`settings-global-status`,role:`status`,children:h(s?`setupRequestRunning`:`setupRequestAccepted`)})]})})}var IC=(0,w.createContext)(null);IC.displayName=`ListContext`;var LC={list:{kogj98:`x1ghz6dp`,kZCmMZ:`x1c1uobl`,kH6xsr:`x3ct3a4`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,$$css:!0},withDividers:{kOIVth:`xxhr3t`,$$css:!0},withCounter:{kt6KFK:`xif0320`,$$css:!0}},RC={kt6KFK:`x1khind5`,$$css:!0},zC={counterStart:e=>[RC,{"--x-counterReset":`astryx-list ${e}`==null?void 0:`astryx-list ${e}`}]};function BC({children:e,density:t=`balanced`,hasDividers:n=!1,header:r,listStyle:i=`none`,start:a,xstyle:o,className:s,style:c,"data-testid":l,ref:u,...d}){let f=(0,w.useId)(),p=i===`decimal`,m=p?`ol`:`ul`,h=(0,w.useMemo)(()=>({density:t,hasDividers:n,listStyle:i}),[t,n,i]),g=(0,K.jsx)(m,{ref:u,...d,"data-testid":l,...r==null?null:{"aria-labelledby":f},...p&&a!=null&&a!==1?{start:a}:{},role:`list`,...rg(X(`list`,{density:t,listStyle:i}),Y(LC.list,n&&LC.withDividers,i!==`none`&&(a!=null&&a!==1?zC.counterStart(a-1):LC.withCounter),o),s,c),children:e});return r==null?(0,K.jsx)(IC,{value:h,children:g}):(0,K.jsx)(IC,{value:h,children:(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf`,children:[(0,K.jsx)(`div`,{id:f,className:`x1p37lm5`,children:r}),g]})})}BC.displayName=`List`;var VC={withCounter:{kAmcRD:`xfrknyr`,$$css:!0},withDivider:{kt9PQ7:`x92x3c3`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},HC={noRadius:{kaIpWk:`x2u8bby`,$$css:!0}};function UC({label:e,description:t,startContent:n,endContent:r,onClick:i,interactiveRef:a,href:o,target:s,rel:c,isDisabled:l=!1,isSelected:u=!1,xstyle:d,className:f,style:p,ref:m,...h}){let g=(0,w.use)(IC),_=g?.density??`balanced`,v=g?.hasDividers??!1,y=g?.listStyle??`none`;return(0,K.jsx)($y,{as:`li`,ref:m,marker:y===`disc`?(0,K.jsx)(`span`,{className:`xoi2r2e x9f619 x78zum5 x6s0dn4 xl56j7k x2lah0s x12xnipv x1233pnv`,children:(0,K.jsx)(`span`,{className:`x1v4s8kt xols6we x16rqkct x19aspcf`})}):y===`circle`?(0,K.jsx)(`span`,{className:`xoi2r2e x9f619 x78zum5 x6s0dn4 xl56j7k x2lah0s x12xnipv x1233pnv`,children:(0,K.jsx)(`span`,{className:`x1v4s8kt xols6we x16rqkct xmkeg23 x1y0btm7 xqcx1ss xjbqb8w`})}):y===`decimal`?(0,K.jsx)(`span`,{className:`xoi2r2e x2lah0s x1tgivj0 xjm74w1 xw6l6zx x12xnipv xc2ndz5`}):null,startContent:n,label:e,description:t,endContent:r,onClick:i,interactiveRef:a,href:o,target:s,rel:c,isDisabled:l,isSelected:u,density:_,xstyle:[y!==`none`&&VC.withCounter,v&&VC.withDivider,v&&HC.noRadius,d],...rg(X(`list-item`),{className:f,style:p}),...h})}UC.displayName=`ListItem`;var WC={base:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kaIpWk:`x16rqkct`,kmuXW:`x2lah0s`,kzqmXN:`x1xc55vz`,kZKoxP:`xdk7pt`,$$css:!0},pulsing:{kKVMdj:`x1mta51n`,k44tkh:`x1c74tu6`,kyAemX:`x4hg4is`,ko0y90:`xa4qsjk`,$$css:!0},reducedMotion:{kjO2d4:`x1aquc0h`,$$css:!0}},GC={success:{kWkggS:`xdsz4j9`,kMwMTN:`xri61p4`,$$css:!0},warning:{kWkggS:`x1q8g9m5`,kMwMTN:`xrebv38`,$$css:!0},error:{kWkggS:`x1pjz0fi`,kMwMTN:`x1m024r3`,$$css:!0},accent:{kWkggS:`x1ewilqj`,kMwMTN:`x17wrial`,$$css:!0},neutral:{kWkggS:`x1q5y3ey`,kMwMTN:`xrkvqaz`,$$css:!0}};function KC({variant:e,label:t,isPulsing:n=!1,tooltip:r,icon:i,xstyle:a,className:o,style:s,ref:c,...l}){let u=og(i),d=(0,K.jsx)(`span`,{ref:c,role:`img`,"aria-label":t,...rg(X(`status-dot`,{variant:e},{legacyNames:[`statusdot`]}),Y(WC.base,GC[e],n&&WC.pulsing,n&&WC.reducedMotion,a),o,s),...l,children:u&&(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`x78zum5 x6s0dn4 xl56j7k x14ju556 x1xc55vz xdk7pt`,children:i})});return r?(0,K.jsx)(Hb,{content:r,children:d}):d}KC.displayName=`StatusDot`;function qC(e){let t=new Map;return e.map(e=>{let n=JSON.stringify(e),r=t.get(n)??0;return t.set(n,r+1),{item:e,key:`${n}:${r}`}})}function JC({name:e,args:t,output:n,state:r}){let{t:i}=Ln();return(0,K.jsxs)(`details`,{className:`subagent-tool ${r}`,"data-status":r,children:[(0,K.jsxs)(`summary`,{children:[(0,K.jsx)(`code`,{children:e}),(0,K.jsx)(`span`,{className:`subagent-state ${r}`,children:i(`subagentTool_${r}`)})]}),t&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`strong`,{className:`subagent-tool-label`,children:i(`trajectoryArguments`)}),(0,K.jsx)(`pre`,{children:t})]}),n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`strong`,{className:`subagent-tool-label`,children:i(`trajectoryOutput`)}),(0,K.jsx)(`pre`,{children:n})]})]})}function YC({sessionId:e,id:t,activity:n,client:r,saved:i,liveAvailable:a,fullView:o,readOnlyNote:s=!0}){let{t:c}=Ln(),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),[p,m]=(0,w.useState)(!0),[h,g]=(0,w.useState)(0),[_,v]=(0,w.useState)(null),y=(0,w.useRef)(null),b=(0,w.useRef)(!0);(0,w.useEffect)(()=>{if(!a){m(!1),f(c(`subagentUnavailable`));return}let i=new AbortController,o,s=!1,l=async()=>{if(s||i.signal.aborted||document.visibilityState===`hidden`)return;s=!0;let a=n?.status===`running`;try{let n=await r.subagentDetail(e,t,i.signal);if(i.signal.aborted)return;if(n.sessionId!==e||n.detail.kind!==`subagents`||n.detail.id!==t)throw u(null),a=!1,Error(c(`inspectionChanged`));a=n.detail.status===`running`,u(n.detail),f(null),v(new Date().toLocaleTimeString())}catch(e){if(i.signal.aborted)return;f(e instanceof Lp&&[404,501].includes(e.status)?c(`subagentUnavailable`):e instanceof Error?e.message:c(`inspectionUnavailable`))}finally{s=!1,i.signal.aborted||(m(!1),a&&(o=setTimeout(()=>void l(),1e3)))}},d=()=>{document.visibilityState===`visible`&&(clearTimeout(o),l())};return document.addEventListener(`visibilitychange`,d),l(),()=>{i.abort(),clearTimeout(o),document.removeEventListener(`visibilitychange`,d)}},[r,e,t,n?.status,h,a,c]),(0,w.useLayoutEffect)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight)},[l]);let x=new Map(l?.transcript.flatMap(e=>e.kind===`toolResult`?[[e.toolId,e]]:[])),S=new Set(l?.transcript.flatMap(e=>e.kind===`assistant`?e.parts.flatMap(e=>e.type===`toolCall`?[e.toolId]:[]):[])),C=l?.outcome===`interrupted`?`interrupted`:l?.status,T=l?.transcript.some(e=>e.kind===`assistant`&&e.parts.flatMap(e=>e.type===`text`?[e.text]:[]).join(` +`).map(e=>e.trim()).find(Boolean)??``;return t.length>60?`${t.slice(0,60)}…`:t}function Zb(e){return e&&typeof e==`object`?e:{}}function Qb(e){let t=new Map;for(let n of e){let e=n.role===`toolResult`&&n.toolName===`subagent_spawn`,r=n.role===`toolResult`&&[`subagent_wait`,`subagent_check`].includes(n.toolName??``)||n.customType===`subagent-result`;if(!e&&!r||n.isError)continue;let i=Zb(n.details);for(let r of Array.isArray(i.results)?i.results:[i]){let a=Zb(r);if(typeof a.id!=`string`||!a.id||a.id.length>160||/[\u0000-\u001f\u007f]/u.test(a.id))continue;let o=t.get(a.id),s={...o,id:a.id,title:typeof a.title==`string`?a.title:o?.title??a.id};e?s.receipt=n.content:(s.result=typeof i.displayContent==`string`?i.displayContent:n.content,s.state=a.outcome===`interrupted`?`interrupted`:a.status===`done`||a.status===`error`||a.status===`running`?a.status:void 0),t.delete(a.id),t.set(a.id,s)}}return[...t.values()].slice(-32)}function $b(e){return e===`interrupted`?`interrupted`:e===`running`?`running`:e===`done`||e===`completed`?`done`:[`error`,`failed`,`aborted`,`killed`,`timed_out`].includes(e)?`error`:e===`uncertain`?`warn`:`unknown`}function ex({kind:e,label:t,status:n,onClick:r}){return(0,K.jsxs)(r?`button`:`span`,{className:`activity-chip ${e} ${n}`,type:r?`button`:void 0,onClick:r,children:[n===`running`?(0,K.jsx)(`i`,{className:`activity-chip-dot`}):n===`done`?(0,K.jsx)(B,{}):n===`error`?(0,K.jsx)(mt,{}):n===`interrupted`?(0,K.jsx)(ie,{}):(0,K.jsx)(`span`,{className:`activity-chip-glyph`,children:`?`}),(0,K.jsx)(`span`,{className:`activity-chip-text`,children:t})]})}function tx({snapshot:e,onInspectTerminal:t,onInspectSubagent:n}){let{t:r}=Ln(),[,i]=(0,w.useState)(0),a=e?.runtime.capabilities,o=(0,w.useMemo)(()=>Qb((e?.selectedSession?.entries??[]).flatMap(e=>e.message?[e.message]:[])),[e?.selectedSession?.entries]),s=a?.subagents,c=new Set([...(s?.items??[]).map(e=>e.id),...o.map(e=>e.id)]).size,l=Math.max(c,(s?.items.length??0)+(s?.omitted??0)),u=(s?.items??[]).filter(e=>e.status===`running`).length,d=s?.childExecutionAdmission,f=[...a?.workflows?.items??[],...a?.[`background-terminals`]?.items??[]].some(e=>e.status===`running`);(0,w.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>i(e=>e+1),1e3);return()=>window.clearInterval(e)},[f]);let p=[];for(let e of a?.workflows?.items??[]){let t=e.agents.total-e.agents.running,n=e.agents.total?` · ${t}/${e.agents.total} agents`:``,r=e.status===`running`&&e.currentPhase?` · ${e.currentPhase}`:``,i=Yb(e.startedAt,e.finishedAt);p.push({key:`workflow-${e.runId}`,kind:`workflow`,label:`${e.name||e.runId}${r}${n}${i?` · ${i}`:``}`,status:$b(e.status)})}for(let e of a?.[`background-terminals`]?.items??[]){let n=Yb(e.createdAt,e.settledAt);p.push({key:`terminal-${e.id}`,onClick:t?()=>t(e.id):void 0,kind:`terminal`,label:`${e.title||e.id}${n?` · ${n}`:``}`,status:$b(e.status)})}p.sort((e,t)=>Number(t.status===`running`)-Number(e.status===`running`));let m=p.slice(0,5),h=p.length-m.length+(a?.workflows?.omitted??0)+(a?.[`background-terminals`]?.omitted??0);return!m.length&&!h&&!(n&&l)&&!d?.enabled?null:(0,K.jsxs)(`div`,{className:`activity-bar`,role:`status`,"aria-label":`Runtime activity`,children:[n&&l>0&&(0,K.jsx)(`button`,{className:`activity-chip subagent-list-trigger`,type:`button`,onClick:()=>n(),children:r(`subagentList`,{count:l,running:u})}),d?.enabled&&d.limit!==void 0&&(0,K.jsx)(`span`,{className:`activity-chip subagent-list-trigger`,children:`${d.held}/${d.limit} child slots · ${d.queued} queued · wf ${d.heldByOrigin.workflow} / direct ${d.heldByOrigin.direct} / btw ${d.heldByOrigin.btw}`}),m.map(({key:e,...t})=>(0,K.jsx)(ex,{...t},e)),h>0&&(0,K.jsxs)(`span`,{className:`activity-chip more`,children:[`+`,h]})]})}var nx={settle(){},release(){}};function rx(e){if(typeof window>`u`||typeof document>`u`)return nx;let t=document.documentElement,n=t.clientWidth;if(n===0)return nx;let r=t.style.scrollbarGutter,i=e.style.paddingRight,a=e.getBoundingClientRect().width,o=!1,s=!1,c=!1;return window.innerWidth>n&&(t.style.scrollbarGutter=`stable`,o=!0),{settle(){if(c)return;c=!0;let t=e.getBoundingClientRect().width-a;if(t<=0)return;let n=Number.parseFloat(window.getComputedStyle(e).paddingRight)||0;e.style.paddingRight=`${n+t}px`,s=!0},release(){s&&=(e.style.paddingRight=i,!1),o&&=(t.style.scrollbarGutter=r,!1)}}}var ix=0,ax=null;function ox(e){(0,w.useEffect)(()=>{if(!e)return;let{body:t}=document;if(ix===0){let e=window.scrollX,n=window.scrollY,r=rx(t);ax={scrollX:e,scrollY:n,overflow:t.style.overflow,position:t.style.position,top:t.style.top,left:t.style.left,right:t.style.right,gutter:r},t.style.overflow=`hidden`,t.style.position=`fixed`,t.style.top=`-${n}px`,t.style.left=`0`,t.style.right=`0`,r.settle()}return ix+=1,()=>{if(--ix,ix!==0||ax==null)return;let e=ax;ax=null,t.style.overflow=e.overflow,t.style.position=e.position,t.style.top=e.top,t.style.left=e.left,t.style.right=e.right,e.gutter.release(),window.scrollTo(e.scrollX,e.scrollY)}},[e])}var sx={container:{kB7OPa:`x9f619`,kZCmMZ:`x1c35znw`,kwRFfy:`x64h4k7`,kLKAdn:`x14m0hsi`,kGO01o:`xc1wllq`,$$css:!0}},cx=om[`--spacing-4`],lx=`var(--astryx-card-padding, ${cx})`,ux=`var(--astryx-card-padding-inline, ${lx})`;`${ux}`,`${ux}`,`${lx}`,`${lx}`;var dx=`var(--_section-padding-propagated, ${`var(--astryx-section-padding, ${cx})`})`,fx=`var(--astryx-section-padding-inline, ${dx})`;`${fx}`,`${fx}`,`${dx}`,`${dx}`;var px=`var(--astryx-dialog-padding, ${cx})`,mx=`var(--astryx-dialog-padding-inline, ${px})`;`${mx}`,`${mx}`,`${px}`,`${px}`;var hx={card:{containerPaddingInlineStart:{"--container-padding-inline-start":`xjmlhfd`,$$css:!0},containerPaddingInlineEnd:{"--container-padding-inline-end":`x1ihxwbr`,$$css:!0},containerPaddingBlockStart:{"--container-padding-block-start":`x1rqz8me`,$$css:!0},containerPaddingBlockEnd:{"--container-padding-block-end":`x1omyuck`,$$css:!0},layoutPaddingOuterX:{"--layout-padding-outer-x":`x14rzhog`,$$css:!0},layoutPaddingOuterY:{"--layout-padding-outer-y":`xjej9fs`,$$css:!0},layoutPaddingInnerX:{"--layout-padding-inner-x":`x4poyjn`,$$css:!0},layoutPaddingInnerY:{"--layout-padding-inner-y":`x1u1kw4e`,$$css:!0}},section:{containerPaddingInlineStart:{"--container-padding-inline-start":`x19lemt0`,$$css:!0},containerPaddingInlineEnd:{"--container-padding-inline-end":`xu1wldr`,$$css:!0},containerPaddingBlockStart:{"--container-padding-block-start":`xnw7zt4`,$$css:!0},containerPaddingBlockEnd:{"--container-padding-block-end":`xek4msv`,$$css:!0},layoutPaddingOuterX:{"--layout-padding-outer-x":`x15i0zw9`,$$css:!0},layoutPaddingOuterY:{"--layout-padding-outer-y":`x1vw4zgg`,$$css:!0},layoutPaddingInnerX:{"--layout-padding-inner-x":`x1v3gmnx`,$$css:!0},layoutPaddingInnerY:{"--layout-padding-inner-y":`x15yx5hm`,$$css:!0}},dialog:{containerPaddingInlineStart:{"--container-padding-inline-start":`x1tewnwq`,$$css:!0},containerPaddingInlineEnd:{"--container-padding-inline-end":`x11h1f2o`,$$css:!0},containerPaddingBlockStart:{"--container-padding-block-start":`x1g2kccc`,$$css:!0},containerPaddingBlockEnd:{"--container-padding-block-end":`x1gvthzm`,$$css:!0},layoutPaddingOuterX:{"--layout-padding-outer-x":`x1hsjncj`,$$css:!0},layoutPaddingOuterY:{"--layout-padding-outer-y":`x1pui4bz`,$$css:!0},layoutPaddingInnerX:{"--layout-padding-inner-x":`x2so38`,$$css:!0},layoutPaddingInnerY:{"--layout-padding-inner-y":`xinu7xd`,$$css:!0}}},gx={spacing0:{"--container-padding-inline-start":`x1gu2k80`,$$css:!0},spacing0_5:{"--container-padding-inline-start":`x14ws0sr`,$$css:!0},spacing1:{"--container-padding-inline-start":`x1cvlban`,$$css:!0},spacing1_5:{"--container-padding-inline-start":`x176g23i`,$$css:!0},spacing2:{"--container-padding-inline-start":`x1xlrr2o`,$$css:!0},spacing3:{"--container-padding-inline-start":`xfdwxua`,$$css:!0},spacing4:{"--container-padding-inline-start":`x1dlhslv`,$$css:!0},spacing5:{"--container-padding-inline-start":`x1s81nki`,$$css:!0},spacing6:{"--container-padding-inline-start":`x1ep0dkj`,$$css:!0},spacing7:{"--container-padding-inline-start":`x157xojc`,$$css:!0},spacing8:{"--container-padding-inline-start":`xw1diwv`,$$css:!0},spacing9:{"--container-padding-inline-start":`xraca2a`,$$css:!0},spacing10:{"--container-padding-inline-start":`xserb3f`,$$css:!0},spacing11:{"--container-padding-inline-start":`xziclwo`,$$css:!0},spacing12:{"--container-padding-inline-start":`x1iiwihq`,$$css:!0}},_x={spacing0:{"--container-padding-inline-end":`x91ghl5`,$$css:!0},spacing0_5:{"--container-padding-inline-end":`x1wz3t3y`,$$css:!0},spacing1:{"--container-padding-inline-end":`x2oyxnl`,$$css:!0},spacing1_5:{"--container-padding-inline-end":`xntetml`,$$css:!0},spacing2:{"--container-padding-inline-end":`xcas3b9`,$$css:!0},spacing3:{"--container-padding-inline-end":`xu0ipoa`,$$css:!0},spacing4:{"--container-padding-inline-end":`xs0pscg`,$$css:!0},spacing5:{"--container-padding-inline-end":`xgkj7vj`,$$css:!0},spacing6:{"--container-padding-inline-end":`x94cj42`,$$css:!0},spacing7:{"--container-padding-inline-end":`x11tj35w`,$$css:!0},spacing8:{"--container-padding-inline-end":`x1b9k1pi`,$$css:!0},spacing9:{"--container-padding-inline-end":`x19w02kr`,$$css:!0},spacing10:{"--container-padding-inline-end":`xx5lg5w`,$$css:!0},spacing11:{"--container-padding-inline-end":`x1nmgbqg`,$$css:!0},spacing12:{"--container-padding-inline-end":`x1wsfsk2`,$$css:!0}},vx={spacing0:{"--container-padding-block-start":`x1i3qcxz`,$$css:!0},spacing0_5:{"--container-padding-block-start":`xvdf9ev`,$$css:!0},spacing1:{"--container-padding-block-start":`xnsckjb`,$$css:!0},spacing1_5:{"--container-padding-block-start":`x1kbx601`,$$css:!0},spacing2:{"--container-padding-block-start":`xa8b4fq`,$$css:!0},spacing3:{"--container-padding-block-start":`x11k4f5r`,$$css:!0},spacing4:{"--container-padding-block-start":`xm01sq8`,$$css:!0},spacing5:{"--container-padding-block-start":`xp8wdkl`,$$css:!0},spacing6:{"--container-padding-block-start":`x1hmud4d`,$$css:!0},spacing7:{"--container-padding-block-start":`x1c00sag`,$$css:!0},spacing8:{"--container-padding-block-start":`xfv60at`,$$css:!0},spacing9:{"--container-padding-block-start":`x14fzdu7`,$$css:!0},spacing10:{"--container-padding-block-start":`x17h9kl7`,$$css:!0},spacing11:{"--container-padding-block-start":`x1rdjxae`,$$css:!0},spacing12:{"--container-padding-block-start":`xecwdl6`,$$css:!0}},yx={spacing0:{"--container-padding-block-end":`xkunwnr`,$$css:!0},spacing0_5:{"--container-padding-block-end":`x1cao3zv`,$$css:!0},spacing1:{"--container-padding-block-end":`x57a7ii`,$$css:!0},spacing1_5:{"--container-padding-block-end":`xv53x8y`,$$css:!0},spacing2:{"--container-padding-block-end":`x1lsgcmx`,$$css:!0},spacing3:{"--container-padding-block-end":`x1q3ppug`,$$css:!0},spacing4:{"--container-padding-block-end":`x4hfsld`,$$css:!0},spacing5:{"--container-padding-block-end":`xbib2ws`,$$css:!0},spacing6:{"--container-padding-block-end":`x1q8d17g`,$$css:!0},spacing7:{"--container-padding-block-end":`x1yqogew`,$$css:!0},spacing8:{"--container-padding-block-end":`x8lgq76`,$$css:!0},spacing9:{"--container-padding-block-end":`x1f7f9rt`,$$css:!0},spacing10:{"--container-padding-block-end":`x15vxphk`,$$css:!0},spacing11:{"--container-padding-block-end":`x4bg2x9`,$$css:!0},spacing12:{"--container-padding-block-end":`x186mjxr`,$$css:!0}},bx={spacing0:{"--layout-padding-outer-x":`xswhm3q`,$$css:!0},spacing0_5:{"--layout-padding-outer-x":`xihiwg7`,$$css:!0},spacing1:{"--layout-padding-outer-x":`xc96xmq`,$$css:!0},spacing1_5:{"--layout-padding-outer-x":`x1u93lgd`,$$css:!0},spacing2:{"--layout-padding-outer-x":`x15dxnc0`,$$css:!0},spacing3:{"--layout-padding-outer-x":`xadgj3j`,$$css:!0},spacing4:{"--layout-padding-outer-x":`x1v56qcf`,$$css:!0},spacing5:{"--layout-padding-outer-x":`x1nzs0gl`,$$css:!0},spacing6:{"--layout-padding-outer-x":`x1c3n52a`,$$css:!0},spacing7:{"--layout-padding-outer-x":`x1gfiokx`,$$css:!0},spacing8:{"--layout-padding-outer-x":`x1t3kfz`,$$css:!0},spacing9:{"--layout-padding-outer-x":`xzr4qsh`,$$css:!0},spacing10:{"--layout-padding-outer-x":`x1jdf5a4`,$$css:!0},spacing11:{"--layout-padding-outer-x":`x1hct0t0`,$$css:!0},spacing12:{"--layout-padding-outer-x":`x11cyqoe`,$$css:!0}},xx={spacing0:{"--layout-padding-outer-y":`x1mzf5mb`,$$css:!0},spacing0_5:{"--layout-padding-outer-y":`x1vj96e0`,$$css:!0},spacing1:{"--layout-padding-outer-y":`x1gpfxoh`,$$css:!0},spacing1_5:{"--layout-padding-outer-y":`xd3dqby`,$$css:!0},spacing2:{"--layout-padding-outer-y":`x10pz7y9`,$$css:!0},spacing3:{"--layout-padding-outer-y":`x1p6yq3h`,$$css:!0},spacing4:{"--layout-padding-outer-y":`xx738ci`,$$css:!0},spacing5:{"--layout-padding-outer-y":`x6yxws5`,$$css:!0},spacing6:{"--layout-padding-outer-y":`x180vrwl`,$$css:!0},spacing7:{"--layout-padding-outer-y":`x1q6rme1`,$$css:!0},spacing8:{"--layout-padding-outer-y":`xid7e43`,$$css:!0},spacing9:{"--layout-padding-outer-y":`x1t5kicu`,$$css:!0},spacing10:{"--layout-padding-outer-y":`x26l4wa`,$$css:!0},spacing11:{"--layout-padding-outer-y":`x10zktp0`,$$css:!0},spacing12:{"--layout-padding-outer-y":`x1yz3n6a`,$$css:!0}},Sx={spacing0:{"--layout-padding-inner-x":`xj1bl4l`,$$css:!0},spacing0_5:{"--layout-padding-inner-x":`xlriy2h`,$$css:!0},spacing1:{"--layout-padding-inner-x":`x6uuyak`,$$css:!0},spacing1_5:{"--layout-padding-inner-x":`xd38f90`,$$css:!0},spacing2:{"--layout-padding-inner-x":`xxqksqd`,$$css:!0},spacing3:{"--layout-padding-inner-x":`x1fyui2f`,$$css:!0},spacing4:{"--layout-padding-inner-x":`x1i2ajwi`,$$css:!0},spacing5:{"--layout-padding-inner-x":`x1tac27u`,$$css:!0},spacing6:{"--layout-padding-inner-x":`x1ntgf3t`,$$css:!0},spacing7:{"--layout-padding-inner-x":`xhjd9tl`,$$css:!0},spacing8:{"--layout-padding-inner-x":`xn7c84u`,$$css:!0},spacing9:{"--layout-padding-inner-x":`xeqkbsz`,$$css:!0},spacing10:{"--layout-padding-inner-x":`x1vf4qco`,$$css:!0},spacing11:{"--layout-padding-inner-x":`xsmamsf`,$$css:!0},spacing12:{"--layout-padding-inner-x":`x2xk2xj`,$$css:!0}},Cx={spacing0:{"--layout-padding-inner-y":`xwuefyo`,$$css:!0},spacing0_5:{"--layout-padding-inner-y":`x180h0y5`,$$css:!0},spacing1:{"--layout-padding-inner-y":`xmpug6m`,$$css:!0},spacing1_5:{"--layout-padding-inner-y":`x1g8jpzm`,$$css:!0},spacing2:{"--layout-padding-inner-y":`x1lksgje`,$$css:!0},spacing3:{"--layout-padding-inner-y":`x4j7gld`,$$css:!0},spacing4:{"--layout-padding-inner-y":`x1s3ehtl`,$$css:!0},spacing5:{"--layout-padding-inner-y":`x1rj5eim`,$$css:!0},spacing6:{"--layout-padding-inner-y":`x1ftgg6u`,$$css:!0},spacing7:{"--layout-padding-inner-y":`x1ho74vh`,$$css:!0},spacing8:{"--layout-padding-inner-y":`xm2cs6f`,$$css:!0},spacing9:{"--layout-padding-inner-y":`x1vsq92b`,$$css:!0},spacing10:{"--layout-padding-inner-y":`x18gbwmk`,$$css:!0},spacing11:{"--layout-padding-inner-y":`x14zymzj`,$$css:!0},spacing12:{"--layout-padding-inner-y":`xzfpkx9`,$$css:!0}},wx={containerMaxHeight:e=>[{"--container-max-height":e==null?e:`x18nyedi`,$$css:!0},{"--x---container-max-height":e??void 0}]};function Tx({padding:e=`spacing4`,paddingOuterX:t,paddingOuterY:n,paddingInnerX:r,paddingInnerY:i,useThemeDefault:a,maxHeight:o}){let s=t??e,c=n??e,l=r??e,u=i??e,d=o?wx.containerMaxHeight(o):null;if(a){let e=hx[a];return[sx.container,e.containerPaddingInlineStart,e.containerPaddingInlineEnd,e.containerPaddingBlockStart,e.containerPaddingBlockEnd,e.layoutPaddingOuterX,e.layoutPaddingOuterY,e.layoutPaddingInnerX,e.layoutPaddingInnerY,d]}return[sx.container,gx[s],_x[s],vx[c],yx[c],bx[s],xx[c],Sx[l],Cx[u],d]}var Ex=(0,w.createContext)(null);Ex.displayName=`DialogContext`;function Dx(e,t=16){let n=e.getBoundingClientRect(),r=n.left+n.width/2-window.innerWidth/2,i=n.top+n.height/2-window.innerHeight/2,a=Math.sqrt(r*r+i*i)||1;return{x:Math.round(r/a*t),y:Math.round(i/a*t)}}`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`,`${om[`--spacing-4`]}`;var Ox={dialog:{kVAEAm:`xixxii4`,kogj98:`x1bpp3o7`,kmVPX3:`x1717udv`,kWkggS:`x10xzikg`,"--_dialog-radius":`xvuvksw`,kaIpWk:`xuacgfc`,kGVxlE:`x1kcpxr7`,k1xSpc:`x1s85apg`,kXwgrk:`xdt5ytf`,kZKoxP:`xg7h5cd`,kZeWKH:`xish69e`,kSiTet:`xg01cxk`,k44tkh:`xqgcaz`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},open:{k1xSpc:`x78zum5`,kSiTet:`x1hc1fzr`,kKVMdj:`x1ewfqum x1aquc0h`,$$css:!0},backdrop:{kGyWv1:`xnixb3f`,kba3nw:`x1abwkk1`,$$css:!0},fullscreen:{kzqmXN:`x1o6l61p`,kZKoxP:`xtdtrs8`,ks0D6T:`xlbgzzq`,kskxy:`x1wj9ous`,kaIpWk:`x2u8bby`,kogj98:`x1ghz6dp`,kpwlN0:`x10a8y8t`,$$css:!0},fullscreenOpen:{kKVMdj:`xqcmdr3 x1aquc0h`,$$css:!0},fullscreenSafeArea:{kLKAdn:`x15ld1ci`,kGO01o:`x1rgxemn`,kZCmMZ:`xqmdmw x1i7f2ot`,kwRFfy:`x1by8st6 xtjjor6`,$$css:!0},inner:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kUk6DE:`x12lumcd`,kAzted:`x2lwn1j`,kVQacm:`xb3r6kr`,kaIpWk:`x1pjcqnp`,$$css:!0},inlineWrapper:{kmVPX3:`x1717udv`,kWkggS:`x10xzikg`,"--_dialog-radius":`xvuvksw`,kaIpWk:`xuacgfc`,kGVxlE:`x1kcpxr7`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kZKoxP:`xg7h5cd`,kZeWKH:`xish69e`,$$css:!0}},kx=om[`--spacing-4`],Ax=`min(100%, ${`calc(100dvw - ${kx} - ${kx})`})`;function jx(e){return typeof e==`number`?`${e}px`:e}function Mx(e,t){return{width:jx(e),maxWidth:Ax,maxHeight:jx(t)}}var Nx={kogj98:`x1ghz6dp`,$$css:!0},Px={sizing:(e,t,n)=>[{kzqmXN:e==null?e:`x5lhr3w`,ks0D6T:t==null?t:`xf68679`,kskxy:n==null?n:`x1jols5v`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-maxWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(t),"--x-maxHeight":(e=>typeof e==`number`?e+`px`:e??void 0)(n)}],position:(e,t,n,r)=>[Nx,{k87sOh:e==null?e:`xjbys53`,kLqNvP:t==null?t:`x1lxsm33`,kt4wiu:n==null?n:`xqxgn94`,krVfgx:r==null?r:`x1nqzi6q`,$$css:!0},{"--x-top":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-insetInlineStart":(e=>typeof e==`number`?e+`px`:e??void 0)(t),"--x-insetInlineEnd":(e=>typeof e==`number`?e+`px`:e??void 0)(n),"--x-bottom":(e=>typeof e==`number`?e+`px`:e??void 0)(r)}]};function Fx(e){return typeof e==`number`?`${e}px`:e}function Ix(e){let{top:t,bottom:n,start:r,end:i}=e;return{top:t===void 0?`auto`:Fx(t),bottom:n===void 0?`auto`:Fx(n),insetInlineStart:r===void 0?`auto`:Fx(r),insetInlineEnd:i===void 0?`auto`:Fx(i)}}function Lx({isOpen:e,isInline:t=!1,onOpenChange:n,width:r=400,maxHeight:i=`75dvh`,position:a,variant:o=`standard`,purpose:s=`info`,padding:c,children:l,xstyle:u,className:d,style:f,ref:p,...m}){let h=c==null,g=c??4,_=um[g],v=o===`fullscreen`,y=v?null:Mx(r,i),b=(0,w.useId)(),x=(0,w.useMemo)(()=>({isInline:t,titleId:b}),[t,b]),S=m[`aria-label`]!=null||m[`aria-labelledby`]!=null,C=(0,w.useRef)(null),T=_g(p,(0,w.useCallback)(e=>{C.current=e,!(!e||S)&&(e.querySelector(`#${CSS.escape(b)}`)==null?e.removeAttribute(`aria-labelledby`):e.setAttribute(`aria-labelledby`,b))},[b,S])),E=(0,w.useRef)(null),D=s!==`required`,O=s===`info`;(0,w.useEffect)(()=>{if(t)return;let n=C.current;if(n)if(e){E.current=document.activeElement;let e=E.current;if(e&&e!==document.body){let t=Dx(e);n.style.setProperty(`--dialog-dir-x`,`${t.x}px`),n.style.setProperty(`--dialog-dir-y`,`${t.y}px`)}else n.style.setProperty(`--dialog-dir-x`,`0px`),n.style.setProperty(`--dialog-dir-y`,`16px`);if(!n.open){n.showModal();let e=n.querySelector(`[data-autofocus]`);e&&e.focus()}}else n.open&&n.close(),E.current?.focus(),E.current=null},[e,t]),ox(e&&!t);let{shouldDismissOnCloseRequest:k}=eh({isActive:e,isEnabled:!t,escapeBehavior:D?`close`:`block`,onDismiss:()=>{n(!1)}}),A=(0,w.useRef)(!1);(0,w.useEffect)(()=>{let n=C.current?.querySelector(`#${CSS.escape(b)}`)!=null;e&&!t&&!S&&!n&&!A.current&&(A.current=!0)},[e,t,S,b]);let j=e=>{e.target===e.currentTarget&&O&&n(!1)},M=e=>{e.preventDefault(),k()&&D&&n(!1)},N=(0,K.jsx)(`div`,{...Y(Ox.inner,...Tx(h?{useThemeDefault:`dialog`,maxHeight:y?.maxHeight}:{paddingInnerX:_,paddingInnerY:_,paddingOuterX:_,paddingOuterY:_,maxHeight:y?.maxHeight}),!h&&g!==4&&dm[g],!h&&g!==4&&fm[g],!h&&g!==4&&pm[g],!h&&g!==4&&mm[g],v&&h&&Ox.fullscreenSafeArea),children:(0,K.jsx)(Ex,{value:x,children:l})}),P=a!=null&&!v,{open:F,...I}=m;return t?e?(0,K.jsx)(`div`,{...I,...rg(X(`dialog`,{variant:o}),Y(Ox.inlineWrapper,ym.reset,y&&Px.sizing(y.width,y.maxWidth,y.maxHeight),v&&Ox.fullscreen,u),d,f),"data-testid":m[`data-testid`],children:(0,K.jsx)(Nm,{children:N})}):null:(0,K.jsx)(`dialog`,{ref:T,...I,...rg(X(`dialog`,{variant:o}),gg.focusVisible(Ox.dialog,ym.reset,e&&Ox.open,Ox.backdrop,y&&Px.sizing(y.width,y.maxWidth,y.maxHeight),P&&(()=>{let e=Ix(a);return Px.position(e.top,e.insetInlineStart,e.insetInlineEnd,e.bottom)})(),v&&Ox.fullscreen,v&&e&&Ox.fullscreenOpen,u),d,f),onClick:j,onCancel:M,"aria-modal":`true`,...s===`required`?{role:`alertdialog`}:void 0,children:(0,K.jsx)(Nm,{children:N})})}Lx.displayName=`Dialog`;var Rx=`data-astryx-live-region`,zx=`position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;inset-block-start:0;inset-inline-start:0;pointer-events:none;user-select:none;`,Bx=2e3,Vx={polite:null,assertive:null};function Hx(e){let t=Vx[e];t!=null&&(clearTimeout(t),Vx[e]=null)}function Ux(e,t){Hx(e),Vx[e]=setTimeout(()=>{Vx[e]=null,t.textContent=``},Bx)}var Wx=null;function Gx(e){let t=document.createElement(`div`);return t.setAttribute(Rx,e),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(`role`,e===`assertive`?`alert`:`status`),t.style.cssText=zx,document.body.appendChild(t),t}function Kx(){return typeof document>`u`?null:Wx?(Wx.polite.isConnected||document.body.appendChild(Wx.polite),Wx.assertive.isConnected||document.body.appendChild(Wx.assertive),Wx):(Wx={polite:Gx(`polite`),assertive:Gx(`assertive`)},Wx)}function qx(e,t){let n=Kx();if(!n)return;let r=t===`assertive`?n.assertive:n.polite;r.textContent=``,requestAnimationFrame(()=>{r.textContent=e}),Ux(t,r)}function Jx(e){if(Hx(e),!Wx)return;let t=e===`assertive`?Wx.assertive:Wx.polite;t.textContent=``}function Yx(){return(0,w.useCallback)((e,t=`polite`)=>{if(!e){Jx(t);return}qx(e,t)},[])}var Xx=!1;typeof window<`u`&&requestAnimationFrame(()=>{Xx=!0});var Zx={slideDown:{kKVMdj:`x1srr2gu x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},slideUp:{kKVMdj:`x1dvww92 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},fadeIn:{kKVMdj:`xqcmdr3 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},scaleIn:{kKVMdj:`x97zbip x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0}};function Qx(e=`slideDown`){let[t]=(0,w.useState)(()=>Xx);return t?Zx[e]:null}var $x=new Set([`text`,`password`,`email`,`number`,`search`,`tel`,`url`,`date`,`datetime-local`,`month`,`time`,`week`]),eS=new Set([`true`,`menu`,`listbox`,`tree`,`grid`,`dialog`]);function tS(e){if(e.getAttribute(`role`)===`combobox`)return!0;let t=e.getAttribute(`aria-haspopup`);return t!=null&&eS.has(t)}function nS({containerRef:e,inputRef:t,disabled:n=!1}){return Jy({containerRef:e,interactiveRef:t,onClick:(0,w.useCallback)(()=>{let e=t.current;e!=null&&(e instanceof HTMLElement&&tS(e)?e.click():e instanceof HTMLInputElement&&$x.has(e.type)||e instanceof HTMLTextAreaElement?e.focus():e instanceof HTMLElement?e.click():`focus`in e&&e.focus())},[t]),disabled:n})}var rS={warning:`warning`,error:`error`,success:`success`},iS={warning:`@astryx.input.statusButton.warning`,error:`@astryx.input.statusButton.error`,success:`@astryx.input.statusButton.success`},aS={statusButton:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmVPX3:`x1717udv`,kogj98:`x1ghz6dp`,kMwMTN:`x1heor9g`,kkrTdU:`x1ypdohk x16khyan`,kfzvcC:`x67bb7w`,kaIpWk:`xjspbzw`,kInvED:`x7s97pk`,$$css:!0}};function oS({status:e,statusVariant:t=`attached`,isInGroup:n=!1,size:r=`md`}){let i=Tv(),a=t===`tooltip`&&!!e?.message,[o,s]=(0,w.useState)(void 0),c=Ph({placement:`above`,isEnabled:a,isOpen:o}),l=(0,w.useCallback)(()=>{s(void 0)},[]),u=(0,w.useCallback)(()=>{typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(hover: none)`).matches||s(e=>e!==!0)},[]);if((0,w.useEffect)(()=>{if(o!==!0)return;let e=e=>{e.key===`Escape`&&s(void 0)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]),!(e&&!n&&t!==`detached`))return{statusIcon:null,describedBy:void 0};let d=(0,K.jsx)(zy,{icon:rS[e.type],size:r,color:e.type,...X(`input-status-icon`,{size:r,status:e.type})});return a?{statusIcon:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,ref:c.ref,"aria-label":i(iS[e.type]),"aria-describedby":c.describedBy,onClick:u,onBlur:l,...Y(mg.focusVisible,aS.statusButton),children:d}),c.renderTooltip(e.message)]}),describedBy:c.describedBy}:{statusIcon:d,describedBy:void 0}}var sS=(0,w.createContext)({direction:`vertical`});sS.displayName=`FormLayoutContext`;var cS={label:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`xzye2dw`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kLWn49:`x1kq96og`,k63SB2:`x1e4wzip`,kMwMTN:`xv1l7n4`,kkrTdU:`x1ypdohk x16khyan`,$$css:!0},labelDisabled:{kMwMTN:`xnbbluu`,kkrTdU:`xt0e3qv`,$$css:!0},srOnly:{ksu8eU:`xng3xce`,kMcinP:`xzpqnlu`,kZKoxP:`xjm9jq1`,kLqNvP:`x1o0tod`,kogj98:`xkdpibf`,kVQacm:`xb3r6kr`,kmVPX3:`x1717udv`,kfzvcC:`x47corl`,kVAEAm:`x10l6tqk`,k87sOh:`x13vifvy`,kfSwDN:`x87ps6o`,khDVqt:`xuxw1ft`,kzqmXN:`x1i1rx1s`,$$css:!0}};function lS({label:e,inputID:t,labelID:n,isGroupLabel:r=!1,isLabelHidden:i=!1,isDisabled:a=!1,isOptional:o=!1,isRequired:s=!1,labelIcon:c,labelTooltip:l,description:u,descriptionID:d,className:f,style:p,xstyle:m,ref:h,...g}){let _=Tv(),{defaultOptionality:v}=(0,w.use)(sS),y=o&&v!==`optional`?_(`@astryx.field.optional`):s&&v!==`required`?_(`@astryx.field.required`):null,b=r?`span`:`label`,x=!r&&t!=null,S=(0,w.useRef)(null),C=nS({containerRef:S,inputRef:(0,w.useMemo)(()=>({get current(){return t==null?null:S.current?.ownerDocument.getElementById(t)??null},set current(e){}}),[t]),disabled:!x}),T=(0,K.jsxs)(K.Fragment,{children:[c&&Vy(c,{size:`sm`,color:`inherit`}),e,y&&(0,K.jsxs)(`span`,{className:`x1sodnla x141an7d x1ltkj2j xv1l7n4`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:` ∙ `}),y]}),l&&(0,K.jsx)(Hb,{content:l,placement:`above`,children:(0,K.jsx)(zy,{icon:`info`,size:`sm`,color:`inherit`})})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(b,{ref:h,id:n,htmlFor:r?void 0:t,...g,...rg(X(`field-label`),Y(cS.label,a&&cS.labelDisabled,i&&cS.srOnly,m),f,p),children:T}),u&&(0,K.jsx)(`span`,{ref:x?S:void 0,id:d,...x?C:void 0,...{0:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4`},2:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 x1ypdohk x16khyan`},1:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 xng3xce xzpqnlu xjm9jq1 x1o0tod xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s`},3:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 x1ypdohk x16khyan xng3xce xzpqnlu xjm9jq1 x1o0tod xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s`}}[!!x<<1|!!i<<0],children:u})]})}lS.displayName=`FieldLabel`;var uS={warning:`warning`,error:`error`,success:`success`},dS={base:{kMv6JI:`x9ynric`,kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,$$css:!0},attached:{keoZOQ:`x1c40v9y`,kLKAdn:`x1ak3mig`,kGO01o:`x1wesfrj`,kg3NbH:`xf314gf`,kVL7Gh:`xquck67`,kT0f0o:`x14i3lts`,$$css:!0},detached:{keoZOQ:`xcsaf9d`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`xh6dtrn`,$$css:!0}},fS={warning:{kWkggS:`x24i8r5`,kMwMTN:`xdhq94a`,$$css:!0},error:{kWkggS:`x1pritpl`,kMwMTN:`x1joocv1`,$$css:!0},success:{kWkggS:`xu13z74`,kMwMTN:`xltfdvo`,$$css:!0}};function pS({ref:e,type:t,message:n,id:r,variant:i=`attached`,xstyle:a,className:o,style:s,...c}){let l=Qx(`slideDown`),u=Yx();return(0,w.useEffect)(()=>{n&&u(n,t===`error`?`assertive`:`polite`)},[u,n,t]),(0,K.jsx)(`div`,{ref:e,id:r,...c,...rg(X(`field-status`,{type:t,variant:i}),Y(dS.base,l,i===`attached`?dS.attached:dS.detached,fS[t],a),o,s),children:i===`detached`?(0,K.jsxs)(`span`,{className:`x78zum5 x1cy8zhl xzye2dw`,children:[(0,K.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 x14o5nre x2lah0s`,children:(0,K.jsx)(zy,{icon:uS[t],size:`sm`,color:`inherit`,...X(`field-status-icon`,{type:t})})}),(0,K.jsx)(`span`,{children:n})]}):n})}pS.displayName=`FieldStatus`;var mS={container:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,$$css:!0},containerGap:{kOIVth:`xzye2dw`,$$css:!0},horizontalLabels:{k1xSpc:`xjp7ctv`,$$css:!0}},hS={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function gS({label:e,isLabelHidden:t=!1,description:n,inputID:r,labelID:i,isGroupLabel:a=!1,descriptionID:o,isOptional:s=!1,isRequired:c=!1,isDisabled:l=!1,labelIcon:u,status:d,labelTooltip:f,statusVariant:p=`attached`,width:m,xstyle:h,children:g,className:_,style:v,ref:y,...b}){let{direction:x}=(0,w.use)(sS),S=x===`horizontal-labels`,C=o??(n?`${r}-desc`:void 0),T=d?.messageID??(d?.message?`${r}-status`:void 0);Fv(`Field`,`isOptional and isRequired are mutually exclusive. isOptional takes precedence.`,s&&c);let E=(0,K.jsx)(lS,{label:e,inputID:r,labelID:i,isGroupLabel:a,isLabelHidden:t,isDisabled:l,isOptional:s,isRequired:c,labelIcon:u,labelTooltip:f,description:S?void 0:n,descriptionID:S?void 0:C}),D=d?.message&&p!==`tooltip`?(0,K.jsx)(pS,{type:d.type,message:d.message,id:T,variant:p}):null;return S?(0,K.jsxs)(`div`,{ref:y,...rg(X(`field`,{layout:`horizontal-labels`}),Y(mS.horizontalLabels,h),_,v),...b,children:[(0,K.jsx)(`div`,{className:`x1enrzb7`,children:E}),(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf xc8icb0`,children:[n&&(0,K.jsx)(Eg,{type:`supporting`,display:`block`,id:C,children:n}),g,D]})]}):(0,K.jsxs)(`div`,{ref:y,...rg(X(`field`),Y(mS.container,!t&&mS.containerGap,m!=null&&hS.width(m),h),_,v),...b,children:[E,p===`attached`?(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf xc8icb0`,children:[g,D]}):(0,K.jsxs)(K.Fragment,{children:[g,D]})]})}gS.displayName=`Field`;var _S={base:{kB7OPa:`x9f619`,kVAEAm:`x1n2onr6`,kY2c9j:`x1vjfegm`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kVAM5u:`xvy26l8 x6q1khz`,"--_field-radius":`x1832zxr`,kaIpWk:`xvdfih8`,kWkggS:`x10xzikg`,k1ekBW:`x12zzom9`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,kGVxlE:`x1gnnqk1 x1xqjsvb xuihb5h`,kI3sdo:`x1a2a7pz`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,kSiTet:`xbyyjgo`,kVAM5u:`xvy26l8`,kGVxlE:`x1gnnqk1`,$$css:!0}},vS={warning:{kVAM5u:`x8wg1ba`,$$css:!0},error:{kVAM5u:`x1ofxpqo`,$$css:!0},success:{kVAM5u:`x16m2moy`,$$css:!0}},yS={warning:{kGVxlE:`x1gnnqk1 x9156jc`,$$css:!0},error:{kGVxlE:`x1gnnqk1 x1bgmis8`,$$css:!0},success:{kGVxlE:`x1gnnqk1 x8wp45d`,$$css:!0}},bS={warning:{kVAM5u:`x8wg1ba xa1yw2k`,$$css:!0},error:{kVAM5u:`x1ofxpqo xk2sxw7`,$$css:!0},success:{kVAM5u:`x16m2moy xyq33ac`,$$css:!0}},xS={button:{kZKoxP:`x1qx5ct2`,kmuXW:`x2lah0s`,kVAEAm:`x1n2onr6`,"--_input-clear-hit-inset":`xtoycft x181bpwf`,"--_input-clear-hit-content":`xqxtgf4 xp8r40j`,k5JduY:`xh3pasq`,kwXMNM:`x1j6awrg`,kv0HGH:`xht581f`,$$css:!0}};function SS({label:e,onClick:t,onPointerDown:n,onClickCapture:r,xstyle:i,iconClassName:a}){let{className:o}=X(`input-clear-icon`),{className:s}=X(`input-clear-button`);return(0,K.jsx)(Pv,{variant:`ghost`,size:`sm`,label:e,className:s,icon:(0,K.jsx)(zy,{icon:`close`,size:`sm`,color:`secondary`,className:a==null?o:`${o} ${a}`}),onClick:t,onPointerDown:n,onClickCapture:r,isIconOnly:!0,xstyle:[xS.button,i]})}function CS(e){return SS(e)}CS.displayName=`InputClearButton`;var wS={inGroup:{kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,kZKoxP:`x5yr21d`,keTefX:`xd10s4z x1pwwqoy`,krdFHd:`x15mokao x8eehn2`,kVL7Gh:`xbiv7yw x1xrp5p4`,kfmiAY:`x1ga7v0g x1tzxhge`,kT0f0o:`x16uus16 x1rmb4wm`,kXnDq0:`x1rm9qnc`,$$css:!0}};function TS({isRequired:e=!1,isOptional:t=!1}){let{defaultOptionality:n}=(0,w.use)(sS);return!t&&(e||n===`required`)}var ES=(0,w.createContext)(null);ES.displayName=`InputGroupContext`;function DS(){return(0,w.use)(ES)}var OS={sm:{kZKoxP:`x6k0iem`,$$css:!0},md:{kZKoxP:`x1ueg155`,$$css:!0},lg:{kZKoxP:`xssyfek`,$$css:!0}};function kS({type:e=`text`,label:t,isLabelHidden:n=!1,description:r,isOptional:i=!1,isRequired:a=!1,isDisabled:o=!1,isReadOnly:s=!1,disabledMessage:c,startIcon:l,status:u,statusVariant:d=`attached`,size:f,onChange:p,changeAction:m,isLoading:h=!1,value:g,placeholder:_,labelTooltip:v,hasClear:y=!1,hasAutoFocus:b=!1,htmlName:x,onEnter:S,onKeyDown:C,width:T,xstyle:E,className:D,style:O,ref:k,...A}){let j=Tv(),M=TS({isRequired:a,isOptional:i}),N=Kg(f,`md`),P=(0,w.useId)(),F=(0,w.useId)(),I=(0,w.useId)(),L=(0,w.useId)(),R=(0,w.useRef)(null),z=(0,w.useRef)(null),B=DS(),[,V]=(0,w.useTransition)(),[H,U]=(0,w.useOptimistic)(g),ee=h||H!==g,te=o&&!!c,ne=Ph({placement:`above`,focusTrigger:`always`,isEnabled:te}),{statusIcon:W,describedBy:re}=oS({status:u,statusVariant:d,isInGroup:!!B}),{ariaLabelledBy:ie,ariaDescribedBy:ae}=cg(F,[r?I:null,!B&&d!==`tooltip`&&u?.message?L:null,re,te?ne.describedBy:null],B),oe=e=>{if(o||s)return;let t=e.target.value;p?.(t,e),m&&!e.defaultPrevented&&V(async()=>{U(t),await m(t,e)})},se=(0,w.useCallback)(()=>{p?.(``,null),R.current?.focus()},[p]),{onClick:ce,onMouseUp:le}=nS({containerRef:z,inputRef:R,disabled:o}),ue=(0,K.jsxs)(`div`,{ref:e=>{z.current=e,ne.ref(e)},onClick:ce,onMouseUp:le,...rg(X(`text-input`,{size:N,status:u?.type??null,disabled:o?`disabled`:null,readonly:s?`readonly`:null}),Y(_S.base,OS[N],o&&_S.disabled,u&&vS[u.type],u&&!o&&yS[u.type],u&&bS[u.type],B&&wS.inGroup,E),D,O),children:[l&&Vy(l,{size:`sm`,color:`secondary`}),B&&(0,K.jsx)(Vg,{id:F,children:t}),(0,K.jsx)(`input`,{...A,ref:_g(k,R),id:P,name:o?void 0:x,type:e,value:H,onChange:oe,onKeyDown:S||C?e=>{e.key===`Enter`&&S?.(),C?.(e)}:void 0,placeholder:_,disabled:o&&!te,"aria-disabled":te?`true`:void 0,readOnly:s||te||void 0,autoFocus:b,"data-autofocus":b||void 0,"aria-describedby":ae,"aria-required":M?`true`:void 0,"aria-invalid":u?.type===`error`?`true`:void 0,"aria-busy":ee||void 0,"aria-labelledby":ie,...{0:{className:`x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx x1tgivj0 xjbqb8w x1a2a7pz xeyghm5`},1:{className:`x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx x1tgivj0 xjbqb8w x1a2a7pz xeyghm5 xt0e3qv`}}[!!o<<0]}),y&&g!==``&&!o&&!s&&(0,K.jsx)(CS,{label:j(`@astryx.textInput.clearLabel`,{label:t}),onClick:se}),ee&&(0,K.jsx)(Bg,{size:`sm`}),W]});return B?(0,K.jsxs)(K.Fragment,{children:[ue,te&&ne.renderTooltip(c)]}):(0,K.jsxs)(gS,{label:t,isLabelHidden:n,description:r,inputID:P,descriptionID:r?I:void 0,isOptional:i,isRequired:a,isDisabled:o,status:u?{type:u.type,message:u.message,messageID:u.message?L:void 0}:void 0,statusVariant:d,labelTooltip:v,width:T,children:[ue,te&&ne.renderTooltip(c)]})}kS.displayName=`TextInput`;var AS={ARTIFACT_DENIED:`fileReferenceDenied`,ARTIFACT_MISSING:`fileReferenceMissing`,ARTIFACT_UNSUPPORTED:`fileReferenceUnsupported`,ARTIFACT_EXPIRED:`fileReferenceExpired`,ARTIFACT_LIMIT:`fileReferenceBusy`,ARTIFACT_BUSY:`fileReferenceBusy`};function jS({open:e,sessionId:t,onClose:n,onInsert:r}){let{t:i}=Ln(),a=(0,w.useMemo)(()=>new zp,[]),o=(0,w.useRef)(null),[s,c]=(0,w.useState)(``),[l,u]=(0,w.useState)(!1),[d,f]=(0,w.useState)(null);(0,w.useEffect)(()=>{e||(o.current?.abort(),o.current=null,c(``),u(!1),f(null))},[e]);let p=()=>{o.current?.abort(),o.current=null,n()},m=async()=>{let e=s.trim();if(!e||l)return;if(f(null),!t){r(e),n();return}let c=new AbortController;o.current=c,u(!0);let d;try{if(d=(await a.resolveArtifact(t,e,void 0,c.signal)).handle,await a.artifactMetadata(t,d,c.signal),c.signal.aborted)return;r(e),n()}catch(e){if(!c.signal.aborted){let t=e instanceof Lp&&e.code?AS[e.code]:void 0;f(t?i(t):e instanceof Error?e.message:i(`fileReferenceFailed`))}}finally{o.current=null,d&&a.releaseArtifact(t,d).catch(()=>void 0),c.signal.aborted||u(!1)}};return(0,K.jsx)(Lx,{isOpen:e,onOpenChange:e=>!e&&p(),purpose:`form`,width:460,"aria-label":i(`fileReferenceTitle`),children:(0,K.jsxs)(`form`,{className:`openpi-dialog file-reference-dialog`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,K.jsxs)(`div`,{className:`file-reference-heading`,children:[(0,K.jsx)(Ce,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:i(`fileReferenceTitle`)}),(0,K.jsx)(`p`,{children:i(`fileReferenceDetail`)})]})]}),(0,K.jsx)(kS,{label:i(`fileReferenceLabel`),value:s,placeholder:i(`fileReferencePlaceholder`),description:i(t?`fileReferenceValidatedHint`:`fileReferenceDraftHint`),hasAutoFocus:!0,hasClear:!0,isDisabled:l,onChange:e=>{c(e.slice(0,4096)),f(null)}}),d&&(0,K.jsx)(`p`,{className:`file-reference-error`,role:`alert`,children:d}),(0,K.jsxs)(`div`,{className:`dialog-actions`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:l,onClick:p,children:i(`cancel`)}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:l||!s.trim(),children:i(l?`fileReferenceChecking`:`insertReference`)})]})]})})}function MS(e,t){return t.every((t,n)=>e[n]===t)}function NS(e){if(MS(e,[137,80,78,71,13,10,26,10]))return`image/png`;if(MS(e,[255,216,255]))return`image/jpeg`;let t=new TextDecoder(`ascii`).decode(e.subarray(0,12));return t.startsWith(`GIF87a`)||t.startsWith(`GIF89a`)?`image/gif`:t.startsWith(`RIFF`)&&t.slice(8,12)===`WEBP`?`image/webp`:null}function PS(e){let t=``,n=32768;for(let r=0;r3145728)throw Error(`image-size`);let t=new Uint8Array(await e.arrayBuffer()),n=NS(t);if(!n)throw Error(`image-type`);let r=PS(t);return{id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${e.name}`,name:e.name||`image`,size:t.length,mimeType:n,data:r,previewUrl:`data:${n};base64,${r}`}}var IS={triggerContainer:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kOIVth:`x1txdalj`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib xdk3u5w`,kLWn49:`x1kq96og`,kMwMTN:`x1tgivj0`,kkrTdU:`x1ypdohk x16khyan`,$$css:!0},trigger:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kOIVth:`x1txdalj`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,kCS8Yb:`x1r8uery`,k7Eaqz:`xeuugli`,kmVPX3:`x1717udv`,kogj98:`x1ghz6dp`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kWkggS:`xjbqb8w`,kMv6JI:`xjb2p0i`,kGuDYH:`x1qlqyl8`,kLWn49:`x15bjb6t`,kMwMTN:`x1heor9g`,kkrTdU:`x1ypdohk x16khyan`,kI3sdo:`x1a2a7pz`,kaIpWk:`xh6dtrn`,$$css:!0},triggerText:{kzQI83:`x1iyjqo2`,k7Eaqz:`xeuugli`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,k9WMMc:`x1yc453h`,$$css:!0},placeholder:{kMwMTN:`xv1l7n4`,$$css:!0},triggerGhost:{kzqmXN:`x14atkfc`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kGVxlE:`x1gnnqk1 x1s17dad x15ysqaf`,k63SB2:`x1e4wzip`,k1ekBW:`xrafxwg`,k3aq6I:`x3oybdh xk4oym4`,$$css:!0},triggerGhostDisabled:{kKwaWg:`x18o3ruo`,k3aq6I:`x1c071of x1pdlv7q`,$$css:!0},triggerIcon:{kmuXW:`x2lah0s`,$$css:!0},triggerIconRotation:{k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,k3nNDw:`x1g0ag68`,$$css:!0},triggerIconOpen:{k3aq6I:`x19jd1h0`,$$css:!0},popover:{k7Eaqz:`xrzjruh`,$$css:!0},content:{kB7OPa:`x9f619`,kskxy:`xpnbb6b`,kVQacm:`xysyzu8`,kmVPX3:`x1b2ylru`,$$css:!0},sm:{kZKoxP:`x6k0iem`,$$css:!0},md:{kZKoxP:`x1ueg155`,$$css:!0},lg:{kZKoxP:`xssyfek`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,$$css:!0}};function LS({label:e,value:t,onChange:n,changeAction:r,children:i,triggerLabel:a,placeholder:o,isLabelHidden:s=!1,description:c,isOptional:l=!1,isRequired:u=!1,isDisabled:d=!1,isLoading:f=!1,status:p,statusVariant:m=`attached`,labelTooltip:h,size:g=`md`,variant:_=`input`,startIcon:v,width:y,placement:b=`below`,alignment:x=`start`,handleRef:S,onOpenChange:C,contentXstyle:T,xstyle:E,className:D,style:O,"data-testid":k,onClick:A,...j}){let M=Tv(),N=TS({isRequired:u,isOptional:l}),P=o??M(`@astryx.selector.placeholder`),F=_===`ghost`&&m===`attached`?`detached`:m,I=(0,w.useId)(),L=(0,w.useId)(),R=(0,w.useId)(),z=(0,w.useId)(),B=(0,w.useId)(),V=[c?z:null,p?.message?B:null].filter(e=>e!=null).join(` `)||void 0,H=(0,w.useRef)(null),[U,ee]=(0,w.useTransition)(),[te,ne]=(0,w.useOptimistic)(t),W=f||U,re=Rv({dialogLabel:e,hasCloseButton:!1,hasAutoFocus:!0,surfaceTarget:`complex-selector-popup`,onShow:(0,w.useCallback)(()=>{C?.(!0)},[C]),onHide:(0,w.useCallback)(()=>{H.current?.focus(),C?.(!1)},[C])}),ie=re.isOpen,ae=(0,w.useCallback)(()=>{d||(re.isOpen?re.hide():re.show())},[d,re]),oe=(0,w.useCallback)(()=>{re.hide()},[re]);(0,w.useImperativeHandle)(S,()=>({open:()=>{d||re.show()},close:()=>re.hide(),toggle:()=>{d||(re.isOpen?re.hide():re.show())},isOpen:()=>re.isOpen}),[d,re]);let se=(0,w.useCallback)(e=>{n?.(e),r&&ee(async()=>{ne(e),await r(e)})},[r,n,ne,ee]),ce=a??P,le=Vy(v,{size:`sm`,color:`secondary`}),ue=(0,K.jsx)(`div`,{id:R,...Y(IS.content,T),children:i(te,se,oe,{isOpen:ie,isBusy:W,triggerId:I,contentId:R})}),de=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{ref:re.triggerRef,"data-testid":k,...j,onClick:ag(A,ae),...rg(X(`complex-selector`,{variant:_,size:g,status:p?.type??null}),Y(_S.base,IS.triggerContainer,IS[g],mg.focusWithin,_===`ghost`&&IS.triggerGhost,_===`ghost`&&Qg.backgroundImage,d&&_S.disabled,_===`ghost`&&d&&IS.triggerGhostDisabled,d&&IS.disabled,a==null&&IS.placeholder,E),D,O),children:[og(le)&&le,(0,K.jsx)(`button`,{ref:H,id:I,type:`button`,"aria-haspopup":`dialog`,"aria-expanded":ie,"aria-controls":R,"aria-describedby":V,"aria-labelledby":L,"aria-required":N?`true`:void 0,"aria-invalid":p?.type===`error`?`true`:void 0,"aria-busy":W||void 0,disabled:d,onKeyDown:e=>{e.key===`ArrowDown`&&!ie&&!d&&(e.preventDefault(),re.show())},className:`x78zum5 x6s0dn4 x1qughib x1txdalj x1iyjqo2 xs83m0k x1r8uery xeuugli x1717udv x1ghz6dp xc342km xng3xce xjbqb8w xjb2p0i x1qlqyl8 x15bjb6t x1heor9g x1ypdohk x16khyan x1a2a7pz xh6dtrn`,children:(0,K.jsx)(`span`,{className:`x1iyjqo2 xeuugli xb3r6kr xlyipyv xuxw1ft x1yc453h`,children:ce})}),W&&(0,K.jsx)(Bg,{size:`sm`}),(0,K.jsx)(zy,{icon:`chevronDown`,size:`sm`,color:`secondary`,xstyle:[IS.triggerIcon,IS.triggerIconRotation,ie&&IS.triggerIconOpen],...X(`complex-selector-indicator-icon`,{state:ie?`expanded`:`collapsed`})})]}),re.render(ue,{placement:b,alignment:x,offset:om[`--spacing-1`],xstyle:[IS.popover,yh[b]]})]});return(0,K.jsx)(gS,{label:e,isLabelHidden:s,description:c,inputID:I,descriptionID:c?z:void 0,labelID:L,isOptional:l,isRequired:u,isDisabled:d,status:p?{type:p.type,message:p.message,messageID:p.message?B:void 0}:void 0,statusVariant:F,labelTooltip:h,width:y,children:de})}LS.displayName=`ComplexSelector`;function RS(e){let t=`${e.provider}/${e.id}`;return e.label===t?t:`${e.label} (${t})`}var zS=250;function BS(e){let{t}=Ln(),[n,r]=(0,w.useState)(``),i=(0,w.useRef)([]),a=e.draftModel??e.currentModel,o=e.snapshot?.models??[],s=(e.snapshot?.truncation.modelsOmitted??0)>0,c=n.trim(),l=e.modelSearch.query===c,u=!!c&&(!l||e.modelSearch.status===`loading`),d=c?l?e.modelSearch.models:[]:o,f=e.actions.searchModels,p=e.snapshot?.generatedAt;(0,w.useEffect)(()=>{if(!c||!p)return;let e=window.setTimeout(()=>{f(c)},zS);return()=>window.clearTimeout(e)},[c,f,p]);let m=()=>{r(``),e.actions.clearModelSearch()},h=(t,n)=>{e.actions.selectModel(`${t.provider}/${t.id}`),n()},g=a?RS(a):t(`noModels`),_=a?g:t(`selectModel`),v=e.sessionSwitching||e.modelSelectionPending||e.promptAdmissionPending||!e.workspaceDraft&&!!e.snapshot?.selectedSession&&e.snapshot?.selectedSession?.id!==e.snapshot?.currentSessionId||e.liveRunning||!o.length&&!s;return(0,K.jsx)(LS,{className:`model-selector model-picker`,label:_,isLabelHidden:!0,value:a?`${a.provider}/${a.id}`:``,triggerLabel:(0,K.jsx)(`span`,{className:`model-picker-label`,children:g}),placeholder:t(`noModels`),variant:`ghost`,size:`sm`,placement:`above`,alignment:`end`,isDisabled:v,isLoading:e.modelSelectionPending,onOpenChange:e=>{e||m()},children:(f,p,m)=>(0,K.jsxs)(`div`,{className:`model-search-panel ${s?`searchable`:``}`,children:[s&&(0,K.jsx)(`p`,{className:`model-search-truncation`,role:`status`,children:t(`modelsTruncated`,{shown:o.length,omitted:e.snapshot?.truncation.modelsOmitted??0})}),s&&(0,K.jsxs)(`label`,{className:`model-search-input`,children:[(0,K.jsx)($e,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:t(`searchModels`)}),(0,K.jsx)(`input`,{value:n,placeholder:t(`searchModelsPlaceholder`),onChange:t=>{let n=t.currentTarget.value;r(n),n.trim()||e.actions.clearModelSearch()},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),m())}})]}),u&&(0,K.jsx)(`p`,{className:`model-search-status`,role:`status`,children:t(`searchingModels`)}),c&&l&&e.modelSearch.status===`error`&&(0,K.jsx)(`p`,{className:`model-search-status model-search-error`,role:`alert`,children:e.modelSearch.error??t(`modelSearchFailed`)}),c&&l&&e.modelSearch.status===`ready`&&e.modelSearch.totalMatches===0&&(0,K.jsx)(`p`,{className:`model-search-status`,role:`status`,children:t(`noMatchingModels`)}),c&&l&&e.modelSearch.status===`ready`&&e.modelSearch.matchesOmitted>0&&(0,K.jsx)(`p`,{className:`model-search-status`,role:`status`,children:t(`modelSearchTruncated`,{omitted:e.modelSearch.matchesOmitted})}),(0,K.jsx)(`div`,{className:`model-search-options`,role:`listbox`,"aria-label":t(`selectModel`),"aria-busy":u,children:d.map((e,t)=>{let n=a?.provider===e.provider&&a.id===e.id;return(0,K.jsxs)(`button`,{className:`model-search-option`,type:`button`,role:`option`,"aria-selected":n,ref:e=>{i.current[t]=e},onClick:()=>h(e,m),onKeyDownCapture:e=>{let n=e.key===`ArrowDown`?Math.min(t+1,d.length-1):e.key===`ArrowUp`?Math.max(t-1,0):e.key===`Home`?0:e.key===`End`?d.length-1:null;n!==null&&n!==t&&(e.preventDefault(),e.stopPropagation(),i.current[n]?.focus())},children:[(0,K.jsx)(`span`,{className:`model-menu-item-label`,children:RS(e)}),n&&(0,K.jsx)(B,{"aria-hidden":`true`})]},`${e.provider}/${e.id}`)})})]})})}var VS=`openpi-slash-command-list`;function HS(e){return`openpi-slash-command-${e}`}function US(e,t){let n=t.trim().toLocaleLowerCase(),r=n?e.filter(e=>e.name.toLocaleLowerCase().includes(n)):[],i=n?r.length>0?r:e.filter(e=>[e.description,e.source].some(e=>e?.toLocaleLowerCase().includes(n))):[...e];return n?[...i.filter(e=>e.availability===`available`),...i.filter(e=>e.availability===`unsupported`)]:i.filter(e=>e.availability===`available`)}function WS({source:e}){return e===`extension`?(0,K.jsx)(Xe,{}):e===`prompt`?(0,K.jsx)(Ce,{}):(0,K.jsx)(rt,{})}function GS(e){let{t}=Ln(),n=(0,w.useRef)(null);(0,w.useLayoutEffect)(()=>{let t=n.current,r=t?.parentElement;if(!t||!r||!e.preferBelow)return;let i=()=>{let e=window.visualViewport,n=e?.offsetTop??0,i=e?.height??window.innerHeight,a=n+i,o=r.getBoundingClientRect(),s=Math.max(0,a-o.bottom-8-12),c=Math.max(0,o.top-n-8-12),l=s>=Math.min(t.scrollHeight,224,i*.32)||s>=c?`below`:`above`,u=l===`below`?s:c;t.dataset.placement=l,t.style.setProperty(`--slash-command-available-height`,`${Math.floor(u)}px`)};i();let a=new ResizeObserver(i);return a.observe(t),a.observe(r),window.addEventListener(`resize`,i),window.visualViewport?.addEventListener(`resize`,i),window.visualViewport?.addEventListener(`scroll`,i),()=>{a.disconnect(),window.removeEventListener(`resize`,i),window.visualViewport?.removeEventListener(`resize`,i),window.visualViewport?.removeEventListener(`scroll`,i)}},[e.preferBelow]);let r=e.commands[e.activeIndex];if((0,w.useEffect)(()=>{r&&(n.current?.querySelector(`[data-command-index="${e.activeIndex}"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[r,e.activeIndex]),e.draft)return(0,K.jsx)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`status`,children:t(`commandSessionRequired`)});if(e.commandDiscovery.status===`idle`||e.commandDiscovery.status===`loading`)return(0,K.jsx)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`status`,children:t(`commandsLoading`)});if(e.commandDiscovery.status===`error`)return(0,K.jsxs)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:t(`commandsUnavailable`)}),(0,K.jsx)(`span`,{children:e.commandDiscovery.error})]});if(e.commandDiscovery.status===`ready`&&e.commands.length===0){let r=e.showUnavailableSummary&&e.commandDiscovery.commands.length>0&&e.commandDiscovery.commands.every(e=>e.availability===`unsupported`);return(0,K.jsx)(`div`,{ref:n,className:`slash-command-menu slash-command-state`,role:`status`,children:t(r?`commandsNoAvailable`:`commandsNoMatch`)})}return(0,K.jsxs)(`div`,{ref:n,className:`slash-command-menu`,children:[(0,K.jsx)(`div`,{id:VS,role:`listbox`,"aria-label":t(`commands`),children:e.commands.map((n,r)=>{let i=n.availability===`unsupported`;return(0,K.jsxs)(`button`,{id:HS(r),"data-command-index":r,className:`slash-command-option`,type:`button`,role:`option`,"aria-selected":r===e.activeIndex,"aria-disabled":i,disabled:i,onMouseEnter:()=>e.onSelect(r),onMouseDown:e=>e.preventDefault(),onClick:()=>e.onComplete(n),children:[(0,K.jsx)(`span`,{className:`slash-command-icon`,children:(0,K.jsx)(WS,{source:n.source})}),(0,K.jsxs)(`span`,{className:`slash-command-copy`,children:[(0,K.jsxs)(`span`,{className:`slash-command-heading`,children:[(0,K.jsxs)(`strong`,{children:[`/`,n.name]}),(0,K.jsx)(`span`,{children:t(`commandSource_${n.source}`)})]}),n.description&&(0,K.jsx)(`span`,{children:n.description}),n.support&&(0,K.jsx)(`span`,{children:t(`commandSupport_${n.support}`)})]}),(0,K.jsx)(`span`,{className:`slash-command-support`,children:i?t(`commandUnsupported`):n.argumentHint?t(`commandAcceptsArguments`):null})]},`${n.source}:${n.name}`)})}),e.commandDiscovery.commandsOmitted>0&&(0,K.jsx)(`div`,{className:`slash-command-bounded`,role:`status`,children:t(`commandsBounded`,{count:e.commandDiscovery.commandsOmitted})})]})}function KS(e){let{t}=Ln(),[n,r]=(0,w.useState)(``),i=e.modelSearch??{query:``,status:`idle`,models:[],totalMatches:0,matchesOmitted:0,error:null},[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(!1),[d,f]=(0,w.useState)(0),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)([]),[_,v]=(0,w.useState)(!1),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(!1),C=(0,w.useRef)(null),T=(0,w.useRef)(null),E=(0,w.useRef)(!1),D=(0,w.useRef)(!1);(0,w.useLayoutEffect)(()=>{let e=C.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`,e.style.overflowY=e.scrollHeight>220?`auto`:`hidden`)},[n]),(0,w.useEffect)(()=>{if(p||!D.current)return;D.current=!1;let e=window.setTimeout(()=>{C.current?.focus(),C.current?.setSelectionRange(a,a)},0);return()=>window.clearTimeout(e)},[a,p]);let O=(0,w.useRef)(null),k=(0,w.useRef)(!1),A=e.snapshot?.selectedSession,j=e.selectedPath===void 0?A?.path??null:e.selectedPath,M=A?.cwd===e.selectedWorkspace?j:null,N=(e.workspaceDraft?null:M)??(e.selectedWorkspace?`new:${e.selectedWorkspace}`:`none`),P=(0,w.useRef)(N),F=(0,w.useRef)(0),I=(0,w.useRef)(!1),R=(0,w.useRef)(null),z=!!(!e.workspaceDraft&&A?.id&&A.id===e.snapshot?.currentSessionId&&j===A.path),V=!!(e.selectedWorkspace&&(e.workspaceDraft||!A&&!e.snapshot?.currentSessionId)),H=z||V,ee=!e.workspaceDraft&&(e.snapshot?.runtime.status===`running`||e.liveRunning),te=z&&ee&&!!(e.activeTurn??e.snapshot?.runtime.activeTurn),ne=e.sessionSwitching||!H&&!!e.selectedWorkspace,W=e.commandDiscovery??{sessionId:null,status:`idle`,commands:[],totalAvailable:0,commandsOmitted:0,error:null},re=/^\/[^\s/]*$/u.test(n)&&a>0,ie=s&&re&&!l&&H&&!e.sessionSwitching,ae=z?A?.id:null,oe=re?n.slice(1):``,se=(0,w.useMemo)(()=>US(W.commands,oe),[oe,W.commands]),ce=ie&&!e.workspaceDraft&&W.status===`ready`&&se.length>0,le=z&&!n.trim()&&!e.sessionSwitching,ue=H&&!!e.selectedWorkspace&&!e.sessionSwitching,fe=async e=>{if(E.current||!ue)return;let n=[...e];if(n.length!==0){if(h.length+n.length>4){b(t(`imageAttachmentCount`,{count:4}));return}E.current=!0,v(!0),b(null);try{let e=[],t=h.reduce((e,t)=>e+t.size,0);for(let r of n){let n=await FS(r);if(t+=n.size,t>8388608)throw Error(`image-total-size`);e.push(n)}F.current+=1,g(t=>[...t,...e])}catch(e){let n=e instanceof Error?e.message:`image-type`;b(t(n===`image-size`?`imageAttachmentTooLarge`:n===`image-total-size`?`imageAttachmentTotalTooLarge`:`imageAttachmentUnsupported`))}finally{E.current=!1,v(!1),T.current&&(T.current.value=``)}}};(0,w.useEffect)(()=>{let t=ie&&!k.current;k.current=ie,!(!ie||e.workspaceDraft||!ae||W.status!==`idle`&&!(t&&W.status===`error`))&&e.actions.discoverCommands()},[W.status,ie,e.actions,e.workspaceDraft,ae]),(0,w.useEffect)(()=>{let e=se.findIndex(e=>e.availability===`available`);f(e>=0?e:0)},[se]),(0,w.useEffect)(()=>{let t=e.promptAdmissionRecovery,n=t?.commandId??null;O.current!==n&&(O.current=n,t&&r(e=>e||t.content))},[e.promptAdmissionRecovery]),(0,w.useEffect)(()=>{let t=e.promptAdmissionResolution;t&&(n.trim()===t.content&&(r(``),g([])),e.actions.acknowledgePromptAdmissionResolution(t.commandId))},[n,e.actions,e.promptAdmissionResolution]),(0,w.useEffect)(()=>{let t=P.current;if(t===N)return;P.current=N;let n=R.current;if(!e.workspaceDraft&&(I.current||n?.canTransferToCreatedSession&&n.scope===t)&&M&&e.snapshot?.selectedSession?.path===M&&e.snapshot?.selectedSession?.cwd===e.selectedWorkspace){n?.canTransferToCreatedSession&&(n.scope=N),I.current=!1;return}if(e.workspaceDraft&&e.selectedWorkspace&&N===`new:${e.selectedWorkspace}`&&e.snapshot?.selectedSession?.cwd===e.selectedWorkspace){I.current=!0;return}F.current+=1,r(``),g([]),b(null),S(!1),m(!1),n?.scope===t&&(n.canTransferToCreatedSession=!1)},[N,e.snapshot?.selectedSession?.path,e.snapshot?.selectedSession?.cwd,e.selectedWorkspace,e.workspaceDraft,M]);let pe=async t=>{if(R.current||e.planSelectionPending)return;if(!e.selectedWorkspace){await e.actions.chooseWorkspace();return}let i={revision:F.current,scope:P.current,canTransferToCreatedSession:V};R.current=i;try{(h.length>0?await t(n,h):await t(n))&&R.current===i&&P.current===i.scope&&F.current===i.revision&&(F.current+=1,r(``),g([]),b(null))}finally{R.current===i&&(R.current=null)}},me=async t=>{t?.preventDefault(),!(!H||e.sessionSwitching||e.modelSelectionPending||e.thinkingPendingLevel!==null||e.promptAdmissionPending||e.promptAdmissionRecovery||e.promptAdmissionResolution||!n.trim()&&h.length===0)&&await pe(e.actions.sendPrompt)},he=()=>pe(e.actions.sendPromptAsNew),ge=e=>{if(e.availability!==`available`)return;let t=`/${e.name} `;F.current+=1,r(t),o(t.length),u(!0),queueMicrotask(()=>{C.current?.focus(),C.current?.setSelectionRange(t.length,t.length)})},_e=e=>{if(!se.length)return;let t=d;for(let n=0;n{let t=Math.min(a,n.length),i=n.slice(0,t),s=n.slice(t),c=`\`${e.replaceAll("`","\\`")}\``,l=i&&!/\s$/u.test(i)?` `:``,u=`${i}${l}${c}${s&&!/^\s/u.test(s)?` `:``}${s}`,d=i.length+l.length+c.length;F.current+=1,r(u),o(d),D.current=!0},ye=[...(e.snapshot?.workspaces??[]).map(t=>({id:t.path,label:t.name,icon:(0,K.jsx)(De,{}),endContent:t.path===e.selectedWorkspace?(0,K.jsx)(B,{}):void 0,onClick:()=>e.actions.setWorkspace(t.path)})),{type:`divider`},{id:`add`,label:t(`addWorkspaceMenu`),icon:(0,K.jsx)(Ye,{}),onClick:()=>void e.actions.chooseWorkspace()}],be=e.draftModel??e.snapshot?.models.find(e=>e.current)??e.snapshot?.models[0],xe=e.snapshot?.workspaces.find(t=>t.path===e.selectedWorkspace)?.name??(e.selectedWorkspace?Wb(e.selectedWorkspace):t(`selectWorkspace`)),Se=e.snapshot?.sessions.find(e=>e.path===M),we=z?Ub(Se??{},A?.id??t(`untitledSession`)):V?t(`newSession`):A?Ub(Se??{},A.id):t(`newSession`),Te=Kb(we,48),Ee=e.selectedWorkspace?z&&e.snapshot?.runtime.planHasPrompt&&[`planning`,`ready`].includes(e.snapshot.runtime.plan??``)?t(`promptPlanMessage`):e.landing?t(`promptTask`):t(z?`promptMessage`:`promptReadonly`):t(`promptStart`),Oe=e.snapshot?.thinking,ke=Oe?.level??null,Ae=e.thinkingPendingLevel??null,je=Ae??ke,Ne=Oe?.supported??!1,Pe=Oe?!Oe.available.includes(ke??``):!1,Ie=(Oe?.available??[]).map(t=>({id:t,label:t,endContent:t===je?(0,K.jsx)(B,{}):void 0,onClick:()=>void e.actions.selectThinking(t)})),Le=Oe?Ne?e.workspaceDraft?`thinkingDraftHint`:z?ee?`thinkingLockedRunning`:e.modelSelectionPending?`thinkingModelPendingHint`:null:`thinkingInactiveHint`:`thinkingUnsupportedHint`:null,Re=Ne?`${t(`thinkingLevel`)}: ${je??t(`unknownState`)}${Ae===null?``:`. ${t(`thinkingPendingHint`)}`}`:t(`thinkingUnsupported`),ze=Oe?[...Pe?[{id:`thinking-level-mismatch`,label:t(`thinkingLevelMismatch`),isDisabled:!0},{type:`divider`}]:[],{type:`section`,id:`thinking-level`,title:t(`thinkingLevel`),items:Ie}]:[],Be=e.promptAdmissionPending&&!te?t(`promptPending`):e.modelSelectionPending?t(`thinkingModelPendingHint`):e.thinkingPendingLevel===null?e.workspaceDraft?t(`enterHint`):e.turnCancellationPending?t(`stoppingTurn`):e.turnTerminalStatus===`cancelled`?t(`stoppedTurn`):e.pendingFollowUpsReceipt===null?t(H?ee?`queuedHint`:`enterHint`:`activeOnlyHint`):e.pendingFollowUpsReceipt>0?t(`pendingFollowUpsHint`,{count:e.pendingFollowUpsReceipt}):t(`acceptedHint`):t(`thinkingPendingHint`),Ve=e.promptAdmissionPending&&!te||e.modelSelectionPending||e.thinkingPendingLevel!==null||e.turnCancellationPending||e.turnTerminalStatus===`cancelled`||e.pendingFollowUpsReceipt!==null||H&&ee&&!!(n.trim()||h.length);return(0,K.jsxs)(`div`,{className:`composer-dock`,children:[!e.workspaceDraft&&e.snapshot?.selectedSession?.id===e.snapshot?.currentSessionId&&e.snapshot?.runtime.plan&&!e.sessionSwitching&&(0,K.jsxs)(`div`,{className:`plan-mode-bar`,children:[(0,K.jsx)(`span`,{children:t(`planMode_${e.snapshot.runtime.plan}`)}),(0,K.jsx)(`button`,{type:`button`,disabled:ee||e.planSelectionPending||e.promptAdmissionPending||!!e.promptAdmissionRecovery,onClick:()=>void e.actions.selectPlanMode(e.snapshot?.runtime.plan===`inactive`),children:t(e.snapshot.runtime.plan===`inactive`?`planModeEnter`:`planModeExit`)})]}),z&&(0,K.jsx)(tx,{snapshot:e.snapshot,onInspectTerminal:e.onInspect,onInspectSubagent:e.onInspectSubagent}),e.accessory,e.landing&&(0,K.jsx)(`div`,{className:`workspace-picker-row`,children:(0,K.jsx)(Rb,{className:`workspace-picker-menu`,button:{label:e.selectedWorkspace?Wb(e.selectedWorkspace):t(`selectWorkspace`),icon:(0,K.jsx)(De,{}),size:`md`,variant:`ghost`,className:`workspace-picker`},items:ye,menuWidth:240,placement:`above`,alignment:`start`,hasChevron:!0})}),e.promptAdmissionRecovery&&(0,K.jsxs)(`section`,{className:`prompt-recovery`,role:`alert`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:t(`promptAdmissionUnknown`)}),(0,K.jsx)(`span`,{children:e.promptAdmissionRecovery.phase===`checking`?t(`promptAdmissionCheckingDetail`):e.promptAdmissionRecovery.phase===`verification-failed`?t(`promptAdmissionVerificationFailedDetail`):t(`promptAdmissionUnknownDetail`)})]}),(0,K.jsxs)(`div`,{className:`prompt-recovery-actions`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:e.promptAdmissionRecovery.phase===`submitting`,onClick:e.actions.abandonPromptAdmission,children:t(`abandonAdmission`)}),e.promptAdmissionRecovery.phase===`verification-failed`&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>void e.actions.checkPromptAdmissionRecovery(),children:t(`retryAdmissionCheck`)}),(0,K.jsx)(`button`,{type:`button`,className:`primary`,disabled:e.promptAdmissionRecovery.phase!==`ready`||!n.trim()&&h.length===0,onClick:()=>void he(),children:e.promptAdmissionRecovery.phase===`submitting`?t(`sendingAsNew`):t(`sendAsNew`)})]})]}),(0,K.jsxs)(`form`,{className:`composer composer-m02 ${e.selectedWorkspace?``:`dormant`} ${x?`is-dragging`:``}`,onSubmit:e=>void me(e),onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),ue&&S(!0))},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),ue&&(e.dataTransfer.dropEffect=`copy`,S(!0)))},onDragLeave:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||S(!1)},onDrop:e=>{S(!1),e.dataTransfer.files.length!==0&&(e.preventDefault(),ue&&fe(e.dataTransfer.files))},children:[!e.selectedWorkspace&&(0,K.jsx)(`button`,{className:`dormant-overlay`,type:`button`,"aria-label":t(`selectWorkspace`),onClick:()=>void e.actions.chooseWorkspace()}),e.selectedWorkspace&&(0,K.jsxs)(`div`,{className:`composer-target`,title:`${xe} / ${we}`,children:[(0,K.jsx)(De,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:xe}),(0,K.jsx)(U,{"aria-hidden":`true`}),(0,K.jsx)(`strong`,{children:Te})]}),(0,K.jsx)(`input`,{ref:T,className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{e.currentTarget.files&&fe(e.currentTarget.files)}}),h.length>0&&(0,K.jsx)(`section`,{className:`composer-attachments`,"aria-label":t(`imageAttachments`),children:h.map(e=>(0,K.jsxs)(`div`,{className:`composer-attachment`,children:[(0,K.jsx)(`img`,{src:e.previewUrl,alt:``}),(0,K.jsx)(`span`,{title:e.name,children:e.name}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`${t(`removeAttachment`)} ${e.name}`,title:t(`removeAttachment`),onClick:()=>{F.current+=1,g(t=>t.filter(t=>t.id!==e.id)),b(null)},children:(0,K.jsx)(mt,{"aria-hidden":`true`})})]},e.id))}),y&&(0,K.jsx)(`p`,{className:`composer-attachment-error`,role:`alert`,children:y}),x&&(0,K.jsxs)(`div`,{className:`composer-drop-overlay`,"aria-hidden":`true`,children:[(0,K.jsx)(Me,{}),(0,K.jsx)(`span`,{children:t(`dropImagesHere`)})]}),(0,K.jsx)(`textarea`,{ref:C,value:n,rows:1,disabled:ne,readOnly:!e.selectedWorkspace,"aria-label":t(`describeTask`),"aria-autocomplete":`list`,"aria-controls":ce?VS:void 0,"aria-activedescendant":ce&&se[d]?HS(d):void 0,placeholder:Ee,onChange:e=>{F.current+=1,r(e.target.value),o(e.target.selectionStart),u(!1)},onClick:e=>o(e.currentTarget.selectionStart),onSelect:e=>o(e.currentTarget.selectionStart),onFocus:()=>{c(!0),u(!1)},onBlur:()=>c(!1),onPaste:e=>{!ue||e.clipboardData.files.length===0||(e.preventDefault(),fe(e.clipboardData.files))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(ie){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),_e(e.key===`ArrowDown`?1:-1);return}if(e.key===`Escape`){e.preventDefault(),u(!0);return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey){let t=se[d];if(t){e.preventDefault(),ge(t);return}}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),me())}}}),ie&&(0,K.jsx)(GS,{activeIndex:d,commandDiscovery:W,commands:se,draft:!!e.workspaceDraft,preferBelow:e.landing,showUnavailableSummary:!oe,onComplete:ge,onSelect:f}),(0,K.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,K.jsx)(`div`,{className:`composer-toolbar-context`,children:ue?(0,K.jsx)(Rb,{className:`composer-context-menu`,button:{label:t(`addContext`),icon:(0,K.jsx)(Ye,{}),isIconOnly:!0,size:`sm`,variant:`ghost`,className:`composer-context-trigger`},items:[{id:`image-attachment`,label:t(`addImages`),description:t(`imageAttachmentDescription`),icon:(0,K.jsx)(Me,{}),isDisabled:_||h.length>=4,onClick:()=>T.current?.click()},{id:`file-reference`,label:t(`fileReference`),icon:(0,K.jsx)(Ce,{}),onClick:()=>m(!0)},{id:`slash-commands`,label:t(`commands`),description:z?n.trim()?t(`commandsEmptyDraftOnly`):void 0:t(`commandsSessionRequired`),icon:(0,K.jsx)(de,{}),isDisabled:!le,onClick:()=>{F.current+=1,r(`/`),o(1),u(!1),requestAnimationFrame(()=>{C.current?.focus(),C.current?.setSelectionRange(1,1)})}}],menuWidth:200,placement:`above`,alignment:`start`,hasChevron:!1}):(0,K.jsx)(`span`,{className:`composer-context-placeholder`})}),(0,K.jsxs)(`div`,{className:`composer-toolbar-controls`,children:[e.onInspect&&(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":t(`runtimeStatus`),title:t(`runtimeStatus`),disabled:!z||e.sessionSwitching,onClick:()=>e.onInspect?.(),children:(0,K.jsx)(nt,{})}),e.onOpenProviders&&(0,K.jsx)(Hb,{content:t(`providerAvailability`),placement:`above`,children:(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"data-provider-settings-trigger":!0,"aria-label":t(`providerAvailability`),onClick:e.onOpenProviders,children:(0,K.jsx)(Fe,{})})}),(0,K.jsx)(`div`,{className:`model-picker-wrap`,children:(0,K.jsx)(BS,{snapshot:e.snapshot,currentModel:be,draftModel:e.draftModel,modelSearch:i,modelSelectionPending:!!e.modelSelectionPending,promptAdmissionPending:e.promptAdmissionPending,sessionSwitching:e.sessionSwitching,liveRunning:ee,workspaceDraft:!!e.workspaceDraft,actions:e.actions})}),Oe&&(0,K.jsx)(`div`,{className:`thinking-picker-wrap`,"data-level":ke??`none`,"data-pending":Ae!==null,"data-warning":Pe,title:Le?t(Le):void 0,children:(0,K.jsx)(Rb,{className:`thinking-menu`,button:{label:Re,icon:(0,K.jsx)(L,{}),isIconOnly:!0,size:`sm`,variant:`ghost`,className:`thinking-picker`,isDisabled:Le!==null||Ie.length===0},items:ze,menuWidth:220,placement:`above`,alignment:`end`,hasChevron:!1})}),te?(0,K.jsx)(Hb,{content:t(`stopTurn`),placement:`above`,children:(0,K.jsx)(`button`,{className:`send-button`,type:`button`,"aria-label":t(`stopTurn`),disabled:e.turnCancellationPending||e.sessionSwitching,onClick:()=>void e.actions.cancelActiveTurn(),children:(0,K.jsx)(ot,{})})}):(0,K.jsx)(Hb,{content:t(`send`),placement:`above`,children:(0,K.jsx)(`button`,{className:`send-button`,type:`submit`,"aria-label":t(`send`),disabled:e.sessionSwitching||e.modelSelectionPending||e.thinkingPendingLevel!==null||!H||!e.selectedWorkspace||e.promptAdmissionPending||e.planSelectionPending||!!e.promptAdmissionRecovery||!!e.promptAdmissionResolution||!n.trim()&&h.length===0,children:(0,K.jsx)(et,{})})})]})]}),(0,K.jsx)(`div`,{className:`composer-hint`,"data-visible":Ve,"aria-live":`polite`,children:Be})]}),(0,K.jsx)(jS,{open:p,sessionId:z?A?.id:void 0,onClose:()=>m(!1),onInsert:ve})]})}function qS({target:e,onClose:t,onOpenProviders:n}){let{t:r}=Ln(),i=(0,w.useMemo)(()=>new zp,[]),[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),p=e=>{f(null),sp(e).then(e=>f(e?`copied`:`failed`))};(0,w.useEffect)(()=>{let t=new AbortController;return c(null),u(null),f(null),(async()=>{let n={errors:[]};if(e.terminalId)try{let a=await i.terminalDetail(e.sessionId,e.terminalId,t.signal);if(a.sessionId!==e.sessionId||a.detail.id!==e.terminalId)throw Error(r(`inspectionChanged`));n.terminal=a.detail}catch(e){n.errors.push(e instanceof Error?e.message:r(`inspectionUnavailable`))}else{let[a,o]=await Promise.allSettled([i.thinking(e.sessionId,t.signal),i.trust(e.sessionId,t.signal)]);a.status===`fulfilled`&&a.value.sessionId===e.sessionId?n.thinking=a.value:n.errors.push(r(`thinkingUnavailable`)),o.status===`fulfilled`&&(o.value.workspace===void 0||o.value.workspace===e.cwd)?n.trust=o.value:n.errors.push(r(`trustUnavailable`))}t.signal.aborted||(c(n),u(new Date().toLocaleTimeString()))})(),()=>t.abort()},[i,e,a,r]);let m=e.terminalId?r(`terminalDetails`):r(`runtimeStatus`),h=s?.terminal;return(0,K.jsx)(Lx,{isOpen:!0,onOpenChange:e=>!e&&t(),width:640,"aria-label":m,children:(0,K.jsxs)(`section`,{className:`inspection-panel`,children:[(0,K.jsxs)(`header`,{className:`inspection-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:m}),(0,K.jsx)(`p`,{className:`inspection-subtitle`,children:e.cwd})]}),(0,K.jsxs)(`div`,{className:`inspection-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":r(`refreshStatus`),disabled:!s,onClick:()=>o(e=>e+1),children:(0,K.jsx)(Ze,{})}),(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":r(`close`),onClick:t,children:(0,K.jsx)(mt,{})})]})]}),d&&(0,K.jsx)(`p`,{role:`status`,children:r(d===`copied`?`copiedMessage`:`copyFailed`)}),s?(0,K.jsxs)(K.Fragment,{children:[s.errors.map(e=>(0,K.jsx)(`p`,{className:`inspection-warning`,role:`alert`,children:e},e)),h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`inspection-section`,children:[(0,K.jsx)(`h3`,{children:h.title||h.id}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{children:r(`executionState`)}),(0,K.jsx)(`dd`,{children:r(`execution_${h.status}`,{defaultValue:h.status})}),(0,K.jsx)(`dt`,{children:r(`terminalCommand`)}),(0,K.jsxs)(`dd`,{children:[(0,K.jsx)(`code`,{children:h.command}),(0,K.jsx)(`button`,{type:`button`,className:`inspection-copy`,"aria-label":r(`copyTerminalCommand`),title:r(`copyTerminalCommand`),onClick:()=>p(h.command),children:(0,K.jsx)(oe,{"aria-hidden":`true`})})]}),(0,K.jsx)(`dt`,{children:r(`terminalDirectory`)}),(0,K.jsx)(`dd`,{children:h.cwd}),(0,K.jsx)(`dt`,{children:r(`startedAt`)}),(0,K.jsx)(`dd`,{children:new Date(h.createdAt).toLocaleString()}),h.status!==`running`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:r(`exitCode`)}),(0,K.jsx)(`dd`,{children:h.exitCode??r(`unknownState`)})]})]}),h.errorText&&(0,K.jsx)(`p`,{className:`inspection-warning`,children:h.errorText}),h.truncated&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`detailTruncated`)})]}),[`stdout`,`stderr`].map(e=>(0,K.jsxs)(`section`,{className:`inspection-section`,children:[(0,K.jsxs)(`div`,{className:`inspection-stream-heading`,children:[(0,K.jsx)(`h3`,{children:r(e===`stdout`?`standardOutput`:`standardError`)}),(0,K.jsx)(`button`,{type:`button`,className:`inspection-copy`,disabled:!h[e].text,"aria-label":r(`copyVisibleOutput`,{stream:r(e===`stdout`?`standardOutput`:`standardError`)}),title:r(`copyVisibleOutput`,{stream:r(e===`stdout`?`standardOutput`:`standardError`)}),onClick:()=>p(h[e].text),children:(0,K.jsx)(oe,{"aria-hidden":`true`})})]}),(0,K.jsx)(`section`,{className:`terminal-evidence`,tabIndex:0,"aria-label":r(e===`stdout`?`standardOutput`:`standardError`),children:(0,K.jsx)(`pre`,{children:h[e].text||r(`noOutput`)})}),h[e].truncated&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`outputTruncated`,{count:h[e].omittedBytes})}),h[e].recoveryAvailable&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`outputRecovery`)})]},e))]}):!e.terminalId&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{className:`inspection-section`,children:[(0,K.jsx)(`h3`,{children:r(`modelAndThinking`)}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{children:r(`selectedModel`)}),(0,K.jsx)(`dd`,{children:e.model||r(`noModels`)}),(0,K.jsx)(`dt`,{children:r(`thinkingLevel`)}),(0,K.jsx)(`dd`,{children:s.thinking?.supported===!1?r(`thinkingUnsupported`):s.thinking?.level??r(`unknownState`)}),!!s.thinking?.available.length&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:r(`availableThinking`)}),(0,K.jsx)(`dd`,{children:s.thinking?.available.join(` · `)})]})]}),s.thinking?.supported===!1&&(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`thinkingUnsupportedHint`)}),s.thinking&&s.thinking.supported!==!1&&!s.thinking.available.includes(s.thinking.level)&&(0,K.jsx)(`p`,{className:`inspection-warning`,role:`status`,children:r(`thinkingLevelMismatch`)})]}),(0,K.jsxs)(`section`,{className:`inspection-section`,children:[(0,K.jsx)(`h3`,{children:r(`projectTrust`)}),(0,K.jsx)(`p`,{children:r(`trust_${s.trust?.state??`unknown`}`)}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{children:r(`savedTrustDecision`)}),(0,K.jsx)(`dd`,{children:r(`trustDecision_${s.trust?.decision??`unknown`}`)}),(0,K.jsx)(`dt`,{children:r(`activeSessionTrust`)}),(0,K.jsx)(`dd`,{children:s.trust?.sessionTrusted===!0?r(`trustActiveYes`):s.trust?.sessionTrusted===!1?r(`trustActiveNo`):r(`unknownState`)})]}),s.trust?.refreshRequired===!0&&(0,K.jsx)(`p`,{className:`inspection-warning`,children:r(`trustRefreshNeeded`)})]}),n&&(0,K.jsxs)(`button`,{type:`button`,className:`inspection-provider-link`,"aria-label":r(`openProviderSettings`),onClick:n,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:r(`providerAvailability`)}),(0,K.jsx)(`small`,{children:r(`authNotVerified`)})]}),r(`openProviderSettings`)]}),(0,K.jsxs)(`div`,{className:`inspection-setup`,children:[(0,K.jsx)(`p`,{className:`inspection-note`,children:r(`configurationViaPi`)}),(0,K.jsx)(`code`,{children:`/openpi-setup`}),(0,K.jsx)(`button`,{type:`button`,className:`inspection-copy`,"aria-label":r(`copySetupCommand`),title:r(`copySetupCommand`),onClick:()=>p(`/openpi-setup`),children:(0,K.jsx)(oe,{"aria-hidden":`true`})})]})]}),(0,K.jsx)(`p`,{className:`inspection-updated`,children:r(`statusCaptured`,{time:l})})]}):(0,K.jsx)(`p`,{role:`status`,children:r(`inspectionLoading`)})]})})}function JS(e){return e.split(/[\\/]/u).at(-1)||e}function YS({snapshot:e,onOpenReview:t}){let{t:n}=Ln(),r=(0,w.useRef)(null),i=(0,w.useRef)(null),[a,o]=(0,w.useState)(!1),[s,c]=(0,w.useState)(320);if((0,w.useEffect)(()=>{if(!a)return;let e=()=>{let e=i.current?.getBoundingClientRect().top??340;c(Math.max(160,Math.min(420,e-20)))},t=e=>{r.current?.contains(e.target)||o(!1)},n=e=>{e.key!==`Escape`||e.isComposing||(e.preventDefault(),o(!1),i.current?.focus())};return e(),window.addEventListener(`resize`,e),document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.removeEventListener(`resize`,e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[a]),e.files.length===0)return null;let l=`session-changes-${e.revision.slice(0,12)}`;return(0,K.jsxs)(`div`,{className:`session-changes`,ref:r,children:[a&&(0,K.jsxs)(`section`,{className:`session-changes-popover`,id:l,role:`dialog`,"aria-label":n(`changeEvidence`),style:{maxHeight:s},children:[(0,K.jsx)(`ul`,{children:e.files.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`session-changes-file`,title:e.path,onClick:()=>{o(!1),t(e.path,i.current??void 0)},children:[(0,K.jsx)(`span`,{children:JS(e.path)}),(e.additions>0||e.deletions>0)&&(0,K.jsxs)(`span`,{className:`session-changes-counts`,"aria-hidden":`true`,children:[(0,K.jsxs)(`span`,{className:`review-additions`,children:[`+`,e.additions]}),(0,K.jsxs)(`span`,{className:`review-deletions`,children:[`-`,e.deletions]})]})]})},e.path))}),(0,K.jsx)(`footer`,{className:`session-changes-footer`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),t(void 0,i.current??void 0)},children:n(`reviewChanges`)})})]}),(0,K.jsxs)(`button`,{ref:i,className:`session-changes-trigger`,type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a,"aria-controls":a?l:void 0,onClick:()=>{if(!a){let e=i.current?.getBoundingClientRect().top??340;c(Math.max(160,Math.min(420,e-20)))}o(e=>!e)},children:[(0,K.jsx)(`strong`,{children:n(`filesChanged`,{count:e.files.length})}),(0,K.jsxs)(`span`,{className:`session-changes-counts`,"aria-hidden":`true`,children:[(0,K.jsxs)(`span`,{className:`review-additions`,children:[`+`,e.additions]}),(0,K.jsxs)(`span`,{className:`review-deletions`,children:[`-`,e.deletions]})]}),(0,K.jsx)(V,{"aria-hidden":`true`})]})]})}function XS(e,t){let n=(0,w.useMemo)(()=>new zp,[]),r=(0,w.useRef)(0),i=(0,w.useRef)(null),[a,o]=(0,w.useState)(null),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(null),d=(0,w.useCallback)(async()=>{if(!e)return;let t=++r.current;i.current?.abort();let a=new AbortController;i.current=a,c(!0),u(null);try{let i=await n.gitReview(e.id,e.path,a.signal);r.current===t&&o(i)}catch(e){r.current===t&&u(e instanceof Error?e.message:`Git review unavailable`)}finally{r.current===t&&(i.current=null,c(!1))}},[n,e]);return(0,w.useEffect)(()=>{if(!e){i.current?.abort(),i.current=null,r.current++,o(null),c(!1),u(null);return}let t=window.setTimeout(()=>void d(),200);return()=>{window.clearTimeout(t),i.current?.abort()}},[d,t,e]),(0,w.useEffect)(()=>{if(!e)return;let t=()=>void d();return window.addEventListener(`focus`,t),()=>window.removeEventListener(`focus`,t)},[d,e]),{result:a,loading:s,error:l,refresh:d}}function ZS({items:e,label:t}){return(0,K.jsx)(`span`,{className:`astryx-menu-trigger`,children:(0,K.jsx)(Rb,{button:{label:t,icon:(0,K.jsx)(_e,{}),isIconOnly:!0,size:`sm`,variant:`ghost`,className:`menu-action-button`},items:e,menuWidth:190,placement:`below`,alignment:`end`,hasChevron:!1})})}function QS(e){let{t}=Ln(),[n,r]=(0,w.useState)(null),[i,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(``),c=(0,w.useRef)(null),l=(0,w.useRef)(null),u=(0,w.useRef)(null),d=(0,w.useRef)(null),f=(0,w.useRef)(null),p=e.snapshot,[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(new Set),[v,y]=(0,w.useState)(new Set),b=(0,w.useRef)(new Set),[x,S]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),E=async t=>{if(!b.current.has(t)){b.current.add(t),y(new Set(b.current)),S(!1);try{await e.actions.unarchiveSession(t)||S(!0)}finally{b.current.delete(t),y(new Set(b.current))}}};(0,w.useEffect)(()=>{if(e.searchOpen)return c.current?.focus(),()=>l.current?.focus()},[e.searchOpen]),(0,w.useEffect)(()=>{if(e.mobileOpen)return f.current?.focus(),()=>{let t=e.returnFocusRef?.current;t?.checkVisibility()&&t.focus()}},[e.mobileOpen,e.returnFocusRef]),(0,w.useEffect)(()=>{e.mobileOpen&&document.activeElement===document.body&&!document.querySelector(`dialog:modal`)&&f.current?.focus()}),(0,w.useEffect)(()=>{n&&(u.current?.focus(),u.current?.select())},[n]);let D=(0,w.useMemo)(()=>{let n=e.query.trim().toLowerCase(),r=(e,r)=>(p?.sessions??[]).filter(i=>!!i.archived===m&&(e===`__ungrouped__`?i.ungrouped:i.cwd===e&&!i.ungrouped)&&(!n||r||`${Ub(i,t(`untitledSession`))} ${i.cwd}`.toLowerCase().includes(n))),i=[...p?.workspaces??[]];for(let e of p?.sessions??[])!e.ungrouped&&!i.some(t=>t.path===e.cwd)&&i.push({path:e.cwd,name:e.cwd,current:!1});return[...i.map(e=>{let t=!!n&&`${e.name} ${e.path}`.toLowerCase().includes(n);return{...e,sessions:r(e.path,t),ungrouped:!1,matches:t}}),{path:`__ungrouped__`,name:t(`ungrouped`),current:!1,sessions:r(`__ungrouped__`,!1),ungrouped:!0,matches:!1}].filter(e=>e.sessions.length>0||!m&&!e.ungrouped&&(!n||e.matches))},[m,e.query,p,t]),O=p?.selectedSession?.id===p?.currentSessionId&&p?.selectedSession?.path===e.selectedPath?e.selectedPath:null,j=O?p?.sessions.find(e=>e.path===O)?.cwd:e.selectedPath?null:e.selectedWorkspace,M=!!(p?.truncation.sessionsOmitted||p?.truncation.workspacesOmitted),N=e=>{s(e.name),r(e)},P=async()=>{let t=o.trim();if(!(!n||!t||C)){T(!0);try{n.kind===`workspace`?await e.actions.renameWorkspace(n.path,t):await e.actions.renameSession(n.path,t),r(null)}catch{}finally{T(!1)}}};return(0,K.jsxs)(`div`,{ref:d,id:`session-sidebar`,className:`session-sidebar`,role:e.mobileOpen?`dialog`:`complementary`,"aria-modal":e.mobileOpen||void 0,"aria-label":`Session navigation`,tabIndex:e.mobileOpen?-1:void 0,onKeyDown:t=>{if(!e.mobileOpen||t.defaultPrevented||t.target instanceof Element&&(t.target.closest(`dialog`)||t.key!==`Tab`&&t.target.closest(`[role="menu"]`))||(t.key===`Escape`&&!t.nativeEvent.isComposing&&(t.preventDefault(),e.actions.closeMobileSidebar()),t.key!==`Tab`))return;let n=Array.from(d.current?.querySelectorAll(`button, input, select, textarea, a[href], [tabindex]`)??[]).filter(e=>e.tabIndex>=0&&!e.matches(`:disabled`)&&e.checkVisibility({visibilityProperty:!0})),r=t.shiftKey?n.at(-1):n[0],i=t.shiftKey?n[0]:n.at(-1);(document.activeElement===d.current||document.activeElement===i)&&(t.preventDefault(),r?.focus())},children:[(0,K.jsxs)(`div`,{className:`sidebar-brand`,children:[(0,K.jsx)(Gn,{compact:!0}),(0,K.jsx)(Hb,{content:t(`collapseSidebar`),placement:`end`,children:(0,K.jsx)(`button`,{ref:f,className:`collapse-button`,type:`button`,"aria-label":t(`collapseSidebar`),onClick:()=>e.mobileOpen?e.actions.closeMobileSidebar():e.actions.toggleSidebar(!1),children:(0,K.jsx)(We,{})})})]}),(0,K.jsxs)(`button`,{className:`new-session-button`,type:`button`,"aria-label":t(`newSession`),title:t(`newSession`),onClick:()=>e.selectedWorkspace?void e.actions.createSession(e.selectedWorkspace):void e.actions.chooseWorkspace(),children:[(0,K.jsx)(it,{}),(0,K.jsx)(`span`,{children:t(`newSession`)})]}),(0,K.jsxs)(`div`,{className:`workspace-heading ${e.searchOpen?`is-searching`:``}`,children:[(0,K.jsx)(`span`,{className:`workspace-heading-label`,children:t(`workspaces`)}),(0,K.jsxs)(`div`,{className:`session-search`,children:[(0,K.jsx)($e,{}),(0,K.jsx)(`input`,{ref:c,type:`search`,value:e.query,placeholder:t(`searchPlaceholder`),"aria-label":t(`searchConversations`),onChange:t=>e.actions.setQuery(t.target.value)}),(0,K.jsx)(`button`,{type:`button`,"aria-label":t(`closeSearch`),onClick:()=>e.actions.setSearchOpen(!1),children:(0,K.jsx)(mt,{})})]}),(0,K.jsxs)(`div`,{className:`workspace-actions`,children:[(0,K.jsx)(Hb,{content:t(`searchConversations`),children:(0,K.jsx)(`button`,{ref:l,className:`icon-button`,type:`button`,"aria-label":t(`searchConversations`),onClick:()=>e.actions.setSearchOpen(!0),children:(0,K.jsx)($e,{})})}),(0,K.jsx)(Hb,{content:t(`addWorkspace`),children:(0,K.jsx)(`button`,{className:`icon-button`,type:`button`,"aria-label":t(`addWorkspace`),onClick:()=>void e.actions.chooseWorkspace(),children:(0,K.jsx)(Ye,{})})})]})]}),(0,K.jsxs)(`fieldset`,{className:`session-view-switch`,"aria-label":t(`conversationViews`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!m,onClick:()=>h(!1),children:t(`currentConversations`)}),(0,K.jsx)(`button`,{type:`button`,"aria-pressed":m,onClick:()=>h(!0),children:t(`archivedConversations`)})]}),m&&(0,K.jsx)(`p`,{className:`sidebar-scope-note`,children:t(`loadedArchives`)}),M&&(0,K.jsx)(`p`,{className:`sidebar-scope-note`,children:t(`loadedHistoryBounded`,{sessions:p?.truncation.sessionsOmitted,workspaces:p?.truncation.workspacesOmitted})}),x&&(0,K.jsx)(`p`,{className:`sidebar-scope-note`,role:`alert`,children:t(`restoreFailed`)}),(0,K.jsx)(`div`,{className:`workspace-tree`,children:D.length?D.map(n=>{let r=(m?g:e.collapsed).has(n.path)&&!e.query.trim(),i=!m&&!n.ungrouped&&j===n.path;return(0,K.jsxs)(`section`,{className:`workspace-group ${r?`collapsed`:``} ${i?`is-active-workspace`:``}`,children:[(0,K.jsxs)(`div`,{className:`workspace-button`,children:[(0,K.jsxs)(`button`,{className:`workspace-label`,type:`button`,"aria-expanded":!r,"aria-current":i?`location`:void 0,disabled:!!e.query.trim(),title:n.path===`__ungrouped__`?void 0:n.path,onClick:()=>{m?_(e=>{let t=new Set(e);return t.has(n.path)?t.delete(n.path):t.add(n.path),t}):e.actions.toggleWorkspace(n.path)},children:[(0,K.jsx)(`span`,{className:`workspace-toggle`,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`workspace-chevron`,children:`⌄`})}),(0,K.jsxs)(`span`,{className:`workspace-identity`,children:[(0,K.jsx)(`strong`,{children:n.name}),!n.ungrouped&&(0,K.jsx)(`small`,{children:Gb(n.path)})]})]}),!n.ungrouped&&(0,K.jsxs)(`span`,{className:`workspace-row-actions`,children:[(0,K.jsx)(ZS,{label:`Workspace options`,items:[{id:`rename`,label:t(`renameWorkspace`),icon:(0,K.jsx)(it,{}),onClick:()=>N({kind:`workspace`,path:n.path,name:n.name})},{id:`remove`,label:t(`removeWorkspace`),icon:(0,K.jsx)(lt,{}),variant:`destructive`,onClick:()=>a({path:n.path,name:n.name})}]}),(0,K.jsx)(Hb,{content:t(`newSession`),children:(0,K.jsx)(`button`,{className:`workspace-action`,type:`button`,"aria-label":`${t(`newSession`)} ${n.name}`,onClick:t=>{t.stopPropagation(),e.actions.createSession(n.path)},children:(0,K.jsx)(Ye,{})})})]})]}),!r&&(0,K.jsx)(`div`,{className:`workspace-sessions`,children:n.sessions.length?n.sessions.map(n=>(0,K.jsxs)(`div`,{className:`session-row`,children:[(0,K.jsxs)(`button`,{className:`session ${n.path===O?`active`:``}`,type:`button`,"aria-current":n.path===O?`page`:void 0,"aria-label":`${Ub(n,t(`untitledSession`))} · ${n.path}`,onClick:()=>void e.actions.selectSession(n.path),children:[(0,K.jsx)(`span`,{className:`session-title`,children:Ub(n,t(`untitledSession`))}),(0,K.jsx)(`span`,{className:`session-time`,children:qb(n.modified)})]}),(0,K.jsx)(ZS,{label:t(`conversationOptions`),items:[{id:`rename`,label:t(`renameConversation`),icon:(0,K.jsx)(it,{}),onClick:()=>N({kind:`session`,path:n.path,name:Ub(n,t(`untitledSession`))})},{id:m?`restore`:`archive`,label:v.has(n.path)?t(`restoringConversation`):t(m?`restoreConversation`:`archiveConversation`),icon:m?(0,K.jsx)(k,{}):(0,K.jsx)(A,{}),isDisabled:v.has(n.path),onClick:()=>m?void E(n.path):void e.actions.archiveSession(n.path)}]})]},n.path)):(0,K.jsx)(`div`,{className:`empty`,children:t(`noConversations`)})})]},n.path)}):(0,K.jsx)(`div`,{className:`empty`,children:e.query.trim()?t(M?`noMatchingLoaded`:`noMatching`):t(m?`noLoadedArchives`:`noSessions`)})}),(0,K.jsx)(`div`,{className:`sidebar-footer`,children:(0,K.jsxs)(`button`,{className:`sidebar-settings-button`,type:`button`,"aria-label":t(`settings`),title:t(`settings`),"data-provider-settings-trigger":!0,disabled:e.settingsDisabled,onClick:e.onOpenSettings,children:[(0,K.jsx)(tt,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:t(`settings`)})]})}),(0,K.jsx)(Lx,{isOpen:!!n,onOpenChange:e=>!e&&!C&&r(null),purpose:`form`,width:400,"aria-label":n?.kind===`workspace`?t(`renameWorkspace`):t(`renameConversation`),children:(0,K.jsxs)(`form`,{className:`openpi-dialog`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,K.jsx)(`strong`,{children:n?.kind===`workspace`?t(`renameWorkspace`):t(`renameConversation`)}),(0,K.jsx)(`input`,{ref:u,value:o,maxLength:80,"aria-label":n?.kind===`workspace`?t(`workspaceName`):t(`conversationName`),onChange:e=>s(e.target.value)}),(0,K.jsxs)(`div`,{className:`dialog-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(null),children:t(`cancel`)}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:C,children:t(`save`)})]})]})}),(0,K.jsx)(Lx,{isOpen:!!i,onOpenChange:e=>!e&&a(null),purpose:`form`,width:440,"aria-label":t(`deleteWorkspace`),children:(0,K.jsxs)(`div`,{className:`openpi-dialog`,children:[(0,K.jsx)(`strong`,{children:t(`deleteWorkspace`)}),(0,K.jsxs)(`p`,{children:[i?.name,`:`,t(`workspaceDeleteConfirm`)]}),(0,K.jsxs)(`div`,{className:`dialog-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(null),children:t(`cancel`)}),(0,K.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>{i&&(e.actions.removeWorkspace(i.path),a(null))},children:t(`deleteWorkspace`)})]})]})})]})}function $S({sessionId:e,providerId:t,active:n}){let{t:r}=Ln(),i=(0,w.useMemo)(()=>new zp,[]),[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(null),d=(0,w.useRef)(null);(0,w.useEffect)(()=>{if(!n)return;let t=`${e}:${a}`;if(d.current===t)return;let o=new AbortController;return c(null),u(null),i.providerAuth(e,o.signal).then(e=>{o.signal.aborted||(d.current=t,c(e))},e=>{o.signal.aborted||u(e instanceof Error?e.message:r(`providerLoadFailed`))}),()=>o.abort()},[n,i,a,e,r]);let f=s?.providers.find(e=>e.id===t),p=Array.isArray(f?.authMethods)?f.authMethods:[],m=p.length?p.map(e=>r(`providerAuth_${e}`)).join(` · `):r(`providerAuthUnknown`);return(0,K.jsxs)(`section`,{className:`provider-status-section provider-status-detail`,children:[(0,K.jsxs)(`div`,{className:`provider-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:r(`modelConnection`)}),(0,K.jsx)(`strong`,{children:f?.name||t})]}),(0,K.jsxs)(`button`,{type:`button`,className:`provider-refresh`,"aria-label":r(`refreshStatus`),disabled:!s,onClick:()=>o(e=>e+1),children:[(0,K.jsx)(Ze,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`refreshStatus`)})]})]}),!s&&!l?(0,K.jsx)(`p`,{className:`provider-settings-state`,role:`status`,children:r(`providerLoading`)}):l?(0,K.jsxs)(`div`,{className:`provider-settings-state error`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:r(`providerLoadFailed`)}),(0,K.jsx)(`span`,{children:l}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(e=>e+1),children:r(`retryAdmissionCheck`)})]}):f?(0,K.jsxs)(`article`,{className:`provider-connection-card`,"data-configured":f.configured?`true`:`false`,children:[(0,K.jsxs)(`div`,{className:`provider-connection-state`,children:[(0,K.jsx)(`span`,{className:`provider-state-icon ${f.configured?`configured`:`missing`}`,"aria-hidden":`true`,children:f.configured?(0,K.jsx)(W,{}):(0,K.jsx)(re,{})}),(0,K.jsxs)(`div`,{className:`provider-identity`,children:[(0,K.jsx)(`strong`,{children:f.name||f.id}),f.name!==f.id&&(0,K.jsx)(`span`,{children:f.id})]}),(0,K.jsx)(`span`,{className:`provider-state-label ${f.configured?`configured`:`missing`}`,children:r(f.configured?`credentialConfigured`:`credentialMissing`)})]}),(0,K.jsxs)(`dl`,{className:`provider-connection-facts`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`authentication`)}),(0,K.jsx)(`dd`,{children:m})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`accessType`)}),(0,K.jsx)(`dd`,{children:r(f.subscription?`providerAccessSubscription`:`providerAccessStandard`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`configurationOwner`)}),(0,K.jsx)(`dd`,{children:r(`providerReadOnly`)})]})]})]}):(0,K.jsxs)(`div`,{className:`provider-settings-state`,children:[(0,K.jsx)(`strong`,{children:t}),(0,K.jsx)(`span`,{children:r(`providerStatusUnavailable`)})]}),(0,K.jsxs)(`aside`,{className:`provider-read-only`,children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:r(`providerReadOnly`)}),(0,K.jsx)(`p`,{children:r(`providerReadOnlyDetail`)}),(0,K.jsx)(`small`,{children:r(`authNotVerified`)})]})]})]})}var eC=20,tC={track:{kVAEAm:`x10l6tqk`,kWkggS:`xdsb6cv`,kaIpWk:`xjspbzw`,$$css:!0},trackHorizontal:{kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kZKoxP:`xqu0tyb`,k87sOh:`xwa60dl`,k3aq6I:`x1cb1t30`,$$css:!0},trackVertical:{k87sOh:`x13vifvy`,krVfgx:`x1ey2m1c`,kzqmXN:`x51ohtg`,$$css:!0},filledTrack:{kVAEAm:`x10l6tqk`,kWkggS:`x1ewilqj`,kaIpWk:`xjspbzw`,$$css:!0},filledTrackHorizontal:{kZKoxP:`xqu0tyb`,k87sOh:`xwa60dl`,k3aq6I:`x1cb1t30`,$$css:!0},filledTrackVertical:{kzqmXN:`x51ohtg`,$$css:!0},thumb:{kVAEAm:`x10l6tqk`,kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,kaIpWk:`xjspbzw`,kWkggS:`x1ewilqj`,k3aq6I:`x11lhmoz`,k1ekBW:`x106061f`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,kI3sdo:`x1a2a7pz`,kkrTdU:`x1jm3nie x16khyan`,kY2c9j:`x1vjfegm`,$$css:!0},thumbHorizontal:{k87sOh:`xwa60dl`,k3aq6I:`x11lhmoz xoffwj3`,$$css:!0},thumbHover:{kWkggS:`x1ewilqj xvxo0qp`,$$css:!0},thumbDisabled:{kWkggS:`xwmxj5m`,kkrTdU:`xt0e3qv`,$$css:!0}};function nC(e,t,n){return Math.min(Math.max(e,t),n)}function rC(e){if(Math.abs(e)<1){let t=e.toExponential().split(`e-`);if(t.length===2)return(t[0].split(`.`)[1]?.length??0)+parseInt(t[1],10)}let t=String(e).split(`.`)[1];return t?t.length:0}function iC(e,t,n){if(n<=0)return e;let r=t+Math.round((e-t)/n)*n,i=Math.min(Math.max(rC(t),rC(n)),20);return Number(r.toFixed(i))}function aC(e,t,n){return n===t?0:(e-t)/(n-t)*100}var oC=eC/2;function sC(e){return uC(e,oC-e/100*eC)}function cC(e,t){let n=t-e;return uC(n,-(n/100)*eC)}function lC(e,t){let n=t-eC;return n>0?(e-oC)/n:t>0?e/t:0}function uC(e,t){let n=e=>Number(e.toFixed(3));return`calc(${n(e)}% ${t<0?`-`:`+`} ${Math.abs(n(t))}px)`}function dC({ref:e,...t}){let{label:n,isLabelHidden:r=!1,description:i,isDisabled:a=!1,disabledMessage:o,isOptional:s=!1,isRequired:c=!1,status:l,labelTooltip:u,min:d=0,max:f=100,step:p=1,orientation:m=`horizontal`,formatValue:h,htmlName:g,valueDisplay:_=`tooltip`,marks:v,width:y,xstyle:b,className:x,style:S,"data-testid":C,value:T,onChange:E,onChangeEnd:D}=t,O=Array.isArray(T),k=O&&`minStepsBetweenThumbs`in t?t.minStepsBetweenThumbs??0:0,A=m===`horizontal`,j=(0,w.useId)(),M=(0,w.useId)(),N=(0,w.useId)(),P=(0,w.useId)(),F=(0,w.useId)(),I=(0,w.useRef)(null),L=(0,w.useRef)(null),[R,z]=(0,w.useState)(null),[B,V]=(0,w.useState)(null);(0,w.useEffect)(()=>{fh()},[]);let H=(0,w.useCallback)((e,t)=>{V(!a&&ph()===`keyboard`?e:null)},[a]),U=(0,w.useCallback)(e=>{V(null)},[]),ee=a&&!!o,te=Ph({placement:`above`,focusTrigger:`always`,isEnabled:ee}),ne=c&&!s,W=[];i&&W.push(N),l?.message&&W.push(P),ne&&W.push(F),ee&&W.push(te.describedBy);let re=W.length>0?W.join(` `):void 0,ie=(0,w.useMemo)(()=>(Array.isArray(T)?T:[T??d]).map(e=>nC(e,d,f)),[T,d,f]),ae=(0,w.useRef)(ie);ae.current=ie;let oe=(0,w.useCallback)((e,t)=>{let n=I.current;if(!n)return d;let r=n.getBoundingClientRect(),i;return i=A?lC(mb(n)?r.right-e:e-r.left,r.width):1-lC(t-r.top,r.height),i=nC(i,0,1),nC(iC(d+i*(f-d),d,p),d,f)},[d,f,p,A]),se=(0,w.useCallback)(e=>{if(!O)return 0;let[t,n]=ie;return Math.abs(e-t)<=Math.abs(e-n)?0:1},[O,ie]),ce=(0,w.useCallback)((e,t)=>{if(a)return;let n=nC(iC(t,d,p),d,f);if(O){let t=[...ie];t[e]=n;let r=k*p;e===0?t[0]=Math.min(t[0],t[1]-r):t[1]=Math.max(t[1],t[0]+r),t[0]=nC(t[0],d,f),t[1]=nC(t[1],d,f),E?.(t)}else E?.(n)},[a,O,ie,d,f,p,k,E]),le=(0,w.useRef)(D);le.current=D;let ue=(0,w.useCallback)(e=>{let t=e??ae.current,n=le.current;O?n?.(t):n?.(t[0])},[O]),de=(0,w.useCallback)(e=>{if(a)return;e.preventDefault();let t=e.target.closest(`[data-mark-value]`),n=t?Number(t.dataset.markValue):oe(e.clientX,e.clientY),r=se(n);L.current=r,z(r),ce(r,n);let i=I.current;i&&i.querySelectorAll(`[role="slider"]`)[r]?.focus(),V(null),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId)},[a,oe,se,ce]),fe=(0,w.useCallback)(e=>{if(L.current===null||a)return;let t=oe(e.clientX,e.clientY);ce(L.current,t)},[a,oe,ce]),pe=(0,w.useCallback)(e=>{L.current!==null&&(L.current=null,z(null),ue())},[ue]),me=(0,w.useCallback)((e,t)=>{if(a)return;ph()===`keyboard`&&V(e);let n=ie[e],r;switch(t.key){case`ArrowRight`:case`ArrowUp`:r=n+p;break;case`ArrowLeft`:case`ArrowDown`:r=n-p;break;case`PageUp`:r=n+p*10;break;case`PageDown`:r=n-p*10;break;case`Home`:r=d;break;case`End`:r=f;break;default:return}t.preventDefault();let i=nC(iC(r,d,p),d,f);if(ce(e,r),O){let t=[...ie];t[e]=i;let n=k*p;e===0?t[0]=Math.min(t[0],t[1]-n):t[1]=Math.max(t[1],t[0]+n),t[0]=nC(t[0],d,f),t[1]=nC(t[1],d,f),ue(t)}else ue([i])},[a,O,ie,p,d,f,k,ce,ue]),he=e=>h?h(e):String(e),ge=e=>{let t=ie[e],n=aC(t,d,f),r=A?{insetInlineStart:sC(n)}:{bottom:sC(n),left:`50%`},i=O?e===0?`Minimum value`:`Maximum value`:void 0,o=k*p,s=O&&e===1?nC(ie[0]+o,d,f):d,c=O&&e===0?nC(ie[1]-o,d,f):f,u=_===`tooltip`&&!ee,g=A?`above`:`start`,v=(0,K.jsx)(`div`,{id:O?void 0:j,role:`slider`,tabIndex:a&&!ee?-1:0,"aria-valuemin":s,"aria-valuemax":c,"aria-valuenow":t,"aria-valuetext":h?h(t):void 0,"aria-orientation":m,"aria-disabled":a||void 0,"aria-invalid":l?.type===`error`||void 0,"aria-label":i,"aria-labelledby":O?void 0:M,"aria-describedby":re,onKeyDown:t=>me(e,t),onFocus:t=>H(e,t),onBlur:U,...rg(X(`slider-thumb`,{orientation:m,disabled:a?`disabled`:null}),Y(tC.thumb,A?tC.thumbHorizontal:ug.centerInline(`50%`),!a&&tC.thumbHover,!a&&B===e&&mg.focusVisible,a&&tC.thumbDisabled),void 0,r)},e);return u?(0,K.jsx)(Hb,{content:he(t),placement:g,delay:0,focusTrigger:`always`,isOpen:R===e||void 0,children:v},e):v},_e=(()=>{if(O){let[e,t]=ie,n=aC(e,d,f),r=aC(t,d,f);return A?{insetInlineStart:sC(n),width:cC(n,r)}:{bottom:sC(n),height:cC(n,r)}}let e=aC(ie[0],d,f);return A?{insetInlineStart:`0%`,width:sC(e)}:{bottom:`0%`,height:sC(e)}})(),ve=_===`text`?(0,K.jsx)(`span`,{className:`x9ynric xcr08ib x1tgivj0 xuxw1ft x2lah0s`,children:O?`${he(ie[0])} – ${he(ie[1])}`:he(ie[0])}):null;return(0,K.jsxs)(gS,{"data-testid":C,label:n,isLabelHidden:r,description:i,inputID:j,labelID:M,isGroupLabel:!0,descriptionID:i?N:void 0,isOptional:s,isRequired:c,isDisabled:a,status:l?{type:l.type,message:l.message,messageID:l.message?P:void 0}:void 0,labelTooltip:u,statusVariant:`detached`,width:y,xstyle:b,className:x,style:S,children:[(0,K.jsxs)(`div`,{...rg(X(`slider`,{orientation:m,disabled:a?`disabled`:null}),{className:`x78zum5 x6s0dn4 x1txdalj`}),children:[g!=null&&ie.map((e,t)=>(0,K.jsx)(`input`,{type:`hidden`,name:g,value:String(e),disabled:a},t===0?`start`:`end`)),(0,K.jsxs)(`div`,{ref:_g(e,I,te.ref),...O?{role:`group`,"aria-labelledby":M}:void 0,onPointerDown:de,onPointerMove:fe,onPointerUp:pe,onPointerCancel:pe,...{0:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 xw4jnvo x1ymw6g xkagaj0 xdt5ytf xl56j7k x1ypdohk x16khyan`},2:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 x1qx5ct2 x80b3aj xh8yej3 x1ypdohk x16khyan`},1:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 xw4jnvo x1ymw6g xkagaj0 xdt5ytf xl56j7k xbyyjgo xt0e3qv`},3:{className:`x1n2onr6 x78zum5 x6s0dn4 x1iyjqo2 x5ve5x3 x87ps6o xc8icb0 x1qx5ct2 x80b3aj xh8yej3 xbyyjgo xt0e3qv`}}[!!A<<1|!!a<<0],children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,...rg(X(`slider-track`,{orientation:m}),Y(tC.track,A?tC.trackHorizontal:[tC.trackVertical,ug.centerInline(`0px`)]))}),(0,K.jsx)(`div`,{"aria-hidden":`true`,...rg(Y(tC.filledTrack,A?tC.filledTrackHorizontal:[tC.filledTrackVertical,ug.centerInline(`0px`)]),{style:_e})}),v&&(0,K.jsx)(`div`,{"aria-hidden":`true`,...{0:{className:`x10l6tqk x13vifvy x1ey2m1c xbudbmw`},1:{className:`x10l6tqk x1o0tod xtijo5x xwa60dl`}}[!!A<<0],children:v.map(e=>{let t=aC(e.value,d,f),n=A?{insetInlineStart:sC(t)}:{bottom:sC(t)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{"data-testid":`slider-mark`,"data-mark-value":e.value,...rg({0:{className:`x10l6tqk x7njt3n xjspbzw x36qwtl x1xc55vz x1m9mm8y`},1:{className:`x10l6tqk x7njt3n xjspbzw xfo62xy xdk7pt x11lhmoz xoffwj3`}}[!!A<<0],{style:n})}),e.label&&(0,K.jsx)(`span`,{"data-testid":`slider-mark-label`,"data-mark-value":e.value,...rg({0:{className:`x10l6tqk x9ynric x141an7d xv1l7n4 xuxw1ft x131p8rn x9p6ekw`},1:{className:`x10l6tqk x9ynric x141an7d xv1l7n4 xuxw1ft xuuh30 x1nyx83j xuivejd`}}[!!A<<0],{style:n}),children:e.label})]},e.value)})}),ie.map((e,t)=>ge(t))]}),ve]}),ne&&(0,K.jsx)(Vg,{id:F,children:`Required`}),ee&&te.renderTooltip(o)]})}dC.displayName=`Slider`;var fC={x1iwu4tg:`x1iwu4tg`,$$css:!0},pC={sm:{kzqmXN:`x1td3qas`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`x100vrsf`,kZKoxP:`xxk0z11`,$$css:!0}},mC={sm:{kzqmXN:`x1td3qas`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`x100vrsf`,kZKoxP:`xxk0z11`,$$css:!0}},hC={sm:{kzqmXN:`x1td3qas`,kZKoxP:`x1qx5ct2`,kmVPX3:`x1i3ajwb`,$$css:!0},md:{kzqmXN:`x100vrsf`,kZKoxP:`xxk0z11`,kmVPX3:`xfawy5m`,$$css:!0}},gC={sm:{kzqmXN:`x6jxa94`,kZKoxP:`x1v9usgg`,k3aq6I:`xbryuvx`,$$css:!0},md:{kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,k3aq6I:`xbryuvx`,$$css:!0}},_C={sm:{kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,k3aq6I:`xv5t66b xi9aj42`,$$css:!0},md:{kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,k3aq6I:`x15481yp x12xz5k6`,$$css:!0}},vC={sm:{kAzted:`xisnujt`,$$css:!0},md:{kAzted:`xjwf9q1`,$$css:!0}},yC={container:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,$$css:!0},containerLabelHidden:{kOIVth:`xxhr3t`,$$css:!0},containerSpread:{kjj79g:`x1qughib`,kzqmXN:`xh8yej3`,$$css:!0},statusGap:{keoZOQ:`xtbrsbv`,$$css:!0},switchWrapper:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kmuXW:`x2lah0s`,kHBbk8:`xc8icb0`,$$css:!0},input:{kVAEAm:`x10l6tqk`,kogj98:`x1ghz6dp`,kmVPX3:`x1717udv`,kSiTet:`xg01cxk`,kkrTdU:`x1ypdohk x16khyan`,kY2c9j:`x1vjfegm`,k7Eaqz:`xkagaj0`,kAzted:`x80b3aj`,k87sOh:`xijlfn0`,kLqNvP:`x1hsn8va`,k3aq6I:`x8i4i9p`,$$css:!0},inputDisabled:{kkrTdU:`xt0e3qv`,$$css:!0},inputBusy:{kfzvcC:`x47corl`,$$css:!0},track:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kaIpWk:`xjspbzw`,k1ekBW:`x15406qy`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,kB7OPa:`x9f619`,kMzoRj:`xc342km x13rsnn2`,ksu8eU:`xng3xce xx61lck`,kVAM5u:`x1w1tqly`,$$css:!0},trackFocus:{kI3sdo:`x1a2a7pz xafswnp`,kInvED:`xwz5zln`,$$css:!0},trackOff:{kWkggS:`xspzpui x1a8ae7b x9yvj25`,$$css:!0},trackOn:{kWkggS:`x1ewilqj xcgwt1n x1jzqe4`,$$css:!0},trackDisabled:{kSiTet:`xbyyjgo`,kVAM5u:`xmnqt3w`,$$css:!0},trackDisabledOff:{kWkggS:`xspzpui`,$$css:!0},thumb:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kaIpWk:`xjspbzw`,k1ekBW:`xh3q6i0`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},thumbOff:{kWkggS:`x10xzikg xwvh9j7`,$$css:!0},thumbOn:{kWkggS:`x10xzikg x1sir5s4`,$$css:!0},labelWrapper:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kjj79g:`xl56j7k`,$$css:!0}},bC={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function xC({label:e,isLabelHidden:t=!1,description:n,onChange:r,changeAction:i,isLoading:a=!1,value:o,isDisabled:s=!1,htmlName:c,disabledMessage:l,isOptional:u=!1,isRequired:d=!1,onFocus:f,onBlur:p,labelIcon:m,labelTooltip:h,labelPosition:g=`end`,labelSpacing:_=`hug`,status:v,size:y=`md`,width:b,xstyle:x,className:S,style:C,ref:T,...E}){let D=(0,w.useId)(),O=(0,w.useId)(),k=(0,w.useId)(),A=TS({isRequired:d,isOptional:u}),[,j]=(0,w.useTransition)(),[M,N]=(0,w.useOptimistic)(o),P=a||M!==o,F=M===!0,I=s&&!!l,L=Ph({placement:`above`,focusTrigger:`always`,isEnabled:I}),R=[];n&&R.push(O),v?.message&&R.push(k),I&&R.push(L.describedBy);let z=R.length>0?R.join(` `):void 0,B=(0,K.jsxs)(`div`,{...Y(yC.switchWrapper,pC[y]),children:[(0,K.jsx)(`input`,{ref:_g(T,L.positionRef),id:D,type:`checkbox`,role:`switch`,name:s?void 0:c,checked:F,disabled:s&&!I,"aria-disabled":I?`true`:void 0,form:I?``:void 0,required:d,"aria-required":A?`true`:void 0,onChange:e=>{if(s||P)return;let t=e.target.checked;r?.(t,e),i&&!e.defaultPrevented&&j(async()=>{N(t),await i(t,e)})},onFocus:f,onBlur:p,"aria-describedby":z,"aria-invalid":v?.type===`error`||void 0,"aria-busy":P||void 0,...Y(yC.input,mC[y],s&&yC.inputDisabled,P&&yC.inputBusy)}),(0,K.jsx)(`div`,{"aria-hidden":`true`,...rg(X(`switch`,{checked:F?`checked`:null,disabled:s?`disabled`:null,size:y}),Y(yC.track,hC[y],F?yC.trackOn:yC.trackOff,!s&&yC.trackFocus,s&&yC.trackDisabled,s&&!F&&yC.trackDisabledOff)),children:(0,K.jsx)(`div`,{...rg(X(`switch-thumb`,{checked:F?`checked`:null,size:y}),Y(yC.thumb,F?_C[y]:gC[y],F?yC.thumbOn:yC.thumbOff)),children:P&&(0,K.jsx)(Bg,{size:`sm`})})}),P&&(0,K.jsx)(Vg,{role:`status`,children:`Loading`})]}),V=(0,K.jsx)(`div`,{...Y(yC.labelWrapper,vC[y]),children:(0,K.jsx)(lS,{...X(`switch-label`),label:e,inputID:D,isLabelHidden:t,isDisabled:s,isOptional:u,isRequired:d,labelIcon:m,labelTooltip:h,description:n,descriptionID:O})});return(0,K.jsxs)(`div`,{...rg(X(`switch-field`,{labelPosition:g===`end`?void 0:g,labelSpacing:_===`hug`?void 0:_}),Y(b!=null&&bC.width(b),x),S,C),...E,children:[(0,K.jsxs)(`div`,{ref:e=>{L.interactionRef(e)},...Y(yC.container,t&&yC.containerLabelHidden,_===`spread`&&yC.containerSpread,!s&&fC),children:[` `,g===`start`?(0,K.jsxs)(K.Fragment,{children:[V,B]}):(0,K.jsxs)(K.Fragment,{children:[B,V]})]}),v?.message&&(0,K.jsx)(pS,{type:v.type,message:v.message,id:k,variant:`detached`,xstyle:yC.statusGap}),I&&L.renderTooltip(l)]})}xC.displayName=`Switch`;var SC=[{id:`light`,label:`themeLight`,Icon:st},{id:`dark`,label:`themeDark`,Icon:Ue},{id:`mist`,label:`themeMist`,Icon:ce},{id:`rose`,label:`themeRose`,Icon:we},{id:`pine`,label:`themePine`,Icon:ut},{id:`system`,label:`themeSystem`,Icon:He}],CC=[`explorer`,`implementer`,`reviewer`,`advisor`];function wC({catalog:e,error:t,onRefresh:n}){let{t:r}=Ln();return!t&&!e?(0,K.jsxs)(`div`,{className:`settings-load-state`,role:`status`,children:[(0,K.jsx)(Ze,{className:`settings-spin`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`settingsCatalogLoading`)})]}):t?(0,K.jsxs)(`div`,{className:`settings-load-state error`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:r(`settingsCatalogFailed`)}),(0,K.jsx)(`span`,{children:t}),(0,K.jsx)(`button`,{type:`button`,onClick:n,children:r(`retryAdmissionCheck`)})]}):null}function TC({isPending:e,onConfigure:t,request:n,label:r}){return(0,K.jsx)(Pv,{label:r,variant:`secondary`,size:`sm`,icon:(0,K.jsx)(pt,{"aria-hidden":`true`}),isDisabled:e,isLoading:e,onClick:()=>void t(n)})}function EC({catalog:e,error:t,currentModel:n,thinkingLevel:r,cwd:i,theme:a,setupPending:o,preferencePending:s,onConfigure:c,onUpdatePreferences:l,onOpenRuntimeStatus:u,onRefresh:d}){let{t:f}=Ln(),p=e?.setup,m=p?.ui.webTheme??a,[h,g]=(0,w.useState)(p?.ui.webChatWidth??820),[_,v]=(0,w.useState)(p?.ui.webChatFontSize??14);return(0,w.useEffect)(()=>{p&&(g(p.ui.webChatWidth),v(p.ui.webChatFontSize))},[p]),(0,K.jsxs)(`section`,{className:`settings-general-panel`,children:[(0,K.jsxs)(`div`,{className:`settings-page-heading`,children:[(0,K.jsx)(`div`,{children:(0,K.jsx)(`h1`,{children:f(`generalSettings`)})}),(0,K.jsx)(TC,{isPending:o,onConfigure:c,request:f(`setupRequestReviewAll`),label:f(`configureOpenPi`)})]}),(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`appearance`)}),(0,K.jsx)(`div`,{className:`settings-theme-options`,role:`radiogroup`,"aria-label":f(`appearance`),children:SC.map(({id:e,label:t,Icon:n})=>(0,K.jsxs)(`label`,{className:`settings-theme-option`,"data-selected":m===e?`true`:void 0,children:[(0,K.jsx)(`input`,{type:`radio`,name:`openpi-web-theme`,value:e,checked:m===e,disabled:s,onChange:()=>{l({theme:e})}}),(0,K.jsx)(n,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(t)})]},e))})]}),p&&(0,K.jsxs)(`section`,{className:`settings-section-block settings-chat-controls`,children:[(0,K.jsx)(`h2`,{children:f(`conversationSettings`)}),(0,K.jsx)(xC,{label:f(`expandThinkingByDefault`),value:p.ui.webExpandThinking,size:`sm`,width:`100%`,labelPosition:`start`,labelSpacing:`spread`,isDisabled:s,isLoading:s,onChange:e=>{l({expandThinking:e})}}),(0,K.jsx)(`div`,{className:`settings-slider-control`,children:(0,K.jsx)(dC,{label:f(`chatContentWidth`),value:h,min:820,max:2e3,step:10,width:`100%`,valueDisplay:`text`,formatValue:e=>`${e}px`,isDisabled:s,onChange:e=>g(e),onChangeEnd:e=>{e!==p.ui.webChatWidth&&l({chatWidth:e}).then(e=>{e||g(p.ui.webChatWidth)})}})}),(0,K.jsx)(`div`,{className:`settings-slider-control`,children:(0,K.jsx)(dC,{label:f(`chatFontSize`),value:_,min:12,max:24,step:1,width:`100%`,valueDisplay:`text`,formatValue:e=>`${e}px`,isDisabled:s,onChange:e=>v(e),onChangeEnd:e=>{e!==p.ui.webChatFontSize&&l({chatFontSize:e}).then(e=>{e||v(p.ui.webChatFontSize)})}})})]}),(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:d}),p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`agentBehavior`)}),(0,K.jsxs)(`div`,{className:`settings-fact-grid`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(rt,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`capabilityDiscovery`)}),(0,K.jsx)(`strong`,{children:f(`capabilityDiscovery_${p.capabilities.discovery}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(ke,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`workflowLimits`)}),(0,K.jsx)(`strong`,{children:f(`workflowLimitsValue`,{concurrency:p.workflows.concurrency,calls:p.workflows.maxAgentCalls})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(I,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`nextActionSuggestions`)}),(0,K.jsx)(`strong`,{children:p.suggestions.enabled?p.suggestions.model?`${p.suggestions.model.provider}/${p.suggestions.model.model} · ${p.suggestions.model.reasoning}`:f(`enabled`):f(`disabled`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(le,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:f(`postEditCommand`)}),(0,K.jsx)(`strong`,{children:f(p.postEditConfigured?`configured`:`disabled`)})]})]})]}),(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`resultDisplay`)}),(0,K.jsxs)(`dl`,{className:`settings-summary-list`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`subagentResults`)}),(0,K.jsx)(`dd`,{children:f(`detailDisplay_${p.ui.subagentResultDisplay}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`bashOperations`)}),(0,K.jsx)(`dd`,{children:f(`detailDisplay_${p.ui.bashToolDisplay}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`fileMutations`)}),(0,K.jsx)(`dd`,{children:f(`detailDisplay_${p.ui.fileMutationDisplay}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`footer`)}),(0,K.jsx)(`dd`,{children:p.ui.customFooter?`${f(`enabled`)} · ${p.ui.footerStyle}`:f(`disabled`)})]})]})]})]}),(0,K.jsxs)(`section`,{className:`settings-section-block`,children:[(0,K.jsx)(`h2`,{children:f(`sessionSettings`)}),(0,K.jsxs)(`dl`,{className:`settings-summary-list`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`selectedModel`)}),(0,K.jsx)(`dd`,{children:n?.label??f(`noModels`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`thinkingLevel`)}),(0,K.jsx)(`dd`,{children:r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:f(`currentWorkspace`)}),(0,K.jsx)(`dd`,{title:i,children:i})]})]}),(0,K.jsx)(Pv,{label:f(`openRuntimeDetails`),variant:`secondary`,size:`sm`,icon:(0,K.jsx)(Te,{"aria-hidden":`true`}),className:`settings-runtime-action`,onClick:u})]})]})}function DC(e){return e.split(/[\\/]/u).filter(Boolean).at(-1)||e}function OC({catalog:e,error:t,onRefresh:n}){let{t:r}=Ln(),i=e?.resources.skills??[],a=(0,w.useMemo)(()=>[`project`,`user`,`temporary`].map(e=>({scope:e,skills:i.filter(t=>t.scope===e)})).filter(e=>e.skills.length>0),[i]),[o,s]=(0,w.useState)(``),[c,l]=(0,w.useState)(null),u=i.find(e=>e.id===o)??i[0];(0,w.useEffect)(()=>{i.length&&!i.some(e=>e.id===o)&&s(i[0].id)},[o,i]);let d=e=>{l(null),sp(`/skill:${e.name} `).then(e=>l(e?`copied`:`failed`))};return(0,K.jsxs)(`section`,{className:`settings-split-panel`,children:[(0,K.jsxs)(`aside`,{className:`settings-resource-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-resource-list`,children:[a.map(e=>(0,K.jsxs)(`section`,{className:`settings-resource-group`,children:[(0,K.jsx)(`span`,{className:`settings-sidebar-label`,children:r(`resourceScope_${e.scope}`)}),e.skills.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`settings-resource-item`,"aria-current":e.id===u?.id?`page`:void 0,onClick:()=>{s(e.id),l(null)},children:[(0,K.jsx)(rt,{"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`small`,{children:DC(e.source)})]})]},e.id))]},e.scope)),!e&&!t&&(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}),e&&!i.length&&(0,K.jsx)(`p`,{className:`settings-resource-empty`,children:r(`noSkillsFound`)})]}),(0,K.jsxs)(`div`,{className:`settings-sidebar-footer`,children:[(0,K.jsx)(`span`,{children:r(`skillCount`,{count:i.length})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":r(`refreshStatus`),onClick:n,children:(0,K.jsx)(Ze,{"aria-hidden":`true`})})]})]}),(0,K.jsx)(`div`,{className:`settings-resource-detail`,children:t?(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}):u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:r(`skill`)}),(0,K.jsx)(`h1`,{children:u.name}),(0,K.jsx)(`p`,{children:u.description})]}),(0,K.jsx)(Pv,{label:r(c===`copied`?`copiedMessage`:`copySkillInvocation`),variant:`secondary`,size:`sm`,icon:c===`copied`?(0,K.jsx)(B,{}):(0,K.jsx)(oe,{}),onClick:()=>d(u)})]}),(0,K.jsxs)(`dl`,{className:`settings-detail-metadata`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`source`)}),(0,K.jsx)(`dd`,{children:u.source})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`scope`)}),(0,K.jsx)(`dd`,{children:r(`resourceScope_${u.scope}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`invocation`)}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{children:`/skill:${u.name}`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`modelInvocation`)}),(0,K.jsx)(`dd`,{children:r(u.disableModelInvocation?`explicitOnly`:`availableToModel`)})]})]}),(0,K.jsxs)(`section`,{className:`settings-path-block`,children:[(0,K.jsx)(Ce,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:r(`skillFile`)}),(0,K.jsx)(`code`,{children:u.filePath})]})]}),c===`failed`&&(0,K.jsx)(`p`,{className:`inspection-warning`,children:r(`copyFailed`)})]}):(0,K.jsxs)(`div`,{className:`settings-empty-detail`,children:[(0,K.jsx)(rt,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`selectSkill`)})]})})]})}function kC({catalog:e,error:t,currentModel:n,activity:r,setupPending:i,onConfigure:a,onRefresh:o}){let{t:s}=Ln(),[c,l]=(0,w.useState)(`explorer`),u=e?.setup.subagents.roleModels[c],d=r?.items.filter(e=>e.status===`running`).length??0,f=r?.items.filter(e=>e.status!==`running`).length??0;return(0,K.jsxs)(`section`,{className:`settings-subagents-panel`,children:[(0,K.jsxs)(`header`,{className:`settings-subagent-summary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:s(`subagentConfiguration`)}),(0,K.jsx)(`span`,{children:s(`subagentConfigurationIntro`)})]}),e&&(0,K.jsxs)(`div`,{className:`settings-subagent-metrics`,children:[(0,K.jsx)(`span`,{children:s(`subagentActiveCount`,{count:d})}),(0,K.jsx)(`span`,{children:s(`subagentCompletedCount`,{count:f})}),(0,K.jsx)(`span`,{children:s(`subagentConcurrency`,{count:e.setup.workflows.concurrency})})]})]}),(0,K.jsxs)(`div`,{className:`settings-split-panel settings-subagent-split`,children:[(0,K.jsxs)(`aside`,{className:`settings-resource-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-resource-list`,children:[(0,K.jsx)(`span`,{className:`settings-sidebar-label`,children:s(`builtInRoles`)}),CC.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`settings-resource-item`,"aria-current":e===c?`page`:void 0,onClick:()=>l(e),children:[(0,K.jsx)(I,{"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:s(`subagentRole_${e}`)}),(0,K.jsx)(`small`,{children:s(`subagentRoleShort_${e}`)})]})]},e))]}),(0,K.jsx)(`div`,{className:`settings-sidebar-footer settings-sidebar-footer-action`,children:(0,K.jsx)(TC,{isPending:i,onConfigure:a,request:s(`setupRequestSubagents`),label:s(`configureRoles`)})})]}),(0,K.jsxs)(`div`,{className:`settings-resource-detail`,children:[(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:o}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:s(`builtInRole`)}),(0,K.jsx)(`h1`,{children:s(`subagentRole_${c}`)}),(0,K.jsx)(`p`,{children:s(`subagentRoleDescription_${c}`)})]}),(0,K.jsx)(`span`,{className:`settings-status-badge`,children:s(`builtIn`)})]}),(0,K.jsxs)(`dl`,{className:`settings-detail-metadata settings-detail-metadata-wide`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`modelAssignment`)}),(0,K.jsx)(`dd`,{children:u?`${u.provider}/${u.model}`:s(`inheritParentModel`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`effectiveModel`)}),(0,K.jsx)(`dd`,{children:u?`${u.provider}/${u.model}`:n?.label??s(`unknownState`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`workflowConcurrencyLabel`)}),(0,K.jsx)(`dd`,{children:e.setup.workflows.concurrency})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:s(`workflowCallLimit`)}),(0,K.jsx)(`dd`,{children:e.setup.workflows.maxAgentCalls})]})]}),(0,K.jsxs)(`section`,{className:`settings-role-principles`,children:[(0,K.jsx)(`h2`,{children:s(`runtimeBoundaries`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),(0,K.jsx)(`p`,{children:s(`subagentAuthorityNote`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(pe,{"aria-hidden":`true`}),(0,K.jsx)(`p`,{children:s(`subagentModelNote`)})]})]})]})]})]})]})}function AC(e){return e.extensions.length+e.skills.length+e.prompts.length+e.themes.length}function jC({catalog:e,error:t,onRefresh:n}){let{t:r}=Ln(),i=e?.resources.plugins??[],[a,o]=(0,w.useState)(``),s=i.find(e=>e.id===a)??i[0];return(0,w.useEffect)(()=>{i.length&&!i.some(e=>e.id===a)&&o(i[0].id)},[i,a]),(0,K.jsxs)(`section`,{className:`settings-split-panel`,children:[(0,K.jsxs)(`aside`,{className:`settings-resource-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-resource-list`,children:[i.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`settings-resource-item`,"aria-current":e.id===s?.id?`page`:void 0,onClick:()=>o(e.id),children:[(0,K.jsx)(Je,{"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:DC(e.source)}),(0,K.jsx)(`small`,{children:r(`resourceCount`,{count:AC(e)})})]})]},e.id)),!e&&!t&&(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}),e&&!i.length&&(0,K.jsx)(`p`,{className:`settings-resource-empty`,children:r(`noPluginsFound`)})]}),(0,K.jsxs)(`div`,{className:`settings-sidebar-footer`,children:[(0,K.jsx)(`span`,{children:e?r(`pluginCatalogTotals`,e.resources.totals):r(`settingsCatalogLoading`)}),(0,K.jsx)(`button`,{type:`button`,"aria-label":r(`refreshStatus`),onClick:n,children:(0,K.jsx)(Ze,{"aria-hidden":`true`})})]})]}),(0,K.jsx)(`div`,{className:`settings-resource-detail`,children:t?(0,K.jsx)(wC,{catalog:e,error:t,onRefresh:n}):s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:r(`resourceScope_${s.scope}`)}),(0,K.jsx)(`h1`,{children:DC(s.source)}),(0,K.jsx)(`code`,{children:s.source})]}),(0,K.jsx)(`span`,{className:`settings-status-badge healthy`,children:r(`loaded`)})]}),(0,K.jsxs)(`dl`,{className:`settings-detail-metadata settings-detail-metadata-wide`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`scope`)}),(0,K.jsx)(`dd`,{children:r(`resourceScope_${s.scope}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`resourceOrigin`)}),(0,K.jsx)(`dd`,{children:r(`resourceOrigin_${s.origin}`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`resources`)}),(0,K.jsx)(`dd`,{children:r(`pluginResourceSummary`,{extensions:s.extensions.length,skills:s.skills.length,prompts:s.prompts.length,themes:s.themes.length})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:r(`baseDirectory`)}),(0,K.jsx)(`dd`,{title:s.baseDir,children:s.baseDir??r(`notReported`)})]})]}),(0,K.jsxs)(`section`,{className:`settings-resource-groups`,children:[s.extensions.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`extensions`)}),(0,K.jsx)(`ul`,{children:s.extensions.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`code`,{children:e.path})]}),(0,K.jsx)(`span`,{children:r(`extensionSurfaceCount`,{tools:e.toolCount,commands:e.commandCount})})]},e.path))})]}),s.skills.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`skillsSettings`)}),(0,K.jsx)(`p`,{children:s.skills.join(` · `)})]}),s.prompts.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`prompts`)}),(0,K.jsx)(`p`,{children:s.prompts.join(` · `)})]}),s.themes.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`themes`)}),(0,K.jsx)(`p`,{children:s.themes.join(` · `)})]})]}),(0,K.jsxs)(`aside`,{className:`provider-read-only`,children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:r(`providerReadOnly`)}),(0,K.jsx)(`p`,{children:r(`pluginsManagedByPi`)})]})]})]}):(0,K.jsxs)(`div`,{className:`settings-empty-detail`,children:[(0,K.jsx)(Je,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:r(`selectPlugin`)})]})})]})}function MC(e){let t=(0,w.useMemo)(()=>new zp,[]),[n,r]=(0,w.useState)(0),[i,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(null),c=(0,w.useCallback)(()=>r(e=>e+1),[]);return(0,w.useEffect)(()=>{let n=new AbortController;return a(null),s(null),t.settingsCatalog(e,n.signal).then(a,e=>{n.signal.aborted||s(e instanceof Error?e.message:String(e))}),()=>n.abort()},[t,n,e]),{catalog:i,error:o,refresh:c}}var NC=[{id:`general`,label:`generalSettings`,Icon:nt},{id:`models`,label:`modelSettings`,Icon:pe},{id:`skills`,label:`skillsSettings`,Icon:Ie},{id:`subagents`,label:`subagentsSettings`,Icon:I},{id:`plugins`,label:`pluginsSettings`,Icon:Je}];function PC(e){return`${e.provider}/${e.id}`}function FC({sessionId:e,cwd:t,models:n,currentModel:r,thinkingLevel:i,theme:a,capabilities:o,setupBusy:s,modelSelectionPending:c,onSelectModel:l,onConfigureOpenPi:u,interaction:d,onPreferencesChanged:f,onOpenRuntimeStatus:p,onClose:m}){let{t:h}=Ln(),g=(0,w.useRef)(null),[_,v]=(0,w.useState)(`general`),[y,b]=(0,w.useState)(!1),[x,S]=(0,w.useState)(!1),C=(0,w.useRef)(!1),T=(0,w.useRef)(!1),E=(0,w.useRef)(0),[D,O]=(0,w.useState)(!1),[k,A]=(0,w.useState)(null),{catalog:j,error:M,refresh:N}=MC(e),[P,F]=(0,w.useState)(r?PC(r):n[0]?PC(n[0]):``),I=(0,w.useMemo)(()=>{let e=new Map;for(let t of n){let n=e.get(t.provider)??[];n.push(t),e.set(t.provider,n)}return[...e.entries()]},[n]),L=n.find(e=>PC(e)===P)??r??n[0];(0,w.useEffect)(()=>{g.current?.focus()},[]),(0,w.useEffect)(()=>{if(!n.length){F(``);return}n.some(e=>PC(e)===P)||F(PC(r??n[0]))},[r,n,P]),(0,w.useEffect)(()=>{if(x){if(s){T.current=!0;return}!T.current||!C.current||(C.current=!1,T.current=!1,window.clearTimeout(E.current),N(),f())}},[f,N,s,x]),(0,w.useEffect)(()=>()=>window.clearTimeout(E.current),[]);let R=async e=>{if(y)return!1;b(!0),S(!1),C.current=!1,T.current=!1,window.clearTimeout(E.current),A(null);try{let t=await u(e);return t?(S(!0),C.current=!0,E.current=window.setTimeout(()=>{!C.current||T.current||(C.current=!1,T.current=!1,N(),f())},2e3)):A(h(`setupRequestFailed`)),t}catch(e){return b(!1),A(e instanceof Error?e.message:h(`setupRequestFailed`)),!1}finally{b(!1)}},z=e=>e.theme===void 0?e.chatWidth===void 0?e.chatFontSize===void 0?e.expandThinking===void 0?h(`setupRequestReviewAll`):h(e.expandThinking?`setupRequestEnableExpandedThinking`:`setupRequestDisableExpandedThinking`):h(`setupRequestSetChatFontSize`,{value:e.chatFontSize}):h(`setupRequestSetChatWidth`,{value:e.chatWidth}):h(`setupRequestSetTheme`,{value:e.theme});return(0,K.jsx)(Lx,{isOpen:!0,purpose:`info`,padding:0,width:1080,maxHeight:`calc(100dvh - 16px)`,className:`provider-settings-dialog`,"aria-label":h(`settings`),onOpenChange:e=>!e&&m(),children:(0,K.jsxs)(`section`,{className:`provider-settings-surface`,children:[(0,K.jsxs)(`header`,{className:`provider-settings-header`,children:[(0,K.jsx)(`strong`,{className:`provider-settings-title`,children:h(`settings`)}),(0,K.jsx)(`div`,{className:`provider-settings-navigation`,"aria-label":h(`settingsNavigation`),role:`tablist`,children:NC.map(({id:e,label:t,Icon:n})=>(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":_===e,"aria-controls":`settings-panel-${e}`,className:`provider-settings-tab`,title:h(t),onClick:()=>{v(e),A(null)},children:[(0,K.jsx)(n,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:h(t)})]},e))}),(0,K.jsx)(`button`,{ref:g,type:`button`,className:`icon-button provider-settings-close`,"aria-label":h(`close`),onClick:m,children:(0,K.jsx)(mt,{})})]}),(0,K.jsxs)(`div`,{className:`provider-settings-main`,children:[(0,K.jsx)(`div`,{id:`settings-panel-general`,role:`tabpanel`,hidden:_!==`general`,children:(0,K.jsx)(EC,{catalog:j,error:M,currentModel:r,thinkingLevel:i,cwd:t,theme:a,setupPending:y||s,preferencePending:D,onConfigure:R,onUpdatePreferences:async e=>{if(D)return!1;O(!0),A(null);try{return await R(z(e))}catch(e){return A(e instanceof Error?e.message:h(`settingsUpdateFailed`)),!1}finally{O(!1)}},onOpenRuntimeStatus:p,onRefresh:N})}),(0,K.jsxs)(`section`,{id:`settings-panel-models`,className:`settings-models`,role:`tabpanel`,hidden:_!==`models`,children:[(0,K.jsxs)(`aside`,{className:`settings-model-sidebar`,children:[(0,K.jsxs)(`div`,{className:`settings-model-list`,children:[I.map(([e,t])=>(0,K.jsxs)(`section`,{className:`settings-model-group`,children:[(0,K.jsxs)(`h2`,{children:[(0,K.jsx)(pe,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`small`,{children:t.length})]}),t.map(e=>{let t=PC(e);return(0,K.jsxs)(`button`,{type:`button`,"aria-current":t===P?`page`:void 0,className:`settings-model-item`,onClick:()=>F(t),children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:e.name||e.id}),e.name!==e.id&&(0,K.jsx)(`small`,{children:e.id})]}),e.current&&(0,K.jsx)(B,{"aria-label":h(`currentModel`)})]},t)})]},e)),!n.length&&(0,K.jsx)(`p`,{className:`settings-model-empty`,children:h(`noModels`)})]}),(0,K.jsxs)(`div`,{className:`settings-model-provider-link`,children:[(0,K.jsx)(Fe,{"aria-hidden":`true`}),` `,h(`providerReadOnly`)]})]}),(0,K.jsx)(`div`,{className:`settings-model-detail`,children:L?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`settings-model-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:h(`model`)}),(0,K.jsx)(`h1`,{children:L.name||L.id}),(0,K.jsx)(`code`,{children:PC(L)})]}),(0,K.jsx)(Pv,{label:L.current?h(`currentModel`):h(`useThisModel`),variant:L.current?`secondary`:`primary`,size:`sm`,icon:L.current?(0,K.jsx)(B,{"aria-hidden":`true`}):void 0,isDisabled:L.current||c,isLoading:c,onClick:()=>l(PC(L))})]}),(0,K.jsxs)(`dl`,{className:`settings-model-metadata`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:h(`provider`)}),(0,K.jsx)(`dd`,{children:L.provider})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:h(`modelId`)}),(0,K.jsx)(`dd`,{children:L.id})]})]}),(0,K.jsx)($S,{sessionId:e,providerId:L.provider,active:_===`models`})]}):(0,K.jsx)(`div`,{className:`provider-settings-state`,children:(0,K.jsx)(`strong`,{children:h(`noModels`)})})})]}),(0,K.jsx)(`div`,{id:`settings-panel-skills`,role:`tabpanel`,hidden:_!==`skills`,children:(0,K.jsx)(OC,{catalog:j,error:M,onRefresh:N})}),(0,K.jsx)(`div`,{id:`settings-panel-subagents`,role:`tabpanel`,hidden:_!==`subagents`,children:(0,K.jsx)(kC,{catalog:j,error:M,currentModel:r,activity:o?.subagents,setupPending:y||s,onConfigure:R,onRefresh:N})}),(0,K.jsx)(`div`,{id:`settings-panel-plugins`,role:`tabpanel`,hidden:_!==`plugins`,children:(0,K.jsx)(jC,{catalog:j,error:M,onRefresh:N})})]}),d,k&&(0,K.jsx)(`div`,{className:`settings-global-error`,role:`alert`,children:k}),x&&!k&&(0,K.jsx)(`div`,{className:`settings-global-status`,role:`status`,children:h(s?`setupRequestRunning`:`setupRequestAccepted`)})]})})}var IC=(0,w.createContext)(null);IC.displayName=`ListContext`;var LC={list:{kogj98:`x1ghz6dp`,kZCmMZ:`x1c1uobl`,kH6xsr:`x3ct3a4`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,$$css:!0},withDividers:{kOIVth:`xxhr3t`,$$css:!0},withCounter:{kt6KFK:`xif0320`,$$css:!0}},RC={kt6KFK:`x1khind5`,$$css:!0},zC={counterStart:e=>[RC,{"--x-counterReset":`astryx-list ${e}`==null?void 0:`astryx-list ${e}`}]};function BC({children:e,density:t=`balanced`,hasDividers:n=!1,header:r,listStyle:i=`none`,start:a,xstyle:o,className:s,style:c,"data-testid":l,ref:u,...d}){let f=(0,w.useId)(),p=i===`decimal`,m=p?`ol`:`ul`,h=(0,w.useMemo)(()=>({density:t,hasDividers:n,listStyle:i}),[t,n,i]),g=(0,K.jsx)(m,{ref:u,...d,"data-testid":l,...r==null?null:{"aria-labelledby":f},...p&&a!=null&&a!==1?{start:a}:{},role:`list`,...rg(X(`list`,{density:t,listStyle:i}),Y(LC.list,n&&LC.withDividers,i!==`none`&&(a!=null&&a!==1?zC.counterStart(a-1):LC.withCounter),o),s,c),children:e});return r==null?(0,K.jsx)(IC,{value:h,children:g}):(0,K.jsx)(IC,{value:h,children:(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf`,children:[(0,K.jsx)(`div`,{id:f,className:`x1p37lm5`,children:r}),g]})})}BC.displayName=`List`;var VC={withCounter:{kAmcRD:`xfrknyr`,$$css:!0},withDivider:{kt9PQ7:`x92x3c3`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},HC={noRadius:{kaIpWk:`x2u8bby`,$$css:!0}};function UC({label:e,description:t,startContent:n,endContent:r,onClick:i,interactiveRef:a,href:o,target:s,rel:c,isDisabled:l=!1,isSelected:u=!1,xstyle:d,className:f,style:p,ref:m,...h}){let g=(0,w.use)(IC),_=g?.density??`balanced`,v=g?.hasDividers??!1,y=g?.listStyle??`none`;return(0,K.jsx)($y,{as:`li`,ref:m,marker:y===`disc`?(0,K.jsx)(`span`,{className:`xoi2r2e x9f619 x78zum5 x6s0dn4 xl56j7k x2lah0s x12xnipv x1233pnv`,children:(0,K.jsx)(`span`,{className:`x1v4s8kt xols6we x16rqkct x19aspcf`})}):y===`circle`?(0,K.jsx)(`span`,{className:`xoi2r2e x9f619 x78zum5 x6s0dn4 xl56j7k x2lah0s x12xnipv x1233pnv`,children:(0,K.jsx)(`span`,{className:`x1v4s8kt xols6we x16rqkct xmkeg23 x1y0btm7 xqcx1ss xjbqb8w`})}):y===`decimal`?(0,K.jsx)(`span`,{className:`xoi2r2e x2lah0s x1tgivj0 xjm74w1 xw6l6zx x12xnipv xc2ndz5`}):null,startContent:n,label:e,description:t,endContent:r,onClick:i,interactiveRef:a,href:o,target:s,rel:c,isDisabled:l,isSelected:u,density:_,xstyle:[y!==`none`&&VC.withCounter,v&&VC.withDivider,v&&HC.noRadius,d],...rg(X(`list-item`),{className:f,style:p}),...h})}UC.displayName=`ListItem`;var WC={base:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kaIpWk:`x16rqkct`,kmuXW:`x2lah0s`,kzqmXN:`x1xc55vz`,kZKoxP:`xdk7pt`,$$css:!0},pulsing:{kKVMdj:`x1mta51n`,k44tkh:`x1c74tu6`,kyAemX:`x4hg4is`,ko0y90:`xa4qsjk`,$$css:!0},reducedMotion:{kjO2d4:`x1aquc0h`,$$css:!0}},GC={success:{kWkggS:`xdsz4j9`,kMwMTN:`xri61p4`,$$css:!0},warning:{kWkggS:`x1q8g9m5`,kMwMTN:`xrebv38`,$$css:!0},error:{kWkggS:`x1pjz0fi`,kMwMTN:`x1m024r3`,$$css:!0},accent:{kWkggS:`x1ewilqj`,kMwMTN:`x17wrial`,$$css:!0},neutral:{kWkggS:`x1q5y3ey`,kMwMTN:`xrkvqaz`,$$css:!0}};function KC({variant:e,label:t,isPulsing:n=!1,tooltip:r,icon:i,xstyle:a,className:o,style:s,ref:c,...l}){let u=og(i),d=(0,K.jsx)(`span`,{ref:c,role:`img`,"aria-label":t,...rg(X(`status-dot`,{variant:e},{legacyNames:[`statusdot`]}),Y(WC.base,GC[e],n&&WC.pulsing,n&&WC.reducedMotion,a),o,s),...l,children:u&&(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`x78zum5 x6s0dn4 xl56j7k x14ju556 x1xc55vz xdk7pt`,children:i})});return r?(0,K.jsx)(Hb,{content:r,children:d}):d}KC.displayName=`StatusDot`;function qC(e){let t=new Map;return e.map(e=>{let n=JSON.stringify(e),r=t.get(n)??0;return t.set(n,r+1),{item:e,key:`${n}:${r}`}})}function JC({name:e,args:t,output:n,state:r}){let{t:i}=Ln();return(0,K.jsxs)(`details`,{className:`subagent-tool ${r}`,"data-status":r,children:[(0,K.jsxs)(`summary`,{children:[(0,K.jsx)(`code`,{children:e}),(0,K.jsx)(`span`,{className:`subagent-state ${r}`,children:i(`subagentTool_${r}`)})]}),t&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`strong`,{className:`subagent-tool-label`,children:i(`trajectoryArguments`)}),(0,K.jsx)(`pre`,{children:t})]}),n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`strong`,{className:`subagent-tool-label`,children:i(`trajectoryOutput`)}),(0,K.jsx)(`pre`,{children:n})]})]})}function YC({sessionId:e,id:t,activity:n,client:r,saved:i,liveAvailable:a,fullView:o,readOnlyNote:s=!0}){let{t:c}=Ln(),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),[p,m]=(0,w.useState)(!0),[h,g]=(0,w.useState)(0),[_,v]=(0,w.useState)(null),y=(0,w.useRef)(null),b=(0,w.useRef)(!0);(0,w.useEffect)(()=>{if(!a){m(!1),f(c(`subagentUnavailable`));return}let i=new AbortController,o,s=!1,l=async()=>{if(s||i.signal.aborted||document.visibilityState===`hidden`)return;s=!0;let a=n?.status===`running`;try{let n=await r.subagentDetail(e,t,i.signal);if(i.signal.aborted)return;if(n.sessionId!==e||n.detail.kind!==`subagents`||n.detail.id!==t)throw u(null),a=!1,Error(c(`inspectionChanged`));a=n.detail.status===`running`,u(n.detail),f(null),v(new Date().toLocaleTimeString())}catch(e){if(i.signal.aborted)return;f(e instanceof Lp&&[404,501].includes(e.status)?c(`subagentUnavailable`):e instanceof Error?e.message:c(`inspectionUnavailable`))}finally{s=!1,i.signal.aborted||(m(!1),a&&(o=setTimeout(()=>void l(),1e3)))}},d=()=>{document.visibilityState===`visible`&&(clearTimeout(o),l())};return document.addEventListener(`visibilitychange`,d),l(),()=>{i.abort(),clearTimeout(o),document.removeEventListener(`visibilitychange`,d)}},[r,e,t,n?.status,h,a,c]),(0,w.useLayoutEffect)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight)},[l]);let x=new Map(l?.transcript.flatMap(e=>e.kind===`toolResult`?[[e.toolId,e]]:[])),S=new Set(l?.transcript.flatMap(e=>e.kind===`assistant`?e.parts.flatMap(e=>e.type===`toolCall`?[e.toolId]:[]):[])),C=l?.outcome===`interrupted`?`interrupted`:l?.status,T=l?.transcript.some(e=>e.kind===`assistant`&&e.parts.flatMap(e=>e.type===`text`?[e.text]:[]).join(` `).trim()===l.finalText.trim()),E=o?`h2`:`h3`;return(0,K.jsxs)(`section`,{className:`subagent-detail`,"aria-label":c(`subagentDetails`),children:[(0,K.jsxs)(`header`,{className:`subagent-detail-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`subagent-state ${C??`unknown`}`,children:C?c(`subagentState_${C}`):i?.state?`${c(`subagentRecordedState`)}: ${c(`subagentState_${i.state}`)}`:c(`unknownState`)}),l&&(0,K.jsx)(`span`,{className:`subagent-duration`,children:Yb(l.createdAt,l.settledAt)})]}),(0,K.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":c(`refreshStatus`),disabled:p||!a,onClick:()=>{m(!0),g(e=>e+1)},children:(0,K.jsx)(Ze,{})})]}),p&&!l&&(0,K.jsx)(`p`,{role:`status`,children:c(`inspectionLoading`)}),d&&(0,K.jsxs)(`div`,{className:`inspection-warning`,role:`alert`,children:[(0,K.jsx)(`p`,{children:c(l?`subagentStale`:`subagentUnavailable`)}),d!==c(`subagentUnavailable`)&&(0,K.jsx)(`small`,{children:d})]}),l&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`subagent-metadata`,children:[(0,K.jsx)(`code`,{children:l.id}),l.model&&(0,K.jsx)(`span`,{children:l.model}),(0,K.jsx)(`span`,{title:l.cwd,children:l.cwd})]}),(0,K.jsxs)(`details`,{className:`subagent-task`,children:[(0,K.jsx)(`summary`,{children:c(`subagentTask`)}),(0,K.jsx)(`pre`,{children:l.prompt})]}),l.errorText&&(0,K.jsx)(`p`,{className:`inspection-warning`,role:`alert`,children:l.errorText}),l.truncated&&(0,K.jsx)(`p`,{className:`inspection-note`,children:c(`subagentTruncated`,{count:l.omittedEntries})}),(0,K.jsxs)(`div`,{className:`subagent-transcript`,ref:y,role:`log`,"aria-label":c(`subagentTranscript`),onScroll:e=>{let t=e.currentTarget;b.current=t.scrollHeight-t.clientHeight-t.scrollTop<48},children:[qC(l.transcript).map(({item:e,key:t})=>(0,K.jsx)(`div`,{className:`subagent-message ${e.kind}`,"data-role":e.kind,children:e.kind===`user`?(0,K.jsx)(`p`,{className:`subagent-user-message`,children:e.text}):e.kind===`toolResult`?S.has(e.toolId)?null:(0,K.jsx)(JC,{name:e.name,output:e.outputPreview,state:e.isError?`error`:`done`}):qC(e.parts).map(({item:e,key:t})=>e.type===`text`?(0,K.jsx)(pp,{children:e.text},t):e.type===`thinking`?(0,K.jsxs)(`details`,{className:`subagent-thinking done`,"data-status":`done`,children:[(0,K.jsx)(`summary`,{children:c(`thinkingDone`)}),(0,K.jsx)(`pre`,{children:e.redacted?c(`subagentThinkingRedacted`):e.text})]},t):(0,K.jsx)(JC,{name:e.name,args:e.argsPreview,output:x.get(e.toolId)?.outputPreview??l.liveTools.find(t=>t.toolId===e.toolId)?.outputPreview,state:x.has(e.toolId)?x.get(e.toolId).isError?`error`:`done`:l.liveTools.some(t=>t.toolId===e.toolId&&!t.done)?`running`:`unknown`},e.toolId))},t)),l.liveAssistant?.thinking&&(0,K.jsxs)(`details`,{className:`subagent-thinking running`,"data-status":`running`,children:[(0,K.jsx)(`summary`,{children:c(`thinkingActive`)}),(0,K.jsx)(`pre`,{children:l.liveAssistant.thinking})]}),l.liveAssistant?.text&&(0,K.jsx)(`div`,{className:`subagent-message assistant live`,"data-role":`assistant`,children:(0,K.jsx)(pp,{children:l.liveAssistant.text})}),l.liveTools.filter(e=>!S.has(e.toolId)).map(e=>(0,K.jsx)(JC,{name:e.name,args:e.argsPreview,output:e.outputPreview,state:e.done?e.isError?`error`:`done`:`running`},e.toolId)),l.finalText&&!T&&(0,K.jsxs)(`section`,{className:`subagent-final`,children:[(0,K.jsx)(E,{children:c(`subagentResult`)}),(0,K.jsx)(pp,{children:l.finalText})]}),l.status===`running`&&(0,K.jsx)(`p`,{className:`subagent-live`,role:`status`,children:c(`subagentLive`)}),!l.transcript.length&&!l.liveAssistant?.text&&!l.finalText&&(0,K.jsx)(`p`,{children:c(`subagentNoMessages`)})]}),(s||_)&&(0,K.jsxs)(`p`,{className:`subagent-footnote`,children:[s&&c(`subagentReadOnly`),s&&_&&` · `,_]})]}),!l&&!p&&i&&(0,K.jsxs)(`section`,{className:`subagent-transcript`,"aria-label":c(`subagentSaved`),children:[(0,K.jsx)(E,{children:c(`subagentSaved`)}),(0,K.jsx)(`p`,{className:`inspection-note`,children:c(`subagentSavedHint`)}),i.state&&(0,K.jsxs)(`p`,{children:[c(`subagentRecordedState`),`: `,c(`subagentState_${i.state}`)]}),i.result&&(0,K.jsx)(pp,{children:i.result}),i.receipt&&(0,K.jsxs)(`details`,{className:`subagent-task`,children:[(0,K.jsx)(`summary`,{children:c(`subagentSpawnReceipt`)}),(0,K.jsx)(`pre`,{children:i.receipt})]})]})]})}function XC({sessionId:e,initialId:t,activity:n,records:r=[],liveAvailable:i=!0,onClose:a}){let{t:o}=Ln(),[s,c]=(0,w.useState)(t??null),[l,u]=(0,w.useState)(()=>window.matchMedia?.(`(max-width: 1100px)`).matches??!1);(0,w.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 1100px)`);if(!e)return;let t=()=>u(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let d=(0,w.useMemo)(()=>new zp,[]),f=n?.items??[],p=f.find(e=>e.id===s),m=r.find(e=>e.id===s),h=(0,w.useRef)(null),g=(0,w.useRef)(document.activeElement);(0,w.useEffect)(()=>{h.current?.focus()},[s]),(0,w.useEffect)(()=>()=>{queueMicrotask(()=>{!document.querySelector(`.subagent-panel`)&&g.current instanceof HTMLElement&&g.current.isConnected&&g.current.focus()})},[]);let _=[...f.map(e=>({id:e.id,title:e.title,state:e.outcome===`interrupted`?`interrupted`:e.status,elapsed:Yb(e.createdAt,e.settledAt),saved:!1})),...r.filter(e=>!f.some(t=>t.id===e.id)).map(e=>({id:e.id,title:e.title,state:e.state,elapsed:``,saved:!0}))],v=l?`main`:`aside`,y=l?`h1`:`h2`,b=l?`h2`:`h3`;return(0,K.jsxs)(v,{className:`subagent-panel`,"aria-label":o(`subagentDetails`),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&!e.defaultPrevented&&(e.preventDefault(),s?c(null):a())},children:[(0,K.jsxs)(`header`,{className:`subagent-panel-heading`,children:[(0,K.jsxs)(`div`,{className:`subagent-breadcrumb`,children:[s&&(0,K.jsx)(`button`,{ref:h,type:`button`,className:`icon-button`,"aria-label":o(`backToSubagents`),onClick:()=>c(null),children:(0,K.jsx)(M,{})}),(0,K.jsx)(I,{"aria-hidden":`true`}),(0,K.jsx)(y,{children:s?p?.title||m?.title||s:o(`subagentDetails`)})]}),(0,K.jsx)(`button`,{ref:s?void 0:h,type:`button`,className:`icon-button`,"aria-label":o(`close`),onClick:a,children:(0,K.jsx)(mt,{})})]}),s?(0,K.jsx)(YC,{sessionId:e,id:s,activity:p,client:d,saved:m,liveAvailable:i,fullView:l},`${e}:${s}`):(0,K.jsxs)(`nav`,{className:`subagent-list`,"aria-label":o(`subagentTasks`),children:[[!0,!1].map(e=>{let t=_.filter(t=>(t.state===`running`&&!t.saved)===e);return(0,K.jsxs)(`section`,{className:`subagent-list-group`,children:[(0,K.jsxs)(b,{children:[o(e?`subagentActiveGroup`:`subagentFinishedGroup`),(0,K.jsx)(`span`,{children:t.length})]}),!t.length&&(0,K.jsx)(`p`,{children:o(e?`subagentNoneRunning`:`subagentNoneFinished`)}),(0,K.jsx)(BC,{density:`compact`,children:t.map(e=>(0,K.jsx)(UC,{className:`subagent-task-row`,onClick:()=>c(e.id),label:e.title||e.id,description:e.saved?o(`subagentSaved`):o(`subagentState_${e.state}`),startContent:(0,K.jsx)(KC,{label:e.saved?o(`subagentSaved`):o(`subagentState_${e.state}`),variant:e.saved?`neutral`:e.state===`running`?`accent`:e.state===`done`?`success`:`error`,isPulsing:!e.saved&&e.state===`running`}),endContent:(0,K.jsxs)(`span`,{className:`subagent-task-end`,children:[(0,K.jsx)(`span`,{children:e.elapsed}),(0,K.jsx)(U,{"aria-hidden":`true`})]})},e.id))})]},String(e))}),!!n?.omitted&&(0,K.jsx)(`p`,{children:o(`subagentListTruncated`,{count:n?.omitted})})]})]})}function ZC(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&(n.kind!==`event`||n.message||n.input!==void 0||n.result))return n}return e.at(-1)}function QC(e){let t=new Map(e.map((e,t)=>[e.id,t])),n=new Map,r=new Map,i=new Map;for(let a of e){let e=`message`in a?a.message:void 0;for(let t of e?.parts??[])t.type===`toolCall`&&t.id&&r.set(t.id,(r.get(t.id)??0)+1);if(e?.role===`toolResult`&&e.toolCallId){let r=i.get(e.toolCallId)??[];r.push(e),n.set(e,t.get(a.id)??-1),i.set(e.toolCallId,r)}}let a=new Set,o=[];for(let s of e){let e=`message`in s?s.message:void 0;if(!e){o.push({key:s.id,kind:`event`,title:s.type,timestamp:s.timestamp});continue}if(e.role!==`toolResult`){(e.role!==`assistant`||e.content||!e.parts?.length||e.parts?.some(e=>e.type!==`toolCall`))&&o.push({key:s.id,kind:e.role===`user`?`user`:e.role===`assistant`?`assistant`:`event`,title:e.customType||e.role||s.type,timestamp:s.timestamp,message:e});for(let[c,l]of(e.parts??[]).entries()){if(l.type!==`toolCall`)continue;let u=l.id?i.get(l.id):void 0,d=l.id&&r.get(l.id)===1&&u?.length===1&&u[0]?.toolName===l.name&&!l.id.includes(`[truncated]`)&&(n.get(u[0])??-1)>(t.get(s.id)??-1)?u[0]:void 0;d&&a.add(d),o.push({key:`${s.id}:call:${c}`,kind:`call`,title:l.name,timestamp:s.timestamp,callId:l.id,input:l.arguments,message:e,result:d,outcome:d?.isError===!0?`error`:d?.isError===!1?`returned`:`unknown`})}}}let s=new Map(o.map(e=>[e.key,t.get(e.key)??-1]));for(let n of e){let e=`message`in n?n.message:void 0;e?.role===`toolResult`&&!a.has(e)&&(o.push({key:n.id,kind:`result`,title:e.toolName||`toolResult`,timestamp:n.timestamp,callId:e.toolCallId,result:e,outcome:e.isError===!0?`error`:e.isError===!1?`returned`:`unknown`}),s.set(n.id,t.get(n.id)??0));for(let[r,i]of(e?.parts??[]).entries())i.type===`toolCall`&&s.set(`${n.id}:call:${r}`,t.get(n.id)??0)}return o.sort((e,t)=>(s.get(e.key)??0)-(s.get(t.key)??0)),o}var $C=[],ew=(0,w.memo)(function({snapshot:e,running:t}){let{t:n}=Ln(),r=e.selectedSession?.entries??$C,i=(0,w.useMemo)(()=>QC(r),[r]),[a,o]=(0,w.useState)(null),[s,c]=(0,w.useState)(50),l=i.findIndex(e=>e.key===a),u=Math.min(Math.max(0,i.length-s),l<0?i.length:l),d=i.slice(u),f=d.find(e=>e.key===a)??ZC(d),p=e.selectedSession?.truncation,m=f?.result,h=f?.message;return(0,K.jsxs)(`section`,{className:`conversation trajectory`,"aria-label":n(`trajectory`),children:[(0,K.jsxs)(`header`,{className:`trajectory-heading`,children:[(0,K.jsx)(`h2`,{children:n(`trajectory`)}),(0,K.jsx)(`p`,{children:n(`trajectoryScope`)}),t&&(0,K.jsx)(`p`,{role:`status`,children:n(`trajectoryRunning`)}),p?.truncated&&(0,K.jsx)(`p`,{className:`trajectory-warning`,children:n(`trajectoryTruncated`,{entries:p.entriesOmitted,parts:p.messagePartsOmitted,messages:p.messagesTruncated})})]}),i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`trajectory-overview`,"aria-label":n(`trajectoryOverview`),children:d.map((e,t)=>(0,K.jsx)(`button`,{type:`button`,"aria-label":`${n(`trajectory_${e.kind}`)} ${i.length-d.length+t+1}: ${e.title}`,"aria-pressed":e.key===f?.key,onClick:()=>o(e.key),className:`trajectory-point ${e.kind} ${e.outcome??``}`,children:(0,K.jsx)(`span`,{children:i.length-d.length+t+1})},e.key))}),(0,K.jsxs)(`div`,{className:`trajectory-body`,children:[(0,K.jsxs)(`div`,{className:`trajectory-ledger`,children:[u>0&&(0,K.jsx)(`button`,{type:`button`,className:`trajectory-load`,onClick:()=>c(e=>e+50),children:n(`trajectoryEarlier`,{count:u})}),(0,K.jsx)(`ol`,{start:i.length-d.length+1,children:d.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":e.key===f?.key,onClick:()=>o(e.key),className:`trajectory-record ${e.kind}`,children:[(0,K.jsx)(`span`,{className:`trajectory-kind`,children:n(`trajectory_${e.kind}`)}),(0,K.jsx)(`strong`,{children:e.title}),(0,K.jsx)(`span`,{className:`trajectory-preview`,children:(e.input??e.message?.content??e.result?.content??``).slice(0,110)}),e.outcome&&(0,K.jsx)(`span`,{children:n(`trajectory_${e.outcome}`)})]})},e.key))})]}),f&&(0,K.jsxs)(`section`,{className:`trajectory-inspector`,"aria-label":n(`trajectoryDetails`),children:[(0,K.jsx)(`h3`,{children:f.title}),f.timestamp&&(0,K.jsxs)(`p`,{className:`trajectory-metadata`,children:[n(`trajectoryRecordedAt`),`:`,` `,(0,K.jsx)(`time`,{children:f.timestamp})]}),f.callId&&(0,K.jsxs)(`p`,{className:`trajectory-metadata`,children:[`Tool call ID: `,f.callId]}),(h?.truncation||m?.truncation)&&(0,K.jsx)(`p`,{className:`trajectory-warning`,children:n(`trajectoryEvidenceTruncated`)}),f.input!==void 0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h4`,{children:n(`trajectoryArguments`)}),(0,K.jsx)(`pre`,{children:f.input})]}),h&&f.kind!==`call`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h4`,{children:n(`trajectoryRecordedContent`)}),(0,K.jsx)(`pre`,{children:h.content||n(`noOutput`)}),h.parts?.some(e=>e.type===`thinking`)&&(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{children:n(`trajectoryThinking`)}),(0,K.jsx)(`pre`,{children:h.parts.filter(e=>e.type===`thinking`).map(e=>e.text).join(` `)})]},f.key)]}),(f.kind===`call`||f.kind===`result`)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h4`,{children:n(`trajectoryOutput`)}),(0,K.jsx)(`p`,{children:n(`trajectory_${f.outcome??`unknown`}`)}),m?(0,K.jsx)(`pre`,{children:m.content||n(`noOutput`)}):(0,K.jsx)(`p`,{children:n(`trajectoryMissingResult`)}),m?.details!==void 0&&(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{children:n(`trajectoryStructured`)}),(0,K.jsx)(`pre`,{children:JSON.stringify(m.details,null,2)})]})]}),f.kind===`event`&&!h&&(0,K.jsx)(`p`,{children:n(`trajectoryEventOnly`)})]})]})]}):(0,K.jsx)(`p`,{children:n(`trajectoryEmpty`)})]})});function tw({children:e,className:t,"aria-label":n}){return(0,K.jsx)(`figure`,{"aria-label":n,children:(0,K.jsx)(`pre`,{className:t,children:e})})}function nw({call:e,result:t,liveState:n,cwd:r,summaryMeta:i}){let a=(0,w.useContext)(op),o=Op(e,t,n),s=o.resolvedPath??o.path,c=(o.diff??o.output).split(` From ae2e757e52cd745952adea1882cc6df713e97101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=98=89=E4=BC=9F?= <202383014@uibe.edu.cn> Date: Wed, 23 Sep 2026 15:23:50 +0800 Subject: [PATCH 3/5] fix(subagents): retain closed-session diagnostics --- extensions/subagents/src/manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/subagents/src/manager.ts b/extensions/subagents/src/manager.ts index 16a598b7..b16cae11 100644 --- a/extensions/subagents/src/manager.ts +++ b/extensions/subagents/src/manager.ts @@ -764,7 +764,7 @@ const makeManager = (config: SubagentManagerConfig = {}) => if (entry.admissionUncertain) { return new SendError({ message: - "Cannot restart this child because its previous termination is uncertain. End the parent Session before starting more child executions.", + "Cannot restart this child because its session is closed and its previous termination is uncertain. End the parent Session before starting more child executions.", }); } // Restarting a settled subagent occupies a running slot again, so it From fb7bd60934f59452c80a77e47f91d8d368bec8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=98=89=E4=BC=9F?= <202383014@uibe.edu.cn> Date: Thu, 24 Sep 2026 13:48:59 +0800 Subject: [PATCH 4/5] fix(workflows): retain admission on uncertain child cleanup --- extensions/workflows/controller.ts | 15 ++++++++++++++- extensions/workflows/runner.ts | 12 ++++++++++++ tests/extensions/workflows/controller.test.ts | 16 ++++++++++++++++ tests/extensions/workflows/runner.test.ts | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/extensions/workflows/controller.ts b/extensions/workflows/controller.ts index 8e9c5254..d9b23255 100644 --- a/extensions/workflows/controller.ts +++ b/extensions/workflows/controller.ts @@ -16,6 +16,17 @@ function abortError(signal: AbortSignal) { : new Error("Workflow was aborted"); } +function retainsAdmissionLease( + value: unknown, +): value is { retainAdmissionLease: true } { + return ( + typeof value === "object" && + value !== null && + "retainAdmissionLease" in value && + value.retainAdmissionLease === true + ); +} + class Semaphore { private active = 0; private readonly limit: number; @@ -168,6 +179,7 @@ export class RunController { let acquired = false; let admissionLease: ChildExecutionLease | undefined; + let releaseAdmissionLease = true; try { await this.semaphore.acquire(taskAbort.signal); acquired = true; @@ -180,12 +192,13 @@ export class RunController { ); if (taskAbort.signal.aborted) throw abortError(taskAbort.signal); const result = await task(taskAbort.signal); + if (retainsAdmissionLease(result)) releaseAdmissionLease = false; if (invocationSignal?.aborted) throw abortError(invocationSignal); return result; } finally { this.signal.removeEventListener("abort", onRunAbort); invocationSignal?.removeEventListener("abort", onInvocationAbort); - admissionLease?.release(); + if (releaseAdmissionLease) admissionLease?.release(); if (acquired) this.semaphore.release(); } })(); diff --git a/extensions/workflows/runner.ts b/extensions/workflows/runner.ts index 5f4c1cb2..5561bb6f 100644 --- a/extensions/workflows/runner.ts +++ b/extensions/workflows/runner.ts @@ -77,6 +77,8 @@ export interface AgentOutcome { model?: string; contextWindow?: number; transcript: TranscriptEntry[]; + /** Set when child shutdown did not provide trustworthy terminal evidence. */ + retainAdmissionLease?: true; } export interface AgentProgress { @@ -352,6 +354,8 @@ export async function runAgent( }) : undefined; const cleanupError = cleanup?.errors.join("; "); + const retainAdmissionLease = + cleanup !== undefined && (!cleanup.ok || cleanup.timedOut); if (aborted) { return { ok: false, @@ -364,6 +368,7 @@ export async function runAgent( model: options.model?.id, contextWindow: options.model?.contextWindow, transcript: [], + ...(retainAdmissionLease ? { retainAdmissionLease: true } : {}), }; } return { @@ -375,6 +380,7 @@ export async function runAgent( model: options.model?.id, contextWindow: options.model?.contextWindow, transcript: [], + ...(retainAdmissionLease ? { retainAdmissionLease: true } : {}), }; } @@ -551,6 +557,7 @@ export async function runAgent( let output = ""; let transcript: TranscriptEntry[] = []; let cleanupErrors: string[] = []; + let retainAdmissionLease = false; try { // Operator reuse may restore messages before this activation subscribes. // Hydrate both bounded projections once; ordinary progress never rescans it. @@ -600,6 +607,7 @@ export async function runAgent( timeoutMs: options.shutdownTimeoutMs, }); cleanupErrors = cleanup.errors; + retainAdmissionLease = !cleanup.ok || cleanup.timedOut; } const cleanupError = @@ -620,6 +628,7 @@ export async function runAgent( model: modelId, contextWindow, transcript, + ...(retainAdmissionLease ? { retainAdmissionLease: true } : {}), }; } @@ -637,6 +646,7 @@ export async function runAgent( model: modelId, contextWindow, transcript, + ...(retainAdmissionLease ? { retainAdmissionLease: true } : {}), }; } @@ -651,6 +661,7 @@ export async function runAgent( model: modelId, contextWindow, transcript, + ...(retainAdmissionLease ? { retainAdmissionLease: true } : {}), }; } @@ -665,6 +676,7 @@ export async function runAgent( model: modelId, contextWindow, transcript, + ...(retainAdmissionLease ? { retainAdmissionLease: true } : {}), }; } diff --git a/tests/extensions/workflows/controller.test.ts b/tests/extensions/workflows/controller.test.ts index 7c5ddbd8..d3c01297 100644 --- a/tests/extensions/workflows/controller.test.ts +++ b/tests/extensions/workflows/controller.test.ts @@ -51,6 +51,22 @@ test("FAIL: workflow waits for the shared Session slot before creating its child assert.equal(admission.snapshot().held, 0); }); +test("retains the shared Session slot when child cleanup is uncertain", async () => { + const admission = new ChildExecutionAdmission({ maxActive: 1 }); + const controller = new RunController(undefined, 1, 8, admission); + + await controller.schedule(async () => ({ + retainAdmissionLease: true as const, + })); + assert.equal(admission.snapshot().held, 1); + + const queued = controller.schedule(async () => "must remain queued"); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.equal(admission.snapshot().queued, 1); + admission.shutdown(); + await assert.rejects(queued, /parent Session is shutting down/); +}); + test("RunController propagates invocation cancellation without aborting the run", async () => { const controller = new RunController(undefined, 1); const invocation = new AbortController(); diff --git a/tests/extensions/workflows/runner.test.ts b/tests/extensions/workflows/runner.test.ts index 2bdf2854..7314f6e9 100644 --- a/tests/extensions/workflows/runner.test.ts +++ b/tests/extensions/workflows/runner.test.ts @@ -815,6 +815,7 @@ test("cancel during prompt owns the session and returns after bounded disposal", const outcome = await outcomePromise; assert.equal(outcome.ok, false); assert.equal(outcome.aborted, true); + assert.equal(outcome.retainAdmissionLease, true); assert.match(outcome.error ?? "", /aborted.*abort timed out/i); assert.equal(harness.aborts(), 1); assert.equal(harness.disposals(), 1); From a7570b48412fd5ba1b925befea4fe9ab9f8e9765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=98=89=E4=BC=9F?= <202383014@uibe.edu.cn> Date: Thu, 24 Sep 2026 23:56:35 +0800 Subject: [PATCH 5/5] fix(workflows): preserve admission receipt through adapter --- extensions/workflows/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extensions/workflows/index.ts b/extensions/workflows/index.ts index 1a8e1feb..eb4f4995 100644 --- a/extensions/workflows/index.ts +++ b/extensions/workflows/index.ts @@ -215,6 +215,7 @@ import { import { createWorkflowResources, runAgent, + type AgentOutcome, type ThinkingLevel, type WorkflowAgentSessionFactory, type WorkflowModel, @@ -550,6 +551,16 @@ interface ScriptAgentResult { /** Present only for the deprecated model self-attestation compatibility path. */ acceptanceWarning?: string; error?: string; + /** Internal runtime receipt; never persisted or shown to the model. */ + retainAdmissionLease?: true; +} + +function admissionLeaseReceipt( + outcome: Pick, +) { + return outcome.retainAdmissionLease === true + ? ({ retainAdmissionLease: true } as const) + : {}; } interface AgentCallOptions { @@ -2117,6 +2128,7 @@ export default function workflows( ok: false, output: "", error: "Agent completed after workflow settlement", + ...admissionLeaseReceipt(outcome), }; } record.usage = outcome.usage; @@ -2223,6 +2235,7 @@ export default function workflows( ? { acceptanceWarning: judged.acceptanceWarning } : {}), ...(record.error !== undefined ? { error: record.error } : {}), + ...admissionLeaseReceipt(outcome), }; } finally { // Reclaim as this agent settles, not at run end: a pipeline can