diff --git a/AGENTS.md b/AGENTS.md index 4b948d09..b2f2b5ab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,7 @@ UniDesk 是一个以主 server 为统一入口的分布式工作平台;本文 - `bun scripts/cli.ts ssh [ssh-like args...]`:通过 provider-gateway 的 Host SSH / WSL SSH 维护桥打开近似原生 ssh 的交互会话或远端命令,并在远端 PATH 注入 `apply_patch`、`glob` 与 `skill-discover`;`apply-patch`、`py`、`skills`、结构化 `find`、`glob` 和 `argv` 子命令用于避免远端补丁、Python stdin、skill 发现与常用只读命令的嵌套转义问题,使用规则见 `docs/reference/cli.md` 和 `docs/reference/provider-gateway.md`。 - `bun scripts/cli.ts microservice list/status/health/diagnostics/tunnel-self-test/proxy`:管理和验证挂载在主 server、计算节点 Docker 或 k3s 控制面上的用户服务,`proxy` 支持受控 JSON body,OA Event Flow/Todo Note/Baidu Netdisk/Code Queue Manager on main-server、k3s Control/Code Queue 执行面/MDTODO/Decision Center/FindJob/Pipeline/MET Nonlinear on D601 的规则见 `docs/reference/microservices.md`。 - `bun scripts/cli.ts decision upload/list/show/health`:通过 backend-core 用户服务代理上传会议记录/决议 Markdown、列出记录和查看详情;Decision Center 运行在 D601 k3s,规则见 `docs/reference/microservices.md`。 +- `bun scripts/cli.ts decision diary import/list/months/show`:把带日期标题的工作日志 Markdown 拆成 `YYYY-MM/YYYY-MM-DD.md` 日记条目并写入 PostgreSQL,规则见 `docs/reference/microservices.md`。 - `bun scripts/cli.ts deploy check/plan/apply [--file deploy.json|--env dev|prod] [--service ]`:按根目录或固定环境 ref 的服务 repo 和 commit 期望状态校验或更新用户服务;`--env dev` 当前开放 backend-core/frontend/code-queue 开发环境部署,目标侧自行 fetch、构建、部署和 live commit 验证;规则见 `docs/reference/deploy.md`。 - `bun scripts/cli.ts dev-env validate [--manifest path] [--kubectl-dry-run]` / `dev-env prewarm-images`:离线校验 D601 `unidesk-dev` 生产隔离护栏,或把开发底座基础镜像预热到 D601 原生 k3s containerd,规则见 `docs/reference/deploy.md` 与 `docs/reference/microservices.md`。 - `bun scripts/cli.ts ci install/status/run/logs`:在 D601 原生 k3s 上安装和运行 Tekton CI,只做每 commit 检查和 Code Queue 只读性能门禁,不部署 CD;规则见 `docs/reference/ci.md`。 diff --git a/TEST.md b/TEST.md index e80906c7..3a6dd04f 100644 --- a/TEST.md +++ b/TEST.md @@ -113,7 +113,7 @@ ## T23B D601 Decision Center User Service -阅读 `AGENTS.md` 和 `docs/reference/microservices.md`,运行 `bun scripts/cli.ts microservice list`,确认 `decision-center` 显示为 `providerId=D601`、`public=false`、`frontendOnly=true`、仓库 URL `https://github.com/pikasTech/unidesk`、k3s/k8s `k3s://unidesk/decision-center:4277` 逻辑服务映射、`deployment.mode=k3sctl-managed`、`runtime.orchestrator=k3sctl` 且无业务直连容器摘要;使用 `bun scripts/cli.ts deploy apply --service decision-center` 按 `deploy.json` 期望状态部署,确认 job 在 D601 target-side build、导入原生 k3s/containerd、apply `src/components/microservices/k3sctl-adapter/k3s/decision-center.k8s.yaml`、stamp deployment commit、rollout 并通过 UniDesk microservice proxy 验证 live commit。运行 `bun scripts/cli.ts microservice health decision-center`,确认 `service=decision-center`、`storage=postgres`、`schemaReady=true`;准备一份临时 Markdown 会议记录,运行 `bun scripts/cli.ts decision upload --title --type meeting --level G1 --status active --evidence <url>`,再运行 `bun scripts/cli.ts decision list` 和 `bun scripts/cli.ts decision show <id>`,确认 CLI 只通过 backend-core 用户服务代理访问,返回结构化 JSON 且能看到刚上传的记录。最后登录公网 frontend `http://74.48.78.17:18081/`,进入 `用户服务 / Decision Center`,确认页面显示 G0/G1 目标、P0/P1 Blocker、停放事项、最近会议/决议、筛选和全部记录表,刚上传的会议记录可见;页面不得提供聊天/LLM 会话窗口,默认不得裸 JSON,完整 JSON 只能通过 `查看原始JSON` 打开。 +阅读 `AGENTS.md` 和 `docs/reference/microservices.md`,运行 `bun scripts/cli.ts microservice list`,确认 `decision-center` 显示为 `providerId=D601`、`public=false`、`frontendOnly=true`、仓库 URL `https://github.com/pikasTech/unidesk`、k3s/k8s `k3s://unidesk/decision-center:4277` 逻辑服务映射、`deployment.mode=k3sctl-managed`、`runtime.orchestrator=k3sctl` 且无业务直连容器摘要;使用 `bun scripts/cli.ts deploy apply --service decision-center` 按 `deploy.json` 期望状态部署,确认 job 在 D601 target-side build、导入原生 k3s/containerd、apply `src/components/microservices/k3sctl-adapter/k3s/decision-center.k8s.yaml`、stamp deployment commit、rollout 并通过 UniDesk microservice proxy 验证 live commit。运行 `bun scripts/cli.ts microservice health decision-center`,确认 `service=decision-center`、`storage=postgres`、`schemaReady=true` 且 health 中包含 `diaryEntryCount`;准备一份临时 Markdown 会议记录,运行 `bun scripts/cli.ts decision upload <markdown-file> --title <title> --type meeting --level G1 --status active --evidence <url>`,再运行 `bun scripts/cli.ts decision list` 和 `bun scripts/cli.ts decision show <id>`,确认 CLI 只通过 backend-core 用户服务代理访问,返回结构化 JSON 且能看到刚上传的记录。再准备一份包含 `# 2026年5月1日` 和 `# 2026年5月2日` 的临时工作日志 Markdown,运行 `bun scripts/cli.ts decision diary import <markdown-file> --source-file test-work-log.md --tag e2e`、`bun scripts/cli.ts decision diary months`、`bun scripts/cli.ts decision diary list --month 2026-05` 和 `bun scripts/cli.ts decision diary show 2026-05-01`,确认日记按 `YYYY-MM/YYYY-MM-DD.md` 虚拟路径拆分、写入 PostgreSQL 且重复导入幂等。最后登录公网 frontend `http://74.48.78.17:18081/`,进入 `用户服务 / Decision Center`,确认页面显示 G0/G1 目标、P0/P1 Blocker、停放事项、最近会议/决议、筛选、全部记录表和工作日记标签;日记标签可按月筛选并查看单日 Markdown 正文;页面不得提供聊天/LLM 会话窗口,默认不得裸 JSON,完整 JSON 只能通过 `查看原始JSON` 打开。 ## T24 MET Nonlinear D601 GPU User Service diff --git a/docs/reference/cli.md b/docs/reference/cli.md index daac577c..a39bc6a1 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -21,6 +21,7 @@ UniDesk 的统一 CLI 入口是根目录 `scripts/cli.ts`,运行方式固定 - `ssh <providerId> skills [--scope all|wsl|windows] [--limit N]` 发现目标节点上的 WSL/Linux skill 根目录;当 provider 是 WSL 时同一次调用还会扫描 Windows 用户目录下的 `.agents/skills` 与 `.codex/skills`。 - `microservice list/status/health/diagnostics/tunnel-self-test/proxy` 通过 backend-core 内网 API 管理挂载在计算节点 Docker 或 k3s 控制面中的用户服务(底层命令名仍为 microservice);`health`、`diagnostics`、`tunnel-self-test` 和 `proxy` 会走真实 backend-core -> provider-gateway 或 k3sctl-adapter -> 节点服务链路,`proxy` 支持受控 JSON 请求体并对超大响应 body 默认输出有界预览,规则见 `docs/reference/microservices.md`。 - `decision upload/list/show/health` 通过 backend-core 用户服务代理访问 D601 k3s Decision Center,用于上传会议记录/决议 Markdown、列出权威记录、查看详情和健康检查;它不得直连 D601 Service、NodePort 或 provider-gateway 业务 HTTP。 +- `decision diary import <markdown-file>` 将带 `# YYYY年M月D日`、`# YYYY-MM-DD` 或 `# YYYY/M/D` 标题的工作日志拆成每天一篇 Markdown 日记,按 `YYYY-MM/YYYY-MM-DD.md` 虚拟路径写入 Decision Center PostgreSQL;`decision diary list/months/show` 分别用于按月/日期查询、列出月份和查看单日正文。 - `deploy check/plan/apply` 默认从根目录 `deploy.json` 读取服务 repo 与 commit 期望状态,join `config.json` 和现有 manifest 后使用 target-side build 单一路径校验或更新直管服务与 k3s 代管服务;`deploy plan --env dev|prod` 只从固定 Git ref 读取 manifest 并输出 dry-run 环境计划,不使用本地 dirty worktree;`deploy apply --env dev --service backend-core|frontend|code-queue` 可按 `origin/deploy/dev:deploy.json` 部署当前 D601 dev slice,`--env prod` apply 仍禁用;规则见 `docs/reference/deploy.md`。 - `dev-env validate [--manifest path] [--kubectl-dry-run]` 离线校验 D601 `unidesk-dev` namespace、dev PostgreSQL 底座和 dev workload manifest。默认检查 `src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-foundation.k8s.yaml`;也可显式校验 `src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-core.k8s.yaml` 或 `src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-code-queue.k8s.yaml`。所有 namespaced 对象必须只落到 `unidesk-dev`,foundation manifest 必须包含 `postgres-dev` StatefulSet/Service、dev secret/config、迁移 Job 和 DB URL guard,core manifest 必须包含 `backend-core-dev`/`frontend-dev` Deployment/Service,Code Queue dev manifest 必须包含 `code-queue-scheduler-dev`、`code-queue-read-dev`、`code-queue-write-dev` 和 dev provider egress proxy。加 `--kubectl-dry-run` 时额外执行 `kubectl apply --dry-run=client --validate=false -f <manifest>`,仍不 apply 资源。 - `dev-env prewarm-images [--image image] [--provider-id D601] [--no-pull] [--proxy-url URL] [--pull-timeout-ms N] [--dry-run]` 创建异步 job,通过 UniDesk SSH 维护桥在 D601 上把开发底座依赖镜像从 Docker 缓存导入原生 k3s containerd。默认镜像是 `postgres:16-alpine` 和 `rancher/mirrored-library-busybox:1.36.1`,用于避免 `postgres-dev` 与 local-path helper pod 卡在外部 registry 拉取。该命令固定验证 `/etc/rancher/k3s/k3s.yaml` 指向的 native k3s 上下文,并输出 `dev_env_containerd_image_ready=...` 作为成功判据;它不 apply manifest、不修改生产 `unidesk` namespace。 @@ -121,7 +122,7 @@ bun scripts/cli.ts ssh D601 glob --root /home/ubuntu/pikapython --pattern '**/*- `--main-server-ip` 是一个全局前缀,必须放在需要透传的命令同一次调用中,例如 `bun scripts/cli.ts --main-server-ip 74.48.78.17 debug health`。默认传输是公网 frontend:本地 CLI 读取本仓库 `config.json` 中的 frontend 登录账号密码,登录 `http://<ip>:<frontendPort>/` 获取 HttpOnly session cookie,然后通过 frontend 的 `/api/*` 同源代理访问 backend-core 内网 API;因此计算节点只需要能访问公网 frontend,不需要主 server SSH key,也不需要打开 backend-core REST API 或 PostgreSQL 端口。 -默认 frontend 传输支持 `debug health`、`debug dispatch`、`debug task`、`microservice list/status/health/diagnostics/tunnel-self-test/proxy`、`decision upload/list/show/health`、`codex task <taskId>`、`codex output <taskId>`、`codex judge <taskId> --attempt N` 和 `ssh <PROVIDER_ID> <remote-command>`。其中 `ssh` 的 remote frontend 传输使用 `host.ssh` dispatch 执行有界远端命令,适合 `ssh D601 hostname` 和 `ssh D601 skills` 这类自测;交互式登录 shell 仍应在主 server 本机 CLI 使用,或显式切换到旧 SSH 传输后在主 server 上执行。frontend 远程透传不会流式转发本地 stdin,因此 `ssh py < script.py`、`ssh apply-patch < patch.diff` 这类 stdin-backed helper 必须在主 server 本机运行,或显式切换到 `--main-server-transport ssh`。若确实需要旧行为,可使用 `--main-server-key <key>` 或 `--main-server-transport ssh`,这时 CLI 会通过 SSH 登录主 server 的 `--main-server-root` 目录执行同一个 `bun scripts/cli.ts <command>`。 +默认 frontend 传输支持 `debug health`、`debug dispatch`、`debug task`、`microservice list/status/health/diagnostics/tunnel-self-test/proxy`、`decision upload/list/show/health`、`decision diary import/list/months/show`、`codex task <taskId>`、`codex output <taskId>`、`codex judge <taskId> --attempt N` 和 `ssh <PROVIDER_ID> <remote-command>`。其中 `ssh` 的 remote frontend 传输使用 `host.ssh` dispatch 执行有界远端命令,适合 `ssh D601 hostname` 和 `ssh D601 skills` 这类自测;交互式登录 shell 仍应在主 server 本机 CLI 使用,或显式切换到旧 SSH 传输后在主 server 上执行。frontend 远程透传不会流式转发本地 stdin,因此 `ssh py < script.py`、`ssh apply-patch < patch.diff` 这类 stdin-backed helper 必须在主 server 本机运行,或显式切换到 `--main-server-transport ssh`。若确实需要旧行为,可使用 `--main-server-key <key>` 或 `--main-server-transport ssh`,这时 CLI 会通过 SSH 登录主 server 的 `--main-server-root` 目录执行同一个 `bun scripts/cli.ts <command>`。 计算节点可以用该入口测试自身的远程升级闭环,而不需要在计算节点公开 core REST API 或 database。标准顺序是:先运行 `bun scripts/cli.ts --main-server-ip 74.48.78.17 debug health` 确认主 server 看到当前 Provider 在线,且该 Provider labels 中 `unideskCapabilities` 包含 `host.ssh`、`hostSshConfigured=true`、`hostSshKeyPresent=true`;再运行 `bun scripts/cli.ts --main-server-ip 74.48.78.17 debug dispatch <PROVIDER_ID> provider.upgrade --mode schedule --wait-ms 15000` 触发真实 `provider.upgrade`;随后再次运行 `debug health` 确认节点重新上线;最后运行 `bun scripts/cli.ts --main-server-ip 74.48.78.17 debug dispatch <PROVIDER_ID> host.ssh --wait-ms 15000` 和 `bun scripts/cli.ts --main-server-ip 74.48.78.17 ssh <PROVIDER_ID> hostname` 验证 SSH 透传能力。provider-gateway 新部署或升级后没有完成这组 remote CLI 自测,不能视为交付完成。 diff --git a/docs/reference/microservices.md b/docs/reference/microservices.md index 710fb3ba..5527b8ba 100644 --- a/docs/reference/microservices.md +++ b/docs/reference/microservices.md @@ -227,15 +227,16 @@ D601 上必须显式使用原生 k3s kubeconfig:`KUBECONFIG=/etc/rancher/k3s/k ### Decision Center k3s-Managed -当前 Decision Center 作为 `id=decision-center` 的 `k3sctl-managed` 用户服务登记在 `config.json`,用于沉淀 Codex/人工会议后的会议记录、决议、目标、问题分级、停放事项和证据。它只负责权威记录和展示,不承载通用聊天、LLM 会话窗口或自动参谋对话。 +当前 Decision Center 作为 `id=decision-center` 的 `k3sctl-managed` 用户服务登记在 `config.json`,用于沉淀 Codex/人工会议后的会议记录、决议、目标、问题分级、停放事项、证据和按天工作日记。它只负责权威记录、Markdown 日记和展示,不承载通用聊天、LLM 会话窗口或自动参谋对话。 - Orchestrator:`deployment.mode=k3sctl-managed`,`deployment.adapterServiceId=k3sctl-adapter`,`deployment.k3sServiceId=decision-center`,`backend.proxyMode=k3sctl-adapter-http`,`backend.nodeBaseUrl=k3s://decision-center`;正式链路只能是 `frontend/CLI -> backend-core -> k3sctl-adapter -> Kubernetes API service proxy -> Kubernetes Service decision-center:4277`。 - 部署引用:后端源码位于 UniDesk 仓库 `src/components/microservices/decision-center`,Dockerfile 为 `src/components/microservices/decision-center/Dockerfile`;k3s manifest 为 `src/components/microservices/k3sctl-adapter/k3s/decision-center.k3s.json`,Kubernetes 运行清单为 `src/components/microservices/k3sctl-adapter/k3s/decision-center.k8s.yaml`,镜像名固定为 `unidesk-decision-center:d601`。主 server `docker-compose.yml` 不得加入该服务,也不得公开 `4277`。 -- 状态权威:Decision Center 必须写入主 PostgreSQL,当前表为 `decision_center_records`;不得使用浏览器 `localStorage`、IndexedDB、容器 writable layer 或本地 JSON 文件作为会议、决议、目标或问题状态权威。D601 Pod 通过集群内 `d601-tcp-egress-gateway.unidesk.svc.cluster.local:15432` 访问主 PostgreSQL。 -- 数据模型:第一版记录类型为 `meeting|decision|goal|blocker|debt|experiment`,等级为 `G0|G1|G2|G3|P0|P1|P2|P3|none`,状态为 `active|blocked|parked|done`,字段包含 `title`、Markdown `summary/body`、`linkedGoalId`、`tags`、`evidenceLinks`、`sourceSession`、`taskId`、`commitId`、`createdAt` 和 `updatedAt`。 -- API:只允许 `/health`、`/live`、`/logs` 和 `/api/` 前缀;允许 `GET`、`HEAD`、`POST`、`PUT` 和 `DELETE`。业务 API 包含 `GET /api/records`、`POST /api/records`、`GET|PUT|DELETE /api/records/:id` 和 `POST /api/meetings/import`,错误必须返回结构化 JSON,便于 CLI 与 frontend 诊断。 -- CLI:`bun scripts/cli.ts decision upload <markdown-file>`、`decision list`、`decision show <id>` 和 `decision health` 只能通过 backend-core 用户服务代理访问 Decision Center,不得直连 D601 Service、NodePort 或 provider-gateway `microservice.http`。 -- UniDesk 前端:`用户服务 / Decision Center` React 页面只展示高密度记录、筛选、当前 G0/G1 目标、P0/P1 blocker、停放事项和最近会议/决议;默认不得展示裸 JSON,完整原始数据只能通过 `查看原始JSON` 打开。 +- 状态权威:Decision Center 必须写入主 PostgreSQL,权威记录表为 `decision_center_records`,日记表为 `decision_center_diary_entries`;不得使用浏览器 `localStorage`、IndexedDB、容器 writable layer 或本地 JSON 文件作为会议、决议、目标、问题或日记状态权威。D601 Pod 通过集群内 `d601-tcp-egress-gateway.unidesk.svc.cluster.local:15432` 访问主 PostgreSQL。 +- 记录数据模型:记录类型为 `meeting|decision|goal|blocker|debt|experiment`,等级为 `G0|G1|G2|G3|P0|P1|P2|P3|none`,状态为 `active|blocked|parked|done`,字段包含 `title`、Markdown `summary/body`、`linkedGoalId`、`tags`、`evidenceLinks`、`sourceSession`、`taskId`、`commitId`、`createdAt` 和 `updatedAt`。 +- 日记数据模型:基于 Markdown 的日记系统以“每天一篇”为最小单元,导入器识别 `# YYYY年M月D日`、`# YYYY-MM-DD` 或 `# YYYY/M/D` 标题并拆分为 `entry_date`、`month`、Markdown `body`、`source_file`、`content_hash` 与虚拟 `markdown_path=YYYY-MM/YYYY-MM-DD.md`;同一 `source_file + entry_date` 使用 upsert,内容未变时保持幂等。 +- API:只允许 `/health`、`/live`、`/logs` 和 `/api/` 前缀;允许 `GET`、`HEAD`、`POST`、`PUT` 和 `DELETE`。业务 API 包含 `GET /api/records`、`POST /api/records`、`GET|PUT|DELETE /api/records/:id`、`POST /api/meetings/import`、`POST /api/diary/import`、`GET /api/diary/entries`、`GET /api/diary/entries/:idOrDate` 和 `GET /api/diary/months`,错误必须返回结构化 JSON,便于 CLI 与 frontend 诊断。 +- CLI:`bun scripts/cli.ts decision upload <markdown-file>`、`decision list`、`decision show <id>`、`decision diary import/list/months/show` 和 `decision health` 只能通过 backend-core 用户服务代理访问 Decision Center,不得直连 D601 Service、NodePort 或 provider-gateway `microservice.http`。 +- UniDesk 前端:`用户服务 / Decision Center` React 页面展示权威记录筛选、当前 G0/G1 目标、P0/P1 blocker、停放事项、最近会议/决议和工作日记;日记视图按月份筛选并展示每天 Markdown 正文。默认不得展示裸 JSON,完整原始数据只能通过 `查看原始JSON` 打开。 ### MDTODO k3s-Managed @@ -256,7 +257,7 @@ D601 上必须显式使用原生 k3s kubeconfig:`KUBECONFIG=/etc/rancher/k3s/k - `pipeline`:Pipeline v2 控制与观测服务,UniDesk frontend 渲染组件矩阵、React Flow 控制图、epoch 甘特图、运行材料索引和 node 精细控制面板。 - `met-nonlinear`:MET Nonlinear 训练编排服务,UniDesk frontend 渲染 GPU/镜像、训练队列、Project config 预览、训练进度、ETA 和历史记录。 - `claudeqq`:ClaudeQQ 纯后端 QQ 消息网关,UniDesk frontend 渲染 NapCat 连接、事件订阅、消息推送、最近 QQ 事件和发送记录。 -- `decision-center`:Decision Center 决策权威记录服务,D601 k3s 代管,状态写入主 PostgreSQL,UniDesk frontend 渲染记录筛选、目标、blocker、停放事项和会议/决议。 +- `decision-center`:Decision Center 决策权威记录和 Markdown 日记服务,D601 k3s 代管,状态写入主 PostgreSQL,UniDesk frontend 渲染记录筛选、目标、blocker、停放事项、会议/决议和按月工作日记。 ### D601 Docker/k3s Restart Recovery diff --git a/scripts/cli.ts b/scripts/cli.ts index dcdea905..7266bcd5 100644 --- a/scripts/cli.ts +++ b/scripts/cli.ts @@ -52,6 +52,10 @@ function help(): unknown { { command: "microservice diagnostics <id>", description: "Split k3sctl-managed proxy health into provider-gateway, HTTP tunnel, adapter, Kubernetes API service proxy, and target Service checks." }, { command: "microservice tunnel-self-test <id>", description: "Trigger an expected provider HTTP tunnel failure and verify requestId/stage diagnostics are returned." }, { command: "decision upload <markdown-file> [--title text] [--type meeting|decision] [--level G0|G1|G2|G3|P0|P1|P2|P3|none] [--status active|blocked|parked|done] [--linked-goal-id id] [--evidence url]", description: "Upload a meeting note or decision record through backend-core -> decision-center user-service proxy." }, + { command: "decision diary import <markdown-file> [--source-file path] [--tag tag] [--include-entries]", description: "Import a dated work log Markdown into PostgreSQL diary entries split as YYYY-MM/YYYY-MM-DD.md." }, + { command: "decision diary list [--month YYYY-MM] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--limit N] [--include-body]", description: "List daily Markdown diary entries stored by Decision Center." }, + { command: "decision diary months", description: "List available Decision Center diary months with day counts." }, + { command: "decision diary show <YYYY-MM-DD|id>", description: "Show one daily diary Markdown entry." }, { command: "decision list [--type ...] [--status ...] [--level ...] [--linked-goal-id id] [--limit N]", description: "List Decision Center records through the user-service proxy." }, { command: "decision show <id>", description: "Show one Decision Center record." }, { command: "deploy check|plan|apply [--file deploy.json|--env dev|prod] [--service id] [--dry-run] [--force]", description: "Reconcile services from a repo+commit manifest; --env reads fixed environment refs and can apply supported dev services." }, diff --git a/scripts/src/decision-center.ts b/scripts/src/decision-center.ts index 74767cdf..49065bbc 100644 --- a/scripts/src/decision-center.ts +++ b/scripts/src/decision-center.ts @@ -74,7 +74,7 @@ function readMarkdownFile(path: string): { absolutePath: string; markdown: strin const absolutePath = resolve(repoRoot, path); const markdown = readFileSync(absolutePath, "utf8"); if (markdown.trim().length === 0) throw new Error(`markdown file is empty: ${absolutePath}`); - if (markdown.length > 1_000_000) throw new Error(`markdown file is too large: ${absolutePath}`); + if (markdown.length > 4_500_000) throw new Error(`markdown file is too large: ${absolutePath}`); return { absolutePath, markdown }; } @@ -143,6 +143,64 @@ async function uploadMeetingAsync(args: string[], fetcher: (path: string, init?: return { file: absolutePath, result: unwrapProxyResponse(await decisionProxyAsync(fetcher, endpoint, { method: "POST", body })) }; } +function summarizeDiaryImportResult(result: unknown, includeEntries: boolean): unknown { + const body = typeof result === "object" && result !== null && !Array.isArray(result) ? result as Record<string, unknown> : {}; + const entries = Array.isArray(body.entries) ? body.entries : []; + const summaryEntries = entries.map((item) => { + const record = typeof item === "object" && item !== null && !Array.isArray(item) ? item as Record<string, unknown> : {}; + return { + id: record.id, + date: record.date, + month: record.month, + title: record.title, + markdownPath: record.markdownPath, + summary: record.summary, + sourceFile: record.sourceFile, + updatedAt: record.updatedAt, + }; + }); + return { + ...body, + entries: includeEntries ? summaryEntries : summaryEntries.slice(0, 20), + entriesOmitted: includeEntries ? 0 : Math.max(0, summaryEntries.length - 20), + outputPolicy: includeEntries + ? { bounded: false, entries: summaryEntries.length } + : { bounded: true, entriesShown: Math.min(summaryEntries.length, 20), fullCommand: "Re-run with --include-entries to show every imported day summary." }, + }; +} + +function diaryImportPayload(args: string[]): { absolutePath: string; payload: Record<string, unknown> } { + const file = positionalArgs(args)[0]; + if (!file) throw new Error("decision diary import requires markdown file"); + const { absolutePath, markdown } = readMarkdownFile(file); + return { + absolutePath, + payload: { + markdown, + sourceFile: optionValue(args, ["--source-file", "--source-path", "--source"]) ?? absolutePath, + tags: splitList(optionValues(args, ["--tag", "--tags"])), + }, + }; +} + +function importDiary(args: string[]): unknown { + const { absolutePath, payload } = diaryImportPayload(args); + const result = unwrapProxyResponse(decisionProxy("/api/diary/import", { method: "POST", body: payload })); + const body = typeof result === "object" && result !== null && !Array.isArray(result) && "body" in result + ? (result as { body?: unknown }).body + : result; + return { file: absolutePath, result: { ...(typeof result === "object" && result !== null && !Array.isArray(result) && "upstream" in result ? { upstream: (result as { upstream?: unknown }).upstream } : {}), body: summarizeDiaryImportResult(body, args.includes("--include-entries")) } }; +} + +async function importDiaryAsync(args: string[], fetcher: (path: string, init?: { method?: string; body?: unknown }) => Promise<unknown>): Promise<unknown> { + const { absolutePath, payload } = diaryImportPayload(args); + const result = unwrapProxyResponse(await decisionProxyAsync(fetcher, "/api/diary/import", { method: "POST", body: payload })); + const body = typeof result === "object" && result !== null && !Array.isArray(result) && "body" in result + ? (result as { body?: unknown }).body + : result; + return { file: absolutePath, result: { ...(typeof result === "object" && result !== null && !Array.isArray(result) && "upstream" in result ? { upstream: (result as { upstream?: unknown }).upstream } : {}), body: summarizeDiaryImportResult(body, args.includes("--include-entries")) } }; +} + function listRecords(args: string[]): unknown { const params = new URLSearchParams(); const type = optionValue(args, ["--type"]); @@ -175,6 +233,49 @@ async function listRecordsAsync(args: string[], fetcher: (path: string, init?: { return unwrapProxyResponse(await decisionProxyAsync(fetcher, `/api/records${query ? `?${query}` : ""}`)); } +function diaryQuery(args: string[]): string { + const params = new URLSearchParams(); + const month = optionValue(args, ["--month"]); + const from = optionValue(args, ["--from"]); + const to = optionValue(args, ["--to"]); + const sourceFile = optionValue(args, ["--source-file", "--source-path", "--source"]); + const limit = optionValue(args, ["--limit"]); + if (month !== undefined) params.set("month", month); + if (from !== undefined) params.set("from", from); + if (to !== undefined) params.set("to", to); + if (sourceFile !== undefined) params.set("sourceFile", sourceFile); + if (limit !== undefined) params.set("limit", limit); + if (args.includes("--include-body")) params.set("includeBody", "true"); + const query = params.toString(); + return query ? `?${query}` : ""; +} + +function listDiary(args: string[]): unknown { + return unwrapProxyResponse(decisionProxy(`/api/diary/entries${diaryQuery(args)}`)); +} + +async function listDiaryAsync(args: string[], fetcher: (path: string, init?: { method?: string; body?: unknown }) => Promise<unknown>): Promise<unknown> { + return unwrapProxyResponse(await decisionProxyAsync(fetcher, `/api/diary/entries${diaryQuery(args)}`)); +} + +function listDiaryMonths(): unknown { + return unwrapProxyResponse(decisionProxy("/api/diary/months")); +} + +async function listDiaryMonthsAsync(fetcher: (path: string, init?: { method?: string; body?: unknown }) => Promise<unknown>): Promise<unknown> { + return unwrapProxyResponse(await decisionProxyAsync(fetcher, "/api/diary/months")); +} + +function showDiary(key: string | undefined): unknown { + if (!key) throw new Error("decision diary show requires entry id or YYYY-MM-DD date"); + return unwrapProxyResponse(decisionProxy(`/api/diary/entries/${encodeURIComponent(key)}`)); +} + +async function showDiaryAsync(key: string | undefined, fetcher: (path: string, init?: { method?: string; body?: unknown }) => Promise<unknown>): Promise<unknown> { + if (!key) throw new Error("decision diary show requires entry id or YYYY-MM-DD date"); + return unwrapProxyResponse(await decisionProxyAsync(fetcher, `/api/diary/entries/${encodeURIComponent(key)}`)); +} + function showRecord(id: string | undefined): unknown { if (!id) throw new Error("decision show requires record id"); return unwrapProxyResponse(decisionProxy(`/api/records/${encodeURIComponent(id)}`)); @@ -187,6 +288,14 @@ async function showRecordAsync(id: string | undefined, fetcher: (path: string, i export async function runDecisionCenterCommand(_config: UniDeskConfig, args: string[]): Promise<unknown> { const [action = "list", id] = args; + if (action === "diary") { + const [diaryAction = "list", diaryId] = args.slice(1); + if (diaryAction === "import") return importDiary(args.slice(2)); + if (diaryAction === "list") return listDiary(args.slice(2)); + if (diaryAction === "months") return listDiaryMonths(); + if (diaryAction === "show") return showDiary(diaryId); + throw new Error("decision diary command must be one of: import, list, months, show"); + } if (action === "upload") return uploadMeeting(args.slice(1)); if (action === "list") return listRecords(args.slice(1)); if (action === "show") return showRecord(id); @@ -200,6 +309,14 @@ export async function runDecisionCenterCommandAsync( fetcher: (path: string, init?: { method?: string; body?: unknown }) => Promise<unknown>, ): Promise<unknown> { const [action = "list", id] = args; + if (action === "diary") { + const [diaryAction = "list", diaryId] = args.slice(1); + if (diaryAction === "import") return importDiaryAsync(args.slice(2), fetcher); + if (diaryAction === "list") return listDiaryAsync(args.slice(2), fetcher); + if (diaryAction === "months") return listDiaryMonthsAsync(fetcher); + if (diaryAction === "show") return showDiaryAsync(diaryId, fetcher); + throw new Error("decision diary command must be one of: import, list, months, show"); + } if (action === "upload") return uploadMeetingAsync(args.slice(1), fetcher); if (action === "list") return listRecordsAsync(args.slice(1), fetcher); if (action === "show") return showRecordAsync(id, fetcher); diff --git a/src/components/frontend/public/app.js b/src/components/frontend/public/app.js index 0c1a7dbe..ab2aa4d4 100644 --- a/src/components/frontend/public/app.js +++ b/src/components/frontend/public/app.js @@ -1,44 +1,45 @@ -(()=>{var eT=Object.create;var{getPrototypeOf:uK,defineProperty:s7,getOwnPropertyNames:lK}=Object;var fK=Object.prototype.hasOwnProperty;function rK(u){return this[u]}var nK,iK,Cu=(u,l,f)=>{var r=u!=null&&typeof u==="object";if(r){var n=l?nK??=new WeakMap:iK??=new WeakMap,i=n.get(u);if(i)return i}f=u!=null?eT(uK(u)):{};let t=l||!u||!u.__esModule?s7(f,"default",{value:u,enumerable:!0}):f;for(let y of lK(u))if(!fK.call(t,y))s7(t,y,{get:rK.bind(u,y),enumerable:!0});if(r)n.set(u,t);return t};var tr=(u,l)=>()=>(l||u((l={exports:{}}).exports,l),l.exports);var fl=((u)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(l,f)=>(typeof require<"u"?require:l)[f]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});var yj=tr((du)=>{var xy=Symbol.for("react.element"),tK=Symbol.for("react.portal"),yK=Symbol.for("react.fragment"),cK=Symbol.for("react.strict_mode"),_K=Symbol.for("react.profiler"),$K=Symbol.for("react.provider"),AK=Symbol.for("react.context"),jK=Symbol.for("react.forward_ref"),FK=Symbol.for("react.suspense"),UK=Symbol.for("react.memo"),JK=Symbol.for("react.lazy"),a7=Symbol.iterator;function QK(u){if(u===null||typeof u!=="object")return null;return u=a7&&u[a7]||u["@@iterator"],typeof u==="function"?u:null}var e7={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},uj=Object.assign,lj={};function jt(u,l,f){this.props=u,this.context=l,this.refs=lj,this.updater=f||e7}jt.prototype.isReactComponent={};jt.prototype.setState=function(u,l){if(typeof u!=="object"&&typeof u!=="function"&&u!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,u,l,"setState")};jt.prototype.forceUpdate=function(u){this.updater.enqueueForceUpdate(this,u,"forceUpdate")};function fj(){}fj.prototype=jt.prototype;function U6(u,l,f){this.props=u,this.context=l,this.refs=lj,this.updater=f||e7}var J6=U6.prototype=new fj;J6.constructor=U6;uj(J6,jt.prototype);J6.isPureReactComponent=!0;var o7=Array.isArray,rj=Object.prototype.hasOwnProperty,Q6={current:null},nj={key:!0,ref:!0,__self:!0,__source:!0};function ij(u,l,f){var r,n={},i=null,t=null;if(l!=null)for(r in l.ref!==void 0&&(t=l.ref),l.key!==void 0&&(i=""+l.key),l)rj.call(l,r)&&!nj.hasOwnProperty(r)&&(n[r]=l[r]);var y=arguments.length-2;if(y===1)n.children=f;else if(1<y){for(var c=Array(y),$=0;$<y;$++)c[$]=arguments[$+2];n.children=c}if(u&&u.defaultProps)for(r in y=u.defaultProps,y)n[r]===void 0&&(n[r]=y[r]);return{$$typeof:xy,type:u,key:i,ref:t,props:n,_owner:Q6.current}}function NK(u,l){return{$$typeof:xy,type:u.type,key:l,ref:u.ref,props:u.props,_owner:u._owner}}function N6(u){return typeof u==="object"&&u!==null&&u.$$typeof===xy}function qK(u){var l={"=":"=0",":":"=2"};return"$"+u.replace(/[=:]/g,function(f){return l[f]})}var d7=/\/+/g;function F6(u,l){return typeof u==="object"&&u!==null&&u.key!=null?qK(""+u.key):l.toString(36)}function q_(u,l,f,r,n){var i=typeof u;if(i==="undefined"||i==="boolean")u=null;var t=!1;if(u===null)t=!0;else switch(i){case"string":case"number":t=!0;break;case"object":switch(u.$$typeof){case xy:case tK:t=!0}}if(t)return t=u,n=n(t),u=r===""?"."+F6(t,0):r,o7(n)?(f="",u!=null&&(f=u.replace(d7,"$&/")+"/"),q_(n,l,f,"",function($){return $})):n!=null&&(N6(n)&&(n=NK(n,f+(!n.key||t&&t.key===n.key?"":(""+n.key).replace(d7,"$&/")+"/")+u)),l.push(n)),1;if(t=0,r=r===""?".":r+":",o7(u))for(var y=0;y<u.length;y++){i=u[y];var c=r+F6(i,y);t+=q_(i,l,f,c,n)}else if(c=QK(u),typeof c==="function")for(u=c.call(u),y=0;!(i=u.next()).done;)i=i.value,c=r+F6(i,y++),t+=q_(i,l,f,c,n);else if(i==="object")throw l=String(u),Error("Objects are not valid as a React child (found: "+(l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)+"). If you meant to render a collection of children, use an array instead.");return t}function N_(u,l,f){if(u==null)return u;var r=[],n=0;return q_(u,r,"","",function(i){return l.call(f,i,n++)}),r}function wK(u){if(u._status===-1){var l=u._result;l=l(),l.then(function(f){if(u._status===0||u._status===-1)u._status=1,u._result=f},function(f){if(u._status===0||u._status===-1)u._status=2,u._result=f}),u._status===-1&&(u._status=0,u._result=l)}if(u._status===1)return u._result.default;throw u._result}var mf={current:null},w_={transition:null},WK={ReactCurrentDispatcher:mf,ReactCurrentBatchConfig:w_,ReactCurrentOwner:Q6};function tj(){throw Error("act(...) is not supported in production builds of React.")}du.Children={map:N_,forEach:function(u,l,f){N_(u,function(){l.apply(this,arguments)},f)},count:function(u){var l=0;return N_(u,function(){l++}),l},toArray:function(u){return N_(u,function(l){return l})||[]},only:function(u){if(!N6(u))throw Error("React.Children.only expected to receive a single React element child.");return u}};du.Component=jt;du.Fragment=yK;du.Profiler=_K;du.PureComponent=U6;du.StrictMode=cK;du.Suspense=FK;du.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=WK;du.act=tj;du.cloneElement=function(u,l,f){if(u===null||u===void 0)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+u+".");var r=uj({},u.props),n=u.key,i=u.ref,t=u._owner;if(l!=null){if(l.ref!==void 0&&(i=l.ref,t=Q6.current),l.key!==void 0&&(n=""+l.key),u.type&&u.type.defaultProps)var y=u.type.defaultProps;for(c in l)rj.call(l,c)&&!nj.hasOwnProperty(c)&&(r[c]=l[c]===void 0&&y!==void 0?y[c]:l[c])}var c=arguments.length-2;if(c===1)r.children=f;else if(1<c){y=Array(c);for(var $=0;$<c;$++)y[$]=arguments[$+2];r.children=y}return{$$typeof:xy,type:u.type,key:n,ref:i,props:r,_owner:t}};du.createContext=function(u){return u={$$typeof:AK,_currentValue:u,_currentValue2:u,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},u.Provider={$$typeof:$K,_context:u},u.Consumer=u};du.createElement=ij;du.createFactory=function(u){var l=ij.bind(null,u);return l.type=u,l};du.createRef=function(){return{current:null}};du.forwardRef=function(u){return{$$typeof:jK,render:u}};du.isValidElement=N6;du.lazy=function(u){return{$$typeof:JK,_payload:{_status:-1,_result:u},_init:wK}};du.memo=function(u,l){return{$$typeof:UK,type:u,compare:l===void 0?null:l}};du.startTransition=function(u){var l=w_.transition;w_.transition={};try{u()}finally{w_.transition=l}};du.unstable_act=tj;du.useCallback=function(u,l){return mf.current.useCallback(u,l)};du.useContext=function(u){return mf.current.useContext(u)};du.useDebugValue=function(){};du.useDeferredValue=function(u){return mf.current.useDeferredValue(u)};du.useEffect=function(u,l){return mf.current.useEffect(u,l)};du.useId=function(){return mf.current.useId()};du.useImperativeHandle=function(u,l,f){return mf.current.useImperativeHandle(u,l,f)};du.useInsertionEffect=function(u,l){return mf.current.useInsertionEffect(u,l)};du.useLayoutEffect=function(u,l){return mf.current.useLayoutEffect(u,l)};du.useMemo=function(u,l){return mf.current.useMemo(u,l)};du.useReducer=function(u,l,f){return mf.current.useReducer(u,l,f)};du.useRef=function(u){return mf.current.useRef(u)};du.useState=function(u){return mf.current.useState(u)};du.useSyncExternalStore=function(u,l,f){return mf.current.useSyncExternalStore(u,l,f)};du.useTransition=function(){return mf.current.useTransition()};du.version="18.3.1"});var Jl=tr((dY,cj)=>{cj.exports=yj()});var qj=tr((wl)=>{function L6(u,l){var f=u.length;u.push(l);u:for(;0<f;){var r=f-1>>>1,n=u[r];if(0<L_(n,l))u[r]=l,u[f]=n,f=r;else break u}}function Mr(u){return u.length===0?null:u[0]}function z_(u){if(u.length===0)return null;var l=u[0],f=u.pop();if(f!==l){u[0]=f;u:for(var r=0,n=u.length,i=n>>>1;r<i;){var t=2*(r+1)-1,y=u[t],c=t+1,$=u[c];if(0>L_(y,f))c<n&&0>L_($,y)?(u[r]=$,u[c]=f,r=c):(u[r]=y,u[t]=f,r=t);else if(c<n&&0>L_($,f))u[r]=$,u[c]=f,r=c;else break u}}return l}function L_(u,l){var f=u.sortIndex-l.sortIndex;return f!==0?f:u.id-l.id}if(typeof performance==="object"&&typeof performance.now==="function")T6=performance,wl.unstable_now=function(){return T6.now()};else T_=Date,K6=T_.now(),wl.unstable_now=function(){return T_.now()-K6};var T6,T_,K6,tn=[],i0=[],GK=1,Tr=null,wf=3,E_=!1,Ai=!1,by=!1,Fj=typeof setTimeout==="function"?setTimeout:null,Uj=typeof clearTimeout==="function"?clearTimeout:null,jj=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G6(u){for(var l=Mr(i0);l!==null;){if(l.callback===null)z_(i0);else if(l.startTime<=u)z_(i0),l.sortIndex=l.expirationTime,L6(tn,l);else break;l=Mr(i0)}}function E6(u){if(by=!1,G6(u),!Ai)if(Mr(tn)!==null)Ai=!0,Z6(O6);else{var l=Mr(i0);l!==null&&H6(E6,l.startTime-u)}}function O6(u,l){Ai=!1,by&&(by=!1,Uj(vy),vy=-1),E_=!0;var f=wf;try{G6(l);for(Tr=Mr(tn);Tr!==null&&(!(Tr.expirationTime>l)||u&&!Nj());){var r=Tr.callback;if(typeof r==="function"){Tr.callback=null,wf=Tr.priorityLevel;var n=r(Tr.expirationTime<=l);l=wl.unstable_now(),typeof n==="function"?Tr.callback=n:Tr===Mr(tn)&&z_(tn),G6(l)}else z_(tn);Tr=Mr(tn)}if(Tr!==null)var i=!0;else{var t=Mr(i0);t!==null&&H6(E6,t.startTime-l),i=!1}return i}finally{Tr=null,wf=f,E_=!1}}var O_=!1,K_=null,vy=-1,Jj=5,Qj=-1;function Nj(){return wl.unstable_now()-Qj<Jj?!1:!0}function W6(){if(K_!==null){var u=wl.unstable_now();Qj=u;var l=!0;try{l=K_(!0,u)}finally{l?hy():(O_=!1,K_=null)}}else O_=!1}var hy;if(typeof jj==="function")hy=function(){jj(W6)};else if(typeof MessageChannel<"u")G_=new MessageChannel,z6=G_.port2,G_.port1.onmessage=W6,hy=function(){z6.postMessage(null)};else hy=function(){Fj(W6,0)};var G_,z6;function Z6(u){K_=u,O_||(O_=!0,hy())}function H6(u,l){vy=Fj(function(){u(wl.unstable_now())},l)}wl.unstable_IdlePriority=5;wl.unstable_ImmediatePriority=1;wl.unstable_LowPriority=4;wl.unstable_NormalPriority=3;wl.unstable_Profiling=null;wl.unstable_UserBlockingPriority=2;wl.unstable_cancelCallback=function(u){u.callback=null};wl.unstable_continueExecution=function(){Ai||E_||(Ai=!0,Z6(O6))};wl.unstable_forceFrameRate=function(u){0>u||125<u?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Jj=0<u?Math.floor(1000/u):5};wl.unstable_getCurrentPriorityLevel=function(){return wf};wl.unstable_getFirstCallbackNode=function(){return Mr(tn)};wl.unstable_next=function(u){switch(wf){case 1:case 2:case 3:var l=3;break;default:l=wf}var f=wf;wf=l;try{return u()}finally{wf=f}};wl.unstable_pauseExecution=function(){};wl.unstable_requestPaint=function(){};wl.unstable_runWithPriority=function(u,l){switch(u){case 1:case 2:case 3:case 4:case 5:break;default:u=3}var f=wf;wf=u;try{return l()}finally{wf=f}};wl.unstable_scheduleCallback=function(u,l,f){var r=wl.unstable_now();switch(typeof f==="object"&&f!==null?(f=f.delay,f=typeof f==="number"&&0<f?r+f:r):f=r,u){case 1:var n=-1;break;case 2:n=250;break;case 5:n=1073741823;break;case 4:n=1e4;break;default:n=5000}return n=f+n,u={id:GK++,callback:l,priorityLevel:u,startTime:f,expirationTime:n,sortIndex:-1},f>r?(u.sortIndex=f,L6(i0,u),Mr(tn)===null&&u===Mr(i0)&&(by?(Uj(vy),vy=-1):by=!0,H6(E6,f-r))):(u.sortIndex=n,L6(tn,u),Ai||E_||(Ai=!0,Z6(O6))),u};wl.unstable_shouldYield=Nj;wl.unstable_wrapCallback=function(u){var l=wf;return function(){var f=wf;wf=l;try{return u.apply(this,arguments)}finally{wf=f}}}});var Wj=tr((lP,wj)=>{wj.exports=qj()});var TJ=tr((jr)=>{var zK=Jl(),$r=Wj();function Ju(u){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+u,f=1;f<arguments.length;f++)l+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+u+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var zF=new Set,Q1={};function zi(u,l){Dt(u,l),Dt(u+"Capture",l)}function Dt(u,l){Q1[u]=l;for(u=0;u<l.length;u++)zF.add(l[u])}var Dn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),o6=Object.prototype.hasOwnProperty,EK=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Lj={},Tj={};function OK(u){if(o6.call(Tj,u))return!0;if(o6.call(Lj,u))return!1;if(EK.test(u))return Tj[u]=!0;return Lj[u]=!0,!1}function ZK(u,l,f,r){if(f!==null&&f.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":if(r)return!1;if(f!==null)return!f.acceptsBooleans;return u=u.toLowerCase().slice(0,5),u!=="data-"&&u!=="aria-";default:return!1}}function HK(u,l,f,r){if(l===null||typeof l>"u"||ZK(u,l,f,r))return!0;if(r)return!1;if(f!==null)switch(f.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function Sf(u,l,f,r,n,i,t){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=r,this.attributeNamespace=n,this.mustUseProperty=f,this.propertyName=u,this.type=l,this.sanitizeURL=i,this.removeEmptyString=t}var Uf={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(u){Uf[u]=new Sf(u,0,!1,u,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(u){var l=u[0];Uf[l]=new Sf(l,1,!1,u[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(u){Uf[u]=new Sf(u,2,!1,u.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(u){Uf[u]=new Sf(u,2,!1,u,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(u){Uf[u]=new Sf(u,3,!1,u.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(u){Uf[u]=new Sf(u,3,!0,u,null,!1,!1)});["capture","download"].forEach(function(u){Uf[u]=new Sf(u,4,!1,u,null,!1,!1)});["cols","rows","size","span"].forEach(function(u){Uf[u]=new Sf(u,6,!1,u,null,!1,!1)});["rowSpan","start"].forEach(function(u){Uf[u]=new Sf(u,5,!1,u.toLowerCase(),null,!1,!1)});var v8=/[\-:]([a-z])/g;function k8(u){return u[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(u){var l=u.replace(v8,k8);Uf[l]=new Sf(l,1,!1,u,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(u){var l=u.replace(v8,k8);Uf[l]=new Sf(l,1,!1,u,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(u){var l=u.replace(v8,k8);Uf[l]=new Sf(l,1,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(u){Uf[u]=new Sf(u,1,!1,u.toLowerCase(),null,!1,!1)});Uf.xlinkHref=new Sf("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(u){Uf[u]=new Sf(u,1,!1,u.toLowerCase(),null,!0,!0)});function I8(u,l,f,r){var n=Uf.hasOwnProperty(l)?Uf[l]:null;if(n!==null?n.type!==0:r||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")HK(l,f,n,r)&&(f=null),r||n===null?OK(l)&&(f===null?u.removeAttribute(l):u.setAttribute(l,""+f)):n.mustUseProperty?u[n.propertyName]=f===null?n.type===3?!1:"":f:(l=n.attributeName,r=n.attributeNamespace,f===null?u.removeAttribute(l):(n=n.type,f=n===3||n===4&&f===!0?"":""+f,r?u.setAttributeNS(r,l,f):u.setAttribute(l,f)))}var Yn=zK.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Z_=Symbol.for("react.element"),Jt=Symbol.for("react.portal"),Qt=Symbol.for("react.fragment"),g8=Symbol.for("react.strict_mode"),d6=Symbol.for("react.profiler"),EF=Symbol.for("react.provider"),OF=Symbol.for("react.context"),s8=Symbol.for("react.forward_ref"),e6=Symbol.for("react.suspense"),u8=Symbol.for("react.suspense_list"),a8=Symbol.for("react.memo"),y0=Symbol.for("react.lazy"),ZF=Symbol.for("react.offscreen"),Kj=Symbol.iterator;function ky(u){if(u===null||typeof u!=="object")return null;return u=Kj&&u[Kj]||u["@@iterator"],typeof u==="function"?u:null}var Vl=Object.assign,B6;function ey(u){if(B6===void 0)try{throw Error()}catch(f){var l=f.stack.trim().match(/\n( *(at )?)/);B6=l&&l[1]||""}return` -`+B6+u}var V6=!1;function m6(u,l){if(!u||V6)return"";V6=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch($){var r=$}Reflect.construct(u,[],l)}else{try{l.call()}catch($){r=$}u.call(l.prototype)}else{try{throw Error()}catch($){r=$}u()}}catch($){if($&&r&&typeof $.stack==="string"){for(var n=$.stack.split(` -`),i=r.stack.split(` +(()=>{var GT=Object.create;var{getPrototypeOf:TT,defineProperty:j7,getOwnPropertyNames:mT}=Object;var KT=Object.prototype.hasOwnProperty;function zT(l){return this[l]}var ET,OT,Rl=(l,u,r)=>{var f=l!=null&&typeof l==="object";if(f){var n=u?ET??=new WeakMap:OT??=new WeakMap,i=n.get(l);if(i)return i}r=l!=null?GT(TT(l)):{};let t=u||!l||!l.__esModule?j7(r,"default",{value:l,enumerable:!0}):r;for(let y of mT(l))if(!KT.call(t,y))j7(t,y,{get:zT.bind(l,y),enumerable:!0});if(f)n.set(l,t);return t};var cf=(l,u)=>()=>(u||l((u={exports:{}}).exports,u),u.exports);var tu=((l)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(u,r)=>(typeof require<"u"?require:u)[r]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});var m7=cf((el)=>{var Iy=Symbol.for("react.element"),ZT=Symbol.for("react.portal"),pT=Symbol.for("react.fragment"),HT=Symbol.for("react.strict_mode"),BT=Symbol.for("react.profiler"),DT=Symbol.for("react.provider"),VT=Symbol.for("react.context"),ST=Symbol.for("react.forward_ref"),XT=Symbol.for("react.suspense"),YT=Symbol.for("react.memo"),PT=Symbol.for("react.lazy"),F7=Symbol.iterator;function CT(l){if(l===null||typeof l!=="object")return null;return l=F7&&l[F7]||l["@@iterator"],typeof l==="function"?l:null}var N7={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Q7=Object.assign,w7={};function Qt(l,u,r){this.props=l,this.context=u,this.refs=w7,this.updater=r||N7}Qt.prototype.isReactComponent={};Qt.prototype.setState=function(l,u){if(typeof l!=="object"&&typeof l!=="function"&&l!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,l,u,"setState")};Qt.prototype.forceUpdate=function(l){this.updater.enqueueForceUpdate(this,l,"forceUpdate")};function q7(){}q7.prototype=Qt.prototype;function O6(l,u,r){this.props=l,this.context=u,this.refs=w7,this.updater=r||N7}var Z6=O6.prototype=new q7;Z6.constructor=O6;Q7(Z6,Qt.prototype);Z6.isPureReactComponent=!0;var J7=Array.isArray,W7=Object.prototype.hasOwnProperty,p6={current:null},L7={key:!0,ref:!0,__self:!0,__source:!0};function G7(l,u,r){var f,n={},i=null,t=null;if(u!=null)for(f in u.ref!==void 0&&(t=u.ref),u.key!==void 0&&(i=""+u.key),u)W7.call(u,f)&&!L7.hasOwnProperty(f)&&(n[f]=u[f]);var y=arguments.length-2;if(y===1)n.children=r;else if(1<y){for(var c=Array(y),$=0;$<y;$++)c[$]=arguments[$+2];n.children=c}if(l&&l.defaultProps)for(f in y=l.defaultProps,y)n[f]===void 0&&(n[f]=y[f]);return{$$typeof:Iy,type:l,key:i,ref:t,props:n,_owner:p6.current}}function MT(l,u){return{$$typeof:Iy,type:l.type,key:u,ref:l.ref,props:l.props,_owner:l._owner}}function H6(l){return typeof l==="object"&&l!==null&&l.$$typeof===Iy}function hT(l){var u={"=":"=0",":":"=2"};return"$"+l.replace(/[=:]/g,function(r){return u[r]})}var U7=/\/+/g;function E6(l,u){return typeof l==="object"&&l!==null&&l.key!=null?hT(""+l.key):u.toString(36)}function E_(l,u,r,f,n){var i=typeof l;if(i==="undefined"||i==="boolean")l=null;var t=!1;if(l===null)t=!0;else switch(i){case"string":case"number":t=!0;break;case"object":switch(l.$$typeof){case Iy:case ZT:t=!0}}if(t)return t=l,n=n(t),l=f===""?"."+E6(t,0):f,J7(n)?(r="",l!=null&&(r=l.replace(U7,"$&/")+"/"),E_(n,u,r,"",function($){return $})):n!=null&&(H6(n)&&(n=MT(n,r+(!n.key||t&&t.key===n.key?"":(""+n.key).replace(U7,"$&/")+"/")+l)),u.push(n)),1;if(t=0,f=f===""?".":f+":",J7(l))for(var y=0;y<l.length;y++){i=l[y];var c=f+E6(i,y);t+=E_(i,u,r,c,n)}else if(c=CT(l),typeof c==="function")for(l=c.call(l),y=0;!(i=l.next()).done;)i=i.value,c=f+E6(i,y++),t+=E_(i,u,r,c,n);else if(i==="object")throw u=String(l),Error("Objects are not valid as a React child (found: "+(u==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":u)+"). If you meant to render a collection of children, use an array instead.");return t}function z_(l,u,r){if(l==null)return l;var f=[],n=0;return E_(l,f,"","",function(i){return u.call(r,i,n++)}),f}function RT(l){if(l._status===-1){var u=l._result;u=u(),u.then(function(r){if(l._status===0||l._status===-1)l._status=1,l._result=r},function(r){if(l._status===0||l._status===-1)l._status=2,l._result=r}),l._status===-1&&(l._status=0,l._result=u)}if(l._status===1)return l._result.default;throw l._result}var Br={current:null},O_={transition:null},xT={ReactCurrentDispatcher:Br,ReactCurrentBatchConfig:O_,ReactCurrentOwner:p6};function T7(){throw Error("act(...) is not supported in production builds of React.")}el.Children={map:z_,forEach:function(l,u,r){z_(l,function(){u.apply(this,arguments)},r)},count:function(l){var u=0;return z_(l,function(){u++}),u},toArray:function(l){return z_(l,function(u){return u})||[]},only:function(l){if(!H6(l))throw Error("React.Children.only expected to receive a single React element child.");return l}};el.Component=Qt;el.Fragment=pT;el.Profiler=BT;el.PureComponent=O6;el.StrictMode=HT;el.Suspense=XT;el.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xT;el.act=T7;el.cloneElement=function(l,u,r){if(l===null||l===void 0)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+l+".");var f=Q7({},l.props),n=l.key,i=l.ref,t=l._owner;if(u!=null){if(u.ref!==void 0&&(i=u.ref,t=p6.current),u.key!==void 0&&(n=""+u.key),l.type&&l.type.defaultProps)var y=l.type.defaultProps;for(c in u)W7.call(u,c)&&!L7.hasOwnProperty(c)&&(f[c]=u[c]===void 0&&y!==void 0?y[c]:u[c])}var c=arguments.length-2;if(c===1)f.children=r;else if(1<c){y=Array(c);for(var $=0;$<c;$++)y[$]=arguments[$+2];f.children=y}return{$$typeof:Iy,type:l.type,key:n,ref:i,props:f,_owner:t}};el.createContext=function(l){return l={$$typeof:VT,_currentValue:l,_currentValue2:l,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},l.Provider={$$typeof:DT,_context:l},l.Consumer=l};el.createElement=G7;el.createFactory=function(l){var u=G7.bind(null,l);return u.type=l,u};el.createRef=function(){return{current:null}};el.forwardRef=function(l){return{$$typeof:ST,render:l}};el.isValidElement=H6;el.lazy=function(l){return{$$typeof:PT,_payload:{_status:-1,_result:l},_init:RT}};el.memo=function(l,u){return{$$typeof:YT,type:l,compare:u===void 0?null:u}};el.startTransition=function(l){var u=O_.transition;O_.transition={};try{l()}finally{O_.transition=u}};el.unstable_act=T7;el.useCallback=function(l,u){return Br.current.useCallback(l,u)};el.useContext=function(l){return Br.current.useContext(l)};el.useDebugValue=function(){};el.useDeferredValue=function(l){return Br.current.useDeferredValue(l)};el.useEffect=function(l,u){return Br.current.useEffect(l,u)};el.useId=function(){return Br.current.useId()};el.useImperativeHandle=function(l,u,r){return Br.current.useImperativeHandle(l,u,r)};el.useInsertionEffect=function(l,u){return Br.current.useInsertionEffect(l,u)};el.useLayoutEffect=function(l,u){return Br.current.useLayoutEffect(l,u)};el.useMemo=function(l,u){return Br.current.useMemo(l,u)};el.useReducer=function(l,u,r){return Br.current.useReducer(l,u,r)};el.useRef=function(l){return Br.current.useRef(l)};el.useState=function(l){return Br.current.useState(l)};el.useSyncExternalStore=function(l,u,r){return Br.current.useSyncExternalStore(l,u,r)};el.useTransition=function(){return Br.current.useTransition()};el.version="18.3.1"});var Ju=cf((BP,K7)=>{K7.exports=m7()});var S7=cf((Wu)=>{function S6(l,u){var r=l.length;l.push(u);l:for(;0<r;){var f=r-1>>>1,n=l[f];if(0<p_(n,u))l[f]=u,l[r]=n,r=f;else break l}}function hf(l){return l.length===0?null:l[0]}function V_(l){if(l.length===0)return null;var u=l[0],r=l.pop();if(r!==u){l[0]=r;l:for(var f=0,n=l.length,i=n>>>1;f<i;){var t=2*(f+1)-1,y=l[t],c=t+1,$=l[c];if(0>p_(y,r))c<n&&0>p_($,y)?(l[f]=$,l[c]=r,f=c):(l[f]=y,l[t]=r,f=t);else if(c<n&&0>p_($,r))l[f]=$,l[c]=r,f=c;else break l}}return u}function p_(l,u){var r=l.sortIndex-u.sortIndex;return r!==0?r:l.id-u.id}if(typeof performance==="object"&&typeof performance.now==="function")X6=performance,Wu.unstable_now=function(){return X6.now()};else H_=Date,Y6=H_.now(),Wu.unstable_now=function(){return H_.now()-Y6};var X6,H_,Y6,cn=[],Ai=[],kT=1,mf=null,Wr=3,S_=!1,J0=!1,oy=!1,p7=typeof setTimeout==="function"?setTimeout:null,H7=typeof clearTimeout==="function"?clearTimeout:null,Z7=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P6(l){for(var u=hf(Ai);u!==null;){if(u.callback===null)V_(Ai);else if(u.startTime<=l)V_(Ai),u.sortIndex=u.expirationTime,S6(cn,u);else break;u=hf(Ai)}}function M6(l){if(oy=!1,P6(l),!J0)if(hf(cn)!==null)J0=!0,R6(h6);else{var u=hf(Ai);u!==null&&x6(M6,u.startTime-l)}}function h6(l,u){J0=!1,oy&&(oy=!1,H7(dy),dy=-1),S_=!0;var r=Wr;try{P6(u);for(mf=hf(cn);mf!==null&&(!(mf.expirationTime>u)||l&&!V7());){var f=mf.callback;if(typeof f==="function"){mf.callback=null,Wr=mf.priorityLevel;var n=f(mf.expirationTime<=u);u=Wu.unstable_now(),typeof n==="function"?mf.callback=n:mf===hf(cn)&&V_(cn),P6(u)}else V_(cn);mf=hf(cn)}if(mf!==null)var i=!0;else{var t=hf(Ai);t!==null&&x6(M6,t.startTime-u),i=!1}return i}finally{mf=null,Wr=r,S_=!1}}var X_=!1,B_=null,dy=-1,B7=5,D7=-1;function V7(){return Wu.unstable_now()-D7<B7?!1:!0}function V6(){if(B_!==null){var l=Wu.unstable_now();D7=l;var u=!0;try{u=B_(!0,l)}finally{u?ay():(X_=!1,B_=null)}}else X_=!1}var ay;if(typeof Z7==="function")ay=function(){Z7(V6)};else if(typeof MessageChannel<"u")D_=new MessageChannel,C6=D_.port2,D_.port1.onmessage=V6,ay=function(){C6.postMessage(null)};else ay=function(){p7(V6,0)};var D_,C6;function R6(l){B_=l,X_||(X_=!0,ay())}function x6(l,u){dy=p7(function(){l(Wu.unstable_now())},u)}Wu.unstable_IdlePriority=5;Wu.unstable_ImmediatePriority=1;Wu.unstable_LowPriority=4;Wu.unstable_NormalPriority=3;Wu.unstable_Profiling=null;Wu.unstable_UserBlockingPriority=2;Wu.unstable_cancelCallback=function(l){l.callback=null};Wu.unstable_continueExecution=function(){J0||S_||(J0=!0,R6(h6))};Wu.unstable_forceFrameRate=function(l){0>l||125<l?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B7=0<l?Math.floor(1000/l):5};Wu.unstable_getCurrentPriorityLevel=function(){return Wr};Wu.unstable_getFirstCallbackNode=function(){return hf(cn)};Wu.unstable_next=function(l){switch(Wr){case 1:case 2:case 3:var u=3;break;default:u=Wr}var r=Wr;Wr=u;try{return l()}finally{Wr=r}};Wu.unstable_pauseExecution=function(){};Wu.unstable_requestPaint=function(){};Wu.unstable_runWithPriority=function(l,u){switch(l){case 1:case 2:case 3:case 4:case 5:break;default:l=3}var r=Wr;Wr=l;try{return u()}finally{Wr=r}};Wu.unstable_scheduleCallback=function(l,u,r){var f=Wu.unstable_now();switch(typeof r==="object"&&r!==null?(r=r.delay,r=typeof r==="number"&&0<r?f+r:f):r=f,l){case 1:var n=-1;break;case 2:n=250;break;case 5:n=1073741823;break;case 4:n=1e4;break;default:n=5000}return n=r+n,l={id:kT++,callback:u,priorityLevel:l,startTime:r,expirationTime:n,sortIndex:-1},r>f?(l.sortIndex=r,S6(Ai,l),hf(cn)===null&&l===hf(Ai)&&(oy?(H7(dy),dy=-1):oy=!0,x6(M6,r-f))):(l.sortIndex=n,S6(cn,l),J0||S_||(J0=!0,R6(h6))),l};Wu.unstable_shouldYield=V7;Wu.unstable_wrapCallback=function(l){var u=Wr;return function(){var r=Wr;Wr=u;try{return l.apply(this,arguments)}finally{Wr=r}}}});var Y7=cf((SP,X7)=>{X7.exports=S7()});var CU=cf((Jf)=>{var gT=Ju(),jf=Y7();function Ul(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,r=1;r<arguments.length;r++)u+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var RF=new Set,T1={};function O0(l,u){Pt(l,u),Pt(l+"Capture",u)}function Pt(l,u){T1[l]=u;for(l=0;l<u.length;l++)RF.add(u[l])}var Pn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),A8=Object.prototype.hasOwnProperty,IT=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,P7={},C7={};function aT(l){if(A8.call(C7,l))return!0;if(A8.call(P7,l))return!1;if(IT.test(l))return C7[l]=!0;return P7[l]=!0,!1}function oT(l,u,r,f){if(r!==null&&r.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":if(f)return!1;if(r!==null)return!r.acceptsBooleans;return l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-";default:return!1}}function dT(l,u,r,f){if(u===null||typeof u>"u"||oT(l,u,r,f))return!0;if(f)return!1;if(r!==null)switch(r.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function Sr(l,u,r,f,n,i,t){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=f,this.attributeNamespace=n,this.mustUseProperty=r,this.propertyName=l,this.type=u,this.sanitizeURL=i,this.removeEmptyString=t}var Jr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){Jr[l]=new Sr(l,0,!1,l,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var u=l[0];Jr[u]=new Sr(u,1,!1,l[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(l){Jr[l]=new Sr(l,2,!1,l.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){Jr[l]=new Sr(l,2,!1,l,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){Jr[l]=new Sr(l,3,!1,l.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(l){Jr[l]=new Sr(l,3,!0,l,null,!1,!1)});["capture","download"].forEach(function(l){Jr[l]=new Sr(l,4,!1,l,null,!1,!1)});["cols","rows","size","span"].forEach(function(l){Jr[l]=new Sr(l,6,!1,l,null,!1,!1)});["rowSpan","start"].forEach(function(l){Jr[l]=new Sr(l,5,!1,l.toLowerCase(),null,!1,!1)});var i4=/[\-:]([a-z])/g;function t4(l){return l[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(l){var u=l.replace(i4,t4);Jr[u]=new Sr(u,1,!1,l,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var u=l.replace(i4,t4);Jr[u]=new Sr(u,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(l){var u=l.replace(i4,t4);Jr[u]=new Sr(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(l){Jr[l]=new Sr(l,1,!1,l.toLowerCase(),null,!1,!1)});Jr.xlinkHref=new Sr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(l){Jr[l]=new Sr(l,1,!1,l.toLowerCase(),null,!0,!0)});function y4(l,u,r,f){var n=Jr.hasOwnProperty(u)?Jr[u]:null;if(n!==null?n.type!==0:f||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")dT(u,r,n,f)&&(r=null),f||n===null?aT(u)&&(r===null?l.removeAttribute(u):l.setAttribute(u,""+r)):n.mustUseProperty?l[n.propertyName]=r===null?n.type===3?!1:"":r:(u=n.attributeName,f=n.attributeNamespace,r===null?l.removeAttribute(u):(n=n.type,r=n===3||n===4&&r===!0?"":""+r,f?l.setAttributeNS(f,u,r):l.setAttribute(u,r)))}var Rn=gT.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y_=Symbol.for("react.element"),Wt=Symbol.for("react.portal"),Lt=Symbol.for("react.fragment"),c4=Symbol.for("react.strict_mode"),j8=Symbol.for("react.profiler"),xF=Symbol.for("react.provider"),bF=Symbol.for("react.context"),_4=Symbol.for("react.forward_ref"),F8=Symbol.for("react.suspense"),J8=Symbol.for("react.suspense_list"),$4=Symbol.for("react.memo"),Fi=Symbol.for("react.lazy"),vF=Symbol.for("react.offscreen"),M7=Symbol.iterator;function ey(l){if(l===null||typeof l!=="object")return null;return l=M7&&l[M7]||l["@@iterator"],typeof l==="function"?l:null}var Bu=Object.assign,b6;function t1(l){if(b6===void 0)try{throw Error()}catch(r){var u=r.stack.trim().match(/\n( *(at )?)/);b6=u&&u[1]||""}return` +`+b6+l}var v6=!1;function s6(l,u){if(!l||v6)return"";v6=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch($){var f=$}Reflect.construct(l,[],u)}else{try{u.call()}catch($){f=$}l.call(u.prototype)}else{try{throw Error()}catch($){f=$}l()}}catch($){if($&&f&&typeof $.stack==="string"){for(var n=$.stack.split(` +`),i=f.stack.split(` `),t=n.length-1,y=i.length-1;1<=t&&0<=y&&n[t]!==i[y];)y--;for(;1<=t&&0<=y;t--,y--)if(n[t]!==i[y]){if(t!==1||y!==1)do if(t--,y--,0>y||n[t]!==i[y]){var c=` -`+n[t].replace(" at new "," at ");return u.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",u.displayName)),c}while(1<=t&&0<=y);break}}}finally{V6=!1,Error.prepareStackTrace=f}return(u=u?u.displayName||u.name:"")?ey(u):""}function BK(u){switch(u.tag){case 5:return ey(u.type);case 16:return ey("Lazy");case 13:return ey("Suspense");case 19:return ey("SuspenseList");case 0:case 2:case 15:return u=m6(u.type,!1),u;case 11:return u=m6(u.type.render,!1),u;case 1:return u=m6(u.type,!0),u;default:return""}}function l8(u){if(u==null)return null;if(typeof u==="function")return u.displayName||u.name||null;if(typeof u==="string")return u;switch(u){case Qt:return"Fragment";case Jt:return"Portal";case d6:return"Profiler";case g8:return"StrictMode";case e6:return"Suspense";case u8:return"SuspenseList"}if(typeof u==="object")switch(u.$$typeof){case OF:return(u.displayName||"Context")+".Consumer";case EF:return(u._context.displayName||"Context")+".Provider";case s8:var l=u.render;return u=u.displayName,u||(u=l.displayName||l.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case a8:return l=u.displayName||null,l!==null?l:l8(u.type)||"Memo";case y0:l=u._payload,u=u._init;try{return l8(u(l))}catch(f){}}return null}function VK(u){var l=u.type;switch(u.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=l.render,u=u.displayName||u.name||"",l.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return l8(l);case 8:return l===g8?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l==="function")return l.displayName||l.name||null;if(typeof l==="string")return l}return null}function L0(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function HF(u){var l=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function mK(u){var l=HF(u)?"checked":"value",f=Object.getOwnPropertyDescriptor(u.constructor.prototype,l),r=""+u[l];if(!u.hasOwnProperty(l)&&typeof f<"u"&&typeof f.get==="function"&&typeof f.set==="function"){var{get:n,set:i}=f;return Object.defineProperty(u,l,{configurable:!0,get:function(){return n.call(this)},set:function(t){r=""+t,i.call(this,t)}}),Object.defineProperty(u,l,{enumerable:f.enumerable}),{getValue:function(){return r},setValue:function(t){r=""+t},stopTracking:function(){u._valueTracker=null,delete u[l]}}}}function H_(u){u._valueTracker||(u._valueTracker=mK(u))}function BF(u){if(!u)return!1;var l=u._valueTracker;if(!l)return!0;var f=l.getValue(),r="";return u&&(r=HF(u)?u.checked?"true":"false":u.value),u=r,u!==f?(l.setValue(u),!0):!1}function u$(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch(l){return u.body}}function f8(u,l){var f=l.checked;return Vl({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f!=null?f:u._wrapperState.initialChecked})}function Gj(u,l){var f=l.defaultValue==null?"":l.defaultValue,r=l.checked!=null?l.checked:l.defaultChecked;f=L0(l.value!=null?l.value:f),u._wrapperState={initialChecked:r,initialValue:f,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function VF(u,l){l=l.checked,l!=null&&I8(u,"checked",l,!1)}function r8(u,l){VF(u,l);var f=L0(l.value),r=l.type;if(f!=null)if(r==="number"){if(f===0&&u.value===""||u.value!=f)u.value=""+f}else u.value!==""+f&&(u.value=""+f);else if(r==="submit"||r==="reset"){u.removeAttribute("value");return}l.hasOwnProperty("value")?n8(u,l.type,f):l.hasOwnProperty("defaultValue")&&n8(u,l.type,L0(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(u.defaultChecked=!!l.defaultChecked)}function zj(u,l,f){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var r=l.type;if(!(r!=="submit"&&r!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+u._wrapperState.initialValue,f||l===u.value||(u.value=l),u.defaultValue=l}f=u.name,f!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,f!==""&&(u.name=f)}function n8(u,l,f){if(l!=="number"||u$(u.ownerDocument)!==u)f==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+f&&(u.defaultValue=""+f)}var u1=Array.isArray;function Ot(u,l,f,r){if(u=u.options,l){l={};for(var n=0;n<f.length;n++)l["$"+f[n]]=!0;for(f=0;f<u.length;f++)n=l.hasOwnProperty("$"+u[f].value),u[f].selected!==n&&(u[f].selected=n),n&&r&&(u[f].defaultSelected=!0)}else{f=""+L0(f),l=null;for(n=0;n<u.length;n++){if(u[n].value===f){u[n].selected=!0,r&&(u[n].defaultSelected=!0);return}l!==null||u[n].disabled||(l=u[n])}l!==null&&(l.selected=!0)}}function i8(u,l){if(l.dangerouslySetInnerHTML!=null)throw Error(Ju(91));return Vl({},l,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function Ej(u,l){var f=l.value;if(f==null){if(f=l.children,l=l.defaultValue,f!=null){if(l!=null)throw Error(Ju(92));if(u1(f)){if(1<f.length)throw Error(Ju(93));f=f[0]}l=f}l==null&&(l=""),f=l}u._wrapperState={initialValue:L0(f)}}function mF(u,l){var f=L0(l.value),r=L0(l.defaultValue);f!=null&&(f=""+f,f!==u.value&&(u.value=f),l.defaultValue==null&&u.defaultValue!==f&&(u.defaultValue=f)),r!=null&&(u.defaultValue=""+r)}function Oj(u){var l=u.textContent;l===u._wrapperState.initialValue&&l!==""&&l!==null&&(u.value=l)}function DF(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function t8(u,l){return u==null||u==="http://www.w3.org/1999/xhtml"?DF(l):u==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var B_,pF=function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,f,r,n){MSApp.execUnsafeLocalFunction(function(){return u(l,f,r,n)})}:u}(function(u,l){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=l;else{B_=B_||document.createElement("div"),B_.innerHTML="<svg>"+l.valueOf().toString()+"</svg>";for(l=B_.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;l.firstChild;)u.appendChild(l.firstChild)}});function N1(u,l){if(l){var f=u.firstChild;if(f&&f===u.lastChild&&f.nodeType===3){f.nodeValue=l;return}}u.textContent=l}var y1={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},DK=["Webkit","ms","Moz","O"];Object.keys(y1).forEach(function(u){DK.forEach(function(l){l=l+u.charAt(0).toUpperCase()+u.substring(1),y1[l]=y1[u]})});function SF(u,l,f){return l==null||typeof l==="boolean"||l===""?"":f||typeof l!=="number"||l===0||y1.hasOwnProperty(u)&&y1[u]?(""+l).trim():l+"px"}function XF(u,l){u=u.style;for(var f in l)if(l.hasOwnProperty(f)){var r=f.indexOf("--")===0,n=SF(f,l[f],r);f==="float"&&(f="cssFloat"),r?u.setProperty(f,n):u[f]=n}}var pK=Vl({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function y8(u,l){if(l){if(pK[u]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(Ju(137,u));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(Ju(60));if(typeof l.dangerouslySetInnerHTML!=="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(Ju(61))}if(l.style!=null&&typeof l.style!=="object")throw Error(Ju(62))}}function c8(u,l){if(u.indexOf("-")===-1)return typeof l.is==="string";switch(u){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var _8=null;function o8(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var $8=null,Zt=null,Ht=null;function Zj(u){if(u=S1(u)){if(typeof $8!=="function")throw Error(Ju(280));var l=u.stateNode;l&&(l=Z$(l),$8(u.stateNode,u.type,l))}}function YF(u){Zt?Ht?Ht.push(u):Ht=[u]:Zt=u}function PF(){if(Zt){var u=Zt,l=Ht;if(Ht=Zt=null,Zj(u),l)for(u=0;u<l.length;u++)Zj(l[u])}}function CF(u,l){return u(l)}function MF(){}var D6=!1;function RF(u,l,f){if(D6)return u(l,f);D6=!0;try{return CF(u,l,f)}finally{if(D6=!1,Zt!==null||Ht!==null)MF(),PF()}}function q1(u,l){var f=u.stateNode;if(f===null)return null;var r=Z$(f);if(r===null)return null;f=r[l];u:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(u=u.type,r=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!r;break u;default:u=!1}if(u)return null;if(f&&typeof f!=="function")throw Error(Ju(231,l,typeof f));return f}var A8=!1;if(Dn)try{ji={},Object.defineProperty(ji,"passive",{get:function(){A8=!0}}),window.addEventListener("test",ji,ji),window.removeEventListener("test",ji,ji)}catch(u){A8=!1}var ji;function SK(u,l,f,r,n,i,t,y,c){var $=Array.prototype.slice.call(arguments,3);try{l.apply(f,$)}catch(A){this.onError(A)}}var c1=!1,l$=null,f$=!1,j8=null,XK={onError:function(u){c1=!0,l$=u}};function YK(u,l,f,r,n,i,t,y,c){c1=!1,l$=null,SK.apply(XK,arguments)}function PK(u,l,f,r,n,i,t,y,c){if(YK.apply(this,arguments),c1){if(c1){var $=l$;c1=!1,l$=null}else throw Error(Ju(198));f$||(f$=!0,j8=$)}}function Ei(u){var l=u,f=u;if(u.alternate)for(;l.return;)l=l.return;else{u=l;do l=u,(l.flags&4098)!==0&&(f=l.return),u=l.return;while(u)}return l.tag===3?f:null}function xF(u){if(u.tag===13){var l=u.memoizedState;if(l===null&&(u=u.alternate,u!==null&&(l=u.memoizedState)),l!==null)return l.dehydrated}return null}function Hj(u){if(Ei(u)!==u)throw Error(Ju(188))}function CK(u){var l=u.alternate;if(!l){if(l=Ei(u),l===null)throw Error(Ju(188));return l!==u?null:u}for(var f=u,r=l;;){var n=f.return;if(n===null)break;var i=n.alternate;if(i===null){if(r=n.return,r!==null){f=r;continue}break}if(n.child===i.child){for(i=n.child;i;){if(i===f)return Hj(n),u;if(i===r)return Hj(n),l;i=i.sibling}throw Error(Ju(188))}if(f.return!==r.return)f=n,r=i;else{for(var t=!1,y=n.child;y;){if(y===f){t=!0,f=n,r=i;break}if(y===r){t=!0,r=n,f=i;break}y=y.sibling}if(!t){for(y=i.child;y;){if(y===f){t=!0,f=i,r=n;break}if(y===r){t=!0,r=i,f=n;break}y=y.sibling}if(!t)throw Error(Ju(189))}}if(f.alternate!==r)throw Error(Ju(190))}if(f.tag!==3)throw Error(Ju(188));return f.stateNode.current===f?u:l}function hF(u){return u=CK(u),u!==null?bF(u):null}function bF(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var l=bF(u);if(l!==null)return l;u=u.sibling}return null}var{unstable_scheduleCallback:vF,unstable_cancelCallback:Bj,unstable_shouldYield:MK,unstable_requestPaint:RK,unstable_now:hl,unstable_getCurrentPriorityLevel:xK,unstable_ImmediatePriority:d8,unstable_UserBlockingPriority:kF,unstable_NormalPriority:r$,unstable_LowPriority:hK,unstable_IdlePriority:IF}=$r,G$=null,$n=null;function bK(u){if($n&&typeof $n.onCommitFiberRoot==="function")try{$n.onCommitFiberRoot(G$,u,void 0,(u.current.flags&128)===128)}catch(l){}}var vr=Math.clz32?Math.clz32:IK,vK=Math.log,kK=Math.LN2;function IK(u){return u>>>=0,u===0?32:31-(vK(u)/kK|0)|0}var V_=64,m_=4194304;function l1(u){switch(u&-u){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function n$(u,l){var f=u.pendingLanes;if(f===0)return 0;var r=0,n=u.suspendedLanes,i=u.pingedLanes,t=f&268435455;if(t!==0){var y=t&~n;y!==0?r=l1(y):(i&=t,i!==0&&(r=l1(i)))}else t=f&~n,t!==0?r=l1(t):i!==0&&(r=l1(i));if(r===0)return 0;if(l!==0&&l!==r&&(l&n)===0&&(n=r&-r,i=l&-l,n>=i||n===16&&(i&4194240)!==0))return l;if((r&4)!==0&&(r|=f&16),l=u.entangledLanes,l!==0)for(u=u.entanglements,l&=r;0<l;)f=31-vr(l),n=1<<f,r|=u[f],l&=~n;return r}function gK(u,l){switch(u){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5000;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function sK(u,l){for(var{suspendedLanes:f,pingedLanes:r,expirationTimes:n,pendingLanes:i}=u;0<i;){var t=31-vr(i),y=1<<t,c=n[t];if(c===-1){if((y&f)===0||(y&r)!==0)n[t]=gK(y,l)}else c<=l&&(u.expiredLanes|=y);i&=~y}}function F8(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function gF(){var u=V_;return V_<<=1,(V_&4194240)===0&&(V_=64),u}function p6(u){for(var l=[],f=0;31>f;f++)l.push(u);return l}function D1(u,l,f){u.pendingLanes|=l,l!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,l=31-vr(l),u[l]=f}function aK(u,l){var f=u.pendingLanes&~l;u.pendingLanes=l,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=l,u.mutableReadLanes&=l,u.entangledLanes&=l,l=u.entanglements;var r=u.eventTimes;for(u=u.expirationTimes;0<f;){var n=31-vr(f),i=1<<n;l[n]=0,r[n]=-1,u[n]=-1,f&=~i}}function e8(u,l){var f=u.entangledLanes|=l;for(u=u.entanglements;f;){var r=31-vr(f),n=1<<r;n&l|u[r]&l&&(u[r]|=l),f&=~n}}var jl=0;function sF(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var aF,u4,oF,dF,eF,U8=!1,D_=[],F0=null,U0=null,J0=null,w1=new Map,W1=new Map,_0=[],oK="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Vj(u,l){switch(u){case"focusin":case"focusout":F0=null;break;case"dragenter":case"dragleave":U0=null;break;case"mouseover":case"mouseout":J0=null;break;case"pointerover":case"pointerout":w1.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":W1.delete(l.pointerId)}}function Iy(u,l,f,r,n,i){if(u===null||u.nativeEvent!==i)return u={blockedOn:l,domEventName:f,eventSystemFlags:r,nativeEvent:i,targetContainers:[n]},l!==null&&(l=S1(l),l!==null&&u4(l)),u;return u.eventSystemFlags|=r,l=u.targetContainers,n!==null&&l.indexOf(n)===-1&&l.push(n),u}function dK(u,l,f,r,n){switch(l){case"focusin":return F0=Iy(F0,u,l,f,r,n),!0;case"dragenter":return U0=Iy(U0,u,l,f,r,n),!0;case"mouseover":return J0=Iy(J0,u,l,f,r,n),!0;case"pointerover":var i=n.pointerId;return w1.set(i,Iy(w1.get(i)||null,u,l,f,r,n)),!0;case"gotpointercapture":return i=n.pointerId,W1.set(i,Iy(W1.get(i)||null,u,l,f,r,n)),!0}return!1}function uU(u){var l=Ji(u.target);if(l!==null){var f=Ei(l);if(f!==null){if(l=f.tag,l===13){if(l=xF(f),l!==null){u.blockedOn=l,eF(u.priority,function(){oF(f)});return}}else if(l===3&&f.stateNode.current.memoizedState.isDehydrated){u.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}u.blockedOn=null}function h_(u){if(u.blockedOn!==null)return!1;for(var l=u.targetContainers;0<l.length;){var f=J8(u.domEventName,u.eventSystemFlags,l[0],u.nativeEvent);if(f===null){f=u.nativeEvent;var r=new f.constructor(f.type,f);_8=r,f.target.dispatchEvent(r),_8=null}else return l=S1(f),l!==null&&u4(l),u.blockedOn=f,!1;l.shift()}return!0}function mj(u,l,f){h_(u)&&f.delete(l)}function eK(){U8=!1,F0!==null&&h_(F0)&&(F0=null),U0!==null&&h_(U0)&&(U0=null),J0!==null&&h_(J0)&&(J0=null),w1.forEach(mj),W1.forEach(mj)}function gy(u,l){u.blockedOn===l&&(u.blockedOn=null,U8||(U8=!0,$r.unstable_scheduleCallback($r.unstable_NormalPriority,eK)))}function L1(u){function l(n){return gy(n,u)}if(0<D_.length){gy(D_[0],u);for(var f=1;f<D_.length;f++){var r=D_[f];r.blockedOn===u&&(r.blockedOn=null)}}F0!==null&&gy(F0,u),U0!==null&&gy(U0,u),J0!==null&&gy(J0,u),w1.forEach(l),W1.forEach(l);for(f=0;f<_0.length;f++)r=_0[f],r.blockedOn===u&&(r.blockedOn=null);for(;0<_0.length&&(f=_0[0],f.blockedOn===null);)uU(f),f.blockedOn===null&&_0.shift()}var Bt=Yn.ReactCurrentBatchConfig,i$=!0;function uG(u,l,f,r){var n=jl,i=Bt.transition;Bt.transition=null;try{jl=1,l4(u,l,f,r)}finally{jl=n,Bt.transition=i}}function lG(u,l,f,r){var n=jl,i=Bt.transition;Bt.transition=null;try{jl=4,l4(u,l,f,r)}finally{jl=n,Bt.transition=i}}function l4(u,l,f,r){if(i$){var n=J8(u,l,f,r);if(n===null)M6(u,l,r,t$,f),Vj(u,r);else if(dK(n,u,l,f,r))r.stopPropagation();else if(Vj(u,r),l&4&&-1<oK.indexOf(u)){for(;n!==null;){var i=S1(n);if(i!==null&&aF(i),i=J8(u,l,f,r),i===null&&M6(u,l,r,t$,f),i===n)break;n=i}n!==null&&r.stopPropagation()}else M6(u,l,r,null,f)}}var t$=null;function J8(u,l,f,r){if(t$=null,u=o8(r),u=Ji(u),u!==null)if(l=Ei(u),l===null)u=null;else if(f=l.tag,f===13){if(u=xF(l),u!==null)return u;u=null}else if(f===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;u=null}else l!==u&&(u=null);return t$=u,null}function lU(u){switch(u){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(xK()){case d8:return 1;case kF:return 4;case r$:case hK:return 16;case IF:return 536870912;default:return 16}default:return 16}}var A0=null,f4=null,b_=null;function fU(){if(b_)return b_;var u,l=f4,f=l.length,r,n="value"in A0?A0.value:A0.textContent,i=n.length;for(u=0;u<f&&l[u]===n[u];u++);var t=f-u;for(r=1;r<=t&&l[f-r]===n[i-r];r++);return b_=n.slice(u,1<r?1-r:void 0)}function v_(u){var l=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&l===13&&(u=13)):u=l,u===10&&(u=13),32<=u||u===13?u:0}function p_(){return!0}function Dj(){return!1}function Ar(u){function l(f,r,n,i,t){this._reactName=f,this._targetInst=n,this.type=r,this.nativeEvent=i,this.target=t,this.currentTarget=null;for(var y in u)u.hasOwnProperty(y)&&(f=u[y],this[y]=f?f(i):i[y]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?p_:Dj,this.isPropagationStopped=Dj,this}return Vl(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!=="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=p_)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!=="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=p_)},persist:function(){},isPersistent:p_}),l}var Mt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},r4=Ar(Mt),p1=Vl({},Mt,{view:0,detail:0}),fG=Ar(p1),S6,X6,sy,z$=Vl({},p1,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:n4,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){if("movementX"in u)return u.movementX;return u!==sy&&(sy&&u.type==="mousemove"?(S6=u.screenX-sy.screenX,X6=u.screenY-sy.screenY):X6=S6=0,sy=u),S6},movementY:function(u){return"movementY"in u?u.movementY:X6}}),pj=Ar(z$),rG=Vl({},z$,{dataTransfer:0}),nG=Ar(rG),iG=Vl({},p1,{relatedTarget:0}),Y6=Ar(iG),tG=Vl({},Mt,{animationName:0,elapsedTime:0,pseudoElement:0}),yG=Ar(tG),cG=Vl({},Mt,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),_G=Ar(cG),$G=Vl({},Mt,{data:0}),Sj=Ar($G),AG={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jG={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},FG={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function UG(u){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(u):(u=FG[u])?!!l[u]:!1}function n4(){return UG}var JG=Vl({},p1,{key:function(u){if(u.key){var l=AG[u.key]||u.key;if(l!=="Unidentified")return l}return u.type==="keypress"?(u=v_(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?jG[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:n4,charCode:function(u){return u.type==="keypress"?v_(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?v_(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),QG=Ar(JG),NG=Vl({},z$,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xj=Ar(NG),qG=Vl({},p1,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:n4}),wG=Ar(qG),WG=Vl({},Mt,{propertyName:0,elapsedTime:0,pseudoElement:0}),LG=Ar(WG),TG=Vl({},z$,{deltaX:function(u){return"deltaX"in u?u.deltaX:("wheelDeltaX"in u)?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:("wheelDeltaY"in u)?-u.wheelDeltaY:("wheelDelta"in u)?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),KG=Ar(TG),GG=[9,13,27,32],i4=Dn&&"CompositionEvent"in window,_1=null;Dn&&"documentMode"in document&&(_1=document.documentMode);var zG=Dn&&"TextEvent"in window&&!_1,rU=Dn&&(!i4||_1&&8<_1&&11>=_1),Yj=String.fromCharCode(32),Pj=!1;function nU(u,l){switch(u){case"keyup":return GG.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function iU(u){return u=u.detail,typeof u==="object"&&"data"in u?u.data:null}var Nt=!1;function EG(u,l){switch(u){case"compositionend":return iU(l);case"keypress":if(l.which!==32)return null;return Pj=!0,Yj;case"textInput":return u=l.data,u===Yj&&Pj?null:u;default:return null}}function OG(u,l){if(Nt)return u==="compositionend"||!i4&&nU(u,l)?(u=fU(),b_=f4=A0=null,Nt=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return rU&&l.locale!=="ko"?null:l.data;default:return null}}var ZG={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Cj(u){var l=u&&u.nodeName&&u.nodeName.toLowerCase();return l==="input"?!!ZG[u.type]:l==="textarea"?!0:!1}function tU(u,l,f,r){YF(r),l=y$(l,"onChange"),0<l.length&&(f=new r4("onChange","change",null,f,r),u.push({event:f,listeners:l}))}var $1=null,T1=null;function HG(u){NU(u,0)}function E$(u){var l=Wt(u);if(BF(l))return u}function BG(u,l){if(u==="change")return l}var yU=!1;if(Dn){if(Dn){if(r1="oninput"in document,!r1)k_=document.createElement("div"),k_.setAttribute("oninput","return;"),r1=typeof k_.oninput==="function";f1=r1}else f1=!1;yU=f1&&(!document.documentMode||9<document.documentMode)}var f1,r1,k_;function Mj(){$1&&($1.detachEvent("onpropertychange",cU),T1=$1=null)}function cU(u){if(u.propertyName==="value"&&E$(T1)){var l=[];tU(l,T1,u,o8(u)),RF(HG,l)}}function VG(u,l,f){u==="focusin"?(Mj(),$1=l,T1=f,$1.attachEvent("onpropertychange",cU)):u==="focusout"&&Mj()}function mG(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return E$(T1)}function DG(u,l){if(u==="click")return E$(l)}function pG(u,l){if(u==="input"||u==="change")return E$(l)}function SG(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}var Ir=typeof Object.is==="function"?Object.is:SG;function K1(u,l){if(Ir(u,l))return!0;if(typeof u!=="object"||u===null||typeof l!=="object"||l===null)return!1;var f=Object.keys(u),r=Object.keys(l);if(f.length!==r.length)return!1;for(r=0;r<f.length;r++){var n=f[r];if(!o6.call(l,n)||!Ir(u[n],l[n]))return!1}return!0}function Rj(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function xj(u,l){var f=Rj(u);u=0;for(var r;f;){if(f.nodeType===3){if(r=u+f.textContent.length,u<=l&&r>=l)return{node:f,offset:l-u};u=r}u:{for(;f;){if(f.nextSibling){f=f.nextSibling;break u}f=f.parentNode}f=void 0}f=Rj(f)}}function _U(u,l){return u&&l?u===l?!0:u&&u.nodeType===3?!1:l&&l.nodeType===3?_U(u,l.parentNode):("contains"in u)?u.contains(l):u.compareDocumentPosition?!!(u.compareDocumentPosition(l)&16):!1:!1}function $U(){for(var u=window,l=u$();l instanceof u.HTMLIFrameElement;){try{var f=typeof l.contentWindow.location.href==="string"}catch(r){f=!1}if(f)u=l.contentWindow;else break;l=u$(u.document)}return l}function t4(u){var l=u&&u.nodeName&&u.nodeName.toLowerCase();return l&&(l==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||l==="textarea"||u.contentEditable==="true")}function XG(u){var l=$U(),f=u.focusedElem,r=u.selectionRange;if(l!==f&&f&&f.ownerDocument&&_U(f.ownerDocument.documentElement,f)){if(r!==null&&t4(f)){if(l=r.start,u=r.end,u===void 0&&(u=l),"selectionStart"in f)f.selectionStart=l,f.selectionEnd=Math.min(u,f.value.length);else if(u=(l=f.ownerDocument||document)&&l.defaultView||window,u.getSelection){u=u.getSelection();var n=f.textContent.length,i=Math.min(r.start,n);r=r.end===void 0?i:Math.min(r.end,n),!u.extend&&i>r&&(n=r,r=i,i=n),n=xj(f,i);var t=xj(f,r);n&&t&&(u.rangeCount!==1||u.anchorNode!==n.node||u.anchorOffset!==n.offset||u.focusNode!==t.node||u.focusOffset!==t.offset)&&(l=l.createRange(),l.setStart(n.node,n.offset),u.removeAllRanges(),i>r?(u.addRange(l),u.extend(t.node,t.offset)):(l.setEnd(t.node,t.offset),u.addRange(l)))}}l=[];for(u=f;u=u.parentNode;)u.nodeType===1&&l.push({element:u,left:u.scrollLeft,top:u.scrollTop});typeof f.focus==="function"&&f.focus();for(f=0;f<l.length;f++)u=l[f],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var YG=Dn&&"documentMode"in document&&11>=document.documentMode,qt=null,Q8=null,A1=null,N8=!1;function hj(u,l,f){var r=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;N8||qt==null||qt!==u$(r)||(r=qt,("selectionStart"in r)&&t4(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),A1&&K1(A1,r)||(A1=r,r=y$(Q8,"onSelect"),0<r.length&&(l=new r4("onSelect","select",null,l,f),u.push({event:l,listeners:r}),l.target=qt)))}function S_(u,l){var f={};return f[u.toLowerCase()]=l.toLowerCase(),f["Webkit"+u]="webkit"+l,f["Moz"+u]="moz"+l,f}var wt={animationend:S_("Animation","AnimationEnd"),animationiteration:S_("Animation","AnimationIteration"),animationstart:S_("Animation","AnimationStart"),transitionend:S_("Transition","TransitionEnd")},P6={},AU={};Dn&&(AU=document.createElement("div").style,("AnimationEvent"in window)||(delete wt.animationend.animation,delete wt.animationiteration.animation,delete wt.animationstart.animation),("TransitionEvent"in window)||delete wt.transitionend.transition);function O$(u){if(P6[u])return P6[u];if(!wt[u])return u;var l=wt[u],f;for(f in l)if(l.hasOwnProperty(f)&&f in AU)return P6[u]=l[f];return u}var jU=O$("animationend"),FU=O$("animationiteration"),UU=O$("animationstart"),JU=O$("transitionend"),QU=new Map,bj="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function K0(u,l){QU.set(u,l),zi(l,[u])}for(n1=0;n1<bj.length;n1++)i1=bj[n1],q8=i1.toLowerCase(),w8=i1[0].toUpperCase()+i1.slice(1),K0(q8,"on"+w8);var i1,q8,w8,n1;K0(jU,"onAnimationEnd");K0(FU,"onAnimationIteration");K0(UU,"onAnimationStart");K0("dblclick","onDoubleClick");K0("focusin","onFocus");K0("focusout","onBlur");K0(JU,"onTransitionEnd");Dt("onMouseEnter",["mouseout","mouseover"]);Dt("onMouseLeave",["mouseout","mouseover"]);Dt("onPointerEnter",["pointerout","pointerover"]);Dt("onPointerLeave",["pointerout","pointerover"]);zi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));zi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));zi("onBeforeInput",["compositionend","keypress","textInput","paste"]);zi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));zi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));zi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var t1="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),PG=new Set("cancel close invalid load scroll toggle".split(" ").concat(t1));function vj(u,l,f){var r=u.type||"unknown-event";u.currentTarget=f,PK(r,l,void 0,u),u.currentTarget=null}function NU(u,l){l=(l&4)!==0;for(var f=0;f<u.length;f++){var r=u[f],n=r.event;r=r.listeners;u:{var i=void 0;if(l)for(var t=r.length-1;0<=t;t--){var y=r[t],c=y.instance,$=y.currentTarget;if(y=y.listener,c!==i&&n.isPropagationStopped())break u;vj(n,y,$),i=c}else for(t=0;t<r.length;t++){if(y=r[t],c=y.instance,$=y.currentTarget,y=y.listener,c!==i&&n.isPropagationStopped())break u;vj(n,y,$),i=c}}}if(f$)throw u=j8,f$=!1,j8=null,u}function Gl(u,l){var f=l[G8];f===void 0&&(f=l[G8]=new Set);var r=u+"__bubble";f.has(r)||(qU(l,u,2,!1),f.add(r))}function C6(u,l,f){var r=0;l&&(r|=4),qU(f,u,r,l)}var X_="_reactListening"+Math.random().toString(36).slice(2);function G1(u){if(!u[X_]){u[X_]=!0,zF.forEach(function(f){f!=="selectionchange"&&(PG.has(f)||C6(f,!1,u),C6(f,!0,u))});var l=u.nodeType===9?u:u.ownerDocument;l===null||l[X_]||(l[X_]=!0,C6("selectionchange",!1,l))}}function qU(u,l,f,r){switch(lU(l)){case 1:var n=uG;break;case 4:n=lG;break;default:n=l4}f=n.bind(null,l,f,u),n=void 0,!A8||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(n=!0),r?n!==void 0?u.addEventListener(l,f,{capture:!0,passive:n}):u.addEventListener(l,f,!0):n!==void 0?u.addEventListener(l,f,{passive:n}):u.addEventListener(l,f,!1)}function M6(u,l,f,r,n){var i=r;if((l&1)===0&&(l&2)===0&&r!==null)u:for(;;){if(r===null)return;var t=r.tag;if(t===3||t===4){var y=r.stateNode.containerInfo;if(y===n||y.nodeType===8&&y.parentNode===n)break;if(t===4)for(t=r.return;t!==null;){var c=t.tag;if(c===3||c===4){if(c=t.stateNode.containerInfo,c===n||c.nodeType===8&&c.parentNode===n)return}t=t.return}for(;y!==null;){if(t=Ji(y),t===null)return;if(c=t.tag,c===5||c===6){r=i=t;continue u}y=y.parentNode}}r=r.return}RF(function(){var $=i,A=o8(f),j=[];u:{var F=QU.get(u);if(F!==void 0){var J=r4,Q=u;switch(u){case"keypress":if(v_(f)===0)break u;case"keydown":case"keyup":J=QG;break;case"focusin":Q="focus",J=Y6;break;case"focusout":Q="blur",J=Y6;break;case"beforeblur":case"afterblur":J=Y6;break;case"click":if(f.button===2)break u;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=pj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=nG;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=wG;break;case jU:case FU:case UU:J=yG;break;case JU:J=LG;break;case"scroll":J=fG;break;case"wheel":J=KG;break;case"copy":case"cut":case"paste":J=_G;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=Xj}var W=(l&4)!==0,L=!W&&u==="scroll",U=W?F!==null?F+"Capture":null:F;W=[];for(var q=$,N;q!==null;){N=q;var w=N.stateNode;if(N.tag===5&&w!==null&&(N=w,U!==null&&(w=q1(q,U),w!=null&&W.push(z1(q,w,N)))),L)break;q=q.return}0<W.length&&(F=new J(F,Q,null,f,A),j.push({event:F,listeners:W}))}}if((l&7)===0){u:{if(F=u==="mouseover"||u==="pointerover",J=u==="mouseout"||u==="pointerout",F&&f!==_8&&(Q=f.relatedTarget||f.fromElement)&&(Ji(Q)||Q[pn]))break u;if(J||F){if(F=A.window===A?A:(F=A.ownerDocument)?F.defaultView||F.parentWindow:window,J){if(Q=f.relatedTarget||f.toElement,J=$,Q=Q?Ji(Q):null,Q!==null&&(L=Ei(Q),Q!==L||Q.tag!==5&&Q.tag!==6))Q=null}else J=null,Q=$;if(J!==Q){if(W=pj,w="onMouseLeave",U="onMouseEnter",q="mouse",u==="pointerout"||u==="pointerover")W=Xj,w="onPointerLeave",U="onPointerEnter",q="pointer";if(L=J==null?F:Wt(J),N=Q==null?F:Wt(Q),F=new W(w,q+"leave",J,f,A),F.target=L,F.relatedTarget=N,w=null,Ji(A)===$&&(W=new W(U,q+"enter",Q,f,A),W.target=N,W.relatedTarget=L,w=W),L=w,J&&Q)l:{W=J,U=Q,q=0;for(N=W;N;N=Ft(N))q++;N=0;for(w=U;w;w=Ft(w))N++;for(;0<q-N;)W=Ft(W),q--;for(;0<N-q;)U=Ft(U),N--;for(;q--;){if(W===U||U!==null&&W===U.alternate)break l;W=Ft(W),U=Ft(U)}W=null}else W=null;J!==null&&kj(j,F,J,W,!1),Q!==null&&L!==null&&kj(j,L,Q,W,!0)}}}u:{if(F=$?Wt($):window,J=F.nodeName&&F.nodeName.toLowerCase(),J==="select"||J==="input"&&F.type==="file")var G=BG;else if(Cj(F))if(yU)G=pG;else{G=mG;var Z=VG}else(J=F.nodeName)&&J.toLowerCase()==="input"&&(F.type==="checkbox"||F.type==="radio")&&(G=DG);if(G&&(G=G(u,$))){tU(j,G,f,A);break u}Z&&Z(u,F,$),u==="focusout"&&(Z=F._wrapperState)&&Z.controlled&&F.type==="number"&&n8(F,"number",F.value)}switch(Z=$?Wt($):window,u){case"focusin":if(Cj(Z)||Z.contentEditable==="true")qt=Z,Q8=$,A1=null;break;case"focusout":A1=Q8=qt=null;break;case"mousedown":N8=!0;break;case"contextmenu":case"mouseup":case"dragend":N8=!1,hj(j,f,A);break;case"selectionchange":if(YG)break;case"keydown":case"keyup":hj(j,f,A)}var H;if(i4)u:{switch(u){case"compositionstart":var E="onCompositionStart";break u;case"compositionend":E="onCompositionEnd";break u;case"compositionupdate":E="onCompositionUpdate";break u}E=void 0}else Nt?nU(u,f)&&(E="onCompositionEnd"):u==="keydown"&&f.keyCode===229&&(E="onCompositionStart");if(E&&(rU&&f.locale!=="ko"&&(Nt||E!=="onCompositionStart"?E==="onCompositionEnd"&&Nt&&(H=fU()):(A0=A,f4=("value"in A0)?A0.value:A0.textContent,Nt=!0)),Z=y$($,E),0<Z.length&&(E=new Sj(E,u,null,f,A),j.push({event:E,listeners:Z}),H?E.data=H:(H=iU(f),H!==null&&(E.data=H)))),H=zG?EG(u,f):OG(u,f))$=y$($,"onBeforeInput"),0<$.length&&(A=new Sj("onBeforeInput","beforeinput",null,f,A),j.push({event:A,listeners:$}),A.data=H)}NU(j,l)})}function z1(u,l,f){return{instance:u,listener:l,currentTarget:f}}function y$(u,l){for(var f=l+"Capture",r=[];u!==null;){var n=u,i=n.stateNode;n.tag===5&&i!==null&&(n=i,i=q1(u,f),i!=null&&r.unshift(z1(u,i,n)),i=q1(u,l),i!=null&&r.push(z1(u,i,n))),u=u.return}return r}function Ft(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u?u:null}function kj(u,l,f,r,n){for(var i=l._reactName,t=[];f!==null&&f!==r;){var y=f,c=y.alternate,$=y.stateNode;if(c!==null&&c===r)break;y.tag===5&&$!==null&&(y=$,n?(c=q1(f,i),c!=null&&t.unshift(z1(f,c,y))):n||(c=q1(f,i),c!=null&&t.push(z1(f,c,y)))),f=f.return}t.length!==0&&u.push({event:l,listeners:t})}var CG=/\r\n?/g,MG=/\u0000|\uFFFD/g;function Ij(u){return(typeof u==="string"?u:""+u).replace(CG,` -`).replace(MG,"")}function Y_(u,l,f){if(l=Ij(l),Ij(u)!==l&&f)throw Error(Ju(425))}function c$(){}var W8=null,L8=null;function T8(u,l){return u==="textarea"||u==="noscript"||typeof l.children==="string"||typeof l.children==="number"||typeof l.dangerouslySetInnerHTML==="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var K8=typeof setTimeout==="function"?setTimeout:void 0,RG=typeof clearTimeout==="function"?clearTimeout:void 0,gj=typeof Promise==="function"?Promise:void 0,xG=typeof queueMicrotask==="function"?queueMicrotask:typeof gj<"u"?function(u){return gj.resolve(null).then(u).catch(hG)}:K8;function hG(u){setTimeout(function(){throw u})}function R6(u,l){var f=l,r=0;do{var n=f.nextSibling;if(u.removeChild(f),n&&n.nodeType===8)if(f=n.data,f==="/$"){if(r===0){u.removeChild(n),L1(l);return}r--}else f!=="$"&&f!=="$?"&&f!=="$!"||r++;f=n}while(f);L1(l)}function Q0(u){for(;u!=null;u=u.nextSibling){var l=u.nodeType;if(l===1||l===3)break;if(l===8){if(l=u.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return u}function sj(u){u=u.previousSibling;for(var l=0;u;){if(u.nodeType===8){var f=u.data;if(f==="$"||f==="$!"||f==="$?"){if(l===0)return u;l--}else f==="/$"&&l++}u=u.previousSibling}return null}var Rt=Math.random().toString(36).slice(2),_n="__reactFiber$"+Rt,E1="__reactProps$"+Rt,pn="__reactContainer$"+Rt,G8="__reactEvents$"+Rt,bG="__reactListeners$"+Rt,vG="__reactHandles$"+Rt;function Ji(u){var l=u[_n];if(l)return l;for(var f=u.parentNode;f;){if(l=f[pn]||f[_n]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(u=sj(u);u!==null;){if(f=u[_n])return f;u=sj(u)}return l}u=f,f=u.parentNode}return null}function S1(u){return u=u[_n]||u[pn],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function Wt(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(Ju(33))}function Z$(u){return u[E1]||null}var z8=[],Lt=-1;function G0(u){return{current:u}}function zl(u){0>Lt||(u.current=z8[Lt],z8[Lt]=null,Lt--)}function Wl(u,l){Lt++,z8[Lt]=u.current,u.current=l}var T0={},Kf=G0(T0),kf=G0(!1),Wi=T0;function pt(u,l){var f=u.type.contextTypes;if(!f)return T0;var r=u.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===l)return r.__reactInternalMemoizedMaskedChildContext;var n={},i;for(i in f)n[i]=l[i];return r&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=l,u.__reactInternalMemoizedMaskedChildContext=n),n}function If(u){return u=u.childContextTypes,u!==null&&u!==void 0}function _$(){zl(kf),zl(Kf)}function aj(u,l,f){if(Kf.current!==T0)throw Error(Ju(168));Wl(Kf,l),Wl(kf,f)}function wU(u,l,f){var r=u.stateNode;if(l=l.childContextTypes,typeof r.getChildContext!=="function")return f;r=r.getChildContext();for(var n in r)if(!(n in l))throw Error(Ju(108,VK(u)||"Unknown",n));return Vl({},f,r)}function $$(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||T0,Wi=Kf.current,Wl(Kf,u),Wl(kf,kf.current),!0}function oj(u,l,f){var r=u.stateNode;if(!r)throw Error(Ju(169));f?(u=wU(u,l,Wi),r.__reactInternalMemoizedMergedChildContext=u,zl(kf),zl(Kf),Wl(Kf,u)):zl(kf),Wl(kf,f)}var Hn=null,H$=!1,x6=!1;function WU(u){Hn===null?Hn=[u]:Hn.push(u)}function kG(u){H$=!0,WU(u)}function z0(){if(!x6&&Hn!==null){x6=!0;var u=0,l=jl;try{var f=Hn;for(jl=1;u<f.length;u++){var r=f[u];do r=r(!0);while(r!==null)}Hn=null,H$=!1}catch(n){throw Hn!==null&&(Hn=Hn.slice(u+1)),vF(d8,z0),n}finally{jl=l,x6=!1}}return null}var Tt=[],Kt=0,A$=null,j$=0,Kr=[],Gr=0,Li=null,Bn=1,Vn="";function Fi(u,l){Tt[Kt++]=j$,Tt[Kt++]=A$,A$=u,j$=l}function LU(u,l,f){Kr[Gr++]=Bn,Kr[Gr++]=Vn,Kr[Gr++]=Li,Li=u;var r=Bn;u=Vn;var n=32-vr(r)-1;r&=~(1<<n),f+=1;var i=32-vr(l)+n;if(30<i){var t=n-n%5;i=(r&(1<<t)-1).toString(32),r>>=t,n-=t,Bn=1<<32-vr(l)+n|f<<n|r,Vn=i+u}else Bn=1<<i|f<<n|r,Vn=u}function y4(u){u.return!==null&&(Fi(u,1),LU(u,1,0))}function c4(u){for(;u===A$;)A$=Tt[--Kt],Tt[Kt]=null,j$=Tt[--Kt],Tt[Kt]=null;for(;u===Li;)Li=Kr[--Gr],Kr[Gr]=null,Vn=Kr[--Gr],Kr[Gr]=null,Bn=Kr[--Gr],Kr[Gr]=null}var _r=null,cr=null,Ol=!1,br=null;function TU(u,l){var f=zr(5,null,null,0);f.elementType="DELETED",f.stateNode=l,f.return=u,l=u.deletions,l===null?(u.deletions=[f],u.flags|=16):l.push(f)}function dj(u,l){switch(u.tag){case 5:var f=u.type;return l=l.nodeType!==1||f.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(u.stateNode=l,_r=u,cr=Q0(l.firstChild),!0):!1;case 6:return l=u.pendingProps===""||l.nodeType!==3?null:l,l!==null?(u.stateNode=l,_r=u,cr=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(f=Li!==null?{id:Bn,overflow:Vn}:null,u.memoizedState={dehydrated:l,treeContext:f,retryLane:1073741824},f=zr(18,null,null,0),f.stateNode=l,f.return=u,u.child=f,_r=u,cr=null,!0):!1;default:return!1}}function E8(u){return(u.mode&1)!==0&&(u.flags&128)===0}function O8(u){if(Ol){var l=cr;if(l){var f=l;if(!dj(u,l)){if(E8(u))throw Error(Ju(418));l=Q0(f.nextSibling);var r=_r;l&&dj(u,l)?TU(r,f):(u.flags=u.flags&-4097|2,Ol=!1,_r=u)}}else{if(E8(u))throw Error(Ju(418));u.flags=u.flags&-4097|2,Ol=!1,_r=u}}}function ej(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;_r=u}function P_(u){if(u!==_r)return!1;if(!Ol)return ej(u),Ol=!0,!1;var l;if((l=u.tag!==3)&&!(l=u.tag!==5)&&(l=u.type,l=l!=="head"&&l!=="body"&&!T8(u.type,u.memoizedProps)),l&&(l=cr)){if(E8(u))throw KU(),Error(Ju(418));for(;l;)TU(u,l),l=Q0(l.nextSibling)}if(ej(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(Ju(317));u:{u=u.nextSibling;for(l=0;u;){if(u.nodeType===8){var f=u.data;if(f==="/$"){if(l===0){cr=Q0(u.nextSibling);break u}l--}else f!=="$"&&f!=="$!"&&f!=="$?"||l++}u=u.nextSibling}cr=null}}else cr=_r?Q0(u.stateNode.nextSibling):null;return!0}function KU(){for(var u=cr;u;)u=Q0(u.nextSibling)}function St(){cr=_r=null,Ol=!1}function _4(u){br===null?br=[u]:br.push(u)}var IG=Yn.ReactCurrentBatchConfig;function ay(u,l,f){if(u=f.ref,u!==null&&typeof u!=="function"&&typeof u!=="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(Ju(309));var r=f.stateNode}if(!r)throw Error(Ju(147,u));var n=r,i=""+u;if(l!==null&&l.ref!==null&&typeof l.ref==="function"&&l.ref._stringRef===i)return l.ref;return l=function(t){var y=n.refs;t===null?delete y[i]:y[i]=t},l._stringRef=i,l}if(typeof u!=="string")throw Error(Ju(284));if(!f._owner)throw Error(Ju(290,u))}return u}function C_(u,l){throw u=Object.prototype.toString.call(l),Error(Ju(31,u==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":u))}function uF(u){var l=u._init;return l(u._payload)}function GU(u){function l(U,q){if(u){var N=U.deletions;N===null?(U.deletions=[q],U.flags|=16):N.push(q)}}function f(U,q){if(!u)return null;for(;q!==null;)l(U,q),q=q.sibling;return null}function r(U,q){for(U=new Map;q!==null;)q.key!==null?U.set(q.key,q):U.set(q.index,q),q=q.sibling;return U}function n(U,q){return U=W0(U,q),U.index=0,U.sibling=null,U}function i(U,q,N){if(U.index=N,!u)return U.flags|=1048576,q;if(N=U.alternate,N!==null)return N=N.index,N<q?(U.flags|=2,q):N;return U.flags|=2,q}function t(U){return u&&U.alternate===null&&(U.flags|=2),U}function y(U,q,N,w){if(q===null||q.tag!==6)return q=s6(N,U.mode,w),q.return=U,q;return q=n(q,N),q.return=U,q}function c(U,q,N,w){var G=N.type;if(G===Qt)return A(U,q,N.props.children,w,N.key);if(q!==null&&(q.elementType===G||typeof G==="object"&&G!==null&&G.$$typeof===y0&&uF(G)===q.type))return w=n(q,N.props),w.ref=ay(U,q,N),w.return=U,w;return w=e_(N.type,N.key,N.props,null,U.mode,w),w.ref=ay(U,q,N),w.return=U,w}function $(U,q,N,w){if(q===null||q.tag!==4||q.stateNode.containerInfo!==N.containerInfo||q.stateNode.implementation!==N.implementation)return q=a6(N,U.mode,w),q.return=U,q;return q=n(q,N.children||[]),q.return=U,q}function A(U,q,N,w,G){if(q===null||q.tag!==7)return q=wi(N,U.mode,w,G),q.return=U,q;return q=n(q,N),q.return=U,q}function j(U,q,N){if(typeof q==="string"&&q!==""||typeof q==="number")return q=s6(""+q,U.mode,N),q.return=U,q;if(typeof q==="object"&&q!==null){switch(q.$$typeof){case Z_:return N=e_(q.type,q.key,q.props,null,U.mode,N),N.ref=ay(U,null,q),N.return=U,N;case Jt:return q=a6(q,U.mode,N),q.return=U,q;case y0:var w=q._init;return j(U,w(q._payload),N)}if(u1(q)||ky(q))return q=wi(q,U.mode,N,null),q.return=U,q;C_(U,q)}return null}function F(U,q,N,w){var G=q!==null?q.key:null;if(typeof N==="string"&&N!==""||typeof N==="number")return G!==null?null:y(U,q,""+N,w);if(typeof N==="object"&&N!==null){switch(N.$$typeof){case Z_:return N.key===G?c(U,q,N,w):null;case Jt:return N.key===G?$(U,q,N,w):null;case y0:return G=N._init,F(U,q,G(N._payload),w)}if(u1(N)||ky(N))return G!==null?null:A(U,q,N,w,null);C_(U,N)}return null}function J(U,q,N,w,G){if(typeof w==="string"&&w!==""||typeof w==="number")return U=U.get(N)||null,y(q,U,""+w,G);if(typeof w==="object"&&w!==null){switch(w.$$typeof){case Z_:return U=U.get(w.key===null?N:w.key)||null,c(q,U,w,G);case Jt:return U=U.get(w.key===null?N:w.key)||null,$(q,U,w,G);case y0:var Z=w._init;return J(U,q,N,Z(w._payload),G)}if(u1(w)||ky(w))return U=U.get(N)||null,A(q,U,w,G,null);C_(q,w)}return null}function Q(U,q,N,w){for(var G=null,Z=null,H=q,E=q=0,m=null;H!==null&&E<N.length;E++){H.index>E?(m=H,H=null):m=H.sibling;var S=F(U,H,N[E],w);if(S===null){H===null&&(H=m);break}u&&H&&S.alternate===null&&l(U,H),q=i(S,q,E),Z===null?G=S:Z.sibling=S,Z=S,H=m}if(E===N.length)return f(U,H),Ol&&Fi(U,E),G;if(H===null){for(;E<N.length;E++)H=j(U,N[E],w),H!==null&&(q=i(H,q,E),Z===null?G=H:Z.sibling=H,Z=H);return Ol&&Fi(U,E),G}for(H=r(U,H);E<N.length;E++)m=J(H,U,E,N[E],w),m!==null&&(u&&m.alternate!==null&&H.delete(m.key===null?E:m.key),q=i(m,q,E),Z===null?G=m:Z.sibling=m,Z=m);return u&&H.forEach(function(B){return l(U,B)}),Ol&&Fi(U,E),G}function W(U,q,N,w){var G=ky(N);if(typeof G!=="function")throw Error(Ju(150));if(N=G.call(N),N==null)throw Error(Ju(151));for(var Z=G=null,H=q,E=q=0,m=null,S=N.next();H!==null&&!S.done;E++,S=N.next()){H.index>E?(m=H,H=null):m=H.sibling;var B=F(U,H,S.value,w);if(B===null){H===null&&(H=m);break}u&&H&&B.alternate===null&&l(U,H),q=i(B,q,E),Z===null?G=B:Z.sibling=B,Z=B,H=m}if(S.done)return f(U,H),Ol&&Fi(U,E),G;if(H===null){for(;!S.done;E++,S=N.next())S=j(U,S.value,w),S!==null&&(q=i(S,q,E),Z===null?G=S:Z.sibling=S,Z=S);return Ol&&Fi(U,E),G}for(H=r(U,H);!S.done;E++,S=N.next())S=J(H,U,E,S.value,w),S!==null&&(u&&S.alternate!==null&&H.delete(S.key===null?E:S.key),q=i(S,q,E),Z===null?G=S:Z.sibling=S,Z=S);return u&&H.forEach(function(D){return l(U,D)}),Ol&&Fi(U,E),G}function L(U,q,N,w){if(typeof N==="object"&&N!==null&&N.type===Qt&&N.key===null&&(N=N.props.children),typeof N==="object"&&N!==null){switch(N.$$typeof){case Z_:u:{for(var G=N.key,Z=q;Z!==null;){if(Z.key===G){if(G=N.type,G===Qt){if(Z.tag===7){f(U,Z.sibling),q=n(Z,N.props.children),q.return=U,U=q;break u}}else if(Z.elementType===G||typeof G==="object"&&G!==null&&G.$$typeof===y0&&uF(G)===Z.type){f(U,Z.sibling),q=n(Z,N.props),q.ref=ay(U,Z,N),q.return=U,U=q;break u}f(U,Z);break}else l(U,Z);Z=Z.sibling}N.type===Qt?(q=wi(N.props.children,U.mode,w,N.key),q.return=U,U=q):(w=e_(N.type,N.key,N.props,null,U.mode,w),w.ref=ay(U,q,N),w.return=U,U=w)}return t(U);case Jt:u:{for(Z=N.key;q!==null;){if(q.key===Z)if(q.tag===4&&q.stateNode.containerInfo===N.containerInfo&&q.stateNode.implementation===N.implementation){f(U,q.sibling),q=n(q,N.children||[]),q.return=U,U=q;break u}else{f(U,q);break}else l(U,q);q=q.sibling}q=a6(N,U.mode,w),q.return=U,U=q}return t(U);case y0:return Z=N._init,L(U,q,Z(N._payload),w)}if(u1(N))return Q(U,q,N,w);if(ky(N))return W(U,q,N,w);C_(U,N)}return typeof N==="string"&&N!==""||typeof N==="number"?(N=""+N,q!==null&&q.tag===6?(f(U,q.sibling),q=n(q,N),q.return=U,U=q):(f(U,q),q=s6(N,U.mode,w),q.return=U,U=q),t(U)):f(U,q)}return L}var Xt=GU(!0),zU=GU(!1),F$=G0(null),U$=null,Gt=null,$4=null;function A4(){$4=Gt=U$=null}function j4(u){var l=F$.current;zl(F$),u._currentValue=l}function Z8(u,l,f){for(;u!==null;){var r=u.alternate;if((u.childLanes&l)!==l?(u.childLanes|=l,r!==null&&(r.childLanes|=l)):r!==null&&(r.childLanes&l)!==l&&(r.childLanes|=l),u===f)break;u=u.return}}function Vt(u,l){U$=u,$4=Gt=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&l)!==0&&(vf=!0),u.firstContext=null)}function Or(u){var l=u._currentValue;if($4!==u)if(u={context:u,memoizedValue:l,next:null},Gt===null){if(U$===null)throw Error(Ju(308));Gt=u,U$.dependencies={lanes:0,firstContext:u}}else Gt=Gt.next=u;return l}var Qi=null;function F4(u){Qi===null?Qi=[u]:Qi.push(u)}function EU(u,l,f,r){var n=l.interleaved;return n===null?(f.next=f,F4(l)):(f.next=n.next,n.next=f),l.interleaved=f,Sn(u,r)}function Sn(u,l){u.lanes|=l;var f=u.alternate;f!==null&&(f.lanes|=l),f=u;for(u=u.return;u!==null;)u.childLanes|=l,f=u.alternate,f!==null&&(f.childLanes|=l),f=u,u=u.return;return f.tag===3?f.stateNode:null}var c0=!1;function U4(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function OU(u,l){u=u.updateQueue,l.updateQueue===u&&(l.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function mn(u,l){return{eventTime:u,lane:l,tag:0,payload:null,callback:null,next:null}}function N0(u,l,f){var r=u.updateQueue;if(r===null)return null;if(r=r.shared,(cl&2)!==0){var n=r.pending;return n===null?l.next=l:(l.next=n.next,n.next=l),r.pending=l,Sn(u,f)}return n=r.interleaved,n===null?(l.next=l,F4(r)):(l.next=n.next,n.next=l),r.interleaved=l,Sn(u,f)}function I_(u,l,f){if(l=l.updateQueue,l!==null&&(l=l.shared,(f&4194240)!==0)){var r=l.lanes;r&=u.pendingLanes,f|=r,l.lanes=f,e8(u,f)}}function lF(u,l){var{updateQueue:f,alternate:r}=u;if(r!==null&&(r=r.updateQueue,f===r)){var n=null,i=null;if(f=f.firstBaseUpdate,f!==null){do{var t={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};i===null?n=i=t:i=i.next=t,f=f.next}while(f!==null);i===null?n=i=l:i=i.next=l}else n=i=l;f={baseState:r.baseState,firstBaseUpdate:n,lastBaseUpdate:i,shared:r.shared,effects:r.effects},u.updateQueue=f;return}u=f.lastBaseUpdate,u===null?f.firstBaseUpdate=l:u.next=l,f.lastBaseUpdate=l}function J$(u,l,f,r){var n=u.updateQueue;c0=!1;var{firstBaseUpdate:i,lastBaseUpdate:t}=n,y=n.shared.pending;if(y!==null){n.shared.pending=null;var c=y,$=c.next;c.next=null,t===null?i=$:t.next=$,t=c;var A=u.alternate;A!==null&&(A=A.updateQueue,y=A.lastBaseUpdate,y!==t&&(y===null?A.firstBaseUpdate=$:y.next=$,A.lastBaseUpdate=c))}if(i!==null){var j=n.baseState;t=0,A=$=c=null,y=i;do{var{lane:F,eventTime:J}=y;if((r&F)===F){A!==null&&(A=A.next={eventTime:J,lane:0,tag:y.tag,payload:y.payload,callback:y.callback,next:null});u:{var Q=u,W=y;switch(F=l,J=f,W.tag){case 1:if(Q=W.payload,typeof Q==="function"){j=Q.call(J,j,F);break u}j=Q;break u;case 3:Q.flags=Q.flags&-65537|128;case 0:if(Q=W.payload,F=typeof Q==="function"?Q.call(J,j,F):Q,F===null||F===void 0)break u;j=Vl({},j,F);break u;case 2:c0=!0}}y.callback!==null&&y.lane!==0&&(u.flags|=64,F=n.effects,F===null?n.effects=[y]:F.push(y))}else J={eventTime:J,lane:F,tag:y.tag,payload:y.payload,callback:y.callback,next:null},A===null?($=A=J,c=j):A=A.next=J,t|=F;if(y=y.next,y===null)if(y=n.shared.pending,y===null)break;else F=y,y=F.next,F.next=null,n.lastBaseUpdate=F,n.shared.pending=null}while(1);if(A===null&&(c=j),n.baseState=c,n.firstBaseUpdate=$,n.lastBaseUpdate=A,l=n.shared.interleaved,l!==null){n=l;do t|=n.lane,n=n.next;while(n!==l)}else i===null&&(n.shared.lanes=0);Ki|=t,u.lanes=t,u.memoizedState=j}}function fF(u,l,f){if(u=l.effects,l.effects=null,u!==null)for(l=0;l<u.length;l++){var r=u[l],n=r.callback;if(n!==null){if(r.callback=null,r=f,typeof n!=="function")throw Error(Ju(191,n));n.call(r)}}}var X1={},An=G0(X1),O1=G0(X1),Z1=G0(X1);function Ni(u){if(u===X1)throw Error(Ju(174));return u}function J4(u,l){switch(Wl(Z1,l),Wl(O1,u),Wl(An,X1),u=l.nodeType,u){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:t8(null,"");break;default:u=u===8?l.parentNode:l,l=u.namespaceURI||null,u=u.tagName,l=t8(l,u)}zl(An),Wl(An,l)}function Yt(){zl(An),zl(O1),zl(Z1)}function ZU(u){Ni(Z1.current);var l=Ni(An.current),f=t8(l,u.type);l!==f&&(Wl(O1,u),Wl(An,f))}function Q4(u){O1.current===u&&(zl(An),zl(O1))}var Hl=G0(0);function Q$(u){for(var l=u;l!==null;){if(l.tag===13){var f=l.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break;for(;l.sibling===null;){if(l.return===null||l.return===u)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var h6=[];function N4(){for(var u=0;u<h6.length;u++)h6[u]._workInProgressVersionPrimary=null;h6.length=0}var{ReactCurrentDispatcher:g_,ReactCurrentBatchConfig:b6}=Yn,Ti=0,Bl=null,uf=null,cf=null,N$=!1,j1=!1,H1=0,gG=0;function Wf(){throw Error(Ju(321))}function q4(u,l){if(l===null)return!1;for(var f=0;f<l.length&&f<u.length;f++)if(!Ir(u[f],l[f]))return!1;return!0}function w4(u,l,f,r,n,i){if(Ti=i,Bl=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,g_.current=u===null||u.memoizedState===null?dG:eG,u=f(r,n),j1){i=0;do{if(j1=!1,H1=0,25<=i)throw Error(Ju(301));i+=1,cf=uf=null,l.updateQueue=null,g_.current=uz,u=f(r,n)}while(j1)}if(g_.current=q$,l=uf!==null&&uf.next!==null,Ti=0,cf=uf=Bl=null,N$=!1,l)throw Error(Ju(300));return u}function W4(){var u=H1!==0;return H1=0,u}function cn(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cf===null?Bl.memoizedState=cf=u:cf=cf.next=u,cf}function Zr(){if(uf===null){var u=Bl.alternate;u=u!==null?u.memoizedState:null}else u=uf.next;var l=cf===null?Bl.memoizedState:cf.next;if(l!==null)cf=l,uf=u;else{if(u===null)throw Error(Ju(310));uf=u,u={memoizedState:uf.memoizedState,baseState:uf.baseState,baseQueue:uf.baseQueue,queue:uf.queue,next:null},cf===null?Bl.memoizedState=cf=u:cf=cf.next=u}return cf}function B1(u,l){return typeof l==="function"?l(u):l}function v6(u){var l=Zr(),f=l.queue;if(f===null)throw Error(Ju(311));f.lastRenderedReducer=u;var r=uf,n=r.baseQueue,i=f.pending;if(i!==null){if(n!==null){var t=n.next;n.next=i.next,i.next=t}r.baseQueue=n=i,f.pending=null}if(n!==null){i=n.next,r=r.baseState;var y=t=null,c=null,$=i;do{var A=$.lane;if((Ti&A)===A)c!==null&&(c=c.next={lane:0,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),r=$.hasEagerState?$.eagerState:u(r,$.action);else{var j={lane:A,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null};c===null?(y=c=j,t=r):c=c.next=j,Bl.lanes|=A,Ki|=A}$=$.next}while($!==null&&$!==i);c===null?t=r:c.next=y,Ir(r,l.memoizedState)||(vf=!0),l.memoizedState=r,l.baseState=t,l.baseQueue=c,f.lastRenderedState=r}if(u=f.interleaved,u!==null){n=u;do i=n.lane,Bl.lanes|=i,Ki|=i,n=n.next;while(n!==u)}else n===null&&(f.lanes=0);return[l.memoizedState,f.dispatch]}function k6(u){var l=Zr(),f=l.queue;if(f===null)throw Error(Ju(311));f.lastRenderedReducer=u;var{dispatch:r,pending:n}=f,i=l.memoizedState;if(n!==null){f.pending=null;var t=n=n.next;do i=u(i,t.action),t=t.next;while(t!==n);Ir(i,l.memoizedState)||(vf=!0),l.memoizedState=i,l.baseQueue===null&&(l.baseState=i),f.lastRenderedState=i}return[i,r]}function HU(){}function BU(u,l){var f=Bl,r=Zr(),n=l(),i=!Ir(r.memoizedState,n);if(i&&(r.memoizedState=n,vf=!0),r=r.queue,L4(DU.bind(null,f,r,u),[u]),r.getSnapshot!==l||i||cf!==null&&cf.memoizedState.tag&1){if(f.flags|=2048,V1(9,mU.bind(null,f,r,n,l),void 0,null),_f===null)throw Error(Ju(349));(Ti&30)!==0||VU(f,l,n)}return n}function VU(u,l,f){u.flags|=16384,u={getSnapshot:l,value:f},l=Bl.updateQueue,l===null?(l={lastEffect:null,stores:null},Bl.updateQueue=l,l.stores=[u]):(f=l.stores,f===null?l.stores=[u]:f.push(u))}function mU(u,l,f,r){l.value=f,l.getSnapshot=r,pU(l)&&SU(u)}function DU(u,l,f){return f(function(){pU(l)&&SU(u)})}function pU(u){var l=u.getSnapshot;u=u.value;try{var f=l();return!Ir(u,f)}catch(r){return!0}}function SU(u){var l=Sn(u,1);l!==null&&kr(l,u,1,-1)}function rF(u){var l=cn();return typeof u==="function"&&(u=u()),l.memoizedState=l.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:B1,lastRenderedState:u},l.queue=u,u=u.dispatch=oG.bind(null,Bl,u),[l.memoizedState,u]}function V1(u,l,f,r){return u={tag:u,create:l,destroy:f,deps:r,next:null},l=Bl.updateQueue,l===null?(l={lastEffect:null,stores:null},Bl.updateQueue=l,l.lastEffect=u.next=u):(f=l.lastEffect,f===null?l.lastEffect=u.next=u:(r=f.next,f.next=u,u.next=r,l.lastEffect=u)),u}function XU(){return Zr().memoizedState}function s_(u,l,f,r){var n=cn();Bl.flags|=u,n.memoizedState=V1(1|l,f,void 0,r===void 0?null:r)}function B$(u,l,f,r){var n=Zr();r=r===void 0?null:r;var i=void 0;if(uf!==null){var t=uf.memoizedState;if(i=t.destroy,r!==null&&q4(r,t.deps)){n.memoizedState=V1(l,f,i,r);return}}Bl.flags|=u,n.memoizedState=V1(1|l,f,i,r)}function nF(u,l){return s_(8390656,8,u,l)}function L4(u,l){return B$(2048,8,u,l)}function YU(u,l){return B$(4,2,u,l)}function PU(u,l){return B$(4,4,u,l)}function CU(u,l){if(typeof l==="function")return u=u(),l(u),function(){l(null)};if(l!==null&&l!==void 0)return u=u(),l.current=u,function(){l.current=null}}function MU(u,l,f){return f=f!==null&&f!==void 0?f.concat([u]):null,B$(4,4,CU.bind(null,l,u),f)}function T4(){}function RU(u,l){var f=Zr();l=l===void 0?null:l;var r=f.memoizedState;if(r!==null&&l!==null&&q4(l,r[1]))return r[0];return f.memoizedState=[u,l],u}function xU(u,l){var f=Zr();l=l===void 0?null:l;var r=f.memoizedState;if(r!==null&&l!==null&&q4(l,r[1]))return r[0];return u=u(),f.memoizedState=[u,l],u}function hU(u,l,f){if((Ti&21)===0)return u.baseState&&(u.baseState=!1,vf=!0),u.memoizedState=f;return Ir(f,l)||(f=gF(),Bl.lanes|=f,Ki|=f,u.baseState=!0),l}function sG(u,l){var f=jl;jl=f!==0&&4>f?f:4,u(!0);var r=b6.transition;b6.transition={};try{u(!1),l()}finally{jl=f,b6.transition=r}}function bU(){return Zr().memoizedState}function aG(u,l,f){var r=w0(u);if(f={lane:r,action:f,hasEagerState:!1,eagerState:null,next:null},vU(u))kU(l,f);else if(f=EU(u,l,f,r),f!==null){var n=pf();kr(f,u,r,n),IU(f,l,r)}}function oG(u,l,f){var r=w0(u),n={lane:r,action:f,hasEagerState:!1,eagerState:null,next:null};if(vU(u))kU(l,n);else{var i=u.alternate;if(u.lanes===0&&(i===null||i.lanes===0)&&(i=l.lastRenderedReducer,i!==null))try{var t=l.lastRenderedState,y=i(t,f);if(n.hasEagerState=!0,n.eagerState=y,Ir(y,t)){var c=l.interleaved;c===null?(n.next=n,F4(l)):(n.next=c.next,c.next=n),l.interleaved=n;return}}catch($){}finally{}f=EU(u,l,n,r),f!==null&&(n=pf(),kr(f,u,r,n),IU(f,l,r))}}function vU(u){var l=u.alternate;return u===Bl||l!==null&&l===Bl}function kU(u,l){j1=N$=!0;var f=u.pending;f===null?l.next=l:(l.next=f.next,f.next=l),u.pending=l}function IU(u,l,f){if((f&4194240)!==0){var r=l.lanes;r&=u.pendingLanes,f|=r,l.lanes=f,e8(u,f)}}var q$={readContext:Or,useCallback:Wf,useContext:Wf,useEffect:Wf,useImperativeHandle:Wf,useInsertionEffect:Wf,useLayoutEffect:Wf,useMemo:Wf,useReducer:Wf,useRef:Wf,useState:Wf,useDebugValue:Wf,useDeferredValue:Wf,useTransition:Wf,useMutableSource:Wf,useSyncExternalStore:Wf,useId:Wf,unstable_isNewReconciler:!1},dG={readContext:Or,useCallback:function(u,l){return cn().memoizedState=[u,l===void 0?null:l],u},useContext:Or,useEffect:nF,useImperativeHandle:function(u,l,f){return f=f!==null&&f!==void 0?f.concat([u]):null,s_(4194308,4,CU.bind(null,l,u),f)},useLayoutEffect:function(u,l){return s_(4194308,4,u,l)},useInsertionEffect:function(u,l){return s_(4,2,u,l)},useMemo:function(u,l){var f=cn();return l=l===void 0?null:l,u=u(),f.memoizedState=[u,l],u},useReducer:function(u,l,f){var r=cn();return l=f!==void 0?f(l):l,r.memoizedState=r.baseState=l,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:l},r.queue=u,u=u.dispatch=aG.bind(null,Bl,u),[r.memoizedState,u]},useRef:function(u){var l=cn();return u={current:u},l.memoizedState=u},useState:rF,useDebugValue:T4,useDeferredValue:function(u){return cn().memoizedState=u},useTransition:function(){var u=rF(!1),l=u[0];return u=sG.bind(null,u[1]),cn().memoizedState=u,[l,u]},useMutableSource:function(){},useSyncExternalStore:function(u,l,f){var r=Bl,n=cn();if(Ol){if(f===void 0)throw Error(Ju(407));f=f()}else{if(f=l(),_f===null)throw Error(Ju(349));(Ti&30)!==0||VU(r,l,f)}n.memoizedState=f;var i={value:f,getSnapshot:l};return n.queue=i,nF(DU.bind(null,r,i,u),[u]),r.flags|=2048,V1(9,mU.bind(null,r,i,f,l),void 0,null),f},useId:function(){var u=cn(),l=_f.identifierPrefix;if(Ol){var f=Vn,r=Bn;f=(r&~(1<<32-vr(r)-1)).toString(32)+f,l=":"+l+"R"+f,f=H1++,0<f&&(l+="H"+f.toString(32)),l+=":"}else f=gG++,l=":"+l+"r"+f.toString(32)+":";return u.memoizedState=l},unstable_isNewReconciler:!1},eG={readContext:Or,useCallback:RU,useContext:Or,useEffect:L4,useImperativeHandle:MU,useInsertionEffect:YU,useLayoutEffect:PU,useMemo:xU,useReducer:v6,useRef:XU,useState:function(){return v6(B1)},useDebugValue:T4,useDeferredValue:function(u){var l=Zr();return hU(l,uf.memoizedState,u)},useTransition:function(){var u=v6(B1)[0],l=Zr().memoizedState;return[u,l]},useMutableSource:HU,useSyncExternalStore:BU,useId:bU,unstable_isNewReconciler:!1},uz={readContext:Or,useCallback:RU,useContext:Or,useEffect:L4,useImperativeHandle:MU,useInsertionEffect:YU,useLayoutEffect:PU,useMemo:xU,useReducer:k6,useRef:XU,useState:function(){return k6(B1)},useDebugValue:T4,useDeferredValue:function(u){var l=Zr();return uf===null?l.memoizedState=u:hU(l,uf.memoizedState,u)},useTransition:function(){var u=k6(B1)[0],l=Zr().memoizedState;return[u,l]},useMutableSource:HU,useSyncExternalStore:BU,useId:bU,unstable_isNewReconciler:!1};function xr(u,l){if(u&&u.defaultProps){l=Vl({},l),u=u.defaultProps;for(var f in u)l[f]===void 0&&(l[f]=u[f]);return l}return l}function H8(u,l,f,r){l=u.memoizedState,f=f(r,l),f=f===null||f===void 0?l:Vl({},l,f),u.memoizedState=f,u.lanes===0&&(u.updateQueue.baseState=f)}var V$={isMounted:function(u){return(u=u._reactInternals)?Ei(u)===u:!1},enqueueSetState:function(u,l,f){u=u._reactInternals;var r=pf(),n=w0(u),i=mn(r,n);i.payload=l,f!==void 0&&f!==null&&(i.callback=f),l=N0(u,i,n),l!==null&&(kr(l,u,n,r),I_(l,u,n))},enqueueReplaceState:function(u,l,f){u=u._reactInternals;var r=pf(),n=w0(u),i=mn(r,n);i.tag=1,i.payload=l,f!==void 0&&f!==null&&(i.callback=f),l=N0(u,i,n),l!==null&&(kr(l,u,n,r),I_(l,u,n))},enqueueForceUpdate:function(u,l){u=u._reactInternals;var f=pf(),r=w0(u),n=mn(f,r);n.tag=2,l!==void 0&&l!==null&&(n.callback=l),l=N0(u,n,r),l!==null&&(kr(l,u,r,f),I_(l,u,r))}};function iF(u,l,f,r,n,i,t){return u=u.stateNode,typeof u.shouldComponentUpdate==="function"?u.shouldComponentUpdate(r,i,t):l.prototype&&l.prototype.isPureReactComponent?!K1(f,r)||!K1(n,i):!0}function gU(u,l,f){var r=!1,n=T0,i=l.contextType;return typeof i==="object"&&i!==null?i=Or(i):(n=If(l)?Wi:Kf.current,r=l.contextTypes,i=(r=r!==null&&r!==void 0)?pt(u,n):T0),l=new l(f,i),u.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=V$,u.stateNode=l,l._reactInternals=u,r&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=n,u.__reactInternalMemoizedMaskedChildContext=i),l}function tF(u,l,f,r){u=l.state,typeof l.componentWillReceiveProps==="function"&&l.componentWillReceiveProps(f,r),typeof l.UNSAFE_componentWillReceiveProps==="function"&&l.UNSAFE_componentWillReceiveProps(f,r),l.state!==u&&V$.enqueueReplaceState(l,l.state,null)}function B8(u,l,f,r){var n=u.stateNode;n.props=f,n.state=u.memoizedState,n.refs={},U4(u);var i=l.contextType;typeof i==="object"&&i!==null?n.context=Or(i):(i=If(l)?Wi:Kf.current,n.context=pt(u,i)),n.state=u.memoizedState,i=l.getDerivedStateFromProps,typeof i==="function"&&(H8(u,l,i,f),n.state=u.memoizedState),typeof l.getDerivedStateFromProps==="function"||typeof n.getSnapshotBeforeUpdate==="function"||typeof n.UNSAFE_componentWillMount!=="function"&&typeof n.componentWillMount!=="function"||(l=n.state,typeof n.componentWillMount==="function"&&n.componentWillMount(),typeof n.UNSAFE_componentWillMount==="function"&&n.UNSAFE_componentWillMount(),l!==n.state&&V$.enqueueReplaceState(n,n.state,null),J$(u,f,n,r),n.state=u.memoizedState),typeof n.componentDidMount==="function"&&(u.flags|=4194308)}function Pt(u,l){try{var f="",r=l;do f+=BK(r),r=r.return;while(r);var n=f}catch(i){n=` +`+n[t].replace(" at new "," at ");return l.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",l.displayName)),c}while(1<=t&&0<=y);break}}}finally{v6=!1,Error.prepareStackTrace=r}return(l=l?l.displayName||l.name:"")?t1(l):""}function eT(l){switch(l.tag){case 5:return t1(l.type);case 16:return t1("Lazy");case 13:return t1("Suspense");case 19:return t1("SuspenseList");case 0:case 2:case 15:return l=s6(l.type,!1),l;case 11:return l=s6(l.type.render,!1),l;case 1:return l=s6(l.type,!0),l;default:return""}}function U8(l){if(l==null)return null;if(typeof l==="function")return l.displayName||l.name||null;if(typeof l==="string")return l;switch(l){case Lt:return"Fragment";case Wt:return"Portal";case j8:return"Profiler";case c4:return"StrictMode";case F8:return"Suspense";case J8:return"SuspenseList"}if(typeof l==="object")switch(l.$$typeof){case bF:return(l.displayName||"Context")+".Consumer";case xF:return(l._context.displayName||"Context")+".Provider";case _4:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case $4:return u=l.displayName||null,u!==null?u:U8(l.type)||"Memo";case Fi:u=l._payload,l=l._init;try{return U8(l(u))}catch(r){}}return null}function lm(l){var u=l.type;switch(l.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=u.render,l=l.displayName||l.name||"",u.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return U8(u);case 8:return u===c4?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u==="function")return u.displayName||u.name||null;if(typeof u==="string")return u}return null}function Ei(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function sF(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function um(l){var u=sF(l)?"checked":"value",r=Object.getOwnPropertyDescriptor(l.constructor.prototype,u),f=""+l[u];if(!l.hasOwnProperty(u)&&typeof r<"u"&&typeof r.get==="function"&&typeof r.set==="function"){var{get:n,set:i}=r;return Object.defineProperty(l,u,{configurable:!0,get:function(){return n.call(this)},set:function(t){f=""+t,i.call(this,t)}}),Object.defineProperty(l,u,{enumerable:r.enumerable}),{getValue:function(){return f},setValue:function(t){f=""+t},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function P_(l){l._valueTracker||(l._valueTracker=um(l))}function kF(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var r=u.getValue(),f="";return l&&(f=sF(l)?l.checked?"true":"false":l.value),l=f,l!==r?(u.setValue(l),!0):!1}function _$(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch(u){return l.body}}function N8(l,u){var r=u.checked;return Bu({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r!=null?r:l._wrapperState.initialChecked})}function h7(l,u){var r=u.defaultValue==null?"":u.defaultValue,f=u.checked!=null?u.checked:u.defaultChecked;r=Ei(u.value!=null?u.value:r),l._wrapperState={initialChecked:f,initialValue:r,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function gF(l,u){u=u.checked,u!=null&&y4(l,"checked",u,!1)}function Q8(l,u){gF(l,u);var r=Ei(u.value),f=u.type;if(r!=null)if(f==="number"){if(r===0&&l.value===""||l.value!=r)l.value=""+r}else l.value!==""+r&&(l.value=""+r);else if(f==="submit"||f==="reset"){l.removeAttribute("value");return}u.hasOwnProperty("value")?w8(l,u.type,r):u.hasOwnProperty("defaultValue")&&w8(l,u.type,Ei(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function R7(l,u,r){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var f=u.type;if(!(f!=="submit"&&f!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+l._wrapperState.initialValue,r||u===l.value||(l.value=u),l.defaultValue=u}r=l.name,r!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,r!==""&&(l.name=r)}function w8(l,u,r){if(u!=="number"||_$(l.ownerDocument)!==l)r==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+r&&(l.defaultValue=""+r)}var y1=Array.isArray;function Bt(l,u,r,f){if(l=l.options,u){u={};for(var n=0;n<r.length;n++)u["$"+r[n]]=!0;for(r=0;r<l.length;r++)n=u.hasOwnProperty("$"+l[r].value),l[r].selected!==n&&(l[r].selected=n),n&&f&&(l[r].defaultSelected=!0)}else{r=""+Ei(r),u=null;for(n=0;n<l.length;n++){if(l[n].value===r){l[n].selected=!0,f&&(l[n].defaultSelected=!0);return}u!==null||l[n].disabled||(u=l[n])}u!==null&&(u.selected=!0)}}function q8(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(Ul(91));return Bu({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function x7(l,u){var r=u.value;if(r==null){if(r=u.children,u=u.defaultValue,r!=null){if(u!=null)throw Error(Ul(92));if(y1(r)){if(1<r.length)throw Error(Ul(93));r=r[0]}u=r}u==null&&(u=""),r=u}l._wrapperState={initialValue:Ei(r)}}function IF(l,u){var r=Ei(u.value),f=Ei(u.defaultValue);r!=null&&(r=""+r,r!==l.value&&(l.value=r),u.defaultValue==null&&l.defaultValue!==r&&(l.defaultValue=r)),f!=null&&(l.defaultValue=""+f)}function b7(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function aF(l){switch(l){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function W8(l,u){return l==null||l==="http://www.w3.org/1999/xhtml"?aF(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var C_,oF=function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,r,f,n){MSApp.execUnsafeLocalFunction(function(){return l(u,r,f,n)})}:l}(function(l,u){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=u;else{C_=C_||document.createElement("div"),C_.innerHTML="<svg>"+u.valueOf().toString()+"</svg>";for(u=C_.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function m1(l,u){if(u){var r=l.firstChild;if(r&&r===l.lastChild&&r.nodeType===3){r.nodeValue=u;return}}l.textContent=u}var J1={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},rm=["Webkit","ms","Moz","O"];Object.keys(J1).forEach(function(l){rm.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),J1[u]=J1[l]})});function dF(l,u,r){return u==null||typeof u==="boolean"||u===""?"":r||typeof u!=="number"||u===0||J1.hasOwnProperty(l)&&J1[l]?(""+u).trim():u+"px"}function eF(l,u){l=l.style;for(var r in u)if(u.hasOwnProperty(r)){var f=r.indexOf("--")===0,n=dF(r,u[r],f);r==="float"&&(r="cssFloat"),f?l.setProperty(r,n):l[r]=n}}var fm=Bu({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function L8(l,u){if(u){if(fm[l]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(Ul(137,l));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(Ul(60));if(typeof u.dangerouslySetInnerHTML!=="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(Ul(61))}if(u.style!=null&&typeof u.style!=="object")throw Error(Ul(62))}}function G8(l,u){if(l.indexOf("-")===-1)return typeof u.is==="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var T8=null;function A4(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var m8=null,Dt=null,Vt=null;function v7(l){if(l=R1(l)){if(typeof m8!=="function")throw Error(Ul(280));var u=l.stateNode;u&&(u=Y$(u),m8(l.stateNode,l.type,u))}}function lJ(l){Dt?Vt?Vt.push(l):Vt=[l]:Dt=l}function uJ(){if(Dt){var l=Dt,u=Vt;if(Vt=Dt=null,v7(l),u)for(l=0;l<u.length;l++)v7(u[l])}}function rJ(l,u){return l(u)}function fJ(){}var k6=!1;function nJ(l,u,r){if(k6)return l(u,r);k6=!0;try{return rJ(l,u,r)}finally{if(k6=!1,Dt!==null||Vt!==null)fJ(),uJ()}}function K1(l,u){var r=l.stateNode;if(r===null)return null;var f=Y$(r);if(f===null)return null;r=f[u];l:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(l=l.type,f=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!f;break l;default:l=!1}if(l)return null;if(r&&typeof r!=="function")throw Error(Ul(231,u,typeof r));return r}var K8=!1;if(Pn)try{U0={},Object.defineProperty(U0,"passive",{get:function(){K8=!0}}),window.addEventListener("test",U0,U0),window.removeEventListener("test",U0,U0)}catch(l){K8=!1}var U0;function nm(l,u,r,f,n,i,t,y,c){var $=Array.prototype.slice.call(arguments,3);try{u.apply(r,$)}catch(A){this.onError(A)}}var U1=!1,$$=null,A$=!1,z8=null,im={onError:function(l){U1=!0,$$=l}};function tm(l,u,r,f,n,i,t,y,c){U1=!1,$$=null,nm.apply(im,arguments)}function ym(l,u,r,f,n,i,t,y,c){if(tm.apply(this,arguments),U1){if(U1){var $=$$;U1=!1,$$=null}else throw Error(Ul(198));A$||(A$=!0,z8=$)}}function Z0(l){var u=l,r=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(r=u.return),l=u.return;while(l)}return u.tag===3?r:null}function iJ(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function s7(l){if(Z0(l)!==l)throw Error(Ul(188))}function cm(l){var u=l.alternate;if(!u){if(u=Z0(l),u===null)throw Error(Ul(188));return u!==l?null:l}for(var r=l,f=u;;){var n=r.return;if(n===null)break;var i=n.alternate;if(i===null){if(f=n.return,f!==null){r=f;continue}break}if(n.child===i.child){for(i=n.child;i;){if(i===r)return s7(n),l;if(i===f)return s7(n),u;i=i.sibling}throw Error(Ul(188))}if(r.return!==f.return)r=n,f=i;else{for(var t=!1,y=n.child;y;){if(y===r){t=!0,r=n,f=i;break}if(y===f){t=!0,f=n,r=i;break}y=y.sibling}if(!t){for(y=i.child;y;){if(y===r){t=!0,r=i,f=n;break}if(y===f){t=!0,f=i,r=n;break}y=y.sibling}if(!t)throw Error(Ul(189))}}if(r.alternate!==f)throw Error(Ul(190))}if(r.tag!==3)throw Error(Ul(188));return r.stateNode.current===r?l:u}function tJ(l){return l=cm(l),l!==null?yJ(l):null}function yJ(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=yJ(l);if(u!==null)return u;l=l.sibling}return null}var{unstable_scheduleCallback:cJ,unstable_cancelCallback:k7,unstable_shouldYield:_m,unstable_requestPaint:$m,unstable_now:su,unstable_getCurrentPriorityLevel:Am,unstable_ImmediatePriority:j4,unstable_UserBlockingPriority:_J,unstable_NormalPriority:j$,unstable_LowPriority:jm,unstable_IdlePriority:$J}=jf,D$=null,jn=null;function Fm(l){if(jn&&typeof jn.onCommitFiberRoot==="function")try{jn.onCommitFiberRoot(D$,l,void 0,(l.current.flags&128)===128)}catch(u){}}var sf=Math.clz32?Math.clz32:Nm,Jm=Math.log,Um=Math.LN2;function Nm(l){return l>>>=0,l===0?32:31-(Jm(l)/Um|0)|0}var M_=64,h_=4194304;function c1(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function F$(l,u){var r=l.pendingLanes;if(r===0)return 0;var f=0,n=l.suspendedLanes,i=l.pingedLanes,t=r&268435455;if(t!==0){var y=t&~n;y!==0?f=c1(y):(i&=t,i!==0&&(f=c1(i)))}else t=r&~n,t!==0?f=c1(t):i!==0&&(f=c1(i));if(f===0)return 0;if(u!==0&&u!==f&&(u&n)===0&&(n=f&-f,i=u&-u,n>=i||n===16&&(i&4194240)!==0))return u;if((f&4)!==0&&(f|=r&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=f;0<u;)r=31-sf(u),n=1<<r,f|=l[r],u&=~n;return f}function Qm(l,u){switch(l){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5000;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wm(l,u){for(var{suspendedLanes:r,pingedLanes:f,expirationTimes:n,pendingLanes:i}=l;0<i;){var t=31-sf(i),y=1<<t,c=n[t];if(c===-1){if((y&r)===0||(y&f)!==0)n[t]=Qm(y,u)}else c<=u&&(l.expiredLanes|=y);i&=~y}}function E8(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function AJ(){var l=M_;return M_<<=1,(M_&4194240)===0&&(M_=64),l}function g6(l){for(var u=[],r=0;31>r;r++)u.push(l);return u}function M1(l,u,r){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-sf(u),l[u]=r}function qm(l,u){var r=l.pendingLanes&~u;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=u,l.mutableReadLanes&=u,l.entangledLanes&=u,u=l.entanglements;var f=l.eventTimes;for(l=l.expirationTimes;0<r;){var n=31-sf(r),i=1<<n;u[n]=0,f[n]=-1,l[n]=-1,r&=~i}}function F4(l,u){var r=l.entangledLanes|=u;for(l=l.entanglements;r;){var f=31-sf(r),n=1<<f;n&u|l[f]&u&&(l[f]|=u),r&=~n}}var Uu=0;function jJ(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var FJ,J4,JJ,UJ,NJ,O8=!1,R_=[],qi=null,Wi=null,Li=null,z1=new Map,E1=new Map,Ui=[],Wm="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function g7(l,u){switch(l){case"focusin":case"focusout":qi=null;break;case"dragenter":case"dragleave":Wi=null;break;case"mouseover":case"mouseout":Li=null;break;case"pointerover":case"pointerout":z1.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":E1.delete(u.pointerId)}}function l1(l,u,r,f,n,i){if(l===null||l.nativeEvent!==i)return l={blockedOn:u,domEventName:r,eventSystemFlags:f,nativeEvent:i,targetContainers:[n]},u!==null&&(u=R1(u),u!==null&&J4(u)),l;return l.eventSystemFlags|=f,u=l.targetContainers,n!==null&&u.indexOf(n)===-1&&u.push(n),l}function Lm(l,u,r,f,n){switch(u){case"focusin":return qi=l1(qi,l,u,r,f,n),!0;case"dragenter":return Wi=l1(Wi,l,u,r,f,n),!0;case"mouseover":return Li=l1(Li,l,u,r,f,n),!0;case"pointerover":var i=n.pointerId;return z1.set(i,l1(z1.get(i)||null,l,u,r,f,n)),!0;case"gotpointercapture":return i=n.pointerId,E1.set(i,l1(E1.get(i)||null,l,u,r,f,n)),!0}return!1}function QJ(l){var u=w0(l.target);if(u!==null){var r=Z0(u);if(r!==null){if(u=r.tag,u===13){if(u=iJ(r),u!==null){l.blockedOn=u,NJ(l.priority,function(){JJ(r)});return}}else if(u===3&&r.stateNode.current.memoizedState.isDehydrated){l.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}l.blockedOn=null}function d_(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var r=Z8(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(r===null){r=l.nativeEvent;var f=new r.constructor(r.type,r);T8=f,r.target.dispatchEvent(f),T8=null}else return u=R1(r),u!==null&&J4(u),l.blockedOn=r,!1;u.shift()}return!0}function I7(l,u,r){d_(l)&&r.delete(u)}function Gm(){O8=!1,qi!==null&&d_(qi)&&(qi=null),Wi!==null&&d_(Wi)&&(Wi=null),Li!==null&&d_(Li)&&(Li=null),z1.forEach(I7),E1.forEach(I7)}function u1(l,u){l.blockedOn===u&&(l.blockedOn=null,O8||(O8=!0,jf.unstable_scheduleCallback(jf.unstable_NormalPriority,Gm)))}function O1(l){function u(n){return u1(n,l)}if(0<R_.length){u1(R_[0],l);for(var r=1;r<R_.length;r++){var f=R_[r];f.blockedOn===l&&(f.blockedOn=null)}}qi!==null&&u1(qi,l),Wi!==null&&u1(Wi,l),Li!==null&&u1(Li,l),z1.forEach(u),E1.forEach(u);for(r=0;r<Ui.length;r++)f=Ui[r],f.blockedOn===l&&(f.blockedOn=null);for(;0<Ui.length&&(r=Ui[0],r.blockedOn===null);)QJ(r),r.blockedOn===null&&Ui.shift()}var St=Rn.ReactCurrentBatchConfig,J$=!0;function Tm(l,u,r,f){var n=Uu,i=St.transition;St.transition=null;try{Uu=1,U4(l,u,r,f)}finally{Uu=n,St.transition=i}}function mm(l,u,r,f){var n=Uu,i=St.transition;St.transition=null;try{Uu=4,U4(l,u,r,f)}finally{Uu=n,St.transition=i}}function U4(l,u,r,f){if(J$){var n=Z8(l,u,r,f);if(n===null)l8(l,u,f,U$,r),g7(l,f);else if(Lm(n,l,u,r,f))f.stopPropagation();else if(g7(l,f),u&4&&-1<Wm.indexOf(l)){for(;n!==null;){var i=R1(n);if(i!==null&&FJ(i),i=Z8(l,u,r,f),i===null&&l8(l,u,f,U$,r),i===n)break;n=i}n!==null&&f.stopPropagation()}else l8(l,u,f,null,r)}}var U$=null;function Z8(l,u,r,f){if(U$=null,l=A4(f),l=w0(l),l!==null)if(u=Z0(l),u===null)l=null;else if(r=u.tag,r===13){if(l=iJ(u),l!==null)return l;l=null}else if(r===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null);return U$=l,null}function wJ(l){switch(l){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Am()){case j4:return 1;case _J:return 4;case j$:case jm:return 16;case $J:return 536870912;default:return 16}default:return 16}}var Qi=null,N4=null,e_=null;function qJ(){if(e_)return e_;var l,u=N4,r=u.length,f,n="value"in Qi?Qi.value:Qi.textContent,i=n.length;for(l=0;l<r&&u[l]===n[l];l++);var t=r-l;for(f=1;f<=t&&u[r-f]===n[i-f];f++);return e_=n.slice(l,1<f?1-f:void 0)}function l$(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function x_(){return!0}function a7(){return!1}function Ff(l){function u(r,f,n,i,t){this._reactName=r,this._targetInst=n,this.type=f,this.nativeEvent=i,this.target=t,this.currentTarget=null;for(var y in l)l.hasOwnProperty(y)&&(r=l[y],this[y]=r?r(i):i[y]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?x_:a7,this.isPropagationStopped=a7,this}return Bu(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!=="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=x_)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!=="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=x_)},persist:function(){},isPersistent:x_}),u}var vt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Q4=Ff(vt),h1=Bu({},vt,{view:0,detail:0}),Km=Ff(h1),I6,a6,r1,V$=Bu({},h1,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:w4,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){if("movementX"in l)return l.movementX;return l!==r1&&(r1&&l.type==="mousemove"?(I6=l.screenX-r1.screenX,a6=l.screenY-r1.screenY):a6=I6=0,r1=l),I6},movementY:function(l){return"movementY"in l?l.movementY:a6}}),o7=Ff(V$),zm=Bu({},V$,{dataTransfer:0}),Em=Ff(zm),Om=Bu({},h1,{relatedTarget:0}),o6=Ff(Om),Zm=Bu({},vt,{animationName:0,elapsedTime:0,pseudoElement:0}),pm=Ff(Zm),Hm=Bu({},vt,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),Bm=Ff(Hm),Dm=Bu({},vt,{data:0}),d7=Ff(Dm),Vm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Sm={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Xm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ym(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=Xm[l])?!!u[l]:!1}function w4(){return Ym}var Pm=Bu({},h1,{key:function(l){if(l.key){var u=Vm[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=l$(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?Sm[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:w4,charCode:function(l){return l.type==="keypress"?l$(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?l$(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Cm=Ff(Pm),Mm=Bu({},V$,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),e7=Ff(Mm),hm=Bu({},h1,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:w4}),Rm=Ff(hm),xm=Bu({},vt,{propertyName:0,elapsedTime:0,pseudoElement:0}),bm=Ff(xm),vm=Bu({},V$,{deltaX:function(l){return"deltaX"in l?l.deltaX:("wheelDeltaX"in l)?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:("wheelDeltaY"in l)?-l.wheelDeltaY:("wheelDelta"in l)?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),sm=Ff(vm),km=[9,13,27,32],q4=Pn&&"CompositionEvent"in window,N1=null;Pn&&"documentMode"in document&&(N1=document.documentMode);var gm=Pn&&"TextEvent"in window&&!N1,WJ=Pn&&(!q4||N1&&8<N1&&11>=N1),lF=String.fromCharCode(32),uF=!1;function LJ(l,u){switch(l){case"keyup":return km.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function GJ(l){return l=l.detail,typeof l==="object"&&"data"in l?l.data:null}var Gt=!1;function Im(l,u){switch(l){case"compositionend":return GJ(u);case"keypress":if(u.which!==32)return null;return uF=!0,lF;case"textInput":return l=u.data,l===lF&&uF?null:l;default:return null}}function am(l,u){if(Gt)return l==="compositionend"||!q4&&LJ(l,u)?(l=qJ(),e_=N4=Qi=null,Gt=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return WJ&&u.locale!=="ko"?null:u.data;default:return null}}var om={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function rF(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!om[l.type]:u==="textarea"?!0:!1}function TJ(l,u,r,f){lJ(f),u=N$(u,"onChange"),0<u.length&&(r=new Q4("onChange","change",null,r,f),l.push({event:r,listeners:u}))}var Q1=null,Z1=null;function dm(l){VJ(l,0)}function S$(l){var u=Kt(l);if(kF(u))return l}function em(l,u){if(l==="change")return u}var mJ=!1;if(Pn){if(Pn){if($1="oninput"in document,!$1)u$=document.createElement("div"),u$.setAttribute("oninput","return;"),$1=typeof u$.oninput==="function";_1=$1}else _1=!1;mJ=_1&&(!document.documentMode||9<document.documentMode)}var _1,$1,u$;function fF(){Q1&&(Q1.detachEvent("onpropertychange",KJ),Z1=Q1=null)}function KJ(l){if(l.propertyName==="value"&&S$(Z1)){var u=[];TJ(u,Z1,l,A4(l)),nJ(dm,u)}}function lK(l,u,r){l==="focusin"?(fF(),Q1=u,Z1=r,Q1.attachEvent("onpropertychange",KJ)):l==="focusout"&&fF()}function uK(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return S$(Z1)}function rK(l,u){if(l==="click")return S$(u)}function fK(l,u){if(l==="input"||l==="change")return S$(u)}function nK(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var gf=typeof Object.is==="function"?Object.is:nK;function p1(l,u){if(gf(l,u))return!0;if(typeof l!=="object"||l===null||typeof u!=="object"||u===null)return!1;var r=Object.keys(l),f=Object.keys(u);if(r.length!==f.length)return!1;for(f=0;f<r.length;f++){var n=r[f];if(!A8.call(u,n)||!gf(l[n],u[n]))return!1}return!0}function nF(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function iF(l,u){var r=nF(l);l=0;for(var f;r;){if(r.nodeType===3){if(f=l+r.textContent.length,l<=u&&f>=u)return{node:r,offset:u-l};l=f}l:{for(;r;){if(r.nextSibling){r=r.nextSibling;break l}r=r.parentNode}r=void 0}r=nF(r)}}function zJ(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?zJ(l,u.parentNode):("contains"in l)?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function EJ(){for(var l=window,u=_$();u instanceof l.HTMLIFrameElement;){try{var r=typeof u.contentWindow.location.href==="string"}catch(f){r=!1}if(r)l=u.contentWindow;else break;u=_$(l.document)}return u}function W4(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}function iK(l){var u=EJ(),r=l.focusedElem,f=l.selectionRange;if(u!==r&&r&&r.ownerDocument&&zJ(r.ownerDocument.documentElement,r)){if(f!==null&&W4(r)){if(u=f.start,l=f.end,l===void 0&&(l=u),"selectionStart"in r)r.selectionStart=u,r.selectionEnd=Math.min(l,r.value.length);else if(l=(u=r.ownerDocument||document)&&u.defaultView||window,l.getSelection){l=l.getSelection();var n=r.textContent.length,i=Math.min(f.start,n);f=f.end===void 0?i:Math.min(f.end,n),!l.extend&&i>f&&(n=f,f=i,i=n),n=iF(r,i);var t=iF(r,f);n&&t&&(l.rangeCount!==1||l.anchorNode!==n.node||l.anchorOffset!==n.offset||l.focusNode!==t.node||l.focusOffset!==t.offset)&&(u=u.createRange(),u.setStart(n.node,n.offset),l.removeAllRanges(),i>f?(l.addRange(u),l.extend(t.node,t.offset)):(u.setEnd(t.node,t.offset),l.addRange(u)))}}u=[];for(l=r;l=l.parentNode;)l.nodeType===1&&u.push({element:l,left:l.scrollLeft,top:l.scrollTop});typeof r.focus==="function"&&r.focus();for(r=0;r<u.length;r++)l=u[r],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var tK=Pn&&"documentMode"in document&&11>=document.documentMode,Tt=null,p8=null,w1=null,H8=!1;function tF(l,u,r){var f=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;H8||Tt==null||Tt!==_$(f)||(f=Tt,("selectionStart"in f)&&W4(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),w1&&p1(w1,f)||(w1=f,f=N$(p8,"onSelect"),0<f.length&&(u=new Q4("onSelect","select",null,u,r),l.push({event:u,listeners:f}),u.target=Tt)))}function b_(l,u){var r={};return r[l.toLowerCase()]=u.toLowerCase(),r["Webkit"+l]="webkit"+u,r["Moz"+l]="moz"+u,r}var mt={animationend:b_("Animation","AnimationEnd"),animationiteration:b_("Animation","AnimationIteration"),animationstart:b_("Animation","AnimationStart"),transitionend:b_("Transition","TransitionEnd")},d6={},OJ={};Pn&&(OJ=document.createElement("div").style,("AnimationEvent"in window)||(delete mt.animationend.animation,delete mt.animationiteration.animation,delete mt.animationstart.animation),("TransitionEvent"in window)||delete mt.transitionend.transition);function X$(l){if(d6[l])return d6[l];if(!mt[l])return l;var u=mt[l],r;for(r in u)if(u.hasOwnProperty(r)&&r in OJ)return d6[l]=u[r];return l}var ZJ=X$("animationend"),pJ=X$("animationiteration"),HJ=X$("animationstart"),BJ=X$("transitionend"),DJ=new Map,yF="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Zi(l,u){DJ.set(l,u),O0(u,[l])}for(A1=0;A1<yF.length;A1++)j1=yF[A1],B8=j1.toLowerCase(),D8=j1[0].toUpperCase()+j1.slice(1),Zi(B8,"on"+D8);var j1,B8,D8,A1;Zi(ZJ,"onAnimationEnd");Zi(pJ,"onAnimationIteration");Zi(HJ,"onAnimationStart");Zi("dblclick","onDoubleClick");Zi("focusin","onFocus");Zi("focusout","onBlur");Zi(BJ,"onTransitionEnd");Pt("onMouseEnter",["mouseout","mouseover"]);Pt("onMouseLeave",["mouseout","mouseover"]);Pt("onPointerEnter",["pointerout","pointerover"]);Pt("onPointerLeave",["pointerout","pointerover"]);O0("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));O0("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));O0("onBeforeInput",["compositionend","keypress","textInput","paste"]);O0("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));O0("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));O0("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var F1="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),yK=new Set("cancel close invalid load scroll toggle".split(" ").concat(F1));function cF(l,u,r){var f=l.type||"unknown-event";l.currentTarget=r,ym(f,u,void 0,l),l.currentTarget=null}function VJ(l,u){u=(u&4)!==0;for(var r=0;r<l.length;r++){var f=l[r],n=f.event;f=f.listeners;l:{var i=void 0;if(u)for(var t=f.length-1;0<=t;t--){var y=f[t],c=y.instance,$=y.currentTarget;if(y=y.listener,c!==i&&n.isPropagationStopped())break l;cF(n,y,$),i=c}else for(t=0;t<f.length;t++){if(y=f[t],c=y.instance,$=y.currentTarget,y=y.listener,c!==i&&n.isPropagationStopped())break l;cF(n,y,$),i=c}}}if(A$)throw l=z8,A$=!1,z8=null,l}function Ku(l,u){var r=u[P8];r===void 0&&(r=u[P8]=new Set);var f=l+"__bubble";r.has(f)||(SJ(u,l,2,!1),r.add(f))}function e6(l,u,r){var f=0;u&&(f|=4),SJ(r,l,f,u)}var v_="_reactListening"+Math.random().toString(36).slice(2);function H1(l){if(!l[v_]){l[v_]=!0,RF.forEach(function(r){r!=="selectionchange"&&(yK.has(r)||e6(r,!1,l),e6(r,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[v_]||(u[v_]=!0,e6("selectionchange",!1,u))}}function SJ(l,u,r,f){switch(wJ(u)){case 1:var n=Tm;break;case 4:n=mm;break;default:n=U4}r=n.bind(null,u,r,l),n=void 0,!K8||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(n=!0),f?n!==void 0?l.addEventListener(u,r,{capture:!0,passive:n}):l.addEventListener(u,r,!0):n!==void 0?l.addEventListener(u,r,{passive:n}):l.addEventListener(u,r,!1)}function l8(l,u,r,f,n){var i=f;if((u&1)===0&&(u&2)===0&&f!==null)l:for(;;){if(f===null)return;var t=f.tag;if(t===3||t===4){var y=f.stateNode.containerInfo;if(y===n||y.nodeType===8&&y.parentNode===n)break;if(t===4)for(t=f.return;t!==null;){var c=t.tag;if(c===3||c===4){if(c=t.stateNode.containerInfo,c===n||c.nodeType===8&&c.parentNode===n)return}t=t.return}for(;y!==null;){if(t=w0(y),t===null)return;if(c=t.tag,c===5||c===6){f=i=t;continue l}y=y.parentNode}}f=f.return}nJ(function(){var $=i,A=A4(r),j=[];l:{var F=DJ.get(l);if(F!==void 0){var U=Q4,N=l;switch(l){case"keypress":if(l$(r)===0)break l;case"keydown":case"keyup":U=Cm;break;case"focusin":N="focus",U=o6;break;case"focusout":N="blur",U=o6;break;case"beforeblur":case"afterblur":U=o6;break;case"click":if(r.button===2)break l;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":U=o7;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":U=Em;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":U=Rm;break;case ZJ:case pJ:case HJ:U=pm;break;case BJ:U=bm;break;case"scroll":U=Km;break;case"wheel":U=sm;break;case"copy":case"cut":case"paste":U=Bm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":U=e7}var W=(u&4)!==0,L=!W&&l==="scroll",J=W?F!==null?F+"Capture":null:F;W=[];for(var w=$,Q;w!==null;){Q=w;var q=Q.stateNode;if(Q.tag===5&&q!==null&&(Q=q,J!==null&&(q=K1(w,J),q!=null&&W.push(B1(w,q,Q)))),L)break;w=w.return}0<W.length&&(F=new U(F,N,null,r,A),j.push({event:F,listeners:W}))}}if((u&7)===0){l:{if(F=l==="mouseover"||l==="pointerover",U=l==="mouseout"||l==="pointerout",F&&r!==T8&&(N=r.relatedTarget||r.fromElement)&&(w0(N)||N[Cn]))break l;if(U||F){if(F=A.window===A?A:(F=A.ownerDocument)?F.defaultView||F.parentWindow:window,U){if(N=r.relatedTarget||r.toElement,U=$,N=N?w0(N):null,N!==null&&(L=Z0(N),N!==L||N.tag!==5&&N.tag!==6))N=null}else U=null,N=$;if(U!==N){if(W=o7,q="onMouseLeave",J="onMouseEnter",w="mouse",l==="pointerout"||l==="pointerover")W=e7,q="onPointerLeave",J="onPointerEnter",w="pointer";if(L=U==null?F:Kt(U),Q=N==null?F:Kt(N),F=new W(q,w+"leave",U,r,A),F.target=L,F.relatedTarget=Q,q=null,w0(A)===$&&(W=new W(J,w+"enter",N,r,A),W.target=Q,W.relatedTarget=L,q=W),L=q,U&&N)u:{W=U,J=N,w=0;for(Q=W;Q;Q=wt(Q))w++;Q=0;for(q=J;q;q=wt(q))Q++;for(;0<w-Q;)W=wt(W),w--;for(;0<Q-w;)J=wt(J),Q--;for(;w--;){if(W===J||J!==null&&W===J.alternate)break u;W=wt(W),J=wt(J)}W=null}else W=null;U!==null&&_F(j,F,U,W,!1),N!==null&&L!==null&&_F(j,L,N,W,!0)}}}l:{if(F=$?Kt($):window,U=F.nodeName&&F.nodeName.toLowerCase(),U==="select"||U==="input"&&F.type==="file")var T=em;else if(rF(F))if(mJ)T=fK;else{T=uK;var O=lK}else(U=F.nodeName)&&U.toLowerCase()==="input"&&(F.type==="checkbox"||F.type==="radio")&&(T=rK);if(T&&(T=T(l,$))){TJ(j,T,r,A);break l}O&&O(l,F,$),l==="focusout"&&(O=F._wrapperState)&&O.controlled&&F.type==="number"&&w8(F,"number",F.value)}switch(O=$?Kt($):window,l){case"focusin":if(rF(O)||O.contentEditable==="true")Tt=O,p8=$,w1=null;break;case"focusout":w1=p8=Tt=null;break;case"mousedown":H8=!0;break;case"contextmenu":case"mouseup":case"dragend":H8=!1,tF(j,r,A);break;case"selectionchange":if(tK)break;case"keydown":case"keyup":tF(j,r,A)}var Z;if(q4)l:{switch(l){case"compositionstart":var E="onCompositionStart";break l;case"compositionend":E="onCompositionEnd";break l;case"compositionupdate":E="onCompositionUpdate";break l}E=void 0}else Gt?LJ(l,r)&&(E="onCompositionEnd"):l==="keydown"&&r.keyCode===229&&(E="onCompositionStart");if(E&&(WJ&&r.locale!=="ko"&&(Gt||E!=="onCompositionStart"?E==="onCompositionEnd"&&Gt&&(Z=qJ()):(Qi=A,N4=("value"in Qi)?Qi.value:Qi.textContent,Gt=!0)),O=N$($,E),0<O.length&&(E=new d7(E,l,null,r,A),j.push({event:E,listeners:O}),Z?E.data=Z:(Z=GJ(r),Z!==null&&(E.data=Z)))),Z=gm?Im(l,r):am(l,r))$=N$($,"onBeforeInput"),0<$.length&&(A=new d7("onBeforeInput","beforeinput",null,r,A),j.push({event:A,listeners:$}),A.data=Z)}VJ(j,u)})}function B1(l,u,r){return{instance:l,listener:u,currentTarget:r}}function N$(l,u){for(var r=u+"Capture",f=[];l!==null;){var n=l,i=n.stateNode;n.tag===5&&i!==null&&(n=i,i=K1(l,r),i!=null&&f.unshift(B1(l,i,n)),i=K1(l,u),i!=null&&f.push(B1(l,i,n))),l=l.return}return f}function wt(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l?l:null}function _F(l,u,r,f,n){for(var i=u._reactName,t=[];r!==null&&r!==f;){var y=r,c=y.alternate,$=y.stateNode;if(c!==null&&c===f)break;y.tag===5&&$!==null&&(y=$,n?(c=K1(r,i),c!=null&&t.unshift(B1(r,c,y))):n||(c=K1(r,i),c!=null&&t.push(B1(r,c,y)))),r=r.return}t.length!==0&&l.push({event:u,listeners:t})}var cK=/\r\n?/g,_K=/\u0000|\uFFFD/g;function $F(l){return(typeof l==="string"?l:""+l).replace(cK,` +`).replace(_K,"")}function s_(l,u,r){if(u=$F(u),$F(l)!==u&&r)throw Error(Ul(425))}function Q$(){}var V8=null,S8=null;function X8(l,u){return l==="textarea"||l==="noscript"||typeof u.children==="string"||typeof u.children==="number"||typeof u.dangerouslySetInnerHTML==="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var Y8=typeof setTimeout==="function"?setTimeout:void 0,$K=typeof clearTimeout==="function"?clearTimeout:void 0,AF=typeof Promise==="function"?Promise:void 0,AK=typeof queueMicrotask==="function"?queueMicrotask:typeof AF<"u"?function(l){return AF.resolve(null).then(l).catch(jK)}:Y8;function jK(l){setTimeout(function(){throw l})}function u8(l,u){var r=u,f=0;do{var n=r.nextSibling;if(l.removeChild(r),n&&n.nodeType===8)if(r=n.data,r==="/$"){if(f===0){l.removeChild(n),O1(u);return}f--}else r!=="$"&&r!=="$?"&&r!=="$!"||f++;r=n}while(r);O1(u)}function Gi(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return l}function jF(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var r=l.data;if(r==="$"||r==="$!"||r==="$?"){if(u===0)return l;u--}else r==="/$"&&u++}l=l.previousSibling}return null}var st=Math.random().toString(36).slice(2),An="__reactFiber$"+st,D1="__reactProps$"+st,Cn="__reactContainer$"+st,P8="__reactEvents$"+st,FK="__reactListeners$"+st,JK="__reactHandles$"+st;function w0(l){var u=l[An];if(u)return u;for(var r=l.parentNode;r;){if(u=r[Cn]||r[An]){if(r=u.alternate,u.child!==null||r!==null&&r.child!==null)for(l=jF(l);l!==null;){if(r=l[An])return r;l=jF(l)}return u}l=r,r=l.parentNode}return null}function R1(l){return l=l[An]||l[Cn],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function Kt(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(Ul(33))}function Y$(l){return l[D1]||null}var C8=[],zt=-1;function pi(l){return{current:l}}function zu(l){0>zt||(l.current=C8[zt],C8[zt]=null,zt--)}function Lu(l,u){zt++,C8[zt]=l.current,l.current=u}var Oi={},mr=pi(Oi),sr=pi(!1),T0=Oi;function Ct(l,u){var r=l.type.contextTypes;if(!r)return Oi;var f=l.stateNode;if(f&&f.__reactInternalMemoizedUnmaskedChildContext===u)return f.__reactInternalMemoizedMaskedChildContext;var n={},i;for(i in r)n[i]=u[i];return f&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=n),n}function kr(l){return l=l.childContextTypes,l!==null&&l!==void 0}function w$(){zu(sr),zu(mr)}function FF(l,u,r){if(mr.current!==Oi)throw Error(Ul(168));Lu(mr,u),Lu(sr,r)}function XJ(l,u,r){var f=l.stateNode;if(u=u.childContextTypes,typeof f.getChildContext!=="function")return r;f=f.getChildContext();for(var n in f)if(!(n in u))throw Error(Ul(108,lm(l)||"Unknown",n));return Bu({},r,f)}function q$(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Oi,T0=mr.current,Lu(mr,l),Lu(sr,sr.current),!0}function JF(l,u,r){var f=l.stateNode;if(!f)throw Error(Ul(169));r?(l=XJ(l,u,T0),f.__reactInternalMemoizedMergedChildContext=l,zu(sr),zu(mr),Lu(mr,l)):zu(sr),Lu(sr,r)}var Vn=null,P$=!1,r8=!1;function YJ(l){Vn===null?Vn=[l]:Vn.push(l)}function UK(l){P$=!0,YJ(l)}function Hi(){if(!r8&&Vn!==null){r8=!0;var l=0,u=Uu;try{var r=Vn;for(Uu=1;l<r.length;l++){var f=r[l];do f=f(!0);while(f!==null)}Vn=null,P$=!1}catch(n){throw Vn!==null&&(Vn=Vn.slice(l+1)),cJ(j4,Hi),n}finally{Uu=u,r8=!1}}return null}var Et=[],Ot=0,W$=null,L$=0,Kf=[],zf=0,m0=null,Sn=1,Xn="";function N0(l,u){Et[Ot++]=L$,Et[Ot++]=W$,W$=l,L$=u}function PJ(l,u,r){Kf[zf++]=Sn,Kf[zf++]=Xn,Kf[zf++]=m0,m0=l;var f=Sn;l=Xn;var n=32-sf(f)-1;f&=~(1<<n),r+=1;var i=32-sf(u)+n;if(30<i){var t=n-n%5;i=(f&(1<<t)-1).toString(32),f>>=t,n-=t,Sn=1<<32-sf(u)+n|r<<n|f,Xn=i+l}else Sn=1<<i|r<<n|f,Xn=l}function L4(l){l.return!==null&&(N0(l,1),PJ(l,1,0))}function G4(l){for(;l===W$;)W$=Et[--Ot],Et[Ot]=null,L$=Et[--Ot],Et[Ot]=null;for(;l===m0;)m0=Kf[--zf],Kf[zf]=null,Xn=Kf[--zf],Kf[zf]=null,Sn=Kf[--zf],Kf[zf]=null}var Af=null,$f=null,Ou=!1,vf=null;function CJ(l,u){var r=Ef(5,null,null,0);r.elementType="DELETED",r.stateNode=u,r.return=l,u=l.deletions,u===null?(l.deletions=[r],l.flags|=16):u.push(r)}function UF(l,u){switch(l.tag){case 5:var r=l.type;return u=u.nodeType!==1||r.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(l.stateNode=u,Af=l,$f=Gi(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,Af=l,$f=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(r=m0!==null?{id:Sn,overflow:Xn}:null,l.memoizedState={dehydrated:u,treeContext:r,retryLane:1073741824},r=Ef(18,null,null,0),r.stateNode=u,r.return=l,l.child=r,Af=l,$f=null,!0):!1;default:return!1}}function M8(l){return(l.mode&1)!==0&&(l.flags&128)===0}function h8(l){if(Ou){var u=$f;if(u){var r=u;if(!UF(l,u)){if(M8(l))throw Error(Ul(418));u=Gi(r.nextSibling);var f=Af;u&&UF(l,u)?CJ(f,r):(l.flags=l.flags&-4097|2,Ou=!1,Af=l)}}else{if(M8(l))throw Error(Ul(418));l.flags=l.flags&-4097|2,Ou=!1,Af=l}}}function NF(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;Af=l}function k_(l){if(l!==Af)return!1;if(!Ou)return NF(l),Ou=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!X8(l.type,l.memoizedProps)),u&&(u=$f)){if(M8(l))throw MJ(),Error(Ul(418));for(;u;)CJ(l,u),u=Gi(u.nextSibling)}if(NF(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(Ul(317));l:{l=l.nextSibling;for(u=0;l;){if(l.nodeType===8){var r=l.data;if(r==="/$"){if(u===0){$f=Gi(l.nextSibling);break l}u--}else r!=="$"&&r!=="$!"&&r!=="$?"||u++}l=l.nextSibling}$f=null}}else $f=Af?Gi(l.stateNode.nextSibling):null;return!0}function MJ(){for(var l=$f;l;)l=Gi(l.nextSibling)}function Mt(){$f=Af=null,Ou=!1}function T4(l){vf===null?vf=[l]:vf.push(l)}var NK=Rn.ReactCurrentBatchConfig;function f1(l,u,r){if(l=r.ref,l!==null&&typeof l!=="function"&&typeof l!=="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(Ul(309));var f=r.stateNode}if(!f)throw Error(Ul(147,l));var n=f,i=""+l;if(u!==null&&u.ref!==null&&typeof u.ref==="function"&&u.ref._stringRef===i)return u.ref;return u=function(t){var y=n.refs;t===null?delete y[i]:y[i]=t},u._stringRef=i,u}if(typeof l!=="string")throw Error(Ul(284));if(!r._owner)throw Error(Ul(290,l))}return l}function g_(l,u){throw l=Object.prototype.toString.call(u),Error(Ul(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function QF(l){var u=l._init;return u(l._payload)}function hJ(l){function u(J,w){if(l){var Q=J.deletions;Q===null?(J.deletions=[w],J.flags|=16):Q.push(w)}}function r(J,w){if(!l)return null;for(;w!==null;)u(J,w),w=w.sibling;return null}function f(J,w){for(J=new Map;w!==null;)w.key!==null?J.set(w.key,w):J.set(w.index,w),w=w.sibling;return J}function n(J,w){return J=zi(J,w),J.index=0,J.sibling=null,J}function i(J,w,Q){if(J.index=Q,!l)return J.flags|=1048576,w;if(Q=J.alternate,Q!==null)return Q=Q.index,Q<w?(J.flags|=2,w):Q;return J.flags|=2,w}function t(J){return l&&J.alternate===null&&(J.flags|=2),J}function y(J,w,Q,q){if(w===null||w.tag!==6)return w=_8(Q,J.mode,q),w.return=J,w;return w=n(w,Q),w.return=J,w}function c(J,w,Q,q){var T=Q.type;if(T===Lt)return A(J,w,Q.props.children,q,Q.key);if(w!==null&&(w.elementType===T||typeof T==="object"&&T!==null&&T.$$typeof===Fi&&QF(T)===w.type))return q=n(w,Q.props),q.ref=f1(J,w,Q),q.return=J,q;return q=c$(Q.type,Q.key,Q.props,null,J.mode,q),q.ref=f1(J,w,Q),q.return=J,q}function $(J,w,Q,q){if(w===null||w.tag!==4||w.stateNode.containerInfo!==Q.containerInfo||w.stateNode.implementation!==Q.implementation)return w=$8(Q,J.mode,q),w.return=J,w;return w=n(w,Q.children||[]),w.return=J,w}function A(J,w,Q,q,T){if(w===null||w.tag!==7)return w=G0(Q,J.mode,q,T),w.return=J,w;return w=n(w,Q),w.return=J,w}function j(J,w,Q){if(typeof w==="string"&&w!==""||typeof w==="number")return w=_8(""+w,J.mode,Q),w.return=J,w;if(typeof w==="object"&&w!==null){switch(w.$$typeof){case Y_:return Q=c$(w.type,w.key,w.props,null,J.mode,Q),Q.ref=f1(J,null,w),Q.return=J,Q;case Wt:return w=$8(w,J.mode,Q),w.return=J,w;case Fi:var q=w._init;return j(J,q(w._payload),Q)}if(y1(w)||ey(w))return w=G0(w,J.mode,Q,null),w.return=J,w;g_(J,w)}return null}function F(J,w,Q,q){var T=w!==null?w.key:null;if(typeof Q==="string"&&Q!==""||typeof Q==="number")return T!==null?null:y(J,w,""+Q,q);if(typeof Q==="object"&&Q!==null){switch(Q.$$typeof){case Y_:return Q.key===T?c(J,w,Q,q):null;case Wt:return Q.key===T?$(J,w,Q,q):null;case Fi:return T=Q._init,F(J,w,T(Q._payload),q)}if(y1(Q)||ey(Q))return T!==null?null:A(J,w,Q,q,null);g_(J,Q)}return null}function U(J,w,Q,q,T){if(typeof q==="string"&&q!==""||typeof q==="number")return J=J.get(Q)||null,y(w,J,""+q,T);if(typeof q==="object"&&q!==null){switch(q.$$typeof){case Y_:return J=J.get(q.key===null?Q:q.key)||null,c(w,J,q,T);case Wt:return J=J.get(q.key===null?Q:q.key)||null,$(w,J,q,T);case Fi:var O=q._init;return U(J,w,Q,O(q._payload),T)}if(y1(q)||ey(q))return J=J.get(Q)||null,A(w,J,q,T,null);g_(w,q)}return null}function N(J,w,Q,q){for(var T=null,O=null,Z=w,E=w=0,D=null;Z!==null&&E<Q.length;E++){Z.index>E?(D=Z,Z=null):D=Z.sibling;var Y=F(J,Z,Q[E],q);if(Y===null){Z===null&&(Z=D);break}l&&Z&&Y.alternate===null&&u(J,Z),w=i(Y,w,E),O===null?T=Y:O.sibling=Y,O=Y,Z=D}if(E===Q.length)return r(J,Z),Ou&&N0(J,E),T;if(Z===null){for(;E<Q.length;E++)Z=j(J,Q[E],q),Z!==null&&(w=i(Z,w,E),O===null?T=Z:O.sibling=Z,O=Z);return Ou&&N0(J,E),T}for(Z=f(J,Z);E<Q.length;E++)D=U(Z,J,E,Q[E],q),D!==null&&(l&&D.alternate!==null&&Z.delete(D.key===null?E:D.key),w=i(D,w,E),O===null?T=D:O.sibling=D,O=D);return l&&Z.forEach(function(p){return u(J,p)}),Ou&&N0(J,E),T}function W(J,w,Q,q){var T=ey(Q);if(typeof T!=="function")throw Error(Ul(150));if(Q=T.call(Q),Q==null)throw Error(Ul(151));for(var O=T=null,Z=w,E=w=0,D=null,Y=Q.next();Z!==null&&!Y.done;E++,Y=Q.next()){Z.index>E?(D=Z,Z=null):D=Z.sibling;var p=F(J,Z,Y.value,q);if(p===null){Z===null&&(Z=D);break}l&&Z&&p.alternate===null&&u(J,Z),w=i(p,w,E),O===null?T=p:O.sibling=p,O=p,Z=D}if(Y.done)return r(J,Z),Ou&&N0(J,E),T;if(Z===null){for(;!Y.done;E++,Y=Q.next())Y=j(J,Y.value,q),Y!==null&&(w=i(Y,w,E),O===null?T=Y:O.sibling=Y,O=Y);return Ou&&N0(J,E),T}for(Z=f(J,Z);!Y.done;E++,Y=Q.next())Y=U(Z,J,E,Y.value,q),Y!==null&&(l&&Y.alternate!==null&&Z.delete(Y.key===null?E:Y.key),w=i(Y,w,E),O===null?T=Y:O.sibling=Y,O=Y);return l&&Z.forEach(function(V){return u(J,V)}),Ou&&N0(J,E),T}function L(J,w,Q,q){if(typeof Q==="object"&&Q!==null&&Q.type===Lt&&Q.key===null&&(Q=Q.props.children),typeof Q==="object"&&Q!==null){switch(Q.$$typeof){case Y_:l:{for(var T=Q.key,O=w;O!==null;){if(O.key===T){if(T=Q.type,T===Lt){if(O.tag===7){r(J,O.sibling),w=n(O,Q.props.children),w.return=J,J=w;break l}}else if(O.elementType===T||typeof T==="object"&&T!==null&&T.$$typeof===Fi&&QF(T)===O.type){r(J,O.sibling),w=n(O,Q.props),w.ref=f1(J,O,Q),w.return=J,J=w;break l}r(J,O);break}else u(J,O);O=O.sibling}Q.type===Lt?(w=G0(Q.props.children,J.mode,q,Q.key),w.return=J,J=w):(q=c$(Q.type,Q.key,Q.props,null,J.mode,q),q.ref=f1(J,w,Q),q.return=J,J=q)}return t(J);case Wt:l:{for(O=Q.key;w!==null;){if(w.key===O)if(w.tag===4&&w.stateNode.containerInfo===Q.containerInfo&&w.stateNode.implementation===Q.implementation){r(J,w.sibling),w=n(w,Q.children||[]),w.return=J,J=w;break l}else{r(J,w);break}else u(J,w);w=w.sibling}w=$8(Q,J.mode,q),w.return=J,J=w}return t(J);case Fi:return O=Q._init,L(J,w,O(Q._payload),q)}if(y1(Q))return N(J,w,Q,q);if(ey(Q))return W(J,w,Q,q);g_(J,Q)}return typeof Q==="string"&&Q!==""||typeof Q==="number"?(Q=""+Q,w!==null&&w.tag===6?(r(J,w.sibling),w=n(w,Q),w.return=J,J=w):(r(J,w),w=_8(Q,J.mode,q),w.return=J,J=w),t(J)):r(J,w)}return L}var ht=hJ(!0),RJ=hJ(!1),G$=pi(null),T$=null,Zt=null,m4=null;function K4(){m4=Zt=T$=null}function z4(l){var u=G$.current;zu(G$),l._currentValue=u}function R8(l,u,r){for(;l!==null;){var f=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,f!==null&&(f.childLanes|=u)):f!==null&&(f.childLanes&u)!==u&&(f.childLanes|=u),l===r)break;l=l.return}}function Xt(l,u){T$=l,m4=Zt=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(vr=!0),l.firstContext=null)}function Zf(l){var u=l._currentValue;if(m4!==l)if(l={context:l,memoizedValue:u,next:null},Zt===null){if(T$===null)throw Error(Ul(308));Zt=l,T$.dependencies={lanes:0,firstContext:l}}else Zt=Zt.next=l;return u}var q0=null;function E4(l){q0===null?q0=[l]:q0.push(l)}function xJ(l,u,r,f){var n=u.interleaved;return n===null?(r.next=r,E4(u)):(r.next=n.next,n.next=r),u.interleaved=r,Mn(l,f)}function Mn(l,u){l.lanes|=u;var r=l.alternate;r!==null&&(r.lanes|=u),r=l;for(l=l.return;l!==null;)l.childLanes|=u,r=l.alternate,r!==null&&(r.childLanes|=u),r=l,l=l.return;return r.tag===3?r.stateNode:null}var Ji=!1;function O4(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function bJ(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Yn(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function Ti(l,u,r){var f=l.updateQueue;if(f===null)return null;if(f=f.shared,(_u&2)!==0){var n=f.pending;return n===null?u.next=u:(u.next=n.next,n.next=u),f.pending=u,Mn(l,r)}return n=f.interleaved,n===null?(u.next=u,E4(f)):(u.next=n.next,n.next=u),f.interleaved=u,Mn(l,r)}function r$(l,u,r){if(u=u.updateQueue,u!==null&&(u=u.shared,(r&4194240)!==0)){var f=u.lanes;f&=l.pendingLanes,r|=f,u.lanes=r,F4(l,r)}}function wF(l,u){var{updateQueue:r,alternate:f}=l;if(f!==null&&(f=f.updateQueue,r===f)){var n=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var t={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?n=i=t:i=i.next=t,r=r.next}while(r!==null);i===null?n=i=u:i=i.next=u}else n=i=u;r={baseState:f.baseState,firstBaseUpdate:n,lastBaseUpdate:i,shared:f.shared,effects:f.effects},l.updateQueue=r;return}l=r.lastBaseUpdate,l===null?r.firstBaseUpdate=u:l.next=u,r.lastBaseUpdate=u}function m$(l,u,r,f){var n=l.updateQueue;Ji=!1;var{firstBaseUpdate:i,lastBaseUpdate:t}=n,y=n.shared.pending;if(y!==null){n.shared.pending=null;var c=y,$=c.next;c.next=null,t===null?i=$:t.next=$,t=c;var A=l.alternate;A!==null&&(A=A.updateQueue,y=A.lastBaseUpdate,y!==t&&(y===null?A.firstBaseUpdate=$:y.next=$,A.lastBaseUpdate=c))}if(i!==null){var j=n.baseState;t=0,A=$=c=null,y=i;do{var{lane:F,eventTime:U}=y;if((f&F)===F){A!==null&&(A=A.next={eventTime:U,lane:0,tag:y.tag,payload:y.payload,callback:y.callback,next:null});l:{var N=l,W=y;switch(F=u,U=r,W.tag){case 1:if(N=W.payload,typeof N==="function"){j=N.call(U,j,F);break l}j=N;break l;case 3:N.flags=N.flags&-65537|128;case 0:if(N=W.payload,F=typeof N==="function"?N.call(U,j,F):N,F===null||F===void 0)break l;j=Bu({},j,F);break l;case 2:Ji=!0}}y.callback!==null&&y.lane!==0&&(l.flags|=64,F=n.effects,F===null?n.effects=[y]:F.push(y))}else U={eventTime:U,lane:F,tag:y.tag,payload:y.payload,callback:y.callback,next:null},A===null?($=A=U,c=j):A=A.next=U,t|=F;if(y=y.next,y===null)if(y=n.shared.pending,y===null)break;else F=y,y=F.next,F.next=null,n.lastBaseUpdate=F,n.shared.pending=null}while(1);if(A===null&&(c=j),n.baseState=c,n.firstBaseUpdate=$,n.lastBaseUpdate=A,u=n.shared.interleaved,u!==null){n=u;do t|=n.lane,n=n.next;while(n!==u)}else i===null&&(n.shared.lanes=0);z0|=t,l.lanes=t,l.memoizedState=j}}function qF(l,u,r){if(l=u.effects,u.effects=null,l!==null)for(u=0;u<l.length;u++){var f=l[u],n=f.callback;if(n!==null){if(f.callback=null,f=r,typeof n!=="function")throw Error(Ul(191,n));n.call(f)}}}var x1={},Fn=pi(x1),V1=pi(x1),S1=pi(x1);function W0(l){if(l===x1)throw Error(Ul(174));return l}function Z4(l,u){switch(Lu(S1,u),Lu(V1,l),Lu(Fn,x1),l=u.nodeType,l){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:W8(null,"");break;default:l=l===8?u.parentNode:u,u=l.namespaceURI||null,l=l.tagName,u=W8(u,l)}zu(Fn),Lu(Fn,u)}function Rt(){zu(Fn),zu(V1),zu(S1)}function vJ(l){W0(S1.current);var u=W0(Fn.current),r=W8(u,l.type);u!==r&&(Lu(V1,l),Lu(Fn,r))}function p4(l){V1.current===l&&(zu(Fn),zu(V1))}var pu=pi(0);function K$(l){for(var u=l;u!==null;){if(u.tag===13){var r=u.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var f8=[];function H4(){for(var l=0;l<f8.length;l++)f8[l]._workInProgressVersionPrimary=null;f8.length=0}var{ReactCurrentDispatcher:f$,ReactCurrentBatchConfig:n8}=Rn,K0=0,Hu=null,ur=null,cr=null,z$=!1,q1=!1,X1=0,QK=0;function Lr(){throw Error(Ul(321))}function B4(l,u){if(u===null)return!1;for(var r=0;r<u.length&&r<l.length;r++)if(!gf(l[r],u[r]))return!1;return!0}function D4(l,u,r,f,n,i){if(K0=i,Hu=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,f$.current=l===null||l.memoizedState===null?LK:GK,l=r(f,n),q1){i=0;do{if(q1=!1,X1=0,25<=i)throw Error(Ul(301));i+=1,cr=ur=null,u.updateQueue=null,f$.current=TK,l=r(f,n)}while(q1)}if(f$.current=E$,u=ur!==null&&ur.next!==null,K0=0,cr=ur=Hu=null,z$=!1,u)throw Error(Ul(300));return l}function V4(){var l=X1!==0;return X1=0,l}function $n(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cr===null?Hu.memoizedState=cr=l:cr=cr.next=l,cr}function pf(){if(ur===null){var l=Hu.alternate;l=l!==null?l.memoizedState:null}else l=ur.next;var u=cr===null?Hu.memoizedState:cr.next;if(u!==null)cr=u,ur=l;else{if(l===null)throw Error(Ul(310));ur=l,l={memoizedState:ur.memoizedState,baseState:ur.baseState,baseQueue:ur.baseQueue,queue:ur.queue,next:null},cr===null?Hu.memoizedState=cr=l:cr=cr.next=l}return cr}function Y1(l,u){return typeof u==="function"?u(l):u}function i8(l){var u=pf(),r=u.queue;if(r===null)throw Error(Ul(311));r.lastRenderedReducer=l;var f=ur,n=f.baseQueue,i=r.pending;if(i!==null){if(n!==null){var t=n.next;n.next=i.next,i.next=t}f.baseQueue=n=i,r.pending=null}if(n!==null){i=n.next,f=f.baseState;var y=t=null,c=null,$=i;do{var A=$.lane;if((K0&A)===A)c!==null&&(c=c.next={lane:0,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),f=$.hasEagerState?$.eagerState:l(f,$.action);else{var j={lane:A,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null};c===null?(y=c=j,t=f):c=c.next=j,Hu.lanes|=A,z0|=A}$=$.next}while($!==null&&$!==i);c===null?t=f:c.next=y,gf(f,u.memoizedState)||(vr=!0),u.memoizedState=f,u.baseState=t,u.baseQueue=c,r.lastRenderedState=f}if(l=r.interleaved,l!==null){n=l;do i=n.lane,Hu.lanes|=i,z0|=i,n=n.next;while(n!==l)}else n===null&&(r.lanes=0);return[u.memoizedState,r.dispatch]}function t8(l){var u=pf(),r=u.queue;if(r===null)throw Error(Ul(311));r.lastRenderedReducer=l;var{dispatch:f,pending:n}=r,i=u.memoizedState;if(n!==null){r.pending=null;var t=n=n.next;do i=l(i,t.action),t=t.next;while(t!==n);gf(i,u.memoizedState)||(vr=!0),u.memoizedState=i,u.baseQueue===null&&(u.baseState=i),r.lastRenderedState=i}return[i,f]}function sJ(){}function kJ(l,u){var r=Hu,f=pf(),n=u(),i=!gf(f.memoizedState,n);if(i&&(f.memoizedState=n,vr=!0),f=f.queue,S4(aJ.bind(null,r,f,l),[l]),f.getSnapshot!==u||i||cr!==null&&cr.memoizedState.tag&1){if(r.flags|=2048,P1(9,IJ.bind(null,r,f,n,u),void 0,null),_r===null)throw Error(Ul(349));(K0&30)!==0||gJ(r,u,n)}return n}function gJ(l,u,r){l.flags|=16384,l={getSnapshot:u,value:r},u=Hu.updateQueue,u===null?(u={lastEffect:null,stores:null},Hu.updateQueue=u,u.stores=[l]):(r=u.stores,r===null?u.stores=[l]:r.push(l))}function IJ(l,u,r,f){u.value=r,u.getSnapshot=f,oJ(u)&&dJ(l)}function aJ(l,u,r){return r(function(){oJ(u)&&dJ(l)})}function oJ(l){var u=l.getSnapshot;l=l.value;try{var r=u();return!gf(l,r)}catch(f){return!0}}function dJ(l){var u=Mn(l,1);u!==null&&kf(u,l,1,-1)}function WF(l){var u=$n();return typeof l==="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Y1,lastRenderedState:l},u.queue=l,l=l.dispatch=WK.bind(null,Hu,l),[u.memoizedState,l]}function P1(l,u,r,f){return l={tag:l,create:u,destroy:r,deps:f,next:null},u=Hu.updateQueue,u===null?(u={lastEffect:null,stores:null},Hu.updateQueue=u,u.lastEffect=l.next=l):(r=u.lastEffect,r===null?u.lastEffect=l.next=l:(f=r.next,r.next=l,l.next=f,u.lastEffect=l)),l}function eJ(){return pf().memoizedState}function n$(l,u,r,f){var n=$n();Hu.flags|=l,n.memoizedState=P1(1|u,r,void 0,f===void 0?null:f)}function C$(l,u,r,f){var n=pf();f=f===void 0?null:f;var i=void 0;if(ur!==null){var t=ur.memoizedState;if(i=t.destroy,f!==null&&B4(f,t.deps)){n.memoizedState=P1(u,r,i,f);return}}Hu.flags|=l,n.memoizedState=P1(1|u,r,i,f)}function LF(l,u){return n$(8390656,8,l,u)}function S4(l,u){return C$(2048,8,l,u)}function lU(l,u){return C$(4,2,l,u)}function uU(l,u){return C$(4,4,l,u)}function rU(l,u){if(typeof u==="function")return l=l(),u(l),function(){u(null)};if(u!==null&&u!==void 0)return l=l(),u.current=l,function(){u.current=null}}function fU(l,u,r){return r=r!==null&&r!==void 0?r.concat([l]):null,C$(4,4,rU.bind(null,u,l),r)}function X4(){}function nU(l,u){var r=pf();u=u===void 0?null:u;var f=r.memoizedState;if(f!==null&&u!==null&&B4(u,f[1]))return f[0];return r.memoizedState=[l,u],l}function iU(l,u){var r=pf();u=u===void 0?null:u;var f=r.memoizedState;if(f!==null&&u!==null&&B4(u,f[1]))return f[0];return l=l(),r.memoizedState=[l,u],l}function tU(l,u,r){if((K0&21)===0)return l.baseState&&(l.baseState=!1,vr=!0),l.memoizedState=r;return gf(r,u)||(r=AJ(),Hu.lanes|=r,z0|=r,l.baseState=!0),u}function wK(l,u){var r=Uu;Uu=r!==0&&4>r?r:4,l(!0);var f=n8.transition;n8.transition={};try{l(!1),u()}finally{Uu=r,n8.transition=f}}function yU(){return pf().memoizedState}function qK(l,u,r){var f=Ki(l);if(r={lane:f,action:r,hasEagerState:!1,eagerState:null,next:null},cU(l))_U(u,r);else if(r=xJ(l,u,r,f),r!==null){var n=Vr();kf(r,l,f,n),$U(r,u,f)}}function WK(l,u,r){var f=Ki(l),n={lane:f,action:r,hasEagerState:!1,eagerState:null,next:null};if(cU(l))_U(u,n);else{var i=l.alternate;if(l.lanes===0&&(i===null||i.lanes===0)&&(i=u.lastRenderedReducer,i!==null))try{var t=u.lastRenderedState,y=i(t,r);if(n.hasEagerState=!0,n.eagerState=y,gf(y,t)){var c=u.interleaved;c===null?(n.next=n,E4(u)):(n.next=c.next,c.next=n),u.interleaved=n;return}}catch($){}finally{}r=xJ(l,u,n,f),r!==null&&(n=Vr(),kf(r,l,f,n),$U(r,u,f))}}function cU(l){var u=l.alternate;return l===Hu||u!==null&&u===Hu}function _U(l,u){q1=z$=!0;var r=l.pending;r===null?u.next=u:(u.next=r.next,r.next=u),l.pending=u}function $U(l,u,r){if((r&4194240)!==0){var f=u.lanes;f&=l.pendingLanes,r|=f,u.lanes=r,F4(l,r)}}var E$={readContext:Zf,useCallback:Lr,useContext:Lr,useEffect:Lr,useImperativeHandle:Lr,useInsertionEffect:Lr,useLayoutEffect:Lr,useMemo:Lr,useReducer:Lr,useRef:Lr,useState:Lr,useDebugValue:Lr,useDeferredValue:Lr,useTransition:Lr,useMutableSource:Lr,useSyncExternalStore:Lr,useId:Lr,unstable_isNewReconciler:!1},LK={readContext:Zf,useCallback:function(l,u){return $n().memoizedState=[l,u===void 0?null:u],l},useContext:Zf,useEffect:LF,useImperativeHandle:function(l,u,r){return r=r!==null&&r!==void 0?r.concat([l]):null,n$(4194308,4,rU.bind(null,u,l),r)},useLayoutEffect:function(l,u){return n$(4194308,4,l,u)},useInsertionEffect:function(l,u){return n$(4,2,l,u)},useMemo:function(l,u){var r=$n();return u=u===void 0?null:u,l=l(),r.memoizedState=[l,u],l},useReducer:function(l,u,r){var f=$n();return u=r!==void 0?r(u):u,f.memoizedState=f.baseState=u,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:u},f.queue=l,l=l.dispatch=qK.bind(null,Hu,l),[f.memoizedState,l]},useRef:function(l){var u=$n();return l={current:l},u.memoizedState=l},useState:WF,useDebugValue:X4,useDeferredValue:function(l){return $n().memoizedState=l},useTransition:function(){var l=WF(!1),u=l[0];return l=wK.bind(null,l[1]),$n().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,r){var f=Hu,n=$n();if(Ou){if(r===void 0)throw Error(Ul(407));r=r()}else{if(r=u(),_r===null)throw Error(Ul(349));(K0&30)!==0||gJ(f,u,r)}n.memoizedState=r;var i={value:r,getSnapshot:u};return n.queue=i,LF(aJ.bind(null,f,i,l),[l]),f.flags|=2048,P1(9,IJ.bind(null,f,i,r,u),void 0,null),r},useId:function(){var l=$n(),u=_r.identifierPrefix;if(Ou){var r=Xn,f=Sn;r=(f&~(1<<32-sf(f)-1)).toString(32)+r,u=":"+u+"R"+r,r=X1++,0<r&&(u+="H"+r.toString(32)),u+=":"}else r=QK++,u=":"+u+"r"+r.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},GK={readContext:Zf,useCallback:nU,useContext:Zf,useEffect:S4,useImperativeHandle:fU,useInsertionEffect:lU,useLayoutEffect:uU,useMemo:iU,useReducer:i8,useRef:eJ,useState:function(){return i8(Y1)},useDebugValue:X4,useDeferredValue:function(l){var u=pf();return tU(u,ur.memoizedState,l)},useTransition:function(){var l=i8(Y1)[0],u=pf().memoizedState;return[l,u]},useMutableSource:sJ,useSyncExternalStore:kJ,useId:yU,unstable_isNewReconciler:!1},TK={readContext:Zf,useCallback:nU,useContext:Zf,useEffect:S4,useImperativeHandle:fU,useInsertionEffect:lU,useLayoutEffect:uU,useMemo:iU,useReducer:t8,useRef:eJ,useState:function(){return t8(Y1)},useDebugValue:X4,useDeferredValue:function(l){var u=pf();return ur===null?u.memoizedState=l:tU(u,ur.memoizedState,l)},useTransition:function(){var l=t8(Y1)[0],u=pf().memoizedState;return[l,u]},useMutableSource:sJ,useSyncExternalStore:kJ,useId:yU,unstable_isNewReconciler:!1};function xf(l,u){if(l&&l.defaultProps){u=Bu({},u),l=l.defaultProps;for(var r in l)u[r]===void 0&&(u[r]=l[r]);return u}return u}function x8(l,u,r,f){u=l.memoizedState,r=r(f,u),r=r===null||r===void 0?u:Bu({},u,r),l.memoizedState=r,l.lanes===0&&(l.updateQueue.baseState=r)}var M$={isMounted:function(l){return(l=l._reactInternals)?Z0(l)===l:!1},enqueueSetState:function(l,u,r){l=l._reactInternals;var f=Vr(),n=Ki(l),i=Yn(f,n);i.payload=u,r!==void 0&&r!==null&&(i.callback=r),u=Ti(l,i,n),u!==null&&(kf(u,l,n,f),r$(u,l,n))},enqueueReplaceState:function(l,u,r){l=l._reactInternals;var f=Vr(),n=Ki(l),i=Yn(f,n);i.tag=1,i.payload=u,r!==void 0&&r!==null&&(i.callback=r),u=Ti(l,i,n),u!==null&&(kf(u,l,n,f),r$(u,l,n))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var r=Vr(),f=Ki(l),n=Yn(r,f);n.tag=2,u!==void 0&&u!==null&&(n.callback=u),u=Ti(l,n,f),u!==null&&(kf(u,l,f,r),r$(u,l,f))}};function GF(l,u,r,f,n,i,t){return l=l.stateNode,typeof l.shouldComponentUpdate==="function"?l.shouldComponentUpdate(f,i,t):u.prototype&&u.prototype.isPureReactComponent?!p1(r,f)||!p1(n,i):!0}function AU(l,u,r){var f=!1,n=Oi,i=u.contextType;return typeof i==="object"&&i!==null?i=Zf(i):(n=kr(u)?T0:mr.current,f=u.contextTypes,i=(f=f!==null&&f!==void 0)?Ct(l,n):Oi),u=new u(r,i),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=M$,l.stateNode=u,u._reactInternals=l,f&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=n,l.__reactInternalMemoizedMaskedChildContext=i),u}function TF(l,u,r,f){l=u.state,typeof u.componentWillReceiveProps==="function"&&u.componentWillReceiveProps(r,f),typeof u.UNSAFE_componentWillReceiveProps==="function"&&u.UNSAFE_componentWillReceiveProps(r,f),u.state!==l&&M$.enqueueReplaceState(u,u.state,null)}function b8(l,u,r,f){var n=l.stateNode;n.props=r,n.state=l.memoizedState,n.refs={},O4(l);var i=u.contextType;typeof i==="object"&&i!==null?n.context=Zf(i):(i=kr(u)?T0:mr.current,n.context=Ct(l,i)),n.state=l.memoizedState,i=u.getDerivedStateFromProps,typeof i==="function"&&(x8(l,u,i,r),n.state=l.memoizedState),typeof u.getDerivedStateFromProps==="function"||typeof n.getSnapshotBeforeUpdate==="function"||typeof n.UNSAFE_componentWillMount!=="function"&&typeof n.componentWillMount!=="function"||(u=n.state,typeof n.componentWillMount==="function"&&n.componentWillMount(),typeof n.UNSAFE_componentWillMount==="function"&&n.UNSAFE_componentWillMount(),u!==n.state&&M$.enqueueReplaceState(n,n.state,null),m$(l,r,n,f),n.state=l.memoizedState),typeof n.componentDidMount==="function"&&(l.flags|=4194308)}function xt(l,u){try{var r="",f=u;do r+=eT(f),f=f.return;while(f);var n=r}catch(i){n=` Error generating stack: `+i.message+` -`+i.stack}return{value:u,source:l,stack:n,digest:null}}function I6(u,l,f){return{value:u,source:null,stack:f!=null?f:null,digest:l!=null?l:null}}function V8(u,l){try{console.error(l.value)}catch(f){setTimeout(function(){throw f})}}var lz=typeof WeakMap==="function"?WeakMap:Map;function sU(u,l,f){f=mn(-1,f),f.tag=3,f.payload={element:null};var r=l.value;return f.callback=function(){W$||(W$=!0,R8=r),V8(u,l)},f}function aU(u,l,f){f=mn(-1,f),f.tag=3;var r=u.type.getDerivedStateFromError;if(typeof r==="function"){var n=l.value;f.payload=function(){return r(n)},f.callback=function(){V8(u,l)}}var i=u.stateNode;return i!==null&&typeof i.componentDidCatch==="function"&&(f.callback=function(){V8(u,l),typeof r!=="function"&&(q0===null?q0=new Set([this]):q0.add(this));var t=l.stack;this.componentDidCatch(l.value,{componentStack:t!==null?t:""})}),f}function yF(u,l,f){var r=u.pingCache;if(r===null){r=u.pingCache=new lz;var n=new Set;r.set(l,n)}else n=r.get(l),n===void 0&&(n=new Set,r.set(l,n));n.has(f)||(n.add(f),u=Jz.bind(null,u,l,f),l.then(u,u))}function cF(u){do{var l;if(l=u.tag===13)l=u.memoizedState,l=l!==null?l.dehydrated!==null?!0:!1:!0;if(l)return u;u=u.return}while(u!==null);return null}function _F(u,l,f,r,n){if((u.mode&1)===0)return u===l?u.flags|=65536:(u.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(l=mn(-1,1),l.tag=2,N0(f,l,1))),f.lanes|=1),u;return u.flags|=65536,u.lanes=n,u}var fz=Yn.ReactCurrentOwner,vf=!1;function Df(u,l,f,r){l.child=u===null?zU(l,null,f,r):Xt(l,u.child,f,r)}function $F(u,l,f,r,n){f=f.render;var i=l.ref;if(Vt(l,n),r=w4(u,l,f,r,i,n),f=W4(),u!==null&&!vf)return l.updateQueue=u.updateQueue,l.flags&=-2053,u.lanes&=~n,Xn(u,l,n);return Ol&&f&&y4(l),l.flags|=1,Df(u,l,r,n),l.child}function AF(u,l,f,r,n){if(u===null){var i=f.type;if(typeof i==="function"&&!B4(i)&&i.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0)return l.tag=15,l.type=i,oU(u,l,i,r,n);return u=e_(f.type,null,r,l,l.mode,n),u.ref=l.ref,u.return=l,l.child=u}if(i=u.child,(u.lanes&n)===0){var t=i.memoizedProps;if(f=f.compare,f=f!==null?f:K1,f(t,r)&&u.ref===l.ref)return Xn(u,l,n)}return l.flags|=1,u=W0(i,r),u.ref=l.ref,u.return=l,l.child=u}function oU(u,l,f,r,n){if(u!==null){var i=u.memoizedProps;if(K1(i,r)&&u.ref===l.ref)if(vf=!1,l.pendingProps=r=i,(u.lanes&n)!==0)(u.flags&131072)!==0&&(vf=!0);else return l.lanes=u.lanes,Xn(u,l,n)}return m8(u,l,f,r,n)}function dU(u,l,f){var r=l.pendingProps,n=r.children,i=u!==null?u.memoizedState:null;if(r.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wl(Et,yr),yr|=f;else{if((f&1073741824)===0)return u=i!==null?i.baseLanes|f:f,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:u,cachePool:null,transitions:null},l.updateQueue=null,Wl(Et,yr),yr|=u,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:f,Wl(Et,yr),yr|=r}else i!==null?(r=i.baseLanes|f,l.memoizedState=null):r=f,Wl(Et,yr),yr|=r;return Df(u,l,n,f),l.child}function eU(u,l){var f=l.ref;if(u===null&&f!==null||u!==null&&u.ref!==f)l.flags|=512,l.flags|=2097152}function m8(u,l,f,r,n){var i=If(f)?Wi:Kf.current;if(i=pt(l,i),Vt(l,n),f=w4(u,l,f,r,i,n),r=W4(),u!==null&&!vf)return l.updateQueue=u.updateQueue,l.flags&=-2053,u.lanes&=~n,Xn(u,l,n);return Ol&&r&&y4(l),l.flags|=1,Df(u,l,f,n),l.child}function jF(u,l,f,r,n){if(If(f)){var i=!0;$$(l)}else i=!1;if(Vt(l,n),l.stateNode===null)a_(u,l),gU(l,f,r),B8(l,f,r,n),r=!0;else if(u===null){var{stateNode:t,memoizedProps:y}=l;t.props=y;var c=t.context,$=f.contextType;typeof $==="object"&&$!==null?$=Or($):($=If(f)?Wi:Kf.current,$=pt(l,$));var A=f.getDerivedStateFromProps,j=typeof A==="function"||typeof t.getSnapshotBeforeUpdate==="function";j||typeof t.UNSAFE_componentWillReceiveProps!=="function"&&typeof t.componentWillReceiveProps!=="function"||(y!==r||c!==$)&&tF(l,t,r,$),c0=!1;var F=l.memoizedState;t.state=F,J$(l,r,t,n),c=l.memoizedState,y!==r||F!==c||kf.current||c0?(typeof A==="function"&&(H8(l,f,A,r),c=l.memoizedState),(y=c0||iF(l,f,y,r,F,c,$))?(j||typeof t.UNSAFE_componentWillMount!=="function"&&typeof t.componentWillMount!=="function"||(typeof t.componentWillMount==="function"&&t.componentWillMount(),typeof t.UNSAFE_componentWillMount==="function"&&t.UNSAFE_componentWillMount()),typeof t.componentDidMount==="function"&&(l.flags|=4194308)):(typeof t.componentDidMount==="function"&&(l.flags|=4194308),l.memoizedProps=r,l.memoizedState=c),t.props=r,t.state=c,t.context=$,r=y):(typeof t.componentDidMount==="function"&&(l.flags|=4194308),r=!1)}else{t=l.stateNode,OU(u,l),y=l.memoizedProps,$=l.type===l.elementType?y:xr(l.type,y),t.props=$,j=l.pendingProps,F=t.context,c=f.contextType,typeof c==="object"&&c!==null?c=Or(c):(c=If(f)?Wi:Kf.current,c=pt(l,c));var J=f.getDerivedStateFromProps;(A=typeof J==="function"||typeof t.getSnapshotBeforeUpdate==="function")||typeof t.UNSAFE_componentWillReceiveProps!=="function"&&typeof t.componentWillReceiveProps!=="function"||(y!==j||F!==c)&&tF(l,t,r,c),c0=!1,F=l.memoizedState,t.state=F,J$(l,r,t,n);var Q=l.memoizedState;y!==j||F!==Q||kf.current||c0?(typeof J==="function"&&(H8(l,f,J,r),Q=l.memoizedState),($=c0||iF(l,f,$,r,F,Q,c)||!1)?(A||typeof t.UNSAFE_componentWillUpdate!=="function"&&typeof t.componentWillUpdate!=="function"||(typeof t.componentWillUpdate==="function"&&t.componentWillUpdate(r,Q,c),typeof t.UNSAFE_componentWillUpdate==="function"&&t.UNSAFE_componentWillUpdate(r,Q,c)),typeof t.componentDidUpdate==="function"&&(l.flags|=4),typeof t.getSnapshotBeforeUpdate==="function"&&(l.flags|=1024)):(typeof t.componentDidUpdate!=="function"||y===u.memoizedProps&&F===u.memoizedState||(l.flags|=4),typeof t.getSnapshotBeforeUpdate!=="function"||y===u.memoizedProps&&F===u.memoizedState||(l.flags|=1024),l.memoizedProps=r,l.memoizedState=Q),t.props=r,t.state=Q,t.context=c,r=$):(typeof t.componentDidUpdate!=="function"||y===u.memoizedProps&&F===u.memoizedState||(l.flags|=4),typeof t.getSnapshotBeforeUpdate!=="function"||y===u.memoizedProps&&F===u.memoizedState||(l.flags|=1024),r=!1)}return D8(u,l,f,r,i,n)}function D8(u,l,f,r,n,i){eU(u,l);var t=(l.flags&128)!==0;if(!r&&!t)return n&&oj(l,f,!1),Xn(u,l,i);r=l.stateNode,fz.current=l;var y=t&&typeof f.getDerivedStateFromError!=="function"?null:r.render();return l.flags|=1,u!==null&&t?(l.child=Xt(l,u.child,null,i),l.child=Xt(l,null,y,i)):Df(u,l,y,i),l.memoizedState=r.state,n&&oj(l,f,!0),l.child}function uJ(u){var l=u.stateNode;l.pendingContext?aj(u,l.pendingContext,l.pendingContext!==l.context):l.context&&aj(u,l.context,!1),J4(u,l.containerInfo)}function FF(u,l,f,r,n){return St(),_4(n),l.flags|=256,Df(u,l,f,r),l.child}var p8={dehydrated:null,treeContext:null,retryLane:0};function S8(u){return{baseLanes:u,cachePool:null,transitions:null}}function lJ(u,l,f){var r=l.pendingProps,n=Hl.current,i=!1,t=(l.flags&128)!==0,y;if((y=t)||(y=u!==null&&u.memoizedState===null?!1:(n&2)!==0),y)i=!0,l.flags&=-129;else if(u===null||u.memoizedState!==null)n|=1;if(Wl(Hl,n&1),u===null){if(O8(l),u=l.memoizedState,u!==null&&(u=u.dehydrated,u!==null))return(l.mode&1)===0?l.lanes=1:u.data==="$!"?l.lanes=8:l.lanes=1073741824,null;return t=r.children,u=r.fallback,i?(r=l.mode,i=l.child,t={mode:"hidden",children:t},(r&1)===0&&i!==null?(i.childLanes=0,i.pendingProps=t):i=p$(t,r,0,null),u=wi(u,r,f,null),i.return=l,u.return=l,i.sibling=u,l.child=i,l.child.memoizedState=S8(f),l.memoizedState=p8,u):K4(l,t)}if(n=u.memoizedState,n!==null&&(y=n.dehydrated,y!==null))return rz(u,l,t,r,y,n,f);if(i){i=r.fallback,t=l.mode,n=u.child,y=n.sibling;var c={mode:"hidden",children:r.children};return(t&1)===0&&l.child!==n?(r=l.child,r.childLanes=0,r.pendingProps=c,l.deletions=null):(r=W0(n,c),r.subtreeFlags=n.subtreeFlags&14680064),y!==null?i=W0(y,i):(i=wi(i,t,f,null),i.flags|=2),i.return=l,r.return=l,r.sibling=i,l.child=r,r=i,i=l.child,t=u.child.memoizedState,t=t===null?S8(f):{baseLanes:t.baseLanes|f,cachePool:null,transitions:t.transitions},i.memoizedState=t,i.childLanes=u.childLanes&~f,l.memoizedState=p8,r}return i=u.child,u=i.sibling,r=W0(i,{mode:"visible",children:r.children}),(l.mode&1)===0&&(r.lanes=f),r.return=l,r.sibling=null,u!==null&&(f=l.deletions,f===null?(l.deletions=[u],l.flags|=16):f.push(u)),l.child=r,l.memoizedState=null,r}function K4(u,l){return l=p$({mode:"visible",children:l},u.mode,0,null),l.return=u,u.child=l}function M_(u,l,f,r){return r!==null&&_4(r),Xt(l,u.child,null,f),u=K4(l,l.pendingProps.children),u.flags|=2,l.memoizedState=null,u}function rz(u,l,f,r,n,i,t){if(f){if(l.flags&256)return l.flags&=-257,r=I6(Error(Ju(422))),M_(u,l,t,r);if(l.memoizedState!==null)return l.child=u.child,l.flags|=128,null;return i=r.fallback,n=l.mode,r=p$({mode:"visible",children:r.children},n,0,null),i=wi(i,n,t,null),i.flags|=2,r.return=l,i.return=l,r.sibling=i,l.child=r,(l.mode&1)!==0&&Xt(l,u.child,null,t),l.child.memoizedState=S8(t),l.memoizedState=p8,i}if((l.mode&1)===0)return M_(u,l,t,null);if(n.data==="$!"){if(r=n.nextSibling&&n.nextSibling.dataset,r)var y=r.dgst;return r=y,i=Error(Ju(419)),r=I6(i,r,void 0),M_(u,l,t,r)}if(y=(t&u.childLanes)!==0,vf||y){if(r=_f,r!==null){switch(t&-t){case 4:n=2;break;case 16:n=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:n=32;break;case 536870912:n=268435456;break;default:n=0}n=(n&(r.suspendedLanes|t))!==0?0:n,n!==0&&n!==i.retryLane&&(i.retryLane=n,Sn(u,n),kr(r,u,n,-1))}return H4(),r=I6(Error(Ju(421))),M_(u,l,t,r)}if(n.data==="$?")return l.flags|=128,l.child=u.child,l=Qz.bind(null,u),n._reactRetry=l,null;return u=i.treeContext,cr=Q0(n.nextSibling),_r=l,Ol=!0,br=null,u!==null&&(Kr[Gr++]=Bn,Kr[Gr++]=Vn,Kr[Gr++]=Li,Bn=u.id,Vn=u.overflow,Li=l),l=K4(l,r.children),l.flags|=4096,l}function UF(u,l,f){u.lanes|=l;var r=u.alternate;r!==null&&(r.lanes|=l),Z8(u.return,l,f)}function g6(u,l,f,r,n){var i=u.memoizedState;i===null?u.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:r,tail:f,tailMode:n}:(i.isBackwards=l,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=f,i.tailMode=n)}function fJ(u,l,f){var r=l.pendingProps,n=r.revealOrder,i=r.tail;if(Df(u,l,r.children,f),r=Hl.current,(r&2)!==0)r=r&1|2,l.flags|=128;else{if(u!==null&&(u.flags&128)!==0)u:for(u=l.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&UF(u,f,l);else if(u.tag===19)UF(u,f,l);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break u;for(;u.sibling===null;){if(u.return===null||u.return===l)break u;u=u.return}u.sibling.return=u.return,u=u.sibling}r&=1}if(Wl(Hl,r),(l.mode&1)===0)l.memoizedState=null;else switch(n){case"forwards":f=l.child;for(n=null;f!==null;)u=f.alternate,u!==null&&Q$(u)===null&&(n=f),f=f.sibling;f=n,f===null?(n=l.child,l.child=null):(n=f.sibling,f.sibling=null),g6(l,!1,n,f,i);break;case"backwards":f=null,n=l.child;for(l.child=null;n!==null;){if(u=n.alternate,u!==null&&Q$(u)===null){l.child=n;break}u=n.sibling,n.sibling=f,f=n,n=u}g6(l,!0,f,null,i);break;case"together":g6(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function a_(u,l){(l.mode&1)===0&&u!==null&&(u.alternate=null,l.alternate=null,l.flags|=2)}function Xn(u,l,f){if(u!==null&&(l.dependencies=u.dependencies),Ki|=l.lanes,(f&l.childLanes)===0)return null;if(u!==null&&l.child!==u.child)throw Error(Ju(153));if(l.child!==null){u=l.child,f=W0(u,u.pendingProps),l.child=f;for(f.return=l;u.sibling!==null;)u=u.sibling,f=f.sibling=W0(u,u.pendingProps),f.return=l;f.sibling=null}return l.child}function nz(u,l,f){switch(l.tag){case 3:uJ(l),St();break;case 5:ZU(l);break;case 1:If(l.type)&&$$(l);break;case 4:J4(l,l.stateNode.containerInfo);break;case 10:var r=l.type._context,n=l.memoizedProps.value;Wl(F$,r._currentValue),r._currentValue=n;break;case 13:if(r=l.memoizedState,r!==null){if(r.dehydrated!==null)return Wl(Hl,Hl.current&1),l.flags|=128,null;if((f&l.child.childLanes)!==0)return lJ(u,l,f);return Wl(Hl,Hl.current&1),u=Xn(u,l,f),u!==null?u.sibling:null}Wl(Hl,Hl.current&1);break;case 19:if(r=(f&l.childLanes)!==0,(u.flags&128)!==0){if(r)return fJ(u,l,f);l.flags|=128}if(n=l.memoizedState,n!==null&&(n.rendering=null,n.tail=null,n.lastEffect=null),Wl(Hl,Hl.current),r)break;else return null;case 22:case 23:return l.lanes=0,dU(u,l,f)}return Xn(u,l,f)}var rJ,X8,nJ,iJ;rJ=function(u,l){for(var f=l.child;f!==null;){if(f.tag===5||f.tag===6)u.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===l)break;for(;f.sibling===null;){if(f.return===null||f.return===l)return;f=f.return}f.sibling.return=f.return,f=f.sibling}};X8=function(){};nJ=function(u,l,f,r){var n=u.memoizedProps;if(n!==r){u=l.stateNode,Ni(An.current);var i=null;switch(f){case"input":n=f8(u,n),r=f8(u,r),i=[];break;case"select":n=Vl({},n,{value:void 0}),r=Vl({},r,{value:void 0}),i=[];break;case"textarea":n=i8(u,n),r=i8(u,r),i=[];break;default:typeof n.onClick!=="function"&&typeof r.onClick==="function"&&(u.onclick=c$)}y8(f,r);var t;f=null;for($ in n)if(!r.hasOwnProperty($)&&n.hasOwnProperty($)&&n[$]!=null)if($==="style"){var y=n[$];for(t in y)y.hasOwnProperty(t)&&(f||(f={}),f[t]="")}else $!=="dangerouslySetInnerHTML"&&$!=="children"&&$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(Q1.hasOwnProperty($)?i||(i=[]):(i=i||[]).push($,null));for($ in r){var c=r[$];if(y=n!=null?n[$]:void 0,r.hasOwnProperty($)&&c!==y&&(c!=null||y!=null))if($==="style")if(y){for(t in y)!y.hasOwnProperty(t)||c&&c.hasOwnProperty(t)||(f||(f={}),f[t]="");for(t in c)c.hasOwnProperty(t)&&y[t]!==c[t]&&(f||(f={}),f[t]=c[t])}else f||(i||(i=[]),i.push($,f)),f=c;else $==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,y=y?y.__html:void 0,c!=null&&y!==c&&(i=i||[]).push($,c)):$==="children"?typeof c!=="string"&&typeof c!=="number"||(i=i||[]).push($,""+c):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&(Q1.hasOwnProperty($)?(c!=null&&$==="onScroll"&&Gl("scroll",u),i||y===c||(i=[])):(i=i||[]).push($,c))}f&&(i=i||[]).push("style",f);var $=i;if(l.updateQueue=$)l.flags|=4}};iJ=function(u,l,f,r){f!==r&&(l.flags|=4)};function oy(u,l){if(!Ol)switch(u.tailMode){case"hidden":l=u.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?u.tail=null:f.sibling=null;break;case"collapsed":f=u.tail;for(var r=null;f!==null;)f.alternate!==null&&(r=f),f=f.sibling;r===null?l||u.tail===null?u.tail=null:u.tail.sibling=null:r.sibling=null}}function Lf(u){var l=u.alternate!==null&&u.alternate.child===u.child,f=0,r=0;if(l)for(var n=u.child;n!==null;)f|=n.lanes|n.childLanes,r|=n.subtreeFlags&14680064,r|=n.flags&14680064,n.return=u,n=n.sibling;else for(n=u.child;n!==null;)f|=n.lanes|n.childLanes,r|=n.subtreeFlags,r|=n.flags,n.return=u,n=n.sibling;return u.subtreeFlags|=r,u.childLanes=f,l}function iz(u,l,f){var r=l.pendingProps;switch(c4(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lf(l),null;case 1:return If(l.type)&&_$(),Lf(l),null;case 3:if(r=l.stateNode,Yt(),zl(kf),zl(Kf),N4(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),u===null||u.child===null)P_(l)?l.flags|=4:u===null||u.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,br!==null&&(b8(br),br=null));return X8(u,l),Lf(l),null;case 5:Q4(l);var n=Ni(Z1.current);if(f=l.type,u!==null&&l.stateNode!=null)nJ(u,l,f,r,n),u.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!r){if(l.stateNode===null)throw Error(Ju(166));return Lf(l),null}if(u=Ni(An.current),P_(l)){r=l.stateNode,f=l.type;var i=l.memoizedProps;switch(r[_n]=l,r[E1]=i,u=(l.mode&1)!==0,f){case"dialog":Gl("cancel",r),Gl("close",r);break;case"iframe":case"object":case"embed":Gl("load",r);break;case"video":case"audio":for(n=0;n<t1.length;n++)Gl(t1[n],r);break;case"source":Gl("error",r);break;case"img":case"image":case"link":Gl("error",r),Gl("load",r);break;case"details":Gl("toggle",r);break;case"input":Gj(r,i),Gl("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Gl("invalid",r);break;case"textarea":Ej(r,i),Gl("invalid",r)}y8(f,i),n=null;for(var t in i)if(i.hasOwnProperty(t)){var y=i[t];t==="children"?typeof y==="string"?r.textContent!==y&&(i.suppressHydrationWarning!==!0&&Y_(r.textContent,y,u),n=["children",y]):typeof y==="number"&&r.textContent!==""+y&&(i.suppressHydrationWarning!==!0&&Y_(r.textContent,y,u),n=["children",""+y]):Q1.hasOwnProperty(t)&&y!=null&&t==="onScroll"&&Gl("scroll",r)}switch(f){case"input":H_(r),zj(r,i,!0);break;case"textarea":H_(r),Oj(r);break;case"select":case"option":break;default:typeof i.onClick==="function"&&(r.onclick=c$)}r=n,l.updateQueue=r,r!==null&&(l.flags|=4)}else{t=n.nodeType===9?n:n.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=DF(f)),u==="http://www.w3.org/1999/xhtml"?f==="script"?(u=t.createElement("div"),u.innerHTML="<script></script>",u=u.removeChild(u.firstChild)):typeof r.is==="string"?u=t.createElement(f,{is:r.is}):(u=t.createElement(f),f==="select"&&(t=u,r.multiple?t.multiple=!0:r.size&&(t.size=r.size))):u=t.createElementNS(u,f),u[_n]=l,u[E1]=r,rJ(u,l,!1,!1),l.stateNode=u;u:{switch(t=c8(f,r),f){case"dialog":Gl("cancel",u),Gl("close",u),n=r;break;case"iframe":case"object":case"embed":Gl("load",u),n=r;break;case"video":case"audio":for(n=0;n<t1.length;n++)Gl(t1[n],u);n=r;break;case"source":Gl("error",u),n=r;break;case"img":case"image":case"link":Gl("error",u),Gl("load",u),n=r;break;case"details":Gl("toggle",u),n=r;break;case"input":Gj(u,r),n=f8(u,r),Gl("invalid",u);break;case"option":n=r;break;case"select":u._wrapperState={wasMultiple:!!r.multiple},n=Vl({},r,{value:void 0}),Gl("invalid",u);break;case"textarea":Ej(u,r),n=i8(u,r),Gl("invalid",u);break;default:n=r}y8(f,n),y=n;for(i in y)if(y.hasOwnProperty(i)){var c=y[i];i==="style"?XF(u,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&pF(u,c)):i==="children"?typeof c==="string"?(f!=="textarea"||c!=="")&&N1(u,c):typeof c==="number"&&N1(u,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Q1.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Gl("scroll",u):c!=null&&I8(u,i,c,t))}switch(f){case"input":H_(u),zj(u,r,!1);break;case"textarea":H_(u),Oj(u);break;case"option":r.value!=null&&u.setAttribute("value",""+L0(r.value));break;case"select":u.multiple=!!r.multiple,i=r.value,i!=null?Ot(u,!!r.multiple,i,!1):r.defaultValue!=null&&Ot(u,!!r.multiple,r.defaultValue,!0);break;default:typeof n.onClick==="function"&&(u.onclick=c$)}switch(f){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break u;case"img":r=!0;break u;default:r=!1}}r&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Lf(l),null;case 6:if(u&&l.stateNode!=null)iJ(u,l,u.memoizedProps,r);else{if(typeof r!=="string"&&l.stateNode===null)throw Error(Ju(166));if(f=Ni(Z1.current),Ni(An.current),P_(l)){if(r=l.stateNode,f=l.memoizedProps,r[_n]=l,i=r.nodeValue!==f){if(u=_r,u!==null)switch(u.tag){case 3:Y_(r.nodeValue,f,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&Y_(r.nodeValue,f,(u.mode&1)!==0)}}i&&(l.flags|=4)}else r=(f.nodeType===9?f:f.ownerDocument).createTextNode(r),r[_n]=l,l.stateNode=r}return Lf(l),null;case 13:if(zl(Hl),r=l.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(Ol&&cr!==null&&(l.mode&1)!==0&&(l.flags&128)===0)KU(),St(),l.flags|=98560,i=!1;else if(i=P_(l),r!==null&&r.dehydrated!==null){if(u===null){if(!i)throw Error(Ju(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ju(317));i[_n]=l}else St(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Lf(l),i=!1}else br!==null&&(b8(br),br=null),i=!0;if(!i)return l.flags&65536?l:null}if((l.flags&128)!==0)return l.lanes=f,l;return r=r!==null,r!==(u!==null&&u.memoizedState!==null)&&r&&(l.child.flags|=8192,(l.mode&1)!==0&&(u===null||(Hl.current&1)!==0?lf===0&&(lf=3):H4())),l.updateQueue!==null&&(l.flags|=4),Lf(l),null;case 4:return Yt(),X8(u,l),u===null&&G1(l.stateNode.containerInfo),Lf(l),null;case 10:return j4(l.type._context),Lf(l),null;case 17:return If(l.type)&&_$(),Lf(l),null;case 19:if(zl(Hl),i=l.memoizedState,i===null)return Lf(l),null;if(r=(l.flags&128)!==0,t=i.rendering,t===null)if(r)oy(i,!1);else{if(lf!==0||u!==null&&(u.flags&128)!==0)for(u=l.child;u!==null;){if(t=Q$(u),t!==null){l.flags|=128,oy(i,!1),r=t.updateQueue,r!==null&&(l.updateQueue=r,l.flags|=4),l.subtreeFlags=0,r=f;for(f=l.child;f!==null;)i=f,u=r,i.flags&=14680066,t=i.alternate,t===null?(i.childLanes=0,i.lanes=u,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,i.type=t.type,u=t.dependencies,i.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),f=f.sibling;return Wl(Hl,Hl.current&1|2),l.child}u=u.sibling}i.tail!==null&&hl()>Ct&&(l.flags|=128,r=!0,oy(i,!1),l.lanes=4194304)}else{if(!r)if(u=Q$(t),u!==null){if(l.flags|=128,r=!0,f=u.updateQueue,f!==null&&(l.updateQueue=f,l.flags|=4),oy(i,!0),i.tail===null&&i.tailMode==="hidden"&&!t.alternate&&!Ol)return Lf(l),null}else 2*hl()-i.renderingStartTime>Ct&&f!==1073741824&&(l.flags|=128,r=!0,oy(i,!1),l.lanes=4194304);i.isBackwards?(t.sibling=l.child,l.child=t):(f=i.last,f!==null?f.sibling=t:l.child=t,i.last=t)}if(i.tail!==null)return l=i.tail,i.rendering=l,i.tail=l.sibling,i.renderingStartTime=hl(),l.sibling=null,f=Hl.current,Wl(Hl,r?f&1|2:f&1),l;return Lf(l),null;case 22:case 23:return Z4(),r=l.memoizedState!==null,u!==null&&u.memoizedState!==null!==r&&(l.flags|=8192),r&&(l.mode&1)!==0?(yr&1073741824)!==0&&(Lf(l),l.subtreeFlags&6&&(l.flags|=8192)):Lf(l),null;case 24:return null;case 25:return null}throw Error(Ju(156,l.tag))}function tz(u,l){switch(c4(l),l.tag){case 1:return If(l.type)&&_$(),u=l.flags,u&65536?(l.flags=u&-65537|128,l):null;case 3:return Yt(),zl(kf),zl(Kf),N4(),u=l.flags,(u&65536)!==0&&(u&128)===0?(l.flags=u&-65537|128,l):null;case 5:return Q4(l),null;case 13:if(zl(Hl),u=l.memoizedState,u!==null&&u.dehydrated!==null){if(l.alternate===null)throw Error(Ju(340));St()}return u=l.flags,u&65536?(l.flags=u&-65537|128,l):null;case 19:return zl(Hl),null;case 4:return Yt(),null;case 10:return j4(l.type._context),null;case 22:case 23:return Z4(),null;case 24:return null;default:return null}}var R_=!1,Tf=!1,yz=typeof WeakSet==="function"?WeakSet:Set,Hu=null;function zt(u,l){var f=u.ref;if(f!==null)if(typeof f==="function")try{f(null)}catch(r){Cl(u,l,r)}else f.current=null}function Y8(u,l,f){try{f()}catch(r){Cl(u,l,r)}}var JF=!1;function cz(u,l){if(W8=i$,u=$U(),t4(u)){if("selectionStart"in u)var f={start:u.selectionStart,end:u.selectionEnd};else u:{f=(f=u.ownerDocument)&&f.defaultView||window;var r=f.getSelection&&f.getSelection();if(r&&r.rangeCount!==0){f=r.anchorNode;var{anchorOffset:n,focusNode:i}=r;r=r.focusOffset;try{f.nodeType,i.nodeType}catch(w){f=null;break u}var t=0,y=-1,c=-1,$=0,A=0,j=u,F=null;l:for(;;){for(var J;;){if(j!==f||n!==0&&j.nodeType!==3||(y=t+n),j!==i||r!==0&&j.nodeType!==3||(c=t+r),j.nodeType===3&&(t+=j.nodeValue.length),(J=j.firstChild)===null)break;F=j,j=J}for(;;){if(j===u)break l;if(F===f&&++$===n&&(y=t),F===i&&++A===r&&(c=t),(J=j.nextSibling)!==null)break;j=F,F=j.parentNode}j=J}f=y===-1||c===-1?null:{start:y,end:c}}else f=null}f=f||{start:0,end:0}}else f=null;L8={focusedElem:u,selectionRange:f},i$=!1;for(Hu=l;Hu!==null;)if(l=Hu,u=l.child,(l.subtreeFlags&1028)!==0&&u!==null)u.return=l,Hu=u;else for(;Hu!==null;){l=Hu;try{var Q=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Q!==null){var{memoizedProps:W,memoizedState:L}=Q,U=l.stateNode,q=U.getSnapshotBeforeUpdate(l.elementType===l.type?W:xr(l.type,W),L);U.__reactInternalSnapshotBeforeUpdate=q}break;case 3:var N=l.stateNode.containerInfo;N.nodeType===1?N.textContent="":N.nodeType===9&&N.documentElement&&N.removeChild(N.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ju(163))}}catch(w){Cl(l,l.return,w)}if(u=l.sibling,u!==null){u.return=l.return,Hu=u;break}Hu=l.return}return Q=JF,JF=!1,Q}function F1(u,l,f){var r=l.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var n=r=r.next;do{if((n.tag&u)===u){var i=n.destroy;n.destroy=void 0,i!==void 0&&Y8(l,f,i)}n=n.next}while(n!==r)}}function m$(u,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&u)===u){var r=f.create;f.destroy=r()}f=f.next}while(f!==l)}}function P8(u){var l=u.ref;if(l!==null){var f=u.stateNode;switch(u.tag){case 5:u=f;break;default:u=f}typeof l==="function"?l(u):l.current=u}}function tJ(u){var l=u.alternate;l!==null&&(u.alternate=null,tJ(l)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(l=u.stateNode,l!==null&&(delete l[_n],delete l[E1],delete l[G8],delete l[bG],delete l[vG])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function yJ(u){return u.tag===5||u.tag===3||u.tag===4}function QF(u){u:for(;;){for(;u.sibling===null;){if(u.return===null||yJ(u.return))return null;u=u.return}u.sibling.return=u.return;for(u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2)continue u;if(u.child===null||u.tag===4)continue u;else u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function C8(u,l,f){var r=u.tag;if(r===5||r===6)u=u.stateNode,l?f.nodeType===8?f.parentNode.insertBefore(u,l):f.insertBefore(u,l):(f.nodeType===8?(l=f.parentNode,l.insertBefore(u,f)):(l=f,l.appendChild(u)),f=f._reactRootContainer,f!==null&&f!==void 0||l.onclick!==null||(l.onclick=c$));else if(r!==4&&(u=u.child,u!==null))for(C8(u,l,f),u=u.sibling;u!==null;)C8(u,l,f),u=u.sibling}function M8(u,l,f){var r=u.tag;if(r===5||r===6)u=u.stateNode,l?f.insertBefore(u,l):f.appendChild(u);else if(r!==4&&(u=u.child,u!==null))for(M8(u,l,f),u=u.sibling;u!==null;)M8(u,l,f),u=u.sibling}var jf=null,hr=!1;function t0(u,l,f){for(f=f.child;f!==null;)cJ(u,l,f),f=f.sibling}function cJ(u,l,f){if($n&&typeof $n.onCommitFiberUnmount==="function")try{$n.onCommitFiberUnmount(G$,f)}catch(y){}switch(f.tag){case 5:Tf||zt(f,l);case 6:var r=jf,n=hr;jf=null,t0(u,l,f),jf=r,hr=n,jf!==null&&(hr?(u=jf,f=f.stateNode,u.nodeType===8?u.parentNode.removeChild(f):u.removeChild(f)):jf.removeChild(f.stateNode));break;case 18:jf!==null&&(hr?(u=jf,f=f.stateNode,u.nodeType===8?R6(u.parentNode,f):u.nodeType===1&&R6(u,f),L1(u)):R6(jf,f.stateNode));break;case 4:r=jf,n=hr,jf=f.stateNode.containerInfo,hr=!0,t0(u,l,f),jf=r,hr=n;break;case 0:case 11:case 14:case 15:if(!Tf&&(r=f.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){n=r=r.next;do{var i=n,t=i.destroy;i=i.tag,t!==void 0&&((i&2)!==0?Y8(f,l,t):(i&4)!==0&&Y8(f,l,t)),n=n.next}while(n!==r)}t0(u,l,f);break;case 1:if(!Tf&&(zt(f,l),r=f.stateNode,typeof r.componentWillUnmount==="function"))try{r.props=f.memoizedProps,r.state=f.memoizedState,r.componentWillUnmount()}catch(y){Cl(f,l,y)}t0(u,l,f);break;case 21:t0(u,l,f);break;case 22:f.mode&1?(Tf=(r=Tf)||f.memoizedState!==null,t0(u,l,f),Tf=r):t0(u,l,f);break;default:t0(u,l,f)}}function NF(u){var l=u.updateQueue;if(l!==null){u.updateQueue=null;var f=u.stateNode;f===null&&(f=u.stateNode=new yz),l.forEach(function(r){var n=Nz.bind(null,u,r);f.has(r)||(f.add(r),r.then(n,n))})}}function Rr(u,l){var f=l.deletions;if(f!==null)for(var r=0;r<f.length;r++){var n=f[r];try{var i=u,t=l,y=t;u:for(;y!==null;){switch(y.tag){case 5:jf=y.stateNode,hr=!1;break u;case 3:jf=y.stateNode.containerInfo,hr=!0;break u;case 4:jf=y.stateNode.containerInfo,hr=!0;break u}y=y.return}if(jf===null)throw Error(Ju(160));cJ(i,t,n),jf=null,hr=!1;var c=n.alternate;c!==null&&(c.return=null),n.return=null}catch($){Cl(n,l,$)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)_J(l,u),l=l.sibling}function _J(u,l){var{alternate:f,flags:r}=u;switch(u.tag){case 0:case 11:case 14:case 15:if(Rr(l,u),yn(u),r&4){try{F1(3,u,u.return),m$(3,u)}catch(W){Cl(u,u.return,W)}try{F1(5,u,u.return)}catch(W){Cl(u,u.return,W)}}break;case 1:Rr(l,u),yn(u),r&512&&f!==null&&zt(f,f.return);break;case 5:if(Rr(l,u),yn(u),r&512&&f!==null&&zt(f,f.return),u.flags&32){var n=u.stateNode;try{N1(n,"")}catch(W){Cl(u,u.return,W)}}if(r&4&&(n=u.stateNode,n!=null)){var i=u.memoizedProps,t=f!==null?f.memoizedProps:i,y=u.type,c=u.updateQueue;if(u.updateQueue=null,c!==null)try{y==="input"&&i.type==="radio"&&i.name!=null&&VF(n,i),c8(y,t);var $=c8(y,i);for(t=0;t<c.length;t+=2){var A=c[t],j=c[t+1];A==="style"?XF(n,j):A==="dangerouslySetInnerHTML"?pF(n,j):A==="children"?N1(n,j):I8(n,A,j,$)}switch(y){case"input":r8(n,i);break;case"textarea":mF(n,i);break;case"select":var F=n._wrapperState.wasMultiple;n._wrapperState.wasMultiple=!!i.multiple;var J=i.value;J!=null?Ot(n,!!i.multiple,J,!1):F!==!!i.multiple&&(i.defaultValue!=null?Ot(n,!!i.multiple,i.defaultValue,!0):Ot(n,!!i.multiple,i.multiple?[]:"",!1))}n[E1]=i}catch(W){Cl(u,u.return,W)}}break;case 6:if(Rr(l,u),yn(u),r&4){if(u.stateNode===null)throw Error(Ju(162));n=u.stateNode,i=u.memoizedProps;try{n.nodeValue=i}catch(W){Cl(u,u.return,W)}}break;case 3:if(Rr(l,u),yn(u),r&4&&f!==null&&f.memoizedState.isDehydrated)try{L1(l.containerInfo)}catch(W){Cl(u,u.return,W)}break;case 4:Rr(l,u),yn(u);break;case 13:Rr(l,u),yn(u),n=u.child,n.flags&8192&&(i=n.memoizedState!==null,n.stateNode.isHidden=i,!i||n.alternate!==null&&n.alternate.memoizedState!==null||(E4=hl())),r&4&&NF(u);break;case 22:if(A=f!==null&&f.memoizedState!==null,u.mode&1?(Tf=($=Tf)||A,Rr(l,u),Tf=$):Rr(l,u),yn(u),r&8192){if($=u.memoizedState!==null,(u.stateNode.isHidden=$)&&!A&&(u.mode&1)!==0)for(Hu=u,A=u.child;A!==null;){for(j=Hu=A;Hu!==null;){switch(F=Hu,J=F.child,F.tag){case 0:case 11:case 14:case 15:F1(4,F,F.return);break;case 1:zt(F,F.return);var Q=F.stateNode;if(typeof Q.componentWillUnmount==="function"){r=F,f=F.return;try{l=r,Q.props=l.memoizedProps,Q.state=l.memoizedState,Q.componentWillUnmount()}catch(W){Cl(r,f,W)}}break;case 5:zt(F,F.return);break;case 22:if(F.memoizedState!==null){wF(j);continue}}J!==null?(J.return=F,Hu=J):wF(j)}A=A.sibling}u:for(A=null,j=u;;){if(j.tag===5){if(A===null){A=j;try{n=j.stateNode,$?(i=n.style,typeof i.setProperty==="function"?i.setProperty("display","none","important"):i.display="none"):(y=j.stateNode,c=j.memoizedProps.style,t=c!==void 0&&c!==null&&c.hasOwnProperty("display")?c.display:null,y.style.display=SF("display",t))}catch(W){Cl(u,u.return,W)}}}else if(j.tag===6){if(A===null)try{j.stateNode.nodeValue=$?"":j.memoizedProps}catch(W){Cl(u,u.return,W)}}else if((j.tag!==22&&j.tag!==23||j.memoizedState===null||j===u)&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===u)break u;for(;j.sibling===null;){if(j.return===null||j.return===u)break u;A===j&&(A=null),j=j.return}A===j&&(A=null),j.sibling.return=j.return,j=j.sibling}}break;case 19:Rr(l,u),yn(u),r&4&&NF(u);break;case 21:break;default:Rr(l,u),yn(u)}}function yn(u){var l=u.flags;if(l&2){try{u:{for(var f=u.return;f!==null;){if(yJ(f)){var r=f;break u}f=f.return}throw Error(Ju(160))}switch(r.tag){case 5:var n=r.stateNode;r.flags&32&&(N1(n,""),r.flags&=-33);var i=QF(u);M8(u,i,n);break;case 3:case 4:var t=r.stateNode.containerInfo,y=QF(u);C8(u,y,t);break;default:throw Error(Ju(161))}}catch(c){Cl(u,u.return,c)}u.flags&=-3}l&4096&&(u.flags&=-4097)}function _z(u,l,f){Hu=u,$J(u,l,f)}function $J(u,l,f){for(var r=(u.mode&1)!==0;Hu!==null;){var n=Hu,i=n.child;if(n.tag===22&&r){var t=n.memoizedState!==null||R_;if(!t){var y=n.alternate,c=y!==null&&y.memoizedState!==null||Tf;y=R_;var $=Tf;if(R_=t,(Tf=c)&&!$)for(Hu=n;Hu!==null;)t=Hu,c=t.child,t.tag===22&&t.memoizedState!==null?WF(n):c!==null?(c.return=t,Hu=c):WF(n);for(;i!==null;)Hu=i,$J(i,l,f),i=i.sibling;Hu=n,R_=y,Tf=$}qF(u,l,f)}else(n.subtreeFlags&8772)!==0&&i!==null?(i.return=n,Hu=i):qF(u,l,f)}}function qF(u){for(;Hu!==null;){var l=Hu;if((l.flags&8772)!==0){var f=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Tf||m$(5,l);break;case 1:var r=l.stateNode;if(l.flags&4&&!Tf)if(f===null)r.componentDidMount();else{var n=l.elementType===l.type?f.memoizedProps:xr(l.type,f.memoizedProps);r.componentDidUpdate(n,f.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=l.updateQueue;i!==null&&fF(l,i,r);break;case 3:var t=l.updateQueue;if(t!==null){if(f=null,l.child!==null)switch(l.child.tag){case 5:f=l.child.stateNode;break;case 1:f=l.child.stateNode}fF(l,t,f)}break;case 5:var y=l.stateNode;if(f===null&&l.flags&4){f=y;var c=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&f.focus();break;case"img":c.src&&(f.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var $=l.alternate;if($!==null){var A=$.memoizedState;if(A!==null){var j=A.dehydrated;j!==null&&L1(j)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ju(163))}Tf||l.flags&512&&P8(l)}catch(F){Cl(l,l.return,F)}}if(l===u){Hu=null;break}if(f=l.sibling,f!==null){f.return=l.return,Hu=f;break}Hu=l.return}}function wF(u){for(;Hu!==null;){var l=Hu;if(l===u){Hu=null;break}var f=l.sibling;if(f!==null){f.return=l.return,Hu=f;break}Hu=l.return}}function WF(u){for(;Hu!==null;){var l=Hu;try{switch(l.tag){case 0:case 11:case 15:var f=l.return;try{m$(4,l)}catch(c){Cl(l,f,c)}break;case 1:var r=l.stateNode;if(typeof r.componentDidMount==="function"){var n=l.return;try{r.componentDidMount()}catch(c){Cl(l,n,c)}}var i=l.return;try{P8(l)}catch(c){Cl(l,i,c)}break;case 5:var t=l.return;try{P8(l)}catch(c){Cl(l,t,c)}}}catch(c){Cl(l,l.return,c)}if(l===u){Hu=null;break}var y=l.sibling;if(y!==null){y.return=l.return,Hu=y;break}Hu=l.return}}var $z=Math.ceil,w$=Yn.ReactCurrentDispatcher,G4=Yn.ReactCurrentOwner,Er=Yn.ReactCurrentBatchConfig,cl=0,_f=null,gl=null,Ff=0,yr=0,Et=G0(0),lf=0,m1=null,Ki=0,D$=0,z4=0,U1=null,bf=null,E4=0,Ct=1/0,Zn=null,W$=!1,R8=null,q0=null,x_=!1,j0=null,L$=0,J1=0,x8=null,o_=-1,d_=0;function pf(){return(cl&6)!==0?hl():o_!==-1?o_:o_=hl()}function w0(u){if((u.mode&1)===0)return 1;if((cl&2)!==0&&Ff!==0)return Ff&-Ff;if(IG.transition!==null)return d_===0&&(d_=gF()),d_;if(u=jl,u!==0)return u;return u=window.event,u=u===void 0?16:lU(u.type),u}function kr(u,l,f,r){if(50<J1)throw J1=0,x8=null,Error(Ju(185));if(D1(u,f,r),(cl&2)===0||u!==_f)u===_f&&((cl&2)===0&&(D$|=f),lf===4&&$0(u,Ff)),gf(u,r),f===1&&cl===0&&(l.mode&1)===0&&(Ct=hl()+500,H$&&z0())}function gf(u,l){var f=u.callbackNode;sK(u,l);var r=n$(u,u===_f?Ff:0);if(r===0)f!==null&&Bj(f),u.callbackNode=null,u.callbackPriority=0;else if(l=r&-r,u.callbackPriority!==l){if(f!=null&&Bj(f),l===1)u.tag===0?kG(LF.bind(null,u)):WU(LF.bind(null,u)),xG(function(){(cl&6)===0&&z0()}),f=null;else{switch(sF(r)){case 1:f=d8;break;case 4:f=kF;break;case 16:f=r$;break;case 536870912:f=IF;break;default:f=r$}f=qJ(f,AJ.bind(null,u))}u.callbackPriority=l,u.callbackNode=f}}function AJ(u,l){if(o_=-1,d_=0,(cl&6)!==0)throw Error(Ju(327));var f=u.callbackNode;if(mt()&&u.callbackNode!==f)return null;var r=n$(u,u===_f?Ff:0);if(r===0)return null;if((r&30)!==0||(r&u.expiredLanes)!==0||l)l=T$(u,r);else{l=r;var n=cl;cl|=2;var i=FJ();if(_f!==u||Ff!==l)Zn=null,Ct=hl()+500,qi(u,l);do try{Fz();break}catch(y){jJ(u,y)}while(1);A4(),w$.current=i,cl=n,gl!==null?l=0:(_f=null,Ff=0,l=lf)}if(l!==0){if(l===2&&(n=F8(u),n!==0&&(r=n,l=h8(u,n))),l===1)throw f=m1,qi(u,0),$0(u,r),gf(u,hl()),f;if(l===6)$0(u,r);else{if(n=u.current.alternate,(r&30)===0&&!Az(n)&&(l=T$(u,r),l===2&&(i=F8(u),i!==0&&(r=i,l=h8(u,i))),l===1))throw f=m1,qi(u,0),$0(u,r),gf(u,hl()),f;switch(u.finishedWork=n,u.finishedLanes=r,l){case 0:case 1:throw Error(Ju(345));case 2:Ui(u,bf,Zn);break;case 3:if($0(u,r),(r&130023424)===r&&(l=E4+500-hl(),10<l)){if(n$(u,0)!==0)break;if(n=u.suspendedLanes,(n&r)!==r){pf(),u.pingedLanes|=u.suspendedLanes&n;break}u.timeoutHandle=K8(Ui.bind(null,u,bf,Zn),l);break}Ui(u,bf,Zn);break;case 4:if($0(u,r),(r&4194240)===r)break;l=u.eventTimes;for(n=-1;0<r;){var t=31-vr(r);i=1<<t,t=l[t],t>n&&(n=t),r&=~i}if(r=n,r=hl()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3000>r?3000:4320>r?4320:1960*$z(r/1960))-r,10<r){u.timeoutHandle=K8(Ui.bind(null,u,bf,Zn),r);break}Ui(u,bf,Zn);break;case 5:Ui(u,bf,Zn);break;default:throw Error(Ju(329))}}}return gf(u,hl()),u.callbackNode===f?AJ.bind(null,u):null}function h8(u,l){var f=U1;return u.current.memoizedState.isDehydrated&&(qi(u,l).flags|=256),u=T$(u,l),u!==2&&(l=bf,bf=f,l!==null&&b8(l)),u}function b8(u){bf===null?bf=u:bf.push.apply(bf,u)}function Az(u){for(var l=u;;){if(l.flags&16384){var f=l.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var r=0;r<f.length;r++){var n=f[r],i=n.getSnapshot;n=n.value;try{if(!Ir(i(),n))return!1}catch(t){return!1}}}if(f=l.child,l.subtreeFlags&16384&&f!==null)f.return=l,l=f;else{if(l===u)break;for(;l.sibling===null;){if(l.return===null||l.return===u)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function $0(u,l){l&=~z4,l&=~D$,u.suspendedLanes|=l,u.pingedLanes&=~l;for(u=u.expirationTimes;0<l;){var f=31-vr(l),r=1<<f;u[f]=-1,l&=~r}}function LF(u){if((cl&6)!==0)throw Error(Ju(327));mt();var l=n$(u,0);if((l&1)===0)return gf(u,hl()),null;var f=T$(u,l);if(u.tag!==0&&f===2){var r=F8(u);r!==0&&(l=r,f=h8(u,r))}if(f===1)throw f=m1,qi(u,0),$0(u,l),gf(u,hl()),f;if(f===6)throw Error(Ju(345));return u.finishedWork=u.current.alternate,u.finishedLanes=l,Ui(u,bf,Zn),gf(u,hl()),null}function O4(u,l){var f=cl;cl|=1;try{return u(l)}finally{cl=f,cl===0&&(Ct=hl()+500,H$&&z0())}}function Gi(u){j0!==null&&j0.tag===0&&(cl&6)===0&&mt();var l=cl;cl|=1;var f=Er.transition,r=jl;try{if(Er.transition=null,jl=1,u)return u()}finally{jl=r,Er.transition=f,cl=l,(cl&6)===0&&z0()}}function Z4(){yr=Et.current,zl(Et)}function qi(u,l){u.finishedWork=null,u.finishedLanes=0;var f=u.timeoutHandle;if(f!==-1&&(u.timeoutHandle=-1,RG(f)),gl!==null)for(f=gl.return;f!==null;){var r=f;switch(c4(r),r.tag){case 1:r=r.type.childContextTypes,r!==null&&r!==void 0&&_$();break;case 3:Yt(),zl(kf),zl(Kf),N4();break;case 5:Q4(r);break;case 4:Yt();break;case 13:zl(Hl);break;case 19:zl(Hl);break;case 10:j4(r.type._context);break;case 22:case 23:Z4()}f=f.return}if(_f=u,gl=u=W0(u.current,null),Ff=yr=l,lf=0,m1=null,z4=D$=Ki=0,bf=U1=null,Qi!==null){for(l=0;l<Qi.length;l++)if(f=Qi[l],r=f.interleaved,r!==null){f.interleaved=null;var n=r.next,i=f.pending;if(i!==null){var t=i.next;i.next=n,r.next=t}f.pending=r}Qi=null}return u}function jJ(u,l){do{var f=gl;try{if(A4(),g_.current=q$,N$){for(var r=Bl.memoizedState;r!==null;){var n=r.queue;n!==null&&(n.pending=null),r=r.next}N$=!1}if(Ti=0,cf=uf=Bl=null,j1=!1,H1=0,G4.current=null,f===null||f.return===null){lf=1,m1=l,gl=null;break}u:{var i=u,t=f.return,y=f,c=l;if(l=Ff,y.flags|=32768,c!==null&&typeof c==="object"&&typeof c.then==="function"){var $=c,A=y,j=A.tag;if((A.mode&1)===0&&(j===0||j===11||j===15)){var F=A.alternate;F?(A.updateQueue=F.updateQueue,A.memoizedState=F.memoizedState,A.lanes=F.lanes):(A.updateQueue=null,A.memoizedState=null)}var J=cF(t);if(J!==null){J.flags&=-257,_F(J,t,y,i,l),J.mode&1&&yF(i,$,l),l=J,c=$;var Q=l.updateQueue;if(Q===null){var W=new Set;W.add(c),l.updateQueue=W}else Q.add(c);break u}else{if((l&1)===0){yF(i,$,l),H4();break u}c=Error(Ju(426))}}else if(Ol&&y.mode&1){var L=cF(t);if(L!==null){(L.flags&65536)===0&&(L.flags|=256),_F(L,t,y,i,l),_4(Pt(c,y));break u}}i=c=Pt(c,y),lf!==4&&(lf=2),U1===null?U1=[i]:U1.push(i),i=t;do{switch(i.tag){case 3:i.flags|=65536,l&=-l,i.lanes|=l;var U=sU(i,c,l);lF(i,U);break u;case 1:y=c;var{type:q,stateNode:N}=i;if((i.flags&128)===0&&(typeof q.getDerivedStateFromError==="function"||N!==null&&typeof N.componentDidCatch==="function"&&(q0===null||!q0.has(N)))){i.flags|=65536,l&=-l,i.lanes|=l;var w=aU(i,y,l);lF(i,w);break u}}i=i.return}while(i!==null)}JJ(f)}catch(G){l=G,gl===f&&f!==null&&(gl=f=f.return);continue}break}while(1)}function FJ(){var u=w$.current;return w$.current=q$,u===null?q$:u}function H4(){if(lf===0||lf===3||lf===2)lf=4;_f===null||(Ki&268435455)===0&&(D$&268435455)===0||$0(_f,Ff)}function T$(u,l){var f=cl;cl|=2;var r=FJ();if(_f!==u||Ff!==l)Zn=null,qi(u,l);do try{jz();break}catch(n){jJ(u,n)}while(1);if(A4(),cl=f,w$.current=r,gl!==null)throw Error(Ju(261));return _f=null,Ff=0,lf}function jz(){for(;gl!==null;)UJ(gl)}function Fz(){for(;gl!==null&&!MK();)UJ(gl)}function UJ(u){var l=NJ(u.alternate,u,yr);u.memoizedProps=u.pendingProps,l===null?JJ(u):gl=l,G4.current=null}function JJ(u){var l=u;do{var f=l.alternate;if(u=l.return,(l.flags&32768)===0){if(f=iz(f,l,yr),f!==null){gl=f;return}}else{if(f=tz(f,l),f!==null){f.flags&=32767,gl=f;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{lf=6,gl=null;return}}if(l=l.sibling,l!==null){gl=l;return}gl=l=u}while(l!==null);lf===0&&(lf=5)}function Ui(u,l,f){var r=jl,n=Er.transition;try{Er.transition=null,jl=1,Uz(u,l,f,r)}finally{Er.transition=n,jl=r}return null}function Uz(u,l,f,r){do mt();while(j0!==null);if((cl&6)!==0)throw Error(Ju(327));f=u.finishedWork;var n=u.finishedLanes;if(f===null)return null;if(u.finishedWork=null,u.finishedLanes=0,f===u.current)throw Error(Ju(177));u.callbackNode=null,u.callbackPriority=0;var i=f.lanes|f.childLanes;if(aK(u,i),u===_f&&(gl=_f=null,Ff=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||x_||(x_=!0,qJ(r$,function(){return mt(),null})),i=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||i){i=Er.transition,Er.transition=null;var t=jl;jl=1;var y=cl;cl|=4,G4.current=null,cz(u,f),_J(f,u),XG(L8),i$=!!W8,L8=W8=null,u.current=f,_z(f,u,n),RK(),cl=y,jl=t,Er.transition=i}else u.current=f;if(x_&&(x_=!1,j0=u,L$=n),i=u.pendingLanes,i===0&&(q0=null),bK(f.stateNode,r),gf(u,hl()),l!==null)for(r=u.onRecoverableError,f=0;f<l.length;f++)n=l[f],r(n.value,{componentStack:n.stack,digest:n.digest});if(W$)throw W$=!1,u=R8,R8=null,u;return(L$&1)!==0&&u.tag!==0&&mt(),i=u.pendingLanes,(i&1)!==0?u===x8?J1++:(J1=0,x8=u):J1=0,z0(),null}function mt(){if(j0!==null){var u=sF(L$),l=Er.transition,f=jl;try{if(Er.transition=null,jl=16>u?16:u,j0===null)var r=!1;else{if(u=j0,j0=null,L$=0,(cl&6)!==0)throw Error(Ju(331));var n=cl;cl|=4;for(Hu=u.current;Hu!==null;){var i=Hu,t=i.child;if((Hu.flags&16)!==0){var y=i.deletions;if(y!==null){for(var c=0;c<y.length;c++){var $=y[c];for(Hu=$;Hu!==null;){var A=Hu;switch(A.tag){case 0:case 11:case 15:F1(8,A,i)}var j=A.child;if(j!==null)j.return=A,Hu=j;else for(;Hu!==null;){A=Hu;var{sibling:F,return:J}=A;if(tJ(A),A===$){Hu=null;break}if(F!==null){F.return=J,Hu=F;break}Hu=J}}}var Q=i.alternate;if(Q!==null){var W=Q.child;if(W!==null){Q.child=null;do{var L=W.sibling;W.sibling=null,W=L}while(W!==null)}}Hu=i}}if((i.subtreeFlags&2064)!==0&&t!==null)t.return=i,Hu=t;else u:for(;Hu!==null;){if(i=Hu,(i.flags&2048)!==0)switch(i.tag){case 0:case 11:case 15:F1(9,i,i.return)}var U=i.sibling;if(U!==null){U.return=i.return,Hu=U;break u}Hu=i.return}}var q=u.current;for(Hu=q;Hu!==null;){t=Hu;var N=t.child;if((t.subtreeFlags&2064)!==0&&N!==null)N.return=t,Hu=N;else u:for(t=q;Hu!==null;){if(y=Hu,(y.flags&2048)!==0)try{switch(y.tag){case 0:case 11:case 15:m$(9,y)}}catch(G){Cl(y,y.return,G)}if(y===t){Hu=null;break u}var w=y.sibling;if(w!==null){w.return=y.return,Hu=w;break u}Hu=y.return}}if(cl=n,z0(),$n&&typeof $n.onPostCommitFiberRoot==="function")try{$n.onPostCommitFiberRoot(G$,u)}catch(G){}r=!0}return r}finally{jl=f,Er.transition=l}}return!1}function TF(u,l,f){l=Pt(f,l),l=sU(u,l,1),u=N0(u,l,1),l=pf(),u!==null&&(D1(u,1,l),gf(u,l))}function Cl(u,l,f){if(u.tag===3)TF(u,u,f);else for(;l!==null;){if(l.tag===3){TF(l,u,f);break}else if(l.tag===1){var r=l.stateNode;if(typeof l.type.getDerivedStateFromError==="function"||typeof r.componentDidCatch==="function"&&(q0===null||!q0.has(r))){u=Pt(f,u),u=aU(l,u,1),l=N0(l,u,1),u=pf(),l!==null&&(D1(l,1,u),gf(l,u));break}}l=l.return}}function Jz(u,l,f){var r=u.pingCache;r!==null&&r.delete(l),l=pf(),u.pingedLanes|=u.suspendedLanes&f,_f===u&&(Ff&f)===f&&(lf===4||lf===3&&(Ff&130023424)===Ff&&500>hl()-E4?qi(u,0):z4|=f),gf(u,l)}function QJ(u,l){l===0&&((u.mode&1)===0?l=1:(l=m_,m_<<=1,(m_&130023424)===0&&(m_=4194304)));var f=pf();u=Sn(u,l),u!==null&&(D1(u,l,f),gf(u,f))}function Qz(u){var l=u.memoizedState,f=0;l!==null&&(f=l.retryLane),QJ(u,f)}function Nz(u,l){var f=0;switch(u.tag){case 13:var{stateNode:r,memoizedState:n}=u;n!==null&&(f=n.retryLane);break;case 19:r=u.stateNode;break;default:throw Error(Ju(314))}r!==null&&r.delete(l),QJ(u,f)}var NJ;NJ=function(u,l,f){if(u!==null)if(u.memoizedProps!==l.pendingProps||kf.current)vf=!0;else{if((u.lanes&f)===0&&(l.flags&128)===0)return vf=!1,nz(u,l,f);vf=(u.flags&131072)!==0?!0:!1}else vf=!1,Ol&&(l.flags&1048576)!==0&&LU(l,j$,l.index);switch(l.lanes=0,l.tag){case 2:var r=l.type;a_(u,l),u=l.pendingProps;var n=pt(l,Kf.current);Vt(l,f),n=w4(null,l,r,u,n,f);var i=W4();return l.flags|=1,typeof n==="object"&&n!==null&&typeof n.render==="function"&&n.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,If(r)?(i=!0,$$(l)):i=!1,l.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,U4(l),n.updater=V$,l.stateNode=n,n._reactInternals=l,B8(l,r,u,f),l=D8(null,l,r,!0,i,f)):(l.tag=0,Ol&&i&&y4(l),Df(null,l,n,f),l=l.child),l;case 16:r=l.elementType;u:{switch(a_(u,l),u=l.pendingProps,n=r._init,r=n(r._payload),l.type=r,n=l.tag=wz(r),u=xr(r,u),n){case 0:l=m8(null,l,r,u,f);break u;case 1:l=jF(null,l,r,u,f);break u;case 11:l=$F(null,l,r,u,f);break u;case 14:l=AF(null,l,r,xr(r.type,u),f);break u}throw Error(Ju(306,r,""))}return l;case 0:return r=l.type,n=l.pendingProps,n=l.elementType===r?n:xr(r,n),m8(u,l,r,n,f);case 1:return r=l.type,n=l.pendingProps,n=l.elementType===r?n:xr(r,n),jF(u,l,r,n,f);case 3:u:{if(uJ(l),u===null)throw Error(Ju(387));r=l.pendingProps,i=l.memoizedState,n=i.element,OU(u,l),J$(l,r,null,f);var t=l.memoizedState;if(r=t.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:t.cache,pendingSuspenseBoundaries:t.pendingSuspenseBoundaries,transitions:t.transitions},l.updateQueue.baseState=i,l.memoizedState=i,l.flags&256){n=Pt(Error(Ju(423)),l),l=FF(u,l,r,f,n);break u}else if(r!==n){n=Pt(Error(Ju(424)),l),l=FF(u,l,r,f,n);break u}else for(cr=Q0(l.stateNode.containerInfo.firstChild),_r=l,Ol=!0,br=null,f=zU(l,null,r,f),l.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(St(),r===n){l=Xn(u,l,f);break u}Df(u,l,r,f)}l=l.child}return l;case 5:return ZU(l),u===null&&O8(l),r=l.type,n=l.pendingProps,i=u!==null?u.memoizedProps:null,t=n.children,T8(r,n)?t=null:i!==null&&T8(r,i)&&(l.flags|=32),eU(u,l),Df(u,l,t,f),l.child;case 6:return u===null&&O8(l),null;case 13:return lJ(u,l,f);case 4:return J4(l,l.stateNode.containerInfo),r=l.pendingProps,u===null?l.child=Xt(l,null,r,f):Df(u,l,r,f),l.child;case 11:return r=l.type,n=l.pendingProps,n=l.elementType===r?n:xr(r,n),$F(u,l,r,n,f);case 7:return Df(u,l,l.pendingProps,f),l.child;case 8:return Df(u,l,l.pendingProps.children,f),l.child;case 12:return Df(u,l,l.pendingProps.children,f),l.child;case 10:u:{if(r=l.type._context,n=l.pendingProps,i=l.memoizedProps,t=n.value,Wl(F$,r._currentValue),r._currentValue=t,i!==null)if(Ir(i.value,t)){if(i.children===n.children&&!kf.current){l=Xn(u,l,f);break u}}else for(i=l.child,i!==null&&(i.return=l);i!==null;){var y=i.dependencies;if(y!==null){t=i.child;for(var c=y.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=mn(-1,f&-f),c.tag=2;var $=i.updateQueue;if($!==null){$=$.shared;var A=$.pending;A===null?c.next=c:(c.next=A.next,A.next=c),$.pending=c}}i.lanes|=f,c=i.alternate,c!==null&&(c.lanes|=f),Z8(i.return,f,l),y.lanes|=f;break}c=c.next}}else if(i.tag===10)t=i.type===l.type?null:i.child;else if(i.tag===18){if(t=i.return,t===null)throw Error(Ju(341));t.lanes|=f,y=t.alternate,y!==null&&(y.lanes|=f),Z8(t,f,l),t=i.sibling}else t=i.child;if(t!==null)t.return=i;else for(t=i;t!==null;){if(t===l){t=null;break}if(i=t.sibling,i!==null){i.return=t.return,t=i;break}t=t.return}i=t}Df(u,l,n.children,f),l=l.child}return l;case 9:return n=l.type,r=l.pendingProps.children,Vt(l,f),n=Or(n),r=r(n),l.flags|=1,Df(u,l,r,f),l.child;case 14:return r=l.type,n=xr(r,l.pendingProps),n=xr(r.type,n),AF(u,l,r,n,f);case 15:return oU(u,l,l.type,l.pendingProps,f);case 17:return r=l.type,n=l.pendingProps,n=l.elementType===r?n:xr(r,n),a_(u,l),l.tag=1,If(r)?(u=!0,$$(l)):u=!1,Vt(l,f),gU(l,r,n),B8(l,r,n,f),D8(null,l,r,!0,u,f);case 19:return fJ(u,l,f);case 22:return dU(u,l,f)}throw Error(Ju(156,l.tag))};function qJ(u,l){return vF(u,l)}function qz(u,l,f,r){this.tag=u,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zr(u,l,f,r){return new qz(u,l,f,r)}function B4(u){return u=u.prototype,!(!u||!u.isReactComponent)}function wz(u){if(typeof u==="function")return B4(u)?1:0;if(u!==void 0&&u!==null){if(u=u.$$typeof,u===s8)return 11;if(u===a8)return 14}return 2}function W0(u,l){var f=u.alternate;return f===null?(f=zr(u.tag,l,u.key,u.mode),f.elementType=u.elementType,f.type=u.type,f.stateNode=u.stateNode,f.alternate=u,u.alternate=f):(f.pendingProps=l,f.type=u.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=u.flags&14680064,f.childLanes=u.childLanes,f.lanes=u.lanes,f.child=u.child,f.memoizedProps=u.memoizedProps,f.memoizedState=u.memoizedState,f.updateQueue=u.updateQueue,l=u.dependencies,f.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},f.sibling=u.sibling,f.index=u.index,f.ref=u.ref,f}function e_(u,l,f,r,n,i){var t=2;if(r=u,typeof u==="function")B4(u)&&(t=1);else if(typeof u==="string")t=5;else u:switch(u){case Qt:return wi(f.children,n,i,l);case g8:t=8,n|=8;break;case d6:return u=zr(12,f,l,n|2),u.elementType=d6,u.lanes=i,u;case e6:return u=zr(13,f,l,n),u.elementType=e6,u.lanes=i,u;case u8:return u=zr(19,f,l,n),u.elementType=u8,u.lanes=i,u;case ZF:return p$(f,n,i,l);default:if(typeof u==="object"&&u!==null)switch(u.$$typeof){case EF:t=10;break u;case OF:t=9;break u;case s8:t=11;break u;case a8:t=14;break u;case y0:t=16,r=null;break u}throw Error(Ju(130,u==null?u:typeof u,""))}return l=zr(t,f,l,n),l.elementType=u,l.type=r,l.lanes=i,l}function wi(u,l,f,r){return u=zr(7,u,r,l),u.lanes=f,u}function p$(u,l,f,r){return u=zr(22,u,r,l),u.elementType=ZF,u.lanes=f,u.stateNode={isHidden:!1},u}function s6(u,l,f){return u=zr(6,u,null,l),u.lanes=f,u}function a6(u,l,f){return l=zr(4,u.children!==null?u.children:[],u.key,l),l.lanes=f,l.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},l}function Wz(u,l,f,r,n){this.tag=l,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=p6(0),this.expirationTimes=p6(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=p6(0),this.identifierPrefix=r,this.onRecoverableError=n,this.mutableSourceEagerHydrationData=null}function V4(u,l,f,r,n,i,t,y,c){return u=new Wz(u,l,f,y,c),l===1?(l=1,i===!0&&(l|=8)):l=0,i=zr(3,null,null,l),u.current=i,i.stateNode=u,i.memoizedState={element:r,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},U4(i),u}function Lz(u,l,f){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Jt,key:r==null?null:""+r,children:u,containerInfo:l,implementation:f}}function wJ(u){if(!u)return T0;u=u._reactInternals;u:{if(Ei(u)!==u||u.tag!==1)throw Error(Ju(170));var l=u;do{switch(l.tag){case 3:l=l.stateNode.context;break u;case 1:if(If(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break u}}l=l.return}while(l!==null);throw Error(Ju(171))}if(u.tag===1){var f=u.type;if(If(f))return wU(u,f,l)}return l}function WJ(u,l,f,r,n,i,t,y,c){return u=V4(f,r,!0,u,n,i,t,y,c),u.context=wJ(null),f=u.current,r=pf(),n=w0(f),i=mn(r,n),i.callback=l!==void 0&&l!==null?l:null,N0(f,i,n),u.current.lanes=n,D1(u,n,r),gf(u,r),u}function S$(u,l,f,r){var n=l.current,i=pf(),t=w0(n);return f=wJ(f),l.context===null?l.context=f:l.pendingContext=f,l=mn(i,t),l.payload={element:u},r=r===void 0?null:r,r!==null&&(l.callback=r),u=N0(n,l,t),u!==null&&(kr(u,n,t,i),I_(u,n,t)),t}function K$(u){if(u=u.current,!u.child)return null;switch(u.child.tag){case 5:return u.child.stateNode;default:return u.child.stateNode}}function KF(u,l){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var f=u.retryLane;u.retryLane=f!==0&&f<l?f:l}}function m4(u,l){KF(u,l),(u=u.alternate)&&KF(u,l)}function Tz(){return null}var LJ=typeof reportError==="function"?reportError:function(u){console.error(u)};function D4(u){this._internalRoot=u}X$.prototype.render=D4.prototype.render=function(u){var l=this._internalRoot;if(l===null)throw Error(Ju(409));S$(u,l,null,null)};X$.prototype.unmount=D4.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var l=u.containerInfo;Gi(function(){S$(null,u,null,null)}),l[pn]=null}};function X$(u){this._internalRoot=u}X$.prototype.unstable_scheduleHydration=function(u){if(u){var l=dF();u={blockedOn:null,target:u,priority:l};for(var f=0;f<_0.length&&l!==0&&l<_0[f].priority;f++);_0.splice(f,0,u),f===0&&uU(u)}};function p4(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function Y$(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function GF(){}function Kz(u,l,f,r,n){if(n){if(typeof r==="function"){var i=r;r=function(){var $=K$(t);i.call($)}}var t=WJ(l,r,u,0,null,!1,!1,"",GF);return u._reactRootContainer=t,u[pn]=t.current,G1(u.nodeType===8?u.parentNode:u),Gi(),t}for(;n=u.lastChild;)u.removeChild(n);if(typeof r==="function"){var y=r;r=function(){var $=K$(c);y.call($)}}var c=V4(u,0,!1,null,null,!1,!1,"",GF);return u._reactRootContainer=c,u[pn]=c.current,G1(u.nodeType===8?u.parentNode:u),Gi(function(){S$(l,c,f,r)}),c}function P$(u,l,f,r,n){var i=f._reactRootContainer;if(i){var t=i;if(typeof n==="function"){var y=n;n=function(){var c=K$(t);y.call(c)}}S$(l,t,u,n)}else t=Kz(f,l,u,n,r);return K$(t)}aF=function(u){switch(u.tag){case 3:var l=u.stateNode;if(l.current.memoizedState.isDehydrated){var f=l1(l.pendingLanes);f!==0&&(e8(l,f|1),gf(l,hl()),(cl&6)===0&&(Ct=hl()+500,z0()))}break;case 13:Gi(function(){var r=Sn(u,1);if(r!==null){var n=pf();kr(r,u,1,n)}}),m4(u,1)}};u4=function(u){if(u.tag===13){var l=Sn(u,134217728);if(l!==null){var f=pf();kr(l,u,134217728,f)}m4(u,134217728)}};oF=function(u){if(u.tag===13){var l=w0(u),f=Sn(u,l);if(f!==null){var r=pf();kr(f,u,l,r)}m4(u,l)}};dF=function(){return jl};eF=function(u,l){var f=jl;try{return jl=u,l()}finally{jl=f}};$8=function(u,l,f){switch(l){case"input":if(r8(u,f),l=f.name,f.type==="radio"&&l!=null){for(f=u;f.parentNode;)f=f.parentNode;f=f.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]');for(l=0;l<f.length;l++){var r=f[l];if(r!==u&&r.form===u.form){var n=Z$(r);if(!n)throw Error(Ju(90));BF(r),r8(r,n)}}}break;case"textarea":mF(u,f);break;case"select":l=f.value,l!=null&&Ot(u,!!f.multiple,l,!1)}};CF=O4;MF=Gi;var Gz={usingClientEntryPoint:!1,Events:[S1,Wt,Z$,YF,PF,O4]},dy={findFiberByHostInstance:Ji,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},zz={bundleType:dy.bundleType,version:dy.version,rendererPackageName:dy.rendererPackageName,rendererConfig:dy.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Yn.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=hF(u),u===null?null:u.stateNode},findFiberByHostInstance:dy.findFiberByHostInstance||Tz,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){if(Ut=__REACT_DEVTOOLS_GLOBAL_HOOK__,!Ut.isDisabled&&Ut.supportsFiber)try{G$=Ut.inject(zz),$n=Ut}catch(u){}}var Ut;jr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Gz;jr.createPortal=function(u,l){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p4(l))throw Error(Ju(200));return Lz(u,l,null,f)};jr.createRoot=function(u,l){if(!p4(u))throw Error(Ju(299));var f=!1,r="",n=LJ;return l!==null&&l!==void 0&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(r=l.identifierPrefix),l.onRecoverableError!==void 0&&(n=l.onRecoverableError)),l=V4(u,1,!1,null,null,f,!1,r,n),u[pn]=l.current,G1(u.nodeType===8?u.parentNode:u),new D4(l)};jr.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var l=u._reactInternals;if(l===void 0){if(typeof u.render==="function")throw Error(Ju(188));throw u=Object.keys(u).join(","),Error(Ju(268,u))}return u=hF(l),u=u===null?null:u.stateNode,u};jr.flushSync=function(u){return Gi(u)};jr.hydrate=function(u,l,f){if(!Y$(l))throw Error(Ju(200));return P$(null,u,l,!0,f)};jr.hydrateRoot=function(u,l,f){if(!p4(u))throw Error(Ju(405));var r=f!=null&&f.hydratedSources||null,n=!1,i="",t=LJ;if(f!==null&&f!==void 0&&(f.unstable_strictMode===!0&&(n=!0),f.identifierPrefix!==void 0&&(i=f.identifierPrefix),f.onRecoverableError!==void 0&&(t=f.onRecoverableError)),l=WJ(l,null,u,1,f!=null?f:null,n,!1,i,t),u[pn]=l.current,G1(u),r)for(u=0;u<r.length;u++)f=r[u],n=f._getVersion,n=n(f._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[f,n]:l.mutableSourceEagerHydrationData.push(f,n);return new X$(l)};jr.render=function(u,l,f){if(!Y$(l))throw Error(Ju(200));return P$(null,u,l,!1,f)};jr.unmountComponentAtNode=function(u){if(!Y$(u))throw Error(Ju(40));return u._reactRootContainer?(Gi(function(){P$(null,null,u,!1,function(){u._reactRootContainer=null,u[pn]=null})}),!0):!1};jr.unstable_batchedUpdates=O4;jr.unstable_renderSubtreeIntoContainer=function(u,l,f,r){if(!Y$(f))throw Error(Ju(200));if(u==null||u._reactInternals===void 0)throw Error(Ju(38));return P$(u,l,f,!1,r)};jr.version="18.3.1-next-f1338f8080-20240426"});var S4=tr((rP,GJ)=>{function KJ(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=="function")return;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(KJ)}catch(u){console.error(u)}}KJ(),GJ.exports=TJ()});var EJ=tr((X4)=>{var zJ=S4();X4.createRoot=zJ.createRoot,X4.hydrateRoot=zJ.hydrateRoot;var Ez});var VN=tr((G3)=>{var dZ=Jl(),eZ=Symbol.for("react.element"),uH=Symbol.for("react.fragment"),lH=Object.prototype.hasOwnProperty,fH=dZ.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rH={key:!0,ref:!0,__self:!0,__source:!0};function BN(u,l,f){var r,n={},i=null,t=null;f!==void 0&&(i=""+f),l.key!==void 0&&(i=""+l.key),l.ref!==void 0&&(t=l.ref);for(r in l)lH.call(l,r)&&!rH.hasOwnProperty(r)&&(n[r]=l[r]);if(u&&u.defaultProps)for(r in l=u.defaultProps,l)n[r]===void 0&&(n[r]=l[r]);return{$$typeof:eZ,type:u,key:i,ref:t,props:n,_owner:fH.current}}G3.Fragment=uH;G3.jsx=BN;G3.jsxs=BN});var DN=tr(($C,mN)=>{mN.exports=VN()});var $w=tr((_w)=>{var Ly=Jl();function Wm(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}var Lm=typeof Object.is==="function"?Object.is:Wm,Tm=Ly.useState,Km=Ly.useEffect,Gm=Ly.useLayoutEffect,zm=Ly.useDebugValue;function Em(u,l){var f=l(),r=Tm({inst:{value:f,getSnapshot:l}}),n=r[0].inst,i=r[1];return Gm(function(){n.value=f,n.getSnapshot=l,H9(n)&&i({inst:n})},[u,f,l]),Km(function(){return H9(n)&&i({inst:n}),u(function(){H9(n)&&i({inst:n})})},[u]),zm(f),f}function H9(u){var l=u.getSnapshot;u=u.value;try{var f=l();return!Lm(u,f)}catch(r){return!0}}function Om(u,l){return l()}var Zm=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Om:Em;_w.useSyncExternalStore=Ly.useSyncExternalStore!==void 0?Ly.useSyncExternalStore:Zm});var jw=tr((rv,Aw)=>{Aw.exports=$w()});var Uw=tr((Fw)=>{var NA=Jl(),Hm=jw();function Bm(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}var Vm=typeof Object.is==="function"?Object.is:Bm,mm=Hm.useSyncExternalStore,Dm=NA.useRef,pm=NA.useEffect,Sm=NA.useMemo,Xm=NA.useDebugValue;Fw.useSyncExternalStoreWithSelector=function(u,l,f,r,n){var i=Dm(null);if(i.current===null){var t={hasValue:!1,value:null};i.current=t}else t=i.current;i=Sm(function(){function c(J){if(!$){if($=!0,A=J,J=r(J),n!==void 0&&t.hasValue){var Q=t.value;if(n(Q,J))return j=Q}return j=J}if(Q=j,Vm(A,J))return Q;var W=r(J);if(n!==void 0&&n(Q,W))return A=J,Q;return A=J,j=W}var $=!1,A,j,F=f===void 0?null:f;return[function(){return c(l())},F===null?void 0:function(){return c(F())}]},[l,f,r,n]);var y=mm(u,i[0],i[1]);return pm(function(){t.hasValue=!0,t.value=y},[y]),Xm(y),y}});var Qw=tr((iv,Jw)=>{Jw.exports=Uw()});var ui=Cu(Jl(),1);var W_="北京时间";var LK={timeZone:"Asia/Shanghai",hour12:!1},TK={timeZone:"Asia/Shanghai",hour12:!1},KK=new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"});function q6(u){if(u===null||u===void 0||u==="")return null;let l=u instanceof Date?u:new Date(u);return Number.isNaN(l.getTime())?null:l}function _j(u){let l=q6(u);if(!l)return null;return KK.formatToParts(l).reduce((f,r)=>{if(r.type!=="literal")f[r.type]=r.value;return f},{})}function wu(u){let l=q6(u);return l?l.toLocaleString("zh-CN",LK):"--"}function yl(u){let l=q6(u);return l?l.toLocaleTimeString("zh-CN",TK):"--"}function w6(u){let l=_j(u);if(!l)return"";let f=l.hour==="24"?"00":l.hour;return`${l.year}-${l.month}-${l.day}T${f}:${l.minute}`}function $j(u=new Date){let l=_j(u);if(!l)return"";return`${l.year}-${l.month}-${l.day}`}function Aj(u){if(!u)return null;let l=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(u);if(!l)return null;let[,f,r,n,i,t,y="00"]=l,c=Date.UTC(Number(f),Number(r)-1,Number(n),Number(i)-8,Number(t),Number(y)),$=new Date(c),A=w6($);return Number.isNaN($.getTime())||A!==`${f}-${r}-${n}T${i}:${t}`?null:$.toISOString()}var hL=Cu(EJ(),1);var R$=Cu(Jl(),1);var OJ=Cu(Jl(),1),Y1=OJ.default.createElement;function Oz({active:u=!0,label:l="正在加载"}){if(!u)return null;return Y1("span",{className:"loading-spinner-indicator",role:"status","aria-label":l,title:l,"data-testid":"loading-title-indicator"},Y1("span",{className:"loading-spinner-ring","aria-hidden":!0}))}function rl({title:u,children:l,loading:f,level:r=2,className:n="",label:i="正在加载"}){return Y1(r===3?"h3":"h2",{className:`loading-title ${f?"is-loading":""} ${n}`.trim()},Y1("span",{className:"loading-title-text"},l??u),Y1(Oz,{active:Boolean(f),label:i}))}class xt extends Error{unideskRequestError=!0;meta;constructor(u,l){super(u);this.name="UniDeskRequestError",this.meta=l}}function Zz(u){return new Promise((l)=>setTimeout(l,u))}function M1(u,l="操作失败"){return u instanceof Error?u.message:String(u||l)}function C$(u,l=500){if(u===null||u===void 0)return"";let f=typeof u==="string"?u:JSON.stringify(u),r=String(f||"").replace(/\s+/gu," ").trim();return r.length>l?`${r.slice(0,l)}...`:r}function Hz(u){try{let l=typeof location<"u"&&location.origin?location.origin:"http://localhost";return new URL(u,l).toString()}catch{return u}}function ZJ(u){return String(u.method||"GET").toUpperCase()}function Bz(u){if(u===null||u===void 0)return!1;if(typeof u!=="object")return!1;if(typeof Blob<"u"&&u instanceof Blob)return!1;if(typeof FormData<"u"&&u instanceof FormData)return!1;if(typeof URLSearchParams<"u"&&u instanceof URLSearchParams)return!1;if(typeof ArrayBuffer<"u"&&u instanceof ArrayBuffer)return!1;return!0}function HJ(u){let l=new Headers(u.headers||{}),f=Bz(u.body)?JSON.stringify(u.body):u.body;if(f&&!l.has("content-type")&&typeof f==="string")l.set("content-type","application/json");return{...u,credentials:u.credentials||"same-origin",body:f,headers:l}}function BJ(u){if(u?.error&&typeof u.error==="object"&&typeof u.error.message==="string")return u.error.message;if(typeof u?.error==="string")return u.error;if(typeof u?.message==="string")return u.message;if(typeof u?.detail==="string")return u.detail;return""}function Vz(u,l){if(!u||typeof u!=="object"||Array.isArray(u))return!1;return l.some((f)=>f!==!1&&u[f]===!1)}function P1(u,l,f,r,n={}){return{kind:u,method:f,url:Hz(l),occurredAt:r.toISOString(),...n}}function C1(u,l){if(!u)return"请求失败";return`HTTP ${u}${l?` ${l}`:""}`}function VJ(u){try{return{body:u?JSON.parse(u):null,parseError:""}}catch(l){return{body:{text:u},parseError:M1(l,"parse failed")}}}async function Eu(u,l={},f=0){let{failureFields:r=["ok"],strictJson:n=!1,retryInvalidJson:i=0,retryDelayMs:t=120,invalidJsonPrefix:y="服务返回了无效 JSON",invalidJsonPreview:c=!1,responsePreviewLength:$=500,...A}=l,j=ZJ(A),F=new Date,J;try{J=await fetch(u,HJ(A))}catch(L){let U=M1(L,"网络请求失败");throw new xt(U,P1("network",u,j,F,{upstreamMessage:U}))}let Q=await J.text(),W=VJ(Q);if(W.parseError){if(n&&j==="GET"&&f<i)return await Zz(t),Eu(u,l,f+1);if(n){let L=c?`;响应预览:${C$(Q,180)}`:"";throw new xt(`${y}(${Q.length} bytes):${W.parseError}${L}`,P1("parse",u,j,F,{status:J.status,statusText:J.statusText,parseError:W.parseError,responsePreview:C$(Q,$)}))}}if(!J.ok||Vz(W.body,r)){let L=BJ(W.body),U=L||C1(J.status,J.statusText);throw new xt(U,P1("http",u,j,F,{status:J.status,statusText:J.statusText,upstreamMessage:L,responsePreview:C$(W.parseError?Q:W.body,$)}))}return W.body}async function mJ(u,l={}){let f=ZJ(l),r=new Date,n;try{n=await fetch(u,HJ(l))}catch($){let A=M1($,"网络请求失败");throw new xt(A,P1("network",u,f,r,{upstreamMessage:A}))}if(n.ok)return n.blob();let i=await n.text(),t=VJ(i),y=BJ(t.body),c=y||C1(n.status,n.statusText);throw new xt(c,P1("http",u,f,r,{status:n.status,statusText:n.statusText,upstreamMessage:y,responsePreview:C$(t.parseError?i:t.body),parseError:t.parseError||void 0}))}function DJ(u){return Boolean(u&&typeof u==="object"&&u.unideskRequestError===!0&&u.meta)}function mz(u){if(!u)return"";let l=new Date(u);if(Number.isNaN(l.getTime()))return u;return`${wu(l)} ${W_}`}function Y4(u,l="操作失败"){if(DJ(u)){let n=u.meta.kind==="parse"?"响应解析失败":u.meta.kind==="network"?"网络请求失败":u.meta.status&&(u.meta.status<200||u.meta.status>=300)?C1(u.meta.status,u.meta.statusText):"应用请求失败",i=u.meta.status?C1(u.meta.status):"",t=(c)=>!c||c===n||c===i,y=!t(u.message)?u.message:t(u.meta.upstreamMessage)?"":u.meta.upstreamMessage||"";return{title:n,message:y,status:u.meta.status,statusText:u.meta.statusText,method:u.meta.method,url:u.meta.url,occurredAt:mz(u.meta.occurredAt),responsePreview:u.meta.responsePreview,parseError:u.meta.parseError,structured:!0}}let r=M1(u,l).split(/\r?\n/u);return{title:r[0]||l,message:r.slice(1).join(` -`),structured:r.length>1}}function Dz(u,l="操作失败"){let f=Y4(u,l),r=[f.title];if(f.message)r.push(`原因: ${f.message}`);if(f.method||f.url)r.push(`请求: ${[f.method,f.url].filter(Boolean).join(" ")}`);if(f.status)r.push(`状态: ${C1(f.status,f.statusText)}`);if(f.occurredAt)r.push(`时间: ${f.occurredAt}`);if(f.parseError)r.push(`解析错误: ${f.parseError}`);if(f.responsePreview&&f.responsePreview!==f.message)r.push(`响应预览: ${f.responsePreview}`);return r.filter(Boolean).join(` -`)}function Ou(u,l="操作失败"){return DJ(u)?Dz(u,l):M1(u,l)}var pJ=Cu(Jl(),1);var E0=pJ.default.createElement;function R1(u,l){return l?[E0("dt",{key:`${u}-label`},u),E0("dd",{key:u},l)]:null}function nl({error:u,wide:l=!1,fallback:f="操作失败",className:r=""}){if(!u)return null;let n=Y4(u,f),i=[R1("请求",[n.method,n.url].filter(Boolean).join(" ")),R1("状态",n.status?`HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`:""),R1("时间",n.occurredAt),R1("解析错误",n.parseError),R1("响应预览",n.responsePreview)].filter(Boolean);return E0("div",{className:`form-error unidesk-error${l?" wide":""}${r?` ${r}`:""}`,role:"alert","data-testid":"unidesk-error"},E0("div",{className:"unidesk-error-title"},E0("strong",null,n.title),n.status?E0("span",{className:"unidesk-error-code"},`HTTP ${n.status}`):null),n.message?E0("pre",{className:"unidesk-error-message"},n.message):null,i.length>0?E0("dl",{className:"unidesk-error-details"},i):null)}var jn=Cu(Jl(),1),SJ=jn.default.createContext(null);function XJ({children:u}){let[l,f]=jn.default.useState([]),[r,n]=jn.default.useState(Date.now()),i=jn.default.useCallback((j,F)=>{let Q={id:`notif_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,type:j,message:F,timestamp:Date.now()};f((W)=>{let L=[...W,Q];if(L.length>50)return L.slice(-50);return L})},[]),t=jn.default.useCallback((j)=>{f((F)=>F.filter((J)=>J.id!==j))},[]),y=jn.default.useCallback(()=>{f([]),n(Date.now())},[]),c=jn.default.useMemo(()=>{return l.filter((j)=>j.timestamp>r).length},[l,r]),$=c>0,A={notifications:l,addNotification:i,removeNotification:t,clearNotifications:y,unreadCount:c,hasUnread:$};return pz(SJ.Provider,{value:A},u)}var pz=jn.default.createElement;function Xf(){let u=jn.default.useContext(SJ);if(!u)throw Error("useNotification must be used within NotificationProvider");return u}var x=R$.default.createElement,{useEffect:M$}=R$.default,ht=R$.default.useState;function Gf(u,l={}){return Eu(u,{failureFields:["ok","success"],...l})}function Yf(u,l){return`${u}/microservices/baidu-netdisk/proxy${l}`}function Sz(u){let l=Number(u);return Number.isFinite(l)?l.toLocaleString("zh-CN"):"--"}function O0(u){let l=Number(u);if(!Number.isFinite(l)||l<=0)return"--";let f=["B","KB","MB","GB","TB"],r=l,n=0;while(r>=1024&&n<f.length-1)r/=1024,n+=1;return`${r.toFixed(n===0?0:1)} ${f[n]}`}function Oi({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return x("span",{className:`status-badge ${f}`},l||u||"unknown")}function bt({label:u,value:l,hint:f,tone:r}){return x("article",{className:`metric-card ${r||""}`},x("div",{className:"metric-label"},u),x("div",{className:"metric-value"},l),x("div",{className:"metric-hint"},f))}function Zi({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return x("section",{className:`panel ${n||""}`},x("div",{className:"panel-head"},x("div",null,l?x("p",{className:"panel-eyebrow"},l):null,x(rl,{title:u,loading:i})),f?x("div",{className:"panel-actions"},f):null),x("div",{className:"panel-body"},r))}function Pn({title:u,data:l,onOpen:f,testId:r}){return x("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:(n)=>{n?.stopPropagation?.(),f(u,l)}},"查看原始JSON")}function vt({title:u,text:l}){return x("div",{className:"empty-state"},x("strong",null,u),x("span",null,l))}function kt({title:u,text:l,href:f,badge:r,testId:n}){return x("a",{className:"doc-link-card",href:f,target:"_blank",rel:"noreferrer","data-testid":n},x("span",null,r||"DOC"),x("strong",null,u),x("p",null,l),x("code",null,f))}function Xz(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function Yz(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function Pz(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function Cz(u){return Array.isArray(u?.files)?u.files:[]}function Mz(u){return Array.isArray(u?.jobs)?u.jobs:[]}function Rz(u,l){if(!u||u===l)return l;let f=u.replace(/\/+$/u,""),r=f.slice(0,f.lastIndexOf("/"))||l;return r.length<l.length?l:r}function P4(u,l){let f=String(l||"").replace(/^\/+|\/+$/gu,"");return`${u.replace(/\/+$/u,"")}/${f}`}function xz(u){return u==="/"?"/":u.split("/").filter(Boolean).pop()||u}function hz({percent:u}){let l=Math.max(0,Math.min(100,Number(u)||0));return x("div",{className:"baidu-progress"},x("span",{style:{width:`${l}%`}}),x("em",null,`${l.toFixed(1)}%`))}function YJ({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((h)=>h.id==="baidu-netdisk")||null,[n,i]=ht({loading:!1,actionLoading:!1,error:"",message:"",health:null,account:null,files:null,transfers:null,logs:null,selfTest:null,refreshedAt:null}),[t,y]=ht("/"),[c,$]=ht(null),[A,j]=ht(""),[F,J]=ht({localPath:"sample.txt",remotePath:"/sample.txt"}),[Q,W]=ht({fsId:"",localPath:"downloads/"}),{addNotification:L}=Xf(),U=n.health?.baidu?.appRoot||n.account?.rootPath||"/";M$(()=>{J((h)=>{let lu=new Set(["/sample.txt","/apps/UniDeskBaiduNetdisk/sample.txt"]);if(h.remotePath&&!lu.has(h.remotePath))return h;let cu=P4(U,"sample.txt");return h.remotePath===cu?h:{...h,remotePath:cu}})},[U]);async function q(h=t){let cu=await Gf(Yf(f,`/api/files?dir=${encodeURIComponent(h||U)}&limit=100`));i((_u)=>({..._u,files:cu}))}async function N(){let h=await Gf(Yf(f,"/api/transfers?limit=80"));i((lu)=>({...lu,transfers:h}))}async function w(){if(!r)return;i((h)=>({...h,loading:!0,error:"",message:""}));try{let h=await Gf(`${f}/microservices/baidu-netdisk/health`),lu=h?.baidu?.appRoot||U,cu=null,_u=null;if(h?.auth?.loggedIn){cu=await Gf(Yf(f,"/api/account?refresh=1"));let Wu=t&&t.startsWith(lu)?t:lu;y(Wu),_u=await Gf(Yf(f,`/api/files?dir=${encodeURIComponent(Wu)}&limit=100`))}else y(lu);let Fu=await Gf(Yf(f,"/api/transfers?limit=80")),zu=await Gf(Yf(f,"/logs?limit=60"));i((Wu)=>({...Wu,loading:!1,health:h,account:cu?.account||null,files:_u,transfers:Fu,logs:zu,refreshedAt:new Date}))}catch(h){i((lu)=>({...lu,loading:!1,error:Ou(h,"百度网盘服务加载失败")}))}}async function G(){i((h)=>({...h,actionLoading:!0,error:"",message:""}));try{let h=await Gf(Yf(f,"/api/auth/device/start"),{method:"POST",body:{}});$(h.session||null),i((lu)=>({...lu,actionLoading:!1,message:"设备码已生成,请扫码授权"}))}catch(h){i((lu)=>({...lu,actionLoading:!1,error:Ou(h,"创建设备码失败")}))}}async function Z(h=!1){if(!c?.id)return;if(h)i((lu)=>({...lu,actionLoading:!0,error:""}));try{let lu=await Gf(Yf(f,`/api/auth/device/status?sessionId=${encodeURIComponent(c.id)}`));if($(lu.session||null),lu.session?.status==="succeeded")i((cu)=>({...cu,actionLoading:!1,message:"授权成功,正在刷新账号与文件列表"})),await w();else if(h)i((cu)=>({...cu,actionLoading:!1}))}catch(lu){i((cu)=>({...cu,actionLoading:!1,error:Ou(lu,"轮询登录状态失败")}))}}async function H(){i((h)=>({...h,actionLoading:!0,error:"",message:""}));try{await Gf(Yf(f,"/api/auth/logout"),{method:"POST",body:{}}),$(null),i((h)=>({...h,actionLoading:!1,account:null,files:null,message:"本地 token 已清除"})),await w()}catch(h){i((lu)=>({...lu,actionLoading:!1,error:Ou(h,"退出登录失败")}))}}async function E(h){h.preventDefault();let lu=A.trim();if(!lu)return;i((cu)=>({...cu,actionLoading:!0,error:"",message:""}));try{await Gf(Yf(f,"/api/folders"),{method:"POST",body:{path:P4(t,lu)}}),j(""),i((cu)=>({...cu,actionLoading:!1,message:"文件夹已创建"})),await q(t)}catch(cu){i((_u)=>({..._u,actionLoading:!1,error:Ou(cu,"创建文件夹失败")}))}}async function m(h){if(!h)return;i((lu)=>({...lu,actionLoading:!0,error:"",message:""}));try{await Gf(Yf(f,"/api/files/manage"),{method:"POST",body:{opera:"delete",filelist:[{path:h}],async:1}}),i((lu)=>({...lu,actionLoading:!1,message:"删除任务已提交"})),await q(t)}catch(lu){i((cu)=>({...cu,actionLoading:!1,error:Ou(lu,"删除失败")}))}}async function S(h){h.preventDefault(),i((lu)=>({...lu,actionLoading:!0,error:"",message:""}));try{await Gf(Yf(f,"/api/transfers/upload-from-path"),{method:"POST",body:F}),i((lu)=>({...lu,actionLoading:!1,message:"上传任务已入队"})),await N()}catch(lu){i((cu)=>({...cu,actionLoading:!1,error:Ou(lu,"上传任务创建失败")}))}}async function B(h){h.preventDefault(),i((lu)=>({...lu,actionLoading:!0,error:"",message:""}));try{await Gf(Yf(f,"/api/transfers/download-to-path"),{method:"POST",body:Q}),i((lu)=>({...lu,actionLoading:!1,message:"下载任务已入队"})),await N()}catch(lu){i((cu)=>({...cu,actionLoading:!1,error:Ou(lu,"下载任务创建失败")}))}}async function D(h,lu){i((cu)=>({...cu,actionLoading:!0,error:"",message:""}));try{await Gf(Yf(f,`/api/transfers/${encodeURIComponent(h)}/${lu}`),{method:"POST",body:{}}),i((cu)=>({...cu,actionLoading:!1,message:lu==="cancel"?"已请求取消任务":"任务已重新入队"})),await N()}catch(cu){i((_u)=>({..._u,actionLoading:!1,error:Ou(cu,"任务操作失败")}))}}async function X(){i((h)=>({...h,actionLoading:!0,error:"",message:"正在运行上传/下载自测..."}));try{let h=await Gf(Yf(f,"/api/self-test"),{method:"POST",body:{}});i((lu)=>({...lu,actionLoading:!1,selfTest:h,message:`上传/下载自测通过:${h.remotePath||""}`})),await q(t),await N()}catch(h){i((lu)=>({...lu,actionLoading:!1,error:Ou(h,"上传/下载自测失败")}))}}if(M$(()=>{if(!r)return;w();return},[r?.id,r?.runtime?.providerStatus]),M$(()=>{if(!c?.id||c.status!=="pending")return;let h=window.setInterval(()=>void Z(!1),Math.max(5000,Number(c.pollIntervalSeconds||5)*1000));return()=>window.clearInterval(h)},[c?.id,c?.status,c?.pollIntervalSeconds]),M$(()=>{if(!r)return;let h=window.setInterval(()=>void N(),5000);return()=>window.clearInterval(h)},[r?.id]),!r)return x(vt,{title:"Baidu Netdisk 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=baidu-netdisk"});let O=Xz(r),Y=Pz(r),p=Yz(r),v=n.health||{},z=n.account||v.auth?.account||null,P=v.auth||{},k=Cz(n.files),I=Mz(n.transfers),b=z?.quota||{},d=Boolean(P.loggedIn||z),s=Boolean(P.configured);return x("div",{className:"baidu-netdisk-page","data-testid":"baidu-netdisk-page"},x(Zi,{title:"Baidu Netdisk 工作台",eyebrow:"Containerized Storage Gateway",loading:n.loading,actions:x("div",{className:"panel-actions"},x("a",{className:"ghost-btn",href:"/docs/issue/baidu-netdisk-env-setup.md",target:"_blank",rel:"noreferrer","data-testid":"baidu-netdisk-config-doc-link"},"配置文档"),x("button",{type:"button",className:"ghost-btn",onClick:w,disabled:n.loading,"data-testid":"baidu-netdisk-refresh"},n.loading?"刷新中":"刷新"),x(Pn,{title:"Baidu Netdisk 用户服务",data:r,onOpen:l,testId:"raw-baidu-netdisk-service"}))},x("div",{className:"baidu-netdisk-hero"},x("div",null,x("div",{className:"node-version-line"},x(Oi,{status:O.providerStatus==="online"?"online":"warn"},O.providerStatus||"unknown"),x("span",null,r.providerId),x(Oi,{status:p.public?"warn":"private"},p.public?"公网暴露":"仅 UniDesk frontend 代理访问")),x("p",{className:"muted paragraph"},r.description)),x("div",{className:"microservice-ref-card"},x("span",null,"Repo"),x("strong",null,Y.url||"--"),x("code",null,Y.commitId||"--")),x("div",{className:"microservice-ref-card"},x("span",null,"Private Backend"),x("strong",null,`${p.nodeBindHost||"--"}:${p.nodePort||"--"}`),x("code",null,`${Y.composeFile||"--"} / ${Y.composeService||"--"}`))),x(nl,{error:n.error,wide:!0})),x("div",{className:"metric-grid"},x(bt,{label:"Health",value:v.ok?"OK":"--",hint:v.storage?.postgres||"postgres",tone:v.ok?"ok":"warn"}),x(bt,{label:"OAuth",value:s?"已配置":"待配置",hint:s?"client + secret + token key":"需要设置 UNIDESK_BAIDU_NETDISK_*",tone:s?"ok":"warn"}),x(bt,{label:"Login",value:d?"已登录":"未登录",hint:z?.username||"Device Code QR",tone:d?"ok":"warn"}),x(bt,{label:"Work Root",value:xz(U),hint:U}),x(bt,{label:"Quota",value:O0(b.used),hint:b.total?`${b.usedPercent||0}% / ${O0(b.total)}`:"授权后刷新"}),x(bt,{label:"Transfers",value:Sz(I.length),hint:`running ${n.transfers?.counts?.running||0} / failed ${n.transfers?.counts?.failed||0}`})),x(Zi,{title:"文件浏览器",eyebrow:t,className:"baidu-files-panel",loading:n.loading,actions:x("div",{className:"panel-actions inline-actions"},x("button",{type:"button",className:"ghost-btn",onClick:()=>{let h=Rz(t,U);y(h),q(h)},disabled:!d||t===U},"上级"),x("button",{type:"button",className:"ghost-btn",onClick:()=>q(t),disabled:!d},"刷新文件"),x(Pn,{title:"Baidu Files",data:n.files,onOpen:l,testId:"raw-baidu-files"}))},x("form",{className:"baidu-pathbar",onSubmit:(h)=>{h.preventDefault(),q(t)}},x("input",{value:t,onChange:(h)=>y(h.target.value),disabled:!d}),x("button",{type:"submit",className:"ghost-btn",disabled:!d},"打开路径")),x("form",{className:"baidu-pathbar",onSubmit:E},x("input",{value:A,onChange:(h)=>j(h.target.value),placeholder:"新文件夹名称",disabled:!d}),x("button",{type:"submit",className:"primary-btn",disabled:!d||!A.trim()},"新建文件夹")),!d?x(vt,{title:"等待授权",text:"登录后通过 /api/files 读取工作目录文件列表"}):k.length===0?x(vt,{title:"目录为空",text:"可以从 staging 目录上传文件或新建文件夹"}):x("div",{className:"table-wrap","data-testid":"baidu-netdisk-file-table"},x("table",null,x("thead",null,x("tr",null,x("th",null,"名称"),x("th",null,"类型"),x("th",null,"大小"),x("th",null,"修改时间"),x("th",null,"fs_id"),x("th",null,"操作"))),x("tbody",null,k.map((h)=>x("tr",{key:h.fsId||h.path},x("td",null,x("strong",null,h.serverFilename||h.path),x("code",null,h.path||"--")),x("td",null,x(Oi,{status:h.isDir?"queued":"private"},h.isDir?"DIR":"FILE")),x("td",null,h.isDir?"--":O0(h.size)),x("td",null,h.serverMtime?wu(h.serverMtime*1000):"--"),x("td",null,x("code",null,h.fsId||"--")),x("td",null,x("div",{className:"inline-actions"},h.isDir?x("button",{type:"button",className:"ghost-btn",onClick:()=>{y(h.path),q(h.path)}},"打开"):x("button",{type:"button",className:"ghost-btn",onClick:()=>W((lu)=>({...lu,fsId:h.fsId}))},"填入下载"),x("button",{type:"button",className:"ghost-btn",onClick:()=>m(h.path),disabled:n.actionLoading},"删除"))))))))),x("div",{className:"baidu-netdisk-grid"},x(Zi,{title:"配置与文档",eyebrow:"Deployment References",className:"baidu-docs-panel",actions:x("div",{className:"panel-actions inline-actions"},x("a",{className:"ghost-btn",href:"/docs/issue/baidu-netdisk-env-setup.md",target:"_blank",rel:"noreferrer"},"打开环境配置"),x("a",{className:"ghost-btn",href:"/docs/issue/baidu-netdisk-user-service.md",target:"_blank",rel:"noreferrer"},"打开服务方案"))},x("p",{className:"muted paragraph"},s?"OAuth 运行时变量已配置;如需轮换密钥、迁移部署或排查代理边界,可直接打开下面的项目内文档。":"首次使用请先按环境变量配置文档填入百度应用 client id / secret,然后重建 baidu-netdisk 服务并刷新本页。"),x("div",{className:"baidu-doc-grid","data-testid":"baidu-netdisk-doc-links"},x(kt,{title:"环境变量配置",text:"填写 UNIDESK_BAIDU_NETDISK_CLIENT_ID、CLIENT_SECRET、TOKEN_KEY,并执行重建与健康检查。",href:"/docs/issue/baidu-netdisk-env-setup.md",badge:"SETUP",testId:"baidu-netdisk-env-doc-card"}),x(kt,{title:"服务方案与 API",text:"说明 OAuth Device Code、根目录工作区、staging 上传下载任务和后端 API 设计。",href:"/docs/issue/baidu-netdisk-user-service.md",badge:"DESIGN"}),x(kt,{title:"用户服务安全边界",text:"查看 UniDesk microservice 私有代理、允许路径、frontendOnly 和密钥边界规则。",href:"/docs/reference/microservices.md",badge:"REF"}),x(kt,{title:"部署与重建流程",text:"查看 server rebuild、Compose 编排、健康检查和交付验证的长期规则。",href:"/docs/reference/deployment.md",badge:"DEPLOY"}),x(kt,{title:"CLI 验证命令",text:"查看 microservice health/proxy、server rebuild、job status 等命令入口。",href:"/docs/reference/cli.md",badge:"CLI"}),x(kt,{title:"百度设备码模式",text:"打开百度官方 OAuth Device Code 文档,对照扫码登录和轮询参数。",href:"https://pan.baidu.com/union/doc/fl1x114ti",badge:"OFFICIAL"}))),x(Zi,{title:"设备码登录",eyebrow:"OAuth Device Code",className:"baidu-login-panel",loading:n.actionLoading,actions:x("div",{className:"panel-actions inline-actions"},x("button",{type:"button",className:"primary-btn",onClick:G,disabled:n.actionLoading||!s,"data-testid":"baidu-netdisk-start-login"},"生成二维码"),c?.id?x("button",{type:"button",className:"ghost-btn",onClick:()=>Z(!0),disabled:n.actionLoading},"检查状态"):null,d?x("button",{type:"button",className:"ghost-btn",onClick:H,disabled:n.actionLoading},"清除本地登录"):null,x(Pn,{title:"Baidu Device Session",data:c||P.latestSession,onOpen:l,testId:"raw-baidu-device-session"}))},x("div",{className:"baidu-login-card","data-testid":"baidu-netdisk-login-card"},x("div",{className:"baidu-qr-frame"},c?.qrcodeUrl?x("img",{src:c.qrcodeUrl,alt:"百度网盘设备码授权二维码","data-testid":"baidu-netdisk-qrcode"}):x(vt,{title:s?"等待二维码":"OAuth 未配置",text:s?"点击生成二维码后使用百度网盘或百度 App 扫码":"设置 client id、secret 和 token key 后重建服务"})),x("div",{className:"claudeqq-login-copy"},x("div",{className:"node-version-line"},x(Oi,{status:d?"online":c?.status==="pending"?"warn":"unknown"},d?"已登录":c?.status||"未开始"),x("span",null,c?.secondsRemaining!==void 0?`${c.secondsRemaining}s`:"--"),x("span",null,"scope basic,netdisk")),x("p",{className:"muted paragraph"},d?"access token / refresh token 已加密保存到 PostgreSQL;前端只看到脱敏登录态。":"后端使用百度 OAuth Device Code 轮询换取 token;二维码过期后重新生成即可。"),x("div",{className:"microservice-ref-card"},x("span",null,"User Code"),x("strong",null,c?.userCode||"--"),x("code",null,c?.verificationUrl||"https://openapi.baidu.com/device")),x("div",{className:"microservice-ref-card"},x("span",null,"Expires"),x("strong",null,c?.expiresAt?wu(c.expiresAt):"--"),x("code",null,c?.error||"no token exposed"))))),x(Zi,{title:"账号与容量",eyebrow:n.refreshedAt?`Updated ${yl(n.refreshedAt)}`:"Account",loading:n.loading,actions:x("div",{className:"panel-actions inline-actions"},x(Pn,{title:"Baidu Account",data:z,onOpen:l,testId:"raw-baidu-account"}))},z?x("div",{className:"baidu-account-card"},x("div",{className:"node-version-line"},x(Oi,{status:"online"},"connected"),x("span",null,z.baiduUid||"--"),x("span",null,`VIP ${z.vipType??"--"}`)),x("h3",null,z.username||"Baidu Netdisk"),x("p",{className:"muted paragraph"},`工作目录固定在 ${z.rootPath||U};v1 上传/下载只读写容器 staging 目录,不把大文件字节流穿过 UniDesk proxy。`),x("div",{className:"quota-bar"},x("span",{style:{width:`${Math.max(0,Math.min(100,Number(b.usedPercent||0)))}%`}})),x("div",{className:"microservice-ref-card"},x("span",null,"Quota"),x("strong",null,`${O0(b.used)} / ${O0(b.total)}`),x("code",null,`${b.usedPercent||0}% used`))):x(vt,{title:"尚未登录",text:"扫码授权后这里会显示账号、UID、会员状态和容量"})),x(Zi,{title:"传输任务",eyebrow:"staging path jobs",className:"baidu-transfers-panel",loading:n.actionLoading,actions:x("div",{className:"panel-actions inline-actions"},x("button",{type:"button",className:"primary-btn",onClick:X,disabled:!d||n.actionLoading,"data-testid":"baidu-netdisk-self-test"},"运行自测"),x("button",{type:"button",className:"ghost-btn",onClick:N},"刷新任务"),x(Pn,{title:"Baidu Transfers",data:n.transfers,onOpen:l,testId:"raw-baidu-transfers"}))},x("div",{className:"baidu-transfer-forms"},x("form",{className:"stack-form",onSubmit:S,"data-testid":"baidu-upload-form"},x("label",null,"容器 staging 文件",x("input",{value:F.localPath,onChange:(h)=>J((lu)=>({...lu,localPath:h.target.value})),placeholder:"sample.txt"})),x("label",null,"百度网盘目标路径",x("input",{value:F.remotePath,onChange:(h)=>J((lu)=>({...lu,remotePath:h.target.value})),placeholder:P4(U,"sample.txt")})),x("button",{type:"submit",className:"primary-btn",disabled:!d||n.actionLoading},"上传 staging 文件")),x("form",{className:"stack-form",onSubmit:B,"data-testid":"baidu-download-form"},x("label",null,"文件 fs_id",x("input",{value:Q.fsId,onChange:(h)=>W((lu)=>({...lu,fsId:h.target.value})),placeholder:"从文件表填入"})),x("label",null,"保存到 staging 路径",x("input",{value:Q.localPath,onChange:(h)=>W((lu)=>({...lu,localPath:h.target.value})),placeholder:"downloads/"})),x("button",{type:"submit",className:"primary-btn",disabled:!d||!Q.fsId||n.actionLoading},"下载到 staging"))),n.selfTest?x("div",{className:"baidu-account-card","data-testid":"baidu-netdisk-self-test-result"},x("div",{className:"node-version-line"},x(Oi,{status:n.selfTest.ok?"online":"warn"},n.selfTest.ok?"self-test ok":"self-test"),x("span",null,O0(n.selfTest.sizeBytes))),x("h3",null,n.selfTest.remotePath||"Baidu self-test"),x("div",{className:"microservice-ref-card"},x("span",null,"fs_id"),x("strong",null,n.selfTest.fsId||"--"),x("code",null,n.selfTest.downloadedPath||"--")),x("div",{className:"microservice-ref-card"},x("span",null,"MD5"),x("strong",null,n.selfTest.downloadedMd5||"--"),x("code",null,n.selfTest.expectedMd5||"--")),x(Pn,{title:"Baidu Self Test",data:n.selfTest,onOpen:l,testId:"raw-baidu-self-test"})):null,I.length===0?x(vt,{title:"暂无传输任务",text:"上传/下载任务会在后端容器内执行,避免大文件穿过 UniDesk proxy"}):x("div",{className:"table-wrap","data-testid":"baidu-transfer-table"},x("table",null,x("thead",null,x("tr",null,x("th",null,"状态"),x("th",null,"方向"),x("th",null,"路径"),x("th",null,"进度"),x("th",null,"时间"),x("th",null,"操作"))),x("tbody",null,I.map((h)=>x("tr",{key:h.id},x("td",null,x(Oi,{status:h.status},h.status)),x("td",null,h.direction),x("td",null,x("strong",null,h.remotePath||h.fsId||"--"),x("code",null,h.localPath||"--"),h.error?x("span",{className:"form-error"},h.error):null),x("td",null,x(hz,{percent:h.progressPercent}),x("span",{className:"muted"},`${O0(h.bytesDone)} / ${O0(h.sizeBytes)}`)),x("td",null,wu(h.updatedAt)),x("td",null,x("div",{className:"inline-actions"},["queued","running"].includes(h.status)?x("button",{type:"button",className:"ghost-btn",onClick:()=>D(h.id,"cancel")},"取消"):null,["failed","canceled"].includes(h.status)?x("button",{type:"button",className:"ghost-btn",onClick:()=>D(h.id,"retry")},"重试"):null,x(Pn,{title:`Transfer ${h.id}`,data:h,onOpen:l}))))))))),x(Zi,{title:"安全与日志",eyebrow:"redacted diagnostics",className:"baidu-wide-panel",loading:n.loading,actions:x("div",{className:"panel-actions inline-actions"},x(Pn,{title:"Baidu Health",data:v,onOpen:l,testId:"raw-baidu-health"}),x(Pn,{title:"Baidu Logs",data:n.logs,onOpen:l,testId:"raw-baidu-logs"}))},x("div",{className:"policy-grid"},x("article",null,x("b",null,"私有后端"),x("span",null,"4244 只在 Compose 网络 expose,浏览器经 UniDesk 同源代理访问")),x("article",null,x("b",null,"Token 加密"),x("span",null,"access/refresh token 使用 BAIDU_NETDISK_TOKEN_KEY 加密后写入 PostgreSQL")),x("article",null,x("b",null,"无浏览器大文件流"),x("span",null,"上传/下载以容器 staging 目录为边界,避免 proxy 文本通道传输大字节流"))))))}var b$=Cu(Jl(),1);var o=b$.default.createElement,{useEffect:bz}=b$.default,x$=b$.default.useState,Hi={label:"主用户私聊账号",userId:645275593};function C4(u){let l=Number(u);return Number.isFinite(l)?l.toLocaleString("zh-CN"):"--"}async function Z0(u,l={}){return Eu(u,{failureFields:["ok","success"],...l})}async function vz(u){let l=await fetch(u,{credentials:"same-origin"}),f=await l.text();try{return f?JSON.parse(f):{ok:l.ok,status:l.status}}catch{return{ok:l.ok,status:l.status,text:f}}}function h$({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return o("span",{className:`status-badge ${f}`},l||u||"unknown")}function It({label:u,value:l,hint:f,tone:r}){return o("article",{className:`metric-card ${r||""}`},o("div",{className:"metric-label"},u),o("div",{className:"metric-value"},l),o("div",{className:"metric-hint"},f))}function gt({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return o("section",{className:`panel ${n||""}`},o("div",{className:"panel-head"},o("div",null,l?o("p",{className:"panel-eyebrow"},l):null,o(rl,{title:u,loading:i})),f?o("div",{className:"panel-actions"},f):null),o("div",{className:"panel-body"},r))}function x1({title:u,data:l,onOpen:f,testId:r}){return o("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:(n)=>{n?.stopPropagation?.(),f(u,l)}},"查看原始JSON")}function h1({title:u,text:l}){return o("div",{className:"empty-state"},o("strong",null,u),o("span",null,l))}function kz(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function Iz(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function gz(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function H0(u,l){return`${u}/microservices/claudeqq/proxy${l}`}function sz(u){return Array.isArray(u?.events)?u.events.slice(0,80):[]}function az(u){return Array.isArray(u?.subscriptions)?u.subscriptions.slice(0,50):[]}function oz(u){return Array.isArray(u?.messages)?u.messages.slice(0,30):[]}function PJ(u){let l=u?.text??u?.message??u?.raw?.raw_message;if(typeof l!=="string")return"--";return l.length>180?`${l.slice(0,177)}...`:l}function CJ(u){let l=u?.groupId??u?.group_id??(u?.message_type==="group"?u?.target_id:void 0),f=u?.userId??u?.user_id??(u?.message_type==="private"?u?.target_id:void 0);if(l)return`群 ${l}`;if(f)return`私聊 ${f}`;return"--"}function MJ({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((z)=>z.id==="claudeqq")||null,[n,i]=x$({loading:!1,qrLoading:!1,error:"",health:null,status:null,napcatLogin:null,napcatQrcode:null,qrcodeFetched:!1,qrcodeRefreshedAt:null,events:null,subscriptions:null,sent:null,refreshedAt:null}),[t,y]=x$({targetType:"private",targetId:String(Hi.userId),message:""}),[c,$]=x$({name:"unidesk-callback",targetUrl:"",eventTypes:"message",secret:""}),[A,j]=x$(""),{addNotification:F}=Xf();async function J(){if(!r)return;i((z)=>({...z,loading:!0,error:""}));try{let[z,P,k,I,b]=await Promise.all([vz(`${f}/microservices/claudeqq/health`),Z0(H0(f,"/api/server/status")),Z0(H0(f,"/api/events/recent?limit=60")),Z0(H0(f,"/api/events/subscriptions")),Z0(H0(f,"/api/messages/sent?limit=20"))]);if(i((d)=>({...d,loading:!1,error:"",health:z,status:P,events:k,subscriptions:I,sent:b,refreshedAt:new Date})),!n.qrcodeFetched)Q(!1)}catch(z){i((P)=>({...P,loading:!1,error:Ou(z,"ClaudeQQ 加载失败")}))}}async function Q(z=!0){if(!r)return;i((P)=>({...P,qrLoading:!0,error:z?"":P.error}));try{let P=await Z0(H0(f,"/api/napcat/login")),k=P?.napcat?.qrcode||P?.qrcode||null;i((I)=>({...I,qrLoading:!1,error:"",napcatLogin:P,napcatQrcode:k,qrcodeFetched:!0,qrcodeRefreshedAt:new Date}))}catch(P){i((k)=>({...k,qrLoading:!1,error:z||!k.napcatQrcode?Ou(P,"NapCat 二维码加载失败"):k.error}))}}async function W(z){z.preventDefault(),j("");let P=Number(t.targetId);if(!Number.isFinite(P)||P<=0||t.message.trim().length===0){i((k)=>({...k,error:"请填写 QQ 目标和消息内容"}));return}try{await Z0(H0(f,"/api/push/text"),{method:"POST",body:JSON.stringify({userId:t.targetType==="private"?P:void 0,groupId:t.targetType==="group"?P:void 0,message:t.message})});let k="消息推送请求已提交";y((I)=>({...I,targetType:"private",targetId:String(Hi.userId),message:""})),j(k),F("success",k),await J()}catch(k){i((I)=>({...I,error:Ou(k,"发送失败")}))}}async function L(z){if(z.preventDefault(),j(""),c.targetUrl.trim().length===0){i((P)=>({...P,error:"请填写订阅回调 URL"}));return}try{await Z0(H0(f,"/api/events/subscriptions"),{method:"POST",body:JSON.stringify({name:c.name,targetUrl:c.targetUrl,eventTypes:c.eventTypes.split(",").map((k)=>k.trim()).filter(Boolean),secret:c.secret||void 0,enabled:!0})});let P="事件订阅已创建";j(P),F("success",P),await J()}catch(P){i((k)=>({...k,error:Ou(P,"订阅失败")}))}}async function U(z){if(!z)return;j("");try{await Z0(H0(f,`/api/events/subscriptions/${encodeURIComponent(z)}`),{method:"DELETE"});let P="事件订阅已删除";j(P),F("success",P),await J()}catch(P){i((k)=>({...k,error:Ou(P,"删除订阅失败")}))}}if(bz(()=>{if(!r)return;J();return},[r?.id,r?.runtime?.providerStatus]),!r)return o(h1,{title:"ClaudeQQ 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=claudeqq"});let q=kz(r),N=gz(r),w=Iz(r),G=n.health||{},Z=n.status||{},H=n.napcatLogin||{},E=G.napcat||Z.napcat||{},m={...H.napcat||{},...E,qrcode:n.napcatQrcode||{},webui:E.webui||H.napcat?.webui},S=H.login||{},B=n.napcatQrcode||{},D=sz(n.events),X=az(n.subscriptions),O=oz(n.sent),Y=Boolean(m.httpConnected||S.ready),p=String(m.loginState||S.state||(Y?"logged_in":"unknown")),v=Boolean(B.available&&B.dataUrl);return o("div",{className:"claudeqq-page","data-testid":"claudeqq-page"},o(gt,{title:"ClaudeQQ 工作台",eyebrow:"D601 QQ Event Gateway",loading:n.loading,actions:o("div",{className:"panel-actions"},o("button",{type:"button",className:"ghost-btn",onClick:J,disabled:n.loading,"data-testid":"claudeqq-refresh-button"},n.loading?"刷新中":"刷新"),o(x1,{title:"ClaudeQQ 用户服务",data:r,onOpen:l,testId:"raw-claudeqq-service"}))},o("div",{className:"findjob-hero"},o("div",null,o("div",{className:"node-version-line"},o(h$,{status:q.providerStatus==="online"?"online":"warn"},q.providerStatus||"unknown"),o("span",null,r.providerId),o("span",null,w.public?"公网暴露":"仅 UniDesk frontend 代理访问")),o("p",{className:"muted paragraph"},r.description)),o("div",{className:"microservice-ref-card"},o("span",null,"Repo"),o("strong",null,N.url||"--"),o("code",null,N.commitId||"--")),o("div",{className:"microservice-ref-card"},o("span",null,"D601 Docker"),o("strong",null,`${w.nodeBindHost||"--"}:${w.nodePort||"--"}`),o("code",null,`${N.composeFile||"--"} / ${N.composeService||"--"}`))),o(nl,{error:n.error,wide:!0})),o("div",{className:"metric-grid"},o(It,{label:"Health",value:G.ok||G.status==="ok"?"OK":"--",hint:"D601 /health",tone:G.ok||G.status==="ok"?"ok":"warn"}),o(It,{label:"NapCat HTTP",value:m.httpConnected||m.http?.connected?"OK":"离线",hint:`${m.httpHost||G.napcat?.httpHost||"--"}:${m.httpPort||G.napcat?.httpPort||"--"}`}),o(It,{label:"NapCat WS",value:m.wsConnected||m.ws?.connected?"OK":"离线",hint:`${m.wsHost||G.napcat?.wsHost||"--"}:${m.wsPort||G.napcat?.wsPort||"--"}`}),o(It,{label:"事件缓存",value:C4(n.events?.count??D.length),hint:"recent QQ events"}),o(It,{label:"订阅",value:C4(n.subscriptions?.count??X.length),hint:"webhook subscribers"}),o(It,{label:"已发送",value:C4(n.sent?.count??O.length),hint:"sent message log"})),o("div",{className:"findjob-grid"},o(gt,{title:"NapCat 容器登录",eyebrow:"QR Login",className:"claudeqq-login-panel",loading:n.qrLoading,actions:o("div",{className:"panel-actions inline-actions"},o("button",{type:"button",className:"ghost-btn",onClick:()=>Q(!0),disabled:n.qrLoading,"data-testid":"claudeqq-napcat-refresh"},n.qrLoading?"刷新中":"手动刷新二维码"),o(x1,{title:"NapCat Login",data:n.napcatLogin,onOpen:l,testId:"raw-claudeqq-napcat-login"}))},o("div",{className:"claudeqq-login-card","data-testid":"claudeqq-napcat-login"},o("div",{className:"claudeqq-qr-frame"},v?o("img",{src:B.dataUrl,alt:"NapCat QQ 登录二维码","data-testid":"claudeqq-napcat-qrcode"}):o(h1,{title:"等待二维码",text:"NapCat 容器启动后会把登录二维码写入 cache/qrcode.png"})),o("div",{className:"claudeqq-login-copy"},o("div",{className:"node-version-line"},o(h$,{status:Y?"online":v?"warn":"unknown"},Y?"已登录":v?"待扫码":"等待二维码"),o("span",null,p),o("span",null,"D601 containerized")),o("p",{className:"muted paragraph"},Y?"NapCat 已登录,ClaudeQQ 可通过容器内 HTTP/WS 链路收发 QQ 消息。":"用手机 QQ 扫描二维码授权登录。二维码只在首次加载或手动刷新时更新,D601 的 NapCat 端口仍只绑定 127.0.0.1。"),o("div",{className:"microservice-ref-card"},o("span",null,"NapCat WebUI"),o("strong",null,m.webui?.url||"http://napcat:6099/webui"),o("code",null,"local-only / proxied QR login")),o("div",{className:"microservice-ref-card"},o("span",null,"QR Source"),o("strong",null,B.modifiedAt?wu(B.modifiedAt):n.qrcodeRefreshedAt?wu(n.qrcodeRefreshedAt):"--"),o("code",null,B.file||"/napcat/cache/qrcode.png"))))),o(gt,{title:"消息推送",eyebrow:"Push API"},o("div",{className:"microservice-ref-card"},o("span",null,Hi.label),o("strong",null,String(Hi.userId)),o("code",null,"private userId / 默认推送测试目标")),o("form",{className:"stack-form",onSubmit:W,"data-testid":"claudeqq-push-form"},o("label",null,"目标类型",o("select",{value:t.targetType,onChange:(z)=>y((P)=>({...P,targetType:z.target.value}))},o("option",{value:"private"},"私聊 userId"),o("option",{value:"group"},"群 groupId"))),o("label",null,"QQ ID",o("input",{value:t.targetId,onChange:(z)=>y((P)=>({...P,targetId:z.target.value})),placeholder:String(Hi.userId)})),o("label",null,"消息内容",o("textarea",{value:t.message,onChange:(z)=>y((P)=>({...P,message:z.target.value})),rows:4,placeholder:"通过 ClaudeQQ 推送一条 QQ 消息"})),o("button",{type:"submit",className:"primary-btn"},"发送 QQ 消息")),o("p",{className:"muted paragraph"},`主 server 和其他用户服务可通过 UniDesk 同源代理调用 /api/push/text;当前人工推送测试默认使用 ${Hi.label} ${Hi.userId},不需要暴露 D601 后端端口。`)),o(gt,{title:"QQ 事件订阅",eyebrow:"Webhook Subscription",loading:n.loading},o("form",{className:"stack-form",onSubmit:L,"data-testid":"claudeqq-subscription-form"},o("label",null,"订阅名称",o("input",{value:c.name,onChange:(z)=>$((P)=>({...P,name:z.target.value}))})),o("label",null,"回调 URL",o("input",{value:c.targetUrl,onChange:(z)=>$((P)=>({...P,targetUrl:z.target.value})),placeholder:"http://host.docker.internal:18080/..."})),o("label",null,"事件类型",o("input",{value:c.eventTypes,onChange:(z)=>$((P)=>({...P,eventTypes:z.target.value})),placeholder:"message,notice"})),o("label",null,"签名密钥",o("input",{value:c.secret,onChange:(z)=>$((P)=>({...P,secret:z.target.value})),placeholder:"可选,生成 x-claudeqq-signature"})),o("button",{type:"submit",className:"primary-btn"},"创建订阅")),X.length===0?o(h1,{title:"暂无订阅",text:"可以为 main server 或其他用户服务注册 HTTP webhook"}):o("div",{className:"table-wrap","data-testid":"claudeqq-subscription-table"},o("table",null,o("thead",null,o("tr",null,o("th",null,"名称"),o("th",null,"状态"),o("th",null,"事件"),o("th",null,"回调"),o("th",null,"最近投递"),o("th",null,"操作"))),o("tbody",null,X.map((z)=>o("tr",{key:z.id},o("td",null,o("strong",null,z.name||z.id),o("code",null,z.id||"--")),o("td",null,o(h$,{status:z.enabled?"online":"warn"},z.enabled?"enabled":"disabled")),o("td",null,Array.isArray(z.eventTypes)?z.eventTypes.join(", "):"message"),o("td",null,z.targetUrl||"--"),o("td",null,z.lastDelivery?`${z.lastDelivery.ok?"OK":"FAIL"} ${wu(z.lastDelivery.at)}`:"--"),o("td",null,o("button",{type:"button",className:"ghost-btn",onClick:()=>U(z.id)},"删除"))))))),o("div",{className:"panel-actions inline-actions"},o(x1,{title:"ClaudeQQ Subscriptions",data:n.subscriptions,onOpen:l,testId:"raw-claudeqq-subscriptions"}))),o(gt,{title:"最近 QQ 事件",eyebrow:n.refreshedAt?`Updated ${yl(n.refreshedAt)}`:"Event Stream",loading:n.loading},D.length===0?o(h1,{title:"暂无事件",text:"等待 NapCat WebSocket 上报 QQ 消息事件,或通过订阅 API 消费后续事件"}):o("div",{className:"table-wrap","data-testid":"claudeqq-event-list"},o("table",null,o("thead",null,o("tr",null,o("th",null,"时间"),o("th",null,"类型"),o("th",null,"会话"),o("th",null,"消息"),o("th",null,"ID"))),o("tbody",null,D.map((z)=>o("tr",{key:z.id},o("td",null,wu(z.receivedAt||z.timestamp)),o("td",null,o(h$,{status:z.postType||z.eventType},z.postType||z.eventType||"--")),o("td",null,CJ(z)),o("td",null,PJ(z)),o("td",null,o("code",null,z.messageId||z.id||"--"))))))),o("div",{className:"panel-actions inline-actions"},o(x1,{title:"ClaudeQQ Events",data:n.events,onOpen:l,testId:"raw-claudeqq-events"}))),o(gt,{title:"已发送消息",eyebrow:`${O.length} Sent`,loading:n.loading},O.length===0?o(h1,{title:"暂无发送记录",text:"发送日志来自 ClaudeQQ bot_workspace/messages/sent_messages.jsonl"}):o("div",{className:"table-wrap"},o("table",null,o("thead",null,o("tr",null,o("th",null,"时间"),o("th",null,"目标"),o("th",null,"消息"),o("th",null,"结果"))),o("tbody",null,O.map((z,P)=>o("tr",{key:z.id||P},o("td",null,wu(z.timestamp||z.sentAt||z.createdAt)),o("td",null,CJ(z)),o("td",null,PJ(z)),o("td",null,z.status||z.messageId||z.message_id||"--")))))),o("div",{className:"panel-actions inline-actions"},o(x1,{title:"ClaudeQQ Sent Messages",data:n.sent,onOpen:l,testId:"raw-claudeqq-sent"})))))}var uc=Cu(Jl(),1);var hJ=Cu(Jl(),1),ql=hJ.default.createElement;function bJ({markdown:u,className:l,testId:f}){let r=String(u??"").trimEnd(),n=["markdown-body",l].filter(Boolean).join(" ");return ql("div",{className:n,"data-testid":f},vJ(r,"md"))}function vJ(u,l){let f=dz(u).split(` -`),r=[],n=0;while(n<f.length){let i=f[n]??"";if(i.trim().length===0){n+=1;continue}let t=kJ(i);if(t!==null){let j=[];n+=1;while(n<f.length&&!ez(f[n]??"",t))j.push(f[n]??""),n+=1;if(n<f.length)n+=1;r.push(RJ(j.join(` -`),t.language,`${l}-fence-${n}`));continue}if(M4(i)){let j=[];while(n<f.length&&(M4(f[n]??"")||(f[n]??"").trim().length===0)){let F=f[n]??"";j.push(F.replace(/^(?: {4}|\t)/u,"")),n+=1}r.push(RJ(j.join(` -`).trimEnd(),"",`${l}-indent-${n}`));continue}let y=i.match(/^(#{1,6})\s+(.+)$/u);if(y!==null){let j=y[1].length,F=`h${Math.min(6,j+2)}`;r.push(ql(F,{key:`${l}-heading-${n}`},Fn(y[2].trim(),`${l}-heading-${n}`))),n+=1;continue}if(/^\s*(?:---+|\*\*\*+|___+)\s*$/u.test(i)){r.push(ql("hr",{key:`${l}-hr-${n}`})),n+=1;continue}if(/^\s*>\s?/u.test(i)){let j=[];while(n<f.length){let F=f[n]??"",J=F.match(/^\s*>\s?(.*)$/u);if(J!==null){j.push(J[1]),n+=1;continue}if(F.trim().length===0){j.push(""),n+=1;continue}break}r.push(ql("blockquote",{key:`${l}-quote-${n}`},vJ(j.join(` -`),`${l}-quote-${n}`)));continue}if(IJ(f,n)){let j=n,F=b1(f[n]??""),J=b1(f[n+1]??"");n+=2;let Q=[];while(n<f.length&&(f[n]??"").includes("|")&&(f[n]??"").trim().length>0)Q.push(b1(f[n]??"")),n+=1;r.push(rE(F,J,Q,`${l}-table-${j}`));continue}let c=k$(i);if(c!==null){let j=n,F=c.ordered,J=c.start,Q=[];while(n<f.length){let L=k$(f[n]??"");if(L===null||L.ordered!==F)break;let U=[L.text];n+=1;while(n<f.length){let q=f[n]??"";if(q.trim().length===0)break;if(k$(q)!==null)break;if(!/^\s{2,}/u.test(q))break;U.push(q.replace(/^\s{2,4}/u,"")),n+=1}Q.push(U.join(` -`).trimEnd())}let W={key:`${l}-list-${j}`};if(F&&J!==void 0&&J!==1)W.start=J;r.push(ql(F?"ol":"ul",W,Q.map((L,U)=>lE(L,`${l}-list-${j}-${U}`))));continue}let $=n,A=[];while(n<f.length&&f[n]!==void 0&&f[n].trim().length>0&&!uE(f,n))A.push(f[n].trim()),n+=1;if(A.length===0)A.push(i.trim()),n+=1;r.push(ql("p",{key:`${l}-p-${$}`},Fn(A.join(` -`),`${l}-p-${$}`)))}return r}function dz(u){return String(u||"").replace(/\r\n/gu,` +`+i.stack}return{value:l,source:u,stack:n,digest:null}}function y8(l,u,r){return{value:l,source:null,stack:r!=null?r:null,digest:u!=null?u:null}}function v8(l,u){try{console.error(u.value)}catch(r){setTimeout(function(){throw r})}}var mK=typeof WeakMap==="function"?WeakMap:Map;function jU(l,u,r){r=Yn(-1,r),r.tag=3,r.payload={element:null};var f=u.value;return r.callback=function(){Z$||(Z$=!0,u4=f),v8(l,u)},r}function FU(l,u,r){r=Yn(-1,r),r.tag=3;var f=l.type.getDerivedStateFromError;if(typeof f==="function"){var n=u.value;r.payload=function(){return f(n)},r.callback=function(){v8(l,u)}}var i=l.stateNode;return i!==null&&typeof i.componentDidCatch==="function"&&(r.callback=function(){v8(l,u),typeof f!=="function"&&(mi===null?mi=new Set([this]):mi.add(this));var t=u.stack;this.componentDidCatch(u.value,{componentStack:t!==null?t:""})}),r}function mF(l,u,r){var f=l.pingCache;if(f===null){f=l.pingCache=new mK;var n=new Set;f.set(u,n)}else n=f.get(u),n===void 0&&(n=new Set,f.set(u,n));n.has(r)||(n.add(r),l=PK.bind(null,l,u,r),u.then(l,l))}function KF(l){do{var u;if(u=l.tag===13)u=l.memoizedState,u=u!==null?u.dehydrated!==null?!0:!1:!0;if(u)return l;l=l.return}while(l!==null);return null}function zF(l,u,r,f,n){if((l.mode&1)===0)return l===u?l.flags|=65536:(l.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(u=Yn(-1,1),u.tag=2,Ti(r,u,1))),r.lanes|=1),l;return l.flags|=65536,l.lanes=n,l}var KK=Rn.ReactCurrentOwner,vr=!1;function Dr(l,u,r,f){u.child=l===null?RJ(u,null,r,f):ht(u,l.child,r,f)}function EF(l,u,r,f,n){r=r.render;var i=u.ref;if(Xt(u,n),f=D4(l,u,r,f,i,n),r=V4(),l!==null&&!vr)return u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~n,hn(l,u,n);return Ou&&r&&L4(u),u.flags|=1,Dr(l,u,f,n),u.child}function OF(l,u,r,f,n){if(l===null){var i=r.type;if(typeof i==="function"&&!b4(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0)return u.tag=15,u.type=i,JU(l,u,i,f,n);return l=c$(r.type,null,f,u,u.mode,n),l.ref=u.ref,l.return=u,u.child=l}if(i=l.child,(l.lanes&n)===0){var t=i.memoizedProps;if(r=r.compare,r=r!==null?r:p1,r(t,f)&&l.ref===u.ref)return hn(l,u,n)}return u.flags|=1,l=zi(i,f),l.ref=u.ref,l.return=u,u.child=l}function JU(l,u,r,f,n){if(l!==null){var i=l.memoizedProps;if(p1(i,f)&&l.ref===u.ref)if(vr=!1,u.pendingProps=f=i,(l.lanes&n)!==0)(l.flags&131072)!==0&&(vr=!0);else return u.lanes=l.lanes,hn(l,u,n)}return s8(l,u,r,f,n)}function UU(l,u,r){var f=u.pendingProps,n=f.children,i=l!==null?l.memoizedState:null;if(f.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},Lu(Ht,_f),_f|=r;else{if((r&1073741824)===0)return l=i!==null?i.baseLanes|r:r,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null,transitions:null},u.updateQueue=null,Lu(Ht,_f),_f|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},f=i!==null?i.baseLanes:r,Lu(Ht,_f),_f|=f}else i!==null?(f=i.baseLanes|r,u.memoizedState=null):f=r,Lu(Ht,_f),_f|=f;return Dr(l,u,n,r),u.child}function NU(l,u){var r=u.ref;if(l===null&&r!==null||l!==null&&l.ref!==r)u.flags|=512,u.flags|=2097152}function s8(l,u,r,f,n){var i=kr(r)?T0:mr.current;if(i=Ct(u,i),Xt(u,n),r=D4(l,u,r,f,i,n),f=V4(),l!==null&&!vr)return u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~n,hn(l,u,n);return Ou&&f&&L4(u),u.flags|=1,Dr(l,u,r,n),u.child}function ZF(l,u,r,f,n){if(kr(r)){var i=!0;q$(u)}else i=!1;if(Xt(u,n),u.stateNode===null)i$(l,u),AU(u,r,f),b8(u,r,f,n),f=!0;else if(l===null){var{stateNode:t,memoizedProps:y}=u;t.props=y;var c=t.context,$=r.contextType;typeof $==="object"&&$!==null?$=Zf($):($=kr(r)?T0:mr.current,$=Ct(u,$));var A=r.getDerivedStateFromProps,j=typeof A==="function"||typeof t.getSnapshotBeforeUpdate==="function";j||typeof t.UNSAFE_componentWillReceiveProps!=="function"&&typeof t.componentWillReceiveProps!=="function"||(y!==f||c!==$)&&TF(u,t,f,$),Ji=!1;var F=u.memoizedState;t.state=F,m$(u,f,t,n),c=u.memoizedState,y!==f||F!==c||sr.current||Ji?(typeof A==="function"&&(x8(u,r,A,f),c=u.memoizedState),(y=Ji||GF(u,r,y,f,F,c,$))?(j||typeof t.UNSAFE_componentWillMount!=="function"&&typeof t.componentWillMount!=="function"||(typeof t.componentWillMount==="function"&&t.componentWillMount(),typeof t.UNSAFE_componentWillMount==="function"&&t.UNSAFE_componentWillMount()),typeof t.componentDidMount==="function"&&(u.flags|=4194308)):(typeof t.componentDidMount==="function"&&(u.flags|=4194308),u.memoizedProps=f,u.memoizedState=c),t.props=f,t.state=c,t.context=$,f=y):(typeof t.componentDidMount==="function"&&(u.flags|=4194308),f=!1)}else{t=u.stateNode,bJ(l,u),y=u.memoizedProps,$=u.type===u.elementType?y:xf(u.type,y),t.props=$,j=u.pendingProps,F=t.context,c=r.contextType,typeof c==="object"&&c!==null?c=Zf(c):(c=kr(r)?T0:mr.current,c=Ct(u,c));var U=r.getDerivedStateFromProps;(A=typeof U==="function"||typeof t.getSnapshotBeforeUpdate==="function")||typeof t.UNSAFE_componentWillReceiveProps!=="function"&&typeof t.componentWillReceiveProps!=="function"||(y!==j||F!==c)&&TF(u,t,f,c),Ji=!1,F=u.memoizedState,t.state=F,m$(u,f,t,n);var N=u.memoizedState;y!==j||F!==N||sr.current||Ji?(typeof U==="function"&&(x8(u,r,U,f),N=u.memoizedState),($=Ji||GF(u,r,$,f,F,N,c)||!1)?(A||typeof t.UNSAFE_componentWillUpdate!=="function"&&typeof t.componentWillUpdate!=="function"||(typeof t.componentWillUpdate==="function"&&t.componentWillUpdate(f,N,c),typeof t.UNSAFE_componentWillUpdate==="function"&&t.UNSAFE_componentWillUpdate(f,N,c)),typeof t.componentDidUpdate==="function"&&(u.flags|=4),typeof t.getSnapshotBeforeUpdate==="function"&&(u.flags|=1024)):(typeof t.componentDidUpdate!=="function"||y===l.memoizedProps&&F===l.memoizedState||(u.flags|=4),typeof t.getSnapshotBeforeUpdate!=="function"||y===l.memoizedProps&&F===l.memoizedState||(u.flags|=1024),u.memoizedProps=f,u.memoizedState=N),t.props=f,t.state=N,t.context=c,f=$):(typeof t.componentDidUpdate!=="function"||y===l.memoizedProps&&F===l.memoizedState||(u.flags|=4),typeof t.getSnapshotBeforeUpdate!=="function"||y===l.memoizedProps&&F===l.memoizedState||(u.flags|=1024),f=!1)}return k8(l,u,r,f,i,n)}function k8(l,u,r,f,n,i){NU(l,u);var t=(u.flags&128)!==0;if(!f&&!t)return n&&JF(u,r,!1),hn(l,u,i);f=u.stateNode,KK.current=u;var y=t&&typeof r.getDerivedStateFromError!=="function"?null:f.render();return u.flags|=1,l!==null&&t?(u.child=ht(u,l.child,null,i),u.child=ht(u,null,y,i)):Dr(l,u,y,i),u.memoizedState=f.state,n&&JF(u,r,!0),u.child}function QU(l){var u=l.stateNode;u.pendingContext?FF(l,u.pendingContext,u.pendingContext!==u.context):u.context&&FF(l,u.context,!1),Z4(l,u.containerInfo)}function pF(l,u,r,f,n){return Mt(),T4(n),u.flags|=256,Dr(l,u,r,f),u.child}var g8={dehydrated:null,treeContext:null,retryLane:0};function I8(l){return{baseLanes:l,cachePool:null,transitions:null}}function wU(l,u,r){var f=u.pendingProps,n=pu.current,i=!1,t=(u.flags&128)!==0,y;if((y=t)||(y=l!==null&&l.memoizedState===null?!1:(n&2)!==0),y)i=!0,u.flags&=-129;else if(l===null||l.memoizedState!==null)n|=1;if(Lu(pu,n&1),l===null){if(h8(u),l=u.memoizedState,l!==null&&(l=l.dehydrated,l!==null))return(u.mode&1)===0?u.lanes=1:l.data==="$!"?u.lanes=8:u.lanes=1073741824,null;return t=f.children,l=f.fallback,i?(f=u.mode,i=u.child,t={mode:"hidden",children:t},(f&1)===0&&i!==null?(i.childLanes=0,i.pendingProps=t):i=x$(t,f,0,null),l=G0(l,f,r,null),i.return=u,l.return=u,i.sibling=l,u.child=i,u.child.memoizedState=I8(r),u.memoizedState=g8,l):Y4(u,t)}if(n=l.memoizedState,n!==null&&(y=n.dehydrated,y!==null))return zK(l,u,t,f,y,n,r);if(i){i=f.fallback,t=u.mode,n=l.child,y=n.sibling;var c={mode:"hidden",children:f.children};return(t&1)===0&&u.child!==n?(f=u.child,f.childLanes=0,f.pendingProps=c,u.deletions=null):(f=zi(n,c),f.subtreeFlags=n.subtreeFlags&14680064),y!==null?i=zi(y,i):(i=G0(i,t,r,null),i.flags|=2),i.return=u,f.return=u,f.sibling=i,u.child=f,f=i,i=u.child,t=l.child.memoizedState,t=t===null?I8(r):{baseLanes:t.baseLanes|r,cachePool:null,transitions:t.transitions},i.memoizedState=t,i.childLanes=l.childLanes&~r,u.memoizedState=g8,f}return i=l.child,l=i.sibling,f=zi(i,{mode:"visible",children:f.children}),(u.mode&1)===0&&(f.lanes=r),f.return=u,f.sibling=null,l!==null&&(r=u.deletions,r===null?(u.deletions=[l],u.flags|=16):r.push(l)),u.child=f,u.memoizedState=null,f}function Y4(l,u){return u=x$({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function I_(l,u,r,f){return f!==null&&T4(f),ht(u,l.child,null,r),l=Y4(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function zK(l,u,r,f,n,i,t){if(r){if(u.flags&256)return u.flags&=-257,f=y8(Error(Ul(422))),I_(l,u,t,f);if(u.memoizedState!==null)return u.child=l.child,u.flags|=128,null;return i=f.fallback,n=u.mode,f=x$({mode:"visible",children:f.children},n,0,null),i=G0(i,n,t,null),i.flags|=2,f.return=u,i.return=u,f.sibling=i,u.child=f,(u.mode&1)!==0&&ht(u,l.child,null,t),u.child.memoizedState=I8(t),u.memoizedState=g8,i}if((u.mode&1)===0)return I_(l,u,t,null);if(n.data==="$!"){if(f=n.nextSibling&&n.nextSibling.dataset,f)var y=f.dgst;return f=y,i=Error(Ul(419)),f=y8(i,f,void 0),I_(l,u,t,f)}if(y=(t&l.childLanes)!==0,vr||y){if(f=_r,f!==null){switch(t&-t){case 4:n=2;break;case 16:n=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:n=32;break;case 536870912:n=268435456;break;default:n=0}n=(n&(f.suspendedLanes|t))!==0?0:n,n!==0&&n!==i.retryLane&&(i.retryLane=n,Mn(l,n),kf(f,l,n,-1))}return x4(),f=y8(Error(Ul(421))),I_(l,u,t,f)}if(n.data==="$?")return u.flags|=128,u.child=l.child,u=CK.bind(null,l),n._reactRetry=u,null;return l=i.treeContext,$f=Gi(n.nextSibling),Af=u,Ou=!0,vf=null,l!==null&&(Kf[zf++]=Sn,Kf[zf++]=Xn,Kf[zf++]=m0,Sn=l.id,Xn=l.overflow,m0=u),u=Y4(u,f.children),u.flags|=4096,u}function HF(l,u,r){l.lanes|=u;var f=l.alternate;f!==null&&(f.lanes|=u),R8(l.return,u,r)}function c8(l,u,r,f,n){var i=l.memoizedState;i===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:f,tail:r,tailMode:n}:(i.isBackwards=u,i.rendering=null,i.renderingStartTime=0,i.last=f,i.tail=r,i.tailMode=n)}function qU(l,u,r){var f=u.pendingProps,n=f.revealOrder,i=f.tail;if(Dr(l,u,f.children,r),f=pu.current,(f&2)!==0)f=f&1|2,u.flags|=128;else{if(l!==null&&(l.flags&128)!==0)l:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&HF(l,r,u);else if(l.tag===19)HF(l,r,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break l;for(;l.sibling===null;){if(l.return===null||l.return===u)break l;l=l.return}l.sibling.return=l.return,l=l.sibling}f&=1}if(Lu(pu,f),(u.mode&1)===0)u.memoizedState=null;else switch(n){case"forwards":r=u.child;for(n=null;r!==null;)l=r.alternate,l!==null&&K$(l)===null&&(n=r),r=r.sibling;r=n,r===null?(n=u.child,u.child=null):(n=r.sibling,r.sibling=null),c8(u,!1,n,r,i);break;case"backwards":r=null,n=u.child;for(u.child=null;n!==null;){if(l=n.alternate,l!==null&&K$(l)===null){u.child=n;break}l=n.sibling,n.sibling=r,r=n,n=l}c8(u,!0,r,null,i);break;case"together":c8(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function i$(l,u){(u.mode&1)===0&&l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2)}function hn(l,u,r){if(l!==null&&(u.dependencies=l.dependencies),z0|=u.lanes,(r&u.childLanes)===0)return null;if(l!==null&&u.child!==l.child)throw Error(Ul(153));if(u.child!==null){l=u.child,r=zi(l,l.pendingProps),u.child=r;for(r.return=u;l.sibling!==null;)l=l.sibling,r=r.sibling=zi(l,l.pendingProps),r.return=u;r.sibling=null}return u.child}function EK(l,u,r){switch(u.tag){case 3:QU(u),Mt();break;case 5:vJ(u);break;case 1:kr(u.type)&&q$(u);break;case 4:Z4(u,u.stateNode.containerInfo);break;case 10:var f=u.type._context,n=u.memoizedProps.value;Lu(G$,f._currentValue),f._currentValue=n;break;case 13:if(f=u.memoizedState,f!==null){if(f.dehydrated!==null)return Lu(pu,pu.current&1),u.flags|=128,null;if((r&u.child.childLanes)!==0)return wU(l,u,r);return Lu(pu,pu.current&1),l=hn(l,u,r),l!==null?l.sibling:null}Lu(pu,pu.current&1);break;case 19:if(f=(r&u.childLanes)!==0,(l.flags&128)!==0){if(f)return qU(l,u,r);u.flags|=128}if(n=u.memoizedState,n!==null&&(n.rendering=null,n.tail=null,n.lastEffect=null),Lu(pu,pu.current),f)break;else return null;case 22:case 23:return u.lanes=0,UU(l,u,r)}return hn(l,u,r)}var WU,a8,LU,GU;WU=function(l,u){for(var r=u.child;r!==null;){if(r.tag===5||r.tag===6)l.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===u)break;for(;r.sibling===null;){if(r.return===null||r.return===u)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};a8=function(){};LU=function(l,u,r,f){var n=l.memoizedProps;if(n!==f){l=u.stateNode,W0(Fn.current);var i=null;switch(r){case"input":n=N8(l,n),f=N8(l,f),i=[];break;case"select":n=Bu({},n,{value:void 0}),f=Bu({},f,{value:void 0}),i=[];break;case"textarea":n=q8(l,n),f=q8(l,f),i=[];break;default:typeof n.onClick!=="function"&&typeof f.onClick==="function"&&(l.onclick=Q$)}L8(r,f);var t;r=null;for($ in n)if(!f.hasOwnProperty($)&&n.hasOwnProperty($)&&n[$]!=null)if($==="style"){var y=n[$];for(t in y)y.hasOwnProperty(t)&&(r||(r={}),r[t]="")}else $!=="dangerouslySetInnerHTML"&&$!=="children"&&$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(T1.hasOwnProperty($)?i||(i=[]):(i=i||[]).push($,null));for($ in f){var c=f[$];if(y=n!=null?n[$]:void 0,f.hasOwnProperty($)&&c!==y&&(c!=null||y!=null))if($==="style")if(y){for(t in y)!y.hasOwnProperty(t)||c&&c.hasOwnProperty(t)||(r||(r={}),r[t]="");for(t in c)c.hasOwnProperty(t)&&y[t]!==c[t]&&(r||(r={}),r[t]=c[t])}else r||(i||(i=[]),i.push($,r)),r=c;else $==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,y=y?y.__html:void 0,c!=null&&y!==c&&(i=i||[]).push($,c)):$==="children"?typeof c!=="string"&&typeof c!=="number"||(i=i||[]).push($,""+c):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&(T1.hasOwnProperty($)?(c!=null&&$==="onScroll"&&Ku("scroll",l),i||y===c||(i=[])):(i=i||[]).push($,c))}r&&(i=i||[]).push("style",r);var $=i;if(u.updateQueue=$)u.flags|=4}};GU=function(l,u,r,f){r!==f&&(u.flags|=4)};function n1(l,u){if(!Ou)switch(l.tailMode){case"hidden":u=l.tail;for(var r=null;u!==null;)u.alternate!==null&&(r=u),u=u.sibling;r===null?l.tail=null:r.sibling=null;break;case"collapsed":r=l.tail;for(var f=null;r!==null;)r.alternate!==null&&(f=r),r=r.sibling;f===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:f.sibling=null}}function Gr(l){var u=l.alternate!==null&&l.alternate.child===l.child,r=0,f=0;if(u)for(var n=l.child;n!==null;)r|=n.lanes|n.childLanes,f|=n.subtreeFlags&14680064,f|=n.flags&14680064,n.return=l,n=n.sibling;else for(n=l.child;n!==null;)r|=n.lanes|n.childLanes,f|=n.subtreeFlags,f|=n.flags,n.return=l,n=n.sibling;return l.subtreeFlags|=f,l.childLanes=r,u}function OK(l,u,r){var f=u.pendingProps;switch(G4(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gr(u),null;case 1:return kr(u.type)&&w$(),Gr(u),null;case 3:if(f=u.stateNode,Rt(),zu(sr),zu(mr),H4(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),l===null||l.child===null)k_(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,vf!==null&&(n4(vf),vf=null));return a8(l,u),Gr(u),null;case 5:p4(u);var n=W0(S1.current);if(r=u.type,l!==null&&u.stateNode!=null)LU(l,u,r,f,n),l.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!f){if(u.stateNode===null)throw Error(Ul(166));return Gr(u),null}if(l=W0(Fn.current),k_(u)){f=u.stateNode,r=u.type;var i=u.memoizedProps;switch(f[An]=u,f[D1]=i,l=(u.mode&1)!==0,r){case"dialog":Ku("cancel",f),Ku("close",f);break;case"iframe":case"object":case"embed":Ku("load",f);break;case"video":case"audio":for(n=0;n<F1.length;n++)Ku(F1[n],f);break;case"source":Ku("error",f);break;case"img":case"image":case"link":Ku("error",f),Ku("load",f);break;case"details":Ku("toggle",f);break;case"input":h7(f,i),Ku("invalid",f);break;case"select":f._wrapperState={wasMultiple:!!i.multiple},Ku("invalid",f);break;case"textarea":x7(f,i),Ku("invalid",f)}L8(r,i),n=null;for(var t in i)if(i.hasOwnProperty(t)){var y=i[t];t==="children"?typeof y==="string"?f.textContent!==y&&(i.suppressHydrationWarning!==!0&&s_(f.textContent,y,l),n=["children",y]):typeof y==="number"&&f.textContent!==""+y&&(i.suppressHydrationWarning!==!0&&s_(f.textContent,y,l),n=["children",""+y]):T1.hasOwnProperty(t)&&y!=null&&t==="onScroll"&&Ku("scroll",f)}switch(r){case"input":P_(f),R7(f,i,!0);break;case"textarea":P_(f),b7(f);break;case"select":case"option":break;default:typeof i.onClick==="function"&&(f.onclick=Q$)}f=n,u.updateQueue=f,f!==null&&(u.flags|=4)}else{t=n.nodeType===9?n:n.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=aF(r)),l==="http://www.w3.org/1999/xhtml"?r==="script"?(l=t.createElement("div"),l.innerHTML="<script></script>",l=l.removeChild(l.firstChild)):typeof f.is==="string"?l=t.createElement(r,{is:f.is}):(l=t.createElement(r),r==="select"&&(t=l,f.multiple?t.multiple=!0:f.size&&(t.size=f.size))):l=t.createElementNS(l,r),l[An]=u,l[D1]=f,WU(l,u,!1,!1),u.stateNode=l;l:{switch(t=G8(r,f),r){case"dialog":Ku("cancel",l),Ku("close",l),n=f;break;case"iframe":case"object":case"embed":Ku("load",l),n=f;break;case"video":case"audio":for(n=0;n<F1.length;n++)Ku(F1[n],l);n=f;break;case"source":Ku("error",l),n=f;break;case"img":case"image":case"link":Ku("error",l),Ku("load",l),n=f;break;case"details":Ku("toggle",l),n=f;break;case"input":h7(l,f),n=N8(l,f),Ku("invalid",l);break;case"option":n=f;break;case"select":l._wrapperState={wasMultiple:!!f.multiple},n=Bu({},f,{value:void 0}),Ku("invalid",l);break;case"textarea":x7(l,f),n=q8(l,f),Ku("invalid",l);break;default:n=f}L8(r,n),y=n;for(i in y)if(y.hasOwnProperty(i)){var c=y[i];i==="style"?eF(l,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&oF(l,c)):i==="children"?typeof c==="string"?(r!=="textarea"||c!=="")&&m1(l,c):typeof c==="number"&&m1(l,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(T1.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Ku("scroll",l):c!=null&&y4(l,i,c,t))}switch(r){case"input":P_(l),R7(l,f,!1);break;case"textarea":P_(l),b7(l);break;case"option":f.value!=null&&l.setAttribute("value",""+Ei(f.value));break;case"select":l.multiple=!!f.multiple,i=f.value,i!=null?Bt(l,!!f.multiple,i,!1):f.defaultValue!=null&&Bt(l,!!f.multiple,f.defaultValue,!0);break;default:typeof n.onClick==="function"&&(l.onclick=Q$)}switch(r){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break l;case"img":f=!0;break l;default:f=!1}}f&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return Gr(u),null;case 6:if(l&&u.stateNode!=null)GU(l,u,l.memoizedProps,f);else{if(typeof f!=="string"&&u.stateNode===null)throw Error(Ul(166));if(r=W0(S1.current),W0(Fn.current),k_(u)){if(f=u.stateNode,r=u.memoizedProps,f[An]=u,i=f.nodeValue!==r){if(l=Af,l!==null)switch(l.tag){case 3:s_(f.nodeValue,r,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&s_(f.nodeValue,r,(l.mode&1)!==0)}}i&&(u.flags|=4)}else f=(r.nodeType===9?r:r.ownerDocument).createTextNode(f),f[An]=u,u.stateNode=f}return Gr(u),null;case 13:if(zu(pu),f=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(Ou&&$f!==null&&(u.mode&1)!==0&&(u.flags&128)===0)MJ(),Mt(),u.flags|=98560,i=!1;else if(i=k_(u),f!==null&&f.dehydrated!==null){if(l===null){if(!i)throw Error(Ul(318));if(i=u.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ul(317));i[An]=u}else Mt(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Gr(u),i=!1}else vf!==null&&(n4(vf),vf=null),i=!0;if(!i)return u.flags&65536?u:null}if((u.flags&128)!==0)return u.lanes=r,u;return f=f!==null,f!==(l!==null&&l.memoizedState!==null)&&f&&(u.child.flags|=8192,(u.mode&1)!==0&&(l===null||(pu.current&1)!==0?rr===0&&(rr=3):x4())),u.updateQueue!==null&&(u.flags|=4),Gr(u),null;case 4:return Rt(),a8(l,u),l===null&&H1(u.stateNode.containerInfo),Gr(u),null;case 10:return z4(u.type._context),Gr(u),null;case 17:return kr(u.type)&&w$(),Gr(u),null;case 19:if(zu(pu),i=u.memoizedState,i===null)return Gr(u),null;if(f=(u.flags&128)!==0,t=i.rendering,t===null)if(f)n1(i,!1);else{if(rr!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(t=K$(l),t!==null){u.flags|=128,n1(i,!1),f=t.updateQueue,f!==null&&(u.updateQueue=f,u.flags|=4),u.subtreeFlags=0,f=r;for(r=u.child;r!==null;)i=r,l=f,i.flags&=14680066,t=i.alternate,t===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,i.type=t.type,l=t.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),r=r.sibling;return Lu(pu,pu.current&1|2),u.child}l=l.sibling}i.tail!==null&&su()>bt&&(u.flags|=128,f=!0,n1(i,!1),u.lanes=4194304)}else{if(!f)if(l=K$(t),l!==null){if(u.flags|=128,f=!0,r=l.updateQueue,r!==null&&(u.updateQueue=r,u.flags|=4),n1(i,!0),i.tail===null&&i.tailMode==="hidden"&&!t.alternate&&!Ou)return Gr(u),null}else 2*su()-i.renderingStartTime>bt&&r!==1073741824&&(u.flags|=128,f=!0,n1(i,!1),u.lanes=4194304);i.isBackwards?(t.sibling=u.child,u.child=t):(r=i.last,r!==null?r.sibling=t:u.child=t,i.last=t)}if(i.tail!==null)return u=i.tail,i.rendering=u,i.tail=u.sibling,i.renderingStartTime=su(),u.sibling=null,r=pu.current,Lu(pu,f?r&1|2:r&1),u;return Gr(u),null;case 22:case 23:return R4(),f=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==f&&(u.flags|=8192),f&&(u.mode&1)!==0?(_f&1073741824)!==0&&(Gr(u),u.subtreeFlags&6&&(u.flags|=8192)):Gr(u),null;case 24:return null;case 25:return null}throw Error(Ul(156,u.tag))}function ZK(l,u){switch(G4(u),u.tag){case 1:return kr(u.type)&&w$(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Rt(),zu(sr),zu(mr),H4(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return p4(u),null;case 13:if(zu(pu),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(Ul(340));Mt()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return zu(pu),null;case 4:return Rt(),null;case 10:return z4(u.type._context),null;case 22:case 23:return R4(),null;case 24:return null;default:return null}}var a_=!1,Tr=!1,pK=typeof WeakSet==="function"?WeakSet:Set,Hl=null;function pt(l,u){var r=l.ref;if(r!==null)if(typeof r==="function")try{r(null)}catch(f){hu(l,u,f)}else r.current=null}function o8(l,u,r){try{r()}catch(f){hu(l,u,f)}}var BF=!1;function HK(l,u){if(V8=J$,l=EJ(),W4(l)){if("selectionStart"in l)var r={start:l.selectionStart,end:l.selectionEnd};else l:{r=(r=l.ownerDocument)&&r.defaultView||window;var f=r.getSelection&&r.getSelection();if(f&&f.rangeCount!==0){r=f.anchorNode;var{anchorOffset:n,focusNode:i}=f;f=f.focusOffset;try{r.nodeType,i.nodeType}catch(q){r=null;break l}var t=0,y=-1,c=-1,$=0,A=0,j=l,F=null;u:for(;;){for(var U;;){if(j!==r||n!==0&&j.nodeType!==3||(y=t+n),j!==i||f!==0&&j.nodeType!==3||(c=t+f),j.nodeType===3&&(t+=j.nodeValue.length),(U=j.firstChild)===null)break;F=j,j=U}for(;;){if(j===l)break u;if(F===r&&++$===n&&(y=t),F===i&&++A===f&&(c=t),(U=j.nextSibling)!==null)break;j=F,F=j.parentNode}j=U}r=y===-1||c===-1?null:{start:y,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;S8={focusedElem:l,selectionRange:r},J$=!1;for(Hl=u;Hl!==null;)if(u=Hl,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Hl=l;else for(;Hl!==null;){u=Hl;try{var N=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(N!==null){var{memoizedProps:W,memoizedState:L}=N,J=u.stateNode,w=J.getSnapshotBeforeUpdate(u.elementType===u.type?W:xf(u.type,W),L);J.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var Q=u.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ul(163))}}catch(q){hu(u,u.return,q)}if(l=u.sibling,l!==null){l.return=u.return,Hl=l;break}Hl=u.return}return N=BF,BF=!1,N}function W1(l,u,r){var f=u.updateQueue;if(f=f!==null?f.lastEffect:null,f!==null){var n=f=f.next;do{if((n.tag&l)===l){var i=n.destroy;n.destroy=void 0,i!==void 0&&o8(u,r,i)}n=n.next}while(n!==f)}}function h$(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var r=u=u.next;do{if((r.tag&l)===l){var f=r.create;r.destroy=f()}r=r.next}while(r!==u)}}function d8(l){var u=l.ref;if(u!==null){var r=l.stateNode;switch(l.tag){case 5:l=r;break;default:l=r}typeof u==="function"?u(l):u.current=l}}function TU(l){var u=l.alternate;u!==null&&(l.alternate=null,TU(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[An],delete u[D1],delete u[P8],delete u[FK],delete u[JK])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function mU(l){return l.tag===5||l.tag===3||l.tag===4}function DF(l){l:for(;;){for(;l.sibling===null;){if(l.return===null||mU(l.return))return null;l=l.return}l.sibling.return=l.return;for(l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2)continue l;if(l.child===null||l.tag===4)continue l;else l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function e8(l,u,r){var f=l.tag;if(f===5||f===6)l=l.stateNode,u?r.nodeType===8?r.parentNode.insertBefore(l,u):r.insertBefore(l,u):(r.nodeType===8?(u=r.parentNode,u.insertBefore(l,r)):(u=r,u.appendChild(l)),r=r._reactRootContainer,r!==null&&r!==void 0||u.onclick!==null||(u.onclick=Q$));else if(f!==4&&(l=l.child,l!==null))for(e8(l,u,r),l=l.sibling;l!==null;)e8(l,u,r),l=l.sibling}function l4(l,u,r){var f=l.tag;if(f===5||f===6)l=l.stateNode,u?r.insertBefore(l,u):r.appendChild(l);else if(f!==4&&(l=l.child,l!==null))for(l4(l,u,r),l=l.sibling;l!==null;)l4(l,u,r),l=l.sibling}var jr=null,bf=!1;function ji(l,u,r){for(r=r.child;r!==null;)KU(l,u,r),r=r.sibling}function KU(l,u,r){if(jn&&typeof jn.onCommitFiberUnmount==="function")try{jn.onCommitFiberUnmount(D$,r)}catch(y){}switch(r.tag){case 5:Tr||pt(r,u);case 6:var f=jr,n=bf;jr=null,ji(l,u,r),jr=f,bf=n,jr!==null&&(bf?(l=jr,r=r.stateNode,l.nodeType===8?l.parentNode.removeChild(r):l.removeChild(r)):jr.removeChild(r.stateNode));break;case 18:jr!==null&&(bf?(l=jr,r=r.stateNode,l.nodeType===8?u8(l.parentNode,r):l.nodeType===1&&u8(l,r),O1(l)):u8(jr,r.stateNode));break;case 4:f=jr,n=bf,jr=r.stateNode.containerInfo,bf=!0,ji(l,u,r),jr=f,bf=n;break;case 0:case 11:case 14:case 15:if(!Tr&&(f=r.updateQueue,f!==null&&(f=f.lastEffect,f!==null))){n=f=f.next;do{var i=n,t=i.destroy;i=i.tag,t!==void 0&&((i&2)!==0?o8(r,u,t):(i&4)!==0&&o8(r,u,t)),n=n.next}while(n!==f)}ji(l,u,r);break;case 1:if(!Tr&&(pt(r,u),f=r.stateNode,typeof f.componentWillUnmount==="function"))try{f.props=r.memoizedProps,f.state=r.memoizedState,f.componentWillUnmount()}catch(y){hu(r,u,y)}ji(l,u,r);break;case 21:ji(l,u,r);break;case 22:r.mode&1?(Tr=(f=Tr)||r.memoizedState!==null,ji(l,u,r),Tr=f):ji(l,u,r);break;default:ji(l,u,r)}}function VF(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var r=l.stateNode;r===null&&(r=l.stateNode=new pK),u.forEach(function(f){var n=MK.bind(null,l,f);r.has(f)||(r.add(f),f.then(n,n))})}}function Rf(l,u){var r=u.deletions;if(r!==null)for(var f=0;f<r.length;f++){var n=r[f];try{var i=l,t=u,y=t;l:for(;y!==null;){switch(y.tag){case 5:jr=y.stateNode,bf=!1;break l;case 3:jr=y.stateNode.containerInfo,bf=!0;break l;case 4:jr=y.stateNode.containerInfo,bf=!0;break l}y=y.return}if(jr===null)throw Error(Ul(160));KU(i,t,n),jr=null,bf=!1;var c=n.alternate;c!==null&&(c.return=null),n.return=null}catch($){hu(n,u,$)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)zU(u,l),u=u.sibling}function zU(l,u){var{alternate:r,flags:f}=l;switch(l.tag){case 0:case 11:case 14:case 15:if(Rf(u,l),_n(l),f&4){try{W1(3,l,l.return),h$(3,l)}catch(W){hu(l,l.return,W)}try{W1(5,l,l.return)}catch(W){hu(l,l.return,W)}}break;case 1:Rf(u,l),_n(l),f&512&&r!==null&&pt(r,r.return);break;case 5:if(Rf(u,l),_n(l),f&512&&r!==null&&pt(r,r.return),l.flags&32){var n=l.stateNode;try{m1(n,"")}catch(W){hu(l,l.return,W)}}if(f&4&&(n=l.stateNode,n!=null)){var i=l.memoizedProps,t=r!==null?r.memoizedProps:i,y=l.type,c=l.updateQueue;if(l.updateQueue=null,c!==null)try{y==="input"&&i.type==="radio"&&i.name!=null&&gF(n,i),G8(y,t);var $=G8(y,i);for(t=0;t<c.length;t+=2){var A=c[t],j=c[t+1];A==="style"?eF(n,j):A==="dangerouslySetInnerHTML"?oF(n,j):A==="children"?m1(n,j):y4(n,A,j,$)}switch(y){case"input":Q8(n,i);break;case"textarea":IF(n,i);break;case"select":var F=n._wrapperState.wasMultiple;n._wrapperState.wasMultiple=!!i.multiple;var U=i.value;U!=null?Bt(n,!!i.multiple,U,!1):F!==!!i.multiple&&(i.defaultValue!=null?Bt(n,!!i.multiple,i.defaultValue,!0):Bt(n,!!i.multiple,i.multiple?[]:"",!1))}n[D1]=i}catch(W){hu(l,l.return,W)}}break;case 6:if(Rf(u,l),_n(l),f&4){if(l.stateNode===null)throw Error(Ul(162));n=l.stateNode,i=l.memoizedProps;try{n.nodeValue=i}catch(W){hu(l,l.return,W)}}break;case 3:if(Rf(u,l),_n(l),f&4&&r!==null&&r.memoizedState.isDehydrated)try{O1(u.containerInfo)}catch(W){hu(l,l.return,W)}break;case 4:Rf(u,l),_n(l);break;case 13:Rf(u,l),_n(l),n=l.child,n.flags&8192&&(i=n.memoizedState!==null,n.stateNode.isHidden=i,!i||n.alternate!==null&&n.alternate.memoizedState!==null||(M4=su())),f&4&&VF(l);break;case 22:if(A=r!==null&&r.memoizedState!==null,l.mode&1?(Tr=($=Tr)||A,Rf(u,l),Tr=$):Rf(u,l),_n(l),f&8192){if($=l.memoizedState!==null,(l.stateNode.isHidden=$)&&!A&&(l.mode&1)!==0)for(Hl=l,A=l.child;A!==null;){for(j=Hl=A;Hl!==null;){switch(F=Hl,U=F.child,F.tag){case 0:case 11:case 14:case 15:W1(4,F,F.return);break;case 1:pt(F,F.return);var N=F.stateNode;if(typeof N.componentWillUnmount==="function"){f=F,r=F.return;try{u=f,N.props=u.memoizedProps,N.state=u.memoizedState,N.componentWillUnmount()}catch(W){hu(f,r,W)}}break;case 5:pt(F,F.return);break;case 22:if(F.memoizedState!==null){XF(j);continue}}U!==null?(U.return=F,Hl=U):XF(j)}A=A.sibling}l:for(A=null,j=l;;){if(j.tag===5){if(A===null){A=j;try{n=j.stateNode,$?(i=n.style,typeof i.setProperty==="function"?i.setProperty("display","none","important"):i.display="none"):(y=j.stateNode,c=j.memoizedProps.style,t=c!==void 0&&c!==null&&c.hasOwnProperty("display")?c.display:null,y.style.display=dF("display",t))}catch(W){hu(l,l.return,W)}}}else if(j.tag===6){if(A===null)try{j.stateNode.nodeValue=$?"":j.memoizedProps}catch(W){hu(l,l.return,W)}}else if((j.tag!==22&&j.tag!==23||j.memoizedState===null||j===l)&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===l)break l;for(;j.sibling===null;){if(j.return===null||j.return===l)break l;A===j&&(A=null),j=j.return}A===j&&(A=null),j.sibling.return=j.return,j=j.sibling}}break;case 19:Rf(u,l),_n(l),f&4&&VF(l);break;case 21:break;default:Rf(u,l),_n(l)}}function _n(l){var u=l.flags;if(u&2){try{l:{for(var r=l.return;r!==null;){if(mU(r)){var f=r;break l}r=r.return}throw Error(Ul(160))}switch(f.tag){case 5:var n=f.stateNode;f.flags&32&&(m1(n,""),f.flags&=-33);var i=DF(l);l4(l,i,n);break;case 3:case 4:var t=f.stateNode.containerInfo,y=DF(l);e8(l,y,t);break;default:throw Error(Ul(161))}}catch(c){hu(l,l.return,c)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function BK(l,u,r){Hl=l,EU(l,u,r)}function EU(l,u,r){for(var f=(l.mode&1)!==0;Hl!==null;){var n=Hl,i=n.child;if(n.tag===22&&f){var t=n.memoizedState!==null||a_;if(!t){var y=n.alternate,c=y!==null&&y.memoizedState!==null||Tr;y=a_;var $=Tr;if(a_=t,(Tr=c)&&!$)for(Hl=n;Hl!==null;)t=Hl,c=t.child,t.tag===22&&t.memoizedState!==null?YF(n):c!==null?(c.return=t,Hl=c):YF(n);for(;i!==null;)Hl=i,EU(i,u,r),i=i.sibling;Hl=n,a_=y,Tr=$}SF(l,u,r)}else(n.subtreeFlags&8772)!==0&&i!==null?(i.return=n,Hl=i):SF(l,u,r)}}function SF(l){for(;Hl!==null;){var u=Hl;if((u.flags&8772)!==0){var r=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:Tr||h$(5,u);break;case 1:var f=u.stateNode;if(u.flags&4&&!Tr)if(r===null)f.componentDidMount();else{var n=u.elementType===u.type?r.memoizedProps:xf(u.type,r.memoizedProps);f.componentDidUpdate(n,r.memoizedState,f.__reactInternalSnapshotBeforeUpdate)}var i=u.updateQueue;i!==null&&qF(u,i,f);break;case 3:var t=u.updateQueue;if(t!==null){if(r=null,u.child!==null)switch(u.child.tag){case 5:r=u.child.stateNode;break;case 1:r=u.child.stateNode}qF(u,t,r)}break;case 5:var y=u.stateNode;if(r===null&&u.flags&4){r=y;var c=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var $=u.alternate;if($!==null){var A=$.memoizedState;if(A!==null){var j=A.dehydrated;j!==null&&O1(j)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ul(163))}Tr||u.flags&512&&d8(u)}catch(F){hu(u,u.return,F)}}if(u===l){Hl=null;break}if(r=u.sibling,r!==null){r.return=u.return,Hl=r;break}Hl=u.return}}function XF(l){for(;Hl!==null;){var u=Hl;if(u===l){Hl=null;break}var r=u.sibling;if(r!==null){r.return=u.return,Hl=r;break}Hl=u.return}}function YF(l){for(;Hl!==null;){var u=Hl;try{switch(u.tag){case 0:case 11:case 15:var r=u.return;try{h$(4,u)}catch(c){hu(u,r,c)}break;case 1:var f=u.stateNode;if(typeof f.componentDidMount==="function"){var n=u.return;try{f.componentDidMount()}catch(c){hu(u,n,c)}}var i=u.return;try{d8(u)}catch(c){hu(u,i,c)}break;case 5:var t=u.return;try{d8(u)}catch(c){hu(u,t,c)}}}catch(c){hu(u,u.return,c)}if(u===l){Hl=null;break}var y=u.sibling;if(y!==null){y.return=u.return,Hl=y;break}Hl=u.return}}var DK=Math.ceil,O$=Rn.ReactCurrentDispatcher,P4=Rn.ReactCurrentOwner,Of=Rn.ReactCurrentBatchConfig,_u=0,_r=null,Iu=null,Fr=0,_f=0,Ht=pi(0),rr=0,C1=null,z0=0,R$=0,C4=0,L1=null,br=null,M4=0,bt=1/0,Dn=null,Z$=!1,u4=null,mi=null,o_=!1,wi=null,p$=0,G1=0,r4=null,t$=-1,y$=0;function Vr(){return(_u&6)!==0?su():t$!==-1?t$:t$=su()}function Ki(l){if((l.mode&1)===0)return 1;if((_u&2)!==0&&Fr!==0)return Fr&-Fr;if(NK.transition!==null)return y$===0&&(y$=AJ()),y$;if(l=Uu,l!==0)return l;return l=window.event,l=l===void 0?16:wJ(l.type),l}function kf(l,u,r,f){if(50<G1)throw G1=0,r4=null,Error(Ul(185));if(M1(l,r,f),(_u&2)===0||l!==_r)l===_r&&((_u&2)===0&&(R$|=r),rr===4&&Ni(l,Fr)),gr(l,f),r===1&&_u===0&&(u.mode&1)===0&&(bt=su()+500,P$&&Hi())}function gr(l,u){var r=l.callbackNode;wm(l,u);var f=F$(l,l===_r?Fr:0);if(f===0)r!==null&&k7(r),l.callbackNode=null,l.callbackPriority=0;else if(u=f&-f,l.callbackPriority!==u){if(r!=null&&k7(r),u===1)l.tag===0?UK(PF.bind(null,l)):YJ(PF.bind(null,l)),AK(function(){(_u&6)===0&&Hi()}),r=null;else{switch(jJ(f)){case 1:r=j4;break;case 4:r=_J;break;case 16:r=j$;break;case 536870912:r=$J;break;default:r=j$}r=SU(r,OU.bind(null,l))}l.callbackPriority=u,l.callbackNode=r}}function OU(l,u){if(t$=-1,y$=0,(_u&6)!==0)throw Error(Ul(327));var r=l.callbackNode;if(Yt()&&l.callbackNode!==r)return null;var f=F$(l,l===_r?Fr:0);if(f===0)return null;if((f&30)!==0||(f&l.expiredLanes)!==0||u)u=H$(l,f);else{u=f;var n=_u;_u|=2;var i=pU();if(_r!==l||Fr!==u)Dn=null,bt=su()+500,L0(l,u);do try{XK();break}catch(y){ZU(l,y)}while(1);K4(),O$.current=i,_u=n,Iu!==null?u=0:(_r=null,Fr=0,u=rr)}if(u!==0){if(u===2&&(n=E8(l),n!==0&&(f=n,u=f4(l,n))),u===1)throw r=C1,L0(l,0),Ni(l,f),gr(l,su()),r;if(u===6)Ni(l,f);else{if(n=l.current.alternate,(f&30)===0&&!VK(n)&&(u=H$(l,f),u===2&&(i=E8(l),i!==0&&(f=i,u=f4(l,i))),u===1))throw r=C1,L0(l,0),Ni(l,f),gr(l,su()),r;switch(l.finishedWork=n,l.finishedLanes=f,u){case 0:case 1:throw Error(Ul(345));case 2:Q0(l,br,Dn);break;case 3:if(Ni(l,f),(f&130023424)===f&&(u=M4+500-su(),10<u)){if(F$(l,0)!==0)break;if(n=l.suspendedLanes,(n&f)!==f){Vr(),l.pingedLanes|=l.suspendedLanes&n;break}l.timeoutHandle=Y8(Q0.bind(null,l,br,Dn),u);break}Q0(l,br,Dn);break;case 4:if(Ni(l,f),(f&4194240)===f)break;u=l.eventTimes;for(n=-1;0<f;){var t=31-sf(f);i=1<<t,t=u[t],t>n&&(n=t),f&=~i}if(f=n,f=su()-f,f=(120>f?120:480>f?480:1080>f?1080:1920>f?1920:3000>f?3000:4320>f?4320:1960*DK(f/1960))-f,10<f){l.timeoutHandle=Y8(Q0.bind(null,l,br,Dn),f);break}Q0(l,br,Dn);break;case 5:Q0(l,br,Dn);break;default:throw Error(Ul(329))}}}return gr(l,su()),l.callbackNode===r?OU.bind(null,l):null}function f4(l,u){var r=L1;return l.current.memoizedState.isDehydrated&&(L0(l,u).flags|=256),l=H$(l,u),l!==2&&(u=br,br=r,u!==null&&n4(u)),l}function n4(l){br===null?br=l:br.push.apply(br,l)}function VK(l){for(var u=l;;){if(u.flags&16384){var r=u.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var f=0;f<r.length;f++){var n=r[f],i=n.getSnapshot;n=n.value;try{if(!gf(i(),n))return!1}catch(t){return!1}}}if(r=u.child,u.subtreeFlags&16384&&r!==null)r.return=u,u=r;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function Ni(l,u){u&=~C4,u&=~R$,l.suspendedLanes|=u,l.pingedLanes&=~u;for(l=l.expirationTimes;0<u;){var r=31-sf(u),f=1<<r;l[r]=-1,u&=~f}}function PF(l){if((_u&6)!==0)throw Error(Ul(327));Yt();var u=F$(l,0);if((u&1)===0)return gr(l,su()),null;var r=H$(l,u);if(l.tag!==0&&r===2){var f=E8(l);f!==0&&(u=f,r=f4(l,f))}if(r===1)throw r=C1,L0(l,0),Ni(l,u),gr(l,su()),r;if(r===6)throw Error(Ul(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,Q0(l,br,Dn),gr(l,su()),null}function h4(l,u){var r=_u;_u|=1;try{return l(u)}finally{_u=r,_u===0&&(bt=su()+500,P$&&Hi())}}function E0(l){wi!==null&&wi.tag===0&&(_u&6)===0&&Yt();var u=_u;_u|=1;var r=Of.transition,f=Uu;try{if(Of.transition=null,Uu=1,l)return l()}finally{Uu=f,Of.transition=r,_u=u,(_u&6)===0&&Hi()}}function R4(){_f=Ht.current,zu(Ht)}function L0(l,u){l.finishedWork=null,l.finishedLanes=0;var r=l.timeoutHandle;if(r!==-1&&(l.timeoutHandle=-1,$K(r)),Iu!==null)for(r=Iu.return;r!==null;){var f=r;switch(G4(f),f.tag){case 1:f=f.type.childContextTypes,f!==null&&f!==void 0&&w$();break;case 3:Rt(),zu(sr),zu(mr),H4();break;case 5:p4(f);break;case 4:Rt();break;case 13:zu(pu);break;case 19:zu(pu);break;case 10:z4(f.type._context);break;case 22:case 23:R4()}r=r.return}if(_r=l,Iu=l=zi(l.current,null),Fr=_f=u,rr=0,C1=null,C4=R$=z0=0,br=L1=null,q0!==null){for(u=0;u<q0.length;u++)if(r=q0[u],f=r.interleaved,f!==null){r.interleaved=null;var n=f.next,i=r.pending;if(i!==null){var t=i.next;i.next=n,f.next=t}r.pending=f}q0=null}return l}function ZU(l,u){do{var r=Iu;try{if(K4(),f$.current=E$,z$){for(var f=Hu.memoizedState;f!==null;){var n=f.queue;n!==null&&(n.pending=null),f=f.next}z$=!1}if(K0=0,cr=ur=Hu=null,q1=!1,X1=0,P4.current=null,r===null||r.return===null){rr=1,C1=u,Iu=null;break}l:{var i=l,t=r.return,y=r,c=u;if(u=Fr,y.flags|=32768,c!==null&&typeof c==="object"&&typeof c.then==="function"){var $=c,A=y,j=A.tag;if((A.mode&1)===0&&(j===0||j===11||j===15)){var F=A.alternate;F?(A.updateQueue=F.updateQueue,A.memoizedState=F.memoizedState,A.lanes=F.lanes):(A.updateQueue=null,A.memoizedState=null)}var U=KF(t);if(U!==null){U.flags&=-257,zF(U,t,y,i,u),U.mode&1&&mF(i,$,u),u=U,c=$;var N=u.updateQueue;if(N===null){var W=new Set;W.add(c),u.updateQueue=W}else N.add(c);break l}else{if((u&1)===0){mF(i,$,u),x4();break l}c=Error(Ul(426))}}else if(Ou&&y.mode&1){var L=KF(t);if(L!==null){(L.flags&65536)===0&&(L.flags|=256),zF(L,t,y,i,u),T4(xt(c,y));break l}}i=c=xt(c,y),rr!==4&&(rr=2),L1===null?L1=[i]:L1.push(i),i=t;do{switch(i.tag){case 3:i.flags|=65536,u&=-u,i.lanes|=u;var J=jU(i,c,u);wF(i,J);break l;case 1:y=c;var{type:w,stateNode:Q}=i;if((i.flags&128)===0&&(typeof w.getDerivedStateFromError==="function"||Q!==null&&typeof Q.componentDidCatch==="function"&&(mi===null||!mi.has(Q)))){i.flags|=65536,u&=-u,i.lanes|=u;var q=FU(i,y,u);wF(i,q);break l}}i=i.return}while(i!==null)}BU(r)}catch(T){u=T,Iu===r&&r!==null&&(Iu=r=r.return);continue}break}while(1)}function pU(){var l=O$.current;return O$.current=E$,l===null?E$:l}function x4(){if(rr===0||rr===3||rr===2)rr=4;_r===null||(z0&268435455)===0&&(R$&268435455)===0||Ni(_r,Fr)}function H$(l,u){var r=_u;_u|=2;var f=pU();if(_r!==l||Fr!==u)Dn=null,L0(l,u);do try{SK();break}catch(n){ZU(l,n)}while(1);if(K4(),_u=r,O$.current=f,Iu!==null)throw Error(Ul(261));return _r=null,Fr=0,rr}function SK(){for(;Iu!==null;)HU(Iu)}function XK(){for(;Iu!==null&&!_m();)HU(Iu)}function HU(l){var u=VU(l.alternate,l,_f);l.memoizedProps=l.pendingProps,u===null?BU(l):Iu=u,P4.current=null}function BU(l){var u=l;do{var r=u.alternate;if(l=u.return,(u.flags&32768)===0){if(r=OK(r,u,_f),r!==null){Iu=r;return}}else{if(r=ZK(r,u),r!==null){r.flags&=32767,Iu=r;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{rr=6,Iu=null;return}}if(u=u.sibling,u!==null){Iu=u;return}Iu=u=l}while(u!==null);rr===0&&(rr=5)}function Q0(l,u,r){var f=Uu,n=Of.transition;try{Of.transition=null,Uu=1,YK(l,u,r,f)}finally{Of.transition=n,Uu=f}return null}function YK(l,u,r,f){do Yt();while(wi!==null);if((_u&6)!==0)throw Error(Ul(327));r=l.finishedWork;var n=l.finishedLanes;if(r===null)return null;if(l.finishedWork=null,l.finishedLanes=0,r===l.current)throw Error(Ul(177));l.callbackNode=null,l.callbackPriority=0;var i=r.lanes|r.childLanes;if(qm(l,i),l===_r&&(Iu=_r=null,Fr=0),(r.subtreeFlags&2064)===0&&(r.flags&2064)===0||o_||(o_=!0,SU(j$,function(){return Yt(),null})),i=(r.flags&15990)!==0,(r.subtreeFlags&15990)!==0||i){i=Of.transition,Of.transition=null;var t=Uu;Uu=1;var y=_u;_u|=4,P4.current=null,HK(l,r),zU(r,l),iK(S8),J$=!!V8,S8=V8=null,l.current=r,BK(r,l,n),$m(),_u=y,Uu=t,Of.transition=i}else l.current=r;if(o_&&(o_=!1,wi=l,p$=n),i=l.pendingLanes,i===0&&(mi=null),Fm(r.stateNode,f),gr(l,su()),u!==null)for(f=l.onRecoverableError,r=0;r<u.length;r++)n=u[r],f(n.value,{componentStack:n.stack,digest:n.digest});if(Z$)throw Z$=!1,l=u4,u4=null,l;return(p$&1)!==0&&l.tag!==0&&Yt(),i=l.pendingLanes,(i&1)!==0?l===r4?G1++:(G1=0,r4=l):G1=0,Hi(),null}function Yt(){if(wi!==null){var l=jJ(p$),u=Of.transition,r=Uu;try{if(Of.transition=null,Uu=16>l?16:l,wi===null)var f=!1;else{if(l=wi,wi=null,p$=0,(_u&6)!==0)throw Error(Ul(331));var n=_u;_u|=4;for(Hl=l.current;Hl!==null;){var i=Hl,t=i.child;if((Hl.flags&16)!==0){var y=i.deletions;if(y!==null){for(var c=0;c<y.length;c++){var $=y[c];for(Hl=$;Hl!==null;){var A=Hl;switch(A.tag){case 0:case 11:case 15:W1(8,A,i)}var j=A.child;if(j!==null)j.return=A,Hl=j;else for(;Hl!==null;){A=Hl;var{sibling:F,return:U}=A;if(TU(A),A===$){Hl=null;break}if(F!==null){F.return=U,Hl=F;break}Hl=U}}}var N=i.alternate;if(N!==null){var W=N.child;if(W!==null){N.child=null;do{var L=W.sibling;W.sibling=null,W=L}while(W!==null)}}Hl=i}}if((i.subtreeFlags&2064)!==0&&t!==null)t.return=i,Hl=t;else l:for(;Hl!==null;){if(i=Hl,(i.flags&2048)!==0)switch(i.tag){case 0:case 11:case 15:W1(9,i,i.return)}var J=i.sibling;if(J!==null){J.return=i.return,Hl=J;break l}Hl=i.return}}var w=l.current;for(Hl=w;Hl!==null;){t=Hl;var Q=t.child;if((t.subtreeFlags&2064)!==0&&Q!==null)Q.return=t,Hl=Q;else l:for(t=w;Hl!==null;){if(y=Hl,(y.flags&2048)!==0)try{switch(y.tag){case 0:case 11:case 15:h$(9,y)}}catch(T){hu(y,y.return,T)}if(y===t){Hl=null;break l}var q=y.sibling;if(q!==null){q.return=y.return,Hl=q;break l}Hl=y.return}}if(_u=n,Hi(),jn&&typeof jn.onPostCommitFiberRoot==="function")try{jn.onPostCommitFiberRoot(D$,l)}catch(T){}f=!0}return f}finally{Uu=r,Of.transition=u}}return!1}function CF(l,u,r){u=xt(r,u),u=jU(l,u,1),l=Ti(l,u,1),u=Vr(),l!==null&&(M1(l,1,u),gr(l,u))}function hu(l,u,r){if(l.tag===3)CF(l,l,r);else for(;u!==null;){if(u.tag===3){CF(u,l,r);break}else if(u.tag===1){var f=u.stateNode;if(typeof u.type.getDerivedStateFromError==="function"||typeof f.componentDidCatch==="function"&&(mi===null||!mi.has(f))){l=xt(r,l),l=FU(u,l,1),u=Ti(u,l,1),l=Vr(),u!==null&&(M1(u,1,l),gr(u,l));break}}u=u.return}}function PK(l,u,r){var f=l.pingCache;f!==null&&f.delete(u),u=Vr(),l.pingedLanes|=l.suspendedLanes&r,_r===l&&(Fr&r)===r&&(rr===4||rr===3&&(Fr&130023424)===Fr&&500>su()-M4?L0(l,0):C4|=r),gr(l,u)}function DU(l,u){u===0&&((l.mode&1)===0?u=1:(u=h_,h_<<=1,(h_&130023424)===0&&(h_=4194304)));var r=Vr();l=Mn(l,u),l!==null&&(M1(l,u,r),gr(l,r))}function CK(l){var u=l.memoizedState,r=0;u!==null&&(r=u.retryLane),DU(l,r)}function MK(l,u){var r=0;switch(l.tag){case 13:var{stateNode:f,memoizedState:n}=l;n!==null&&(r=n.retryLane);break;case 19:f=l.stateNode;break;default:throw Error(Ul(314))}f!==null&&f.delete(u),DU(l,r)}var VU;VU=function(l,u,r){if(l!==null)if(l.memoizedProps!==u.pendingProps||sr.current)vr=!0;else{if((l.lanes&r)===0&&(u.flags&128)===0)return vr=!1,EK(l,u,r);vr=(l.flags&131072)!==0?!0:!1}else vr=!1,Ou&&(u.flags&1048576)!==0&&PJ(u,L$,u.index);switch(u.lanes=0,u.tag){case 2:var f=u.type;i$(l,u),l=u.pendingProps;var n=Ct(u,mr.current);Xt(u,r),n=D4(null,u,f,l,n,r);var i=V4();return u.flags|=1,typeof n==="object"&&n!==null&&typeof n.render==="function"&&n.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,kr(f)?(i=!0,q$(u)):i=!1,u.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,O4(u),n.updater=M$,u.stateNode=n,n._reactInternals=u,b8(u,f,l,r),u=k8(null,u,f,!0,i,r)):(u.tag=0,Ou&&i&&L4(u),Dr(null,u,n,r),u=u.child),u;case 16:f=u.elementType;l:{switch(i$(l,u),l=u.pendingProps,n=f._init,f=n(f._payload),u.type=f,n=u.tag=RK(f),l=xf(f,l),n){case 0:u=s8(null,u,f,l,r);break l;case 1:u=ZF(null,u,f,l,r);break l;case 11:u=EF(null,u,f,l,r);break l;case 14:u=OF(null,u,f,xf(f.type,l),r);break l}throw Error(Ul(306,f,""))}return u;case 0:return f=u.type,n=u.pendingProps,n=u.elementType===f?n:xf(f,n),s8(l,u,f,n,r);case 1:return f=u.type,n=u.pendingProps,n=u.elementType===f?n:xf(f,n),ZF(l,u,f,n,r);case 3:l:{if(QU(u),l===null)throw Error(Ul(387));f=u.pendingProps,i=u.memoizedState,n=i.element,bJ(l,u),m$(u,f,null,r);var t=u.memoizedState;if(f=t.element,i.isDehydrated)if(i={element:f,isDehydrated:!1,cache:t.cache,pendingSuspenseBoundaries:t.pendingSuspenseBoundaries,transitions:t.transitions},u.updateQueue.baseState=i,u.memoizedState=i,u.flags&256){n=xt(Error(Ul(423)),u),u=pF(l,u,f,r,n);break l}else if(f!==n){n=xt(Error(Ul(424)),u),u=pF(l,u,f,r,n);break l}else for($f=Gi(u.stateNode.containerInfo.firstChild),Af=u,Ou=!0,vf=null,r=RJ(u,null,f,r),u.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Mt(),f===n){u=hn(l,u,r);break l}Dr(l,u,f,r)}u=u.child}return u;case 5:return vJ(u),l===null&&h8(u),f=u.type,n=u.pendingProps,i=l!==null?l.memoizedProps:null,t=n.children,X8(f,n)?t=null:i!==null&&X8(f,i)&&(u.flags|=32),NU(l,u),Dr(l,u,t,r),u.child;case 6:return l===null&&h8(u),null;case 13:return wU(l,u,r);case 4:return Z4(u,u.stateNode.containerInfo),f=u.pendingProps,l===null?u.child=ht(u,null,f,r):Dr(l,u,f,r),u.child;case 11:return f=u.type,n=u.pendingProps,n=u.elementType===f?n:xf(f,n),EF(l,u,f,n,r);case 7:return Dr(l,u,u.pendingProps,r),u.child;case 8:return Dr(l,u,u.pendingProps.children,r),u.child;case 12:return Dr(l,u,u.pendingProps.children,r),u.child;case 10:l:{if(f=u.type._context,n=u.pendingProps,i=u.memoizedProps,t=n.value,Lu(G$,f._currentValue),f._currentValue=t,i!==null)if(gf(i.value,t)){if(i.children===n.children&&!sr.current){u=hn(l,u,r);break l}}else for(i=u.child,i!==null&&(i.return=u);i!==null;){var y=i.dependencies;if(y!==null){t=i.child;for(var c=y.firstContext;c!==null;){if(c.context===f){if(i.tag===1){c=Yn(-1,r&-r),c.tag=2;var $=i.updateQueue;if($!==null){$=$.shared;var A=$.pending;A===null?c.next=c:(c.next=A.next,A.next=c),$.pending=c}}i.lanes|=r,c=i.alternate,c!==null&&(c.lanes|=r),R8(i.return,r,u),y.lanes|=r;break}c=c.next}}else if(i.tag===10)t=i.type===u.type?null:i.child;else if(i.tag===18){if(t=i.return,t===null)throw Error(Ul(341));t.lanes|=r,y=t.alternate,y!==null&&(y.lanes|=r),R8(t,r,u),t=i.sibling}else t=i.child;if(t!==null)t.return=i;else for(t=i;t!==null;){if(t===u){t=null;break}if(i=t.sibling,i!==null){i.return=t.return,t=i;break}t=t.return}i=t}Dr(l,u,n.children,r),u=u.child}return u;case 9:return n=u.type,f=u.pendingProps.children,Xt(u,r),n=Zf(n),f=f(n),u.flags|=1,Dr(l,u,f,r),u.child;case 14:return f=u.type,n=xf(f,u.pendingProps),n=xf(f.type,n),OF(l,u,f,n,r);case 15:return JU(l,u,u.type,u.pendingProps,r);case 17:return f=u.type,n=u.pendingProps,n=u.elementType===f?n:xf(f,n),i$(l,u),u.tag=1,kr(f)?(l=!0,q$(u)):l=!1,Xt(u,r),AU(u,f,n),b8(u,f,n,r),k8(null,u,f,!0,l,r);case 19:return qU(l,u,r);case 22:return UU(l,u,r)}throw Error(Ul(156,u.tag))};function SU(l,u){return cJ(l,u)}function hK(l,u,r,f){this.tag=l,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ef(l,u,r,f){return new hK(l,u,r,f)}function b4(l){return l=l.prototype,!(!l||!l.isReactComponent)}function RK(l){if(typeof l==="function")return b4(l)?1:0;if(l!==void 0&&l!==null){if(l=l.$$typeof,l===_4)return 11;if(l===$4)return 14}return 2}function zi(l,u){var r=l.alternate;return r===null?(r=Ef(l.tag,u,l.key,l.mode),r.elementType=l.elementType,r.type=l.type,r.stateNode=l.stateNode,r.alternate=l,l.alternate=r):(r.pendingProps=u,r.type=l.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=l.flags&14680064,r.childLanes=l.childLanes,r.lanes=l.lanes,r.child=l.child,r.memoizedProps=l.memoizedProps,r.memoizedState=l.memoizedState,r.updateQueue=l.updateQueue,u=l.dependencies,r.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},r.sibling=l.sibling,r.index=l.index,r.ref=l.ref,r}function c$(l,u,r,f,n,i){var t=2;if(f=l,typeof l==="function")b4(l)&&(t=1);else if(typeof l==="string")t=5;else l:switch(l){case Lt:return G0(r.children,n,i,u);case c4:t=8,n|=8;break;case j8:return l=Ef(12,r,u,n|2),l.elementType=j8,l.lanes=i,l;case F8:return l=Ef(13,r,u,n),l.elementType=F8,l.lanes=i,l;case J8:return l=Ef(19,r,u,n),l.elementType=J8,l.lanes=i,l;case vF:return x$(r,n,i,u);default:if(typeof l==="object"&&l!==null)switch(l.$$typeof){case xF:t=10;break l;case bF:t=9;break l;case _4:t=11;break l;case $4:t=14;break l;case Fi:t=16,f=null;break l}throw Error(Ul(130,l==null?l:typeof l,""))}return u=Ef(t,r,u,n),u.elementType=l,u.type=f,u.lanes=i,u}function G0(l,u,r,f){return l=Ef(7,l,f,u),l.lanes=r,l}function x$(l,u,r,f){return l=Ef(22,l,f,u),l.elementType=vF,l.lanes=r,l.stateNode={isHidden:!1},l}function _8(l,u,r){return l=Ef(6,l,null,u),l.lanes=r,l}function $8(l,u,r){return u=Ef(4,l.children!==null?l.children:[],l.key,u),u.lanes=r,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function xK(l,u,r,f,n){this.tag=u,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=g6(0),this.expirationTimes=g6(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=g6(0),this.identifierPrefix=f,this.onRecoverableError=n,this.mutableSourceEagerHydrationData=null}function v4(l,u,r,f,n,i,t,y,c){return l=new xK(l,u,r,y,c),u===1?(u=1,i===!0&&(u|=8)):u=0,i=Ef(3,null,null,u),l.current=i,i.stateNode=l,i.memoizedState={element:f,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},O4(i),l}function bK(l,u,r){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Wt,key:f==null?null:""+f,children:l,containerInfo:u,implementation:r}}function XU(l){if(!l)return Oi;l=l._reactInternals;l:{if(Z0(l)!==l||l.tag!==1)throw Error(Ul(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break l;case 1:if(kr(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break l}}u=u.return}while(u!==null);throw Error(Ul(171))}if(l.tag===1){var r=l.type;if(kr(r))return XJ(l,r,u)}return u}function YU(l,u,r,f,n,i,t,y,c){return l=v4(r,f,!0,l,n,i,t,y,c),l.context=XU(null),r=l.current,f=Vr(),n=Ki(r),i=Yn(f,n),i.callback=u!==void 0&&u!==null?u:null,Ti(r,i,n),l.current.lanes=n,M1(l,n,f),gr(l,f),l}function b$(l,u,r,f){var n=u.current,i=Vr(),t=Ki(n);return r=XU(r),u.context===null?u.context=r:u.pendingContext=r,u=Yn(i,t),u.payload={element:l},f=f===void 0?null:f,f!==null&&(u.callback=f),l=Ti(n,u,t),l!==null&&(kf(l,n,t,i),r$(l,n,t)),t}function B$(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function MF(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var r=l.retryLane;l.retryLane=r!==0&&r<u?r:u}}function s4(l,u){MF(l,u),(l=l.alternate)&&MF(l,u)}function vK(){return null}var PU=typeof reportError==="function"?reportError:function(l){console.error(l)};function k4(l){this._internalRoot=l}v$.prototype.render=k4.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(Ul(409));b$(l,u,null,null)};v$.prototype.unmount=k4.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;E0(function(){b$(null,l,null,null)}),u[Cn]=null}};function v$(l){this._internalRoot=l}v$.prototype.unstable_scheduleHydration=function(l){if(l){var u=UJ();l={blockedOn:null,target:l,priority:u};for(var r=0;r<Ui.length&&u!==0&&u<Ui[r].priority;r++);Ui.splice(r,0,l),r===0&&QJ(l)}};function g4(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function s$(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function hF(){}function sK(l,u,r,f,n){if(n){if(typeof f==="function"){var i=f;f=function(){var $=B$(t);i.call($)}}var t=YU(u,f,l,0,null,!1,!1,"",hF);return l._reactRootContainer=t,l[Cn]=t.current,H1(l.nodeType===8?l.parentNode:l),E0(),t}for(;n=l.lastChild;)l.removeChild(n);if(typeof f==="function"){var y=f;f=function(){var $=B$(c);y.call($)}}var c=v4(l,0,!1,null,null,!1,!1,"",hF);return l._reactRootContainer=c,l[Cn]=c.current,H1(l.nodeType===8?l.parentNode:l),E0(function(){b$(u,c,r,f)}),c}function k$(l,u,r,f,n){var i=r._reactRootContainer;if(i){var t=i;if(typeof n==="function"){var y=n;n=function(){var c=B$(t);y.call(c)}}b$(u,t,l,n)}else t=sK(r,u,l,n,f);return B$(t)}FJ=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var r=c1(u.pendingLanes);r!==0&&(F4(u,r|1),gr(u,su()),(_u&6)===0&&(bt=su()+500,Hi()))}break;case 13:E0(function(){var f=Mn(l,1);if(f!==null){var n=Vr();kf(f,l,1,n)}}),s4(l,1)}};J4=function(l){if(l.tag===13){var u=Mn(l,134217728);if(u!==null){var r=Vr();kf(u,l,134217728,r)}s4(l,134217728)}};JJ=function(l){if(l.tag===13){var u=Ki(l),r=Mn(l,u);if(r!==null){var f=Vr();kf(r,l,u,f)}s4(l,u)}};UJ=function(){return Uu};NJ=function(l,u){var r=Uu;try{return Uu=l,u()}finally{Uu=r}};m8=function(l,u,r){switch(u){case"input":if(Q8(l,r),u=r.name,r.type==="radio"&&u!=null){for(r=l;r.parentNode;)r=r.parentNode;r=r.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]');for(u=0;u<r.length;u++){var f=r[u];if(f!==l&&f.form===l.form){var n=Y$(f);if(!n)throw Error(Ul(90));kF(f),Q8(f,n)}}}break;case"textarea":IF(l,r);break;case"select":u=r.value,u!=null&&Bt(l,!!r.multiple,u,!1)}};rJ=h4;fJ=E0;var kK={usingClientEntryPoint:!1,Events:[R1,Kt,Y$,lJ,uJ,h4]},i1={findFiberByHostInstance:w0,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},gK={bundleType:i1.bundleType,version:i1.version,rendererPackageName:i1.rendererPackageName,rendererConfig:i1.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Rn.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=tJ(l),l===null?null:l.stateNode},findFiberByHostInstance:i1.findFiberByHostInstance||vK,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){if(qt=__REACT_DEVTOOLS_GLOBAL_HOOK__,!qt.isDisabled&&qt.supportsFiber)try{D$=qt.inject(gK),jn=qt}catch(l){}}var qt;Jf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kK;Jf.createPortal=function(l,u){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g4(u))throw Error(Ul(200));return bK(l,u,null,r)};Jf.createRoot=function(l,u){if(!g4(l))throw Error(Ul(299));var r=!1,f="",n=PU;return u!==null&&u!==void 0&&(u.unstable_strictMode===!0&&(r=!0),u.identifierPrefix!==void 0&&(f=u.identifierPrefix),u.onRecoverableError!==void 0&&(n=u.onRecoverableError)),u=v4(l,1,!1,null,null,r,!1,f,n),l[Cn]=u.current,H1(l.nodeType===8?l.parentNode:l),new k4(u)};Jf.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var u=l._reactInternals;if(u===void 0){if(typeof l.render==="function")throw Error(Ul(188));throw l=Object.keys(l).join(","),Error(Ul(268,l))}return l=tJ(u),l=l===null?null:l.stateNode,l};Jf.flushSync=function(l){return E0(l)};Jf.hydrate=function(l,u,r){if(!s$(u))throw Error(Ul(200));return k$(null,l,u,!0,r)};Jf.hydrateRoot=function(l,u,r){if(!g4(l))throw Error(Ul(405));var f=r!=null&&r.hydratedSources||null,n=!1,i="",t=PU;if(r!==null&&r!==void 0&&(r.unstable_strictMode===!0&&(n=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(t=r.onRecoverableError)),u=YU(u,null,l,1,r!=null?r:null,n,!1,i,t),l[Cn]=u.current,H1(l),f)for(l=0;l<f.length;l++)r=f[l],n=r._getVersion,n=n(r._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[r,n]:u.mutableSourceEagerHydrationData.push(r,n);return new v$(u)};Jf.render=function(l,u,r){if(!s$(u))throw Error(Ul(200));return k$(null,l,u,!1,r)};Jf.unmountComponentAtNode=function(l){if(!s$(l))throw Error(Ul(40));return l._reactRootContainer?(E0(function(){k$(null,null,l,!1,function(){l._reactRootContainer=null,l[Cn]=null})}),!0):!1};Jf.unstable_batchedUpdates=h4;Jf.unstable_renderSubtreeIntoContainer=function(l,u,r,f){if(!s$(r))throw Error(Ul(200));if(l==null||l._reactInternals===void 0)throw Error(Ul(38));return k$(l,u,r,!1,f)};Jf.version="18.3.1-next-f1338f8080-20240426"});var I4=cf((YP,hU)=>{function MU(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=="function")return;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(MU)}catch(l){console.error(l)}}MU(),hU.exports=CU()});var xU=cf((a4)=>{var RU=I4();a4.createRoot=RU.createRoot,a4.hydrateRoot=RU.hydrateRoot;var IK});var aQ=cf((X3)=>{var HZ=Ju(),BZ=Symbol.for("react.element"),DZ=Symbol.for("react.fragment"),VZ=Object.prototype.hasOwnProperty,SZ=HZ.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,XZ={key:!0,ref:!0,__self:!0,__source:!0};function IQ(l,u,r){var f,n={},i=null,t=null;r!==void 0&&(i=""+r),u.key!==void 0&&(i=""+u.key),u.ref!==void 0&&(t=u.ref);for(f in u)VZ.call(u,f)&&!XZ.hasOwnProperty(f)&&(n[f]=u[f]);if(l&&l.defaultProps)for(f in u=l.defaultProps,u)n[f]===void 0&&(n[f]=u[f]);return{$$typeof:BZ,type:l,key:i,ref:t,props:n,_owner:SZ.current}}X3.Fragment=DZ;X3.jsx=IQ;X3.jsxs=IQ});var dQ=cf((aC,oQ)=>{oQ.exports=aQ()});var Zq=cf((Oq)=>{var py=Ju();function eB(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var lD=typeof Object.is==="function"?Object.is:eB,uD=py.useState,rD=py.useEffect,fD=py.useLayoutEffect,nD=py.useDebugValue;function iD(l,u){var r=u(),f=uD({inst:{value:r,getSnapshot:u}}),n=f[0].inst,i=f[1];return fD(function(){n.value=r,n.getSnapshot=u,s9(n)&&i({inst:n})},[l,r,u]),rD(function(){return s9(n)&&i({inst:n}),l(function(){s9(n)&&i({inst:n})})},[l]),nD(r),r}function s9(l){var u=l.getSnapshot;l=l.value;try{var r=u();return!lD(l,r)}catch(f){return!0}}function tD(l,u){return u()}var yD=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?tD:iD;Oq.useSyncExternalStore=py.useSyncExternalStore!==void 0?py.useSyncExternalStore:yD});var Hq=cf((xv,pq)=>{pq.exports=Zq()});var Dq=cf((Bq)=>{var ZA=Ju(),cD=Hq();function _D(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var $D=typeof Object.is==="function"?Object.is:_D,AD=cD.useSyncExternalStore,jD=ZA.useRef,FD=ZA.useEffect,JD=ZA.useMemo,UD=ZA.useDebugValue;Bq.useSyncExternalStoreWithSelector=function(l,u,r,f,n){var i=jD(null);if(i.current===null){var t={hasValue:!1,value:null};i.current=t}else t=i.current;i=JD(function(){function c(U){if(!$){if($=!0,A=U,U=f(U),n!==void 0&&t.hasValue){var N=t.value;if(n(N,U))return j=N}return j=U}if(N=j,$D(A,U))return N;var W=f(U);if(n!==void 0&&n(N,W))return A=U,N;return A=U,j=W}var $=!1,A,j,F=r===void 0?null:r;return[function(){return c(u())},F===null?void 0:function(){return c(F())}]},[u,r,f,n]);var y=AD(l,i[0],i[1]);return FD(function(){t.hasValue=!0,t.value=y},[y]),UD(y),y}});var Sq=cf((vv,Vq)=>{Vq.exports=Dq()});var i0=Rl(Ju(),1);var Z_="北京时间";var bT={timeZone:"Asia/Shanghai",hour12:!1},vT={timeZone:"Asia/Shanghai",hour12:!1},sT=new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"});function B6(l){if(l===null||l===void 0||l==="")return null;let u=l instanceof Date?l:new Date(l);return Number.isNaN(u.getTime())?null:u}function z7(l){let u=B6(l);if(!u)return null;return sT.formatToParts(u).reduce((r,f)=>{if(f.type!=="literal")r[f.type]=f.value;return r},{})}function Wl(l){let u=B6(l);return u?u.toLocaleString("zh-CN",bT):"--"}function iu(l){let u=B6(l);return u?u.toLocaleTimeString("zh-CN",vT):"--"}function D6(l){let u=z7(l);if(!u)return"";let r=u.hour==="24"?"00":u.hour;return`${u.year}-${u.month}-${u.day}T${r}:${u.minute}`}function E7(l=new Date){let u=z7(l);if(!u)return"";return`${u.year}-${u.month}-${u.day}`}function O7(l){if(!l)return null;let u=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(l);if(!u)return null;let[,r,f,n,i,t,y="00"]=u,c=Date.UTC(Number(r),Number(f)-1,Number(n),Number(i)-8,Number(t),Number(y)),$=new Date(c),A=D6($);return Number.isNaN($.getTime())||A!==`${r}-${f}-${n}T${i}:${t}`?null:$.toISOString()}var _G=Rl(xU(),1);var a$=Rl(Ju(),1);var bU=Rl(Ju(),1),b1=bU.default.createElement;function aK({active:l=!0,label:u="正在加载"}){if(!l)return null;return b1("span",{className:"loading-spinner-indicator",role:"status","aria-label":u,title:u,"data-testid":"loading-title-indicator"},b1("span",{className:"loading-spinner-ring","aria-hidden":!0}))}function fu({title:l,children:u,loading:r,level:f=2,className:n="",label:i="正在加载"}){return b1(f===3?"h3":"h2",{className:`loading-title ${r?"is-loading":""} ${n}`.trim()},b1("span",{className:"loading-title-text"},u??l),b1(aK,{active:Boolean(r),label:i}))}class kt extends Error{unideskRequestError=!0;meta;constructor(l,u){super(l);this.name="UniDeskRequestError",this.meta=u}}function oK(l){return new Promise((u)=>setTimeout(u,l))}function k1(l,u="操作失败"){return l instanceof Error?l.message:String(l||u)}function g$(l,u=500){if(l===null||l===void 0)return"";let r=typeof l==="string"?l:JSON.stringify(l),f=String(r||"").replace(/\s+/gu," ").trim();return f.length>u?`${f.slice(0,u)}...`:f}function dK(l){try{let u=typeof location<"u"&&location.origin?location.origin:"http://localhost";return new URL(l,u).toString()}catch{return l}}function vU(l){return String(l.method||"GET").toUpperCase()}function eK(l){if(l===null||l===void 0)return!1;if(typeof l!=="object")return!1;if(typeof Blob<"u"&&l instanceof Blob)return!1;if(typeof FormData<"u"&&l instanceof FormData)return!1;if(typeof URLSearchParams<"u"&&l instanceof URLSearchParams)return!1;if(typeof ArrayBuffer<"u"&&l instanceof ArrayBuffer)return!1;return!0}function sU(l){let u=new Headers(l.headers||{}),r=eK(l.body)?JSON.stringify(l.body):l.body;if(r&&!u.has("content-type")&&typeof r==="string")u.set("content-type","application/json");return{...l,credentials:l.credentials||"same-origin",body:r,headers:u}}function kU(l){if(l?.error&&typeof l.error==="object"&&typeof l.error.message==="string")return l.error.message;if(typeof l?.error==="string")return l.error;if(typeof l?.message==="string")return l.message;if(typeof l?.detail==="string")return l.detail;return""}function lz(l,u){if(!l||typeof l!=="object"||Array.isArray(l))return!1;return u.some((r)=>r!==!1&&l[r]===!1)}function v1(l,u,r,f,n={}){return{kind:l,method:r,url:dK(u),occurredAt:f.toISOString(),...n}}function s1(l,u){if(!l)return"请求失败";return`HTTP ${l}${u?` ${u}`:""}`}function gU(l){try{return{body:l?JSON.parse(l):null,parseError:""}}catch(u){return{body:{text:l},parseError:k1(u,"parse failed")}}}async function ml(l,u={},r=0){let{failureFields:f=["ok"],strictJson:n=!1,retryInvalidJson:i=0,retryDelayMs:t=120,invalidJsonPrefix:y="服务返回了无效 JSON",invalidJsonPreview:c=!1,responsePreviewLength:$=500,...A}=u,j=vU(A),F=new Date,U;try{U=await fetch(l,sU(A))}catch(L){let J=k1(L,"网络请求失败");throw new kt(J,v1("network",l,j,F,{upstreamMessage:J}))}let N=await U.text(),W=gU(N);if(W.parseError){if(n&&j==="GET"&&r<i)return await oK(t),ml(l,u,r+1);if(n){let L=c?`;响应预览:${g$(N,180)}`:"";throw new kt(`${y}(${N.length} bytes):${W.parseError}${L}`,v1("parse",l,j,F,{status:U.status,statusText:U.statusText,parseError:W.parseError,responsePreview:g$(N,$)}))}}if(!U.ok||lz(W.body,f)){let L=kU(W.body),J=L||s1(U.status,U.statusText);throw new kt(J,v1("http",l,j,F,{status:U.status,statusText:U.statusText,upstreamMessage:L,responsePreview:g$(W.parseError?N:W.body,$)}))}return W.body}async function IU(l,u={}){let r=vU(u),f=new Date,n;try{n=await fetch(l,sU(u))}catch($){let A=k1($,"网络请求失败");throw new kt(A,v1("network",l,r,f,{upstreamMessage:A}))}if(n.ok)return n.blob();let i=await n.text(),t=gU(i),y=kU(t.body),c=y||s1(n.status,n.statusText);throw new kt(c,v1("http",l,r,f,{status:n.status,statusText:n.statusText,upstreamMessage:y,responsePreview:g$(t.parseError?i:t.body),parseError:t.parseError||void 0}))}function aU(l){return Boolean(l&&typeof l==="object"&&l.unideskRequestError===!0&&l.meta)}function uz(l){if(!l)return"";let u=new Date(l);if(Number.isNaN(u.getTime()))return l;return`${Wl(u)} ${Z_}`}function o4(l,u="操作失败"){if(aU(l)){let n=l.meta.kind==="parse"?"响应解析失败":l.meta.kind==="network"?"网络请求失败":l.meta.status&&(l.meta.status<200||l.meta.status>=300)?s1(l.meta.status,l.meta.statusText):"应用请求失败",i=l.meta.status?s1(l.meta.status):"",t=(c)=>!c||c===n||c===i,y=!t(l.message)?l.message:t(l.meta.upstreamMessage)?"":l.meta.upstreamMessage||"";return{title:n,message:y,status:l.meta.status,statusText:l.meta.statusText,method:l.meta.method,url:l.meta.url,occurredAt:uz(l.meta.occurredAt),responsePreview:l.meta.responsePreview,parseError:l.meta.parseError,structured:!0}}let f=k1(l,u).split(/\r?\n/u);return{title:f[0]||u,message:f.slice(1).join(` +`),structured:f.length>1}}function rz(l,u="操作失败"){let r=o4(l,u),f=[r.title];if(r.message)f.push(`原因: ${r.message}`);if(r.method||r.url)f.push(`请求: ${[r.method,r.url].filter(Boolean).join(" ")}`);if(r.status)f.push(`状态: ${s1(r.status,r.statusText)}`);if(r.occurredAt)f.push(`时间: ${r.occurredAt}`);if(r.parseError)f.push(`解析错误: ${r.parseError}`);if(r.responsePreview&&r.responsePreview!==r.message)f.push(`响应预览: ${r.responsePreview}`);return f.filter(Boolean).join(` +`)}function El(l,u="操作失败"){return aU(l)?rz(l,u):k1(l,u)}var oU=Rl(Ju(),1);var Bi=oU.default.createElement;function g1(l,u){return u?[Bi("dt",{key:`${l}-label`},l),Bi("dd",{key:l},u)]:null}function lu({error:l,wide:u=!1,fallback:r="操作失败",className:f=""}){if(!l)return null;let n=o4(l,r),i=[g1("请求",[n.method,n.url].filter(Boolean).join(" ")),g1("状态",n.status?`HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`:""),g1("时间",n.occurredAt),g1("解析错误",n.parseError),g1("响应预览",n.responsePreview)].filter(Boolean);return Bi("div",{className:`form-error unidesk-error${u?" wide":""}${f?` ${f}`:""}`,role:"alert","data-testid":"unidesk-error"},Bi("div",{className:"unidesk-error-title"},Bi("strong",null,n.title),n.status?Bi("span",{className:"unidesk-error-code"},`HTTP ${n.status}`):null),n.message?Bi("pre",{className:"unidesk-error-message"},n.message):null,i.length>0?Bi("dl",{className:"unidesk-error-details"},i):null)}var Jn=Rl(Ju(),1),dU=Jn.default.createContext(null);function eU({children:l}){let[u,r]=Jn.default.useState([]),[f,n]=Jn.default.useState(Date.now()),i=Jn.default.useCallback((j,F)=>{let N={id:`notif_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,type:j,message:F,timestamp:Date.now()};r((W)=>{let L=[...W,N];if(L.length>50)return L.slice(-50);return L})},[]),t=Jn.default.useCallback((j)=>{r((F)=>F.filter((U)=>U.id!==j))},[]),y=Jn.default.useCallback(()=>{r([]),n(Date.now())},[]),c=Jn.default.useMemo(()=>{return u.filter((j)=>j.timestamp>f).length},[u,f]),$=c>0,A={notifications:u,addNotification:i,removeNotification:t,clearNotifications:y,unreadCount:c,hasUnread:$};return fz(dU.Provider,{value:A},l)}var fz=Jn.default.createElement;function Xr(){let l=Jn.default.useContext(dU);if(!l)throw Error("useNotification must be used within NotificationProvider");return l}var x=a$.default.createElement,{useEffect:I$}=a$.default,gt=a$.default.useState;function Kr(l,u={}){return ml(l,{failureFields:["ok","success"],...u})}function Yr(l,u){return`${l}/microservices/baidu-netdisk/proxy${u}`}function nz(l){let u=Number(l);return Number.isFinite(u)?u.toLocaleString("zh-CN"):"--"}function Di(l){let u=Number(l);if(!Number.isFinite(u)||u<=0)return"--";let r=["B","KB","MB","GB","TB"],f=u,n=0;while(f>=1024&&n<r.length-1)f/=1024,n+=1;return`${f.toFixed(n===0?0:1)} ${r[n]}`}function p0({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return x("span",{className:`status-badge ${r}`},u||l||"unknown")}function It({label:l,value:u,hint:r,tone:f}){return x("article",{className:`metric-card ${f||""}`},x("div",{className:"metric-label"},l),x("div",{className:"metric-value"},u),x("div",{className:"metric-hint"},r))}function H0({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return x("section",{className:`panel ${n||""}`},x("div",{className:"panel-head"},x("div",null,u?x("p",{className:"panel-eyebrow"},u):null,x(fu,{title:l,loading:i})),r?x("div",{className:"panel-actions"},r):null),x("div",{className:"panel-body"},f))}function xn({title:l,data:u,onOpen:r,testId:f}){return x("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:(n)=>{n?.stopPropagation?.(),r(l,u)}},"查看原始JSON")}function at({title:l,text:u}){return x("div",{className:"empty-state"},x("strong",null,l),x("span",null,u))}function ot({title:l,text:u,href:r,badge:f,testId:n}){return x("a",{className:"doc-link-card",href:r,target:"_blank",rel:"noreferrer","data-testid":n},x("span",null,f||"DOC"),x("strong",null,l),x("p",null,u),x("code",null,r))}function iz(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function tz(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function yz(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function cz(l){return Array.isArray(l?.files)?l.files:[]}function _z(l){return Array.isArray(l?.jobs)?l.jobs:[]}function $z(l,u){if(!l||l===u)return u;let r=l.replace(/\/+$/u,""),f=r.slice(0,r.lastIndexOf("/"))||u;return f.length<u.length?u:f}function d4(l,u){let r=String(u||"").replace(/^\/+|\/+$/gu,"");return`${l.replace(/\/+$/u,"")}/${r}`}function Az(l){return l==="/"?"/":l.split("/").filter(Boolean).pop()||l}function jz({percent:l}){let u=Math.max(0,Math.min(100,Number(l)||0));return x("div",{className:"baidu-progress"},x("span",{style:{width:`${u}%`}}),x("em",null,`${u.toFixed(1)}%`))}function lN({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((M)=>M.id==="baidu-netdisk")||null,[n,i]=gt({loading:!1,actionLoading:!1,error:"",message:"",health:null,account:null,files:null,transfers:null,logs:null,selfTest:null,refreshedAt:null}),[t,y]=gt("/"),[c,$]=gt(null),[A,j]=gt(""),[F,U]=gt({localPath:"sample.txt",remotePath:"/sample.txt"}),[N,W]=gt({fsId:"",localPath:"downloads/"}),{addNotification:L}=Xr(),J=n.health?.baidu?.appRoot||n.account?.rootPath||"/";I$(()=>{U((M)=>{let rl=new Set(["/sample.txt","/apps/UniDeskBaiduNetdisk/sample.txt"]);if(M.remotePath&&!rl.has(M.remotePath))return M;let cl=d4(J,"sample.txt");return M.remotePath===cl?M:{...M,remotePath:cl}})},[J]);async function w(M=t){let cl=await Kr(Yr(r,`/api/files?dir=${encodeURIComponent(M||J)}&limit=100`));i(($l)=>({...$l,files:cl}))}async function Q(){let M=await Kr(Yr(r,"/api/transfers?limit=80"));i((rl)=>({...rl,transfers:M}))}async function q(){if(!f)return;i((M)=>({...M,loading:!0,error:"",message:""}));try{let M=await Kr(`${r}/microservices/baidu-netdisk/health`),rl=M?.baidu?.appRoot||J,cl=null,$l=null;if(M?.auth?.loggedIn){cl=await Kr(Yr(r,"/api/account?refresh=1"));let Ol=t&&t.startsWith(rl)?t:rl;y(Ol),$l=await Kr(Yr(r,`/api/files?dir=${encodeURIComponent(Ol)}&limit=100`))}else y(rl);let Tl=await Kr(Yr(r,"/api/transfers?limit=80")),Ql=await Kr(Yr(r,"/logs?limit=60"));i((Ol)=>({...Ol,loading:!1,health:M,account:cl?.account||null,files:$l,transfers:Tl,logs:Ql,refreshedAt:new Date}))}catch(M){i((rl)=>({...rl,loading:!1,error:El(M,"百度网盘服务加载失败")}))}}async function T(){i((M)=>({...M,actionLoading:!0,error:"",message:""}));try{let M=await Kr(Yr(r,"/api/auth/device/start"),{method:"POST",body:{}});$(M.session||null),i((rl)=>({...rl,actionLoading:!1,message:"设备码已生成,请扫码授权"}))}catch(M){i((rl)=>({...rl,actionLoading:!1,error:El(M,"创建设备码失败")}))}}async function O(M=!1){if(!c?.id)return;if(M)i((rl)=>({...rl,actionLoading:!0,error:""}));try{let rl=await Kr(Yr(r,`/api/auth/device/status?sessionId=${encodeURIComponent(c.id)}`));if($(rl.session||null),rl.session?.status==="succeeded")i((cl)=>({...cl,actionLoading:!1,message:"授权成功,正在刷新账号与文件列表"})),await q();else if(M)i((cl)=>({...cl,actionLoading:!1}))}catch(rl){i((cl)=>({...cl,actionLoading:!1,error:El(rl,"轮询登录状态失败")}))}}async function Z(){i((M)=>({...M,actionLoading:!0,error:"",message:""}));try{await Kr(Yr(r,"/api/auth/logout"),{method:"POST",body:{}}),$(null),i((M)=>({...M,actionLoading:!1,account:null,files:null,message:"本地 token 已清除"})),await q()}catch(M){i((rl)=>({...rl,actionLoading:!1,error:El(M,"退出登录失败")}))}}async function E(M){M.preventDefault();let rl=A.trim();if(!rl)return;i((cl)=>({...cl,actionLoading:!0,error:"",message:""}));try{await Kr(Yr(r,"/api/folders"),{method:"POST",body:{path:d4(t,rl)}}),j(""),i((cl)=>({...cl,actionLoading:!1,message:"文件夹已创建"})),await w(t)}catch(cl){i(($l)=>({...$l,actionLoading:!1,error:El(cl,"创建文件夹失败")}))}}async function D(M){if(!M)return;i((rl)=>({...rl,actionLoading:!0,error:"",message:""}));try{await Kr(Yr(r,"/api/files/manage"),{method:"POST",body:{opera:"delete",filelist:[{path:M}],async:1}}),i((rl)=>({...rl,actionLoading:!1,message:"删除任务已提交"})),await w(t)}catch(rl){i((cl)=>({...cl,actionLoading:!1,error:El(rl,"删除失败")}))}}async function Y(M){M.preventDefault(),i((rl)=>({...rl,actionLoading:!0,error:"",message:""}));try{await Kr(Yr(r,"/api/transfers/upload-from-path"),{method:"POST",body:F}),i((rl)=>({...rl,actionLoading:!1,message:"上传任务已入队"})),await Q()}catch(rl){i((cl)=>({...cl,actionLoading:!1,error:El(rl,"上传任务创建失败")}))}}async function p(M){M.preventDefault(),i((rl)=>({...rl,actionLoading:!0,error:"",message:""}));try{await Kr(Yr(r,"/api/transfers/download-to-path"),{method:"POST",body:N}),i((rl)=>({...rl,actionLoading:!1,message:"下载任务已入队"})),await Q()}catch(rl){i((cl)=>({...cl,actionLoading:!1,error:El(rl,"下载任务创建失败")}))}}async function V(M,rl){i((cl)=>({...cl,actionLoading:!0,error:"",message:""}));try{await Kr(Yr(r,`/api/transfers/${encodeURIComponent(M)}/${rl}`),{method:"POST",body:{}}),i((cl)=>({...cl,actionLoading:!1,message:rl==="cancel"?"已请求取消任务":"任务已重新入队"})),await Q()}catch(cl){i(($l)=>({...$l,actionLoading:!1,error:El(cl,"任务操作失败")}))}}async function B(){i((M)=>({...M,actionLoading:!0,error:"",message:"正在运行上传/下载自测..."}));try{let M=await Kr(Yr(r,"/api/self-test"),{method:"POST",body:{}});i((rl)=>({...rl,actionLoading:!1,selfTest:M,message:`上传/下载自测通过:${M.remotePath||""}`})),await w(t),await Q()}catch(M){i((rl)=>({...rl,actionLoading:!1,error:El(M,"上传/下载自测失败")}))}}if(I$(()=>{if(!f)return;q();return},[f?.id,f?.runtime?.providerStatus]),I$(()=>{if(!c?.id||c.status!=="pending")return;let M=window.setInterval(()=>void O(!1),Math.max(5000,Number(c.pollIntervalSeconds||5)*1000));return()=>window.clearInterval(M)},[c?.id,c?.status,c?.pollIntervalSeconds]),I$(()=>{if(!f)return;let M=window.setInterval(()=>void Q(),5000);return()=>window.clearInterval(M)},[f?.id]),!f)return x(at,{title:"Baidu Netdisk 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=baidu-netdisk"});let m=iz(f),X=yz(f),S=tz(f),b=n.health||{},z=n.account||b.auth?.account||null,P=b.auth||{},s=cz(n.files),k=_z(n.transfers),v=z?.quota||{},tl=Boolean(P.loggedIn||z),I=Boolean(P.configured);return x("div",{className:"baidu-netdisk-page","data-testid":"baidu-netdisk-page"},x(H0,{title:"Baidu Netdisk 工作台",eyebrow:"Containerized Storage Gateway",loading:n.loading,actions:x("div",{className:"panel-actions"},x("a",{className:"ghost-btn",href:"/docs/issue/baidu-netdisk-env-setup.md",target:"_blank",rel:"noreferrer","data-testid":"baidu-netdisk-config-doc-link"},"配置文档"),x("button",{type:"button",className:"ghost-btn",onClick:q,disabled:n.loading,"data-testid":"baidu-netdisk-refresh"},n.loading?"刷新中":"刷新"),x(xn,{title:"Baidu Netdisk 用户服务",data:f,onOpen:u,testId:"raw-baidu-netdisk-service"}))},x("div",{className:"baidu-netdisk-hero"},x("div",null,x("div",{className:"node-version-line"},x(p0,{status:m.providerStatus==="online"?"online":"warn"},m.providerStatus||"unknown"),x("span",null,f.providerId),x(p0,{status:S.public?"warn":"private"},S.public?"公网暴露":"仅 UniDesk frontend 代理访问")),x("p",{className:"muted paragraph"},f.description)),x("div",{className:"microservice-ref-card"},x("span",null,"Repo"),x("strong",null,X.url||"--"),x("code",null,X.commitId||"--")),x("div",{className:"microservice-ref-card"},x("span",null,"Private Backend"),x("strong",null,`${S.nodeBindHost||"--"}:${S.nodePort||"--"}`),x("code",null,`${X.composeFile||"--"} / ${X.composeService||"--"}`))),x(lu,{error:n.error,wide:!0})),x("div",{className:"metric-grid"},x(It,{label:"Health",value:b.ok?"OK":"--",hint:b.storage?.postgres||"postgres",tone:b.ok?"ok":"warn"}),x(It,{label:"OAuth",value:I?"已配置":"待配置",hint:I?"client + secret + token key":"需要设置 UNIDESK_BAIDU_NETDISK_*",tone:I?"ok":"warn"}),x(It,{label:"Login",value:tl?"已登录":"未登录",hint:z?.username||"Device Code QR",tone:tl?"ok":"warn"}),x(It,{label:"Work Root",value:Az(J),hint:J}),x(It,{label:"Quota",value:Di(v.used),hint:v.total?`${v.usedPercent||0}% / ${Di(v.total)}`:"授权后刷新"}),x(It,{label:"Transfers",value:nz(k.length),hint:`running ${n.transfers?.counts?.running||0} / failed ${n.transfers?.counts?.failed||0}`})),x(H0,{title:"文件浏览器",eyebrow:t,className:"baidu-files-panel",loading:n.loading,actions:x("div",{className:"panel-actions inline-actions"},x("button",{type:"button",className:"ghost-btn",onClick:()=>{let M=$z(t,J);y(M),w(M)},disabled:!tl||t===J},"上级"),x("button",{type:"button",className:"ghost-btn",onClick:()=>w(t),disabled:!tl},"刷新文件"),x(xn,{title:"Baidu Files",data:n.files,onOpen:u,testId:"raw-baidu-files"}))},x("form",{className:"baidu-pathbar",onSubmit:(M)=>{M.preventDefault(),w(t)}},x("input",{value:t,onChange:(M)=>y(M.target.value),disabled:!tl}),x("button",{type:"submit",className:"ghost-btn",disabled:!tl},"打开路径")),x("form",{className:"baidu-pathbar",onSubmit:E},x("input",{value:A,onChange:(M)=>j(M.target.value),placeholder:"新文件夹名称",disabled:!tl}),x("button",{type:"submit",className:"primary-btn",disabled:!tl||!A.trim()},"新建文件夹")),!tl?x(at,{title:"等待授权",text:"登录后通过 /api/files 读取工作目录文件列表"}):s.length===0?x(at,{title:"目录为空",text:"可以从 staging 目录上传文件或新建文件夹"}):x("div",{className:"table-wrap","data-testid":"baidu-netdisk-file-table"},x("table",null,x("thead",null,x("tr",null,x("th",null,"名称"),x("th",null,"类型"),x("th",null,"大小"),x("th",null,"修改时间"),x("th",null,"fs_id"),x("th",null,"操作"))),x("tbody",null,s.map((M)=>x("tr",{key:M.fsId||M.path},x("td",null,x("strong",null,M.serverFilename||M.path),x("code",null,M.path||"--")),x("td",null,x(p0,{status:M.isDir?"queued":"private"},M.isDir?"DIR":"FILE")),x("td",null,M.isDir?"--":Di(M.size)),x("td",null,M.serverMtime?Wl(M.serverMtime*1000):"--"),x("td",null,x("code",null,M.fsId||"--")),x("td",null,x("div",{className:"inline-actions"},M.isDir?x("button",{type:"button",className:"ghost-btn",onClick:()=>{y(M.path),w(M.path)}},"打开"):x("button",{type:"button",className:"ghost-btn",onClick:()=>W((rl)=>({...rl,fsId:M.fsId}))},"填入下载"),x("button",{type:"button",className:"ghost-btn",onClick:()=>D(M.path),disabled:n.actionLoading},"删除"))))))))),x("div",{className:"baidu-netdisk-grid"},x(H0,{title:"配置与文档",eyebrow:"Deployment References",className:"baidu-docs-panel",actions:x("div",{className:"panel-actions inline-actions"},x("a",{className:"ghost-btn",href:"/docs/issue/baidu-netdisk-env-setup.md",target:"_blank",rel:"noreferrer"},"打开环境配置"),x("a",{className:"ghost-btn",href:"/docs/issue/baidu-netdisk-user-service.md",target:"_blank",rel:"noreferrer"},"打开服务方案"))},x("p",{className:"muted paragraph"},I?"OAuth 运行时变量已配置;如需轮换密钥、迁移部署或排查代理边界,可直接打开下面的项目内文档。":"首次使用请先按环境变量配置文档填入百度应用 client id / secret,然后重建 baidu-netdisk 服务并刷新本页。"),x("div",{className:"baidu-doc-grid","data-testid":"baidu-netdisk-doc-links"},x(ot,{title:"环境变量配置",text:"填写 UNIDESK_BAIDU_NETDISK_CLIENT_ID、CLIENT_SECRET、TOKEN_KEY,并执行重建与健康检查。",href:"/docs/issue/baidu-netdisk-env-setup.md",badge:"SETUP",testId:"baidu-netdisk-env-doc-card"}),x(ot,{title:"服务方案与 API",text:"说明 OAuth Device Code、根目录工作区、staging 上传下载任务和后端 API 设计。",href:"/docs/issue/baidu-netdisk-user-service.md",badge:"DESIGN"}),x(ot,{title:"用户服务安全边界",text:"查看 UniDesk microservice 私有代理、允许路径、frontendOnly 和密钥边界规则。",href:"/docs/reference/microservices.md",badge:"REF"}),x(ot,{title:"部署与重建流程",text:"查看 server rebuild、Compose 编排、健康检查和交付验证的长期规则。",href:"/docs/reference/deployment.md",badge:"DEPLOY"}),x(ot,{title:"CLI 验证命令",text:"查看 microservice health/proxy、server rebuild、job status 等命令入口。",href:"/docs/reference/cli.md",badge:"CLI"}),x(ot,{title:"百度设备码模式",text:"打开百度官方 OAuth Device Code 文档,对照扫码登录和轮询参数。",href:"https://pan.baidu.com/union/doc/fl1x114ti",badge:"OFFICIAL"}))),x(H0,{title:"设备码登录",eyebrow:"OAuth Device Code",className:"baidu-login-panel",loading:n.actionLoading,actions:x("div",{className:"panel-actions inline-actions"},x("button",{type:"button",className:"primary-btn",onClick:T,disabled:n.actionLoading||!I,"data-testid":"baidu-netdisk-start-login"},"生成二维码"),c?.id?x("button",{type:"button",className:"ghost-btn",onClick:()=>O(!0),disabled:n.actionLoading},"检查状态"):null,tl?x("button",{type:"button",className:"ghost-btn",onClick:Z,disabled:n.actionLoading},"清除本地登录"):null,x(xn,{title:"Baidu Device Session",data:c||P.latestSession,onOpen:u,testId:"raw-baidu-device-session"}))},x("div",{className:"baidu-login-card","data-testid":"baidu-netdisk-login-card"},x("div",{className:"baidu-qr-frame"},c?.qrcodeUrl?x("img",{src:c.qrcodeUrl,alt:"百度网盘设备码授权二维码","data-testid":"baidu-netdisk-qrcode"}):x(at,{title:I?"等待二维码":"OAuth 未配置",text:I?"点击生成二维码后使用百度网盘或百度 App 扫码":"设置 client id、secret 和 token key 后重建服务"})),x("div",{className:"claudeqq-login-copy"},x("div",{className:"node-version-line"},x(p0,{status:tl?"online":c?.status==="pending"?"warn":"unknown"},tl?"已登录":c?.status||"未开始"),x("span",null,c?.secondsRemaining!==void 0?`${c.secondsRemaining}s`:"--"),x("span",null,"scope basic,netdisk")),x("p",{className:"muted paragraph"},tl?"access token / refresh token 已加密保存到 PostgreSQL;前端只看到脱敏登录态。":"后端使用百度 OAuth Device Code 轮询换取 token;二维码过期后重新生成即可。"),x("div",{className:"microservice-ref-card"},x("span",null,"User Code"),x("strong",null,c?.userCode||"--"),x("code",null,c?.verificationUrl||"https://openapi.baidu.com/device")),x("div",{className:"microservice-ref-card"},x("span",null,"Expires"),x("strong",null,c?.expiresAt?Wl(c.expiresAt):"--"),x("code",null,c?.error||"no token exposed"))))),x(H0,{title:"账号与容量",eyebrow:n.refreshedAt?`Updated ${iu(n.refreshedAt)}`:"Account",loading:n.loading,actions:x("div",{className:"panel-actions inline-actions"},x(xn,{title:"Baidu Account",data:z,onOpen:u,testId:"raw-baidu-account"}))},z?x("div",{className:"baidu-account-card"},x("div",{className:"node-version-line"},x(p0,{status:"online"},"connected"),x("span",null,z.baiduUid||"--"),x("span",null,`VIP ${z.vipType??"--"}`)),x("h3",null,z.username||"Baidu Netdisk"),x("p",{className:"muted paragraph"},`工作目录固定在 ${z.rootPath||J};v1 上传/下载只读写容器 staging 目录,不把大文件字节流穿过 UniDesk proxy。`),x("div",{className:"quota-bar"},x("span",{style:{width:`${Math.max(0,Math.min(100,Number(v.usedPercent||0)))}%`}})),x("div",{className:"microservice-ref-card"},x("span",null,"Quota"),x("strong",null,`${Di(v.used)} / ${Di(v.total)}`),x("code",null,`${v.usedPercent||0}% used`))):x(at,{title:"尚未登录",text:"扫码授权后这里会显示账号、UID、会员状态和容量"})),x(H0,{title:"传输任务",eyebrow:"staging path jobs",className:"baidu-transfers-panel",loading:n.actionLoading,actions:x("div",{className:"panel-actions inline-actions"},x("button",{type:"button",className:"primary-btn",onClick:B,disabled:!tl||n.actionLoading,"data-testid":"baidu-netdisk-self-test"},"运行自测"),x("button",{type:"button",className:"ghost-btn",onClick:Q},"刷新任务"),x(xn,{title:"Baidu Transfers",data:n.transfers,onOpen:u,testId:"raw-baidu-transfers"}))},x("div",{className:"baidu-transfer-forms"},x("form",{className:"stack-form",onSubmit:Y,"data-testid":"baidu-upload-form"},x("label",null,"容器 staging 文件",x("input",{value:F.localPath,onChange:(M)=>U((rl)=>({...rl,localPath:M.target.value})),placeholder:"sample.txt"})),x("label",null,"百度网盘目标路径",x("input",{value:F.remotePath,onChange:(M)=>U((rl)=>({...rl,remotePath:M.target.value})),placeholder:d4(J,"sample.txt")})),x("button",{type:"submit",className:"primary-btn",disabled:!tl||n.actionLoading},"上传 staging 文件")),x("form",{className:"stack-form",onSubmit:p,"data-testid":"baidu-download-form"},x("label",null,"文件 fs_id",x("input",{value:N.fsId,onChange:(M)=>W((rl)=>({...rl,fsId:M.target.value})),placeholder:"从文件表填入"})),x("label",null,"保存到 staging 路径",x("input",{value:N.localPath,onChange:(M)=>W((rl)=>({...rl,localPath:M.target.value})),placeholder:"downloads/"})),x("button",{type:"submit",className:"primary-btn",disabled:!tl||!N.fsId||n.actionLoading},"下载到 staging"))),n.selfTest?x("div",{className:"baidu-account-card","data-testid":"baidu-netdisk-self-test-result"},x("div",{className:"node-version-line"},x(p0,{status:n.selfTest.ok?"online":"warn"},n.selfTest.ok?"self-test ok":"self-test"),x("span",null,Di(n.selfTest.sizeBytes))),x("h3",null,n.selfTest.remotePath||"Baidu self-test"),x("div",{className:"microservice-ref-card"},x("span",null,"fs_id"),x("strong",null,n.selfTest.fsId||"--"),x("code",null,n.selfTest.downloadedPath||"--")),x("div",{className:"microservice-ref-card"},x("span",null,"MD5"),x("strong",null,n.selfTest.downloadedMd5||"--"),x("code",null,n.selfTest.expectedMd5||"--")),x(xn,{title:"Baidu Self Test",data:n.selfTest,onOpen:u,testId:"raw-baidu-self-test"})):null,k.length===0?x(at,{title:"暂无传输任务",text:"上传/下载任务会在后端容器内执行,避免大文件穿过 UniDesk proxy"}):x("div",{className:"table-wrap","data-testid":"baidu-transfer-table"},x("table",null,x("thead",null,x("tr",null,x("th",null,"状态"),x("th",null,"方向"),x("th",null,"路径"),x("th",null,"进度"),x("th",null,"时间"),x("th",null,"操作"))),x("tbody",null,k.map((M)=>x("tr",{key:M.id},x("td",null,x(p0,{status:M.status},M.status)),x("td",null,M.direction),x("td",null,x("strong",null,M.remotePath||M.fsId||"--"),x("code",null,M.localPath||"--"),M.error?x("span",{className:"form-error"},M.error):null),x("td",null,x(jz,{percent:M.progressPercent}),x("span",{className:"muted"},`${Di(M.bytesDone)} / ${Di(M.sizeBytes)}`)),x("td",null,Wl(M.updatedAt)),x("td",null,x("div",{className:"inline-actions"},["queued","running"].includes(M.status)?x("button",{type:"button",className:"ghost-btn",onClick:()=>V(M.id,"cancel")},"取消"):null,["failed","canceled"].includes(M.status)?x("button",{type:"button",className:"ghost-btn",onClick:()=>V(M.id,"retry")},"重试"):null,x(xn,{title:`Transfer ${M.id}`,data:M,onOpen:u}))))))))),x(H0,{title:"安全与日志",eyebrow:"redacted diagnostics",className:"baidu-wide-panel",loading:n.loading,actions:x("div",{className:"panel-actions inline-actions"},x(xn,{title:"Baidu Health",data:b,onOpen:u,testId:"raw-baidu-health"}),x(xn,{title:"Baidu Logs",data:n.logs,onOpen:u,testId:"raw-baidu-logs"}))},x("div",{className:"policy-grid"},x("article",null,x("b",null,"私有后端"),x("span",null,"4244 只在 Compose 网络 expose,浏览器经 UniDesk 同源代理访问")),x("article",null,x("b",null,"Token 加密"),x("span",null,"access/refresh token 使用 BAIDU_NETDISK_TOKEN_KEY 加密后写入 PostgreSQL")),x("article",null,x("b",null,"无浏览器大文件流"),x("span",null,"上传/下载以容器 staging 目录为边界,避免 proxy 文本通道传输大字节流"))))))}var e$=Rl(Ju(),1);var d=e$.default.createElement,{useEffect:Fz}=e$.default,o$=e$.default.useState,B0={label:"主用户私聊账号",userId:645275593};function e4(l){let u=Number(l);return Number.isFinite(u)?u.toLocaleString("zh-CN"):"--"}async function Vi(l,u={}){return ml(l,{failureFields:["ok","success"],...u})}async function Jz(l){let u=await fetch(l,{credentials:"same-origin"}),r=await u.text();try{return r?JSON.parse(r):{ok:u.ok,status:u.status}}catch{return{ok:u.ok,status:u.status,text:r}}}function d$({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return d("span",{className:`status-badge ${r}`},u||l||"unknown")}function dt({label:l,value:u,hint:r,tone:f}){return d("article",{className:`metric-card ${f||""}`},d("div",{className:"metric-label"},l),d("div",{className:"metric-value"},u),d("div",{className:"metric-hint"},r))}function et({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return d("section",{className:`panel ${n||""}`},d("div",{className:"panel-head"},d("div",null,u?d("p",{className:"panel-eyebrow"},u):null,d(fu,{title:l,loading:i})),r?d("div",{className:"panel-actions"},r):null),d("div",{className:"panel-body"},f))}function I1({title:l,data:u,onOpen:r,testId:f}){return d("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:(n)=>{n?.stopPropagation?.(),r(l,u)}},"查看原始JSON")}function a1({title:l,text:u}){return d("div",{className:"empty-state"},d("strong",null,l),d("span",null,u))}function Uz(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function Nz(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function Qz(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function Si(l,u){return`${l}/microservices/claudeqq/proxy${u}`}function wz(l){return Array.isArray(l?.events)?l.events.slice(0,80):[]}function qz(l){return Array.isArray(l?.subscriptions)?l.subscriptions.slice(0,50):[]}function Wz(l){return Array.isArray(l?.messages)?l.messages.slice(0,30):[]}function uN(l){let u=l?.text??l?.message??l?.raw?.raw_message;if(typeof u!=="string")return"--";return u.length>180?`${u.slice(0,177)}...`:u}function rN(l){let u=l?.groupId??l?.group_id??(l?.message_type==="group"?l?.target_id:void 0),r=l?.userId??l?.user_id??(l?.message_type==="private"?l?.target_id:void 0);if(u)return`群 ${u}`;if(r)return`私聊 ${r}`;return"--"}function fN({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((z)=>z.id==="claudeqq")||null,[n,i]=o$({loading:!1,qrLoading:!1,error:"",health:null,status:null,napcatLogin:null,napcatQrcode:null,qrcodeFetched:!1,qrcodeRefreshedAt:null,events:null,subscriptions:null,sent:null,refreshedAt:null}),[t,y]=o$({targetType:"private",targetId:String(B0.userId),message:""}),[c,$]=o$({name:"unidesk-callback",targetUrl:"",eventTypes:"message",secret:""}),[A,j]=o$(""),{addNotification:F}=Xr();async function U(){if(!f)return;i((z)=>({...z,loading:!0,error:""}));try{let[z,P,s,k,v]=await Promise.all([Jz(`${r}/microservices/claudeqq/health`),Vi(Si(r,"/api/server/status")),Vi(Si(r,"/api/events/recent?limit=60")),Vi(Si(r,"/api/events/subscriptions")),Vi(Si(r,"/api/messages/sent?limit=20"))]);if(i((tl)=>({...tl,loading:!1,error:"",health:z,status:P,events:s,subscriptions:k,sent:v,refreshedAt:new Date})),!n.qrcodeFetched)N(!1)}catch(z){i((P)=>({...P,loading:!1,error:El(z,"ClaudeQQ 加载失败")}))}}async function N(z=!0){if(!f)return;i((P)=>({...P,qrLoading:!0,error:z?"":P.error}));try{let P=await Vi(Si(r,"/api/napcat/login")),s=P?.napcat?.qrcode||P?.qrcode||null;i((k)=>({...k,qrLoading:!1,error:"",napcatLogin:P,napcatQrcode:s,qrcodeFetched:!0,qrcodeRefreshedAt:new Date}))}catch(P){i((s)=>({...s,qrLoading:!1,error:z||!s.napcatQrcode?El(P,"NapCat 二维码加载失败"):s.error}))}}async function W(z){z.preventDefault(),j("");let P=Number(t.targetId);if(!Number.isFinite(P)||P<=0||t.message.trim().length===0){i((s)=>({...s,error:"请填写 QQ 目标和消息内容"}));return}try{await Vi(Si(r,"/api/push/text"),{method:"POST",body:JSON.stringify({userId:t.targetType==="private"?P:void 0,groupId:t.targetType==="group"?P:void 0,message:t.message})});let s="消息推送请求已提交";y((k)=>({...k,targetType:"private",targetId:String(B0.userId),message:""})),j(s),F("success",s),await U()}catch(s){i((k)=>({...k,error:El(s,"发送失败")}))}}async function L(z){if(z.preventDefault(),j(""),c.targetUrl.trim().length===0){i((P)=>({...P,error:"请填写订阅回调 URL"}));return}try{await Vi(Si(r,"/api/events/subscriptions"),{method:"POST",body:JSON.stringify({name:c.name,targetUrl:c.targetUrl,eventTypes:c.eventTypes.split(",").map((s)=>s.trim()).filter(Boolean),secret:c.secret||void 0,enabled:!0})});let P="事件订阅已创建";j(P),F("success",P),await U()}catch(P){i((s)=>({...s,error:El(P,"订阅失败")}))}}async function J(z){if(!z)return;j("");try{await Vi(Si(r,`/api/events/subscriptions/${encodeURIComponent(z)}`),{method:"DELETE"});let P="事件订阅已删除";j(P),F("success",P),await U()}catch(P){i((s)=>({...s,error:El(P,"删除订阅失败")}))}}if(Fz(()=>{if(!f)return;U();return},[f?.id,f?.runtime?.providerStatus]),!f)return d(a1,{title:"ClaudeQQ 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=claudeqq"});let w=Uz(f),Q=Qz(f),q=Nz(f),T=n.health||{},O=n.status||{},Z=n.napcatLogin||{},E=T.napcat||O.napcat||{},D={...Z.napcat||{},...E,qrcode:n.napcatQrcode||{},webui:E.webui||Z.napcat?.webui},Y=Z.login||{},p=n.napcatQrcode||{},V=wz(n.events),B=qz(n.subscriptions),m=Wz(n.sent),X=Boolean(D.httpConnected||Y.ready),S=String(D.loginState||Y.state||(X?"logged_in":"unknown")),b=Boolean(p.available&&p.dataUrl);return d("div",{className:"claudeqq-page","data-testid":"claudeqq-page"},d(et,{title:"ClaudeQQ 工作台",eyebrow:"D601 QQ Event Gateway",loading:n.loading,actions:d("div",{className:"panel-actions"},d("button",{type:"button",className:"ghost-btn",onClick:U,disabled:n.loading,"data-testid":"claudeqq-refresh-button"},n.loading?"刷新中":"刷新"),d(I1,{title:"ClaudeQQ 用户服务",data:f,onOpen:u,testId:"raw-claudeqq-service"}))},d("div",{className:"findjob-hero"},d("div",null,d("div",{className:"node-version-line"},d(d$,{status:w.providerStatus==="online"?"online":"warn"},w.providerStatus||"unknown"),d("span",null,f.providerId),d("span",null,q.public?"公网暴露":"仅 UniDesk frontend 代理访问")),d("p",{className:"muted paragraph"},f.description)),d("div",{className:"microservice-ref-card"},d("span",null,"Repo"),d("strong",null,Q.url||"--"),d("code",null,Q.commitId||"--")),d("div",{className:"microservice-ref-card"},d("span",null,"D601 k3s Service"),d("strong",null,`${q.nodeBindHost||"--"}:${q.nodePort||"--"}`),d("code",null,`${q.proxyMode||"--"} / ${Q.composeFile||"--"}`))),d(lu,{error:n.error,wide:!0})),d("div",{className:"metric-grid"},d(dt,{label:"Health",value:T.ok||T.status==="ok"?"OK":"--",hint:"D601 /health",tone:T.ok||T.status==="ok"?"ok":"warn"}),d(dt,{label:"NapCat HTTP",value:D.httpConnected||D.http?.connected?"OK":"离线",hint:`${D.httpHost||T.napcat?.httpHost||"--"}:${D.httpPort||T.napcat?.httpPort||"--"}`}),d(dt,{label:"NapCat WS",value:D.wsConnected||D.ws?.connected?"OK":"离线",hint:`${D.wsHost||T.napcat?.wsHost||"--"}:${D.wsPort||T.napcat?.wsPort||"--"}`}),d(dt,{label:"事件缓存",value:e4(n.events?.count??V.length),hint:"recent QQ events"}),d(dt,{label:"订阅",value:e4(n.subscriptions?.count??B.length),hint:"webhook subscribers"}),d(dt,{label:"已发送",value:e4(n.sent?.count??m.length),hint:"sent message log"})),d("div",{className:"findjob-grid"},d(et,{title:"NapCat 容器登录",eyebrow:"QR Login",className:"claudeqq-login-panel",loading:n.qrLoading,actions:d("div",{className:"panel-actions inline-actions"},d("button",{type:"button",className:"ghost-btn",onClick:()=>N(!0),disabled:n.qrLoading,"data-testid":"claudeqq-napcat-refresh"},n.qrLoading?"刷新中":"手动刷新二维码"),d(I1,{title:"NapCat Login",data:n.napcatLogin,onOpen:u,testId:"raw-claudeqq-napcat-login"}))},d("div",{className:"claudeqq-login-card","data-testid":"claudeqq-napcat-login"},d("div",{className:"claudeqq-qr-frame"},b?d("img",{src:p.dataUrl,alt:"NapCat QQ 登录二维码","data-testid":"claudeqq-napcat-qrcode"}):d(a1,{title:"等待二维码",text:"NapCat 容器启动后会把登录二维码写入 cache/qrcode.png"})),d("div",{className:"claudeqq-login-copy"},d("div",{className:"node-version-line"},d(d$,{status:X?"online":b?"warn":"unknown"},X?"已登录":b?"待扫码":"等待二维码"),d("span",null,S),d("span",null,"D601 containerized")),d("p",{className:"muted paragraph"},X?"NapCat 已登录,ClaudeQQ 可通过容器内 HTTP/WS 链路收发 QQ 消息。":"用手机 QQ 扫描二维码授权登录。二维码只在首次加载或手动刷新时更新,D601 的 NapCat 端口仍只绑定 127.0.0.1。"),d("div",{className:"microservice-ref-card"},d("span",null,"NapCat WebUI"),d("strong",null,D.webui?.url||"http://napcat:6099/webui"),d("code",null,"local-only / proxied QR login")),d("div",{className:"microservice-ref-card"},d("span",null,"QR Source"),d("strong",null,p.modifiedAt?Wl(p.modifiedAt):n.qrcodeRefreshedAt?Wl(n.qrcodeRefreshedAt):"--"),d("code",null,p.file||"/napcat/cache/qrcode.png"))))),d(et,{title:"消息推送",eyebrow:"Push API"},d("div",{className:"microservice-ref-card"},d("span",null,B0.label),d("strong",null,String(B0.userId)),d("code",null,"private userId / 默认推送测试目标")),d("form",{className:"stack-form",onSubmit:W,"data-testid":"claudeqq-push-form"},d("label",null,"目标类型",d("select",{value:t.targetType,onChange:(z)=>y((P)=>({...P,targetType:z.target.value}))},d("option",{value:"private"},"私聊 userId"),d("option",{value:"group"},"群 groupId"))),d("label",null,"QQ ID",d("input",{value:t.targetId,onChange:(z)=>y((P)=>({...P,targetId:z.target.value})),placeholder:String(B0.userId)})),d("label",null,"消息内容",d("textarea",{value:t.message,onChange:(z)=>y((P)=>({...P,message:z.target.value})),rows:4,placeholder:"通过 ClaudeQQ 推送一条 QQ 消息"})),d("button",{type:"submit",className:"primary-btn"},"发送 QQ 消息")),d("p",{className:"muted paragraph"},`主 server 和其他用户服务可通过 UniDesk 同源代理调用 /api/push/text;当前人工推送测试默认使用 ${B0.label} ${B0.userId},不需要暴露 D601 后端端口。`)),d(et,{title:"QQ 事件订阅",eyebrow:"Webhook Subscription",loading:n.loading},d("form",{className:"stack-form",onSubmit:L,"data-testid":"claudeqq-subscription-form"},d("label",null,"订阅名称",d("input",{value:c.name,onChange:(z)=>$((P)=>({...P,name:z.target.value}))})),d("label",null,"回调 URL",d("input",{value:c.targetUrl,onChange:(z)=>$((P)=>({...P,targetUrl:z.target.value})),placeholder:"http://host.docker.internal:18080/..."})),d("label",null,"事件类型",d("input",{value:c.eventTypes,onChange:(z)=>$((P)=>({...P,eventTypes:z.target.value})),placeholder:"message,notice"})),d("label",null,"签名密钥",d("input",{value:c.secret,onChange:(z)=>$((P)=>({...P,secret:z.target.value})),placeholder:"可选,生成 x-claudeqq-signature"})),d("button",{type:"submit",className:"primary-btn"},"创建订阅")),B.length===0?d(a1,{title:"暂无订阅",text:"可以为 main server 或其他用户服务注册 HTTP webhook"}):d("div",{className:"table-wrap","data-testid":"claudeqq-subscription-table"},d("table",null,d("thead",null,d("tr",null,d("th",null,"名称"),d("th",null,"状态"),d("th",null,"事件"),d("th",null,"回调"),d("th",null,"最近投递"),d("th",null,"操作"))),d("tbody",null,B.map((z)=>d("tr",{key:z.id},d("td",null,d("strong",null,z.name||z.id),d("code",null,z.id||"--")),d("td",null,d(d$,{status:z.enabled?"online":"warn"},z.enabled?"enabled":"disabled")),d("td",null,Array.isArray(z.eventTypes)?z.eventTypes.join(", "):"message"),d("td",null,z.targetUrl||"--"),d("td",null,z.lastDelivery?`${z.lastDelivery.ok?"OK":"FAIL"} ${Wl(z.lastDelivery.at)}`:"--"),d("td",null,d("button",{type:"button",className:"ghost-btn",onClick:()=>J(z.id)},"删除"))))))),d("div",{className:"panel-actions inline-actions"},d(I1,{title:"ClaudeQQ Subscriptions",data:n.subscriptions,onOpen:u,testId:"raw-claudeqq-subscriptions"}))),d(et,{title:"最近 QQ 事件",eyebrow:n.refreshedAt?`Updated ${iu(n.refreshedAt)}`:"Event Stream",loading:n.loading},V.length===0?d(a1,{title:"暂无事件",text:"等待 NapCat WebSocket 上报 QQ 消息事件,或通过订阅 API 消费后续事件"}):d("div",{className:"table-wrap","data-testid":"claudeqq-event-list"},d("table",null,d("thead",null,d("tr",null,d("th",null,"时间"),d("th",null,"类型"),d("th",null,"会话"),d("th",null,"消息"),d("th",null,"ID"))),d("tbody",null,V.map((z)=>d("tr",{key:z.id},d("td",null,Wl(z.receivedAt||z.timestamp)),d("td",null,d(d$,{status:z.postType||z.eventType},z.postType||z.eventType||"--")),d("td",null,rN(z)),d("td",null,uN(z)),d("td",null,d("code",null,z.messageId||z.id||"--"))))))),d("div",{className:"panel-actions inline-actions"},d(I1,{title:"ClaudeQQ Events",data:n.events,onOpen:u,testId:"raw-claudeqq-events"}))),d(et,{title:"已发送消息",eyebrow:`${m.length} Sent`,loading:n.loading},m.length===0?d(a1,{title:"暂无发送记录",text:"发送日志来自 ClaudeQQ bot_workspace/messages/sent_messages.jsonl"}):d("div",{className:"table-wrap"},d("table",null,d("thead",null,d("tr",null,d("th",null,"时间"),d("th",null,"目标"),d("th",null,"消息"),d("th",null,"结果"))),d("tbody",null,m.map((z,P)=>d("tr",{key:z.id||P},d("td",null,Wl(z.timestamp||z.sentAt||z.createdAt)),d("td",null,rN(z)),d("td",null,uN(z)),d("td",null,z.status||z.messageId||z.message_id||"--")))))),d("div",{className:"panel-actions inline-actions"},d(I1,{title:"ClaudeQQ Sent Messages",data:n.sent,onOpen:u,testId:"raw-claudeqq-sent"})))))}var yc=Rl(Ju(),1);var tN=Rl(Ju(),1),qu=tN.default.createElement;function d1({markdown:l,className:u,testId:r}){let f=String(l??"").trimEnd(),n=["markdown-body",u].filter(Boolean).join(" ");return qu("div",{className:n,"data-testid":r},yN(f,"md"))}function yN(l,u){let r=Lz(l).split(` +`),f=[],n=0;while(n<r.length){let i=r[n]??"";if(i.trim().length===0){n+=1;continue}let t=cN(i);if(t!==null){let j=[];n+=1;while(n<r.length&&!Gz(r[n]??"",t))j.push(r[n]??""),n+=1;if(n<r.length)n+=1;f.push(nN(j.join(` +`),t.language,`${u}-fence-${n}`));continue}if(l2(i)){let j=[];while(n<r.length&&(l2(r[n]??"")||(r[n]??"").trim().length===0)){let F=r[n]??"";j.push(F.replace(/^(?: {4}|\t)/u,"")),n+=1}f.push(nN(j.join(` +`).trimEnd(),"",`${u}-indent-${n}`));continue}let y=i.match(/^(#{1,6})\s+(.+)$/u);if(y!==null){let j=y[1].length,F=`h${Math.min(6,j+2)}`;f.push(qu(F,{key:`${u}-heading-${n}`},Un(y[2].trim(),`${u}-heading-${n}`))),n+=1;continue}if(/^\s*(?:---+|\*\*\*+|___+)\s*$/u.test(i)){f.push(qu("hr",{key:`${u}-hr-${n}`})),n+=1;continue}if(/^\s*>\s?/u.test(i)){let j=[];while(n<r.length){let F=r[n]??"",U=F.match(/^\s*>\s?(.*)$/u);if(U!==null){j.push(U[1]),n+=1;continue}if(F.trim().length===0){j.push(""),n+=1;continue}break}f.push(qu("blockquote",{key:`${u}-quote-${n}`},yN(j.join(` +`),`${u}-quote-${n}`)));continue}if(_N(r,n)){let j=n,F=o1(r[n]??""),U=o1(r[n+1]??"");n+=2;let N=[];while(n<r.length&&(r[n]??"").includes("|")&&(r[n]??"").trim().length>0)N.push(o1(r[n]??"")),n+=1;f.push(zz(F,U,N,`${u}-table-${j}`));continue}let c=u3(i);if(c!==null){let j=n,F=c.ordered,U=c.start,N=[];while(n<r.length){let L=u3(r[n]??"");if(L===null||L.ordered!==F)break;let J=[L.text];n+=1;while(n<r.length){let w=r[n]??"";if(w.trim().length===0)break;if(u3(w)!==null)break;if(!/^\s{2,}/u.test(w))break;J.push(w.replace(/^\s{2,4}/u,"")),n+=1}N.push(J.join(` +`).trimEnd())}let W={key:`${u}-list-${j}`};if(F&&U!==void 0&&U!==1)W.start=U;f.push(qu(F?"ol":"ul",W,N.map((L,J)=>mz(L,`${u}-list-${j}-${J}`))));continue}let $=n,A=[];while(n<r.length&&r[n]!==void 0&&r[n].trim().length>0&&!Tz(r,n))A.push(r[n].trim()),n+=1;if(A.length===0)A.push(i.trim()),n+=1;f.push(qu("p",{key:`${u}-p-${$}`},Un(A.join(` +`),`${u}-p-${$}`)))}return f}function Lz(l){return String(l||"").replace(/\r\n/gu,` `).replace(/\r/gu,` -`).trimEnd()}function kJ(u){let l=u.match(/^\s*(```+|~~~+)\s*([A-Za-z0-9_-]+)?\s*$/u);if(l===null)return null;let f=l[1];return{marker:f.startsWith("`")?"`":"~",length:f.length,language:l[2]||""}}function ez(u,l){let f=u.trim();return f.length>=l.length&&f.split("").every((r)=>r===l.marker)}function M4(u){return/^(?: {4}|\t)/u.test(u)}function RJ(u,l,f){let r=l.trim().length>0?`language-${iE(l)}`:void 0;return ql("pre",{key:f,className:"markdown-code-block"},ql("code",{className:r},u))}function uE(u,l){let f=u[l]??"";if(f.trim().length===0)return!0;return kJ(f)!==null||M4(f)||/^(#{1,6})\s+.+$/u.test(f)||/^\s*(?:---+|\*\*\*+|___+)\s*$/u.test(f)||/^\s*>\s?/u.test(f)||IJ(u,l)||k$(f)!==null}function k$(u){let l=u.match(/^\s{0,3}[-*+]\s+(.+)$/u);if(l!==null)return{ordered:!1,text:l[1]};let f=u.match(/^\s{0,3}(\d+)[.)]\s+(.+)$/u);if(f!==null)return{ordered:!0,start:Number(f[1]),text:f[2]};return null}function lE(u,l){let f=u.match(/^\[([ xX])\]\s+(.+)$/u);if(f!==null){let r=f[1].toLowerCase()==="x";return ql("li",{key:l,className:"task-list-item"},ql("input",{type:"checkbox",checked:r,readOnly:!0,tabIndex:-1}),ql("span",null,Fn(f[2],`${l}-task`)))}return ql("li",{key:l},Fn(u,l))}function IJ(u,l){let f=u[l]??"",r=u[l+1]??"";if(!f.includes("|")||!r.includes("|"))return!1;let n=b1(f),i=b1(r);return n.length>1&&i.length===n.length&&i.every((t)=>/^:?-{3,}:?$/u.test(t.trim()))}function b1(u){let l=u.trim();if(l.startsWith("|"))l=l.slice(1);if(l.endsWith("|"))l=l.slice(0,-1);return l.split("|").map((f)=>f.trim())}function fE(u){let l=u.trim();if(l.startsWith(":")&&l.endsWith(":"))return"center";if(l.endsWith(":"))return"right";if(l.startsWith(":"))return"left";return}function rE(u,l,f,r){let n=l.map(fE);return ql("div",{key:r,className:"markdown-table-wrap"},ql("table",null,ql("thead",null,ql("tr",null,u.map((i,t)=>ql("th",{key:`${r}-h-${t}`,style:n[t]?{textAlign:n[t]}:void 0},Fn(i,`${r}-h-${t}`))))),ql("tbody",null,f.map((i,t)=>ql("tr",{key:`${r}-r-${t}`},u.map((y,c)=>ql("td",{key:`${r}-r-${t}-${c}`,style:n[c]?{textAlign:n[c]}:void 0},Fn(i[c]||"",`${r}-r-${t}-${c}`))))))))}function Fn(u,l,f={}){let r=[],n=/`([^`\n]+)`|\[([^\]\n]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<>)]+)|\*\*([^*\n]+)\*\*|__([^_\n]+)__|~~([^~\n]+)~~|\*([^*\n]+)\*|_([^_\n]+)_/gu,i=f.linkify!==!1,t=0,y=0;for(let c of u.matchAll(n)){let $=c[0],A=c.index??0;v$(r,u.slice(t,A),`${l}-text-${y}`),t=A+$.length;let j=`${l}-inline-${y}`;if(y+=1,c[1]!==void 0){r.push(ql("code",{key:j},c[1]));continue}if(c[2]!==void 0&&c[3]!==void 0){if(!i){v$(r,$,`${j}-literal`);continue}r.push(xJ(c[2],c[3],j));continue}if(c[4]!==void 0){if(!i){v$(r,$,`${j}-literal`);continue}r.push(xJ(c[4],c[4],j));continue}let F=c[5]??c[6];if(F!==void 0){r.push(ql("strong",{key:j},Fn(F,`${j}-strong`)));continue}if(c[7]!==void 0){r.push(ql("del",{key:j},Fn(c[7],`${j}-del`)));continue}let J=c[8]??c[9];if(J!==void 0)r.push(ql("em",{key:j},Fn(J,`${j}-em`)))}return v$(r,u.slice(t),`${l}-text-tail`),r}function v$(u,l,f){if(l.length===0)return;l.split(` -`).forEach((n,i)=>{if(i>0)u.push(ql("br",{key:`${f}-br-${i}`}));if(n.length>0)u.push(n)})}function xJ(u,l,f){let r=nE(l);if(r===null)return ql("span",{key:f},u);let n=/^(?:https?:|mailto:)/iu.test(r);return ql("a",{key:f,href:r,target:n?"_blank":void 0,rel:n?"noreferrer":void 0},Fn(u,`${f}-label`,{linkify:!1}))}function nE(u){let l=String(u||"").trim();if(/^(?:https?:|mailto:)/iu.test(l))return l;if(l.startsWith("/")&&!l.startsWith("//"))return l;if(l.startsWith("#"))return l;return null}function iE(u){return String(u||"").toLowerCase().replace(/[^a-z0-9_-]+/gu,"-").replace(/^-+|-+$/gu,"")||"text"}var k4=Cu(Jl(),1);var Su=k4.default.createElement,{useEffect:tE,useRef:gJ}=k4.default;function yE(u,l){return $Q(u.toTrace(l))}function cE(u){let l=Number(u);if(!Number.isFinite(l)||l<0)return"--";let f=Math.floor(l/1000),r=Math.floor(f/3600),n=Math.floor(f%3600/60),i=f%60;if(r>0)return`${r}h ${String(n).padStart(2,"0")}m`;if(n>0)return`${n}m ${String(i).padStart(2,"0")}s`;return`${i}s`}function gr(u){let l=Number(u);return Number.isFinite(l)&&l>=0?l:null}function at(u,l=180){let f=String(u||"").replace(/\s+/gu," ").trim();return f.length>l?`${f.slice(0,l-1)}…`:f}function _E(u){if(!u)return 0;return u.split(/\r?\n/u).length}function h4(u){return{ran:"Ran",explored:"Explored",edited:"Edited",toolGroup:"Tool calls",plan:"Plan",message:"Message",system:"System",error:"Error"}[u]||"Message"}function b4(u){let l=Number(u||0);return Number.isFinite(l)&&l>0?`… +${Math.floor(l)} lines`:""}function $E(u){return(Array.isArray(u)?u:[]).reduce((l,f)=>Math.max(l,Number(f?.seq??0)),0)}function sJ(u){return["explored","edited","ran"].includes(String(u?.kind||""))}function rQ(u){let l={read:0,edit:0,run:0};for(let f of u){let r=String(f?.kind||"");if(r==="explored")l.read+=1;else if(r==="edited")l.edit+=1;else if(r==="ran")l.run+=1}return l}function nQ(u){let l=rQ(u);return`${l.read} read, ${l.edit} edit, ${l.run} run`}function iQ(u){return u.replace(/^['"`([{<]+/u,"").replace(/['"`)\]}>.,;:]+$/u,"").replace(/:\d+(?::\d+)?$/u,"").trim()}function aJ(u){let f=String(u||"").match(/(?:~|\.{1,2}|\/)?(?:[A-Za-z0-9_.@+-]+\/)+[A-Za-z0-9_.@+-]+|[A-Za-z0-9_.@+-]+\.(?:c|cc|cpp|h|hpp|js|jsx|ts|tsx|json|md|py|sh|toml|ya?ml|txt|log|lock)/gu)||[],r=[];for(let n of f){let i=iQ(n);if(i.length<2||i.includes("..."))continue;if(/^(http|https|status|method)$/iu.test(i))continue;if(!r.includes(i))r.push(i)}return r}function R4(u,l=4){if(u.length===0)return"--";let f=u.slice(0,l).join(", ");return u.length>l?`${f} +${u.length-l}`:f}function oJ(u){let l="";for(let f of u){if(f.length===0)continue;if(l.length>0&&!l.endsWith(` -`)&&!f.startsWith(` -`))l+=` -`;l+=f}return l}function tQ(u){let l=String(u||"").replace(/\r\n/gu,` +`).trimEnd()}function cN(l){let u=l.match(/^\s*(```+|~~~+)\s*([A-Za-z0-9_-]+)?\s*$/u);if(u===null)return null;let r=u[1];return{marker:r.startsWith("`")?"`":"~",length:r.length,language:u[2]||""}}function Gz(l,u){let r=l.trim();return r.length>=u.length&&r.split("").every((f)=>f===u.marker)}function l2(l){return/^(?: {4}|\t)/u.test(l)}function nN(l,u,r){let f=u.trim().length>0?`language-${Oz(u)}`:void 0;return qu("pre",{key:r,className:"markdown-code-block"},qu("code",{className:f},l))}function Tz(l,u){let r=l[u]??"";if(r.trim().length===0)return!0;return cN(r)!==null||l2(r)||/^(#{1,6})\s+.+$/u.test(r)||/^\s*(?:---+|\*\*\*+|___+)\s*$/u.test(r)||/^\s*>\s?/u.test(r)||_N(l,u)||u3(r)!==null}function u3(l){let u=l.match(/^\s{0,3}[-*+]\s+(.+)$/u);if(u!==null)return{ordered:!1,text:u[1]};let r=l.match(/^\s{0,3}(\d+)[.)]\s+(.+)$/u);if(r!==null)return{ordered:!0,start:Number(r[1]),text:r[2]};return null}function mz(l,u){let r=l.match(/^\[([ xX])\]\s+(.+)$/u);if(r!==null){let f=r[1].toLowerCase()==="x";return qu("li",{key:u,className:"task-list-item"},qu("input",{type:"checkbox",checked:f,readOnly:!0,tabIndex:-1}),qu("span",null,Un(r[2],`${u}-task`)))}return qu("li",{key:u},Un(l,u))}function _N(l,u){let r=l[u]??"",f=l[u+1]??"";if(!r.includes("|")||!f.includes("|"))return!1;let n=o1(r),i=o1(f);return n.length>1&&i.length===n.length&&i.every((t)=>/^:?-{3,}:?$/u.test(t.trim()))}function o1(l){let u=l.trim();if(u.startsWith("|"))u=u.slice(1);if(u.endsWith("|"))u=u.slice(0,-1);return u.split("|").map((r)=>r.trim())}function Kz(l){let u=l.trim();if(u.startsWith(":")&&u.endsWith(":"))return"center";if(u.endsWith(":"))return"right";if(u.startsWith(":"))return"left";return}function zz(l,u,r,f){let n=u.map(Kz);return qu("div",{key:f,className:"markdown-table-wrap"},qu("table",null,qu("thead",null,qu("tr",null,l.map((i,t)=>qu("th",{key:`${f}-h-${t}`,style:n[t]?{textAlign:n[t]}:void 0},Un(i,`${f}-h-${t}`))))),qu("tbody",null,r.map((i,t)=>qu("tr",{key:`${f}-r-${t}`},l.map((y,c)=>qu("td",{key:`${f}-r-${t}-${c}`,style:n[c]?{textAlign:n[c]}:void 0},Un(i[c]||"",`${f}-r-${t}-${c}`))))))))}function Un(l,u,r={}){let f=[],n=/`([^`\n]+)`|\[([^\]\n]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<>)]+)|\*\*([^*\n]+)\*\*|__([^_\n]+)__|~~([^~\n]+)~~|\*([^*\n]+)\*|_([^_\n]+)_/gu,i=r.linkify!==!1,t=0,y=0;for(let c of l.matchAll(n)){let $=c[0],A=c.index??0;l3(f,l.slice(t,A),`${u}-text-${y}`),t=A+$.length;let j=`${u}-inline-${y}`;if(y+=1,c[1]!==void 0){f.push(qu("code",{key:j},c[1]));continue}if(c[2]!==void 0&&c[3]!==void 0){if(!i){l3(f,$,`${j}-literal`);continue}f.push(iN(c[2],c[3],j));continue}if(c[4]!==void 0){if(!i){l3(f,$,`${j}-literal`);continue}f.push(iN(c[4],c[4],j));continue}let F=c[5]??c[6];if(F!==void 0){f.push(qu("strong",{key:j},Un(F,`${j}-strong`)));continue}if(c[7]!==void 0){f.push(qu("del",{key:j},Un(c[7],`${j}-del`)));continue}let U=c[8]??c[9];if(U!==void 0)f.push(qu("em",{key:j},Un(U,`${j}-em`)))}return l3(f,l.slice(t),`${u}-text-tail`),f}function l3(l,u,r){if(u.length===0)return;u.split(` +`).forEach((n,i)=>{if(i>0)l.push(qu("br",{key:`${r}-br-${i}`}));if(n.length>0)l.push(n)})}function iN(l,u,r){let f=Ez(u);if(f===null)return qu("span",{key:r},l);let n=/^(?:https?:|mailto:)/iu.test(f);return qu("a",{key:r,href:f,target:n?"_blank":void 0,rel:n?"noreferrer":void 0},Un(l,`${r}-label`,{linkify:!1}))}function Ez(l){let u=String(l||"").trim();if(/^(?:https?:|mailto:)/iu.test(u))return u;if(u.startsWith("/")&&!u.startsWith("//"))return u;if(u.startsWith("#"))return u;return null}function Oz(l){return String(l||"").toLowerCase().replace(/[^a-z0-9_-]+/gu,"-").replace(/^-+|-+$/gu,"")||"text"}var t2=Rl(Ju(),1);var Pl=t2.default.createElement,{useEffect:Zz,useRef:$N}=t2.default;function pz(l,u){return zN(l.toTrace(u))}function Hz(l){let u=Number(l);if(!Number.isFinite(u)||u<0)return"--";let r=Math.floor(u/1000),f=Math.floor(r/3600),n=Math.floor(r%3600/60),i=r%60;if(f>0)return`${f}h ${String(n).padStart(2,"0")}m`;if(n>0)return`${n}m ${String(i).padStart(2,"0")}s`;return`${i}s`}function If(l){let u=Number(l);return Number.isFinite(u)&&u>=0?u:null}function uy(l,u=180){let r=String(l||"").replace(/\s+/gu," ").trim();return r.length>u?`${r.slice(0,u-1)}…`:r}function Bz(l){if(!l)return 0;return l.split(/\r?\n/u).length}function f2(l){return{ran:"Ran",explored:"Explored",edited:"Edited",toolGroup:"Tool calls",plan:"Plan",message:"Message",system:"System",error:"Error"}[l]||"Message"}function n2(l){let u=Number(l||0);return Number.isFinite(u)&&u>0?`… +${Math.floor(u)} lines`:""}function Dz(l){return(Array.isArray(l)?l:[]).reduce((u,r)=>Math.max(u,Number(r?.seq??0)),0)}function AN(l){return["explored","edited","ran"].includes(String(l?.kind||""))}function qN(l){let u={read:0,edit:0,run:0};for(let r of l){let f=String(r?.kind||"");if(f==="explored")u.read+=1;else if(f==="edited")u.edit+=1;else if(f==="ran")u.run+=1}return u}function WN(l){let u=qN(l);return`${u.read} read, ${u.edit} edit, ${u.run} run`}function LN(l){return l.replace(/^['"`([{<]+/u,"").replace(/['"`)\]}>.,;:]+$/u,"").replace(/:\d+(?::\d+)?$/u,"").trim()}function jN(l){let r=String(l||"").match(/(?:~|\.{1,2}|\/)?(?:[A-Za-z0-9_.@+-]+\/)+[A-Za-z0-9_.@+-]+|[A-Za-z0-9_.@+-]+\.(?:c|cc|cpp|h|hpp|js|jsx|ts|tsx|json|md|py|sh|toml|ya?ml|txt|log|lock)/gu)||[],f=[];for(let n of r){let i=LN(n);if(i.length<2||i.includes("..."))continue;if(/^(http|https|status|method)$/iu.test(i))continue;if(!f.includes(i))f.push(i)}return f}function u2(l,u=4){if(l.length===0)return"--";let r=l.slice(0,u).join(", ");return l.length>u?`${r} +${l.length-u}`:r}function FN(l){let u="";for(let r of l){if(r.length===0)continue;if(u.length>0&&!u.endsWith(` +`)&&!r.startsWith(` +`))u+=` +`;u+=r}return u}function GN(l){let u=String(l||"").replace(/\r\n/gu,` `).replace(/\r/gu,` -`).trimEnd();return l.length>0?l.split(` -`):[]}function v4(u){let l=String(u.status||"").trim();if(l.length>0)return l;let f=String(u.bodyPreview||"");return/^(item\/[A-Za-z]+(?:\/[A-Za-z]+)?):/u.exec(f)?.[1]||"item/fileChange"}function AE(u){let l=String(u.bodyPreview||"");return/file changes status=([A-Za-z0-9_-]+)/u.exec(l)?.[1]}function jE(u){return/^item\/(?:started|completed): file changes status=/u.test(String(u||"").trim())}function yQ(u){if(String(u.kind||"")!=="edited")return!1;let l=String(u.status||""),f=String(u.title||""),r=String(u.bodyPreview||""),n=String(u.commandPreview||"");if(f==="Edited files")return!0;if(/^item\/fileChange\//u.test(l))return!0;if((l==="item/started"||l==="item/completed")&&/file changes status=/u.test(r))return!0;if(/^Success\. Updated the following files:/mu.test(r))return!0;if(/^diff --git /mu.test(r))return!0;return/^([AMDRCU?]{1,2})\s+\S+/mu.test(r)||n.length>0&&g$(r).length>0}function st(u){return iQ(String(u||"").replace(/^[ab]\//u,"").trim())}function I4(u){let l=/^([AMDRCU?]{1,2})\s+(.+)$/u.exec(u);if(!l)return null;let f=st(l[2]||"");return f.length>0?{status:l[1]||"M",path:f}:null}function g4(u){let l=/^\*\*\*\s+(Add|Update|Delete)\s+File:\s+(.+)$/u.exec(u);if(l){let r=l[1]==="Add"?"A":l[1]==="Delete"?"D":"M",n=st(l[2]||"");return n.length>0?{status:r,path:n}:null}let f=/^\*\*\*\s+Move to:\s+(.+)$/u.exec(u);if(f){let r=st(f[1]||"");return r.length>0?{status:"R",path:r}:null}return null}function g$(u){let l=[],f=(n,i)=>{let t=st(i);if(t.length===0||t==="/dev/null")return;let y=l.find((c)=>c.path===t);if(y){if(y.status==="M"&&n!=="M")y.status=n;return}l.push({status:n,path:t})},r="";for(let n of tQ(u)){let i=I4(n)||g4(n);if(i!==null){f(i.status,i.path),r=i.path;continue}let t=/^diff --git a\/(.+?) b\/(.+)$/u.exec(n);if(t){let j=t[2]||t[1]||"";f("M",j),r=st(j);continue}let y=/^\+\+\+ b\/(.+)$/u.exec(n);if(y&&y[1]!=="/dev/null"){f("M",y[1]||""),r=st(y[1]||"");continue}if(/^new file mode /u.exec(n)&&r)f("A",r);if(/^deleted file mode /u.exec(n)&&r)f("D",r);let A=/^rename to (.+)$/u.exec(n);if(A)f("R",A[1]||"")}return l}function FE(u){if(I4(u)!==null||g4(u)!==null)return"file";if(/^(diff --git |index |--- |\+\+\+ |\*\*\* Begin Patch|\*\*\* End Patch)/u.test(u))return"meta";if(/^@@ /u.test(u))return"hunk";if(/^\+/u.test(u))return"add";if(/^-/u.test(u))return"del";if(/^(Success\.|No changes|Updated\b|Created\b|Deleted\b|Added\s+\d+\s+lines?|Wrote\s+\d+\s+lines?|Read\s+\d+\s+files?|\.\.\.\[patch content truncated)/iu.test(u))return"note";return"context"}function s4(u){return tQ(u).map((l)=>{let f=I4(l)||g4(l);if(f!==null)return{text:l,kind:"file",path:f.path,status:f.status};return{text:l,kind:FE(l)}})}function UE(u){return u.reduce((l,f)=>{if(f.kind==="add")l.added+=1;else if(f.kind==="del")l.removed+=1;return l},{added:0,removed:0})}function dJ(u,l){return`${l} ${u} line${u===1?"":"s"}`}function JE(u,l){let f=[];if(u>0)f.push(dJ(u,"Added"));if(l>0)f.push(dJ(l,"removed"));return f.join(", ")}function QE(u){for(let f=u.length-1;f>=0;f-=1){let r=String(u[f]?.status||"").trim();if(r.length>0)return r}let l=String(u[u.length-1]?.method||"").trim();if(l==="item/fileChange/outputDelta")return"updated";if(l==="item/started")return"started";if(l==="item/completed")return"completed";return l.replace(/^item\//u,"")||"changed"}function NE(u){return`${u} file${u===1?"":"s"}`}function cQ(u){let l=u.length>0?u:[],f=oJ(l.map((F)=>String(F.bodyPreview||""))),n=oJ(l.map((F)=>String(F.bodyPreview||"")).filter((F)=>F.trim().length>0&&!jE(F)))||f,i=g$(n||f),t=l.map((F)=>({method:v4(F),status:AE(F),at:F.at})),y=s4(n||f),c=UE(y),$=JE(c.added,c.removed),A=i.length>0?NE(i.length):"",j=$.length>0?`${$}${A?` in ${A}`:""}`:i.length>0?A:at(n||f||"File changes",72);return{status:QE(t),summary:j,files:i,stages:t,lines:y,addedLines:c.added,removedLines:c.removed,rawText:f}}function qE(u){let l=u[0],f=u[u.length-1]||l,r=cQ(u);return{...l,seq:Number.isFinite(Number(f?.seq))?Number(f?.seq):Number(l?.seq??0),at:f?.at||l?.at,title:r.files.length>0?`Edited ${r.summary}`:"Edited files",status:r.status,commandPreview:"",commandOmittedLines:void 0,bodyPreview:r.rawText,bodyOmittedLines:u.reduce((n,i)=>n+Number(i.bodyOmittedLines||0),0)||void 0,rawSeqs:u.flatMap((n)=>Array.isArray(n?.rawSeqs)?n.rawSeqs:[n?.seq]).filter((n)=>n!==void 0),editObservation:r}}function wE(u){let l=Array.isArray(u)?u:[],f=[],r=[],n=()=>{if(r.length===0)return;f.push(qE(r)),r=[]};for(let i of l){if(yQ(i)){if(v4(i)==="item/started"&&r.length>0)n();if(r.push(i),v4(i)==="item/completed")n();continue}n(),f.push(i)}return n(),f}function _Q(u){let l=[],f=[],r=[],n=($,A)=>{for(let j of A)if(!$.includes(j))$.push(j)};for(let $ of u){let A=String($?.kind||""),j=[$?.commandPreview,$?.bodyPreview,$?.title].map((F)=>String(F||"")).join(` -`);if(A==="explored")n(l,aJ(j));else if(A==="edited")n(f,aJ(j));else if(A==="ran"){let F=String($?.commandPreview||$?.title||"").trim();if(F.length>0&&!r.includes(F))r.push(at(F,90))}}let i=u.map(($)=>Date.parse(String($?.at||""))).filter(($)=>Number.isFinite($)),t=i.length>=2?Math.max(0,Math.max(...i)-Math.min(...i)):0,y=u.reduce(($,A)=>$+(gr(A?.durationMs)??gr(A?.elapsedMs)??0),0),c=t>0?t:y;return{readFiles:l,editedFiles:f,runCommands:r,durationLabel:cE(c)}}function WE(u,l=3){let f=Array.isArray(u)?u:[],r=[],n=[],i=Math.max(0,l),t=new Set;for(let c=f.length-1;c>=0&&i>0;c-=1){let $=f[c];if(!sJ($))continue;t.add($),i-=1}let y=()=>{if(n.length>=2){let c=rQ(n);r.push({seq:Number(n[0]?.seq??0),at:n[0]?.at||n.at(-1)?.at,kind:"toolGroup",title:nQ(n),status:`${n.length} calls`,items:n,counts:c,digest:_Q(n),rawSeqs:n.flatMap(($)=>Array.isArray($?.rawSeqs)?$.rawSeqs:[$?.seq]).filter(($)=>$!==void 0)})}else r.push(...n);n=[]};for(let c of f){if(sJ(c)&&!t.has(c)){n.push(c);continue}y(),r.push(c)}return y(),r}function $Q(u){return(Array.isArray(u)?u:[]).map((l,f)=>({...l,seq:Number.isFinite(Number(l?.seq))?Number(l.seq):f+1,kind:String(l?.kind||"message"),at:l?.at===void 0?void 0:String(l.at),durationMs:gr(l?.durationMs)??void 0,title:l?.title===void 0?void 0:String(l.title),status:l?.status===void 0?void 0:String(l.status)}))}function v1(u){let l=gr(u?.state?.time?.start)??gr(u?.time?.start),f=gr(u?.state?.time?.end)??gr(u?.time?.end);return gr(u?.durationMs)??gr(u?.elapsedMs)??gr(u?.timing?.durationMs)??gr(u?.metadata?.durationMs)??(l!==null&&f!==null&&f>=l?f-l:null)??void 0}function k1(u,l){return u?.createdAt||u?.updatedAt||u?.completedAt||l||void 0}function x4(u,l){return u?.id||u?.messageId||l}function LE(u,l=1200){if(typeof u==="string")return u;if(u===void 0||u===null)return"";try{return at(JSON.stringify(u),l)}catch{return at(String(u),l)}}function AQ(u,l,f){if(typeof u?.metadata?.diff==="string"&&u.metadata.diff.length>0)return u.metadata.diff;if(typeof u?.metadata?.filediff?.patch==="string"&&u.metadata.filediff.patch.length>0)return u.metadata.filediff.patch;if(typeof u?.output==="string"&&u.output.length>0)return u.output;if(typeof u?.result==="string"&&u.result.length>0)return u.result;if(typeof l?.output==="string"&&l.output.length>0)return l.output;if(typeof f?.output==="string"&&f.output.length>0)return f.output;if(typeof u?.metadata?.output==="string"&&u.metadata.output.length>0)return u.metadata.output;return""}function I$(u,l){if(!u||typeof u!=="object"||Array.isArray(u))return"";for(let f of l){let r=u[f];if(typeof r==="string"&&r.length>0)return r;if(r!==void 0&&r!==null&&typeof r!=="object")return String(r)}return""}function eJ(u,l){if(!u||typeof u!=="object"||Array.isArray(u))return null;for(let f of l){let r=Number(u[f]);if(Number.isFinite(r))return r}return null}function jQ(u,l){let f=l?.input&&typeof l.input==="object"&&!Array.isArray(l.input)?l.input:u?.input&&typeof u.input==="object"&&!Array.isArray(u.input)?u.input:{},r=I$(f,["command","cmd","script"]);if(r.length>0)return r;if(typeof u?.command==="string"&&u.command.length>0)return u.command;if(typeof l?.command==="string"&&l.command.length>0)return l.command;let n=String(u?.tool||u?.title||"tool"),i=I$(f,["filePath","filepath","path"])||I$(u,["filePath","filepath","path"]),t=I$(f,["pattern","query"]),y=eJ(f,["offset"]),c=eJ(f,["limit"]),$=[n];if(t.length>0)$.push(t);if(i.length>0)$.push(i);if(y!==null)$.push(`offset=${y}`);if(c!==null)$.push(`limit=${c}`);return $.length>1?$.join(" "):n}function TE(u,l){let f=u?.part&&typeof u.part==="object"&&!Array.isArray(u.part)?u.part:{},r=String(u?.type||u?.event||u?.name||f?.type||"").toLowerCase(),n=String(f?.type||"").toLowerCase(),i=u?.at||u?.timestamp||f?.updatedAt||f?.createdAt,t=Number.isFinite(Number(u?.seq))?Number(u.seq):l;if(r==="step_start"||r==="step-start"||n==="step-start")return null;if(r==="step_finish"||r==="step-finish"||n==="step-finish")return null;if(n==="tool"||/tool|bash|command/iu.test(`${r} ${n}`)){let c=f?.state&&typeof f.state==="object"&&!Array.isArray(f.state)?f.state:{},$=jQ(f,c),A=AQ(c,f,u),j=FQ($,String(f?.tool||f?.title||"")),F=j==="edited"?{status:String(c?.status||f?.status||u?.status||""),summary:at(A||$,72),files:g$(A),stages:[],lines:s4(A),addedLines:0,removedLines:0,rawText:A}:void 0;return{seq:t,at:k1(f,i),kind:j,title:String(c?.title||f?.title||c?.metadata?.description||f?.tool||"OpenCode tool"),status:String(c?.status||f?.status||u?.status||""),commandPreview:$,bodyPreview:A,durationMs:v1(f),rawSeqs:[f?.id||f?.callID||u?.sessionID||t],editObservation:F}}let y=LE(f?.text??f?.content??f?.delta??u?.text??u?.content??u?.delta,3000).trim();if(y.length>0)return{seq:t,at:k1(f,i),kind:n==="reasoning"?"message":/error|failed/iu.test(`${r} ${n}`)?"error":"message",title:n==="reasoning"?"Reasoning":/error|failed/iu.test(`${r} ${n}`)?"OpenCode error":"Assistant message",status:`opencode/${r||n||"event"}`,bodyPreview:y,durationMs:v1(f),rawSeqs:[f?.id||u?.sessionID||t]};return null}function FQ(u,l){let f=`${l} ${u}`.toLowerCase();if(/\b(read|grep|glob|list|ls|find|search|view|cat|sed|rg|head|tail|wc|file)\b/iu.test(f))return"explored";if(/\b(edit|write|patch|apply|update|create|delete|apply_patch|git apply|cat >|tee .*<<|sed -i|python3? .*write_text|mkdir|rm |touch )\b/iu.test(f))return"edited";return"ran"}function KE(u){let l=[],f=1;for(let r of Array.isArray(u)?u:[]){if(r?.kind&&r?.title){let y=String(r?.status||"");if(y==="opencode/step-start"||y==="opencode/step-finish")continue;l.push({...r,seq:Number.isFinite(Number(r?.seq))?Number(r.seq):f++});continue}let n=r?.createdAt||r?.updatedAt||r?.completedAt,i=String(r?.role||"assistant").toLowerCase(),t=Array.isArray(r?.parts)?r.parts:[];if(t.length===0){if(r?.part&&(r?.sessionID||String(r?.type||"").startsWith("step_")||String(r?.type||"").includes("tool"))){let y=TE(r,f);if(y!==null)l.push(y),f=Math.max(f+1,Number(y.seq)+1)}else if(r?.textPreview)l.push({seq:f++,at:n,kind:"message",title:`${i||"assistant"} message`,status:i,bodyPreview:String(r.textPreview),rawSeqs:[r?.messageId||f]});continue}for(let y of t){let c=String(y?.type||"").toLowerCase();if(c==="step-start"||c==="step-finish")continue;if(c==="text"||c==="reasoning"){let A=String(y?.textPreview||r?.textPreview||"").trim();if(A.length===0)continue;l.push({seq:f++,at:k1(y,n),kind:"message",title:c==="reasoning"?"Reasoning":i==="user"?"User message":i==="system"?"System message":"Assistant message",status:c==="reasoning"?"reasoning":i,bodyPreview:A,durationMs:v1(y),rawSeqs:[x4(y,f)]});continue}if(c==="tool"){let A=y?.state&&typeof y.state==="object"&&!Array.isArray(y.state)?y.state:{},j=jQ(y,A),F=AQ(A,y,{}),J=FQ(j,String(y?.tool||y?.title||"")),Q=J==="edited"?{status:String(A?.status||y?.status||""),summary:at(F||j,72),files:g$(F),stages:[],lines:s4(F),addedLines:0,removedLines:0,rawText:F}:void 0;l.push({seq:f++,at:k1(y,n),kind:J,title:String(y?.title||y?.tool||"tool"),status:String(y?.status||""),commandPreview:j,bodyPreview:F,durationMs:v1(y),rawSeqs:[x4(y,f)],editObservation:Q});continue}let $=String(y?.textPreview||y?.title||c||"").trim();if($)l.push({seq:f++,at:k1(y,n),kind:"system",title:c||"part",bodyPreview:$,status:String(y?.status||""),durationMs:v1(y),rawSeqs:[x4(y,f)]})}}return l}var UQ={source:"opencode",toTrace:KE};function GE(u){return String(u||"unknown").toLowerCase().replace(/[^a-z0-9_-]+/gu,"-")||"unknown"}function uQ(u){let l=String(u||"M").toUpperCase();if(l.startsWith("A")||l==="??")return"added";if(l.startsWith("D"))return"deleted";if(l.startsWith("R"))return"renamed";return"modified"}function zE(u){if(u==="item/fileChange/outputDelta")return"delta";return u.replace(/^item\//u,"")}function EE(u,l){if(u.kind==="file"){let n=String(u.status||"M");return Su("div",{key:`${l}-${u.text}`,className:`codex-edit-diff-line file ${uQ(n)}`},Su("span",{className:`codex-edit-file-status ${uQ(n)}`},n),Su("code",null,u.path||u.text.replace(/^([AMDRCU?]{1,2})\s+/u,"")))}let f=u.kind==="add"||u.kind==="del"?u.text.slice(0,1):u.kind==="hunk"?"@@":u.kind==="note"?"ok":"",r=u.kind==="add"||u.kind==="del"?u.text.slice(1):u.text;return Su("div",{key:`${l}-${u.text}`,className:`codex-edit-diff-line ${u.kind}`},Su("span",{className:"codex-edit-diff-sign"},f),Su("code",null,r||" "))}function OE(u,l){let f=u.lines.length>0?u.lines:u.files.map((n)=>({text:`${n.status} ${n.path}`,kind:"file",path:n.path,status:n.status})),r=Number(u.addedLines||0)+Number(u.removedLines||0)>0;return Su("div",{className:"codex-edit-observation","data-testid":"codex-edit-observation"},Su("div",{className:"codex-edit-observation-head"},Su("span",{className:"codex-edit-window-controls","aria-hidden":"true"},Su("i",null),Su("i",null),Su("i",null)),Su("strong",null,r?"git diff":"git diff --stat"),Su("code",null,u.summary||"File changes")),u.stages.length>0?Su("div",{className:"codex-edit-stage-strip"},u.stages.map((n,i)=>Su("span",{key:`${n.method}-${i}`,className:`codex-edit-stage ${GE(n.status||n.method)}`},Su("b",null,zE(n.method)),n.status?Su("em",null,n.status):null))):null,f.length>0?Su("div",{className:"codex-edit-diff",role:"list"},f.map(EE)):null,l?Su("div",{className:"codex-edit-omitted"},`${l} (查看原始JSON获取完整记录)`):null)}function lQ(u,l,f){let r=b4(f);return Su("div",{className:`codex-transcript-stream ${u}`,"data-testid":`codex-trace-${u}`},Su("span",{className:"codex-transcript-stream-label"},u),Su("pre",{className:"codex-transcript-body"},l,r?` -${r} (查看原始JSON获取完整记录)`:""))}function JQ(u,l=!1){let f=String(u.kind||"message"),r=["ran","explored","edited"].includes(f),n=b4(u.commandOmittedLines),i=b4(u.bodyOmittedLines),t=String(u.commandPreview||(r?u.title||"":"")),y=String(u.stdoutPreview||""),c=String(u.stderrPreview||""),$=y.length>0||c.length>0,A=Boolean(u.foldedReferencePrompt)&&String(u.fullPrompt||"").length>0,j=f==="edited"&&(u.editObservation!==void 0||yQ(u))?u.editObservation||cQ([u]):null;return Su("article",{key:`${u.seq}-${f}`,className:`codex-transcript-item ${f} ${l?"nested":""}`},Su("div",{className:"codex-transcript-main"},Su("div",{className:"codex-transcript-title"},Su("span",{className:"codex-output-channel"},h4(f)),r&&j===null?null:Su("strong",null,j!==null?"File changes":String(u.title||h4(f))),u.status?Su("code",null,String(j?.status||u.status)):null,Su("time",null,wu(u.at))),t&&j===null?Su("pre",{className:"codex-transcript-command"},t,n?` -${n}`:""):null,j!==null?OE(j,i):$?Su("div",{className:"codex-transcript-streams"},y.length>0?lQ("stdout",y,u.stdoutOmittedLines):null,c.length>0?lQ("stderr",c,u.stderrOmittedLines):null):u.bodyPreview?Su("pre",{className:"codex-transcript-body"},String(u.bodyPreview),i?` -${i} (查看原始JSON获取完整记录)`:""):null,A?Su("details",{className:"codex-initial-prompt-full","data-testid":"codex-initial-prompt-full"},Su("summary",null,Su("span",null,"引用注入已折叠,点击查看最终传入 Codex 的完整 prompt"),Su("code",null,`${u.fullPromptLines||_E(String(u.fullPrompt||""))} lines / ${u.fullPromptChars||String(u.fullPrompt||"").length} chars`)),Su("pre",{className:"codex-transcript-body codex-transcript-full-prompt","data-testid":"codex-initial-prompt-full-text"},String(u.fullPrompt||""))):null))}function ZE(u){let l=Array.isArray(u.items)?u.items:[],f=u.digest&&typeof u.digest==="object"?u.digest:_Q(l);return Su("article",{key:`${u.seq}-toolGroup`,className:"codex-transcript-item toolGroup"},Su("div",{className:"codex-transcript-main"},Su("details",{className:"codex-tool-group","data-testid":"codex-tool-group"},Su("summary",null,Su("div",{className:"codex-tool-group-head"},Su("span",{className:"codex-output-channel"},h4("toolGroup")),Su("strong",null,String(u.title||nQ(l))),Su("code",null,String(u.status||`${l.length} calls`)),Su("time",null,wu(u.at)))),Su("div",{className:"codex-tool-group-digest"},Su("span",null,`read: ${R4(Array.isArray(f.readFiles)?f.readFiles:[])}`),Su("span",null,`edit: ${R4(Array.isArray(f.editedFiles)?f.editedFiles:[])}`),Su("span",null,`run: ${R4(Array.isArray(f.runCommands)?f.runCommands:[],2)}`),Su("span",null,`duration: ${f.durationLabel||"--"}`)),Su("div",{className:"codex-tool-group-items"},l.map((r)=>JQ(r,!0))))))}function HE(u){let l=[u.title,u.status,u.bodyPreview,u.commandPreview,u.stderrPreview,u.stdoutPreview].map((f)=>String(f||"")).join(` -`);return/\b(error|failed|failure|interrupt|interrupted|cancell?ed|watchdog|timeout|closed|refused|aborted|exception)\b/iu.test(l)}function QQ(u,l){if(l)return u;return u.flatMap((f)=>{if(String(f.kind||"")==="system"&&!HE(f))return[];if(String(f.kind||"")!=="toolGroup"||!Array.isArray(f.items))return[f];let r=QQ(f.items,l);return[{...f,items:r}]})}var BE=16;function fQ(u){return u.scrollHeight-u.scrollTop-u.clientHeight<=BE}function s$({items:u,input:l,port:f,autoScroll:r=!1,loading:n=!1,hasDetail:i=!0,emptyText:t="等待 Trace 输出...",loadingText:y="正在加载完整 Trace...",testId:c="trace-output",className:$="codex-transcript",keepRecentToolCalls:A=3,collapseTools:j=!0,showSystemEvents:F=!1}){let J=gJ(null),Q=gJ(!0),W=QQ(wE(f?yE(f,l):$Q(u)),Boolean(F)),L=j?WE(W,A):W,U=$E(W);tE(()=>{let w=J.current;if(!r||!w)return;if(!Q.current&&!fQ(w))return;w.scrollTop=w.scrollHeight,Q.current=!0},[r,W.length,U]);let N={className:$,ref:J,onScroll:(w)=>{let G=w.currentTarget;Q.current=fQ(G)},"data-testid":c};if(n&&!i)return Su("div",N,Su("div",{className:"codex-output-empty"},y));return Su("div",N,L.length===0?Su("div",{className:"codex-output-empty"},t):L.map((w)=>String(w.kind||"")==="toolGroup"?ZE(w):JQ(w)))}var NQ=Cu(Jl(),1),Bi=NQ.default.createElement;function a$(...u){return u.filter(Boolean).join(" ")}function qQ({title:u,children:l,actions:f,onClose:r,className:n,backdropClassName:i,bodyClassName:t,actionsClassName:y,titleId:c,testId:$,closeTestId:A,closeLabel:j="关闭",disableClose:F=!1,closeOnBackdrop:J=!0}){let Q={className:a$("raw-dialog","unidesk-dialog",n),role:"dialog","aria-modal":"true"};if(c)Q["aria-labelledby"]=c;else if(typeof u==="string")Q["aria-label"]=u;if($)Q["data-testid"]=$;return Bi("div",{className:a$("modal-backdrop","unidesk-dialog-backdrop",i),role:"presentation",onClick:(W)=>{if(J&&!F&&W.target===W.currentTarget)r()}},Bi("section",Q,Bi("div",{className:"raw-dialog-head unidesk-dialog-head"},Bi("strong",c?{id:c}:null,u),Bi("button",{type:"button",className:"ghost-btn",onClick:r,disabled:F,"data-testid":A},j)),Bi("div",{className:a$("unidesk-dialog-body",t)},l),f?Bi("div",{className:a$("unidesk-dialog-actions",y)},f):null))}var T=uc.default.createElement,{useEffect:Mn,useMemo:wQ,useRef:Ml}=uc.default,vu=uc.default.useState,VE=120,XQ=12,YQ=48,mE=1200;function a4(){return typeof document>"u"||document.visibilityState!=="hidden"}function bl(u,l="操作失败"){return Ou(u,l)}function ar(u){let l=Number(u);if(!Number.isFinite(l)||l<0)return"--";let f=Math.floor(l/1000),r=Math.floor(f/3600),n=Math.floor(f%3600/60),i=f%60;if(r>0)return`${r}h ${String(n).padStart(2,"0")}m`;if(n>0)return`${n}m ${String(i).padStart(2,"0")}s`;return`${i}s`}function hn(u){if(u===null||u===void 0||u==="")return null;let l=u instanceof Date?u.getTime():new Date(u).getTime();return Number.isFinite(l)?l:null}function PQ(u,l=Date.now()){let f=hn(u);if(f===null)return"--";let r=Math.max(0,Math.floor((l-f)/1000));if(r<1)return"刚刚";let n=Math.floor(r/86400),i=Math.floor(r%86400/3600),t=Math.floor(r%3600/60),y=r%60;if(n>0)return`${n}天${i>0?`${i}小时`:""}前`;if(i>0)return`${i}小时${t>0?`${t}分钟`:""}前`;if(t>0)return`${t}分钟${y}秒前`;return`${y}秒前`}function CQ(...u){let l="",f=-1/0;for(let r of u){let n=String(r||"");if(n.length===0)continue;let i=hn(r);if(i!==null&&i>=f)l=n,f=i;else if(l.length===0)l=n}return l}function DE(u){let l=Number(u);if(!Number.isFinite(l)||l<0)return"--";if(l<1000)return`${Math.round(l)}ms`;return`${(l/1000).toFixed(l<1e4?2:1)}s`}function r2(u,l=180){let f=String(u||"").replace(/\s+/gu," ").trim();return f.length>l?`${f.slice(0,l-1)}…`:f}async function ml(u,l={}){return Eu(u,{strictJson:!0,retryInvalidJson:1,invalidJsonPrefix:"Code Queue 返回了无效 JSON",invalidJsonPreview:!0,responsePreviewLength:mE,...l})}function pi({status:u,children:l,title:f}){let r=String(u||"unknown").toLowerCase();return T("span",{className:`status-badge ${r}`,title:f},l||u||"unknown")}function ot({title:u,eyebrow:l,summary:f,actions:r,children:n,className:i,loading:t}){return T("section",{className:`panel ${i||""}`},T("div",{className:"panel-head"},T("div",null,l?T("p",{className:"panel-eyebrow"},l):null,T(rl,{title:u,loading:t}),f?T("div",{className:"panel-summary"},f):null),r?T("div",{className:"panel-actions"},r):null),T("div",{className:"panel-body"},n))}function MQ({title:u,data:l,onOpen:f,testId:r}){return T("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function Si({title:u,text:l}){return T("div",{className:"empty-state"},T("strong",null,u),T("span",null,l))}function pE(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function SE(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function Dl(u,l){return`${u}/microservices/code-queue/proxy${l}`}function XE(u){return`${u}/microservices/oa-event-flow/proxy/api/events/stream?tags=${encodeURIComponent("service:code-queue")}`}function $2(){return{headers:{"cache-control":"no-cache","x-unidesk-no-cache":"1"}}}function vl(u){return Array.isArray(u?.tasks)?u.tasks:[]}function B0(u){return u?.pagination&&typeof u.pagination==="object"&&!Array.isArray(u.pagination)?u.pagination:{}}function WQ(u){let l=Date.parse(String(u?.updatedAt||u?.createdAt||""));return Number.isFinite(l)?l:0}function LQ(u){return hn(u?.queueEnteredAt)??hn(u?.createdAt)??hn(u?.updatedAt)??0}function YE(u,l){let f=LQ(u)-LQ(l);if(f!==0)return f;let r=(hn(u?.createdAt)??0)-(hn(l?.createdAt)??0);if(r!==0)return r;return String(u?.id||"").localeCompare(String(l?.id||""))}function PE(u,l=""){let f=new Map;for(let r of u)for(let n of r){let i=String(n?.id||"");if(i.length>0&&!f.has(i))f.set(i,n)}return Array.from(f.values()).sort((r,n)=>{let i=VQ(r)-VQ(n);if(i!==0)return i;let t=String(r?.id||"")===l?0:1,y=String(n?.id||"")===l?0:1;if(t!==y)return t-y;return WQ(n)-WQ(r)})}function V0(u,l=""){let f=new Map;for(let r of u)for(let n of r){let i=String(n?.id||"");if(i.length===0)continue;f.set(i,{...f.get(i)||{},...n})}return PE([Array.from(f.values())],l)}function g1(u){return Array.isArray(u?.activeTaskIds)?u.activeTaskIds.map((l)=>String(l||"")).filter(Boolean):[String(u?.activeTaskId||"")].filter(Boolean)}var D0="__all__",CE="(max-width: 760px)",ME="(min-width: 761px)";function sf(u){return!u||u===D0}function RE(){return typeof window<"u"&&window.matchMedia(CE).matches}function xE(u){return sf(u)?"":`&queueId=${encodeURIComponent(u)}`}function n2(u){return String(u||"").trim().replace(/\s+/gu," ").slice(0,200)}function hE(u){let l=n2(u);return l.length===0?"":`&search=${encodeURIComponent(l)}`}function A2(u,l=""){return`${xE(u)}${hE(l)}`}function o$(u,l){return Number(u?.counts?.[l]||0)}function TQ(u,l=""){let f=new Map;for(let n of Array.isArray(u?.queues)?u.queues:[]){let i=String(n?.id||"").trim();if(i.length>0)f.set(i,{...n,name:String(n?.name||i).trim()||i})}for(let n of[String(u?.defaultQueueId||"default"),l].map((i)=>i.trim()).filter(Boolean))if(!f.has(n))f.set(n,{id:n,name:n,total:0,counts:{},activeTaskId:null,runnableTaskId:null,processing:!1});return Array.from(f.values()).sort((n,i)=>{let t=String(n?.id||"")===String(u?.defaultQueueId||"default")?0:1,y=String(i?.id||"")===String(u?.defaultQueueId||"default")?0:1;if(t!==y)return t-y;return String(n?.id||"").localeCompare(String(i?.id||""))})}function RQ(u){let l=String(u?.id||"default"),f=String(u?.name||"").trim();return f.length>0?f:l}function i2(u){let l=String(u?.id||"default"),f=RQ(u);return f===l?l:`${f} (${l})`}function s1(u){let l=o$(u,"running")+o$(u,"judging"),f=o$(u,"queued")+o$(u,"retry_wait"),r=Number(u?.total||0),n=[i2(u),`${r} tasks`];if(l>0)n.push(`${l} running`);if(f>0)n.push(`${f} queued`);return n.join(" · ")}function et(u,l){if(sf(l))return null;return u.find((f)=>String(f?.id||"")===l)||null}function KQ(u,l,f,r){if(sf(f)){let i=g1(u);return String(u?.activeTaskId||i[0]||r.find((t)=>HQ(t))?.id||"")}let n=et(l,f);return String(n?.activeTaskId||r.find((i)=>HQ(i))?.id||"")}function bE(u,l,f){if(!sf(l)){let r=et(u,l);return String(r?.runnableTaskId||f.find((n)=>String(n?.status||"")==="queued"||String(n?.status||"")==="retry_wait")?.id||"")}return String(f.find((r)=>String(r?.status||"")==="queued"||String(r?.status||"")==="retry_wait")?.id||"")}async function GQ(u,l=D0,f=""){return ml(Dl(u,`/api/tasks/overview?limit=${XQ}&transcriptLimit=1&compact=1&selected=0&includeActive=0&stats=0&skipTrace=1${A2(l,f)}`),$2())}async function o4(u,l,f=0,r=D0,n="",i=!1,t={}){let y=t.selected===!1?"&selected=0":"",c=t.includeActive===!1?"&includeActive=0":"",$=t.stats===!1?"&stats=0":"",A=Number.isInteger(t.limit)&&t.limit>0?Math.min(500,t.limit):XQ;return ml(Dl(u,`/api/tasks/overview?limit=${encodeURIComponent(String(A))}&transcriptLimit=3&compact=1&afterSeq=${encodeURIComponent(String(Math.max(0,f)))}&preferId=${encodeURIComponent(l)}${y}${c}${$}${i?"&skipTrace=1":""}${A2(r,n)}`),$2())}async function zQ(u,l,f,r=YQ,n=""){return ml(Dl(u,`/api/tasks/overview?limit=${encodeURIComponent(String(r))}&transcriptLimit=1&compact=1&selected=0&includeActive=0&stats=0&beforeId=${encodeURIComponent(f)}${A2(l,n)}`),$2())}async function vE(u,l){return ml(Dl(u,`/api/tasks/${encodeURIComponent(l)}/trace-summary`))}async function kE(u,l,f,r=null){let n=r===null||r===void 0||String(r).length===0?"":`&attempt=${encodeURIComponent(String(r))}`;return ml(Dl(u,`/api/tasks/${encodeURIComponent(l)}/prompt?part=${encodeURIComponent(f)}${n}`))}async function IE(u,l,f=0,r=500,n=null){let i=n===null||n===void 0||String(n).length===0?"":`&attempt=${encodeURIComponent(String(n))}`;return ml(Dl(u,`/api/tasks/${encodeURIComponent(l)}/trace-steps?afterSeq=${encodeURIComponent(String(f))}&limit=${encodeURIComponent(String(r))}${i}`))}async function gE(u,l,f){return ml(Dl(u,`/api/tasks/${encodeURIComponent(l)}/trace-step?seq=${encodeURIComponent(String(f))}`))}async function sE(u,l){return ml(Dl(u,`/api/tasks/${encodeURIComponent(l)}/read`),{method:"POST",body:{}})}async function aE(u){return ml(Dl(u,"/api/tasks/read-all"),{method:"POST",body:{}})}function oE(u){return Array.isArray(u?.output)?u.output:[]}function dE(u){return Array.isArray(u?.attempts)?u.attempts:[]}function d4(u){return u?.counts&&typeof u.counts==="object"&&!Array.isArray(u.counts)?u.counts:{}}function eE(u){return u.split(/^\s*---+\s*$/gmu).map((l)=>l.trim()).filter(Boolean)}function EQ(u){let l=Number(u);return Number.isFinite(l)?Math.max(1,Math.min(50,Math.floor(l))):1}function Vi(u){let l=[];for(let f of u.split(/[\s,,;;]+/u)){let r=f.trim();if(/^codex_\d+_[A-Za-z0-9_-]+$/u.test(r)&&!l.includes(r))l.push(r)}return l}function uO(u,l){let f=Vi(l);if(f.length===0)return u;return[`引用 Code Queue 任务 ${f.join(" ")}。后端会在入队时只注入这些任务的 initial prompt 和 final response 全文;中间执行过程不注入,如需补充核查可运行:${f.map((r)=>`bun scripts/cli.ts codex task ${r}`).join(";")}`,"","本次任务:",u].join(` -`)}function lO(u){let r=u.trimStart();if(!r.startsWith("# Code Queue 已解析引用上下文"))return{hasInjection:!1,reference:"",userPrompt:u};let n=u.length-r.length,i=u.lastIndexOf(` +`).trimEnd();return u.length>0?u.split(` +`):[]}function i2(l){let u=String(l.status||"").trim();if(u.length>0)return u;let r=String(l.bodyPreview||"");return/^(item\/[A-Za-z]+(?:\/[A-Za-z]+)?):/u.exec(r)?.[1]||"item/fileChange"}function Vz(l){let u=String(l.bodyPreview||"");return/file changes status=([A-Za-z0-9_-]+)/u.exec(u)?.[1]}function Sz(l){return/^item\/(?:started|completed): file changes status=/u.test(String(l||"").trim())}function TN(l){if(String(l.kind||"")!=="edited")return!1;let u=String(l.status||""),r=String(l.title||""),f=String(l.bodyPreview||""),n=String(l.commandPreview||"");if(r==="Edited files")return!0;if(/^item\/fileChange\//u.test(u))return!0;if((u==="item/started"||u==="item/completed")&&/file changes status=/u.test(f))return!0;if(/^Success\. Updated the following files:/mu.test(f))return!0;if(/^diff --git /mu.test(f))return!0;return/^([AMDRCU?]{1,2})\s+\S+/mu.test(f)||n.length>0&&f3(f).length>0}function ly(l){return LN(String(l||"").replace(/^[ab]\//u,"").trim())}function y2(l){let u=/^([AMDRCU?]{1,2})\s+(.+)$/u.exec(l);if(!u)return null;let r=ly(u[2]||"");return r.length>0?{status:u[1]||"M",path:r}:null}function c2(l){let u=/^\*\*\*\s+(Add|Update|Delete)\s+File:\s+(.+)$/u.exec(l);if(u){let f=u[1]==="Add"?"A":u[1]==="Delete"?"D":"M",n=ly(u[2]||"");return n.length>0?{status:f,path:n}:null}let r=/^\*\*\*\s+Move to:\s+(.+)$/u.exec(l);if(r){let f=ly(r[1]||"");return f.length>0?{status:"R",path:f}:null}return null}function f3(l){let u=[],r=(n,i)=>{let t=ly(i);if(t.length===0||t==="/dev/null")return;let y=u.find((c)=>c.path===t);if(y){if(y.status==="M"&&n!=="M")y.status=n;return}u.push({status:n,path:t})},f="";for(let n of GN(l)){let i=y2(n)||c2(n);if(i!==null){r(i.status,i.path),f=i.path;continue}let t=/^diff --git a\/(.+?) b\/(.+)$/u.exec(n);if(t){let j=t[2]||t[1]||"";r("M",j),f=ly(j);continue}let y=/^\+\+\+ b\/(.+)$/u.exec(n);if(y&&y[1]!=="/dev/null"){r("M",y[1]||""),f=ly(y[1]||"");continue}if(/^new file mode /u.exec(n)&&f)r("A",f);if(/^deleted file mode /u.exec(n)&&f)r("D",f);let A=/^rename to (.+)$/u.exec(n);if(A)r("R",A[1]||"")}return u}function Xz(l){if(y2(l)!==null||c2(l)!==null)return"file";if(/^(diff --git |index |--- |\+\+\+ |\*\*\* Begin Patch|\*\*\* End Patch)/u.test(l))return"meta";if(/^@@ /u.test(l))return"hunk";if(/^\+/u.test(l))return"add";if(/^-/u.test(l))return"del";if(/^(Success\.|No changes|Updated\b|Created\b|Deleted\b|Added\s+\d+\s+lines?|Wrote\s+\d+\s+lines?|Read\s+\d+\s+files?|\.\.\.\[patch content truncated)/iu.test(l))return"note";return"context"}function _2(l){return GN(l).map((u)=>{let r=y2(u)||c2(u);if(r!==null)return{text:u,kind:"file",path:r.path,status:r.status};return{text:u,kind:Xz(u)}})}function Yz(l){return l.reduce((u,r)=>{if(r.kind==="add")u.added+=1;else if(r.kind==="del")u.removed+=1;return u},{added:0,removed:0})}function JN(l,u){return`${u} ${l} line${l===1?"":"s"}`}function Pz(l,u){let r=[];if(l>0)r.push(JN(l,"Added"));if(u>0)r.push(JN(u,"removed"));return r.join(", ")}function Cz(l){for(let r=l.length-1;r>=0;r-=1){let f=String(l[r]?.status||"").trim();if(f.length>0)return f}let u=String(l[l.length-1]?.method||"").trim();if(u==="item/fileChange/outputDelta")return"updated";if(u==="item/started")return"started";if(u==="item/completed")return"completed";return u.replace(/^item\//u,"")||"changed"}function Mz(l){return`${l} file${l===1?"":"s"}`}function mN(l){let u=l.length>0?l:[],r=FN(u.map((F)=>String(F.bodyPreview||""))),n=FN(u.map((F)=>String(F.bodyPreview||"")).filter((F)=>F.trim().length>0&&!Sz(F)))||r,i=f3(n||r),t=u.map((F)=>({method:i2(F),status:Vz(F),at:F.at})),y=_2(n||r),c=Yz(y),$=Pz(c.added,c.removed),A=i.length>0?Mz(i.length):"",j=$.length>0?`${$}${A?` in ${A}`:""}`:i.length>0?A:uy(n||r||"File changes",72);return{status:Cz(t),summary:j,files:i,stages:t,lines:y,addedLines:c.added,removedLines:c.removed,rawText:r}}function hz(l){let u=l[0],r=l[l.length-1]||u,f=mN(l);return{...u,seq:Number.isFinite(Number(r?.seq))?Number(r?.seq):Number(u?.seq??0),at:r?.at||u?.at,title:f.files.length>0?`Edited ${f.summary}`:"Edited files",status:f.status,commandPreview:"",commandOmittedLines:void 0,bodyPreview:f.rawText,bodyOmittedLines:l.reduce((n,i)=>n+Number(i.bodyOmittedLines||0),0)||void 0,rawSeqs:l.flatMap((n)=>Array.isArray(n?.rawSeqs)?n.rawSeqs:[n?.seq]).filter((n)=>n!==void 0),editObservation:f}}function Rz(l){let u=Array.isArray(l)?l:[],r=[],f=[],n=()=>{if(f.length===0)return;r.push(hz(f)),f=[]};for(let i of u){if(TN(i)){if(i2(i)==="item/started"&&f.length>0)n();if(f.push(i),i2(i)==="item/completed")n();continue}n(),r.push(i)}return n(),r}function KN(l){let u=[],r=[],f=[],n=($,A)=>{for(let j of A)if(!$.includes(j))$.push(j)};for(let $ of l){let A=String($?.kind||""),j=[$?.commandPreview,$?.bodyPreview,$?.title].map((F)=>String(F||"")).join(` +`);if(A==="explored")n(u,jN(j));else if(A==="edited")n(r,jN(j));else if(A==="ran"){let F=String($?.commandPreview||$?.title||"").trim();if(F.length>0&&!f.includes(F))f.push(uy(F,90))}}let i=l.map(($)=>Date.parse(String($?.at||""))).filter(($)=>Number.isFinite($)),t=i.length>=2?Math.max(0,Math.max(...i)-Math.min(...i)):0,y=l.reduce(($,A)=>$+(If(A?.durationMs)??If(A?.elapsedMs)??0),0),c=t>0?t:y;return{readFiles:u,editedFiles:r,runCommands:f,durationLabel:Hz(c)}}function xz(l,u=3){let r=Array.isArray(l)?l:[],f=[],n=[],i=Math.max(0,u),t=new Set;for(let c=r.length-1;c>=0&&i>0;c-=1){let $=r[c];if(!AN($))continue;t.add($),i-=1}let y=()=>{if(n.length>=2){let c=qN(n);f.push({seq:Number(n[0]?.seq??0),at:n[0]?.at||n.at(-1)?.at,kind:"toolGroup",title:WN(n),status:`${n.length} calls`,items:n,counts:c,digest:KN(n),rawSeqs:n.flatMap(($)=>Array.isArray($?.rawSeqs)?$.rawSeqs:[$?.seq]).filter(($)=>$!==void 0)})}else f.push(...n);n=[]};for(let c of r){if(AN(c)&&!t.has(c)){n.push(c);continue}y(),f.push(c)}return y(),f}function zN(l){return(Array.isArray(l)?l:[]).map((u,r)=>({...u,seq:Number.isFinite(Number(u?.seq))?Number(u.seq):r+1,kind:String(u?.kind||"message"),at:u?.at===void 0?void 0:String(u.at),durationMs:If(u?.durationMs)??void 0,title:u?.title===void 0?void 0:String(u.title),status:u?.status===void 0?void 0:String(u.status)}))}function e1(l){let u=If(l?.state?.time?.start)??If(l?.time?.start),r=If(l?.state?.time?.end)??If(l?.time?.end);return If(l?.durationMs)??If(l?.elapsedMs)??If(l?.timing?.durationMs)??If(l?.metadata?.durationMs)??(u!==null&&r!==null&&r>=u?r-u:null)??void 0}function lc(l,u){return l?.createdAt||l?.updatedAt||l?.completedAt||u||void 0}function r2(l,u){return l?.id||l?.messageId||u}function bz(l,u=1200){if(typeof l==="string")return l;if(l===void 0||l===null)return"";try{return uy(JSON.stringify(l),u)}catch{return uy(String(l),u)}}function EN(l,u,r){if(typeof l?.metadata?.diff==="string"&&l.metadata.diff.length>0)return l.metadata.diff;if(typeof l?.metadata?.filediff?.patch==="string"&&l.metadata.filediff.patch.length>0)return l.metadata.filediff.patch;if(typeof l?.output==="string"&&l.output.length>0)return l.output;if(typeof l?.result==="string"&&l.result.length>0)return l.result;if(typeof u?.output==="string"&&u.output.length>0)return u.output;if(typeof r?.output==="string"&&r.output.length>0)return r.output;if(typeof l?.metadata?.output==="string"&&l.metadata.output.length>0)return l.metadata.output;return""}function r3(l,u){if(!l||typeof l!=="object"||Array.isArray(l))return"";for(let r of u){let f=l[r];if(typeof f==="string"&&f.length>0)return f;if(f!==void 0&&f!==null&&typeof f!=="object")return String(f)}return""}function UN(l,u){if(!l||typeof l!=="object"||Array.isArray(l))return null;for(let r of u){let f=Number(l[r]);if(Number.isFinite(f))return f}return null}function ON(l,u){let r=u?.input&&typeof u.input==="object"&&!Array.isArray(u.input)?u.input:l?.input&&typeof l.input==="object"&&!Array.isArray(l.input)?l.input:{},f=r3(r,["command","cmd","script"]);if(f.length>0)return f;if(typeof l?.command==="string"&&l.command.length>0)return l.command;if(typeof u?.command==="string"&&u.command.length>0)return u.command;let n=String(l?.tool||l?.title||"tool"),i=r3(r,["filePath","filepath","path"])||r3(l,["filePath","filepath","path"]),t=r3(r,["pattern","query"]),y=UN(r,["offset"]),c=UN(r,["limit"]),$=[n];if(t.length>0)$.push(t);if(i.length>0)$.push(i);if(y!==null)$.push(`offset=${y}`);if(c!==null)$.push(`limit=${c}`);return $.length>1?$.join(" "):n}function vz(l,u){let r=l?.part&&typeof l.part==="object"&&!Array.isArray(l.part)?l.part:{},f=String(l?.type||l?.event||l?.name||r?.type||"").toLowerCase(),n=String(r?.type||"").toLowerCase(),i=l?.at||l?.timestamp||r?.updatedAt||r?.createdAt,t=Number.isFinite(Number(l?.seq))?Number(l.seq):u;if(f==="step_start"||f==="step-start"||n==="step-start")return null;if(f==="step_finish"||f==="step-finish"||n==="step-finish")return null;if(n==="tool"||/tool|bash|command/iu.test(`${f} ${n}`)){let c=r?.state&&typeof r.state==="object"&&!Array.isArray(r.state)?r.state:{},$=ON(r,c),A=EN(c,r,l),j=ZN($,String(r?.tool||r?.title||"")),F=j==="edited"?{status:String(c?.status||r?.status||l?.status||""),summary:uy(A||$,72),files:f3(A),stages:[],lines:_2(A),addedLines:0,removedLines:0,rawText:A}:void 0;return{seq:t,at:lc(r,i),kind:j,title:String(c?.title||r?.title||c?.metadata?.description||r?.tool||"OpenCode tool"),status:String(c?.status||r?.status||l?.status||""),commandPreview:$,bodyPreview:A,durationMs:e1(r),rawSeqs:[r?.id||r?.callID||l?.sessionID||t],editObservation:F}}let y=bz(r?.text??r?.content??r?.delta??l?.text??l?.content??l?.delta,3000).trim();if(y.length>0)return{seq:t,at:lc(r,i),kind:n==="reasoning"?"message":/error|failed/iu.test(`${f} ${n}`)?"error":"message",title:n==="reasoning"?"Reasoning":/error|failed/iu.test(`${f} ${n}`)?"OpenCode error":"Assistant message",status:`opencode/${f||n||"event"}`,bodyPreview:y,durationMs:e1(r),rawSeqs:[r?.id||l?.sessionID||t]};return null}function ZN(l,u){let r=`${u} ${l}`.toLowerCase();if(/\b(read|grep|glob|list|ls|find|search|view|cat|sed|rg|head|tail|wc|file)\b/iu.test(r))return"explored";if(/\b(edit|write|patch|apply|update|create|delete|apply_patch|git apply|cat >|tee .*<<|sed -i|python3? .*write_text|mkdir|rm |touch )\b/iu.test(r))return"edited";return"ran"}function sz(l){let u=[],r=1;for(let f of Array.isArray(l)?l:[]){if(f?.kind&&f?.title){let y=String(f?.status||"");if(y==="opencode/step-start"||y==="opencode/step-finish")continue;u.push({...f,seq:Number.isFinite(Number(f?.seq))?Number(f.seq):r++});continue}let n=f?.createdAt||f?.updatedAt||f?.completedAt,i=String(f?.role||"assistant").toLowerCase(),t=Array.isArray(f?.parts)?f.parts:[];if(t.length===0){if(f?.part&&(f?.sessionID||String(f?.type||"").startsWith("step_")||String(f?.type||"").includes("tool"))){let y=vz(f,r);if(y!==null)u.push(y),r=Math.max(r+1,Number(y.seq)+1)}else if(f?.textPreview)u.push({seq:r++,at:n,kind:"message",title:`${i||"assistant"} message`,status:i,bodyPreview:String(f.textPreview),rawSeqs:[f?.messageId||r]});continue}for(let y of t){let c=String(y?.type||"").toLowerCase();if(c==="step-start"||c==="step-finish")continue;if(c==="text"||c==="reasoning"){let A=String(y?.textPreview||f?.textPreview||"").trim();if(A.length===0)continue;u.push({seq:r++,at:lc(y,n),kind:"message",title:c==="reasoning"?"Reasoning":i==="user"?"User message":i==="system"?"System message":"Assistant message",status:c==="reasoning"?"reasoning":i,bodyPreview:A,durationMs:e1(y),rawSeqs:[r2(y,r)]});continue}if(c==="tool"){let A=y?.state&&typeof y.state==="object"&&!Array.isArray(y.state)?y.state:{},j=ON(y,A),F=EN(A,y,{}),U=ZN(j,String(y?.tool||y?.title||"")),N=U==="edited"?{status:String(A?.status||y?.status||""),summary:uy(F||j,72),files:f3(F),stages:[],lines:_2(F),addedLines:0,removedLines:0,rawText:F}:void 0;u.push({seq:r++,at:lc(y,n),kind:U,title:String(y?.title||y?.tool||"tool"),status:String(y?.status||""),commandPreview:j,bodyPreview:F,durationMs:e1(y),rawSeqs:[r2(y,r)],editObservation:N});continue}let $=String(y?.textPreview||y?.title||c||"").trim();if($)u.push({seq:r++,at:lc(y,n),kind:"system",title:c||"part",bodyPreview:$,status:String(y?.status||""),durationMs:e1(y),rawSeqs:[r2(y,r)]})}}return u}var pN={source:"opencode",toTrace:sz};function kz(l){return String(l||"unknown").toLowerCase().replace(/[^a-z0-9_-]+/gu,"-")||"unknown"}function NN(l){let u=String(l||"M").toUpperCase();if(u.startsWith("A")||u==="??")return"added";if(u.startsWith("D"))return"deleted";if(u.startsWith("R"))return"renamed";return"modified"}function gz(l){if(l==="item/fileChange/outputDelta")return"delta";return l.replace(/^item\//u,"")}function Iz(l,u){if(l.kind==="file"){let n=String(l.status||"M");return Pl("div",{key:`${u}-${l.text}`,className:`codex-edit-diff-line file ${NN(n)}`},Pl("span",{className:`codex-edit-file-status ${NN(n)}`},n),Pl("code",null,l.path||l.text.replace(/^([AMDRCU?]{1,2})\s+/u,"")))}let r=l.kind==="add"||l.kind==="del"?l.text.slice(0,1):l.kind==="hunk"?"@@":l.kind==="note"?"ok":"",f=l.kind==="add"||l.kind==="del"?l.text.slice(1):l.text;return Pl("div",{key:`${u}-${l.text}`,className:`codex-edit-diff-line ${l.kind}`},Pl("span",{className:"codex-edit-diff-sign"},r),Pl("code",null,f||" "))}function az(l,u){let r=l.lines.length>0?l.lines:l.files.map((n)=>({text:`${n.status} ${n.path}`,kind:"file",path:n.path,status:n.status})),f=Number(l.addedLines||0)+Number(l.removedLines||0)>0;return Pl("div",{className:"codex-edit-observation","data-testid":"codex-edit-observation"},Pl("div",{className:"codex-edit-observation-head"},Pl("span",{className:"codex-edit-window-controls","aria-hidden":"true"},Pl("i",null),Pl("i",null),Pl("i",null)),Pl("strong",null,f?"git diff":"git diff --stat"),Pl("code",null,l.summary||"File changes")),l.stages.length>0?Pl("div",{className:"codex-edit-stage-strip"},l.stages.map((n,i)=>Pl("span",{key:`${n.method}-${i}`,className:`codex-edit-stage ${kz(n.status||n.method)}`},Pl("b",null,gz(n.method)),n.status?Pl("em",null,n.status):null))):null,r.length>0?Pl("div",{className:"codex-edit-diff",role:"list"},r.map(Iz)):null,u?Pl("div",{className:"codex-edit-omitted"},`${u} (查看原始JSON获取完整记录)`):null)}function QN(l,u,r){let f=n2(r);return Pl("div",{className:`codex-transcript-stream ${l}`,"data-testid":`codex-trace-${l}`},Pl("span",{className:"codex-transcript-stream-label"},l),Pl("pre",{className:"codex-transcript-body"},u,f?` +${f} (查看原始JSON获取完整记录)`:""))}function HN(l,u=!1){let r=String(l.kind||"message"),f=["ran","explored","edited"].includes(r),n=n2(l.commandOmittedLines),i=n2(l.bodyOmittedLines),t=String(l.commandPreview||(f?l.title||"":"")),y=String(l.stdoutPreview||""),c=String(l.stderrPreview||""),$=y.length>0||c.length>0,A=Boolean(l.foldedReferencePrompt)&&String(l.fullPrompt||"").length>0,j=r==="edited"&&(l.editObservation!==void 0||TN(l))?l.editObservation||mN([l]):null;return Pl("article",{key:`${l.seq}-${r}`,className:`codex-transcript-item ${r} ${u?"nested":""}`},Pl("div",{className:"codex-transcript-main"},Pl("div",{className:"codex-transcript-title"},Pl("span",{className:"codex-output-channel"},f2(r)),f&&j===null?null:Pl("strong",null,j!==null?"File changes":String(l.title||f2(r))),l.status?Pl("code",null,String(j?.status||l.status)):null,Pl("time",null,Wl(l.at))),t&&j===null?Pl("pre",{className:"codex-transcript-command"},t,n?` +${n}`:""):null,j!==null?az(j,i):$?Pl("div",{className:"codex-transcript-streams"},y.length>0?QN("stdout",y,l.stdoutOmittedLines):null,c.length>0?QN("stderr",c,l.stderrOmittedLines):null):l.bodyPreview?Pl("pre",{className:"codex-transcript-body"},String(l.bodyPreview),i?` +${i} (查看原始JSON获取完整记录)`:""):null,A?Pl("details",{className:"codex-initial-prompt-full","data-testid":"codex-initial-prompt-full"},Pl("summary",null,Pl("span",null,"引用注入已折叠,点击查看最终传入 Codex 的完整 prompt"),Pl("code",null,`${l.fullPromptLines||Bz(String(l.fullPrompt||""))} lines / ${l.fullPromptChars||String(l.fullPrompt||"").length} chars`)),Pl("pre",{className:"codex-transcript-body codex-transcript-full-prompt","data-testid":"codex-initial-prompt-full-text"},String(l.fullPrompt||""))):null))}function oz(l){let u=Array.isArray(l.items)?l.items:[],r=l.digest&&typeof l.digest==="object"?l.digest:KN(u);return Pl("article",{key:`${l.seq}-toolGroup`,className:"codex-transcript-item toolGroup"},Pl("div",{className:"codex-transcript-main"},Pl("details",{className:"codex-tool-group","data-testid":"codex-tool-group"},Pl("summary",null,Pl("div",{className:"codex-tool-group-head"},Pl("span",{className:"codex-output-channel"},f2("toolGroup")),Pl("strong",null,String(l.title||WN(u))),Pl("code",null,String(l.status||`${u.length} calls`)),Pl("time",null,Wl(l.at)))),Pl("div",{className:"codex-tool-group-digest"},Pl("span",null,`read: ${u2(Array.isArray(r.readFiles)?r.readFiles:[])}`),Pl("span",null,`edit: ${u2(Array.isArray(r.editedFiles)?r.editedFiles:[])}`),Pl("span",null,`run: ${u2(Array.isArray(r.runCommands)?r.runCommands:[],2)}`),Pl("span",null,`duration: ${r.durationLabel||"--"}`)),Pl("div",{className:"codex-tool-group-items"},u.map((f)=>HN(f,!0))))))}function dz(l){let u=[l.title,l.status,l.bodyPreview,l.commandPreview,l.stderrPreview,l.stdoutPreview].map((r)=>String(r||"")).join(` +`);return/\b(error|failed|failure|interrupt|interrupted|cancell?ed|watchdog|timeout|closed|refused|aborted|exception)\b/iu.test(u)}function BN(l,u){if(u)return l;return l.flatMap((r)=>{if(String(r.kind||"")==="system"&&!dz(r))return[];if(String(r.kind||"")!=="toolGroup"||!Array.isArray(r.items))return[r];let f=BN(r.items,u);return[{...r,items:f}]})}var ez=16;function wN(l){return l.scrollHeight-l.scrollTop-l.clientHeight<=ez}function n3({items:l,input:u,port:r,autoScroll:f=!1,loading:n=!1,hasDetail:i=!0,emptyText:t="等待 Trace 输出...",loadingText:y="正在加载完整 Trace...",testId:c="trace-output",className:$="codex-transcript",keepRecentToolCalls:A=3,collapseTools:j=!0,showSystemEvents:F=!1}){let U=$N(null),N=$N(!0),W=BN(Rz(r?pz(r,u):zN(l)),Boolean(F)),L=j?xz(W,A):W,J=Dz(W);Zz(()=>{let q=U.current;if(!f||!q)return;if(!N.current&&!wN(q))return;q.scrollTop=q.scrollHeight,N.current=!0},[f,W.length,J]);let Q={className:$,ref:U,onScroll:(q)=>{let T=q.currentTarget;N.current=wN(T)},"data-testid":c};if(n&&!i)return Pl("div",Q,Pl("div",{className:"codex-output-empty"},y));return Pl("div",Q,L.length===0?Pl("div",{className:"codex-output-empty"},t):L.map((q)=>String(q.kind||"")==="toolGroup"?oz(q):HN(q)))}var DN=Rl(Ju(),1),D0=DN.default.createElement;function i3(...l){return l.filter(Boolean).join(" ")}function VN({title:l,children:u,actions:r,onClose:f,className:n,backdropClassName:i,bodyClassName:t,actionsClassName:y,titleId:c,testId:$,closeTestId:A,closeLabel:j="关闭",disableClose:F=!1,closeOnBackdrop:U=!0}){let N={className:i3("raw-dialog","unidesk-dialog",n),role:"dialog","aria-modal":"true"};if(c)N["aria-labelledby"]=c;else if(typeof l==="string")N["aria-label"]=l;if($)N["data-testid"]=$;return D0("div",{className:i3("modal-backdrop","unidesk-dialog-backdrop",i),role:"presentation",onClick:(W)=>{if(U&&!F&&W.target===W.currentTarget)f()}},D0("section",N,D0("div",{className:"raw-dialog-head unidesk-dialog-head"},D0("strong",c?{id:c}:null,l),D0("button",{type:"button",className:"ghost-btn",onClick:f,disabled:F,"data-testid":A},j)),D0("div",{className:i3("unidesk-dialog-body",t)},u),r?D0("div",{className:i3("unidesk-dialog-actions",y)},r):null))}var G=yc.default.createElement,{useEffect:vn,useMemo:SN,useRef:Ru}=yc.default,gl=yc.default.useState,lE=120,dN=12,eN=48,uE=1200;function $2(){return typeof document>"u"||document.visibilityState!=="hidden"}function xu(l,u="操作失败"){return El(l,u)}function of(l){let u=Number(l);if(!Number.isFinite(u)||u<0)return"--";let r=Math.floor(u/1000),f=Math.floor(r/3600),n=Math.floor(r%3600/60),i=r%60;if(f>0)return`${f}h ${String(n).padStart(2,"0")}m`;if(n>0)return`${n}m ${String(i).padStart(2,"0")}s`;return`${i}s`}function gn(l){if(l===null||l===void 0||l==="")return null;let u=l instanceof Date?l.getTime():new Date(l).getTime();return Number.isFinite(u)?u:null}function lQ(l,u=Date.now()){let r=gn(l);if(r===null)return"--";let f=Math.max(0,Math.floor((u-r)/1000));if(f<1)return"刚刚";let n=Math.floor(f/86400),i=Math.floor(f%86400/3600),t=Math.floor(f%3600/60),y=f%60;if(n>0)return`${n}天${i>0?`${i}小时`:""}前`;if(i>0)return`${i}小时${t>0?`${t}分钟`:""}前`;if(t>0)return`${t}分钟${y}秒前`;return`${y}秒前`}function uQ(...l){let u="",r=-1/0;for(let f of l){let n=String(f||"");if(n.length===0)continue;let i=gn(f);if(i!==null&&i>=r)u=n,r=i;else if(u.length===0)u=n}return u}function rE(l){let u=Number(l);if(!Number.isFinite(u)||u<0)return"--";if(u<1000)return`${Math.round(u)}ms`;return`${(u/1000).toFixed(u<1e4?2:1)}s`}function Q2(l,u=180){let r=String(l||"").replace(/\s+/gu," ").trim();return r.length>u?`${r.slice(0,u-1)}…`:r}async function Vu(l,u={}){return ml(l,{strictJson:!0,retryInvalidJson:1,invalidJsonPrefix:"Code Queue 返回了无效 JSON",invalidJsonPreview:!0,responsePreviewLength:uE,...u})}function Y0({status:l,children:u,title:r}){let f=String(l||"unknown").toLowerCase();return G("span",{className:`status-badge ${f}`,title:r},u||l||"unknown")}function ry({title:l,eyebrow:u,summary:r,actions:f,children:n,className:i,loading:t}){return G("section",{className:`panel ${i||""}`},G("div",{className:"panel-head"},G("div",null,u?G("p",{className:"panel-eyebrow"},u):null,G(fu,{title:l,loading:t}),r?G("div",{className:"panel-summary"},r):null),f?G("div",{className:"panel-actions"},f):null),G("div",{className:"panel-body"},n))}function rQ({title:l,data:u,onOpen:r,testId:f}){return G("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function P0({title:l,text:u}){return G("div",{className:"empty-state"},G("strong",null,l),G("span",null,u))}function fE(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function nE(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function Su(l,u){return`${l}/microservices/code-queue/proxy${u}`}function iE(l){return`${l}/microservices/oa-event-flow/proxy/api/events/stream?tags=${encodeURIComponent("service:code-queue")}`}function m2(){return{headers:{"cache-control":"no-cache","x-unidesk-no-cache":"1"}}}function Du(l){return Array.isArray(l?.tasks)?l.tasks:[]}function Nn(l){return l?.pagination&&typeof l.pagination==="object"&&!Array.isArray(l.pagination)?l.pagination:{}}function XN(l){let u=Date.parse(String(l?.updatedAt||l?.createdAt||""));return Number.isFinite(u)?u:0}function YN(l){return gn(l?.queueEnteredAt)??gn(l?.createdAt)??gn(l?.updatedAt)??0}function tE(l,u){let r=YN(l)-YN(u);if(r!==0)return r;let f=(gn(l?.createdAt)??0)-(gn(u?.createdAt)??0);if(f!==0)return f;return String(l?.id||"").localeCompare(String(u?.id||""))}function yE(l,u=""){let r=new Map;for(let f of l)for(let n of f){let i=String(n?.id||"");if(i.length>0&&!r.has(i))r.set(i,n)}return Array.from(r.values()).sort((f,n)=>{let i=kN(f)-kN(n);if(i!==0)return i;let t=String(f?.id||"")===u?0:1,y=String(n?.id||"")===u?0:1;if(t!==y)return t-y;return XN(n)-XN(f)})}function Qn(l,u=""){let r=new Map;for(let f of l)for(let n of f){let i=String(n?.id||"");if(i.length===0)continue;r.set(i,{...r.get(i)||{},...n})}return yE([Array.from(r.values())],u)}function fy(l){return Array.isArray(l?.activeTaskIds)?l.activeTaskIds.map((u)=>String(u||"")).filter(Boolean):[String(l?.activeTaskId||"")].filter(Boolean)}var Yi="__all__",cE="(max-width: 760px)",_E="(min-width: 761px)";function Pr(l){return!l||l===Yi}function $E(){return typeof window<"u"&&window.matchMedia(cE).matches}function AE(l){return Pr(l)?"":`&queueId=${encodeURIComponent(l)}`}function w2(l){return String(l||"").trim().replace(/\s+/gu," ").slice(0,200)}function jE(l){let u=w2(l);return u.length===0?"":`&search=${encodeURIComponent(u)}`}function K2(l,u=""){return`${AE(l)}${jE(u)}`}function t3(l,u){return Number(l?.counts?.[u]||0)}function PN(l,u=""){let r=new Map;for(let n of Array.isArray(l?.queues)?l.queues:[]){let i=String(n?.id||"").trim();if(i.length>0)r.set(i,{...n,name:String(n?.name||i).trim()||i})}for(let n of[String(l?.defaultQueueId||"default"),u].map((i)=>i.trim()).filter(Boolean))if(!r.has(n))r.set(n,{id:n,name:n,total:0,counts:{},activeTaskId:null,runnableTaskId:null,processing:!1});return Array.from(r.values()).sort((n,i)=>{let t=String(n?.id||"")===String(l?.defaultQueueId||"default")?0:1,y=String(i?.id||"")===String(l?.defaultQueueId||"default")?0:1;if(t!==y)return t-y;return String(n?.id||"").localeCompare(String(i?.id||""))})}function fQ(l){let u=String(l?.id||"default"),r=String(l?.name||"").trim();return r.length>0?r:u}function q2(l){let u=String(l?.id||"default"),r=fQ(l);return r===u?u:`${r} (${u})`}function fc(l){let u=t3(l,"running")+t3(l,"judging"),r=t3(l,"queued")+t3(l,"retry_wait"),f=Number(l?.total||0),n=[q2(l),`${f} tasks`];if(u>0)n.push(`${u} running`);if(r>0)n.push(`${r} queued`);return n.join(" · ")}function iy(l,u){if(Pr(u))return null;return l.find((r)=>String(r?.id||"")===u)||null}function CN(l,u,r,f){if(Pr(r)){let i=fy(l);return String(l?.activeTaskId||i[0]||f.find((t)=>vN(t))?.id||"")}let n=iy(u,r);return String(n?.activeTaskId||f.find((i)=>vN(i))?.id||"")}function FE(l,u,r){if(!Pr(u)){let f=iy(l,u);return String(f?.runnableTaskId||r.find((n)=>String(n?.status||"")==="queued"||String(n?.status||"")==="retry_wait")?.id||"")}return String(r.find((f)=>String(f?.status||"")==="queued"||String(f?.status||"")==="retry_wait")?.id||"")}async function MN(l,u=Yi,r=""){return Vu(Su(l,`/api/tasks/overview?limit=${dN}&transcriptLimit=1&compact=1&selected=0&includeActive=0&stats=0&skipTrace=1${K2(u,r)}`),m2())}async function A2(l,u,r=0,f=Yi,n="",i=!1,t={}){let y=t.selected===!1?"&selected=0":"",c=t.includeActive===!1?"&includeActive=0":"",$=t.stats===!1?"&stats=0":"",A=Number.isInteger(t.limit)&&t.limit>0?Math.min(500,t.limit):dN;return Vu(Su(l,`/api/tasks/overview?limit=${encodeURIComponent(String(A))}&transcriptLimit=3&compact=1&afterSeq=${encodeURIComponent(String(Math.max(0,r)))}&preferId=${encodeURIComponent(u)}${y}${c}${$}${i?"&skipTrace=1":""}${K2(f,n)}`),m2())}async function hN(l,u,r,f=eN,n=""){return Vu(Su(l,`/api/tasks/overview?limit=${encodeURIComponent(String(f))}&transcriptLimit=1&compact=1&selected=0&includeActive=0&stats=0&beforeId=${encodeURIComponent(r)}${K2(u,n)}`),m2())}async function JE(l,u){return Vu(Su(l,`/api/tasks/${encodeURIComponent(u)}/trace-summary`))}async function UE(l,u,r,f=null){let n=f===null||f===void 0||String(f).length===0?"":`&attempt=${encodeURIComponent(String(f))}`;return Vu(Su(l,`/api/tasks/${encodeURIComponent(u)}/prompt?part=${encodeURIComponent(r)}${n}`))}async function NE(l,u,r=0,f=500,n=null){let i=n===null||n===void 0||String(n).length===0?"":`&attempt=${encodeURIComponent(String(n))}`;return Vu(Su(l,`/api/tasks/${encodeURIComponent(u)}/trace-steps?afterSeq=${encodeURIComponent(String(r))}&limit=${encodeURIComponent(String(f))}${i}`))}async function QE(l,u,r){return Vu(Su(l,`/api/tasks/${encodeURIComponent(u)}/trace-step?seq=${encodeURIComponent(String(r))}`))}async function wE(l,u){return Vu(Su(l,`/api/tasks/${encodeURIComponent(u)}/read`),{method:"POST",body:{}})}async function qE(l){return Vu(Su(l,"/api/tasks/read-all"),{method:"POST",body:{}})}function WE(l){return Array.isArray(l?.output)?l.output:[]}function LE(l){return Array.isArray(l?.attempts)?l.attempts:[]}function j2(l){return l?.counts&&typeof l.counts==="object"&&!Array.isArray(l.counts)?l.counts:{}}function GE(l){return l.split(/^\s*---+\s*$/gmu).map((u)=>u.trim()).filter(Boolean)}function RN(l){let u=Number(l);return Number.isFinite(u)?Math.max(1,Math.min(50,Math.floor(u))):1}function V0(l){let u=[];for(let r of l.split(/[\s,,;;]+/u)){let f=r.trim();if(/^codex_\d+_[A-Za-z0-9_-]+$/u.test(f)&&!u.includes(f))u.push(f)}return u}function TE(l,u){let r=V0(u);if(r.length===0)return l;return[`引用 Code Queue 任务 ${r.join(" ")}。后端会在入队时只注入这些任务的 initial prompt 和 final response 全文;中间执行过程不注入,如需补充核查可运行:${r.map((f)=>`bun scripts/cli.ts codex task ${f}`).join(";")}`,"","本次任务:",l].join(` +`)}function mE(l){let f=l.trimStart();if(!f.startsWith("# Code Queue 已解析引用上下文"))return{hasInjection:!1,reference:"",userPrompt:l};let n=l.length-f.length,i=l.lastIndexOf(` # 本次任务 -`);if(i<n)return{hasInjection:!1,reference:"",userPrompt:u};return{hasInjection:!0,reference:u.slice(n,i).trimEnd(),userPrompt:u.slice(i+8).trimStart()}}function fO(u){let l=u.trimStart();if(!/^引用\s+Code Queue\s+任务\s+codex_\d+_[A-Za-z0-9_-]+/u.test(l))return u;let f=` +`);if(i<n)return{hasInjection:!1,reference:"",userPrompt:l};return{hasInjection:!0,reference:l.slice(n,i).trimEnd(),userPrompt:l.slice(i+8).trimStart()}}function KE(l){let u=l.trimStart();if(!/^引用\s+Code Queue\s+任务\s+codex_\d+_[A-Za-z0-9_-]+/u.test(u))return l;let r=` -本次任务:`,r=l.indexOf(f);if(r===-1)return u;return l.slice(r+f.length).trimStart()}function Di(u){return u.length>0?u.split(/\r\n|\r|\n/u).length:0}function xQ(u){let l=String(u?.displayPrompt||"");if(l.length>0)return l;let f=String(u?.prompt||"");return fO(lO(f).userPrompt)}function Fr(u){return u?._traceSummary&&typeof u._traceSummary==="object"&&!Array.isArray(u._traceSummary)?u._traceSummary:null}function f3(u){return u?._promptDetails&&typeof u._promptDetails==="object"&&!Array.isArray(u._promptDetails)?u._promptDetails:{}}function j2(u){let l=Fr(u)?.prompt;return l&&typeof l==="object"&&!Array.isArray(l)?l:{}}function hQ(u){let l=Fr(u)?.execution;return l&&typeof l==="object"&&!Array.isArray(l)?l:{}}function OQ(u){let l=Number(u);return Number.isFinite(l)&&l>=0?Math.floor(l):0}function xn(u){let l=Number(u);return Number.isFinite(l)&&l>=0?Math.floor(l):null}function bQ(u){let l=Ll(u?.traceStats);if(l&&(u?.statsSource==="oa-event-flow"||l.source==="oa-event-flow"))return l;let f=Fr(u),r=Ll(f?.traceStats);if(r&&(f?.statsSource==="oa-event-flow"||r.source==="oa-event-flow"))return r;return null}function rO(u,l){let f=Ll(l?.traceStats)||Ll(l?.execution?.traceStats),r=String(l?.statsSource||l?.execution?.statsSource||"");if(f&&(r==="oa-event-flow"||f.source==="oa-event-flow"))return f;return null}function nO(u,l){return xn(bQ(u)?.[l])}function vQ(u){let l=nO(u,"stepCount");if(l!==null)return l;let f=Fr(u);if(f!==null)return iO(f);return null}function iO(u){let l=Ll(u?.traceStats);if(!l||u?.statsSource!=="oa-event-flow"&&l.source!=="oa-event-flow")return null;return xn(l.stepCount)}function d$(u){if(!u||u?._traceSummaryLoaded!==!0)return!1;let l=Fr(u),f=String(u?._traceSummaryUpdatedAt||l?.updatedAt||""),r=String(u?.updatedAt||"");if(r.length>0){let n=hn(f),i=hn(r);if(n!==null&&i!==null){if(n+1<i)return!1}else if(f!==r)return!1}return!0}function l3(u){let l=j2(u),f=String(l.basePrompt||"");return f.length>0?f:xQ(u)}function kQ(u){let l=Fr(u);return String(l?.finalResponse||u?.finalResponse||"").trimEnd()}function IQ(u){let f=Fr(u)?.lastJudge||u?.lastJudge;return f&&typeof f==="object"&&!Array.isArray(f)?f:null}function Ll(u){return u&&typeof u==="object"&&!Array.isArray(u)?u:null}function tO(u){let l=Ll(u?.raw),f=Ll(u?.failureDetails)||Ll(l?.minimaxFailure);if(f===null)return"";let r=f.repairAttempt===void 0?"":`${f.repairAttempt}/${f.maxRepairAttempts??"?"}`;return[["provider",f.provider||"minimax"],["stage",f.stage],["model",f.model],["timedOut",f.timedOut],["durationMs",f.durationMs],["timeoutMs",f.timeoutMs],["promptChars",f.promptChars],["promptLines",f.promptLines],["payloadBytes",f.payloadBytes],["responseStatus",f.responseStatus],["repairAttempt",r],["errorName",f.errorName],["error",f.errorMessage],["responseContentPreview",f.responseContentPreview],["responseTextPreview",f.responseTextPreview]].filter(([,i])=>i!==void 0&&i!==null&&String(i).length>0).map(([i,t])=>`${i}: ${String(t)}`).join(` -`)}function gQ({judge:u,testId:l="codex-judge-failure-details"}){let f=tO(u);if(f.length===0)return null;return T("details",{className:"codex-judge-failure-details","data-testid":l},T("summary",null,"MiniMax failure details"),T("pre",null,f))}function yO(u){let l=Fr(u)?.attempts;if(Array.isArray(l)&&l.length>0)return l;let f=hQ(u),r=kQ(u),n=IQ(u);if(Object.keys(f).length===0&&r.length===0&&n===null)return[];return[{index:Number(u?.currentAttempt||1),mode:u?.currentMode||"initial",startedAt:u?.startedAt,finishedAt:u?.finishedAt,terminalStatus:u?.status,execution:f,finalResponse:r,finalResponseChars:r.length,judge:n}]}function cO(u,l){return Ll(l?.execution)||hQ(u)}function _O(u,l,f,r){let n=Fr(u),i=Number(n?.currentAttempt||u?.currentAttempt||0),t=Number(f),y=Number.isFinite(t)&&t>0&&t===i,c=CQ(u?.updatedAt,n?.updatedAt);if(y&&!l?.finishedAt&&c.length>0)return c;return String(l?.updatedAt||l?.finishedAt||r.effectiveEndAt||(y?c:"")||c||u?.finishedAt||u?.startedAt||"")}function $O(u,l){let f=String(l?.finalResponse||l?.finalResponsePreview||"");if(Object.prototype.hasOwnProperty.call(l||{},"finalResponse")||Object.prototype.hasOwnProperty.call(l||{},"finalResponsePreview"))return f.trimEnd();return f.length>0?f.trimEnd():kQ(u)}function sQ(u,l){if(Object.prototype.hasOwnProperty.call(l||{},"judge"))return Ll(l?.judge);return IQ(u)}function AO(u,l,f){if(!VO(u))return!1;if(F2(l,f))return!1;if(l?.finishedAt)return!1;if(["succeeded","failed","canceled"].includes(String(l?.terminalStatus||"")))return!1;let r=Fr(u),n=Number(r?.currentAttempt||u?.currentAttempt||0),i=Number(f);if(Number.isFinite(i)&&i>0&&Number.isFinite(n)&&n>0)return i===n;return!0}function aQ(u){return`feedback:${String(u||"latest")}`}function jO(u,l,f){let r=String(l?.feedbackPrompt||"").trimEnd(),n=String(l?.feedbackPromptPreview||r||"").trimEnd(),i=Number(l?.feedbackPromptChars||r.length||n.length||0),t=Number(l?.feedbackPromptLines||Di(r||n));if(r.length>0||n.length>0||i>0)return{text:r,preview:n,chars:i,lines:t,source:l?.feedbackPromptSource||"judge-feedback",forAttempt:l?.feedbackPromptForAttempt||Number(f||0)+1,truncated:Boolean(l?.feedbackPromptTruncated)};let y=sQ(u,l),c=String(y?.continuePrompt||"").trimEnd();if(y?.decision==="retry"&&c.length>0)return{text:"",preview:c,chars:c.length,lines:Di(c),source:"judge-continue-prompt",forAttempt:Number(f||0)+1,truncated:!1};return null}function FO(u){let l=j2(u);return Boolean(l.hasReferenceInjection||Number(l.referencePromptChars||0)>0||u?.referenceInjection||u?.referenceInjectionSummary)}function oQ(u,l=null){if(l!==null&&l!==void 0){let r=(Ll(u?._traceStepsByAttempt)||{})[String(l)];return Array.isArray(r)?r:[]}return Array.isArray(u?._traceSteps)?u._traceSteps:[]}function e1(u){let f=[u?.seq,...Array.isArray(u?.rawSeqs)?u.rawSeqs:[]].map((r)=>Number(r)).filter((r)=>Number.isFinite(r));return f.length>0?Math.max(...f):0}function UO(u){return(Array.isArray(u)?u:[]).reduce((l,f)=>Math.max(l,e1(f)),0)}function JO(u,l){let f=new Map;for(let r of[...Array.isArray(u)?u:[],...Array.isArray(l)?l:[]]){let n=String(r?.seq??`${r?.title||"step"}:${r?.at||""}`);f.set(n,{...f.get(n)||{},...r})}return Array.from(f.values()).sort((r,n)=>e1(r)-e1(n))}function Xi(u){return(Array.isArray(u?.summaryLines)?u.summaryLines:[]).map((l)=>String(l||""))}function QO(u){let l=String(u?.kind||"").trim().toLowerCase(),f=String(u?.status||"").trim().toLowerCase();return l==="error"||f==="error"}function r3(u){let l=String(u?.status||"").trim();if(l.length>0)return l;let f=Xi(u).join(` -`);return/^(item\/[A-Za-z]+(?:\/[A-Za-z]+)?):/u.exec(f)?.[1]||""}function ZQ(u){return/^item\/(?:started|completed): file changes status=/u.test(String(u||"").trim())}function NO(u){let l=Xi(u);for(let r=l.length-1;r>=0;r-=1){let n=/file changes status=([A-Za-z0-9_-]+)/u.exec(l[r]||"")?.[1];if(n)return n}let f=r3(u);if(f==="item/fileChange/outputDelta")return"updated";if(f==="item/started")return"started";if(f==="item/completed")return"completed";return f.replace(/^item\//u,"")||String(u?.status||"changed")}function qO(u){if(String(u?.kind||"")!=="edited")return!1;let l=String(u?.title||""),f=String(u?.status||""),r=Xi(u).join(` -`);if(l==="Edited files")return!0;if(/^item\/fileChange\//u.test(f))return!0;if((f==="item/started"||f==="item/completed")&&/file changes status=/u.test(r))return!0;if(/^Success\. Updated the following files:/mu.test(r))return!0;if(/^diff --git /mu.test(r))return!0;return/^([AMDRCU?]{1,2})\s+\S+/mu.test(r)}function wO(u){if(u.length<=1)return u[0];let l=u.find((i)=>r3(i)==="item/fileChange/outputDelta")||u.find((i)=>Xi(i).some((t)=>!ZQ(t)))||u.at(-1)||u[0],f=u.flatMap((i)=>Array.isArray(i?.rawSeqs)?i.rawSeqs:[i?.seq]).filter((i)=>i!==void 0),r=u.flatMap(Xi).filter((i)=>i.trim().length>0&&!ZQ(i)),n=u[u.length-1]||l;return{...l,at:l?.at||n?.at,title:String(l?.title||"Edited files"),status:NO(n),summaryLines:r.length>0?r:Xi(l),rawSeqs:f}}function WO(u){let l=Array.isArray(u)?u:[],f=[],r=[],n=()=>{if(r.length>0)f.push(wO(r));r=[]};for(let i of l){if(qO(i)){if(r3(i)==="item/started"&&r.length>0)n();if(r.push(i),r3(i)==="item/completed")n();continue}n(),f.push(i)}return n(),f}function LO(u){if(String(u?.kind||"")!=="message")return"";let l=String(u?.title||"").trim().toLowerCase();if(l!=="assistant message"&&l!=="reasoning")return"";return`${l}:${String(u?.status||"")}`}function TO(u){if(u.length<=1)return u[0];let l=u[0],f=u.at(-1)||l,r=u.flatMap((t)=>Array.isArray(t?.rawSeqs)?t.rawSeqs:[t?.seq]).filter((t)=>t!==void 0),n=[];for(let t of r)if(!n.includes(t))n.push(t);let i=u.flatMap(Xi).filter((t)=>t.trim().length>0);return{...l,seq:e1(f)||e1(l),at:f?.at||l?.at,summaryLines:i.length>0?[i.at(-1)||i[0]]:[],rawSeqs:n}}function KO(u){let l=Array.isArray(u)?u:[],f=[],r=[],n="",i=()=>{if(r.length>0)f.push(TO(r));r=[],n=""};for(let t of l){let y=LO(t);if(y.length>0&&y===n){r.push(t);continue}if(i(),y.length>0)r=[t],n=y;else f.push(t)}return i(),f}function GO(u){return KO(WO(u))}function zO(u){return{...u}}function t2(u,l=null){if(l!==null&&l!==void 0){let f=Ll(u?._traceStepsLoadedByAttempt)||{};return Boolean(f[String(l)])}return Boolean(u?._traceStepsLoaded)}function y2(u){return u?._traceStepDetails&&typeof u._traceStepDetails==="object"&&!Array.isArray(u._traceStepDetails)?u._traceStepDetails:{}}function EO(u,l){let f=Number(u?.index);return Number.isFinite(f)?f:l+1}function F2(u,l){return Boolean(u?.synthetic)||Number(l)<=0}function n3(u){let l=Number(u);return Number.isFinite(l)?String(l):void 0}function OO(u){let l=u?.timing&&typeof u.timing==="object"?u.timing:{},f=String(u?.status||"");if(["queued"].includes(f))return`等待 ${ar(l.queueWaitMs??l.totalElapsedMs)}`;if(["running","judging","retry_wait"].includes(f))return`耗时 ${ar(l.durationMs??l.totalElapsedMs)}`;return`耗时 ${ar(l.durationMs??l.totalElapsedMs)}`}function o1(u){return String(u?.queueId||"default")}function dQ(u){return Ll(u?.queuedReason)}function eQ(u){let l=String(u?.queuedReasonLabel||"").trim();if(l.length>0)return l.toUpperCase();let f=dQ(u),r=String(f?.label||"").trim();return r.length>0?r.toUpperCase():""}function ZO(u){let l=String(u?.status||"unknown");if(l!=="queued")return l;let f=eQ(u);return f.length>0?`QUEUED(${f})`:"QUEUED"}function HO(u){if(String(u?.status||"")!=="queued")return;let l=dQ(u),f=String(l?.message||"").trim(),r=eQ(u);if(f.length>0&&r.length>0)return`${r}: ${f}`;if(f.length>0)return f;return r.length>0?r:void 0}function BO(u){return{system:"SYS",user:"YOU",assistant:"GPT",reasoning:"THINK",command:"CMD",diff:"DIFF",tool:"TOOL",error:"ERR"}[u]||u.toUpperCase()}function HQ(u){return["running","judging","retry_wait"].includes(String(u?.status||""))}function VO(u){return String(u?.status||"")==="running"}function sr(u){return["succeeded","failed","canceled"].includes(String(u?.status||""))}function uN(u){if(u?.promptEditable===!0)return!0;if(u?.promptEditable===!1)return!1;return String(u?.status||"")==="queued"&&!u?.startedAt&&Number(u?.currentAttempt||0)===0&&!u?.codexThreadId&&!u?.nextMode}function Rn(u){if(!sr(u))return!1;if(u?.terminalUnread===!0)return!0;if(u?.terminalUnread===!1)return!1;return!u?.readAt}function sl(u){let l=Number(u||0);return Number.isFinite(l)?l:0}function mO(u){return sl(u.queued)+sl(u.retry_wait)}function DO(u){return sl(u.running)+sl(u.judging)}function pO(u,l){return Ll(u?.statistics)||Ll(l?.statistics)||{}}function SO(u){return Array.isArray(u?.daily)?u.daily:[]}function XO(u){return Ll(u?.totals)||{}}function U2(u,l){let f=Number(u?.[l]??0);return Number.isFinite(f)&&f>0?f:0}function e4(u,l){return u.reduce((f,r)=>Math.max(f,U2(r,l)),0)}var mi=700,BQ=220,m0=30,dt=24,d1=184,c2=d1-dt;function lN(u,l){if(l<=1)return mi/2;return m0+u*(mi-m0*2)/(l-1)}function fN(u,l){let f=l>0?l:1;return d1-Math.min(1,u/f)*c2}function u2(u,l,f){let r=u.length>0?u:[{[l]:0}],n=r.length>1?r:[r[0],r[0]];return n.map((i,t)=>`${lN(t,n.length).toFixed(2)},${fN(U2(i,l),f).toFixed(2)}`).join(" ")}function Cn(u){let l=String(u||"");return/^\d{4}-\d{2}-\d{2}$/u.test(l)?l.slice(5):l||"--"}function e$(u){if(!u)return"";return`${String(u.seriesKey||"")}:${String(u.row?.date||u.index||"")}`}function YO(u,l,f,r){let n=U2(u,r.key);return{...r,row:u,index:l,value:n,valueLabel:r.format(n),x:lN(l,f),y:fN(n,r.max),seriesKey:r.key}}function VQ(u){if(Rn(u))return 0;return{running:1,judging:2,retry_wait:3,queued:4,succeeded:8,failed:8,canceled:8}[String(u?.status||"")]??9}function I1(u){if(!u)return!1;if(u?._traceSummaryLoaded===!0)return!1;return u?.summaryOnly===!0||u?._metaLoaded!==!0}function PO(u){return Boolean(u?._metaLoaded)||u?.summaryOnly===!1}function CO(u,l,f){let r=String(u?.[f]||""),n=String(l?.[f]||"");return r.length>n.length?r:n}function _2(u,l,f){let r=Array.isArray(u?.[f])?u[f]:[],n=Array.isArray(l?.[f])?l[f]:[];if(n.length===0&&r.length>0)return r;return r.length>n.length?r:n}function mQ(u,l){let f=l?.summaryOnly===!0&&PO(u),r={...u,...l};if(!f)return r;for(let n of["prompt","basePrompt","displayPrompt","finalResponse"])r[n]=CO(u,l,n);for(let n of["promptHistory","attempts","output","events"])r[n]=_2(u,l,n);if(u?.referenceInjection?.items&&!l?.referenceInjection?.items)r.referenceInjection=u.referenceInjection;if(u?.referenceInjectionSummary&&!l?.referenceInjectionSummary)r.referenceInjectionSummary=u.referenceInjectionSummary;r.summaryOnly=u?.summaryOnly===!1?!1:l.summaryOnly,r._metaLoaded=u?._metaLoaded,r._detailLoaded=u?._detailLoaded,r._transcriptComplete=u?._transcriptComplete,r._transcriptPreview=Object.prototype.hasOwnProperty.call(l,"_transcriptPreview")?l._transcriptPreview:u?._transcriptPreview;for(let n of["_traceSummary","_traceSummaryLoaded","_traceSteps","_traceStepsLoaded","_traceStepsByAttempt","_traceStepsLoadedByAttempt","_traceStepsNextAfterSeqByAttempt","_traceStepDetails","_promptDetails"])if(!Object.prototype.hasOwnProperty.call(l,n)&&Object.prototype.hasOwnProperty.call(u||{},n))r[n]=u[n];return r}function DQ(u){let l=u?.selected,f=l?.task&&typeof l.task==="object"?l.task:null;if(f!==null){let n=Boolean(l?.preview);return{...f,transcript:Array.isArray(l?.transcript)?l.transcript:[],_detailLoaded:Array.isArray(l?.transcript)&&l.transcript.length>0,_transcriptComplete:Boolean(!n&&!l?.hasMore&&sr(f)),_transcriptPreview:n,_summaryLoaded:!0}}let r=vl(u)[0];return r?{...r,_summaryLoaded:!0}:null}function l2(u,l){let f=new Map;for(let r of[...Array.isArray(u)?u:[],...Array.isArray(l)?l:[]]){let n=`${Number(r?.seq??0)}:${String(r?.kind||"message")}`,i=f.get(n);if(!i){f.set(n,r);continue}let t={...i,...r};for(let[y,c]of[["bodyPreview","bodyOmittedLines"],["commandPreview","commandOmittedLines"]]){let $=String(i?.[y]||""),A=String(r?.[y]||"");if($.length>A.length)t[y]=i[y],t[c]=i[c]}f.set(n,t)}return Array.from(f.values()).sort((r,n)=>Number(r?.seq??0)-Number(n?.seq??0))}function u3(u){return(Array.isArray(u)?u:[]).reduce((l,f)=>Math.max(l,Number(f?.seq??0)),0)}function pQ(u,l=8){let f=Array.from(new Set((Array.isArray(u)?u:[]).map((n)=>Number(n?.seq??0)).filter((n)=>Number.isFinite(n)&&n>0))).sort((n,i)=>n-i);if(f.length===0)return 0;let r=f[Math.max(0,f.length-l)]??0;return Math.max(0,r-0.001)}function MO(u,l){let f=Array.isArray(u?.codeModels)?u.codeModels:Array.isArray(u?.codexModels)?u.codexModels:[],r=["gpt-5.5","gpt-5.4-mini","gpt-5.4","minimax-m2.7"];return Array.from(new Set([...f,...r,l].map((n)=>String(n||"").trim()).filter(Boolean)))}function RO(u,l){let r=(Array.isArray(u?.executionProviders)?u.executionProviders:[]).map((t)=>({id:String(t?.id||"").trim(),label:String(t?.label||t?.id||"").trim(),defaultWorkdir:String(t?.defaultWorkdir||"").trim(),supportsWindowsNativeCodex:t?.supportsWindowsNativeCodex===!0,windowsNativeDefaultWorkdir:String(t?.windowsNativeDefaultWorkdir||"").trim(),kind:String(t?.kind||"").trim()})).filter((t)=>t.id.length>0),n=String(u?.mainProviderId||u?.defaultProviderId||"D601").trim()||"D601",i=new Map;for(let t of[...r,{id:n,label:`${n} (local)`,defaultWorkdir:String(u?.defaultWorkdir||"/workspace"),supportsWindowsNativeCodex:!1,windowsNativeDefaultWorkdir:"",kind:"local"},l?{id:l,label:l,defaultWorkdir:J2(u,l),supportsWindowsNativeCodex:l!==n,windowsNativeDefaultWorkdir:String(u?.windowsNativeCodexDefaultWorkdir||"/mnt/f/Work/ConStart"),kind:""}:null].filter(Boolean))if(!i.has(t.id))i.set(t.id,t);return Array.from(i.values())}function xO(u,l){let r=(Array.isArray(u?.executionModes)?u.executionModes:[]).map((t)=>({id:String(t?.id||t?.kind||"").trim(),label:String(t?.label||t?.id||t?.kind||"").trim(),description:String(t?.description||"").trim(),defaultWorkdir:String(t?.defaultWorkdir||"").trim(),requiresProvider:t?.requiresProvider===!0,requiresWindowsCwd:t?.requiresWindowsCwd===!0})).filter((t)=>t.id.length>0),n=[{id:"default",label:"默认容器/本机",description:"Code Queue 所在节点用本机 Codex;远程 Provider 用执行容器 Codex。",defaultWorkdir:"",requiresProvider:!1,requiresWindowsCwd:!1},{id:"windows-native",label:"Windows 原生 Codex",description:"启动执行容器,但容器只做 stdio relay,Codex 运行在 Provider 的 Windows 宿主。",defaultWorkdir:String(u?.windowsNativeCodexDefaultWorkdir||"/mnt/f/Work/ConStart"),requiresProvider:!0,requiresWindowsCwd:!0}],i=new Map;for(let t of[...r,...n,l?{id:l,label:l,description:"",defaultWorkdir:"",requiresProvider:l==="windows-native",requiresWindowsCwd:l==="windows-native"}:null].filter(Boolean))if(!i.has(t.id))i.set(t.id,t);return Array.from(i.values())}function a1(u,l,f){if(l!=="windows-native")return J2(u,f);let r=Array.isArray(u?.executionModes)?u.executionModes.find((i)=>String(i?.id||i?.kind||"")==="windows-native"):null,n=Array.isArray(u?.executionProviders)?u.executionProviders.find((i)=>String(i?.id||"")===f):null;return String(n?.windowsNativeDefaultWorkdir||r?.defaultWorkdir||u?.windowsNativeCodexDefaultWorkdir||"/mnt/f/Work/ConStart")}function J2(u,l){let f=String(l||"").trim(),r=u?.defaultWorkdirByProvider&&typeof u.defaultWorkdirByProvider==="object"?u.defaultWorkdirByProvider:{};if(typeof r[f]==="string"&&String(r[f]).trim().length>0)return String(r[f]).trim();let n=Array.isArray(u?.executionProviders)?u.executionProviders.find((t)=>String(t?.id||"")===f):null;if(typeof n?.defaultWorkdir==="string"&&n.defaultWorkdir.trim().length>0)return n.defaultWorkdir.trim();let i=String(u?.mainProviderId||u?.defaultProviderId||"D601");return f===i?String(u?.defaultWorkdir||"/workspace"):String(u?.remoteDefaultWorkdir||"/home/ubuntu")}function uy(u){return String(u||"").trim().replace(/\/+$/u,"")||"/"}function hO(u,l,f){return String(u?.providerId||"")===String(l||"")&&String(u?.executionMode||"default")===String(f||"default")&&String(u?.path||"").trim().length>0}function bO(u,l,f,r,n){let i=new Map,t=uy(n),y=(c,$,A={})=>{let j=uy(c);if(j.length===0||i.has(j))return;i.set(j,{providerId:f,executionMode:r,path:j,source:$,createdAt:A?.createdAt||"",updatedAt:A?.updatedAt||""})};y(a1(u,r,f),"default");for(let c of Array.isArray(l)?l:[])if(hO(c,f,r))y(c.path,"saved",c);return y(n,"current"),Array.from(i.values()).sort((c,$)=>{if(c.path===t)return-1;if($.path===t)return 1;if(c.source==="default"&&$.source!=="default")return-1;if($.source==="default"&&c.source!=="default")return 1;return c.path.localeCompare($.path)})}function vO(u){return vQ(u)}function kO({task:u,selected:l,onSelect:f,onCopy:r,onReference:n,onMarkRead:i,copied:t,markingRead:y}){let c=u?.lastJudge||{},$=String(u?.id||""),A=Rn(u),j=CQ(u?.updatedAt,Fr(u)?.updatedAt),F=`最近更新: ${PQ(j)}`,J=vO(u),Q=J===null?"--":String(J),W=J===null?"STEP 统计中心同步中":"STEP 来自 OA Event Flow 统计中心";return T("article",{role:"button",tabIndex:0,className:`codex-task-card ${l?"selected":""} ${A?"unread-terminal":""}`,onClick:f,onKeyDown:(L)=>{if(L.key==="Enter"||L.key===" ")L.preventDefault(),f()},"data-unread-terminal":A?"true":"false","data-testid":`codex-task-${u?.id||"unknown"}`},A?T("span",{className:"codex-unread-badge",title:"待读","aria-label":"待读","data-testid":`codex-unread-task-${$||"unknown"}`}):null,T("div",{className:"codex-task-card-head"},T("div",{className:"codex-task-status-line"},T(pi,{status:u?.status,title:HO(u)},ZO(u))),T("span",{className:"mono-text"},`${u?.currentAttempt||0}/${u?.maxAttempts||0}`)),T("div",{className:"codex-task-id-row"},T("code",{title:$},$||"unknown"),T("div",{className:"codex-task-id-actions"},T("button",{type:"button",className:"codex-copy-id-btn",onClick:(L)=>{L.stopPropagation(),n($)},"data-testid":`codex-reference-task-${$||"unknown"}`},"引用"),T("button",{type:"button",className:"codex-copy-id-btn",onClick:(L)=>{L.stopPropagation(),r($)},"data-testid":`codex-copy-task-id-${$||"unknown"}`},t?"已复制":"复制ID"),A?T("button",{type:"button",className:"codex-copy-id-btn codex-mark-read-btn",disabled:Boolean(y),onClick:(L)=>{L.stopPropagation(),i($)},"data-testid":`codex-mark-task-read-${$||"unknown"}`},y?"标记中":"标为已读"):null)),T("strong",null,r2(xQ(u),120)||"空任务"),T("div",{className:"codex-task-meta"},T("span",null,`queue=${o1(u)}`),T("span",null,`provider=${u?.providerId||"D601"}`),T("span",null,`mode=${u?.executionMode||"default"}`),T("span",null,u?.model||"--"),T("span",null,OO(u))),T("div",{className:"codex-task-meta codex-task-update-meta"},T("span",{className:"codex-task-recent-update codex-task-step-count",title:W,"data-testid":`codex-task-step-count-${$||"unknown"}`},`STEP ${Q}`),T("span",{className:"codex-task-recent-update",title:j?`更新时间: ${wu(j)}`:F,"data-testid":`codex-task-recent-update-${$||"unknown"}`},F),T("span",null,wu(j||u?.updatedAt))),uN(u)?T("div",{className:"codex-judge-line","data-testid":`codex-task-prompt-editable-${$||"unknown"}`},"queued prompt 可编辑"):null,c?.decision?T("div",{className:"codex-judge-line"},`judge=${c.decision} ${Math.round(Number(c.confidence||0)*100)}%`):null)}function f2({title:u,tasks:l,selectedId:f,onSelect:r,onCopy:n,onReference:i,onMarkRead:t,copiedTaskId:y,markingReadTaskId:c,emptyText:$}){let A=Array.isArray(l)?l:[];return T("section",{className:"codex-task-section"},T("div",{className:"codex-task-section-head"},T("span",null,u),T("code",null,String(A.length))),A.length===0?T("p",{className:"codex-task-section-empty"},$):T("div",{className:"codex-task-section-list"},A.map((j)=>T(kO,{key:j.id,task:j,selected:f===j.id,onSelect:()=>r(j.id),onCopy:n,onReference:i,onMarkRead:t,copied:y===j.id,markingRead:c===j.id}))))}function IO(){return T("span",{className:"codex-stats-icon","aria-hidden":"true"},T("svg",{viewBox:"0 0 36 24",focusable:"false"},T("path",{className:"grid",d:"M3 20.5H33M3 12.5H33M3 4.5H33"}),T("polyline",{className:"line tasks",points:"3,18 9,14 15,15 21,8 27,10 33,4"}),T("polyline",{className:"line retry",points:"3,20 9,17 15,18 21,13 27,14 33,9"})))}function gO({stats:u,queueName:l,onRaw:f}){let r=SO(u),n=XO(u),i=r.at(-1)||{},t=e4(r,"executedTasks"),y=e4(r,"retryAttempts"),c=e4(r,"avgDurationMs"),$=r.length>0,A=Ll(u?.range)||{},[j,F]=vu(null),[J,Q]=vu(null),W=[];if(t>0)W.push(`tasks ${t}`);if(y>0)W.push(`retry ${y}`);if(c>0)W.push(`avg ${ar(c)}`);let L=[{key:"executedTasks",className:"tasks",label:"执行任务",max:t,format:(E)=>`${sl(E)} tasks`},{key:"retryAttempts",className:"retry",label:"重试次数",max:y,format:(E)=>`${sl(E)} retries`},{key:"avgDurationMs",className:"duration",label:"平均耗时",max:c,format:(E)=>ar(E)}],U=j||J,q=e$(U),N=String(U?.row?.date||""),w=U?{left:`${Math.max(8,Math.min(92,Number(U.x)/mi*100))}%`,top:`${Math.max(14,Math.min(86,Number(U.y)/BQ*100))}%`}:void 0;Mn(()=>{F(null),Q(null)},[l,A.startDate,A.endDate,r.length]);let G=(E)=>{F(E)},Z=(E)=>{let m=e$(E);Q((S)=>e$(S)===m?null:E),F(E)},H=L.flatMap((E)=>r.map((m,S)=>{let B=YO(m,S,r.length,E),D=e$(B),X=q===D,O=String(m?.date||`day-${S}`),Y=`${Cn(O)} ${E.label}: ${B.valueLabel}`;return T("g",{key:`${E.key}-${O}`,className:`stat-point-group ${E.className} ${X?"active":""}`,role:"button",tabIndex:0,"aria-label":Y,"data-testid":`codex-stats-point-${E.className}-${O}`,onMouseEnter:()=>G(B),onFocus:()=>G(B),onClick:()=>Z(B),onKeyDown:(p)=>{if(p.key==="Enter"||p.key===" ")p.preventDefault(),Z(B)}},T("circle",{className:"stat-hit-point",cx:B.x,cy:B.y,r:13}),T("circle",{className:`stat-point ${E.className} ${X?"active":""}`,cx:B.x,cy:B.y,r:X?5.6:4.2}))}));return T(ot,{title:"统计曲线",eyebrow:`Daily task stats / ${l}`,className:"codex-stats-panel",summary:T("span",null,`${Cn(A.startDate)} -> ${Cn(A.endDate)} · ${u?.timezone||"Asia/Shanghai"}`),actions:Ll(u)?T(MQ,{title:"Code Queue Stats",data:u,onOpen:f,testId:"raw-codex-stats"}):null},T("div",{className:"codex-stats-hero","data-testid":"codex-stats-panel"},T(IO),T("div",null,T("strong",null,`${sl(n.executedTasks)} tasks / ${sl(n.retryAttempts)} retries`),T("span",null,`平均完成耗时 ${ar(n.avgDurationMs??void 0)} · 终态 ${sl(n.completedTasks)} 个`))),$?T("div",{className:"codex-stats-chart","data-testid":"codex-stats-chart",onMouseLeave:()=>F(null)},T("svg",{viewBox:`0 0 ${mi} ${BQ}`,preserveAspectRatio:"none",role:"img","aria-label":"Code Queue daily task statistics"},T("line",{className:"axis",x1:m0,x2:mi-m0,y1:d1,y2:d1}),T("line",{className:"grid",x1:m0,x2:mi-m0,y1:dt+c2/2,y2:dt+c2/2}),T("line",{className:"grid",x1:m0,x2:mi-m0,y1:dt,y2:dt}),T("polyline",{className:"stat-line tasks",points:u2(r,"executedTasks",t)}),T("polyline",{className:"stat-line retry",points:u2(r,"retryAttempts",y)}),T("polyline",{className:"stat-line duration",points:u2(r,"avgDurationMs",c)}),U?T("g",{className:"stat-cursor-layer","data-testid":"codex-stats-active-point"},T("line",{className:"stat-cursor",x1:U.x,x2:U.x,y1:dt,y2:d1}),T("circle",{className:`stat-point-active ${U.className}`,cx:U.x,cy:U.y,r:8})):null,T("g",{className:"stat-point-layer"},H)),U?T("div",{className:"codex-stats-tooltip active",style:w,"data-testid":"codex-stats-tooltip"},T("b",null,Cn(U.row?.date)),T("span",null,`${U.label} · ${U.valueLabel}`),T("code",null,`${sl(U.row?.executedTasks)} exec / ${sl(U.row?.retryAttempts)} retry / ${ar(U.row?.avgDurationMs??void 0)}`)):null,T("div",{className:"codex-stats-legend"},T("span",{className:"tasks"},"执行任务"),T("span",{className:"retry"},"重试次数"),T("span",{className:"duration"},"平均耗时")),T("div",{className:"codex-stats-scale"},T("span",null,Cn(r[0]?.date)),T("span",null,W.join(" · ")||"暂无峰值"),T("span",null,Cn(r.at(-1)?.date))),T("div",{className:`codex-stats-focus ${U?"active":""}`,"data-testid":"codex-stats-focus"},U?T(uc.default.Fragment,null,T("div",null,T("strong",null,Cn(U.row?.date)),T("span",null,`${U.label} · ${U.valueLabel}`)),T("div",{className:"codex-stats-focus-metrics"},T("code",null,`${sl(U.row?.executedTasks)} exec`),T("code",null,`${sl(U.row?.retryAttempts)} retry`),T("code",null,ar(U.row?.avgDurationMs??void 0)))):T("span",null,"将鼠标悬停到曲线数据点查看明细,点击数据点可固定。"))):T(Si,{title:"暂无统计",text:"任务开始执行后会生成按天汇总的曲线。"}),T("div",{className:"codex-stats-summary-grid"},T("article",null,T("span",null,"今日执行"),T("strong",null,String(sl(i.executedTasks))),T("code",null,Cn(i.date))),T("article",null,T("span",null,"今日重试"),T("strong",null,String(sl(i.retryAttempts))),T("code",null,`累计 ${sl(n.retryAttempts)}`)),T("article",null,T("span",null,"平均耗时"),T("strong",null,ar(n.avgDurationMs??void 0)),T("code",null,`${sl(n.durationSamples)} samples`))),T("div",{className:"codex-stats-daily-list","data-testid":"codex-stats-daily-list"},r.slice(-7).map((E)=>T("div",{key:String(E?.date||""),className:`codex-stats-daily-row ${N===String(E?.date||"")?"active":""}`,"data-testid":`codex-stats-day-${String(E?.date||"unknown")}`},T("span",null,Cn(E?.date)),T("b",null,`${sl(E?.executedTasks)} exec`),T("b",null,`${sl(E?.retryAttempts)} retry`),T("code",null,ar(E?.avgDurationMs??void 0))))))}function sO({task:u,queueRows:l,busy:f,onMove:r}){let n=String(u?.id||""),i=o1(u),[t,y]=vu(i);Mn(()=>{y(i)},[n,i]);let c=!n||f||["running","judging","retry_wait"].includes(String(u?.status||""));return T("div",{className:"codex-task-move-control","data-testid":"codex-task-queue-move-control"},T("label",null,"任务 queue",T("select",{value:t,disabled:!n||f,onChange:($)=>y(String($.target.value||i)),"data-testid":"codex-task-queue-move-select"},l.map(($)=>T("option",{key:String($?.id||""),value:String($?.id||"")},s1($))))),T("button",{type:"button",className:"ghost-btn",disabled:c||t===i,onClick:()=>r(t),title:c?"运行中 / judging / retry_wait 的任务不能移动;请先打断或等当前 turn 结束":"移动已创建任务到另一个 queue","data-testid":"codex-task-queue-move-button"},"移动"))}function SQ(u,l=4){let f=(Array.isArray(u)?u:[]).map((n)=>String(n||"").trim()).filter(Boolean);if(f.length===0)return"--";let r=f.slice(0,l).join(" / ");return f.length>l?`${r} +${f.length-l}`:r}function aO({task:u,loading:l,onLoadPromptPart:f,testId:r="codex-initial-prompt-full",textTestId:n="codex-initial-prompt-full-text",baseTextTestId:i="codex-initial-prompt-base"}){let t=j2(u),y=f3(u),c=l3(u).trimEnd(),$=String(y.full?.text||""),A=FO(u),j=Number(t.promptChars||u?.promptChars||$.length),F=Number(t.basePromptLines||Di(c)),J=Number(t.promptLines||Di($));return T("section",{className:"codex-progressive-card codex-progressive-prompt","data-testid":"codex-progressive-prompt"},T("div",{className:"codex-progressive-card-head"},T("span",{className:"codex-output-channel"},"Prompt"),T("strong",null,"Submitted prompt / 原始用户 prompt"),T("code",null,`${F||Di(c)} lines / ${c.length} chars`)),T("pre",{className:"codex-prompt-full","data-testid":i},c||"空 prompt"),A?T("details",{className:"codex-reference-injection codex-progressive-full-prompt","data-testid":r,onToggle:(Q)=>{if(Q.currentTarget?.open&&!$)f?.("full")}},T("summary",null,T("span",null,"引用注入已折叠,点击按需拉取最终进入 Code agent 的完整 prompt"),T("code",null,$?`${J||Di($)} lines / ${$.length} chars`:`${Number.isFinite(j)&&j>0?j:"--"} chars`)),T("pre",{className:"codex-prompt-full codex-prompt-final-full","data-testid":n},$||(l?"正在按需拉取完整 prompt...":"展开后将只请求 full prompt,不拉取完整 transcript。"))):null)}function rN({task:u,attempt:l,attemptIndex:f,loading:r,onLoadSteps:n,onLoadStep:i,testId:t="codex-execution-summary"}){let y=GO(oQ(u,f)),c=zO(cO(u,l)),$=l?rO(u,l):bQ(u),A=y2(u),j=t2(u,f),F=xn($?.errorCount),J=xn($?.stepCount??$?.llmStepCount),Q=xn($?.readCount),W=xn($?.editCount),L=xn($?.runCount),U=xn($?.stepCount??$?.llmStepCount),q=J===null?"--":String(J),N=U===null?"--":String(U),w=Array.isArray(c.editedFiles)?c.editedFiles:[],G=Array.isArray(c.commands)?c.commands:[],H=F2(l,f)?` · ${String(l?.label||"recovered thread execution")}`:f?` #${f}`:"",E=_O(u,l,f,c),m=`最近更新: ${PQ(E)}`,S=AO(u,l,f);return T("details",{className:`codex-progressive-card codex-execution-summary ${S?"running":""}`,"data-testid":t,"data-attempt-index":n3(f),"data-running":S?"true":"false",onToggle:(B)=>{if(B.currentTarget?.open&&!j)n?.(f)}},T("summary",null,T("div",{className:"codex-progressive-card-head"},T("span",{className:"codex-output-channel"},"Summary"),T("strong",null,`执行过程摘要${H}`),S?T("span",{className:"codex-summary-running-pill","data-testid":`${t}-running`},"执行中"):null,T("code",{title:E?`最近更新: ${wu(E)}`:m},`${ar(c.durationMs??c.totalElapsedMs)} / ${q} tools / ${m}`)),T("div",{className:"codex-execution-digest"},T("span",{title:"来自 OA Event Flow 统计中心"},`read ${Q===null?"--":Q}`),T("span",{title:"来自 OA Event Flow 统计中心"},`edit ${W===null?"--":W}`),T("span",{title:"来自 OA Event Flow 统计中心"},`run ${L===null?"--":L}`),T("span",{title:"来自 OA Event Flow 统计中心"},`STEP ${N}`),F!==null&&F>0?T("span",{className:"codex-execution-error-pill","data-testid":`${t}-error-count`},`Error ${F}`):null)),T("div",{className:"codex-execution-digest expanded"},T("span",null,`修改文件:${SQ(w,6)}`),T("span",null,`执行命令:${SQ(G,4)}`)),y.length===0?T("div",{className:"codex-output-empty"},r?"正在按需拉取步骤 summary...":"展开后将只请求执行步骤 summary,不拉取单步骤全量。"):T("div",{className:"codex-trace-step-list"},y.map((B)=>{let D=String(B?.seq??""),X=A[D],O=Array.isArray(B?.summaryLines)?B.summaryLines.slice(0,4):[],Y=O.find((p)=>String(p||"").trim().length>0);return T("details",{key:D||`${B?.title}-${B?.at}`,className:`codex-trace-step ${String(B?.kind||"message")} ${QO(B)?"error":""}`,"data-testid":`codex-trace-step-${D||"unknown"}`,onToggle:(p)=>{if(p.currentTarget?.open&&!X)i?.(B?.seq)}},T("summary",null,T("span",{className:"codex-output-channel"},oO(B?.kind)),T("strong",null,String(B?.title||"Trace step")),B?.status?T("code",null,String(B.status)):null,Y?T("span",{className:"codex-trace-step-inline-summary",title:String(Y)},String(Y)):null,T("time",null,wu(B?.at))),T("div",{className:"codex-trace-step-summary"},O.length>0?O.map((p,v)=>T("pre",{key:`${D}-${v}`},String(p||""))):T("span",null,"无 summary")),X?.line?T(s$,{items:[X.line],autoScroll:!1,loading:!1,hasDetail:!0,emptyText:"无步骤详情",testId:`codex-trace-step-detail-${D||"unknown"}`,className:"codex-transcript codex-step-detail-transcript",collapseTools:!1}):T("div",{className:"codex-output-empty"},r?"正在按需拉取这个步骤的全量数据...":"展开后将只请求这个单步骤的全量数据。"))})))}function oO(u){let l=String(u||"");if(l==="ran")return"Ran";if(l==="explored")return"Explored";if(l==="edited")return"Edited";if(l==="error")return"Error";if(l==="system")return"System";return"Message"}function nN({task:u,attempt:l,attemptIndex:f,testId:r="codex-final-response"}){let n=$O(u,l);if(n.length===0)return null;let i=Number(l?.finalResponseChars||n.length),t=f?` #${f}`:"";return T("section",{className:"codex-progressive-card codex-final-response","data-testid":r,"data-attempt-index":n3(f)},T("div",{className:"codex-progressive-card-head"},T("span",{className:"codex-output-channel"},"Final"),T("strong",null,`最终 response${t}`),T("code",null,`${Number.isFinite(i)?i:n.length} chars`)),T(bJ,{markdown:n,className:"codex-transcript-body codex-markdown",testId:`${r}-markdown`}))}function iN({task:u,attempt:l,attemptIndex:f,testId:r="codex-progressive-judge"}){let n=sQ(u,l);if(!n?.decision)return null;let i=f?` #${f}`:"";return T("section",{className:"codex-progressive-card codex-progressive-judge","data-testid":r,"data-attempt-index":n3(f)},T("div",{className:"codex-progressive-card-head"},T("span",{className:"codex-output-channel"},"Judge"),T("strong",null,`完成判定${i}`),T("code",null,`${n.decision} ${Math.round(Number(n.confidence||0)*100)}%`)),T("div",{className:"codex-judge-card","data-testid":`${r}-card`},T(pi,{status:n.decision},n.decision),T("strong",null,`${Math.round(Number(n.confidence||0)*100)}% confidence`),T("p",{"data-testid":`${r}-reason`},n.reason||"--"),T(gQ,{judge:n,testId:`${r}-failure-details`}),n.continuePrompt?T("pre",{"data-testid":`${r}-continue-prompt`},String(n.continuePrompt||"")):null))}function dO({task:u,attempt:l,attemptIndex:f,loading:r,onLoadPromptPart:n,testId:i="codex-judge-feedback-prompt"}){let t=jO(u,l,f);if(t===null)return null;let y=aQ(f),$=f3(u)[y],A=String($?.text||"").trimEnd(),j=String(t.preview||t.text||"").trimEnd(),F=A||String(t.text||"").trimEnd(),J=Number($?.chars||t.chars||F.length||j.length),Q=Number($?.lines||t.lines||Di(F||j)),W=$?.forAttempt||t.forAttempt||Number(f||0)+1;return T("details",{className:"codex-progressive-card codex-judge-feedback-prompt","data-testid":i,"data-attempt-index":n3(f),onToggle:(L)=>{if(L.currentTarget?.open&&!A)n?.("feedback",f)}},T("summary",null,T("div",{className:"codex-progressive-card-head"},T("span",{className:"codex-output-channel"},"Prompt"),T("strong",null,`judge feedback prompt #${f} -> #${W}`),T("code",null,`${Q||"--"} lines / ${Number.isFinite(J)?J:j.length} chars`)),T("p",{className:"codex-feedback-preview","data-testid":`${i}-preview`},j||"展开后按需拉取 judge feedback prompt。")),T("pre",{className:"codex-prompt-full codex-feedback-full","data-testid":`${i}-text`},F||(r?"正在按需拉取 judge feedback prompt...":"展开后将只请求这一次 judge feedback prompt。")))}function eO({task:u,attempt:l,position:f,loading:r,onLoadPromptPart:n,onLoadSteps:i,onLoadStep:t}){let y=EO(l,f),c=f===0,$=F2(l,y),A=$?String(l?.label||"Recovered thread execution"):`Attempt ${y}`;return T("section",{className:"codex-attempt-cycle","data-testid":`codex-attempt-cycle-${y}`},T("div",{className:"codex-attempt-cycle-head"},T("span",{className:"codex-output-channel"},A),T("strong",null,String(l?.mode||(y<=1?"initial":"retry"))),l?.terminalStatus?T(pi,{status:l.terminalStatus},l.terminalStatus):null,T("code",null,`${wu(l?.startedAt)} -> ${wu(l?.finishedAt)}`)),T(rN,{task:u,attempt:l,attemptIndex:y,loading:r,onLoadSteps:i,onLoadStep:t,testId:c?"codex-execution-summary":`codex-execution-summary-attempt-${y}`}),$?null:T(nN,{task:u,attempt:l,attemptIndex:y,testId:c?"codex-final-response":`codex-final-response-attempt-${y}`}),$?null:T(iN,{task:u,attempt:l,attemptIndex:y,testId:c?"codex-progressive-judge":`codex-progressive-judge-attempt-${y}`}),$?null:T(dO,{task:u,attempt:l,attemptIndex:y,loading:r,onLoadPromptPart:n,testId:c?"codex-judge-feedback-prompt":`codex-judge-feedback-prompt-attempt-${y}`}))}function uZ({task:u,loading:l,onLoadPromptPart:f,onLoadSteps:r,onLoadStep:n}){if(!u)return T(Si,{title:"未选择任务",text:"从左侧队列选择任务,或提交新 Codex 任务。"});let i=yO(u);return T("div",{className:"codex-transcript codex-progressive-trace","data-testid":"codex-output"},l&&!Fr(u)?T("div",{className:"codex-output-empty"},"正在加载 Trace Summary..."):null,T(aO,{task:u,loading:l,onLoadPromptPart:f}),i.length>0?i.map((t,y)=>T(eO,{key:`${t?.index||y+1}-${t?.startedAt||y}`,task:u,attempt:t,position:y,loading:l,onLoadPromptPart:f,onLoadSteps:r,onLoadStep:n})):[T(rN,{key:"execution",task:u,loading:l,onLoadSteps:r,onLoadStep:n}),T(nN,{key:"final",task:u}),T(iN,{key:"judge",task:u})])}function lZ({task:u}){let l=oE(u);if(!u||l.length===0)return T(Si,{title:"暂无原始消息",text:"原始 Codex app-server 消息会保留在任务 JSON 中。"});return T("details",{className:"codex-raw-output"},T("summary",null,`原始 messages (${l.length})`),T("div",null,l.map((f)=>T("article",{key:`${f.seq}-${f.channel}`,className:`codex-output-line ${f.channel||"system"}`},T("div",{className:"codex-output-meta"},T("span",{className:"codex-output-channel"},BO(String(f.channel||"system"))),T("span",null,wu(f.at)),f.method?T("code",null,f.method):null),T("pre",null,String(f.text||""))))))}function fZ({task:u}){let l=dE(u).slice().reverse();if(l.length===0)return T(Si,{title:"尚无 attempt",text:"任务开始运行后,这里会记录 Codex 终态、传输中断和 stderr tail。"});return T("div",{className:"table-wrap codex-attempt-table"},T("table",null,T("thead",null,T("tr",null,T("th",null,"#"),T("th",null,"模式"),T("th",null,"终态"),T("th",null,"传输"),T("th",null,"退出"),T("th",null,"完成时间"))),T("tbody",null,l.map((f)=>T("tr",{key:`${f.index}-${f.startedAt}`},T("td",null,f.index),T("td",null,f.mode),T("td",null,T(pi,{status:f.terminalStatus||"unknown"},f.terminalStatus||"unknown")),T("td",null,f.transportClosedBeforeTerminal?T(pi,{status:"failed"},"closed-before-terminal"):T(pi,{status:"succeeded"},"normal")),T("td",null,`code=${f.appServerExitCode??"--"} signal=${f.appServerSignal??"--"}`),T("td",null,wu(f.finishedAt)))))))}function tN({microservices:u,onRaw:l,apiBaseUrl:f="/api",initialTasksData:r=null,standalone:n=!1}){let i=u.find((V)=>V.id==="code-queue")||null,t=DQ(r),y=String(t?.id||""),c=new Map;if(t!==null&&y.length>0)c.set(y,{task:t,maxSeq:u3(Array.isArray(t.transcript)?t.transcript:[]),complete:Boolean(t._transcriptComplete),completeUpdatedAt:t._transcriptComplete?String(t.updatedAt||""):""});let $=typeof performance>"u"?0:performance.now(),A=Ml(y),j=Ml(0),F=Ml(0),J=Ml(0),Q=Ml(!1),W=Ml(!1),L=Ml(!1),U=Ml(null),q=Ml(new Map),N=Ml(new Map),w=Ml(new Map),G=Ml(new Map),Z=Ml(new Set),H=Ml(null),E=Ml(null),m=Ml(!1),S=Ml(!1),B=Ml(Boolean(r)),D=Ml(new Map),X=Ml(new Set),O=Ml(c),Y=Ml(r),[p,v]=vu(null),[z,P]=vu(r),[k,I]=vu(y),[b,d]=vu(t),[s,h]=vu(!1),[lu,cu]=vu(""),[_u,Fu]=vu(null),[zu,Wu]=vu(!1),[C,e]=vu(!1),uu=r?.queue||{},Gu=String(uu?.mainProviderId||uu?.defaultProviderId||"D601").trim()||"D601",[a,qu]=vu(""),[Zu,Bu]=vu(""),[gu,ll]=vu("default"),[Pu,Nl]=vu(D0),[Qf,Zf]=vu(!1),[$f,nf]=vu(""),[tf,Mf]=vu(Gu),[$u,au]=vu("default"),[Nf,Yu]=vu("gpt-5.5"),[Sl,dl]=vu(a1(uu,"default",Gu)||"/workspace"),[rr,Af]=vu(99),[Hf,Gn]=vu(1),[nr,u0]=vu(!1),[$l,lt]=vu(!1),[fu,Vu]=vu(""),[Xu,ou]=vu(""),[Al,kl]=vu(""),[_l,qf]=vu(!0),[Sr,Dy]=vu(()=>typeof window>"u"?!0:window.matchMedia(ME).matches),[Kl,n_]=vu(!1),[aA,Ul]=vu(""),[O7,Xl]=vu(""),{addNotification:Bf}=Xf(),[ft,py]=vu(""),[rt,i_]=vu(""),[Sy,t_]=vu(!1),[y_,fi]=vu(null),[nt,ri]=vu(!1),[Rf,Xr]=vu(r?{phase:"complete",taskId:y,queueMs:0,detailMs:0,totalMs:$,chunks:t?1:0,transcriptRows:Array.isArray(t?.transcript)?t.transcript.length:0,partial:Boolean(r?.selected?.hasMore||I1(t)),completedAt:new Date}:null),[c_,Xy]=vu(r?new Date:null),[Yy,__]=vu(!1),fn=l0(vl(z)),Py=fn.filter(Rn),Yl=z?.queue||p?.body?.queue||p?.queue||{},oA=pO(z,Yl),$_=B0(z),Yr=TQ(Yl,gu),ni=String(gu||"default").trim()||"default",ii=Yr.filter((V)=>String(V?.id||"")!==ni),it=et(Yr,Pu),ti=Number((sf(Pu)?Yl?.total:it?.total)??$_.total??fn.length),tt=g1(Yl),Z7=sf(Pu)?tt:[String(et(Yr,Pu)?.activeTaskId||"")].filter(Boolean),yi=KQ(Yl,Yr,Pu,fn),H7=sf(Pu)?d4(Yl):d4(it||{}),A_=d4(Yl),Cy=mO(A_),dA=Math.max(DO(A_),tt.length),eA=sl((sf(Pu)?Yl?.unreadTerminal:it?.unreadTerminal)??Py.length),zn=z?Py.length:eA,j_=sf(Pu)?"All queues":i2(it||{id:Pu,name:Pu}),My=n2(lu),wr=My.length>0,B7=wr?l0(vl(_u)):[],u6=B0(_u),rn=wr?B7:fn,V7=rn.filter(Rn),cT=rn.filter((V)=>!sr(V)).sort(YE),_T=rn.filter((V)=>sr(V)&&!Rn(V)),m7=wr?u6:$_,yt=wr?Number(u6.total??B7.length):ti,D7=m7.hasMore===!0&&String(m7.nextBeforeId||"").length>0,l6=wr?C:Yy,$T=i?pE(i):{},AT=i?SE(i):{},f6=wQ(()=>eE(a),[a]),En=wQ(()=>{let V=EQ(Hf);return f6.flatMap((M)=>Array.from({length:V},()=>uO(M,Zu)))},[f6,Hf,Zu]),Ry=En.length,p7=Ry>1&&!nr,jT=$l||Kl||Ry===0||p7,S7=MO(Yl,Nf),F_=RO(Yl,tf),X7=xO(Yl,$u),Y7=a1(Yl,$u,tf),FT=Array.isArray(y_?.workdirs)?y_.workdirs:[],P7=bO(Yl,FT,tf,$u,Sl),r6=P7.some((V)=>V.source==="saved"&&uy(V.path)===uy(Sl)),n6=b?.id&&b?.activeTurnId&&String(b?.status)==="running",UT=b?.id&&!["succeeded","failed","canceled"].includes(String(b?.status||"")),JT=b?.id&&["succeeded","failed","canceled"].includes(String(b?.status||"")),ct=b?.id&&uN(b);function xf(V){let M=typeof V==="function"?V(Y.current):V;return Y.current=M,P(M),M}function QT(V,M,g=!0){let ru=Array.from(new Set(V.map((ju)=>String(ju||"")).filter(Boolean)));for(let ju of ru)if(D.current.set(ju,M),g)X.current.add(ju);return ru}function C7(V){for(let M of V.map((g)=>String(g||"")).filter(Boolean))D.current.delete(M),X.current.delete(M)}function U_(V){let M=String(V?.id||""),g=M?D.current.get(M):void 0;if(!g)return V;if(String(V?.status||"").length>0&&!sr(V))return D.current.delete(M),X.current.delete(M),V;return{...V,readAt:V?.readAt||g,terminalUnread:!1}}function i6(V){let M=String(V?.id||"");return M.length>0&&X.current.has(M)&&sr(V)}function l0(V,M=!0){let g=[];for(let ru of Array.isArray(V)?V:[]){let ju=U_(ru);if(M&&i6(ju))continue;g.push(ju)}return g}function NT(V,M=!0){if(!V||!Array.isArray(V?.tasks))return V;let g=l0(vl(V),M),ru=B0(V);return{...V,tasks:g,pagination:V.pagination?{...ru,returned:g.length}:V.pagination}}function qT(V){let M=String(V||Yl?.mainProviderId||"D601").trim()||"D601";Mf(M),dl(a1(Yl,$u,M)),fi(null),$6().catch((g)=>Ul(bl(g,"加载工作目录失败")))}function wT(V){let M=String(V||"default").trim()||"default",g=tf;if(M==="windows-native"){if(!F_.find((ju)=>ju.id===tf)?.supportsWindowsNativeCodex)g=String(F_.find((ju)=>ju.supportsWindowsNativeCodex)?.id||tf||"D601"),Mf(g)}au(M),dl(a1(Yl,M,g)),fi(null),$6().catch((ru)=>Ul(bl(ru,"加载工作目录失败")))}function J_(V,M,g=null,ru=null){let ju=new Set(QT(V,M));if(ju.size===0&&ru===null&&g===null)return;xf((Lu)=>{if(!Lu)return Lu;let Tu=vl(Lu).flatMap((xu)=>{let hu=String(xu?.id||"");if(!ju.has(hu)){let tl=U_(xu);return i6(tl)?[]:[tl]}let Mu=ru&&String(ru?.id||"")===hu?ru:{},ku={...xu,...Mu,readAt:M,terminalUnread:!1};return i6(ku)?[]:[ku]});return{...Lu,queue:g||Lu.queue,tasks:ju.size>0?V0([Tu],yi):Tu}});for(let Lu of ju){let Tu=O.current.get(Lu);if(Tu?.task){let xu=ru&&String(ru?.id||"")===Lu?ru:{},hu={...Tu.task,...xu,readAt:M,terminalUnread:!1};if(O.current.set(Lu,{...Tu,task:hu}),A.current===Lu)d(hu)}}}Mn(()=>{u0(!1)},[a,Hf,Zu]),Mn(()=>{let V=n2(lu);F.current+=1;let M=F.current;if(!i||V.length===0){Fu(null),Wu(!1),e(!1),L.current=!1;return}Wu(!0),Fu(null);let g=window.setTimeout(()=>{(async()=>{try{let ru=await GQ(f,Pu,V);if(M!==F.current)return;Fu(NT(ru))}catch(ru){if(M===F.current)Fu(null),Ul(bl(ru,"搜索 Codex tasks 失败"))}finally{if(M===F.current)Wu(!1)}})()},240);return()=>window.clearTimeout(g)},[i?.id,f,Pu,lu]),Mn(()=>{ou(b?l3(b):""),kl(Array.isArray(b?.referenceTaskIds)?b.referenceTaskIds.join(" "):"")},[k]);function Pr(V,M,g){let ru=O.current.get(V)||{},ju=ru.task||{},Lu=Array.isArray(ju.transcript)?ju.transcript:[],Tu=mQ(ju,M),xu=Object.prototype.hasOwnProperty.call(M,"transcript")?l2(Lu,Array.isArray(M.transcript)?M.transcript:[]):Lu,hu={...ju,...Tu,transcript:xu,output:Array.isArray(Tu.output)?_2(ju,Tu,"output"):Array.isArray(ju.output)?ju.output:[],events:Array.isArray(Tu.events)?_2(ju,Tu,"events"):Array.isArray(ju.events)?ju.events:[]},Mu=U_(hu),ku=String(Mu?.updatedAt||""),tl=Boolean(M._transcriptComplete)&&sr(Mu),el=Boolean(ru.complete)&&sr(Mu)&&String(ru.completeUpdatedAt||"")===ku,ul=tl||el,yf={...ru,task:Mu,maxSeq:u3(xu),complete:ul,completeUpdatedAt:ul?ku:""};if(O.current.set(V,yf),g===J.current&&A.current===V)d(Mu);return yf}async function ci(V,M=!1,g,ru){if(!i||!V)return;let Lu=O.current.get(V)?.task;if(!M&&d$(Lu))return;let Tu=V,xu=q.current.get(Tu);if(xu){if(M||!d$(Lu))xu.refreshAfter=!0;return xu.promise}let hu=J.current,Mu=performance.now();if(A.current===V)h(!0);let ku={promise:Promise.resolve(),refreshAfter:!1},tl=(async()=>{try{let el=await vE(f,V);if(hu!==J.current||A.current!==V)return;let ul=el?.summary||{},yf=String(ul.updatedAt||"");Pr(V,{id:V,status:ul.status,updatedAt:yf,startedAt:ul.startedAt,finishedAt:ul.finishedAt,currentAttempt:ul.currentAttempt,maxAttempts:ul.maxAttempts,finalResponse:ul.finalResponse,lastJudge:ul.lastJudge,lastError:ul.lastError,attempts:Array.isArray(ul.attempts)?ul.attempts:[],stepCount:ul.stepCount,llmStepCount:ul.llmStepCount,traceStats:ul.traceStats,statsSource:ul.statsSource,timing:ul.timing,_traceSummary:ul,_traceSummaryLoaded:!0,_traceSummaryUpdatedAt:yf,_detailLoaded:!0},hu),Xr({phase:"complete",taskId:V,queueMs:ru??0,detailMs:performance.now()-Mu,totalMs:g===void 0?performance.now()-Mu:performance.now()-g,chunks:1,transcriptRows:Number(ul?.execution?.traceLineCount||ul?.execution?.stepCount||0),partial:!1,completedAt:new Date})}finally{let el=Boolean(ku.refreshAfter&&A.current===V&&!d$(O.current.get(V)?.task));if(q.current.delete(Tu),hu===J.current&&A.current===V)h(!1);if(el)window.setTimeout(()=>{ci(V,!0).catch((ul)=>Ul(bl(ul,"自动刷新 Trace Summary 失败")))},0)}})();ku.promise=tl,q.current.set(Tu,ku),await tl}async function WT(V,M=null){let g=A.current;if(!i||!g||!V)return;let ru=O.current.get(g)?.task,ju=f3(ru),Lu=V==="feedback"||V==="judge-feedback"?aQ(M):V;if(ju[Lu]?.text)return;let Tu=`${g}:${Lu}`,xu=N.current.get(Tu);if(xu)return xu;let hu=J.current;if(A.current===g)h(!0);let Mu=(async()=>{try{let ku=await kE(f,g,V,M);if(hu!==J.current||A.current!==g)return;let tl=O.current.get(g)?.task,el=f3(tl);Pr(g,{...V==="full"?{prompt:String(ku?.text||""),promptChars:Number(ku?.chars||0)}:{},_promptDetails:{...el,[Lu]:ku}},hu)}finally{if(N.current.delete(Tu),hu===J.current&&A.current===g)h(!1)}})();N.current.set(Tu,Mu),await Mu}async function t6(V=null,M={}){let g=A.current;if(!i||!g)return;let ru=O.current.get(g)?.task,ju=V===null||V===void 0||String(V).length===0?"":String(V),Lu=t2(ru,ju||null),Tu=Boolean(M.force),xu=Boolean(M.incremental);if(Lu&&!Tu)return;let hu=oQ(ru,ju||null),Mu=xu&&hu.length>0?UO(hu):0,ku=`${g}:${ju||"all"}:${Mu}`,tl=w.current.get(ku);if(tl)return tl;let el=J.current;if(A.current===g)h(!0);let ul=(async()=>{try{let yf=await IE(f,g,Mu,500,ju||null);if(el!==J.current||A.current!==g)return;let nn=Array.isArray(yf?.steps)?yf.steps:[],On=Mu>0?JO(hu,nn):nn;if(ju){let f0=O.current.get(g)?.task,_t=Ll(f0?._traceStepsByAttempt)||{},Cr=Ll(f0?._traceStepsLoadedByAttempt)||{},Wr=Ll(f0?._traceStepsNextAfterSeqByAttempt)||{};Pr(g,{_traceStepsByAttempt:{..._t,[ju]:On},_traceStepsLoadedByAttempt:{...Cr,[ju]:!0},_traceStepsNextAfterSeqByAttempt:{...Wr,[ju]:yf?.nextAfterSeq}},el)}else Pr(g,{_traceSteps:On,_traceStepsLoaded:!0,_traceStepsHasMore:Boolean(yf?.hasMore),_traceStepsNextAfterSeq:yf?.nextAfterSeq},el)}finally{if(w.current.delete(ku),el===J.current&&A.current===g)h(!1)}})();w.current.set(ku,ul),await ul}async function LT(V){let M=A.current,g=String(V??"");if(!i||!M||g.length===0)return;let ru=O.current.get(M)?.task;if(y2(ru)[g]?.line)return;let Lu=`${M}:${g}`,Tu=G.current.get(Lu);if(Tu)return Tu;let xu=J.current;if(A.current===M)h(!0);let hu=(async()=>{try{let Mu=await gE(f,M,V);if(xu!==J.current||A.current!==M)return;let ku=O.current.get(M)?.task,tl=y2(ku);Pr(M,{_traceStepDetails:{...tl,[g]:Mu}},xu)}finally{if(G.current.delete(Lu),xu===J.current&&A.current===M)h(!1)}})();G.current.set(Lu,hu),await hu}function TT(V){if(A.current!==V)return;let M=O.current.get(V)?.task;if(!M)return;if(t2(M,null))t6(null,{force:!0,incremental:!0}).catch((ru)=>Ul(bl(ru,"增量刷新 Trace Steps 失败")));let g=Ll(M?._traceStepsLoadedByAttempt)||{};for(let ru of Object.keys(g).filter((ju)=>g[ju]))t6(ru,{force:!0,incremental:!0}).catch((ju)=>Ul(bl(ju,"增量刷新 Attempt Trace Steps 失败")))}async function sY(V,M,g){if(!i||!V)return;let ru=performance.now(),ju=J.current,Lu=O.current.get(V);if(Lu?.task){if(d(Lu.task),h(I1(Lu.task)||!Lu.complete),!I1(Lu.task)&&Lu.complete&&sr(Lu.task)&&String(Lu.completeUpdatedAt||"")===String(Lu.task?.updatedAt||"")){Xr({phase:"complete",taskId:V,queueMs:g??0,detailMs:0,totalMs:M===void 0?0:performance.now()-M,chunks:0,transcriptRows:Array.isArray(Lu.task.transcript)?Lu.task.transcript.length:0,completedAt:new Date});return}}else h(!0);let Tu=U.current;if(Tu?.taskId===V&&Tu.token===ju)return Tu.promise;let xu=(async()=>{try{let hu=await ml(Dl(f,`/api/tasks/${encodeURIComponent(V)}?meta=1`));if(ju!==J.current||A.current!==V)return;let Mu=O.current.get(V),ku=Array.isArray(Mu?.task?.transcript)?Mu.task.transcript:[],tl=hu?.task||{},el=Boolean(Mu?.complete)&&String(Mu?.completeUpdatedAt||"")===String(tl?.updatedAt||"");Pr(V,{...tl,summaryOnly:!1,_metaLoaded:!0,transcript:ku,_detailLoaded:ku.length>0,_transcriptComplete:el},ju);let ul=I1(Mu?.task)||Boolean(Mu?.task?._transcriptPreview),yf=ul?0:ku.length>0?pQ(ku):0,nn=!ul&&Mu?.complete&&sr(tl)&&String(Mu?.completeUpdatedAt||"")===String(tl?.updatedAt||"")?u3(ku):yf,On=!0,f0=0,_t=ku.length;while(On){let Cr=await ml(Dl(f,`/api/tasks/${encodeURIComponent(V)}/transcript?afterSeq=${encodeURIComponent(String(nn))}&limit=${VE}&fullText=1`));if(ju!==J.current||A.current!==V)return;let Wr=O.current.get(V),$t=Array.isArray(Wr?.task?.transcript)?Wr.task.transcript:[],_i=l2($t,Array.isArray(Cr?.transcript)?Cr.transcript:[]);f0+=1,_t=_i.length;let Pl=Boolean(!Cr?.hasMore);if(Pr(V,{status:Cr?.status||tl.status,updatedAt:Cr?.updatedAt||tl.updatedAt,transcript:_i,_detailLoaded:Pl||_i.length>0,_transcriptComplete:Pl,_transcriptPreview:ul&&!Pl},ju),On=Boolean(Cr?.hasMore),nn=Number(Cr?.nextAfterSeq??u3(_i)),!On)break;await new Promise((g7)=>window.setTimeout(g7,0))}Xr({phase:"complete",taskId:V,queueMs:g??0,detailMs:performance.now()-ru,totalMs:M===void 0?performance.now()-ru:performance.now()-M,chunks:f0,transcriptRows:_t,completedAt:new Date})}finally{if(U.current?.taskId===V&&U.current?.token===ju)U.current=null;if(ju===J.current&&A.current===V)h(!1)}})();U.current={taskId:V,token:ju,promise:xu},await xu}async function hf(V=A.current,M=!0,g=Pu){if(!i)return;if(!M&&S.current)return;let ru=performance.now();if(M)S.current=!0;if(M)Xr({phase:"loading",taskId:String(V||A.current||""),startedAt:new Date});let ju=j.current+1;j.current=ju;let Lu=String(V||A.current||""),Tu=Lu?O.current.get(Lu):null,xu=Array.isArray(Tu?.task?.transcript)?Tu.task.transcript:[],hu=pQ(xu),Mu=null,ku=M&&Lu.length===0;if(Mu=ku?await GQ(f,g,""):await o4(f,Lu,hu,g,"",!0,{stats:!1}),ju!==j.current){if(M)S.current=!1;return}let tl=performance.now()-ru;v(p||{});let el=Mu?.queue||{},ul=String(el?.activeTaskId||g1(el)[0]||""),yf=Mu;xf((Il)=>{let r0=vl(Mu),ir=vl(Il),Lr=ir.length>0?V0([ir,r0],ul):V0([r0],ul),n0=l0(Lr),Q_=B0(Mu),$i=B0(Il),j6=ir.length>r0.length&&($i.hasMore===!1||String($i.nextBeforeId||"").length>0),dT={...Q_,...j6?{hasMore:$i.hasMore,nextBeforeId:$i.nextBeforeId}:{},returned:n0.length};return yf={...Mu,tasks:n0,pagination:dT},yf});let nn=vl(yf),On=TQ(el,gu),f0=KQ(el,On,g,nn),_t=bE(On,g,nn),Cr=Lu||A.current,Wr=yf?.selected||null,$t=Wr?.task||null,_i=Array.isArray(Wr?.transcript)?Wr.transcript:null,Pl=Cr||f0||_t||nn[0]?.id||"";if(A.current!==Pl)J.current+=1;A.current=Pl,I(Pl);let At=nn.find((Il)=>Il.id===Pl);if(At){let Il=O.current.get(Pl);if(Il?.task)O.current.set(Pl,{...Il,task:{...At,...Il.task,status:At.status,updatedAt:At.updatedAt}})}if(ku&&At){if(Pr(Pl,{...At,_summaryLoaded:!1,transcript:[],_detailLoaded:!1,_transcriptComplete:!1,_transcriptPreview:!0},J.current),h(!0),Xr({phase:"complete",taskId:Pl,queueMs:tl,detailMs:0,totalMs:performance.now()-ru,chunks:0,transcriptRows:0,partial:!0,completedAt:new Date}),Xy(new Date),M)S.current=!1;ci(Pl,!0).catch((Il)=>Ul(bl(Il,"加载 Codex Trace Summary 失败"))),o4(f,Pl,0,g,"",!1).then((Il)=>{if(ju!==j.current)return;let r0=vl(Il),ir=DQ(Il);if(r0.length>0)xf((Lr)=>{let n0=V0([vl(Lr),r0],ul);return{...Lr,statistics:Il?.statistics||Lr?.statistics,tasks:l0(n0)}});if(ir?.id===A.current){let Lr=Array.isArray(ir.transcript)?ir.transcript:[];Pr(ir.id,{...ir,transcript:Lr,_summaryLoaded:!0,_detailLoaded:Lr.length>0,_transcriptPreview:Boolean(Il?.selected?.preview)},J.current)}}).catch(()=>{});return}if($t?.id===Pl&&_i!==null){let Il=O.current.get(Pl),r0=Array.isArray(Il?.task?.transcript)?Il.task.transcript:[],ir=l2(r0,_i),Lr=Boolean(Wr?.preview);if(Pr(Pl,{...$t,_summaryLoaded:!0,transcript:ir,_detailLoaded:!Wr?.hasMore||ir.length>0,_transcriptComplete:!Lr&&!Wr?.hasMore&&sr($t),_transcriptPreview:Lr},J.current),h(!1),M)Xr({phase:"complete",taskId:Pl,queueMs:tl,detailMs:Math.max(0,performance.now()-ru-tl),totalMs:performance.now()-ru,chunks:1,transcriptRows:ir.length,partial:Boolean(Lr||Wr?.hasMore||I1($t)),completedAt:new Date});if(Xy(new Date),M)S.current=!1;ci(Pl,!1,M?ru:void 0,M?tl:void 0).catch((n0)=>Ul(bl(n0,"加载 Codex Trace Summary 失败"))),o4(f,Lu,hu,g,"",!1).then((n0)=>{if(ju!==j.current)return;let Q_=vl(n0);if(Q_.length>0)xf(($i)=>{let j6=V0([vl($i),Q_],ul);return{...$i,tasks:l0(j6)}})}).catch(()=>{});return}if(M)Xr({phase:"session",taskId:Pl,queueMs:tl,totalMs:tl,startedAt:new Date(Date.now()-tl)});if(Pl)ci(Pl,!0,M?ru:void 0,M?tl:void 0).catch((Il)=>Ul(bl(Il,"加载 Codex Trace Summary 失败")));else if(J.current+=1,d(null),h(!1),M)Xr({phase:"complete",taskId:"",queueMs:tl,detailMs:0,totalMs:performance.now()-ru,chunks:0,transcriptRows:0,completedAt:new Date});if(Xy(new Date),M)S.current=!1}async function M7(){if(wr){if(!i||C||L.current)return;let M=String(u6.nextBeforeId||"");if(!M)return;L.current=!0,e(!0),Ul("");try{let g=await zQ(f,Pu,M,YQ,My),ru=vl(g),ju=g?.queue||Yl||{},Lu=String(ju?.activeTaskId||g1(ju)[0]||yi||"");Fu((Tu)=>{let xu=l0(V0([vl(Tu),ru],Lu)),hu=B0(g);return{...Tu||{},queue:ju,tasks:xu,pagination:{...hu,returned:xu.length}}})}catch(g){Ul(bl(g,"加载更多搜索结果失败"))}finally{L.current=!1,e(!1)}return}if(!i||Yy||W.current)return;let V=String(B0(z).nextBeforeId||"");if(!V)return;W.current=!0,__(!0),Ul("");try{let M=await zQ(f,Pu,V),g=vl(M),ru=M?.queue||Yl||{},ju=String(ru?.activeTaskId||g1(ru)[0]||yi||"");xf((Lu)=>{let Tu=l0(V0([vl(Lu),g],ju)),xu=B0(M);return{...Lu||{},queue:ru,statistics:M?.statistics||Lu?.statistics,tasks:Tu,pagination:{...xu,returned:Tu.length}}})}catch(M){Ul(bl(M,"加载更早 Codex tasks 失败"))}finally{W.current=!1,__(!1)}}function KT(V){let M=V.currentTarget;if(!M||l6||!D7)return;if(M.scrollHeight-M.scrollTop-M.clientHeight<120)M7()}async function Vf(V,M){n_(!0),Ul("");try{await V()}catch(g){Ul(bl(g,M))}finally{n_(!1)}}async function y6(V){if(!V)return;try{let M=!1;try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(V),M=!0}catch{M=!1}if(!M){let ru=document.createElement("textarea");ru.value=V,ru.style.position="fixed",ru.style.opacity="0",document.body.appendChild(ru),ru.select(),M=document.execCommand("copy"),document.body.removeChild(ru)}if(!M)throw Error("browser clipboard rejected the copy request");py(V);let g=`已复制任务 ID:${V}`;Xl(g),Bf("success",g),window.setTimeout(()=>py((ru)=>ru===V?"":ru),1600)}catch(M){Ul(`复制任务 ID 失败:${bl(M)}`)}}function c6(V){if(!V)return;Bu(V);let M=`已引用任务 ID:${V};提交时后端会读取并注入该任务上下文`;Xl(M),Bf("success",M)}async function _6(V){if(!i||!V)return;let M=new Date().toISOString();j.current+=1,J_([V],M,null,{id:V,readAt:M,terminalUnread:!1}),i_(V);let g=!1;if(await Vf(async()=>{let ru=await sE(f,V),ju=ru?.task||{id:V,readAt:new Date().toISOString(),terminalUnread:!1},Lu=String(ju?.readAt||new Date().toISOString());J_([V],Lu,ru?.queue||null,ju),g=!0;let Tu=`已将任务 ${V} 标为已读`;Xl(Tu),Bf("success",Tu)},"标记 Codex task 已读失败"),!g)C7([V]),hf(A.current,!1).catch((ru)=>Ul(bl(ru,"刷新 Codex tasks 失败")));i_((ru)=>ru===V?"":ru)}async function GT(){if(!i||Sy)return;t_(!0);let V=new Date().toISOString(),M=Array.from(new Set([...vl(Y.current).filter(Rn).map((ru)=>String(ru?.id||"")).filter(Boolean),...Array.from(O.current.entries()).filter(([,ru])=>Rn(ru?.task)).map(([ru])=>ru)]));if(j.current+=1,M.length>0)J_(M,V);let g=!1;if(await Vf(async()=>{let ru=await aE(f),ju=String(ru?.readAt||new Date().toISOString()),Lu=vl(Y.current).filter(Rn).map((ku)=>String(ku?.id||"")).filter(Boolean),Tu=Array.from(O.current.entries()).filter(([,ku])=>Rn(ku?.task)).map(([ku])=>ku),xu=Array.from(new Set([...M,...Lu,...Tu]));J_(xu,ju,ru?.queue||null);let hu=Number(ru?.count||xu.length);g=!0;let Mu=`已将 ${hu} 个已结束未读任务标为已读`;Xl(Mu),Bf("success",Mu)},"全部标为已读失败"),!g&&M.length>0)C7(M),hf(A.current,!1).catch((ru)=>Ul(bl(ru,"刷新 Codex tasks 失败")));t_(!1)}function zT(V){let M=V||D0;if(Nl(M),!sf(M))ll(M);if(xf(null),!(sf(M)?A.current:""))A.current="",J.current+=1,I(""),d(null),h(!0)}async function $6(){if(!i)return;let V=await ml(Dl(f,"/api/workdirs"));fi(V)}async function ET(){let V=Sl.trim()||Y7||"/workspace",M=typeof window>"u"?V:window.prompt("输入新的工作目录绝对路径",V),g=String(M||"").trim();if(!g)return;ri(!0),await Vf(async()=>{let ru=await ml(Dl(f,"/api/workdirs"),{method:"POST",body:{providerId:tf,executionMode:$u,path:g,ensure:!0}});fi((Lu)=>({...Lu||{},...ru})),dl(String(ru?.workdir?.path||g));let ju=`已保存工作目录:${String(ru?.workdir?.path||g)}`;Xl(ju),Bf("success",ju)},"创建工作目录失败"),ri(!1)}async function OT(){let V=uy(Sl);if(!r6){Xl("当前工作目录还没有保存到下拉菜单。");return}if(!(typeof window>"u"?!0:window.confirm(`从下拉菜单删除工作目录选项? -${V} +本次任务:`,f=u.indexOf(r);if(f===-1)return l;return u.slice(f+r.length).trimStart()}function X0(l){return l.length>0?l.split(/\r\n|\r|\n/u).length:0}function nQ(l){let u=String(l?.displayPrompt||"");if(u.length>0)return u;let r=String(l?.prompt||"");return KE(mE(r).userPrompt)}function Uf(l){return l?._traceSummary&&typeof l._traceSummary==="object"&&!Array.isArray(l._traceSummary)?l._traceSummary:null}function $3(l){return l?._promptDetails&&typeof l._promptDetails==="object"&&!Array.isArray(l._promptDetails)?l._promptDetails:{}}function z2(l){let u=Uf(l)?.prompt;return u&&typeof u==="object"&&!Array.isArray(u)?u:{}}function iQ(l){let u=Uf(l)?.execution;return u&&typeof u==="object"&&!Array.isArray(u)?u:{}}function xN(l){let u=Number(l);return Number.isFinite(u)&&u>=0?Math.floor(u):0}function kn(l){let u=Number(l);return Number.isFinite(u)&&u>=0?Math.floor(u):null}function tQ(l){let u=Gu(l?.traceStats);if(u&&(l?.statsSource==="oa-event-flow"||u.source==="oa-event-flow"))return u;let r=Uf(l),f=Gu(r?.traceStats);if(f&&(r?.statsSource==="oa-event-flow"||f.source==="oa-event-flow"))return f;return null}function zE(l,u){let r=Gu(u?.traceStats)||Gu(u?.execution?.traceStats),f=String(u?.statsSource||u?.execution?.statsSource||"");if(r&&(f==="oa-event-flow"||r.source==="oa-event-flow"))return r;return null}function EE(l,u){return kn(tQ(l)?.[u])}function yQ(l){let u=EE(l,"stepCount");if(u!==null)return u;let r=Uf(l);if(r!==null)return OE(r);return null}function OE(l){let u=Gu(l?.traceStats);if(!u||l?.statsSource!=="oa-event-flow"&&u.source!=="oa-event-flow")return null;return kn(u.stepCount)}function y3(l){if(!l||l?._traceSummaryLoaded!==!0)return!1;let u=Uf(l),r=String(l?._traceSummaryUpdatedAt||u?.updatedAt||""),f=String(l?.updatedAt||"");if(f.length>0){let n=gn(r),i=gn(f);if(n!==null&&i!==null){if(n+1<i)return!1}else if(r!==f)return!1}return!0}function _3(l){let u=z2(l),r=String(u.basePrompt||"");return r.length>0?r:nQ(l)}function cQ(l){let u=Uf(l);return String(u?.finalResponse||l?.finalResponse||"").trimEnd()}function _Q(l){let r=Uf(l)?.lastJudge||l?.lastJudge;return r&&typeof r==="object"&&!Array.isArray(r)?r:null}function Gu(l){return l&&typeof l==="object"&&!Array.isArray(l)?l:null}function ZE(l){let u=Gu(l?.raw),r=Gu(l?.failureDetails)||Gu(u?.minimaxFailure);if(r===null)return"";let f=r.repairAttempt===void 0?"":`${r.repairAttempt}/${r.maxRepairAttempts??"?"}`;return[["provider",r.provider||"minimax"],["stage",r.stage],["model",r.model],["timedOut",r.timedOut],["durationMs",r.durationMs],["timeoutMs",r.timeoutMs],["promptChars",r.promptChars],["promptLines",r.promptLines],["payloadBytes",r.payloadBytes],["responseStatus",r.responseStatus],["repairAttempt",f],["errorName",r.errorName],["error",r.errorMessage],["responseContentPreview",r.responseContentPreview],["responseTextPreview",r.responseTextPreview]].filter(([,i])=>i!==void 0&&i!==null&&String(i).length>0).map(([i,t])=>`${i}: ${String(t)}`).join(` +`)}function $Q({judge:l,testId:u="codex-judge-failure-details"}){let r=ZE(l);if(r.length===0)return null;return G("details",{className:"codex-judge-failure-details","data-testid":u},G("summary",null,"MiniMax failure details"),G("pre",null,r))}function pE(l){let u=Uf(l)?.attempts;if(Array.isArray(u)&&u.length>0)return u;let r=iQ(l),f=cQ(l),n=_Q(l);if(Object.keys(r).length===0&&f.length===0&&n===null)return[];return[{index:Number(l?.currentAttempt||1),mode:l?.currentMode||"initial",startedAt:l?.startedAt,finishedAt:l?.finishedAt,terminalStatus:l?.status,execution:r,finalResponse:f,finalResponseChars:f.length,judge:n}]}function HE(l,u){return Gu(u?.execution)||iQ(l)}function BE(l,u,r,f){let n=Uf(l),i=Number(n?.currentAttempt||l?.currentAttempt||0),t=Number(r),y=Number.isFinite(t)&&t>0&&t===i,c=uQ(l?.updatedAt,n?.updatedAt);if(y&&!u?.finishedAt&&c.length>0)return c;return String(u?.updatedAt||u?.finishedAt||f.effectiveEndAt||(y?c:"")||c||l?.finishedAt||l?.startedAt||"")}function DE(l,u){let r=String(u?.finalResponse||u?.finalResponsePreview||"");if(Object.prototype.hasOwnProperty.call(u||{},"finalResponse")||Object.prototype.hasOwnProperty.call(u||{},"finalResponsePreview"))return r.trimEnd();return r.length>0?r.trimEnd():cQ(l)}function AQ(l,u){if(Object.prototype.hasOwnProperty.call(u||{},"judge"))return Gu(u?.judge);return _Q(l)}function VE(l,u,r){if(!lO(l))return!1;if(E2(u,r))return!1;if(u?.finishedAt)return!1;if(["succeeded","failed","canceled"].includes(String(u?.terminalStatus||"")))return!1;let f=Uf(l),n=Number(f?.currentAttempt||l?.currentAttempt||0),i=Number(r);if(Number.isFinite(i)&&i>0&&Number.isFinite(n)&&n>0)return i===n;return!0}function jQ(l){return`feedback:${String(l||"latest")}`}function SE(l,u,r){let f=String(u?.feedbackPrompt||"").trimEnd(),n=String(u?.feedbackPromptPreview||f||"").trimEnd(),i=Number(u?.feedbackPromptChars||f.length||n.length||0),t=Number(u?.feedbackPromptLines||X0(f||n));if(f.length>0||n.length>0||i>0)return{text:f,preview:n,chars:i,lines:t,source:u?.feedbackPromptSource||"judge-feedback",forAttempt:u?.feedbackPromptForAttempt||Number(r||0)+1,truncated:Boolean(u?.feedbackPromptTruncated)};let y=AQ(l,u),c=String(y?.continuePrompt||"").trimEnd();if(y?.decision==="retry"&&c.length>0)return{text:"",preview:c,chars:c.length,lines:X0(c),source:"judge-continue-prompt",forAttempt:Number(r||0)+1,truncated:!1};return null}function XE(l){let u=z2(l);return Boolean(u.hasReferenceInjection||Number(u.referencePromptChars||0)>0||l?.referenceInjection||l?.referenceInjectionSummary)}function FQ(l,u=null){if(u!==null&&u!==void 0){let f=(Gu(l?._traceStepsByAttempt)||{})[String(u)];return Array.isArray(f)?f:[]}return Array.isArray(l?._traceSteps)?l._traceSteps:[]}function tc(l){let r=[l?.seq,...Array.isArray(l?.rawSeqs)?l.rawSeqs:[]].map((f)=>Number(f)).filter((f)=>Number.isFinite(f));return r.length>0?Math.max(...r):0}function YE(l){return(Array.isArray(l)?l:[]).reduce((u,r)=>Math.max(u,tc(r)),0)}function PE(l,u){let r=new Map;for(let f of[...Array.isArray(l)?l:[],...Array.isArray(u)?u:[]]){let n=String(f?.seq??`${f?.title||"step"}:${f?.at||""}`);r.set(n,{...r.get(n)||{},...f})}return Array.from(r.values()).sort((f,n)=>tc(f)-tc(n))}function C0(l){return(Array.isArray(l?.summaryLines)?l.summaryLines:[]).map((u)=>String(u||""))}function CE(l){let u=String(l?.kind||"").trim().toLowerCase(),r=String(l?.status||"").trim().toLowerCase();return u==="error"||r==="error"}function A3(l){let u=String(l?.status||"").trim();if(u.length>0)return u;let r=C0(l).join(` +`);return/^(item\/[A-Za-z]+(?:\/[A-Za-z]+)?):/u.exec(r)?.[1]||""}function bN(l){return/^item\/(?:started|completed): file changes status=/u.test(String(l||"").trim())}function ME(l){let u=C0(l);for(let f=u.length-1;f>=0;f-=1){let n=/file changes status=([A-Za-z0-9_-]+)/u.exec(u[f]||"")?.[1];if(n)return n}let r=A3(l);if(r==="item/fileChange/outputDelta")return"updated";if(r==="item/started")return"started";if(r==="item/completed")return"completed";return r.replace(/^item\//u,"")||String(l?.status||"changed")}function hE(l){if(String(l?.kind||"")!=="edited")return!1;let u=String(l?.title||""),r=String(l?.status||""),f=C0(l).join(` +`);if(u==="Edited files")return!0;if(/^item\/fileChange\//u.test(r))return!0;if((r==="item/started"||r==="item/completed")&&/file changes status=/u.test(f))return!0;if(/^Success\. Updated the following files:/mu.test(f))return!0;if(/^diff --git /mu.test(f))return!0;return/^([AMDRCU?]{1,2})\s+\S+/mu.test(f)}function RE(l){if(l.length<=1)return l[0];let u=l.find((i)=>A3(i)==="item/fileChange/outputDelta")||l.find((i)=>C0(i).some((t)=>!bN(t)))||l.at(-1)||l[0],r=l.flatMap((i)=>Array.isArray(i?.rawSeqs)?i.rawSeqs:[i?.seq]).filter((i)=>i!==void 0),f=l.flatMap(C0).filter((i)=>i.trim().length>0&&!bN(i)),n=l[l.length-1]||u;return{...u,at:u?.at||n?.at,title:String(u?.title||"Edited files"),status:ME(n),summaryLines:f.length>0?f:C0(u),rawSeqs:r}}function xE(l){let u=Array.isArray(l)?l:[],r=[],f=[],n=()=>{if(f.length>0)r.push(RE(f));f=[]};for(let i of u){if(hE(i)){if(A3(i)==="item/started"&&f.length>0)n();if(f.push(i),A3(i)==="item/completed")n();continue}n(),r.push(i)}return n(),r}function bE(l){if(String(l?.kind||"")!=="message")return"";let u=String(l?.title||"").trim().toLowerCase();if(u!=="assistant message"&&u!=="reasoning")return"";return`${u}:${String(l?.status||"")}`}function vE(l){if(l.length<=1)return l[0];let u=l[0],r=l.at(-1)||u,f=l.flatMap((t)=>Array.isArray(t?.rawSeqs)?t.rawSeqs:[t?.seq]).filter((t)=>t!==void 0),n=[];for(let t of f)if(!n.includes(t))n.push(t);let i=l.flatMap(C0).filter((t)=>t.trim().length>0);return{...u,seq:tc(r)||tc(u),at:r?.at||u?.at,summaryLines:i.length>0?[i.at(-1)||i[0]]:[],rawSeqs:n}}function sE(l){let u=Array.isArray(l)?l:[],r=[],f=[],n="",i=()=>{if(f.length>0)r.push(vE(f));f=[],n=""};for(let t of u){let y=bE(t);if(y.length>0&&y===n){f.push(t);continue}if(i(),y.length>0)f=[t],n=y;else r.push(t)}return i(),r}function kE(l){return sE(xE(l))}function gE(l){return{...l}}function W2(l,u=null){if(u!==null&&u!==void 0){let r=Gu(l?._traceStepsLoadedByAttempt)||{};return Boolean(r[String(u)])}return Boolean(l?._traceStepsLoaded)}function L2(l){return l?._traceStepDetails&&typeof l._traceStepDetails==="object"&&!Array.isArray(l._traceStepDetails)?l._traceStepDetails:{}}function IE(l,u){let r=Number(l?.index);return Number.isFinite(r)?r:u+1}function E2(l,u){return Boolean(l?.synthetic)||Number(u)<=0}function j3(l){let u=Number(l);return Number.isFinite(u)?String(u):void 0}function aE(l){let u=l?.timing&&typeof l.timing==="object"?l.timing:{},r=String(l?.status||"");if(["queued"].includes(r))return`等待 ${of(u.queueWaitMs??u.totalElapsedMs)}`;if(["running","judging","retry_wait"].includes(r))return`耗时 ${of(u.durationMs??u.totalElapsedMs)}`;return`耗时 ${of(u.durationMs??u.totalElapsedMs)}`}function ty(l){return String(l?.queueId||"default")}function JQ(l){return Gu(l?.queuedReason)}function UQ(l){let u=String(l?.queuedReasonLabel||"").trim();if(u.length>0)return u.toUpperCase();let r=JQ(l),f=String(r?.label||"").trim();return f.length>0?f.toUpperCase():""}function oE(l){let u=String(l?.status||"unknown");if(u!=="queued")return u;let r=UQ(l);return r.length>0?`QUEUED(${r})`:"QUEUED"}function dE(l){if(String(l?.status||"")!=="queued")return;let u=JQ(l),r=String(u?.message||"").trim(),f=UQ(l);if(r.length>0&&f.length>0)return`${f}: ${r}`;if(r.length>0)return r;return f.length>0?f:void 0}function eE(l){return{system:"SYS",user:"YOU",assistant:"GPT",reasoning:"THINK",command:"CMD",diff:"DIFF",tool:"TOOL",error:"ERR"}[l]||l.toUpperCase()}function vN(l){return["running","judging","retry_wait"].includes(String(l?.status||""))}function lO(l){return String(l?.status||"")==="running"}function af(l){return["succeeded","failed","canceled"].includes(String(l?.status||""))}function NQ(l){if(l?.promptEditable===!0)return!0;if(l?.promptEditable===!1)return!1;return String(l?.status||"")==="queued"&&!l?.startedAt&&Number(l?.currentAttempt||0)===0&&!l?.codexThreadId&&!l?.nextMode}function sn(l){if(!af(l))return!1;if(l?.terminalUnread===!0)return!0;if(l?.terminalUnread===!1)return!1;return!l?.readAt}function au(l){let u=Number(l||0);return Number.isFinite(u)?u:0}function uO(l){return au(l.queued)+au(l.retry_wait)}function rO(l){return au(l.running)+au(l.judging)}function fO(l,u){return Gu(l?.statistics)||Gu(u?.statistics)||{}}function nO(l){return Array.isArray(l?.daily)?l.daily:[]}function iO(l){return Gu(l?.totals)||{}}function O2(l,u){let r=Number(l?.[u]??0);return Number.isFinite(r)&&r>0?r:0}function F2(l,u){return l.reduce((r,f)=>Math.max(r,O2(f,u)),0)}var S0=700,sN=220,Xi=30,ny=24,ic=184,G2=ic-ny;function QQ(l,u){if(u<=1)return S0/2;return Xi+l*(S0-Xi*2)/(u-1)}function wQ(l,u){let r=u>0?u:1;return ic-Math.min(1,l/r)*G2}function J2(l,u,r){let f=l.length>0?l:[{[u]:0}],n=f.length>1?f:[f[0],f[0]];return n.map((i,t)=>`${QQ(t,n.length).toFixed(2)},${wQ(O2(i,u),r).toFixed(2)}`).join(" ")}function bn(l){let u=String(l||"");return/^\d{4}-\d{2}-\d{2}$/u.test(u)?u.slice(5):u||"--"}function c3(l){if(!l)return"";return`${String(l.seriesKey||"")}:${String(l.row?.date||l.index||"")}`}function tO(l,u,r,f){let n=O2(l,f.key);return{...f,row:l,index:u,value:n,valueLabel:f.format(n),x:QQ(u,r),y:wQ(n,f.max),seriesKey:f.key}}function kN(l){if(sn(l))return 0;return{running:1,judging:2,retry_wait:3,queued:4,succeeded:8,failed:8,canceled:8}[String(l?.status||"")]??9}function uc(l){if(!l)return!1;if(l?._traceSummaryLoaded===!0)return!1;return l?.summaryOnly===!0||l?._metaLoaded!==!0}function yO(l){return Boolean(l?._metaLoaded)||l?.summaryOnly===!1}function cO(l,u,r){let f=String(l?.[r]||""),n=String(u?.[r]||"");return f.length>n.length?f:n}function T2(l,u,r){let f=Array.isArray(l?.[r])?l[r]:[],n=Array.isArray(u?.[r])?u[r]:[];if(n.length===0&&f.length>0)return f;return f.length>n.length?f:n}function gN(l,u){let r=u?.summaryOnly===!0&&yO(l),f={...l,...u};if(!r)return f;for(let n of["prompt","basePrompt","displayPrompt","finalResponse"])f[n]=cO(l,u,n);for(let n of["promptHistory","attempts","output","events"])f[n]=T2(l,u,n);if(l?.referenceInjection?.items&&!u?.referenceInjection?.items)f.referenceInjection=l.referenceInjection;if(l?.referenceInjectionSummary&&!u?.referenceInjectionSummary)f.referenceInjectionSummary=l.referenceInjectionSummary;f.summaryOnly=l?.summaryOnly===!1?!1:u.summaryOnly,f._metaLoaded=l?._metaLoaded,f._detailLoaded=l?._detailLoaded,f._transcriptComplete=l?._transcriptComplete,f._transcriptPreview=Object.prototype.hasOwnProperty.call(u,"_transcriptPreview")?u._transcriptPreview:l?._transcriptPreview;for(let n of["_traceSummary","_traceSummaryLoaded","_traceSteps","_traceStepsLoaded","_traceStepsByAttempt","_traceStepsLoadedByAttempt","_traceStepsNextAfterSeqByAttempt","_traceStepDetails","_promptDetails"])if(!Object.prototype.hasOwnProperty.call(u,n)&&Object.prototype.hasOwnProperty.call(l||{},n))f[n]=l[n];return f}function IN(l){let u=l?.selected,r=u?.task&&typeof u.task==="object"?u.task:null;if(r!==null){let n=Boolean(u?.preview);return{...r,transcript:Array.isArray(u?.transcript)?u.transcript:[],_detailLoaded:Array.isArray(u?.transcript)&&u.transcript.length>0,_transcriptComplete:Boolean(!n&&!u?.hasMore&&af(r)),_transcriptPreview:n,_summaryLoaded:!0}}let f=Du(l)[0];return f?{...f,_summaryLoaded:!0}:null}function U2(l,u){let r=new Map;for(let f of[...Array.isArray(l)?l:[],...Array.isArray(u)?u:[]]){let n=`${Number(f?.seq??0)}:${String(f?.kind||"message")}`,i=r.get(n);if(!i){r.set(n,f);continue}let t={...i,...f};for(let[y,c]of[["bodyPreview","bodyOmittedLines"],["commandPreview","commandOmittedLines"]]){let $=String(i?.[y]||""),A=String(f?.[y]||"");if($.length>A.length)t[y]=i[y],t[c]=i[c]}r.set(n,t)}return Array.from(r.values()).sort((f,n)=>Number(f?.seq??0)-Number(n?.seq??0))}function rc(l){return(Array.isArray(l)?l:[]).reduce((u,r)=>Math.max(u,Number(r?.seq??0)),0)}function aN(l,u=8){let r=Array.from(new Set((Array.isArray(l)?l:[]).map((n)=>Number(n?.seq??0)).filter((n)=>Number.isFinite(n)&&n>0))).sort((n,i)=>n-i);if(r.length===0)return 0;let f=r[Math.max(0,r.length-u)]??0;return Math.max(0,f-0.001)}function _O(l,u){let r=Array.isArray(l?.codeModels)?l.codeModels:Array.isArray(l?.codexModels)?l.codexModels:[],f=["gpt-5.5","gpt-5.4-mini","gpt-5.4","minimax-m2.7"];return Array.from(new Set([...r,...f,u].map((n)=>String(n||"").trim()).filter(Boolean)))}function $O(l,u){let f=(Array.isArray(l?.executionProviders)?l.executionProviders:[]).map((t)=>({id:String(t?.id||"").trim(),label:String(t?.label||t?.id||"").trim(),defaultWorkdir:String(t?.defaultWorkdir||"").trim(),supportsWindowsNativeCodex:t?.supportsWindowsNativeCodex===!0,windowsNativeDefaultWorkdir:String(t?.windowsNativeDefaultWorkdir||"").trim(),kind:String(t?.kind||"").trim()})).filter((t)=>t.id.length>0),n=String(l?.mainProviderId||l?.defaultProviderId||"D601").trim()||"D601",i=new Map;for(let t of[...f,{id:n,label:`${n} (local)`,defaultWorkdir:String(l?.defaultWorkdir||"/workspace"),supportsWindowsNativeCodex:!1,windowsNativeDefaultWorkdir:"",kind:"local"},u?{id:u,label:u,defaultWorkdir:Z2(l,u),supportsWindowsNativeCodex:u!==n,windowsNativeDefaultWorkdir:String(l?.windowsNativeCodexDefaultWorkdir||"/mnt/f/Work/ConStart"),kind:""}:null].filter(Boolean))if(!i.has(t.id))i.set(t.id,t);return Array.from(i.values())}function AO(l,u){let f=(Array.isArray(l?.executionModes)?l.executionModes:[]).map((t)=>({id:String(t?.id||t?.kind||"").trim(),label:String(t?.label||t?.id||t?.kind||"").trim(),description:String(t?.description||"").trim(),defaultWorkdir:String(t?.defaultWorkdir||"").trim(),requiresProvider:t?.requiresProvider===!0,requiresWindowsCwd:t?.requiresWindowsCwd===!0})).filter((t)=>t.id.length>0),n=[{id:"default",label:"默认容器/本机",description:"Code Queue 所在节点用本机 Codex;远程 Provider 用执行容器 Codex。",defaultWorkdir:"",requiresProvider:!1,requiresWindowsCwd:!1},{id:"windows-native",label:"Windows 原生 Codex",description:"启动执行容器,但容器只做 stdio relay,Codex 运行在 Provider 的 Windows 宿主。",defaultWorkdir:String(l?.windowsNativeCodexDefaultWorkdir||"/mnt/f/Work/ConStart"),requiresProvider:!0,requiresWindowsCwd:!0}],i=new Map;for(let t of[...f,...n,u?{id:u,label:u,description:"",defaultWorkdir:"",requiresProvider:u==="windows-native",requiresWindowsCwd:u==="windows-native"}:null].filter(Boolean))if(!i.has(t.id))i.set(t.id,t);return Array.from(i.values())}function nc(l,u,r){if(u!=="windows-native")return Z2(l,r);let f=Array.isArray(l?.executionModes)?l.executionModes.find((i)=>String(i?.id||i?.kind||"")==="windows-native"):null,n=Array.isArray(l?.executionProviders)?l.executionProviders.find((i)=>String(i?.id||"")===r):null;return String(n?.windowsNativeDefaultWorkdir||f?.defaultWorkdir||l?.windowsNativeCodexDefaultWorkdir||"/mnt/f/Work/ConStart")}function Z2(l,u){let r=String(u||"").trim(),f=l?.defaultWorkdirByProvider&&typeof l.defaultWorkdirByProvider==="object"?l.defaultWorkdirByProvider:{};if(typeof f[r]==="string"&&String(f[r]).trim().length>0)return String(f[r]).trim();let n=Array.isArray(l?.executionProviders)?l.executionProviders.find((t)=>String(t?.id||"")===r):null;if(typeof n?.defaultWorkdir==="string"&&n.defaultWorkdir.trim().length>0)return n.defaultWorkdir.trim();let i=String(l?.mainProviderId||l?.defaultProviderId||"D601");return r===i?String(l?.defaultWorkdir||"/workspace"):String(l?.remoteDefaultWorkdir||"/home/ubuntu")}function yy(l){return String(l||"").trim().replace(/\/+$/u,"")||"/"}function jO(l,u,r){return String(l?.providerId||"")===String(u||"")&&String(l?.executionMode||"default")===String(r||"default")&&String(l?.path||"").trim().length>0}function FO(l,u,r,f,n){let i=new Map,t=yy(n),y=(c,$,A={})=>{let j=yy(c);if(j.length===0||i.has(j))return;i.set(j,{providerId:r,executionMode:f,path:j,source:$,createdAt:A?.createdAt||"",updatedAt:A?.updatedAt||""})};y(nc(l,f,r),"default");for(let c of Array.isArray(u)?u:[])if(jO(c,r,f))y(c.path,"saved",c);return y(n,"current"),Array.from(i.values()).sort((c,$)=>{if(c.path===t)return-1;if($.path===t)return 1;if(c.source==="default"&&$.source!=="default")return-1;if($.source==="default"&&c.source!=="default")return 1;return c.path.localeCompare($.path)})}function JO(l){return yQ(l)}function UO({task:l,selected:u,onSelect:r,onCopy:f,onReference:n,onMarkRead:i,copied:t,markingRead:y}){let c=l?.lastJudge||{},$=String(l?.id||""),A=sn(l),j=uQ(l?.updatedAt,Uf(l)?.updatedAt),F=`最近更新: ${lQ(j)}`,U=JO(l),N=U===null?"--":String(U),W=U===null?"STEP 统计中心同步中":"STEP 来自 OA Event Flow 统计中心";return G("article",{role:"button",tabIndex:0,className:`codex-task-card ${u?"selected":""} ${A?"unread-terminal":""}`,onClick:r,onKeyDown:(L)=>{if(L.key==="Enter"||L.key===" ")L.preventDefault(),r()},"data-unread-terminal":A?"true":"false","data-testid":`codex-task-${l?.id||"unknown"}`},A?G("span",{className:"codex-unread-badge",title:"待读","aria-label":"待读","data-testid":`codex-unread-task-${$||"unknown"}`}):null,G("div",{className:"codex-task-card-head"},G("div",{className:"codex-task-status-line"},G(Y0,{status:l?.status,title:dE(l)},oE(l))),G("span",{className:"mono-text"},`${l?.currentAttempt||0}/${l?.maxAttempts||0}`)),G("div",{className:"codex-task-id-row"},G("code",{title:$},$||"unknown"),G("div",{className:"codex-task-id-actions"},G("button",{type:"button",className:"codex-copy-id-btn",onClick:(L)=>{L.stopPropagation(),n($)},"data-testid":`codex-reference-task-${$||"unknown"}`},"引用"),G("button",{type:"button",className:"codex-copy-id-btn",onClick:(L)=>{L.stopPropagation(),f($)},"data-testid":`codex-copy-task-id-${$||"unknown"}`},t?"已复制":"复制ID"),A?G("button",{type:"button",className:"codex-copy-id-btn codex-mark-read-btn",disabled:Boolean(y),onClick:(L)=>{L.stopPropagation(),i($)},"data-testid":`codex-mark-task-read-${$||"unknown"}`},y?"标记中":"标为已读"):null)),G("strong",null,Q2(nQ(l),120)||"空任务"),G("div",{className:"codex-task-meta"},G("span",null,`queue=${ty(l)}`),G("span",null,`provider=${l?.providerId||"D601"}`),G("span",null,`mode=${l?.executionMode||"default"}`),G("span",null,l?.model||"--"),G("span",null,aE(l))),G("div",{className:"codex-task-meta codex-task-update-meta"},G("span",{className:"codex-task-recent-update codex-task-step-count",title:W,"data-testid":`codex-task-step-count-${$||"unknown"}`},`STEP ${N}`),G("span",{className:"codex-task-recent-update",title:j?`更新时间: ${Wl(j)}`:F,"data-testid":`codex-task-recent-update-${$||"unknown"}`},F),G("span",null,Wl(j||l?.updatedAt))),NQ(l)?G("div",{className:"codex-judge-line","data-testid":`codex-task-prompt-editable-${$||"unknown"}`},"queued prompt 可编辑"):null,c?.decision?G("div",{className:"codex-judge-line"},`judge=${c.decision} ${Math.round(Number(c.confidence||0)*100)}%`):null)}function N2({title:l,tasks:u,selectedId:r,onSelect:f,onCopy:n,onReference:i,onMarkRead:t,copiedTaskId:y,markingReadTaskId:c,emptyText:$}){let A=Array.isArray(u)?u:[];return G("section",{className:"codex-task-section"},G("div",{className:"codex-task-section-head"},G("span",null,l),G("code",null,String(A.length))),A.length===0?G("p",{className:"codex-task-section-empty"},$):G("div",{className:"codex-task-section-list"},A.map((j)=>G(UO,{key:j.id,task:j,selected:r===j.id,onSelect:()=>f(j.id),onCopy:n,onReference:i,onMarkRead:t,copied:y===j.id,markingRead:c===j.id}))))}function NO(){return G("span",{className:"codex-stats-icon","aria-hidden":"true"},G("svg",{viewBox:"0 0 36 24",focusable:"false"},G("path",{className:"grid",d:"M3 20.5H33M3 12.5H33M3 4.5H33"}),G("polyline",{className:"line tasks",points:"3,18 9,14 15,15 21,8 27,10 33,4"}),G("polyline",{className:"line retry",points:"3,20 9,17 15,18 21,13 27,14 33,9"})))}function QO({stats:l,queueName:u,onRaw:r}){let f=nO(l),n=iO(l),i=f.at(-1)||{},t=F2(f,"executedTasks"),y=F2(f,"retryAttempts"),c=F2(f,"avgDurationMs"),$=f.length>0,A=Gu(l?.range)||{},[j,F]=gl(null),[U,N]=gl(null),W=[];if(t>0)W.push(`tasks ${t}`);if(y>0)W.push(`retry ${y}`);if(c>0)W.push(`avg ${of(c)}`);let L=[{key:"executedTasks",className:"tasks",label:"执行任务",max:t,format:(E)=>`${au(E)} tasks`},{key:"retryAttempts",className:"retry",label:"重试次数",max:y,format:(E)=>`${au(E)} retries`},{key:"avgDurationMs",className:"duration",label:"平均耗时",max:c,format:(E)=>of(E)}],J=j||U,w=c3(J),Q=String(J?.row?.date||""),q=J?{left:`${Math.max(8,Math.min(92,Number(J.x)/S0*100))}%`,top:`${Math.max(14,Math.min(86,Number(J.y)/sN*100))}%`}:void 0;vn(()=>{F(null),N(null)},[u,A.startDate,A.endDate,f.length]);let T=(E)=>{F(E)},O=(E)=>{let D=c3(E);N((Y)=>c3(Y)===D?null:E),F(E)},Z=L.flatMap((E)=>f.map((D,Y)=>{let p=tO(D,Y,f.length,E),V=c3(p),B=w===V,m=String(D?.date||`day-${Y}`),X=`${bn(m)} ${E.label}: ${p.valueLabel}`;return G("g",{key:`${E.key}-${m}`,className:`stat-point-group ${E.className} ${B?"active":""}`,role:"button",tabIndex:0,"aria-label":X,"data-testid":`codex-stats-point-${E.className}-${m}`,onMouseEnter:()=>T(p),onFocus:()=>T(p),onClick:()=>O(p),onKeyDown:(S)=>{if(S.key==="Enter"||S.key===" ")S.preventDefault(),O(p)}},G("circle",{className:"stat-hit-point",cx:p.x,cy:p.y,r:13}),G("circle",{className:`stat-point ${E.className} ${B?"active":""}`,cx:p.x,cy:p.y,r:B?5.6:4.2}))}));return G(ry,{title:"统计曲线",eyebrow:`Daily task stats / ${u}`,className:"codex-stats-panel",summary:G("span",null,`${bn(A.startDate)} -> ${bn(A.endDate)} · ${l?.timezone||"Asia/Shanghai"}`),actions:Gu(l)?G(rQ,{title:"Code Queue Stats",data:l,onOpen:r,testId:"raw-codex-stats"}):null},G("div",{className:"codex-stats-hero","data-testid":"codex-stats-panel"},G(NO),G("div",null,G("strong",null,`${au(n.executedTasks)} tasks / ${au(n.retryAttempts)} retries`),G("span",null,`平均完成耗时 ${of(n.avgDurationMs??void 0)} · 终态 ${au(n.completedTasks)} 个`))),$?G("div",{className:"codex-stats-chart","data-testid":"codex-stats-chart",onMouseLeave:()=>F(null)},G("svg",{viewBox:`0 0 ${S0} ${sN}`,preserveAspectRatio:"none",role:"img","aria-label":"Code Queue daily task statistics"},G("line",{className:"axis",x1:Xi,x2:S0-Xi,y1:ic,y2:ic}),G("line",{className:"grid",x1:Xi,x2:S0-Xi,y1:ny+G2/2,y2:ny+G2/2}),G("line",{className:"grid",x1:Xi,x2:S0-Xi,y1:ny,y2:ny}),G("polyline",{className:"stat-line tasks",points:J2(f,"executedTasks",t)}),G("polyline",{className:"stat-line retry",points:J2(f,"retryAttempts",y)}),G("polyline",{className:"stat-line duration",points:J2(f,"avgDurationMs",c)}),J?G("g",{className:"stat-cursor-layer","data-testid":"codex-stats-active-point"},G("line",{className:"stat-cursor",x1:J.x,x2:J.x,y1:ny,y2:ic}),G("circle",{className:`stat-point-active ${J.className}`,cx:J.x,cy:J.y,r:8})):null,G("g",{className:"stat-point-layer"},Z)),J?G("div",{className:"codex-stats-tooltip active",style:q,"data-testid":"codex-stats-tooltip"},G("b",null,bn(J.row?.date)),G("span",null,`${J.label} · ${J.valueLabel}`),G("code",null,`${au(J.row?.executedTasks)} exec / ${au(J.row?.retryAttempts)} retry / ${of(J.row?.avgDurationMs??void 0)}`)):null,G("div",{className:"codex-stats-legend"},G("span",{className:"tasks"},"执行任务"),G("span",{className:"retry"},"重试次数"),G("span",{className:"duration"},"平均耗时")),G("div",{className:"codex-stats-scale"},G("span",null,bn(f[0]?.date)),G("span",null,W.join(" · ")||"暂无峰值"),G("span",null,bn(f.at(-1)?.date))),G("div",{className:`codex-stats-focus ${J?"active":""}`,"data-testid":"codex-stats-focus"},J?G(yc.default.Fragment,null,G("div",null,G("strong",null,bn(J.row?.date)),G("span",null,`${J.label} · ${J.valueLabel}`)),G("div",{className:"codex-stats-focus-metrics"},G("code",null,`${au(J.row?.executedTasks)} exec`),G("code",null,`${au(J.row?.retryAttempts)} retry`),G("code",null,of(J.row?.avgDurationMs??void 0)))):G("span",null,"将鼠标悬停到曲线数据点查看明细,点击数据点可固定。"))):G(P0,{title:"暂无统计",text:"任务开始执行后会生成按天汇总的曲线。"}),G("div",{className:"codex-stats-summary-grid"},G("article",null,G("span",null,"今日执行"),G("strong",null,String(au(i.executedTasks))),G("code",null,bn(i.date))),G("article",null,G("span",null,"今日重试"),G("strong",null,String(au(i.retryAttempts))),G("code",null,`累计 ${au(n.retryAttempts)}`)),G("article",null,G("span",null,"平均耗时"),G("strong",null,of(n.avgDurationMs??void 0)),G("code",null,`${au(n.durationSamples)} samples`))),G("div",{className:"codex-stats-daily-list","data-testid":"codex-stats-daily-list"},f.slice(-7).map((E)=>G("div",{key:String(E?.date||""),className:`codex-stats-daily-row ${Q===String(E?.date||"")?"active":""}`,"data-testid":`codex-stats-day-${String(E?.date||"unknown")}`},G("span",null,bn(E?.date)),G("b",null,`${au(E?.executedTasks)} exec`),G("b",null,`${au(E?.retryAttempts)} retry`),G("code",null,of(E?.avgDurationMs??void 0))))))}function wO({task:l,queueRows:u,busy:r,onMove:f}){let n=String(l?.id||""),i=ty(l),[t,y]=gl(i);vn(()=>{y(i)},[n,i]);let c=!n||r||["running","judging","retry_wait"].includes(String(l?.status||""));return G("div",{className:"codex-task-move-control","data-testid":"codex-task-queue-move-control"},G("label",null,"任务 queue",G("select",{value:t,disabled:!n||r,onChange:($)=>y(String($.target.value||i)),"data-testid":"codex-task-queue-move-select"},u.map(($)=>G("option",{key:String($?.id||""),value:String($?.id||"")},fc($))))),G("button",{type:"button",className:"ghost-btn",disabled:c||t===i,onClick:()=>f(t),title:c?"运行中 / judging / retry_wait 的任务不能移动;请先打断或等当前 turn 结束":"移动已创建任务到另一个 queue","data-testid":"codex-task-queue-move-button"},"移动"))}function oN(l,u=4){let r=(Array.isArray(l)?l:[]).map((n)=>String(n||"").trim()).filter(Boolean);if(r.length===0)return"--";let f=r.slice(0,u).join(" / ");return r.length>u?`${f} +${r.length-u}`:f}function qO({task:l,loading:u,onLoadPromptPart:r,testId:f="codex-initial-prompt-full",textTestId:n="codex-initial-prompt-full-text",baseTextTestId:i="codex-initial-prompt-base"}){let t=z2(l),y=$3(l),c=_3(l).trimEnd(),$=String(y.full?.text||""),A=XE(l),j=Number(t.promptChars||l?.promptChars||$.length),F=Number(t.basePromptLines||X0(c)),U=Number(t.promptLines||X0($));return G("section",{className:"codex-progressive-card codex-progressive-prompt","data-testid":"codex-progressive-prompt"},G("div",{className:"codex-progressive-card-head"},G("span",{className:"codex-output-channel"},"Prompt"),G("strong",null,"Submitted prompt / 原始用户 prompt"),G("code",null,`${F||X0(c)} lines / ${c.length} chars`)),G("pre",{className:"codex-prompt-full","data-testid":i},c||"空 prompt"),A?G("details",{className:"codex-reference-injection codex-progressive-full-prompt","data-testid":f,onToggle:(N)=>{if(N.currentTarget?.open&&!$)r?.("full")}},G("summary",null,G("span",null,"引用注入已折叠,点击按需拉取最终进入 Code agent 的完整 prompt"),G("code",null,$?`${U||X0($)} lines / ${$.length} chars`:`${Number.isFinite(j)&&j>0?j:"--"} chars`)),G("pre",{className:"codex-prompt-full codex-prompt-final-full","data-testid":n},$||(u?"正在按需拉取完整 prompt...":"展开后将只请求 full prompt,不拉取完整 transcript。"))):null)}function qQ({task:l,attempt:u,attemptIndex:r,loading:f,onLoadSteps:n,onLoadStep:i,testId:t="codex-execution-summary"}){let y=kE(FQ(l,r)),c=gE(HE(l,u)),$=u?zE(l,u):tQ(l),A=L2(l),j=W2(l,r),F=kn($?.errorCount),U=kn($?.stepCount??$?.llmStepCount),N=kn($?.readCount),W=kn($?.editCount),L=kn($?.runCount),J=kn($?.stepCount??$?.llmStepCount),w=U===null?"--":String(U),Q=J===null?"--":String(J),q=Array.isArray(c.editedFiles)?c.editedFiles:[],T=Array.isArray(c.commands)?c.commands:[],Z=E2(u,r)?` · ${String(u?.label||"recovered thread execution")}`:r?` #${r}`:"",E=BE(l,u,r,c),D=`最近更新: ${lQ(E)}`,Y=VE(l,u,r);return G("details",{className:`codex-progressive-card codex-execution-summary ${Y?"running":""}`,"data-testid":t,"data-attempt-index":j3(r),"data-running":Y?"true":"false",onToggle:(p)=>{if(p.currentTarget?.open&&!j)n?.(r)}},G("summary",null,G("div",{className:"codex-progressive-card-head"},G("span",{className:"codex-output-channel"},"Summary"),G("strong",null,`执行过程摘要${Z}`),Y?G("span",{className:"codex-summary-running-pill","data-testid":`${t}-running`},"执行中"):null,G("code",{title:E?`最近更新: ${Wl(E)}`:D},`${of(c.durationMs??c.totalElapsedMs)} / ${w} tools / ${D}`)),G("div",{className:"codex-execution-digest"},G("span",{title:"来自 OA Event Flow 统计中心"},`read ${N===null?"--":N}`),G("span",{title:"来自 OA Event Flow 统计中心"},`edit ${W===null?"--":W}`),G("span",{title:"来自 OA Event Flow 统计中心"},`run ${L===null?"--":L}`),G("span",{title:"来自 OA Event Flow 统计中心"},`STEP ${Q}`),F!==null&&F>0?G("span",{className:"codex-execution-error-pill","data-testid":`${t}-error-count`},`Error ${F}`):null)),G("div",{className:"codex-execution-digest expanded"},G("span",null,`修改文件:${oN(q,6)}`),G("span",null,`执行命令:${oN(T,4)}`)),y.length===0?G("div",{className:"codex-output-empty"},f?"正在按需拉取步骤 summary...":"展开后将只请求执行步骤 summary,不拉取单步骤全量。"):G("div",{className:"codex-trace-step-list"},y.map((p)=>{let V=String(p?.seq??""),B=A[V],m=Array.isArray(p?.summaryLines)?p.summaryLines.slice(0,4):[],X=m.find((S)=>String(S||"").trim().length>0);return G("details",{key:V||`${p?.title}-${p?.at}`,className:`codex-trace-step ${String(p?.kind||"message")} ${CE(p)?"error":""}`,"data-testid":`codex-trace-step-${V||"unknown"}`,onToggle:(S)=>{if(S.currentTarget?.open&&!B)i?.(p?.seq)}},G("summary",null,G("span",{className:"codex-output-channel"},WO(p?.kind)),G("strong",null,String(p?.title||"Trace step")),p?.status?G("code",null,String(p.status)):null,X?G("span",{className:"codex-trace-step-inline-summary",title:String(X)},String(X)):null,G("time",null,Wl(p?.at))),G("div",{className:"codex-trace-step-summary"},m.length>0?m.map((S,b)=>G("pre",{key:`${V}-${b}`},String(S||""))):G("span",null,"无 summary")),B?.line?G(n3,{items:[B.line],autoScroll:!1,loading:!1,hasDetail:!0,emptyText:"无步骤详情",testId:`codex-trace-step-detail-${V||"unknown"}`,className:"codex-transcript codex-step-detail-transcript",collapseTools:!1}):G("div",{className:"codex-output-empty"},f?"正在按需拉取这个步骤的全量数据...":"展开后将只请求这个单步骤的全量数据。"))})))}function WO(l){let u=String(l||"");if(u==="ran")return"Ran";if(u==="explored")return"Explored";if(u==="edited")return"Edited";if(u==="error")return"Error";if(u==="system")return"System";return"Message"}function WQ({task:l,attempt:u,attemptIndex:r,testId:f="codex-final-response"}){let n=DE(l,u);if(n.length===0)return null;let i=Number(u?.finalResponseChars||n.length),t=r?` #${r}`:"";return G("section",{className:"codex-progressive-card codex-final-response","data-testid":f,"data-attempt-index":j3(r)},G("div",{className:"codex-progressive-card-head"},G("span",{className:"codex-output-channel"},"Final"),G("strong",null,`最终 response${t}`),G("code",null,`${Number.isFinite(i)?i:n.length} chars`)),G(d1,{markdown:n,className:"codex-transcript-body codex-markdown",testId:`${f}-markdown`}))}function LQ({task:l,attempt:u,attemptIndex:r,testId:f="codex-progressive-judge"}){let n=AQ(l,u);if(!n?.decision)return null;let i=r?` #${r}`:"";return G("section",{className:"codex-progressive-card codex-progressive-judge","data-testid":f,"data-attempt-index":j3(r)},G("div",{className:"codex-progressive-card-head"},G("span",{className:"codex-output-channel"},"Judge"),G("strong",null,`完成判定${i}`),G("code",null,`${n.decision} ${Math.round(Number(n.confidence||0)*100)}%`)),G("div",{className:"codex-judge-card","data-testid":`${f}-card`},G(Y0,{status:n.decision},n.decision),G("strong",null,`${Math.round(Number(n.confidence||0)*100)}% confidence`),G("p",{"data-testid":`${f}-reason`},n.reason||"--"),G($Q,{judge:n,testId:`${f}-failure-details`}),n.continuePrompt?G("pre",{"data-testid":`${f}-continue-prompt`},String(n.continuePrompt||"")):null))}function LO({task:l,attempt:u,attemptIndex:r,loading:f,onLoadPromptPart:n,testId:i="codex-judge-feedback-prompt"}){let t=SE(l,u,r);if(t===null)return null;let y=jQ(r),$=$3(l)[y],A=String($?.text||"").trimEnd(),j=String(t.preview||t.text||"").trimEnd(),F=A||String(t.text||"").trimEnd(),U=Number($?.chars||t.chars||F.length||j.length),N=Number($?.lines||t.lines||X0(F||j)),W=$?.forAttempt||t.forAttempt||Number(r||0)+1;return G("details",{className:"codex-progressive-card codex-judge-feedback-prompt","data-testid":i,"data-attempt-index":j3(r),onToggle:(L)=>{if(L.currentTarget?.open&&!A)n?.("feedback",r)}},G("summary",null,G("div",{className:"codex-progressive-card-head"},G("span",{className:"codex-output-channel"},"Prompt"),G("strong",null,`judge feedback prompt #${r} -> #${W}`),G("code",null,`${N||"--"} lines / ${Number.isFinite(U)?U:j.length} chars`)),G("p",{className:"codex-feedback-preview","data-testid":`${i}-preview`},j||"展开后按需拉取 judge feedback prompt。")),G("pre",{className:"codex-prompt-full codex-feedback-full","data-testid":`${i}-text`},F||(f?"正在按需拉取 judge feedback prompt...":"展开后将只请求这一次 judge feedback prompt。")))}function GO({task:l,attempt:u,position:r,loading:f,onLoadPromptPart:n,onLoadSteps:i,onLoadStep:t}){let y=IE(u,r),c=r===0,$=E2(u,y),A=$?String(u?.label||"Recovered thread execution"):`Attempt ${y}`;return G("section",{className:"codex-attempt-cycle","data-testid":`codex-attempt-cycle-${y}`},G("div",{className:"codex-attempt-cycle-head"},G("span",{className:"codex-output-channel"},A),G("strong",null,String(u?.mode||(y<=1?"initial":"retry"))),u?.terminalStatus?G(Y0,{status:u.terminalStatus},u.terminalStatus):null,G("code",null,`${Wl(u?.startedAt)} -> ${Wl(u?.finishedAt)}`)),G(qQ,{task:l,attempt:u,attemptIndex:y,loading:f,onLoadSteps:i,onLoadStep:t,testId:c?"codex-execution-summary":`codex-execution-summary-attempt-${y}`}),$?null:G(WQ,{task:l,attempt:u,attemptIndex:y,testId:c?"codex-final-response":`codex-final-response-attempt-${y}`}),$?null:G(LQ,{task:l,attempt:u,attemptIndex:y,testId:c?"codex-progressive-judge":`codex-progressive-judge-attempt-${y}`}),$?null:G(LO,{task:l,attempt:u,attemptIndex:y,loading:f,onLoadPromptPart:n,testId:c?"codex-judge-feedback-prompt":`codex-judge-feedback-prompt-attempt-${y}`}))}function TO({task:l,loading:u,onLoadPromptPart:r,onLoadSteps:f,onLoadStep:n}){if(!l)return G(P0,{title:"未选择任务",text:"从左侧队列选择任务,或提交新 Codex 任务。"});let i=pE(l);return G("div",{className:"codex-transcript codex-progressive-trace","data-testid":"codex-output"},u&&!Uf(l)?G("div",{className:"codex-output-empty"},"正在加载 Trace Summary..."):null,G(qO,{task:l,loading:u,onLoadPromptPart:r}),i.length>0?i.map((t,y)=>G(GO,{key:`${t?.index||y+1}-${t?.startedAt||y}`,task:l,attempt:t,position:y,loading:u,onLoadPromptPart:r,onLoadSteps:f,onLoadStep:n})):[G(qQ,{key:"execution",task:l,loading:u,onLoadSteps:f,onLoadStep:n}),G(WQ,{key:"final",task:l}),G(LQ,{key:"judge",task:l})])}function mO({task:l}){let u=WE(l);if(!l||u.length===0)return G(P0,{title:"暂无原始消息",text:"原始 Codex app-server 消息会保留在任务 JSON 中。"});return G("details",{className:"codex-raw-output"},G("summary",null,`原始 messages (${u.length})`),G("div",null,u.map((r)=>G("article",{key:`${r.seq}-${r.channel}`,className:`codex-output-line ${r.channel||"system"}`},G("div",{className:"codex-output-meta"},G("span",{className:"codex-output-channel"},eE(String(r.channel||"system"))),G("span",null,Wl(r.at)),r.method?G("code",null,r.method):null),G("pre",null,String(r.text||""))))))}function KO({task:l}){let u=LE(l).slice().reverse();if(u.length===0)return G(P0,{title:"尚无 attempt",text:"任务开始运行后,这里会记录 Codex 终态、传输中断和 stderr tail。"});return G("div",{className:"table-wrap codex-attempt-table"},G("table",null,G("thead",null,G("tr",null,G("th",null,"#"),G("th",null,"模式"),G("th",null,"终态"),G("th",null,"传输"),G("th",null,"退出"),G("th",null,"完成时间"))),G("tbody",null,u.map((r)=>G("tr",{key:`${r.index}-${r.startedAt}`},G("td",null,r.index),G("td",null,r.mode),G("td",null,G(Y0,{status:r.terminalStatus||"unknown"},r.terminalStatus||"unknown")),G("td",null,r.transportClosedBeforeTerminal?G(Y0,{status:"failed"},"closed-before-terminal"):G(Y0,{status:"succeeded"},"normal")),G("td",null,`code=${r.appServerExitCode??"--"} signal=${r.appServerSignal??"--"}`),G("td",null,Wl(r.finishedAt)))))))}function GQ({microservices:l,onRaw:u,apiBaseUrl:r="/api",initialTasksData:f=null,standalone:n=!1}){let i=l.find((H)=>H.id==="code-queue")||null,t=IN(f),y=String(t?.id||""),c=new Map;if(t!==null&&y.length>0)c.set(y,{task:t,maxSeq:rc(Array.isArray(t.transcript)?t.transcript:[]),complete:Boolean(t._transcriptComplete),completeUpdatedAt:t._transcriptComplete?String(t.updatedAt||""):""});let $=typeof performance>"u"?0:performance.now(),A=Ru(y),j=Ru(0),F=Ru(0),U=Ru(0),N=Ru(!1),W=Ru(!1),L=Ru(!1),J=Ru(null),w=Ru(new Map),Q=Ru(new Map),q=Ru(new Map),T=Ru(new Map),O=Ru(new Set),Z=Ru(null),E=Ru(null),D=Ru(!1),Y=Ru(!1),p=Ru(Boolean(f)),V=Ru(new Map),B=Ru(new Set),m=Ru(c),X=Ru(f),[S,b]=gl(null),[z,P]=gl(f),[s,k]=gl(y),[v,tl]=gl(t),[I,M]=gl(!1),[rl,cl]=gl(""),[$l,Tl]=gl(null),[Ql,Ol]=gl(!1),[h,a]=gl(!1),ul=f?.queue||{},zl=String(ul?.mainProviderId||ul?.defaultProviderId||"D601").trim()||"D601",[o,ql]=gl(""),[pl,Bl]=gl(""),[Il,nu]=gl("default"),[Ml,wu]=gl(Yi),[Qr,Or]=gl(!1),[$r,ir]=gl(""),[tr,hr]=gl(zl),[jl,ol]=gl("default"),[wr,hl]=gl("gpt-5.5"),[Yu,eu]=gl(nc(ul,"default",zl)||"/workspace"),[rf,Ar]=gl(99),[Zr,Zn]=gl(1),[ff,ii]=gl(!1),[Au,nt]=gl(!1),[fl,Dl]=gl(""),[Cl,dl]=gl(""),[ju,ku]=gl(""),[$u,qr]=gl(!0),[Yf,Ry]=gl(()=>typeof window>"u"?!0:window.matchMedia(_E).matches),[mu,F_]=gl(!1),[c6,Fu]=gl(""),[bj,Pu]=gl(""),{addNotification:pr}=Xr(),[it,xy]=gl(""),[tt,J_]=gl(""),[by,U_]=gl(!1),[N_,y0]=gl(null),[yt,c0]=gl(!1),[Rr,Lf]=gl(f?{phase:"complete",taskId:y,queueMs:0,detailMs:0,totalMs:$,chunks:t?1:0,transcriptRows:Array.isArray(t?.transcript)?t.transcript.length:0,partial:Boolean(f?.selected?.hasMore||uc(t)),completedAt:new Date}:null),[Q_,ct]=gl(f?new Date:null),[vy,w_]=gl(!1),fn=tn(Du(z)),sy=fn.filter(sn),Cu=z?.queue||S?.body?.queue||S?.queue||{},_6=fO(z,Cu),q_=Nn(z),Pf=PN(Cu,Il),_0=String(Il||"default").trim()||"default",$0=Pf.filter((H)=>String(H?.id||"")!==_0),_t=iy(Pf,Ml),A0=Number((Pr(Ml)?Cu?.total:_t?.total)??q_.total??fn.length),$t=fy(Cu),vj=Pr(Ml)?$t:[String(iy(Pf,Ml)?.activeTaskId||"")].filter(Boolean),ti=CN(Cu,Pf,Ml,fn),sj=Pr(Ml)?j2(Cu):j2(_t||{}),W_=j2(Cu),ky=uO(W_),$6=Math.max(rO(W_),$t.length),A6=au((Pr(Ml)?Cu?.unreadTerminal:_t?.unreadTerminal)??sy.length),pn=z?sy.length:A6,L_=Pr(Ml)?"All queues":q2(_t||{id:Ml,name:Ml}),At=w2(rl),nf=At.length>0,kj=nf?tn(Du($l)):[],j6=Nn($l),nn=nf?kj:fn,gj=nn.filter(sn),pG=nn.filter((H)=>!af(H)).sort(tE),HG=nn.filter((H)=>af(H)&&!sn(H)),Ij=nf?j6:q_,jt=nf?Number(j6.total??kj.length):A0,aj=Ij.hasMore===!0&&String(Ij.nextBeforeId||"").length>0,F6=nf?h:vy,BG=i?fE(i):{},DG=i?nE(i):{},J6=SN(()=>GE(o),[o]),Hn=SN(()=>{let H=RN(Zr);return J6.flatMap((C)=>Array.from({length:H},()=>TE(C,pl)))},[J6,Zr,pl]),gy=Hn.length,oj=gy>1&&!ff,VG=Au||mu||gy===0||oj,dj=_O(Cu,wr),G_=$O(Cu,tr),ej=AO(Cu,jl),l7=nc(Cu,jl,tr),SG=Array.isArray(N_?.workdirs)?N_.workdirs:[],u7=FO(Cu,SG,tr,jl,Yu),U6=u7.some((H)=>H.source==="saved"&&yy(H.path)===yy(Yu)),N6=v?.id&&v?.activeTurnId&&String(v?.status)==="running",XG=v?.id&&!["succeeded","failed","canceled"].includes(String(v?.status||"")),YG=v?.id&&["succeeded","failed","canceled"].includes(String(v?.status||"")),Ft=v?.id&&NQ(v);function xr(H){let C=typeof H==="function"?H(X.current):H;return X.current=C,P(C),C}function PG(H,C,g=!0){let ll=Array.from(new Set(H.map((Al)=>String(Al||"")).filter(Boolean)));for(let Al of ll)if(V.current.set(Al,C),g)B.current.add(Al);return ll}function r7(H){for(let C of H.map((g)=>String(g||"")).filter(Boolean))V.current.delete(C),B.current.delete(C)}function T_(H){let C=String(H?.id||""),g=C?V.current.get(C):void 0;if(!g)return H;if(String(H?.status||"").length>0&&!af(H))return V.current.delete(C),B.current.delete(C),H;return{...H,readAt:H?.readAt||g,terminalUnread:!1}}function Q6(H){let C=String(H?.id||"");return C.length>0&&B.current.has(C)&&af(H)}function tn(H,C=!0){let g=[];for(let ll of Array.isArray(H)?H:[]){let Al=T_(ll);if(C&&Q6(Al))continue;g.push(Al)}return g}function CG(H,C=!0){if(!H||!Array.isArray(H?.tasks))return H;let g=tn(Du(H),C),ll=Nn(H);return{...H,tasks:g,pagination:H.pagination?{...ll,returned:g.length}:H.pagination}}function w6(H,C){return Pr(C)||ty(H)===C}function q6(H){let C=At.toLowerCase();if(C.length===0)return!0;return[H?.id,H?.status,H?.queueId,H?.providerId,H?.model,H?.cwd,H?.displayPrompt,H?.basePrompt,H?.prompt,H?.finalResponse,H?.lastError?.message].map((ll)=>String(ll||"").toLowerCase()).join(` +`).includes(C)}function MG(H,C){let g=H.filter((Zl)=>String(Zl?.id||"").length>0);if(g.length===0&&!C)return;let ll=g[0]||null,Al=String(ll?.id||""),Gl=g.filter((Zl)=>w6(Zl,Ml)),Ll=Gl.filter(q6),xl=String(C?.activeTaskId||fy(C)[0]||Al||ti||"");for(let Zl of g){let Xl=String(Zl?.id||"");if(!Xl)continue;let bl=Array.isArray(Zl?.transcript)?Zl.transcript:[];m.current.set(Xl,{...m.current.get(Xl)||{},task:{...Zl,_summaryLoaded:!0,_detailLoaded:bl.length>0,_transcriptComplete:!1,_transcriptPreview:!1},maxSeq:rc(bl),complete:!1,completeUpdatedAt:""})}if(xr((Zl)=>{if(!Zl&&(Gl.length===0||!C))return Zl;let Xl=Du(Zl),bl=tn(Qn([Xl,Gl],xl));return{...Zl||{},queue:C||Zl?.queue,tasks:bl,pagination:Zl?.pagination?{...Nn(Zl),returned:bl.length}:Zl?.pagination}}),nf)Tl((Zl)=>{if(!Zl||Ll.length===0)return Zl;let Xl=tn(Qn([Du(Zl),Ll],xl));return{...Zl,queue:C||Zl.queue,tasks:Xl,pagination:Zl.pagination?{...Nn(Zl),returned:Xl.length}:Zl.pagination}});if(ll&&w6(ll,Ml)&&q6(ll))U.current+=1,A.current=Al,k(Al),tl(m.current.get(Al)?.task||ll),M(!1),Lf({phase:"complete",taskId:Al,queueMs:0,detailMs:0,totalMs:0,chunks:1,transcriptRows:Array.isArray(ll?.transcript)?ll.transcript.length:0,partial:!0,completedAt:new Date});ct(new Date)}function hG(H){let C=String(H||Cu?.mainProviderId||"D601").trim()||"D601";hr(C),eu(nc(Cu,jl,C)),y0(null),m6().catch((g)=>Fu(xu(g,"加载工作目录失败")))}function RG(H){let C=String(H||"default").trim()||"default",g=tr;if(C==="windows-native"){if(!G_.find((Al)=>Al.id===tr)?.supportsWindowsNativeCodex)g=String(G_.find((Al)=>Al.supportsWindowsNativeCodex)?.id||tr||"D601"),hr(g)}ol(C),eu(nc(Cu,C,g)),y0(null),m6().catch((ll)=>Fu(xu(ll,"加载工作目录失败")))}function m_(H,C,g=null,ll=null){let Al=new Set(PG(H,C));if(Al.size===0&&ll===null&&g===null)return;xr((Gl)=>{if(!Gl)return Gl;let Ll=Du(Gl).flatMap((xl)=>{let Zl=String(xl?.id||"");if(!Al.has(Zl)){let cu=T_(xl);return Q6(cu)?[]:[cu]}let Xl=ll&&String(ll?.id||"")===Zl?ll:{},bl={...xl,...Xl,readAt:C,terminalUnread:!1};return Q6(bl)?[]:[bl]});return{...Gl,queue:g||Gl.queue,tasks:Al.size>0?Qn([Ll],ti):Ll}});for(let Gl of Al){let Ll=m.current.get(Gl);if(Ll?.task){let xl=ll&&String(ll?.id||"")===Gl?ll:{},Zl={...Ll.task,...xl,readAt:C,terminalUnread:!1};if(m.current.set(Gl,{...Ll,task:Zl}),A.current===Gl)tl(Zl)}}}vn(()=>{ii(!1)},[o,Zr,pl]),vn(()=>{let H=w2(rl);F.current+=1;let C=F.current;if(!i||H.length===0){Tl(null),Ol(!1),a(!1),L.current=!1;return}Ol(!0),Tl(null);let g=window.setTimeout(()=>{(async()=>{try{let ll=await MN(r,Ml,H);if(C!==F.current)return;Tl(CG(ll))}catch(ll){if(C===F.current)Tl(null),Fu(xu(ll,"搜索 Codex tasks 失败"))}finally{if(C===F.current)Ol(!1)}})()},240);return()=>window.clearTimeout(g)},[i?.id,r,Ml,rl]),vn(()=>{dl(v?_3(v):""),ku(Array.isArray(v?.referenceTaskIds)?v.referenceTaskIds.join(" "):"")},[s]);function Cf(H,C,g){let ll=m.current.get(H)||{},Al=ll.task||{},Gl=Array.isArray(Al.transcript)?Al.transcript:[],Ll=gN(Al,C),xl=Object.prototype.hasOwnProperty.call(C,"transcript")?U2(Gl,Array.isArray(C.transcript)?C.transcript:[]):Gl,Zl={...Al,...Ll,transcript:xl,output:Array.isArray(Ll.output)?T2(Al,Ll,"output"):Array.isArray(Al.output)?Al.output:[],events:Array.isArray(Ll.events)?T2(Al,Ll,"events"):Array.isArray(Al.events)?Al.events:[]},Xl=T_(Zl),bl=String(Xl?.updatedAt||""),cu=Boolean(C._transcriptComplete)&&af(Xl),lr=Boolean(ll.complete)&&af(Xl)&&String(ll.completeUpdatedAt||"")===bl,ru=cu||lr,yr={...ll,task:Xl,maxSeq:rc(xl),complete:ru,completeUpdatedAt:ru?bl:""};if(m.current.set(H,yr),g===U.current&&A.current===H)tl(Xl);return yr}async function yi(H,C=!1,g,ll){if(!i||!H)return;let Gl=m.current.get(H)?.task;if(!C&&y3(Gl))return;let Ll=H,xl=w.current.get(Ll);if(xl){if(C||!y3(Gl))xl.refreshAfter=!0;return xl.promise}let Zl=U.current,Xl=performance.now();if(A.current===H)M(!0);let bl={promise:Promise.resolve(),refreshAfter:!1},cu=(async()=>{try{let lr=await JE(r,H);if(Zl!==U.current||A.current!==H)return;let ru=lr?.summary||{},yr=String(ru.updatedAt||"");Cf(H,{id:H,status:ru.status,updatedAt:yr,startedAt:ru.startedAt,finishedAt:ru.finishedAt,currentAttempt:ru.currentAttempt,maxAttempts:ru.maxAttempts,finalResponse:ru.finalResponse,lastJudge:ru.lastJudge,lastError:ru.lastError,attempts:Array.isArray(ru.attempts)?ru.attempts:[],stepCount:ru.stepCount,llmStepCount:ru.llmStepCount,traceStats:ru.traceStats,statsSource:ru.statsSource,timing:ru.timing,_traceSummary:ru,_traceSummaryLoaded:!0,_traceSummaryUpdatedAt:yr,_detailLoaded:!0},Zl),Lf({phase:"complete",taskId:H,queueMs:ll??0,detailMs:performance.now()-Xl,totalMs:g===void 0?performance.now()-Xl:performance.now()-g,chunks:1,transcriptRows:Number(ru?.execution?.traceLineCount||ru?.execution?.stepCount||0),partial:!1,completedAt:new Date})}finally{let lr=Boolean(bl.refreshAfter&&A.current===H&&!y3(m.current.get(H)?.task));if(w.current.delete(Ll),Zl===U.current&&A.current===H)M(!1);if(lr)window.setTimeout(()=>{yi(H,!0).catch((ru)=>Fu(xu(ru,"自动刷新 Trace Summary 失败")))},0)}})();bl.promise=cu,w.current.set(Ll,bl),await cu}async function xG(H,C=null){let g=A.current;if(!i||!g||!H)return;let ll=m.current.get(g)?.task,Al=$3(ll),Gl=H==="feedback"||H==="judge-feedback"?jQ(C):H;if(Al[Gl]?.text)return;let Ll=`${g}:${Gl}`,xl=Q.current.get(Ll);if(xl)return xl;let Zl=U.current;if(A.current===g)M(!0);let Xl=(async()=>{try{let bl=await UE(r,g,H,C);if(Zl!==U.current||A.current!==g)return;let cu=m.current.get(g)?.task,lr=$3(cu);Cf(g,{...H==="full"?{prompt:String(bl?.text||""),promptChars:Number(bl?.chars||0)}:{},_promptDetails:{...lr,[Gl]:bl}},Zl)}finally{if(Q.current.delete(Ll),Zl===U.current&&A.current===g)M(!1)}})();Q.current.set(Ll,Xl),await Xl}async function W6(H=null,C={}){let g=A.current;if(!i||!g)return;let ll=m.current.get(g)?.task,Al=H===null||H===void 0||String(H).length===0?"":String(H),Gl=W2(ll,Al||null),Ll=Boolean(C.force),xl=Boolean(C.incremental);if(Gl&&!Ll)return;let Zl=FQ(ll,Al||null),Xl=xl&&Zl.length>0?YE(Zl):0,bl=`${g}:${Al||"all"}:${Xl}`,cu=q.current.get(bl);if(cu)return cu;let lr=U.current;if(A.current===g)M(!0);let ru=(async()=>{try{let yr=await NE(r,g,Xl,500,Al||null);if(lr!==U.current||A.current!==g)return;let yn=Array.isArray(yr?.steps)?yr.steps:[],Bn=Xl>0?PE(Zl,yn):yn;if(Al){let ci=m.current.get(g)?.task,Jt=Gu(ci?._traceStepsByAttempt)||{},Mf=Gu(ci?._traceStepsLoadedByAttempt)||{},Gf=Gu(ci?._traceStepsNextAfterSeqByAttempt)||{};Cf(g,{_traceStepsByAttempt:{...Jt,[Al]:Bn},_traceStepsLoadedByAttempt:{...Mf,[Al]:!0},_traceStepsNextAfterSeqByAttempt:{...Gf,[Al]:yr?.nextAfterSeq}},lr)}else Cf(g,{_traceSteps:Bn,_traceStepsLoaded:!0,_traceStepsHasMore:Boolean(yr?.hasMore),_traceStepsNextAfterSeq:yr?.nextAfterSeq},lr)}finally{if(q.current.delete(bl),lr===U.current&&A.current===g)M(!1)}})();q.current.set(bl,ru),await ru}async function bG(H){let C=A.current,g=String(H??"");if(!i||!C||g.length===0)return;let ll=m.current.get(C)?.task;if(L2(ll)[g]?.line)return;let Gl=`${C}:${g}`,Ll=T.current.get(Gl);if(Ll)return Ll;let xl=U.current;if(A.current===C)M(!0);let Zl=(async()=>{try{let Xl=await QE(r,C,H);if(xl!==U.current||A.current!==C)return;let bl=m.current.get(C)?.task,cu=L2(bl);Cf(C,{_traceStepDetails:{...cu,[g]:Xl}},xl)}finally{if(T.current.delete(Gl),xl===U.current&&A.current===C)M(!1)}})();T.current.set(Gl,Zl),await Zl}function vG(H){if(A.current!==H)return;let C=m.current.get(H)?.task;if(!C)return;if(W2(C,null))W6(null,{force:!0,incremental:!0}).catch((ll)=>Fu(xu(ll,"增量刷新 Trace Steps 失败")));let g=Gu(C?._traceStepsLoadedByAttempt)||{};for(let ll of Object.keys(g).filter((Al)=>g[Al]))W6(ll,{force:!0,incremental:!0}).catch((Al)=>Fu(xu(Al,"增量刷新 Attempt Trace Steps 失败")))}async function ZP(H,C,g){if(!i||!H)return;let ll=performance.now(),Al=U.current,Gl=m.current.get(H);if(Gl?.task){if(tl(Gl.task),M(uc(Gl.task)||!Gl.complete),!uc(Gl.task)&&Gl.complete&&af(Gl.task)&&String(Gl.completeUpdatedAt||"")===String(Gl.task?.updatedAt||"")){Lf({phase:"complete",taskId:H,queueMs:g??0,detailMs:0,totalMs:C===void 0?0:performance.now()-C,chunks:0,transcriptRows:Array.isArray(Gl.task.transcript)?Gl.task.transcript.length:0,completedAt:new Date});return}}else M(!0);let Ll=J.current;if(Ll?.taskId===H&&Ll.token===Al)return Ll.promise;let xl=(async()=>{try{let Zl=await Vu(Su(r,`/api/tasks/${encodeURIComponent(H)}?meta=1`));if(Al!==U.current||A.current!==H)return;let Xl=m.current.get(H),bl=Array.isArray(Xl?.task?.transcript)?Xl.task.transcript:[],cu=Zl?.task||{},lr=Boolean(Xl?.complete)&&String(Xl?.completeUpdatedAt||"")===String(cu?.updatedAt||"");Cf(H,{...cu,summaryOnly:!1,_metaLoaded:!0,transcript:bl,_detailLoaded:bl.length>0,_transcriptComplete:lr},Al);let ru=uc(Xl?.task)||Boolean(Xl?.task?._transcriptPreview),yr=ru?0:bl.length>0?aN(bl):0,yn=!ru&&Xl?.complete&&af(cu)&&String(Xl?.completeUpdatedAt||"")===String(cu?.updatedAt||"")?rc(bl):yr,Bn=!0,ci=0,Jt=bl.length;while(Bn){let Mf=await Vu(Su(r,`/api/tasks/${encodeURIComponent(H)}/transcript?afterSeq=${encodeURIComponent(String(yn))}&limit=${lE}&fullText=1`));if(Al!==U.current||A.current!==H)return;let Gf=m.current.get(H),Ut=Array.isArray(Gf?.task?.transcript)?Gf.task.transcript:[],j0=U2(Ut,Array.isArray(Mf?.transcript)?Mf.transcript:[]);ci+=1,Jt=j0.length;let Mu=Boolean(!Mf?.hasMore);if(Cf(H,{status:Mf?.status||cu.status,updatedAt:Mf?.updatedAt||cu.updatedAt,transcript:j0,_detailLoaded:Mu||j0.length>0,_transcriptComplete:Mu,_transcriptPreview:ru&&!Mu},Al),Bn=Boolean(Mf?.hasMore),yn=Number(Mf?.nextAfterSeq??rc(j0)),!Bn)break;await new Promise((A7)=>window.setTimeout(A7,0))}Lf({phase:"complete",taskId:H,queueMs:g??0,detailMs:performance.now()-ll,totalMs:C===void 0?performance.now()-ll:performance.now()-C,chunks:ci,transcriptRows:Jt,completedAt:new Date})}finally{if(J.current?.taskId===H&&J.current?.token===Al)J.current=null;if(Al===U.current&&A.current===H)M(!1)}})();J.current={taskId:H,token:Al,promise:xl},await xl}async function tf(H=A.current,C=!0,g=Ml){if(!i)return;if(!C&&Y.current)return;let ll=performance.now();if(C)Y.current=!0;if(C)Lf({phase:"loading",taskId:String(H||A.current||""),startedAt:new Date});let Al=j.current+1;j.current=Al;let Gl=String(H||A.current||""),Ll=Gl?m.current.get(Gl):null,xl=Array.isArray(Ll?.task?.transcript)?Ll.task.transcript:[],Zl=aN(xl),Xl=null,bl=C&&Gl.length===0;if(Xl=bl?await MN(r,g,""):await A2(r,Gl,Zl,g,"",!0,{stats:!1}),Al!==j.current){if(C)Y.current=!1;return}let cu=performance.now()-ll;b(S||{});let lr=Xl?.queue||{},ru=String(lr?.activeTaskId||fy(lr)[0]||""),yr=Xl;xr((gu)=>{let _i=Du(Xl),yf=Du(gu),Tf=yf.length>0?Qn([yf,_i],ru):Qn([_i],ru),$i=tn(Tf),K_=Nn(Xl),F0=Nn(gu),z6=yf.length>_i.length&&(F0.hasMore===!1||String(F0.nextBeforeId||"").length>0),LT={...K_,...z6?{hasMore:F0.hasMore,nextBeforeId:F0.nextBeforeId}:{},returned:$i.length};return yr={...Xl,tasks:$i,pagination:LT},yr});let yn=Du(yr),Bn=PN(lr,Il),ci=CN(lr,Bn,g,yn),Jt=FE(Bn,g,yn),Mf=Gl||A.current,Gf=yr?.selected||null,Ut=Gf?.task||null,j0=Array.isArray(Gf?.transcript)?Gf.transcript:null,Mu=Mf||ci||Jt||yn[0]?.id||"";if(A.current!==Mu)U.current+=1;A.current=Mu,k(Mu);let Nt=yn.find((gu)=>gu.id===Mu);if(Nt){let gu=m.current.get(Mu);if(gu?.task)m.current.set(Mu,{...gu,task:{...Nt,...gu.task,status:Nt.status,updatedAt:Nt.updatedAt}})}if(bl&&Nt){if(Cf(Mu,{...Nt,_summaryLoaded:!1,transcript:[],_detailLoaded:!1,_transcriptComplete:!1,_transcriptPreview:!0},U.current),M(!0),Lf({phase:"complete",taskId:Mu,queueMs:cu,detailMs:0,totalMs:performance.now()-ll,chunks:0,transcriptRows:0,partial:!0,completedAt:new Date}),ct(new Date),C)Y.current=!1;yi(Mu,!0).catch((gu)=>Fu(xu(gu,"加载 Codex Trace Summary 失败"))),A2(r,Mu,0,g,"",!1).then((gu)=>{if(Al!==j.current)return;let _i=Du(gu),yf=IN(gu);if(_i.length>0)xr((Tf)=>{let $i=Qn([Du(Tf),_i],ru);return{...Tf,statistics:gu?.statistics||Tf?.statistics,tasks:tn($i)}});if(yf?.id===A.current){let Tf=Array.isArray(yf.transcript)?yf.transcript:[];Cf(yf.id,{...yf,transcript:Tf,_summaryLoaded:!0,_detailLoaded:Tf.length>0,_transcriptPreview:Boolean(gu?.selected?.preview)},U.current)}}).catch(()=>{});return}if(Ut?.id===Mu&&j0!==null){let gu=m.current.get(Mu),_i=Array.isArray(gu?.task?.transcript)?gu.task.transcript:[],yf=U2(_i,j0),Tf=Boolean(Gf?.preview);if(Cf(Mu,{...Ut,_summaryLoaded:!0,transcript:yf,_detailLoaded:!Gf?.hasMore||yf.length>0,_transcriptComplete:!Tf&&!Gf?.hasMore&&af(Ut),_transcriptPreview:Tf},U.current),M(!1),C)Lf({phase:"complete",taskId:Mu,queueMs:cu,detailMs:Math.max(0,performance.now()-ll-cu),totalMs:performance.now()-ll,chunks:1,transcriptRows:yf.length,partial:Boolean(Tf||Gf?.hasMore||uc(Ut)),completedAt:new Date});if(ct(new Date),C)Y.current=!1;yi(Mu,!1,C?ll:void 0,C?cu:void 0).catch(($i)=>Fu(xu($i,"加载 Codex Trace Summary 失败"))),A2(r,Gl,Zl,g,"",!1).then(($i)=>{if(Al!==j.current)return;let K_=Du($i);if(K_.length>0)xr((F0)=>{let z6=Qn([Du(F0),K_],ru);return{...F0,tasks:tn(z6)}})}).catch(()=>{});return}if(C)Lf({phase:"session",taskId:Mu,queueMs:cu,totalMs:cu,startedAt:new Date(Date.now()-cu)});if(Mu)yi(Mu,!0,C?ll:void 0,C?cu:void 0).catch((gu)=>Fu(xu(gu,"加载 Codex Trace Summary 失败")));else if(U.current+=1,tl(null),M(!1),C)Lf({phase:"complete",taskId:"",queueMs:cu,detailMs:0,totalMs:performance.now()-ll,chunks:0,transcriptRows:0,completedAt:new Date});if(ct(new Date),C)Y.current=!1}async function f7(){if(nf){if(!i||h||L.current)return;let C=String(j6.nextBeforeId||"");if(!C)return;L.current=!0,a(!0),Fu("");try{let g=await hN(r,Ml,C,eN,At),ll=Du(g),Al=g?.queue||Cu||{},Gl=String(Al?.activeTaskId||fy(Al)[0]||ti||"");Tl((Ll)=>{let xl=tn(Qn([Du(Ll),ll],Gl)),Zl=Nn(g);return{...Ll||{},queue:Al,tasks:xl,pagination:{...Zl,returned:xl.length}}})}catch(g){Fu(xu(g,"加载更多搜索结果失败"))}finally{L.current=!1,a(!1)}return}if(!i||vy||W.current)return;let H=String(Nn(z).nextBeforeId||"");if(!H)return;W.current=!0,w_(!0),Fu("");try{let C=await hN(r,Ml,H),g=Du(C),ll=C?.queue||Cu||{},Al=String(ll?.activeTaskId||fy(ll)[0]||ti||"");xr((Gl)=>{let Ll=tn(Qn([Du(Gl),g],Al)),xl=Nn(C);return{...Gl||{},queue:ll,statistics:C?.statistics||Gl?.statistics,tasks:Ll,pagination:{...xl,returned:Ll.length}}})}catch(C){Fu(xu(C,"加载更早 Codex tasks 失败"))}finally{W.current=!1,w_(!1)}}function sG(H){let C=H.currentTarget;if(!C||F6||!aj)return;if(C.scrollHeight-C.scrollTop-C.clientHeight<120)f7()}async function Hr(H,C){F_(!0),Fu("");try{await H()}catch(g){Fu(xu(g,C))}finally{F_(!1)}}async function L6(H){if(!H)return;try{let C=!1;try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(H),C=!0}catch{C=!1}if(!C){let ll=document.createElement("textarea");ll.value=H,ll.style.position="fixed",ll.style.opacity="0",document.body.appendChild(ll),ll.select(),C=document.execCommand("copy"),document.body.removeChild(ll)}if(!C)throw Error("browser clipboard rejected the copy request");xy(H);let g=`已复制任务 ID:${H}`;Pu(g),pr("success",g),window.setTimeout(()=>xy((ll)=>ll===H?"":ll),1600)}catch(C){Fu(`复制任务 ID 失败:${xu(C)}`)}}function G6(H){if(!H)return;Bl(H);let C=`已引用任务 ID:${H};提交时后端会读取并注入该任务上下文`;Pu(C),pr("success",C)}async function T6(H){if(!i||!H)return;let C=new Date().toISOString();j.current+=1,m_([H],C,null,{id:H,readAt:C,terminalUnread:!1}),J_(H);let g=!1;if(await Hr(async()=>{let ll=await wE(r,H),Al=ll?.task||{id:H,readAt:new Date().toISOString(),terminalUnread:!1},Gl=String(Al?.readAt||new Date().toISOString());m_([H],Gl,ll?.queue||null,Al),g=!0;let Ll=`已将任务 ${H} 标为已读`;Pu(Ll),pr("success",Ll)},"标记 Codex task 已读失败"),!g)r7([H]),tf(A.current,!1).catch((ll)=>Fu(xu(ll,"刷新 Codex tasks 失败")));J_((ll)=>ll===H?"":ll)}async function kG(){if(!i||by)return;U_(!0);let H=new Date().toISOString(),C=Array.from(new Set([...Du(X.current).filter(sn).map((ll)=>String(ll?.id||"")).filter(Boolean),...Array.from(m.current.entries()).filter(([,ll])=>sn(ll?.task)).map(([ll])=>ll)]));if(j.current+=1,C.length>0)m_(C,H);let g=!1;if(await Hr(async()=>{let ll=await qE(r),Al=String(ll?.readAt||new Date().toISOString()),Gl=Du(X.current).filter(sn).map((bl)=>String(bl?.id||"")).filter(Boolean),Ll=Array.from(m.current.entries()).filter(([,bl])=>sn(bl?.task)).map(([bl])=>bl),xl=Array.from(new Set([...C,...Gl,...Ll]));m_(xl,Al,ll?.queue||null);let Zl=Number(ll?.count||xl.length);g=!0;let Xl=`已将 ${Zl} 个已结束未读任务标为已读`;Pu(Xl),pr("success",Xl)},"全部标为已读失败"),!g&&C.length>0)r7(C),tf(A.current,!1).catch((ll)=>Fu(xu(ll,"刷新 Codex tasks 失败")));U_(!1)}function gG(H){let C=H||Yi;if(wu(C),!Pr(C))nu(C);if(xr(null),!(Pr(C)?A.current:""))A.current="",U.current+=1,k(""),tl(null),M(!0)}async function m6(){if(!i)return;let H=await Vu(Su(r,"/api/workdirs"));y0(H)}async function IG(){let H=Yu.trim()||l7||"/workspace",C=typeof window>"u"?H:window.prompt("输入新的工作目录绝对路径",H),g=String(C||"").trim();if(!g)return;c0(!0),await Hr(async()=>{let ll=await Vu(Su(r,"/api/workdirs"),{method:"POST",body:{providerId:tr,executionMode:jl,path:g,ensure:!0}});y0((Gl)=>({...Gl||{},...ll})),eu(String(ll?.workdir?.path||g));let Al=`已保存工作目录:${String(ll?.workdir?.path||g)}`;Pu(Al),pr("success",Al)},"创建工作目录失败"),c0(!1)}async function aG(){let H=yy(Yu);if(!U6){Pu("当前工作目录还没有保存到下拉菜单。");return}if(!(typeof window>"u"?!0:window.confirm(`从下拉菜单删除工作目录选项? +${H} -不会删除磁盘上的实际目录。`)))return;ri(!0),await Vf(async()=>{let g=await ml(Dl(f,`/api/workdirs/${encodeURIComponent(tf)}/${encodeURIComponent($u)}/${encodeURIComponent(V)}`),{method:"DELETE"});fi((ju)=>({...ju||{},...g}));let ru=`已从下拉菜单删除工作目录:${V}`;Xl(ru),Bf("success",ru)},"删除工作目录失败"),ri(!1)}async function ZT(){let V=typeof window>"u"?"":window.prompt("输入新的 Codex queue ID(字母/数字/._-,最长 64)","new-lane"),M=String(V||"").trim();if(!M)return;await Vf(async()=>{let g=await ml(Dl(f,"/api/queues"),{method:"POST",body:{queueId:M}}),ru=String(g?.queue?.id||M);ll(ru),Nl(ru),xf(null),A.current="",J.current+=1,I(""),d(null);let ju=`已创建并切换到 queue:${ru}`;Xl(ju),Bf("success",ju),await hf("",!0,ru)},"创建 Codex queue 失败")}async function HT(){let V=String(gu||"default").trim()||"default",M=et(Yr,V)||{id:V,name:V},g=typeof window>"u"?null:window.prompt(`输入 queue 显示名称(ID 不变:${V};留空恢复为 ID)`,RQ(M));if(g===null)return;await Vf(async()=>{let ru=await ml(Dl(f,`/api/queues/${encodeURIComponent(V)}`),{method:"PATCH",body:{name:String(g)}}),ju=ru?.queue||{id:V,name:String(g||V)};if(ru?.summary)xf((Tu)=>Tu?{...Tu,queue:ru.summary}:Tu);let Lu=`已更新 queue 名称:${i2(ju)}`;Xl(Lu),Bf("success",Lu),await hf(A.current,!0,Pu)},"修改 Codex queue 名称失败")}function BT(){if(ii.length===0){Xl("没有可合并的其他 queue;请先创建或选择另一个 queue。");return}let V=ii.some((M)=>String(M?.id||"")===$f)?$f:"";nf(V),Zf(!0)}async function VT(){let V=ni;if(ii.length===0){Xl("没有可合并的其他 queue;请先创建或选择另一个 queue。");return}let g=String($f||""||"").trim();if(!g){Xl("请先选择要合并的源 queue。");return}if(g===V){Ul("源 queue 和目标 queue 不能相同。");return}await Vf(async()=>{let ru=await ml(Dl(f,`/api/queues/${encodeURIComponent(V)}/merge`),{method:"POST",body:{sourceQueueId:g}});if(ru?.summary)xf((Tu)=>Tu?{...Tu,queue:ru.summary}:Tu);ll(V),Nl(V),xf(null);let ju=Number(ru?.mergedTaskCount||0),Lu=`已将 queue=${g} 合并到 ${V},移动 ${ju} 个任务;源 queue 已自动删除。`;Xl(Lu),Bf("success",Lu),Zf(!1),nf(""),await hf(A.current,!0,V)},"合并 Codex queue 失败")}async function mT(V){if(V.preventDefault(),Q.current){Xl("任务正在提交中,请等待当前请求完成,已阻止重复提交。");return}if(En.length>1&&!nr){Ul(`检测到将创建 ${En.length} 个任务;请先勾选“确认批量入队”,避免误传多个任务。`);return}Q.current=!0,lt(!0),Xl("正在提交 Code Queue 任务,请等待后端确认,输入已临时锁定。"),await Vf(async()=>{if(En.length===0)throw Error("prompt 不能为空");let M=Vi(Zu),g=gu.trim()||"default",ru=[...En],ju=(ku)=>({prompt:ku,queueId:g,providerId:tf,executionMode:$u,model:Nf,cwd:Sl,maxAttempts:Number(rr),...M.length>0?{referenceTaskIds:M}:{}}),Lu=ru.length===1?ju(ru[0]):{tasks:ru.map(ju)},Tu=await ml(Dl(f,ru.length===1?"/api/tasks":"/api/tasks/batch"),{method:"POST",body:Lu}),xu=Tu?.tasks?.[0]?.id||"",hu=Array.isArray(Tu?.tasks)?Tu.tasks.map((ku)=>String(ku?.id||"")).filter(Boolean):[],Mu=`已创建 ${hu.length||ru.length} 个任务${hu.length>0?`:${hu.join(" / ")}`:""}`;if(Xl(Mu),Bf("success",Mu),qu(""),Bu(""),u0(!1),A.current=xu,Pu!==g)xf(null);ll(g),await hf(xu,!0,g)},"Codex 任务入队失败"),Q.current=!1,lt(!1)}async function DT(V){if(V.preventDefault(),!b?.id)return;await Vf(async()=>{await ml(Dl(f,`/api/tasks/${encodeURIComponent(b.id)}/steer`),{method:"POST",body:{prompt:fu}}),Vu(""),await hf(b.id)},"追加 prompt 失败")}async function pT(V){V.preventDefault();let M=String(b?.id||"");if(!M||!ct)return;await Vf(async()=>{let g=Vi(Al),ru=await ml(Dl(f,`/api/tasks/${encodeURIComponent(M)}/edit`),{method:"POST",body:{prompt:Xu,referenceTaskIds:g}}),ju={...ru?.task||b||{},_traceSummary:null,_traceSummaryLoaded:!1,_traceSummaryUpdatedAt:"",_promptDetails:{},_traceSteps:[],_traceStepsLoaded:!1,_traceStepsByAttempt:{},_traceStepsLoadedByAttempt:{},_traceStepsNextAfterSeqByAttempt:{},_traceStepDetails:{}};O.current.set(M,{...O.current.get(M)||{},task:ju,complete:!1,completeUpdatedAt:""}),A.current=M,d(ju),I(M),ou(l3(ju)),kl(Array.isArray(ju?.referenceTaskIds)?ju.referenceTaskIds.join(" "):""),xf((Tu)=>{if(!Tu)return Tu;let xu=vl(Tu).map((hu)=>String(hu?.id||"")===M?{...hu,...ju}:hu);return{...Tu,queue:ru?.queue||Tu.queue,tasks:V0([xu],yi)}});let Lu=ru?.changed===!1?`任务 ${M} 的 prompt 未变化`:`已更新 queued 任务 ${M} 的用户 prompt`;Xl(Lu),Bf("success",Lu),await hf(M,!0,Pu)},"编辑 queued 任务 prompt 失败")}async function ST(){if(!b?.id)return;await Vf(async()=>{await ml(Dl(f,`/api/tasks/${encodeURIComponent(b.id)}/interrupt`),{method:"POST",body:{}}),await hf(b.id)},"打断 Codex session 失败")}async function XT(){if(!b?.id)return;await Vf(async()=>{await ml(Dl(f,`/api/tasks/${encodeURIComponent(b.id)}/retry`),{method:"POST",body:{}}),await hf(b.id)},"重新入队失败")}async function YT(V){let M=String(b?.id||""),g=String(V||"").trim();if(!M||!g)return;let ru=o1(b);if(g===ru){Xl(`任务 ${M} 已在 queue=${g}`);return}await Vf(async()=>{let Lu=(await ml(Dl(f,`/api/tasks/${encodeURIComponent(M)}/move`),{method:"POST",body:{queueId:g}}))?.task||{...b,queueId:g};if(O.current.set(M,{...O.current.get(M)||{},task:Lu}),A.current=M,d(Lu),I(M),ll(g),!sf(Pu))xf(null),Nl(g);let Tu=`已将任务 ${M} 从 ${ru} 移动到 ${g}`;Xl(Tu),Bf("success",Tu),await hf(M,!0,sf(Pu)?D0:g)},"移动任务 queue 失败")}async function PT(){let V=A.current;if(!V)return;let M=performance.now();await Vf(async()=>{Xr({phase:"session",taskId:V,queueMs:0,totalMs:0,partial:!0,startedAt:new Date}),await ci(V,!0,M,0)},"刷新 Trace Summary 失败")}function CT(V){A.current=V,J.current+=1,I(V);let M=O.current.get(V);if(M?.task)d(M.task),h(!1);else{h(!0);let g=fn.find((ru)=>ru.id===V);if(g)d(g);else d(null)}hf(V).catch((g)=>Ul(bl(g,"切换 Codex session 失败")))}function A6(V){if(CT(V),RE())Dy(!1)}function R7(V,M,g){if(!V||!Array.isArray(V?.tasks)||M.length===0||Object.keys(g).length===0)return V;let ru=!1,ju=vl(V).map((Lu)=>{if(String(Lu?.id||"")!==M)return Lu;return ru=!0,U_(mQ(Lu,g))});return ru?{...V,tasks:ju}:V}function MT(V,M){xf((g)=>R7(g,V,M)),Fu((g)=>R7(g,V,M))}function RT(V,M,g){let ru=String(V?.type||"");if(ru==="queue-updated")return!0;if(ru==="trace-stats-updated"||ru==="trace-step-created")return!1;if(M.length===0)return!0;if(!g)return!0;if(V?.queueId&&String(V.queueId)!==o1(g))return!0;if(V?.status&&String(V.status)!==String(g?.status||""))return!0;return String(V?.reason||"")!=="output"}function x7(){if(!i||!a4())return;if(H.current!==null)window.clearTimeout(H.current);H.current=window.setTimeout(()=>{H.current=null,hf(A.current,!1).catch((V)=>Ul(bl(V,"Code Queue 事件刷新失败")))},120)}function xT(V,M){if(!i||!a4()||A.current!==V)return;if(m.current=m.current||M,E.current!==null)return;E.current=window.setTimeout(()=>{E.current=null;let g=m.current;if(m.current=!1,ci(V,!0).catch((ru)=>Ul(bl(ru,"事件刷新 Trace Summary 失败"))),g)TT(V)},250)}function hT(V){let M=Ll(V?.payload)||V,g=Ll(M?.stats),ru=String(V?.type||M?.type||""),ju=String(M?.subjectKind||g?.subjectKind||""),Lu=String(M?.scopeId||g?.scopeId||""),Tu=String(M?.taskId||(ju==="task"?M?.subjectId:"")||g?.taskId||V?.taskId||""),xu=M?.attemptIndex??g?.attemptIndex,hu=xu===null||xu===void 0||xu===""?null:xn(xu),Mu=g||Ll(M?.traceStats),ku=Mu?.stepCount??Mu?.llmStepCount,tl=Mu?.outputMaxSeq;return{...M,type:ru,eventId:V?.eventId||M?.eventId,sequence:V?.sequence??M?.sequence,taskId:Tu,subjectKind:ju,scopeId:Lu,attemptIndex:hu,stepCount:ku,outputMaxSeq:tl,updatedAt:Mu?.updatedAt||M?.updatedAt||V?.createdAt,traceStats:Mu,statsSource:Mu?"oa-event-flow":M?.statsSource}}function bT(V){let M=hT(V),g=String(M?.taskId||""),ru=String(M?.scopeId||M?.traceStats?.scopeId||""),ju=String(M?.subjectKind||M?.traceStats?.subjectKind||"")==="task-attempt"||Number(M?.attemptIndex)>0||/:attempt:\d+$/u.test(ru),Lu=OQ(M?.stepCount),Tu={},xu=g.length>0?vl(Y.current).find((hu)=>String(hu?.id||"")===g):null;if(g.length>0){if(M?.status)Tu.status=String(M.status);if(M?.updatedAt)Tu.updatedAt=String(M.updatedAt);if(M?.queueId)Tu.queueId=String(M.queueId);if(!ju&&Number.isFinite(Number(M?.stepCount)))Tu.stepCount=Lu,Tu.llmStepCount=Lu;if(!ju&&Number.isFinite(Number(M?.outputMaxSeq)))Tu.outputMaxSeq=OQ(M.outputMaxSeq);if(!ju&&Ll(M?.traceStats))Tu.traceStats=M.traceStats,Tu.statsSource="oa-event-flow";if(Object.keys(Tu).length>0&&(O.current.has(g)||A.current===g))Pr(g,Tu,J.current);if(Object.keys(Tu).length>0)MT(g,Tu);if(A.current===g&&(M?.type==="trace-step-created"||M?.type==="task-updated"||M?.type==="trace-stats-updated")){let hu=vQ(xu),Mu=M?.type==="trace-step-created"||M?.type==="trace-stats-updated"&&!ju&&Number.isFinite(Number(M?.stepCount))&&(hu===null||Lu>hu);xT(g,Mu)}}if(RT(M,g,xu))x7()}Mn(()=>{if(B.current){B.current=!1;return}Vf(()=>hf(A.current),"Code Queue 加载失败")},[i?.id,Pu]),Mn(()=>{if(!i||typeof EventSource>"u")return;let V=new EventSource(XE(f),{withCredentials:!0}),M=(ru)=>{try{bT(JSON.parse(String(ru.data||"{}")))}catch(ju){Ul(bl(ju,"解析 Code Queue 事件失败"))}},g=()=>{if(a4())x7()};return V.addEventListener("trace-step-created",M),V.addEventListener("task-updated",M),V.addEventListener("queue-updated",M),V.addEventListener("trace-stats-updated",M),document.addEventListener("visibilitychange",g),()=>{if(V.close(),document.removeEventListener("visibilitychange",g),H.current!==null)window.clearTimeout(H.current),H.current=null;if(E.current!==null)window.clearTimeout(E.current),E.current=null}},[i?.id,f,Pu]),Mn(()=>{if(!i||!b||s)return;let V=String(b.id||"");if(!V)return;let M=String(b.updatedAt||"");if(d$(b))return;let g=`${V}:${M||"unknown"}:${String(b?._traceSummaryUpdatedAt||"")}`;if(Z.current.has(g))return;Z.current.add(g),ci(V,!0).catch((ru)=>Ul(bl(ru,"自动加载 Trace Summary 失败")))},[i?.id,b?.id,b?.updatedAt,b?.traceStats?.statsRevision,b?._traceSummaryUpdatedAt,b?._traceSummaryLoaded,s]),Mn(()=>{if(!i)return;$6().catch((V)=>Ul(bl(V,"加载工作目录失败")));return},[i?.id]);let vT=rn.length===0?T(Si,{title:wr?zu?"搜索中":"没有匹配任务":"队列为空",text:wr?zu?`正在搜索包含“${My}”的 task...`:`未找到包含“${My}”的 task;可换个关键词或切换 queue。`:"提交一个任务后,Codex 会串行执行并保存输出。"}):[V7.length>0?T(f2,{key:"unread",title:"已结束未读",tasks:V7,selectedId:k,emptyText:"暂无已结束未读任务。",onSelect:A6,onCopy:y6,onReference:c6,onMarkRead:_6,copiedTaskId:ft,markingReadTaskId:rt}):null,T(f2,{key:"active",title:"运行 / 排队",tasks:cT,selectedId:k,emptyText:"当前没有运行或排队任务。",onSelect:A6,onCopy:y6,onReference:c6,onMarkRead:_6,copiedTaskId:ft,markingReadTaskId:rt}),T(f2,{key:"history",title:"历史 session",tasks:_T,selectedId:k,emptyText:"最近没有完成、失败或取消的 session。",onSelect:A6,onCopy:y6,onReference:c6,onMarkRead:_6,copiedTaskId:ft,markingReadTaskId:rt}),T("div",{key:"pagination",className:"codex-task-pagination","data-testid":"codex-task-pagination"},T("span",null,wr?`搜索“${My}” · 已显示 ${rn.length} / ${Number.isFinite(yt)?yt:rn.length}`:`已加载 ${rn.length} / ${Number.isFinite(yt)?yt:rn.length}`),D7?T("button",{type:"button",className:"ghost-btn",disabled:l6,onClick:()=>void M7(),"data-testid":"codex-load-more-tasks-button"},l6?"加载中":wr?"加载更多结果":"加载更早任务"):T("code",null,wr?"已到结果末尾":"已到队列末尾"))],h7=(V,M=!1)=>T("label",{className:`code-queue-switcher ${M?"compact":""}`},T("span",null,M?"Queue":"查看 queue"),T("select",{value:Pu,onChange:(g)=>zT(String(g.target.value||D0)),"data-testid":V},T("option",{value:D0},`All queues · ${Number.isFinite(ti)?ti:fn.length} tasks · ${tt.length} running`),Yr.map((g)=>T("option",{key:String(g?.id||""),value:String(g?.id||"")},s1(g))))),kT=T("div",{className:"codex-task-search","data-testid":"codex-task-search"},T("label",{htmlFor:"codex-task-search-input"},"搜索 task"),T("div",{className:"codex-task-search-row"},T("input",{id:"codex-task-search-input",type:"search",value:lu,placeholder:"关键词 / task ID / prompt",autoComplete:"off",onChange:(V)=>cu(String(V.target.value||"")),"data-testid":"codex-task-search-input"}),lu?T("button",{type:"button",className:"ghost-btn",onClick:()=>cu(""),"data-testid":"codex-task-search-clear"},"清除"):null),T("small",{"data-testid":"codex-task-search-summary"},wr?zu?"搜索中...":`匹配 ${rn.length}/${Number.isFinite(yt)?yt:rn.length}`:"支持 task ID、prompt、状态、provider、模型和最近输出关键词")),IT=T("div",{className:"codex-trace-status","data-testid":"codex-trace-status-summary"},T("span",{className:"codex-trace-status-chip queued"},T("b",null,"排队"),String(Cy)),T("span",{className:"codex-trace-status-chip running"},T("b",null,"运行"),String(dA)),T("span",{className:`codex-trace-status-chip unread ${zn>0?"warn":""}`},T("b",null,"结束未读"),String(zn)),T("span",{className:"codex-trace-status-chip service"},T("b",null,"服务"),`${$T.providerStatus||"unknown"} · ${i?.providerId||"D601"} · ${AT.public?"公网暴露":"仅 UniDesk frontend 代理访问"}`),T("span",{className:"codex-trace-status-chip"},T("b",null,"执行节点"),F_.map((V)=>V.id).join(" / ")),T("span",{className:"codex-trace-status-chip"},T("b",null,"执行模式"),X7.map((V)=>V.id).join(" / ")),T("span",{className:"codex-trace-status-chip"},T("b",null,"模型"),S7.join(" / ")),T("span",{className:"codex-trace-status-chip"},T("b",null,"加载"),Rf?.phase==="complete"?DE(Rf?.totalMs):String(Rf?.phase||"idle")),T("span",{className:"codex-trace-status-chip"},T("b",null,"刷新"),c_?yl(c_):"--")),gT=T(ot,{title:b?`Trace ${String(b.id).slice(0,22)}`:"Trace 输出",eyebrow:b?`${b.status} / view=${j_} / task queue=${o1(b)} / provider=${b.providerId||"D601"} / mode=${b.executionMode||"default"} / ${b.model} / agent loop trace`:`Agent loop trace / view=${j_}`,summary:IT,loading:s||Yy||zu||C||Rf?.phase==="loading",actions:T("div",{className:"panel-actions"},h7("code-queue-filter-select"),T("button",{type:"button",className:"ghost-btn codex-mark-all-read-btn",disabled:zn===0||Kl||Sy,onClick:()=>void GT(),"data-testid":"codex-mark-all-read-button"},Sy?"标记中":`全部标已读${zn>0?` (${zn})`:""}`),b?T("button",{type:"button",className:"ghost-btn",disabled:s||Kl,onClick:()=>void PT(),"data-testid":"codex-load-full-trace-button"},s?"加载中":Fr(b)?"刷新 Summary":"加载 Summary"):null,T("button",{type:"button",className:"codex-session-title-toggle",onClick:()=>Dy((V)=>!V),"data-testid":"code-queue-sidebar-toggle"},Sr?"收起队列":"展开队列"),T("label",{className:"inline-check"},T("input",{type:"checkbox",checked:_l,onChange:(V)=>qf(Boolean(V.target.checked))}),"自动滚动"),T("button",{type:"button",className:"ghost-btn",disabled:!UT||Kl,onClick:()=>void ST(),"data-testid":"codex-interrupt-button"},"打断"),T("button",{type:"button",className:"ghost-btn",disabled:!JT||Kl,onClick:()=>void XT()},"重试"),b?T(MQ,{title:"Codex Task",data:b,onOpen:l,testId:"raw-codex-task"}):null),className:"codex-output-panel"},T("div",{className:`codex-session-shell ${Sr?"":"queue-collapsed"}`},Sr?T("aside",{className:"codex-session-sidebar","data-testid":"codex-session-sidebar"},T("div",{className:"codex-session-sidebar-head"},T("div",null,T("span",null,sf(Pu)?"All queues":"Queue lane"),T("strong",null,`${j_} · ${fn.length}/${Number.isFinite(ti)?ti:fn.length} sessions · 未读 ${zn}`)),T("button",{type:"button",className:"ghost-btn",onClick:()=>Dy(!1)},"收起")),h7("code-queue-filter-sidebar",!0),kT,T("div",{className:"codex-task-list codex-task-list-session",onScroll:KT,"data-testid":"codex-task-list-scroll"},vT)):null,T("div",{className:"codex-session-main"},T("div",{className:"codex-output-stack"},T(uZ,{task:b,loading:s,onLoadPromptPart:WT,onLoadSteps:t6,onLoadStep:LT}),T(lZ,{task:b})))));if(!i)return T(Si,{title:"Code Queue 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=code-queue"});let b7=Number(Rf?.totalMs),v7=Number(Rf?.queueMs),k7=Number(Rf?.detailMs),I7=Number(Rf?.transcriptRows),sT=Rf?.phase==="complete"?"complete":String(Rf?.phase||"idle"),aT=et(Yr,ni)||{id:ni,name:ni},oT=Qf?T(qQ,{title:"合并 queue",titleId:"codex-merge-dialog-title",className:"codex-merge-dialog",backdropClassName:"codex-merge-dialog-backdrop",bodyClassName:"codex-merge-dialog-body",actionsClassName:"codex-merge-dialog-actions",testId:"codex-merge-queue-dialog",closeTestId:"codex-merge-queue-close",disableClose:Kl,onClose:()=>Zf(!1),actions:[T("button",{key:"cancel",type:"button",className:"ghost-btn",onClick:()=>Zf(!1),disabled:Kl,"data-testid":"codex-merge-queue-cancel"},"取消"),T("button",{key:"confirm",type:"button",className:"primary-btn",onClick:()=>void VT(),disabled:Kl||$l||!$f,"data-testid":"codex-merge-queue-confirm"},Kl?"合并中...":"确认合并")]},T("p",{className:"codex-merge-dialog-target"},"目标 queue:",T("code",null,s1(aT))),T("label",null,"源 queue",T("select",{value:$f,disabled:Kl||$l,onChange:(V)=>nf(String(V.target.value||"")),"data-testid":"codex-merge-source-queue-select"},T("option",{value:""},"选择要合并进来的源 queue"),ii.map((V)=>T("option",{key:String(V?.id||""),value:String(V?.id||"")},s1(V))))),T("p",{className:"codex-merge-dialog-note"},"会把源 queue 的任务归属合并到目标 queue,并自动删除源 queue;目标 queue 会按原 queueEnteredAt/createdAt 时间顺序运行。")):null;return T("div",{className:`code-queue-page ${n?"codex-standalone-page":""}`,"data-testid":"code-queue-page","data-load-state":sT,"data-load-total-ms":Number.isFinite(b7)?String(Math.round(b7*10)/10):"","data-load-queue-ms":Number.isFinite(v7)?String(Math.round(v7*10)/10):"","data-load-detail-ms":Number.isFinite(k7)?String(Math.round(k7*10)/10):"","data-load-transcript-rows":Number.isFinite(I7)?String(I7):"","data-load-task-id":String(Rf?.taskId||k||""),"data-load-partial":Rf?.partial?"true":"false"},T(nl,{error:aA,wide:!0}),oT,T("div",{className:"codex-session-stage codex-session-stage-top"},gT),T("div",{className:"code-queue-layout"},T("div",{className:"codex-left-rail"},T(ot,{title:"提交任务",eyebrow:$l?"Submitting...":En.length>1?`${En.length} tasks`:"Single or Batch",className:"codex-compose-panel",loading:$l},T("form",{className:`codex-task-form ${$l?"is-submitting":""}`,onSubmit:mT,"data-testid":"code-queue-task-form","aria-busy":$l?"true":"false"},T("label",null,"Prompt / 多任务用单独一行 --- 分隔",T("textarea",{value:a,rows:8,disabled:$l,onChange:(V)=>qu(V.target.value),placeholder:"写入 Codex 任务;多个任务之间用 --- 分隔。"})),T("label",{className:"codex-reference-field"},"引用任务 ID(可选)",T("input",{value:Zu,disabled:$l,onChange:(V)=>Bu(V.target.value),placeholder:"codex_...;支持空格/逗号分隔多个 ID","data-testid":"codex-reference-task-id"}),Vi(Zu).length>0?T("code",null,`后端将解析并注入:${Vi(Zu).join(" / ")}`):null),T("div",{className:"codex-form-grid"},T("label",{className:"codex-submit-queue-field"},"Queue",T("div",{className:"codex-submit-queue-row"},T("select",{className:"codex-submit-queue-select",value:gu,disabled:$l,onChange:(V)=>ll(String(V.target.value||"default")),"data-testid":"code-queue-id-select"},Yr.map((V)=>T("option",{key:String(V?.id||""),value:String(V?.id||"")},s1(V)))),T("button",{type:"button",className:"ghost-btn codex-rename-queue-btn",onClick:()=>void HT(),disabled:Kl||$l||!gu,title:"修改当前 queue 的显示名称,ID 不变","data-testid":"codex-rename-queue-button"},"改名"),T("button",{type:"button",className:"ghost-btn codex-merge-queue-btn",onClick:()=>BT(),disabled:Kl||$l||ii.length===0,title:"打开独立窗口选择源 queue 并合并到当前 queue;合并后自动删除源 queue","data-testid":"codex-merge-queue-button"},"合并 queue"),T("button",{type:"button",className:"ghost-btn codex-create-queue-btn",onClick:()=>void ZT(),disabled:Kl||$l,"data-testid":"codex-create-queue-button"},"创建 queue"))),T("label",null,"模型",T("select",{value:Nf,disabled:$l,onChange:(V)=>Yu(V.target.value),"data-testid":"codex-model-select"},S7.map((V)=>T("option",{key:V,value:V},V)))),T("label",null,"执行 Provider",T("select",{value:tf,disabled:$l,onChange:(V)=>qT(String(V.target.value||"D601")),"data-testid":"codex-provider-select"},F_.map((V)=>T("option",{key:V.id,value:V.id},`${V.label||V.id} · ${V.defaultWorkdir||J2(Yl,V.id)}${V.supportsWindowsNativeCodex?" · Windows native":""}`)))),T("label",null,"执行模式",T("select",{value:$u,disabled:$l,onChange:(V)=>wT(String(V.target.value||"default")),"data-testid":"codex-execution-mode-select"},X7.map((V)=>T("option",{key:V.id,value:V.id},`${V.label||V.id}${V.id==="windows-native"?" · 宿主 Codex":""}`)))),T("label",{className:"codex-workdir-field"},"工作目录",T("div",{className:"codex-workdir-row"},T("input",{value:Sl,disabled:$l,onChange:(V)=>dl(V.target.value),placeholder:Y7||Yl?.defaultWorkdir||"/workspace","data-testid":"codex-cwd-input"}),T("select",{value:uy(Sl),disabled:$l||nt,onChange:(V)=>dl(String(V.target.value||"")),"data-testid":"codex-cwd-select"},P7.map((V)=>T("option",{key:`${V.providerId}:${V.executionMode}:${V.path}`,value:V.path},`${V.path}${V.source==="default"?" · 默认":""}`))),T("button",{type:"button",className:"ghost-btn codex-workdir-create-btn",disabled:$l||Kl||nt,onClick:()=>void ET(),"data-testid":"codex-cwd-create-button"},nt?"处理中":"新建"),T("button",{type:"button",className:"ghost-btn codex-workdir-delete-btn",disabled:$l||Kl||nt||!r6,onClick:()=>void OT(),title:r6?"从工作目录下拉菜单删除这个选项,不删除磁盘目录":"当前工作目录尚未保存到下拉菜单","data-testid":"codex-cwd-delete-button"},"删除"))),T("label",null,"最大尝试",T("input",{type:"number",min:1,max:99,value:rr,disabled:$l,onChange:(V)=>Af(Number(V.target.value)),"data-testid":"codex-max-attempts-input"})),T("label",null,"入队份数",T("input",{type:"number",min:1,max:50,value:Hf,disabled:$l,onChange:(V)=>Gn(Number(V.target.value)),"data-testid":"codex-repeat-count-input"}))),Ry>1?T("label",{className:`codex-batch-confirm ${nr?"confirmed":""}`,"data-testid":"codex-batch-confirm-row"},T("input",{type:"checkbox",checked:nr,disabled:$l,onChange:(V)=>u0(Boolean(V.target.checked)),"data-testid":"codex-batch-confirm-checkbox"}),T("span",null,`确认批量入队 ${Ry} 个任务(prompt 分段 ${f6.length} × 入队份数 ${EQ(Hf)})`)):null,$l?T("div",{className:"codex-submit-wait","data-testid":"codex-submit-wait"},"正在提交到后端,已锁定输入以防重复提交..."):null,T("div",{className:"codex-form-actions"},T("button",{type:"button",className:"ghost-btn",disabled:Kl||$l||a.length===0&&Zu.length===0,onClick:()=>{qu(""),Bu(""),u0(!1);let V="已清空任务输入栏";Xl(V),Bf("success",V)},"data-testid":"codex-clear-input-button"},"清空输入"),T("button",{type:"submit",className:"primary-btn",disabled:jT,"data-testid":"codex-enqueue-button"},$l?"提交中,请等待...":p7?`请确认批量入队 ${Ry} 个任务`:En.length>1?`批量入队 ${En.length} 个任务`:"入队并运行"))))),T("div",{className:"codex-main-stage"},T("div",{className:"codex-detail-grid"},T(ot,{title:"运行控制",eyebrow:ct?"Queued prompt editable":n6?"Active turn steer":"Steer when running",loading:Kl},T("div",{className:"codex-run-control-stack"},T(sO,{task:b,queueRows:Yr,busy:Kl,onMove:YT}),b?.id?T("form",{className:"codex-steer-form codex-edit-prompt-form",onSubmit:pT,"data-testid":"codex-edit-prompt-form"},T("label",null,"编辑 queued 用户 prompt",T("textarea",{value:Xu,rows:5,onChange:(V)=>ou(V.target.value),placeholder:"仅 QUEUED 且尚未开始运行的任务可在这里修改原始用户 prompt。",disabled:!ct||Kl,"data-testid":"codex-edit-prompt-textarea"})),T("label",{className:"codex-reference-field"},"引用任务 ID(可选,留空会清除引用)",T("input",{value:Al,disabled:!ct||Kl,onChange:(V)=>kl(V.target.value),placeholder:"codex_...;支持空格/逗号分隔多个 ID","data-testid":"codex-edit-reference-task-id"}),Vi(Al).length>0?T("code",null,`将保留/注入:${Vi(Al).join(" / ")}`):null),T("div",{className:"codex-form-actions"},T("button",{type:"button",className:"ghost-btn",disabled:!b?.id||Kl,onClick:()=>{ou(b?l3(b):""),kl(Array.isArray(b?.referenceTaskIds)?b.referenceTaskIds.join(" "):"")},"data-testid":"codex-edit-prompt-reset"},"恢复当前值"),T("button",{type:"submit",className:"primary-btn",disabled:!ct||Kl||Xu.trim().length===0,title:ct?"保存后会重写尚未运行任务的用户 prompt":"只有 QUEUED 且尚未开始的任务可编辑 prompt","data-testid":"codex-edit-prompt-submit"},"保存 queued prompt"))):null,T("form",{className:"codex-steer-form",onSubmit:DT},T("label",null,"追加 prompt",T("textarea",{value:fu,rows:4,onChange:(V)=>Vu(V.target.value),placeholder:"给正在运行的 Codex session 推入新的指令或纠偏。",disabled:!n6})),T("button",{type:"submit",className:"primary-btn",disabled:!n6||Kl||fu.trim().length===0,"data-testid":"codex-steer-button"},"推入运行中 session")))),T(ot,{title:"完成判定",eyebrow:b?.lastJudge?b.lastJudge.source:"judge",loading:s},b?.lastJudge?T("div",{className:"codex-judge-card","data-testid":"codex-task-judge-card"},T(pi,{status:b.lastJudge.decision},b.lastJudge.decision),T("strong",null,`${Math.round(Number(b.lastJudge.confidence||0)*100)}% confidence`),T("p",{"data-testid":"codex-task-judge-reason"},r2(b.lastJudge.reason||"--",180)),T(gQ,{judge:b.lastJudge,testId:"codex-task-judge-failure-details"}),b.lastJudge.continuePrompt?T("code",{"data-testid":"codex-task-judge-continue-prompt"},r2(b.lastJudge.continuePrompt,160)):null):T(Si,{title:"尚未判定",text:"Codex turn 结束后会由 MiniMax M2.7 或 fallback judge 判定 complete/retry/fail;retry 会在已有 thread 追加继续执行 prompt。"}))),T(gO,{stats:oA,queueName:j_,onRaw:l}),T(ot,{title:"Attempts",eyebrow:"terminal vs interruption",loading:s},T(fZ,{task:b})))))}var lc=Cu(Jl(),1);var mu=lc.default.createElement,{useEffect:Q2}=lc.default,N2=lc.default.useState,rZ=lc.default.useRef,w2=` +不会删除磁盘上的实际目录。`)))return;c0(!0),await Hr(async()=>{let g=await Vu(Su(r,`/api/workdirs/${encodeURIComponent(tr)}/${encodeURIComponent(jl)}/${encodeURIComponent(H)}`),{method:"DELETE"});y0((Al)=>({...Al||{},...g}));let ll=`已从下拉菜单删除工作目录:${H}`;Pu(ll),pr("success",ll)},"删除工作目录失败"),c0(!1)}async function oG(){let H=typeof window>"u"?"":window.prompt("输入新的 Codex queue ID(字母/数字/._-,最长 64)","new-lane"),C=String(H||"").trim();if(!C)return;await Hr(async()=>{let g=await Vu(Su(r,"/api/queues"),{method:"POST",body:{queueId:C}}),ll=String(g?.queue?.id||C);nu(ll),wu(ll),xr(null),A.current="",U.current+=1,k(""),tl(null);let Al=`已创建并切换到 queue:${ll}`;Pu(Al),pr("success",Al),await tf("",!0,ll)},"创建 Codex queue 失败")}async function dG(){let H=String(Il||"default").trim()||"default",C=iy(Pf,H)||{id:H,name:H},g=typeof window>"u"?null:window.prompt(`输入 queue 显示名称(ID 不变:${H};留空恢复为 ID)`,fQ(C));if(g===null)return;await Hr(async()=>{let ll=await Vu(Su(r,`/api/queues/${encodeURIComponent(H)}`),{method:"PATCH",body:{name:String(g)}}),Al=ll?.queue||{id:H,name:String(g||H)};if(ll?.summary)xr((Ll)=>Ll?{...Ll,queue:ll.summary}:Ll);let Gl=`已更新 queue 名称:${q2(Al)}`;Pu(Gl),pr("success",Gl),await tf(A.current,!0,Ml)},"修改 Codex queue 名称失败")}function eG(){if($0.length===0){Pu("没有可合并的其他 queue;请先创建或选择另一个 queue。");return}let H=$0.some((C)=>String(C?.id||"")===$r)?$r:"";ir(H),Or(!0)}async function lT(){let H=_0;if($0.length===0){Pu("没有可合并的其他 queue;请先创建或选择另一个 queue。");return}let g=String($r||""||"").trim();if(!g){Pu("请先选择要合并的源 queue。");return}if(g===H){Fu("源 queue 和目标 queue 不能相同。");return}await Hr(async()=>{let ll=await Vu(Su(r,`/api/queues/${encodeURIComponent(H)}/merge`),{method:"POST",body:{sourceQueueId:g}});if(ll?.summary)xr((Ll)=>Ll?{...Ll,queue:ll.summary}:Ll);nu(H),wu(H),xr(null);let Al=Number(ll?.mergedTaskCount||0),Gl=`已将 queue=${g} 合并到 ${H},移动 ${Al} 个任务;源 queue 已自动删除。`;Pu(Gl),pr("success",Gl),Or(!1),ir(""),await tf(A.current,!0,H)},"合并 Codex queue 失败")}async function uT(H){if(H.preventDefault(),N.current){Pu("任务正在提交中,请等待当前请求完成,已阻止重复提交。");return}if(Hn.length>1&&!ff){Fu(`检测到将创建 ${Hn.length} 个任务;请先勾选“确认批量入队”,避免误传多个任务。`);return}N.current=!0,nt(!0),Pu("正在提交 Code Queue 任务,请等待后端确认,输入已临时锁定。"),await Hr(async()=>{if(Hn.length===0)throw Error("prompt 不能为空");let C=V0(pl),g=Il.trim()||"default",ll=[...Hn],Al=(bl)=>({prompt:bl,queueId:g,providerId:tr,executionMode:jl,model:wr,cwd:Yu,maxAttempts:Number(rf),...C.length>0?{referenceTaskIds:C}:{}}),Gl=ll.length===1?Al(ll[0]):{tasks:ll.map(Al)},Ll=await Vu(Su(r,ll.length===1?"/api/tasks":"/api/tasks/batch"),{method:"POST",body:Gl}),xl=Ll?.tasks?.[0]?.id||"",Zl=Array.isArray(Ll?.tasks)?Ll.tasks.map((bl)=>String(bl?.id||"")).filter(Boolean):[],Xl=`已创建 ${Zl.length||ll.length} 个任务${Zl.length>0?`:${Zl.join(" / ")}`:""}`;if(MG(Array.isArray(Ll?.tasks)?Ll.tasks:[],Ll?.queue||null),Pu(Xl),pr("success",Xl),ql(""),Bl(""),ii(!1),nu(g),xl&&w6(Ll?.tasks?.[0],Ml)&&q6(Ll?.tasks?.[0]))yi(String(xl),!1).catch((bl)=>Fu(xu(bl,"加载 Codex Trace Summary 失败")))},"Codex 任务入队失败"),N.current=!1,nt(!1)}async function rT(H){if(H.preventDefault(),!v?.id)return;await Hr(async()=>{await Vu(Su(r,`/api/tasks/${encodeURIComponent(v.id)}/steer`),{method:"POST",body:{prompt:fl}}),Dl(""),await tf(v.id)},"追加 prompt 失败")}async function fT(H){H.preventDefault();let C=String(v?.id||"");if(!C||!Ft)return;await Hr(async()=>{let g=V0(ju),ll=await Vu(Su(r,`/api/tasks/${encodeURIComponent(C)}/edit`),{method:"POST",body:{prompt:Cl,referenceTaskIds:g}}),Al={...ll?.task||v||{},_traceSummary:null,_traceSummaryLoaded:!1,_traceSummaryUpdatedAt:"",_promptDetails:{},_traceSteps:[],_traceStepsLoaded:!1,_traceStepsByAttempt:{},_traceStepsLoadedByAttempt:{},_traceStepsNextAfterSeqByAttempt:{},_traceStepDetails:{}};m.current.set(C,{...m.current.get(C)||{},task:Al,complete:!1,completeUpdatedAt:""}),A.current=C,tl(Al),k(C),dl(_3(Al)),ku(Array.isArray(Al?.referenceTaskIds)?Al.referenceTaskIds.join(" "):""),xr((Ll)=>{if(!Ll)return Ll;let xl=Du(Ll).map((Zl)=>String(Zl?.id||"")===C?{...Zl,...Al}:Zl);return{...Ll,queue:ll?.queue||Ll.queue,tasks:Qn([xl],ti)}});let Gl=ll?.changed===!1?`任务 ${C} 的 prompt 未变化`:`已更新 queued 任务 ${C} 的用户 prompt`;Pu(Gl),pr("success",Gl),await tf(C,!0,Ml)},"编辑 queued 任务 prompt 失败")}async function nT(){if(!v?.id)return;await Hr(async()=>{await Vu(Su(r,`/api/tasks/${encodeURIComponent(v.id)}/interrupt`),{method:"POST",body:{}}),await tf(v.id)},"打断 Codex session 失败")}async function iT(){if(!v?.id)return;await Hr(async()=>{await Vu(Su(r,`/api/tasks/${encodeURIComponent(v.id)}/retry`),{method:"POST",body:{}}),await tf(v.id)},"重新入队失败")}async function tT(H){let C=String(v?.id||""),g=String(H||"").trim();if(!C||!g)return;let ll=ty(v);if(g===ll){Pu(`任务 ${C} 已在 queue=${g}`);return}await Hr(async()=>{let Gl=(await Vu(Su(r,`/api/tasks/${encodeURIComponent(C)}/move`),{method:"POST",body:{queueId:g}}))?.task||{...v,queueId:g};if(m.current.set(C,{...m.current.get(C)||{},task:Gl}),A.current=C,tl(Gl),k(C),nu(g),!Pr(Ml))xr(null),wu(g);let Ll=`已将任务 ${C} 从 ${ll} 移动到 ${g}`;Pu(Ll),pr("success",Ll),await tf(C,!0,Pr(Ml)?Yi:g)},"移动任务 queue 失败")}async function yT(){let H=A.current;if(!H)return;let C=performance.now();await Hr(async()=>{Lf({phase:"session",taskId:H,queueMs:0,totalMs:0,partial:!0,startedAt:new Date}),await yi(H,!0,C,0)},"刷新 Trace Summary 失败")}function cT(H){A.current=H,U.current+=1,k(H);let C=m.current.get(H);if(C?.task)tl(C.task),M(!1);else{M(!0);let g=fn.find((ll)=>ll.id===H);if(g)tl(g);else tl(null)}tf(H).catch((g)=>Fu(xu(g,"切换 Codex session 失败")))}function K6(H){if(cT(H),$E())Ry(!1)}function n7(H,C,g){if(!H||!Array.isArray(H?.tasks)||C.length===0||Object.keys(g).length===0)return H;let ll=!1,Al=Du(H).map((Gl)=>{if(String(Gl?.id||"")!==C)return Gl;return ll=!0,T_(gN(Gl,g))});return ll?{...H,tasks:Al}:H}function _T(H,C){xr((g)=>n7(g,H,C)),Tl((g)=>n7(g,H,C))}function $T(H,C,g){let ll=String(H?.type||"");if(ll==="queue-updated")return!0;if(ll==="trace-stats-updated"||ll==="trace-step-created")return!1;if(C.length===0)return!0;if(!g)return!0;if(H?.queueId&&String(H.queueId)!==ty(g))return!0;if(H?.status&&String(H.status)!==String(g?.status||""))return!0;return String(H?.reason||"")!=="output"}function i7(){if(!i||!$2())return;if(Z.current!==null)window.clearTimeout(Z.current);Z.current=window.setTimeout(()=>{Z.current=null,tf(A.current,!1).catch((H)=>Fu(xu(H,"Code Queue 事件刷新失败")))},120)}function AT(H,C){if(!i||!$2()||A.current!==H)return;if(D.current=D.current||C,E.current!==null)return;E.current=window.setTimeout(()=>{E.current=null;let g=D.current;if(D.current=!1,yi(H,!0).catch((ll)=>Fu(xu(ll,"事件刷新 Trace Summary 失败"))),g)vG(H)},250)}function jT(H){let C=Gu(H?.payload)||H,g=Gu(C?.stats),ll=String(H?.type||C?.type||""),Al=String(C?.subjectKind||g?.subjectKind||""),Gl=String(C?.scopeId||g?.scopeId||""),Ll=String(C?.taskId||(Al==="task"?C?.subjectId:"")||g?.taskId||H?.taskId||""),xl=C?.attemptIndex??g?.attemptIndex,Zl=xl===null||xl===void 0||xl===""?null:kn(xl),Xl=g||Gu(C?.traceStats),bl=Xl?.stepCount??Xl?.llmStepCount,cu=Xl?.outputMaxSeq;return{...C,type:ll,eventId:H?.eventId||C?.eventId,sequence:H?.sequence??C?.sequence,taskId:Ll,subjectKind:Al,scopeId:Gl,attemptIndex:Zl,stepCount:bl,outputMaxSeq:cu,updatedAt:Xl?.updatedAt||C?.updatedAt||H?.createdAt,traceStats:Xl,statsSource:Xl?"oa-event-flow":C?.statsSource}}function FT(H){let C=jT(H),g=String(C?.taskId||""),ll=String(C?.scopeId||C?.traceStats?.scopeId||""),Al=String(C?.subjectKind||C?.traceStats?.subjectKind||"")==="task-attempt"||Number(C?.attemptIndex)>0||/:attempt:\d+$/u.test(ll),Gl=xN(C?.stepCount),Ll={},xl=g.length>0?Du(X.current).find((Zl)=>String(Zl?.id||"")===g):null;if(g.length>0){if(C?.status)Ll.status=String(C.status);if(C?.updatedAt)Ll.updatedAt=String(C.updatedAt);if(C?.queueId)Ll.queueId=String(C.queueId);if(!Al&&Number.isFinite(Number(C?.stepCount)))Ll.stepCount=Gl,Ll.llmStepCount=Gl;if(!Al&&Number.isFinite(Number(C?.outputMaxSeq)))Ll.outputMaxSeq=xN(C.outputMaxSeq);if(!Al&&Gu(C?.traceStats))Ll.traceStats=C.traceStats,Ll.statsSource="oa-event-flow";if(Object.keys(Ll).length>0&&(m.current.has(g)||A.current===g))Cf(g,Ll,U.current);if(Object.keys(Ll).length>0)_T(g,Ll);if(A.current===g&&(C?.type==="trace-step-created"||C?.type==="task-updated"||C?.type==="trace-stats-updated")){let Zl=yQ(xl),Xl=C?.type==="trace-step-created"||C?.type==="trace-stats-updated"&&!Al&&Number.isFinite(Number(C?.stepCount))&&(Zl===null||Gl>Zl);AT(g,Xl)}}if($T(C,g,xl))i7()}vn(()=>{if(p.current){p.current=!1;return}Hr(()=>tf(A.current),"Code Queue 加载失败")},[i?.id,Ml]),vn(()=>{if(!i||typeof EventSource>"u")return;let H=new EventSource(iE(r),{withCredentials:!0}),C=(ll)=>{try{FT(JSON.parse(String(ll.data||"{}")))}catch(Al){Fu(xu(Al,"解析 Code Queue 事件失败"))}},g=()=>{if($2())i7()};return H.addEventListener("trace-step-created",C),H.addEventListener("task-updated",C),H.addEventListener("queue-updated",C),H.addEventListener("trace-stats-updated",C),document.addEventListener("visibilitychange",g),()=>{if(H.close(),document.removeEventListener("visibilitychange",g),Z.current!==null)window.clearTimeout(Z.current),Z.current=null;if(E.current!==null)window.clearTimeout(E.current),E.current=null}},[i?.id,r,Ml]),vn(()=>{if(!i||!v||I)return;let H=String(v.id||"");if(!H)return;let C=String(v.updatedAt||"");if(y3(v))return;let g=`${H}:${C||"unknown"}:${String(v?._traceSummaryUpdatedAt||"")}`;if(O.current.has(g))return;O.current.add(g),yi(H,!0).catch((ll)=>Fu(xu(ll,"自动加载 Trace Summary 失败")))},[i?.id,v?.id,v?.updatedAt,v?.traceStats?.statsRevision,v?._traceSummaryUpdatedAt,v?._traceSummaryLoaded,I]),vn(()=>{if(!i)return;m6().catch((H)=>Fu(xu(H,"加载工作目录失败")));return},[i?.id]);let JT=nn.length===0?G(P0,{title:nf?Ql?"搜索中":"没有匹配任务":"队列为空",text:nf?Ql?`正在搜索包含“${At}”的 task...`:`未找到包含“${At}”的 task;可换个关键词或切换 queue。`:"提交一个任务后,Codex 会串行执行并保存输出。"}):[gj.length>0?G(N2,{key:"unread",title:"已结束未读",tasks:gj,selectedId:s,emptyText:"暂无已结束未读任务。",onSelect:K6,onCopy:L6,onReference:G6,onMarkRead:T6,copiedTaskId:it,markingReadTaskId:tt}):null,G(N2,{key:"active",title:"运行 / 排队",tasks:pG,selectedId:s,emptyText:"当前没有运行或排队任务。",onSelect:K6,onCopy:L6,onReference:G6,onMarkRead:T6,copiedTaskId:it,markingReadTaskId:tt}),G(N2,{key:"history",title:"历史 session",tasks:HG,selectedId:s,emptyText:"最近没有完成、失败或取消的 session。",onSelect:K6,onCopy:L6,onReference:G6,onMarkRead:T6,copiedTaskId:it,markingReadTaskId:tt}),G("div",{key:"pagination",className:"codex-task-pagination","data-testid":"codex-task-pagination"},G("span",null,nf?`搜索“${At}” · 已显示 ${nn.length} / ${Number.isFinite(jt)?jt:nn.length}`:`已加载 ${nn.length} / ${Number.isFinite(jt)?jt:nn.length}`),aj?G("button",{type:"button",className:"ghost-btn",disabled:F6,onClick:()=>void f7(),"data-testid":"codex-load-more-tasks-button"},F6?"加载中":nf?"加载更多结果":"加载更早任务"):G("code",null,nf?"已到结果末尾":"已到队列末尾"))],t7=(H,C=!1)=>G("label",{className:`code-queue-switcher ${C?"compact":""}`},G("span",null,C?"Queue":"查看 queue"),G("select",{value:Ml,onChange:(g)=>gG(String(g.target.value||Yi)),"data-testid":H},G("option",{value:Yi},`All queues · ${Number.isFinite(A0)?A0:fn.length} tasks · ${$t.length} running`),Pf.map((g)=>G("option",{key:String(g?.id||""),value:String(g?.id||"")},fc(g))))),UT=G("div",{className:"codex-task-search","data-testid":"codex-task-search"},G("label",{htmlFor:"codex-task-search-input"},"搜索 task"),G("div",{className:"codex-task-search-row"},G("input",{id:"codex-task-search-input",type:"search",value:rl,placeholder:"关键词 / task ID / prompt",autoComplete:"off",onChange:(H)=>cl(String(H.target.value||"")),"data-testid":"codex-task-search-input"}),rl?G("button",{type:"button",className:"ghost-btn",onClick:()=>cl(""),"data-testid":"codex-task-search-clear"},"清除"):null),G("small",{"data-testid":"codex-task-search-summary"},nf?Ql?"搜索中...":`匹配 ${nn.length}/${Number.isFinite(jt)?jt:nn.length}`:"支持 task ID、prompt、状态、provider、模型和最近输出关键词")),NT=G("div",{className:"codex-trace-status","data-testid":"codex-trace-status-summary"},G("span",{className:"codex-trace-status-chip queued"},G("b",null,"排队"),String(ky)),G("span",{className:"codex-trace-status-chip running"},G("b",null,"运行"),String($6)),G("span",{className:`codex-trace-status-chip unread ${pn>0?"warn":""}`},G("b",null,"结束未读"),String(pn)),G("span",{className:"codex-trace-status-chip service"},G("b",null,"服务"),`${BG.providerStatus||"unknown"} · ${i?.providerId||"D601"} · ${DG.public?"公网暴露":"仅 UniDesk frontend 代理访问"}`),G("span",{className:"codex-trace-status-chip"},G("b",null,"执行节点"),G_.map((H)=>H.id).join(" / ")),G("span",{className:"codex-trace-status-chip"},G("b",null,"执行模式"),ej.map((H)=>H.id).join(" / ")),G("span",{className:"codex-trace-status-chip"},G("b",null,"模型"),dj.join(" / ")),G("span",{className:"codex-trace-status-chip"},G("b",null,"加载"),Rr?.phase==="complete"?rE(Rr?.totalMs):String(Rr?.phase||"idle")),G("span",{className:"codex-trace-status-chip"},G("b",null,"刷新"),Q_?iu(Q_):"--")),QT=G(ry,{title:v?`Trace ${String(v.id).slice(0,22)}`:"Trace 输出",eyebrow:v?`${v.status} / view=${L_} / task queue=${ty(v)} / provider=${v.providerId||"D601"} / mode=${v.executionMode||"default"} / ${v.model} / agent loop trace`:`Agent loop trace / view=${L_}`,summary:NT,loading:I||vy||Ql||h||Rr?.phase==="loading",actions:G("div",{className:"panel-actions"},t7("code-queue-filter-select"),G("button",{type:"button",className:"ghost-btn codex-mark-all-read-btn",disabled:pn===0||mu||by,onClick:()=>void kG(),"data-testid":"codex-mark-all-read-button"},by?"标记中":`全部标已读${pn>0?` (${pn})`:""}`),v?G("button",{type:"button",className:"ghost-btn",disabled:I||mu,onClick:()=>void yT(),"data-testid":"codex-load-full-trace-button"},I?"加载中":Uf(v)?"刷新 Summary":"加载 Summary"):null,G("button",{type:"button",className:"codex-session-title-toggle",onClick:()=>Ry((H)=>!H),"data-testid":"code-queue-sidebar-toggle"},Yf?"收起队列":"展开队列"),G("label",{className:"inline-check"},G("input",{type:"checkbox",checked:$u,onChange:(H)=>qr(Boolean(H.target.checked))}),"自动滚动"),G("button",{type:"button",className:"ghost-btn",disabled:!XG||mu,onClick:()=>void nT(),"data-testid":"codex-interrupt-button"},"打断"),G("button",{type:"button",className:"ghost-btn",disabled:!YG||mu,onClick:()=>void iT()},"重试"),v?G(rQ,{title:"Codex Task",data:v,onOpen:u,testId:"raw-codex-task"}):null),className:"codex-output-panel"},G("div",{className:`codex-session-shell ${Yf?"":"queue-collapsed"}`},Yf?G("aside",{className:"codex-session-sidebar","data-testid":"codex-session-sidebar"},G("div",{className:"codex-session-sidebar-head"},G("div",null,G("span",null,Pr(Ml)?"All queues":"Queue lane"),G("strong",null,`${L_} · ${fn.length}/${Number.isFinite(A0)?A0:fn.length} sessions · 未读 ${pn}`)),G("button",{type:"button",className:"ghost-btn",onClick:()=>Ry(!1)},"收起")),t7("code-queue-filter-sidebar",!0),UT,G("div",{className:"codex-task-list codex-task-list-session",onScroll:sG,"data-testid":"codex-task-list-scroll"},JT)):null,G("div",{className:"codex-session-main"},G("div",{className:"codex-output-stack"},G(TO,{task:v,loading:I,onLoadPromptPart:xG,onLoadSteps:W6,onLoadStep:bG}),G(mO,{task:v})))));if(!i)return G(P0,{title:"Code Queue 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=code-queue"});let y7=Number(Rr?.totalMs),c7=Number(Rr?.queueMs),_7=Number(Rr?.detailMs),$7=Number(Rr?.transcriptRows),wT=Rr?.phase==="complete"?"complete":String(Rr?.phase||"idle"),qT=iy(Pf,_0)||{id:_0,name:_0},WT=Qr?G(VN,{title:"合并 queue",titleId:"codex-merge-dialog-title",className:"codex-merge-dialog",backdropClassName:"codex-merge-dialog-backdrop",bodyClassName:"codex-merge-dialog-body",actionsClassName:"codex-merge-dialog-actions",testId:"codex-merge-queue-dialog",closeTestId:"codex-merge-queue-close",disableClose:mu,onClose:()=>Or(!1),actions:[G("button",{key:"cancel",type:"button",className:"ghost-btn",onClick:()=>Or(!1),disabled:mu,"data-testid":"codex-merge-queue-cancel"},"取消"),G("button",{key:"confirm",type:"button",className:"primary-btn",onClick:()=>void lT(),disabled:mu||Au||!$r,"data-testid":"codex-merge-queue-confirm"},mu?"合并中...":"确认合并")]},G("p",{className:"codex-merge-dialog-target"},"目标 queue:",G("code",null,fc(qT))),G("label",null,"源 queue",G("select",{value:$r,disabled:mu||Au,onChange:(H)=>ir(String(H.target.value||"")),"data-testid":"codex-merge-source-queue-select"},G("option",{value:""},"选择要合并进来的源 queue"),$0.map((H)=>G("option",{key:String(H?.id||""),value:String(H?.id||"")},fc(H))))),G("p",{className:"codex-merge-dialog-note"},"会把源 queue 的任务归属合并到目标 queue,并自动删除源 queue;目标 queue 会按原 queueEnteredAt/createdAt 时间顺序运行。")):null;return G("div",{className:`code-queue-page ${n?"codex-standalone-page":""}`,"data-testid":"code-queue-page","data-load-state":wT,"data-load-total-ms":Number.isFinite(y7)?String(Math.round(y7*10)/10):"","data-load-queue-ms":Number.isFinite(c7)?String(Math.round(c7*10)/10):"","data-load-detail-ms":Number.isFinite(_7)?String(Math.round(_7*10)/10):"","data-load-transcript-rows":Number.isFinite($7)?String($7):"","data-load-task-id":String(Rr?.taskId||s||""),"data-load-partial":Rr?.partial?"true":"false"},G(lu,{error:c6,wide:!0}),WT,G("div",{className:"codex-session-stage codex-session-stage-top"},QT),G("div",{className:"code-queue-layout"},G("div",{className:"codex-left-rail"},G(ry,{title:"提交任务",eyebrow:Au?"Submitting...":Hn.length>1?`${Hn.length} tasks`:"Single or Batch",className:"codex-compose-panel",loading:Au},G("form",{className:`codex-task-form ${Au?"is-submitting":""}`,onSubmit:uT,"data-testid":"code-queue-task-form","aria-busy":Au?"true":"false"},G("label",null,"Prompt / 多任务用单独一行 --- 分隔",G("textarea",{value:o,rows:8,disabled:Au,onChange:(H)=>ql(H.target.value),placeholder:"写入 Codex 任务;多个任务之间用 --- 分隔。"})),G("label",{className:"codex-reference-field"},"引用任务 ID(可选)",G("input",{value:pl,disabled:Au,onChange:(H)=>Bl(H.target.value),placeholder:"codex_...;支持空格/逗号分隔多个 ID","data-testid":"codex-reference-task-id"}),V0(pl).length>0?G("code",null,`后端将解析并注入:${V0(pl).join(" / ")}`):null),G("div",{className:"codex-form-grid"},G("label",{className:"codex-submit-queue-field"},"Queue",G("div",{className:"codex-submit-queue-row"},G("select",{className:"codex-submit-queue-select",value:Il,disabled:Au,onChange:(H)=>nu(String(H.target.value||"default")),"data-testid":"code-queue-id-select"},Pf.map((H)=>G("option",{key:String(H?.id||""),value:String(H?.id||"")},fc(H)))),G("button",{type:"button",className:"ghost-btn codex-rename-queue-btn",onClick:()=>void dG(),disabled:mu||Au||!Il,title:"修改当前 queue 的显示名称,ID 不变","data-testid":"codex-rename-queue-button"},"改名"),G("button",{type:"button",className:"ghost-btn codex-merge-queue-btn",onClick:()=>eG(),disabled:mu||Au||$0.length===0,title:"打开独立窗口选择源 queue 并合并到当前 queue;合并后自动删除源 queue","data-testid":"codex-merge-queue-button"},"合并 queue"),G("button",{type:"button",className:"ghost-btn codex-create-queue-btn",onClick:()=>void oG(),disabled:mu||Au,"data-testid":"codex-create-queue-button"},"创建 queue"))),G("label",null,"模型",G("select",{value:wr,disabled:Au,onChange:(H)=>hl(H.target.value),"data-testid":"codex-model-select"},dj.map((H)=>G("option",{key:H,value:H},H)))),G("label",null,"执行 Provider",G("select",{value:tr,disabled:Au,onChange:(H)=>hG(String(H.target.value||"D601")),"data-testid":"codex-provider-select"},G_.map((H)=>G("option",{key:H.id,value:H.id},`${H.label||H.id} · ${H.defaultWorkdir||Z2(Cu,H.id)}${H.supportsWindowsNativeCodex?" · Windows native":""}`)))),G("label",null,"执行模式",G("select",{value:jl,disabled:Au,onChange:(H)=>RG(String(H.target.value||"default")),"data-testid":"codex-execution-mode-select"},ej.map((H)=>G("option",{key:H.id,value:H.id},`${H.label||H.id}${H.id==="windows-native"?" · 宿主 Codex":""}`)))),G("label",{className:"codex-workdir-field"},"工作目录",G("div",{className:"codex-workdir-row"},G("input",{value:Yu,disabled:Au,onChange:(H)=>eu(H.target.value),placeholder:l7||Cu?.defaultWorkdir||"/workspace","data-testid":"codex-cwd-input"}),G("select",{value:yy(Yu),disabled:Au||yt,onChange:(H)=>eu(String(H.target.value||"")),"data-testid":"codex-cwd-select"},u7.map((H)=>G("option",{key:`${H.providerId}:${H.executionMode}:${H.path}`,value:H.path},`${H.path}${H.source==="default"?" · 默认":""}`))),G("button",{type:"button",className:"ghost-btn codex-workdir-create-btn",disabled:Au||mu||yt,onClick:()=>void IG(),"data-testid":"codex-cwd-create-button"},yt?"处理中":"新建"),G("button",{type:"button",className:"ghost-btn codex-workdir-delete-btn",disabled:Au||mu||yt||!U6,onClick:()=>void aG(),title:U6?"从工作目录下拉菜单删除这个选项,不删除磁盘目录":"当前工作目录尚未保存到下拉菜单","data-testid":"codex-cwd-delete-button"},"删除"))),G("label",null,"最大尝试",G("input",{type:"number",min:1,max:99,value:rf,disabled:Au,onChange:(H)=>Ar(Number(H.target.value)),"data-testid":"codex-max-attempts-input"})),G("label",null,"入队份数",G("input",{type:"number",min:1,max:50,value:Zr,disabled:Au,onChange:(H)=>Zn(Number(H.target.value)),"data-testid":"codex-repeat-count-input"}))),gy>1?G("label",{className:`codex-batch-confirm ${ff?"confirmed":""}`,"data-testid":"codex-batch-confirm-row"},G("input",{type:"checkbox",checked:ff,disabled:Au,onChange:(H)=>ii(Boolean(H.target.checked)),"data-testid":"codex-batch-confirm-checkbox"}),G("span",null,`确认批量入队 ${gy} 个任务(prompt 分段 ${J6.length} × 入队份数 ${RN(Zr)})`)):null,Au?G("div",{className:"codex-submit-wait","data-testid":"codex-submit-wait"},"正在提交到后端,已锁定输入以防重复提交..."):null,G("div",{className:"codex-form-actions"},G("button",{type:"button",className:"ghost-btn",disabled:mu||Au||o.length===0&&pl.length===0,onClick:()=>{ql(""),Bl(""),ii(!1);let H="已清空任务输入栏";Pu(H),pr("success",H)},"data-testid":"codex-clear-input-button"},"清空输入"),G("button",{type:"submit",className:"primary-btn",disabled:VG,"data-testid":"codex-enqueue-button"},Au?"提交中,请等待...":oj?`请确认批量入队 ${gy} 个任务`:Hn.length>1?`批量入队 ${Hn.length} 个任务`:"入队并运行"))))),G("div",{className:"codex-main-stage"},G("div",{className:"codex-detail-grid"},G(ry,{title:"运行控制",eyebrow:Ft?"Queued prompt editable":N6?"Active turn steer":"Steer when running",loading:mu},G("div",{className:"codex-run-control-stack"},G(wO,{task:v,queueRows:Pf,busy:mu,onMove:tT}),v?.id?G("form",{className:"codex-steer-form codex-edit-prompt-form",onSubmit:fT,"data-testid":"codex-edit-prompt-form"},G("label",null,"编辑 queued 用户 prompt",G("textarea",{value:Cl,rows:5,onChange:(H)=>dl(H.target.value),placeholder:"仅 QUEUED 且尚未开始运行的任务可在这里修改原始用户 prompt。",disabled:!Ft||mu,"data-testid":"codex-edit-prompt-textarea"})),G("label",{className:"codex-reference-field"},"引用任务 ID(可选,留空会清除引用)",G("input",{value:ju,disabled:!Ft||mu,onChange:(H)=>ku(H.target.value),placeholder:"codex_...;支持空格/逗号分隔多个 ID","data-testid":"codex-edit-reference-task-id"}),V0(ju).length>0?G("code",null,`将保留/注入:${V0(ju).join(" / ")}`):null),G("div",{className:"codex-form-actions"},G("button",{type:"button",className:"ghost-btn",disabled:!v?.id||mu,onClick:()=>{dl(v?_3(v):""),ku(Array.isArray(v?.referenceTaskIds)?v.referenceTaskIds.join(" "):"")},"data-testid":"codex-edit-prompt-reset"},"恢复当前值"),G("button",{type:"submit",className:"primary-btn",disabled:!Ft||mu||Cl.trim().length===0,title:Ft?"保存后会重写尚未运行任务的用户 prompt":"只有 QUEUED 且尚未开始的任务可编辑 prompt","data-testid":"codex-edit-prompt-submit"},"保存 queued prompt"))):null,G("form",{className:"codex-steer-form",onSubmit:rT},G("label",null,"追加 prompt",G("textarea",{value:fl,rows:4,onChange:(H)=>Dl(H.target.value),placeholder:"给正在运行的 Codex session 推入新的指令或纠偏。",disabled:!N6})),G("button",{type:"submit",className:"primary-btn",disabled:!N6||mu||fl.trim().length===0,"data-testid":"codex-steer-button"},"推入运行中 session")))),G(ry,{title:"完成判定",eyebrow:v?.lastJudge?v.lastJudge.source:"judge",loading:I},v?.lastJudge?G("div",{className:"codex-judge-card","data-testid":"codex-task-judge-card"},G(Y0,{status:v.lastJudge.decision},v.lastJudge.decision),G("strong",null,`${Math.round(Number(v.lastJudge.confidence||0)*100)}% confidence`),G("p",{"data-testid":"codex-task-judge-reason"},Q2(v.lastJudge.reason||"--",180)),G($Q,{judge:v.lastJudge,testId:"codex-task-judge-failure-details"}),v.lastJudge.continuePrompt?G("code",{"data-testid":"codex-task-judge-continue-prompt"},Q2(v.lastJudge.continuePrompt,160)):null):G(P0,{title:"尚未判定",text:"Codex turn 结束后会由 MiniMax M2.7 或 fallback judge 判定 complete/retry/fail;retry 会在已有 thread 追加继续执行 prompt。"}))),G(QO,{stats:_6,queueName:L_,onRaw:u}),G(ry,{title:"Attempts",eyebrow:"terminal vs interruption",loading:I},G(KO,{task:v})))))}var _y=Rl(Ju(),1);var e=_y.default.createElement,{useEffect:p2}=_y.default,cc=_y.default.useState,zO=["all","meeting","decision","goal","blocker","debt","experiment"],EO=["all","G0","G1","G2","G3","P0","P1","P2","P3","none"],OO=["all","active","blocked","parked","done"];function U3({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return e("span",{className:`status-badge ${r}`},u||l||"unknown")}function F3({label:l,value:u,hint:r,tone:f}){return e("article",{className:`metric-card ${f||""}`},e("div",{className:"metric-label"},l),e("div",{className:"metric-value"},u),e("div",{className:"metric-hint"},r))}function wn({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return e("section",{className:`panel ${n||""}`},e("div",{className:"panel-head"},e("div",null,u?e("p",{className:"panel-eyebrow"},u):null,e(fu,{title:l,loading:i})),r?e("div",{className:"panel-actions"},r):null),e("div",{className:"panel-body"},f))}function cy({title:l,data:u,onOpen:r,testId:f}){return e("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function Pi({title:l,text:u}){return e("div",{className:"empty-state"},e("strong",null,l),e("span",null,u))}function ZO(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function pO(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function HO(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function _c(l,u){return`${l}/microservices/decision-center/proxy${u}`}function TQ(l){if(l==="G0"||l==="G1")return"online";if(l==="P0"||l==="P1")return"failed";if(l==="none")return"unknown";return"warn"}function mQ(l){if(l==="done")return"online";if(l==="blocked")return"failed";if(l==="parked")return"warn";return"unknown"}function B2(l){return Wl(l)||"--"}function N3(l,u=220){let r=String(l||"").replace(/\s+/gu," ").trim();return r.length>u?`${r.slice(0,u-1)}...`:r}function J3({record:l,onRaw:u,compact:r}){let f=Array.isArray(l.tags)?l.tags:[],n=Array.isArray(l.evidenceLinks)?l.evidenceLinks:[];return e("article",{className:`decision-record-card ${r?"compact":""}`,"data-testid":`decision-record-${String(l.id||"").replace(/[^A-Za-z0-9_-]+/g,"-")}`},e("div",{className:"decision-record-head"},e("div",null,e("div",{className:"decision-record-meta"},e("span",null,l.type||"--"),e(U3,{status:TQ(l.level)},l.level||"none"),e(U3,{status:mQ(l.status)},l.status||"--")),e("strong",null,l.title||"--")),e(cy,{title:`Decision ${l.id}`,data:l,onOpen:u})),r?e("p",{className:"decision-summary"},N3(l.summary||l.body)):e(d1,{markdown:l.body||l.summary||"",className:"decision-markdown"}),e("div",{className:"decision-record-foot"},l.linkedGoalId?e("code",null,`goal:${l.linkedGoalId}`):null,l.taskId?e("code",null,`task:${l.taskId}`):null,l.commitId?e("code",null,l.commitId.slice(0,12)):null,e("span",null,B2(l.updatedAt))),f.length>0?e("div",{className:"decision-tags"},f.slice(0,8).map((i)=>e("span",{key:i},i))):null,n.length>0?e("div",{className:"decision-evidence"},n.slice(0,4).map((i)=>e("a",{key:i,href:i,target:"_blank",rel:"noreferrer"},N3(i,58)))):null)}function BO({records:l,onRaw:u}){if(!l.length)return e(Pi,{title:"暂无记录",text:"通过 CLI 上传会议记录或决议后会显示在这里。"});return e("div",{className:"table-wrap"},e("table",{className:"decision-table","data-testid":"decision-center-record-table"},e("thead",null,e("tr",null,e("th",null,"等级"),e("th",null,"状态"),e("th",null,"类型"),e("th",null,"标题"),e("th",null,"摘要"),e("th",null,"证据"),e("th",null,"更新"),e("th",null,"操作"))),e("tbody",null,l.map((r)=>e("tr",{key:r.id},e("td",null,e(U3,{status:TQ(r.level)},r.level||"none")),e("td",null,e(U3,{status:mQ(r.status)},r.status||"--")),e("td",null,r.type||"--"),e("td",null,e("strong",null,r.title||"--"),r.linkedGoalId?e("code",null,r.linkedGoalId):null),e("td",null,N3(r.summary||r.body,180)),e("td",null,Array.isArray(r.evidenceLinks)?r.evidenceLinks.length:0),e("td",null,B2(r.updatedAt)),e("td",null,e(cy,{title:`Decision ${r.id}`,data:r,onOpen:u})))))))}function H2(l){return l.map((u)=>e("option",{key:u,value:u},u))}function DO(l){let u=new URLSearchParams;if(l.type!=="all")u.set("type",l.type);if(l.status!=="all")u.set("status",l.status);if(l.level!=="all")u.set("level",l.level);if(l.linkedGoalId.trim())u.set("linkedGoalId",l.linkedGoalId.trim());return u.set("limit","240"),u.toString()}function VO(l){let u=new URLSearchParams;if(l.month!=="all")u.set("month",l.month);if(l.from.trim())u.set("from",l.from.trim());if(l.to.trim())u.set("to",l.to.trim());return u.set("limit","180"),u.toString()}function SO({entry:l,selected:u,onSelect:r,onRaw:f}){return e("article",{className:`diary-entry-card ${u?"selected":""}`,"data-testid":`diary-entry-${String(l.date||l.id||"").replace(/[^A-Za-z0-9_-]+/g,"-")}`},e("button",{type:"button",className:"diary-entry-main",onClick:()=>r(l)},e("span",{className:"diary-date"},l.date||"--"),e("strong",null,l.title||l.markdownPath||"--"),e("span",null,N3(l.summary||l.body,180))),e("div",{className:"decision-record-foot"},e("code",null,l.markdownPath||"--"),e("span",null,B2(l.updatedAt||l.importedAt)),e(cy,{title:`Diary ${l.date||l.id}`,data:l,onOpen:f})))}function KQ({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((B)=>B.id==="decision-center")||null,[n,i]=cc({loading:!1,error:"",health:null,records:[],refreshedAt:null}),[t,y]=cc({type:"all",status:"all",level:"all",linkedGoalId:""}),[c,$]=cc("records"),[A,j]=cc({loading:!1,error:"",entries:[],months:[],selected:null,refreshedAt:null}),[F,U]=cc({month:"all",from:"",to:""});async function N(){if(!f)return;i((B)=>({...B,loading:!0,error:""}));try{let B=DO(t),m=await ml(_c(r,`/api/records?${B}`)),X=await ml(_c(r,"/api/diary/months")),S=n.health,b="";try{S=await ml(`${r}/microservices/decision-center/health`)}catch(z){b=El(z,"Decision Center health 检查失败")}i({loading:!1,error:b,health:S,records:Array.isArray(m.records)?m.records:[],refreshedAt:new Date}),j((z)=>({...z,months:Array.isArray(X.months)?X.months:[]}))}catch(B){i((m)=>({...m,loading:!1,error:El(B,"Decision Center 加载失败")}))}}async function W(){if(!f)return;j((B)=>({...B,loading:!0,error:""}));try{let B=await ml(_c(r,`/api/diary/entries?${VO(F)}`)),m=await ml(_c(r,"/api/diary/months")),X=Array.isArray(B.entries)?B.entries:[];j((S)=>({loading:!1,error:"",entries:X,months:Array.isArray(m.months)?m.months:S.months,selected:S.selected&&X.some((b)=>b.id===S.selected?.id)?S.selected:X[0]||null,refreshedAt:new Date}))}catch(B){j((m)=>({...m,loading:!1,error:El(B,"日记加载失败")}))}}async function L(B){j((m)=>({...m,selected:B}));try{let m=await ml(_c(r,`/api/diary/entries/${encodeURIComponent(B.date||B.id)}`));j((X)=>({...X,selected:m.entry||B}))}catch(m){j((X)=>({...X,error:El(m,"日记正文加载失败")}))}}if(p2(()=>{N()},[f?.id,f?.runtime?.providerStatus]),p2(()=>{let B=setTimeout(()=>void N(),120);return()=>clearTimeout(B)},[t.type,t.status,t.level,t.linkedGoalId]),p2(()=>{if(c!=="diary")return;let B=setTimeout(()=>void W(),120);return()=>clearTimeout(B)},[c,F.month,F.from,F.to,f?.id,f?.runtime?.providerStatus]),!f)return e(Pi,{title:"Decision Center 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=decision-center"});let J=ZO(f),w=HO(f),Q=pO(f),q=Array.isArray(n.records)?n.records:[],T=q.filter((B)=>B.type==="goal"&&["G0","G1"].includes(B.level)&&B.status!=="done").slice(0,8),O=q.filter((B)=>B.type==="blocker"&&["P0","P1"].includes(B.level)&&B.status!=="done").slice(0,8),Z=q.filter((B)=>B.status==="parked").slice(0,8),E=q.filter((B)=>B.type==="meeting"||B.type==="decision").slice(0,12),D=Array.isArray(A.entries)?A.entries:[],Y=Array.isArray(A.months)?A.months:[],p=A.selected,V=Number(n.health?.diaryEntryCount??0);return e("div",{className:"decision-center-page","data-testid":"decision-center-page"},e(wn,{title:"Decision Center",eyebrow:"Authority Records",loading:n.loading,actions:e("div",{className:"inline-actions"},e("button",{type:"button",className:"ghost-btn",onClick:()=>void N(),disabled:n.loading},n.loading?"刷新中":"刷新"),e(cy,{title:"Decision Center Health",data:n.health,onOpen:u,testId:"raw-decision-center-health"}))},e("div",{className:"decision-hero"},e("div",{className:"metric-grid"},e(F3,{label:"记录数",value:q.length,hint:`PostgreSQL / ${n.health?.storage||"postgres"}`,tone:"ok"}),e(F3,{label:"日记",value:V,hint:"按月 Markdown",tone:V>0?"ok":"warn"}),e(F3,{label:"G0/G1 目标",value:T.length,hint:"active authority goals",tone:"ok"}),e(F3,{label:"P0/P1 Blocker",value:O.length,hint:"requires decision",tone:O.length>0?"warn":"ok"})),e("div",{className:"microservice-ref-card"},e("span",null,"Runtime"),e("strong",null,J.orchestrator||f.deployment?.mode||"k3sctl"),e("code",null,`${f.providerId} / ${Q.nodeBindHost||"--"}:${Q.nodePort||"--"}`),e("code",null,w.commitId||"--"))),e(lu,{error:n.error,title:"Decision Center 请求失败"})),e("div",{className:"decision-tabs",role:"tablist"},e("button",{type:"button",className:c==="records"?"active":"",onClick:()=>$("records")},"权威记录"),e("button",{type:"button",className:c==="diary"?"active":"",onClick:()=>$("diary")},"工作日记")),c==="diary"?e(_y.default.Fragment,null,e(wn,{title:"日记筛选",eyebrow:"Markdown by Month",loading:A.loading,actions:e("div",{className:"inline-actions"},e("button",{type:"button",className:"ghost-btn",onClick:()=>void W(),disabled:A.loading},A.loading?"刷新中":"刷新"),e(cy,{title:"Diary Months",data:Y,onOpen:u,testId:"raw-decision-center-diary-months"}))},e("div",{className:"decision-filter-bar"},e("label",null,"月份",e("select",{value:F.month,onChange:(B)=>U((m)=>({...m,month:B.target.value}))},e("option",{value:"all"},"all"),Y.map((B)=>e("option",{key:B.month,value:B.month},`${B.month} (${B.count})`)))),e("label",null,"开始日期",e("input",{type:"date",value:F.from,onChange:(B)=>U((m)=>({...m,from:B.target.value}))})),e("label",null,"结束日期",e("input",{type:"date",value:F.to,onChange:(B)=>U((m)=>({...m,to:B.target.value}))})),e("label",null,"存储",e("input",{value:"PostgreSQL / YYYY-MM/YYYY-MM-DD.md",readOnly:!0}))),e(lu,{error:A.error,title:"日记请求失败"})),e("div",{className:"diary-layout"},e(wn,{title:"按天条目",eyebrow:`${D.length} Entries`,loading:A.loading},D.length===0?e(Pi,{title:"暂无日记",text:"使用 CLI 导入按日期标题拆分的工作日志 Markdown。"}):e("div",{className:"diary-entry-list"},D.map((B)=>e(SO,{key:B.id,entry:B,selected:p?.id===B.id,onSelect:L,onRaw:u})))),e(wn,{title:p?.title||"日记正文",eyebrow:p?.markdownPath||"Daily Markdown",actions:p?e(cy,{title:`Diary ${p.date}`,data:p,onOpen:u,testId:"raw-decision-center-diary-selected"}):null},p?e(d1,{markdown:p.body||p.summary||"",className:"decision-markdown diary-markdown"}):e(Pi,{title:"未选择日记",text:"从左侧选择一天查看 Markdown 正文。"})))):e(_y.default.Fragment,null,e(wn,{title:"筛选",eyebrow:"Type / Status / Level"},e("div",{className:"decision-filter-bar","data-testid":"decision-center-filters"},e("label",null,"类型",e("select",{value:t.type,onChange:(B)=>y((m)=>({...m,type:B.target.value}))},H2(zO))),e("label",null,"状态",e("select",{value:t.status,onChange:(B)=>y((m)=>({...m,status:B.target.value}))},H2(OO))),e("label",null,"等级",e("select",{value:t.level,onChange:(B)=>y((m)=>({...m,level:B.target.value}))},H2(EO))),e("label",null,"Linked Goal",e("input",{value:t.linkedGoalId,onChange:(B)=>y((m)=>({...m,linkedGoalId:B.target.value})),placeholder:"goal id"})))),e("div",{className:"decision-default-grid"},e(wn,{title:"G0/G1 目标",eyebrow:`${T.length} Goals`},T.length===0?e(Pi,{title:"暂无当前目标",text:"目标记录使用 type=goal 且 level=G0/G1。"}):e("div",{className:"decision-card-list"},T.map((B)=>e(J3,{key:B.id,record:B,onRaw:u,compact:!0})))),e(wn,{title:"P0/P1 Blocker",eyebrow:`${O.length} Blockers`},O.length===0?e(Pi,{title:"暂无高优先级阻塞",text:"阻塞记录使用 type=blocker 且 level=P0/P1。"}):e("div",{className:"decision-card-list"},O.map((B)=>e(J3,{key:B.id,record:B,onRaw:u,compact:!0})))),e(wn,{title:"停放事项",eyebrow:`${Z.length} Parked`},Z.length===0?e(Pi,{title:"暂无停放事项",text:"status=parked 的记录会集中展示。"}):e("div",{className:"decision-card-list"},Z.map((B)=>e(J3,{key:B.id,record:B,onRaw:u,compact:!0})))),e(wn,{title:"最近会议/决议",eyebrow:`${E.length} Recent`},E.length===0?e(Pi,{title:"暂无会议或决议",text:"使用 CLI 上传 Markdown 会议记录后会显示。"}):e("div",{className:"decision-card-list"},E.map((B)=>e(J3,{key:B.id,record:B,onRaw:u,compact:!0}))))),e(wn,{title:"全部记录",eyebrow:`${q.length} Records`,actions:n.refreshedAt?e("span",{className:"muted"},`刷新 ${iu(n.refreshedAt)}`):null},e(BO,{records:q,onRaw:u}))))}var $c=Rl(Ju(),1);var Vl=$c.default.createElement,{useEffect:D2}=$c.default,V2=$c.default.useState,XO=$c.default.useRef,X2=` :root { --surfacePrimary: #ffffff; --surfaceSecondary: #f8fafc; @@ -229,64 +230,64 @@ nav .material-icons::before { display: none !important; } } -`;function q2({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return mu("section",{className:`panel ${n||""}`},mu("div",{className:"panel-head"},mu("div",null,l?mu("p",{className:"panel-eyebrow"},l):null,mu(rl,{title:u,loading:i})),f?mu("div",{className:"panel-actions"},f):null),mu("div",{className:"panel-body"},r))}function nZ({title:u,data:l,onOpen:f,testId:r}){return mu("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function iZ({title:u,text:l}){return mu("div",{className:"empty-state"},mu("strong",null,u),mu("span",null,l))}function yN(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function cN(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function _N(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function tZ(u){return u.filter((f)=>f?.id==="filebrowser"||String(f?.id||"").startsWith("filebrowser-")).sort((f,r)=>{let n=(i)=>i.providerId==="D518"?0:i.providerId==="D601"?1:i.id==="filebrowser"?2:3;return n(f)-n(r)||String(f.id).localeCompare(String(r.id))})}function yZ(u){if(u?.providerId==="D518")return"D518";return u?.providerId||u?.name||u?.id||"Unknown"}function cZ(u,l,f="/"){let r=f.startsWith("/")?f:`/${f}`;return`${u}/microservices/${encodeURIComponent(l)}/proxy${r}`}function _Z(u,l){return`${u}/microservices/${encodeURIComponent(l)}/health`}async function $Z(u,l=16000){let f=new AbortController,r=setTimeout(()=>f.abort(),l);try{return await Eu(u,{signal:f.signal,failureFields:[!1]})}finally{clearTimeout(r)}}function $N(u){if(u?.providerId==="main-server")return"host / -> /srv";if(u?.providerId==="D601"||u?.providerId==="D518")return"WSL / + /mnt/c -> /srv";return"provider / -> /srv"}function i3(u){return u?.status==="OK"||u?.ok===!0}function AZ({service:u,active:l,health:f,onSelect:r,onRaw:n}){let i=yN(u),t=cN(u),y=_N(u),c=i.container||{},$=i3(f?.body);return mu("button",{type:"button",className:`filebrowser-target-card ${l?"active":""}`,"data-testid":`filebrowser-target-card-${u.id}`,onClick:r},mu("span",{className:`status-badge ${$?"ok":i.providerStatus==="online"?"running":"warn"}`},$?"Health OK":i.providerStatus||"unknown"),mu("strong",null,u.name||u.id),mu("span",null,$N(u)),mu("code",null,`${t.nodeBindHost||"--"}:${t.nodePort||"--"}`),mu("small",null,c.name?`${c.name} / ${c.state||"--"}`:`${y.composeService||"--"}`),mu("span",{className:"filebrowser-card-raw",onClick:(A)=>{A.stopPropagation(),n(`${u.name} service`,u)}},"JSON"))}function AN(u){try{return u?.contentDocument||u?.contentWindow?.document||null}catch{return null}}function W2(u){let l=AN(u);if(l===null||l.head===null)return!1;let f=l.getElementById("unidesk-filebrowser-compact-style");if(f===null)f=l.createElement("style"),f.id="unidesk-filebrowser-compact-style",l.head.appendChild(f);if(f.textContent!==w2)f.textContent=w2;return!0}function jZ(u,l){let f=URL.createObjectURL(u),r=document.createElement("a");r.href=f,r.download=l,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(f),2000)}function FZ(u,l){let f=AN(u);if(f===null||f.documentElement===null)throw Error("无法访问 File Browser iframe 文档");W2(u);let r=Math.max(640,Math.ceil(u.clientWidth||f.documentElement.clientWidth||1280)),n=Math.max(480,Math.ceil(u.clientHeight||f.documentElement.clientHeight||720)),i=f.documentElement.cloneNode(!0);i.querySelectorAll("script, style, link[rel='stylesheet'], link[rel='preload'], link[rel='icon']").forEach((A)=>A.remove()),i.querySelectorAll("img").forEach((A)=>{A.removeAttribute("src"),A.removeAttribute("srcset")});let t=i.querySelector("head");if(t===null)t=f.createElement("head"),i.insertBefore(t,i.firstChild);let y=f.createElement("style");y.textContent=`${w2} -html,body{width:${r}px!important;min-height:${n}px!important;overflow:hidden!important;}`,t.appendChild(y);let c=new XMLSerializer().serializeToString(i),$=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${n}" viewBox="0 0 ${r} ${n}"><foreignObject width="100%" height="100%">${c}</foreignObject></svg>`;jZ(new Blob([$],{type:"image/svg+xml;charset=utf-8"}),l.replace(/\.png$/i,".svg"))}function jN({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=tZ(Array.isArray(u)?u:[]),n=new URLSearchParams(window.location.search).get("target")||"",i=n==="filebrowser-d518"?"filebrowser":n,t=r.some((Z)=>Z.id===i)?i:r[0]?.id||"",[y,c]=N2(t),[$,A]=N2({loading:!1,refreshedAt:null,health:{},error:""}),[j,F]=N2({exporting:!1,message:"",error:""}),J=rZ(null),Q=r.find((Z)=>Z.id===y)||r[0]||null,W=yN(Q),L=cN(Q),U=_N(Q),q=Q?$.health[Q.id]:null,N=Q?cZ(f,Q.id,"/"):"about:blank";Q2(()=>{if(r.length===0)return;if(!y||!r.some((Z)=>Z.id===y))c(r[0].id)},[r.map((Z)=>Z.id).join(",")]),Q2(()=>{let Z=0,H=setInterval(()=>{if(Z+=1,W2(J.current)||Z>=24)clearInterval(H)},500);return()=>clearInterval(H)},[N]),Q2(()=>{if(r.length===0)return;let Z=!1;async function H(){A((S)=>({...S,loading:!0,error:""}));let m=await Promise.all(r.map(async(S)=>{try{let B=await $Z(_Z(f,S.id));return[S.id,{ok:!0,body:B}]}catch(B){return[S.id,{ok:!1,error:Ou(B,"File Browser health failed")}]}}));if(Z)return;A({loading:!1,refreshedAt:new Date().toISOString(),health:Object.fromEntries(m),error:""})}H();let E=setInterval(H,30000);return()=>{Z=!0,clearInterval(E)}},[r.map((Z)=>`${Z.id}:${Z.runtime?.providerStatus||""}`).join(","),f]);function w(Z){c(Z);let H=new URL(window.location.href);H.searchParams.set("target",Z),window.history.replaceState({},"",`${H.pathname}${H.search}`)}async function G(){if(j.exporting)return;F({exporting:!0,message:"",error:""});try{let Z=new Date().toISOString().replace(/[-:.TZ]/g,"").slice(0,14);await FZ(J.current,`unidesk-filebrowser-${Q?.id||"target"}-${Z}.png`),F({exporting:!1,message:"截图已导出",error:""})}catch(Z){F({exporting:!1,message:"",error:Ou(Z,"截图导出失败")})}}if(r.length===0)return mu(iZ,{title:"File Browser 未登记",text:"请在 config.json 的 microservices 中登记 id=filebrowser 或 filebrowser-* 用户服务"});return mu("div",{className:"filebrowser-page","data-testid":"filebrowser-page"},$.error?mu(nl,{error:$.error,wide:!0}):null,mu(q2,{title:"文件管理器",eyebrow:"File Browser / Host Files",loading:$.loading,actions:mu("div",{className:"panel-actions"},Q?mu("button",{type:"button",className:"ghost-btn",onClick:G,disabled:j.exporting,"data-testid":"filebrowser-export-screenshot"},j.exporting?"导出中...":"导出截图"):null,Q?mu("a",{className:"ghost-btn",href:N,target:"_blank",rel:"noreferrer"},"新窗口打开"):null,Q?mu(nZ,{title:"File Browser 当前目标",data:{service:Q,health:q},onOpen:l,testId:"raw-filebrowser-active"}):null)},mu("div",{className:"filebrowser-hero"},mu("div",null,mu("span",{className:`status-badge ${i3(q?.body)?"ok":"warn"}`},i3(q?.body)?"Health OK":"Health Pending"),mu("h3",null,Q?.name||"File Browser"),mu("p",{className:"muted paragraph"},Q?.description||"通过 UniDesk 登录态代理访问,不开放 File Browser 公网端口。"),j.error?mu("p",{className:"filebrowser-shot-error"},j.error):null,j.message?mu("p",{className:"filebrowser-shot-ok"},j.message):null),mu("div",{className:"microservice-ref-card"},mu("span",null,"Provider"),mu("strong",null,Q?.providerId||"--"),mu("code",null,W.providerName||Q?.providerId||"--")),mu("div",{className:"microservice-ref-card"},mu("span",null,"Private Backend"),mu("strong",null,`${L.nodeBindHost||"--"}:${L.nodePort||"--"}`),mu("code",null,L.nodeBaseUrl||"--")),mu("div",{className:"microservice-ref-card"},mu("span",null,"Image"),mu("strong",null,U.dockerfile||"filebrowser/filebrowser:v2.63.3"),mu("code",null,U.commitId||"--")),mu("div",{className:"microservice-ref-card"},mu("span",null,"Mount"),mu("strong",null,$N(Q)),mu("code",null,Q?.providerId==="main-server"?"/root, /var, /home":"/home, /mnt/c, /mnt/d")))),mu(q2,{title:"浏览目标",eyebrow:`${r.length} host targets`,loading:$.loading},mu("div",{className:"filebrowser-target-grid"},r.map((Z)=>mu(AZ,{key:Z.id,service:Z,active:Z.id===Q?.id,health:$.health[Z.id],onSelect:()=>w(Z.id),onRaw:l})))),mu(q2,{title:`${yZ(Q)} 文件视图`,eyebrow:q?.body?`Health ${i3(q.body)?"OK":"UNKNOWN"} / ${$.refreshedAt?yl($.refreshedAt):"--"}`:"Embedded WebUI",className:"filebrowser-frame-panel"},mu("div",{className:"filebrowser-frame-shell"},mu("div",{className:"filebrowser-frame-toolbar"},mu("span",null,"BaseURL"),mu("code",null,`/api/microservices/${Q?.id||"filebrowser"}/proxy`),mu("span",null,"Root"),mu("code",null,"/srv"),mu("span",{className:"filebrowser-compact-note"},"Compact layout injected")),mu("iframe",{ref:J,key:N,title:`${Q?.name||"File Browser"} WebUI`,src:N,className:"filebrowser-frame","data-testid":"filebrowser-frame",onLoad:(Z)=>W2(Z.currentTarget),sandbox:"allow-downloads allow-forms allow-modals allow-same-origin allow-scripts"}))))}var _3=Cu(Jl(),1);var Uu=_3.default.createElement,{useEffect:UZ}=_3.default,JZ=_3.default.useState;function t3({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return Uu("span",{className:`status-badge ${f}`},l||u||"unknown")}function p0({label:u,value:l,hint:f,tone:r}){return Uu("article",{className:`metric-card ${r||""}`},Uu("div",{className:"metric-label"},u),Uu("div",{className:"metric-value"},l),Uu("div",{className:"metric-hint"},f))}function y3({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return Uu("section",{className:`panel ${n||""}`},Uu("div",{className:"panel-head"},Uu("div",null,l?Uu("p",{className:"panel-eyebrow"},l):null,Uu(rl,{title:u,loading:i})),f?Uu("div",{className:"panel-actions"},f):null),Uu("div",{className:"panel-body"},r))}function c3({title:u,data:l,onOpen:f,testId:r}){return Uu("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function L2({title:u,text:l}){return Uu("div",{className:"empty-state"},Uu("strong",null,u),Uu("span",null,l))}function QZ(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function NZ(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function qZ(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function Yi(u,l){let f=u&&typeof u==="object"?u[l]:void 0;return Number.isFinite(Number(f))?String(f):"--"}function wZ(u){return(Array.isArray(u?.jobs)?u.jobs:[]).slice(0,40)}function WZ(u){return(Array.isArray(u?.drafts)?u.drafts:[]).slice(0,12)}function FN({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((Q)=>Q.id==="findjob")||null,[n,i]=JZ({loading:!1,error:"",health:null,summary:null,jobs:null,drafts:null,refreshedAt:null});async function t(){if(!r)return;i((Q)=>({...Q,loading:!0,error:""}));try{let[Q,W,L,U]=await Promise.all([Eu(`${f}/microservices/findjob/health`),Eu(`${f}/microservices/findjob/proxy/api/summary`),Eu(`${f}/microservices/findjob/proxy/api/jobs?__unideskArrayLimit=jobs:40`),Eu(`${f}/microservices/findjob/proxy/api/drafts`)]);i({loading:!1,error:"",health:Q,summary:W,jobs:L,drafts:U,refreshedAt:new Date})}catch(Q){i((W)=>({...W,loading:!1,error:Ou(Q,"FindJob 加载失败")}))}}if(UZ(()=>{t()},[r?.id,r?.runtime?.providerStatus]),!r)return Uu(L2,{title:"FindJob 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=findjob"});let y=QZ(r),c=qZ(r),$=NZ(r),A=n.summary||{},j=wZ(n.jobs),F=WZ(n.drafts),J=n.jobs?._unidesk?.arrayLimits?.jobs;return Uu("div",{className:"findjob-page","data-testid":"findjob-page"},Uu(y3,{title:"FindJob 工作台",eyebrow:"D601 用户服务",loading:n.loading,actions:Uu("div",{className:"panel-actions"},Uu("button",{type:"button",className:"ghost-btn",onClick:t,disabled:n.loading,"data-testid":"findjob-refresh-button"},n.loading?"刷新中":"刷新"),Uu(c3,{title:"FindJob 用户服务",data:r,onOpen:l,testId:"raw-findjob-service"}))},Uu("div",{className:"findjob-hero"},Uu("div",null,Uu("div",{className:"node-version-line"},Uu(t3,{status:y.providerStatus==="online"?"online":"warn"},y.providerStatus||"unknown"),Uu("span",null,r.providerId),Uu("span",null,$.public?"公网暴露":"仅 UniDesk frontend 代理访问")),Uu("p",{className:"muted paragraph"},r.description)),Uu("div",{className:"microservice-ref-card"},Uu("span",null,"Repo"),Uu("strong",null,c.url||"--"),Uu("code",null,c.commitId||"--")),Uu("div",{className:"microservice-ref-card"},Uu("span",null,"D601 Docker"),Uu("strong",null,`${$.nodeBindHost||"--"}:${$.nodePort||"--"}`),Uu("code",null,`${c.composeFile||"--"} / ${c.composeService||"--"}`))),Uu(nl,{error:n.error,wide:!0})),Uu("div",{className:"findjob-grid"},Uu(y3,{title:"岗位指标",eyebrow:n.refreshedAt?`Updated ${yl(n.refreshedAt)}`:"Summary",loading:n.loading},Uu("div",{className:"metric-grid"},Uu(p0,{label:"岗位总量",value:Yi(A,"totalJobs"),hint:"tracked jobs",tone:"ok"}),Uu(p0,{label:"原始岗位",value:Yi(A,"rawJobs"),hint:"raw queue"}),Uu(p0,{label:"已验证",value:Yi(A,"verifiedJobs"),hint:"verified set"}),Uu(p0,{label:"优先处理",value:Yi(A,"prioritizedJobs"),hint:"prioritized"}),Uu(p0,{label:"过期",value:Yi(A,"staleJobs"),hint:"stale jobs",tone:"warn"}),Uu(p0,{label:"无效",value:Yi(A,"invalidJobs"),hint:"invalid jobs",tone:"warn"}),Uu(p0,{label:"上海",value:Yi(A,"shanghaiJobs"),hint:"city filter"}),Uu(p0,{label:"Health",value:n.health?.ok?"OK":"--",hint:"D601 /api/health"})),Uu("div",{className:"panel-actions inline-actions"},Uu(c3,{title:"FindJob Summary",data:A,onOpen:l,testId:"raw-findjob-summary"}))),Uu(y3,{title:"近期岗位",eyebrow:J?`${J.returnedLength}/${J.originalLength} Preview`:`${j.length} Preview`,loading:n.loading},j.length===0?Uu(L2,{title:"暂无岗位预览",text:"等待 D601 findjob backend 返回 /api/jobs"}):Uu("div",{className:"table-wrap findjob-job-table"},Uu("table",null,Uu("thead",null,Uu("tr",null,Uu("th",null,"优先级"),Uu("th",null,"状态"),Uu("th",null,"单位"),Uu("th",null,"职位"),Uu("th",null,"城市"),Uu("th",null,"阶段"),Uu("th",null,"截止"),Uu("th",null,"证据"))),Uu("tbody",null,j.map((Q)=>Uu("tr",{key:Q.id},Uu("td",null,Uu(t3,{status:String(Q.priority||"").toLowerCase()||"unknown"},Q.priority||"--")),Uu("td",null,Uu(t3,{status:String(Q.status||"").toLowerCase()||"unknown"},Q.status||"--")),Uu("td",null,Q.organization_name||"--",Uu("code",null,Q.id||"--")),Uu("td",null,Q.display_title||Q.title||"--"),Uu("td",null,Q.display_city||Q.city||"--"),Uu("td",null,Q.workflow_stage||"--"),Uu("td",null,Q.deadline||"--"),Uu("td",null,Q.evidence_url?Uu("a",{href:Q.evidence_url,target:"_blank",rel:"noreferrer"},"打开"):Uu("span",{className:"muted"},"无"))))))),Uu("div",{className:"panel-actions inline-actions"},Uu(c3,{title:"FindJob Jobs Preview",data:n.jobs,onOpen:l,testId:"raw-findjob-jobs"}))),Uu(y3,{title:"草稿与报告",eyebrow:`${F.length} Drafts`,loading:n.loading},F.length===0?Uu(L2,{title:"暂无草稿",text:"D601 findjob backend 未返回 drafts"}):Uu("div",{className:"draft-list"},F.map((Q)=>Uu("article",{key:Q.id,className:"draft-card"},Uu("div",{className:"node-card-head"},Uu("strong",null,Q.id),Uu(t3,{status:Q.status},Q.status||"--")),Uu("div",{className:"docker-meta compact"},Uu("span",null,Q.workflow_stage||"--"),Uu("span",null,`jobs ${Q.counts?.jobs??0}`),Uu("span",null,`reports ${Q.counts?.reports??0}`)),Uu("span",null,Q.latestReportPath||"暂无报告"),Uu("code",null,wu(Q.updated_at||Q.updatedAt))))),Uu("div",{className:"panel-actions inline-actions"},Uu(c3,{title:"FindJob Drafts",data:n.drafts,onOpen:l,testId:"raw-findjob-drafts"})))))}var ic=Cu(Jl(),1);var R=ic.default.createElement,{useEffect:LZ}=ic.default,T2=ic.default.useState;function fc(u){let l=Number(u);return Number.isFinite(l)?`${Math.max(0,Math.min(100,l)).toFixed(1)}%`:"--"}function G2(u){if(u===null||u===void 0||u==="")return"--";let l=Number(u);if(!Number.isFinite(l))return"--";if(l<60)return`${Math.max(0,Math.round(l))}s`;if(l<3600)return`${Math.floor(l/60)}m ${Math.round(l%60)}s`;return`${Math.floor(l/3600)}h ${Math.floor(l%3600/60)}m`}function z2(u,l=2){let f=Number(u);if(!Number.isFinite(f))return u===!1?"false":u===!0?"true":"--";let r=Math.abs(f);if(Number.isInteger(f)||r>=1000)return f.toLocaleString("zh-CN",{maximumFractionDigits:0});if(r>=1)return f.toLocaleString("zh-CN",{maximumFractionDigits:l});return f.toLocaleString("zh-CN",{maximumFractionDigits:Math.max(l,6)})}function nc(u){if(u===null||u===void 0||u==="")return"--";if(typeof u==="boolean")return u?"true":"false";if(typeof u==="number")return z2(u,4);if(Array.isArray(u))return u.map((l)=>nc(l)).join(" x ");if(typeof u==="object")return"已上报";return String(u)}function $3(u){let l=Number(u);if(!Number.isFinite(l)||l<=0)return"--";let f=l>=100?0:l>=10?1:2;return`${l.toLocaleString("zh-CN",{maximumFractionDigits:f})} epoch/h`}function A3(u){return u.replace(/[^a-zA-Z0-9_-]/g,"-")}function af(u){return u&&typeof u==="object"&&!Array.isArray(u)?u:{}}function rc({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return R("span",{className:`status-badge ${f}`},l||u||"unknown")}function S0({label:u,value:l,hint:f,tone:r}){return R("article",{className:`metric-card ${r||""}`},R("div",{className:"metric-label"},u),R("div",{className:"metric-value"},l),R("div",{className:"metric-hint"},f))}function K2({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return R("section",{className:`panel ${n||""}`},R("div",{className:"panel-head"},R("div",null,l?R("p",{className:"panel-eyebrow"},l):null,R(rl,{title:u,loading:i})),f?R("div",{className:"panel-actions"},f):null),R("div",{className:"panel-body"},r))}function ly({title:u,data:l,onOpen:f,testId:r}){return R("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:(n)=>{n?.stopPropagation?.(),f(u,l)}},"查看原始JSON")}function bn({title:u,text:l}){return R("div",{className:"empty-state"},R("strong",null,u),R("span",null,l))}function TZ(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function KZ(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function GZ(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function zZ(u){return u?.counts&&typeof u.counts==="object"&&!Array.isArray(u.counts)?u.counts:{}}function EZ(u){return Array.isArray(u?.jobs)?u.jobs.slice(0,240):[]}function OZ(u){return Array.isArray(u?.projects)?u.projects.slice(0,1000):[]}function j3(u){return Array.isArray(u?.projects)?u.projects:[]}function ZZ(u,l){if(Array.isArray(l?.gpu))return l.gpu;if(Array.isArray(u?.gpu))return u.gpu;return[]}function Ur(u,l){return`${u}/microservices/met-nonlinear/proxy${l}`}function UN(u){return u.startedAt&&u.finishedAt?G2((Date.parse(u.finishedAt)-Date.parse(u.startedAt))/1000):"--"}function HZ(u){let l=u.progress||{};if(l.etaSeconds!==null&&l.etaSeconds!==void 0&&l.etaSeconds!==""){let t=Number(l.etaSeconds);if(Number.isFinite(t))return Math.max(0,t)}let f=Number(l.currentEpoch),r=Number(l.epochTarget??u.epochTarget),n=Date.parse(u.startedAt||"");if(!Number.isFinite(f)||f<=0||!Number.isFinite(r)||r<=f||!Number.isFinite(n))return null;let i=Math.max(0,(Date.now()-n)/1000);if(i<=0)return null;return Math.max(0,i/f*(r-f))}function JN(u){let l=u.progress||{},f=Number(l.epochPerHour);if(Number.isFinite(f)&&f>0)return f;let r=Date.parse(u.startedAt||""),n=["succeeded","failed","canceled"].includes(u.status)?Date.parse(u.finishedAt||""):Date.now();if(!Number.isFinite(r)||!Number.isFinite(n)||n<=r)return null;let i=Number(l.currentEpoch??u.epochTarget);if(!Number.isFinite(i)||i<=0)return null;return i/((n-r)/3600000)}function QN(u){if(u==="staged")return"待启动";if(u==="queued")return"排队中";if(u==="running")return"训练中";if(u==="succeeded")return"已完成";if(u==="failed")return"失败";if(u==="canceled")return"已取消";return u||"unknown"}function NN(u,l,f){return{name:u,path:l,depth:f,count:0,children:[],project:null}}function BZ(u){let l=NN("","",-1);for(let r of u){let i=String(r?.projectPath||"").replace(/\\/g,"/").split("/").filter(Boolean);if(i.length===0)continue;let t=l,y=[];for(let[c,$]of i.entries()){y.push($);let A=y.join("/"),j=t.children.find((F)=>F.path===A);if(!j)j=NN($,A,c),t.children.push(j);if(c===i.length-1)j.project=r;t=j}}let f=(r)=>{let n=r.children.reduce((i,t)=>i+f(t),0);return r.count=(r.project?1:0)+n,r.children.sort((i,t)=>{if(Boolean(i.project)!==Boolean(t.project))return i.project?1:-1;return i.name.localeCompare(t.name,"zh-CN",{numeric:!0,sensitivity:"base"})}),r.count};return f(l),l}function VZ(u){let l=af(u.data);return af(l.project).projectPath?af(l.project):l}function mZ(u){return af(af(u.data).job)}function qN({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((C)=>C.id==="met-nonlinear")||null,[n,i]=T2({loading:!1,actionBusy:!1,error:"",health:null,summary:null,queue:null,projects:null,history:null,images:null,refreshedAt:null}),[t,y]=T2({loading:!1,error:"",kind:"",key:"",title:"",data:null}),[c,$]=T2(()=>({activeTab:"projects",selectedProjects:{},expandedProjectDirs:{},sourceProject:"",forkCount:1,forkEpochs:200,forkPrefix:`ui_fork_${Date.now()}`,maxConcurrency:3,targetGpuName:"2080 Ti",actionMessage:""}));function A(C){$((e)=>({...e,...C}))}async function j(C=c.activeTab){if(!r)return;i((e)=>({...e,loading:!0,error:""}));try{let e=[["health",Eu(`${f}/microservices/met-nonlinear/health`)],["summary",Eu(Ur(f,"/api/summary"))]];if(C==="projects")e.push(["projectsRoot",Eu(Ur(f,"/api/projects?root=projects&limit=500"))]),e.push(["exProjectsRoot",Eu(Ur(f,"/api/projects?root=ex_projects&limit=500"))]);if(C==="current"||C==="completed"||C==="failed")e.push(["queue",Eu(Ur(f,"/api/queue"))]);if(C==="completed"||C==="failed")e.push(["history",Eu(Ur(f,"/api/history"))]);if(C==="gpu")e.push(["images",Eu(Ur(f,"/api/images"))]);let uu=Object.fromEntries(await Promise.all(e.map(async([a,qu])=>[a,await qu]))),Gu={loading:!1,actionBusy:!1,error:"",health:uu.health,summary:uu.summary,refreshedAt:new Date};if(uu.projectsRoot||uu.exProjectsRoot){let{projectsRoot:a,exProjectsRoot:qu}=uu;Gu.projects={ok:a?.ok!==!1&&qu?.ok!==!1,roots:[{root:"projects",count:j3(a).length},{root:"ex_projects",count:j3(qu).length}],projects:[...j3(a),...j3(qu)]}}if(uu.queue)Gu.queue=uu.queue;if(uu.history)Gu.history=uu.history;if(uu.images)Gu.images=uu.images;i((a)=>({...a,...Gu}))}catch(e){i((uu)=>({...uu,loading:!1,actionBusy:!1,error:Ou(e,"MET Nonlinear 加载失败")}))}}async function F(C,e){i((uu)=>({...uu,actionBusy:!0,error:""})),A({actionMessage:`${C}...`});try{let uu=await e();A({actionMessage:uu||`${C}完成`}),await j()}catch(uu){i((Gu)=>({...Gu,actionBusy:!1,error:Ou(uu,`${C}失败`)}))}}async function J(){await F("保存并发设置",async()=>{await Eu(Ur(f,"/api/queue/settings"),{method:"PUT",body:JSON.stringify({maxConcurrency:Number(c.maxConcurrency),targetGpuName:c.targetGpuName})})})}function Q(){return Object.entries(c.selectedProjects).filter(([,C])=>C).map(([C])=>C)}async function W(){let C=Q();if(C.length===0)throw Error("请先选择至少一个 project");await F("加入待启动队列",async()=>{await Eu(Ur(f,"/api/queue"),{method:"POST",body:JSON.stringify({projectPaths:C,maxConcurrency:Number(c.maxConcurrency),targetGpuName:c.targetGpuName,start:!1})}),A({activeTab:"current",selectedProjects:{}})})}async function L(){let C=c.sourceProject||X[0]?.projectPath;if(!C)throw Error("请先选择源 project");await F("Fork Project",async()=>{let e=await Eu(Ur(f,"/api/projects/fork"),{method:"POST",body:JSON.stringify({sourceProject:C,count:Number(c.forkCount),epochs:Number(c.forkEpochs),prefix:c.forkPrefix})}),uu=Array.isArray(e.projectPaths)?e.projectPaths:[],Gu=uu.reduce((a,qu)=>{return a[qu]=!0,a},{...c.selectedProjects});return A({selectedProjects:Gu}),`已 fork ${uu.length} 个 project,并已自动勾选;请确认后点击加入待启动队列。`})}async function U(){await F("启动队列",async()=>{await Eu(Ur(f,"/api/queue/start"),{method:"POST",body:JSON.stringify({maxConcurrency:Number(c.maxConcurrency),targetGpuName:c.targetGpuName})}),A({activeTab:"current"})})}async function q(C){await F("取消任务",async()=>{await Eu(Ur(f,`/api/jobs/${encodeURIComponent(C.id)}/cancel`),{method:"POST",body:JSON.stringify({})})})}async function N(C){let e=String(C?.projectPath||"");if(!e)return;y({loading:!0,error:"",kind:"project",key:e,title:e,data:null});try{let uu=await Eu(Ur(f,`/api/projects/config?path=${encodeURIComponent(e)}`));y({loading:!1,error:"",kind:"project",key:e,title:e,data:uu})}catch(uu){y({loading:!1,error:Ou(uu,"Project 详情加载失败"),kind:"project",key:e,title:e,data:null})}}async function w(C){let e=String(C?.id||"");if(!e)return;y({loading:!0,error:"",kind:"job",key:e,title:C.projectPath||e,data:null});try{let uu=await Eu(Ur(f,`/api/jobs/${encodeURIComponent(e)}`));y({loading:!1,error:"",kind:"job",key:e,title:uu?.job?.projectPath||C.projectPath||e,data:uu})}catch(uu){y({loading:!1,error:Ou(uu,"Job 详情加载失败"),kind:"job",key:e,title:C.projectPath||e,data:null})}}if(LZ(()=>{j(c.activeTab)},[r?.id,r?.runtime?.providerStatus,c.activeTab]),!r)return R(bn,{title:"MET Nonlinear 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=met-nonlinear"});let G=TZ(r),Z=GZ(r),H=KZ(r),E=zZ(n.queue?.queue||n.summary?.queue),m=ZZ(n.health,n.queue),S=n.health?.targetGpu||n.summary?.targetGpu||m.find((C)=>String(C.name||"").includes("2080")),B=n.images?.mlImage||n.health?.image||{},D=EZ(n.queue),X=OZ(n.projects),O=BZ(X),Y=c.sourceProject||X[0]?.projectPath||"",p=D.filter((C)=>["staged","queued","running"].includes(C.status)),v=D.filter((C)=>C.status==="succeeded"),z=D.filter((C)=>["failed","canceled"].includes(C.status)),P=Array.isArray(n.history?.jobs)?n.history.jobs.slice(0,120):[],k=[{id:"projects",label:"项目库",count:X.length},{id:"current",label:"当前队列",count:p.length||Number(E.staged||0)+Number(E.queued||0)+Number(E.running||0)},{id:"completed",label:"已完成",count:v.length||Number(E.succeeded||0)},{id:"failed",label:"失败诊断",count:z.length||Number(E.failed||0)+Number(E.canceled||0)},{id:"gpu",label:"GPU/镜像",count:m.length}];function I(C,e){if(C.length===0)return R(bn,{title:e==="current"?"当前队列为空":"暂无记录",text:e==="current"?"从项目库选择或 fork project 后先加入待启动队列,再启动队列。":"终态任务会显示耗时、exit code 和失败诊断。"});return R("div",{className:"table-wrap met-job-table"},R("table",null,R("thead",null,R("tr",null,R("th",null,"状态"),R("th",null,"Project"),R("th",null,"Epoch"),R("th",null,"速度"),R("th",null,"ETA/耗时"),R("th",null,"GPU"),R("th",null,"Exit"),R("th",null,"更新时间"),R("th",null,"操作"))),R("tbody",null,C.map((uu)=>{let Gu=uu.progress||{},a=["staged","queued","running"].includes(uu.status),qu=t.kind==="job"&&t.key===uu.id;return R("tr",{key:uu.id,className:`met-click-row ${qu?"active":""}`,onClick:()=>w(uu),"data-testid":`met-job-row-${A3(uu.id)}`},R("td",null,R(rc,{status:uu.status},QN(uu.status))),R("td",null,R("button",{type:"button",className:"met-inline-link",onClick:(Zu)=>{Zu.stopPropagation(),w(uu)}},uu.projectPath),R("code",null,uu.id)),R("td",null,R("span",null,`${Gu.currentEpoch??"--"} / ${Gu.epochTarget??uu.epochTarget??"--"}`),R("div",{className:"met-progress"},R("span",{style:{width:fc(Gu.progressPercent)}}))),R("td",null,R("strong",null,$3(JN(uu)))),R("td",null,uu.status==="succeeded"||uu.status==="failed"||uu.status==="canceled"?UN(uu):uu.status==="running"?`ETA ${G2(HZ(uu))}`:"--"),R("td",null,uu.gpuName||"--"),R("td",null,uu.exitCode??"--"),R("td",null,wu(uu.updatedAt)),R("td",null,a?R("button",{type:"button",className:"ghost-btn mini",onClick:(Zu)=>{Zu.stopPropagation(),q(uu)},disabled:n.actionBusy},"取消"):null,R(ly,{title:`MET Job ${uu.id}`,data:uu,onOpen:l,testId:`raw-met-job-${uu.id}`})))}))))}function b(){return R("div",{className:"met-queue-summary","data-testid":"met-current-summary"},R(rc,{status:"staged"},`待启动 ${E.staged??0}`),R(rc,{status:"queued"},`排队中 ${E.queued??0}`),R(rc,{status:"running"},`训练中 ${E.running??0}`),R("span",null,`最大并发 ${n.summary?.queue?.maxConcurrency??n.queue?.queue?.maxConcurrency??c.maxConcurrency}`),R("span",null,`目标 GPU ${n.summary?.queue?.targetGpuName??n.queue?.queue?.targetGpuName??c.targetGpuName}`))}function d(C,e){let uu=c.expandedProjectDirs[C];return uu===void 0?e<2:Boolean(uu)}function s(C,e){let uu=d(C,e);A({expandedProjectDirs:{...c.expandedProjectDirs,[C]:!uu}})}function h(C){let e=8+Math.max(0,C.depth)*16;if(Boolean(C.project)){let a=C.project,qu=Boolean(c.selectedProjects[a.projectPath]),Zu=t.kind==="project"&&t.key===a.projectPath;return R("div",{key:C.path,className:`met-tree-row project ${qu?"selected":""} ${Zu?"active":""}`,style:{paddingLeft:e},onClick:()=>N(a),"data-testid":`met-project-node-${A3(a.projectPath)}`},R("div",{className:"met-tree-name"},R("input",{type:"checkbox",checked:qu,onClick:(Bu)=>Bu.stopPropagation(),onChange:(Bu)=>A({selectedProjects:{...c.selectedProjects,[a.projectPath]:Bu.target.checked}}),"data-testid":`met-project-checkbox-${A3(a.projectPath)}`}),R("button",{type:"button",className:"met-inline-link project-path",onClick:(Bu)=>{Bu.stopPropagation(),N(a)}},C.name)),R("span",null,a.useModel||"--"),R("span",null,a.epochTrain??"--"),R("span",null,fc(a.progress?.progressPercent)),R("span",null,$3(a.progress?.epochPerHour)))}let Gu=d(C.path,C.depth);return R(ic.default.Fragment,{key:C.path},R("div",{className:"met-tree-row folder",style:{paddingLeft:e},"data-testid":`met-project-folder-${A3(C.path)}`},R("button",{type:"button",className:"met-tree-toggle",onClick:()=>s(C.path,C.depth),"aria-label":Gu?`折叠 ${C.path}`:`展开 ${C.path}`},Gu?"-":"+"),R("strong",null,C.name),R("span",{className:"met-tree-count"},`${C.count} projects`)),Gu?C.children.map((a)=>h(a)):null)}function lu(C){return R("div",{className:"met-detail-kv"},C.map((e)=>R("div",{key:e.label,className:"met-detail-kv-item"},R("span",null,e.label),R("strong",null,nc(e.value)),e.hint?R("small",null,e.hint):null)))}function cu(C,e){return R("div",{className:"met-detail-section"},R("h3",null,C),lu(e))}function _u(C){if(!Array.isArray(C)||C.length===0)return R(bn,{title:"模型层未上报",text:"等待 data/model_info.json 或 compute_analysis.json 生成。"});return R("div",{className:"table-wrap met-layer-table"},R("table",null,R("thead",null,R("tr",null,R("th",null,"Layer"),R("th",null,"Type"),R("th",null,"Params"),R("th",null,"Trainable"),R("th",null,"Compute"))),R("tbody",null,C.slice(0,18).map((e,uu)=>R("tr",{key:`${e.name||"layer"}-${uu}`},R("td",null,e.name||`#${uu+1}`),R("td",null,e.type||"--"),R("td",null,z2(e.num_params)),R("td",null,e.trainable===void 0?"--":String(Boolean(e.trainable))),R("td",null,z2(e.compute?.total??e.estimated_cost?.weighted_units?.total)))))))}function Fu(C){let e=Array.isArray(C)?C:[];if(e.length===0)return R(bn,{title:"data/ 暂无文件",text:"训练或评估完成后会生成 training_state、metrics、model_info 等文件。"});return R("div",{className:"met-file-chip-grid"},e.slice(0,48).map((uu)=>R("span",{key:uu},uu)),e.length>48?R("span",null,`+${e.length-48}`):null)}function zu(C){let e=String(C||"").replace(/\x1b\[[0-9;]*[A-Za-z]/g,"").split(/\r?\n/).map((uu)=>uu.trim()).filter(Boolean).slice(-12);if(e.length===0)return R(bn,{title:"暂无日志尾部",text:"该任务未上报 logTail 或日志已轮转。"});return R("div",{className:"met-log-lines"},e.map((uu,Gu)=>R("div",{key:`${Gu}-${uu.slice(0,16)}`},uu)))}function Wu(){if(t.loading)return R("section",{className:"met-detail-panel","data-testid":"met-detail-panel"},R("div",{className:"panel-head compact"},R("div",null,R("p",{className:"panel-eyebrow"},"Detail Loading"),R(rl,{title:"详情加载中",loading:!0}))),R(bn,{title:"详情加载中",text:t.title||"正在读取 D601 data/ 和 config.json"}));if(t.error)return R("section",{className:"met-detail-panel","data-testid":"met-detail-panel"},R(nl,{error:t.error,wide:!0}));if(!t.data)return R("section",{className:"met-detail-panel muted","data-testid":"met-detail-panel"},R(bn,{title:"选择一个项目或任务查看详情",text:"项目库、当前队列、已完成和失败诊断中的行都可以点击;默认只展示结构化字段,原始 JSON 需显式点击按钮。"}));let C=VZ(t),e=mZ(t),uu=af(C.config),Gu=af(C.progress||e.progress),a=af(C.data),qu=af(C.metrics||a.metrics||Gu.trainingInfo?.evaluation_metrics),Zu=af(a.trainingInfo||Gu.trainingInfo),Bu=af(a.trainingState),gu=af(C.model||a.model),ll=Array.isArray(gu.modelSummary)&&gu.modelSummary.length>0?gu.modelSummary:gu.computeLayers,Pu=af(Zu.evaluation_metrics),Nl=t.kind==="job"?"训练任务详情":"Project 详情";return R("section",{className:"met-detail-panel","data-testid":"met-detail-panel"},R("div",{className:"panel-head compact"},R("div",null,R("p",{className:"panel-eyebrow"},t.kind==="job"?"Job + Project Detail":"Project Library Detail"),R(rl,{title:Nl}),R("code",null,C.projectPath||e.projectPath||t.title)),R("div",{className:"panel-actions"},R(ly,{title:`MET ${Nl}`,data:t.data,onOpen:l,testId:"raw-met-detail"}))),t.kind==="job"?cu("任务状态",[{label:"Job ID",value:e.id},{label:"状态",value:QN(e.status)},{label:"GPU",value:e.gpuName},{label:"Exit Code",value:e.exitCode},{label:"耗时",value:UN(e)},{label:"训练速度",value:$3(JN({...e,progress:Gu}))}]):null,cu("config.json",[{label:"use_model",value:uu.use_model},{label:"epoch_train",value:uu.epoch_train},{label:"step_per_epoch",value:uu.step_per_epoch},{label:"learning_rate",value:uu.learning_rate},{label:"using_gpu",value:uu.using_gpu},{label:"use_points",value:uu.use_points},{label:"sample_rate",value:uu.sample_rate},{label:"time_clipped_s",value:uu.time_clipped_s},{label:"H_UNITS",value:uu.H_UNITS},{label:"INNER_KAN_UNITS",value:uu.INNER_KAN_UNITS},{label:"INNER_KAN_LAYERS",value:uu.INNER_KAN_LAYERS},{label:"GRID_SIZE",value:uu.GRID_SIZE},{label:"SPLINE_ORDER",value:uu.SPLINE_ORDER},{label:"USE_FAST_MODEL",value:uu.USE_FAST_MODEL},{label:"IIR_TRAINABLE",value:uu.IIR_TRAINABLE}]),cu("data/ 训练状态",[{label:"Epoch",value:`${Gu.currentEpoch??Bu.current_epoch??Bu.completed_epoch??"--"} / ${Gu.epochTarget??uu.epoch_train??"--"}`},{label:"Progress",value:fc(Gu.progressPercent)},{label:"Last Loss",value:Gu.lastLoss??Bu.loss},{label:"Last Val Loss",value:Gu.lastValLoss??Bu.val_loss},{label:"Min Loss",value:Zu.min_loss??Bu.min_loss},{label:"Min Val Loss",value:Zu.min_val_loss??Bu.min_val_loss},{label:"Log Lines",value:Gu.logLineCount},{label:"ETA",value:G2(Gu.etaSeconds??Bu.remaining_time)},{label:"训练速度",value:$3(Gu.epochPerHour??Bu.smoothed_speed)},{label:"Training Alive",value:Bu.training_alive}]),cu("模型参数",[{label:"Model Type",value:gu.modelType??uu.use_model},{label:"Total Params",value:gu.totalParams,hint:gu.totalParams===null||gu.totalParams===void 0?"未上报":"data/model_info.json"},{label:"Trainable",value:gu.trainableParams},{label:"Non-trainable",value:gu.nonTrainableParams},{label:"Compute Cost",value:gu.computeCost},{label:"Estimate Status",value:gu.estimateStatus},{label:"Unsupported Layers",value:gu.unsupportedLayerCount}]),cu("指标",[{label:"train_loss",value:qu.train_loss??Pu.train_loss},{label:"val_loss",value:qu.val_loss??Pu.val_loss},{label:"train_mae",value:qu.train_mae??Pu.train_mae},{label:"val_mae",value:qu.val_mae??Pu.val_mae},{label:"train_afmae",value:qu.train_afmae??Pu.train_afmae},{label:"val_afmae",value:qu.val_afmae??Pu.val_afmae},{label:"freq_drift_hz",value:qu.freq_drift_hz},{label:"sens_drift_percent",value:qu.sens_drift_percent},{label:"linearity_percent",value:qu.linearity_percent},{label:"weights_source",value:qu.weights_source??Pu.weights_source},{label:"lr min/mean/max",value:`${nc(Zu.learning_rate_min)} / ${nc(Zu.learning_rate_mean)} / ${nc(Zu.learning_rate_max)}`}]),R("div",{className:"met-detail-section"},R("h3",null,"模型层"),_u(ll)),R("div",{className:"met-detail-section"},R("h3",null,"data/ 文件"),Fu(a.files)),t.kind==="job"?R("div",{className:"met-detail-section"},R("h3",null,"日志尾部"),zu(af(t.data).logTail)):null)}return R("div",{className:"met-page","data-testid":"met-nonlinear-page"},R(K2,{title:"MET Nonlinear 训练编排",eyebrow:"D601 GPU 用户服务",loading:n.loading||n.actionBusy,actions:R("div",{className:"panel-actions"},R("button",{type:"button",className:"ghost-btn",onClick:j,disabled:n.loading,"data-testid":"met-refresh-button"},n.loading?"刷新中":"刷新"),R(ly,{title:"MET Nonlinear 用户服务",data:r,onOpen:l,testId:"raw-met-service"}))},R("div",{className:"findjob-hero"},R("div",null,R("div",{className:"node-version-line"},R(rc,{status:G.providerStatus==="online"?"online":"warn"},G.providerStatus||"unknown"),R("span",null,r.providerId),R("span",null,H.public?"公网暴露":"仅 UniDesk frontend 代理访问")),R("p",{className:"muted paragraph"},r.description)),R("div",{className:"microservice-ref-card"},R("span",null,"Repo"),R("strong",null,Z.url||"--"),R("code",null,Z.commitId||"--")),R("div",{className:"microservice-ref-card"},R("span",null,"D601 Docker"),R("strong",null,`${H.nodeBindHost||"--"}:${H.nodePort||"--"}`),R("code",null,`${Z.composeFile||"--"} / ${Z.containerName||"--"}`))),R(nl,{error:n.error,wide:!0}),c.actionMessage?R("div",{className:"met-action-log","data-testid":"met-action-message"},c.actionMessage):null),R("div",{className:"met-grid"},R(K2,{title:"核心状态",eyebrow:n.refreshedAt?`Updated ${yl(n.refreshedAt)}`:"Queue + GPU",loading:n.loading},R("div",{className:"metric-grid"},R(S0,{label:"Staged",value:E.staged??0,hint:"加入队列未开始",tone:Number(E.staged||0)>0?"warn":""}),R(S0,{label:"Queued",value:E.queued??0,hint:"排队等待调度",tone:Number(E.queued||0)>0?"warn":""}),R(S0,{label:"Running",value:E.running??0,hint:`max ${n.summary?.queue?.maxConcurrency??n.queue?.queue?.maxConcurrency??"--"}`,tone:Number(E.running||0)>0?"ok":""}),R(S0,{label:"Succeeded",value:E.succeeded??0,hint:"已完成"}),R(S0,{label:"Failed",value:E.failed??0,hint:"需要诊断",tone:Number(E.failed||0)>0?"warn":""}),R(S0,{label:"2080Ti Free",value:S?fc(Number(S.freeRatio)*100):"--",hint:S?`${S.memoryFreeMiB}/${S.memoryTotalMiB} MiB`:"等待 GPU 上报"}),R(S0,{label:"ML Image",value:B.present?"READY":"MISSING",hint:B.image||"met-nonlinear-ml:tf26",tone:B.present?"ok":"warn"}),R(S0,{label:"Health",value:n.health?.ok?"OK":"--",hint:"D601 /health"}))),R(K2,{title:"队列控制",eyebrow:"Downloader-like staging",loading:n.actionBusy},R("div",{className:"met-control-strip"},R("label",null,"最大并发",R("input",{type:"number",min:1,max:16,value:c.maxConcurrency,"data-testid":"met-max-concurrency-input",onChange:(C)=>A({maxConcurrency:C.target.value})})),R("label",null,"目标 GPU",R("input",{value:c.targetGpuName,"data-testid":"met-target-gpu-input",onChange:(C)=>A({targetGpuName:C.target.value})})),R("button",{type:"button",className:"ghost-btn",onClick:J,disabled:n.actionBusy,"data-testid":"met-save-settings-button"},"保存设置"),R("button",{type:"button",className:"primary-btn",onClick:U,disabled:n.actionBusy||Number(E.staged||0)===0,"data-testid":"met-start-queue-button"},"启动队列")),R("p",{className:"muted paragraph"},"Project 先进入待启动队列,不会立即训练;点击启动队列后才切换为排队中,并由 D601 scheduler 按最大并发和 2080Ti 显存策略调度。")),R("section",{className:"panel met-workspace"},R("div",{className:"met-tabs",role:"tablist"},k.map((C)=>R("button",{key:C.id,type:"button",className:c.activeTab===C.id?"active":"",onClick:()=>A({activeTab:C.id}),"data-testid":`met-tab-${C.id}`},`${C.label} ${C.count}`))),R("div",{className:"panel-body"},c.activeTab==="projects"?R("div",{className:"met-form-grid","data-testid":"met-projects-pane"},R("div",{className:"met-fork-card"},R("h3",null,"Fork Project"),R("label",null,"源 Project",R("select",{value:Y,"data-testid":"met-source-project-select",onChange:(C)=>A({sourceProject:C.target.value})},X.map((C)=>R("option",{key:C.projectPath,value:C.projectPath},`${C.projectPath} · ${C.useModel||"model?"}`)))),R("label",null,"Fork 数量",R("input",{type:"number",min:1,max:100,value:c.forkCount,"data-testid":"met-fork-count-input",onChange:(C)=>A({forkCount:C.target.value})})),R("label",null,"训练轮数",R("input",{type:"number",min:1,max:1e5,value:c.forkEpochs,"data-testid":"met-fork-epochs-input",onChange:(C)=>A({forkEpochs:C.target.value})})),R("label",null,"目标前缀",R("input",{value:c.forkPrefix,"data-testid":"met-fork-prefix-input",onChange:(C)=>A({forkPrefix:C.target.value})})),R("button",{type:"button",className:"primary-btn",onClick:L,disabled:n.actionBusy||!Y,"data-testid":"met-fork-button"},"Fork Project"),R("p",{className:"muted paragraph"},"Fork 只创建新 Project 并自动勾选,不会直接训练;需要在右侧确认后加入待启动队列。")),R("div",{className:"met-project-list"},R("div",{className:"panel-head compact"},R("div",null,R("p",{className:"panel-eyebrow"},`Existing Projects · ${(n.projects?.roots||[]).map((C)=>`${C.root} ${C.count}`).join(" / ")}`),R(rl,{title:"选择已有 Project",loading:n.loading||n.actionBusy})),R("button",{type:"button",className:"ghost-btn",onClick:W,disabled:n.actionBusy||Q().length===0,"data-testid":"met-stage-selected-button"},`加入待启动队列 (${Q().length})`)),X.length===0?R(bn,{title:"暂无 project",text:"等待 D601 返回 /api/projects"}):R("div",{className:"met-project-table","data-testid":"met-project-tree"},R("div",{className:"met-tree-header"},R("span",null,"文件树 Project"),R("span",null,"Model"),R("span",null,"Epochs"),R("span",null,"Progress"),R("span",null,"速度")),O.children.map((C)=>h(C)))),Wu()):null,c.activeTab==="current"?R("div",{"data-testid":"met-current-pane"},b(),I(p,"current"),Wu(),R("div",{className:"panel-actions inline-actions"},R(ly,{title:"MET Queue",data:n.queue,onOpen:l,testId:"raw-met-queue"}))):null,c.activeTab==="completed"?R("div",{"data-testid":"met-completed-pane"},I(v.length>0?v:P.filter((C)=>C.status==="succeeded"),"completed"),Wu()):null,c.activeTab==="failed"?R("div",{"data-testid":"met-failed-pane"},I(z.length>0?z:P.filter((C)=>["failed","canceled"].includes(C.status)),"failed"),Wu(),R("div",{className:"panel-actions inline-actions"},R(ly,{title:"MET History",data:n.history,onOpen:l,testId:"raw-met-history"}))):null,c.activeTab==="gpu"?R("div",{className:"met-gpu-pane","data-testid":"met-gpu-pane"},m.length===0?R(bn,{title:"暂无 GPU 上报",text:"等待 D601 met-nonlinear-ts 或 ML image 提供 nvidia-smi 数据"}):R("div",{className:"table-wrap"},R("table",null,R("thead",null,R("tr",null,R("th",null,"Index"),R("th",null,"Name"),R("th",null,"Free"),R("th",null,"Policy"))),R("tbody",null,m.map((C)=>R("tr",{key:C.index},R("td",null,C.index),R("td",null,C.name),R("td",null,`${C.memoryFreeMiB} / ${C.memoryTotalMiB} MiB`,R("div",{className:"met-progress"},R("span",{style:{width:fc(Number(C.freeRatio)*100)}}))),R("td",null,String(C.name||"").includes("2080")?"target 2080Ti, <20% 限制并发":"non-target")))))),R("div",{className:"panel-actions inline-actions"},R(ly,{title:"MET Images",data:n.images,onOpen:l,testId:"raw-met-images"}))):null))))}var Q3=Cu(Jl(),1);var Qu=Q3.default.createElement,{useEffect:wN,useMemo:DZ}=Q3.default,F3=Q3.default.useState;function WN({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return Qu("span",{className:`status-badge ${f}`},l||u||"unknown")}function tc({label:u,value:l,hint:f,tone:r}){return Qu("article",{className:`metric-card ${r||""}`},Qu("div",{className:"metric-label"},u),Qu("div",{className:"metric-value"},l),Qu("div",{className:"metric-hint"},f))}function U3({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return Qu("section",{className:`panel ${n||""}`},Qu("div",{className:"panel-head"},Qu("div",null,l?Qu("p",{className:"panel-eyebrow"},l):null,Qu(rl,{title:u,loading:i})),f?Qu("div",{className:"panel-actions"},f):null),Qu("div",{className:"panel-body"},r))}function E2({title:u,data:l,onOpen:f,testId:r}){return Qu("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function J3({title:u,text:l}){return Qu("div",{className:"empty-state"},Qu("strong",null,u),Qu("span",null,l))}function pZ(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function SZ(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function XZ(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function fy(u,l){return`${u}/microservices/mdtodo/proxy${l}`}function LN(u){if(u==="completed")return"已完成";if(u==="in_progress")return"进行中";return"待处理"}function YZ(u){if(u==="completed")return"online";if(u==="in_progress")return"warn";return"unknown"}function O2(u){let l=[],f=(r)=>{for(let n of r)if(l.push(n),Array.isArray(n.children))f(n.children)};return f(Array.isArray(u)?u:[]),l}function PZ({tasks:u,selectedId:l,onSelect:f}){if(!u.length)return Qu(J3,{title:"暂无任务",text:"当前文件没有 R 编号任务。"});let r=(n)=>Qu("li",{key:n.id},Qu("button",{type:"button",className:`mdtodo-task-row ${l===n.id?"active":""}`,style:{"--task-depth":Math.min(Number(n.depth||0),6)},onClick:()=>f(n.id),"data-testid":`mdtodo-task-${String(n.id).replace(/[^A-Za-z0-9_-]+/g,"-")}`},Qu(WN,{status:YZ(n.status)},LN(n.status)),Qu("code",null,n.id),Qu("span",{className:"mdtodo-task-title"},n.title||"--"),Qu("span",{className:"mdtodo-link-count"},`${n.linkExists??0}/${n.linkCount??0}`)),Array.isArray(n.children)&&n.children.length>0?Qu("ol",null,n.children.map(r)):null);return Qu("ol",{className:"mdtodo-tree"},u.map(r))}function TN({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((S)=>S.id==="mdtodo")||null,[n,i]=F3({loading:!1,saving:!1,error:"",notice:"",health:null,files:[],todo:null,selectedFile:"",selectedTaskId:"",refreshedAt:null,command:null}),[t,y]=F3(""),[c,$]=F3(""),[A,j]=F3(""),F=Array.isArray(n.todo?.tasks)?n.todo.tasks:[],J=DZ(()=>O2(F),[n.todo]),Q=J.find((S)=>S.id===n.selectedTaskId)||J[0]||null,W=n.todo?.stats||{};async function L(S=n.selectedFile){if(!r)return;i((B)=>({...B,loading:!0,error:"",notice:""}));try{let[B,D]=await Promise.all([Eu(`${f}/microservices/mdtodo/health`),Eu(fy(f,"/api/files"))]),X=Array.isArray(D.files)?D.files:[],O=S||X[0]?.path||"",Y=O?await Eu(fy(f,`/api/tasks?file=${encodeURIComponent(O)}`)):null,p=Array.isArray(Y?.tasks)?O2(Y.tasks):[],v=p.some((z)=>z.id===n.selectedTaskId)?n.selectedTaskId:p[0]?.id||"";i({loading:!1,saving:!1,error:"",notice:"",health:B,files:X,todo:Y,selectedFile:O,selectedTaskId:v,refreshedAt:new Date,command:n.command})}catch(B){i((D)=>({...D,loading:!1,error:Ou(B,"MDTODO 加载失败")}))}}if(wN(()=>{L()},[r?.id,r?.runtime?.providerStatus]),wN(()=>{y(Q?.title||""),$(Q?.rawContent||"")},[Q?.id,n.selectedFile]),!r)return Qu(J3,{title:"MDTODO 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=mdtodo"});let U=pZ(r),q=XZ(r),N=SZ(r);async function w(S){i((B)=>({...B,selectedFile:S,selectedTaskId:"",command:null})),await L(S)}async function G(S){if(!Q||!n.selectedFile)return;i((B)=>({...B,saving:!0,error:"",notice:""}));try{let B=await Eu(fy(f,`/api/tasks/${encodeURIComponent(Q.id)}`),{method:"PATCH",body:{file:n.selectedFile,...S}});i((D)=>({...D,saving:!1,todo:B.file,notice:B.result?.message||"任务已更新"}))}catch(B){i((D)=>({...D,saving:!1,error:Ou(B,"任务更新失败")}))}}async function Z(){await G({title:t,rawContent:c})}async function H(S){if(!n.selectedFile)return;i((B)=>({...B,saving:!0,error:"",notice:""}));try{let B=await Eu(fy(f,"/api/tasks"),{method:"POST",body:{file:n.selectedFile,parentId:S,title:A||"新任务"}});j(""),i((D)=>({...D,saving:!1,todo:B.file,selectedTaskId:B.result?.taskId||D.selectedTaskId,notice:B.result?.message||"任务已创建"})),await L(n.selectedFile)}catch(B){i((D)=>({...D,saving:!1,error:Ou(B,"创建任务失败")}))}}async function E(){if(!Q||!n.selectedFile)return;if(!window.confirm(`删除 ${Q.id} 及其子任务?`))return;i((S)=>({...S,saving:!0,error:"",notice:""}));try{let S=await Eu(fy(f,`/api/tasks/${encodeURIComponent(Q.id)}?file=${encodeURIComponent(n.selectedFile)}`),{method:"DELETE"}),B=O2(S.file?.tasks||[]);i((D)=>({...D,saving:!1,todo:S.file,selectedTaskId:B[0]?.id||"",notice:S.result?.message||"任务已删除"}))}catch(S){i((B)=>({...B,saving:!1,error:Ou(S,"删除任务失败")}))}}async function m(){if(!Q||!n.selectedFile)return;i((S)=>({...S,saving:!0,error:"",command:null}));try{let S=await Eu(fy(f,"/api/execute-command"),{method:"POST",body:{file:n.selectedFile,taskId:Q.id,mode:"codex"}});i((B)=>({...B,saving:!1,command:S,notice:"执行命令已生成"}))}catch(S){i((B)=>({...B,saving:!1,error:Ou(S,"执行命令生成失败")}))}}return Qu("div",{className:"mdtodo-page","data-testid":"mdtodo-page"},Qu(U3,{title:"MDTODO 工作台",eyebrow:"D601 k3s managed service",loading:n.loading,actions:Qu("div",{className:"panel-actions"},Qu("button",{type:"button",className:"ghost-btn",onClick:()=>void L(),disabled:n.loading,"data-testid":"mdtodo-refresh-button"},n.loading?"刷新中":"刷新"),Qu(E2,{title:"MDTODO 用户服务",data:r,onOpen:l,testId:"raw-mdtodo-service"}))},Qu("div",{className:"findjob-hero"},Qu("div",null,Qu("div",{className:"node-version-line"},Qu(WN,{status:U.providerStatus==="online"?"online":"warn"},U.providerStatus||"unknown"),Qu("span",null,r.providerId),Qu("span",null,N.proxyMode||"--")),Qu("p",{className:"muted paragraph"},r.description)),Qu("div",{className:"microservice-ref-card"},Qu("span",null,"Repo"),Qu("strong",null,q.url||"--"),Qu("code",null,q.composeFile||"--")),Qu("div",{className:"microservice-ref-card"},Qu("span",null,"Workspace"),Qu("strong",null,n.health?.rootDir||"/workspace"),Qu("code",null,`${N.nodeBindHost||"--"}:${N.nodePort||"--"}`))),Qu(nl,{error:n.error,wide:!0}),n.notice?Qu("div",{className:"notice-line"},n.notice):null),Qu("div",{className:"metric-grid"},Qu(tc,{label:"TODO 文件",value:n.files.length,hint:n.health?.rootExists?"hostPath ready":"hostPath missing",tone:n.health?.ok?"ok":"warn"}),Qu(tc,{label:"任务总数",value:W.total??"--",hint:n.selectedFile||"--"}),Qu(tc,{label:"已完成",value:W.completed??"--",hint:"completed",tone:"ok"}),Qu(tc,{label:"进行中",value:W.inProgress??"--",hint:"in progress",tone:"warn"}),Qu(tc,{label:"待处理",value:W.pending??"--",hint:n.refreshedAt?yl(n.refreshedAt):"pending"})),Qu("div",{className:"mdtodo-layout"},Qu(U3,{title:"文件",eyebrow:`${n.files.length} Markdown`,loading:n.loading,className:"mdtodo-file-panel"},n.files.length===0?Qu(J3,{title:"暂无 TODO 文件",text:"等待后端扫描 MDTODO 工作区。"}):Qu("div",{className:"mdtodo-file-list"},n.files.map((S)=>Qu("button",{key:S.path,type:"button",className:`mdtodo-file-item ${n.selectedFile===S.path?"active":""}`,onClick:()=>void w(S.path)},Qu("strong",null,S.name),Qu("span",null,S.directory||"."),Qu("code",null,`${S.stats?.total??"--"} tasks / ${wu(S.mtime)}`))))),Qu(U3,{title:"任务树",eyebrow:n.selectedFile||"Tasks",loading:n.loading,actions:Qu("div",{className:"panel-actions"},Qu("input",{value:A,onChange:(S)=>j(S.target.value),placeholder:"新任务标题","data-testid":"mdtodo-new-title"}),Qu("button",{type:"button",className:"ghost-btn",onClick:()=>void H(),disabled:n.saving||!n.selectedFile},"新增"),Q?Qu("button",{type:"button",className:"ghost-btn",onClick:()=>void H(Q.id),disabled:n.saving},"新增子任务"):null,n.todo?Qu(E2,{title:"MDTODO 当前文件",data:n.todo,onOpen:l,testId:"raw-mdtodo-file"}):null)},Qu(PZ,{tasks:F,selectedId:Q?.id||"",onSelect:(S)=>i((B)=>({...B,selectedTaskId:S,command:null}))})),Qu(U3,{title:Q?`${Q.id} 详情`:"任务详情",eyebrow:Q?LN(Q.status):"Detail",loading:n.saving,className:"mdtodo-detail-panel",actions:Q?Qu("div",{className:"panel-actions"},Qu("button",{type:"button",className:"ghost-btn",onClick:()=>void G({status:"pending"}),disabled:n.saving},"待处理"),Qu("button",{type:"button",className:"ghost-btn",onClick:()=>void G({status:"in_progress"}),disabled:n.saving},"进行中"),Qu("button",{type:"button",className:"primary-btn",onClick:()=>void G({status:"completed"}),disabled:n.saving},"完成")):null},!Q?Qu(J3,{title:"未选中任务",text:"请选择一个任务。"}):Qu("div",{className:"mdtodo-editor"},Qu("label",null,"标题",Qu("input",{value:t,onChange:(S)=>y(S.target.value),"data-testid":"mdtodo-title-input"})),Qu("label",null,"正文",Qu("textarea",{value:c,onChange:(S)=>$(S.target.value),rows:12,"data-testid":"mdtodo-raw-input"})),Qu("div",{className:"docker-meta compact"},Qu("span",null,`line ${Number(Q.lineNumber??0)+1}`),Qu("span",null,`depth ${Q.depth??0}`),Qu("span",null,`links ${Q.linkExists??0}/${Q.linkCount??0}`)),Qu("div",{className:"inline-actions"},Qu("button",{type:"button",className:"primary-btn",onClick:Z,disabled:n.saving},n.saving?"保存中":"保存"),Qu("button",{type:"button",className:"ghost-btn",onClick:m,disabled:n.saving},"生成执行命令"),Qu("button",{type:"button",className:"danger-btn",onClick:E,disabled:n.saving},"删除"),Qu(E2,{title:`MDTODO ${Q.id}`,data:Q,onOpen:l,testId:"raw-mdtodo-task"})),n.command?Qu("div",{className:"mdtodo-command"},Qu("span",null,n.command.prompt||"--"),Qu("code",null,n.command.command||"--")):null))))}var q3=[{id:"ops",label:"运行总览",code:"OPS",tabs:[{id:"status",label:"态势总览"},{id:"performance",label:"性能面板"},{id:"events",label:"事件摘要"},{id:"logs",label:"服务日志"}]},{id:"nodes",label:"资源节点",code:"NODE",tabs:[{id:"list",label:"节点清单"},{id:"monitor",label:"资源监控"},{id:"docker",label:"Docker 状态"},{id:"gateway",label:"网关版本"},{id:"labels",label:"资源标签"},{id:"heartbeats",label:"心跳状态"}]},{id:"tasks",label:"任务调度",code:"TASK",tabs:[{id:"dispatch",label:"下发任务"},{id:"scheduled",label:"定时任务"},{id:"pending",label:"待处理任务"},{id:"history",label:"任务历史"},{id:"results",label:"执行结果"}]},{id:"apps",label:"用户服务",code:"APP",routeSegment:"app",tabs:[{id:"catalog",label:"服务目录"},{id:"todo-note",label:"Todo Note"},{id:"findjob",label:"FindJob"},{id:"pipeline",label:"Pipeline"},{id:"met-nonlinear",label:"MET Nonlinear"},{id:"claudeqq",label:"ClaudeQQ"},{id:"baidu-netdisk",label:"Baidu Netdisk"},{id:"filebrowser",label:"File Browser"},{id:"oa-event-flow",label:"OA Event Flow"},{id:"k3sctl",label:"k3s Control"},{id:"code-queue",label:"Code Queue"},{id:"mdtodo",label:"MDTODO"},{id:"project-manager",label:"Project Manager"}]},{id:"config",label:"系统配置",code:"CFG",tabs:[{id:"topology",label:"连接拓扑"},{id:"auth",label:"认证策略"},{id:"security",label:"安全边界"}]}],yc=Object.fromEntries(q3.map((u)=>[u.id,u.tabs[0]?.id??""]));function CZ(u){let l=String(u||"").trim();if(!l)return"";try{return decodeURIComponent(l)}catch{return l}}function N3(u){let l=String(u||"/"),[f]=l.split(/[?#]/u,1);if(f==="/")return"/";let n=`/${f.split("/").map(CZ).filter(Boolean).join("/")}`;return n.endsWith("/")?n:`${n}/`}function MZ(u){let l=2166136261;for(let f of u)l^=f.charCodeAt(0),l=Math.imul(l,16777619);return Math.abs(l>>>0).toString(36)}function Z2(u){return String(u||"").normalize("NFKD").replace(/[\u0300-\u036f]/gu,"").toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"")}function KN(u){return String(u||"").trim().toLowerCase().replace(/[\s/\\?#%]+/gu,"-").replace(/-+/gu,"-").replace(/^-+|-+$/gu,"")}function GN(u){let l=Z2(u.routeSegment||"")||KN(u.routeSegment||"");if(l)return l;let f=Z2(u.id||"");if(f)return f;let r=Z2(u.label||"")||KN(u.label||"");if(r)return r;return`route-${MZ(JSON.stringify(u))}`}function H2(u,l){return`${u}:${l}`}function zN(u){let l=u.map((c)=>{let $=GN(c);return{...c,routeSegment:$,tabs:c.tabs.map((A)=>({...A,routeSegment:GN(A)}))}}),f={},r={},n={},i=l.map((c)=>{let $=c.tabs[0]?.id??"";n[c.id]=$;let A=c.tabs.map((J)=>{let Q=`/${c.routeSegment}/${J.routeSegment}/`,W=[Q],L={moduleId:c.id,tabId:J.id};for(let U of W)f[N3(U)]=L;return r[H2(c.id,J.id)]=Q,{...J,canonicalPath:Q,aliases:W}}),j=`/${c.routeSegment}/`,F={moduleId:c.id,tabId:$};return f[N3(j)]=F,{...c,routeSegment:c.routeSegment,canonicalPath:j,tabs:A}}),t=i[0],y={moduleId:t?.id||"",tabId:t?.tabs[0]?.id||""};return f["/"]=y,{modules:i,moduleById:Object.fromEntries(i.map((c)=>[c.id,c])),defaultActiveTabs:n,routeMap:f,canonicalPathByTarget:r,fallbackTarget:y}}function B2(u,l){return u.routeMap[N3(l)]||u.fallbackTarget}function w3(u,l,f){return u.canonicalPathByTarget[H2(l,f)]||u.canonicalPathByTarget[H2(u.fallbackTarget.moduleId,u.fallbackTarget.tabId)]||"/"}function EN(u,l){let f=u.routeMap[N3(l)];if(!f)return null;return w3(u,f.moduleId,f.tabId)}var K3=Cu(Jl(),1);var iu=K3.default.createElement,{useEffect:ON,useMemo:RZ}=K3.default,V2=K3.default.useState;function T3({status:u,children:l,title:f}){let r=String(u||"unknown").toLowerCase();return iu("span",{className:`status-badge ${r}`,title:f},l||u||"unknown")}function cc({label:u,value:l,hint:f,tone:r}){return iu("article",{className:`metric-card ${r||""}`},iu("div",{className:"metric-label"},u),iu("div",{className:"metric-value"},l),iu("div",{className:"metric-hint"},f))}function W3({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return iu("section",{className:`panel ${n||""}`},iu("div",{className:"panel-head"},iu("div",null,l?iu("p",{className:"panel-eyebrow"},l):null,iu(rl,{title:u,loading:i})),f?iu("div",{className:"panel-actions"},f):null),iu("div",{className:"panel-body"},r))}function _c({title:u,data:l,onOpen:f,testId:r}){return iu("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f?.(u,l)},"查看原始JSON")}function m2({title:u,text:l}){return iu("div",{className:"empty-state"},iu("strong",null,u),iu("span",null,l))}function xZ(u){return u&&typeof u==="object"&&!Array.isArray(u)?u:null}function vn(u){return Array.isArray(u)?u:[]}function of(u){let l=Number(u);return Number.isFinite(l)?l.toLocaleString("zh-CN"):"--"}function ZN(u,l=140){if(u===null||u===void 0)return"--";let f=typeof u==="string"?u:JSON.stringify(u),r=String(f||"").replace(/\s+/gu," ").trim();return r.length>l?`${r.slice(0,l-1)}...`:r||"--"}function hZ(u){return vn(u?.tags).map((l)=>String(l||"").trim()).filter(Boolean)}function Pi(u){let l=Number(u);return Number.isFinite(l)&&l>=0?Math.floor(l):0}function bZ(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function vZ(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function kZ(u){return String(u||"").split(/[\s,]+/u).map((l)=>l.trim()).filter(Boolean).join(",")}function L3(u,l){return`${u}/microservices/oa-event-flow/proxy${l}`}function IZ(u){if(u.includes("error")||u.includes("failed"))return"failed";if(u.includes("stats"))return"ok";if(u.includes("step")||u.includes("updated"))return"running";return"queued"}function gZ(u){let l=String(u?.subjectKind||"trace"),f=String(u?.subjectId||u?.scopeId||"");return f?`${l}:${f}`:String(u?.scopeId||"--")}function sZ({tags:u}){let l=hZ({tags:u}).slice(0,6);return iu("div",{className:"oa-tag-rail"},l.length===0?iu("span",{className:"muted"},"--"):l.map((f)=>iu("code",{key:f},f)))}function aZ({events:u,onRaw:l}){let f=[...vn(u)].reverse();return f.length===0?iu(m2,{title:"事件表暂无记录",text:"等待 Code Queue 或 Pipeline 按 tag 发布 OA 事件"}):iu("div",{className:"table-wrap oa-event-table-wrap"},iu("table",{className:"oa-event-table","data-testid":"oa-event-flow-event-table"},iu("thead",null,iu("tr",null,iu("th",null,"Seq"),iu("th",null,"Type"),iu("th",null,"Source"),iu("th",null,"Aggregate"),iu("th",null,"Tags"),iu("th",null,"Payload"),iu("th",null,"Created"),iu("th",null,"Raw"))),iu("tbody",null,f.map((r)=>{let n=String(r?.type||"event"),i=`${String(r?.aggregateType||"--")}:${String(r?.aggregateId||"--")}`;return iu("tr",{key:r?.eventId||r?.sequence},iu("td",null,iu("code",null,of(r?.sequence))),iu("td",null,iu(T3,{status:IZ(n)},n)),iu("td",null,iu("strong",null,r?.sourceId||"--"),iu("code",null,r?.sourceKind||"--")),iu("td",null,iu("code",null,i)),iu("td",null,iu(sZ,{tags:r?.tags})),iu("td",null,iu("span",{className:"oa-payload-preview"},ZN(r?.payload,180))),iu("td",null,wu(r?.createdAt)),iu("td",null,iu(_c,{title:`OA Event ${r?.sequence||""}`,data:r,onOpen:l,testId:`raw-oa-event-${r?.sequence||"unknown"}`})))}))))}function oZ({stats:u,onRaw:l}){let f=vn(u);return f.length===0?iu(m2,{title:"统计中心暂无投影",text:"trace-stats-snapshot / trace-step-created 进入事件流后会更新这里"}):iu("div",{className:"table-wrap oa-stats-table-wrap"},iu("table",{className:"oa-stats-table","data-testid":"oa-event-flow-stats"},iu("thead",null,iu("tr",null,iu("th",null,"Scope"),iu("th",null,"Service"),iu("th",null,"STEP"),iu("th",null,"Read"),iu("th",null,"Edit"),iu("th",null,"Run"),iu("th",null,"Error"),iu("th",null,"Output Seq"),iu("th",null,"Revision"),iu("th",null,"Updated"),iu("th",null,"Raw"))),iu("tbody",null,f.map((r)=>iu("tr",{key:r?.scopeId||`${r?.serviceId}-${r?.subjectId}`},iu("td",null,iu("strong",null,gZ(r)),iu("code",null,r?.scopeId||"--")),iu("td",null,iu(T3,{status:String(r?.serviceId||"unknown")==="code-queue"?"running":"queued"},r?.serviceId||"--")),iu("td",null,iu("strong",null,of(Pi(r?.stepCount??r?.llmStepCount)))),iu("td",null,of(Pi(r?.readCount))),iu("td",null,of(Pi(r?.editCount))),iu("td",null,of(Pi(r?.runCount))),iu("td",null,of(Pi(r?.errorCount))),iu("td",null,iu("code",null,of(Pi(r?.outputMaxSeq)))),iu("td",null,of(Pi(r?.statsRevision))),iu("td",null,wu(r?.updatedAt)),iu("td",null,iu(_c,{title:`OA Trace Stats ${r?.scopeId||""}`,data:r,onOpen:l,testId:`raw-oa-stats-${String(r?.scopeId||"unknown").replace(/[^a-zA-Z0-9_-]/gu,"_")}`})))))))}function HN({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((G)=>G.id==="oa-event-flow")||null,[n,i]=V2("service:code-queue"),[t,y]=V2({loading:!1,error:"",health:null,diagnostics:null,events:[],stats:[],refreshedAt:null}),[c,$]=V2({status:"idle",message:"未连接",lastEventAt:""}),A=RZ(()=>kZ(n),[n]);async function j(){if(!r)return;y((G)=>({...G,loading:!0,error:""}));try{let G=A?`tags=${encodeURIComponent(A)}&`:"",[Z,H,E,m]=await Promise.all([Eu(`${f}/microservices/oa-event-flow/health`,{failureFields:[]}),Eu(L3(f,"/api/diagnostics")),Eu(L3(f,`/api/events?${G}limit=100`)),Eu(L3(f,`/api/stats/trace?${G}limit=100`))]);y({loading:!1,error:"",health:Z,diagnostics:H,events:vn(E?.events),stats:vn(m?.stats),refreshedAt:new Date})}catch(G){y((Z)=>({...Z,loading:!1,error:Ou(G,"OA Event Flow 加载失败")}))}}if(ON(()=>{j()},[r?.id,r?.runtime?.providerStatus,A]),ON(()=>{if(!r||typeof EventSource>"u")return;let G=A?`?tags=${encodeURIComponent(A)}`:"",Z=new EventSource(`${L3(f,"/api/events/stream")}${G}`,{withCredentials:!0});$({status:"running",message:"SSE connecting",lastEventAt:""});let H=(S)=>{$({status:"online",message:ZN(S.data,120),lastEventAt:new Date().toISOString()})},E=(S)=>{try{let B=JSON.parse(String(S.data||"{}"));$({status:"online",message:String(B?.type||S.type||"event"),lastEventAt:new Date().toISOString()}),y((D)=>{let X=[...vn(D.events).filter((Y)=>String(Y?.eventId||"")!==String(B?.eventId||"")),B].sort((Y,p)=>Number(Y?.sequence||0)-Number(p?.sequence||0)).slice(-100),O=B?.type==="trace-stats-updated"&&xZ(B?.payload?.stats)?[B.payload.stats,...vn(D.stats).filter((Y)=>String(Y?.scopeId||"")!==String(B.payload.stats.scopeId||""))].slice(0,100):D.stats;return{...D,events:X,stats:O}})}catch(B){$({status:"warn",message:Ou(B,"SSE 事件解析失败"),lastEventAt:new Date().toISOString()})}},m=()=>{$((S)=>({...S,status:"warn",message:"SSE reconnecting"}))};return Z.addEventListener("hello",H),Z.addEventListener("task-updated",E),Z.addEventListener("queue-updated",E),Z.addEventListener("trace-step-created",E),Z.addEventListener("trace-stats-snapshot",E),Z.addEventListener("trace-stats-updated",E),Z.addEventListener("trace-error",E),Z.onerror=m,()=>Z.close()},[r?.id,f,A]),!r)return iu(m2,{title:"OA Event Flow 未登记",text:"请在 config.json 的 microservices 中登记 id=oa-event-flow"});let F=bZ(r),J=vZ(r),Q=t.diagnostics||{},W=t.health||{},L=Q.eventCount??W.eventCount,U=Q.traceStatsCount??W.traceStatsCount,q=Q.latestSequence??W.latestSequence,N=Q.pipelineBridge||W.pipelineBridge||{},w=vn(Q.eventTypes).slice(0,8);return iu("div",{className:"oa-event-flow-page","data-testid":"oa-event-flow-page"},iu(W3,{title:"OA Event Flow 控制台",eyebrow:"Unified OA Event Bus + Stats Projection",loading:t.loading,actions:iu("div",{className:"panel-actions"},iu("button",{type:"button",className:"ghost-btn",onClick:j,disabled:t.loading,"data-testid":"oa-event-flow-refresh"},t.loading?"刷新中":"刷新"),iu(_c,{title:"OA Event Flow Service",data:r,onOpen:l,testId:"raw-oa-event-flow-service"}))},iu("div",{className:"oa-flow-hero"},iu("div",null,iu("div",{className:"node-version-line"},iu(T3,{status:W?.ok||F.providerStatus==="online"?"online":"warn"},W?.ok?"HEALTH OK":F.providerStatus||"unknown"),iu(T3,{status:c.status},c.status.toUpperCase()),iu("span",null,J.public?"公网暴露":"仅 UniDesk frontend 代理访问")),iu("p",{className:"muted paragraph"},"独立事件流微服务统一承载 Code Queue 与 Pipeline 的事件发布、tag 订阅、事件表审计和 Trace/STEP 统计投影。")),iu("div",{className:"oa-flow-signal"},iu("span",null,"stream"),iu("strong",null,c.message||"--"),iu("code",null,c.lastEventAt?yl(new Date(c.lastEventAt)):"waiting"))),iu(nl,{error:t.error,wide:!0})),iu("div",{className:"oa-flow-metrics"},iu(cc,{label:"事件总量",value:of(L),hint:`latest seq ${of(q)}`,tone:"ok"}),iu(cc,{label:"Trace Stats",value:of(U),hint:"oa_trace_stats 投影"}),iu(cc,{label:"SSE Clients",value:of(W?.sseClientCount??vn(Q.sseClients).length),hint:c.message||"tag subscription"}),iu(cc,{label:"Pipeline Bridge",value:N?.enabled?of(N?.insertedCount):"OFF",hint:N?.lastError||N?.lastFinishedAt||`${N?.mode||"snapshot"} service:pipeline`}),iu(cc,{label:"DB",value:W?.databaseReady||Q.databaseReady?"READY":"WAIT",hint:W?.databaseLastError||Q.databaseLastError||"PostgreSQL persisted"})),iu(W3,{title:"标签订阅",eyebrow:t.refreshedAt?`Updated ${yl(t.refreshedAt)}`:"Tag Pub/Sub"},iu("div",{className:"oa-filter-bar"},iu("label",null,iu("span",null,"tags"),iu("input",{value:n,onChange:(G)=>i(G.target.value),placeholder:"service:code-queue, trace","data-testid":"oa-event-flow-tag-filter"})),iu("div",{className:"oa-filter-presets"},iu("button",{type:"button",className:"ghost-btn",onClick:()=>i("service:code-queue")},"Code Queue"),iu("button",{type:"button",className:"ghost-btn",onClick:()=>i("service:pipeline")},"Pipeline"),iu("button",{type:"button",className:"ghost-btn",onClick:()=>i("trace")},"Trace"),iu("button",{type:"button",className:"ghost-btn",onClick:()=>i("")},"All")),iu("code",null,A||"all events")),iu("div",{className:"oa-type-strip"},w.length===0?iu("span",{className:"muted"},"等待事件类型统计"):w.map((G)=>iu("span",{key:G.type,className:"data-chip"},`${G.type} ${of(G.count)}`)))),iu("div",{className:"oa-flow-grid"},iu(W3,{title:"事件表",eyebrow:"oa_events persisted log",className:"oa-flow-wide",loading:t.loading,actions:iu(_c,{title:"OA Event Query",data:{events:t.events,diagnostics:Q},onOpen:l,testId:"raw-oa-events"})},iu(aZ,{events:t.events,onRaw:l})),iu(W3,{title:"统计中心",eyebrow:"oa_trace_stats read model",className:"oa-flow-wide",loading:t.loading,actions:iu(_c,{title:"OA Trace Stats",data:t.stats,onOpen:l,testId:"raw-oa-trace-stats"})},iu(oZ,{stats:t.stats,onRaw:l}))))}var s0=Cu(Jl(),1);var nu=Cu(DN(),1),tu=Cu(Jl(),1);function Rl(u){if(typeof u==="string"||typeof u==="number")return""+u;let l="";if(Array.isArray(u)){for(let f=0,r;f<u.length;f++)if((r=Rl(u[f]))!=="")l+=(l&&" ")+r}else for(let f in u)if(u[f])l+=(l&&" ")+f;return l}var nH={value:()=>{}};function SN(){for(var u=0,l=arguments.length,f={},r;u<l;++u){if(!(r=arguments[u]+"")||r in f||/[\s.]/.test(r))throw Error("illegal type: "+r);f[r]=[]}return new z3(f)}function z3(u){this._=u}function iH(u,l){return u.trim().split(/^|\s+/).map(function(f){var r="",n=f.indexOf(".");if(n>=0)r=f.slice(n+1),f=f.slice(0,n);if(f&&!l.hasOwnProperty(f))throw Error("unknown type: "+f);return{type:f,name:r}})}z3.prototype=SN.prototype={constructor:z3,on:function(u,l){var f=this._,r=iH(u+"",f),n,i=-1,t=r.length;if(arguments.length<2){while(++i<t)if((n=(u=r[i]).type)&&(n=tH(f[n],u.name)))return n;return}if(l!=null&&typeof l!=="function")throw Error("invalid callback: "+l);while(++i<t)if(n=(u=r[i]).type)f[n]=pN(f[n],u.name,l);else if(l==null)for(n in f)f[n]=pN(f[n],u.name,null);return this},copy:function(){var u={},l=this._;for(var f in l)u[f]=l[f].slice();return new z3(u)},call:function(u,l){if((n=arguments.length-2)>0)for(var f=Array(n),r=0,n,i;r<n;++r)f[r]=arguments[r+2];if(!this._.hasOwnProperty(u))throw Error("unknown type: "+u);for(i=this._[u],r=0,n=i.length;r<n;++r)i[r].value.apply(l,f)},apply:function(u,l,f){if(!this._.hasOwnProperty(u))throw Error("unknown type: "+u);for(var r=this._[u],n=0,i=r.length;n<i;++n)r[n].value.apply(l,f)}};function tH(u,l){for(var f=0,r=u.length,n;f<r;++f)if((n=u[f]).name===l)return n.value}function pN(u,l,f){for(var r=0,n=u.length;r<n;++r)if(u[r].name===l){u[r]=nH,u=u.slice(0,r).concat(u.slice(r+1));break}if(f!=null)u.push({name:l,value:f});return u}var Ci=SN;function ry(u){return function(){return this.matches(u)}}function E3(u){return function(l){return l.matches(u)}}var O3="http://www.w3.org/1999/xhtml",D2={svg:"http://www.w3.org/2000/svg",xhtml:O3,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Un(u){var l=u+="",f=l.indexOf(":");if(f>=0&&(l=u.slice(0,f))!=="xmlns")u=u.slice(f+1);return D2.hasOwnProperty(l)?{space:D2[l],local:u}:u}function p2(u){let l;while(l=u.sourceEvent)u=l;return u}function zf(u,l){if(u=p2(u),l===void 0)l=u.currentTarget;if(l){var f=l.ownerSVGElement||l;if(f.createSVGPoint){var r=f.createSVGPoint();return r.x=u.clientX,r.y=u.clientY,r=r.matrixTransform(l.getScreenCTM().inverse()),[r.x,r.y]}if(l.getBoundingClientRect){var n=l.getBoundingClientRect();return[u.clientX-n.left-l.clientLeft,u.clientY-n.top-l.clientTop]}}return[u.pageX,u.pageY]}function yH(){}function X0(u){return u==null?yH:function(){return this.querySelector(u)}}function S2(u){if(typeof u!=="function")u=X0(u);for(var l=this._groups,f=l.length,r=Array(f),n=0;n<f;++n)for(var i=l[n],t=i.length,y=r[n]=Array(t),c,$,A=0;A<t;++A)if((c=i[A])&&($=u.call(c,c.__data__,A,i))){if("__data__"in c)$.__data__=c.__data__;y[A]=$}return new xl(r,this._parents)}function X2(u){return u==null?[]:Array.isArray(u)?u:Array.from(u)}function cH(){return[]}function ny(u){return u==null?cH:function(){return this.querySelectorAll(u)}}function _H(u){return function(){return X2(u.apply(this,arguments))}}function Y2(u){if(typeof u==="function")u=_H(u);else u=ny(u);for(var l=this._groups,f=l.length,r=[],n=[],i=0;i<f;++i)for(var t=l[i],y=t.length,c,$=0;$<y;++$)if(c=t[$])r.push(u.call(c,c.__data__,$,t)),n.push(c);return new xl(r,n)}var $H=Array.prototype.find;function AH(u){return function(){return $H.call(this.children,u)}}function jH(){return this.firstElementChild}function P2(u){return this.select(u==null?jH:AH(typeof u==="function"?u:E3(u)))}var FH=Array.prototype.filter;function UH(){return Array.from(this.children)}function JH(u){return function(){return FH.call(this.children,u)}}function C2(u){return this.selectAll(u==null?UH:JH(typeof u==="function"?u:E3(u)))}function M2(u){if(typeof u!=="function")u=ry(u);for(var l=this._groups,f=l.length,r=Array(f),n=0;n<f;++n)for(var i=l[n],t=i.length,y=r[n]=[],c,$=0;$<t;++$)if((c=i[$])&&u.call(c,c.__data__,$,i))y.push(c);return new xl(r,this._parents)}function $c(u){return Array(u.length)}function R2(){return new xl(this._enter||this._groups.map($c),this._parents)}function Ac(u,l){this.ownerDocument=u.ownerDocument,this.namespaceURI=u.namespaceURI,this._next=null,this._parent=u,this.__data__=l}Ac.prototype={constructor:Ac,appendChild:function(u){return this._parent.insertBefore(u,this._next)},insertBefore:function(u,l){return this._parent.insertBefore(u,l)},querySelector:function(u){return this._parent.querySelector(u)},querySelectorAll:function(u){return this._parent.querySelectorAll(u)}};function x2(u){return function(){return u}}function QH(u,l,f,r,n,i){var t=0,y,c=l.length,$=i.length;for(;t<$;++t)if(y=l[t])y.__data__=i[t],r[t]=y;else f[t]=new Ac(u,i[t]);for(;t<c;++t)if(y=l[t])n[t]=y}function NH(u,l,f,r,n,i,t){var y,c,$=new Map,A=l.length,j=i.length,F=Array(A),J;for(y=0;y<A;++y)if(c=l[y])if(F[y]=J=t.call(c,c.__data__,y,l)+"",$.has(J))n[y]=c;else $.set(J,c);for(y=0;y<j;++y)if(J=t.call(u,i[y],y,i)+"",c=$.get(J))r[y]=c,c.__data__=i[y],$.delete(J);else f[y]=new Ac(u,i[y]);for(y=0;y<A;++y)if((c=l[y])&&$.get(F[y])===c)n[y]=c}function qH(u){return u.__data__}function h2(u,l){if(!arguments.length)return Array.from(this,qH);var f=l?NH:QH,r=this._parents,n=this._groups;if(typeof u!=="function")u=x2(u);for(var i=n.length,t=Array(i),y=Array(i),c=Array(i),$=0;$<i;++$){var A=r[$],j=n[$],F=j.length,J=wH(u.call(A,A&&A.__data__,$,r)),Q=J.length,W=y[$]=Array(Q),L=t[$]=Array(Q),U=c[$]=Array(F);f(A,j,W,L,U,J,l);for(var q=0,N=0,w,G;q<Q;++q)if(w=W[q]){if(q>=N)N=q+1;while(!(G=L[N])&&++N<Q);w._next=G||null}}return t=new xl(t,r),t._enter=y,t._exit=c,t}function wH(u){return typeof u==="object"&&"length"in u?u:Array.from(u)}function b2(){return new xl(this._exit||this._groups.map($c),this._parents)}function v2(u,l,f){var r=this.enter(),n=this,i=this.exit();if(typeof u==="function"){if(r=u(r),r)r=r.selection()}else r=r.append(u+"");if(l!=null){if(n=l(n),n)n=n.selection()}if(f==null)i.remove();else f(i);return r&&n?r.merge(n).order():n}function k2(u){var l=u.selection?u.selection():u;for(var f=this._groups,r=l._groups,n=f.length,i=r.length,t=Math.min(n,i),y=Array(n),c=0;c<t;++c)for(var $=f[c],A=r[c],j=$.length,F=y[c]=Array(j),J,Q=0;Q<j;++Q)if(J=$[Q]||A[Q])F[Q]=J;for(;c<n;++c)y[c]=f[c];return new xl(y,this._parents)}function I2(){for(var u=this._groups,l=-1,f=u.length;++l<f;)for(var r=u[l],n=r.length-1,i=r[n],t;--n>=0;)if(t=r[n]){if(i&&t.compareDocumentPosition(i)^4)i.parentNode.insertBefore(t,i);i=t}return this}function g2(u){if(!u)u=WH;function l(j,F){return j&&F?u(j.__data__,F.__data__):!j-!F}for(var f=this._groups,r=f.length,n=Array(r),i=0;i<r;++i){for(var t=f[i],y=t.length,c=n[i]=Array(y),$,A=0;A<y;++A)if($=t[A])c[A]=$;c.sort(l)}return new xl(n,this._parents).order()}function WH(u,l){return u<l?-1:u>l?1:u>=l?0:NaN}function s2(){var u=arguments[0];return arguments[0]=this,u.apply(null,arguments),this}function a2(){return Array.from(this)}function o2(){for(var u=this._groups,l=0,f=u.length;l<f;++l)for(var r=u[l],n=0,i=r.length;n<i;++n){var t=r[n];if(t)return t}return null}function d2(){let u=0;for(let l of this)++u;return u}function e2(){return!this.node()}function u5(u){for(var l=this._groups,f=0,r=l.length;f<r;++f)for(var n=l[f],i=0,t=n.length,y;i<t;++i)if(y=n[i])u.call(y,y.__data__,i,n);return this}function LH(u){return function(){this.removeAttribute(u)}}function TH(u){return function(){this.removeAttributeNS(u.space,u.local)}}function KH(u,l){return function(){this.setAttribute(u,l)}}function GH(u,l){return function(){this.setAttributeNS(u.space,u.local,l)}}function zH(u,l){return function(){var f=l.apply(this,arguments);if(f==null)this.removeAttribute(u);else this.setAttribute(u,f)}}function EH(u,l){return function(){var f=l.apply(this,arguments);if(f==null)this.removeAttributeNS(u.space,u.local);else this.setAttributeNS(u.space,u.local,f)}}function l5(u,l){var f=Un(u);if(arguments.length<2){var r=this.node();return f.local?r.getAttributeNS(f.space,f.local):r.getAttribute(f)}return this.each((l==null?f.local?TH:LH:typeof l==="function"?f.local?EH:zH:f.local?GH:KH)(f,l))}function jc(u){return u.ownerDocument&&u.ownerDocument.defaultView||u.document&&u||u.defaultView}function OH(u){return function(){this.style.removeProperty(u)}}function ZH(u,l,f){return function(){this.style.setProperty(u,l,f)}}function HH(u,l,f){return function(){var r=l.apply(this,arguments);if(r==null)this.style.removeProperty(u);else this.style.setProperty(u,r,f)}}function f5(u,l,f){return arguments.length>1?this.each((l==null?OH:typeof l==="function"?HH:ZH)(u,l,f==null?"":f)):Y0(this.node(),u)}function Y0(u,l){return u.style.getPropertyValue(l)||jc(u).getComputedStyle(u,null).getPropertyValue(l)}function BH(u){return function(){delete this[u]}}function VH(u,l){return function(){this[u]=l}}function mH(u,l){return function(){var f=l.apply(this,arguments);if(f==null)delete this[u];else this[u]=f}}function r5(u,l){return arguments.length>1?this.each((l==null?BH:typeof l==="function"?mH:VH)(u,l)):this.node()[u]}function XN(u){return u.trim().split(/^|\s+/)}function n5(u){return u.classList||new YN(u)}function YN(u){this._node=u,this._names=XN(u.getAttribute("class")||"")}YN.prototype={add:function(u){var l=this._names.indexOf(u);if(l<0)this._names.push(u),this._node.setAttribute("class",this._names.join(" "))},remove:function(u){var l=this._names.indexOf(u);if(l>=0)this._names.splice(l,1),this._node.setAttribute("class",this._names.join(" "))},contains:function(u){return this._names.indexOf(u)>=0}};function PN(u,l){var f=n5(u),r=-1,n=l.length;while(++r<n)f.add(l[r])}function CN(u,l){var f=n5(u),r=-1,n=l.length;while(++r<n)f.remove(l[r])}function DH(u){return function(){PN(this,u)}}function pH(u){return function(){CN(this,u)}}function SH(u,l){return function(){(l.apply(this,arguments)?PN:CN)(this,u)}}function i5(u,l){var f=XN(u+"");if(arguments.length<2){var r=n5(this.node()),n=-1,i=f.length;while(++n<i)if(!r.contains(f[n]))return!1;return!0}return this.each((typeof l==="function"?SH:l?DH:pH)(f,l))}function XH(){this.textContent=""}function YH(u){return function(){this.textContent=u}}function PH(u){return function(){var l=u.apply(this,arguments);this.textContent=l==null?"":l}}function t5(u){return arguments.length?this.each(u==null?XH:(typeof u==="function"?PH:YH)(u)):this.node().textContent}function CH(){this.innerHTML=""}function MH(u){return function(){this.innerHTML=u}}function RH(u){return function(){var l=u.apply(this,arguments);this.innerHTML=l==null?"":l}}function y5(u){return arguments.length?this.each(u==null?CH:(typeof u==="function"?RH:MH)(u)):this.node().innerHTML}function xH(){if(this.nextSibling)this.parentNode.appendChild(this)}function c5(){return this.each(xH)}function hH(){if(this.previousSibling)this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _5(){return this.each(hH)}function bH(u){return function(){var l=this.ownerDocument,f=this.namespaceURI;return f===O3&&l.documentElement.namespaceURI===O3?l.createElement(u):l.createElementNS(f,u)}}function vH(u){return function(){return this.ownerDocument.createElementNS(u.space,u.local)}}function Fc(u){var l=Un(u);return(l.local?vH:bH)(l)}function $5(u){var l=typeof u==="function"?u:Fc(u);return this.select(function(){return this.appendChild(l.apply(this,arguments))})}function kH(){return null}function A5(u,l){var f=typeof u==="function"?u:Fc(u),r=l==null?kH:typeof l==="function"?l:X0(l);return this.select(function(){return this.insertBefore(f.apply(this,arguments),r.apply(this,arguments)||null)})}function IH(){var u=this.parentNode;if(u)u.removeChild(this)}function j5(){return this.each(IH)}function gH(){var u=this.cloneNode(!1),l=this.parentNode;return l?l.insertBefore(u,this.nextSibling):u}function sH(){var u=this.cloneNode(!0),l=this.parentNode;return l?l.insertBefore(u,this.nextSibling):u}function F5(u){return this.select(u?sH:gH)}function U5(u){return arguments.length?this.property("__data__",u):this.node().__data__}function aH(u){return function(l){u.call(this,l,this.__data__)}}function oH(u){return u.trim().split(/^|\s+/).map(function(l){var f="",r=l.indexOf(".");if(r>=0)f=l.slice(r+1),l=l.slice(0,r);return{type:l,name:f}})}function dH(u){return function(){var l=this.__on;if(!l)return;for(var f=0,r=-1,n=l.length,i;f<n;++f)if(i=l[f],(!u.type||i.type===u.type)&&i.name===u.name)this.removeEventListener(i.type,i.listener,i.options);else l[++r]=i;if(++r)l.length=r;else delete this.__on}}function eH(u,l,f){return function(){var r=this.__on,n,i=aH(l);if(r){for(var t=0,y=r.length;t<y;++t)if((n=r[t]).type===u.type&&n.name===u.name){this.removeEventListener(n.type,n.listener,n.options),this.addEventListener(n.type,n.listener=i,n.options=f),n.value=l;return}}if(this.addEventListener(u.type,i,f),n={type:u.type,name:u.name,value:l,listener:i,options:f},!r)this.__on=[n];else r.push(n)}}function J5(u,l,f){var r=oH(u+""),n,i=r.length,t;if(arguments.length<2){var y=this.node().__on;if(y){for(var c=0,$=y.length,A;c<$;++c)for(n=0,A=y[c];n<i;++n)if((t=r[n]).type===A.type&&t.name===A.name)return A.value}return}y=l?eH:dH;for(n=0;n<i;++n)this.each(y(r[n],l,f));return this}function MN(u,l,f){var r=jc(u),n=r.CustomEvent;if(typeof n==="function")n=new n(l,f);else if(n=r.document.createEvent("Event"),f)n.initEvent(l,f.bubbles,f.cancelable),n.detail=f.detail;else n.initEvent(l,!1,!1);u.dispatchEvent(n)}function uB(u,l){return function(){return MN(this,u,l)}}function lB(u,l){return function(){return MN(this,u,l.apply(this,arguments))}}function Q5(u,l){return this.each((typeof l==="function"?lB:uB)(u,l))}function*N5(){for(var u=this._groups,l=0,f=u.length;l<f;++l)for(var r=u[l],n=0,i=r.length,t;n<i;++n)if(t=r[n])yield t}var q5=[null];function xl(u,l){this._groups=u,this._parents=l}function RN(){return new xl([[document.documentElement]],q5)}function fB(){return this}xl.prototype=RN.prototype={constructor:xl,select:S2,selectAll:Y2,selectChild:P2,selectChildren:C2,filter:M2,data:h2,enter:R2,exit:b2,join:v2,merge:k2,selection:fB,order:I2,sort:g2,call:s2,nodes:a2,node:o2,size:d2,empty:e2,each:u5,attr:l5,style:f5,property:r5,classed:i5,text:t5,html:y5,raise:c5,lower:_5,append:$5,insert:A5,remove:j5,clone:F5,datum:U5,on:J5,dispatch:Q5,[Symbol.iterator]:N5};var kn=RN;function ff(u){return typeof u==="string"?new xl([[document.querySelector(u)]],[document.documentElement]):new xl([[u]],q5)}var xN={passive:!1},Mi={capture:!0,passive:!1};function Z3(u){u.stopImmediatePropagation()}function In(u){u.preventDefault(),u.stopImmediatePropagation()}function iy(u){var l=u.document.documentElement,f=ff(u).on("dragstart.drag",In,Mi);if("onselectstart"in l)f.on("selectstart.drag",In,Mi);else l.__noselect=l.style.MozUserSelect,l.style.MozUserSelect="none"}function Uc(u,l){var f=u.document.documentElement,r=ff(u).on("dragstart.drag",null);if(l)r.on("click.drag",In,Mi),setTimeout(function(){r.on("click.drag",null)},0);if("onselectstart"in f)r.on("selectstart.drag",null);else f.style.MozUserSelect=f.__noselect,delete f.__noselect}var Jc=(u)=>()=>u;function Qc(u,{sourceEvent:l,subject:f,target:r,identifier:n,active:i,x:t,y,dx:c,dy:$,dispatch:A}){Object.defineProperties(this,{type:{value:u,enumerable:!0,configurable:!0},sourceEvent:{value:l,enumerable:!0,configurable:!0},subject:{value:f,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:n,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:t,enumerable:!0,configurable:!0},y:{value:y,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:$,enumerable:!0,configurable:!0},_:{value:A}})}Qc.prototype.on=function(){var u=this._.on.apply(this._,arguments);return u===this._?this:u};function $B(u){return!u.ctrlKey&&!u.button}function AB(){return this.parentNode}function jB(u,l){return l==null?{x:u.x,y:u.y}:l}function FB(){return navigator.maxTouchPoints||"ontouchstart"in this}function Nc(){var u=$B,l=AB,f=jB,r=FB,n={},i=Ci("start","drag","end"),t=0,y,c,$,A,j=0;function F(w){w.on("mousedown.drag",J).filter(r).on("touchstart.drag",L).on("touchmove.drag",U,xN).on("touchend.drag touchcancel.drag",q).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function J(w,G){if(A||!u.call(this,w,G))return;var Z=N(this,l.call(this,w,G),w,G,"mouse");if(!Z)return;ff(w.view).on("mousemove.drag",Q,Mi).on("mouseup.drag",W,Mi),iy(w.view),Z3(w),$=!1,y=w.clientX,c=w.clientY,Z("start",w)}function Q(w){if(In(w),!$){var G=w.clientX-y,Z=w.clientY-c;$=G*G+Z*Z>j}n.mouse("drag",w)}function W(w){ff(w.view).on("mousemove.drag mouseup.drag",null),Uc(w.view,$),In(w),n.mouse("end",w)}function L(w,G){if(!u.call(this,w,G))return;var Z=w.changedTouches,H=l.call(this,w,G),E=Z.length,m,S;for(m=0;m<E;++m)if(S=N(this,H,w,G,Z[m].identifier,Z[m]))Z3(w),S("start",w,Z[m])}function U(w){var G=w.changedTouches,Z=G.length,H,E;for(H=0;H<Z;++H)if(E=n[G[H].identifier])In(w),E("drag",w,G[H])}function q(w){var G=w.changedTouches,Z=G.length,H,E;if(A)clearTimeout(A);A=setTimeout(function(){A=null},500);for(H=0;H<Z;++H)if(E=n[G[H].identifier])Z3(w),E("end",w,G[H])}function N(w,G,Z,H,E,m){var S=i.copy(),B=zf(m||Z,G),D,X,O;if((O=f.call(w,new Qc("beforestart",{sourceEvent:Z,target:F,identifier:E,active:t,x:B[0],y:B[1],dx:0,dy:0,dispatch:S}),H))==null)return;return D=O.x-B[0]||0,X=O.y-B[1]||0,function Y(p,v,z){var P=B,k;switch(p){case"start":n[E]=Y,k=t++;break;case"end":delete n[E],--t;case"drag":B=zf(z||v,G),k=t;break}S.call(p,w,new Qc(p,{sourceEvent:v,subject:O,target:F,identifier:E,active:k,x:B[0]+D,y:B[1]+X,dx:B[0]-P[0],dy:B[1]-P[1],dispatch:S}),H)}}return F.filter=function(w){return arguments.length?(u=typeof w==="function"?w:Jc(!!w),F):u},F.container=function(w){return arguments.length?(l=typeof w==="function"?w:Jc(w),F):l},F.subject=function(w){return arguments.length?(f=typeof w==="function"?w:Jc(w),F):f},F.touchable=function(w){return arguments.length?(r=typeof w==="function"?w:Jc(!!w),F):r},F.on=function(){var w=i.on.apply(i,arguments);return w===i?F:w},F.clickDistance=function(w){return arguments.length?(j=(w=+w)*w,F):Math.sqrt(j)},F}function qc(u,l,f){u.prototype=l.prototype=f,f.constructor=u}function w5(u,l){var f=Object.create(u.prototype);for(var r in l)f[r]=l[r];return f}function Lc(){}var wc=0.7,V3=1/wc,ty="\\s*([+-]?\\d+)\\s*",Wc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",UB=/^#([0-9a-f]{3,8})$/,JB=new RegExp(`^rgb\\(${ty},${ty},${ty}\\)$`),QB=new RegExp(`^rgb\\(${Jn},${Jn},${Jn}\\)$`),NB=new RegExp(`^rgba\\(${ty},${ty},${ty},${Wc}\\)$`),qB=new RegExp(`^rgba\\(${Jn},${Jn},${Jn},${Wc}\\)$`),wB=new RegExp(`^hsl\\(${Wc},${Jn},${Jn}\\)$`),WB=new RegExp(`^hsla\\(${Wc},${Jn},${Jn},${Wc}\\)$`),hN={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};qc(Lc,dr,{copy(u){return Object.assign(new this.constructor,this,u)},displayable(){return this.rgb().displayable()},hex:bN,formatHex:bN,formatHex8:LB,formatHsl:TB,formatRgb:vN,toString:vN});function bN(){return this.rgb().formatHex()}function LB(){return this.rgb().formatHex8()}function TB(){return oN(this).formatHsl()}function vN(){return this.rgb().formatRgb()}function dr(u){var l,f;return u=(u+"").trim().toLowerCase(),(l=UB.exec(u))?(f=l[1].length,l=parseInt(l[1],16),f===6?kN(l):f===3?new df(l>>8&15|l>>4&240,l>>4&15|l&240,(l&15)<<4|l&15,1):f===8?H3(l>>24&255,l>>16&255,l>>8&255,(l&255)/255):f===4?H3(l>>12&15|l>>8&240,l>>8&15|l>>4&240,l>>4&15|l&240,((l&15)<<4|l&15)/255):null):(l=JB.exec(u))?new df(l[1],l[2],l[3],1):(l=QB.exec(u))?new df(l[1]*255/100,l[2]*255/100,l[3]*255/100,1):(l=NB.exec(u))?H3(l[1],l[2],l[3],l[4]):(l=qB.exec(u))?H3(l[1]*255/100,l[2]*255/100,l[3]*255/100,l[4]):(l=wB.exec(u))?sN(l[1],l[2]/100,l[3]/100,1):(l=WB.exec(u))?sN(l[1],l[2]/100,l[3]/100,l[4]):hN.hasOwnProperty(u)?kN(hN[u]):u==="transparent"?new df(NaN,NaN,NaN,0):null}function kN(u){return new df(u>>16&255,u>>8&255,u&255,1)}function H3(u,l,f,r){if(r<=0)u=l=f=NaN;return new df(u,l,f,r)}function KB(u){if(!(u instanceof Lc))u=dr(u);if(!u)return new df;return u=u.rgb(),new df(u.r,u.g,u.b,u.opacity)}function yy(u,l,f,r){return arguments.length===1?KB(u):new df(u,l,f,r==null?1:r)}function df(u,l,f,r){this.r=+u,this.g=+l,this.b=+f,this.opacity=+r}qc(df,yy,w5(Lc,{brighter(u){return u=u==null?V3:Math.pow(V3,u),new df(this.r*u,this.g*u,this.b*u,this.opacity)},darker(u){return u=u==null?wc:Math.pow(wc,u),new df(this.r*u,this.g*u,this.b*u,this.opacity)},rgb(){return this},clamp(){return new df(xi(this.r),xi(this.g),xi(this.b),m3(this.opacity))},displayable(){return-0.5<=this.r&&this.r<255.5&&(-0.5<=this.g&&this.g<255.5)&&(-0.5<=this.b&&this.b<255.5)&&(0<=this.opacity&&this.opacity<=1)},hex:IN,formatHex:IN,formatHex8:GB,formatRgb:gN,toString:gN}));function IN(){return`#${Ri(this.r)}${Ri(this.g)}${Ri(this.b)}`}function GB(){return`#${Ri(this.r)}${Ri(this.g)}${Ri(this.b)}${Ri((isNaN(this.opacity)?1:this.opacity)*255)}`}function gN(){let u=m3(this.opacity);return`${u===1?"rgb(":"rgba("}${xi(this.r)}, ${xi(this.g)}, ${xi(this.b)}${u===1?")":`, ${u})`}`}function m3(u){return isNaN(u)?1:Math.max(0,Math.min(1,u))}function xi(u){return Math.max(0,Math.min(255,Math.round(u)||0))}function Ri(u){return u=xi(u),(u<16?"0":"")+u.toString(16)}function sN(u,l,f,r){if(r<=0)u=l=f=NaN;else if(f<=0||f>=1)u=l=NaN;else if(l<=0)u=NaN;return new or(u,l,f,r)}function oN(u){if(u instanceof or)return new or(u.h,u.s,u.l,u.opacity);if(!(u instanceof Lc))u=dr(u);if(!u)return new or;if(u instanceof or)return u;u=u.rgb();var l=u.r/255,f=u.g/255,r=u.b/255,n=Math.min(l,f,r),i=Math.max(l,f,r),t=NaN,y=i-n,c=(i+n)/2;if(y){if(l===i)t=(f-r)/y+(f<r)*6;else if(f===i)t=(r-l)/y+2;else t=(l-f)/y+4;y/=c<0.5?i+n:2-i-n,t*=60}else y=c>0&&c<1?0:t;return new or(t,y,c,u.opacity)}function dN(u,l,f,r){return arguments.length===1?oN(u):new or(u,l,f,r==null?1:r)}function or(u,l,f,r){this.h=+u,this.s=+l,this.l=+f,this.opacity=+r}qc(or,dN,w5(Lc,{brighter(u){return u=u==null?V3:Math.pow(V3,u),new or(this.h,this.s,this.l*u,this.opacity)},darker(u){return u=u==null?wc:Math.pow(wc,u),new or(this.h,this.s,this.l*u,this.opacity)},rgb(){var u=this.h%360+(this.h<0)*360,l=isNaN(u)||isNaN(this.s)?0:this.s,f=this.l,r=f+(f<0.5?f:1-f)*l,n=2*f-r;return new df(W5(u>=240?u-240:u+120,n,r),W5(u,n,r),W5(u<120?u+240:u-120,n,r),this.opacity)},clamp(){return new or(aN(this.h),B3(this.s),B3(this.l),m3(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&(0<=this.l&&this.l<=1)&&(0<=this.opacity&&this.opacity<=1)},formatHsl(){let u=m3(this.opacity);return`${u===1?"hsl(":"hsla("}${aN(this.h)}, ${B3(this.s)*100}%, ${B3(this.l)*100}%${u===1?")":`, ${u})`}`}}));function aN(u){return u=(u||0)%360,u<0?u+360:u}function B3(u){return Math.max(0,Math.min(1,u||0))}function W5(u,l,f){return(u<60?l+(f-l)*u/60:u<180?f:u<240?l+(f-l)*(240-u)/60:l)*255}function L5(u,l,f,r,n){var i=u*u,t=i*u;return((1-3*u+3*i-t)*l+(4-6*i+3*t)*f+(1+3*u+3*i-3*t)*r+t*n)/6}function T5(u){var l=u.length-1;return function(f){var r=f<=0?f=0:f>=1?(f=1,l-1):Math.floor(f*l),n=u[r],i=u[r+1],t=r>0?u[r-1]:2*n-i,y=r<l-1?u[r+2]:2*i-n;return L5((f-r/l)*l,t,n,i,y)}}function K5(u){var l=u.length;return function(f){var r=Math.floor(((f%=1)<0?++f:f)*l),n=u[(r+l-1)%l],i=u[r%l],t=u[(r+1)%l],y=u[(r+2)%l];return L5((f-r/l)*l,n,i,t,y)}}var Tc=(u)=>()=>u;function EB(u,l){return function(f){return u+f*l}}function OB(u,l,f){return u=Math.pow(u,f),l=Math.pow(l,f)-u,f=1/f,function(r){return Math.pow(u+r*l,f)}}function eN(u){return(u=+u)===1?p3:function(l,f){return f-l?OB(l,f,u):Tc(isNaN(l)?f:l)}}function p3(u,l){var f=l-u;return f?EB(u,f):Tc(isNaN(u)?l:u)}var hi=function u(l){var f=eN(l);function r(n,i){var t=f((n=yy(n)).r,(i=yy(i)).r),y=f(n.g,i.g),c=f(n.b,i.b),$=p3(n.opacity,i.opacity);return function(A){return n.r=t(A),n.g=y(A),n.b=c(A),n.opacity=$(A),n+""}}return r.gamma=u,r}(1);function uq(u){return function(l){var f=l.length,r=Array(f),n=Array(f),i=Array(f),t,y;for(t=0;t<f;++t)y=yy(l[t]),r[t]=y.r||0,n[t]=y.g||0,i[t]=y.b||0;return r=u(r),n=u(n),i=u(i),y.opacity=1,function(c){return y.r=r(c),y.g=n(c),y.b=i(c),y+""}}}var ZB=uq(T5),HB=uq(K5);function G5(u,l){if(!l)l=[];var f=u?Math.min(l.length,u.length):0,r=l.slice(),n;return function(i){for(n=0;n<f;++n)r[n]=u[n]*(1-i)+l[n]*i;return r}}function lq(u){return ArrayBuffer.isView(u)&&!(u instanceof DataView)}function fq(u,l){var f=l?l.length:0,r=u?Math.min(f,u.length):0,n=Array(r),i=Array(f),t;for(t=0;t<r;++t)n[t]=Qn(u[t],l[t]);for(;t<f;++t)i[t]=l[t];return function(y){for(t=0;t<r;++t)i[t]=n[t](y);return i}}function z5(u,l){var f=new Date;return u=+u,l=+l,function(r){return f.setTime(u*(1-r)+l*r),f}}function Ef(u,l){return u=+u,l=+l,function(f){return u*(1-f)+l*f}}function E5(u,l){var f={},r={},n;if(u===null||typeof u!=="object")u={};if(l===null||typeof l!=="object")l={};for(n in l)if(n in u)f[n]=Qn(u[n],l[n]);else r[n]=l[n];return function(i){for(n in f)r[n]=f[n](i);return r}}var Z5=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,O5=new RegExp(Z5.source,"g");function BB(u){return function(){return u}}function VB(u){return function(l){return u(l)+""}}function cy(u,l){var f=Z5.lastIndex=O5.lastIndex=0,r,n,i,t=-1,y=[],c=[];u=u+"",l=l+"";while((r=Z5.exec(u))&&(n=O5.exec(l))){if((i=n.index)>f)if(i=l.slice(f,i),y[t])y[t]+=i;else y[++t]=i;if((r=r[0])===(n=n[0]))if(y[t])y[t]+=n;else y[++t]=n;else y[++t]=null,c.push({i:t,x:Ef(r,n)});f=O5.lastIndex}if(f<l.length)if(i=l.slice(f),y[t])y[t]+=i;else y[++t]=i;return y.length<2?c[0]?VB(c[0].x):BB(l):(l=c.length,function($){for(var A=0,j;A<l;++A)y[(j=c[A]).i]=j.x($);return y.join("")})}function Qn(u,l){var f=typeof l,r;return l==null||f==="boolean"?Tc(l):(f==="number"?Ef:f==="string"?(r=dr(l))?(l=r,hi):cy:l instanceof dr?hi:l instanceof Date?z5:lq(l)?G5:Array.isArray(l)?fq:typeof l.valueOf!=="function"&&typeof l.toString!=="function"||isNaN(l)?E5:Ef)(u,l)}var rq=180/Math.PI,S3={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function X3(u,l,f,r,n,i){var t,y,c;if(t=Math.sqrt(u*u+l*l))u/=t,l/=t;if(c=u*f+l*r)f-=u*c,r-=l*c;if(y=Math.sqrt(f*f+r*r))f/=y,r/=y,c/=y;if(u*r<l*f)u=-u,l=-l,c=-c,t=-t;return{translateX:n,translateY:i,rotate:Math.atan2(l,u)*rq,skewX:Math.atan(c)*rq,scaleX:t,scaleY:y}}var Y3;function nq(u){let l=new(typeof DOMMatrix==="function"?DOMMatrix:WebKitCSSMatrix)(u+"");return l.isIdentity?S3:X3(l.a,l.b,l.c,l.d,l.e,l.f)}function iq(u){if(u==null)return S3;if(!Y3)Y3=document.createElementNS("http://www.w3.org/2000/svg","g");if(Y3.setAttribute("transform",u),!(u=Y3.transform.baseVal.consolidate()))return S3;return u=u.matrix,X3(u.a,u.b,u.c,u.d,u.e,u.f)}function tq(u,l,f,r){function n($){return $.length?$.pop()+" ":""}function i($,A,j,F,J,Q){if($!==j||A!==F){var W=J.push("translate(",null,l,null,f);Q.push({i:W-4,x:Ef($,j)},{i:W-2,x:Ef(A,F)})}else if(j||F)J.push("translate("+j+l+F+f)}function t($,A,j,F){if($!==A){if($-A>180)A+=360;else if(A-$>180)$+=360;F.push({i:j.push(n(j)+"rotate(",null,r)-2,x:Ef($,A)})}else if(A)j.push(n(j)+"rotate("+A+r)}function y($,A,j,F){if($!==A)F.push({i:j.push(n(j)+"skewX(",null,r)-2,x:Ef($,A)});else if(A)j.push(n(j)+"skewX("+A+r)}function c($,A,j,F,J,Q){if($!==j||A!==F){var W=J.push(n(J)+"scale(",null,",",null,")");Q.push({i:W-4,x:Ef($,j)},{i:W-2,x:Ef(A,F)})}else if(j!==1||F!==1)J.push(n(J)+"scale("+j+","+F+")")}return function($,A){var j=[],F=[];return $=u($),A=u(A),i($.translateX,$.translateY,A.translateX,A.translateY,j,F),t($.rotate,A.rotate,j,F),y($.skewX,A.skewX,j,F),c($.scaleX,$.scaleY,A.scaleX,A.scaleY,j,F),$=A=null,function(J){var Q=-1,W=F.length,L;while(++Q<W)j[(L=F[Q]).i]=L.x(J);return j.join("")}}}var H5=tq(nq,"px, ","px)","deg)"),B5=tq(iq,", ",")",")");var mB=0.000000000001;function yq(u){return((u=Math.exp(u))+1/u)/2}function DB(u){return((u=Math.exp(u))-1/u)/2}function pB(u){return((u=Math.exp(2*u))-1)/(u+1)}var bi=function u(l,f,r){function n(i,t){var y=i[0],c=i[1],$=i[2],A=t[0],j=t[1],F=t[2],J=A-y,Q=j-c,W=J*J+Q*Q,L,U;if(W<mB)U=Math.log(F/$)/l,L=function(H){return[y+H*J,c+H*Q,$*Math.exp(l*H*U)]};else{var q=Math.sqrt(W),N=(F*F-$*$+r*W)/(2*$*f*q),w=(F*F-$*$-r*W)/(2*F*f*q),G=Math.log(Math.sqrt(N*N+1)-N),Z=Math.log(Math.sqrt(w*w+1)-w);U=(Z-G)/l,L=function(H){var E=H*U,m=yq(G),S=$/(f*q)*(m*pB(l*E+G)-DB(G));return[y+S*J,c+S*Q,$*m/yq(l*E+G)]}}return L.duration=U*1000*l/Math.SQRT2,L}return n.rho=function(i){var t=Math.max(0.001,+i),y=t*t,c=y*y;return u(t,y,c)},n}(Math.SQRT2,2,4);var _y=0,Gc=0,Kc=0,jq=1000,P3,zc,C3=0,vi=0,M3=0,Ec=typeof performance==="object"&&performance.now?performance:Date,Fq=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(u){setTimeout(u,17)};function Zc(){return vi||(Fq(IB),vi=Ec.now()+M3)}function IB(){vi=0}function Oc(){this._call=this._time=this._next=null}Oc.prototype=R3.prototype={constructor:Oc,restart:function(u,l,f){if(typeof u!=="function")throw TypeError("callback is not a function");if(f=(f==null?Zc():+f)+(l==null?0:+l),!this._next&&zc!==this){if(zc)zc._next=this;else P3=this;zc=this}this._call=u,this._time=f,V5()},stop:function(){if(this._call)this._call=null,this._time=1/0,V5()}};function R3(u,l,f){var r=new Oc;return r.restart(u,l,f),r}function Uq(){Zc(),++_y;var u=P3,l;while(u){if((l=vi-u._time)>=0)u._call.call(void 0,l);u=u._next}--_y}function Aq(){vi=(C3=Ec.now())+M3,_y=Gc=0;try{Uq()}finally{_y=0,sB(),vi=0}}function gB(){var u=Ec.now(),l=u-C3;if(l>jq)M3-=l,C3=u}function sB(){var u,l=P3,f,r=1/0;while(l)if(l._call){if(r>l._time)r=l._time;u=l,l=l._next}else f=l._next,l._next=null,l=u?u._next=f:P3=f;zc=u,V5(r)}function V5(u){if(_y)return;if(Gc)Gc=clearTimeout(Gc);var l=u-vi;if(l>24){if(u<1/0)Gc=setTimeout(Aq,u-Ec.now()-M3);if(Kc)Kc=clearInterval(Kc)}else{if(!Kc)C3=Ec.now(),Kc=setInterval(gB,jq);_y=1,Fq(Aq)}}function Hc(u,l,f){var r=new Oc;return l=l==null?0:+l,r.restart((n)=>{r.stop(),u(n+l)},l,f),r}var oB=Ci("start","end","cancel","interrupt"),dB=[],Nq=0,Jq=1,h3=2,x3=3,Qq=4,b3=5,Bc=6;function gn(u,l,f,r,n,i){var t=u.__transition;if(!t)u.__transition={};else if(f in t)return;eB(u,f,{name:l,index:r,group:n,on:oB,tween:dB,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Nq})}function Vc(u,l){var f=rf(u,l);if(f.state>Nq)throw Error("too late; already scheduled");return f}function Jf(u,l){var f=rf(u,l);if(f.state>x3)throw Error("too late; already running");return f}function rf(u,l){var f=u.__transition;if(!f||!(f=f[l]))throw Error("transition not found");return f}function eB(u,l,f){var r=u.__transition,n;r[l]=f,f.timer=R3(i,0,f.time);function i($){if(f.state=Jq,f.timer.restart(t,f.delay,f.time),f.delay<=$)t($-f.delay)}function t($){var A,j,F,J;if(f.state!==Jq)return c();for(A in r){if(J=r[A],J.name!==f.name)continue;if(J.state===x3)return Hc(t);if(J.state===Qq)J.state=Bc,J.timer.stop(),J.on.call("interrupt",u,u.__data__,J.index,J.group),delete r[A];else if(+A<l)J.state=Bc,J.timer.stop(),J.on.call("cancel",u,u.__data__,J.index,J.group),delete r[A]}if(Hc(function(){if(f.state===x3)f.state=Qq,f.timer.restart(y,f.delay,f.time),y($)}),f.state=h3,f.on.call("start",u,u.__data__,f.index,f.group),f.state!==h3)return;f.state=x3,n=Array(F=f.tween.length);for(A=0,j=-1;A<F;++A)if(J=f.tween[A].value.call(u,u.__data__,f.index,f.group))n[++j]=J;n.length=j+1}function y($){var A=$<f.duration?f.ease.call(null,$/f.duration):(f.timer.restart(c),f.state=b3,1),j=-1,F=n.length;while(++j<F)n[j].call(u,A);if(f.state===b3)f.on.call("end",u,u.__data__,f.index,f.group),c()}function c(){f.state=Bc,f.timer.stop(),delete r[l];for(var $ in r)return;delete u.__transition}}function P0(u,l){var f=u.__transition,r,n,i=!0,t;if(!f)return;l=l==null?null:l+"";for(t in f){if((r=f[t]).name!==l){i=!1;continue}n=r.state>h3&&r.state<b3,r.state=Bc,r.timer.stop(),r.on.call(n?"interrupt":"cancel",u,u.__data__,r.index,r.group),delete f[t]}if(i)delete u.__transition}function m5(u){return this.each(function(){P0(this,u)})}function uV(u,l){var f,r;return function(){var n=Jf(this,u),i=n.tween;if(i!==f){r=f=i;for(var t=0,y=r.length;t<y;++t)if(r[t].name===l){r=r.slice(),r.splice(t,1);break}}n.tween=r}}function lV(u,l,f){var r,n;if(typeof f!=="function")throw Error();return function(){var i=Jf(this,u),t=i.tween;if(t!==r){n=(r=t).slice();for(var y={name:l,value:f},c=0,$=n.length;c<$;++c)if(n[c].name===l){n[c]=y;break}if(c===$)n.push(y)}i.tween=n}}function D5(u,l){var f=this._id;if(u+="",arguments.length<2){var r=rf(this.node(),f).tween;for(var n=0,i=r.length,t;n<i;++n)if((t=r[n]).name===u)return t.value;return null}return this.each((l==null?uV:lV)(f,u,l))}function $y(u,l,f){var r=u._id;return u.each(function(){var n=Jf(this,r);(n.value||(n.value={}))[l]=f.apply(this,arguments)}),function(n){return rf(n,r).value[l]}}function mc(u,l){var f;return(typeof l==="number"?Ef:l instanceof dr?hi:(f=dr(l))?(l=f,hi):cy)(u,l)}function fV(u){return function(){this.removeAttribute(u)}}function rV(u){return function(){this.removeAttributeNS(u.space,u.local)}}function nV(u,l,f){var r,n=f+"",i;return function(){var t=this.getAttribute(u);return t===n?null:t===r?i:i=l(r=t,f)}}function iV(u,l,f){var r,n=f+"",i;return function(){var t=this.getAttributeNS(u.space,u.local);return t===n?null:t===r?i:i=l(r=t,f)}}function tV(u,l,f){var r,n,i;return function(){var t,y=f(this),c;if(y==null)return void this.removeAttribute(u);return t=this.getAttribute(u),c=y+"",t===c?null:t===r&&c===n?i:(n=c,i=l(r=t,y))}}function yV(u,l,f){var r,n,i;return function(){var t,y=f(this),c;if(y==null)return void this.removeAttributeNS(u.space,u.local);return t=this.getAttributeNS(u.space,u.local),c=y+"",t===c?null:t===r&&c===n?i:(n=c,i=l(r=t,y))}}function p5(u,l){var f=Un(u),r=f==="transform"?B5:mc;return this.attrTween(u,typeof l==="function"?(f.local?yV:tV)(f,r,$y(this,"attr."+u,l)):l==null?(f.local?rV:fV)(f):(f.local?iV:nV)(f,r,l))}function cV(u,l){return function(f){this.setAttribute(u,l.call(this,f))}}function _V(u,l){return function(f){this.setAttributeNS(u.space,u.local,l.call(this,f))}}function $V(u,l){var f,r;function n(){var i=l.apply(this,arguments);if(i!==r)f=(r=i)&&_V(u,i);return f}return n._value=l,n}function AV(u,l){var f,r;function n(){var i=l.apply(this,arguments);if(i!==r)f=(r=i)&&cV(u,i);return f}return n._value=l,n}function S5(u,l){var f="attr."+u;if(arguments.length<2)return(f=this.tween(f))&&f._value;if(l==null)return this.tween(f,null);if(typeof l!=="function")throw Error();var r=Un(u);return this.tween(f,(r.local?$V:AV)(r,l))}function jV(u,l){return function(){Vc(this,u).delay=+l.apply(this,arguments)}}function FV(u,l){return l=+l,function(){Vc(this,u).delay=l}}function X5(u){var l=this._id;return arguments.length?this.each((typeof u==="function"?jV:FV)(l,u)):rf(this.node(),l).delay}function UV(u,l){return function(){Jf(this,u).duration=+l.apply(this,arguments)}}function JV(u,l){return l=+l,function(){Jf(this,u).duration=l}}function Y5(u){var l=this._id;return arguments.length?this.each((typeof u==="function"?UV:JV)(l,u)):rf(this.node(),l).duration}function QV(u,l){if(typeof l!=="function")throw Error();return function(){Jf(this,u).ease=l}}function P5(u){var l=this._id;return arguments.length?this.each(QV(l,u)):rf(this.node(),l).ease}function NV(u,l){return function(){var f=l.apply(this,arguments);if(typeof f!=="function")throw Error();Jf(this,u).ease=f}}function C5(u){if(typeof u!=="function")throw Error();return this.each(NV(this._id,u))}function M5(u){if(typeof u!=="function")u=ry(u);for(var l=this._groups,f=l.length,r=Array(f),n=0;n<f;++n)for(var i=l[n],t=i.length,y=r[n]=[],c,$=0;$<t;++$)if((c=i[$])&&u.call(c,c.__data__,$,i))y.push(c);return new Pf(r,this._parents,this._name,this._id)}function R5(u){if(u._id!==this._id)throw Error();for(var l=this._groups,f=u._groups,r=l.length,n=f.length,i=Math.min(r,n),t=Array(r),y=0;y<i;++y)for(var c=l[y],$=f[y],A=c.length,j=t[y]=Array(A),F,J=0;J<A;++J)if(F=c[J]||$[J])j[J]=F;for(;y<r;++y)t[y]=l[y];return new Pf(t,this._parents,this._name,this._id)}function qV(u){return(u+"").trim().split(/^|\s+/).every(function(l){var f=l.indexOf(".");if(f>=0)l=l.slice(0,f);return!l||l==="start"})}function wV(u,l,f){var r,n,i=qV(l)?Vc:Jf;return function(){var t=i(this,u),y=t.on;if(y!==r)(n=(r=y).copy()).on(l,f);t.on=n}}function x5(u,l){var f=this._id;return arguments.length<2?rf(this.node(),f).on.on(u):this.each(wV(f,u,l))}function WV(u){return function(){var l=this.parentNode;for(var f in this.__transition)if(+f!==u)return;if(l)l.removeChild(this)}}function h5(){return this.on("end.remove",WV(this._id))}function b5(u){var l=this._name,f=this._id;if(typeof u!=="function")u=X0(u);for(var r=this._groups,n=r.length,i=Array(n),t=0;t<n;++t)for(var y=r[t],c=y.length,$=i[t]=Array(c),A,j,F=0;F<c;++F)if((A=y[F])&&(j=u.call(A,A.__data__,F,y))){if("__data__"in A)j.__data__=A.__data__;$[F]=j,gn($[F],l,f,F,$,rf(A,f))}return new Pf(i,this._parents,l,f)}function v5(u){var l=this._name,f=this._id;if(typeof u!=="function")u=ny(u);for(var r=this._groups,n=r.length,i=[],t=[],y=0;y<n;++y)for(var c=r[y],$=c.length,A,j=0;j<$;++j)if(A=c[j]){for(var F=u.call(A,A.__data__,j,c),J,Q=rf(A,f),W=0,L=F.length;W<L;++W)if(J=F[W])gn(J,l,f,W,F,Q);i.push(F),t.push(A)}return new Pf(i,t,l,f)}var LV=kn.prototype.constructor;function k5(){return new LV(this._groups,this._parents)}function TV(u,l){var f,r,n;return function(){var i=Y0(this,u),t=(this.style.removeProperty(u),Y0(this,u));return i===t?null:i===f&&t===r?n:n=l(f=i,r=t)}}function qq(u){return function(){this.style.removeProperty(u)}}function KV(u,l,f){var r,n=f+"",i;return function(){var t=Y0(this,u);return t===n?null:t===r?i:i=l(r=t,f)}}function GV(u,l,f){var r,n,i;return function(){var t=Y0(this,u),y=f(this),c=y+"";if(y==null)c=y=(this.style.removeProperty(u),Y0(this,u));return t===c?null:t===r&&c===n?i:(n=c,i=l(r=t,y))}}function zV(u,l){var f,r,n,i="style."+l,t="end."+i,y;return function(){var c=Jf(this,u),$=c.on,A=c.value[i]==null?y||(y=qq(l)):void 0;if($!==f||n!==A)(r=(f=$).copy()).on(t,n=A);c.on=r}}function I5(u,l,f){var r=(u+="")==="transform"?H5:mc;return l==null?this.styleTween(u,TV(u,r)).on("end.style."+u,qq(u)):typeof l==="function"?this.styleTween(u,GV(u,r,$y(this,"style."+u,l))).each(zV(this._id,u)):this.styleTween(u,KV(u,r,l),f).on("end.style."+u,null)}function EV(u,l,f){return function(r){this.style.setProperty(u,l.call(this,r),f)}}function OV(u,l,f){var r,n;function i(){var t=l.apply(this,arguments);if(t!==n)r=(n=t)&&EV(u,t,f);return r}return i._value=l,i}function g5(u,l,f){var r="style."+(u+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(l==null)return this.tween(r,null);if(typeof l!=="function")throw Error();return this.tween(r,OV(u,l,f==null?"":f))}function ZV(u){return function(){this.textContent=u}}function HV(u){return function(){var l=u(this);this.textContent=l==null?"":l}}function s5(u){return this.tween("text",typeof u==="function"?HV($y(this,"text",u)):ZV(u==null?"":u+""))}function BV(u){return function(l){this.textContent=u.call(this,l)}}function VV(u){var l,f;function r(){var n=u.apply(this,arguments);if(n!==f)l=(f=n)&&BV(n);return l}return r._value=u,r}function a5(u){var l="text";if(arguments.length<1)return(l=this.tween(l))&&l._value;if(u==null)return this.tween(l,null);if(typeof u!=="function")throw Error();return this.tween(l,VV(u))}function o5(){var u=this._name,l=this._id,f=v3();for(var r=this._groups,n=r.length,i=0;i<n;++i)for(var t=r[i],y=t.length,c,$=0;$<y;++$)if(c=t[$]){var A=rf(c,l);gn(c,u,f,$,t,{time:A.time+A.delay+A.duration,delay:0,duration:A.duration,ease:A.ease})}return new Pf(r,this._parents,u,f)}function d5(){var u,l,f=this,r=f._id,n=f.size();return new Promise(function(i,t){var y={value:t},c={value:function(){if(--n===0)i()}};if(f.each(function(){var $=Jf(this,r),A=$.on;if(A!==u)l=(u=A).copy(),l._.cancel.push(y),l._.interrupt.push(y),l._.end.push(c);$.on=l}),n===0)i()})}var mV=0;function Pf(u,l,f,r){this._groups=u,this._parents=l,this._name=f,this._id=r}function wq(u){return kn().transition(u)}function v3(){return++mV}var sn=kn.prototype;Pf.prototype=wq.prototype={constructor:Pf,select:b5,selectAll:v5,selectChild:sn.selectChild,selectChildren:sn.selectChildren,filter:M5,merge:R5,selection:k5,transition:o5,call:sn.call,nodes:sn.nodes,node:sn.node,size:sn.size,empty:sn.empty,each:sn.each,on:x5,attr:p5,attrTween:S5,style:I5,styleTween:g5,text:s5,textTween:a5,remove:h5,tween:D5,delay:X5,duration:Y5,ease:P5,easeVarying:C5,end:d5,[Symbol.iterator]:sn[Symbol.iterator]};function k3(u){return((u*=2)<=1?u*u*u:(u-=2)*u*u+2)/2}var pV={time:null,delay:0,duration:250,ease:k3};function SV(u,l){var f;while(!(f=u.__transition)||!(f=f[l]))if(!(u=u.parentNode))throw Error(`transition ${l} not found`);return f}function e5(u){var l,f;if(u instanceof Pf)l=u._id,u=u._name;else l=v3(),(f=pV).time=Zc(),u=u==null?null:u+"";for(var r=this._groups,n=r.length,i=0;i<n;++i)for(var t=r[i],y=t.length,c,$=0;$<y;++$)if(c=t[$])gn(c,u,l,$,t,f||SV(c,l));return new Pf(r,this._parents,u,l)}kn.prototype.interrupt=m5;kn.prototype.transition=e5;var Dc=(u)=>()=>u;function u9(u,{sourceEvent:l,target:f,transform:r,dispatch:n}){Object.defineProperties(this,{type:{value:u,enumerable:!0,configurable:!0},sourceEvent:{value:l,enumerable:!0,configurable:!0},target:{value:f,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:n}})}function er(u,l,f){this.k=u,this.x=l,this.y=f}er.prototype={constructor:er,scale:function(u){return u===1?this:new er(this.k*u,this.x,this.y)},translate:function(u,l){return u===0&l===0?this:new er(this.k,this.x+this.k*u,this.y+this.k*l)},apply:function(u){return[u[0]*this.k+this.x,u[1]*this.k+this.y]},applyX:function(u){return u*this.k+this.x},applyY:function(u){return u*this.k+this.y},invert:function(u){return[(u[0]-this.x)/this.k,(u[1]-this.y)/this.k]},invertX:function(u){return(u-this.x)/this.k},invertY:function(u){return(u-this.y)/this.k},rescaleX:function(u){return u.copy().domain(u.range().map(this.invertX,this).map(u.invert,u))},rescaleY:function(u){return u.copy().domain(u.range().map(this.invertY,this).map(u.invert,u))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ki=new er(1,0,0);pc.prototype=er.prototype;function pc(u){while(!u.__zoom)if(!(u=u.parentNode))return ki;return u.__zoom}function lA(u){u.stopImmediatePropagation()}function Ii(u){u.preventDefault(),u.stopImmediatePropagation()}function XV(u){return(!u.ctrlKey||u.type==="wheel")&&!u.button}function YV(){var u=this;if(u instanceof SVGElement){if(u=u.ownerSVGElement||u,u.hasAttribute("viewBox"))return u=u.viewBox.baseVal,[[u.x,u.y],[u.x+u.width,u.y+u.height]];return[[0,0],[u.width.baseVal.value,u.height.baseVal.value]]}return[[0,0],[u.clientWidth,u.clientHeight]]}function Wq(){return this.__zoom||ki}function PV(u){return-u.deltaY*(u.deltaMode===1?0.05:u.deltaMode?1:0.002)*(u.ctrlKey?10:1)}function CV(){return navigator.maxTouchPoints||"ontouchstart"in this}function MV(u,l,f){var r=u.invertX(l[0][0])-f[0][0],n=u.invertX(l[1][0])-f[1][0],i=u.invertY(l[0][1])-f[0][1],t=u.invertY(l[1][1])-f[1][1];return u.translate(n>r?(r+n)/2:Math.min(0,r)||Math.max(0,n),t>i?(i+t)/2:Math.min(0,i)||Math.max(0,t))}function Sc(){var u=XV,l=YV,f=MV,r=PV,n=CV,i=[0,1/0],t=[[-1/0,-1/0],[1/0,1/0]],y=250,c=bi,$=Ci("start","zoom","end"),A,j,F,J=500,Q=150,W=0,L=10;function U(O){O.property("__zoom",Wq).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",m).on("dblclick.zoom",S).filter(n).on("touchstart.zoom",B).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}U.transform=function(O,Y,p,v){var z=O.selection?O.selection():O;if(z.property("__zoom",Wq),O!==z)G(O,Y,p,v);else z.interrupt().each(function(){Z(this,arguments).event(v).start().zoom(null,typeof Y==="function"?Y.apply(this,arguments):Y).end()})},U.scaleBy=function(O,Y,p,v){U.scaleTo(O,function(){var z=this.__zoom.k,P=typeof Y==="function"?Y.apply(this,arguments):Y;return z*P},p,v)},U.scaleTo=function(O,Y,p,v){U.transform(O,function(){var z=l.apply(this,arguments),P=this.__zoom,k=p==null?w(z):typeof p==="function"?p.apply(this,arguments):p,I=P.invert(k),b=typeof Y==="function"?Y.apply(this,arguments):Y;return f(N(q(P,b),k,I),z,t)},p,v)},U.translateBy=function(O,Y,p,v){U.transform(O,function(){return f(this.__zoom.translate(typeof Y==="function"?Y.apply(this,arguments):Y,typeof p==="function"?p.apply(this,arguments):p),l.apply(this,arguments),t)},null,v)},U.translateTo=function(O,Y,p,v,z){U.transform(O,function(){var P=l.apply(this,arguments),k=this.__zoom,I=v==null?w(P):typeof v==="function"?v.apply(this,arguments):v;return f(ki.translate(I[0],I[1]).scale(k.k).translate(typeof Y==="function"?-Y.apply(this,arguments):-Y,typeof p==="function"?-p.apply(this,arguments):-p),P,t)},v,z)};function q(O,Y){return Y=Math.max(i[0],Math.min(i[1],Y)),Y===O.k?O:new er(Y,O.x,O.y)}function N(O,Y,p){var v=Y[0]-p[0]*O.k,z=Y[1]-p[1]*O.k;return v===O.x&&z===O.y?O:new er(O.k,v,z)}function w(O){return[(+O[0][0]+ +O[1][0])/2,(+O[0][1]+ +O[1][1])/2]}function G(O,Y,p,v){O.on("start.zoom",function(){Z(this,arguments).event(v).start()}).on("interrupt.zoom end.zoom",function(){Z(this,arguments).event(v).end()}).tween("zoom",function(){var z=this,P=arguments,k=Z(z,P).event(v),I=l.apply(z,P),b=p==null?w(I):typeof p==="function"?p.apply(z,P):p,d=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),s=z.__zoom,h=typeof Y==="function"?Y.apply(z,P):Y,lu=c(s.invert(b).concat(d/s.k),h.invert(b).concat(d/h.k));return function(cu){if(cu===1)cu=h;else{var _u=lu(cu),Fu=d/_u[2];cu=new er(Fu,b[0]-_u[0]*Fu,b[1]-_u[1]*Fu)}k.zoom(null,cu)}})}function Z(O,Y,p){return!p&&O.__zooming||new H(O,Y)}function H(O,Y){this.that=O,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=l.apply(O,Y),this.taps=0}H.prototype={event:function(O){if(O)this.sourceEvent=O;return this},start:function(){if(++this.active===1)this.that.__zooming=this,this.emit("start");return this},zoom:function(O,Y){if(this.mouse&&O!=="mouse")this.mouse[1]=Y.invert(this.mouse[0]);if(this.touch0&&O!=="touch")this.touch0[1]=Y.invert(this.touch0[0]);if(this.touch1&&O!=="touch")this.touch1[1]=Y.invert(this.touch1[0]);return this.that.__zoom=Y,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(O){var Y=ff(this.that).datum();$.call(O,this.that,new u9(O,{sourceEvent:this.sourceEvent,target:U,type:O,transform:this.that.__zoom,dispatch:$}),Y)}};function E(O,...Y){if(!u.apply(this,arguments))return;var p=Z(this,Y).event(O),v=this.__zoom,z=Math.max(i[0],Math.min(i[1],v.k*Math.pow(2,r.apply(this,arguments)))),P=zf(O);if(p.wheel){if(p.mouse[0][0]!==P[0]||p.mouse[0][1]!==P[1])p.mouse[1]=v.invert(p.mouse[0]=P);clearTimeout(p.wheel)}else if(v.k===z)return;else p.mouse=[P,v.invert(P)],P0(this),p.start();Ii(O),p.wheel=setTimeout(k,Q),p.zoom("mouse",f(N(q(v,z),p.mouse[0],p.mouse[1]),p.extent,t));function k(){p.wheel=null,p.end()}}function m(O,...Y){if(F||!u.apply(this,arguments))return;var p=O.currentTarget,v=Z(this,Y,!0).event(O),z=ff(O.view).on("mousemove.zoom",b,!0).on("mouseup.zoom",d,!0),P=zf(O,p),k=O.clientX,I=O.clientY;iy(O.view),lA(O),v.mouse=[P,this.__zoom.invert(P)],P0(this),v.start();function b(s){if(Ii(s),!v.moved){var h=s.clientX-k,lu=s.clientY-I;v.moved=h*h+lu*lu>W}v.event(s).zoom("mouse",f(N(v.that.__zoom,v.mouse[0]=zf(s,p),v.mouse[1]),v.extent,t))}function d(s){z.on("mousemove.zoom mouseup.zoom",null),Uc(s.view,v.moved),Ii(s),v.event(s).end()}}function S(O,...Y){if(!u.apply(this,arguments))return;var p=this.__zoom,v=zf(O.changedTouches?O.changedTouches[0]:O,this),z=p.invert(v),P=p.k*(O.shiftKey?0.5:2),k=f(N(q(p,P),v,z),l.apply(this,Y),t);if(Ii(O),y>0)ff(this).transition().duration(y).call(G,k,v,O);else ff(this).call(U.transform,k,v,O)}function B(O,...Y){if(!u.apply(this,arguments))return;var p=O.touches,v=p.length,z=Z(this,Y,O.changedTouches.length===v).event(O),P,k,I,b;lA(O);for(k=0;k<v;++k)if(I=p[k],b=zf(I,this),b=[b,this.__zoom.invert(b),I.identifier],!z.touch0)z.touch0=b,P=!0,z.taps=1+!!A;else if(!z.touch1&&z.touch0[2]!==b[2])z.touch1=b,z.taps=0;if(A)A=clearTimeout(A);if(P){if(z.taps<2)j=b[0],A=setTimeout(function(){A=null},J);P0(this),z.start()}}function D(O,...Y){if(!this.__zooming)return;var p=Z(this,Y).event(O),v=O.changedTouches,z=v.length,P,k,I,b;Ii(O);for(P=0;P<z;++P)if(k=v[P],I=zf(k,this),p.touch0&&p.touch0[2]===k.identifier)p.touch0[0]=I;else if(p.touch1&&p.touch1[2]===k.identifier)p.touch1[0]=I;if(k=p.that.__zoom,p.touch1){var d=p.touch0[0],s=p.touch0[1],h=p.touch1[0],lu=p.touch1[1],cu=(cu=h[0]-d[0])*cu+(cu=h[1]-d[1])*cu,_u=(_u=lu[0]-s[0])*_u+(_u=lu[1]-s[1])*_u;k=q(k,Math.sqrt(cu/_u)),I=[(d[0]+h[0])/2,(d[1]+h[1])/2],b=[(s[0]+lu[0])/2,(s[1]+lu[1])/2]}else if(p.touch0)I=p.touch0[0],b=p.touch0[1];else return;p.zoom("touch",f(N(k,I,b),p.extent,t))}function X(O,...Y){if(!this.__zooming)return;var p=Z(this,Y).event(O),v=O.changedTouches,z=v.length,P,k;if(lA(O),F)clearTimeout(F);F=setTimeout(function(){F=null},J);for(P=0;P<z;++P)if(k=v[P],p.touch0&&p.touch0[2]===k.identifier)delete p.touch0;else if(p.touch1&&p.touch1[2]===k.identifier)delete p.touch1;if(p.touch1&&!p.touch0)p.touch0=p.touch1,delete p.touch1;if(p.touch0)p.touch0[1]=this.__zoom.invert(p.touch0[0]);else if(p.end(),p.taps===2){if(k=zf(k,this),Math.hypot(j[0]-k[0],j[1]-k[1])<L){var I=ff(this).on("dblclick.zoom");if(I)I.apply(this,arguments)}}}return U.wheelDelta=function(O){return arguments.length?(r=typeof O==="function"?O:Dc(+O),U):r},U.filter=function(O){return arguments.length?(u=typeof O==="function"?O:Dc(!!O),U):u},U.touchable=function(O){return arguments.length?(n=typeof O==="function"?O:Dc(!!O),U):n},U.extent=function(O){return arguments.length?(l=typeof O==="function"?O:Dc([[+O[0][0],+O[0][1]],[+O[1][0],+O[1][1]]]),U):l},U.scaleExtent=function(O){return arguments.length?(i[0]=+O[0],i[1]=+O[1],U):[i[0],i[1]]},U.translateExtent=function(O){return arguments.length?(t[0][0]=+O[0][0],t[1][0]=+O[1][0],t[0][1]=+O[0][1],t[1][1]=+O[1][1],U):[[t[0][0],t[0][1]],[t[1][0],t[1][1]]]},U.constrain=function(O){return arguments.length?(f=O,U):f},U.duration=function(O){return arguments.length?(y=+O,U):y},U.interpolate=function(O){return arguments.length?(c=O,U):c},U.on=function(){var O=$.on.apply($,arguments);return O===$?U:O},U.clickDistance=function(O){return arguments.length?(W=(O=+O)*O,U):Math.sqrt(W)},U.tapDistance=function(O){return arguments.length?(L=+O,U):L},U}var Jr={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:(u)=>`Node type "${u}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:(u)=>`The old edge with id=${u} does not exist.`,error009:(u)=>`Marker type "${u}" doesn't exist.`,error008:(u,{id:l,sourceHandle:f,targetHandle:r})=>`Couldn't create edge for ${u} handle id: "${u==="source"?f:r}", edge id: ${l}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:(u)=>`Edge type "${u}" not found. Using fallback type "default".`,error012:(u)=>`Node with id "${u}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(u="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${u}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Jy=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],i9=["Enter"," ","Escape"],t9={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:u,x:l,y:f})=>`Moved selected node ${u}. New position, x: ${l}, y: ${f}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"},R0;(function(u){u.Strict="strict",u.Loose="loose"})(R0||(R0={}));var an;(function(u){u.Free="free",u.Vertical="vertical",u.Horizontal="horizontal"})(an||(an={}));var gi;(function(u){u.Partial="partial",u.Full="full"})(gi||(gi={}));var y9={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},Nn;(function(u){u.Bezier="default",u.Straight="straight",u.Step="step",u.SmoothStep="smoothstep",u.SimpleBezier="simplebezier"})(Nn||(Nn={}));var x0;(function(u){u.Arrow="arrow",u.ArrowClosed="arrowclosed"})(x0||(x0={}));var Ku;(function(u){u.Left="left",u.Top="top",u.Right="right",u.Bottom="bottom"})(Ku||(Ku={}));var Lq={[Ku.Left]:Ku.Right,[Ku.Right]:Ku.Left,[Ku.Top]:Ku.Bottom,[Ku.Bottom]:Ku.Top};function c9(u){return u===null?null:u?"valid":"invalid"}var _9=(u)=>("id"in u)&&("source"in u)&&("target"in u),pq=(u)=>("id"in u)&&("position"in u)&&!("source"in u)&&!("target"in u),$9=(u)=>("id"in u)&&("internals"in u)&&!("source"in u)&&!("target"in u);var Pc=(u,l=[0,0])=>{let{width:f,height:r}=qn(u),n=u.origin??l,i=f*n[0],t=r*n[1];return{x:u.position.x-i,y:u.position.y-t}},A9=(u,l={nodeOrigin:[0,0]})=>{if(u.length===0)return{x:0,y:0,width:0,height:0};let f=u.reduce((r,n)=>{let i=typeof n==="string",t=!l.nodeLookup&&!i?n:void 0;if(l.nodeLookup)t=i?l.nodeLookup.get(n):!$9(n)?l.nodeLookup.get(n.id):n;let y=t?nA(t,l.nodeOrigin):{x:0,y:0,x2:0,y2:0};return tA(r,y)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return yA(f)},Qy=(u,l={})=>{let f={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return u.forEach((n)=>{if(l.filter===void 0||l.filter(n))f=tA(f,nA(n)),r=!0}),r?yA(f):{x:0,y:0,width:0,height:0}},iA=(u,l,[f,r,n]=[0,0,1],i=!1,t=!1)=>{let y={...wy(l,[f,r,n]),width:l.width/n,height:l.height/n},c=[];for(let $ of u.values()){let{measured:A,selectable:j=!0,hidden:F=!1}=$;if(t&&!j||F)continue;let J=A.width??$.width??$.initialWidth??null,Q=A.height??$.height??$.initialHeight??null,W=Ny(y,ai($)),L=(J??0)*(Q??0),U=i&&W>0;if(!$.internals.handleBounds||U||W>=L||$.dragging)c.push($)}return c},Sq=(u,l)=>{let f=new Set;return u.forEach((r)=>{f.add(r.id)}),l.filter((r)=>f.has(r.source)||f.has(r.target))};function RV(u,l){let f=new Map,r=l?.nodes?new Set(l.nodes.map((n)=>n.id)):null;return u.forEach((n)=>{if(n.measured.width&&n.measured.height&&(l?.includeHiddenNodes||!n.hidden)&&(!r||r.has(n.id)))f.set(n.id,n)}),f}async function Xq({nodes:u,width:l,height:f,panZoom:r,minZoom:n,maxZoom:i},t){if(u.size===0)return Promise.resolve(!0);let y=RV(u,t),c=Qy(y),$=Cc(c,l,f,t?.minZoom??n,t?.maxZoom??i,t?.padding??0.1);return await r.setViewport($,{duration:t?.duration,ease:t?.ease,interpolate:t?.interpolate}),Promise.resolve(!0)}function j9({nodeId:u,nextPosition:l,nodeLookup:f,nodeOrigin:r=[0,0],nodeExtent:n,onError:i}){let t=f.get(u),y=t.parentId?f.get(t.parentId):void 0,{x:c,y:$}=y?y.internals.positionAbsolute:{x:0,y:0},A=t.origin??r,j=t.extent||n;if(t.extent==="parent"&&!t.expandParent)if(!y)i?.("005",Jr.error005());else{let J=y.measured.width,Q=y.measured.height;if(J&&Q)j=[[c,$],[c+J,$+Q]]}else if(y&&Uy(t.extent))j=[[t.extent[0][0]+c,t.extent[0][1]+$],[t.extent[1][0]+c,t.extent[1][1]+$]];let F=Uy(j)?si(l,j,t.measured):l;if(t.measured.width===void 0||t.measured.height===void 0)i?.("015",Jr.error015());return{position:{x:F.x-c+(t.measured.width??0)*A[0],y:F.y-$+(t.measured.height??0)*A[1]},positionAbsolute:F}}async function Yq({nodesToRemove:u=[],edgesToRemove:l=[],nodes:f,edges:r,onBeforeDelete:n}){let i=new Set(u.map((F)=>F.id)),t=[];for(let F of f){if(F.deletable===!1)continue;let J=i.has(F.id),Q=!J&&F.parentId&&t.find((W)=>W.id===F.parentId);if(J||Q)t.push(F)}let y=new Set(l.map((F)=>F.id)),c=r.filter((F)=>F.deletable!==!1),A=Sq(t,c);for(let F of c)if(y.has(F.id)&&!A.find((Q)=>Q.id===F.id))A.push(F);if(!n)return{edges:A,nodes:t};let j=await n({nodes:t,edges:A});if(typeof j==="boolean")return j?{edges:A,nodes:t}:{edges:[],nodes:[]};return j}var Fy=(u,l=0,f=1)=>Math.min(Math.max(u,l),f),si=(u={x:0,y:0},l,f)=>({x:Fy(u.x,l[0][0],l[1][0]-(f?.width??0)),y:Fy(u.y,l[0][1],l[1][1]-(f?.height??0))});function Pq(u,l,f){let{width:r,height:n}=qn(f),{x:i,y:t}=f.internals.positionAbsolute;return si(u,[[i,t],[i+r,t+n]],l)}var Tq=(u,l,f)=>{if(u<l)return Fy(Math.abs(u-l),1,l)/l;else if(u>f)return-Fy(Math.abs(u-f),1,l)/l;return 0},Cq=(u,l,f=15,r=40)=>{let n=Tq(u.x,r,l.width-r)*f,i=Tq(u.y,r,l.height-r)*f;return[n,i]},tA=(u,l)=>({x:Math.min(u.x,l.x),y:Math.min(u.y,l.y),x2:Math.max(u.x2,l.x2),y2:Math.max(u.y2,l.y2)}),n9=({x:u,y:l,width:f,height:r})=>({x:u,y:l,x2:u+f,y2:l+r}),yA=({x:u,y:l,x2:f,y2:r})=>({x:u,y:l,width:f-u,height:r-l}),ai=(u,l=[0,0])=>{let{x:f,y:r}=$9(u)?u.internals.positionAbsolute:Pc(u,l);return{x:f,y:r,width:u.measured?.width??u.width??u.initialWidth??0,height:u.measured?.height??u.height??u.initialHeight??0}},nA=(u,l=[0,0])=>{let{x:f,y:r}=$9(u)?u.internals.positionAbsolute:Pc(u,l);return{x:f,y:r,x2:f+(u.measured?.width??u.width??u.initialWidth??0),y2:r+(u.measured?.height??u.height??u.initialHeight??0)}},F9=(u,l)=>yA(tA(n9(u),n9(l))),Ny=(u,l)=>{let f=Math.max(0,Math.min(u.x+u.width,l.x+l.width)-Math.max(u.x,l.x)),r=Math.max(0,Math.min(u.y+u.height,l.y+l.height)-Math.max(u.y,l.y));return Math.ceil(f*r)},U9=(u)=>Hr(u.width)&&Hr(u.height)&&Hr(u.x)&&Hr(u.y),Hr=(u)=>!isNaN(u)&&isFinite(u),J9=(u,l)=>{},qy=(u,l=[1,1])=>{return{x:l[0]*Math.round(u.x/l[0]),y:l[1]*Math.round(u.y/l[1])}},wy=({x:u,y:l},[f,r,n],i=!1,t=[1,1])=>{let y={x:(u-f)/n,y:(l-r)/n};return i?qy(y,t):y},Yc=({x:u,y:l},[f,r,n])=>{return{x:u*n+f,y:l*n+r}};function Ay(u,l){if(typeof u==="number")return Math.floor((l-l/(1+u))*0.5);if(typeof u==="string"&&u.endsWith("px")){let f=parseFloat(u);if(!Number.isNaN(f))return Math.floor(f)}if(typeof u==="string"&&u.endsWith("%")){let f=parseFloat(u);if(!Number.isNaN(f))return Math.floor(l*f*0.01)}return console.error(`[React Flow] The padding value "${u}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function xV(u,l,f){if(typeof u==="string"||typeof u==="number"){let r=Ay(u,f),n=Ay(u,l);return{top:r,right:n,bottom:r,left:n,x:n*2,y:r*2}}if(typeof u==="object"){let r=Ay(u.top??u.y??0,f),n=Ay(u.bottom??u.y??0,f),i=Ay(u.left??u.x??0,l),t=Ay(u.right??u.x??0,l);return{top:r,right:t,bottom:n,left:i,x:i+t,y:r+n}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function hV(u,l,f,r,n,i){let{x:t,y}=Yc(u,[l,f,r]),{x:c,y:$}=Yc({x:u.x+u.width,y:u.y+u.height},[l,f,r]),A=n-c,j=i-$;return{left:Math.floor(t),top:Math.floor(y),right:Math.floor(A),bottom:Math.floor(j)}}var Cc=(u,l,f,r,n,i)=>{let t=xV(i,l,f),y=(l-t.x)/u.width,c=(f-t.y)/u.height,$=Math.min(y,c),A=Fy($,r,n),j=u.x+u.width/2,F=u.y+u.height/2,J=l/2-j*A,Q=f/2-F*A,W=hV(u,J,Q,A,l,f),L={left:Math.min(W.left-t.left,0),top:Math.min(W.top-t.top,0),right:Math.min(W.right-t.right,0),bottom:Math.min(W.bottom-t.bottom,0)};return{x:J-L.left+L.right,y:Q-L.top+L.bottom,zoom:A}},Wy=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Uy(u){return u!==void 0&&u!==null&&u!=="parent"}function qn(u){return{width:u.measured?.width??u.width??u.initialWidth??0,height:u.measured?.height??u.height??u.initialHeight??0}}function Q9(u){return(u.measured?.width??u.width??u.initialWidth)!==void 0&&(u.measured?.height??u.height??u.initialHeight)!==void 0}function N9(u,l={width:0,height:0},f,r,n){let i={...u},t=r.get(f);if(t){let y=t.origin||n;i.x+=t.internals.positionAbsolute.x-(l.width??0)*y[0],i.y+=t.internals.positionAbsolute.y-(l.height??0)*y[1]}return i}function q9(u,l){if(u.size!==l.size)return!1;for(let f of u)if(!l.has(f))return!1;return!0}function Mq(){let u,l;return{promise:new Promise((r,n)=>{u=r,l=n}),resolve:u,reject:l}}function Rq(u){return{...t9,...u||{}}}function Xc(u,{snapGrid:l=[0,0],snapToGrid:f=!1,transform:r,containerBounds:n}){let{x:i,y:t}=Br(u),y=wy({x:i-(n?.left??0),y:t-(n?.top??0)},r),{x:c,y:$}=f?qy(y,l):y;return{xSnapped:c,ySnapped:$,...y}}var cA=(u)=>({width:u.offsetWidth,height:u.offsetHeight}),w9=(u)=>u?.getRootNode?.()||window?.document,bV=["INPUT","SELECT","TEXTAREA"];function W9(u){let l=u.composedPath?.()?.[0]||u.target;if(l?.nodeType!==1)return!1;return bV.includes(l.nodeName)||l.hasAttribute("contenteditable")||!!l.closest(".nokey")}var L9=(u)=>("clientX"in u),Br=(u,l)=>{let f=L9(u),r=f?u.clientX:u.touches?.[0].clientX,n=f?u.clientY:u.touches?.[0].clientY;return{x:r-(l?.left??0),y:n-(l?.top??0)}},Kq=(u,l,f,r,n)=>{let i=l.querySelectorAll(`.${u}`);if(!i||!i.length)return null;return Array.from(i).map((t)=>{let y=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:u,nodeId:n,position:t.getAttribute("data-handlepos"),x:(y.left-f.left)/r,y:(y.top-f.top)/r,...cA(t)}})};function _A({sourceX:u,sourceY:l,targetX:f,targetY:r,sourceControlX:n,sourceControlY:i,targetControlX:t,targetControlY:y}){let c=u*0.125+n*0.375+t*0.375+f*0.125,$=l*0.125+i*0.375+y*0.375+r*0.125,A=Math.abs(c-u),j=Math.abs($-l);return[c,$,A,j]}function fA(u,l){if(u>=0)return 0.5*u;return l*25*Math.sqrt(-u)}function Gq({pos:u,x1:l,y1:f,x2:r,y2:n,c:i}){switch(u){case Ku.Left:return[l-fA(l-r,i),f];case Ku.Right:return[l+fA(r-l,i),f];case Ku.Top:return[l,f-fA(f-n,i)];case Ku.Bottom:return[l,f+fA(n-f,i)]}}function $A({sourceX:u,sourceY:l,sourcePosition:f=Ku.Bottom,targetX:r,targetY:n,targetPosition:i=Ku.Top,curvature:t=0.25}){let[y,c]=Gq({pos:f,x1:u,y1:l,x2:r,y2:n,c:t}),[$,A]=Gq({pos:i,x1:r,y1:n,x2:u,y2:l,c:t}),[j,F,J,Q]=_A({sourceX:u,sourceY:l,targetX:r,targetY:n,sourceControlX:y,sourceControlY:c,targetControlX:$,targetControlY:A});return[`M${u},${l} C${y},${c} ${$},${A} ${r},${n}`,j,F,J,Q]}function T9({sourceX:u,sourceY:l,targetX:f,targetY:r}){let n=Math.abs(f-u)/2,i=f<u?f+n:f-n,t=Math.abs(r-l)/2,y=r<l?r+t:r-t;return[i,y,n,t]}function xq({sourceNode:u,targetNode:l,selected:f=!1,zIndex:r=0,elevateOnSelect:n=!1,zIndexMode:i="basic"}){if(i==="manual")return r;let t=n&&f?r+1000:r,y=Math.max(u.parentId||n&&u.selected?u.internals.z:0,l.parentId||n&&l.selected?l.internals.z:0);return t+y}function hq({sourceNode:u,targetNode:l,width:f,height:r,transform:n}){let i=tA(nA(u),nA(l));if(i.x===i.x2)i.x2+=1;if(i.y===i.y2)i.y2+=1;let t={x:-n[0]/n[2],y:-n[1]/n[2],width:f/n[2],height:r/n[2]};return Ny(t,yA(i))>0}var vV=({source:u,sourceHandle:l,target:f,targetHandle:r})=>`xy-edge__${u}${l||""}-${f}${r||""}`,kV=(u,l)=>{return l.some((f)=>f.source===u.source&&f.target===u.target&&(f.sourceHandle===u.sourceHandle||!f.sourceHandle&&!u.sourceHandle)&&(f.targetHandle===u.targetHandle||!f.targetHandle&&!u.targetHandle))},K9=(u,l,f={})=>{if(!u.source||!u.target)return J9("006",Jr.error006()),l;let r=f.getEdgeId||vV,n;if(_9(u))n={...u};else n={...u,id:r(u)};if(kV(n,l))return l;if(n.sourceHandle===null)delete n.sourceHandle;if(n.targetHandle===null)delete n.targetHandle;return l.concat(n)};function AA({sourceX:u,sourceY:l,targetX:f,targetY:r}){let[n,i,t,y]=T9({sourceX:u,sourceY:l,targetX:f,targetY:r});return[`M ${u},${l}L ${f},${r}`,n,i,t,y]}var zq={[Ku.Left]:{x:-1,y:0},[Ku.Right]:{x:1,y:0},[Ku.Top]:{x:0,y:-1},[Ku.Bottom]:{x:0,y:1}},IV=({source:u,sourcePosition:l=Ku.Bottom,target:f})=>{if(l===Ku.Left||l===Ku.Right)return u.x<f.x?{x:1,y:0}:{x:-1,y:0};return u.y<f.y?{x:0,y:1}:{x:0,y:-1}},Eq=(u,l)=>Math.sqrt(Math.pow(l.x-u.x,2)+Math.pow(l.y-u.y,2));function gV({source:u,sourcePosition:l=Ku.Bottom,target:f,targetPosition:r=Ku.Top,center:n,offset:i,stepPosition:t}){let y=zq[l],c=zq[r],$={x:u.x+y.x*i,y:u.y+y.y*i},A={x:f.x+c.x*i,y:f.y+c.y*i},j=IV({source:$,sourcePosition:l,target:A}),F=j.x!==0?"x":"y",J=j[F],Q=[],W,L,U={x:0,y:0},q={x:0,y:0},[,,N,w]=T9({sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y});if(y[F]*c[F]===-1){if(F==="x")W=n.x??$.x+(A.x-$.x)*t,L=n.y??($.y+A.y)/2;else W=n.x??($.x+A.x)/2,L=n.y??$.y+(A.y-$.y)*t;let E=[{x:W,y:$.y},{x:W,y:A.y}],m=[{x:$.x,y:L},{x:A.x,y:L}];if(y[F]===J)Q=F==="x"?E:m;else Q=F==="x"?m:E}else{let E=[{x:$.x,y:A.y}],m=[{x:A.x,y:$.y}];if(F==="x")Q=y.x===J?m:E;else Q=y.y===J?E:m;if(l===r){let O=Math.abs(u[F]-f[F]);if(O<=i){let Y=Math.min(i-1,i-O);if(y[F]===J)U[F]=($[F]>u[F]?-1:1)*Y;else q[F]=(A[F]>f[F]?-1:1)*Y}}if(l!==r){let O=F==="x"?"y":"x",Y=y[F]===c[O],p=$[O]>A[O],v=$[O]<A[O];if(y[F]===1&&(!Y&&p||Y&&v)||y[F]!==1&&(!Y&&v||Y&&p))Q=F==="x"?E:m}let S={x:$.x+U.x,y:$.y+U.y},B={x:A.x+q.x,y:A.y+q.y},D=Math.max(Math.abs(S.x-Q[0].x),Math.abs(B.x-Q[0].x)),X=Math.max(Math.abs(S.y-Q[0].y),Math.abs(B.y-Q[0].y));if(D>=X)W=(S.x+B.x)/2,L=Q[0].y;else W=Q[0].x,L=(S.y+B.y)/2}let G={x:$.x+U.x,y:$.y+U.y},Z={x:A.x+q.x,y:A.y+q.y};return[[u,...G.x!==Q[0].x||G.y!==Q[0].y?[G]:[],...Q,...Z.x!==Q[Q.length-1].x||Z.y!==Q[Q.length-1].y?[Z]:[],f],W,L,N,w]}function sV(u,l,f,r){let n=Math.min(Eq(u,l)/2,Eq(l,f)/2,r),{x:i,y:t}=l;if(u.x===i&&i===f.x||u.y===t&&t===f.y)return`L${i} ${t}`;if(u.y===t){let $=u.x<f.x?-1:1,A=u.y<f.y?1:-1;return`L ${i+n*$},${t}Q ${i},${t} ${i},${t+n*A}`}let y=u.x<f.x?1:-1,c=u.y<f.y?-1:1;return`L ${i},${t+n*c}Q ${i},${t} ${i+n*y},${t}`}function Mc({sourceX:u,sourceY:l,sourcePosition:f=Ku.Bottom,targetX:r,targetY:n,targetPosition:i=Ku.Top,borderRadius:t=5,centerX:y,centerY:c,offset:$=20,stepPosition:A=0.5}){let[j,F,J,Q,W]=gV({source:{x:u,y:l},sourcePosition:f,target:{x:r,y:n},targetPosition:i,center:{x:y,y:c},offset:$,stepPosition:A}),L=`M${j[0].x} ${j[0].y}`;for(let U=1;U<j.length-1;U++)L+=sV(j[U-1],j[U],j[U+1],t);return L+=`L${j[j.length-1].x} ${j[j.length-1].y}`,[L,F,J,Q,W]}function Oq(u){return u&&!!(u.internals.handleBounds||u.handles?.length)&&!!(u.measured.width||u.width||u.initialWidth)}function bq(u){let{sourceNode:l,targetNode:f}=u;if(!Oq(l)||!Oq(f))return null;let r=l.internals.handleBounds||Zq(l.handles),n=f.internals.handleBounds||Zq(f.handles),i=Hq(r?.source??[],u.sourceHandle),t=Hq(u.connectionMode===R0.Strict?n?.target??[]:(n?.target??[]).concat(n?.source??[]),u.targetHandle);if(!i||!t)return u.onError?.("008",Jr.error008(!i?"source":"target",{id:u.id,sourceHandle:u.sourceHandle,targetHandle:u.targetHandle})),null;let y=i?.position||Ku.Bottom,c=t?.position||Ku.Top,$=h0(l,i,y),A=h0(f,t,c);return{sourceX:$.x,sourceY:$.y,targetX:A.x,targetY:A.y,sourcePosition:y,targetPosition:c}}function Zq(u){if(!u)return null;let l=[],f=[];for(let r of u)if(r.width=r.width??1,r.height=r.height??1,r.type==="source")l.push(r);else if(r.type==="target")f.push(r);return{source:l,target:f}}function h0(u,l,f=Ku.Left,r=!1){let n=(l?.x??0)+u.internals.positionAbsolute.x,i=(l?.y??0)+u.internals.positionAbsolute.y,{width:t,height:y}=l??qn(u);if(r)return{x:n+t/2,y:i+y/2};switch(l?.position??f){case Ku.Top:return{x:n+t/2,y:i};case Ku.Right:return{x:n+t,y:i+y/2};case Ku.Bottom:return{x:n+t/2,y:i+y};case Ku.Left:return{x:n,y:i+y/2}}}function Hq(u,l){if(!u)return null;return(!l?u[0]:u.find((f)=>f.id===l))||null}function jA(u,l){if(!u)return"";if(typeof u==="string")return u;return`${l?`${l}__`:""}${Object.keys(u).sort().map((r)=>`${r}=${u[r]}`).join("&")}`}function vq(u,{id:l,defaultColor:f,defaultMarkerStart:r,defaultMarkerEnd:n}){let i=new Set;return u.reduce((t,y)=>{return[y.markerStart||r,y.markerEnd||n].forEach((c)=>{if(c&&typeof c==="object"){let $=jA(c,l);if(!i.has($))t.push({id:$,color:c.color||f,...c}),i.add($)}}),t},[]).sort((t,y)=>t.id.localeCompare(y.id))}var kq=1000,aV=10,G9={nodeOrigin:[0,0],nodeExtent:Jy,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oV={...G9,checkEquality:!0};function z9(u,l){let f={...u};for(let r in l)if(l[r]!==void 0)f[r]=l[r];return f}function Iq(u,l,f){let r=z9(G9,f);for(let n of u.values())if(n.parentId)O9(n,u,l,r);else{let i=Pc(n,r.nodeOrigin),t=Uy(n.extent)?n.extent:r.nodeExtent,y=si(i,t,qn(n));n.internals.positionAbsolute=y}}function dV(u,l){if(!u.handles)return!u.measured?void 0:l?.internals.handleBounds;let f=[],r=[];for(let n of u.handles){let i={id:n.id,width:n.width??1,height:n.height??1,nodeId:u.id,x:n.x,y:n.y,position:n.position,type:n.type};if(n.type==="source")f.push(i);else if(n.type==="target")r.push(i)}return{source:f,target:r}}function E9(u){return u==="manual"}function FA(u,l,f,r={}){let n=z9(oV,r),i={i:0},t=new Map(l),y=n?.elevateNodesOnSelect&&!E9(n.zIndexMode)?kq:0,c=u.length>0,$=!1;l.clear(),f.clear();for(let A of u){let j=t.get(A.id);if(n.checkEquality&&A===j?.internals.userNode)l.set(A.id,j);else{let F=Pc(A,n.nodeOrigin),J=Uy(A.extent)?A.extent:n.nodeExtent,Q=si(F,J,qn(A));j={...n.defaults,...A,measured:{width:A.measured?.width,height:A.measured?.height},internals:{positionAbsolute:Q,handleBounds:dV(A,j),z:gq(A,y,n.zIndexMode),userNode:A}},l.set(A.id,j)}if((j.measured===void 0||j.measured.width===void 0||j.measured.height===void 0)&&!j.hidden)c=!1;if(A.parentId)O9(j,l,f,r,i);$||=A.selected??!1}return{nodesInitialized:c,hasSelectedNodes:$}}function eV(u,l){if(!u.parentId)return;let f=l.get(u.parentId);if(f)f.set(u.id,u);else l.set(u.parentId,new Map([[u.id,u]]))}function O9(u,l,f,r,n){let{elevateNodesOnSelect:i,nodeOrigin:t,nodeExtent:y,zIndexMode:c}=z9(G9,r),$=u.parentId,A=l.get($);if(!A){console.warn(`Parent node ${$} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}if(eV(u,f),n&&!A.parentId&&A.internals.rootParentIndex===void 0&&c==="auto")A.internals.rootParentIndex=++n.i,A.internals.z=A.internals.z+n.i*aV;if(n&&A.internals.rootParentIndex!==void 0)n.i=A.internals.rootParentIndex;let j=i&&!E9(c)?kq:0,{x:F,y:J,z:Q}=um(u,A,t,y,j,c),{positionAbsolute:W}=u.internals,L=F!==W.x||J!==W.y;if(L||Q!==u.internals.z)l.set(u.id,{...u,internals:{...u.internals,positionAbsolute:L?{x:F,y:J}:W,z:Q}})}function gq(u,l,f){let r=Hr(u.zIndex)?u.zIndex:0;if(E9(f))return r;return r+(u.selected?l:0)}function um(u,l,f,r,n,i){let{x:t,y}=l.internals.positionAbsolute,c=qn(u),$=Pc(u,f),A=Uy(u.extent)?si($,u.extent,c):$,j=si({x:t+A.x,y:y+A.y},r,c);if(u.extent==="parent")j=Pq(j,c,l);let F=gq(u,n,i),J=l.internals.z??0;return{x:j.x,y:j.y,z:J>=F?J+1:F}}function UA(u,l,f,r=[0,0]){let n=[],i=new Map;for(let t of u){let y=l.get(t.parentId);if(!y)continue;let c=i.get(t.parentId)?.expandedRect??ai(y),$=F9(c,t.rect);i.set(t.parentId,{expandedRect:$,parent:y})}if(i.size>0)i.forEach(({expandedRect:t,parent:y},c)=>{let $=y.internals.positionAbsolute,A=qn(y),j=y.origin??r,F=t.x<$.x?Math.round(Math.abs($.x-t.x)):0,J=t.y<$.y?Math.round(Math.abs($.y-t.y)):0,Q=Math.max(A.width,Math.round(t.width)),W=Math.max(A.height,Math.round(t.height)),L=(Q-A.width)*j[0],U=(W-A.height)*j[1];if(F>0||J>0||L||U)n.push({id:c,type:"position",position:{x:y.position.x-F+L,y:y.position.y-J+U}}),f.get(c)?.forEach((q)=>{if(!u.some((N)=>N.id===q.id))n.push({id:q.id,type:"position",position:{x:q.position.x+F,y:q.position.y+J}})});if(A.width<t.width||A.height<t.height||F||J)n.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:Q+(F?j[0]*F-L:0),height:W+(J?j[1]*J-U:0)}})});return n}function sq(u,l,f,r,n,i,t){let y=r?.querySelector(".xyflow__viewport"),c=!1;if(!y)return{changes:[],updatedInternals:c};let $=[],A=window.getComputedStyle(y),{m22:j}=new window.DOMMatrixReadOnly(A.transform),F=[];for(let J of u.values()){let Q=l.get(J.id);if(!Q)continue;if(Q.hidden){l.set(Q.id,{...Q,internals:{...Q.internals,handleBounds:void 0}}),c=!0;continue}let W=cA(J.nodeElement),L=Q.measured.width!==W.width||Q.measured.height!==W.height;if(!!(W.width&&W.height&&(L||!Q.internals.handleBounds||J.force))){let q=J.nodeElement.getBoundingClientRect(),N=Uy(Q.extent)?Q.extent:i,{positionAbsolute:w}=Q.internals;if(Q.parentId&&Q.extent==="parent")w=Pq(w,W,l.get(Q.parentId));else if(N)w=si(w,N,W);let G={...Q,measured:W,internals:{...Q.internals,positionAbsolute:w,handleBounds:{source:Kq("source",J.nodeElement,q,j,Q.id),target:Kq("target",J.nodeElement,q,j,Q.id)}}};if(l.set(Q.id,G),Q.parentId)O9(G,l,f,{nodeOrigin:n,zIndexMode:t});if(c=!0,L){if($.push({id:Q.id,type:"dimensions",dimensions:W}),Q.expandParent&&Q.parentId)F.push({id:Q.id,parentId:Q.parentId,rect:ai(G,n)})}}}if(F.length>0){let J=UA(F,l,f,n);$.push(...J)}return{changes:$,updatedInternals:c}}async function aq({delta:u,panZoom:l,transform:f,translateExtent:r,width:n,height:i}){if(!l||!u.x&&!u.y)return Promise.resolve(!1);let t=await l.setViewportConstrained({x:f[0]+u.x,y:f[1]+u.y,zoom:f[2]},[[0,0],[n,i]],r),y=!!t&&(t.x!==f[0]||t.y!==f[1]||t.k!==f[2]);return Promise.resolve(y)}function Bq(u,l,f,r,n,i){let t=n,y=r.get(t)||new Map;r.set(t,y.set(f,l)),t=`${n}-${u}`;let c=r.get(t)||new Map;if(r.set(t,c.set(f,l)),i){t=`${n}-${u}-${i}`;let $=r.get(t)||new Map;r.set(t,$.set(f,l))}}function Z9(u,l,f){u.clear(),l.clear();for(let r of f){let{source:n,target:i,sourceHandle:t=null,targetHandle:y=null}=r,c={edgeId:r.id,source:n,target:i,sourceHandle:t,targetHandle:y},$=`${n}-${t}--${i}-${y}`,A=`${i}-${y}--${n}-${t}`;Bq("source",c,A,u,n,t),Bq("target",c,$,u,i,y),l.set(r.id,r)}}function oq(u,l){if(!u.parentId)return!1;let f=l.get(u.parentId);if(!f)return!1;if(f.selected)return!0;return oq(f,l)}function Vq(u,l,f){let r=u;do{if(r?.matches?.(l))return!0;if(r===f)return!1;r=r?.parentElement}while(r);return!1}function lm(u,l,f,r){let n=new Map;for(let[i,t]of u)if((t.selected||t.id===r)&&(!t.parentId||!oq(t,u))&&(t.draggable||l&&typeof t.draggable>"u")){let y=u.get(i);if(y)n.set(i,{id:i,position:y.position||{x:0,y:0},distance:{x:f.x-y.internals.positionAbsolute.x,y:f.y-y.internals.positionAbsolute.y},extent:y.extent,parentId:y.parentId,origin:y.origin,expandParent:y.expandParent,internals:{positionAbsolute:y.internals.positionAbsolute||{x:0,y:0}},measured:{width:y.measured.width??0,height:y.measured.height??0}})}return n}function l9({nodeId:u,dragItems:l,nodeLookup:f,dragging:r=!0}){let n=[];for(let[t,y]of l){let c=f.get(t)?.internals.userNode;if(c)n.push({...c,position:y.position,dragging:r})}if(!u)return[n[0],n];let i=f.get(u)?.internals.userNode;return[!i?n[0]:{...i,position:l.get(u)?.position||i.position,dragging:r},n]}function fm({dragItems:u,snapGrid:l,x:f,y:r}){let n=u.values().next().value;if(!n)return null;let i={x:f-n.distance.x,y:r-n.distance.y},t=qy(i,l);return{x:t.x-i.x,y:t.y-i.y}}function dq({onNodeMouseDown:u,getStoreItems:l,onDragStart:f,onDrag:r,onDragStop:n}){let i={x:null,y:null},t=0,y=new Map,c=!1,$={x:0,y:0},A=null,j=!1,F=null,J=!1,Q=!1,W=null;function L({noDragClassName:q,handleSelector:N,domNode:w,isSelectable:G,nodeId:Z,nodeClickDistance:H=0}){F=ff(w);function E({x:D,y:X}){let{nodeLookup:O,nodeExtent:Y,snapGrid:p,snapToGrid:v,nodeOrigin:z,onNodeDrag:P,onSelectionDrag:k,onError:I,updateNodePositions:b}=l();i={x:D,y:X};let d=!1,s=y.size>1,h=s&&Y?n9(Qy(y)):null,lu=s&&v?fm({dragItems:y,snapGrid:p,x:D,y:X}):null;for(let[cu,_u]of y){if(!O.has(cu))continue;let Fu={x:D-_u.distance.x,y:X-_u.distance.y};if(v)Fu=lu?{x:Math.round(Fu.x+lu.x),y:Math.round(Fu.y+lu.y)}:qy(Fu,p);let zu=null;if(s&&Y&&!_u.extent&&h){let{positionAbsolute:e}=_u.internals,uu=e.x-h.x+Y[0][0],Gu=e.x+_u.measured.width-h.x2+Y[1][0],a=e.y-h.y+Y[0][1],qu=e.y+_u.measured.height-h.y2+Y[1][1];zu=[[uu,a],[Gu,qu]]}let{position:Wu,positionAbsolute:C}=j9({nodeId:cu,nextPosition:Fu,nodeLookup:O,nodeExtent:zu?zu:Y,nodeOrigin:z,onError:I});d=d||_u.position.x!==Wu.x||_u.position.y!==Wu.y,_u.position=Wu,_u.internals.positionAbsolute=C}if(Q=Q||d,!d)return;if(b(y,!0),W&&(r||P||!Z&&k)){let[cu,_u]=l9({nodeId:Z,dragItems:y,nodeLookup:O});if(r?.(W,y,cu,_u),P?.(W,cu,_u),!Z)k?.(W,_u)}}async function m(){if(!A)return;let{transform:D,panBy:X,autoPanSpeed:O,autoPanOnNodeDrag:Y}=l();if(!Y){c=!1,cancelAnimationFrame(t);return}let[p,v]=Cq($,A,O);if(p!==0||v!==0){if(i.x=(i.x??0)-p/D[2],i.y=(i.y??0)-v/D[2],await X({x:p,y:v}))E(i)}t=requestAnimationFrame(m)}function S(D){let{nodeLookup:X,multiSelectionActive:O,nodesDraggable:Y,transform:p,snapGrid:v,snapToGrid:z,selectNodesOnDrag:P,onNodeDragStart:k,onSelectionDragStart:I,unselectNodesAndEdges:b}=l();if(j=!0,(!P||!G)&&!O&&Z){if(!X.get(Z)?.selected)b()}if(G&&P&&Z)u?.(Z);let d=Xc(D.sourceEvent,{transform:p,snapGrid:v,snapToGrid:z,containerBounds:A});if(i=d,y=lm(X,Y,d,Z),y.size>0&&(f||k||!Z&&I)){let[s,h]=l9({nodeId:Z,dragItems:y,nodeLookup:X});if(f?.(D.sourceEvent,y,s,h),k?.(D.sourceEvent,s,h),!Z)I?.(D.sourceEvent,h)}}let B=Nc().clickDistance(H).on("start",(D)=>{let{domNode:X,nodeDragThreshold:O,transform:Y,snapGrid:p,snapToGrid:v}=l();if(A=X?.getBoundingClientRect()||null,J=!1,Q=!1,W=D.sourceEvent,O===0)S(D);i=Xc(D.sourceEvent,{transform:Y,snapGrid:p,snapToGrid:v,containerBounds:A}),$=Br(D.sourceEvent,A)}).on("drag",(D)=>{let{autoPanOnNodeDrag:X,transform:O,snapGrid:Y,snapToGrid:p,nodeDragThreshold:v,nodeLookup:z}=l(),P=Xc(D.sourceEvent,{transform:O,snapGrid:Y,snapToGrid:p,containerBounds:A});if(W=D.sourceEvent,D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||Z&&!z.has(Z))J=!0;if(J)return;if(!c&&X&&j)c=!0,m();if(!j){let k=Br(D.sourceEvent,A),I=k.x-$.x,b=k.y-$.y;if(Math.sqrt(I*I+b*b)>v)S(D)}if((i.x!==P.xSnapped||i.y!==P.ySnapped)&&y&&j)$=Br(D.sourceEvent,A),E(P)}).on("end",(D)=>{if(!j||J)return;if(c=!1,j=!1,cancelAnimationFrame(t),y.size>0){let{nodeLookup:X,updateNodePositions:O,onNodeDragStop:Y,onSelectionDragStop:p}=l();if(Q)O(y,!1),Q=!1;if(n||Y||!Z&&p){let[v,z]=l9({nodeId:Z,dragItems:y,nodeLookup:X,dragging:!1});if(n?.(D.sourceEvent,y,v,z),Y?.(D.sourceEvent,v,z),!Z)p?.(D.sourceEvent,z)}}}).filter((D)=>{let X=D.target;return!D.button&&(!q||!Vq(X,`.${q}`,w))&&(!N||Vq(X,N,w))});F.call(B)}function U(){F?.on(".drag",null)}return{update:L,destroy:U}}function rm(u,l,f){let r=[],n={x:u.x-f,y:u.y-f,width:f*2,height:f*2};for(let i of l.values())if(Ny(n,ai(i))>0)r.push(i);return r}var nm=250;function im(u,l,f,r){let n=[],i=1/0,t=rm(u,f,l+nm);for(let y of t){let c=[...y.internals.handleBounds?.source??[],...y.internals.handleBounds?.target??[]];for(let $ of c){if(r.nodeId===$.nodeId&&r.type===$.type&&r.id===$.id)continue;let{x:A,y:j}=h0(y,$,$.position,!0),F=Math.sqrt(Math.pow(A-u.x,2)+Math.pow(j-u.y,2));if(F>l)continue;if(F<i)n=[{...$,x:A,y:j}],i=F;else if(F===i)n.push({...$,x:A,y:j})}}if(!n.length)return null;if(n.length>1){let y=r.type==="source"?"target":"source";return n.find((c)=>c.type===y)??n[0]}return n[0]}function eq(u,l,f,r,n,i=!1){let t=r.get(u);if(!t)return null;let y=n==="strict"?t.internals.handleBounds?.[l]:[...t.internals.handleBounds?.source??[],...t.internals.handleBounds?.target??[]],c=(f?y?.find(($)=>$.id===f):y?.[0])??null;return c&&i?{...c,...h0(t,c,c.position,!0)}:c}function uw(u,l){if(u)return u;else if(l?.classList.contains("target"))return"target";else if(l?.classList.contains("source"))return"source";return null}function tm(u,l){let f=null;if(l)f=!0;else if(u&&!l)f=!1;return f}var lw=()=>!0;function ym(u,{connectionMode:l,connectionRadius:f,handleId:r,nodeId:n,edgeUpdaterType:i,isTarget:t,domNode:y,nodeLookup:c,lib:$,autoPanOnConnect:A,flowId:j,panBy:F,cancelConnection:J,onConnectStart:Q,onConnect:W,onConnectEnd:L,isValidConnection:U=lw,onReconnectEnd:q,updateConnection:N,getTransform:w,getFromHandle:G,autoPanSpeed:Z,dragThreshold:H=1,handleDomNode:E}){let m=w9(u.target),S=0,B,{x:D,y:X}=Br(u),O=uw(i,E),Y=y?.getBoundingClientRect(),p=!1;if(!Y||!O)return;let v=eq(n,O,r,c,l);if(!v)return;let z=Br(u,Y),P=!1,k=null,I=!1,b=null;function d(){if(!A||!Y)return;let[Wu,C]=Cq(z,Y,Z);F({x:Wu,y:C}),S=requestAnimationFrame(d)}let s={...v,nodeId:n,type:O,position:v.position},h=c.get(n),cu={inProgress:!0,isValid:null,from:h0(h,s,Ku.Left,!0),fromHandle:s,fromPosition:s.position,fromNode:h,to:z,toHandle:null,toPosition:Lq[s.position],toNode:null,pointer:z};function _u(){p=!0,N(cu),Q?.(u,{nodeId:n,handleId:r,handleType:O})}if(H===0)_u();function Fu(Wu){if(!p){let{x:qu,y:Zu}=Br(Wu),Bu=qu-D,gu=Zu-X;if(!(Bu*Bu+gu*gu>H*H))return;_u()}if(!G()||!s){zu(Wu);return}let C=w();if(z=Br(Wu,Y),B=im(wy(z,C,!1,[1,1]),f,c,s),!P)d(),P=!0;let e=fw(Wu,{handle:B,connectionMode:l,fromNodeId:n,fromHandleId:r,fromType:t?"target":"source",isValidConnection:U,doc:m,lib:$,flowId:j,nodeLookup:c});b=e.handleDomNode,k=e.connection,I=tm(!!B,e.isValid);let uu=c.get(n),Gu=uu?h0(uu,s,Ku.Left,!0):cu.from,a={...cu,from:Gu,isValid:I,to:e.toHandle&&I?Yc({x:e.toHandle.x,y:e.toHandle.y},C):z,toHandle:e.toHandle,toPosition:I&&e.toHandle?e.toHandle.position:Lq[s.position],toNode:e.toHandle?c.get(e.toHandle.nodeId):null,pointer:z};N(a),cu=a}function zu(Wu){if("touches"in Wu&&Wu.touches.length>0)return;if(p){if((B||b)&&k&&I)W?.(k);let{inProgress:C,...e}=cu,uu={...e,toPosition:cu.toHandle?cu.toPosition:null};if(L?.(Wu,uu),i)q?.(Wu,uu)}J(),cancelAnimationFrame(S),P=!1,I=!1,k=null,b=null,m.removeEventListener("mousemove",Fu),m.removeEventListener("mouseup",zu),m.removeEventListener("touchmove",Fu),m.removeEventListener("touchend",zu)}m.addEventListener("mousemove",Fu),m.addEventListener("mouseup",zu),m.addEventListener("touchmove",Fu),m.addEventListener("touchend",zu)}function fw(u,{handle:l,connectionMode:f,fromNodeId:r,fromHandleId:n,fromType:i,doc:t,lib:y,flowId:c,isValidConnection:$=lw,nodeLookup:A}){let j=i==="target",F=l?t.querySelector(`.${y}-flow__handle[data-id="${c}-${l?.nodeId}-${l?.id}-${l?.type}"]`):null,{x:J,y:Q}=Br(u),W=t.elementFromPoint(J,Q),L=W?.classList.contains(`${y}-flow__handle`)?W:F,U={handleDomNode:L,isValid:!1,connection:null,toHandle:null};if(L){let q=uw(void 0,L),N=L.getAttribute("data-nodeid"),w=L.getAttribute("data-handleid"),G=L.classList.contains("connectable"),Z=L.classList.contains("connectableend");if(!N||!q)return U;let H={source:j?N:r,sourceHandle:j?w:n,target:j?r:N,targetHandle:j?n:w};U.connection=H;let m=G&&Z&&(f===R0.Strict?j&&q==="source"||!j&&q==="target":N!==r||w!==n);U.isValid=m&&$(H),U.toHandle=eq(N,q,w,A,f,!0)}return U}var JA={onPointerDown:ym,isValid:fw};function rw({domNode:u,panZoom:l,getTransform:f,getViewScale:r}){let n=ff(u);function i({translateExtent:y,width:c,height:$,zoomStep:A=1,pannable:j=!0,zoomable:F=!0,inversePan:J=!1}){let Q=(N)=>{if(N.sourceEvent.type!=="wheel"||!l)return;let w=f(),G=N.sourceEvent.ctrlKey&&Wy()?10:1,Z=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?0.05:N.sourceEvent.deltaMode?1:0.002)*A,H=w[2]*Math.pow(2,Z*G);l.scaleTo(H)},W=[0,0],L=(N)=>{if(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")W=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY]},U=(N)=>{let w=f();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!l)return;let G=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],Z=[G[0]-W[0],G[1]-W[1]];W=G;let H=r()*Math.max(w[2],Math.log(w[2]))*(J?-1:1),E={x:w[0]-Z[0]*H,y:w[1]-Z[1]*H},m=[[0,0],[c,$]];l.setViewportConstrained({x:E.x,y:E.y,zoom:w[2]},m,y)},q=Sc().on("start",L).on("zoom",j?U:null).on("zoom.wheel",F?Q:null);n.call(q,{})}function t(){n.on("zoom",null)}return{update:i,destroy:t,pointer:zf}}var QA=(u)=>({x:u.x,y:u.y,zoom:u.k}),f9=({x:u,y:l,zoom:f})=>ki.translate(u,l).scale(f),jy=(u,l)=>u.target.closest(`.${l}`),nw=(u,l)=>l===2&&Array.isArray(u)&&u.includes(2),cm=(u)=>((u*=2)<=1?u*u*u:(u-=2)*u*u+2)/2,r9=(u,l=0,f=cm,r=()=>{})=>{let n=typeof l==="number"&&l>0;if(!n)r();return n?u.transition().duration(l).ease(f).on("end",r):u},iw=(u)=>{let l=u.ctrlKey&&Wy()?10:1;return-u.deltaY*(u.deltaMode===1?0.05:u.deltaMode?1:0.002)*l};function _m({zoomPanValues:u,noWheelClassName:l,d3Selection:f,d3Zoom:r,panOnScrollMode:n,panOnScrollSpeed:i,zoomOnPinch:t,onPanZoomStart:y,onPanZoom:c,onPanZoomEnd:$}){return(A)=>{if(jy(A,l)){if(A.ctrlKey)A.preventDefault();return!1}A.preventDefault(),A.stopImmediatePropagation();let j=f.property("__zoom").k||1;if(A.ctrlKey&&t){let L=zf(A),U=iw(A),q=j*Math.pow(2,U);r.scaleTo(f,q,L,A);return}let F=A.deltaMode===1?20:1,J=n===an.Vertical?0:A.deltaX*F,Q=n===an.Horizontal?0:A.deltaY*F;if(!Wy()&&A.shiftKey&&n!==an.Vertical)J=A.deltaY*F,Q=0;r.translateBy(f,-(J/j)*i,-(Q/j)*i,{internal:!0});let W=QA(f.property("__zoom"));if(clearTimeout(u.panScrollTimeout),!u.isPanScrolling)u.isPanScrolling=!0,y?.(A,W);else c?.(A,W),u.panScrollTimeout=setTimeout(()=>{$?.(A,W),u.isPanScrolling=!1},150)}}function $m({noWheelClassName:u,preventScrolling:l,d3ZoomHandler:f}){return function(r,n){let i=r.type==="wheel",t=!l&&i&&!r.ctrlKey,y=jy(r,u);if(r.ctrlKey&&i&&y)r.preventDefault();if(t||y)return null;r.preventDefault(),f.call(this,r,n)}}function Am({zoomPanValues:u,onDraggingChange:l,onPanZoomStart:f}){return(r)=>{if(r.sourceEvent?.internal)return;let n=QA(r.transform);if(u.mouseButton=r.sourceEvent?.button||0,u.isZoomingOrPanning=!0,u.prevViewport=n,r.sourceEvent?.type==="mousedown")l(!0);if(f)f?.(r.sourceEvent,n)}}function jm({zoomPanValues:u,panOnDrag:l,onPaneContextMenu:f,onTransformChange:r,onPanZoom:n}){return(i)=>{if(u.usedRightMouseButton=!!(f&&nw(l,u.mouseButton??0)),!i.sourceEvent?.sync)r([i.transform.x,i.transform.y,i.transform.k]);if(n&&!i.sourceEvent?.internal)n?.(i.sourceEvent,QA(i.transform))}}function Fm({zoomPanValues:u,panOnDrag:l,panOnScroll:f,onDraggingChange:r,onPanZoomEnd:n,onPaneContextMenu:i}){return(t)=>{if(t.sourceEvent?.internal)return;if(u.isZoomingOrPanning=!1,i&&nw(l,u.mouseButton??0)&&!u.usedRightMouseButton&&t.sourceEvent)i(t.sourceEvent);if(u.usedRightMouseButton=!1,r(!1),n){let y=QA(t.transform);u.prevViewport=y,clearTimeout(u.timerId),u.timerId=setTimeout(()=>{n?.(t.sourceEvent,y)},f?150:0)}}}function Um({zoomActivationKeyPressed:u,zoomOnScroll:l,zoomOnPinch:f,panOnDrag:r,panOnScroll:n,zoomOnDoubleClick:i,userSelectionActive:t,noWheelClassName:y,noPanClassName:c,lib:$,connectionInProgress:A}){return(j)=>{let F=u||l,J=f&&j.ctrlKey,Q=j.type==="wheel";if(j.button===1&&j.type==="mousedown"&&(jy(j,`${$}-flow__node`)||jy(j,`${$}-flow__edge`)))return!0;if(!r&&!F&&!n&&!i&&!f)return!1;if(t)return!1;if(A&&!Q)return!1;if(jy(j,y)&&Q)return!1;if(jy(j,c)&&(!Q||n&&Q&&!u))return!1;if(!f&&j.ctrlKey&&Q)return!1;if(!f&&j.type==="touchstart"&&j.touches?.length>1)return j.preventDefault(),!1;if(!F&&!n&&!J&&Q)return!1;if(!r&&(j.type==="mousedown"||j.type==="touchstart"))return!1;if(Array.isArray(r)&&!r.includes(j.button)&&j.type==="mousedown")return!1;let W=Array.isArray(r)&&r.includes(j.button)||!j.button||j.button<=1;return(!j.ctrlKey||Q)&&W}}function tw({domNode:u,minZoom:l,maxZoom:f,translateExtent:r,viewport:n,onPanZoom:i,onPanZoomStart:t,onPanZoomEnd:y,onDraggingChange:c}){let $={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},A=u.getBoundingClientRect(),j=Sc().scaleExtent([l,f]).translateExtent(r),F=ff(u).call(j);q({x:n.x,y:n.y,zoom:Fy(n.zoom,l,f)},[[0,0],[A.width,A.height]],r);let J=F.on("wheel.zoom"),Q=F.on("dblclick.zoom");j.wheelDelta(iw);function W(B,D){if(F)return new Promise((X)=>{j?.interpolate(D?.interpolate==="linear"?Qn:bi).transform(r9(F,D?.duration,D?.ease,()=>X(!0)),B)});return Promise.resolve(!1)}function L({noWheelClassName:B,noPanClassName:D,onPaneContextMenu:X,userSelectionActive:O,panOnScroll:Y,panOnDrag:p,panOnScrollMode:v,panOnScrollSpeed:z,preventScrolling:P,zoomOnPinch:k,zoomOnScroll:I,zoomOnDoubleClick:b,zoomActivationKeyPressed:d,lib:s,onTransformChange:h,connectionInProgress:lu,paneClickDistance:cu,selectionOnDrag:_u}){if(O&&!$.isZoomingOrPanning)U();let Fu=Y&&!d&&!O;j.clickDistance(_u?1/0:!Hr(cu)||cu<0?0:cu);let zu=Fu?_m({zoomPanValues:$,noWheelClassName:B,d3Selection:F,d3Zoom:j,panOnScrollMode:v,panOnScrollSpeed:z,zoomOnPinch:k,onPanZoomStart:t,onPanZoom:i,onPanZoomEnd:y}):$m({noWheelClassName:B,preventScrolling:P,d3ZoomHandler:J});if(F.on("wheel.zoom",zu,{passive:!1}),!O){let C=Am({zoomPanValues:$,onDraggingChange:c,onPanZoomStart:t});j.on("start",C);let e=jm({zoomPanValues:$,panOnDrag:p,onPaneContextMenu:!!X,onPanZoom:i,onTransformChange:h});j.on("zoom",e);let uu=Fm({zoomPanValues:$,panOnDrag:p,panOnScroll:Y,onPaneContextMenu:X,onPanZoomEnd:y,onDraggingChange:c});j.on("end",uu)}let Wu=Um({zoomActivationKeyPressed:d,panOnDrag:p,zoomOnScroll:I,panOnScroll:Y,zoomOnDoubleClick:b,zoomOnPinch:k,userSelectionActive:O,noPanClassName:D,noWheelClassName:B,lib:s,connectionInProgress:lu});if(j.filter(Wu),b)F.on("dblclick.zoom",Q);else F.on("dblclick.zoom",null)}function U(){j.on("zoom",null)}async function q(B,D,X){let O=f9(B),Y=j?.constrain()(O,D,X);if(Y)await W(Y);return new Promise((p)=>p(Y))}async function N(B,D){let X=f9(B);return await W(X,D),new Promise((O)=>O(X))}function w(B){if(F){let D=f9(B),X=F.property("__zoom");if(X.k!==B.zoom||X.x!==B.x||X.y!==B.y)j?.transform(F,D,null,{sync:!0})}}function G(){let B=F?pc(F.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function Z(B,D){if(F)return new Promise((X)=>{j?.interpolate(D?.interpolate==="linear"?Qn:bi).scaleTo(r9(F,D?.duration,D?.ease,()=>X(!0)),B)});return Promise.resolve(!1)}function H(B,D){if(F)return new Promise((X)=>{j?.interpolate(D?.interpolate==="linear"?Qn:bi).scaleBy(r9(F,D?.duration,D?.ease,()=>X(!0)),B)});return Promise.resolve(!1)}function E(B){j?.scaleExtent(B)}function m(B){j?.translateExtent(B)}function S(B){let D=!Hr(B)||B<0?0:B;j?.clickDistance(D)}return{update:L,destroy:U,setViewport:N,setViewportConstrained:q,getViewport:G,scaleTo:Z,scaleBy:H,setScaleExtent:E,setTranslateExtent:m,syncViewport:w,setClickDistance:S}}var b0;(function(u){u.Line="line",u.Handle="handle"})(b0||(b0={}));function Jm({width:u,prevWidth:l,height:f,prevHeight:r,affectsX:n,affectsY:i}){let t=u-l,y=f-r,c=[t>0?1:t<0?-1:0,y>0?1:y<0?-1:0];if(t&&n)c[0]=c[0]*-1;if(y&&i)c[1]=c[1]*-1;return c}function mq(u){let l=u.includes("right")||u.includes("left"),f=u.includes("bottom")||u.includes("top"),r=u.includes("left"),n=u.includes("top");return{isHorizontal:l,isVertical:f,affectsX:r,affectsY:n}}function C0(u,l){return Math.max(0,l-u)}function M0(u,l){return Math.max(0,u-l)}function rA(u,l,f){return Math.max(0,l-u,u-f)}function Dq(u,l){return u?!l:l}function Qm(u,l,f,r,n,i,t,y){let{affectsX:c,affectsY:$}=l,{isHorizontal:A,isVertical:j}=l,F=A&&j,{xSnapped:J,ySnapped:Q}=f,{minWidth:W,maxWidth:L,minHeight:U,maxHeight:q}=r,{x:N,y:w,width:G,height:Z,aspectRatio:H}=u,E=Math.floor(A?J-u.pointerX:0),m=Math.floor(j?Q-u.pointerY:0),S=G+(c?-E:E),B=Z+($?-m:m),D=-i[0]*G,X=-i[1]*Z,O=rA(S,W,L),Y=rA(B,U,q);if(t){let z=0,P=0;if(c&&E<0)z=C0(N+E+D,t[0][0]);else if(!c&&E>0)z=M0(N+S+D,t[1][0]);if($&&m<0)P=C0(w+m+X,t[0][1]);else if(!$&&m>0)P=M0(w+B+X,t[1][1]);O=Math.max(O,z),Y=Math.max(Y,P)}if(y){let z=0,P=0;if(c&&E>0)z=M0(N+E,y[0][0]);else if(!c&&E<0)z=C0(N+S,y[1][0]);if($&&m>0)P=M0(w+m,y[0][1]);else if(!$&&m<0)P=C0(w+B,y[1][1]);O=Math.max(O,z),Y=Math.max(Y,P)}if(n){if(A){let z=rA(S/H,U,q)*H;if(O=Math.max(O,z),t){let P=0;if(!c&&!$||c&&!$&&F)P=M0(w+X+S/H,t[1][1])*H;else P=C0(w+X+(c?E:-E)/H,t[0][1])*H;O=Math.max(O,P)}if(y){let P=0;if(!c&&!$||c&&!$&&F)P=C0(w+S/H,y[1][1])*H;else P=M0(w+(c?E:-E)/H,y[0][1])*H;O=Math.max(O,P)}}if(j){let z=rA(B*H,W,L)/H;if(Y=Math.max(Y,z),t){let P=0;if(!c&&!$||$&&!c&&F)P=M0(N+B*H+D,t[1][0])/H;else P=C0(N+($?m:-m)*H+D,t[0][0])/H;Y=Math.max(Y,P)}if(y){let P=0;if(!c&&!$||$&&!c&&F)P=C0(N+B*H,y[1][0])/H;else P=M0(N+($?m:-m)*H,y[0][0])/H;Y=Math.max(Y,P)}}}if(m=m+(m<0?Y:-Y),E=E+(E<0?O:-O),n)if(F)if(S>B*H)m=(Dq(c,$)?-E:E)/H;else E=(Dq(c,$)?-m:m)*H;else if(A)m=E/H,$=c;else E=m*H,c=$;let p=c?N+E:N,v=$?w+m:w;return{width:G+(c?-E:E),height:Z+($?-m:m),x:i[0]*E*(!c?1:-1)+p,y:i[1]*m*(!$?1:-1)+v}}var yw={width:0,height:0,x:0,y:0},Nm={...yw,pointerX:0,pointerY:0,aspectRatio:1};function qm(u){return[[0,0],[u.measured.width,u.measured.height]]}function wm(u,l,f){let r=l.position.x+u.position.x,n=l.position.y+u.position.y,i=u.measured.width??0,t=u.measured.height??0,y=f[0]*i,c=f[1]*t;return[[r-y,n-c],[r+i-y,n+t-c]]}function cw({domNode:u,nodeId:l,getStoreItems:f,onChange:r,onEnd:n}){let i=ff(u),t={controlDirection:mq("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function y({controlPosition:$,boundaries:A,keepAspectRatio:j,resizeDirection:F,onResizeStart:J,onResize:Q,onResizeEnd:W,shouldResize:L}){let U={...yw},q={...Nm};t={boundaries:A,resizeDirection:F,keepAspectRatio:j,controlDirection:mq($)};let N=void 0,w=null,G=[],Z=void 0,H=void 0,E=void 0,m=!1,S=Nc().on("start",(B)=>{let{nodeLookup:D,transform:X,snapGrid:O,snapToGrid:Y,nodeOrigin:p,paneDomNode:v}=f();if(N=D.get(l),!N)return;w=v?.getBoundingClientRect()??null;let{xSnapped:z,ySnapped:P}=Xc(B.sourceEvent,{transform:X,snapGrid:O,snapToGrid:Y,containerBounds:w});if(U={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},q={...U,pointerX:z,pointerY:P,aspectRatio:U.width/U.height},Z=void 0,N.parentId&&(N.extent==="parent"||N.expandParent))Z=D.get(N.parentId),H=Z&&N.extent==="parent"?qm(Z):void 0;G=[],E=void 0;for(let[k,I]of D)if(I.parentId===l){if(G.push({id:k,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent){let b=wm(I,N,I.origin??p);if(E)E=[[Math.min(b[0][0],E[0][0]),Math.min(b[0][1],E[0][1])],[Math.max(b[1][0],E[1][0]),Math.max(b[1][1],E[1][1])]];else E=b}}J?.(B,{...U})}).on("drag",(B)=>{let{transform:D,snapGrid:X,snapToGrid:O,nodeOrigin:Y}=f(),p=Xc(B.sourceEvent,{transform:D,snapGrid:X,snapToGrid:O,containerBounds:w}),v=[];if(!N)return;let{x:z,y:P,width:k,height:I}=U,b={},d=N.origin??Y,{width:s,height:h,x:lu,y:cu}=Qm(q,t.controlDirection,p,t.boundaries,t.keepAspectRatio,d,H,E),_u=s!==k,Fu=h!==I,zu=lu!==z&&_u,Wu=cu!==P&&Fu;if(!zu&&!Wu&&!_u&&!Fu)return;if(zu||Wu||d[0]===1||d[1]===1){if(b.x=zu?lu:U.x,b.y=Wu?cu:U.y,U.x=b.x,U.y=b.y,G.length>0){let Gu=lu-z,a=cu-P;for(let qu of G)qu.position={x:qu.position.x-Gu+d[0]*(s-k),y:qu.position.y-a+d[1]*(h-I)},v.push(qu)}}if(_u||Fu)b.width=_u&&(!t.resizeDirection||t.resizeDirection==="horizontal")?s:U.width,b.height=Fu&&(!t.resizeDirection||t.resizeDirection==="vertical")?h:U.height,U.width=b.width,U.height=b.height;if(Z&&N.expandParent){let Gu=d[0]*(b.width??0);if(b.x&&b.x<Gu)U.x=Gu,q.x=q.x-(b.x-Gu);let a=d[1]*(b.height??0);if(b.y&&b.y<a)U.y=a,q.y=q.y-(b.y-a)}let C=Jm({width:U.width,prevWidth:k,height:U.height,prevHeight:I,affectsX:t.controlDirection.affectsX,affectsY:t.controlDirection.affectsY}),e={...U,direction:C};if(L?.(B,e)===!1)return;m=!0,Q?.(B,e),r(b,v)}).on("end",(B)=>{if(!m)return;W?.(B,{...U}),n?.({...U}),m=!1});i.call(S)}function c(){i.on(".drag",null)}return{update:y,destroy:c}}var Ww=Cu(Jl(),1),Lw=Cu(Qw(),1);var Nw=(u)=>{let l,f=new Set,r=(A,j)=>{let F=typeof A==="function"?A(l):A;if(!Object.is(F,l)){let J=l;l=(j!=null?j:typeof F!=="object"||F===null)?F:Object.assign({},l,F),f.forEach((Q)=>Q(l,J))}},n=()=>l,c={setState:r,getState:n,getInitialState:()=>$,subscribe:(A)=>{return f.add(A),()=>f.delete(A)},destroy:()=>{f.clear()}},$=l=u(r,n,c);return c},qw=(u)=>u?Nw(u):Nw;var{useDebugValue:Ym}=Ww.default,{useSyncExternalStoreWithSelector:Pm}=Lw.default,Cm=(u)=>u;function B9(u,l=Cm,f){let r=Pm(u.subscribe,u.getState,u.getServerState||u.getInitialState,l,f);return Ym(r),r}var ww=(u,l)=>{let f=qw(u),r=(n,i=l)=>B9(f,n,i);return Object.assign(r,f),r},Tw=(u,l)=>u?ww(u,l):ww;function El(u,l){if(Object.is(u,l))return!0;if(typeof u!=="object"||u===null||typeof l!=="object"||l===null)return!1;if(u instanceof Map&&l instanceof Map){if(u.size!==l.size)return!1;for(let[r,n]of u)if(!Object.is(n,l.get(r)))return!1;return!0}if(u instanceof Set&&l instanceof Set){if(u.size!==l.size)return!1;for(let r of u)if(!l.has(r))return!1;return!0}let f=Object.keys(u);if(f.length!==Object.keys(l).length)return!1;for(let r of f)if(!Object.prototype.hasOwnProperty.call(l,r)||!Object.is(u[r],l[r]))return!1;return!0}var Mm=Cu(S4(),1),LA=tu.createContext(null),Rm=LA.Provider,kw=Jr.error001();function il(u,l){let f=tu.useContext(LA);if(f===null)throw Error(kw);return B9(f,u,l)}function Zl(){let u=tu.useContext(LA);if(u===null)throw Error(kw);return tu.useMemo(()=>({getState:u.getState,setState:u.setState,subscribe:u.subscribe}),[u])}var Kw={display:"none"},xm={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Iw="react-flow__node-desc",gw="react-flow__edge-desc",hm="react-flow__aria-live",bm=(u)=>u.ariaLiveMessage,vm=(u)=>u.ariaLabelConfig;function km({rfId:u}){let l=il(bm);return nu.jsx("div",{id:`${hm}-${u}`,"aria-live":"assertive","aria-atomic":"true",style:xm,children:l})}function Im({rfId:u,disableKeyboardA11y:l}){let f=il(vm);return nu.jsxs(nu.Fragment,{children:[nu.jsx("div",{id:`${Iw}-${u}`,style:Kw,children:l?f["node.a11yDescription.default"]:f["node.a11yDescription.keyboardDisabled"]}),nu.jsx("div",{id:`${gw}-${u}`,style:Kw,children:f["edge.a11yDescription.default"]}),!l&&nu.jsx(km,{rfId:u})]})}var TA=tu.forwardRef(({position:u="top-left",children:l,className:f,style:r,...n},i)=>{let t=`${u}`.split("-");return nu.jsx("div",{className:Rl(["react-flow__panel",f,...t]),style:r,ref:i,...n,children:l})});TA.displayName="Panel";function gm({proOptions:u,position:l="bottom-right"}){if(u?.hideAttribution)return null;return nu.jsx(TA,{position:l,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:nu.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}var sm=(u)=>{let l=[],f=[];for(let[,r]of u.nodeLookup)if(r.selected)l.push(r.internals.userNode);for(let[,r]of u.edgeLookup)if(r.selected)f.push(r);return{selectedNodes:l,selectedEdges:f}},qA=(u)=>u.id;function am(u,l){return El(u.selectedNodes.map(qA),l.selectedNodes.map(qA))&&El(u.selectedEdges.map(qA),l.selectedEdges.map(qA))}function om({onSelectionChange:u}){let l=Zl(),{selectedNodes:f,selectedEdges:r}=il(sm,am);return tu.useEffect(()=>{let n={nodes:f,edges:r};u?.(n),l.getState().onSelectionChangeHandlers.forEach((i)=>i(n))},[f,r,u]),null}var dm=(u)=>!!u.onSelectionChangeHandlers;function em({onSelectionChange:u}){let l=il(dm);if(u||l)return nu.jsx(om,{onSelectionChange:u});return null}var D9=typeof window<"u"?tu.useLayoutEffect:tu.useEffect,sw=[0,0],uD={x:0,y:0,zoom:1},lD=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Gw=[...lD,"rfId"],fD=(u)=>({setNodes:u.setNodes,setEdges:u.setEdges,setMinZoom:u.setMinZoom,setMaxZoom:u.setMaxZoom,setTranslateExtent:u.setTranslateExtent,setNodeExtent:u.setNodeExtent,reset:u.reset,setDefaultNodesAndEdges:u.setDefaultNodesAndEdges}),zw={translateExtent:Jy,nodeOrigin:sw,minZoom:0.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function rD(u){let{setNodes:l,setEdges:f,setMinZoom:r,setMaxZoom:n,setTranslateExtent:i,setNodeExtent:t,reset:y,setDefaultNodesAndEdges:c}=il(fD,El),$=Zl();D9(()=>{return c(u.defaultNodes,u.defaultEdges),()=>{A.current=zw,y()}},[]);let A=tu.useRef(zw);return D9(()=>{for(let j of Gw){let F=u[j],J=A.current[j];if(F===J)continue;if(typeof u[j]>"u")continue;if(j==="nodes")l(F);else if(j==="edges")f(F);else if(j==="minZoom")r(F);else if(j==="maxZoom")n(F);else if(j==="translateExtent")i(F);else if(j==="nodeExtent")t(F);else if(j==="ariaLabelConfig")$.setState({ariaLabelConfig:Rq(F)});else if(j==="fitView")$.setState({fitViewQueued:F});else if(j==="fitViewOptions")$.setState({fitViewOptions:F});else $.setState({[j]:F})}A.current=u},Gw.map((j)=>u[j])),null}function Ew(){if(typeof window>"u"||!window.matchMedia)return null;return window.matchMedia("(prefers-color-scheme: dark)")}function nD(u){let[l,f]=tu.useState(u==="system"?null:u);return tu.useEffect(()=>{if(u!=="system"){f(u);return}let r=Ew(),n=()=>f(r?.matches?"dark":"light");return n(),r?.addEventListener("change",n),()=>{r?.removeEventListener("change",n)}},[u]),l!==null?l:Ew()?.matches?"dark":"light"}var Ow=typeof document<"u"?document:null;function Rc(u=null,l={target:Ow,actInsideInputWithModifier:!0}){let[f,r]=tu.useState(!1),n=tu.useRef(!1),i=tu.useRef(new Set([])),[t,y]=tu.useMemo(()=>{if(u!==null){let $=(Array.isArray(u)?u:[u]).filter((j)=>typeof j==="string").map((j)=>j.replace("+",` +`;function S2({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return Vl("section",{className:`panel ${n||""}`},Vl("div",{className:"panel-head"},Vl("div",null,u?Vl("p",{className:"panel-eyebrow"},u):null,Vl(fu,{title:l,loading:i})),r?Vl("div",{className:"panel-actions"},r):null),Vl("div",{className:"panel-body"},f))}function YO({title:l,data:u,onOpen:r,testId:f}){return Vl("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function PO({title:l,text:u}){return Vl("div",{className:"empty-state"},Vl("strong",null,l),Vl("span",null,u))}function zQ(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function EQ(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function OQ(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function CO(l){return l.filter((r)=>r?.id==="filebrowser"||String(r?.id||"").startsWith("filebrowser-")).sort((r,f)=>{let n=(i)=>i.providerId==="D518"?0:i.providerId==="D601"?1:i.id==="filebrowser"?2:3;return n(r)-n(f)||String(r.id).localeCompare(String(f.id))})}function MO(l){if(l?.providerId==="D518")return"D518";return l?.providerId||l?.name||l?.id||"Unknown"}function hO(l,u,r="/"){let f=r.startsWith("/")?r:`/${r}`;return`${l}/microservices/${encodeURIComponent(u)}/proxy${f}`}function RO(l,u){return`${l}/microservices/${encodeURIComponent(u)}/health`}async function xO(l,u=16000){let r=new AbortController,f=setTimeout(()=>r.abort(),u);try{return await ml(l,{signal:r.signal,failureFields:[!1]})}finally{clearTimeout(f)}}function ZQ(l){if(l?.providerId==="main-server")return"host / -> /srv";if(l?.providerId==="D601"||l?.providerId==="D518")return"WSL / + /mnt/c -> /srv";return"provider / -> /srv"}function Q3(l){return l?.status==="OK"||l?.ok===!0}function bO({service:l,active:u,health:r,onSelect:f,onRaw:n}){let i=zQ(l),t=EQ(l),y=OQ(l),c=i.container||{},$=Q3(r?.body);return Vl("button",{type:"button",className:`filebrowser-target-card ${u?"active":""}`,"data-testid":`filebrowser-target-card-${l.id}`,onClick:f},Vl("span",{className:`status-badge ${$?"ok":i.providerStatus==="online"?"running":"warn"}`},$?"Health OK":i.providerStatus||"unknown"),Vl("strong",null,l.name||l.id),Vl("span",null,ZQ(l)),Vl("code",null,`${t.nodeBindHost||"--"}:${t.nodePort||"--"}`),Vl("small",null,c.name?`${c.name} / ${c.state||"--"}`:`${y.composeService||"--"}`),Vl("span",{className:"filebrowser-card-raw",onClick:(A)=>{A.stopPropagation(),n(`${l.name} service`,l)}},"JSON"))}function pQ(l){try{return l?.contentDocument||l?.contentWindow?.document||null}catch{return null}}function Y2(l){let u=pQ(l);if(u===null||u.head===null)return!1;let r=u.getElementById("unidesk-filebrowser-compact-style");if(r===null)r=u.createElement("style"),r.id="unidesk-filebrowser-compact-style",u.head.appendChild(r);if(r.textContent!==X2)r.textContent=X2;return!0}function vO(l,u){let r=URL.createObjectURL(l),f=document.createElement("a");f.href=r,f.download=u,document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(r),2000)}function sO(l,u){let r=pQ(l);if(r===null||r.documentElement===null)throw Error("无法访问 File Browser iframe 文档");Y2(l);let f=Math.max(640,Math.ceil(l.clientWidth||r.documentElement.clientWidth||1280)),n=Math.max(480,Math.ceil(l.clientHeight||r.documentElement.clientHeight||720)),i=r.documentElement.cloneNode(!0);i.querySelectorAll("script, style, link[rel='stylesheet'], link[rel='preload'], link[rel='icon']").forEach((A)=>A.remove()),i.querySelectorAll("img").forEach((A)=>{A.removeAttribute("src"),A.removeAttribute("srcset")});let t=i.querySelector("head");if(t===null)t=r.createElement("head"),i.insertBefore(t,i.firstChild);let y=r.createElement("style");y.textContent=`${X2} +html,body{width:${f}px!important;min-height:${n}px!important;overflow:hidden!important;}`,t.appendChild(y);let c=new XMLSerializer().serializeToString(i),$=`<svg xmlns="http://www.w3.org/2000/svg" width="${f}" height="${n}" viewBox="0 0 ${f} ${n}"><foreignObject width="100%" height="100%">${c}</foreignObject></svg>`;vO(new Blob([$],{type:"image/svg+xml;charset=utf-8"}),u.replace(/\.png$/i,".svg"))}function HQ({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=CO(Array.isArray(l)?l:[]),n=new URLSearchParams(window.location.search).get("target")||"",i=n==="filebrowser-d518"?"filebrowser":n,t=f.some((O)=>O.id===i)?i:f[0]?.id||"",[y,c]=V2(t),[$,A]=V2({loading:!1,refreshedAt:null,health:{},error:""}),[j,F]=V2({exporting:!1,message:"",error:""}),U=XO(null),N=f.find((O)=>O.id===y)||f[0]||null,W=zQ(N),L=EQ(N),J=OQ(N),w=N?$.health[N.id]:null,Q=N?hO(r,N.id,"/"):"about:blank";D2(()=>{if(f.length===0)return;if(!y||!f.some((O)=>O.id===y))c(f[0].id)},[f.map((O)=>O.id).join(",")]),D2(()=>{let O=0,Z=setInterval(()=>{if(O+=1,Y2(U.current)||O>=24)clearInterval(Z)},500);return()=>clearInterval(Z)},[Q]),D2(()=>{if(f.length===0)return;let O=!1;async function Z(){A((Y)=>({...Y,loading:!0,error:""}));let D=await Promise.all(f.map(async(Y)=>{try{let p=await xO(RO(r,Y.id));return[Y.id,{ok:!0,body:p}]}catch(p){return[Y.id,{ok:!1,error:El(p,"File Browser health failed")}]}}));if(O)return;A({loading:!1,refreshedAt:new Date().toISOString(),health:Object.fromEntries(D),error:""})}Z();let E=setInterval(Z,30000);return()=>{O=!0,clearInterval(E)}},[f.map((O)=>`${O.id}:${O.runtime?.providerStatus||""}`).join(","),r]);function q(O){c(O);let Z=new URL(window.location.href);Z.searchParams.set("target",O),window.history.replaceState({},"",`${Z.pathname}${Z.search}`)}async function T(){if(j.exporting)return;F({exporting:!0,message:"",error:""});try{let O=new Date().toISOString().replace(/[-:.TZ]/g,"").slice(0,14);await sO(U.current,`unidesk-filebrowser-${N?.id||"target"}-${O}.png`),F({exporting:!1,message:"截图已导出",error:""})}catch(O){F({exporting:!1,message:"",error:El(O,"截图导出失败")})}}if(f.length===0)return Vl(PO,{title:"File Browser 未登记",text:"请在 config.json 的 microservices 中登记 id=filebrowser 或 filebrowser-* 用户服务"});return Vl("div",{className:"filebrowser-page","data-testid":"filebrowser-page"},$.error?Vl(lu,{error:$.error,wide:!0}):null,Vl(S2,{title:"文件管理器",eyebrow:"File Browser / Host Files",loading:$.loading,actions:Vl("div",{className:"panel-actions"},N?Vl("button",{type:"button",className:"ghost-btn",onClick:T,disabled:j.exporting,"data-testid":"filebrowser-export-screenshot"},j.exporting?"导出中...":"导出截图"):null,N?Vl("a",{className:"ghost-btn",href:Q,target:"_blank",rel:"noreferrer"},"新窗口打开"):null,N?Vl(YO,{title:"File Browser 当前目标",data:{service:N,health:w},onOpen:u,testId:"raw-filebrowser-active"}):null)},Vl("div",{className:"filebrowser-hero"},Vl("div",null,Vl("span",{className:`status-badge ${Q3(w?.body)?"ok":"warn"}`},Q3(w?.body)?"Health OK":"Health Pending"),Vl("h3",null,N?.name||"File Browser"),Vl("p",{className:"muted paragraph"},N?.description||"通过 UniDesk 登录态代理访问,不开放 File Browser 公网端口。"),j.error?Vl("p",{className:"filebrowser-shot-error"},j.error):null,j.message?Vl("p",{className:"filebrowser-shot-ok"},j.message):null),Vl("div",{className:"microservice-ref-card"},Vl("span",null,"Provider"),Vl("strong",null,N?.providerId||"--"),Vl("code",null,W.providerName||N?.providerId||"--")),Vl("div",{className:"microservice-ref-card"},Vl("span",null,"Private Backend"),Vl("strong",null,`${L.nodeBindHost||"--"}:${L.nodePort||"--"}`),Vl("code",null,L.nodeBaseUrl||"--")),Vl("div",{className:"microservice-ref-card"},Vl("span",null,"Image"),Vl("strong",null,J.dockerfile||"filebrowser/filebrowser:v2.63.3"),Vl("code",null,J.commitId||"--")),Vl("div",{className:"microservice-ref-card"},Vl("span",null,"Mount"),Vl("strong",null,ZQ(N)),Vl("code",null,N?.providerId==="main-server"?"/root, /var, /home":"/home, /mnt/c, /mnt/d")))),Vl(S2,{title:"浏览目标",eyebrow:`${f.length} host targets`,loading:$.loading},Vl("div",{className:"filebrowser-target-grid"},f.map((O)=>Vl(bO,{key:O.id,service:O,active:O.id===N?.id,health:$.health[O.id],onSelect:()=>q(O.id),onRaw:u})))),Vl(S2,{title:`${MO(N)} 文件视图`,eyebrow:w?.body?`Health ${Q3(w.body)?"OK":"UNKNOWN"} / ${$.refreshedAt?iu($.refreshedAt):"--"}`:"Embedded WebUI",className:"filebrowser-frame-panel"},Vl("div",{className:"filebrowser-frame-shell"},Vl("div",{className:"filebrowser-frame-toolbar"},Vl("span",null,"BaseURL"),Vl("code",null,`/api/microservices/${N?.id||"filebrowser"}/proxy`),Vl("span",null,"Root"),Vl("code",null,"/srv"),Vl("span",{className:"filebrowser-compact-note"},"Compact layout injected")),Vl("iframe",{ref:U,key:Q,title:`${N?.name||"File Browser"} WebUI`,src:Q,className:"filebrowser-frame","data-testid":"filebrowser-frame",onLoad:(O)=>Y2(O.currentTarget),sandbox:"allow-downloads allow-forms allow-modals allow-same-origin allow-scripts"}))))}var L3=Rl(Ju(),1);var Jl=L3.default.createElement,{useEffect:kO}=L3.default,gO=L3.default.useState;function w3({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return Jl("span",{className:`status-badge ${r}`},u||l||"unknown")}function Ci({label:l,value:u,hint:r,tone:f}){return Jl("article",{className:`metric-card ${f||""}`},Jl("div",{className:"metric-label"},l),Jl("div",{className:"metric-value"},u),Jl("div",{className:"metric-hint"},r))}function q3({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return Jl("section",{className:`panel ${n||""}`},Jl("div",{className:"panel-head"},Jl("div",null,u?Jl("p",{className:"panel-eyebrow"},u):null,Jl(fu,{title:l,loading:i})),r?Jl("div",{className:"panel-actions"},r):null),Jl("div",{className:"panel-body"},f))}function W3({title:l,data:u,onOpen:r,testId:f}){return Jl("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function P2({title:l,text:u}){return Jl("div",{className:"empty-state"},Jl("strong",null,l),Jl("span",null,u))}function IO(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function aO(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function oO(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function M0(l,u){let r=l&&typeof l==="object"?l[u]:void 0;return Number.isFinite(Number(r))?String(r):"--"}function dO(l){return(Array.isArray(l?.jobs)?l.jobs:[]).slice(0,40)}function eO(l){return(Array.isArray(l?.drafts)?l.drafts:[]).slice(0,12)}function BQ({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((N)=>N.id==="findjob")||null,[n,i]=gO({loading:!1,error:"",health:null,summary:null,jobs:null,drafts:null,refreshedAt:null});async function t(){if(!f)return;i((N)=>({...N,loading:!0,error:""}));try{let[N,W,L,J]=await Promise.all([ml(`${r}/microservices/findjob/health`),ml(`${r}/microservices/findjob/proxy/api/summary`),ml(`${r}/microservices/findjob/proxy/api/jobs?__unideskArrayLimit=jobs:40`),ml(`${r}/microservices/findjob/proxy/api/drafts`)]);i({loading:!1,error:"",health:N,summary:W,jobs:L,drafts:J,refreshedAt:new Date})}catch(N){i((W)=>({...W,loading:!1,error:El(N,"FindJob 加载失败")}))}}if(kO(()=>{t()},[f?.id,f?.runtime?.providerStatus]),!f)return Jl(P2,{title:"FindJob 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=findjob"});let y=IO(f),c=oO(f),$=aO(f),A=n.summary||{},j=dO(n.jobs),F=eO(n.drafts),U=n.jobs?._unidesk?.arrayLimits?.jobs;return Jl("div",{className:"findjob-page","data-testid":"findjob-page"},Jl(q3,{title:"FindJob 工作台",eyebrow:"D601 用户服务",loading:n.loading,actions:Jl("div",{className:"panel-actions"},Jl("button",{type:"button",className:"ghost-btn",onClick:t,disabled:n.loading,"data-testid":"findjob-refresh-button"},n.loading?"刷新中":"刷新"),Jl(W3,{title:"FindJob 用户服务",data:f,onOpen:u,testId:"raw-findjob-service"}))},Jl("div",{className:"findjob-hero"},Jl("div",null,Jl("div",{className:"node-version-line"},Jl(w3,{status:y.providerStatus==="online"?"online":"warn"},y.providerStatus||"unknown"),Jl("span",null,f.providerId),Jl("span",null,$.public?"公网暴露":"仅 UniDesk frontend 代理访问")),Jl("p",{className:"muted paragraph"},f.description)),Jl("div",{className:"microservice-ref-card"},Jl("span",null,"Repo"),Jl("strong",null,c.url||"--"),Jl("code",null,c.commitId||"--")),Jl("div",{className:"microservice-ref-card"},Jl("span",null,"D601 Docker"),Jl("strong",null,`${$.nodeBindHost||"--"}:${$.nodePort||"--"}`),Jl("code",null,`${c.composeFile||"--"} / ${c.composeService||"--"}`))),Jl(lu,{error:n.error,wide:!0})),Jl("div",{className:"findjob-grid"},Jl(q3,{title:"岗位指标",eyebrow:n.refreshedAt?`Updated ${iu(n.refreshedAt)}`:"Summary",loading:n.loading},Jl("div",{className:"metric-grid"},Jl(Ci,{label:"岗位总量",value:M0(A,"totalJobs"),hint:"tracked jobs",tone:"ok"}),Jl(Ci,{label:"原始岗位",value:M0(A,"rawJobs"),hint:"raw queue"}),Jl(Ci,{label:"已验证",value:M0(A,"verifiedJobs"),hint:"verified set"}),Jl(Ci,{label:"优先处理",value:M0(A,"prioritizedJobs"),hint:"prioritized"}),Jl(Ci,{label:"过期",value:M0(A,"staleJobs"),hint:"stale jobs",tone:"warn"}),Jl(Ci,{label:"无效",value:M0(A,"invalidJobs"),hint:"invalid jobs",tone:"warn"}),Jl(Ci,{label:"上海",value:M0(A,"shanghaiJobs"),hint:"city filter"}),Jl(Ci,{label:"Health",value:n.health?.ok?"OK":"--",hint:"D601 /api/health"})),Jl("div",{className:"panel-actions inline-actions"},Jl(W3,{title:"FindJob Summary",data:A,onOpen:u,testId:"raw-findjob-summary"}))),Jl(q3,{title:"近期岗位",eyebrow:U?`${U.returnedLength}/${U.originalLength} Preview`:`${j.length} Preview`,loading:n.loading},j.length===0?Jl(P2,{title:"暂无岗位预览",text:"等待 D601 findjob backend 返回 /api/jobs"}):Jl("div",{className:"table-wrap findjob-job-table"},Jl("table",null,Jl("thead",null,Jl("tr",null,Jl("th",null,"优先级"),Jl("th",null,"状态"),Jl("th",null,"单位"),Jl("th",null,"职位"),Jl("th",null,"城市"),Jl("th",null,"阶段"),Jl("th",null,"截止"),Jl("th",null,"证据"))),Jl("tbody",null,j.map((N)=>Jl("tr",{key:N.id},Jl("td",null,Jl(w3,{status:String(N.priority||"").toLowerCase()||"unknown"},N.priority||"--")),Jl("td",null,Jl(w3,{status:String(N.status||"").toLowerCase()||"unknown"},N.status||"--")),Jl("td",null,N.organization_name||"--",Jl("code",null,N.id||"--")),Jl("td",null,N.display_title||N.title||"--"),Jl("td",null,N.display_city||N.city||"--"),Jl("td",null,N.workflow_stage||"--"),Jl("td",null,N.deadline||"--"),Jl("td",null,N.evidence_url?Jl("a",{href:N.evidence_url,target:"_blank",rel:"noreferrer"},"打开"):Jl("span",{className:"muted"},"无"))))))),Jl("div",{className:"panel-actions inline-actions"},Jl(W3,{title:"FindJob Jobs Preview",data:n.jobs,onOpen:u,testId:"raw-findjob-jobs"}))),Jl(q3,{title:"草稿与报告",eyebrow:`${F.length} Drafts`,loading:n.loading},F.length===0?Jl(P2,{title:"暂无草稿",text:"D601 findjob backend 未返回 drafts"}):Jl("div",{className:"draft-list"},F.map((N)=>Jl("article",{key:N.id,className:"draft-card"},Jl("div",{className:"node-card-head"},Jl("strong",null,N.id),Jl(w3,{status:N.status},N.status||"--")),Jl("div",{className:"docker-meta compact"},Jl("span",null,N.workflow_stage||"--"),Jl("span",null,`jobs ${N.counts?.jobs??0}`),Jl("span",null,`reports ${N.counts?.reports??0}`)),Jl("span",null,N.latestReportPath||"暂无报告"),Jl("code",null,Wl(N.updated_at||N.updatedAt))))),Jl("div",{className:"panel-actions inline-actions"},Jl(W3,{title:"FindJob Drafts",data:n.drafts,onOpen:u,testId:"raw-findjob-drafts"})))))}var Jc=Rl(Ju(),1);var R=Jc.default.createElement,{useEffect:lZ}=Jc.default,C2=Jc.default.useState;function Ac(l){let u=Number(l);return Number.isFinite(u)?`${Math.max(0,Math.min(100,u)).toFixed(1)}%`:"--"}function h2(l){if(l===null||l===void 0||l==="")return"--";let u=Number(l);if(!Number.isFinite(u))return"--";if(u<60)return`${Math.max(0,Math.round(u))}s`;if(u<3600)return`${Math.floor(u/60)}m ${Math.round(u%60)}s`;return`${Math.floor(u/3600)}h ${Math.floor(u%3600/60)}m`}function R2(l,u=2){let r=Number(l);if(!Number.isFinite(r))return l===!1?"false":l===!0?"true":"--";let f=Math.abs(r);if(Number.isInteger(r)||f>=1000)return r.toLocaleString("zh-CN",{maximumFractionDigits:0});if(f>=1)return r.toLocaleString("zh-CN",{maximumFractionDigits:u});return r.toLocaleString("zh-CN",{maximumFractionDigits:Math.max(u,6)})}function Fc(l){if(l===null||l===void 0||l==="")return"--";if(typeof l==="boolean")return l?"true":"false";if(typeof l==="number")return R2(l,4);if(Array.isArray(l))return l.map((u)=>Fc(u)).join(" x ");if(typeof l==="object")return"已上报";return String(l)}function G3(l){let u=Number(l);if(!Number.isFinite(u)||u<=0)return"--";let r=u>=100?0:u>=10?1:2;return`${u.toLocaleString("zh-CN",{maximumFractionDigits:r})} epoch/h`}function T3(l){return l.replace(/[^a-zA-Z0-9_-]/g,"-")}function Ir(l){return l&&typeof l==="object"&&!Array.isArray(l)?l:{}}function jc({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return R("span",{className:`status-badge ${r}`},u||l||"unknown")}function Mi({label:l,value:u,hint:r,tone:f}){return R("article",{className:`metric-card ${f||""}`},R("div",{className:"metric-label"},l),R("div",{className:"metric-value"},u),R("div",{className:"metric-hint"},r))}function M2({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return R("section",{className:`panel ${n||""}`},R("div",{className:"panel-head"},R("div",null,u?R("p",{className:"panel-eyebrow"},u):null,R(fu,{title:l,loading:i})),r?R("div",{className:"panel-actions"},r):null),R("div",{className:"panel-body"},f))}function $y({title:l,data:u,onOpen:r,testId:f}){return R("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:(n)=>{n?.stopPropagation?.(),r(l,u)}},"查看原始JSON")}function In({title:l,text:u}){return R("div",{className:"empty-state"},R("strong",null,l),R("span",null,u))}function uZ(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function rZ(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function fZ(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function nZ(l){return l?.counts&&typeof l.counts==="object"&&!Array.isArray(l.counts)?l.counts:{}}function iZ(l){return Array.isArray(l?.jobs)?l.jobs.slice(0,240):[]}function tZ(l){return Array.isArray(l?.projects)?l.projects.slice(0,1000):[]}function m3(l){return Array.isArray(l?.projects)?l.projects:[]}function yZ(l,u){if(Array.isArray(u?.gpu))return u.gpu;if(Array.isArray(l?.gpu))return l.gpu;return[]}function Nf(l,u){return`${l}/microservices/met-nonlinear/proxy${u}`}function DQ(l){return l.startedAt&&l.finishedAt?h2((Date.parse(l.finishedAt)-Date.parse(l.startedAt))/1000):"--"}function cZ(l){let u=l.progress||{};if(u.etaSeconds!==null&&u.etaSeconds!==void 0&&u.etaSeconds!==""){let t=Number(u.etaSeconds);if(Number.isFinite(t))return Math.max(0,t)}let r=Number(u.currentEpoch),f=Number(u.epochTarget??l.epochTarget),n=Date.parse(l.startedAt||"");if(!Number.isFinite(r)||r<=0||!Number.isFinite(f)||f<=r||!Number.isFinite(n))return null;let i=Math.max(0,(Date.now()-n)/1000);if(i<=0)return null;return Math.max(0,i/r*(f-r))}function VQ(l){let u=l.progress||{},r=Number(u.epochPerHour);if(Number.isFinite(r)&&r>0)return r;let f=Date.parse(l.startedAt||""),n=["succeeded","failed","canceled"].includes(l.status)?Date.parse(l.finishedAt||""):Date.now();if(!Number.isFinite(f)||!Number.isFinite(n)||n<=f)return null;let i=Number(u.currentEpoch??l.epochTarget);if(!Number.isFinite(i)||i<=0)return null;return i/((n-f)/3600000)}function SQ(l){if(l==="staged")return"待启动";if(l==="queued")return"排队中";if(l==="running")return"训练中";if(l==="succeeded")return"已完成";if(l==="failed")return"失败";if(l==="canceled")return"已取消";return l||"unknown"}function XQ(l,u,r){return{name:l,path:u,depth:r,count:0,children:[],project:null}}function _Z(l){let u=XQ("","",-1);for(let f of l){let i=String(f?.projectPath||"").replace(/\\/g,"/").split("/").filter(Boolean);if(i.length===0)continue;let t=u,y=[];for(let[c,$]of i.entries()){y.push($);let A=y.join("/"),j=t.children.find((F)=>F.path===A);if(!j)j=XQ($,A,c),t.children.push(j);if(c===i.length-1)j.project=f;t=j}}let r=(f)=>{let n=f.children.reduce((i,t)=>i+r(t),0);return f.count=(f.project?1:0)+n,f.children.sort((i,t)=>{if(Boolean(i.project)!==Boolean(t.project))return i.project?1:-1;return i.name.localeCompare(t.name,"zh-CN",{numeric:!0,sensitivity:"base"})}),f.count};return r(u),u}function $Z(l){let u=Ir(l.data);return Ir(u.project).projectPath?Ir(u.project):u}function AZ(l){return Ir(Ir(l.data).job)}function YQ({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((h)=>h.id==="met-nonlinear")||null,[n,i]=C2({loading:!1,actionBusy:!1,error:"",health:null,summary:null,queue:null,projects:null,history:null,images:null,refreshedAt:null}),[t,y]=C2({loading:!1,error:"",kind:"",key:"",title:"",data:null}),[c,$]=C2(()=>({activeTab:"projects",selectedProjects:{},expandedProjectDirs:{},sourceProject:"",forkCount:1,forkEpochs:200,forkPrefix:`ui_fork_${Date.now()}`,maxConcurrency:3,targetGpuName:"2080 Ti",actionMessage:""}));function A(h){$((a)=>({...a,...h}))}async function j(h=c.activeTab){if(!f)return;i((a)=>({...a,loading:!0,error:""}));try{let a=[["health",ml(`${r}/microservices/met-nonlinear/health`)],["summary",ml(Nf(r,"/api/summary"))]];if(h==="projects")a.push(["projectsRoot",ml(Nf(r,"/api/projects?root=projects&limit=500"))]),a.push(["exProjectsRoot",ml(Nf(r,"/api/projects?root=ex_projects&limit=500"))]);if(h==="current"||h==="completed"||h==="failed")a.push(["queue",ml(Nf(r,"/api/queue"))]);if(h==="completed"||h==="failed")a.push(["history",ml(Nf(r,"/api/history"))]);if(h==="gpu")a.push(["images",ml(Nf(r,"/api/images"))]);let ul=Object.fromEntries(await Promise.all(a.map(async([o,ql])=>[o,await ql]))),zl={loading:!1,actionBusy:!1,error:"",health:ul.health,summary:ul.summary,refreshedAt:new Date};if(ul.projectsRoot||ul.exProjectsRoot){let{projectsRoot:o,exProjectsRoot:ql}=ul;zl.projects={ok:o?.ok!==!1&&ql?.ok!==!1,roots:[{root:"projects",count:m3(o).length},{root:"ex_projects",count:m3(ql).length}],projects:[...m3(o),...m3(ql)]}}if(ul.queue)zl.queue=ul.queue;if(ul.history)zl.history=ul.history;if(ul.images)zl.images=ul.images;i((o)=>({...o,...zl}))}catch(a){i((ul)=>({...ul,loading:!1,actionBusy:!1,error:El(a,"MET Nonlinear 加载失败")}))}}async function F(h,a){i((ul)=>({...ul,actionBusy:!0,error:""})),A({actionMessage:`${h}...`});try{let ul=await a();A({actionMessage:ul||`${h}完成`}),await j()}catch(ul){i((zl)=>({...zl,actionBusy:!1,error:El(ul,`${h}失败`)}))}}async function U(){await F("保存并发设置",async()=>{await ml(Nf(r,"/api/queue/settings"),{method:"PUT",body:JSON.stringify({maxConcurrency:Number(c.maxConcurrency),targetGpuName:c.targetGpuName})})})}function N(){return Object.entries(c.selectedProjects).filter(([,h])=>h).map(([h])=>h)}async function W(){let h=N();if(h.length===0)throw Error("请先选择至少一个 project");await F("加入待启动队列",async()=>{await ml(Nf(r,"/api/queue"),{method:"POST",body:JSON.stringify({projectPaths:h,maxConcurrency:Number(c.maxConcurrency),targetGpuName:c.targetGpuName,start:!1})}),A({activeTab:"current",selectedProjects:{}})})}async function L(){let h=c.sourceProject||B[0]?.projectPath;if(!h)throw Error("请先选择源 project");await F("Fork Project",async()=>{let a=await ml(Nf(r,"/api/projects/fork"),{method:"POST",body:JSON.stringify({sourceProject:h,count:Number(c.forkCount),epochs:Number(c.forkEpochs),prefix:c.forkPrefix})}),ul=Array.isArray(a.projectPaths)?a.projectPaths:[],zl=ul.reduce((o,ql)=>{return o[ql]=!0,o},{...c.selectedProjects});return A({selectedProjects:zl}),`已 fork ${ul.length} 个 project,并已自动勾选;请确认后点击加入待启动队列。`})}async function J(){await F("启动队列",async()=>{await ml(Nf(r,"/api/queue/start"),{method:"POST",body:JSON.stringify({maxConcurrency:Number(c.maxConcurrency),targetGpuName:c.targetGpuName})}),A({activeTab:"current"})})}async function w(h){await F("取消任务",async()=>{await ml(Nf(r,`/api/jobs/${encodeURIComponent(h.id)}/cancel`),{method:"POST",body:JSON.stringify({})})})}async function Q(h){let a=String(h?.projectPath||"");if(!a)return;y({loading:!0,error:"",kind:"project",key:a,title:a,data:null});try{let ul=await ml(Nf(r,`/api/projects/config?path=${encodeURIComponent(a)}`));y({loading:!1,error:"",kind:"project",key:a,title:a,data:ul})}catch(ul){y({loading:!1,error:El(ul,"Project 详情加载失败"),kind:"project",key:a,title:a,data:null})}}async function q(h){let a=String(h?.id||"");if(!a)return;y({loading:!0,error:"",kind:"job",key:a,title:h.projectPath||a,data:null});try{let ul=await ml(Nf(r,`/api/jobs/${encodeURIComponent(a)}`));y({loading:!1,error:"",kind:"job",key:a,title:ul?.job?.projectPath||h.projectPath||a,data:ul})}catch(ul){y({loading:!1,error:El(ul,"Job 详情加载失败"),kind:"job",key:a,title:h.projectPath||a,data:null})}}if(lZ(()=>{j(c.activeTab)},[f?.id,f?.runtime?.providerStatus,c.activeTab]),!f)return R(In,{title:"MET Nonlinear 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=met-nonlinear"});let T=uZ(f),O=fZ(f),Z=rZ(f),E=nZ(n.queue?.queue||n.summary?.queue),D=yZ(n.health,n.queue),Y=n.health?.targetGpu||n.summary?.targetGpu||D.find((h)=>String(h.name||"").includes("2080")),p=n.images?.mlImage||n.health?.image||{},V=iZ(n.queue),B=tZ(n.projects),m=_Z(B),X=c.sourceProject||B[0]?.projectPath||"",S=V.filter((h)=>["staged","queued","running"].includes(h.status)),b=V.filter((h)=>h.status==="succeeded"),z=V.filter((h)=>["failed","canceled"].includes(h.status)),P=Array.isArray(n.history?.jobs)?n.history.jobs.slice(0,120):[],s=[{id:"projects",label:"项目库",count:B.length},{id:"current",label:"当前队列",count:S.length||Number(E.staged||0)+Number(E.queued||0)+Number(E.running||0)},{id:"completed",label:"已完成",count:b.length||Number(E.succeeded||0)},{id:"failed",label:"失败诊断",count:z.length||Number(E.failed||0)+Number(E.canceled||0)},{id:"gpu",label:"GPU/镜像",count:D.length}];function k(h,a){if(h.length===0)return R(In,{title:a==="current"?"当前队列为空":"暂无记录",text:a==="current"?"从项目库选择或 fork project 后先加入待启动队列,再启动队列。":"终态任务会显示耗时、exit code 和失败诊断。"});return R("div",{className:"table-wrap met-job-table"},R("table",null,R("thead",null,R("tr",null,R("th",null,"状态"),R("th",null,"Project"),R("th",null,"Epoch"),R("th",null,"速度"),R("th",null,"ETA/耗时"),R("th",null,"GPU"),R("th",null,"Exit"),R("th",null,"更新时间"),R("th",null,"操作"))),R("tbody",null,h.map((ul)=>{let zl=ul.progress||{},o=["staged","queued","running"].includes(ul.status),ql=t.kind==="job"&&t.key===ul.id;return R("tr",{key:ul.id,className:`met-click-row ${ql?"active":""}`,onClick:()=>q(ul),"data-testid":`met-job-row-${T3(ul.id)}`},R("td",null,R(jc,{status:ul.status},SQ(ul.status))),R("td",null,R("button",{type:"button",className:"met-inline-link",onClick:(pl)=>{pl.stopPropagation(),q(ul)}},ul.projectPath),R("code",null,ul.id)),R("td",null,R("span",null,`${zl.currentEpoch??"--"} / ${zl.epochTarget??ul.epochTarget??"--"}`),R("div",{className:"met-progress"},R("span",{style:{width:Ac(zl.progressPercent)}}))),R("td",null,R("strong",null,G3(VQ(ul)))),R("td",null,ul.status==="succeeded"||ul.status==="failed"||ul.status==="canceled"?DQ(ul):ul.status==="running"?`ETA ${h2(cZ(ul))}`:"--"),R("td",null,ul.gpuName||"--"),R("td",null,ul.exitCode??"--"),R("td",null,Wl(ul.updatedAt)),R("td",null,o?R("button",{type:"button",className:"ghost-btn mini",onClick:(pl)=>{pl.stopPropagation(),w(ul)},disabled:n.actionBusy},"取消"):null,R($y,{title:`MET Job ${ul.id}`,data:ul,onOpen:u,testId:`raw-met-job-${ul.id}`})))}))))}function v(){return R("div",{className:"met-queue-summary","data-testid":"met-current-summary"},R(jc,{status:"staged"},`待启动 ${E.staged??0}`),R(jc,{status:"queued"},`排队中 ${E.queued??0}`),R(jc,{status:"running"},`训练中 ${E.running??0}`),R("span",null,`最大并发 ${n.summary?.queue?.maxConcurrency??n.queue?.queue?.maxConcurrency??c.maxConcurrency}`),R("span",null,`目标 GPU ${n.summary?.queue?.targetGpuName??n.queue?.queue?.targetGpuName??c.targetGpuName}`))}function tl(h,a){let ul=c.expandedProjectDirs[h];return ul===void 0?a<2:Boolean(ul)}function I(h,a){let ul=tl(h,a);A({expandedProjectDirs:{...c.expandedProjectDirs,[h]:!ul}})}function M(h){let a=8+Math.max(0,h.depth)*16;if(Boolean(h.project)){let o=h.project,ql=Boolean(c.selectedProjects[o.projectPath]),pl=t.kind==="project"&&t.key===o.projectPath;return R("div",{key:h.path,className:`met-tree-row project ${ql?"selected":""} ${pl?"active":""}`,style:{paddingLeft:a},onClick:()=>Q(o),"data-testid":`met-project-node-${T3(o.projectPath)}`},R("div",{className:"met-tree-name"},R("input",{type:"checkbox",checked:ql,onClick:(Bl)=>Bl.stopPropagation(),onChange:(Bl)=>A({selectedProjects:{...c.selectedProjects,[o.projectPath]:Bl.target.checked}}),"data-testid":`met-project-checkbox-${T3(o.projectPath)}`}),R("button",{type:"button",className:"met-inline-link project-path",onClick:(Bl)=>{Bl.stopPropagation(),Q(o)}},h.name)),R("span",null,o.useModel||"--"),R("span",null,o.epochTrain??"--"),R("span",null,Ac(o.progress?.progressPercent)),R("span",null,G3(o.progress?.epochPerHour)))}let zl=tl(h.path,h.depth);return R(Jc.default.Fragment,{key:h.path},R("div",{className:"met-tree-row folder",style:{paddingLeft:a},"data-testid":`met-project-folder-${T3(h.path)}`},R("button",{type:"button",className:"met-tree-toggle",onClick:()=>I(h.path,h.depth),"aria-label":zl?`折叠 ${h.path}`:`展开 ${h.path}`},zl?"-":"+"),R("strong",null,h.name),R("span",{className:"met-tree-count"},`${h.count} projects`)),zl?h.children.map((o)=>M(o)):null)}function rl(h){return R("div",{className:"met-detail-kv"},h.map((a)=>R("div",{key:a.label,className:"met-detail-kv-item"},R("span",null,a.label),R("strong",null,Fc(a.value)),a.hint?R("small",null,a.hint):null)))}function cl(h,a){return R("div",{className:"met-detail-section"},R("h3",null,h),rl(a))}function $l(h){if(!Array.isArray(h)||h.length===0)return R(In,{title:"模型层未上报",text:"等待 data/model_info.json 或 compute_analysis.json 生成。"});return R("div",{className:"table-wrap met-layer-table"},R("table",null,R("thead",null,R("tr",null,R("th",null,"Layer"),R("th",null,"Type"),R("th",null,"Params"),R("th",null,"Trainable"),R("th",null,"Compute"))),R("tbody",null,h.slice(0,18).map((a,ul)=>R("tr",{key:`${a.name||"layer"}-${ul}`},R("td",null,a.name||`#${ul+1}`),R("td",null,a.type||"--"),R("td",null,R2(a.num_params)),R("td",null,a.trainable===void 0?"--":String(Boolean(a.trainable))),R("td",null,R2(a.compute?.total??a.estimated_cost?.weighted_units?.total)))))))}function Tl(h){let a=Array.isArray(h)?h:[];if(a.length===0)return R(In,{title:"data/ 暂无文件",text:"训练或评估完成后会生成 training_state、metrics、model_info 等文件。"});return R("div",{className:"met-file-chip-grid"},a.slice(0,48).map((ul)=>R("span",{key:ul},ul)),a.length>48?R("span",null,`+${a.length-48}`):null)}function Ql(h){let a=String(h||"").replace(/\x1b\[[0-9;]*[A-Za-z]/g,"").split(/\r?\n/).map((ul)=>ul.trim()).filter(Boolean).slice(-12);if(a.length===0)return R(In,{title:"暂无日志尾部",text:"该任务未上报 logTail 或日志已轮转。"});return R("div",{className:"met-log-lines"},a.map((ul,zl)=>R("div",{key:`${zl}-${ul.slice(0,16)}`},ul)))}function Ol(){if(t.loading)return R("section",{className:"met-detail-panel","data-testid":"met-detail-panel"},R("div",{className:"panel-head compact"},R("div",null,R("p",{className:"panel-eyebrow"},"Detail Loading"),R(fu,{title:"详情加载中",loading:!0}))),R(In,{title:"详情加载中",text:t.title||"正在读取 D601 data/ 和 config.json"}));if(t.error)return R("section",{className:"met-detail-panel","data-testid":"met-detail-panel"},R(lu,{error:t.error,wide:!0}));if(!t.data)return R("section",{className:"met-detail-panel muted","data-testid":"met-detail-panel"},R(In,{title:"选择一个项目或任务查看详情",text:"项目库、当前队列、已完成和失败诊断中的行都可以点击;默认只展示结构化字段,原始 JSON 需显式点击按钮。"}));let h=$Z(t),a=AZ(t),ul=Ir(h.config),zl=Ir(h.progress||a.progress),o=Ir(h.data),ql=Ir(h.metrics||o.metrics||zl.trainingInfo?.evaluation_metrics),pl=Ir(o.trainingInfo||zl.trainingInfo),Bl=Ir(o.trainingState),Il=Ir(h.model||o.model),nu=Array.isArray(Il.modelSummary)&&Il.modelSummary.length>0?Il.modelSummary:Il.computeLayers,Ml=Ir(pl.evaluation_metrics),wu=t.kind==="job"?"训练任务详情":"Project 详情";return R("section",{className:"met-detail-panel","data-testid":"met-detail-panel"},R("div",{className:"panel-head compact"},R("div",null,R("p",{className:"panel-eyebrow"},t.kind==="job"?"Job + Project Detail":"Project Library Detail"),R(fu,{title:wu}),R("code",null,h.projectPath||a.projectPath||t.title)),R("div",{className:"panel-actions"},R($y,{title:`MET ${wu}`,data:t.data,onOpen:u,testId:"raw-met-detail"}))),t.kind==="job"?cl("任务状态",[{label:"Job ID",value:a.id},{label:"状态",value:SQ(a.status)},{label:"GPU",value:a.gpuName},{label:"Exit Code",value:a.exitCode},{label:"耗时",value:DQ(a)},{label:"训练速度",value:G3(VQ({...a,progress:zl}))}]):null,cl("config.json",[{label:"use_model",value:ul.use_model},{label:"epoch_train",value:ul.epoch_train},{label:"step_per_epoch",value:ul.step_per_epoch},{label:"learning_rate",value:ul.learning_rate},{label:"using_gpu",value:ul.using_gpu},{label:"use_points",value:ul.use_points},{label:"sample_rate",value:ul.sample_rate},{label:"time_clipped_s",value:ul.time_clipped_s},{label:"H_UNITS",value:ul.H_UNITS},{label:"INNER_KAN_UNITS",value:ul.INNER_KAN_UNITS},{label:"INNER_KAN_LAYERS",value:ul.INNER_KAN_LAYERS},{label:"GRID_SIZE",value:ul.GRID_SIZE},{label:"SPLINE_ORDER",value:ul.SPLINE_ORDER},{label:"USE_FAST_MODEL",value:ul.USE_FAST_MODEL},{label:"IIR_TRAINABLE",value:ul.IIR_TRAINABLE}]),cl("data/ 训练状态",[{label:"Epoch",value:`${zl.currentEpoch??Bl.current_epoch??Bl.completed_epoch??"--"} / ${zl.epochTarget??ul.epoch_train??"--"}`},{label:"Progress",value:Ac(zl.progressPercent)},{label:"Last Loss",value:zl.lastLoss??Bl.loss},{label:"Last Val Loss",value:zl.lastValLoss??Bl.val_loss},{label:"Min Loss",value:pl.min_loss??Bl.min_loss},{label:"Min Val Loss",value:pl.min_val_loss??Bl.min_val_loss},{label:"Log Lines",value:zl.logLineCount},{label:"ETA",value:h2(zl.etaSeconds??Bl.remaining_time)},{label:"训练速度",value:G3(zl.epochPerHour??Bl.smoothed_speed)},{label:"Training Alive",value:Bl.training_alive}]),cl("模型参数",[{label:"Model Type",value:Il.modelType??ul.use_model},{label:"Total Params",value:Il.totalParams,hint:Il.totalParams===null||Il.totalParams===void 0?"未上报":"data/model_info.json"},{label:"Trainable",value:Il.trainableParams},{label:"Non-trainable",value:Il.nonTrainableParams},{label:"Compute Cost",value:Il.computeCost},{label:"Estimate Status",value:Il.estimateStatus},{label:"Unsupported Layers",value:Il.unsupportedLayerCount}]),cl("指标",[{label:"train_loss",value:ql.train_loss??Ml.train_loss},{label:"val_loss",value:ql.val_loss??Ml.val_loss},{label:"train_mae",value:ql.train_mae??Ml.train_mae},{label:"val_mae",value:ql.val_mae??Ml.val_mae},{label:"train_afmae",value:ql.train_afmae??Ml.train_afmae},{label:"val_afmae",value:ql.val_afmae??Ml.val_afmae},{label:"freq_drift_hz",value:ql.freq_drift_hz},{label:"sens_drift_percent",value:ql.sens_drift_percent},{label:"linearity_percent",value:ql.linearity_percent},{label:"weights_source",value:ql.weights_source??Ml.weights_source},{label:"lr min/mean/max",value:`${Fc(pl.learning_rate_min)} / ${Fc(pl.learning_rate_mean)} / ${Fc(pl.learning_rate_max)}`}]),R("div",{className:"met-detail-section"},R("h3",null,"模型层"),$l(nu)),R("div",{className:"met-detail-section"},R("h3",null,"data/ 文件"),Tl(o.files)),t.kind==="job"?R("div",{className:"met-detail-section"},R("h3",null,"日志尾部"),Ql(Ir(t.data).logTail)):null)}return R("div",{className:"met-page","data-testid":"met-nonlinear-page"},R(M2,{title:"MET Nonlinear 训练编排",eyebrow:"D601 GPU 用户服务",loading:n.loading||n.actionBusy,actions:R("div",{className:"panel-actions"},R("button",{type:"button",className:"ghost-btn",onClick:j,disabled:n.loading,"data-testid":"met-refresh-button"},n.loading?"刷新中":"刷新"),R($y,{title:"MET Nonlinear 用户服务",data:f,onOpen:u,testId:"raw-met-service"}))},R("div",{className:"findjob-hero"},R("div",null,R("div",{className:"node-version-line"},R(jc,{status:T.providerStatus==="online"?"online":"warn"},T.providerStatus||"unknown"),R("span",null,f.providerId),R("span",null,Z.public?"公网暴露":"仅 UniDesk frontend 代理访问")),R("p",{className:"muted paragraph"},f.description)),R("div",{className:"microservice-ref-card"},R("span",null,"Repo"),R("strong",null,O.url||"--"),R("code",null,O.commitId||"--")),R("div",{className:"microservice-ref-card"},R("span",null,"D601 Docker"),R("strong",null,`${Z.nodeBindHost||"--"}:${Z.nodePort||"--"}`),R("code",null,`${O.composeFile||"--"} / ${O.containerName||"--"}`))),R(lu,{error:n.error,wide:!0}),c.actionMessage?R("div",{className:"met-action-log","data-testid":"met-action-message"},c.actionMessage):null),R("div",{className:"met-grid"},R(M2,{title:"核心状态",eyebrow:n.refreshedAt?`Updated ${iu(n.refreshedAt)}`:"Queue + GPU",loading:n.loading},R("div",{className:"metric-grid"},R(Mi,{label:"Staged",value:E.staged??0,hint:"加入队列未开始",tone:Number(E.staged||0)>0?"warn":""}),R(Mi,{label:"Queued",value:E.queued??0,hint:"排队等待调度",tone:Number(E.queued||0)>0?"warn":""}),R(Mi,{label:"Running",value:E.running??0,hint:`max ${n.summary?.queue?.maxConcurrency??n.queue?.queue?.maxConcurrency??"--"}`,tone:Number(E.running||0)>0?"ok":""}),R(Mi,{label:"Succeeded",value:E.succeeded??0,hint:"已完成"}),R(Mi,{label:"Failed",value:E.failed??0,hint:"需要诊断",tone:Number(E.failed||0)>0?"warn":""}),R(Mi,{label:"2080Ti Free",value:Y?Ac(Number(Y.freeRatio)*100):"--",hint:Y?`${Y.memoryFreeMiB}/${Y.memoryTotalMiB} MiB`:"等待 GPU 上报"}),R(Mi,{label:"ML Image",value:p.present?"READY":"MISSING",hint:p.image||"met-nonlinear-ml:tf26",tone:p.present?"ok":"warn"}),R(Mi,{label:"Health",value:n.health?.ok?"OK":"--",hint:"D601 /health"}))),R(M2,{title:"队列控制",eyebrow:"Downloader-like staging",loading:n.actionBusy},R("div",{className:"met-control-strip"},R("label",null,"最大并发",R("input",{type:"number",min:1,max:16,value:c.maxConcurrency,"data-testid":"met-max-concurrency-input",onChange:(h)=>A({maxConcurrency:h.target.value})})),R("label",null,"目标 GPU",R("input",{value:c.targetGpuName,"data-testid":"met-target-gpu-input",onChange:(h)=>A({targetGpuName:h.target.value})})),R("button",{type:"button",className:"ghost-btn",onClick:U,disabled:n.actionBusy,"data-testid":"met-save-settings-button"},"保存设置"),R("button",{type:"button",className:"primary-btn",onClick:J,disabled:n.actionBusy||Number(E.staged||0)===0,"data-testid":"met-start-queue-button"},"启动队列")),R("p",{className:"muted paragraph"},"Project 先进入待启动队列,不会立即训练;点击启动队列后才切换为排队中,并由 D601 scheduler 按最大并发和 2080Ti 显存策略调度。")),R("section",{className:"panel met-workspace"},R("div",{className:"met-tabs",role:"tablist"},s.map((h)=>R("button",{key:h.id,type:"button",className:c.activeTab===h.id?"active":"",onClick:()=>A({activeTab:h.id}),"data-testid":`met-tab-${h.id}`},`${h.label} ${h.count}`))),R("div",{className:"panel-body"},c.activeTab==="projects"?R("div",{className:"met-form-grid","data-testid":"met-projects-pane"},R("div",{className:"met-fork-card"},R("h3",null,"Fork Project"),R("label",null,"源 Project",R("select",{value:X,"data-testid":"met-source-project-select",onChange:(h)=>A({sourceProject:h.target.value})},B.map((h)=>R("option",{key:h.projectPath,value:h.projectPath},`${h.projectPath} · ${h.useModel||"model?"}`)))),R("label",null,"Fork 数量",R("input",{type:"number",min:1,max:100,value:c.forkCount,"data-testid":"met-fork-count-input",onChange:(h)=>A({forkCount:h.target.value})})),R("label",null,"训练轮数",R("input",{type:"number",min:1,max:1e5,value:c.forkEpochs,"data-testid":"met-fork-epochs-input",onChange:(h)=>A({forkEpochs:h.target.value})})),R("label",null,"目标前缀",R("input",{value:c.forkPrefix,"data-testid":"met-fork-prefix-input",onChange:(h)=>A({forkPrefix:h.target.value})})),R("button",{type:"button",className:"primary-btn",onClick:L,disabled:n.actionBusy||!X,"data-testid":"met-fork-button"},"Fork Project"),R("p",{className:"muted paragraph"},"Fork 只创建新 Project 并自动勾选,不会直接训练;需要在右侧确认后加入待启动队列。")),R("div",{className:"met-project-list"},R("div",{className:"panel-head compact"},R("div",null,R("p",{className:"panel-eyebrow"},`Existing Projects · ${(n.projects?.roots||[]).map((h)=>`${h.root} ${h.count}`).join(" / ")}`),R(fu,{title:"选择已有 Project",loading:n.loading||n.actionBusy})),R("button",{type:"button",className:"ghost-btn",onClick:W,disabled:n.actionBusy||N().length===0,"data-testid":"met-stage-selected-button"},`加入待启动队列 (${N().length})`)),B.length===0?R(In,{title:"暂无 project",text:"等待 D601 返回 /api/projects"}):R("div",{className:"met-project-table","data-testid":"met-project-tree"},R("div",{className:"met-tree-header"},R("span",null,"文件树 Project"),R("span",null,"Model"),R("span",null,"Epochs"),R("span",null,"Progress"),R("span",null,"速度")),m.children.map((h)=>M(h)))),Ol()):null,c.activeTab==="current"?R("div",{"data-testid":"met-current-pane"},v(),k(S,"current"),Ol(),R("div",{className:"panel-actions inline-actions"},R($y,{title:"MET Queue",data:n.queue,onOpen:u,testId:"raw-met-queue"}))):null,c.activeTab==="completed"?R("div",{"data-testid":"met-completed-pane"},k(b.length>0?b:P.filter((h)=>h.status==="succeeded"),"completed"),Ol()):null,c.activeTab==="failed"?R("div",{"data-testid":"met-failed-pane"},k(z.length>0?z:P.filter((h)=>["failed","canceled"].includes(h.status)),"failed"),Ol(),R("div",{className:"panel-actions inline-actions"},R($y,{title:"MET History",data:n.history,onOpen:u,testId:"raw-met-history"}))):null,c.activeTab==="gpu"?R("div",{className:"met-gpu-pane","data-testid":"met-gpu-pane"},D.length===0?R(In,{title:"暂无 GPU 上报",text:"等待 D601 met-nonlinear-ts 或 ML image 提供 nvidia-smi 数据"}):R("div",{className:"table-wrap"},R("table",null,R("thead",null,R("tr",null,R("th",null,"Index"),R("th",null,"Name"),R("th",null,"Free"),R("th",null,"Policy"))),R("tbody",null,D.map((h)=>R("tr",{key:h.index},R("td",null,h.index),R("td",null,h.name),R("td",null,`${h.memoryFreeMiB} / ${h.memoryTotalMiB} MiB`,R("div",{className:"met-progress"},R("span",{style:{width:Ac(Number(h.freeRatio)*100)}}))),R("td",null,String(h.name||"").includes("2080")?"target 2080Ti, <20% 限制并发":"non-target")))))),R("div",{className:"panel-actions inline-actions"},R($y,{title:"MET Images",data:n.images,onOpen:u,testId:"raw-met-images"}))):null))))}var O3=Rl(Ju(),1);var Nl=O3.default.createElement,{useEffect:PQ,useMemo:jZ}=O3.default,K3=O3.default.useState;function CQ({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return Nl("span",{className:`status-badge ${r}`},u||l||"unknown")}function Uc({label:l,value:u,hint:r,tone:f}){return Nl("article",{className:`metric-card ${f||""}`},Nl("div",{className:"metric-label"},l),Nl("div",{className:"metric-value"},u),Nl("div",{className:"metric-hint"},r))}function z3({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return Nl("section",{className:`panel ${n||""}`},Nl("div",{className:"panel-head"},Nl("div",null,u?Nl("p",{className:"panel-eyebrow"},u):null,Nl(fu,{title:l,loading:i})),r?Nl("div",{className:"panel-actions"},r):null),Nl("div",{className:"panel-body"},f))}function x2({title:l,data:u,onOpen:r,testId:f}){return Nl("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function E3({title:l,text:u}){return Nl("div",{className:"empty-state"},Nl("strong",null,l),Nl("span",null,u))}function FZ(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function JZ(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function UZ(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function Ay(l,u){return`${l}/microservices/mdtodo/proxy${u}`}function MQ(l){if(l==="completed")return"已完成";if(l==="in_progress")return"进行中";return"待处理"}function NZ(l){if(l==="completed")return"online";if(l==="in_progress")return"warn";return"unknown"}function b2(l){let u=[],r=(f)=>{for(let n of f)if(u.push(n),Array.isArray(n.children))r(n.children)};return r(Array.isArray(l)?l:[]),u}function QZ({tasks:l,selectedId:u,onSelect:r}){if(!l.length)return Nl(E3,{title:"暂无任务",text:"当前文件没有 R 编号任务。"});let f=(n)=>Nl("li",{key:n.id},Nl("button",{type:"button",className:`mdtodo-task-row ${u===n.id?"active":""}`,style:{"--task-depth":Math.min(Number(n.depth||0),6)},onClick:()=>r(n.id),"data-testid":`mdtodo-task-${String(n.id).replace(/[^A-Za-z0-9_-]+/g,"-")}`},Nl(CQ,{status:NZ(n.status)},MQ(n.status)),Nl("code",null,n.id),Nl("span",{className:"mdtodo-task-title"},n.title||"--"),Nl("span",{className:"mdtodo-link-count"},`${n.linkExists??0}/${n.linkCount??0}`)),Array.isArray(n.children)&&n.children.length>0?Nl("ol",null,n.children.map(f)):null);return Nl("ol",{className:"mdtodo-tree"},l.map(f))}function hQ({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((Y)=>Y.id==="mdtodo")||null,[n,i]=K3({loading:!1,saving:!1,error:"",notice:"",health:null,files:[],todo:null,selectedFile:"",selectedTaskId:"",refreshedAt:null,command:null}),[t,y]=K3(""),[c,$]=K3(""),[A,j]=K3(""),F=Array.isArray(n.todo?.tasks)?n.todo.tasks:[],U=jZ(()=>b2(F),[n.todo]),N=U.find((Y)=>Y.id===n.selectedTaskId)||U[0]||null,W=n.todo?.stats||{};async function L(Y=n.selectedFile){if(!f)return;i((p)=>({...p,loading:!0,error:"",notice:""}));try{let[p,V]=await Promise.all([ml(`${r}/microservices/mdtodo/health`),ml(Ay(r,"/api/files"))]),B=Array.isArray(V.files)?V.files:[],m=Y||B[0]?.path||"",X=m?await ml(Ay(r,`/api/tasks?file=${encodeURIComponent(m)}`)):null,S=Array.isArray(X?.tasks)?b2(X.tasks):[],b=S.some((z)=>z.id===n.selectedTaskId)?n.selectedTaskId:S[0]?.id||"";i({loading:!1,saving:!1,error:"",notice:"",health:p,files:B,todo:X,selectedFile:m,selectedTaskId:b,refreshedAt:new Date,command:n.command})}catch(p){i((V)=>({...V,loading:!1,error:El(p,"MDTODO 加载失败")}))}}if(PQ(()=>{L()},[f?.id,f?.runtime?.providerStatus]),PQ(()=>{y(N?.title||""),$(N?.rawContent||"")},[N?.id,n.selectedFile]),!f)return Nl(E3,{title:"MDTODO 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=mdtodo"});let J=FZ(f),w=UZ(f),Q=JZ(f);async function q(Y){i((p)=>({...p,selectedFile:Y,selectedTaskId:"",command:null})),await L(Y)}async function T(Y){if(!N||!n.selectedFile)return;i((p)=>({...p,saving:!0,error:"",notice:""}));try{let p=await ml(Ay(r,`/api/tasks/${encodeURIComponent(N.id)}`),{method:"PATCH",body:{file:n.selectedFile,...Y}});i((V)=>({...V,saving:!1,todo:p.file,notice:p.result?.message||"任务已更新"}))}catch(p){i((V)=>({...V,saving:!1,error:El(p,"任务更新失败")}))}}async function O(){await T({title:t,rawContent:c})}async function Z(Y){if(!n.selectedFile)return;i((p)=>({...p,saving:!0,error:"",notice:""}));try{let p=await ml(Ay(r,"/api/tasks"),{method:"POST",body:{file:n.selectedFile,parentId:Y,title:A||"新任务"}});j(""),i((V)=>({...V,saving:!1,todo:p.file,selectedTaskId:p.result?.taskId||V.selectedTaskId,notice:p.result?.message||"任务已创建"})),await L(n.selectedFile)}catch(p){i((V)=>({...V,saving:!1,error:El(p,"创建任务失败")}))}}async function E(){if(!N||!n.selectedFile)return;if(!window.confirm(`删除 ${N.id} 及其子任务?`))return;i((Y)=>({...Y,saving:!0,error:"",notice:""}));try{let Y=await ml(Ay(r,`/api/tasks/${encodeURIComponent(N.id)}?file=${encodeURIComponent(n.selectedFile)}`),{method:"DELETE"}),p=b2(Y.file?.tasks||[]);i((V)=>({...V,saving:!1,todo:Y.file,selectedTaskId:p[0]?.id||"",notice:Y.result?.message||"任务已删除"}))}catch(Y){i((p)=>({...p,saving:!1,error:El(Y,"删除任务失败")}))}}async function D(){if(!N||!n.selectedFile)return;i((Y)=>({...Y,saving:!0,error:"",command:null}));try{let Y=await ml(Ay(r,"/api/execute-command"),{method:"POST",body:{file:n.selectedFile,taskId:N.id,mode:"codex"}});i((p)=>({...p,saving:!1,command:Y,notice:"执行命令已生成"}))}catch(Y){i((p)=>({...p,saving:!1,error:El(Y,"执行命令生成失败")}))}}return Nl("div",{className:"mdtodo-page","data-testid":"mdtodo-page"},Nl(z3,{title:"MDTODO 工作台",eyebrow:"D601 k3s managed service",loading:n.loading,actions:Nl("div",{className:"panel-actions"},Nl("button",{type:"button",className:"ghost-btn",onClick:()=>void L(),disabled:n.loading,"data-testid":"mdtodo-refresh-button"},n.loading?"刷新中":"刷新"),Nl(x2,{title:"MDTODO 用户服务",data:f,onOpen:u,testId:"raw-mdtodo-service"}))},Nl("div",{className:"findjob-hero"},Nl("div",null,Nl("div",{className:"node-version-line"},Nl(CQ,{status:J.providerStatus==="online"?"online":"warn"},J.providerStatus||"unknown"),Nl("span",null,f.providerId),Nl("span",null,Q.proxyMode||"--")),Nl("p",{className:"muted paragraph"},f.description)),Nl("div",{className:"microservice-ref-card"},Nl("span",null,"Repo"),Nl("strong",null,w.url||"--"),Nl("code",null,w.composeFile||"--")),Nl("div",{className:"microservice-ref-card"},Nl("span",null,"Workspace"),Nl("strong",null,n.health?.rootDir||"/workspace"),Nl("code",null,`${Q.nodeBindHost||"--"}:${Q.nodePort||"--"}`))),Nl(lu,{error:n.error,wide:!0}),n.notice?Nl("div",{className:"notice-line"},n.notice):null),Nl("div",{className:"metric-grid"},Nl(Uc,{label:"TODO 文件",value:n.files.length,hint:n.health?.rootExists?"hostPath ready":"hostPath missing",tone:n.health?.ok?"ok":"warn"}),Nl(Uc,{label:"任务总数",value:W.total??"--",hint:n.selectedFile||"--"}),Nl(Uc,{label:"已完成",value:W.completed??"--",hint:"completed",tone:"ok"}),Nl(Uc,{label:"进行中",value:W.inProgress??"--",hint:"in progress",tone:"warn"}),Nl(Uc,{label:"待处理",value:W.pending??"--",hint:n.refreshedAt?iu(n.refreshedAt):"pending"})),Nl("div",{className:"mdtodo-layout"},Nl(z3,{title:"文件",eyebrow:`${n.files.length} Markdown`,loading:n.loading,className:"mdtodo-file-panel"},n.files.length===0?Nl(E3,{title:"暂无 TODO 文件",text:"等待后端扫描 MDTODO 工作区。"}):Nl("div",{className:"mdtodo-file-list"},n.files.map((Y)=>Nl("button",{key:Y.path,type:"button",className:`mdtodo-file-item ${n.selectedFile===Y.path?"active":""}`,onClick:()=>void q(Y.path)},Nl("strong",null,Y.name),Nl("span",null,Y.directory||"."),Nl("code",null,`${Y.stats?.total??"--"} tasks / ${Wl(Y.mtime)}`))))),Nl(z3,{title:"任务树",eyebrow:n.selectedFile||"Tasks",loading:n.loading,actions:Nl("div",{className:"panel-actions"},Nl("input",{value:A,onChange:(Y)=>j(Y.target.value),placeholder:"新任务标题","data-testid":"mdtodo-new-title"}),Nl("button",{type:"button",className:"ghost-btn",onClick:()=>void Z(),disabled:n.saving||!n.selectedFile},"新增"),N?Nl("button",{type:"button",className:"ghost-btn",onClick:()=>void Z(N.id),disabled:n.saving},"新增子任务"):null,n.todo?Nl(x2,{title:"MDTODO 当前文件",data:n.todo,onOpen:u,testId:"raw-mdtodo-file"}):null)},Nl(QZ,{tasks:F,selectedId:N?.id||"",onSelect:(Y)=>i((p)=>({...p,selectedTaskId:Y,command:null}))})),Nl(z3,{title:N?`${N.id} 详情`:"任务详情",eyebrow:N?MQ(N.status):"Detail",loading:n.saving,className:"mdtodo-detail-panel",actions:N?Nl("div",{className:"panel-actions"},Nl("button",{type:"button",className:"ghost-btn",onClick:()=>void T({status:"pending"}),disabled:n.saving},"待处理"),Nl("button",{type:"button",className:"ghost-btn",onClick:()=>void T({status:"in_progress"}),disabled:n.saving},"进行中"),Nl("button",{type:"button",className:"primary-btn",onClick:()=>void T({status:"completed"}),disabled:n.saving},"完成")):null},!N?Nl(E3,{title:"未选中任务",text:"请选择一个任务。"}):Nl("div",{className:"mdtodo-editor"},Nl("label",null,"标题",Nl("input",{value:t,onChange:(Y)=>y(Y.target.value),"data-testid":"mdtodo-title-input"})),Nl("label",null,"正文",Nl("textarea",{value:c,onChange:(Y)=>$(Y.target.value),rows:12,"data-testid":"mdtodo-raw-input"})),Nl("div",{className:"docker-meta compact"},Nl("span",null,`line ${Number(N.lineNumber??0)+1}`),Nl("span",null,`depth ${N.depth??0}`),Nl("span",null,`links ${N.linkExists??0}/${N.linkCount??0}`)),Nl("div",{className:"inline-actions"},Nl("button",{type:"button",className:"primary-btn",onClick:O,disabled:n.saving},n.saving?"保存中":"保存"),Nl("button",{type:"button",className:"ghost-btn",onClick:D,disabled:n.saving},"生成执行命令"),Nl("button",{type:"button",className:"danger-btn",onClick:E,disabled:n.saving},"删除"),Nl(x2,{title:`MDTODO ${N.id}`,data:N,onOpen:u,testId:"raw-mdtodo-task"})),n.command?Nl("div",{className:"mdtodo-command"},Nl("span",null,n.command.prompt||"--"),Nl("code",null,n.command.command||"--")):null))))}var p3=[{id:"ops",label:"运行总览",code:"OPS",tabs:[{id:"status",label:"态势总览"},{id:"performance",label:"性能面板"},{id:"events",label:"事件摘要"},{id:"logs",label:"服务日志"}]},{id:"nodes",label:"资源节点",code:"NODE",tabs:[{id:"list",label:"节点清单"},{id:"monitor",label:"资源监控"},{id:"docker",label:"Docker 状态"},{id:"gateway",label:"网关版本"},{id:"labels",label:"资源标签"},{id:"heartbeats",label:"心跳状态"}]},{id:"tasks",label:"任务调度",code:"TASK",tabs:[{id:"dispatch",label:"下发任务"},{id:"scheduled",label:"定时任务"},{id:"pending",label:"待处理任务"},{id:"history",label:"任务历史"},{id:"results",label:"执行结果"}]},{id:"apps",label:"用户服务",code:"APP",routeSegment:"app",tabs:[{id:"catalog",label:"服务目录"},{id:"todo-note",label:"Todo Note"},{id:"findjob",label:"FindJob"},{id:"pipeline",label:"Pipeline"},{id:"met-nonlinear",label:"MET Nonlinear"},{id:"claudeqq",label:"ClaudeQQ"},{id:"baidu-netdisk",label:"Baidu Netdisk"},{id:"filebrowser",label:"File Browser"},{id:"oa-event-flow",label:"OA Event Flow"},{id:"k3sctl",label:"k3s Control"},{id:"code-queue",label:"Code Queue"},{id:"mdtodo",label:"MDTODO"},{id:"decision-center",label:"Decision Center"},{id:"project-manager",label:"Project Manager"}]},{id:"config",label:"系统配置",code:"CFG",tabs:[{id:"topology",label:"连接拓扑"},{id:"auth",label:"认证策略"},{id:"security",label:"安全边界"}]}],Nc=Object.fromEntries(p3.map((l)=>[l.id,l.tabs[0]?.id??""]));function wZ(l){let u=String(l||"").trim();if(!u)return"";try{return decodeURIComponent(u)}catch{return u}}function Z3(l){let u=String(l||"/"),[r]=u.split(/[?#]/u,1);if(r==="/")return"/";let n=`/${r.split("/").map(wZ).filter(Boolean).join("/")}`;return n.endsWith("/")?n:`${n}/`}function qZ(l){let u=2166136261;for(let r of l)u^=r.charCodeAt(0),u=Math.imul(u,16777619);return Math.abs(u>>>0).toString(36)}function v2(l){return String(l||"").normalize("NFKD").replace(/[\u0300-\u036f]/gu,"").toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"")}function RQ(l){return String(l||"").trim().toLowerCase().replace(/[\s/\\?#%]+/gu,"-").replace(/-+/gu,"-").replace(/^-+|-+$/gu,"")}function xQ(l){let u=v2(l.routeSegment||"")||RQ(l.routeSegment||"");if(u)return u;let r=v2(l.id||"");if(r)return r;let f=v2(l.label||"")||RQ(l.label||"");if(f)return f;return`route-${qZ(JSON.stringify(l))}`}function s2(l,u){return`${l}:${u}`}function bQ(l){let u=l.map((c)=>{let $=xQ(c);return{...c,routeSegment:$,tabs:c.tabs.map((A)=>({...A,routeSegment:xQ(A)}))}}),r={},f={},n={},i=u.map((c)=>{let $=c.tabs[0]?.id??"";n[c.id]=$;let A=c.tabs.map((U)=>{let N=`/${c.routeSegment}/${U.routeSegment}/`,W=[N],L={moduleId:c.id,tabId:U.id};for(let J of W)r[Z3(J)]=L;return f[s2(c.id,U.id)]=N,{...U,canonicalPath:N,aliases:W}}),j=`/${c.routeSegment}/`,F={moduleId:c.id,tabId:$};return r[Z3(j)]=F,{...c,routeSegment:c.routeSegment,canonicalPath:j,tabs:A}}),t=i[0],y={moduleId:t?.id||"",tabId:t?.tabs[0]?.id||""};return r["/"]=y,{modules:i,moduleById:Object.fromEntries(i.map((c)=>[c.id,c])),defaultActiveTabs:n,routeMap:r,canonicalPathByTarget:f,fallbackTarget:y}}function k2(l,u){return l.routeMap[Z3(u)]||l.fallbackTarget}function H3(l,u,r){return l.canonicalPathByTarget[s2(u,r)]||l.canonicalPathByTarget[s2(l.fallbackTarget.moduleId,l.fallbackTarget.tabId)]||"/"}function vQ(l,u){let r=l.routeMap[Z3(u)];if(!r)return null;return H3(l,r.moduleId,r.tabId)}var S3=Rl(Ju(),1);var il=S3.default.createElement,{useEffect:sQ,useMemo:WZ}=S3.default,g2=S3.default.useState;function V3({status:l,children:u,title:r}){let f=String(l||"unknown").toLowerCase();return il("span",{className:`status-badge ${f}`,title:r},u||l||"unknown")}function Qc({label:l,value:u,hint:r,tone:f}){return il("article",{className:`metric-card ${f||""}`},il("div",{className:"metric-label"},l),il("div",{className:"metric-value"},u),il("div",{className:"metric-hint"},r))}function B3({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return il("section",{className:`panel ${n||""}`},il("div",{className:"panel-head"},il("div",null,u?il("p",{className:"panel-eyebrow"},u):null,il(fu,{title:l,loading:i})),r?il("div",{className:"panel-actions"},r):null),il("div",{className:"panel-body"},f))}function wc({title:l,data:u,onOpen:r,testId:f}){return il("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r?.(l,u)},"查看原始JSON")}function I2({title:l,text:u}){return il("div",{className:"empty-state"},il("strong",null,l),il("span",null,u))}function LZ(l){return l&&typeof l==="object"&&!Array.isArray(l)?l:null}function an(l){return Array.isArray(l)?l:[]}function ar(l){let u=Number(l);return Number.isFinite(u)?u.toLocaleString("zh-CN"):"--"}function kQ(l,u=140){if(l===null||l===void 0)return"--";let r=typeof l==="string"?l:JSON.stringify(l),f=String(r||"").replace(/\s+/gu," ").trim();return f.length>u?`${f.slice(0,u-1)}...`:f||"--"}function GZ(l){return an(l?.tags).map((u)=>String(u||"").trim()).filter(Boolean)}function h0(l){let u=Number(l);return Number.isFinite(u)&&u>=0?Math.floor(u):0}function TZ(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function mZ(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function KZ(l){return String(l||"").split(/[\s,]+/u).map((u)=>u.trim()).filter(Boolean).join(",")}function D3(l,u){return`${l}/microservices/oa-event-flow/proxy${u}`}function zZ(l){if(l.includes("error")||l.includes("failed"))return"failed";if(l.includes("stats"))return"ok";if(l.includes("step")||l.includes("updated"))return"running";return"queued"}function EZ(l){let u=String(l?.subjectKind||"trace"),r=String(l?.subjectId||l?.scopeId||"");return r?`${u}:${r}`:String(l?.scopeId||"--")}function OZ({tags:l}){let u=GZ({tags:l}).slice(0,6);return il("div",{className:"oa-tag-rail"},u.length===0?il("span",{className:"muted"},"--"):u.map((r)=>il("code",{key:r},r)))}function ZZ({events:l,onRaw:u}){let r=[...an(l)].reverse();return r.length===0?il(I2,{title:"事件表暂无记录",text:"等待 Code Queue 或 Pipeline 按 tag 发布 OA 事件"}):il("div",{className:"table-wrap oa-event-table-wrap"},il("table",{className:"oa-event-table","data-testid":"oa-event-flow-event-table"},il("thead",null,il("tr",null,il("th",null,"Seq"),il("th",null,"Type"),il("th",null,"Source"),il("th",null,"Aggregate"),il("th",null,"Tags"),il("th",null,"Payload"),il("th",null,"Created"),il("th",null,"Raw"))),il("tbody",null,r.map((f)=>{let n=String(f?.type||"event"),i=`${String(f?.aggregateType||"--")}:${String(f?.aggregateId||"--")}`;return il("tr",{key:f?.eventId||f?.sequence},il("td",null,il("code",null,ar(f?.sequence))),il("td",null,il(V3,{status:zZ(n)},n)),il("td",null,il("strong",null,f?.sourceId||"--"),il("code",null,f?.sourceKind||"--")),il("td",null,il("code",null,i)),il("td",null,il(OZ,{tags:f?.tags})),il("td",null,il("span",{className:"oa-payload-preview"},kQ(f?.payload,180))),il("td",null,Wl(f?.createdAt)),il("td",null,il(wc,{title:`OA Event ${f?.sequence||""}`,data:f,onOpen:u,testId:`raw-oa-event-${f?.sequence||"unknown"}`})))}))))}function pZ({stats:l,onRaw:u}){let r=an(l);return r.length===0?il(I2,{title:"统计中心暂无投影",text:"trace-stats-snapshot / trace-step-created 进入事件流后会更新这里"}):il("div",{className:"table-wrap oa-stats-table-wrap"},il("table",{className:"oa-stats-table","data-testid":"oa-event-flow-stats"},il("thead",null,il("tr",null,il("th",null,"Scope"),il("th",null,"Service"),il("th",null,"STEP"),il("th",null,"Read"),il("th",null,"Edit"),il("th",null,"Run"),il("th",null,"Error"),il("th",null,"Output Seq"),il("th",null,"Revision"),il("th",null,"Updated"),il("th",null,"Raw"))),il("tbody",null,r.map((f)=>il("tr",{key:f?.scopeId||`${f?.serviceId}-${f?.subjectId}`},il("td",null,il("strong",null,EZ(f)),il("code",null,f?.scopeId||"--")),il("td",null,il(V3,{status:String(f?.serviceId||"unknown")==="code-queue"?"running":"queued"},f?.serviceId||"--")),il("td",null,il("strong",null,ar(h0(f?.stepCount??f?.llmStepCount)))),il("td",null,ar(h0(f?.readCount))),il("td",null,ar(h0(f?.editCount))),il("td",null,ar(h0(f?.runCount))),il("td",null,ar(h0(f?.errorCount))),il("td",null,il("code",null,ar(h0(f?.outputMaxSeq)))),il("td",null,ar(h0(f?.statsRevision))),il("td",null,Wl(f?.updatedAt)),il("td",null,il(wc,{title:`OA Trace Stats ${f?.scopeId||""}`,data:f,onOpen:u,testId:`raw-oa-stats-${String(f?.scopeId||"unknown").replace(/[^a-zA-Z0-9_-]/gu,"_")}`})))))))}function gQ({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((T)=>T.id==="oa-event-flow")||null,[n,i]=g2("service:code-queue"),[t,y]=g2({loading:!1,error:"",health:null,diagnostics:null,events:[],stats:[],refreshedAt:null}),[c,$]=g2({status:"idle",message:"未连接",lastEventAt:""}),A=WZ(()=>KZ(n),[n]);async function j(){if(!f)return;y((T)=>({...T,loading:!0,error:""}));try{let T=A?`tags=${encodeURIComponent(A)}&`:"",[O,Z,E,D]=await Promise.all([ml(`${r}/microservices/oa-event-flow/health`,{failureFields:[]}),ml(D3(r,"/api/diagnostics")),ml(D3(r,`/api/events?${T}limit=100`)),ml(D3(r,`/api/stats/trace?${T}limit=100`))]);y({loading:!1,error:"",health:O,diagnostics:Z,events:an(E?.events),stats:an(D?.stats),refreshedAt:new Date})}catch(T){y((O)=>({...O,loading:!1,error:El(T,"OA Event Flow 加载失败")}))}}if(sQ(()=>{j()},[f?.id,f?.runtime?.providerStatus,A]),sQ(()=>{if(!f||typeof EventSource>"u")return;let T=A?`?tags=${encodeURIComponent(A)}`:"",O=new EventSource(`${D3(r,"/api/events/stream")}${T}`,{withCredentials:!0});$({status:"running",message:"SSE connecting",lastEventAt:""});let Z=(Y)=>{$({status:"online",message:kQ(Y.data,120),lastEventAt:new Date().toISOString()})},E=(Y)=>{try{let p=JSON.parse(String(Y.data||"{}"));$({status:"online",message:String(p?.type||Y.type||"event"),lastEventAt:new Date().toISOString()}),y((V)=>{let B=[...an(V.events).filter((X)=>String(X?.eventId||"")!==String(p?.eventId||"")),p].sort((X,S)=>Number(X?.sequence||0)-Number(S?.sequence||0)).slice(-100),m=p?.type==="trace-stats-updated"&&LZ(p?.payload?.stats)?[p.payload.stats,...an(V.stats).filter((X)=>String(X?.scopeId||"")!==String(p.payload.stats.scopeId||""))].slice(0,100):V.stats;return{...V,events:B,stats:m}})}catch(p){$({status:"warn",message:El(p,"SSE 事件解析失败"),lastEventAt:new Date().toISOString()})}},D=()=>{$((Y)=>({...Y,status:"warn",message:"SSE reconnecting"}))};return O.addEventListener("hello",Z),O.addEventListener("task-updated",E),O.addEventListener("queue-updated",E),O.addEventListener("trace-step-created",E),O.addEventListener("trace-stats-snapshot",E),O.addEventListener("trace-stats-updated",E),O.addEventListener("trace-error",E),O.onerror=D,()=>O.close()},[f?.id,r,A]),!f)return il(I2,{title:"OA Event Flow 未登记",text:"请在 config.json 的 microservices 中登记 id=oa-event-flow"});let F=TZ(f),U=mZ(f),N=t.diagnostics||{},W=t.health||{},L=N.eventCount??W.eventCount,J=N.traceStatsCount??W.traceStatsCount,w=N.latestSequence??W.latestSequence,Q=N.pipelineBridge||W.pipelineBridge||{},q=an(N.eventTypes).slice(0,8);return il("div",{className:"oa-event-flow-page","data-testid":"oa-event-flow-page"},il(B3,{title:"OA Event Flow 控制台",eyebrow:"Unified OA Event Bus + Stats Projection",loading:t.loading,actions:il("div",{className:"panel-actions"},il("button",{type:"button",className:"ghost-btn",onClick:j,disabled:t.loading,"data-testid":"oa-event-flow-refresh"},t.loading?"刷新中":"刷新"),il(wc,{title:"OA Event Flow Service",data:f,onOpen:u,testId:"raw-oa-event-flow-service"}))},il("div",{className:"oa-flow-hero"},il("div",null,il("div",{className:"node-version-line"},il(V3,{status:W?.ok||F.providerStatus==="online"?"online":"warn"},W?.ok?"HEALTH OK":F.providerStatus||"unknown"),il(V3,{status:c.status},c.status.toUpperCase()),il("span",null,U.public?"公网暴露":"仅 UniDesk frontend 代理访问")),il("p",{className:"muted paragraph"},"独立事件流微服务统一承载 Code Queue 与 Pipeline 的事件发布、tag 订阅、事件表审计和 Trace/STEP 统计投影。")),il("div",{className:"oa-flow-signal"},il("span",null,"stream"),il("strong",null,c.message||"--"),il("code",null,c.lastEventAt?iu(new Date(c.lastEventAt)):"waiting"))),il(lu,{error:t.error,wide:!0})),il("div",{className:"oa-flow-metrics"},il(Qc,{label:"事件总量",value:ar(L),hint:`latest seq ${ar(w)}`,tone:"ok"}),il(Qc,{label:"Trace Stats",value:ar(J),hint:"oa_trace_stats 投影"}),il(Qc,{label:"SSE Clients",value:ar(W?.sseClientCount??an(N.sseClients).length),hint:c.message||"tag subscription"}),il(Qc,{label:"Pipeline Bridge",value:Q?.enabled?ar(Q?.insertedCount):"OFF",hint:Q?.lastError||Q?.lastFinishedAt||`${Q?.mode||"snapshot"} service:pipeline`}),il(Qc,{label:"DB",value:W?.databaseReady||N.databaseReady?"READY":"WAIT",hint:W?.databaseLastError||N.databaseLastError||"PostgreSQL persisted"})),il(B3,{title:"标签订阅",eyebrow:t.refreshedAt?`Updated ${iu(t.refreshedAt)}`:"Tag Pub/Sub"},il("div",{className:"oa-filter-bar"},il("label",null,il("span",null,"tags"),il("input",{value:n,onChange:(T)=>i(T.target.value),placeholder:"service:code-queue, trace","data-testid":"oa-event-flow-tag-filter"})),il("div",{className:"oa-filter-presets"},il("button",{type:"button",className:"ghost-btn",onClick:()=>i("service:code-queue")},"Code Queue"),il("button",{type:"button",className:"ghost-btn",onClick:()=>i("service:pipeline")},"Pipeline"),il("button",{type:"button",className:"ghost-btn",onClick:()=>i("trace")},"Trace"),il("button",{type:"button",className:"ghost-btn",onClick:()=>i("")},"All")),il("code",null,A||"all events")),il("div",{className:"oa-type-strip"},q.length===0?il("span",{className:"muted"},"等待事件类型统计"):q.map((T)=>il("span",{key:T.type,className:"data-chip"},`${T.type} ${ar(T.count)}`)))),il("div",{className:"oa-flow-grid"},il(B3,{title:"事件表",eyebrow:"oa_events persisted log",className:"oa-flow-wide",loading:t.loading,actions:il(wc,{title:"OA Event Query",data:{events:t.events,diagnostics:N},onOpen:u,testId:"raw-oa-events"})},il(ZZ,{events:t.events,onRaw:u})),il(B3,{title:"统计中心",eyebrow:"oa_trace_stats read model",className:"oa-flow-wide",loading:t.loading,actions:il(wc,{title:"OA Trace Stats",data:t.stats,onOpen:u,testId:"raw-oa-trace-stats"})},il(pZ,{stats:t.stats,onRaw:u}))))}var l0=Rl(Ju(),1);var nl=Rl(dQ(),1),yl=Rl(Ju(),1);function bu(l){if(typeof l==="string"||typeof l==="number")return""+l;let u="";if(Array.isArray(l)){for(let r=0,f;r<l.length;r++)if((f=bu(l[r]))!=="")u+=(u&&" ")+f}else for(let r in l)if(l[r])u+=(u&&" ")+r;return u}var YZ={value:()=>{}};function lw(){for(var l=0,u=arguments.length,r={},f;l<u;++l){if(!(f=arguments[l]+"")||f in r||/[\s.]/.test(f))throw Error("illegal type: "+f);r[f]=[]}return new Y3(r)}function Y3(l){this._=l}function PZ(l,u){return l.trim().split(/^|\s+/).map(function(r){var f="",n=r.indexOf(".");if(n>=0)f=r.slice(n+1),r=r.slice(0,n);if(r&&!u.hasOwnProperty(r))throw Error("unknown type: "+r);return{type:r,name:f}})}Y3.prototype=lw.prototype={constructor:Y3,on:function(l,u){var r=this._,f=PZ(l+"",r),n,i=-1,t=f.length;if(arguments.length<2){while(++i<t)if((n=(l=f[i]).type)&&(n=CZ(r[n],l.name)))return n;return}if(u!=null&&typeof u!=="function")throw Error("invalid callback: "+u);while(++i<t)if(n=(l=f[i]).type)r[n]=eQ(r[n],l.name,u);else if(u==null)for(n in r)r[n]=eQ(r[n],l.name,null);return this},copy:function(){var l={},u=this._;for(var r in u)l[r]=u[r].slice();return new Y3(l)},call:function(l,u){if((n=arguments.length-2)>0)for(var r=Array(n),f=0,n,i;f<n;++f)r[f]=arguments[f+2];if(!this._.hasOwnProperty(l))throw Error("unknown type: "+l);for(i=this._[l],f=0,n=i.length;f<n;++f)i[f].value.apply(u,r)},apply:function(l,u,r){if(!this._.hasOwnProperty(l))throw Error("unknown type: "+l);for(var f=this._[l],n=0,i=f.length;n<i;++n)f[n].value.apply(u,r)}};function CZ(l,u){for(var r=0,f=l.length,n;r<f;++r)if((n=l[r]).name===u)return n.value}function eQ(l,u,r){for(var f=0,n=l.length;f<n;++f)if(l[f].name===u){l[f]=YZ,l=l.slice(0,f).concat(l.slice(f+1));break}if(r!=null)l.push({name:u,value:r});return l}var R0=lw;function jy(l){return function(){return this.matches(l)}}function P3(l){return function(u){return u.matches(l)}}var C3="http://www.w3.org/1999/xhtml",a2={svg:"http://www.w3.org/2000/svg",xhtml:C3,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function qn(l){var u=l+="",r=u.indexOf(":");if(r>=0&&(u=l.slice(0,r))!=="xmlns")l=l.slice(r+1);return a2.hasOwnProperty(u)?{space:a2[u],local:l}:l}function o2(l){let u;while(u=l.sourceEvent)l=u;return l}function zr(l,u){if(l=o2(l),u===void 0)u=l.currentTarget;if(u){var r=u.ownerSVGElement||u;if(r.createSVGPoint){var f=r.createSVGPoint();return f.x=l.clientX,f.y=l.clientY,f=f.matrixTransform(u.getScreenCTM().inverse()),[f.x,f.y]}if(u.getBoundingClientRect){var n=u.getBoundingClientRect();return[l.clientX-n.left-u.clientLeft,l.clientY-n.top-u.clientTop]}}return[l.pageX,l.pageY]}function MZ(){}function hi(l){return l==null?MZ:function(){return this.querySelector(l)}}function d2(l){if(typeof l!=="function")l=hi(l);for(var u=this._groups,r=u.length,f=Array(r),n=0;n<r;++n)for(var i=u[n],t=i.length,y=f[n]=Array(t),c,$,A=0;A<t;++A)if((c=i[A])&&($=l.call(c,c.__data__,A,i))){if("__data__"in c)$.__data__=c.__data__;y[A]=$}return new vu(f,this._parents)}function e2(l){return l==null?[]:Array.isArray(l)?l:Array.from(l)}function hZ(){return[]}function Fy(l){return l==null?hZ:function(){return this.querySelectorAll(l)}}function RZ(l){return function(){return e2(l.apply(this,arguments))}}function l5(l){if(typeof l==="function")l=RZ(l);else l=Fy(l);for(var u=this._groups,r=u.length,f=[],n=[],i=0;i<r;++i)for(var t=u[i],y=t.length,c,$=0;$<y;++$)if(c=t[$])f.push(l.call(c,c.__data__,$,t)),n.push(c);return new vu(f,n)}var xZ=Array.prototype.find;function bZ(l){return function(){return xZ.call(this.children,l)}}function vZ(){return this.firstElementChild}function u5(l){return this.select(l==null?vZ:bZ(typeof l==="function"?l:P3(l)))}var sZ=Array.prototype.filter;function kZ(){return Array.from(this.children)}function gZ(l){return function(){return sZ.call(this.children,l)}}function r5(l){return this.selectAll(l==null?kZ:gZ(typeof l==="function"?l:P3(l)))}function f5(l){if(typeof l!=="function")l=jy(l);for(var u=this._groups,r=u.length,f=Array(r),n=0;n<r;++n)for(var i=u[n],t=i.length,y=f[n]=[],c,$=0;$<t;++$)if((c=i[$])&&l.call(c,c.__data__,$,i))y.push(c);return new vu(f,this._parents)}function qc(l){return Array(l.length)}function n5(){return new vu(this._enter||this._groups.map(qc),this._parents)}function Wc(l,u){this.ownerDocument=l.ownerDocument,this.namespaceURI=l.namespaceURI,this._next=null,this._parent=l,this.__data__=u}Wc.prototype={constructor:Wc,appendChild:function(l){return this._parent.insertBefore(l,this._next)},insertBefore:function(l,u){return this._parent.insertBefore(l,u)},querySelector:function(l){return this._parent.querySelector(l)},querySelectorAll:function(l){return this._parent.querySelectorAll(l)}};function i5(l){return function(){return l}}function IZ(l,u,r,f,n,i){var t=0,y,c=u.length,$=i.length;for(;t<$;++t)if(y=u[t])y.__data__=i[t],f[t]=y;else r[t]=new Wc(l,i[t]);for(;t<c;++t)if(y=u[t])n[t]=y}function aZ(l,u,r,f,n,i,t){var y,c,$=new Map,A=u.length,j=i.length,F=Array(A),U;for(y=0;y<A;++y)if(c=u[y])if(F[y]=U=t.call(c,c.__data__,y,u)+"",$.has(U))n[y]=c;else $.set(U,c);for(y=0;y<j;++y)if(U=t.call(l,i[y],y,i)+"",c=$.get(U))f[y]=c,c.__data__=i[y],$.delete(U);else r[y]=new Wc(l,i[y]);for(y=0;y<A;++y)if((c=u[y])&&$.get(F[y])===c)n[y]=c}function oZ(l){return l.__data__}function t5(l,u){if(!arguments.length)return Array.from(this,oZ);var r=u?aZ:IZ,f=this._parents,n=this._groups;if(typeof l!=="function")l=i5(l);for(var i=n.length,t=Array(i),y=Array(i),c=Array(i),$=0;$<i;++$){var A=f[$],j=n[$],F=j.length,U=dZ(l.call(A,A&&A.__data__,$,f)),N=U.length,W=y[$]=Array(N),L=t[$]=Array(N),J=c[$]=Array(F);r(A,j,W,L,J,U,u);for(var w=0,Q=0,q,T;w<N;++w)if(q=W[w]){if(w>=Q)Q=w+1;while(!(T=L[Q])&&++Q<N);q._next=T||null}}return t=new vu(t,f),t._enter=y,t._exit=c,t}function dZ(l){return typeof l==="object"&&"length"in l?l:Array.from(l)}function y5(){return new vu(this._exit||this._groups.map(qc),this._parents)}function c5(l,u,r){var f=this.enter(),n=this,i=this.exit();if(typeof l==="function"){if(f=l(f),f)f=f.selection()}else f=f.append(l+"");if(u!=null){if(n=u(n),n)n=n.selection()}if(r==null)i.remove();else r(i);return f&&n?f.merge(n).order():n}function _5(l){var u=l.selection?l.selection():l;for(var r=this._groups,f=u._groups,n=r.length,i=f.length,t=Math.min(n,i),y=Array(n),c=0;c<t;++c)for(var $=r[c],A=f[c],j=$.length,F=y[c]=Array(j),U,N=0;N<j;++N)if(U=$[N]||A[N])F[N]=U;for(;c<n;++c)y[c]=r[c];return new vu(y,this._parents)}function $5(){for(var l=this._groups,u=-1,r=l.length;++u<r;)for(var f=l[u],n=f.length-1,i=f[n],t;--n>=0;)if(t=f[n]){if(i&&t.compareDocumentPosition(i)^4)i.parentNode.insertBefore(t,i);i=t}return this}function A5(l){if(!l)l=eZ;function u(j,F){return j&&F?l(j.__data__,F.__data__):!j-!F}for(var r=this._groups,f=r.length,n=Array(f),i=0;i<f;++i){for(var t=r[i],y=t.length,c=n[i]=Array(y),$,A=0;A<y;++A)if($=t[A])c[A]=$;c.sort(u)}return new vu(n,this._parents).order()}function eZ(l,u){return l<u?-1:l>u?1:l>=u?0:NaN}function j5(){var l=arguments[0];return arguments[0]=this,l.apply(null,arguments),this}function F5(){return Array.from(this)}function J5(){for(var l=this._groups,u=0,r=l.length;u<r;++u)for(var f=l[u],n=0,i=f.length;n<i;++n){var t=f[n];if(t)return t}return null}function U5(){let l=0;for(let u of this)++l;return l}function N5(){return!this.node()}function Q5(l){for(var u=this._groups,r=0,f=u.length;r<f;++r)for(var n=u[r],i=0,t=n.length,y;i<t;++i)if(y=n[i])l.call(y,y.__data__,i,n);return this}function lp(l){return function(){this.removeAttribute(l)}}function up(l){return function(){this.removeAttributeNS(l.space,l.local)}}function rp(l,u){return function(){this.setAttribute(l,u)}}function fp(l,u){return function(){this.setAttributeNS(l.space,l.local,u)}}function np(l,u){return function(){var r=u.apply(this,arguments);if(r==null)this.removeAttribute(l);else this.setAttribute(l,r)}}function ip(l,u){return function(){var r=u.apply(this,arguments);if(r==null)this.removeAttributeNS(l.space,l.local);else this.setAttributeNS(l.space,l.local,r)}}function w5(l,u){var r=qn(l);if(arguments.length<2){var f=this.node();return r.local?f.getAttributeNS(r.space,r.local):f.getAttribute(r)}return this.each((u==null?r.local?up:lp:typeof u==="function"?r.local?ip:np:r.local?fp:rp)(r,u))}function Lc(l){return l.ownerDocument&&l.ownerDocument.defaultView||l.document&&l||l.defaultView}function tp(l){return function(){this.style.removeProperty(l)}}function yp(l,u,r){return function(){this.style.setProperty(l,u,r)}}function cp(l,u,r){return function(){var f=u.apply(this,arguments);if(f==null)this.style.removeProperty(l);else this.style.setProperty(l,f,r)}}function q5(l,u,r){return arguments.length>1?this.each((u==null?tp:typeof u==="function"?cp:yp)(l,u,r==null?"":r)):Ri(this.node(),l)}function Ri(l,u){return l.style.getPropertyValue(u)||Lc(l).getComputedStyle(l,null).getPropertyValue(u)}function _p(l){return function(){delete this[l]}}function $p(l,u){return function(){this[l]=u}}function Ap(l,u){return function(){var r=u.apply(this,arguments);if(r==null)delete this[l];else this[l]=r}}function W5(l,u){return arguments.length>1?this.each((u==null?_p:typeof u==="function"?Ap:$p)(l,u)):this.node()[l]}function uw(l){return l.trim().split(/^|\s+/)}function L5(l){return l.classList||new rw(l)}function rw(l){this._node=l,this._names=uw(l.getAttribute("class")||"")}rw.prototype={add:function(l){var u=this._names.indexOf(l);if(u<0)this._names.push(l),this._node.setAttribute("class",this._names.join(" "))},remove:function(l){var u=this._names.indexOf(l);if(u>=0)this._names.splice(u,1),this._node.setAttribute("class",this._names.join(" "))},contains:function(l){return this._names.indexOf(l)>=0}};function fw(l,u){var r=L5(l),f=-1,n=u.length;while(++f<n)r.add(u[f])}function nw(l,u){var r=L5(l),f=-1,n=u.length;while(++f<n)r.remove(u[f])}function jp(l){return function(){fw(this,l)}}function Fp(l){return function(){nw(this,l)}}function Jp(l,u){return function(){(u.apply(this,arguments)?fw:nw)(this,l)}}function G5(l,u){var r=uw(l+"");if(arguments.length<2){var f=L5(this.node()),n=-1,i=r.length;while(++n<i)if(!f.contains(r[n]))return!1;return!0}return this.each((typeof u==="function"?Jp:u?jp:Fp)(r,u))}function Up(){this.textContent=""}function Np(l){return function(){this.textContent=l}}function Qp(l){return function(){var u=l.apply(this,arguments);this.textContent=u==null?"":u}}function T5(l){return arguments.length?this.each(l==null?Up:(typeof l==="function"?Qp:Np)(l)):this.node().textContent}function wp(){this.innerHTML=""}function qp(l){return function(){this.innerHTML=l}}function Wp(l){return function(){var u=l.apply(this,arguments);this.innerHTML=u==null?"":u}}function m5(l){return arguments.length?this.each(l==null?wp:(typeof l==="function"?Wp:qp)(l)):this.node().innerHTML}function Lp(){if(this.nextSibling)this.parentNode.appendChild(this)}function K5(){return this.each(Lp)}function Gp(){if(this.previousSibling)this.parentNode.insertBefore(this,this.parentNode.firstChild)}function z5(){return this.each(Gp)}function Tp(l){return function(){var u=this.ownerDocument,r=this.namespaceURI;return r===C3&&u.documentElement.namespaceURI===C3?u.createElement(l):u.createElementNS(r,l)}}function mp(l){return function(){return this.ownerDocument.createElementNS(l.space,l.local)}}function Gc(l){var u=qn(l);return(u.local?mp:Tp)(u)}function E5(l){var u=typeof l==="function"?l:Gc(l);return this.select(function(){return this.appendChild(u.apply(this,arguments))})}function Kp(){return null}function O5(l,u){var r=typeof l==="function"?l:Gc(l),f=u==null?Kp:typeof u==="function"?u:hi(u);return this.select(function(){return this.insertBefore(r.apply(this,arguments),f.apply(this,arguments)||null)})}function zp(){var l=this.parentNode;if(l)l.removeChild(this)}function Z5(){return this.each(zp)}function Ep(){var l=this.cloneNode(!1),u=this.parentNode;return u?u.insertBefore(l,this.nextSibling):l}function Op(){var l=this.cloneNode(!0),u=this.parentNode;return u?u.insertBefore(l,this.nextSibling):l}function p5(l){return this.select(l?Op:Ep)}function H5(l){return arguments.length?this.property("__data__",l):this.node().__data__}function Zp(l){return function(u){l.call(this,u,this.__data__)}}function pp(l){return l.trim().split(/^|\s+/).map(function(u){var r="",f=u.indexOf(".");if(f>=0)r=u.slice(f+1),u=u.slice(0,f);return{type:u,name:r}})}function Hp(l){return function(){var u=this.__on;if(!u)return;for(var r=0,f=-1,n=u.length,i;r<n;++r)if(i=u[r],(!l.type||i.type===l.type)&&i.name===l.name)this.removeEventListener(i.type,i.listener,i.options);else u[++f]=i;if(++f)u.length=f;else delete this.__on}}function Bp(l,u,r){return function(){var f=this.__on,n,i=Zp(u);if(f){for(var t=0,y=f.length;t<y;++t)if((n=f[t]).type===l.type&&n.name===l.name){this.removeEventListener(n.type,n.listener,n.options),this.addEventListener(n.type,n.listener=i,n.options=r),n.value=u;return}}if(this.addEventListener(l.type,i,r),n={type:l.type,name:l.name,value:u,listener:i,options:r},!f)this.__on=[n];else f.push(n)}}function B5(l,u,r){var f=pp(l+""),n,i=f.length,t;if(arguments.length<2){var y=this.node().__on;if(y){for(var c=0,$=y.length,A;c<$;++c)for(n=0,A=y[c];n<i;++n)if((t=f[n]).type===A.type&&t.name===A.name)return A.value}return}y=u?Bp:Hp;for(n=0;n<i;++n)this.each(y(f[n],u,r));return this}function iw(l,u,r){var f=Lc(l),n=f.CustomEvent;if(typeof n==="function")n=new n(u,r);else if(n=f.document.createEvent("Event"),r)n.initEvent(u,r.bubbles,r.cancelable),n.detail=r.detail;else n.initEvent(u,!1,!1);l.dispatchEvent(n)}function Dp(l,u){return function(){return iw(this,l,u)}}function Vp(l,u){return function(){return iw(this,l,u.apply(this,arguments))}}function D5(l,u){return this.each((typeof u==="function"?Vp:Dp)(l,u))}function*V5(){for(var l=this._groups,u=0,r=l.length;u<r;++u)for(var f=l[u],n=0,i=f.length,t;n<i;++n)if(t=f[n])yield t}var S5=[null];function vu(l,u){this._groups=l,this._parents=u}function tw(){return new vu([[document.documentElement]],S5)}function Sp(){return this}vu.prototype=tw.prototype={constructor:vu,select:d2,selectAll:l5,selectChild:u5,selectChildren:r5,filter:f5,data:t5,enter:n5,exit:y5,join:c5,merge:_5,selection:Sp,order:$5,sort:A5,call:j5,nodes:F5,node:J5,size:U5,empty:N5,each:Q5,attr:w5,style:q5,property:W5,classed:G5,text:T5,html:m5,raise:K5,lower:z5,append:E5,insert:O5,remove:Z5,clone:p5,datum:H5,on:B5,dispatch:D5,[Symbol.iterator]:V5};var on=tw;function fr(l){return typeof l==="string"?new vu([[document.querySelector(l)]],[document.documentElement]):new vu([[l]],S5)}var yw={passive:!1},x0={capture:!0,passive:!1};function M3(l){l.stopImmediatePropagation()}function dn(l){l.preventDefault(),l.stopImmediatePropagation()}function Jy(l){var u=l.document.documentElement,r=fr(l).on("dragstart.drag",dn,x0);if("onselectstart"in u)r.on("selectstart.drag",dn,x0);else u.__noselect=u.style.MozUserSelect,u.style.MozUserSelect="none"}function Tc(l,u){var r=l.document.documentElement,f=fr(l).on("dragstart.drag",null);if(u)f.on("click.drag",dn,x0),setTimeout(function(){f.on("click.drag",null)},0);if("onselectstart"in r)f.on("selectstart.drag",null);else r.style.MozUserSelect=r.__noselect,delete r.__noselect}var mc=(l)=>()=>l;function Kc(l,{sourceEvent:u,subject:r,target:f,identifier:n,active:i,x:t,y,dx:c,dy:$,dispatch:A}){Object.defineProperties(this,{type:{value:l,enumerable:!0,configurable:!0},sourceEvent:{value:u,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:f,enumerable:!0,configurable:!0},identifier:{value:n,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:t,enumerable:!0,configurable:!0},y:{value:y,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:$,enumerable:!0,configurable:!0},_:{value:A}})}Kc.prototype.on=function(){var l=this._.on.apply(this._,arguments);return l===this._?this:l};function xp(l){return!l.ctrlKey&&!l.button}function bp(){return this.parentNode}function vp(l,u){return u==null?{x:l.x,y:l.y}:u}function sp(){return navigator.maxTouchPoints||"ontouchstart"in this}function zc(){var l=xp,u=bp,r=vp,f=sp,n={},i=R0("start","drag","end"),t=0,y,c,$,A,j=0;function F(q){q.on("mousedown.drag",U).filter(f).on("touchstart.drag",L).on("touchmove.drag",J,yw).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function U(q,T){if(A||!l.call(this,q,T))return;var O=Q(this,u.call(this,q,T),q,T,"mouse");if(!O)return;fr(q.view).on("mousemove.drag",N,x0).on("mouseup.drag",W,x0),Jy(q.view),M3(q),$=!1,y=q.clientX,c=q.clientY,O("start",q)}function N(q){if(dn(q),!$){var T=q.clientX-y,O=q.clientY-c;$=T*T+O*O>j}n.mouse("drag",q)}function W(q){fr(q.view).on("mousemove.drag mouseup.drag",null),Tc(q.view,$),dn(q),n.mouse("end",q)}function L(q,T){if(!l.call(this,q,T))return;var O=q.changedTouches,Z=u.call(this,q,T),E=O.length,D,Y;for(D=0;D<E;++D)if(Y=Q(this,Z,q,T,O[D].identifier,O[D]))M3(q),Y("start",q,O[D])}function J(q){var T=q.changedTouches,O=T.length,Z,E;for(Z=0;Z<O;++Z)if(E=n[T[Z].identifier])dn(q),E("drag",q,T[Z])}function w(q){var T=q.changedTouches,O=T.length,Z,E;if(A)clearTimeout(A);A=setTimeout(function(){A=null},500);for(Z=0;Z<O;++Z)if(E=n[T[Z].identifier])M3(q),E("end",q,T[Z])}function Q(q,T,O,Z,E,D){var Y=i.copy(),p=zr(D||O,T),V,B,m;if((m=r.call(q,new Kc("beforestart",{sourceEvent:O,target:F,identifier:E,active:t,x:p[0],y:p[1],dx:0,dy:0,dispatch:Y}),Z))==null)return;return V=m.x-p[0]||0,B=m.y-p[1]||0,function X(S,b,z){var P=p,s;switch(S){case"start":n[E]=X,s=t++;break;case"end":delete n[E],--t;case"drag":p=zr(z||b,T),s=t;break}Y.call(S,q,new Kc(S,{sourceEvent:b,subject:m,target:F,identifier:E,active:s,x:p[0]+V,y:p[1]+B,dx:p[0]-P[0],dy:p[1]-P[1],dispatch:Y}),Z)}}return F.filter=function(q){return arguments.length?(l=typeof q==="function"?q:mc(!!q),F):l},F.container=function(q){return arguments.length?(u=typeof q==="function"?q:mc(q),F):u},F.subject=function(q){return arguments.length?(r=typeof q==="function"?q:mc(q),F):r},F.touchable=function(q){return arguments.length?(f=typeof q==="function"?q:mc(!!q),F):f},F.on=function(){var q=i.on.apply(i,arguments);return q===i?F:q},F.clickDistance=function(q){return arguments.length?(j=(q=+q)*q,F):Math.sqrt(j)},F}function Ec(l,u,r){l.prototype=u.prototype=r,r.constructor=l}function X5(l,u){var r=Object.create(l.prototype);for(var f in u)r[f]=u[f];return r}function pc(){}var Oc=0.7,x3=1/Oc,Uy="\\s*([+-]?\\d+)\\s*",Zc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",kp=/^#([0-9a-f]{3,8})$/,gp=new RegExp(`^rgb\\(${Uy},${Uy},${Uy}\\)$`),Ip=new RegExp(`^rgb\\(${Wn},${Wn},${Wn}\\)$`),ap=new RegExp(`^rgba\\(${Uy},${Uy},${Uy},${Zc}\\)$`),op=new RegExp(`^rgba\\(${Wn},${Wn},${Wn},${Zc}\\)$`),dp=new RegExp(`^hsl\\(${Zc},${Wn},${Wn}\\)$`),ep=new RegExp(`^hsla\\(${Zc},${Wn},${Wn},${Zc}\\)$`),cw={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ec(pc,ef,{copy(l){return Object.assign(new this.constructor,this,l)},displayable(){return this.rgb().displayable()},hex:_w,formatHex:_w,formatHex8:lH,formatHsl:uH,formatRgb:$w,toString:$w});function _w(){return this.rgb().formatHex()}function lH(){return this.rgb().formatHex8()}function uH(){return Nw(this).formatHsl()}function $w(){return this.rgb().formatRgb()}function ef(l){var u,r;return l=(l+"").trim().toLowerCase(),(u=kp.exec(l))?(r=u[1].length,u=parseInt(u[1],16),r===6?Aw(u):r===3?new or(u>>8&15|u>>4&240,u>>4&15|u&240,(u&15)<<4|u&15,1):r===8?h3(u>>24&255,u>>16&255,u>>8&255,(u&255)/255):r===4?h3(u>>12&15|u>>8&240,u>>8&15|u>>4&240,u>>4&15|u&240,((u&15)<<4|u&15)/255):null):(u=gp.exec(l))?new or(u[1],u[2],u[3],1):(u=Ip.exec(l))?new or(u[1]*255/100,u[2]*255/100,u[3]*255/100,1):(u=ap.exec(l))?h3(u[1],u[2],u[3],u[4]):(u=op.exec(l))?h3(u[1]*255/100,u[2]*255/100,u[3]*255/100,u[4]):(u=dp.exec(l))?Jw(u[1],u[2]/100,u[3]/100,1):(u=ep.exec(l))?Jw(u[1],u[2]/100,u[3]/100,u[4]):cw.hasOwnProperty(l)?Aw(cw[l]):l==="transparent"?new or(NaN,NaN,NaN,0):null}function Aw(l){return new or(l>>16&255,l>>8&255,l&255,1)}function h3(l,u,r,f){if(f<=0)l=u=r=NaN;return new or(l,u,r,f)}function rH(l){if(!(l instanceof pc))l=ef(l);if(!l)return new or;return l=l.rgb(),new or(l.r,l.g,l.b,l.opacity)}function Ny(l,u,r,f){return arguments.length===1?rH(l):new or(l,u,r,f==null?1:f)}function or(l,u,r,f){this.r=+l,this.g=+u,this.b=+r,this.opacity=+f}Ec(or,Ny,X5(pc,{brighter(l){return l=l==null?x3:Math.pow(x3,l),new or(this.r*l,this.g*l,this.b*l,this.opacity)},darker(l){return l=l==null?Oc:Math.pow(Oc,l),new or(this.r*l,this.g*l,this.b*l,this.opacity)},rgb(){return this},clamp(){return new or(v0(this.r),v0(this.g),v0(this.b),b3(this.opacity))},displayable(){return-0.5<=this.r&&this.r<255.5&&(-0.5<=this.g&&this.g<255.5)&&(-0.5<=this.b&&this.b<255.5)&&(0<=this.opacity&&this.opacity<=1)},hex:jw,formatHex:jw,formatHex8:fH,formatRgb:Fw,toString:Fw}));function jw(){return`#${b0(this.r)}${b0(this.g)}${b0(this.b)}`}function fH(){return`#${b0(this.r)}${b0(this.g)}${b0(this.b)}${b0((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fw(){let l=b3(this.opacity);return`${l===1?"rgb(":"rgba("}${v0(this.r)}, ${v0(this.g)}, ${v0(this.b)}${l===1?")":`, ${l})`}`}function b3(l){return isNaN(l)?1:Math.max(0,Math.min(1,l))}function v0(l){return Math.max(0,Math.min(255,Math.round(l)||0))}function b0(l){return l=v0(l),(l<16?"0":"")+l.toString(16)}function Jw(l,u,r,f){if(f<=0)l=u=r=NaN;else if(r<=0||r>=1)l=u=NaN;else if(u<=0)l=NaN;return new df(l,u,r,f)}function Nw(l){if(l instanceof df)return new df(l.h,l.s,l.l,l.opacity);if(!(l instanceof pc))l=ef(l);if(!l)return new df;if(l instanceof df)return l;l=l.rgb();var u=l.r/255,r=l.g/255,f=l.b/255,n=Math.min(u,r,f),i=Math.max(u,r,f),t=NaN,y=i-n,c=(i+n)/2;if(y){if(u===i)t=(r-f)/y+(r<f)*6;else if(r===i)t=(f-u)/y+2;else t=(u-r)/y+4;y/=c<0.5?i+n:2-i-n,t*=60}else y=c>0&&c<1?0:t;return new df(t,y,c,l.opacity)}function Qw(l,u,r,f){return arguments.length===1?Nw(l):new df(l,u,r,f==null?1:f)}function df(l,u,r,f){this.h=+l,this.s=+u,this.l=+r,this.opacity=+f}Ec(df,Qw,X5(pc,{brighter(l){return l=l==null?x3:Math.pow(x3,l),new df(this.h,this.s,this.l*l,this.opacity)},darker(l){return l=l==null?Oc:Math.pow(Oc,l),new df(this.h,this.s,this.l*l,this.opacity)},rgb(){var l=this.h%360+(this.h<0)*360,u=isNaN(l)||isNaN(this.s)?0:this.s,r=this.l,f=r+(r<0.5?r:1-r)*u,n=2*r-f;return new or(Y5(l>=240?l-240:l+120,n,f),Y5(l,n,f),Y5(l<120?l+240:l-120,n,f),this.opacity)},clamp(){return new df(Uw(this.h),R3(this.s),R3(this.l),b3(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&(0<=this.l&&this.l<=1)&&(0<=this.opacity&&this.opacity<=1)},formatHsl(){let l=b3(this.opacity);return`${l===1?"hsl(":"hsla("}${Uw(this.h)}, ${R3(this.s)*100}%, ${R3(this.l)*100}%${l===1?")":`, ${l})`}`}}));function Uw(l){return l=(l||0)%360,l<0?l+360:l}function R3(l){return Math.max(0,Math.min(1,l||0))}function Y5(l,u,r){return(l<60?u+(r-u)*l/60:l<180?r:l<240?u+(r-u)*(240-l)/60:u)*255}function P5(l,u,r,f,n){var i=l*l,t=i*l;return((1-3*l+3*i-t)*u+(4-6*i+3*t)*r+(1+3*l+3*i-3*t)*f+t*n)/6}function C5(l){var u=l.length-1;return function(r){var f=r<=0?r=0:r>=1?(r=1,u-1):Math.floor(r*u),n=l[f],i=l[f+1],t=f>0?l[f-1]:2*n-i,y=f<u-1?l[f+2]:2*i-n;return P5((r-f/u)*u,t,n,i,y)}}function M5(l){var u=l.length;return function(r){var f=Math.floor(((r%=1)<0?++r:r)*u),n=l[(f+u-1)%u],i=l[f%u],t=l[(f+1)%u],y=l[(f+2)%u];return P5((r-f/u)*u,n,i,t,y)}}var Hc=(l)=>()=>l;function iH(l,u){return function(r){return l+r*u}}function tH(l,u,r){return l=Math.pow(l,r),u=Math.pow(u,r)-l,r=1/r,function(f){return Math.pow(l+f*u,r)}}function ww(l){return(l=+l)===1?s3:function(u,r){return r-u?tH(u,r,l):Hc(isNaN(u)?r:u)}}function s3(l,u){var r=u-l;return r?iH(l,r):Hc(isNaN(l)?u:l)}var s0=function l(u){var r=ww(u);function f(n,i){var t=r((n=Ny(n)).r,(i=Ny(i)).r),y=r(n.g,i.g),c=r(n.b,i.b),$=s3(n.opacity,i.opacity);return function(A){return n.r=t(A),n.g=y(A),n.b=c(A),n.opacity=$(A),n+""}}return f.gamma=l,f}(1);function qw(l){return function(u){var r=u.length,f=Array(r),n=Array(r),i=Array(r),t,y;for(t=0;t<r;++t)y=Ny(u[t]),f[t]=y.r||0,n[t]=y.g||0,i[t]=y.b||0;return f=l(f),n=l(n),i=l(i),y.opacity=1,function(c){return y.r=f(c),y.g=n(c),y.b=i(c),y+""}}}var yH=qw(C5),cH=qw(M5);function h5(l,u){if(!u)u=[];var r=l?Math.min(u.length,l.length):0,f=u.slice(),n;return function(i){for(n=0;n<r;++n)f[n]=l[n]*(1-i)+u[n]*i;return f}}function Ww(l){return ArrayBuffer.isView(l)&&!(l instanceof DataView)}function Lw(l,u){var r=u?u.length:0,f=l?Math.min(r,l.length):0,n=Array(f),i=Array(r),t;for(t=0;t<f;++t)n[t]=Ln(l[t],u[t]);for(;t<r;++t)i[t]=u[t];return function(y){for(t=0;t<f;++t)i[t]=n[t](y);return i}}function R5(l,u){var r=new Date;return l=+l,u=+u,function(f){return r.setTime(l*(1-f)+u*f),r}}function Er(l,u){return l=+l,u=+u,function(r){return l*(1-r)+u*r}}function x5(l,u){var r={},f={},n;if(l===null||typeof l!=="object")l={};if(u===null||typeof u!=="object")u={};for(n in u)if(n in l)r[n]=Ln(l[n],u[n]);else f[n]=u[n];return function(i){for(n in r)f[n]=r[n](i);return f}}var v5=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,b5=new RegExp(v5.source,"g");function _H(l){return function(){return l}}function $H(l){return function(u){return l(u)+""}}function Qy(l,u){var r=v5.lastIndex=b5.lastIndex=0,f,n,i,t=-1,y=[],c=[];l=l+"",u=u+"";while((f=v5.exec(l))&&(n=b5.exec(u))){if((i=n.index)>r)if(i=u.slice(r,i),y[t])y[t]+=i;else y[++t]=i;if((f=f[0])===(n=n[0]))if(y[t])y[t]+=n;else y[++t]=n;else y[++t]=null,c.push({i:t,x:Er(f,n)});r=b5.lastIndex}if(r<u.length)if(i=u.slice(r),y[t])y[t]+=i;else y[++t]=i;return y.length<2?c[0]?$H(c[0].x):_H(u):(u=c.length,function($){for(var A=0,j;A<u;++A)y[(j=c[A]).i]=j.x($);return y.join("")})}function Ln(l,u){var r=typeof u,f;return u==null||r==="boolean"?Hc(u):(r==="number"?Er:r==="string"?(f=ef(u))?(u=f,s0):Qy:u instanceof ef?s0:u instanceof Date?R5:Ww(u)?h5:Array.isArray(u)?Lw:typeof u.valueOf!=="function"&&typeof u.toString!=="function"||isNaN(u)?x5:Er)(l,u)}var Gw=180/Math.PI,k3={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function g3(l,u,r,f,n,i){var t,y,c;if(t=Math.sqrt(l*l+u*u))l/=t,u/=t;if(c=l*r+u*f)r-=l*c,f-=u*c;if(y=Math.sqrt(r*r+f*f))r/=y,f/=y,c/=y;if(l*f<u*r)l=-l,u=-u,c=-c,t=-t;return{translateX:n,translateY:i,rotate:Math.atan2(u,l)*Gw,skewX:Math.atan(c)*Gw,scaleX:t,scaleY:y}}var I3;function Tw(l){let u=new(typeof DOMMatrix==="function"?DOMMatrix:WebKitCSSMatrix)(l+"");return u.isIdentity?k3:g3(u.a,u.b,u.c,u.d,u.e,u.f)}function mw(l){if(l==null)return k3;if(!I3)I3=document.createElementNS("http://www.w3.org/2000/svg","g");if(I3.setAttribute("transform",l),!(l=I3.transform.baseVal.consolidate()))return k3;return l=l.matrix,g3(l.a,l.b,l.c,l.d,l.e,l.f)}function Kw(l,u,r,f){function n($){return $.length?$.pop()+" ":""}function i($,A,j,F,U,N){if($!==j||A!==F){var W=U.push("translate(",null,u,null,r);N.push({i:W-4,x:Er($,j)},{i:W-2,x:Er(A,F)})}else if(j||F)U.push("translate("+j+u+F+r)}function t($,A,j,F){if($!==A){if($-A>180)A+=360;else if(A-$>180)$+=360;F.push({i:j.push(n(j)+"rotate(",null,f)-2,x:Er($,A)})}else if(A)j.push(n(j)+"rotate("+A+f)}function y($,A,j,F){if($!==A)F.push({i:j.push(n(j)+"skewX(",null,f)-2,x:Er($,A)});else if(A)j.push(n(j)+"skewX("+A+f)}function c($,A,j,F,U,N){if($!==j||A!==F){var W=U.push(n(U)+"scale(",null,",",null,")");N.push({i:W-4,x:Er($,j)},{i:W-2,x:Er(A,F)})}else if(j!==1||F!==1)U.push(n(U)+"scale("+j+","+F+")")}return function($,A){var j=[],F=[];return $=l($),A=l(A),i($.translateX,$.translateY,A.translateX,A.translateY,j,F),t($.rotate,A.rotate,j,F),y($.skewX,A.skewX,j,F),c($.scaleX,$.scaleY,A.scaleX,A.scaleY,j,F),$=A=null,function(U){var N=-1,W=F.length,L;while(++N<W)j[(L=F[N]).i]=L.x(U);return j.join("")}}}var s5=Kw(Tw,"px, ","px)","deg)"),k5=Kw(mw,", ",")",")");var AH=0.000000000001;function zw(l){return((l=Math.exp(l))+1/l)/2}function jH(l){return((l=Math.exp(l))-1/l)/2}function FH(l){return((l=Math.exp(2*l))-1)/(l+1)}var k0=function l(u,r,f){function n(i,t){var y=i[0],c=i[1],$=i[2],A=t[0],j=t[1],F=t[2],U=A-y,N=j-c,W=U*U+N*N,L,J;if(W<AH)J=Math.log(F/$)/u,L=function(Z){return[y+Z*U,c+Z*N,$*Math.exp(u*Z*J)]};else{var w=Math.sqrt(W),Q=(F*F-$*$+f*W)/(2*$*r*w),q=(F*F-$*$-f*W)/(2*F*r*w),T=Math.log(Math.sqrt(Q*Q+1)-Q),O=Math.log(Math.sqrt(q*q+1)-q);J=(O-T)/u,L=function(Z){var E=Z*J,D=zw(T),Y=$/(r*w)*(D*FH(u*E+T)-jH(T));return[y+Y*U,c+Y*N,$*D/zw(u*E+T)]}}return L.duration=J*1000*u/Math.SQRT2,L}return n.rho=function(i){var t=Math.max(0.001,+i),y=t*t,c=y*y;return l(t,y,c)},n}(Math.SQRT2,2,4);var wy=0,Dc=0,Bc=0,Hw=1000,a3,Vc,o3=0,g0=0,d3=0,Sc=typeof performance==="object"&&performance.now?performance:Date,Bw=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(l){setTimeout(l,17)};function Yc(){return g0||(Bw(zH),g0=Sc.now()+d3)}function zH(){g0=0}function Xc(){this._call=this._time=this._next=null}Xc.prototype=e3.prototype={constructor:Xc,restart:function(l,u,r){if(typeof l!=="function")throw TypeError("callback is not a function");if(r=(r==null?Yc():+r)+(u==null?0:+u),!this._next&&Vc!==this){if(Vc)Vc._next=this;else a3=this;Vc=this}this._call=l,this._time=r,g5()},stop:function(){if(this._call)this._call=null,this._time=1/0,g5()}};function e3(l,u,r){var f=new Xc;return f.restart(l,u,r),f}function Dw(){Yc(),++wy;var l=a3,u;while(l){if((u=g0-l._time)>=0)l._call.call(void 0,u);l=l._next}--wy}function pw(){g0=(o3=Sc.now())+d3,wy=Dc=0;try{Dw()}finally{wy=0,OH(),g0=0}}function EH(){var l=Sc.now(),u=l-o3;if(u>Hw)d3-=u,o3=l}function OH(){var l,u=a3,r,f=1/0;while(u)if(u._call){if(f>u._time)f=u._time;l=u,u=u._next}else r=u._next,u._next=null,u=l?l._next=r:a3=r;Vc=l,g5(f)}function g5(l){if(wy)return;if(Dc)Dc=clearTimeout(Dc);var u=l-g0;if(u>24){if(l<1/0)Dc=setTimeout(pw,l-Sc.now()-d3);if(Bc)Bc=clearInterval(Bc)}else{if(!Bc)o3=Sc.now(),Bc=setInterval(EH,Hw);wy=1,Bw(pw)}}function Pc(l,u,r){var f=new Xc;return u=u==null?0:+u,f.restart((n)=>{f.stop(),l(n+u)},u,r),f}var pH=R0("start","end","cancel","interrupt"),HH=[],Xw=0,Vw=1,uA=2,lA=3,Sw=4,rA=5,Cc=6;function en(l,u,r,f,n,i){var t=l.__transition;if(!t)l.__transition={};else if(r in t)return;BH(l,r,{name:u,index:f,group:n,on:pH,tween:HH,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Xw})}function Mc(l,u){var r=nr(l,u);if(r.state>Xw)throw Error("too late; already scheduled");return r}function Ur(l,u){var r=nr(l,u);if(r.state>lA)throw Error("too late; already running");return r}function nr(l,u){var r=l.__transition;if(!r||!(r=r[u]))throw Error("transition not found");return r}function BH(l,u,r){var f=l.__transition,n;f[u]=r,r.timer=e3(i,0,r.time);function i($){if(r.state=Vw,r.timer.restart(t,r.delay,r.time),r.delay<=$)t($-r.delay)}function t($){var A,j,F,U;if(r.state!==Vw)return c();for(A in f){if(U=f[A],U.name!==r.name)continue;if(U.state===lA)return Pc(t);if(U.state===Sw)U.state=Cc,U.timer.stop(),U.on.call("interrupt",l,l.__data__,U.index,U.group),delete f[A];else if(+A<u)U.state=Cc,U.timer.stop(),U.on.call("cancel",l,l.__data__,U.index,U.group),delete f[A]}if(Pc(function(){if(r.state===lA)r.state=Sw,r.timer.restart(y,r.delay,r.time),y($)}),r.state=uA,r.on.call("start",l,l.__data__,r.index,r.group),r.state!==uA)return;r.state=lA,n=Array(F=r.tween.length);for(A=0,j=-1;A<F;++A)if(U=r.tween[A].value.call(l,l.__data__,r.index,r.group))n[++j]=U;n.length=j+1}function y($){var A=$<r.duration?r.ease.call(null,$/r.duration):(r.timer.restart(c),r.state=rA,1),j=-1,F=n.length;while(++j<F)n[j].call(l,A);if(r.state===rA)r.on.call("end",l,l.__data__,r.index,r.group),c()}function c(){r.state=Cc,r.timer.stop(),delete f[u];for(var $ in f)return;delete l.__transition}}function xi(l,u){var r=l.__transition,f,n,i=!0,t;if(!r)return;u=u==null?null:u+"";for(t in r){if((f=r[t]).name!==u){i=!1;continue}n=f.state>uA&&f.state<rA,f.state=Cc,f.timer.stop(),f.on.call(n?"interrupt":"cancel",l,l.__data__,f.index,f.group),delete r[t]}if(i)delete l.__transition}function I5(l){return this.each(function(){xi(this,l)})}function DH(l,u){var r,f;return function(){var n=Ur(this,l),i=n.tween;if(i!==r){f=r=i;for(var t=0,y=f.length;t<y;++t)if(f[t].name===u){f=f.slice(),f.splice(t,1);break}}n.tween=f}}function VH(l,u,r){var f,n;if(typeof r!=="function")throw Error();return function(){var i=Ur(this,l),t=i.tween;if(t!==f){n=(f=t).slice();for(var y={name:u,value:r},c=0,$=n.length;c<$;++c)if(n[c].name===u){n[c]=y;break}if(c===$)n.push(y)}i.tween=n}}function a5(l,u){var r=this._id;if(l+="",arguments.length<2){var f=nr(this.node(),r).tween;for(var n=0,i=f.length,t;n<i;++n)if((t=f[n]).name===l)return t.value;return null}return this.each((u==null?DH:VH)(r,l,u))}function qy(l,u,r){var f=l._id;return l.each(function(){var n=Ur(this,f);(n.value||(n.value={}))[u]=r.apply(this,arguments)}),function(n){return nr(n,f).value[u]}}function hc(l,u){var r;return(typeof u==="number"?Er:u instanceof ef?s0:(r=ef(u))?(u=r,s0):Qy)(l,u)}function SH(l){return function(){this.removeAttribute(l)}}function XH(l){return function(){this.removeAttributeNS(l.space,l.local)}}function YH(l,u,r){var f,n=r+"",i;return function(){var t=this.getAttribute(l);return t===n?null:t===f?i:i=u(f=t,r)}}function PH(l,u,r){var f,n=r+"",i;return function(){var t=this.getAttributeNS(l.space,l.local);return t===n?null:t===f?i:i=u(f=t,r)}}function CH(l,u,r){var f,n,i;return function(){var t,y=r(this),c;if(y==null)return void this.removeAttribute(l);return t=this.getAttribute(l),c=y+"",t===c?null:t===f&&c===n?i:(n=c,i=u(f=t,y))}}function MH(l,u,r){var f,n,i;return function(){var t,y=r(this),c;if(y==null)return void this.removeAttributeNS(l.space,l.local);return t=this.getAttributeNS(l.space,l.local),c=y+"",t===c?null:t===f&&c===n?i:(n=c,i=u(f=t,y))}}function o5(l,u){var r=qn(l),f=r==="transform"?k5:hc;return this.attrTween(l,typeof u==="function"?(r.local?MH:CH)(r,f,qy(this,"attr."+l,u)):u==null?(r.local?XH:SH)(r):(r.local?PH:YH)(r,f,u))}function hH(l,u){return function(r){this.setAttribute(l,u.call(this,r))}}function RH(l,u){return function(r){this.setAttributeNS(l.space,l.local,u.call(this,r))}}function xH(l,u){var r,f;function n(){var i=u.apply(this,arguments);if(i!==f)r=(f=i)&&RH(l,i);return r}return n._value=u,n}function bH(l,u){var r,f;function n(){var i=u.apply(this,arguments);if(i!==f)r=(f=i)&&hH(l,i);return r}return n._value=u,n}function d5(l,u){var r="attr."+l;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(u==null)return this.tween(r,null);if(typeof u!=="function")throw Error();var f=qn(l);return this.tween(r,(f.local?xH:bH)(f,u))}function vH(l,u){return function(){Mc(this,l).delay=+u.apply(this,arguments)}}function sH(l,u){return u=+u,function(){Mc(this,l).delay=u}}function e5(l){var u=this._id;return arguments.length?this.each((typeof l==="function"?vH:sH)(u,l)):nr(this.node(),u).delay}function kH(l,u){return function(){Ur(this,l).duration=+u.apply(this,arguments)}}function gH(l,u){return u=+u,function(){Ur(this,l).duration=u}}function l9(l){var u=this._id;return arguments.length?this.each((typeof l==="function"?kH:gH)(u,l)):nr(this.node(),u).duration}function IH(l,u){if(typeof u!=="function")throw Error();return function(){Ur(this,l).ease=u}}function u9(l){var u=this._id;return arguments.length?this.each(IH(u,l)):nr(this.node(),u).ease}function aH(l,u){return function(){var r=u.apply(this,arguments);if(typeof r!=="function")throw Error();Ur(this,l).ease=r}}function r9(l){if(typeof l!=="function")throw Error();return this.each(aH(this._id,l))}function f9(l){if(typeof l!=="function")l=jy(l);for(var u=this._groups,r=u.length,f=Array(r),n=0;n<r;++n)for(var i=u[n],t=i.length,y=f[n]=[],c,$=0;$<t;++$)if((c=i[$])&&l.call(c,c.__data__,$,i))y.push(c);return new Cr(f,this._parents,this._name,this._id)}function n9(l){if(l._id!==this._id)throw Error();for(var u=this._groups,r=l._groups,f=u.length,n=r.length,i=Math.min(f,n),t=Array(f),y=0;y<i;++y)for(var c=u[y],$=r[y],A=c.length,j=t[y]=Array(A),F,U=0;U<A;++U)if(F=c[U]||$[U])j[U]=F;for(;y<f;++y)t[y]=u[y];return new Cr(t,this._parents,this._name,this._id)}function oH(l){return(l+"").trim().split(/^|\s+/).every(function(u){var r=u.indexOf(".");if(r>=0)u=u.slice(0,r);return!u||u==="start"})}function dH(l,u,r){var f,n,i=oH(u)?Mc:Ur;return function(){var t=i(this,l),y=t.on;if(y!==f)(n=(f=y).copy()).on(u,r);t.on=n}}function i9(l,u){var r=this._id;return arguments.length<2?nr(this.node(),r).on.on(l):this.each(dH(r,l,u))}function eH(l){return function(){var u=this.parentNode;for(var r in this.__transition)if(+r!==l)return;if(u)u.removeChild(this)}}function t9(){return this.on("end.remove",eH(this._id))}function y9(l){var u=this._name,r=this._id;if(typeof l!=="function")l=hi(l);for(var f=this._groups,n=f.length,i=Array(n),t=0;t<n;++t)for(var y=f[t],c=y.length,$=i[t]=Array(c),A,j,F=0;F<c;++F)if((A=y[F])&&(j=l.call(A,A.__data__,F,y))){if("__data__"in A)j.__data__=A.__data__;$[F]=j,en($[F],u,r,F,$,nr(A,r))}return new Cr(i,this._parents,u,r)}function c9(l){var u=this._name,r=this._id;if(typeof l!=="function")l=Fy(l);for(var f=this._groups,n=f.length,i=[],t=[],y=0;y<n;++y)for(var c=f[y],$=c.length,A,j=0;j<$;++j)if(A=c[j]){for(var F=l.call(A,A.__data__,j,c),U,N=nr(A,r),W=0,L=F.length;W<L;++W)if(U=F[W])en(U,u,r,W,F,N);i.push(F),t.push(A)}return new Cr(i,t,u,r)}var lB=on.prototype.constructor;function _9(){return new lB(this._groups,this._parents)}function uB(l,u){var r,f,n;return function(){var i=Ri(this,l),t=(this.style.removeProperty(l),Ri(this,l));return i===t?null:i===r&&t===f?n:n=u(r=i,f=t)}}function Yw(l){return function(){this.style.removeProperty(l)}}function rB(l,u,r){var f,n=r+"",i;return function(){var t=Ri(this,l);return t===n?null:t===f?i:i=u(f=t,r)}}function fB(l,u,r){var f,n,i;return function(){var t=Ri(this,l),y=r(this),c=y+"";if(y==null)c=y=(this.style.removeProperty(l),Ri(this,l));return t===c?null:t===f&&c===n?i:(n=c,i=u(f=t,y))}}function nB(l,u){var r,f,n,i="style."+u,t="end."+i,y;return function(){var c=Ur(this,l),$=c.on,A=c.value[i]==null?y||(y=Yw(u)):void 0;if($!==r||n!==A)(f=(r=$).copy()).on(t,n=A);c.on=f}}function $9(l,u,r){var f=(l+="")==="transform"?s5:hc;return u==null?this.styleTween(l,uB(l,f)).on("end.style."+l,Yw(l)):typeof u==="function"?this.styleTween(l,fB(l,f,qy(this,"style."+l,u))).each(nB(this._id,l)):this.styleTween(l,rB(l,f,u),r).on("end.style."+l,null)}function iB(l,u,r){return function(f){this.style.setProperty(l,u.call(this,f),r)}}function tB(l,u,r){var f,n;function i(){var t=u.apply(this,arguments);if(t!==n)f=(n=t)&&iB(l,t,r);return f}return i._value=u,i}function A9(l,u,r){var f="style."+(l+="");if(arguments.length<2)return(f=this.tween(f))&&f._value;if(u==null)return this.tween(f,null);if(typeof u!=="function")throw Error();return this.tween(f,tB(l,u,r==null?"":r))}function yB(l){return function(){this.textContent=l}}function cB(l){return function(){var u=l(this);this.textContent=u==null?"":u}}function j9(l){return this.tween("text",typeof l==="function"?cB(qy(this,"text",l)):yB(l==null?"":l+""))}function _B(l){return function(u){this.textContent=l.call(this,u)}}function $B(l){var u,r;function f(){var n=l.apply(this,arguments);if(n!==r)u=(r=n)&&_B(n);return u}return f._value=l,f}function F9(l){var u="text";if(arguments.length<1)return(u=this.tween(u))&&u._value;if(l==null)return this.tween(u,null);if(typeof l!=="function")throw Error();return this.tween(u,$B(l))}function J9(){var l=this._name,u=this._id,r=fA();for(var f=this._groups,n=f.length,i=0;i<n;++i)for(var t=f[i],y=t.length,c,$=0;$<y;++$)if(c=t[$]){var A=nr(c,u);en(c,l,r,$,t,{time:A.time+A.delay+A.duration,delay:0,duration:A.duration,ease:A.ease})}return new Cr(f,this._parents,l,r)}function U9(){var l,u,r=this,f=r._id,n=r.size();return new Promise(function(i,t){var y={value:t},c={value:function(){if(--n===0)i()}};if(r.each(function(){var $=Ur(this,f),A=$.on;if(A!==l)u=(l=A).copy(),u._.cancel.push(y),u._.interrupt.push(y),u._.end.push(c);$.on=u}),n===0)i()})}var AB=0;function Cr(l,u,r,f){this._groups=l,this._parents=u,this._name=r,this._id=f}function Pw(l){return on().transition(l)}function fA(){return++AB}var li=on.prototype;Cr.prototype=Pw.prototype={constructor:Cr,select:y9,selectAll:c9,selectChild:li.selectChild,selectChildren:li.selectChildren,filter:f9,merge:n9,selection:_9,transition:J9,call:li.call,nodes:li.nodes,node:li.node,size:li.size,empty:li.empty,each:li.each,on:i9,attr:o5,attrTween:d5,style:$9,styleTween:A9,text:j9,textTween:F9,remove:t9,tween:a5,delay:e5,duration:l9,ease:u9,easeVarying:r9,end:U9,[Symbol.iterator]:li[Symbol.iterator]};function nA(l){return((l*=2)<=1?l*l*l:(l-=2)*l*l+2)/2}var FB={time:null,delay:0,duration:250,ease:nA};function JB(l,u){var r;while(!(r=l.__transition)||!(r=r[u]))if(!(l=l.parentNode))throw Error(`transition ${u} not found`);return r}function N9(l){var u,r;if(l instanceof Cr)u=l._id,l=l._name;else u=fA(),(r=FB).time=Yc(),l=l==null?null:l+"";for(var f=this._groups,n=f.length,i=0;i<n;++i)for(var t=f[i],y=t.length,c,$=0;$<y;++$)if(c=t[$])en(c,l,u,$,t,r||JB(c,u));return new Cr(f,this._parents,l,u)}on.prototype.interrupt=I5;on.prototype.transition=N9;var Rc=(l)=>()=>l;function Q9(l,{sourceEvent:u,target:r,transform:f,dispatch:n}){Object.defineProperties(this,{type:{value:l,enumerable:!0,configurable:!0},sourceEvent:{value:u,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:f,enumerable:!0,configurable:!0},_:{value:n}})}function ln(l,u,r){this.k=l,this.x=u,this.y=r}ln.prototype={constructor:ln,scale:function(l){return l===1?this:new ln(this.k*l,this.x,this.y)},translate:function(l,u){return l===0&u===0?this:new ln(this.k,this.x+this.k*l,this.y+this.k*u)},apply:function(l){return[l[0]*this.k+this.x,l[1]*this.k+this.y]},applyX:function(l){return l*this.k+this.x},applyY:function(l){return l*this.k+this.y},invert:function(l){return[(l[0]-this.x)/this.k,(l[1]-this.y)/this.k]},invertX:function(l){return(l-this.x)/this.k},invertY:function(l){return(l-this.y)/this.k},rescaleX:function(l){return l.copy().domain(l.range().map(this.invertX,this).map(l.invert,l))},rescaleY:function(l){return l.copy().domain(l.range().map(this.invertY,this).map(l.invert,l))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var I0=new ln(1,0,0);xc.prototype=ln.prototype;function xc(l){while(!l.__zoom)if(!(l=l.parentNode))return I0;return l.__zoom}function FA(l){l.stopImmediatePropagation()}function a0(l){l.preventDefault(),l.stopImmediatePropagation()}function UB(l){return(!l.ctrlKey||l.type==="wheel")&&!l.button}function NB(){var l=this;if(l instanceof SVGElement){if(l=l.ownerSVGElement||l,l.hasAttribute("viewBox"))return l=l.viewBox.baseVal,[[l.x,l.y],[l.x+l.width,l.y+l.height]];return[[0,0],[l.width.baseVal.value,l.height.baseVal.value]]}return[[0,0],[l.clientWidth,l.clientHeight]]}function Cw(){return this.__zoom||I0}function QB(l){return-l.deltaY*(l.deltaMode===1?0.05:l.deltaMode?1:0.002)*(l.ctrlKey?10:1)}function wB(){return navigator.maxTouchPoints||"ontouchstart"in this}function qB(l,u,r){var f=l.invertX(u[0][0])-r[0][0],n=l.invertX(u[1][0])-r[1][0],i=l.invertY(u[0][1])-r[0][1],t=l.invertY(u[1][1])-r[1][1];return l.translate(n>f?(f+n)/2:Math.min(0,f)||Math.max(0,n),t>i?(i+t)/2:Math.min(0,i)||Math.max(0,t))}function bc(){var l=UB,u=NB,r=qB,f=QB,n=wB,i=[0,1/0],t=[[-1/0,-1/0],[1/0,1/0]],y=250,c=k0,$=R0("start","zoom","end"),A,j,F,U=500,N=150,W=0,L=10;function J(m){m.property("__zoom",Cw).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",Y).filter(n).on("touchstart.zoom",p).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}J.transform=function(m,X,S,b){var z=m.selection?m.selection():m;if(z.property("__zoom",Cw),m!==z)T(m,X,S,b);else z.interrupt().each(function(){O(this,arguments).event(b).start().zoom(null,typeof X==="function"?X.apply(this,arguments):X).end()})},J.scaleBy=function(m,X,S,b){J.scaleTo(m,function(){var z=this.__zoom.k,P=typeof X==="function"?X.apply(this,arguments):X;return z*P},S,b)},J.scaleTo=function(m,X,S,b){J.transform(m,function(){var z=u.apply(this,arguments),P=this.__zoom,s=S==null?q(z):typeof S==="function"?S.apply(this,arguments):S,k=P.invert(s),v=typeof X==="function"?X.apply(this,arguments):X;return r(Q(w(P,v),s,k),z,t)},S,b)},J.translateBy=function(m,X,S,b){J.transform(m,function(){return r(this.__zoom.translate(typeof X==="function"?X.apply(this,arguments):X,typeof S==="function"?S.apply(this,arguments):S),u.apply(this,arguments),t)},null,b)},J.translateTo=function(m,X,S,b,z){J.transform(m,function(){var P=u.apply(this,arguments),s=this.__zoom,k=b==null?q(P):typeof b==="function"?b.apply(this,arguments):b;return r(I0.translate(k[0],k[1]).scale(s.k).translate(typeof X==="function"?-X.apply(this,arguments):-X,typeof S==="function"?-S.apply(this,arguments):-S),P,t)},b,z)};function w(m,X){return X=Math.max(i[0],Math.min(i[1],X)),X===m.k?m:new ln(X,m.x,m.y)}function Q(m,X,S){var b=X[0]-S[0]*m.k,z=X[1]-S[1]*m.k;return b===m.x&&z===m.y?m:new ln(m.k,b,z)}function q(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function T(m,X,S,b){m.on("start.zoom",function(){O(this,arguments).event(b).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(b).end()}).tween("zoom",function(){var z=this,P=arguments,s=O(z,P).event(b),k=u.apply(z,P),v=S==null?q(k):typeof S==="function"?S.apply(z,P):S,tl=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),I=z.__zoom,M=typeof X==="function"?X.apply(z,P):X,rl=c(I.invert(v).concat(tl/I.k),M.invert(v).concat(tl/M.k));return function(cl){if(cl===1)cl=M;else{var $l=rl(cl),Tl=tl/$l[2];cl=new ln(Tl,v[0]-$l[0]*Tl,v[1]-$l[1]*Tl)}s.zoom(null,cl)}})}function O(m,X,S){return!S&&m.__zooming||new Z(m,X)}function Z(m,X){this.that=m,this.args=X,this.active=0,this.sourceEvent=null,this.extent=u.apply(m,X),this.taps=0}Z.prototype={event:function(m){if(m)this.sourceEvent=m;return this},start:function(){if(++this.active===1)this.that.__zooming=this,this.emit("start");return this},zoom:function(m,X){if(this.mouse&&m!=="mouse")this.mouse[1]=X.invert(this.mouse[0]);if(this.touch0&&m!=="touch")this.touch0[1]=X.invert(this.touch0[0]);if(this.touch1&&m!=="touch")this.touch1[1]=X.invert(this.touch1[0]);return this.that.__zoom=X,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(m){var X=fr(this.that).datum();$.call(m,this.that,new Q9(m,{sourceEvent:this.sourceEvent,target:J,type:m,transform:this.that.__zoom,dispatch:$}),X)}};function E(m,...X){if(!l.apply(this,arguments))return;var S=O(this,X).event(m),b=this.__zoom,z=Math.max(i[0],Math.min(i[1],b.k*Math.pow(2,f.apply(this,arguments)))),P=zr(m);if(S.wheel){if(S.mouse[0][0]!==P[0]||S.mouse[0][1]!==P[1])S.mouse[1]=b.invert(S.mouse[0]=P);clearTimeout(S.wheel)}else if(b.k===z)return;else S.mouse=[P,b.invert(P)],xi(this),S.start();a0(m),S.wheel=setTimeout(s,N),S.zoom("mouse",r(Q(w(b,z),S.mouse[0],S.mouse[1]),S.extent,t));function s(){S.wheel=null,S.end()}}function D(m,...X){if(F||!l.apply(this,arguments))return;var S=m.currentTarget,b=O(this,X,!0).event(m),z=fr(m.view).on("mousemove.zoom",v,!0).on("mouseup.zoom",tl,!0),P=zr(m,S),s=m.clientX,k=m.clientY;Jy(m.view),FA(m),b.mouse=[P,this.__zoom.invert(P)],xi(this),b.start();function v(I){if(a0(I),!b.moved){var M=I.clientX-s,rl=I.clientY-k;b.moved=M*M+rl*rl>W}b.event(I).zoom("mouse",r(Q(b.that.__zoom,b.mouse[0]=zr(I,S),b.mouse[1]),b.extent,t))}function tl(I){z.on("mousemove.zoom mouseup.zoom",null),Tc(I.view,b.moved),a0(I),b.event(I).end()}}function Y(m,...X){if(!l.apply(this,arguments))return;var S=this.__zoom,b=zr(m.changedTouches?m.changedTouches[0]:m,this),z=S.invert(b),P=S.k*(m.shiftKey?0.5:2),s=r(Q(w(S,P),b,z),u.apply(this,X),t);if(a0(m),y>0)fr(this).transition().duration(y).call(T,s,b,m);else fr(this).call(J.transform,s,b,m)}function p(m,...X){if(!l.apply(this,arguments))return;var S=m.touches,b=S.length,z=O(this,X,m.changedTouches.length===b).event(m),P,s,k,v;FA(m);for(s=0;s<b;++s)if(k=S[s],v=zr(k,this),v=[v,this.__zoom.invert(v),k.identifier],!z.touch0)z.touch0=v,P=!0,z.taps=1+!!A;else if(!z.touch1&&z.touch0[2]!==v[2])z.touch1=v,z.taps=0;if(A)A=clearTimeout(A);if(P){if(z.taps<2)j=v[0],A=setTimeout(function(){A=null},U);xi(this),z.start()}}function V(m,...X){if(!this.__zooming)return;var S=O(this,X).event(m),b=m.changedTouches,z=b.length,P,s,k,v;a0(m);for(P=0;P<z;++P)if(s=b[P],k=zr(s,this),S.touch0&&S.touch0[2]===s.identifier)S.touch0[0]=k;else if(S.touch1&&S.touch1[2]===s.identifier)S.touch1[0]=k;if(s=S.that.__zoom,S.touch1){var tl=S.touch0[0],I=S.touch0[1],M=S.touch1[0],rl=S.touch1[1],cl=(cl=M[0]-tl[0])*cl+(cl=M[1]-tl[1])*cl,$l=($l=rl[0]-I[0])*$l+($l=rl[1]-I[1])*$l;s=w(s,Math.sqrt(cl/$l)),k=[(tl[0]+M[0])/2,(tl[1]+M[1])/2],v=[(I[0]+rl[0])/2,(I[1]+rl[1])/2]}else if(S.touch0)k=S.touch0[0],v=S.touch0[1];else return;S.zoom("touch",r(Q(s,k,v),S.extent,t))}function B(m,...X){if(!this.__zooming)return;var S=O(this,X).event(m),b=m.changedTouches,z=b.length,P,s;if(FA(m),F)clearTimeout(F);F=setTimeout(function(){F=null},U);for(P=0;P<z;++P)if(s=b[P],S.touch0&&S.touch0[2]===s.identifier)delete S.touch0;else if(S.touch1&&S.touch1[2]===s.identifier)delete S.touch1;if(S.touch1&&!S.touch0)S.touch0=S.touch1,delete S.touch1;if(S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2){if(s=zr(s,this),Math.hypot(j[0]-s[0],j[1]-s[1])<L){var k=fr(this).on("dblclick.zoom");if(k)k.apply(this,arguments)}}}return J.wheelDelta=function(m){return arguments.length?(f=typeof m==="function"?m:Rc(+m),J):f},J.filter=function(m){return arguments.length?(l=typeof m==="function"?m:Rc(!!m),J):l},J.touchable=function(m){return arguments.length?(n=typeof m==="function"?m:Rc(!!m),J):n},J.extent=function(m){return arguments.length?(u=typeof m==="function"?m:Rc([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),J):u},J.scaleExtent=function(m){return arguments.length?(i[0]=+m[0],i[1]=+m[1],J):[i[0],i[1]]},J.translateExtent=function(m){return arguments.length?(t[0][0]=+m[0][0],t[1][0]=+m[1][0],t[0][1]=+m[0][1],t[1][1]=+m[1][1],J):[[t[0][0],t[0][1]],[t[1][0],t[1][1]]]},J.constrain=function(m){return arguments.length?(r=m,J):r},J.duration=function(m){return arguments.length?(y=+m,J):y},J.interpolate=function(m){return arguments.length?(c=m,J):c},J.on=function(){var m=$.on.apply($,arguments);return m===$?J:m},J.clickDistance=function(m){return arguments.length?(W=(m=+m)*m,J):Math.sqrt(W)},J.tapDistance=function(m){return arguments.length?(L=+m,J):L},J}var Qf={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:(l)=>`Node type "${l}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:(l)=>`The old edge with id=${l} does not exist.`,error009:(l)=>`Marker type "${l}" doesn't exist.`,error008:(l,{id:u,sourceHandle:r,targetHandle:f})=>`Couldn't create edge for ${l} handle id: "${l==="source"?r:f}", edge id: ${u}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:(l)=>`Edge type "${l}" not found. Using fallback type "default".`,error012:(l)=>`Node with id "${l}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(l="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${l}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},my=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],G9=["Enter"," ","Escape"],T9={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:l,x:u,y:r})=>`Moved selected node ${l}. New position, x: ${u}, y: ${r}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"},si;(function(l){l.Strict="strict",l.Loose="loose"})(si||(si={}));var ui;(function(l){l.Free="free",l.Vertical="vertical",l.Horizontal="horizontal"})(ui||(ui={}));var o0;(function(l){l.Partial="partial",l.Full="full"})(o0||(o0={}));var m9={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},Gn;(function(l){l.Bezier="default",l.Straight="straight",l.Step="step",l.SmoothStep="smoothstep",l.SimpleBezier="simplebezier"})(Gn||(Gn={}));var ki;(function(l){l.Arrow="arrow",l.ArrowClosed="arrowclosed"})(ki||(ki={}));var Kl;(function(l){l.Left="left",l.Top="top",l.Right="right",l.Bottom="bottom"})(Kl||(Kl={}));var Mw={[Kl.Left]:Kl.Right,[Kl.Right]:Kl.Left,[Kl.Top]:Kl.Bottom,[Kl.Bottom]:Kl.Top};function K9(l){return l===null?null:l?"valid":"invalid"}var z9=(l)=>("id"in l)&&("source"in l)&&("target"in l),ew=(l)=>("id"in l)&&("position"in l)&&!("source"in l)&&!("target"in l),E9=(l)=>("id"in l)&&("internals"in l)&&!("source"in l)&&!("target"in l);var kc=(l,u=[0,0])=>{let{width:r,height:f}=Tn(l),n=l.origin??u,i=r*n[0],t=f*n[1];return{x:l.position.x-i,y:l.position.y-t}},O9=(l,u={nodeOrigin:[0,0]})=>{if(l.length===0)return{x:0,y:0,width:0,height:0};let r=l.reduce((f,n)=>{let i=typeof n==="string",t=!u.nodeLookup&&!i?n:void 0;if(u.nodeLookup)t=i?u.nodeLookup.get(n):!E9(n)?u.nodeLookup.get(n.id):n;let y=t?NA(t,u.nodeOrigin):{x:0,y:0,x2:0,y2:0};return wA(f,y)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return qA(r)},Ky=(l,u={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},f=!1;return l.forEach((n)=>{if(u.filter===void 0||u.filter(n))r=wA(r,NA(n)),f=!0}),f?qA(r):{x:0,y:0,width:0,height:0}},QA=(l,u,[r,f,n]=[0,0,1],i=!1,t=!1)=>{let y={...Oy(u,[r,f,n]),width:u.width/n,height:u.height/n},c=[];for(let $ of l.values()){let{measured:A,selectable:j=!0,hidden:F=!1}=$;if(t&&!j||F)continue;let U=A.width??$.width??$.initialWidth??null,N=A.height??$.height??$.initialHeight??null,W=zy(y,e0($)),L=(U??0)*(N??0),J=i&&W>0;if(!$.internals.handleBounds||J||W>=L||$.dragging)c.push($)}return c},lq=(l,u)=>{let r=new Set;return l.forEach((f)=>{r.add(f.id)}),u.filter((f)=>r.has(f.source)||r.has(f.target))};function WB(l,u){let r=new Map,f=u?.nodes?new Set(u.nodes.map((n)=>n.id)):null;return l.forEach((n)=>{if(n.measured.width&&n.measured.height&&(u?.includeHiddenNodes||!n.hidden)&&(!f||f.has(n.id)))r.set(n.id,n)}),r}async function uq({nodes:l,width:u,height:r,panZoom:f,minZoom:n,maxZoom:i},t){if(l.size===0)return Promise.resolve(!0);let y=WB(l,t),c=Ky(y),$=gc(c,u,r,t?.minZoom??n,t?.maxZoom??i,t?.padding??0.1);return await f.setViewport($,{duration:t?.duration,ease:t?.ease,interpolate:t?.interpolate}),Promise.resolve(!0)}function Z9({nodeId:l,nextPosition:u,nodeLookup:r,nodeOrigin:f=[0,0],nodeExtent:n,onError:i}){let t=r.get(l),y=t.parentId?r.get(t.parentId):void 0,{x:c,y:$}=y?y.internals.positionAbsolute:{x:0,y:0},A=t.origin??f,j=t.extent||n;if(t.extent==="parent"&&!t.expandParent)if(!y)i?.("005",Qf.error005());else{let U=y.measured.width,N=y.measured.height;if(U&&N)j=[[c,$],[c+U,$+N]]}else if(y&&Ty(t.extent))j=[[t.extent[0][0]+c,t.extent[0][1]+$],[t.extent[1][0]+c,t.extent[1][1]+$]];let F=Ty(j)?d0(u,j,t.measured):u;if(t.measured.width===void 0||t.measured.height===void 0)i?.("015",Qf.error015());return{position:{x:F.x-c+(t.measured.width??0)*A[0],y:F.y-$+(t.measured.height??0)*A[1]},positionAbsolute:F}}async function rq({nodesToRemove:l=[],edgesToRemove:u=[],nodes:r,edges:f,onBeforeDelete:n}){let i=new Set(l.map((F)=>F.id)),t=[];for(let F of r){if(F.deletable===!1)continue;let U=i.has(F.id),N=!U&&F.parentId&&t.find((W)=>W.id===F.parentId);if(U||N)t.push(F)}let y=new Set(u.map((F)=>F.id)),c=f.filter((F)=>F.deletable!==!1),A=lq(t,c);for(let F of c)if(y.has(F.id)&&!A.find((N)=>N.id===F.id))A.push(F);if(!n)return{edges:A,nodes:t};let j=await n({nodes:t,edges:A});if(typeof j==="boolean")return j?{edges:A,nodes:t}:{edges:[],nodes:[]};return j}var Gy=(l,u=0,r=1)=>Math.min(Math.max(l,u),r),d0=(l={x:0,y:0},u,r)=>({x:Gy(l.x,u[0][0],u[1][0]-(r?.width??0)),y:Gy(l.y,u[0][1],u[1][1]-(r?.height??0))});function fq(l,u,r){let{width:f,height:n}=Tn(r),{x:i,y:t}=r.internals.positionAbsolute;return d0(l,[[i,t],[i+f,t+n]],u)}var hw=(l,u,r)=>{if(l<u)return Gy(Math.abs(l-u),1,u)/u;else if(l>r)return-Gy(Math.abs(l-r),1,u)/u;return 0},nq=(l,u,r=15,f=40)=>{let n=hw(l.x,f,u.width-f)*r,i=hw(l.y,f,u.height-f)*r;return[n,i]},wA=(l,u)=>({x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),x2:Math.max(l.x2,u.x2),y2:Math.max(l.y2,u.y2)}),L9=({x:l,y:u,width:r,height:f})=>({x:l,y:u,x2:l+r,y2:u+f}),qA=({x:l,y:u,x2:r,y2:f})=>({x:l,y:u,width:r-l,height:f-u}),e0=(l,u=[0,0])=>{let{x:r,y:f}=E9(l)?l.internals.positionAbsolute:kc(l,u);return{x:r,y:f,width:l.measured?.width??l.width??l.initialWidth??0,height:l.measured?.height??l.height??l.initialHeight??0}},NA=(l,u=[0,0])=>{let{x:r,y:f}=E9(l)?l.internals.positionAbsolute:kc(l,u);return{x:r,y:f,x2:r+(l.measured?.width??l.width??l.initialWidth??0),y2:f+(l.measured?.height??l.height??l.initialHeight??0)}},p9=(l,u)=>qA(wA(L9(l),L9(u))),zy=(l,u)=>{let r=Math.max(0,Math.min(l.x+l.width,u.x+u.width)-Math.max(l.x,u.x)),f=Math.max(0,Math.min(l.y+l.height,u.y+u.height)-Math.max(l.y,u.y));return Math.ceil(r*f)},H9=(l)=>Hf(l.width)&&Hf(l.height)&&Hf(l.x)&&Hf(l.y),Hf=(l)=>!isNaN(l)&&isFinite(l),B9=(l,u)=>{},Ey=(l,u=[1,1])=>{return{x:u[0]*Math.round(l.x/u[0]),y:u[1]*Math.round(l.y/u[1])}},Oy=({x:l,y:u},[r,f,n],i=!1,t=[1,1])=>{let y={x:(l-r)/n,y:(u-f)/n};return i?Ey(y,t):y},sc=({x:l,y:u},[r,f,n])=>{return{x:l*n+r,y:u*n+f}};function Wy(l,u){if(typeof l==="number")return Math.floor((u-u/(1+l))*0.5);if(typeof l==="string"&&l.endsWith("px")){let r=parseFloat(l);if(!Number.isNaN(r))return Math.floor(r)}if(typeof l==="string"&&l.endsWith("%")){let r=parseFloat(l);if(!Number.isNaN(r))return Math.floor(u*r*0.01)}return console.error(`[React Flow] The padding value "${l}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function LB(l,u,r){if(typeof l==="string"||typeof l==="number"){let f=Wy(l,r),n=Wy(l,u);return{top:f,right:n,bottom:f,left:n,x:n*2,y:f*2}}if(typeof l==="object"){let f=Wy(l.top??l.y??0,r),n=Wy(l.bottom??l.y??0,r),i=Wy(l.left??l.x??0,u),t=Wy(l.right??l.x??0,u);return{top:f,right:t,bottom:n,left:i,x:i+t,y:f+n}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function GB(l,u,r,f,n,i){let{x:t,y}=sc(l,[u,r,f]),{x:c,y:$}=sc({x:l.x+l.width,y:l.y+l.height},[u,r,f]),A=n-c,j=i-$;return{left:Math.floor(t),top:Math.floor(y),right:Math.floor(A),bottom:Math.floor(j)}}var gc=(l,u,r,f,n,i)=>{let t=LB(i,u,r),y=(u-t.x)/l.width,c=(r-t.y)/l.height,$=Math.min(y,c),A=Gy($,f,n),j=l.x+l.width/2,F=l.y+l.height/2,U=u/2-j*A,N=r/2-F*A,W=GB(l,U,N,A,u,r),L={left:Math.min(W.left-t.left,0),top:Math.min(W.top-t.top,0),right:Math.min(W.right-t.right,0),bottom:Math.min(W.bottom-t.bottom,0)};return{x:U-L.left+L.right,y:N-L.top+L.bottom,zoom:A}},Zy=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ty(l){return l!==void 0&&l!==null&&l!=="parent"}function Tn(l){return{width:l.measured?.width??l.width??l.initialWidth??0,height:l.measured?.height??l.height??l.initialHeight??0}}function D9(l){return(l.measured?.width??l.width??l.initialWidth)!==void 0&&(l.measured?.height??l.height??l.initialHeight)!==void 0}function V9(l,u={width:0,height:0},r,f,n){let i={...l},t=f.get(r);if(t){let y=t.origin||n;i.x+=t.internals.positionAbsolute.x-(u.width??0)*y[0],i.y+=t.internals.positionAbsolute.y-(u.height??0)*y[1]}return i}function S9(l,u){if(l.size!==u.size)return!1;for(let r of l)if(!u.has(r))return!1;return!0}function iq(){let l,u;return{promise:new Promise((f,n)=>{l=f,u=n}),resolve:l,reject:u}}function tq(l){return{...T9,...l||{}}}function vc(l,{snapGrid:u=[0,0],snapToGrid:r=!1,transform:f,containerBounds:n}){let{x:i,y:t}=Bf(l),y=Oy({x:i-(n?.left??0),y:t-(n?.top??0)},f),{x:c,y:$}=r?Ey(y,u):y;return{xSnapped:c,ySnapped:$,...y}}var WA=(l)=>({width:l.offsetWidth,height:l.offsetHeight}),X9=(l)=>l?.getRootNode?.()||window?.document,TB=["INPUT","SELECT","TEXTAREA"];function Y9(l){let u=l.composedPath?.()?.[0]||l.target;if(u?.nodeType!==1)return!1;return TB.includes(u.nodeName)||u.hasAttribute("contenteditable")||!!u.closest(".nokey")}var P9=(l)=>("clientX"in l),Bf=(l,u)=>{let r=P9(l),f=r?l.clientX:l.touches?.[0].clientX,n=r?l.clientY:l.touches?.[0].clientY;return{x:f-(u?.left??0),y:n-(u?.top??0)}},Rw=(l,u,r,f,n)=>{let i=u.querySelectorAll(`.${l}`);if(!i||!i.length)return null;return Array.from(i).map((t)=>{let y=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:l,nodeId:n,position:t.getAttribute("data-handlepos"),x:(y.left-r.left)/f,y:(y.top-r.top)/f,...WA(t)}})};function LA({sourceX:l,sourceY:u,targetX:r,targetY:f,sourceControlX:n,sourceControlY:i,targetControlX:t,targetControlY:y}){let c=l*0.125+n*0.375+t*0.375+r*0.125,$=u*0.125+i*0.375+y*0.375+f*0.125,A=Math.abs(c-l),j=Math.abs($-u);return[c,$,A,j]}function JA(l,u){if(l>=0)return 0.5*l;return u*25*Math.sqrt(-l)}function xw({pos:l,x1:u,y1:r,x2:f,y2:n,c:i}){switch(l){case Kl.Left:return[u-JA(u-f,i),r];case Kl.Right:return[u+JA(f-u,i),r];case Kl.Top:return[u,r-JA(r-n,i)];case Kl.Bottom:return[u,r+JA(n-r,i)]}}function GA({sourceX:l,sourceY:u,sourcePosition:r=Kl.Bottom,targetX:f,targetY:n,targetPosition:i=Kl.Top,curvature:t=0.25}){let[y,c]=xw({pos:r,x1:l,y1:u,x2:f,y2:n,c:t}),[$,A]=xw({pos:i,x1:f,y1:n,x2:l,y2:u,c:t}),[j,F,U,N]=LA({sourceX:l,sourceY:u,targetX:f,targetY:n,sourceControlX:y,sourceControlY:c,targetControlX:$,targetControlY:A});return[`M${l},${u} C${y},${c} ${$},${A} ${f},${n}`,j,F,U,N]}function C9({sourceX:l,sourceY:u,targetX:r,targetY:f}){let n=Math.abs(r-l)/2,i=r<l?r+n:r-n,t=Math.abs(f-u)/2,y=f<u?f+t:f-t;return[i,y,n,t]}function yq({sourceNode:l,targetNode:u,selected:r=!1,zIndex:f=0,elevateOnSelect:n=!1,zIndexMode:i="basic"}){if(i==="manual")return f;let t=n&&r?f+1000:f,y=Math.max(l.parentId||n&&l.selected?l.internals.z:0,u.parentId||n&&u.selected?u.internals.z:0);return t+y}function cq({sourceNode:l,targetNode:u,width:r,height:f,transform:n}){let i=wA(NA(l),NA(u));if(i.x===i.x2)i.x2+=1;if(i.y===i.y2)i.y2+=1;let t={x:-n[0]/n[2],y:-n[1]/n[2],width:r/n[2],height:f/n[2]};return zy(t,qA(i))>0}var mB=({source:l,sourceHandle:u,target:r,targetHandle:f})=>`xy-edge__${l}${u||""}-${r}${f||""}`,KB=(l,u)=>{return u.some((r)=>r.source===l.source&&r.target===l.target&&(r.sourceHandle===l.sourceHandle||!r.sourceHandle&&!l.sourceHandle)&&(r.targetHandle===l.targetHandle||!r.targetHandle&&!l.targetHandle))},M9=(l,u,r={})=>{if(!l.source||!l.target)return B9("006",Qf.error006()),u;let f=r.getEdgeId||mB,n;if(z9(l))n={...l};else n={...l,id:f(l)};if(KB(n,u))return u;if(n.sourceHandle===null)delete n.sourceHandle;if(n.targetHandle===null)delete n.targetHandle;return u.concat(n)};function TA({sourceX:l,sourceY:u,targetX:r,targetY:f}){let[n,i,t,y]=C9({sourceX:l,sourceY:u,targetX:r,targetY:f});return[`M ${l},${u}L ${r},${f}`,n,i,t,y]}var bw={[Kl.Left]:{x:-1,y:0},[Kl.Right]:{x:1,y:0},[Kl.Top]:{x:0,y:-1},[Kl.Bottom]:{x:0,y:1}},zB=({source:l,sourcePosition:u=Kl.Bottom,target:r})=>{if(u===Kl.Left||u===Kl.Right)return l.x<r.x?{x:1,y:0}:{x:-1,y:0};return l.y<r.y?{x:0,y:1}:{x:0,y:-1}},vw=(l,u)=>Math.sqrt(Math.pow(u.x-l.x,2)+Math.pow(u.y-l.y,2));function EB({source:l,sourcePosition:u=Kl.Bottom,target:r,targetPosition:f=Kl.Top,center:n,offset:i,stepPosition:t}){let y=bw[u],c=bw[f],$={x:l.x+y.x*i,y:l.y+y.y*i},A={x:r.x+c.x*i,y:r.y+c.y*i},j=zB({source:$,sourcePosition:u,target:A}),F=j.x!==0?"x":"y",U=j[F],N=[],W,L,J={x:0,y:0},w={x:0,y:0},[,,Q,q]=C9({sourceX:l.x,sourceY:l.y,targetX:r.x,targetY:r.y});if(y[F]*c[F]===-1){if(F==="x")W=n.x??$.x+(A.x-$.x)*t,L=n.y??($.y+A.y)/2;else W=n.x??($.x+A.x)/2,L=n.y??$.y+(A.y-$.y)*t;let E=[{x:W,y:$.y},{x:W,y:A.y}],D=[{x:$.x,y:L},{x:A.x,y:L}];if(y[F]===U)N=F==="x"?E:D;else N=F==="x"?D:E}else{let E=[{x:$.x,y:A.y}],D=[{x:A.x,y:$.y}];if(F==="x")N=y.x===U?D:E;else N=y.y===U?E:D;if(u===f){let m=Math.abs(l[F]-r[F]);if(m<=i){let X=Math.min(i-1,i-m);if(y[F]===U)J[F]=($[F]>l[F]?-1:1)*X;else w[F]=(A[F]>r[F]?-1:1)*X}}if(u!==f){let m=F==="x"?"y":"x",X=y[F]===c[m],S=$[m]>A[m],b=$[m]<A[m];if(y[F]===1&&(!X&&S||X&&b)||y[F]!==1&&(!X&&b||X&&S))N=F==="x"?E:D}let Y={x:$.x+J.x,y:$.y+J.y},p={x:A.x+w.x,y:A.y+w.y},V=Math.max(Math.abs(Y.x-N[0].x),Math.abs(p.x-N[0].x)),B=Math.max(Math.abs(Y.y-N[0].y),Math.abs(p.y-N[0].y));if(V>=B)W=(Y.x+p.x)/2,L=N[0].y;else W=N[0].x,L=(Y.y+p.y)/2}let T={x:$.x+J.x,y:$.y+J.y},O={x:A.x+w.x,y:A.y+w.y};return[[l,...T.x!==N[0].x||T.y!==N[0].y?[T]:[],...N,...O.x!==N[N.length-1].x||O.y!==N[N.length-1].y?[O]:[],r],W,L,Q,q]}function OB(l,u,r,f){let n=Math.min(vw(l,u)/2,vw(u,r)/2,f),{x:i,y:t}=u;if(l.x===i&&i===r.x||l.y===t&&t===r.y)return`L${i} ${t}`;if(l.y===t){let $=l.x<r.x?-1:1,A=l.y<r.y?1:-1;return`L ${i+n*$},${t}Q ${i},${t} ${i},${t+n*A}`}let y=l.x<r.x?1:-1,c=l.y<r.y?-1:1;return`L ${i},${t+n*c}Q ${i},${t} ${i+n*y},${t}`}function Ic({sourceX:l,sourceY:u,sourcePosition:r=Kl.Bottom,targetX:f,targetY:n,targetPosition:i=Kl.Top,borderRadius:t=5,centerX:y,centerY:c,offset:$=20,stepPosition:A=0.5}){let[j,F,U,N,W]=EB({source:{x:l,y:u},sourcePosition:r,target:{x:f,y:n},targetPosition:i,center:{x:y,y:c},offset:$,stepPosition:A}),L=`M${j[0].x} ${j[0].y}`;for(let J=1;J<j.length-1;J++)L+=OB(j[J-1],j[J],j[J+1],t);return L+=`L${j[j.length-1].x} ${j[j.length-1].y}`,[L,F,U,N,W]}function sw(l){return l&&!!(l.internals.handleBounds||l.handles?.length)&&!!(l.measured.width||l.width||l.initialWidth)}function _q(l){let{sourceNode:u,targetNode:r}=l;if(!sw(u)||!sw(r))return null;let f=u.internals.handleBounds||kw(u.handles),n=r.internals.handleBounds||kw(r.handles),i=gw(f?.source??[],l.sourceHandle),t=gw(l.connectionMode===si.Strict?n?.target??[]:(n?.target??[]).concat(n?.source??[]),l.targetHandle);if(!i||!t)return l.onError?.("008",Qf.error008(!i?"source":"target",{id:l.id,sourceHandle:l.sourceHandle,targetHandle:l.targetHandle})),null;let y=i?.position||Kl.Bottom,c=t?.position||Kl.Top,$=gi(u,i,y),A=gi(r,t,c);return{sourceX:$.x,sourceY:$.y,targetX:A.x,targetY:A.y,sourcePosition:y,targetPosition:c}}function kw(l){if(!l)return null;let u=[],r=[];for(let f of l)if(f.width=f.width??1,f.height=f.height??1,f.type==="source")u.push(f);else if(f.type==="target")r.push(f);return{source:u,target:r}}function gi(l,u,r=Kl.Left,f=!1){let n=(u?.x??0)+l.internals.positionAbsolute.x,i=(u?.y??0)+l.internals.positionAbsolute.y,{width:t,height:y}=u??Tn(l);if(f)return{x:n+t/2,y:i+y/2};switch(u?.position??r){case Kl.Top:return{x:n+t/2,y:i};case Kl.Right:return{x:n+t,y:i+y/2};case Kl.Bottom:return{x:n+t/2,y:i+y};case Kl.Left:return{x:n,y:i+y/2}}}function gw(l,u){if(!l)return null;return(!u?l[0]:l.find((r)=>r.id===u))||null}function mA(l,u){if(!l)return"";if(typeof l==="string")return l;return`${u?`${u}__`:""}${Object.keys(l).sort().map((f)=>`${f}=${l[f]}`).join("&")}`}function $q(l,{id:u,defaultColor:r,defaultMarkerStart:f,defaultMarkerEnd:n}){let i=new Set;return l.reduce((t,y)=>{return[y.markerStart||f,y.markerEnd||n].forEach((c)=>{if(c&&typeof c==="object"){let $=mA(c,u);if(!i.has($))t.push({id:$,color:c.color||r,...c}),i.add($)}}),t},[]).sort((t,y)=>t.id.localeCompare(y.id))}var Aq=1000,ZB=10,h9={nodeOrigin:[0,0],nodeExtent:my,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},pB={...h9,checkEquality:!0};function R9(l,u){let r={...l};for(let f in u)if(u[f]!==void 0)r[f]=u[f];return r}function jq(l,u,r){let f=R9(h9,r);for(let n of l.values())if(n.parentId)b9(n,l,u,f);else{let i=kc(n,f.nodeOrigin),t=Ty(n.extent)?n.extent:f.nodeExtent,y=d0(i,t,Tn(n));n.internals.positionAbsolute=y}}function HB(l,u){if(!l.handles)return!l.measured?void 0:u?.internals.handleBounds;let r=[],f=[];for(let n of l.handles){let i={id:n.id,width:n.width??1,height:n.height??1,nodeId:l.id,x:n.x,y:n.y,position:n.position,type:n.type};if(n.type==="source")r.push(i);else if(n.type==="target")f.push(i)}return{source:r,target:f}}function x9(l){return l==="manual"}function KA(l,u,r,f={}){let n=R9(pB,f),i={i:0},t=new Map(u),y=n?.elevateNodesOnSelect&&!x9(n.zIndexMode)?Aq:0,c=l.length>0,$=!1;u.clear(),r.clear();for(let A of l){let j=t.get(A.id);if(n.checkEquality&&A===j?.internals.userNode)u.set(A.id,j);else{let F=kc(A,n.nodeOrigin),U=Ty(A.extent)?A.extent:n.nodeExtent,N=d0(F,U,Tn(A));j={...n.defaults,...A,measured:{width:A.measured?.width,height:A.measured?.height},internals:{positionAbsolute:N,handleBounds:HB(A,j),z:Fq(A,y,n.zIndexMode),userNode:A}},u.set(A.id,j)}if((j.measured===void 0||j.measured.width===void 0||j.measured.height===void 0)&&!j.hidden)c=!1;if(A.parentId)b9(j,u,r,f,i);$||=A.selected??!1}return{nodesInitialized:c,hasSelectedNodes:$}}function BB(l,u){if(!l.parentId)return;let r=u.get(l.parentId);if(r)r.set(l.id,l);else u.set(l.parentId,new Map([[l.id,l]]))}function b9(l,u,r,f,n){let{elevateNodesOnSelect:i,nodeOrigin:t,nodeExtent:y,zIndexMode:c}=R9(h9,f),$=l.parentId,A=u.get($);if(!A){console.warn(`Parent node ${$} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}if(BB(l,r),n&&!A.parentId&&A.internals.rootParentIndex===void 0&&c==="auto")A.internals.rootParentIndex=++n.i,A.internals.z=A.internals.z+n.i*ZB;if(n&&A.internals.rootParentIndex!==void 0)n.i=A.internals.rootParentIndex;let j=i&&!x9(c)?Aq:0,{x:F,y:U,z:N}=DB(l,A,t,y,j,c),{positionAbsolute:W}=l.internals,L=F!==W.x||U!==W.y;if(L||N!==l.internals.z)u.set(l.id,{...l,internals:{...l.internals,positionAbsolute:L?{x:F,y:U}:W,z:N}})}function Fq(l,u,r){let f=Hf(l.zIndex)?l.zIndex:0;if(x9(r))return f;return f+(l.selected?u:0)}function DB(l,u,r,f,n,i){let{x:t,y}=u.internals.positionAbsolute,c=Tn(l),$=kc(l,r),A=Ty(l.extent)?d0($,l.extent,c):$,j=d0({x:t+A.x,y:y+A.y},f,c);if(l.extent==="parent")j=fq(j,c,u);let F=Fq(l,n,i),U=u.internals.z??0;return{x:j.x,y:j.y,z:U>=F?U+1:F}}function zA(l,u,r,f=[0,0]){let n=[],i=new Map;for(let t of l){let y=u.get(t.parentId);if(!y)continue;let c=i.get(t.parentId)?.expandedRect??e0(y),$=p9(c,t.rect);i.set(t.parentId,{expandedRect:$,parent:y})}if(i.size>0)i.forEach(({expandedRect:t,parent:y},c)=>{let $=y.internals.positionAbsolute,A=Tn(y),j=y.origin??f,F=t.x<$.x?Math.round(Math.abs($.x-t.x)):0,U=t.y<$.y?Math.round(Math.abs($.y-t.y)):0,N=Math.max(A.width,Math.round(t.width)),W=Math.max(A.height,Math.round(t.height)),L=(N-A.width)*j[0],J=(W-A.height)*j[1];if(F>0||U>0||L||J)n.push({id:c,type:"position",position:{x:y.position.x-F+L,y:y.position.y-U+J}}),r.get(c)?.forEach((w)=>{if(!l.some((Q)=>Q.id===w.id))n.push({id:w.id,type:"position",position:{x:w.position.x+F,y:w.position.y+U}})});if(A.width<t.width||A.height<t.height||F||U)n.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:N+(F?j[0]*F-L:0),height:W+(U?j[1]*U-J:0)}})});return n}function Jq(l,u,r,f,n,i,t){let y=f?.querySelector(".xyflow__viewport"),c=!1;if(!y)return{changes:[],updatedInternals:c};let $=[],A=window.getComputedStyle(y),{m22:j}=new window.DOMMatrixReadOnly(A.transform),F=[];for(let U of l.values()){let N=u.get(U.id);if(!N)continue;if(N.hidden){u.set(N.id,{...N,internals:{...N.internals,handleBounds:void 0}}),c=!0;continue}let W=WA(U.nodeElement),L=N.measured.width!==W.width||N.measured.height!==W.height;if(!!(W.width&&W.height&&(L||!N.internals.handleBounds||U.force))){let w=U.nodeElement.getBoundingClientRect(),Q=Ty(N.extent)?N.extent:i,{positionAbsolute:q}=N.internals;if(N.parentId&&N.extent==="parent")q=fq(q,W,u.get(N.parentId));else if(Q)q=d0(q,Q,W);let T={...N,measured:W,internals:{...N.internals,positionAbsolute:q,handleBounds:{source:Rw("source",U.nodeElement,w,j,N.id),target:Rw("target",U.nodeElement,w,j,N.id)}}};if(u.set(N.id,T),N.parentId)b9(T,u,r,{nodeOrigin:n,zIndexMode:t});if(c=!0,L){if($.push({id:N.id,type:"dimensions",dimensions:W}),N.expandParent&&N.parentId)F.push({id:N.id,parentId:N.parentId,rect:e0(T,n)})}}}if(F.length>0){let U=zA(F,u,r,n);$.push(...U)}return{changes:$,updatedInternals:c}}async function Uq({delta:l,panZoom:u,transform:r,translateExtent:f,width:n,height:i}){if(!u||!l.x&&!l.y)return Promise.resolve(!1);let t=await u.setViewportConstrained({x:r[0]+l.x,y:r[1]+l.y,zoom:r[2]},[[0,0],[n,i]],f),y=!!t&&(t.x!==r[0]||t.y!==r[1]||t.k!==r[2]);return Promise.resolve(y)}function Iw(l,u,r,f,n,i){let t=n,y=f.get(t)||new Map;f.set(t,y.set(r,u)),t=`${n}-${l}`;let c=f.get(t)||new Map;if(f.set(t,c.set(r,u)),i){t=`${n}-${l}-${i}`;let $=f.get(t)||new Map;f.set(t,$.set(r,u))}}function v9(l,u,r){l.clear(),u.clear();for(let f of r){let{source:n,target:i,sourceHandle:t=null,targetHandle:y=null}=f,c={edgeId:f.id,source:n,target:i,sourceHandle:t,targetHandle:y},$=`${n}-${t}--${i}-${y}`,A=`${i}-${y}--${n}-${t}`;Iw("source",c,A,l,n,t),Iw("target",c,$,l,i,y),u.set(f.id,f)}}function Nq(l,u){if(!l.parentId)return!1;let r=u.get(l.parentId);if(!r)return!1;if(r.selected)return!0;return Nq(r,u)}function aw(l,u,r){let f=l;do{if(f?.matches?.(u))return!0;if(f===r)return!1;f=f?.parentElement}while(f);return!1}function VB(l,u,r,f){let n=new Map;for(let[i,t]of l)if((t.selected||t.id===f)&&(!t.parentId||!Nq(t,l))&&(t.draggable||u&&typeof t.draggable>"u")){let y=l.get(i);if(y)n.set(i,{id:i,position:y.position||{x:0,y:0},distance:{x:r.x-y.internals.positionAbsolute.x,y:r.y-y.internals.positionAbsolute.y},extent:y.extent,parentId:y.parentId,origin:y.origin,expandParent:y.expandParent,internals:{positionAbsolute:y.internals.positionAbsolute||{x:0,y:0}},measured:{width:y.measured.width??0,height:y.measured.height??0}})}return n}function w9({nodeId:l,dragItems:u,nodeLookup:r,dragging:f=!0}){let n=[];for(let[t,y]of u){let c=r.get(t)?.internals.userNode;if(c)n.push({...c,position:y.position,dragging:f})}if(!l)return[n[0],n];let i=r.get(l)?.internals.userNode;return[!i?n[0]:{...i,position:u.get(l)?.position||i.position,dragging:f},n]}function SB({dragItems:l,snapGrid:u,x:r,y:f}){let n=l.values().next().value;if(!n)return null;let i={x:r-n.distance.x,y:f-n.distance.y},t=Ey(i,u);return{x:t.x-i.x,y:t.y-i.y}}function Qq({onNodeMouseDown:l,getStoreItems:u,onDragStart:r,onDrag:f,onDragStop:n}){let i={x:null,y:null},t=0,y=new Map,c=!1,$={x:0,y:0},A=null,j=!1,F=null,U=!1,N=!1,W=null;function L({noDragClassName:w,handleSelector:Q,domNode:q,isSelectable:T,nodeId:O,nodeClickDistance:Z=0}){F=fr(q);function E({x:V,y:B}){let{nodeLookup:m,nodeExtent:X,snapGrid:S,snapToGrid:b,nodeOrigin:z,onNodeDrag:P,onSelectionDrag:s,onError:k,updateNodePositions:v}=u();i={x:V,y:B};let tl=!1,I=y.size>1,M=I&&X?L9(Ky(y)):null,rl=I&&b?SB({dragItems:y,snapGrid:S,x:V,y:B}):null;for(let[cl,$l]of y){if(!m.has(cl))continue;let Tl={x:V-$l.distance.x,y:B-$l.distance.y};if(b)Tl=rl?{x:Math.round(Tl.x+rl.x),y:Math.round(Tl.y+rl.y)}:Ey(Tl,S);let Ql=null;if(I&&X&&!$l.extent&&M){let{positionAbsolute:a}=$l.internals,ul=a.x-M.x+X[0][0],zl=a.x+$l.measured.width-M.x2+X[1][0],o=a.y-M.y+X[0][1],ql=a.y+$l.measured.height-M.y2+X[1][1];Ql=[[ul,o],[zl,ql]]}let{position:Ol,positionAbsolute:h}=Z9({nodeId:cl,nextPosition:Tl,nodeLookup:m,nodeExtent:Ql?Ql:X,nodeOrigin:z,onError:k});tl=tl||$l.position.x!==Ol.x||$l.position.y!==Ol.y,$l.position=Ol,$l.internals.positionAbsolute=h}if(N=N||tl,!tl)return;if(v(y,!0),W&&(f||P||!O&&s)){let[cl,$l]=w9({nodeId:O,dragItems:y,nodeLookup:m});if(f?.(W,y,cl,$l),P?.(W,cl,$l),!O)s?.(W,$l)}}async function D(){if(!A)return;let{transform:V,panBy:B,autoPanSpeed:m,autoPanOnNodeDrag:X}=u();if(!X){c=!1,cancelAnimationFrame(t);return}let[S,b]=nq($,A,m);if(S!==0||b!==0){if(i.x=(i.x??0)-S/V[2],i.y=(i.y??0)-b/V[2],await B({x:S,y:b}))E(i)}t=requestAnimationFrame(D)}function Y(V){let{nodeLookup:B,multiSelectionActive:m,nodesDraggable:X,transform:S,snapGrid:b,snapToGrid:z,selectNodesOnDrag:P,onNodeDragStart:s,onSelectionDragStart:k,unselectNodesAndEdges:v}=u();if(j=!0,(!P||!T)&&!m&&O){if(!B.get(O)?.selected)v()}if(T&&P&&O)l?.(O);let tl=vc(V.sourceEvent,{transform:S,snapGrid:b,snapToGrid:z,containerBounds:A});if(i=tl,y=VB(B,X,tl,O),y.size>0&&(r||s||!O&&k)){let[I,M]=w9({nodeId:O,dragItems:y,nodeLookup:B});if(r?.(V.sourceEvent,y,I,M),s?.(V.sourceEvent,I,M),!O)k?.(V.sourceEvent,M)}}let p=zc().clickDistance(Z).on("start",(V)=>{let{domNode:B,nodeDragThreshold:m,transform:X,snapGrid:S,snapToGrid:b}=u();if(A=B?.getBoundingClientRect()||null,U=!1,N=!1,W=V.sourceEvent,m===0)Y(V);i=vc(V.sourceEvent,{transform:X,snapGrid:S,snapToGrid:b,containerBounds:A}),$=Bf(V.sourceEvent,A)}).on("drag",(V)=>{let{autoPanOnNodeDrag:B,transform:m,snapGrid:X,snapToGrid:S,nodeDragThreshold:b,nodeLookup:z}=u(),P=vc(V.sourceEvent,{transform:m,snapGrid:X,snapToGrid:S,containerBounds:A});if(W=V.sourceEvent,V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1||O&&!z.has(O))U=!0;if(U)return;if(!c&&B&&j)c=!0,D();if(!j){let s=Bf(V.sourceEvent,A),k=s.x-$.x,v=s.y-$.y;if(Math.sqrt(k*k+v*v)>b)Y(V)}if((i.x!==P.xSnapped||i.y!==P.ySnapped)&&y&&j)$=Bf(V.sourceEvent,A),E(P)}).on("end",(V)=>{if(!j||U)return;if(c=!1,j=!1,cancelAnimationFrame(t),y.size>0){let{nodeLookup:B,updateNodePositions:m,onNodeDragStop:X,onSelectionDragStop:S}=u();if(N)m(y,!1),N=!1;if(n||X||!O&&S){let[b,z]=w9({nodeId:O,dragItems:y,nodeLookup:B,dragging:!1});if(n?.(V.sourceEvent,y,b,z),X?.(V.sourceEvent,b,z),!O)S?.(V.sourceEvent,z)}}}).filter((V)=>{let B=V.target;return!V.button&&(!w||!aw(B,`.${w}`,q))&&(!Q||aw(B,Q,q))});F.call(p)}function J(){F?.on(".drag",null)}return{update:L,destroy:J}}function XB(l,u,r){let f=[],n={x:l.x-r,y:l.y-r,width:r*2,height:r*2};for(let i of u.values())if(zy(n,e0(i))>0)f.push(i);return f}var YB=250;function PB(l,u,r,f){let n=[],i=1/0,t=XB(l,r,u+YB);for(let y of t){let c=[...y.internals.handleBounds?.source??[],...y.internals.handleBounds?.target??[]];for(let $ of c){if(f.nodeId===$.nodeId&&f.type===$.type&&f.id===$.id)continue;let{x:A,y:j}=gi(y,$,$.position,!0),F=Math.sqrt(Math.pow(A-l.x,2)+Math.pow(j-l.y,2));if(F>u)continue;if(F<i)n=[{...$,x:A,y:j}],i=F;else if(F===i)n.push({...$,x:A,y:j})}}if(!n.length)return null;if(n.length>1){let y=f.type==="source"?"target":"source";return n.find((c)=>c.type===y)??n[0]}return n[0]}function wq(l,u,r,f,n,i=!1){let t=f.get(l);if(!t)return null;let y=n==="strict"?t.internals.handleBounds?.[u]:[...t.internals.handleBounds?.source??[],...t.internals.handleBounds?.target??[]],c=(r?y?.find(($)=>$.id===r):y?.[0])??null;return c&&i?{...c,...gi(t,c,c.position,!0)}:c}function qq(l,u){if(l)return l;else if(u?.classList.contains("target"))return"target";else if(u?.classList.contains("source"))return"source";return null}function CB(l,u){let r=null;if(u)r=!0;else if(l&&!u)r=!1;return r}var Wq=()=>!0;function MB(l,{connectionMode:u,connectionRadius:r,handleId:f,nodeId:n,edgeUpdaterType:i,isTarget:t,domNode:y,nodeLookup:c,lib:$,autoPanOnConnect:A,flowId:j,panBy:F,cancelConnection:U,onConnectStart:N,onConnect:W,onConnectEnd:L,isValidConnection:J=Wq,onReconnectEnd:w,updateConnection:Q,getTransform:q,getFromHandle:T,autoPanSpeed:O,dragThreshold:Z=1,handleDomNode:E}){let D=X9(l.target),Y=0,p,{x:V,y:B}=Bf(l),m=qq(i,E),X=y?.getBoundingClientRect(),S=!1;if(!X||!m)return;let b=wq(n,m,f,c,u);if(!b)return;let z=Bf(l,X),P=!1,s=null,k=!1,v=null;function tl(){if(!A||!X)return;let[Ol,h]=nq(z,X,O);F({x:Ol,y:h}),Y=requestAnimationFrame(tl)}let I={...b,nodeId:n,type:m,position:b.position},M=c.get(n),cl={inProgress:!0,isValid:null,from:gi(M,I,Kl.Left,!0),fromHandle:I,fromPosition:I.position,fromNode:M,to:z,toHandle:null,toPosition:Mw[I.position],toNode:null,pointer:z};function $l(){S=!0,Q(cl),N?.(l,{nodeId:n,handleId:f,handleType:m})}if(Z===0)$l();function Tl(Ol){if(!S){let{x:ql,y:pl}=Bf(Ol),Bl=ql-V,Il=pl-B;if(!(Bl*Bl+Il*Il>Z*Z))return;$l()}if(!T()||!I){Ql(Ol);return}let h=q();if(z=Bf(Ol,X),p=PB(Oy(z,h,!1,[1,1]),r,c,I),!P)tl(),P=!0;let a=Lq(Ol,{handle:p,connectionMode:u,fromNodeId:n,fromHandleId:f,fromType:t?"target":"source",isValidConnection:J,doc:D,lib:$,flowId:j,nodeLookup:c});v=a.handleDomNode,s=a.connection,k=CB(!!p,a.isValid);let ul=c.get(n),zl=ul?gi(ul,I,Kl.Left,!0):cl.from,o={...cl,from:zl,isValid:k,to:a.toHandle&&k?sc({x:a.toHandle.x,y:a.toHandle.y},h):z,toHandle:a.toHandle,toPosition:k&&a.toHandle?a.toHandle.position:Mw[I.position],toNode:a.toHandle?c.get(a.toHandle.nodeId):null,pointer:z};Q(o),cl=o}function Ql(Ol){if("touches"in Ol&&Ol.touches.length>0)return;if(S){if((p||v)&&s&&k)W?.(s);let{inProgress:h,...a}=cl,ul={...a,toPosition:cl.toHandle?cl.toPosition:null};if(L?.(Ol,ul),i)w?.(Ol,ul)}U(),cancelAnimationFrame(Y),P=!1,k=!1,s=null,v=null,D.removeEventListener("mousemove",Tl),D.removeEventListener("mouseup",Ql),D.removeEventListener("touchmove",Tl),D.removeEventListener("touchend",Ql)}D.addEventListener("mousemove",Tl),D.addEventListener("mouseup",Ql),D.addEventListener("touchmove",Tl),D.addEventListener("touchend",Ql)}function Lq(l,{handle:u,connectionMode:r,fromNodeId:f,fromHandleId:n,fromType:i,doc:t,lib:y,flowId:c,isValidConnection:$=Wq,nodeLookup:A}){let j=i==="target",F=u?t.querySelector(`.${y}-flow__handle[data-id="${c}-${u?.nodeId}-${u?.id}-${u?.type}"]`):null,{x:U,y:N}=Bf(l),W=t.elementFromPoint(U,N),L=W?.classList.contains(`${y}-flow__handle`)?W:F,J={handleDomNode:L,isValid:!1,connection:null,toHandle:null};if(L){let w=qq(void 0,L),Q=L.getAttribute("data-nodeid"),q=L.getAttribute("data-handleid"),T=L.classList.contains("connectable"),O=L.classList.contains("connectableend");if(!Q||!w)return J;let Z={source:j?Q:f,sourceHandle:j?q:n,target:j?f:Q,targetHandle:j?n:q};J.connection=Z;let D=T&&O&&(r===si.Strict?j&&w==="source"||!j&&w==="target":Q!==f||q!==n);J.isValid=D&&$(Z),J.toHandle=wq(Q,w,q,A,r,!0)}return J}var EA={onPointerDown:MB,isValid:Lq};function Gq({domNode:l,panZoom:u,getTransform:r,getViewScale:f}){let n=fr(l);function i({translateExtent:y,width:c,height:$,zoomStep:A=1,pannable:j=!0,zoomable:F=!0,inversePan:U=!1}){let N=(Q)=>{if(Q.sourceEvent.type!=="wheel"||!u)return;let q=r(),T=Q.sourceEvent.ctrlKey&&Zy()?10:1,O=-Q.sourceEvent.deltaY*(Q.sourceEvent.deltaMode===1?0.05:Q.sourceEvent.deltaMode?1:0.002)*A,Z=q[2]*Math.pow(2,O*T);u.scaleTo(Z)},W=[0,0],L=(Q)=>{if(Q.sourceEvent.type==="mousedown"||Q.sourceEvent.type==="touchstart")W=[Q.sourceEvent.clientX??Q.sourceEvent.touches[0].clientX,Q.sourceEvent.clientY??Q.sourceEvent.touches[0].clientY]},J=(Q)=>{let q=r();if(Q.sourceEvent.type!=="mousemove"&&Q.sourceEvent.type!=="touchmove"||!u)return;let T=[Q.sourceEvent.clientX??Q.sourceEvent.touches[0].clientX,Q.sourceEvent.clientY??Q.sourceEvent.touches[0].clientY],O=[T[0]-W[0],T[1]-W[1]];W=T;let Z=f()*Math.max(q[2],Math.log(q[2]))*(U?-1:1),E={x:q[0]-O[0]*Z,y:q[1]-O[1]*Z},D=[[0,0],[c,$]];u.setViewportConstrained({x:E.x,y:E.y,zoom:q[2]},D,y)},w=bc().on("start",L).on("zoom",j?J:null).on("zoom.wheel",F?N:null);n.call(w,{})}function t(){n.on("zoom",null)}return{update:i,destroy:t,pointer:zr}}var OA=(l)=>({x:l.x,y:l.y,zoom:l.k}),q9=({x:l,y:u,zoom:r})=>I0.translate(l,u).scale(r),Ly=(l,u)=>l.target.closest(`.${u}`),Tq=(l,u)=>u===2&&Array.isArray(l)&&l.includes(2),hB=(l)=>((l*=2)<=1?l*l*l:(l-=2)*l*l+2)/2,W9=(l,u=0,r=hB,f=()=>{})=>{let n=typeof u==="number"&&u>0;if(!n)f();return n?l.transition().duration(u).ease(r).on("end",f):l},mq=(l)=>{let u=l.ctrlKey&&Zy()?10:1;return-l.deltaY*(l.deltaMode===1?0.05:l.deltaMode?1:0.002)*u};function RB({zoomPanValues:l,noWheelClassName:u,d3Selection:r,d3Zoom:f,panOnScrollMode:n,panOnScrollSpeed:i,zoomOnPinch:t,onPanZoomStart:y,onPanZoom:c,onPanZoomEnd:$}){return(A)=>{if(Ly(A,u)){if(A.ctrlKey)A.preventDefault();return!1}A.preventDefault(),A.stopImmediatePropagation();let j=r.property("__zoom").k||1;if(A.ctrlKey&&t){let L=zr(A),J=mq(A),w=j*Math.pow(2,J);f.scaleTo(r,w,L,A);return}let F=A.deltaMode===1?20:1,U=n===ui.Vertical?0:A.deltaX*F,N=n===ui.Horizontal?0:A.deltaY*F;if(!Zy()&&A.shiftKey&&n!==ui.Vertical)U=A.deltaY*F,N=0;f.translateBy(r,-(U/j)*i,-(N/j)*i,{internal:!0});let W=OA(r.property("__zoom"));if(clearTimeout(l.panScrollTimeout),!l.isPanScrolling)l.isPanScrolling=!0,y?.(A,W);else c?.(A,W),l.panScrollTimeout=setTimeout(()=>{$?.(A,W),l.isPanScrolling=!1},150)}}function xB({noWheelClassName:l,preventScrolling:u,d3ZoomHandler:r}){return function(f,n){let i=f.type==="wheel",t=!u&&i&&!f.ctrlKey,y=Ly(f,l);if(f.ctrlKey&&i&&y)f.preventDefault();if(t||y)return null;f.preventDefault(),r.call(this,f,n)}}function bB({zoomPanValues:l,onDraggingChange:u,onPanZoomStart:r}){return(f)=>{if(f.sourceEvent?.internal)return;let n=OA(f.transform);if(l.mouseButton=f.sourceEvent?.button||0,l.isZoomingOrPanning=!0,l.prevViewport=n,f.sourceEvent?.type==="mousedown")u(!0);if(r)r?.(f.sourceEvent,n)}}function vB({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:r,onTransformChange:f,onPanZoom:n}){return(i)=>{if(l.usedRightMouseButton=!!(r&&Tq(u,l.mouseButton??0)),!i.sourceEvent?.sync)f([i.transform.x,i.transform.y,i.transform.k]);if(n&&!i.sourceEvent?.internal)n?.(i.sourceEvent,OA(i.transform))}}function sB({zoomPanValues:l,panOnDrag:u,panOnScroll:r,onDraggingChange:f,onPanZoomEnd:n,onPaneContextMenu:i}){return(t)=>{if(t.sourceEvent?.internal)return;if(l.isZoomingOrPanning=!1,i&&Tq(u,l.mouseButton??0)&&!l.usedRightMouseButton&&t.sourceEvent)i(t.sourceEvent);if(l.usedRightMouseButton=!1,f(!1),n){let y=OA(t.transform);l.prevViewport=y,clearTimeout(l.timerId),l.timerId=setTimeout(()=>{n?.(t.sourceEvent,y)},r?150:0)}}}function kB({zoomActivationKeyPressed:l,zoomOnScroll:u,zoomOnPinch:r,panOnDrag:f,panOnScroll:n,zoomOnDoubleClick:i,userSelectionActive:t,noWheelClassName:y,noPanClassName:c,lib:$,connectionInProgress:A}){return(j)=>{let F=l||u,U=r&&j.ctrlKey,N=j.type==="wheel";if(j.button===1&&j.type==="mousedown"&&(Ly(j,`${$}-flow__node`)||Ly(j,`${$}-flow__edge`)))return!0;if(!f&&!F&&!n&&!i&&!r)return!1;if(t)return!1;if(A&&!N)return!1;if(Ly(j,y)&&N)return!1;if(Ly(j,c)&&(!N||n&&N&&!l))return!1;if(!r&&j.ctrlKey&&N)return!1;if(!r&&j.type==="touchstart"&&j.touches?.length>1)return j.preventDefault(),!1;if(!F&&!n&&!U&&N)return!1;if(!f&&(j.type==="mousedown"||j.type==="touchstart"))return!1;if(Array.isArray(f)&&!f.includes(j.button)&&j.type==="mousedown")return!1;let W=Array.isArray(f)&&f.includes(j.button)||!j.button||j.button<=1;return(!j.ctrlKey||N)&&W}}function Kq({domNode:l,minZoom:u,maxZoom:r,translateExtent:f,viewport:n,onPanZoom:i,onPanZoomStart:t,onPanZoomEnd:y,onDraggingChange:c}){let $={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},A=l.getBoundingClientRect(),j=bc().scaleExtent([u,r]).translateExtent(f),F=fr(l).call(j);w({x:n.x,y:n.y,zoom:Gy(n.zoom,u,r)},[[0,0],[A.width,A.height]],f);let U=F.on("wheel.zoom"),N=F.on("dblclick.zoom");j.wheelDelta(mq);function W(p,V){if(F)return new Promise((B)=>{j?.interpolate(V?.interpolate==="linear"?Ln:k0).transform(W9(F,V?.duration,V?.ease,()=>B(!0)),p)});return Promise.resolve(!1)}function L({noWheelClassName:p,noPanClassName:V,onPaneContextMenu:B,userSelectionActive:m,panOnScroll:X,panOnDrag:S,panOnScrollMode:b,panOnScrollSpeed:z,preventScrolling:P,zoomOnPinch:s,zoomOnScroll:k,zoomOnDoubleClick:v,zoomActivationKeyPressed:tl,lib:I,onTransformChange:M,connectionInProgress:rl,paneClickDistance:cl,selectionOnDrag:$l}){if(m&&!$.isZoomingOrPanning)J();let Tl=X&&!tl&&!m;j.clickDistance($l?1/0:!Hf(cl)||cl<0?0:cl);let Ql=Tl?RB({zoomPanValues:$,noWheelClassName:p,d3Selection:F,d3Zoom:j,panOnScrollMode:b,panOnScrollSpeed:z,zoomOnPinch:s,onPanZoomStart:t,onPanZoom:i,onPanZoomEnd:y}):xB({noWheelClassName:p,preventScrolling:P,d3ZoomHandler:U});if(F.on("wheel.zoom",Ql,{passive:!1}),!m){let h=bB({zoomPanValues:$,onDraggingChange:c,onPanZoomStart:t});j.on("start",h);let a=vB({zoomPanValues:$,panOnDrag:S,onPaneContextMenu:!!B,onPanZoom:i,onTransformChange:M});j.on("zoom",a);let ul=sB({zoomPanValues:$,panOnDrag:S,panOnScroll:X,onPaneContextMenu:B,onPanZoomEnd:y,onDraggingChange:c});j.on("end",ul)}let Ol=kB({zoomActivationKeyPressed:tl,panOnDrag:S,zoomOnScroll:k,panOnScroll:X,zoomOnDoubleClick:v,zoomOnPinch:s,userSelectionActive:m,noPanClassName:V,noWheelClassName:p,lib:I,connectionInProgress:rl});if(j.filter(Ol),v)F.on("dblclick.zoom",N);else F.on("dblclick.zoom",null)}function J(){j.on("zoom",null)}async function w(p,V,B){let m=q9(p),X=j?.constrain()(m,V,B);if(X)await W(X);return new Promise((S)=>S(X))}async function Q(p,V){let B=q9(p);return await W(B,V),new Promise((m)=>m(B))}function q(p){if(F){let V=q9(p),B=F.property("__zoom");if(B.k!==p.zoom||B.x!==p.x||B.y!==p.y)j?.transform(F,V,null,{sync:!0})}}function T(){let p=F?xc(F.node()):{x:0,y:0,k:1};return{x:p.x,y:p.y,zoom:p.k}}function O(p,V){if(F)return new Promise((B)=>{j?.interpolate(V?.interpolate==="linear"?Ln:k0).scaleTo(W9(F,V?.duration,V?.ease,()=>B(!0)),p)});return Promise.resolve(!1)}function Z(p,V){if(F)return new Promise((B)=>{j?.interpolate(V?.interpolate==="linear"?Ln:k0).scaleBy(W9(F,V?.duration,V?.ease,()=>B(!0)),p)});return Promise.resolve(!1)}function E(p){j?.scaleExtent(p)}function D(p){j?.translateExtent(p)}function Y(p){let V=!Hf(p)||p<0?0:p;j?.clickDistance(V)}return{update:L,destroy:J,setViewport:Q,setViewportConstrained:w,getViewport:T,scaleTo:O,scaleBy:Z,setScaleExtent:E,setTranslateExtent:D,syncViewport:q,setClickDistance:Y}}var Ii;(function(l){l.Line="line",l.Handle="handle"})(Ii||(Ii={}));function gB({width:l,prevWidth:u,height:r,prevHeight:f,affectsX:n,affectsY:i}){let t=l-u,y=r-f,c=[t>0?1:t<0?-1:0,y>0?1:y<0?-1:0];if(t&&n)c[0]=c[0]*-1;if(y&&i)c[1]=c[1]*-1;return c}function ow(l){let u=l.includes("right")||l.includes("left"),r=l.includes("bottom")||l.includes("top"),f=l.includes("left"),n=l.includes("top");return{isHorizontal:u,isVertical:r,affectsX:f,affectsY:n}}function bi(l,u){return Math.max(0,u-l)}function vi(l,u){return Math.max(0,l-u)}function UA(l,u,r){return Math.max(0,u-l,l-r)}function dw(l,u){return l?!u:u}function IB(l,u,r,f,n,i,t,y){let{affectsX:c,affectsY:$}=u,{isHorizontal:A,isVertical:j}=u,F=A&&j,{xSnapped:U,ySnapped:N}=r,{minWidth:W,maxWidth:L,minHeight:J,maxHeight:w}=f,{x:Q,y:q,width:T,height:O,aspectRatio:Z}=l,E=Math.floor(A?U-l.pointerX:0),D=Math.floor(j?N-l.pointerY:0),Y=T+(c?-E:E),p=O+($?-D:D),V=-i[0]*T,B=-i[1]*O,m=UA(Y,W,L),X=UA(p,J,w);if(t){let z=0,P=0;if(c&&E<0)z=bi(Q+E+V,t[0][0]);else if(!c&&E>0)z=vi(Q+Y+V,t[1][0]);if($&&D<0)P=bi(q+D+B,t[0][1]);else if(!$&&D>0)P=vi(q+p+B,t[1][1]);m=Math.max(m,z),X=Math.max(X,P)}if(y){let z=0,P=0;if(c&&E>0)z=vi(Q+E,y[0][0]);else if(!c&&E<0)z=bi(Q+Y,y[1][0]);if($&&D>0)P=vi(q+D,y[0][1]);else if(!$&&D<0)P=bi(q+p,y[1][1]);m=Math.max(m,z),X=Math.max(X,P)}if(n){if(A){let z=UA(Y/Z,J,w)*Z;if(m=Math.max(m,z),t){let P=0;if(!c&&!$||c&&!$&&F)P=vi(q+B+Y/Z,t[1][1])*Z;else P=bi(q+B+(c?E:-E)/Z,t[0][1])*Z;m=Math.max(m,P)}if(y){let P=0;if(!c&&!$||c&&!$&&F)P=bi(q+Y/Z,y[1][1])*Z;else P=vi(q+(c?E:-E)/Z,y[0][1])*Z;m=Math.max(m,P)}}if(j){let z=UA(p*Z,W,L)/Z;if(X=Math.max(X,z),t){let P=0;if(!c&&!$||$&&!c&&F)P=vi(Q+p*Z+V,t[1][0])/Z;else P=bi(Q+($?D:-D)*Z+V,t[0][0])/Z;X=Math.max(X,P)}if(y){let P=0;if(!c&&!$||$&&!c&&F)P=bi(Q+p*Z,y[1][0])/Z;else P=vi(Q+($?D:-D)*Z,y[0][0])/Z;X=Math.max(X,P)}}}if(D=D+(D<0?X:-X),E=E+(E<0?m:-m),n)if(F)if(Y>p*Z)D=(dw(c,$)?-E:E)/Z;else E=(dw(c,$)?-D:D)*Z;else if(A)D=E/Z,$=c;else E=D*Z,c=$;let S=c?Q+E:Q,b=$?q+D:q;return{width:T+(c?-E:E),height:O+($?-D:D),x:i[0]*E*(!c?1:-1)+S,y:i[1]*D*(!$?1:-1)+b}}var zq={width:0,height:0,x:0,y:0},aB={...zq,pointerX:0,pointerY:0,aspectRatio:1};function oB(l){return[[0,0],[l.measured.width,l.measured.height]]}function dB(l,u,r){let f=u.position.x+l.position.x,n=u.position.y+l.position.y,i=l.measured.width??0,t=l.measured.height??0,y=r[0]*i,c=r[1]*t;return[[f-y,n-c],[f+i-y,n+t-c]]}function Eq({domNode:l,nodeId:u,getStoreItems:r,onChange:f,onEnd:n}){let i=fr(l),t={controlDirection:ow("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function y({controlPosition:$,boundaries:A,keepAspectRatio:j,resizeDirection:F,onResizeStart:U,onResize:N,onResizeEnd:W,shouldResize:L}){let J={...zq},w={...aB};t={boundaries:A,resizeDirection:F,keepAspectRatio:j,controlDirection:ow($)};let Q=void 0,q=null,T=[],O=void 0,Z=void 0,E=void 0,D=!1,Y=zc().on("start",(p)=>{let{nodeLookup:V,transform:B,snapGrid:m,snapToGrid:X,nodeOrigin:S,paneDomNode:b}=r();if(Q=V.get(u),!Q)return;q=b?.getBoundingClientRect()??null;let{xSnapped:z,ySnapped:P}=vc(p.sourceEvent,{transform:B,snapGrid:m,snapToGrid:X,containerBounds:q});if(J={width:Q.measured.width??0,height:Q.measured.height??0,x:Q.position.x??0,y:Q.position.y??0},w={...J,pointerX:z,pointerY:P,aspectRatio:J.width/J.height},O=void 0,Q.parentId&&(Q.extent==="parent"||Q.expandParent))O=V.get(Q.parentId),Z=O&&Q.extent==="parent"?oB(O):void 0;T=[],E=void 0;for(let[s,k]of V)if(k.parentId===u){if(T.push({id:s,position:{...k.position},extent:k.extent}),k.extent==="parent"||k.expandParent){let v=dB(k,Q,k.origin??S);if(E)E=[[Math.min(v[0][0],E[0][0]),Math.min(v[0][1],E[0][1])],[Math.max(v[1][0],E[1][0]),Math.max(v[1][1],E[1][1])]];else E=v}}U?.(p,{...J})}).on("drag",(p)=>{let{transform:V,snapGrid:B,snapToGrid:m,nodeOrigin:X}=r(),S=vc(p.sourceEvent,{transform:V,snapGrid:B,snapToGrid:m,containerBounds:q}),b=[];if(!Q)return;let{x:z,y:P,width:s,height:k}=J,v={},tl=Q.origin??X,{width:I,height:M,x:rl,y:cl}=IB(w,t.controlDirection,S,t.boundaries,t.keepAspectRatio,tl,Z,E),$l=I!==s,Tl=M!==k,Ql=rl!==z&&$l,Ol=cl!==P&&Tl;if(!Ql&&!Ol&&!$l&&!Tl)return;if(Ql||Ol||tl[0]===1||tl[1]===1){if(v.x=Ql?rl:J.x,v.y=Ol?cl:J.y,J.x=v.x,J.y=v.y,T.length>0){let zl=rl-z,o=cl-P;for(let ql of T)ql.position={x:ql.position.x-zl+tl[0]*(I-s),y:ql.position.y-o+tl[1]*(M-k)},b.push(ql)}}if($l||Tl)v.width=$l&&(!t.resizeDirection||t.resizeDirection==="horizontal")?I:J.width,v.height=Tl&&(!t.resizeDirection||t.resizeDirection==="vertical")?M:J.height,J.width=v.width,J.height=v.height;if(O&&Q.expandParent){let zl=tl[0]*(v.width??0);if(v.x&&v.x<zl)J.x=zl,w.x=w.x-(v.x-zl);let o=tl[1]*(v.height??0);if(v.y&&v.y<o)J.y=o,w.y=w.y-(v.y-o)}let h=gB({width:J.width,prevWidth:s,height:J.height,prevHeight:k,affectsX:t.controlDirection.affectsX,affectsY:t.controlDirection.affectsY}),a={...J,direction:h};if(L?.(p,a)===!1)return;D=!0,N?.(p,a),f(v,b)}).on("end",(p)=>{if(!D)return;W?.(p,{...J}),n?.({...J}),D=!1});i.call(Y)}function c(){i.on(".drag",null)}return{update:y,destroy:c}}var Cq=Rl(Ju(),1),Mq=Rl(Sq(),1);var Xq=(l)=>{let u,r=new Set,f=(A,j)=>{let F=typeof A==="function"?A(u):A;if(!Object.is(F,u)){let U=u;u=(j!=null?j:typeof F!=="object"||F===null)?F:Object.assign({},u,F),r.forEach((N)=>N(u,U))}},n=()=>u,c={setState:f,getState:n,getInitialState:()=>$,subscribe:(A)=>{return r.add(A),()=>r.delete(A)},destroy:()=>{r.clear()}},$=u=l(f,n,c);return c},Yq=(l)=>l?Xq(l):Xq;var{useDebugValue:ND}=Cq.default,{useSyncExternalStoreWithSelector:QD}=Mq.default,wD=(l)=>l;function k9(l,u=wD,r){let f=QD(l.subscribe,l.getState,l.getServerState||l.getInitialState,u,r);return ND(f),f}var Pq=(l,u)=>{let r=Yq(l),f=(n,i=u)=>k9(r,n,i);return Object.assign(f,r),f},hq=(l,u)=>l?Pq(l,u):Pq;function Eu(l,u){if(Object.is(l,u))return!0;if(typeof l!=="object"||l===null||typeof u!=="object"||u===null)return!1;if(l instanceof Map&&u instanceof Map){if(l.size!==u.size)return!1;for(let[f,n]of l)if(!Object.is(n,u.get(f)))return!1;return!0}if(l instanceof Set&&u instanceof Set){if(l.size!==u.size)return!1;for(let f of l)if(!u.has(f))return!1;return!0}let r=Object.keys(l);if(r.length!==Object.keys(u).length)return!1;for(let f of r)if(!Object.prototype.hasOwnProperty.call(u,f)||!Object.is(l[f],u[f]))return!1;return!0}var qD=Rl(I4(),1),DA=yl.createContext(null),WD=DA.Provider,AW=Qf.error001();function yu(l,u){let r=yl.useContext(DA);if(r===null)throw Error(AW);return k9(r,l,u)}function Zu(){let l=yl.useContext(DA);if(l===null)throw Error(AW);return yl.useMemo(()=>({getState:l.getState,setState:l.setState,subscribe:l.subscribe}),[l])}var Rq={display:"none"},LD={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},jW="react-flow__node-desc",FW="react-flow__edge-desc",GD="react-flow__aria-live",TD=(l)=>l.ariaLiveMessage,mD=(l)=>l.ariaLabelConfig;function KD({rfId:l}){let u=yu(TD);return nl.jsx("div",{id:`${GD}-${l}`,"aria-live":"assertive","aria-atomic":"true",style:LD,children:u})}function zD({rfId:l,disableKeyboardA11y:u}){let r=yu(mD);return nl.jsxs(nl.Fragment,{children:[nl.jsx("div",{id:`${jW}-${l}`,style:Rq,children:u?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),nl.jsx("div",{id:`${FW}-${l}`,style:Rq,children:r["edge.a11yDescription.default"]}),!u&&nl.jsx(KD,{rfId:l})]})}var VA=yl.forwardRef(({position:l="top-left",children:u,className:r,style:f,...n},i)=>{let t=`${l}`.split("-");return nl.jsx("div",{className:bu(["react-flow__panel",r,...t]),style:f,ref:i,...n,children:u})});VA.displayName="Panel";function ED({proOptions:l,position:u="bottom-right"}){if(l?.hideAttribution)return null;return nl.jsx(VA,{position:u,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:nl.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}var OD=(l)=>{let u=[],r=[];for(let[,f]of l.nodeLookup)if(f.selected)u.push(f.internals.userNode);for(let[,f]of l.edgeLookup)if(f.selected)r.push(f);return{selectedNodes:u,selectedEdges:r}},pA=(l)=>l.id;function ZD(l,u){return Eu(l.selectedNodes.map(pA),u.selectedNodes.map(pA))&&Eu(l.selectedEdges.map(pA),u.selectedEdges.map(pA))}function pD({onSelectionChange:l}){let u=Zu(),{selectedNodes:r,selectedEdges:f}=yu(OD,ZD);return yl.useEffect(()=>{let n={nodes:r,edges:f};l?.(n),u.getState().onSelectionChangeHandlers.forEach((i)=>i(n))},[r,f,l]),null}var HD=(l)=>!!l.onSelectionChangeHandlers;function BD({onSelectionChange:l}){let u=yu(HD);if(l||u)return nl.jsx(pD,{onSelectionChange:l});return null}var a9=typeof window<"u"?yl.useLayoutEffect:yl.useEffect,JW=[0,0],DD={x:0,y:0,zoom:1},VD=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],xq=[...VD,"rfId"],SD=(l)=>({setNodes:l.setNodes,setEdges:l.setEdges,setMinZoom:l.setMinZoom,setMaxZoom:l.setMaxZoom,setTranslateExtent:l.setTranslateExtent,setNodeExtent:l.setNodeExtent,reset:l.reset,setDefaultNodesAndEdges:l.setDefaultNodesAndEdges}),bq={translateExtent:my,nodeOrigin:JW,minZoom:0.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function XD(l){let{setNodes:u,setEdges:r,setMinZoom:f,setMaxZoom:n,setTranslateExtent:i,setNodeExtent:t,reset:y,setDefaultNodesAndEdges:c}=yu(SD,Eu),$=Zu();a9(()=>{return c(l.defaultNodes,l.defaultEdges),()=>{A.current=bq,y()}},[]);let A=yl.useRef(bq);return a9(()=>{for(let j of xq){let F=l[j],U=A.current[j];if(F===U)continue;if(typeof l[j]>"u")continue;if(j==="nodes")u(F);else if(j==="edges")r(F);else if(j==="minZoom")f(F);else if(j==="maxZoom")n(F);else if(j==="translateExtent")i(F);else if(j==="nodeExtent")t(F);else if(j==="ariaLabelConfig")$.setState({ariaLabelConfig:tq(F)});else if(j==="fitView")$.setState({fitViewQueued:F});else if(j==="fitViewOptions")$.setState({fitViewOptions:F});else $.setState({[j]:F})}A.current=l},xq.map((j)=>l[j])),null}function vq(){if(typeof window>"u"||!window.matchMedia)return null;return window.matchMedia("(prefers-color-scheme: dark)")}function YD(l){let[u,r]=yl.useState(l==="system"?null:l);return yl.useEffect(()=>{if(l!=="system"){r(l);return}let f=vq(),n=()=>r(f?.matches?"dark":"light");return n(),f?.addEventListener("change",n),()=>{f?.removeEventListener("change",n)}},[l]),u!==null?u:vq()?.matches?"dark":"light"}var sq=typeof document<"u"?document:null;function ac(l=null,u={target:sq,actInsideInputWithModifier:!0}){let[r,f]=yl.useState(!1),n=yl.useRef(!1),i=yl.useRef(new Set([])),[t,y]=yl.useMemo(()=>{if(l!==null){let $=(Array.isArray(l)?l:[l]).filter((j)=>typeof j==="string").map((j)=>j.replace("+",` `).replace(` `,` +`).split(` -`)),A=$.reduce((j,F)=>j.concat(...F),[]);return[$,A]}return[[],[]]},[u]);return tu.useEffect(()=>{let c=l?.target??Ow,$=l?.actInsideInputWithModifier??!0;if(u!==null){let A=(J)=>{if(n.current=J.ctrlKey||J.metaKey||J.shiftKey||J.altKey,(!n.current||n.current&&!$)&&W9(J))return!1;let W=Hw(J.code,y);if(i.current.add(J[W]),Zw(t,i.current,!1)){let L=J.composedPath?.()?.[0]||J.target,U=L?.nodeName==="BUTTON"||L?.nodeName==="A";if(l.preventDefault!==!1&&(n.current||!U))J.preventDefault();r(!0)}},j=(J)=>{let Q=Hw(J.code,y);if(Zw(t,i.current,!0))r(!1),i.current.clear();else i.current.delete(J[Q]);if(J.key==="Meta")i.current.clear();n.current=!1},F=()=>{i.current.clear(),r(!1)};return c?.addEventListener("keydown",A),c?.addEventListener("keyup",j),window.addEventListener("blur",F),window.addEventListener("contextmenu",F),()=>{c?.removeEventListener("keydown",A),c?.removeEventListener("keyup",j),window.removeEventListener("blur",F),window.removeEventListener("contextmenu",F)}}},[u,r]),f}function Zw(u,l,f){return u.filter((r)=>f||r.length===l.size).some((r)=>r.every((n)=>l.has(n)))}function Hw(u,l){return l.includes(u)?"code":"key"}var iD=()=>{let u=Zl();return tu.useMemo(()=>{return{zoomIn:(l)=>{let{panZoom:f}=u.getState();return f?f.scaleBy(1.2,l):Promise.resolve(!1)},zoomOut:(l)=>{let{panZoom:f}=u.getState();return f?f.scaleBy(0.8333333333333334,l):Promise.resolve(!1)},zoomTo:(l,f)=>{let{panZoom:r}=u.getState();return r?r.scaleTo(l,f):Promise.resolve(!1)},getZoom:()=>u.getState().transform[2],setViewport:async(l,f)=>{let{transform:[r,n,i],panZoom:t}=u.getState();if(!t)return Promise.resolve(!1);return await t.setViewport({x:l.x??r,y:l.y??n,zoom:l.zoom??i},f),Promise.resolve(!0)},getViewport:()=>{let[l,f,r]=u.getState().transform;return{x:l,y:f,zoom:r}},setCenter:async(l,f,r)=>{return u.getState().setCenter(l,f,r)},fitBounds:async(l,f)=>{let{width:r,height:n,minZoom:i,maxZoom:t,panZoom:y}=u.getState(),c=Cc(l,r,n,i,t,f?.padding??0.1);if(!y)return Promise.resolve(!1);return await y.setViewport(c,{duration:f?.duration,ease:f?.ease,interpolate:f?.interpolate}),Promise.resolve(!0)},screenToFlowPosition:(l,f={})=>{let{transform:r,snapGrid:n,snapToGrid:i,domNode:t}=u.getState();if(!t)return l;let{x:y,y:c}=t.getBoundingClientRect(),$={x:l.x-y,y:l.y-c},A=f.snapGrid??n,j=f.snapToGrid??i;return wy($,r,j,A)},flowToScreenPosition:(l)=>{let{transform:f,domNode:r}=u.getState();if(!r)return l;let{x:n,y:i}=r.getBoundingClientRect(),t=Yc(l,f);return{x:t.x+n,y:t.y+i}}}},[])};function aw(u,l){let f=[],r=new Map,n=[];for(let i of u)if(i.type==="add"){n.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{let t=r.get(i.id);if(t)t.push(i);else r.set(i.id,[i])}for(let i of l){let t=r.get(i.id);if(!t){f.push(i);continue}if(t[0].type==="remove")continue;if(t[0].type==="replace"){f.push({...t[0].item});continue}let y={...i};for(let c of t)tD(c,y);f.push(y)}if(n.length)n.forEach((i)=>{if(i.index!==void 0)f.splice(i.index,0,{...i.item});else f.push({...i.item})});return f}function tD(u,l){switch(u.type){case"select":{l.selected=u.selected;break}case"position":{if(typeof u.position<"u")l.position=u.position;if(typeof u.dragging<"u")l.dragging=u.dragging;break}case"dimensions":{if(typeof u.dimensions<"u"){if(l.measured={...u.dimensions},u.setAttributes){if(u.setAttributes===!0||u.setAttributes==="width")l.width=u.dimensions.width;if(u.setAttributes===!0||u.setAttributes==="height")l.height=u.dimensions.height}}if(typeof u.resizing==="boolean")l.resizing=u.resizing;break}}}function yD(u,l){return aw(u,l)}function cD(u,l){return aw(u,l)}function oi(u,l){return{id:u,type:"select",selected:l}}function Ty(u,l=new Set,f=!1){let r=[];for(let[n,i]of u){let t=l.has(n);if(!(i.selected===void 0&&!t)&&i.selected!==t){if(f)i.selected=t;r.push(oi(i.id,t))}}return r}function Bw({items:u=[],lookup:l}){let f=[],r=new Map(u.map((n)=>[n.id,n]));for(let[n,i]of u.entries()){let t=l.get(i.id),y=t?.internals?.userNode??t;if(y!==void 0&&y!==i)f.push({id:i.id,item:i,type:"replace"});if(y===void 0)f.push({item:i,type:"add",index:n})}for(let[n]of l)if(r.get(n)===void 0)f.push({id:n,type:"remove"});return f}function Vw(u){return{id:u.id,type:"remove"}}var mw=(u)=>pq(u),_D=(u)=>_9(u);function ow(u){return tu.forwardRef(u)}function Dw(u){let[l,f]=tu.useState(BigInt(0)),[r]=tu.useState(()=>$D(()=>f((n)=>n+BigInt(1))));return D9(()=>{let n=r.get();if(n.length)u(n),r.reset()},[l]),r}function $D(u){let l=[];return{get:()=>l,reset:()=>{l=[]},push:(f)=>{l.push(f),u()}}}var dw=tu.createContext(null);function AD({children:u}){let l=Zl(),f=tu.useCallback((y)=>{let{nodes:c=[],setNodes:$,hasDefaultNodes:A,onNodesChange:j,nodeLookup:F,fitViewQueued:J,onNodesChangeMiddlewareMap:Q}=l.getState(),W=c;for(let U of y)W=typeof U==="function"?U(W):U;let L=Bw({items:W,lookup:F});for(let U of Q.values())L=U(L);if(A)$(W);if(L.length>0)j?.(L);else if(J)window.requestAnimationFrame(()=>{let{fitViewQueued:U,nodes:q,setNodes:N}=l.getState();if(U)N(q)})},[]),r=Dw(f),n=tu.useCallback((y)=>{let{edges:c=[],setEdges:$,hasDefaultEdges:A,onEdgesChange:j,edgeLookup:F}=l.getState(),J=c;for(let Q of y)J=typeof Q==="function"?Q(J):Q;if(A)$(J);else if(j)j(Bw({items:J,lookup:F}))},[]),i=Dw(n),t=tu.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return nu.jsx(dw.Provider,{value:t,children:u})}function jD(){let u=tu.useContext(dw);if(!u)throw Error("useBatchContext must be used within a BatchProvider");return u}var FD=(u)=>!!u.panZoom;function S9(){let u=iD(),l=Zl(),f=jD(),r=il(FD),n=tu.useMemo(()=>{let i=(j)=>l.getState().nodeLookup.get(j),t=(j)=>{f.nodeQueue.push(j)},y=(j)=>{f.edgeQueue.push(j)},c=(j)=>{let{nodeLookup:F,nodeOrigin:J}=l.getState(),Q=mw(j)?j:F.get(j.id),W=Q.parentId?N9(Q.position,Q.measured,Q.parentId,F,J):Q.position,L={...Q,position:W,width:Q.measured?.width??Q.width,height:Q.measured?.height??Q.height};return ai(L)},$=(j,F,J={replace:!1})=>{t((Q)=>Q.map((W)=>{if(W.id===j){let L=typeof F==="function"?F(W):F;return J.replace&&mw(L)?L:{...W,...L}}return W}))},A=(j,F,J={replace:!1})=>{y((Q)=>Q.map((W)=>{if(W.id===j){let L=typeof F==="function"?F(W):F;return J.replace&&_D(L)?L:{...W,...L}}return W}))};return{getNodes:()=>l.getState().nodes.map((j)=>({...j})),getNode:(j)=>i(j)?.internals.userNode,getInternalNode:i,getEdges:()=>{let{edges:j=[]}=l.getState();return j.map((F)=>({...F}))},getEdge:(j)=>l.getState().edgeLookup.get(j),setNodes:t,setEdges:y,addNodes:(j)=>{let F=Array.isArray(j)?j:[j];f.nodeQueue.push((J)=>[...J,...F])},addEdges:(j)=>{let F=Array.isArray(j)?j:[j];f.edgeQueue.push((J)=>[...J,...F])},toObject:()=>{let{nodes:j=[],edges:F=[],transform:J}=l.getState(),[Q,W,L]=J;return{nodes:j.map((U)=>({...U})),edges:F.map((U)=>({...U})),viewport:{x:Q,y:W,zoom:L}}},deleteElements:async({nodes:j=[],edges:F=[]})=>{let{nodes:J,edges:Q,onNodesDelete:W,onEdgesDelete:L,triggerNodeChanges:U,triggerEdgeChanges:q,onDelete:N,onBeforeDelete:w}=l.getState(),{nodes:G,edges:Z}=await Yq({nodesToRemove:j,edgesToRemove:F,nodes:J,edges:Q,onBeforeDelete:w}),H=Z.length>0,E=G.length>0;if(H){let m=Z.map(Vw);L?.(Z),q(m)}if(E){let m=G.map(Vw);W?.(G),U(m)}if(E||H)N?.({nodes:G,edges:Z});return{deletedNodes:G,deletedEdges:Z}},getIntersectingNodes:(j,F=!0,J)=>{let Q=U9(j),W=Q?j:c(j),L=J!==void 0;if(!W)return[];return(J||l.getState().nodes).filter((U)=>{let q=l.getState().nodeLookup.get(U.id);if(q&&!Q&&(U.id===j.id||!q.internals.positionAbsolute))return!1;let N=ai(L?U:q),w=Ny(N,W);return F&&w>0||w>=N.width*N.height||w>=W.width*W.height})},isNodeIntersecting:(j,F,J=!0)=>{let W=U9(j)?j:c(j);if(!W)return!1;let L=Ny(W,F);return J&&L>0||L>=F.width*F.height||L>=W.width*W.height},updateNode:$,updateNodeData:(j,F,J={replace:!1})=>{$(j,(Q)=>{let W=typeof F==="function"?F(Q):F;return J.replace?{...Q,data:W}:{...Q,data:{...Q.data,...W}}},J)},updateEdge:A,updateEdgeData:(j,F,J={replace:!1})=>{A(j,(Q)=>{let W=typeof F==="function"?F(Q):F;return J.replace?{...Q,data:W}:{...Q,data:{...Q.data,...W}}},J)},getNodesBounds:(j)=>{let{nodeLookup:F,nodeOrigin:J}=l.getState();return A9(j,{nodeLookup:F,nodeOrigin:J})},getHandleConnections:({type:j,id:F,nodeId:J})=>Array.from(l.getState().connectionLookup.get(`${J}-${j}${F?`-${F}`:""}`)?.values()??[]),getNodeConnections:({type:j,handleId:F,nodeId:J})=>Array.from(l.getState().connectionLookup.get(`${J}${j?F?`-${j}-${F}`:`-${j}`:""}`)?.values()??[]),fitView:async(j)=>{let F=l.getState().fitViewResolver??Mq();return l.setState({fitViewQueued:!0,fitViewOptions:j,fitViewResolver:F}),f.nodeQueue.push((J)=>[...J]),F.promise}}},[]);return tu.useMemo(()=>{return{...n,...u,viewportInitialized:r}},[r])}var pw=(u)=>u.selected,UD=typeof window<"u"?window:void 0;function JD({deleteKeyCode:u,multiSelectionKeyCode:l}){let f=Zl(),{deleteElements:r}=S9(),n=Rc(u,{actInsideInputWithModifier:!1}),i=Rc(l,{target:UD});tu.useEffect(()=>{if(n){let{edges:t,nodes:y}=f.getState();r({nodes:y.filter(pw),edges:t.filter(pw)}),f.setState({nodesSelectionActive:!1})}},[n]),tu.useEffect(()=>{f.setState({multiSelectionActive:i})},[i])}function QD(u){let l=Zl();tu.useEffect(()=>{let f=()=>{if(!u.current||!(u.current.checkVisibility?.()??!0))return!1;let r=cA(u.current);if(r.height===0||r.width===0)l.getState().onError?.("004",Jr.error004());l.setState({width:r.width||500,height:r.height||500})};if(u.current){f(),window.addEventListener("resize",f);let r=new ResizeObserver(()=>f());return r.observe(u.current),()=>{if(window.removeEventListener("resize",f),r&&u.current)r.unobserve(u.current)}}},[])}var KA={position:"absolute",width:"100%",height:"100%",top:0,left:0},ND=(u)=>({userSelectionActive:u.userSelectionActive,lib:u.lib,connectionInProgress:u.connection.inProgress});function qD({onPaneContextMenu:u,zoomOnScroll:l=!0,zoomOnPinch:f=!0,panOnScroll:r=!1,panOnScrollSpeed:n=0.5,panOnScrollMode:i=an.Free,zoomOnDoubleClick:t=!0,panOnDrag:y=!0,defaultViewport:c,translateExtent:$,minZoom:A,maxZoom:j,zoomActivationKeyCode:F,preventScrolling:J=!0,children:Q,noWheelClassName:W,noPanClassName:L,onViewportChange:U,isControlledViewport:q,paneClickDistance:N,selectionOnDrag:w}){let G=Zl(),Z=tu.useRef(null),{userSelectionActive:H,lib:E,connectionInProgress:m}=il(ND,El),S=Rc(F),B=tu.useRef();QD(Z);let D=tu.useCallback((X)=>{if(U?.({x:X[0],y:X[1],zoom:X[2]}),!q)G.setState({transform:X})},[U,q]);return tu.useEffect(()=>{if(Z.current){B.current=tw({domNode:Z.current,minZoom:A,maxZoom:j,translateExtent:$,viewport:c,onDraggingChange:(p)=>G.setState((v)=>v.paneDragging===p?v:{paneDragging:p}),onPanZoomStart:(p,v)=>{let{onViewportChangeStart:z,onMoveStart:P}=G.getState();P?.(p,v),z?.(v)},onPanZoom:(p,v)=>{let{onViewportChange:z,onMove:P}=G.getState();P?.(p,v),z?.(v)},onPanZoomEnd:(p,v)=>{let{onViewportChangeEnd:z,onMoveEnd:P}=G.getState();P?.(p,v),z?.(v)}});let{x:X,y:O,zoom:Y}=B.current.getViewport();return G.setState({panZoom:B.current,transform:[X,O,Y],domNode:Z.current.closest(".react-flow")}),()=>{B.current?.destroy()}}},[]),tu.useEffect(()=>{B.current?.update({onPaneContextMenu:u,zoomOnScroll:l,zoomOnPinch:f,panOnScroll:r,panOnScrollSpeed:n,panOnScrollMode:i,zoomOnDoubleClick:t,panOnDrag:y,zoomActivationKeyPressed:S,preventScrolling:J,noPanClassName:L,userSelectionActive:H,noWheelClassName:W,lib:E,onTransformChange:D,connectionInProgress:m,selectionOnDrag:w,paneClickDistance:N})},[u,l,f,r,n,i,t,y,S,J,L,H,W,E,D,m,w,N]),nu.jsx("div",{className:"react-flow__renderer",ref:Z,style:KA,children:Q})}var wD=(u)=>({userSelectionActive:u.userSelectionActive,userSelectionRect:u.userSelectionRect});function WD(){let{userSelectionActive:u,userSelectionRect:l}=il(wD,El);if(!(u&&l))return null;return nu.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:l.width,height:l.height,transform:`translate(${l.x}px, ${l.y}px)`}})}var V9=(u,l)=>{return(f)=>{if(f.target!==l.current)return;u?.(f)}},LD=(u)=>({userSelectionActive:u.userSelectionActive,elementsSelectable:u.elementsSelectable,connectionInProgress:u.connection.inProgress,dragging:u.paneDragging});function TD({isSelecting:u,selectionKeyPressed:l,selectionMode:f=gi.Full,panOnDrag:r,paneClickDistance:n,selectionOnDrag:i,onSelectionStart:t,onSelectionEnd:y,onPaneClick:c,onPaneContextMenu:$,onPaneScroll:A,onPaneMouseEnter:j,onPaneMouseMove:F,onPaneMouseLeave:J,children:Q}){let W=Zl(),{userSelectionActive:L,elementsSelectable:U,dragging:q,connectionInProgress:N}=il(LD,El),w=U&&(u||L),G=tu.useRef(null),Z=tu.useRef(),H=tu.useRef(new Set),E=tu.useRef(new Set),m=tu.useRef(!1),S=(z)=>{if(m.current||N){m.current=!1;return}c?.(z),W.getState().resetSelectedElements(),W.setState({nodesSelectionActive:!1})},B=(z)=>{if(Array.isArray(r)&&r?.includes(2)){z.preventDefault();return}$?.(z)},D=A?(z)=>A(z):void 0,X=(z)=>{if(m.current)z.stopPropagation(),m.current=!1},O=(z)=>{let{domNode:P}=W.getState();if(Z.current=P?.getBoundingClientRect(),!Z.current)return;let k=z.target===G.current;if(!k&&!!z.target.closest(".nokey")||!u||!(i&&k||l)||z.button!==0||!z.isPrimary)return;z.target?.setPointerCapture?.(z.pointerId),m.current=!1;let{x:d,y:s}=Br(z.nativeEvent,Z.current);if(W.setState({userSelectionRect:{width:0,height:0,startX:d,startY:s,x:d,y:s}}),!k)z.stopPropagation(),z.preventDefault()},Y=(z)=>{let{userSelectionRect:P,transform:k,nodeLookup:I,edgeLookup:b,connectionLookup:d,triggerNodeChanges:s,triggerEdgeChanges:h,defaultEdgeOptions:lu,resetSelectedElements:cu}=W.getState();if(!Z.current||!P)return;let{x:_u,y:Fu}=Br(z.nativeEvent,Z.current),{startX:zu,startY:Wu}=P;if(!m.current){let a=l?0:n;if(Math.hypot(_u-zu,Fu-Wu)<=a)return;cu(),t?.(z)}m.current=!0;let C={startX:zu,startY:Wu,x:_u<zu?_u:zu,y:Fu<Wu?Fu:Wu,width:Math.abs(_u-zu),height:Math.abs(Fu-Wu)},e=H.current,uu=E.current;H.current=new Set(iA(I,C,k,f===gi.Partial,!0).map((a)=>a.id)),E.current=new Set;let Gu=lu?.selectable??!0;for(let a of H.current){let qu=d.get(a);if(!qu)continue;for(let{edgeId:Zu}of qu.values()){let Bu=b.get(Zu);if(Bu&&(Bu.selectable??Gu))E.current.add(Zu)}}if(!q9(e,H.current)){let a=Ty(I,H.current,!0);s(a)}if(!q9(uu,E.current)){let a=Ty(b,E.current);h(a)}W.setState({userSelectionRect:C,userSelectionActive:!0,nodesSelectionActive:!1})},p=(z)=>{if(z.button!==0)return;if(z.target?.releasePointerCapture?.(z.pointerId),!L&&z.target===G.current&&W.getState().userSelectionRect)S?.(z);if(W.setState({userSelectionActive:!1,userSelectionRect:null}),m.current)y?.(z),W.setState({nodesSelectionActive:H.current.size>0})},v=r===!0||Array.isArray(r)&&r.includes(0);return nu.jsxs("div",{className:Rl(["react-flow__pane",{draggable:v,dragging:q,selection:u}]),onClick:w?void 0:V9(S,G),onContextMenu:V9(B,G),onWheel:V9(D,G),onPointerEnter:w?void 0:j,onPointerMove:w?Y:F,onPointerUp:w?p:void 0,onPointerDownCapture:w?O:void 0,onClickCapture:w?X:void 0,onPointerLeave:J,ref:G,style:KA,children:[Q,nu.jsx(WD,{})]})}function p9({id:u,store:l,unselect:f=!1,nodeRef:r}){let{addSelectedNodes:n,unselectNodesAndEdges:i,multiSelectionActive:t,nodeLookup:y,onError:c}=l.getState(),$=y.get(u);if(!$){c?.("012",Jr.error012(u));return}if(l.setState({nodesSelectionActive:!1}),!$.selected)n([u]);else if(f||$.selected&&t)i({nodes:[$],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())}function ew({nodeRef:u,disabled:l=!1,noDragClassName:f,handleSelector:r,nodeId:n,isSelectable:i,nodeClickDistance:t}){let y=Zl(),[c,$]=tu.useState(!1),A=tu.useRef();return tu.useEffect(()=>{A.current=dq({getStoreItems:()=>y.getState(),onNodeMouseDown:(j)=>{p9({id:j,store:y,nodeRef:u})},onDragStart:()=>{$(!0)},onDragStop:()=>{$(!1)}})},[]),tu.useEffect(()=>{if(l||!u.current||!A.current)return;return A.current.update({noDragClassName:f,handleSelector:r,domNode:u.current,isSelectable:i,nodeId:n,nodeClickDistance:t}),()=>{A.current?.destroy()}},[f,r,l,i,u,n,t]),c}var KD=(u)=>(l)=>l.selected&&(l.draggable||u&&typeof l.draggable>"u");function uW(){let u=Zl();return tu.useCallback((f)=>{let{nodeExtent:r,snapToGrid:n,snapGrid:i,nodesDraggable:t,onError:y,updateNodePositions:c,nodeLookup:$,nodeOrigin:A}=u.getState(),j=new Map,F=KD(t),J=n?i[0]:5,Q=n?i[1]:5,W=f.direction.x*J*f.factor,L=f.direction.y*Q*f.factor;for(let[,U]of $){if(!F(U))continue;let q={x:U.internals.positionAbsolute.x+W,y:U.internals.positionAbsolute.y+L};if(n)q=qy(q,i);let{position:N,positionAbsolute:w}=j9({nodeId:U.id,nextPosition:q,nodeLookup:$,nodeExtent:r,nodeOrigin:A,onError:y});U.position=N,U.internals.positionAbsolute=w,j.set(U.id,U)}c(j)},[])}var X9=tu.createContext(null),GD=X9.Provider;X9.Consumer;var lW=()=>{return tu.useContext(X9)},zD=(u)=>({connectOnClick:u.connectOnClick,noPanClassName:u.noPanClassName,rfId:u.rfId}),ED=(u,l,f)=>(r)=>{let{connectionClickStartHandle:n,connectionMode:i,connection:t}=r,{fromHandle:y,toHandle:c,isValid:$}=t,A=c?.nodeId===u&&c?.id===l&&c?.type===f;return{connectingFrom:y?.nodeId===u&&y?.id===l&&y?.type===f,connectingTo:A,clickConnecting:n?.nodeId===u&&n?.id===l&&n?.type===f,isPossibleEndHandle:i===R0.Strict?y?.type!==f:u!==y?.nodeId||l!==y?.id,connectionInProcess:!!y,clickConnectionInProcess:!!n,valid:A&&$}};function OD({type:u="source",position:l=Ku.Top,isValidConnection:f,isConnectable:r=!0,isConnectableStart:n=!0,isConnectableEnd:i=!0,id:t,onConnect:y,children:c,className:$,onMouseDown:A,onTouchStart:j,...F},J){let Q=t||null,W=u==="target",L=Zl(),U=lW(),{connectOnClick:q,noPanClassName:N,rfId:w}=il(zD,El),{connectingFrom:G,connectingTo:Z,clickConnecting:H,isPossibleEndHandle:E,connectionInProcess:m,clickConnectionInProcess:S,valid:B}=il(ED(U,Q,u),El);if(!U)L.getState().onError?.("010",Jr.error010());let D=(Y)=>{let{defaultEdgeOptions:p,onConnect:v,hasDefaultEdges:z}=L.getState(),P={...p,...Y};if(z){let{edges:k,setEdges:I}=L.getState();I(K9(P,k))}v?.(P),y?.(P)},X=(Y)=>{if(!U)return;let p=L9(Y.nativeEvent);if(n&&(p&&Y.button===0||!p)){let v=L.getState();JA.onPointerDown(Y.nativeEvent,{handleDomNode:Y.currentTarget,autoPanOnConnect:v.autoPanOnConnect,connectionMode:v.connectionMode,connectionRadius:v.connectionRadius,domNode:v.domNode,nodeLookup:v.nodeLookup,lib:v.lib,isTarget:W,handleId:Q,nodeId:U,flowId:v.rfId,panBy:v.panBy,cancelConnection:v.cancelConnection,onConnectStart:v.onConnectStart,onConnectEnd:(...z)=>L.getState().onConnectEnd?.(...z),updateConnection:v.updateConnection,onConnect:D,isValidConnection:f||((...z)=>L.getState().isValidConnection?.(...z)??!0),getTransform:()=>L.getState().transform,getFromHandle:()=>L.getState().connection.fromHandle,autoPanSpeed:v.autoPanSpeed,dragThreshold:v.connectionDragThreshold})}if(p)A?.(Y);else j?.(Y)},O=(Y)=>{let{onClickConnectStart:p,onClickConnectEnd:v,connectionClickStartHandle:z,connectionMode:P,isValidConnection:k,lib:I,rfId:b,nodeLookup:d,connection:s}=L.getState();if(!U||!z&&!n)return;if(!z){p?.(Y.nativeEvent,{nodeId:U,handleId:Q,handleType:u}),L.setState({connectionClickStartHandle:{nodeId:U,type:u,id:Q}});return}let h=w9(Y.target),lu=f||k,{connection:cu,isValid:_u}=JA.isValid(Y.nativeEvent,{handle:{nodeId:U,id:Q,type:u},connectionMode:P,fromNodeId:z.nodeId,fromHandleId:z.id||null,fromType:z.type,isValidConnection:lu,flowId:b,doc:h,lib:I,nodeLookup:d});if(_u&&cu)D(cu);let Fu=structuredClone(s);delete Fu.inProgress,Fu.toPosition=Fu.toHandle?Fu.toHandle.position:null,v?.(Y,Fu),L.setState({connectionClickStartHandle:null})};return nu.jsx("div",{"data-handleid":Q,"data-nodeid":U,"data-handlepos":l,"data-id":`${w}-${U}-${Q}-${u}`,className:Rl(["react-flow__handle",`react-flow__handle-${l}`,"nodrag",N,$,{source:!W,target:W,connectable:r,connectablestart:n,connectableend:i,clickconnecting:H,connectingfrom:G,connectingto:Z,valid:B,connectionindicator:r&&(!m||E)&&(m||S?i:n)}]),onMouseDown:X,onTouchStart:X,onClick:q?O:void 0,ref:J,...F,children:c})}var di=tu.memo(ow(OD));function ZD({data:u,isConnectable:l,sourcePosition:f=Ku.Bottom}){return nu.jsxs(nu.Fragment,{children:[u?.label,nu.jsx(di,{type:"source",position:f,isConnectable:l})]})}function HD({data:u,isConnectable:l,targetPosition:f=Ku.Top,sourcePosition:r=Ku.Bottom}){return nu.jsxs(nu.Fragment,{children:[nu.jsx(di,{type:"target",position:f,isConnectable:l}),u?.label,nu.jsx(di,{type:"source",position:r,isConnectable:l})]})}function BD(){return null}function VD({data:u,isConnectable:l,targetPosition:f=Ku.Top}){return nu.jsxs(nu.Fragment,{children:[nu.jsx(di,{type:"target",position:f,isConnectable:l}),u?.label]})}var WA={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Sw={input:ZD,default:HD,output:VD,group:BD};function mD(u){if(u.internals.handleBounds===void 0)return{width:u.width??u.initialWidth??u.style?.width,height:u.height??u.initialHeight??u.style?.height};return{width:u.width??u.style?.width,height:u.height??u.style?.height}}var DD=(u)=>{let{width:l,height:f,x:r,y:n}=Qy(u.nodeLookup,{filter:(i)=>!!i.selected});return{width:Hr(l)?l:null,height:Hr(f)?f:null,userSelectionActive:u.userSelectionActive,transformString:`translate(${u.transform[0]}px,${u.transform[1]}px) scale(${u.transform[2]}) translate(${r}px,${n}px)`}};function pD({onSelectionContextMenu:u,noPanClassName:l,disableKeyboardA11y:f}){let r=Zl(),{width:n,height:i,transformString:t,userSelectionActive:y}=il(DD,El),c=uW(),$=tu.useRef(null);tu.useEffect(()=>{if(!f)$.current?.focus({preventScroll:!0})},[f]);let A=!y&&n!==null&&i!==null;if(ew({nodeRef:$,disabled:!A}),!A)return null;let j=u?(J)=>{let Q=r.getState().nodes.filter((W)=>W.selected);u(J,Q)}:void 0,F=(J)=>{if(Object.prototype.hasOwnProperty.call(WA,J.key))J.preventDefault(),c({direction:WA[J.key],factor:J.shiftKey?4:1})};return nu.jsx("div",{className:Rl(["react-flow__nodesselection","react-flow__container",l]),style:{transform:t},children:nu.jsx("div",{ref:$,className:"react-flow__nodesselection-rect",onContextMenu:j,tabIndex:f?void 0:-1,onKeyDown:f?void 0:F,style:{width:n,height:i}})})}var Xw=typeof window<"u"?window:void 0,SD=(u)=>{return{nodesSelectionActive:u.nodesSelectionActive,userSelectionActive:u.userSelectionActive}};function fW({children:u,onPaneClick:l,onPaneMouseEnter:f,onPaneMouseMove:r,onPaneMouseLeave:n,onPaneContextMenu:i,onPaneScroll:t,paneClickDistance:y,deleteKeyCode:c,selectionKeyCode:$,selectionOnDrag:A,selectionMode:j,onSelectionStart:F,onSelectionEnd:J,multiSelectionKeyCode:Q,panActivationKeyCode:W,zoomActivationKeyCode:L,elementsSelectable:U,zoomOnScroll:q,zoomOnPinch:N,panOnScroll:w,panOnScrollSpeed:G,panOnScrollMode:Z,zoomOnDoubleClick:H,panOnDrag:E,defaultViewport:m,translateExtent:S,minZoom:B,maxZoom:D,preventScrolling:X,onSelectionContextMenu:O,noWheelClassName:Y,noPanClassName:p,disableKeyboardA11y:v,onViewportChange:z,isControlledViewport:P}){let{nodesSelectionActive:k,userSelectionActive:I}=il(SD,El),b=Rc($,{target:Xw}),d=Rc(W,{target:Xw}),s=d||E,h=d||w,lu=A&&s!==!0,cu=b||I||lu;return JD({deleteKeyCode:c,multiSelectionKeyCode:Q}),nu.jsx(qD,{onPaneContextMenu:i,elementsSelectable:U,zoomOnScroll:q,zoomOnPinch:N,panOnScroll:h,panOnScrollSpeed:G,panOnScrollMode:Z,zoomOnDoubleClick:H,panOnDrag:!b&&s,defaultViewport:m,translateExtent:S,minZoom:B,maxZoom:D,zoomActivationKeyCode:L,preventScrolling:X,noWheelClassName:Y,noPanClassName:p,onViewportChange:z,isControlledViewport:P,paneClickDistance:y,selectionOnDrag:lu,children:nu.jsxs(TD,{onSelectionStart:F,onSelectionEnd:J,onPaneClick:l,onPaneMouseEnter:f,onPaneMouseMove:r,onPaneMouseLeave:n,onPaneContextMenu:i,onPaneScroll:t,panOnDrag:s,isSelecting:!!cu,selectionMode:j,selectionKeyPressed:b,paneClickDistance:y,selectionOnDrag:lu,children:[u,k&&nu.jsx(pD,{onSelectionContextMenu:O,noPanClassName:p,disableKeyboardA11y:v})]})})}fW.displayName="FlowRenderer";var XD=tu.memo(fW),YD=(u)=>(l)=>{return u?iA(l.nodeLookup,{x:0,y:0,width:l.width,height:l.height},l.transform,!0).map((f)=>f.id):Array.from(l.nodeLookup.keys())};function PD(u){return il(tu.useCallback(YD(u),[u]),El)}var CD=(u)=>u.updateNodeInternals;function MD(){let u=il(CD),[l]=tu.useState(()=>{if(typeof ResizeObserver>"u")return null;return new ResizeObserver((f)=>{let r=new Map;f.forEach((n)=>{let i=n.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:n.target,force:!0})}),u(r)})});return tu.useEffect(()=>{return()=>{l?.disconnect()}},[l]),l}function RD({node:u,nodeType:l,hasDimensions:f,resizeObserver:r}){let n=Zl(),i=tu.useRef(null),t=tu.useRef(null),y=tu.useRef(u.sourcePosition),c=tu.useRef(u.targetPosition),$=tu.useRef(l),A=f&&!!u.internals.handleBounds;return tu.useEffect(()=>{if(i.current&&!u.hidden&&(!A||t.current!==i.current)){if(t.current)r?.unobserve(t.current);r?.observe(i.current),t.current=i.current}},[A,u.hidden]),tu.useEffect(()=>{return()=>{if(t.current)r?.unobserve(t.current),t.current=null}},[]),tu.useEffect(()=>{if(i.current){let j=$.current!==l,F=y.current!==u.sourcePosition,J=c.current!==u.targetPosition;if(j||F||J)$.current=l,y.current=u.sourcePosition,c.current=u.targetPosition,n.getState().updateNodeInternals(new Map([[u.id,{id:u.id,nodeElement:i.current,force:!0}]]))}},[u.id,l,u.sourcePosition,u.targetPosition]),i}function xD({id:u,onClick:l,onMouseEnter:f,onMouseMove:r,onMouseLeave:n,onContextMenu:i,onDoubleClick:t,nodesDraggable:y,elementsSelectable:c,nodesConnectable:$,nodesFocusable:A,resizeObserver:j,noDragClassName:F,noPanClassName:J,disableKeyboardA11y:Q,rfId:W,nodeTypes:L,nodeClickDistance:U,onError:q}){let{node:N,internals:w,isParent:G}=il((_u)=>{let Fu=_u.nodeLookup.get(u),zu=_u.parentLookup.has(u);return{node:Fu,internals:Fu.internals,isParent:zu}},El),Z=N.type||"default",H=L?.[Z]||Sw[Z];if(H===void 0)q?.("003",Jr.error003(Z)),Z="default",H=L?.default||Sw.default;let E=!!(N.draggable||y&&typeof N.draggable>"u"),m=!!(N.selectable||c&&typeof N.selectable>"u"),S=!!(N.connectable||$&&typeof N.connectable>"u"),B=!!(N.focusable||A&&typeof N.focusable>"u"),D=Zl(),X=Q9(N),O=RD({node:N,nodeType:Z,hasDimensions:X,resizeObserver:j}),Y=ew({nodeRef:O,disabled:N.hidden||!E,noDragClassName:F,handleSelector:N.dragHandle,nodeId:u,isSelectable:m,nodeClickDistance:U}),p=uW();if(N.hidden)return null;let v=qn(N),z=mD(N),P=m||E||l||f||r||n,k=f?(_u)=>f(_u,{...w.userNode}):void 0,I=r?(_u)=>r(_u,{...w.userNode}):void 0,b=n?(_u)=>n(_u,{...w.userNode}):void 0,d=i?(_u)=>i(_u,{...w.userNode}):void 0,s=t?(_u)=>t(_u,{...w.userNode}):void 0,h=(_u)=>{let{selectNodesOnDrag:Fu,nodeDragThreshold:zu}=D.getState();if(m&&(!Fu||!E||zu>0))p9({id:u,store:D,nodeRef:O});if(l)l(_u,{...w.userNode})},lu=(_u)=>{if(W9(_u.nativeEvent)||Q)return;if(i9.includes(_u.key)&&m){let Fu=_u.key==="Escape";p9({id:u,store:D,unselect:Fu,nodeRef:O})}else if(E&&N.selected&&Object.prototype.hasOwnProperty.call(WA,_u.key)){_u.preventDefault();let{ariaLabelConfig:Fu}=D.getState();D.setState({ariaLiveMessage:Fu["node.a11yDescription.ariaLiveMessage"]({direction:_u.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),p({direction:WA[_u.key],factor:_u.shiftKey?4:1})}},cu=()=>{if(Q||!O.current?.matches(":focus-visible"))return;let{transform:_u,width:Fu,height:zu,autoPanOnNodeFocus:Wu,setCenter:C}=D.getState();if(!Wu)return;if(!(iA(new Map([[u,N]]),{x:0,y:0,width:Fu,height:zu},_u,!0).length>0))C(N.position.x+v.width/2,N.position.y+v.height/2,{zoom:_u[2]})};return nu.jsx("div",{className:Rl(["react-flow__node",`react-flow__node-${Z}`,{[J]:E},N.className,{selected:N.selected,selectable:m,parent:G,draggable:E,dragging:Y}]),ref:O,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:X?"visible":"hidden",...N.style,...z},"data-id":u,"data-testid":`rf__node-${u}`,onMouseEnter:k,onMouseMove:I,onMouseLeave:b,onContextMenu:d,onClick:h,onDoubleClick:s,onKeyDown:B?lu:void 0,tabIndex:B?0:void 0,onFocus:B?cu:void 0,role:N.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":Q?void 0:`${Iw}-${W}`,"aria-label":N.ariaLabel,...N.domAttributes,children:nu.jsx(GD,{value:u,children:nu.jsx(H,{id:u,data:N.data,type:Z,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:N.selected??!1,selectable:m,draggable:E,deletable:N.deletable??!0,isConnectable:S,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:Y,dragHandle:N.dragHandle,zIndex:w.z,parentId:N.parentId,...v})})})}var hD=tu.memo(xD),bD=(u)=>({nodesDraggable:u.nodesDraggable,nodesConnectable:u.nodesConnectable,nodesFocusable:u.nodesFocusable,elementsSelectable:u.elementsSelectable,onError:u.onError});function rW(u){let{nodesDraggable:l,nodesConnectable:f,nodesFocusable:r,elementsSelectable:n,onError:i}=il(bD,El),t=PD(u.onlyRenderVisibleElements),y=MD();return nu.jsx("div",{className:"react-flow__nodes",style:KA,children:t.map((c)=>{return nu.jsx(hD,{id:c,nodeTypes:u.nodeTypes,nodeExtent:u.nodeExtent,onClick:u.onNodeClick,onMouseEnter:u.onNodeMouseEnter,onMouseMove:u.onNodeMouseMove,onMouseLeave:u.onNodeMouseLeave,onContextMenu:u.onNodeContextMenu,onDoubleClick:u.onNodeDoubleClick,noDragClassName:u.noDragClassName,noPanClassName:u.noPanClassName,rfId:u.rfId,disableKeyboardA11y:u.disableKeyboardA11y,resizeObserver:y,nodesDraggable:l,nodesConnectable:f,nodesFocusable:r,elementsSelectable:n,nodeClickDistance:u.nodeClickDistance,onError:i},c)})})}rW.displayName="NodeRenderer";var vD=tu.memo(rW);function kD(u){return il(tu.useCallback((f)=>{if(!u)return f.edges.map((n)=>n.id);let r=[];if(f.width&&f.height)for(let n of f.edges){let i=f.nodeLookup.get(n.source),t=f.nodeLookup.get(n.target);if(i&&t&&hq({sourceNode:i,targetNode:t,width:f.width,height:f.height,transform:f.transform}))r.push(n.id)}return r},[u]),El)}var ID=({color:u="none",strokeWidth:l=1})=>{let f={strokeWidth:l,...u&&{stroke:u}};return nu.jsx("polyline",{className:"arrow",style:f,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},gD=({color:u="none",strokeWidth:l=1})=>{let f={strokeWidth:l,...u&&{stroke:u,fill:u}};return nu.jsx("polyline",{className:"arrowclosed",style:f,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Yw={[x0.Arrow]:ID,[x0.ArrowClosed]:gD};function sD(u){let l=Zl();return tu.useMemo(()=>{if(!Object.prototype.hasOwnProperty.call(Yw,u))return l.getState().onError?.("009",Jr.error009(u)),null;return Yw[u]},[u])}var aD=({id:u,type:l,color:f,width:r=12.5,height:n=12.5,markerUnits:i="strokeWidth",strokeWidth:t,orient:y="auto-start-reverse"})=>{let c=sD(l);if(!c)return null;return nu.jsx("marker",{className:"react-flow__arrowhead",id:u,markerWidth:`${r}`,markerHeight:`${n}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:y,refX:"0",refY:"0",children:nu.jsx(c,{color:f,strokeWidth:t})})},nW=({defaultColor:u,rfId:l})=>{let f=il((i)=>i.edges),r=il((i)=>i.defaultEdgeOptions),n=tu.useMemo(()=>{return vq(f,{id:l,defaultColor:u,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd})},[f,r,l,u]);if(!n.length)return null;return nu.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:nu.jsx("defs",{children:n.map((i)=>nu.jsx(aD,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})})};nW.displayName="MarkerDefinitions";var oD=tu.memo(nW);function iW({x:u,y:l,label:f,labelStyle:r,labelShowBg:n=!0,labelBgStyle:i,labelBgPadding:t=[2,4],labelBgBorderRadius:y=2,children:c,className:$,...A}){let[j,F]=tu.useState({x:1,y:0,width:0,height:0}),J=Rl(["react-flow__edge-textwrapper",$]),Q=tu.useRef(null);if(tu.useEffect(()=>{if(Q.current){let W=Q.current.getBBox();F({x:W.x,y:W.y,width:W.width,height:W.height})}},[f]),!f)return null;return nu.jsxs("g",{transform:`translate(${u-j.width/2} ${l-j.height/2})`,className:J,visibility:j.width?"visible":"hidden",...A,children:[n&&nu.jsx("rect",{width:j.width+2*t[0],x:-t[0],y:-t[1],height:j.height+2*t[1],className:"react-flow__edge-textbg",style:i,rx:y,ry:y}),nu.jsx("text",{className:"react-flow__edge-text",y:j.height/2,dy:"0.3em",ref:Q,style:r,children:f}),c]})}iW.displayName="EdgeText";var dD=tu.memo(iW);function Ky({path:u,labelX:l,labelY:f,label:r,labelStyle:n,labelShowBg:i,labelBgStyle:t,labelBgPadding:y,labelBgBorderRadius:c,interactionWidth:$=20,...A}){return nu.jsxs(nu.Fragment,{children:[nu.jsx("path",{...A,d:u,fill:"none",className:Rl(["react-flow__edge-path",A.className])}),$?nu.jsx("path",{d:u,fill:"none",strokeOpacity:0,strokeWidth:$,className:"react-flow__edge-interaction"}):null,r&&Hr(l)&&Hr(f)?nu.jsx(dD,{x:l,y:f,label:r,labelStyle:n,labelShowBg:i,labelBgStyle:t,labelBgPadding:y,labelBgBorderRadius:c}):null]})}function Pw({pos:u,x1:l,y1:f,x2:r,y2:n}){if(u===Ku.Left||u===Ku.Right)return[0.5*(l+r),f];return[l,0.5*(f+n)]}function tW({sourceX:u,sourceY:l,sourcePosition:f=Ku.Bottom,targetX:r,targetY:n,targetPosition:i=Ku.Top}){let[t,y]=Pw({pos:f,x1:u,y1:l,x2:r,y2:n}),[c,$]=Pw({pos:i,x1:r,y1:n,x2:u,y2:l}),[A,j,F,J]=_A({sourceX:u,sourceY:l,targetX:r,targetY:n,sourceControlX:t,sourceControlY:y,targetControlX:c,targetControlY:$});return[`M${u},${l} C${t},${y} ${c},${$} ${r},${n}`,A,j,F,J]}function yW(u){return tu.memo(({id:l,sourceX:f,sourceY:r,targetX:n,targetY:i,sourcePosition:t,targetPosition:y,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:J,style:Q,markerEnd:W,markerStart:L,interactionWidth:U})=>{let[q,N,w]=tW({sourceX:f,sourceY:r,sourcePosition:t,targetX:n,targetY:i,targetPosition:y}),G=u.isInternal?void 0:l;return nu.jsx(Ky,{id:G,path:q,labelX:N,labelY:w,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:J,style:Q,markerEnd:W,markerStart:L,interactionWidth:U})})}var eD=yW({isInternal:!1}),cW=yW({isInternal:!0});eD.displayName="SimpleBezierEdge";cW.displayName="SimpleBezierEdgeInternal";function _W(u){return tu.memo(({id:l,sourceX:f,sourceY:r,targetX:n,targetY:i,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,sourcePosition:J=Ku.Bottom,targetPosition:Q=Ku.Top,markerEnd:W,markerStart:L,pathOptions:U,interactionWidth:q})=>{let[N,w,G]=Mc({sourceX:f,sourceY:r,sourcePosition:J,targetX:n,targetY:i,targetPosition:Q,borderRadius:U?.borderRadius,offset:U?.offset,stepPosition:U?.stepPosition}),Z=u.isInternal?void 0:l;return nu.jsx(Ky,{id:Z,path:N,labelX:w,labelY:G,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,markerEnd:W,markerStart:L,interactionWidth:q})})}var $W=_W({isInternal:!1}),AW=_W({isInternal:!0});$W.displayName="SmoothStepEdge";AW.displayName="SmoothStepEdgeInternal";function jW(u){return tu.memo(({id:l,...f})=>{let r=u.isInternal?void 0:l;return nu.jsx($W,{...f,id:r,pathOptions:tu.useMemo(()=>({borderRadius:0,offset:f.pathOptions?.offset}),[f.pathOptions?.offset])})})}var up=jW({isInternal:!1}),FW=jW({isInternal:!0});up.displayName="StepEdge";FW.displayName="StepEdgeInternal";function UW(u){return tu.memo(({id:l,sourceX:f,sourceY:r,targetX:n,targetY:i,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,markerEnd:J,markerStart:Q,interactionWidth:W})=>{let[L,U,q]=AA({sourceX:f,sourceY:r,targetX:n,targetY:i}),N=u.isInternal?void 0:l;return nu.jsx(Ky,{id:N,path:L,labelX:U,labelY:q,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,markerEnd:J,markerStart:Q,interactionWidth:W})})}var lp=UW({isInternal:!1}),JW=UW({isInternal:!0});lp.displayName="StraightEdge";JW.displayName="StraightEdgeInternal";function QW(u){return tu.memo(({id:l,sourceX:f,sourceY:r,targetX:n,targetY:i,sourcePosition:t=Ku.Bottom,targetPosition:y=Ku.Top,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:J,style:Q,markerEnd:W,markerStart:L,pathOptions:U,interactionWidth:q})=>{let[N,w,G]=$A({sourceX:f,sourceY:r,sourcePosition:t,targetX:n,targetY:i,targetPosition:y,curvature:U?.curvature}),Z=u.isInternal?void 0:l;return nu.jsx(Ky,{id:Z,path:N,labelX:w,labelY:G,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:J,style:Q,markerEnd:W,markerStart:L,interactionWidth:q})})}var fp=QW({isInternal:!1}),NW=QW({isInternal:!0});fp.displayName="BezierEdge";NW.displayName="BezierEdgeInternal";var Cw={default:NW,straight:JW,step:FW,smoothstep:AW,simplebezier:cW},Mw={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},rp=(u,l,f)=>{if(f===Ku.Left)return u-l;if(f===Ku.Right)return u+l;return u},np=(u,l,f)=>{if(f===Ku.Top)return u-l;if(f===Ku.Bottom)return u+l;return u},Rw="react-flow__edgeupdater";function xw({position:u,centerX:l,centerY:f,radius:r=10,onMouseDown:n,onMouseEnter:i,onMouseOut:t,type:y}){return nu.jsx("circle",{onMouseDown:n,onMouseEnter:i,onMouseOut:t,className:Rl([Rw,`${Rw}-${y}`]),cx:rp(l,r,u),cy:np(f,r,u),r,stroke:"transparent",fill:"transparent"})}function ip({isReconnectable:u,reconnectRadius:l,edge:f,sourceX:r,sourceY:n,targetX:i,targetY:t,sourcePosition:y,targetPosition:c,onReconnect:$,onReconnectStart:A,onReconnectEnd:j,setReconnecting:F,setUpdateHover:J}){let Q=Zl(),W=(w,G)=>{if(w.button!==0)return;let{autoPanOnConnect:Z,domNode:H,connectionMode:E,connectionRadius:m,lib:S,onConnectStart:B,cancelConnection:D,nodeLookup:X,rfId:O,panBy:Y,updateConnection:p}=Q.getState(),v=G.type==="target",z=(I,b)=>{F(!1),j?.(I,f,G.type,b)},P=(I)=>$?.(f,I),k=(I,b)=>{F(!0),A?.(w,f,G.type),B?.(I,b)};JA.onPointerDown(w.nativeEvent,{autoPanOnConnect:Z,connectionMode:E,connectionRadius:m,domNode:H,handleId:G.id,nodeId:G.nodeId,nodeLookup:X,isTarget:v,edgeUpdaterType:G.type,lib:S,flowId:O,cancelConnection:D,panBy:Y,isValidConnection:(...I)=>Q.getState().isValidConnection?.(...I)??!0,onConnect:P,onConnectStart:k,onConnectEnd:(...I)=>Q.getState().onConnectEnd?.(...I),onReconnectEnd:z,updateConnection:p,getTransform:()=>Q.getState().transform,getFromHandle:()=>Q.getState().connection.fromHandle,dragThreshold:Q.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},L=(w)=>W(w,{nodeId:f.target,id:f.targetHandle??null,type:"target"}),U=(w)=>W(w,{nodeId:f.source,id:f.sourceHandle??null,type:"source"}),q=()=>J(!0),N=()=>J(!1);return nu.jsxs(nu.Fragment,{children:[(u===!0||u==="source")&&nu.jsx(xw,{position:y,centerX:r,centerY:n,radius:l,onMouseDown:L,onMouseEnter:q,onMouseOut:N,type:"source"}),(u===!0||u==="target")&&nu.jsx(xw,{position:c,centerX:i,centerY:t,radius:l,onMouseDown:U,onMouseEnter:q,onMouseOut:N,type:"target"})]})}function tp({id:u,edgesFocusable:l,edgesReconnectable:f,elementsSelectable:r,onClick:n,onDoubleClick:i,onContextMenu:t,onMouseEnter:y,onMouseMove:c,onMouseLeave:$,reconnectRadius:A,onReconnect:j,onReconnectStart:F,onReconnectEnd:J,rfId:Q,edgeTypes:W,noPanClassName:L,onError:U,disableKeyboardA11y:q}){let N=il((C)=>C.edgeLookup.get(u)),w=il((C)=>C.defaultEdgeOptions);N=w?{...w,...N}:N;let G=N.type||"default",Z=W?.[G]||Cw[G];if(Z===void 0)U?.("011",Jr.error011(G)),G="default",Z=W?.default||Cw.default;let H=!!(N.focusable||l&&typeof N.focusable>"u"),E=typeof j<"u"&&(N.reconnectable||f&&typeof N.reconnectable>"u"),m=!!(N.selectable||r&&typeof N.selectable>"u"),S=tu.useRef(null),[B,D]=tu.useState(!1),[X,O]=tu.useState(!1),Y=Zl(),{zIndex:p,sourceX:v,sourceY:z,targetX:P,targetY:k,sourcePosition:I,targetPosition:b}=il(tu.useCallback((C)=>{let e=C.nodeLookup.get(N.source),uu=C.nodeLookup.get(N.target);if(!e||!uu)return{zIndex:N.zIndex,...Mw};let Gu=bq({id:u,sourceNode:e,targetNode:uu,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:C.connectionMode,onError:U});return{zIndex:xq({selected:N.selected,zIndex:N.zIndex,sourceNode:e,targetNode:uu,elevateOnSelect:C.elevateEdgesOnSelect,zIndexMode:C.zIndexMode}),...Gu||Mw}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex]),El),d=tu.useMemo(()=>N.markerStart?`url('#${jA(N.markerStart,Q)}')`:void 0,[N.markerStart,Q]),s=tu.useMemo(()=>N.markerEnd?`url('#${jA(N.markerEnd,Q)}')`:void 0,[N.markerEnd,Q]);if(N.hidden||v===null||z===null||P===null||k===null)return null;let h=(C)=>{let{addSelectedEdges:e,unselectNodesAndEdges:uu,multiSelectionActive:Gu}=Y.getState();if(m)if(Y.setState({nodesSelectionActive:!1}),N.selected&&Gu)uu({nodes:[],edges:[N]}),S.current?.blur();else e([u]);if(n)n(C,N)},lu=i?(C)=>{i(C,{...N})}:void 0,cu=t?(C)=>{t(C,{...N})}:void 0,_u=y?(C)=>{y(C,{...N})}:void 0,Fu=c?(C)=>{c(C,{...N})}:void 0,zu=$?(C)=>{$(C,{...N})}:void 0,Wu=(C)=>{if(!q&&i9.includes(C.key)&&m){let{unselectNodesAndEdges:e,addSelectedEdges:uu}=Y.getState();if(C.key==="Escape")S.current?.blur(),e({edges:[N]});else uu([u])}};return nu.jsx("svg",{style:{zIndex:p},children:nu.jsxs("g",{className:Rl(["react-flow__edge",`react-flow__edge-${G}`,N.className,L,{selected:N.selected,animated:N.animated,inactive:!m&&!n,updating:B,selectable:m}]),onClick:h,onDoubleClick:lu,onContextMenu:cu,onMouseEnter:_u,onMouseMove:Fu,onMouseLeave:zu,onKeyDown:H?Wu:void 0,tabIndex:H?0:void 0,role:N.ariaRole??(H?"group":"img"),"aria-roledescription":"edge","data-id":u,"data-testid":`rf__edge-${u}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":H?`${gw}-${Q}`:void 0,ref:S,...N.domAttributes,children:[!X&&nu.jsx(Z,{id:u,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:m,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:v,sourceY:z,targetX:P,targetY:k,sourcePosition:I,targetPosition:b,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:d,markerEnd:s,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),E&&nu.jsx(ip,{edge:N,isReconnectable:E,reconnectRadius:A,onReconnect:j,onReconnectStart:F,onReconnectEnd:J,sourceX:v,sourceY:z,targetX:P,targetY:k,sourcePosition:I,targetPosition:b,setUpdateHover:D,setReconnecting:O})]})})}var yp=tu.memo(tp),cp=(u)=>({edgesFocusable:u.edgesFocusable,edgesReconnectable:u.edgesReconnectable,elementsSelectable:u.elementsSelectable,connectionMode:u.connectionMode,onError:u.onError});function qW({defaultMarkerColor:u,onlyRenderVisibleElements:l,rfId:f,edgeTypes:r,noPanClassName:n,onReconnect:i,onEdgeContextMenu:t,onEdgeMouseEnter:y,onEdgeMouseMove:c,onEdgeMouseLeave:$,onEdgeClick:A,reconnectRadius:j,onEdgeDoubleClick:F,onReconnectStart:J,onReconnectEnd:Q,disableKeyboardA11y:W}){let{edgesFocusable:L,edgesReconnectable:U,elementsSelectable:q,onError:N}=il(cp,El),w=kD(l);return nu.jsxs("div",{className:"react-flow__edges",children:[nu.jsx(oD,{defaultColor:u,rfId:f}),w.map((G)=>{return nu.jsx(yp,{id:G,edgesFocusable:L,edgesReconnectable:U,elementsSelectable:q,noPanClassName:n,onReconnect:i,onContextMenu:t,onMouseEnter:y,onMouseMove:c,onMouseLeave:$,onClick:A,reconnectRadius:j,onDoubleClick:F,onReconnectStart:J,onReconnectEnd:Q,rfId:f,onError:N,edgeTypes:r,disableKeyboardA11y:W},G)})]})}qW.displayName="EdgeRenderer";var _p=tu.memo(qW),$p=(u)=>`translate(${u.transform[0]}px,${u.transform[1]}px) scale(${u.transform[2]})`;function Ap({children:u}){let l=il($p);return nu.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:l},children:u})}function jp(u){let l=S9(),f=tu.useRef(!1);tu.useEffect(()=>{if(!f.current&&l.viewportInitialized&&u)setTimeout(()=>u(l),1),f.current=!0},[u,l.viewportInitialized])}var Fp=(u)=>u.panZoom?.syncViewport;function Up(u){let l=il(Fp),f=Zl();return tu.useEffect(()=>{if(u)l?.(u),f.setState({transform:[u.x,u.y,u.zoom]})},[u,l]),null}function hw(u){return u.connection.inProgress?{...u.connection,to:wy(u.connection.to,u.transform)}:{...u.connection}}function Jp(u){if(u)return(f)=>{let r=hw(f);return u(r)};return hw}function Qp(u){let l=Jp(u);return il(l,El)}var Np=(u)=>({nodesConnectable:u.nodesConnectable,isValid:u.connection.isValid,inProgress:u.connection.inProgress,width:u.width,height:u.height});function qp({containerStyle:u,style:l,type:f,component:r}){let{nodesConnectable:n,width:i,height:t,isValid:y,inProgress:c}=il(Np,El);if(!(i&&n&&c))return null;return nu.jsx("svg",{style:u,width:i,height:t,className:"react-flow__connectionline react-flow__container",children:nu.jsx("g",{className:Rl(["react-flow__connection",c9(y)]),children:nu.jsx(wW,{style:l,type:f,CustomComponent:r,isValid:y})})})}var wW=({style:u,type:l=Nn.Bezier,CustomComponent:f,isValid:r})=>{let{inProgress:n,from:i,fromNode:t,fromHandle:y,fromPosition:c,to:$,toNode:A,toHandle:j,toPosition:F,pointer:J}=Qp();if(!n)return;if(f)return nu.jsx(f,{connectionLineType:l,connectionLineStyle:u,fromNode:t,fromHandle:y,fromX:i.x,fromY:i.y,toX:$.x,toY:$.y,fromPosition:c,toPosition:F,connectionStatus:c9(r),toNode:A,toHandle:j,pointer:J});let Q="",W={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:$.x,targetY:$.y,targetPosition:F};switch(l){case Nn.Bezier:[Q]=$A(W);break;case Nn.SimpleBezier:[Q]=tW(W);break;case Nn.Step:[Q]=Mc({...W,borderRadius:0});break;case Nn.SmoothStep:[Q]=Mc(W);break;default:[Q]=AA(W)}return nu.jsx("path",{d:Q,fill:"none",className:"react-flow__connection-path",style:u})};wW.displayName="ConnectionLine";var wp={};function bw(u=wp){let l=tu.useRef(u),f=Zl();tu.useEffect(()=>{},[u])}function Wp(){let u=Zl(),l=tu.useRef(!1);tu.useEffect(()=>{},[])}function WW({nodeTypes:u,edgeTypes:l,onInit:f,onNodeClick:r,onEdgeClick:n,onNodeDoubleClick:i,onEdgeDoubleClick:t,onNodeMouseEnter:y,onNodeMouseMove:c,onNodeMouseLeave:$,onNodeContextMenu:A,onSelectionContextMenu:j,onSelectionStart:F,onSelectionEnd:J,connectionLineType:Q,connectionLineStyle:W,connectionLineComponent:L,connectionLineContainerStyle:U,selectionKeyCode:q,selectionOnDrag:N,selectionMode:w,multiSelectionKeyCode:G,panActivationKeyCode:Z,zoomActivationKeyCode:H,deleteKeyCode:E,onlyRenderVisibleElements:m,elementsSelectable:S,defaultViewport:B,translateExtent:D,minZoom:X,maxZoom:O,preventScrolling:Y,defaultMarkerColor:p,zoomOnScroll:v,zoomOnPinch:z,panOnScroll:P,panOnScrollSpeed:k,panOnScrollMode:I,zoomOnDoubleClick:b,panOnDrag:d,onPaneClick:s,onPaneMouseEnter:h,onPaneMouseMove:lu,onPaneMouseLeave:cu,onPaneScroll:_u,onPaneContextMenu:Fu,paneClickDistance:zu,nodeClickDistance:Wu,onEdgeContextMenu:C,onEdgeMouseEnter:e,onEdgeMouseMove:uu,onEdgeMouseLeave:Gu,reconnectRadius:a,onReconnect:qu,onReconnectStart:Zu,onReconnectEnd:Bu,noDragClassName:gu,noWheelClassName:ll,noPanClassName:Pu,disableKeyboardA11y:Nl,nodeExtent:Qf,rfId:Zf,viewport:$f,onViewportChange:nf}){return bw(u),bw(l),Wp(),jp(f),Up($f),nu.jsx(XD,{onPaneClick:s,onPaneMouseEnter:h,onPaneMouseMove:lu,onPaneMouseLeave:cu,onPaneContextMenu:Fu,onPaneScroll:_u,paneClickDistance:zu,deleteKeyCode:E,selectionKeyCode:q,selectionOnDrag:N,selectionMode:w,onSelectionStart:F,onSelectionEnd:J,multiSelectionKeyCode:G,panActivationKeyCode:Z,zoomActivationKeyCode:H,elementsSelectable:S,zoomOnScroll:v,zoomOnPinch:z,zoomOnDoubleClick:b,panOnScroll:P,panOnScrollSpeed:k,panOnScrollMode:I,panOnDrag:d,defaultViewport:B,translateExtent:D,minZoom:X,maxZoom:O,onSelectionContextMenu:j,preventScrolling:Y,noDragClassName:gu,noWheelClassName:ll,noPanClassName:Pu,disableKeyboardA11y:Nl,onViewportChange:nf,isControlledViewport:!!$f,children:nu.jsxs(Ap,{children:[nu.jsx(_p,{edgeTypes:l,onEdgeClick:n,onEdgeDoubleClick:t,onReconnect:qu,onReconnectStart:Zu,onReconnectEnd:Bu,onlyRenderVisibleElements:m,onEdgeContextMenu:C,onEdgeMouseEnter:e,onEdgeMouseMove:uu,onEdgeMouseLeave:Gu,reconnectRadius:a,defaultMarkerColor:p,noPanClassName:Pu,disableKeyboardA11y:Nl,rfId:Zf}),nu.jsx(qp,{style:W,type:Q,component:L,containerStyle:U}),nu.jsx("div",{className:"react-flow__edgelabel-renderer"}),nu.jsx(vD,{nodeTypes:u,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:y,onNodeMouseMove:c,onNodeMouseLeave:$,onNodeContextMenu:A,nodeClickDistance:Wu,onlyRenderVisibleElements:m,noPanClassName:Pu,noDragClassName:gu,disableKeyboardA11y:Nl,nodeExtent:Qf,rfId:Zf}),nu.jsx("div",{className:"react-flow__viewport-portal"})]})})}WW.displayName="GraphView";var Lp=tu.memo(WW),vw=({nodes:u,edges:l,defaultNodes:f,defaultEdges:r,width:n,height:i,fitView:t,fitViewOptions:y,minZoom:c=0.5,maxZoom:$=2,nodeOrigin:A,nodeExtent:j,zIndexMode:F="basic"}={})=>{let J=new Map,Q=new Map,W=new Map,L=new Map,U=r??l??[],q=f??u??[],N=A??[0,0],w=j??Jy;Z9(W,L,U);let{nodesInitialized:G}=FA(q,J,Q,{nodeOrigin:N,nodeExtent:w,zIndexMode:F}),Z=[0,0,1];if(t&&n&&i){let H=Qy(J,{filter:(B)=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:E,y:m,zoom:S}=Cc(H,n,i,c,$,y?.padding??0.1);Z=[E,m,S]}return{rfId:"1",width:n??0,height:i??0,transform:Z,nodes:q,nodesInitialized:G,nodeLookup:J,parentLookup:Q,edges:U,edgeLookup:L,connectionLookup:W,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:f!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:$,translateExtent:Jy,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:R0.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:t??!1,fitViewOptions:y,fitViewResolver:null,connection:{...y9},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:J9,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:t9,zIndexMode:F,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Tp=({nodes:u,edges:l,defaultNodes:f,defaultEdges:r,width:n,height:i,fitView:t,fitViewOptions:y,minZoom:c,maxZoom:$,nodeOrigin:A,nodeExtent:j,zIndexMode:F})=>Tw((J,Q)=>{async function W(){let{nodeLookup:L,panZoom:U,fitViewOptions:q,fitViewResolver:N,width:w,height:G,minZoom:Z,maxZoom:H}=Q();if(!U)return;await Xq({nodes:L,width:w,height:G,panZoom:U,minZoom:Z,maxZoom:H},q),N?.resolve(!0),J({fitViewResolver:null})}return{...vw({nodes:u,edges:l,width:n,height:i,fitView:t,fitViewOptions:y,minZoom:c,maxZoom:$,nodeOrigin:A,nodeExtent:j,defaultNodes:f,defaultEdges:r,zIndexMode:F}),setNodes:(L)=>{let{nodeLookup:U,parentLookup:q,nodeOrigin:N,elevateNodesOnSelect:w,fitViewQueued:G,zIndexMode:Z,nodesSelectionActive:H}=Q(),{nodesInitialized:E,hasSelectedNodes:m}=FA(L,U,q,{nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:Z}),S=H&&m;if(G&&E)W(),J({nodes:L,nodesInitialized:E,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:S});else J({nodes:L,nodesInitialized:E,nodesSelectionActive:S})},setEdges:(L)=>{let{connectionLookup:U,edgeLookup:q}=Q();Z9(U,q,L),J({edges:L})},setDefaultNodesAndEdges:(L,U)=>{if(L){let{setNodes:q}=Q();q(L),J({hasDefaultNodes:!0})}if(U){let{setEdges:q}=Q();q(U),J({hasDefaultEdges:!0})}},updateNodeInternals:(L)=>{let{triggerNodeChanges:U,nodeLookup:q,parentLookup:N,domNode:w,nodeOrigin:G,nodeExtent:Z,debug:H,fitViewQueued:E,zIndexMode:m}=Q(),{changes:S,updatedInternals:B}=sq(L,q,N,w,G,Z,m);if(!B)return;if(Iq(q,N,{nodeOrigin:G,nodeExtent:Z,zIndexMode:m}),E)W(),J({fitViewQueued:!1,fitViewOptions:void 0});else J({});if(S?.length>0){if(H)console.log("React Flow: trigger node changes",S);U?.(S)}},updateNodePositions:(L,U=!1)=>{let q=[],N=[],{nodeLookup:w,triggerNodeChanges:G,connection:Z,updateConnection:H,onNodesChangeMiddlewareMap:E}=Q();for(let[m,S]of L){let B=w.get(m),D=!!(B?.expandParent&&B?.parentId&&S?.position),X={id:m,type:"position",position:D?{x:Math.max(0,S.position.x),y:Math.max(0,S.position.y)}:S.position,dragging:U};if(B&&Z.inProgress&&Z.fromNode.id===B.id){let O=h0(B,Z.fromHandle,Ku.Left,!0);H({...Z,from:O})}if(D&&B.parentId)q.push({id:m,parentId:B.parentId,rect:{...S.internals.positionAbsolute,width:S.measured.width??0,height:S.measured.height??0}});N.push(X)}if(q.length>0){let{parentLookup:m,nodeOrigin:S}=Q(),B=UA(q,w,m,S);N.push(...B)}for(let m of E.values())N=m(N);G(N)},triggerNodeChanges:(L)=>{let{onNodesChange:U,setNodes:q,nodes:N,hasDefaultNodes:w,debug:G}=Q();if(L?.length){if(w){let Z=yD(L,N);q(Z)}if(G)console.log("React Flow: trigger node changes",L);U?.(L)}},triggerEdgeChanges:(L)=>{let{onEdgesChange:U,setEdges:q,edges:N,hasDefaultEdges:w,debug:G}=Q();if(L?.length){if(w){let Z=cD(L,N);q(Z)}if(G)console.log("React Flow: trigger edge changes",L);U?.(L)}},addSelectedNodes:(L)=>{let{multiSelectionActive:U,edgeLookup:q,nodeLookup:N,triggerNodeChanges:w,triggerEdgeChanges:G}=Q();if(U){let Z=L.map((H)=>oi(H,!0));w(Z);return}w(Ty(N,new Set([...L]),!0)),G(Ty(q))},addSelectedEdges:(L)=>{let{multiSelectionActive:U,edgeLookup:q,nodeLookup:N,triggerNodeChanges:w,triggerEdgeChanges:G}=Q();if(U){let Z=L.map((H)=>oi(H,!0));G(Z);return}G(Ty(q,new Set([...L]))),w(Ty(N,new Set,!0))},unselectNodesAndEdges:({nodes:L,edges:U}={})=>{let{edges:q,nodes:N,nodeLookup:w,triggerNodeChanges:G,triggerEdgeChanges:Z}=Q(),H=L?L:N,E=U?U:q,m=[];for(let B of H){if(!B.selected)continue;let D=w.get(B.id);if(D)D.selected=!1;m.push(oi(B.id,!1))}let S=[];for(let B of E){if(!B.selected)continue;S.push(oi(B.id,!1))}G(m),Z(S)},setMinZoom:(L)=>{let{panZoom:U,maxZoom:q}=Q();U?.setScaleExtent([L,q]),J({minZoom:L})},setMaxZoom:(L)=>{let{panZoom:U,minZoom:q}=Q();U?.setScaleExtent([q,L]),J({maxZoom:L})},setTranslateExtent:(L)=>{Q().panZoom?.setTranslateExtent(L),J({translateExtent:L})},resetSelectedElements:()=>{let{edges:L,nodes:U,triggerNodeChanges:q,triggerEdgeChanges:N,elementsSelectable:w}=Q();if(!w)return;let G=U.reduce((H,E)=>E.selected?[...H,oi(E.id,!1)]:H,[]),Z=L.reduce((H,E)=>E.selected?[...H,oi(E.id,!1)]:H,[]);q(G),N(Z)},setNodeExtent:(L)=>{let{nodes:U,nodeLookup:q,parentLookup:N,nodeOrigin:w,elevateNodesOnSelect:G,nodeExtent:Z,zIndexMode:H}=Q();if(L[0][0]===Z[0][0]&&L[0][1]===Z[0][1]&&L[1][0]===Z[1][0]&&L[1][1]===Z[1][1])return;FA(U,q,N,{nodeOrigin:w,nodeExtent:L,elevateNodesOnSelect:G,checkEquality:!1,zIndexMode:H}),J({nodeExtent:L})},panBy:(L)=>{let{transform:U,width:q,height:N,panZoom:w,translateExtent:G}=Q();return aq({delta:L,panZoom:w,transform:U,translateExtent:G,width:q,height:N})},setCenter:async(L,U,q)=>{let{width:N,height:w,maxZoom:G,panZoom:Z}=Q();if(!Z)return Promise.resolve(!1);let H=typeof q?.zoom<"u"?q.zoom:G;return await Z.setViewport({x:N/2-L*H,y:w/2-U*H,zoom:H},{duration:q?.duration,ease:q?.ease,interpolate:q?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{J({connection:{...y9}})},updateConnection:(L)=>{J({connection:L})},reset:()=>J({...vw()})}},Object.is);function Kp({initialNodes:u,initialEdges:l,defaultNodes:f,defaultEdges:r,initialWidth:n,initialHeight:i,initialMinZoom:t,initialMaxZoom:y,initialFitViewOptions:c,fitView:$,nodeOrigin:A,nodeExtent:j,zIndexMode:F,children:J}){let[Q]=tu.useState(()=>Tp({nodes:u,edges:l,defaultNodes:f,defaultEdges:r,width:n,height:i,fitView:$,minZoom:t,maxZoom:y,fitViewOptions:c,nodeOrigin:A,nodeExtent:j,zIndexMode:F}));return nu.jsx(Rm,{value:Q,children:nu.jsx(AD,{children:J})})}function Gp({children:u,nodes:l,edges:f,defaultNodes:r,defaultEdges:n,width:i,height:t,fitView:y,fitViewOptions:c,minZoom:$,maxZoom:A,nodeOrigin:j,nodeExtent:F,zIndexMode:J}){if(tu.useContext(LA))return nu.jsx(nu.Fragment,{children:u});return nu.jsx(Kp,{initialNodes:l,initialEdges:f,defaultNodes:r,defaultEdges:n,initialWidth:i,initialHeight:t,fitView:y,initialFitViewOptions:c,initialMinZoom:$,initialMaxZoom:A,nodeOrigin:j,nodeExtent:F,zIndexMode:J,children:u})}var zp={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Ep({nodes:u,edges:l,defaultNodes:f,defaultEdges:r,className:n,nodeTypes:i,edgeTypes:t,onNodeClick:y,onEdgeClick:c,onInit:$,onMove:A,onMoveStart:j,onMoveEnd:F,onConnect:J,onConnectStart:Q,onConnectEnd:W,onClickConnectStart:L,onClickConnectEnd:U,onNodeMouseEnter:q,onNodeMouseMove:N,onNodeMouseLeave:w,onNodeContextMenu:G,onNodeDoubleClick:Z,onNodeDragStart:H,onNodeDrag:E,onNodeDragStop:m,onNodesDelete:S,onEdgesDelete:B,onDelete:D,onSelectionChange:X,onSelectionDragStart:O,onSelectionDrag:Y,onSelectionDragStop:p,onSelectionContextMenu:v,onSelectionStart:z,onSelectionEnd:P,onBeforeDelete:k,connectionMode:I,connectionLineType:b=Nn.Bezier,connectionLineStyle:d,connectionLineComponent:s,connectionLineContainerStyle:h,deleteKeyCode:lu="Backspace",selectionKeyCode:cu="Shift",selectionOnDrag:_u=!1,selectionMode:Fu=gi.Full,panActivationKeyCode:zu="Space",multiSelectionKeyCode:Wu=Wy()?"Meta":"Control",zoomActivationKeyCode:C=Wy()?"Meta":"Control",snapToGrid:e,snapGrid:uu,onlyRenderVisibleElements:Gu=!1,selectNodesOnDrag:a,nodesDraggable:qu,autoPanOnNodeFocus:Zu,nodesConnectable:Bu,nodesFocusable:gu,nodeOrigin:ll=sw,edgesFocusable:Pu,edgesReconnectable:Nl,elementsSelectable:Qf=!0,defaultViewport:Zf=uD,minZoom:$f=0.5,maxZoom:nf=2,translateExtent:tf=Jy,preventScrolling:Mf=!0,nodeExtent:$u,defaultMarkerColor:au="#b1b1b7",zoomOnScroll:Nf=!0,zoomOnPinch:Yu=!0,panOnScroll:Sl=!1,panOnScrollSpeed:dl=0.5,panOnScrollMode:rr=an.Free,zoomOnDoubleClick:Af=!0,panOnDrag:Hf=!0,onPaneClick:Gn,onPaneMouseEnter:nr,onPaneMouseMove:u0,onPaneMouseLeave:$l,onPaneScroll:lt,onPaneContextMenu:fu,paneClickDistance:Vu=1,nodeClickDistance:Xu=0,children:ou,onReconnect:Al,onReconnectStart:kl,onReconnectEnd:_l,onEdgeContextMenu:qf,onEdgeDoubleClick:Sr,onEdgeMouseEnter:Dy,onEdgeMouseMove:Kl,onEdgeMouseLeave:n_,reconnectRadius:aA=10,onNodesChange:Ul,onEdgesChange:O7,noDragClassName:Xl="nodrag",noWheelClassName:Bf="nowheel",noPanClassName:ft="nopan",fitView:py,fitViewOptions:rt,connectOnClick:i_,attributionPosition:Sy,proOptions:t_,defaultEdgeOptions:y_,elevateNodesOnSelect:fi=!0,elevateEdgesOnSelect:nt=!1,disableKeyboardA11y:ri=!1,autoPanOnConnect:Rf,autoPanOnNodeDrag:Xr,autoPanSpeed:c_,connectionRadius:Xy,isValidConnection:Yy,onError:__,style:fn,id:Py,nodeDragThreshold:Yl,connectionDragThreshold:oA,viewport:$_,onViewportChange:Yr,width:ni,height:ii,colorMode:it="light",debug:ti,onScroll:tt,ariaLabelConfig:Z7,zIndexMode:yi="basic",...H7},A_){let Cy=Py||"1",dA=nD(it),eA=tu.useCallback((zn)=>{zn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),tt?.(zn)},[tt]);return nu.jsx("div",{"data-testid":"rf__wrapper",...H7,onScroll:eA,style:{...fn,...zp},ref:A_,className:Rl(["react-flow",n,dA]),id:Py,role:"application",children:nu.jsxs(Gp,{nodes:u,edges:l,width:ni,height:ii,fitView:py,fitViewOptions:rt,minZoom:$f,maxZoom:nf,nodeOrigin:ll,nodeExtent:$u,zIndexMode:yi,children:[nu.jsx(rD,{nodes:u,edges:l,defaultNodes:f,defaultEdges:r,onConnect:J,onConnectStart:Q,onConnectEnd:W,onClickConnectStart:L,onClickConnectEnd:U,nodesDraggable:qu,autoPanOnNodeFocus:Zu,nodesConnectable:Bu,nodesFocusable:gu,edgesFocusable:Pu,edgesReconnectable:Nl,elementsSelectable:Qf,elevateNodesOnSelect:fi,elevateEdgesOnSelect:nt,minZoom:$f,maxZoom:nf,nodeExtent:$u,onNodesChange:Ul,onEdgesChange:O7,snapToGrid:e,snapGrid:uu,connectionMode:I,translateExtent:tf,connectOnClick:i_,defaultEdgeOptions:y_,fitView:py,fitViewOptions:rt,onNodesDelete:S,onEdgesDelete:B,onDelete:D,onNodeDragStart:H,onNodeDrag:E,onNodeDragStop:m,onSelectionDrag:Y,onSelectionDragStart:O,onSelectionDragStop:p,onMove:A,onMoveStart:j,onMoveEnd:F,noPanClassName:ft,nodeOrigin:ll,rfId:Cy,autoPanOnConnect:Rf,autoPanOnNodeDrag:Xr,autoPanSpeed:c_,onError:__,connectionRadius:Xy,isValidConnection:Yy,selectNodesOnDrag:a,nodeDragThreshold:Yl,connectionDragThreshold:oA,onBeforeDelete:k,debug:ti,ariaLabelConfig:Z7,zIndexMode:yi}),nu.jsx(Lp,{onInit:$,onNodeClick:y,onEdgeClick:c,onNodeMouseEnter:q,onNodeMouseMove:N,onNodeMouseLeave:w,onNodeContextMenu:G,onNodeDoubleClick:Z,nodeTypes:i,edgeTypes:t,connectionLineType:b,connectionLineStyle:d,connectionLineComponent:s,connectionLineContainerStyle:h,selectionKeyCode:cu,selectionOnDrag:_u,selectionMode:Fu,deleteKeyCode:lu,multiSelectionKeyCode:Wu,panActivationKeyCode:zu,zoomActivationKeyCode:C,onlyRenderVisibleElements:Gu,defaultViewport:Zf,translateExtent:tf,minZoom:$f,maxZoom:nf,preventScrolling:Mf,zoomOnScroll:Nf,zoomOnPinch:Yu,zoomOnDoubleClick:Af,panOnScroll:Sl,panOnScrollSpeed:dl,panOnScrollMode:rr,panOnDrag:Hf,onPaneClick:Gn,onPaneMouseEnter:nr,onPaneMouseMove:u0,onPaneMouseLeave:$l,onPaneScroll:lt,onPaneContextMenu:fu,paneClickDistance:Vu,nodeClickDistance:Xu,onSelectionContextMenu:v,onSelectionStart:z,onSelectionEnd:P,onReconnect:Al,onReconnectStart:kl,onReconnectEnd:_l,onEdgeContextMenu:qf,onEdgeDoubleClick:Sr,onEdgeMouseEnter:Dy,onEdgeMouseMove:Kl,onEdgeMouseLeave:n_,reconnectRadius:aA,defaultMarkerColor:au,noDragClassName:Xl,noWheelClassName:Bf,noPanClassName:ft,rfId:Cy,disableKeyboardA11y:ri,nodeExtent:$u,viewport:$_,onViewportChange:Yr}),nu.jsx(em,{onSelectionChange:X}),ou,nu.jsx(gm,{proOptions:t_,position:Sy}),nu.jsx(Im,{rfId:Cy,disableKeyboardA11y:ri})]})})}var LW=ow(Ep);var Gv=Jr.error014();function Op({dimensions:u,lineWidth:l,variant:f,className:r}){return nu.jsx("path",{strokeWidth:l,d:`M${u[0]/2} 0 V${u[1]} M0 ${u[1]/2} H${u[0]}`,className:Rl(["react-flow__background-pattern",f,r])})}function Zp({radius:u,className:l}){return nu.jsx("circle",{cx:u,cy:u,r:u,className:Rl(["react-flow__background-pattern","dots",l])})}var v0;(function(u){u.Lines="lines",u.Dots="dots",u.Cross="cross"})(v0||(v0={}));var Hp={[v0.Dots]:1,[v0.Lines]:1,[v0.Cross]:6},Bp=(u)=>({transform:u.transform,patternId:`pattern-${u.rfId}`});function TW({id:u,variant:l=v0.Dots,gap:f=20,size:r,lineWidth:n=1,offset:i=0,color:t,bgColor:y,style:c,className:$,patternClassName:A}){let j=tu.useRef(null),{transform:F,patternId:J}=il(Bp,El),Q=r||Hp[l],W=l===v0.Dots,L=l===v0.Cross,U=Array.isArray(f)?f:[f,f],q=[U[0]*F[2]||1,U[1]*F[2]||1],N=Q*F[2],w=Array.isArray(i)?i:[i,i],G=L?[N,N]:q,Z=[w[0]*F[2]||1+G[0]/2,w[1]*F[2]||1+G[1]/2],H=`${J}${u?u:""}`;return nu.jsxs("svg",{className:Rl(["react-flow__background",$]),style:{...c,...KA,"--xy-background-color-props":y,"--xy-background-pattern-color-props":t},ref:j,"data-testid":"rf__background",children:[nu.jsx("pattern",{id:H,x:F[0]%q[0],y:F[1]%q[1],width:q[0],height:q[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${Z[0]},-${Z[1]})`,children:W?nu.jsx(Zp,{radius:N/2,className:A}):nu.jsx(Op,{dimensions:G,lineWidth:n,variant:l,className:A})}),nu.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}TW.displayName="Background";var KW=tu.memo(TW);function Vp(){return nu.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:nu.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function mp(){return nu.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:nu.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Dp(){return nu.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:nu.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function pp(){return nu.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:nu.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Sp(){return nu.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:nu.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function wA({children:u,className:l,...f}){return nu.jsx("button",{type:"button",className:Rl(["react-flow__controls-button",l]),...f,children:u})}var Xp=(u)=>({isInteractive:u.nodesDraggable||u.nodesConnectable||u.elementsSelectable,minZoomReached:u.transform[2]<=u.minZoom,maxZoomReached:u.transform[2]>=u.maxZoom,ariaLabelConfig:u.ariaLabelConfig});function GW({style:u,showZoom:l=!0,showFitView:f=!0,showInteractive:r=!0,fitViewOptions:n,onZoomIn:i,onZoomOut:t,onFitView:y,onInteractiveChange:c,className:$,children:A,position:j="bottom-left",orientation:F="vertical","aria-label":J}){let Q=Zl(),{isInteractive:W,minZoomReached:L,maxZoomReached:U,ariaLabelConfig:q}=il(Xp,El),{zoomIn:N,zoomOut:w,fitView:G}=S9(),Z=()=>{N(),i?.()},H=()=>{w(),t?.()},E=()=>{G(n),y?.()},m=()=>{Q.setState({nodesDraggable:!W,nodesConnectable:!W,elementsSelectable:!W}),c?.(!W)};return nu.jsxs(TA,{className:Rl(["react-flow__controls",F==="horizontal"?"horizontal":"vertical",$]),position:j,style:u,"data-testid":"rf__controls","aria-label":J??q["controls.ariaLabel"],children:[l&&nu.jsxs(nu.Fragment,{children:[nu.jsx(wA,{onClick:Z,className:"react-flow__controls-zoomin",title:q["controls.zoomIn.ariaLabel"],"aria-label":q["controls.zoomIn.ariaLabel"],disabled:U,children:nu.jsx(Vp,{})}),nu.jsx(wA,{onClick:H,className:"react-flow__controls-zoomout",title:q["controls.zoomOut.ariaLabel"],"aria-label":q["controls.zoomOut.ariaLabel"],disabled:L,children:nu.jsx(mp,{})})]}),f&&nu.jsx(wA,{className:"react-flow__controls-fitview",onClick:E,title:q["controls.fitView.ariaLabel"],"aria-label":q["controls.fitView.ariaLabel"],children:nu.jsx(Dp,{})}),r&&nu.jsx(wA,{className:"react-flow__controls-interactive",onClick:m,title:q["controls.interactive.ariaLabel"],"aria-label":q["controls.interactive.ariaLabel"],children:W?nu.jsx(Sp,{}):nu.jsx(pp,{})}),A]})}GW.displayName="Controls";var zW=tu.memo(GW);function Yp({id:u,x:l,y:f,width:r,height:n,style:i,color:t,strokeColor:y,strokeWidth:c,className:$,borderRadius:A,shapeRendering:j,selected:F,onClick:J}){let{background:Q,backgroundColor:W}=i||{},L=t||Q||W;return nu.jsx("rect",{className:Rl(["react-flow__minimap-node",{selected:F},$]),x:l,y:f,rx:A,ry:A,width:r,height:n,style:{fill:L,stroke:y,strokeWidth:c},shapeRendering:j,onClick:J?(U)=>J(U,u):void 0})}var Pp=tu.memo(Yp),Cp=(u)=>u.nodes.map((l)=>l.id),m9=(u)=>u instanceof Function?u:()=>u;function Mp({nodeStrokeColor:u,nodeColor:l,nodeClassName:f="",nodeBorderRadius:r=5,nodeStrokeWidth:n,nodeComponent:i=Pp,onClick:t}){let y=il(Cp,El),c=m9(l),$=m9(u),A=m9(f),j=typeof window>"u"||!!window.chrome?"crispEdges":"geometricPrecision";return nu.jsx(nu.Fragment,{children:y.map((F)=>nu.jsx(xp,{id:F,nodeColorFunc:c,nodeStrokeColorFunc:$,nodeClassNameFunc:A,nodeBorderRadius:r,nodeStrokeWidth:n,NodeComponent:i,onClick:t,shapeRendering:j},F))})}function Rp({id:u,nodeColorFunc:l,nodeStrokeColorFunc:f,nodeClassNameFunc:r,nodeBorderRadius:n,nodeStrokeWidth:i,shapeRendering:t,NodeComponent:y,onClick:c}){let{node:$,x:A,y:j,width:F,height:J}=il((Q)=>{let W=Q.nodeLookup.get(u);if(!W)return{node:void 0,x:0,y:0,width:0,height:0};let L=W.internals.userNode,{x:U,y:q}=W.internals.positionAbsolute,{width:N,height:w}=qn(L);return{node:L,x:U,y:q,width:N,height:w}},El);if(!$||$.hidden||!Q9($))return null;return nu.jsx(y,{x:A,y:j,width:F,height:J,style:$.style,selected:!!$.selected,className:r($),color:l($),borderRadius:n,strokeColor:f($),strokeWidth:i,shapeRendering:t,onClick:c,id:$.id})}var xp=tu.memo(Rp),hp=tu.memo(Mp),bp=200,vp=150,kp=(u)=>!u.hidden,Ip=(u)=>{let l={x:-u.transform[0]/u.transform[2],y:-u.transform[1]/u.transform[2],width:u.width/u.transform[2],height:u.height/u.transform[2]};return{viewBB:l,boundingRect:u.nodeLookup.size>0?F9(Qy(u.nodeLookup,{filter:kp}),l):l,rfId:u.rfId,panZoom:u.panZoom,translateExtent:u.translateExtent,flowWidth:u.width,flowHeight:u.height,ariaLabelConfig:u.ariaLabelConfig}},gp="react-flow__minimap-desc";function EW({style:u,className:l,nodeStrokeColor:f,nodeColor:r,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:t,nodeComponent:y,bgColor:c,maskColor:$,maskStrokeColor:A,maskStrokeWidth:j,position:F="bottom-right",onClick:J,onNodeClick:Q,pannable:W=!1,zoomable:L=!1,ariaLabel:U,inversePan:q,zoomStep:N=1,offsetScale:w=5}){let G=Zl(),Z=tu.useRef(null),{boundingRect:H,viewBB:E,rfId:m,panZoom:S,translateExtent:B,flowWidth:D,flowHeight:X,ariaLabelConfig:O}=il(Ip,El),Y=u?.width??bp,p=u?.height??vp,v=H.width/Y,z=H.height/p,P=Math.max(v,z),k=P*Y,I=P*p,b=w*P,d=H.x-(k-H.width)/2-b,s=H.y-(I-H.height)/2-b,h=k+b*2,lu=I+b*2,cu=`${gp}-${m}`,_u=tu.useRef(0),Fu=tu.useRef();_u.current=P,tu.useEffect(()=>{if(Z.current&&S)return Fu.current=rw({domNode:Z.current,panZoom:S,getTransform:()=>G.getState().transform,getViewScale:()=>_u.current}),()=>{Fu.current?.destroy()}},[S]),tu.useEffect(()=>{Fu.current?.update({translateExtent:B,width:D,height:X,inversePan:q,pannable:W,zoomStep:N,zoomable:L})},[W,L,q,N,B,D,X]);let zu=J?(e)=>{let[uu,Gu]=Fu.current?.pointer(e)||[0,0];J(e,{x:uu,y:Gu})}:void 0,Wu=Q?tu.useCallback((e,uu)=>{let Gu=G.getState().nodeLookup.get(uu).internals.userNode;Q(e,Gu)},[]):void 0,C=U??O["minimap.ariaLabel"];return nu.jsx(TA,{position:F,style:{...u,"--xy-minimap-background-color-props":typeof c==="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof $==="string"?$:void 0,"--xy-minimap-mask-stroke-color-props":typeof A==="string"?A:void 0,"--xy-minimap-mask-stroke-width-props":typeof j==="number"?j*P:void 0,"--xy-minimap-node-background-color-props":typeof r==="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof f==="string"?f:void 0,"--xy-minimap-node-stroke-width-props":typeof t==="number"?t:void 0},className:Rl(["react-flow__minimap",l]),"data-testid":"rf__minimap",children:nu.jsxs("svg",{width:Y,height:p,viewBox:`${d} ${s} ${h} ${lu}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":cu,ref:Z,onClick:zu,children:[C&&nu.jsx("title",{id:cu,children:C}),nu.jsx(hp,{onClick:Wu,nodeColor:r,nodeStrokeColor:f,nodeBorderRadius:i,nodeClassName:n,nodeStrokeWidth:t,nodeComponent:y}),nu.jsx("path",{className:"react-flow__minimap-mask",d:`M${d-b},${s-b}h${h+b*2}v${lu+b*2}h${-h-b*2}z - M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}EW.displayName="MiniMap";var zv=tu.memo(EW),sp=(u)=>(l)=>u?`${Math.max(1/l.transform[2],1)}`:void 0,ap={[b0.Line]:"right",[b0.Handle]:"bottom-right"};function op({nodeId:u,position:l,variant:f=b0.Handle,className:r,style:n=void 0,children:i,color:t,minWidth:y=10,minHeight:c=10,maxWidth:$=Number.MAX_VALUE,maxHeight:A=Number.MAX_VALUE,keepAspectRatio:j=!1,resizeDirection:F,autoScale:J=!0,shouldResize:Q,onResizeStart:W,onResize:L,onResizeEnd:U}){let q=lW(),N=typeof u==="string"?u:q,w=Zl(),G=tu.useRef(null),Z=f===b0.Handle,H=il(tu.useCallback(sp(Z&&J),[Z,J]),El),E=tu.useRef(null),m=l??ap[f];tu.useEffect(()=>{if(!G.current||!N)return;if(!E.current)E.current=cw({domNode:G.current,nodeId:N,getStoreItems:()=>{let{nodeLookup:B,transform:D,snapGrid:X,snapToGrid:O,nodeOrigin:Y,domNode:p}=w.getState();return{nodeLookup:B,transform:D,snapGrid:X,snapToGrid:O,nodeOrigin:Y,paneDomNode:p}},onChange:(B,D)=>{let{triggerNodeChanges:X,nodeLookup:O,parentLookup:Y,nodeOrigin:p}=w.getState(),v=[],z={x:B.x,y:B.y},P=O.get(N);if(P&&P.expandParent&&P.parentId){let k=P.origin??p,I=B.width??P.measured.width??0,b=B.height??P.measured.height??0,d={id:P.id,parentId:P.parentId,rect:{width:I,height:b,...N9({x:B.x??P.position.x,y:B.y??P.position.y},{width:I,height:b},P.parentId,O,k)}},s=UA([d],O,Y,p);v.push(...s),z.x=B.x?Math.max(k[0]*I,B.x):void 0,z.y=B.y?Math.max(k[1]*b,B.y):void 0}if(z.x!==void 0&&z.y!==void 0){let k={id:N,type:"position",position:{...z}};v.push(k)}if(B.width!==void 0&&B.height!==void 0){let I={id:N,type:"dimensions",resizing:!0,setAttributes:!F?!0:F==="horizontal"?"width":"height",dimensions:{width:B.width,height:B.height}};v.push(I)}for(let k of D){let I={...k,type:"position"};v.push(I)}X(v)},onEnd:({width:B,height:D})=>{let X={id:N,type:"dimensions",resizing:!1,dimensions:{width:B,height:D}};w.getState().triggerNodeChanges([X])}});return E.current.update({controlPosition:m,boundaries:{minWidth:y,minHeight:c,maxWidth:$,maxHeight:A},keepAspectRatio:j,resizeDirection:F,onResizeStart:W,onResize:L,onResizeEnd:U,shouldResize:Q}),()=>{E.current?.destroy()}},[m,y,c,$,A,j,W,L,U,Q]);let S=m.split("-");return nu.jsx("div",{className:Rl(["react-flow__resize-control","nodrag",...S,f,r]),ref:G,style:{...n,scale:H,...t&&{[Z?"backgroundColor":"borderColor"]:t}},children:i})}var Ev=tu.memo(op);var K=s0.default.createElement,{useEffect:Ln}=s0.default,ef=s0.default.useState,g0=s0.default.useRef,Ic=[{id:"in-left",side:"left",position:Ku.Left,style:{top:"50%"}},{id:"in-top-left",side:"top",slot:"left",slotIndex:-1,position:Ku.Top,style:{left:"28%"}},{id:"in-top-mid",side:"top",slot:"mid",slotIndex:0,position:Ku.Top,style:{left:"50%"}},{id:"in-top-right",side:"top",slot:"right",slotIndex:1,position:Ku.Top,style:{left:"72%"}},{id:"in-bottom-left",side:"bottom",slot:"left",slotIndex:-1,position:Ku.Bottom,style:{left:"28%"}},{id:"in-bottom-mid",side:"bottom",slot:"mid",slotIndex:0,position:Ku.Bottom,style:{left:"50%"}},{id:"in-bottom-right",side:"bottom",slot:"right",slotIndex:1,position:Ku.Bottom,style:{left:"72%"}}],bc=[{id:"out-right",position:Ku.Right,style:{top:"50%"}}],OW=["#4eb7a8","#d7a13a","#69aee8","#e0835f","#b7d86b","#d98bd2","#5fc6bf"],zy=236,Ey=88,ZW=15000,dp=10,Y9=96,wn=72,P9=64,HW=12;function GA(){return typeof document>"u"||document.visibilityState!=="hidden"}function BW(u,l){let f=Number.parseFloat(String(u||""));return Number.isFinite(f)?f/100:l}function ep(u,l,f){let r=String(u.side||"");if(r!=="top"&&r!=="bottom")return 0;let n=Number(u.slotIndex||0),i=r==="top"?"in-top-mid":"in-bottom-mid",t=l.get(u.id)||0,y=l.get(i)||0;if(n===0)return y===0?-26:28+t*74;let c=f===0?Math.abs(n)*2:Math.sign(f)===Math.sign(n)?-3:3;if(y>0&&t===0)return-14+c;return 8+t*74+c}function zA(u){let l=u.filter((i,t)=>{let y=u[t-1];return!y||Math.abs(y.x-i.x)>0.5||Math.abs(y.y-i.y)>0.5});if(l.length<2)return"";let f=`M ${l[0].x},${l[0].y}`,r=l[0];for(let i=1;i<l.length-1;i+=1){let t=l[i-1],y=l[i],c=l[i+1],$=Math.hypot(y.x-t.x,y.y-t.y),A=Math.hypot(c.x-y.x,c.y-y.y),j=Math.min(64,$*0.42,A*0.42);if(j<2){f+=` L ${y.x},${y.y}`,r=y;continue}let F={x:y.x+(t.x-y.x)/$*j,y:y.y+(t.y-y.y)/$*j},J={x:y.x+(c.x-y.x)/A*j,y:y.y+(c.y-y.y)/A*j};if(Math.abs(F.x-r.x)>0.5||Math.abs(F.y-r.y)>0.5)f+=` L ${F.x},${F.y}`;f+=` Q ${y.x},${y.y} ${J.x},${J.y}`,r=J}let n=l[l.length-1];return`${f} L ${n.x},${n.y}`}function gW(u,l,f,r,n,i,t=""){let y=f>=u,c=Math.max(1,Math.abs(f-u)),$=Math.abs(r-l),A=Math.max(34,Math.min(118,c*0.26)),j=Math.min(280,Math.abs(i));if(y&&n===Ku.Left&&j<4&&$<28&&c<420)return`M ${u},${l} C ${u+A},${l} ${f-A},${r} ${f},${r}`;if(y&&n===Ku.Left&&(t==="direct-forward-left"||c<=260&&$<=210)){let U=Math.max(42,Math.min(140,c*0.48)),q=Math.max(-28,Math.min(28,i*0.18));return`M ${u},${l} C ${u+U},${l+q} ${f-U},${r} ${f},${r}`}if(y){let U=u+A;if(n===Ku.Top||n===Ku.Bottom){let w=n===Ku.Top?-1:1,G=r+w*(54+j*0.42);return zA([{x:u,y:l},{x:U,y:l},{x:U+Math.min(120,c*0.18),y:G},{x:f,y:G},{x:f,y:r+w*34},{x:f,y:r}])}let q=f-A,N=(l+r)/2+i;return zA([{x:u,y:l},{x:U,y:l},{x:U+Math.min(110,c*0.16),y:N},{x:q-Math.min(90,c*0.12),y:N},{x:q,y:r},{x:f,y:r}])}let Q=n===Ku.Bottom?1:n===Ku.Top?-1:i>=0?1:-1,W=Math.max(u,f)+92+Math.min(180,j*0.52),L=Q<0?Math.min(l,r)-84-j*0.62:Math.max(l,r)+84+j*0.62;if(n===Ku.Top||n===Ku.Bottom)return zA([{x:u,y:l},{x:u+A,y:l},{x:W,y:L},{x:f,y:L},{x:f,y:r+Q*38},{x:f,y:r}]);return zA([{x:u,y:l},{x:u+A,y:l},{x:W,y:L},{x:f-A,y:L},{x:f-A,y:r},{x:f,y:r}])}function uS({data:u}){return K("div",{className:"pipeline-flow-node-body"},Ic.map((l)=>K(di,{key:l.id,id:l.id,type:"target",position:l.position,isConnectable:!1,className:`pipeline-flow-handle input ${l.side} slot-${l.slot||"mid"}`,style:l.style})),bc.map((l)=>K(di,{key:l.id,id:l.id,type:"source",position:l.position,isConnectable:!1,className:"pipeline-flow-handle output right",style:l.style})),u?.label)}function lS({id:u,sourceX:l,sourceY:f,targetX:r,targetY:n,targetPosition:i,markerEnd:t,markerStart:y,style:c,data:$}){let A=Number($?.laneOffset||0),j=gW(l,f,r,n,i,A,String($?.routeMode||""));return K(Ky,{id:u,path:j,markerEnd:t,markerStart:y,style:c,interactionWidth:28})}var fS={pipelineCurve:lS},rS={pipelineNode:uS};function HA(u){if(!u)return"--";let l=new Date(u);if(Number.isNaN(l.getTime()))return"--";return yl(l)}function mr(u){let l=Number(u);if(!Number.isFinite(l)||l<0)return"--";let f=Math.round(l/1000);if(f<60)return`${f}s`;if(f<3600)return`${Math.floor(f/60)}m ${f%60}s`;return`${Math.floor(f/3600)}h ${Math.floor(f%3600/60)}m`}function C9(u){let l=Number(u);if(!Number.isFinite(l))return"--";return l.toLocaleString("zh-CN")}function VW(u){let l=Number(u);if(!Number.isFinite(l))return"--";return`${Math.round(Math.max(0,Math.min(1,l))*100)}%`}function pu(u){return typeof u==="object"&&u!==null&&!Array.isArray(u)}function Du(u){return Array.isArray(u)?u:[]}function su(u){if(!u)return null;let l=new Date(u);return Number.isNaN(l.getTime())?null:l.getTime()}function gc(u){return Number.isFinite(Number(u))?new Date(Number(u)).toISOString():""}function oc(...u){for(let l of u){let f=su(l);if(f!==null)return new Date(f).toISOString()}return""}function u7(...u){let l=u.map(su).filter((f)=>f!==null);return l.length>0?new Date(Math.max(...l)).toISOString():""}function l7(u){return["succeeded","failed","skipped","cancelled","canceled","completed"].includes(String(u||"").toLowerCase())}function sW(u){let l=dW(u).toLowerCase();return["running","active","in-progress","in_progress"].includes(l)}function mW(u,l="status"){return u.reduce((f,r)=>{let n=String(r?.[l]||"unknown").toLowerCase();return f[n]=(f[n]||0)+1,f},{})}function aW(u){if(!u||typeof u!=="string")return null;try{let l=JSON.parse(u);return pu(l)?l:null}catch{return null}}function M9(u){let l=u.map(aW).filter((i)=>Boolean(i)),f=l.flatMap((i)=>[i.timestamp,i.createdAt,i.updatedAt]).filter(Boolean),r=u7(...f),n=Array.from(new Set(l.map((i)=>String(i.event||i.action||i.type||"")).filter(Boolean))).slice(0,3);return{total:u.length,parsed:l.length,lastAt:r,eventKinds:n}}function BA(u){if(u===null||u===void 0)return"--";if(typeof u==="boolean")return u?"是":"否";if(typeof u==="number")return String(u);if(typeof u==="string")return u.length>80?`${u.slice(0,77)}...`:u;if(Array.isArray(u))return`${u.length} 项`;if(typeof u==="object")return`${Object.keys(u).length} 字段`;return String(u)}function oW(u,l=280){if(u===null||u===void 0)return"";let r=(typeof u==="string"?u:String(u)).replace(/\r\n/gu,` -`).trim();return r.length>l?`${r.slice(0,Math.max(0,l-1))}...`:r}function dW(u){if(typeof u==="string")return u;if(pu(u))return String(u.status||u.state||u.phase||"unknown");return"unknown"}function nS(u){return u.filter((l)=>l&&l.value!==void 0&&l.value!==null&&String(l.value)!=="")}function k9({items:u}){let l=nS(Du(u));return K("div",{className:"pipeline-kv-grid"},l.map((f)=>K("span",{key:f.label},K("b",null,f.label),K("span",null,f.value))))}function f7({items:u}){let l=Du(u).map((f)=>String(f||"")).filter(Boolean);if(l.length===0)return null;return K("div",{className:"pipeline-chip-row"},l.map((f,r)=>K("span",{key:`${r}-${f}`},f)))}function I9(u,l){let f=String(l?.procedureRunId||""),r=Du(u?.procedureRuns);return r.find((n)=>String(Dr(n))===f)||r.at(-1)||null}function iS(u,l){let f=String(l||"");if(!f)return null;return Du(u?.procedureRuns).find((r)=>Dr(r)===f)||null}function R9(u){return Du(u?.attempts).length}function DW(u){return Du(u?.attempts).reduce((l,f)=>l+YA(f).length,0)}function YA(u){return Du(u?.opencodeMessages?.steps).filter(pu)}function eW(u){let l=String(u?.status||"").toLowerCase();if(["error","failed","failure"].includes(l))return"failed";if(["completed","succeeded","success"].includes(l))return"succeeded";if(["running","started","in_progress"].includes(l))return"running";return"unknown"}function tS(u,l){let f=s9(u.map((i)=>i?.agent)).slice(0,3),r=s9(u.map((i)=>i?.model)).slice(0,3),n=l.length<=2?l.map((i)=>`session ${i}`):[`sessions ${l.length}`,...l.slice(0,2).map((i)=>`session ${i}`)];return[...f.map((i)=>`agent ${i}`),...r.map((i)=>`model ${i}`),...n]}function vc(u,l=0){return String(u?.messageId||u?.index||"")||`step-${l}`}function yS({steps:u,sessionIds:l,sessionFacts:f,matchedStepKey:r}){let n=Du(u),i=n.findIndex((L,U)=>vc(L,U)===r),t=i>=0?n[i]:null,y=n.flatMap((L)=>[su(L?.createdAt),su(L?.completedAt)]).filter((L)=>L!==null),c=y.length>0?Math.min(...y):null,$=y.length>0?Math.max(...y):null,A=c!==null&&$!==null?Math.max(0,$-c):null,j=n.reduce((L,U)=>L+Du(U?.parts).filter((q)=>String(q?.type||"").toLowerCase()==="tool").length,0),F=n.reduce((L,U)=>L+Du(U?.parts).filter((q)=>["text","reasoning"].includes(String(q?.type||"").toLowerCase())).length,0),J=n.reduce((L,U)=>L+Du(U?.parts).filter((q)=>String(q?.type||"").toLowerCase()==="tool"&&eW(q)==="failed").length,0),Q=[`${n.length} steps`,`${l.length} sessions`,`${F} messages`,`${j} tools`,A!==null?`duration ${mr(A)}`:"",J>0?`${J} failed tools`:""].filter(Boolean),W=t?[`Step ${t?.index??i+1}`,String(t?.role||"role --"),t?.model?`model ${t.model}`:"",t?.finish?`finish ${t.finish}`:"",t?.durationMs!==void 0&&t?.durationMs!==null?`duration ${mr(t.durationMs)}`:""].filter(Boolean):[];return K("section",{className:"pipeline-trace-timeline","data-testid":"pipeline-step-timeline"},K("div",{className:"pipeline-trace-head"},K("div",null,K("b",null,"OpenCode Trace"),K("span",null,"Trace 使用 Code Queue 统一样式展示完整 agent loop;Pipeline 旧 step/message/tool 卡片样式已废弃。")),K("div",{className:"pipeline-trace-session-head","data-testid":"pipeline-step-timeline-session"},K("span",null,Q.join(" / ")||"Trace"),f.length>0?K(f7,{items:f}):null)),t?K("div",{className:"pipeline-trace-focus","data-testid":"pipeline-trace-matched-step"},K("span",{className:"codex-output-channel"},"Matched"),K("strong",null,`Gantt selection -> ${W.join(" / ")}`),K("time",null,`${HA(t?.createdAt)} -> ${HA(t?.completedAt)}`)):null,K(s$,{port:UQ,input:n,className:"codex-transcript pipeline-trace",testId:"pipeline-opencode-step-trace",emptyText:"暂无 OpenCode Trace 输出",keepRecentToolCalls:3}))}function g9(u){return Du(u).flatMap((l)=>{if(pu(l))return[l];let f=aW(l);return f?[f]:[]})}function un(u){return String(u?.event||u?.action||u?.requestedAction||u?.type||"").toLowerCase()}function Gy(u){return oc(u?.timestamp,u?.createdAt,u?.updatedAt,u?.startedAt,u?.finishedAt)}function cS(u){return su(Gy(u))}function PA(u){return String(u?.attempt||u?.id||"")}function s9(u){let l=new Set,f=[];for(let r of u){let n=String(r||"");if(!n||l.has(n))continue;l.add(n),f.push(n)}return f}function pW(u){switch(String(u||"").toLowerCase()){case"monitor":return"monitor";case"webui":return"webui";case"cli":return"cli";case"system":return"runner";default:return String(u||"--")}}function ei(u){return String(u?.requestedAction||u?.action||"").toLowerCase()}function kc(u){switch(ei(u)){case"guide":return"引导";case"modify":return"修改";case"approve":return"审核通过";case"restart":return"重启";case"redo":return"重做";default:return String(u?.requestedAction||u?.action||"控制")}}function SW(u){switch(un(u)){case"initial-prompt-delivered":return"初始 prompt";case"append-prompt-delivered":return"追加 prompt";case"append-prompt-queued":return"追加 prompt 已排队";case"monitor-prompt-delivered":return"Monitor prompt";case"node-long-running-observation":return"长任务观察";case"node-finished":return"节点完成";case"oa-policy-downstream-evaluated":return"OA 下游策略";case"control-command-queued":return`${kc(u)} 已发起`;case"control-command-applied":return`${kc(u)} 已生效`;case"control-command-ignored":return`${kc(u)} 已忽略`;default:return String(u?.event||u?.action||u?.requestedAction||"event")}}function XW(u){return oW(u?.promptPreview||u?.reasonPreview||u?.prompt||u?.reason||"",240)}function _S(u){let l=String(u?.prompt||""),f=String(u?.reason||u?.restartReason||""),r=l?"":String(u?.promptPreview||""),n=f?"":String(u?.reasonPreview||"");return[l||r?{label:l?"prompt":"prompt preview",value:l||r}:null,f||n?{label:f?"reason":"reason preview",value:f||n}:null,Du(u?.resetNodeIds).length>0?{label:"reset nodes",value:Du(u.resetNodeIds).join(", ")}:null,Du(u?.runningResetNodeIds).length>0?{label:"interrupted running nodes",value:Du(u.runningResetNodeIds).join(", ")}:null,Du(u?.interruptedProcedureRunIds).length>0?{label:"interrupted procedures",value:Du(u.interruptedProcedureRunIds).join(", ")}:null,u?.interruptedProcedureRunId?{label:"interrupted procedure",value:String(u.interruptedProcedureRunId)}:null].filter(Boolean)}function x9(u){let l=YA(u),f=l.map((c)=>su(c?.createdAt)).filter((c)=>c!==null),r=l.map((c)=>su(c?.completedAt)??su(c?.createdAt)).filter((c)=>c!==null),n=g9(u?.controlEventRecords).map((c)=>cS(c)).filter((c)=>c!==null),i=Du(u?.assistantOutputs).map((c)=>su(c?.updatedAt)).filter((c)=>c!==null),t=f[0]??n[0]??i[0]??null,y=r.at(-1)??n.at(-1)??i.at(-1)??t;return{startMs:t,endMs:y}}function $S(u,l,f,r,n=""){let i=Du(u?.procedureRuns).filter((y)=>CA(y,l)===f);if(i.length===0)return null;if(n){let y=i.find((c)=>Dr(c)===n);if(y)return y}if(r===null)return i.at(-1)||null;let t=i.find((y)=>{let c=su(EA(y,u)),$=su(OA(y,u))??c;return c!==null&&$!==null&&r>=c-1000&&r<=$+1000});if(t)return t;return i.slice().sort((y,c)=>{let $=su(EA(y,u))??r,A=su(OA(y,u))??$,j=su(EA(c,u))??r,F=su(OA(c,u))??j,J=Math.min(Math.abs($-r),Math.abs(A-r)),Q=Math.min(Math.abs(j-r),Math.abs(F-r));return J-Q})[0]||null}function uL(u,l){let f=Du(u?.attempts).filter(pu);if(f.length===0)return null;let r=String(l?.attempt||"");if(r){let t=f.find((y)=>PA(y)===r);if(t)return t}let n=Number.isFinite(Number(l?.ms))?Number(l.ms):null;if(n===null)return f.at(-1)||null;let i=f.find((t)=>{let y=x9(t);return Number.isFinite(y.startMs)&&Number.isFinite(y.endMs)&&n>=Number(y.startMs)-1000&&n<=Number(y.endMs)+1000});if(i)return i;return f.slice().sort((t,y)=>{let c=x9(t),$=x9(y),A=Math.min(Math.abs(Number(c.startMs??n)-n),Math.abs(Number(c.endMs??n)-n)),j=Math.min(Math.abs(Number($.startMs??n)-n),Math.abs(Number($.endMs??n)-n));return A-j})[0]||f.at(-1)||null}function lL(u,l){let f=YA(u);if(f.length===0)return{step:null,stepIndex:-1,stepKey:""};if(l===null){let i=f[0];return{step:i,stepIndex:0,stepKey:vc(i,0)}}for(let i=0;i<f.length;i+=1){let t=f[i],y=su(t?.createdAt)??su(t?.completedAt),c=su(t?.completedAt)??y;if(y!==null&&c!==null&&l>=y-1000&&l<=c+1000)return{step:t,stepIndex:i,stepKey:vc(t,i)}}let r=f.findIndex((i)=>{let t=su(i?.createdAt)??su(i?.completedAt);return t!==null&&t>=l});if(r>=0){let i=f[r];return{step:i,stepIndex:r,stepKey:vc(i,r)}}let n=Math.max(0,f.length-1);return{step:f[n],stepIndex:n,stepKey:vc(f[n],n)}}function AS(u,l){let f=String(l?.runId||u?.runId||"");if(String(l?.mode||"")==="interval"){let $=l?.interval||{},A=I9(u,$)||$.raw||{};return{mode:"interval",runId:f,interval:$,marker:null,nodeId:String($?.nodeId||CA(A,f)||""),procedure:A,attempt:null,matchedStep:null,matchedStepIndex:-1,matchedStepKey:""}}let r=pu(l?.marker)?l.marker:{},n=Number.isFinite(Number(r?.ms))?Number(r.ms):null,i=String(r?.nodeId||""),t=i?$S(u,f,i,n,String(r?.procedureRunId||"")):null,y=t?uL(t,r):null,c=y?lL(y,n):{step:null,stepIndex:-1,stepKey:""};return{mode:"event",runId:f,interval:null,marker:r,nodeId:i,procedure:t,attempt:y,matchedStep:c.step,matchedStepIndex:c.stepIndex,matchedStepKey:c.stepKey}}function jS({procedure:u,matchedStepKey:l="",matchedAttemptId:f=""}){let r=Du(u?.attempts);if(r.length===0)return K(Nr,{title:"暂无 attempt 详情",text:"当前 procedure 还没有可展示的 attempt / OpenCode Trace;若刚点击甘特线,请等待 node 详情抓取完成。"});return r.map((n,i)=>{let t=n?.opencodeMessages||{},y=YA(n),c=Du(t.sessionIds).map((F)=>String(F)).filter(Boolean),$=tS(y,c),A=PA(n)||`attempt-${i+1}`,j=y.reduce((F,J)=>F+Du(J?.parts).filter((Q)=>String(Q?.type||"").toLowerCase()==="tool"&&eW(Q)==="failed").length,0);return K("article",{key:A,className:`pipeline-attempt-card ${f===A?"matched":""}`},K("div",{className:"pipeline-attempt-head"},K("div",null,K("strong",null,A),K("span",null,t.source||"opencode")),K("div",{className:"pipeline-attempt-badges"},K("span",null,`${y.length} steps`),K("span",null,`${t.toolCallCount??"--"} tools`),j>0?K("span",{className:"danger"},`${j} failed`):null)),K(k9,{items:[{label:"messages",value:t.messageCount??"--"},{label:"steps",value:t.stepCount??"--"},{label:"tools",value:t.toolCallCount??"--"},{label:"updated",value:wu(t.updatedAt)},{label:"sessions",value:c.join(", ")||"--"}]}),y.length===0?K("p",{className:"muted paragraph"},"当前 attempt 尚未返回 OpenCode Trace;请确认 D601 pipeline-control 已重建并重新抓取。"):K(yS,{steps:y,sessionIds:c,sessionFacts:$,matchedStepKey:l}))})}function h9(u,l){return`${u}::${l}`}function VA(u,l,f){if(!pu(u))return null;return String(u.runId||"")===l&&String(u.nodeId||"")===f?u:null}function FS(u,l){let f=pu(u)?u:{};if(!pu(l))return f;let r=Du(l.attempts),n=Du(f.attempts);return{...f,...l,attempts:r.length>0?r:n}}function US(u,l,f,r){if(!VA(l,f,r))return u;let n=Du(l.procedureRuns),i=pu(u)?u:{};return{...i,...l,controlEvents:Du(l.controlEvents).length>0?l.controlEvents:i.controlEvents,procedureRuns:n.length>0?n:i.procedureRuns}}function JS({selection:u,runDetails:l,nodeDetails:f,nodeDetailsState:r,onRaw:n,onCollapse:i}){if(!u?.mode)return K("aside",{className:"pipeline-gantt-detail-panel empty","data-testid":"pipeline-gantt-detail-panel"},K("div",{className:"pipeline-gantt-detail-head"},K("div",null,K("span",{className:"panel-eyebrow"},"Gantt Detail"),K(rl,{title:"未选择元素",level:3})),K("button",{type:"button",className:"ghost-btn mini",onClick:i,"data-testid":"pipeline-gantt-sidebar-collapse"},"收起")),K(Nr,{title:"选择一条执行线或一个控制点",text:"点击甘特图中的 node 执行线、prompt 点或控制点,在这里查看结构化过程和 OpenCode step。"}));let t=String(u?.runId||""),y=String(u?.interval?.nodeId||u?.marker?.nodeId||""),c=l?.runId===t?l.details:null,$=VA(f,t,y),A=String(r?.runId||"")===t&&String(r?.nodeId||"")===y,j=US(c,$,t,y),F=(String(l?.runId||"")!==t||Boolean(l?.loading))&&!j,J=String(l?.runId||"")===t?String(l?.error||""):"",Q=A?String(r?.error||""):"",W=j?AS(j,u):null,L=W?.interval||u?.interval||null,U=W?.marker||u?.marker||null,q=String(L?.procedureRunId||U?.procedureRunId||""),N=$?iS($,q)||I9($,L||{procedureRunId:q}):null,w=W?.procedure||(j?I9(j,L||{procedureRunId:q}):null)||L?.raw||{};if(N&&(R9(w)===0||DW(N)>=DW(w)))w=FS(w,N);let G=W?.attempt||null,Z=String(W?.matchedStepKey||"");if(!G&&U&&R9(w)>0)G=uL(w,U),Z=String(lL(G,Number.isFinite(Number(U?.ms))?Number(U.ms):null).stepKey||"");let H=PA(G),E=R9(w)>0,m=A&&Boolean(r?.loading)&&!E,S=Boolean(F||m),B=[E?"":J,Q].filter(Boolean).join(" / "),D=A&&r?.fetchedAt?r.fetchedAt:l?.fetchedAt,X=dW(w?.status||L?.status||U?.status||U?.event),O=u?.mode==="event"?U?.label||SW(U?.raw||U)||"event":W?.nodeId||L?.nodeId||"node",Y=U?_S(U?.raw||U):[],p=U?[un(U?.raw||U)?`event ${un(U?.raw||U)}`:"",U?.promptEvent?`prompt ${U.promptEvent}`:"",U?.action?`action ${U.action}`:"",U?.sourceKind?`source ${pW(U.sourceKind)}`:"",U?.sourceNodeId?`from ${U.sourceNodeId}`:"",U?.targetNodeId?`to ${U.targetNodeId}`:"",U?.snapReason?`draw ${U.snapReason}`:""].filter(Boolean):[];return K("aside",{className:"pipeline-gantt-detail-panel","data-testid":"pipeline-gantt-detail-panel"},K("div",{className:"pipeline-gantt-detail-head"},K("div",null,K("span",{className:"panel-eyebrow"},u?.mode==="event"?"Gantt Event Detail":"Gantt Line Detail"),K(rl,{title:O,level:3,loading:S})),K("div",{className:"pipeline-gantt-detail-head-actions"},K(a0,{status:X},X),K("button",{type:"button",className:"ghost-btn mini",onClick:i,"data-testid":"pipeline-gantt-sidebar-collapse"},"收起"))),U?K("article",{className:"pipeline-event-card"},K("div",{className:"pipeline-event-card-head"},K("strong",null,U?.label||SW(U?.raw||U)),K(f7,{items:p})),K(k9,{items:[{label:"event time",value:wu(U?.timestampIso||U?.timestamp||"--")},U?.snapped?{label:"drawn time",value:wu(U?.renderedTimestampIso||U?.ms)}:null,{label:"node",value:U?.nodeId||"--"},{label:"procedure",value:U?.procedureRunId||Dr(w)||"--"},{label:"attempt",value:U?.attempt||H||"--"},{label:"source kind",value:U?.sourceKind?pW(U.sourceKind):"--"},{label:"source node",value:U?.sourceNodeId||"--"},{label:"target node",value:U?.targetNodeId||"--"},{label:"command",value:U?.commandId||U?.eventId||"--"},U?.snapReason?{label:"placement",value:U.snapReason}:null]}),Y.length>0?K("div",{className:"pipeline-event-blocks"},Y.map((v,z)=>K("section",{key:`${v.label}-${z}`,className:"pipeline-event-text-block"},K("b",null,v.label),K("p",null,v.value)))):null,XW(U?.raw||U)?K("p",{className:"pipeline-text-preview"},XW(U?.raw||U)):null):null,K(k9,{items:[{label:"epoch",value:t||L?.runId||"--"},{label:"node",value:W?.nodeId||L?.nodeId||U?.nodeId||"--"},{label:"procedure",value:L?.procedureRunId||U?.procedureRunId||Dr(w)||"--"},{label:"started",value:wu(L?.startedAt||w?.startedAt)},{label:"finished",value:wu(L?.finishedAt||w?.finishedAt)},{label:"duration",value:mr(L?.durationMs||w?.durationMs)},{label:"fetched",value:D?yl(D):"--"},W?.matchedStep?{label:"matched step",value:`Step ${W.matchedStep.index??W.matchedStepIndex+1}`}:null]}),K(nl,{error:B}),K("div",{className:"pipeline-gantt-detail-actions"},K(ln,{title:`Procedure ${L?.procedureRunId||U?.procedureRunId||W?.nodeId||"node"}`,data:w,onOpen:n,testId:"raw-pipeline-gantt-procedure"}),U?K(ln,{title:`Pipeline event ${U?.id||U?.commandId||U?.eventId||W?.nodeId||"event"}`,data:U?.raw||U,onOpen:n,testId:"raw-pipeline-gantt-event"}):null,j?K(ln,{title:`Pipeline run ${t||"--"}`,data:j,onOpen:n,testId:"raw-pipeline-gantt-node-details"}):null),!S&&!Dr(w)&&!U?K(Nr,{title:"暂无过程详情",text:"当前选择还没有可匹配的 procedure 运行记录。"}):null,!S&&Dr(w)?K(jS,{procedure:w,matchedStepKey:Z,matchedAttemptId:H}):null)}function QS({value:u}){let f=String(u||"--").split(/([_-])/u);return K(s0.default.Fragment,null,f.map((r,n)=>r==="-"||r==="_"?K(s0.default.Fragment,{key:n},r,K("wbr",null)):K(s0.default.Fragment,{key:n},r)))}async function k0(u,l={}){return Eu(u,{invalidJsonPrefix:"Pipeline 返回了无效 JSON",...l})}function a0({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return K("span",{className:`status-badge ${f}`},l||u||"unknown")}function Cf({label:u,value:l,hint:f,tone:r}){return K("article",{className:`metric-card ${r||""}`},K("div",{className:"metric-label"},u),K("div",{className:"metric-value"},l),K("div",{className:"metric-hint"},f))}function Wn({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return K("section",{className:`panel ${n||""}`},K("div",{className:"panel-head"},K("div",null,l?K("p",{className:"panel-eyebrow"},l):null,K(rl,{title:u,loading:i})),f?K("div",{className:"panel-actions"},f):null),K("div",{className:"panel-body"},r))}function ln({title:u,data:l,onOpen:f,testId:r}){return K("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function Vr({title:u,subtitle:l,facts:f,data:r,onRaw:n,testId:i}){let t=Du(f).map((y)=>String(y||"")).filter(Boolean);return K("article",{className:"pipeline-evidence-row"},K("div",{className:"pipeline-evidence-main"},K("strong",null,u),l?K("span",null,l):null),K("div",{className:"pipeline-evidence-facts"},t.map((y,c)=>K("span",{key:`${c}-${y.slice(0,16)}`},y))),r!==void 0?K(ln,{title:u,data:r,onOpen:n,testId:i}):null)}function Nr({title:u,text:l}){return K("div",{className:"empty-state"},K("strong",null,u),K("span",null,l))}function NS(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function qS(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function wS(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function WS(u){return{components:Array.isArray(u?.registry?.components)?u.registry.components:[],pipelines:Array.isArray(u?.pipelines)?u.pipelines:[],runs:Array.isArray(u?.runs)?u.runs:[]}}function YW(u,l,f){let r=u?._unidesk?.arrayLimits?.[l],n=Number(r?.originalLength);return Number.isFinite(n)?n:f}function fL(u){if(!u||typeof u!=="object"||Array.isArray(u))return"--";return`${u.componentClass||"--"}/${u.id||"--"}`}function mA(u){if(!u||typeof u!=="object"||Array.isArray(u))return"";let l=String(u.componentClass||"").trim(),f=String(u.id||"").trim();return l&&f?`${l}/${f}`:""}function r7(u){return u?.config&&typeof u.config==="object"&&!Array.isArray(u.config)?u.config:{}}function rL(u){let l=r7(u),f=Array.isArray(l.nodes)?l.nodes:Array.isArray(u?.nodes)?u.nodes:[],r=new Map;for(let t of f){let y=String(t?.id||t?.nodeId||"");if(y)r.set(y,{...t,id:y})}let n=n7(u),i=(t)=>{if(t&&!r.has(t))r.set(t,{id:t})};for(let t of i7(u))sc(t).forEach(i);for(let t of n)i(String(t?.from||t?.source||"")),i(String(t?.to||t?.target||""));return Array.from(r.values())}function n7(u){let l=r7(u);return Array.isArray(l.edges)?l.edges:Array.isArray(u?.edges)?u.edges:[]}function i7(u){let l=r7(u);return Array.isArray(l.topologicalBatches)?l.topologicalBatches:Array.isArray(u?.topologicalBatches)?u.topologicalBatches:[]}function LS(u){let l=new Map;for(let f of u){let r=mA(f);if(r)l.set(r,f);let n=Array.isArray(f?.refs)?f.refs:[];for(let i of n){let t=mA(i);if(t)l.set(t,f)}}return l}function PW(u,l){let f=l.get(mA(u?.componentRef));if(f)return f;let r=mA({componentClass:u?.kind,id:u?.id});return r?l.get(r)||null:null}function CW(u,l){let f=nL(u,l);return String(f?.status||"pending")}function nL(u,l){return(Array.isArray(u?.nodes)?u.nodes:[]).find((r)=>r?.nodeId===l||r?.id===l)||null}function TS(u){return u.reduce((l,f)=>{let r=String(f?.status||"unknown").toLowerCase();return l[r]=(l[r]||0)+1,l},{})}function KS(u){if(Array.isArray(u?.scorers))return u.scorers.filter(pu);if(Array.isArray(u?.summary?.scorers))return u.summary.scorers.filter(pu);if(Array.isArray(u?.artifact?.summary?.scorers))return u.artifact.summary.scorers.filter(pu);return[]}function GS(u){if(pu(u?.run))return u.run;if(pu(u?.runSummary))return u.runSummary;return null}function zS(u,l){if(!pu(u)&&!pu(l))return null;if(!pu(u))return l;if(!pu(l))return u;return{...u,...l,request:pu(u.request)||pu(l.request)?{...pu(u.request)?u.request:{},...pu(l.request)?l.request:{}}:l.request??u.request,artifact:pu(u.artifact)||pu(l.artifact)?{...pu(u.artifact)?u.artifact:{},...pu(l.artifact)?l.artifact:{}}:l.artifact??u.artifact,summary:pu(u.summary)||pu(l.summary)?{...pu(u.summary)?u.summary:{},...pu(l.summary)?l.summary:{}}:l.summary??u.summary}}function DA(u){let l=KS(u),f=l.find((A)=>pu(A?.score))||l[0]||null,r=pu(f?.score)?f.score:{},n=Number(r.passed),i=Number(r.total),t=Number(r.ratio),y=Number.isFinite(t)?t:Number.isFinite(n)&&Number.isFinite(i)&&i>0?n/i:null,c=y===null?null:Math.round(Math.max(0,Math.min(100,y<=1?y*100:y))),$=String(r.text||(Number.isFinite(n)&&Number.isFinite(i)?`${n}/${i}`:""));return{scorer:f,scorers:l,score:r,passed:Number.isFinite(n)?n:null,total:Number.isFinite(i)?i:null,percent:c,text:$}}function a9(u){let l=DA(u);return l.text||(l.scorers.length>0?String(l.scorer?.status||"pending"):"--")}function t7(u){let l=DA(u);if(l.total>0&&l.passed===l.total)return"succeeded";if(l.total>0&&l.passed>0)return"running";if(l.scorers.length>0)return"failed";return"pending"}function ES(u){return Array.isArray(u?.items)?u.items.filter(pu):[]}function OS({run:u}){let l=a9(u);return K("span",{className:`pipeline-score-badge ${t7(u)}`},`score ${l}`)}function ZS({run:u,onRaw:l}){let r=DA(u).scorers;if(!u)return K(Nr,{title:"暂无评分",text:"选择一个 epoch 后会显示 scorer 结果。"});if(r.length===0)return K("div",{className:"pipeline-score-empty"},K("strong",null,"评分器等待中"),K("span",null,"DAG 完成后,Pipeline control backend 会把 scorer summary 追加到 run artifact,并通过 UniDesk 显示。"));return K("div",{className:"pipeline-score-board","data-testid":"pipeline-score-board"},r.map((n,i)=>{let t=DA({scorers:[n]}),y=ES(n),c=t.percent??0;return K("article",{key:`${n.scorerId||n.component||i}`,className:`pipeline-score-card ${t7({scorers:[n]})}`},K("div",{className:"pipeline-score-head"},K("div",null,K("span",null,n.scorerId||n.component||"scorer"),K("strong",null,t.text||n.status||"--")),K(a0,{status:n.status||"unknown"},n.status||"unknown")),K("div",{className:"pipeline-score-meter","aria-label":`score ${c}%`},K("span",{style:{width:`${c}%`}})),K("div",{className:"pipeline-score-facts"},K("span",null,`${c}%`),K("span",null,n.component||"--"),K("span",null,n.applicationCheckoutRef||"--")),y.length>0?K("div",{className:"pipeline-score-items"},y.map(($)=>K("span",{key:`${$.id||$.filter}`,className:`pipeline-score-item ${String($.status||"").toLowerCase()}`,title:`${$.filter||"--"} / ran=${$.ran??"?"}`},K("b",null,$.id||"--"),K("small",null,$.status||"--")))):K("p",{className:"muted paragraph"},"当前 scorer 尚未返回 item 级结果。"),n.error?K("p",{className:"pipeline-score-error"},oW(n.error,360)):null,K("div",{className:"panel-actions inline-actions"},K(ln,{title:`Scorer ${n.scorerId||i}`,data:n,onOpen:l,testId:"raw-pipeline-score"})))}))}function HS(u){let l=u.reduce((f,r)=>{let n=String(r?.componentClass||"unknown");return f[n]=(f[n]||0)+1,f},{});return Object.entries(l).map(([f,r])=>({name:f,count:Number(r)})).sort((f,r)=>r.count-f.count||f.name.localeCompare(r.name))}function sc(u){if(Array.isArray(u))return u.map((l)=>typeof l==="string"?l:String(l?.id||l?.nodeId||"")).filter(Boolean);if(Array.isArray(u?.nodes))return sc(u.nodes);if(Array.isArray(u?.nodeIds))return sc(u.nodeIds);return[]}function BS(u){return pu(u?.instanceInputs?.monitor)?u.instanceInputs.monitor:{}}function iL(u,l){if(String(u?.kind||"").toLowerCase()!=="procedure")return!1;let f=BS(u);if(u?.instanceInputs?.monitorMode===!0||f.enabled===!0)return!0;let r=fL(u?.componentRef);return String(l?.id||l?.config?.id||r||"").toLowerCase().includes("monitor")}function VS(u){return u.filter((l)=>iL(l)).map((l)=>String(l?.id||"")).filter(Boolean)}function mS(u,l){if(l.length===0)return u;let f=new Set(l),r=l.filter((n)=>u.includes(n));if(r.length===0)return u;return[...r,...u.filter((n)=>!f.has(n))]}function DS(u,l){if(l.length===0)return u;let f=new Set(l),r=l.filter((i)=>u.some((t)=>t.includes(i)));if(r.length===0)return u;let n=u.map((i)=>i.filter((t)=>!f.has(t))).filter((i)=>i.length>0);return[r,...n]}function pS(u,l,f){let n=i7(u).map(sc).filter((F)=>F.length>0);if(n.length>0)return n;let i=l.map((F)=>String(F?.id||"")).filter(Boolean),t=new Set(i),y=new Map(i.map((F)=>[F,0])),c=new Map(i.map((F)=>[F,[]]));for(let F of f){let J=String(F?.from||F?.source||""),Q=String(F?.to||F?.target||"");if(!t.has(J)||!t.has(Q))continue;c.get(J)?.push(Q),y.set(Q,(y.get(Q)||0)+1)}let $=new Map,A=i.filter((F)=>(y.get(F)||0)===0);for(let F of A)$.set(F,0);while(A.length>0){let F=A.shift(),J=($.get(F)||0)+1;for(let Q of c.get(F)||[])if(y.set(Q,Math.max(0,(y.get(Q)||0)-1)),$.set(Q,Math.max($.get(Q)||0,J)),(y.get(Q)||0)===0)A.push(Q)}i.forEach((F)=>{if(!$.has(F))$.set(F,0)});let j=Math.max(0,...Array.from($.values()));return Array.from({length:j+1},(F,J)=>i.filter((Q)=>$.get(Q)===J)).filter((F)=>F.length>0)}function SS(u,l,f){let n=i7(u).map(sc).filter((y)=>y.length>0),i=n.length>0?n.flatMap((y)=>y):(()=>{let y=l.map((W)=>String(W?.id||"")).filter(Boolean),c=new Set(y),$=f.filter((W)=>String(W?.edgeType||"").toLowerCase()!=="rework"),A=new Map(y.map((W)=>[W,0])),j=new Map(y.map((W)=>[W,[]]));for(let W of $){let L=String(W?.from||W?.source||""),U=String(W?.to||W?.target||"");if(!c.has(L)||!c.has(U))continue;j.get(L)?.push(U),A.set(U,(A.get(U)||0)+1)}let F=new Map,J=y.filter((W)=>(A.get(W)||0)===0);for(let W of J)F.set(W,0);while(J.length>0){let W=J.shift(),L=(F.get(W)||0)+1;for(let U of j.get(W)||[])if(A.set(U,Math.max(0,(A.get(U)||0)-1)),F.set(U,Math.max(F.get(U)||0,L)),(A.get(U)||0)===0)J.push(U)}y.forEach((W)=>{if(!F.has(W))F.set(W,0)});let Q=Math.max(0,...Array.from(F.values()));return Array.from({length:Q+1},(W,L)=>y.filter((U)=>F.get(U)===L)).flatMap((W)=>W)})(),t=new Set(i);for(let y of l){let c=String(y?.id||"");if(!c||t.has(c))continue;i.push(c),t.add(c)}return mS(i,VS(l))}function xc(u){return`${u.source}->${u.target}-${u.index}`}function MW(u,l,f){let r=rL(u),n=n7(u),i=LS(f),t=new Map(r.map((X)=>[String(X?.id||""),X])),y=r.filter((X)=>iL(X,PW(X,i))).map((X)=>String(X?.id||"")).filter(Boolean),c=DS(pS(u,r,n),y),$=[],A=new Map,j=330,F=122;c.forEach((X,O)=>{let Y=X.length*122;X.forEach((p,v)=>{let z=t.get(p)||{id:p},P=PW(z,i),k=CW(l,p).toLowerCase(),I=String(z.kind||P?.componentClass||"node").toLowerCase(),b=fL(z.componentRef||P),d=String(P?.config?.version||P?.version||""),s=String(P?.config?.description||P?.description||""),h=v*122-Math.floor(Y/2);A.set(p,{column:O,row:v,y:h}),$.push({id:p,type:"pipelineNode",position:{x:O*330,y:h},data:{exportLabel:{id:p,kind:I,componentRef:b,componentVersion:d,componentDescription:s,status:k},label:K("div",{className:"flow-node-label"},K("strong",null,p),K("span",null,I),K("code",{title:s||b},d?`${b}@${d}`:b),K(a0,{status:k},k))},className:`pipeline-flow-node ${I} ${k}`})})});let J=n.flatMap((X,O)=>{let Y=String(X?.from||X?.source||""),p=String(X?.to||X?.target||"");if(!t.has(Y)||!t.has(p))return[];return[{source:Y,target:p,index:O,condition:X?.condition,edgeType:X?.edgeType}]}),Q=J.reduce((X,O)=>X.set(O.source,(X.get(O.source)||0)+1),new Map),W=J.reduce((X,O)=>X.set(O.target,(X.get(O.target)||0)+1),new Map),L=J.reduce((X,O)=>{let Y=`${O.source}->${O.target}`;return X.set(Y,(X.get(Y)||0)+1)},new Map),U=new Map,q=new Map,N=new Map,w=new Map,G=new Map,Z=new Map,H=J.reduce((X,O)=>{let Y=A.get(O.source),p=A.get(O.target),v=(p?.column||0)-(Y?.column||0);if(v<=0||String(O.edgeType||"").toLowerCase()==="rework"||v!==1)return X;let P=`${O.source}->column:${p?.column??""}`,k=X.get(P)||[];return k.push(O),X.set(P,k),X},new Map);for(let X of H.values()){if(X.length<2)continue;X.slice().sort((O,Y)=>{let p=A.get(O.target),v=A.get(Y.target);return(p?.y||0)-(v?.y||0)||O.index-Y.index}).forEach((O,Y,p)=>{Z.set(xc(O),{slot:Y-(p.length-1)/2,count:p.length})})}[...J].sort((X,O)=>{let Y=A.get(X.source),p=A.get(X.target),v=A.get(O.source),z=A.get(O.target),P=Math.abs((p?.column||0)-(Y?.column||0))*330+Math.abs((p?.y||0)-(Y?.y||0)),k=Math.abs((z?.column||0)-(v?.column||0))*330+Math.abs((z?.y||0)-(v?.y||0));return P-k||X.index-O.index}).forEach((X)=>{let O=A.get(X.source)||{column:0,row:0,y:0},Y=A.get(X.target)||{column:0,row:0,y:0},p=Y.column-O.column,v=Math.max(0,p),z=p<=0||String(X.edgeType||"").toLowerCase()==="rework",P=O.y-Y.y,k=W.get(X.target)||1,I=Z.has(xc(X)),b=!z&&v<=1&&(I||k===1),d=G.get(X.target)||new Map;G.set(X.target,d);let s=Ic.slice().sort((h,lu)=>{let cu=(Wu)=>{let C=String(Wu.side),e=0;if(z){if(C==="left")e+=86;if(C==="top")e+=Y.y<=0?-22:12;if(C==="bottom")e+=Y.y>=0?-22:12;if(Math.abs(Y.y)<12&&C!=="left")e+=X.index%2===0?C==="top"?-6:6:C==="bottom"?-6:6;return e}if(b){if(C==="left")e-=I?72:44;if(C!=="left")e+=I?72:44;return e+Math.abs(P)*0.02}if(C==="left")e+=v<=1?0:24;if(C==="top")e+=P<-36?-18:42;if(C==="bottom")e+=P>36?-18:42;if(v<=1&&Math.abs(P)<=82&&C!=="left")e+=38;if(v>1&&C!=="left")e-=10;return e},_u=O.y-Y.y,Fu=_u!==0?_u:X.index%2===0?-1:1,zu=(Wu)=>{let C=d.get(Wu.id)||0;return cu(Wu)+C*64+ep(Wu,d,Fu)};return zu(h)-zu(lu)||String(h.id).localeCompare(String(lu.id))})[0];d.set(s.id,(d.get(s.id)||0)+1),w.set(xc(X),s)});let m=J.map((X)=>{let O=CW(l,X.target).toLowerCase(),Y=`${X.source}->${X.target}`,p=U.get(X.source)||0,v=q.get(X.target)||0,z=N.get(Y)||0;U.set(X.source,p+1),q.set(X.target,v+1),N.set(Y,z+1);let P=p-((Q.get(X.source)||1)-1)/2,k=v-((W.get(X.target)||1)-1)/2,I=z-((L.get(Y)||1)-1)/2,b=A.get(X.source),d=A.get(X.target),s=(d?.column||0)-(b?.column||0),h=Math.max(1,Math.abs(s)),lu=s<=0||String(X.edgeType||"").toLowerCase()==="rework",cu=Math.abs((d?.y||0)-(b?.y||0)),_u=Z.get(xc(X)),Fu=!lu&&s===1&&(W.get(X.target)||0)>1,zu=_u?_u.slot:I*2+P+k*0.45,Wu=zu===0?X.index%2===0?-1:1:Math.sign(zu),C=w.get(xc(X))||Ic[1],e=C.side==="top"?-1:C.side==="bottom"?1:Wu,uu=lu||h>1||cu>96||Math.abs(zu)>0.2||C.side!=="left",Gu=lu?118+h*18:22+h*16,a=C.side==="left"?0:28,qu=uu?Math.max(-280,Math.min(280,e*Math.min(180,Gu+a+cu*0.22)+zu*28)):0,Zu=Math.max(0,Math.min(bc.length-1,Math.round(P+(bc.length-1)/2))),Bu=bc[Zu]||bc[1],gu=O==="succeeded"?"var(--accent-2)":O==="running"?"var(--accent)":O==="failed"?"var(--danger)":"rgba(129, 147, 159, 0.78)",ll=b?.column||0,Pu=d?.column||0,Nl=qu===0?0:Math.sign(qu),Qf=lu?`feedback:${ll}->${Pu}:${Nl}`:_u?`fanout:${ll}->${Pu}:${X.source}`:Fu?`fanin:${ll}->${Pu}:${X.target}`:C.side!=="left"||h>1?`corridor:${ll}->${Pu}:${C.side}:${Nl}:${Math.round(Math.abs(qu)/56)}`:"";return{id:`${X.source}->${X.target}-${X.index}`,source:X.source,target:X.target,sourceHandle:Bu.id,targetHandle:C.id,type:"pipelineCurve",zIndex:12,animated:O==="running",data:{baseEdgeColor:gu,laneOffset:qu,routeMode:_u&&C.side==="left"?"direct-forward-left":"",targetSide:C.side,isFeedback:lu,overlapGroup:Qf},targetStatus:O}}),S=m.reduce((X,O)=>{let Y=String(O.data?.overlapGroup||"");return Y?X.set(Y,(X.get(Y)||0)+1):X},new Map),B=new Map,D=m.map((X)=>{let O=String(X.targetStatus||"pending"),Y={...X};delete Y.targetStatus;let p=String(X.data?.overlapGroup||""),v=p?S.get(p)||0:0,z=v>1?B.get(p)||0:-1;if(v>1)B.set(p,z+1);let P=z>=0?OW[z%OW.length]:String(X.data.baseEdgeColor),k={stroke:P};if(X.data.isFeedback)k.strokeDasharray="9 7";return{...Y,data:{...X.data,edgeColor:P,overlapSlot:z,overlapCount:v},style:k,markerEnd:{type:x0.ArrowClosed,color:P},className:`pipeline-flow-edge ${O} ${X.data.isFeedback?"feedback":""} ${z>=0?"overlap-colored":""}`}});return{nodes:$,edges:D}}function ur(u){return String(u??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function RW(u){let l=String(u||"");if(l.includes("--accent-2"))return"#4eb7a8";if(l.includes("--accent"))return"#d7a13a";if(l.includes("--danger"))return"#cf6a54";return l.startsWith("#")?l:"#81939f"}function pA(u){return`arrow-${u.replace(/[^a-zA-Z0-9_-]+/g,"")}`}function tL(u,l="pipeline"){return String(u||l).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-|-$/g,"")||l}function xW(u,l){let f=u.position.x,r=u.position.y,n=Ic.find((i)=>i.id===l);if(n?.side==="top")return{x:f+zy*BW(n.style?.left,0.5),y:r,position:Ku.Top};if(n?.side==="bottom")return{x:f+zy*BW(n.style?.left,0.5),y:r+Ey,position:Ku.Bottom};return{x:f,y:r+Ey/2,position:Ku.Left}}function XS(u){return{x:u.position.x+zy,y:u.position.y+Ey/2}}function YS(u,l){let f=Math.min(...u.nodes.map((W)=>W.position.x),0)-220,r=Math.min(...u.nodes.map((W)=>W.position.y),0)-220,n=Math.max(...u.nodes.map((W)=>W.position.x+zy),1)+220,i=Math.max(...u.nodes.map((W)=>W.position.y+Ey),1)+220,t=Math.ceil(n-f),y=Math.ceil(i-r),c=new Map(u.nodes.map((W)=>[W.id,W])),$=u.edges.map((W)=>RW(W.data?.edgeColor||W.style?.stroke)),j=Array.from(new Set(["#4eb7a8","#d7a13a","#cf6a54","#81939f",...$])).map((W)=>`<marker id="${pA(W)}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="${W}"/></marker>`).join(""),F=u.edges.flatMap((W)=>{let L=c.get(W.source),U=c.get(W.target);if(!L||!U)return[];let q=XS(L),N=xW(U,String(W.targetHandle||"in-left")),w=gW(q.x,q.y,N.x,N.y,N.position,Number(W.data?.laneOffset||0),String(W.data?.routeMode||"")),G=RW(W.data?.edgeColor||W.style?.stroke),Z=W.data?.isFeedback?' stroke-dasharray="9 7"':"";return`<path d="${ur(w)}" fill="none" stroke="${G}" stroke-width="2.35" stroke-linecap="round" stroke-linejoin="round" opacity="0.82"${Z} marker-end="url(#${pA(G)})"/>`}).join(` -`),J=u.nodes.map((W)=>{let L=W.data?.exportLabel||{},U=String(L.status||"pending").toLowerCase(),q=U==="succeeded"?"#4eb7a8":U==="running"?"#d7a13a":U==="failed"?"#cf6a54":"#81939f",N=W.position.x,w=W.position.y,G=Ic.map((Z)=>{let H=xW(W,Z.id);if(Z.side==="top"||Z.side==="bottom")return`<rect x="${H.x-9}" y="${H.y-5}" width="18" height="10" rx="2" fill="#071016" stroke="#4eb7a8"/>`;return`<rect x="${H.x-5}" y="${H.y-9}" width="10" height="18" rx="2" fill="#071016" stroke="#4eb7a8"/>`}).join(` +`)),A=$.reduce((j,F)=>j.concat(...F),[]);return[$,A]}return[[],[]]},[l]);return yl.useEffect(()=>{let c=u?.target??sq,$=u?.actInsideInputWithModifier??!0;if(l!==null){let A=(U)=>{if(n.current=U.ctrlKey||U.metaKey||U.shiftKey||U.altKey,(!n.current||n.current&&!$)&&Y9(U))return!1;let W=gq(U.code,y);if(i.current.add(U[W]),kq(t,i.current,!1)){let L=U.composedPath?.()?.[0]||U.target,J=L?.nodeName==="BUTTON"||L?.nodeName==="A";if(u.preventDefault!==!1&&(n.current||!J))U.preventDefault();f(!0)}},j=(U)=>{let N=gq(U.code,y);if(kq(t,i.current,!0))f(!1),i.current.clear();else i.current.delete(U[N]);if(U.key==="Meta")i.current.clear();n.current=!1},F=()=>{i.current.clear(),f(!1)};return c?.addEventListener("keydown",A),c?.addEventListener("keyup",j),window.addEventListener("blur",F),window.addEventListener("contextmenu",F),()=>{c?.removeEventListener("keydown",A),c?.removeEventListener("keyup",j),window.removeEventListener("blur",F),window.removeEventListener("contextmenu",F)}}},[l,f]),r}function kq(l,u,r){return l.filter((f)=>r||f.length===u.size).some((f)=>f.every((n)=>u.has(n)))}function gq(l,u){return u.includes(l)?"code":"key"}var PD=()=>{let l=Zu();return yl.useMemo(()=>{return{zoomIn:(u)=>{let{panZoom:r}=l.getState();return r?r.scaleBy(1.2,u):Promise.resolve(!1)},zoomOut:(u)=>{let{panZoom:r}=l.getState();return r?r.scaleBy(0.8333333333333334,u):Promise.resolve(!1)},zoomTo:(u,r)=>{let{panZoom:f}=l.getState();return f?f.scaleTo(u,r):Promise.resolve(!1)},getZoom:()=>l.getState().transform[2],setViewport:async(u,r)=>{let{transform:[f,n,i],panZoom:t}=l.getState();if(!t)return Promise.resolve(!1);return await t.setViewport({x:u.x??f,y:u.y??n,zoom:u.zoom??i},r),Promise.resolve(!0)},getViewport:()=>{let[u,r,f]=l.getState().transform;return{x:u,y:r,zoom:f}},setCenter:async(u,r,f)=>{return l.getState().setCenter(u,r,f)},fitBounds:async(u,r)=>{let{width:f,height:n,minZoom:i,maxZoom:t,panZoom:y}=l.getState(),c=gc(u,f,n,i,t,r?.padding??0.1);if(!y)return Promise.resolve(!1);return await y.setViewport(c,{duration:r?.duration,ease:r?.ease,interpolate:r?.interpolate}),Promise.resolve(!0)},screenToFlowPosition:(u,r={})=>{let{transform:f,snapGrid:n,snapToGrid:i,domNode:t}=l.getState();if(!t)return u;let{x:y,y:c}=t.getBoundingClientRect(),$={x:u.x-y,y:u.y-c},A=r.snapGrid??n,j=r.snapToGrid??i;return Oy($,f,j,A)},flowToScreenPosition:(u)=>{let{transform:r,domNode:f}=l.getState();if(!f)return u;let{x:n,y:i}=f.getBoundingClientRect(),t=sc(u,r);return{x:t.x+n,y:t.y+i}}}},[])};function UW(l,u){let r=[],f=new Map,n=[];for(let i of l)if(i.type==="add"){n.push(i);continue}else if(i.type==="remove"||i.type==="replace")f.set(i.id,[i]);else{let t=f.get(i.id);if(t)t.push(i);else f.set(i.id,[i])}for(let i of u){let t=f.get(i.id);if(!t){r.push(i);continue}if(t[0].type==="remove")continue;if(t[0].type==="replace"){r.push({...t[0].item});continue}let y={...i};for(let c of t)CD(c,y);r.push(y)}if(n.length)n.forEach((i)=>{if(i.index!==void 0)r.splice(i.index,0,{...i.item});else r.push({...i.item})});return r}function CD(l,u){switch(l.type){case"select":{u.selected=l.selected;break}case"position":{if(typeof l.position<"u")u.position=l.position;if(typeof l.dragging<"u")u.dragging=l.dragging;break}case"dimensions":{if(typeof l.dimensions<"u"){if(u.measured={...l.dimensions},l.setAttributes){if(l.setAttributes===!0||l.setAttributes==="width")u.width=l.dimensions.width;if(l.setAttributes===!0||l.setAttributes==="height")u.height=l.dimensions.height}}if(typeof l.resizing==="boolean")u.resizing=l.resizing;break}}}function MD(l,u){return UW(l,u)}function hD(l,u){return UW(l,u)}function lt(l,u){return{id:l,type:"select",selected:u}}function Hy(l,u=new Set,r=!1){let f=[];for(let[n,i]of l){let t=u.has(n);if(!(i.selected===void 0&&!t)&&i.selected!==t){if(r)i.selected=t;f.push(lt(i.id,t))}}return f}function Iq({items:l=[],lookup:u}){let r=[],f=new Map(l.map((n)=>[n.id,n]));for(let[n,i]of l.entries()){let t=u.get(i.id),y=t?.internals?.userNode??t;if(y!==void 0&&y!==i)r.push({id:i.id,item:i,type:"replace"});if(y===void 0)r.push({item:i,type:"add",index:n})}for(let[n]of u)if(f.get(n)===void 0)r.push({id:n,type:"remove"});return r}function aq(l){return{id:l.id,type:"remove"}}var oq=(l)=>ew(l),RD=(l)=>z9(l);function NW(l){return yl.forwardRef(l)}function dq(l){let[u,r]=yl.useState(BigInt(0)),[f]=yl.useState(()=>xD(()=>r((n)=>n+BigInt(1))));return a9(()=>{let n=f.get();if(n.length)l(n),f.reset()},[u]),f}function xD(l){let u=[];return{get:()=>u,reset:()=>{u=[]},push:(r)=>{u.push(r),l()}}}var QW=yl.createContext(null);function bD({children:l}){let u=Zu(),r=yl.useCallback((y)=>{let{nodes:c=[],setNodes:$,hasDefaultNodes:A,onNodesChange:j,nodeLookup:F,fitViewQueued:U,onNodesChangeMiddlewareMap:N}=u.getState(),W=c;for(let J of y)W=typeof J==="function"?J(W):J;let L=Iq({items:W,lookup:F});for(let J of N.values())L=J(L);if(A)$(W);if(L.length>0)j?.(L);else if(U)window.requestAnimationFrame(()=>{let{fitViewQueued:J,nodes:w,setNodes:Q}=u.getState();if(J)Q(w)})},[]),f=dq(r),n=yl.useCallback((y)=>{let{edges:c=[],setEdges:$,hasDefaultEdges:A,onEdgesChange:j,edgeLookup:F}=u.getState(),U=c;for(let N of y)U=typeof N==="function"?N(U):N;if(A)$(U);else if(j)j(Iq({items:U,lookup:F}))},[]),i=dq(n),t=yl.useMemo(()=>({nodeQueue:f,edgeQueue:i}),[]);return nl.jsx(QW.Provider,{value:t,children:l})}function vD(){let l=yl.useContext(QW);if(!l)throw Error("useBatchContext must be used within a BatchProvider");return l}var sD=(l)=>!!l.panZoom;function d9(){let l=PD(),u=Zu(),r=vD(),f=yu(sD),n=yl.useMemo(()=>{let i=(j)=>u.getState().nodeLookup.get(j),t=(j)=>{r.nodeQueue.push(j)},y=(j)=>{r.edgeQueue.push(j)},c=(j)=>{let{nodeLookup:F,nodeOrigin:U}=u.getState(),N=oq(j)?j:F.get(j.id),W=N.parentId?V9(N.position,N.measured,N.parentId,F,U):N.position,L={...N,position:W,width:N.measured?.width??N.width,height:N.measured?.height??N.height};return e0(L)},$=(j,F,U={replace:!1})=>{t((N)=>N.map((W)=>{if(W.id===j){let L=typeof F==="function"?F(W):F;return U.replace&&oq(L)?L:{...W,...L}}return W}))},A=(j,F,U={replace:!1})=>{y((N)=>N.map((W)=>{if(W.id===j){let L=typeof F==="function"?F(W):F;return U.replace&&RD(L)?L:{...W,...L}}return W}))};return{getNodes:()=>u.getState().nodes.map((j)=>({...j})),getNode:(j)=>i(j)?.internals.userNode,getInternalNode:i,getEdges:()=>{let{edges:j=[]}=u.getState();return j.map((F)=>({...F}))},getEdge:(j)=>u.getState().edgeLookup.get(j),setNodes:t,setEdges:y,addNodes:(j)=>{let F=Array.isArray(j)?j:[j];r.nodeQueue.push((U)=>[...U,...F])},addEdges:(j)=>{let F=Array.isArray(j)?j:[j];r.edgeQueue.push((U)=>[...U,...F])},toObject:()=>{let{nodes:j=[],edges:F=[],transform:U}=u.getState(),[N,W,L]=U;return{nodes:j.map((J)=>({...J})),edges:F.map((J)=>({...J})),viewport:{x:N,y:W,zoom:L}}},deleteElements:async({nodes:j=[],edges:F=[]})=>{let{nodes:U,edges:N,onNodesDelete:W,onEdgesDelete:L,triggerNodeChanges:J,triggerEdgeChanges:w,onDelete:Q,onBeforeDelete:q}=u.getState(),{nodes:T,edges:O}=await rq({nodesToRemove:j,edgesToRemove:F,nodes:U,edges:N,onBeforeDelete:q}),Z=O.length>0,E=T.length>0;if(Z){let D=O.map(aq);L?.(O),w(D)}if(E){let D=T.map(aq);W?.(T),J(D)}if(E||Z)Q?.({nodes:T,edges:O});return{deletedNodes:T,deletedEdges:O}},getIntersectingNodes:(j,F=!0,U)=>{let N=H9(j),W=N?j:c(j),L=U!==void 0;if(!W)return[];return(U||u.getState().nodes).filter((J)=>{let w=u.getState().nodeLookup.get(J.id);if(w&&!N&&(J.id===j.id||!w.internals.positionAbsolute))return!1;let Q=e0(L?J:w),q=zy(Q,W);return F&&q>0||q>=Q.width*Q.height||q>=W.width*W.height})},isNodeIntersecting:(j,F,U=!0)=>{let W=H9(j)?j:c(j);if(!W)return!1;let L=zy(W,F);return U&&L>0||L>=F.width*F.height||L>=W.width*W.height},updateNode:$,updateNodeData:(j,F,U={replace:!1})=>{$(j,(N)=>{let W=typeof F==="function"?F(N):F;return U.replace?{...N,data:W}:{...N,data:{...N.data,...W}}},U)},updateEdge:A,updateEdgeData:(j,F,U={replace:!1})=>{A(j,(N)=>{let W=typeof F==="function"?F(N):F;return U.replace?{...N,data:W}:{...N,data:{...N.data,...W}}},U)},getNodesBounds:(j)=>{let{nodeLookup:F,nodeOrigin:U}=u.getState();return O9(j,{nodeLookup:F,nodeOrigin:U})},getHandleConnections:({type:j,id:F,nodeId:U})=>Array.from(u.getState().connectionLookup.get(`${U}-${j}${F?`-${F}`:""}`)?.values()??[]),getNodeConnections:({type:j,handleId:F,nodeId:U})=>Array.from(u.getState().connectionLookup.get(`${U}${j?F?`-${j}-${F}`:`-${j}`:""}`)?.values()??[]),fitView:async(j)=>{let F=u.getState().fitViewResolver??iq();return u.setState({fitViewQueued:!0,fitViewOptions:j,fitViewResolver:F}),r.nodeQueue.push((U)=>[...U]),F.promise}}},[]);return yl.useMemo(()=>{return{...n,...l,viewportInitialized:f}},[f])}var eq=(l)=>l.selected,kD=typeof window<"u"?window:void 0;function gD({deleteKeyCode:l,multiSelectionKeyCode:u}){let r=Zu(),{deleteElements:f}=d9(),n=ac(l,{actInsideInputWithModifier:!1}),i=ac(u,{target:kD});yl.useEffect(()=>{if(n){let{edges:t,nodes:y}=r.getState();f({nodes:y.filter(eq),edges:t.filter(eq)}),r.setState({nodesSelectionActive:!1})}},[n]),yl.useEffect(()=>{r.setState({multiSelectionActive:i})},[i])}function ID(l){let u=Zu();yl.useEffect(()=>{let r=()=>{if(!l.current||!(l.current.checkVisibility?.()??!0))return!1;let f=WA(l.current);if(f.height===0||f.width===0)u.getState().onError?.("004",Qf.error004());u.setState({width:f.width||500,height:f.height||500})};if(l.current){r(),window.addEventListener("resize",r);let f=new ResizeObserver(()=>r());return f.observe(l.current),()=>{if(window.removeEventListener("resize",r),f&&l.current)f.unobserve(l.current)}}},[])}var SA={position:"absolute",width:"100%",height:"100%",top:0,left:0},aD=(l)=>({userSelectionActive:l.userSelectionActive,lib:l.lib,connectionInProgress:l.connection.inProgress});function oD({onPaneContextMenu:l,zoomOnScroll:u=!0,zoomOnPinch:r=!0,panOnScroll:f=!1,panOnScrollSpeed:n=0.5,panOnScrollMode:i=ui.Free,zoomOnDoubleClick:t=!0,panOnDrag:y=!0,defaultViewport:c,translateExtent:$,minZoom:A,maxZoom:j,zoomActivationKeyCode:F,preventScrolling:U=!0,children:N,noWheelClassName:W,noPanClassName:L,onViewportChange:J,isControlledViewport:w,paneClickDistance:Q,selectionOnDrag:q}){let T=Zu(),O=yl.useRef(null),{userSelectionActive:Z,lib:E,connectionInProgress:D}=yu(aD,Eu),Y=ac(F),p=yl.useRef();ID(O);let V=yl.useCallback((B)=>{if(J?.({x:B[0],y:B[1],zoom:B[2]}),!w)T.setState({transform:B})},[J,w]);return yl.useEffect(()=>{if(O.current){p.current=Kq({domNode:O.current,minZoom:A,maxZoom:j,translateExtent:$,viewport:c,onDraggingChange:(S)=>T.setState((b)=>b.paneDragging===S?b:{paneDragging:S}),onPanZoomStart:(S,b)=>{let{onViewportChangeStart:z,onMoveStart:P}=T.getState();P?.(S,b),z?.(b)},onPanZoom:(S,b)=>{let{onViewportChange:z,onMove:P}=T.getState();P?.(S,b),z?.(b)},onPanZoomEnd:(S,b)=>{let{onViewportChangeEnd:z,onMoveEnd:P}=T.getState();P?.(S,b),z?.(b)}});let{x:B,y:m,zoom:X}=p.current.getViewport();return T.setState({panZoom:p.current,transform:[B,m,X],domNode:O.current.closest(".react-flow")}),()=>{p.current?.destroy()}}},[]),yl.useEffect(()=>{p.current?.update({onPaneContextMenu:l,zoomOnScroll:u,zoomOnPinch:r,panOnScroll:f,panOnScrollSpeed:n,panOnScrollMode:i,zoomOnDoubleClick:t,panOnDrag:y,zoomActivationKeyPressed:Y,preventScrolling:U,noPanClassName:L,userSelectionActive:Z,noWheelClassName:W,lib:E,onTransformChange:V,connectionInProgress:D,selectionOnDrag:q,paneClickDistance:Q})},[l,u,r,f,n,i,t,y,Y,U,L,Z,W,E,V,D,q,Q]),nl.jsx("div",{className:"react-flow__renderer",ref:O,style:SA,children:N})}var dD=(l)=>({userSelectionActive:l.userSelectionActive,userSelectionRect:l.userSelectionRect});function eD(){let{userSelectionActive:l,userSelectionRect:u}=yu(dD,Eu);if(!(l&&u))return null;return nl.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:u.width,height:u.height,transform:`translate(${u.x}px, ${u.y}px)`}})}var g9=(l,u)=>{return(r)=>{if(r.target!==u.current)return;l?.(r)}},lV=(l)=>({userSelectionActive:l.userSelectionActive,elementsSelectable:l.elementsSelectable,connectionInProgress:l.connection.inProgress,dragging:l.paneDragging});function uV({isSelecting:l,selectionKeyPressed:u,selectionMode:r=o0.Full,panOnDrag:f,paneClickDistance:n,selectionOnDrag:i,onSelectionStart:t,onSelectionEnd:y,onPaneClick:c,onPaneContextMenu:$,onPaneScroll:A,onPaneMouseEnter:j,onPaneMouseMove:F,onPaneMouseLeave:U,children:N}){let W=Zu(),{userSelectionActive:L,elementsSelectable:J,dragging:w,connectionInProgress:Q}=yu(lV,Eu),q=J&&(l||L),T=yl.useRef(null),O=yl.useRef(),Z=yl.useRef(new Set),E=yl.useRef(new Set),D=yl.useRef(!1),Y=(z)=>{if(D.current||Q){D.current=!1;return}c?.(z),W.getState().resetSelectedElements(),W.setState({nodesSelectionActive:!1})},p=(z)=>{if(Array.isArray(f)&&f?.includes(2)){z.preventDefault();return}$?.(z)},V=A?(z)=>A(z):void 0,B=(z)=>{if(D.current)z.stopPropagation(),D.current=!1},m=(z)=>{let{domNode:P}=W.getState();if(O.current=P?.getBoundingClientRect(),!O.current)return;let s=z.target===T.current;if(!s&&!!z.target.closest(".nokey")||!l||!(i&&s||u)||z.button!==0||!z.isPrimary)return;z.target?.setPointerCapture?.(z.pointerId),D.current=!1;let{x:tl,y:I}=Bf(z.nativeEvent,O.current);if(W.setState({userSelectionRect:{width:0,height:0,startX:tl,startY:I,x:tl,y:I}}),!s)z.stopPropagation(),z.preventDefault()},X=(z)=>{let{userSelectionRect:P,transform:s,nodeLookup:k,edgeLookup:v,connectionLookup:tl,triggerNodeChanges:I,triggerEdgeChanges:M,defaultEdgeOptions:rl,resetSelectedElements:cl}=W.getState();if(!O.current||!P)return;let{x:$l,y:Tl}=Bf(z.nativeEvent,O.current),{startX:Ql,startY:Ol}=P;if(!D.current){let o=u?0:n;if(Math.hypot($l-Ql,Tl-Ol)<=o)return;cl(),t?.(z)}D.current=!0;let h={startX:Ql,startY:Ol,x:$l<Ql?$l:Ql,y:Tl<Ol?Tl:Ol,width:Math.abs($l-Ql),height:Math.abs(Tl-Ol)},a=Z.current,ul=E.current;Z.current=new Set(QA(k,h,s,r===o0.Partial,!0).map((o)=>o.id)),E.current=new Set;let zl=rl?.selectable??!0;for(let o of Z.current){let ql=tl.get(o);if(!ql)continue;for(let{edgeId:pl}of ql.values()){let Bl=v.get(pl);if(Bl&&(Bl.selectable??zl))E.current.add(pl)}}if(!S9(a,Z.current)){let o=Hy(k,Z.current,!0);I(o)}if(!S9(ul,E.current)){let o=Hy(v,E.current);M(o)}W.setState({userSelectionRect:h,userSelectionActive:!0,nodesSelectionActive:!1})},S=(z)=>{if(z.button!==0)return;if(z.target?.releasePointerCapture?.(z.pointerId),!L&&z.target===T.current&&W.getState().userSelectionRect)Y?.(z);if(W.setState({userSelectionActive:!1,userSelectionRect:null}),D.current)y?.(z),W.setState({nodesSelectionActive:Z.current.size>0})},b=f===!0||Array.isArray(f)&&f.includes(0);return nl.jsxs("div",{className:bu(["react-flow__pane",{draggable:b,dragging:w,selection:l}]),onClick:q?void 0:g9(Y,T),onContextMenu:g9(p,T),onWheel:g9(V,T),onPointerEnter:q?void 0:j,onPointerMove:q?X:F,onPointerUp:q?S:void 0,onPointerDownCapture:q?m:void 0,onClickCapture:q?B:void 0,onPointerLeave:U,ref:T,style:SA,children:[N,nl.jsx(eD,{})]})}function o9({id:l,store:u,unselect:r=!1,nodeRef:f}){let{addSelectedNodes:n,unselectNodesAndEdges:i,multiSelectionActive:t,nodeLookup:y,onError:c}=u.getState(),$=y.get(l);if(!$){c?.("012",Qf.error012(l));return}if(u.setState({nodesSelectionActive:!1}),!$.selected)n([l]);else if(r||$.selected&&t)i({nodes:[$],edges:[]}),requestAnimationFrame(()=>f?.current?.blur())}function wW({nodeRef:l,disabled:u=!1,noDragClassName:r,handleSelector:f,nodeId:n,isSelectable:i,nodeClickDistance:t}){let y=Zu(),[c,$]=yl.useState(!1),A=yl.useRef();return yl.useEffect(()=>{A.current=Qq({getStoreItems:()=>y.getState(),onNodeMouseDown:(j)=>{o9({id:j,store:y,nodeRef:l})},onDragStart:()=>{$(!0)},onDragStop:()=>{$(!1)}})},[]),yl.useEffect(()=>{if(u||!l.current||!A.current)return;return A.current.update({noDragClassName:r,handleSelector:f,domNode:l.current,isSelectable:i,nodeId:n,nodeClickDistance:t}),()=>{A.current?.destroy()}},[r,f,u,i,l,n,t]),c}var rV=(l)=>(u)=>u.selected&&(u.draggable||l&&typeof u.draggable>"u");function qW(){let l=Zu();return yl.useCallback((r)=>{let{nodeExtent:f,snapToGrid:n,snapGrid:i,nodesDraggable:t,onError:y,updateNodePositions:c,nodeLookup:$,nodeOrigin:A}=l.getState(),j=new Map,F=rV(t),U=n?i[0]:5,N=n?i[1]:5,W=r.direction.x*U*r.factor,L=r.direction.y*N*r.factor;for(let[,J]of $){if(!F(J))continue;let w={x:J.internals.positionAbsolute.x+W,y:J.internals.positionAbsolute.y+L};if(n)w=Ey(w,i);let{position:Q,positionAbsolute:q}=Z9({nodeId:J.id,nextPosition:w,nodeLookup:$,nodeExtent:f,nodeOrigin:A,onError:y});J.position=Q,J.internals.positionAbsolute=q,j.set(J.id,J)}c(j)},[])}var e9=yl.createContext(null),fV=e9.Provider;e9.Consumer;var WW=()=>{return yl.useContext(e9)},nV=(l)=>({connectOnClick:l.connectOnClick,noPanClassName:l.noPanClassName,rfId:l.rfId}),iV=(l,u,r)=>(f)=>{let{connectionClickStartHandle:n,connectionMode:i,connection:t}=f,{fromHandle:y,toHandle:c,isValid:$}=t,A=c?.nodeId===l&&c?.id===u&&c?.type===r;return{connectingFrom:y?.nodeId===l&&y?.id===u&&y?.type===r,connectingTo:A,clickConnecting:n?.nodeId===l&&n?.id===u&&n?.type===r,isPossibleEndHandle:i===si.Strict?y?.type!==r:l!==y?.nodeId||u!==y?.id,connectionInProcess:!!y,clickConnectionInProcess:!!n,valid:A&&$}};function tV({type:l="source",position:u=Kl.Top,isValidConnection:r,isConnectable:f=!0,isConnectableStart:n=!0,isConnectableEnd:i=!0,id:t,onConnect:y,children:c,className:$,onMouseDown:A,onTouchStart:j,...F},U){let N=t||null,W=l==="target",L=Zu(),J=WW(),{connectOnClick:w,noPanClassName:Q,rfId:q}=yu(nV,Eu),{connectingFrom:T,connectingTo:O,clickConnecting:Z,isPossibleEndHandle:E,connectionInProcess:D,clickConnectionInProcess:Y,valid:p}=yu(iV(J,N,l),Eu);if(!J)L.getState().onError?.("010",Qf.error010());let V=(X)=>{let{defaultEdgeOptions:S,onConnect:b,hasDefaultEdges:z}=L.getState(),P={...S,...X};if(z){let{edges:s,setEdges:k}=L.getState();k(M9(P,s))}b?.(P),y?.(P)},B=(X)=>{if(!J)return;let S=P9(X.nativeEvent);if(n&&(S&&X.button===0||!S)){let b=L.getState();EA.onPointerDown(X.nativeEvent,{handleDomNode:X.currentTarget,autoPanOnConnect:b.autoPanOnConnect,connectionMode:b.connectionMode,connectionRadius:b.connectionRadius,domNode:b.domNode,nodeLookup:b.nodeLookup,lib:b.lib,isTarget:W,handleId:N,nodeId:J,flowId:b.rfId,panBy:b.panBy,cancelConnection:b.cancelConnection,onConnectStart:b.onConnectStart,onConnectEnd:(...z)=>L.getState().onConnectEnd?.(...z),updateConnection:b.updateConnection,onConnect:V,isValidConnection:r||((...z)=>L.getState().isValidConnection?.(...z)??!0),getTransform:()=>L.getState().transform,getFromHandle:()=>L.getState().connection.fromHandle,autoPanSpeed:b.autoPanSpeed,dragThreshold:b.connectionDragThreshold})}if(S)A?.(X);else j?.(X)},m=(X)=>{let{onClickConnectStart:S,onClickConnectEnd:b,connectionClickStartHandle:z,connectionMode:P,isValidConnection:s,lib:k,rfId:v,nodeLookup:tl,connection:I}=L.getState();if(!J||!z&&!n)return;if(!z){S?.(X.nativeEvent,{nodeId:J,handleId:N,handleType:l}),L.setState({connectionClickStartHandle:{nodeId:J,type:l,id:N}});return}let M=X9(X.target),rl=r||s,{connection:cl,isValid:$l}=EA.isValid(X.nativeEvent,{handle:{nodeId:J,id:N,type:l},connectionMode:P,fromNodeId:z.nodeId,fromHandleId:z.id||null,fromType:z.type,isValidConnection:rl,flowId:v,doc:M,lib:k,nodeLookup:tl});if($l&&cl)V(cl);let Tl=structuredClone(I);delete Tl.inProgress,Tl.toPosition=Tl.toHandle?Tl.toHandle.position:null,b?.(X,Tl),L.setState({connectionClickStartHandle:null})};return nl.jsx("div",{"data-handleid":N,"data-nodeid":J,"data-handlepos":u,"data-id":`${q}-${J}-${N}-${l}`,className:bu(["react-flow__handle",`react-flow__handle-${u}`,"nodrag",Q,$,{source:!W,target:W,connectable:f,connectablestart:n,connectableend:i,clickconnecting:Z,connectingfrom:T,connectingto:O,valid:p,connectionindicator:f&&(!D||E)&&(D||Y?i:n)}]),onMouseDown:B,onTouchStart:B,onClick:w?m:void 0,ref:U,...F,children:c})}var ut=yl.memo(NW(tV));function yV({data:l,isConnectable:u,sourcePosition:r=Kl.Bottom}){return nl.jsxs(nl.Fragment,{children:[l?.label,nl.jsx(ut,{type:"source",position:r,isConnectable:u})]})}function cV({data:l,isConnectable:u,targetPosition:r=Kl.Top,sourcePosition:f=Kl.Bottom}){return nl.jsxs(nl.Fragment,{children:[nl.jsx(ut,{type:"target",position:r,isConnectable:u}),l?.label,nl.jsx(ut,{type:"source",position:f,isConnectable:u})]})}function _V(){return null}function $V({data:l,isConnectable:u,targetPosition:r=Kl.Top}){return nl.jsxs(nl.Fragment,{children:[nl.jsx(ut,{type:"target",position:r,isConnectable:u}),l?.label]})}var BA={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},lW={input:yV,default:cV,output:$V,group:_V};function AV(l){if(l.internals.handleBounds===void 0)return{width:l.width??l.initialWidth??l.style?.width,height:l.height??l.initialHeight??l.style?.height};return{width:l.width??l.style?.width,height:l.height??l.style?.height}}var jV=(l)=>{let{width:u,height:r,x:f,y:n}=Ky(l.nodeLookup,{filter:(i)=>!!i.selected});return{width:Hf(u)?u:null,height:Hf(r)?r:null,userSelectionActive:l.userSelectionActive,transformString:`translate(${l.transform[0]}px,${l.transform[1]}px) scale(${l.transform[2]}) translate(${f}px,${n}px)`}};function FV({onSelectionContextMenu:l,noPanClassName:u,disableKeyboardA11y:r}){let f=Zu(),{width:n,height:i,transformString:t,userSelectionActive:y}=yu(jV,Eu),c=qW(),$=yl.useRef(null);yl.useEffect(()=>{if(!r)$.current?.focus({preventScroll:!0})},[r]);let A=!y&&n!==null&&i!==null;if(wW({nodeRef:$,disabled:!A}),!A)return null;let j=l?(U)=>{let N=f.getState().nodes.filter((W)=>W.selected);l(U,N)}:void 0,F=(U)=>{if(Object.prototype.hasOwnProperty.call(BA,U.key))U.preventDefault(),c({direction:BA[U.key],factor:U.shiftKey?4:1})};return nl.jsx("div",{className:bu(["react-flow__nodesselection","react-flow__container",u]),style:{transform:t},children:nl.jsx("div",{ref:$,className:"react-flow__nodesselection-rect",onContextMenu:j,tabIndex:r?void 0:-1,onKeyDown:r?void 0:F,style:{width:n,height:i}})})}var uW=typeof window<"u"?window:void 0,JV=(l)=>{return{nodesSelectionActive:l.nodesSelectionActive,userSelectionActive:l.userSelectionActive}};function LW({children:l,onPaneClick:u,onPaneMouseEnter:r,onPaneMouseMove:f,onPaneMouseLeave:n,onPaneContextMenu:i,onPaneScroll:t,paneClickDistance:y,deleteKeyCode:c,selectionKeyCode:$,selectionOnDrag:A,selectionMode:j,onSelectionStart:F,onSelectionEnd:U,multiSelectionKeyCode:N,panActivationKeyCode:W,zoomActivationKeyCode:L,elementsSelectable:J,zoomOnScroll:w,zoomOnPinch:Q,panOnScroll:q,panOnScrollSpeed:T,panOnScrollMode:O,zoomOnDoubleClick:Z,panOnDrag:E,defaultViewport:D,translateExtent:Y,minZoom:p,maxZoom:V,preventScrolling:B,onSelectionContextMenu:m,noWheelClassName:X,noPanClassName:S,disableKeyboardA11y:b,onViewportChange:z,isControlledViewport:P}){let{nodesSelectionActive:s,userSelectionActive:k}=yu(JV,Eu),v=ac($,{target:uW}),tl=ac(W,{target:uW}),I=tl||E,M=tl||q,rl=A&&I!==!0,cl=v||k||rl;return gD({deleteKeyCode:c,multiSelectionKeyCode:N}),nl.jsx(oD,{onPaneContextMenu:i,elementsSelectable:J,zoomOnScroll:w,zoomOnPinch:Q,panOnScroll:M,panOnScrollSpeed:T,panOnScrollMode:O,zoomOnDoubleClick:Z,panOnDrag:!v&&I,defaultViewport:D,translateExtent:Y,minZoom:p,maxZoom:V,zoomActivationKeyCode:L,preventScrolling:B,noWheelClassName:X,noPanClassName:S,onViewportChange:z,isControlledViewport:P,paneClickDistance:y,selectionOnDrag:rl,children:nl.jsxs(uV,{onSelectionStart:F,onSelectionEnd:U,onPaneClick:u,onPaneMouseEnter:r,onPaneMouseMove:f,onPaneMouseLeave:n,onPaneContextMenu:i,onPaneScroll:t,panOnDrag:I,isSelecting:!!cl,selectionMode:j,selectionKeyPressed:v,paneClickDistance:y,selectionOnDrag:rl,children:[l,s&&nl.jsx(FV,{onSelectionContextMenu:m,noPanClassName:S,disableKeyboardA11y:b})]})})}LW.displayName="FlowRenderer";var UV=yl.memo(LW),NV=(l)=>(u)=>{return l?QA(u.nodeLookup,{x:0,y:0,width:u.width,height:u.height},u.transform,!0).map((r)=>r.id):Array.from(u.nodeLookup.keys())};function QV(l){return yu(yl.useCallback(NV(l),[l]),Eu)}var wV=(l)=>l.updateNodeInternals;function qV(){let l=yu(wV),[u]=yl.useState(()=>{if(typeof ResizeObserver>"u")return null;return new ResizeObserver((r)=>{let f=new Map;r.forEach((n)=>{let i=n.target.getAttribute("data-id");f.set(i,{id:i,nodeElement:n.target,force:!0})}),l(f)})});return yl.useEffect(()=>{return()=>{u?.disconnect()}},[u]),u}function WV({node:l,nodeType:u,hasDimensions:r,resizeObserver:f}){let n=Zu(),i=yl.useRef(null),t=yl.useRef(null),y=yl.useRef(l.sourcePosition),c=yl.useRef(l.targetPosition),$=yl.useRef(u),A=r&&!!l.internals.handleBounds;return yl.useEffect(()=>{if(i.current&&!l.hidden&&(!A||t.current!==i.current)){if(t.current)f?.unobserve(t.current);f?.observe(i.current),t.current=i.current}},[A,l.hidden]),yl.useEffect(()=>{return()=>{if(t.current)f?.unobserve(t.current),t.current=null}},[]),yl.useEffect(()=>{if(i.current){let j=$.current!==u,F=y.current!==l.sourcePosition,U=c.current!==l.targetPosition;if(j||F||U)$.current=u,y.current=l.sourcePosition,c.current=l.targetPosition,n.getState().updateNodeInternals(new Map([[l.id,{id:l.id,nodeElement:i.current,force:!0}]]))}},[l.id,u,l.sourcePosition,l.targetPosition]),i}function LV({id:l,onClick:u,onMouseEnter:r,onMouseMove:f,onMouseLeave:n,onContextMenu:i,onDoubleClick:t,nodesDraggable:y,elementsSelectable:c,nodesConnectable:$,nodesFocusable:A,resizeObserver:j,noDragClassName:F,noPanClassName:U,disableKeyboardA11y:N,rfId:W,nodeTypes:L,nodeClickDistance:J,onError:w}){let{node:Q,internals:q,isParent:T}=yu(($l)=>{let Tl=$l.nodeLookup.get(l),Ql=$l.parentLookup.has(l);return{node:Tl,internals:Tl.internals,isParent:Ql}},Eu),O=Q.type||"default",Z=L?.[O]||lW[O];if(Z===void 0)w?.("003",Qf.error003(O)),O="default",Z=L?.default||lW.default;let E=!!(Q.draggable||y&&typeof Q.draggable>"u"),D=!!(Q.selectable||c&&typeof Q.selectable>"u"),Y=!!(Q.connectable||$&&typeof Q.connectable>"u"),p=!!(Q.focusable||A&&typeof Q.focusable>"u"),V=Zu(),B=D9(Q),m=WV({node:Q,nodeType:O,hasDimensions:B,resizeObserver:j}),X=wW({nodeRef:m,disabled:Q.hidden||!E,noDragClassName:F,handleSelector:Q.dragHandle,nodeId:l,isSelectable:D,nodeClickDistance:J}),S=qW();if(Q.hidden)return null;let b=Tn(Q),z=AV(Q),P=D||E||u||r||f||n,s=r?($l)=>r($l,{...q.userNode}):void 0,k=f?($l)=>f($l,{...q.userNode}):void 0,v=n?($l)=>n($l,{...q.userNode}):void 0,tl=i?($l)=>i($l,{...q.userNode}):void 0,I=t?($l)=>t($l,{...q.userNode}):void 0,M=($l)=>{let{selectNodesOnDrag:Tl,nodeDragThreshold:Ql}=V.getState();if(D&&(!Tl||!E||Ql>0))o9({id:l,store:V,nodeRef:m});if(u)u($l,{...q.userNode})},rl=($l)=>{if(Y9($l.nativeEvent)||N)return;if(G9.includes($l.key)&&D){let Tl=$l.key==="Escape";o9({id:l,store:V,unselect:Tl,nodeRef:m})}else if(E&&Q.selected&&Object.prototype.hasOwnProperty.call(BA,$l.key)){$l.preventDefault();let{ariaLabelConfig:Tl}=V.getState();V.setState({ariaLiveMessage:Tl["node.a11yDescription.ariaLiveMessage"]({direction:$l.key.replace("Arrow","").toLowerCase(),x:~~q.positionAbsolute.x,y:~~q.positionAbsolute.y})}),S({direction:BA[$l.key],factor:$l.shiftKey?4:1})}},cl=()=>{if(N||!m.current?.matches(":focus-visible"))return;let{transform:$l,width:Tl,height:Ql,autoPanOnNodeFocus:Ol,setCenter:h}=V.getState();if(!Ol)return;if(!(QA(new Map([[l,Q]]),{x:0,y:0,width:Tl,height:Ql},$l,!0).length>0))h(Q.position.x+b.width/2,Q.position.y+b.height/2,{zoom:$l[2]})};return nl.jsx("div",{className:bu(["react-flow__node",`react-flow__node-${O}`,{[U]:E},Q.className,{selected:Q.selected,selectable:D,parent:T,draggable:E,dragging:X}]),ref:m,style:{zIndex:q.z,transform:`translate(${q.positionAbsolute.x}px,${q.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:B?"visible":"hidden",...Q.style,...z},"data-id":l,"data-testid":`rf__node-${l}`,onMouseEnter:s,onMouseMove:k,onMouseLeave:v,onContextMenu:tl,onClick:M,onDoubleClick:I,onKeyDown:p?rl:void 0,tabIndex:p?0:void 0,onFocus:p?cl:void 0,role:Q.ariaRole??(p?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${jW}-${W}`,"aria-label":Q.ariaLabel,...Q.domAttributes,children:nl.jsx(fV,{value:l,children:nl.jsx(Z,{id:l,data:Q.data,type:O,positionAbsoluteX:q.positionAbsolute.x,positionAbsoluteY:q.positionAbsolute.y,selected:Q.selected??!1,selectable:D,draggable:E,deletable:Q.deletable??!0,isConnectable:Y,sourcePosition:Q.sourcePosition,targetPosition:Q.targetPosition,dragging:X,dragHandle:Q.dragHandle,zIndex:q.z,parentId:Q.parentId,...b})})})}var GV=yl.memo(LV),TV=(l)=>({nodesDraggable:l.nodesDraggable,nodesConnectable:l.nodesConnectable,nodesFocusable:l.nodesFocusable,elementsSelectable:l.elementsSelectable,onError:l.onError});function GW(l){let{nodesDraggable:u,nodesConnectable:r,nodesFocusable:f,elementsSelectable:n,onError:i}=yu(TV,Eu),t=QV(l.onlyRenderVisibleElements),y=qV();return nl.jsx("div",{className:"react-flow__nodes",style:SA,children:t.map((c)=>{return nl.jsx(GV,{id:c,nodeTypes:l.nodeTypes,nodeExtent:l.nodeExtent,onClick:l.onNodeClick,onMouseEnter:l.onNodeMouseEnter,onMouseMove:l.onNodeMouseMove,onMouseLeave:l.onNodeMouseLeave,onContextMenu:l.onNodeContextMenu,onDoubleClick:l.onNodeDoubleClick,noDragClassName:l.noDragClassName,noPanClassName:l.noPanClassName,rfId:l.rfId,disableKeyboardA11y:l.disableKeyboardA11y,resizeObserver:y,nodesDraggable:u,nodesConnectable:r,nodesFocusable:f,elementsSelectable:n,nodeClickDistance:l.nodeClickDistance,onError:i},c)})})}GW.displayName="NodeRenderer";var mV=yl.memo(GW);function KV(l){return yu(yl.useCallback((r)=>{if(!l)return r.edges.map((n)=>n.id);let f=[];if(r.width&&r.height)for(let n of r.edges){let i=r.nodeLookup.get(n.source),t=r.nodeLookup.get(n.target);if(i&&t&&cq({sourceNode:i,targetNode:t,width:r.width,height:r.height,transform:r.transform}))f.push(n.id)}return f},[l]),Eu)}var zV=({color:l="none",strokeWidth:u=1})=>{let r={strokeWidth:u,...l&&{stroke:l}};return nl.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},EV=({color:l="none",strokeWidth:u=1})=>{let r={strokeWidth:u,...l&&{stroke:l,fill:l}};return nl.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},rW={[ki.Arrow]:zV,[ki.ArrowClosed]:EV};function OV(l){let u=Zu();return yl.useMemo(()=>{if(!Object.prototype.hasOwnProperty.call(rW,l))return u.getState().onError?.("009",Qf.error009(l)),null;return rW[l]},[l])}var ZV=({id:l,type:u,color:r,width:f=12.5,height:n=12.5,markerUnits:i="strokeWidth",strokeWidth:t,orient:y="auto-start-reverse"})=>{let c=OV(u);if(!c)return null;return nl.jsx("marker",{className:"react-flow__arrowhead",id:l,markerWidth:`${f}`,markerHeight:`${n}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:y,refX:"0",refY:"0",children:nl.jsx(c,{color:r,strokeWidth:t})})},TW=({defaultColor:l,rfId:u})=>{let r=yu((i)=>i.edges),f=yu((i)=>i.defaultEdgeOptions),n=yl.useMemo(()=>{return $q(r,{id:u,defaultColor:l,defaultMarkerStart:f?.markerStart,defaultMarkerEnd:f?.markerEnd})},[r,f,u,l]);if(!n.length)return null;return nl.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:nl.jsx("defs",{children:n.map((i)=>nl.jsx(ZV,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})})};TW.displayName="MarkerDefinitions";var pV=yl.memo(TW);function mW({x:l,y:u,label:r,labelStyle:f,labelShowBg:n=!0,labelBgStyle:i,labelBgPadding:t=[2,4],labelBgBorderRadius:y=2,children:c,className:$,...A}){let[j,F]=yl.useState({x:1,y:0,width:0,height:0}),U=bu(["react-flow__edge-textwrapper",$]),N=yl.useRef(null);if(yl.useEffect(()=>{if(N.current){let W=N.current.getBBox();F({x:W.x,y:W.y,width:W.width,height:W.height})}},[r]),!r)return null;return nl.jsxs("g",{transform:`translate(${l-j.width/2} ${u-j.height/2})`,className:U,visibility:j.width?"visible":"hidden",...A,children:[n&&nl.jsx("rect",{width:j.width+2*t[0],x:-t[0],y:-t[1],height:j.height+2*t[1],className:"react-flow__edge-textbg",style:i,rx:y,ry:y}),nl.jsx("text",{className:"react-flow__edge-text",y:j.height/2,dy:"0.3em",ref:N,style:f,children:r}),c]})}mW.displayName="EdgeText";var HV=yl.memo(mW);function By({path:l,labelX:u,labelY:r,label:f,labelStyle:n,labelShowBg:i,labelBgStyle:t,labelBgPadding:y,labelBgBorderRadius:c,interactionWidth:$=20,...A}){return nl.jsxs(nl.Fragment,{children:[nl.jsx("path",{...A,d:l,fill:"none",className:bu(["react-flow__edge-path",A.className])}),$?nl.jsx("path",{d:l,fill:"none",strokeOpacity:0,strokeWidth:$,className:"react-flow__edge-interaction"}):null,f&&Hf(u)&&Hf(r)?nl.jsx(HV,{x:u,y:r,label:f,labelStyle:n,labelShowBg:i,labelBgStyle:t,labelBgPadding:y,labelBgBorderRadius:c}):null]})}function fW({pos:l,x1:u,y1:r,x2:f,y2:n}){if(l===Kl.Left||l===Kl.Right)return[0.5*(u+f),r];return[u,0.5*(r+n)]}function KW({sourceX:l,sourceY:u,sourcePosition:r=Kl.Bottom,targetX:f,targetY:n,targetPosition:i=Kl.Top}){let[t,y]=fW({pos:r,x1:l,y1:u,x2:f,y2:n}),[c,$]=fW({pos:i,x1:f,y1:n,x2:l,y2:u}),[A,j,F,U]=LA({sourceX:l,sourceY:u,targetX:f,targetY:n,sourceControlX:t,sourceControlY:y,targetControlX:c,targetControlY:$});return[`M${l},${u} C${t},${y} ${c},${$} ${f},${n}`,A,j,F,U]}function zW(l){return yl.memo(({id:u,sourceX:r,sourceY:f,targetX:n,targetY:i,sourcePosition:t,targetPosition:y,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:U,style:N,markerEnd:W,markerStart:L,interactionWidth:J})=>{let[w,Q,q]=KW({sourceX:r,sourceY:f,sourcePosition:t,targetX:n,targetY:i,targetPosition:y}),T=l.isInternal?void 0:u;return nl.jsx(By,{id:T,path:w,labelX:Q,labelY:q,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:U,style:N,markerEnd:W,markerStart:L,interactionWidth:J})})}var BV=zW({isInternal:!1}),EW=zW({isInternal:!0});BV.displayName="SimpleBezierEdge";EW.displayName="SimpleBezierEdgeInternal";function OW(l){return yl.memo(({id:u,sourceX:r,sourceY:f,targetX:n,targetY:i,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,sourcePosition:U=Kl.Bottom,targetPosition:N=Kl.Top,markerEnd:W,markerStart:L,pathOptions:J,interactionWidth:w})=>{let[Q,q,T]=Ic({sourceX:r,sourceY:f,sourcePosition:U,targetX:n,targetY:i,targetPosition:N,borderRadius:J?.borderRadius,offset:J?.offset,stepPosition:J?.stepPosition}),O=l.isInternal?void 0:u;return nl.jsx(By,{id:O,path:Q,labelX:q,labelY:T,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,markerEnd:W,markerStart:L,interactionWidth:w})})}var ZW=OW({isInternal:!1}),pW=OW({isInternal:!0});ZW.displayName="SmoothStepEdge";pW.displayName="SmoothStepEdgeInternal";function HW(l){return yl.memo(({id:u,...r})=>{let f=l.isInternal?void 0:u;return nl.jsx(ZW,{...r,id:f,pathOptions:yl.useMemo(()=>({borderRadius:0,offset:r.pathOptions?.offset}),[r.pathOptions?.offset])})})}var DV=HW({isInternal:!1}),BW=HW({isInternal:!0});DV.displayName="StepEdge";BW.displayName="StepEdgeInternal";function DW(l){return yl.memo(({id:u,sourceX:r,sourceY:f,targetX:n,targetY:i,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,markerEnd:U,markerStart:N,interactionWidth:W})=>{let[L,J,w]=TA({sourceX:r,sourceY:f,targetX:n,targetY:i}),Q=l.isInternal?void 0:u;return nl.jsx(By,{id:Q,path:L,labelX:J,labelY:w,label:t,labelStyle:y,labelShowBg:c,labelBgStyle:$,labelBgPadding:A,labelBgBorderRadius:j,style:F,markerEnd:U,markerStart:N,interactionWidth:W})})}var VV=DW({isInternal:!1}),VW=DW({isInternal:!0});VV.displayName="StraightEdge";VW.displayName="StraightEdgeInternal";function SW(l){return yl.memo(({id:u,sourceX:r,sourceY:f,targetX:n,targetY:i,sourcePosition:t=Kl.Bottom,targetPosition:y=Kl.Top,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:U,style:N,markerEnd:W,markerStart:L,pathOptions:J,interactionWidth:w})=>{let[Q,q,T]=GA({sourceX:r,sourceY:f,sourcePosition:t,targetX:n,targetY:i,targetPosition:y,curvature:J?.curvature}),O=l.isInternal?void 0:u;return nl.jsx(By,{id:O,path:Q,labelX:q,labelY:T,label:c,labelStyle:$,labelShowBg:A,labelBgStyle:j,labelBgPadding:F,labelBgBorderRadius:U,style:N,markerEnd:W,markerStart:L,interactionWidth:w})})}var SV=SW({isInternal:!1}),XW=SW({isInternal:!0});SV.displayName="BezierEdge";XW.displayName="BezierEdgeInternal";var nW={default:XW,straight:VW,step:BW,smoothstep:pW,simplebezier:EW},iW={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},XV=(l,u,r)=>{if(r===Kl.Left)return l-u;if(r===Kl.Right)return l+u;return l},YV=(l,u,r)=>{if(r===Kl.Top)return l-u;if(r===Kl.Bottom)return l+u;return l},tW="react-flow__edgeupdater";function yW({position:l,centerX:u,centerY:r,radius:f=10,onMouseDown:n,onMouseEnter:i,onMouseOut:t,type:y}){return nl.jsx("circle",{onMouseDown:n,onMouseEnter:i,onMouseOut:t,className:bu([tW,`${tW}-${y}`]),cx:XV(u,f,l),cy:YV(r,f,l),r:f,stroke:"transparent",fill:"transparent"})}function PV({isReconnectable:l,reconnectRadius:u,edge:r,sourceX:f,sourceY:n,targetX:i,targetY:t,sourcePosition:y,targetPosition:c,onReconnect:$,onReconnectStart:A,onReconnectEnd:j,setReconnecting:F,setUpdateHover:U}){let N=Zu(),W=(q,T)=>{if(q.button!==0)return;let{autoPanOnConnect:O,domNode:Z,connectionMode:E,connectionRadius:D,lib:Y,onConnectStart:p,cancelConnection:V,nodeLookup:B,rfId:m,panBy:X,updateConnection:S}=N.getState(),b=T.type==="target",z=(k,v)=>{F(!1),j?.(k,r,T.type,v)},P=(k)=>$?.(r,k),s=(k,v)=>{F(!0),A?.(q,r,T.type),p?.(k,v)};EA.onPointerDown(q.nativeEvent,{autoPanOnConnect:O,connectionMode:E,connectionRadius:D,domNode:Z,handleId:T.id,nodeId:T.nodeId,nodeLookup:B,isTarget:b,edgeUpdaterType:T.type,lib:Y,flowId:m,cancelConnection:V,panBy:X,isValidConnection:(...k)=>N.getState().isValidConnection?.(...k)??!0,onConnect:P,onConnectStart:s,onConnectEnd:(...k)=>N.getState().onConnectEnd?.(...k),onReconnectEnd:z,updateConnection:S,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:q.currentTarget})},L=(q)=>W(q,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),J=(q)=>W(q,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),w=()=>U(!0),Q=()=>U(!1);return nl.jsxs(nl.Fragment,{children:[(l===!0||l==="source")&&nl.jsx(yW,{position:y,centerX:f,centerY:n,radius:u,onMouseDown:L,onMouseEnter:w,onMouseOut:Q,type:"source"}),(l===!0||l==="target")&&nl.jsx(yW,{position:c,centerX:i,centerY:t,radius:u,onMouseDown:J,onMouseEnter:w,onMouseOut:Q,type:"target"})]})}function CV({id:l,edgesFocusable:u,edgesReconnectable:r,elementsSelectable:f,onClick:n,onDoubleClick:i,onContextMenu:t,onMouseEnter:y,onMouseMove:c,onMouseLeave:$,reconnectRadius:A,onReconnect:j,onReconnectStart:F,onReconnectEnd:U,rfId:N,edgeTypes:W,noPanClassName:L,onError:J,disableKeyboardA11y:w}){let Q=yu((h)=>h.edgeLookup.get(l)),q=yu((h)=>h.defaultEdgeOptions);Q=q?{...q,...Q}:Q;let T=Q.type||"default",O=W?.[T]||nW[T];if(O===void 0)J?.("011",Qf.error011(T)),T="default",O=W?.default||nW.default;let Z=!!(Q.focusable||u&&typeof Q.focusable>"u"),E=typeof j<"u"&&(Q.reconnectable||r&&typeof Q.reconnectable>"u"),D=!!(Q.selectable||f&&typeof Q.selectable>"u"),Y=yl.useRef(null),[p,V]=yl.useState(!1),[B,m]=yl.useState(!1),X=Zu(),{zIndex:S,sourceX:b,sourceY:z,targetX:P,targetY:s,sourcePosition:k,targetPosition:v}=yu(yl.useCallback((h)=>{let a=h.nodeLookup.get(Q.source),ul=h.nodeLookup.get(Q.target);if(!a||!ul)return{zIndex:Q.zIndex,...iW};let zl=_q({id:l,sourceNode:a,targetNode:ul,sourceHandle:Q.sourceHandle||null,targetHandle:Q.targetHandle||null,connectionMode:h.connectionMode,onError:J});return{zIndex:yq({selected:Q.selected,zIndex:Q.zIndex,sourceNode:a,targetNode:ul,elevateOnSelect:h.elevateEdgesOnSelect,zIndexMode:h.zIndexMode}),...zl||iW}},[Q.source,Q.target,Q.sourceHandle,Q.targetHandle,Q.selected,Q.zIndex]),Eu),tl=yl.useMemo(()=>Q.markerStart?`url('#${mA(Q.markerStart,N)}')`:void 0,[Q.markerStart,N]),I=yl.useMemo(()=>Q.markerEnd?`url('#${mA(Q.markerEnd,N)}')`:void 0,[Q.markerEnd,N]);if(Q.hidden||b===null||z===null||P===null||s===null)return null;let M=(h)=>{let{addSelectedEdges:a,unselectNodesAndEdges:ul,multiSelectionActive:zl}=X.getState();if(D)if(X.setState({nodesSelectionActive:!1}),Q.selected&&zl)ul({nodes:[],edges:[Q]}),Y.current?.blur();else a([l]);if(n)n(h,Q)},rl=i?(h)=>{i(h,{...Q})}:void 0,cl=t?(h)=>{t(h,{...Q})}:void 0,$l=y?(h)=>{y(h,{...Q})}:void 0,Tl=c?(h)=>{c(h,{...Q})}:void 0,Ql=$?(h)=>{$(h,{...Q})}:void 0,Ol=(h)=>{if(!w&&G9.includes(h.key)&&D){let{unselectNodesAndEdges:a,addSelectedEdges:ul}=X.getState();if(h.key==="Escape")Y.current?.blur(),a({edges:[Q]});else ul([l])}};return nl.jsx("svg",{style:{zIndex:S},children:nl.jsxs("g",{className:bu(["react-flow__edge",`react-flow__edge-${T}`,Q.className,L,{selected:Q.selected,animated:Q.animated,inactive:!D&&!n,updating:p,selectable:D}]),onClick:M,onDoubleClick:rl,onContextMenu:cl,onMouseEnter:$l,onMouseMove:Tl,onMouseLeave:Ql,onKeyDown:Z?Ol:void 0,tabIndex:Z?0:void 0,role:Q.ariaRole??(Z?"group":"img"),"aria-roledescription":"edge","data-id":l,"data-testid":`rf__edge-${l}`,"aria-label":Q.ariaLabel===null?void 0:Q.ariaLabel||`Edge from ${Q.source} to ${Q.target}`,"aria-describedby":Z?`${FW}-${N}`:void 0,ref:Y,...Q.domAttributes,children:[!B&&nl.jsx(O,{id:l,source:Q.source,target:Q.target,type:Q.type,selected:Q.selected,animated:Q.animated,selectable:D,deletable:Q.deletable??!0,label:Q.label,labelStyle:Q.labelStyle,labelShowBg:Q.labelShowBg,labelBgStyle:Q.labelBgStyle,labelBgPadding:Q.labelBgPadding,labelBgBorderRadius:Q.labelBgBorderRadius,sourceX:b,sourceY:z,targetX:P,targetY:s,sourcePosition:k,targetPosition:v,data:Q.data,style:Q.style,sourceHandleId:Q.sourceHandle,targetHandleId:Q.targetHandle,markerStart:tl,markerEnd:I,pathOptions:"pathOptions"in Q?Q.pathOptions:void 0,interactionWidth:Q.interactionWidth}),E&&nl.jsx(PV,{edge:Q,isReconnectable:E,reconnectRadius:A,onReconnect:j,onReconnectStart:F,onReconnectEnd:U,sourceX:b,sourceY:z,targetX:P,targetY:s,sourcePosition:k,targetPosition:v,setUpdateHover:V,setReconnecting:m})]})})}var MV=yl.memo(CV),hV=(l)=>({edgesFocusable:l.edgesFocusable,edgesReconnectable:l.edgesReconnectable,elementsSelectable:l.elementsSelectable,connectionMode:l.connectionMode,onError:l.onError});function YW({defaultMarkerColor:l,onlyRenderVisibleElements:u,rfId:r,edgeTypes:f,noPanClassName:n,onReconnect:i,onEdgeContextMenu:t,onEdgeMouseEnter:y,onEdgeMouseMove:c,onEdgeMouseLeave:$,onEdgeClick:A,reconnectRadius:j,onEdgeDoubleClick:F,onReconnectStart:U,onReconnectEnd:N,disableKeyboardA11y:W}){let{edgesFocusable:L,edgesReconnectable:J,elementsSelectable:w,onError:Q}=yu(hV,Eu),q=KV(u);return nl.jsxs("div",{className:"react-flow__edges",children:[nl.jsx(pV,{defaultColor:l,rfId:r}),q.map((T)=>{return nl.jsx(MV,{id:T,edgesFocusable:L,edgesReconnectable:J,elementsSelectable:w,noPanClassName:n,onReconnect:i,onContextMenu:t,onMouseEnter:y,onMouseMove:c,onMouseLeave:$,onClick:A,reconnectRadius:j,onDoubleClick:F,onReconnectStart:U,onReconnectEnd:N,rfId:r,onError:Q,edgeTypes:f,disableKeyboardA11y:W},T)})]})}YW.displayName="EdgeRenderer";var RV=yl.memo(YW),xV=(l)=>`translate(${l.transform[0]}px,${l.transform[1]}px) scale(${l.transform[2]})`;function bV({children:l}){let u=yu(xV);return nl.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:u},children:l})}function vV(l){let u=d9(),r=yl.useRef(!1);yl.useEffect(()=>{if(!r.current&&u.viewportInitialized&&l)setTimeout(()=>l(u),1),r.current=!0},[l,u.viewportInitialized])}var sV=(l)=>l.panZoom?.syncViewport;function kV(l){let u=yu(sV),r=Zu();return yl.useEffect(()=>{if(l)u?.(l),r.setState({transform:[l.x,l.y,l.zoom]})},[l,u]),null}function cW(l){return l.connection.inProgress?{...l.connection,to:Oy(l.connection.to,l.transform)}:{...l.connection}}function gV(l){if(l)return(r)=>{let f=cW(r);return l(f)};return cW}function IV(l){let u=gV(l);return yu(u,Eu)}var aV=(l)=>({nodesConnectable:l.nodesConnectable,isValid:l.connection.isValid,inProgress:l.connection.inProgress,width:l.width,height:l.height});function oV({containerStyle:l,style:u,type:r,component:f}){let{nodesConnectable:n,width:i,height:t,isValid:y,inProgress:c}=yu(aV,Eu);if(!(i&&n&&c))return null;return nl.jsx("svg",{style:l,width:i,height:t,className:"react-flow__connectionline react-flow__container",children:nl.jsx("g",{className:bu(["react-flow__connection",K9(y)]),children:nl.jsx(PW,{style:u,type:r,CustomComponent:f,isValid:y})})})}var PW=({style:l,type:u=Gn.Bezier,CustomComponent:r,isValid:f})=>{let{inProgress:n,from:i,fromNode:t,fromHandle:y,fromPosition:c,to:$,toNode:A,toHandle:j,toPosition:F,pointer:U}=IV();if(!n)return;if(r)return nl.jsx(r,{connectionLineType:u,connectionLineStyle:l,fromNode:t,fromHandle:y,fromX:i.x,fromY:i.y,toX:$.x,toY:$.y,fromPosition:c,toPosition:F,connectionStatus:K9(f),toNode:A,toHandle:j,pointer:U});let N="",W={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:$.x,targetY:$.y,targetPosition:F};switch(u){case Gn.Bezier:[N]=GA(W);break;case Gn.SimpleBezier:[N]=KW(W);break;case Gn.Step:[N]=Ic({...W,borderRadius:0});break;case Gn.SmoothStep:[N]=Ic(W);break;default:[N]=TA(W)}return nl.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:l})};PW.displayName="ConnectionLine";var dV={};function _W(l=dV){let u=yl.useRef(l),r=Zu();yl.useEffect(()=>{},[l])}function eV(){let l=Zu(),u=yl.useRef(!1);yl.useEffect(()=>{},[])}function CW({nodeTypes:l,edgeTypes:u,onInit:r,onNodeClick:f,onEdgeClick:n,onNodeDoubleClick:i,onEdgeDoubleClick:t,onNodeMouseEnter:y,onNodeMouseMove:c,onNodeMouseLeave:$,onNodeContextMenu:A,onSelectionContextMenu:j,onSelectionStart:F,onSelectionEnd:U,connectionLineType:N,connectionLineStyle:W,connectionLineComponent:L,connectionLineContainerStyle:J,selectionKeyCode:w,selectionOnDrag:Q,selectionMode:q,multiSelectionKeyCode:T,panActivationKeyCode:O,zoomActivationKeyCode:Z,deleteKeyCode:E,onlyRenderVisibleElements:D,elementsSelectable:Y,defaultViewport:p,translateExtent:V,minZoom:B,maxZoom:m,preventScrolling:X,defaultMarkerColor:S,zoomOnScroll:b,zoomOnPinch:z,panOnScroll:P,panOnScrollSpeed:s,panOnScrollMode:k,zoomOnDoubleClick:v,panOnDrag:tl,onPaneClick:I,onPaneMouseEnter:M,onPaneMouseMove:rl,onPaneMouseLeave:cl,onPaneScroll:$l,onPaneContextMenu:Tl,paneClickDistance:Ql,nodeClickDistance:Ol,onEdgeContextMenu:h,onEdgeMouseEnter:a,onEdgeMouseMove:ul,onEdgeMouseLeave:zl,reconnectRadius:o,onReconnect:ql,onReconnectStart:pl,onReconnectEnd:Bl,noDragClassName:Il,noWheelClassName:nu,noPanClassName:Ml,disableKeyboardA11y:wu,nodeExtent:Qr,rfId:Or,viewport:$r,onViewportChange:ir}){return _W(l),_W(u),eV(),vV(r),kV($r),nl.jsx(UV,{onPaneClick:I,onPaneMouseEnter:M,onPaneMouseMove:rl,onPaneMouseLeave:cl,onPaneContextMenu:Tl,onPaneScroll:$l,paneClickDistance:Ql,deleteKeyCode:E,selectionKeyCode:w,selectionOnDrag:Q,selectionMode:q,onSelectionStart:F,onSelectionEnd:U,multiSelectionKeyCode:T,panActivationKeyCode:O,zoomActivationKeyCode:Z,elementsSelectable:Y,zoomOnScroll:b,zoomOnPinch:z,zoomOnDoubleClick:v,panOnScroll:P,panOnScrollSpeed:s,panOnScrollMode:k,panOnDrag:tl,defaultViewport:p,translateExtent:V,minZoom:B,maxZoom:m,onSelectionContextMenu:j,preventScrolling:X,noDragClassName:Il,noWheelClassName:nu,noPanClassName:Ml,disableKeyboardA11y:wu,onViewportChange:ir,isControlledViewport:!!$r,children:nl.jsxs(bV,{children:[nl.jsx(RV,{edgeTypes:u,onEdgeClick:n,onEdgeDoubleClick:t,onReconnect:ql,onReconnectStart:pl,onReconnectEnd:Bl,onlyRenderVisibleElements:D,onEdgeContextMenu:h,onEdgeMouseEnter:a,onEdgeMouseMove:ul,onEdgeMouseLeave:zl,reconnectRadius:o,defaultMarkerColor:S,noPanClassName:Ml,disableKeyboardA11y:wu,rfId:Or}),nl.jsx(oV,{style:W,type:N,component:L,containerStyle:J}),nl.jsx("div",{className:"react-flow__edgelabel-renderer"}),nl.jsx(mV,{nodeTypes:l,onNodeClick:f,onNodeDoubleClick:i,onNodeMouseEnter:y,onNodeMouseMove:c,onNodeMouseLeave:$,onNodeContextMenu:A,nodeClickDistance:Ol,onlyRenderVisibleElements:D,noPanClassName:Ml,noDragClassName:Il,disableKeyboardA11y:wu,nodeExtent:Qr,rfId:Or}),nl.jsx("div",{className:"react-flow__viewport-portal"})]})})}CW.displayName="GraphView";var lS=yl.memo(CW),$W=({nodes:l,edges:u,defaultNodes:r,defaultEdges:f,width:n,height:i,fitView:t,fitViewOptions:y,minZoom:c=0.5,maxZoom:$=2,nodeOrigin:A,nodeExtent:j,zIndexMode:F="basic"}={})=>{let U=new Map,N=new Map,W=new Map,L=new Map,J=f??u??[],w=r??l??[],Q=A??[0,0],q=j??my;v9(W,L,J);let{nodesInitialized:T}=KA(w,U,N,{nodeOrigin:Q,nodeExtent:q,zIndexMode:F}),O=[0,0,1];if(t&&n&&i){let Z=Ky(U,{filter:(p)=>!!((p.width||p.initialWidth)&&(p.height||p.initialHeight))}),{x:E,y:D,zoom:Y}=gc(Z,n,i,c,$,y?.padding??0.1);O=[E,D,Y]}return{rfId:"1",width:n??0,height:i??0,transform:O,nodes:w,nodesInitialized:T,nodeLookup:U,parentLookup:N,edges:J,edgeLookup:L,connectionLookup:W,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:f!==void 0,panZoom:null,minZoom:c,maxZoom:$,translateExtent:my,nodeExtent:q,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:si.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:Q,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:t??!1,fitViewOptions:y,fitViewResolver:null,connection:{...m9},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:B9,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:T9,zIndexMode:F,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},uS=({nodes:l,edges:u,defaultNodes:r,defaultEdges:f,width:n,height:i,fitView:t,fitViewOptions:y,minZoom:c,maxZoom:$,nodeOrigin:A,nodeExtent:j,zIndexMode:F})=>hq((U,N)=>{async function W(){let{nodeLookup:L,panZoom:J,fitViewOptions:w,fitViewResolver:Q,width:q,height:T,minZoom:O,maxZoom:Z}=N();if(!J)return;await uq({nodes:L,width:q,height:T,panZoom:J,minZoom:O,maxZoom:Z},w),Q?.resolve(!0),U({fitViewResolver:null})}return{...$W({nodes:l,edges:u,width:n,height:i,fitView:t,fitViewOptions:y,minZoom:c,maxZoom:$,nodeOrigin:A,nodeExtent:j,defaultNodes:r,defaultEdges:f,zIndexMode:F}),setNodes:(L)=>{let{nodeLookup:J,parentLookup:w,nodeOrigin:Q,elevateNodesOnSelect:q,fitViewQueued:T,zIndexMode:O,nodesSelectionActive:Z}=N(),{nodesInitialized:E,hasSelectedNodes:D}=KA(L,J,w,{nodeOrigin:Q,nodeExtent:j,elevateNodesOnSelect:q,checkEquality:!0,zIndexMode:O}),Y=Z&&D;if(T&&E)W(),U({nodes:L,nodesInitialized:E,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:Y});else U({nodes:L,nodesInitialized:E,nodesSelectionActive:Y})},setEdges:(L)=>{let{connectionLookup:J,edgeLookup:w}=N();v9(J,w,L),U({edges:L})},setDefaultNodesAndEdges:(L,J)=>{if(L){let{setNodes:w}=N();w(L),U({hasDefaultNodes:!0})}if(J){let{setEdges:w}=N();w(J),U({hasDefaultEdges:!0})}},updateNodeInternals:(L)=>{let{triggerNodeChanges:J,nodeLookup:w,parentLookup:Q,domNode:q,nodeOrigin:T,nodeExtent:O,debug:Z,fitViewQueued:E,zIndexMode:D}=N(),{changes:Y,updatedInternals:p}=Jq(L,w,Q,q,T,O,D);if(!p)return;if(jq(w,Q,{nodeOrigin:T,nodeExtent:O,zIndexMode:D}),E)W(),U({fitViewQueued:!1,fitViewOptions:void 0});else U({});if(Y?.length>0){if(Z)console.log("React Flow: trigger node changes",Y);J?.(Y)}},updateNodePositions:(L,J=!1)=>{let w=[],Q=[],{nodeLookup:q,triggerNodeChanges:T,connection:O,updateConnection:Z,onNodesChangeMiddlewareMap:E}=N();for(let[D,Y]of L){let p=q.get(D),V=!!(p?.expandParent&&p?.parentId&&Y?.position),B={id:D,type:"position",position:V?{x:Math.max(0,Y.position.x),y:Math.max(0,Y.position.y)}:Y.position,dragging:J};if(p&&O.inProgress&&O.fromNode.id===p.id){let m=gi(p,O.fromHandle,Kl.Left,!0);Z({...O,from:m})}if(V&&p.parentId)w.push({id:D,parentId:p.parentId,rect:{...Y.internals.positionAbsolute,width:Y.measured.width??0,height:Y.measured.height??0}});Q.push(B)}if(w.length>0){let{parentLookup:D,nodeOrigin:Y}=N(),p=zA(w,q,D,Y);Q.push(...p)}for(let D of E.values())Q=D(Q);T(Q)},triggerNodeChanges:(L)=>{let{onNodesChange:J,setNodes:w,nodes:Q,hasDefaultNodes:q,debug:T}=N();if(L?.length){if(q){let O=MD(L,Q);w(O)}if(T)console.log("React Flow: trigger node changes",L);J?.(L)}},triggerEdgeChanges:(L)=>{let{onEdgesChange:J,setEdges:w,edges:Q,hasDefaultEdges:q,debug:T}=N();if(L?.length){if(q){let O=hD(L,Q);w(O)}if(T)console.log("React Flow: trigger edge changes",L);J?.(L)}},addSelectedNodes:(L)=>{let{multiSelectionActive:J,edgeLookup:w,nodeLookup:Q,triggerNodeChanges:q,triggerEdgeChanges:T}=N();if(J){let O=L.map((Z)=>lt(Z,!0));q(O);return}q(Hy(Q,new Set([...L]),!0)),T(Hy(w))},addSelectedEdges:(L)=>{let{multiSelectionActive:J,edgeLookup:w,nodeLookup:Q,triggerNodeChanges:q,triggerEdgeChanges:T}=N();if(J){let O=L.map((Z)=>lt(Z,!0));T(O);return}T(Hy(w,new Set([...L]))),q(Hy(Q,new Set,!0))},unselectNodesAndEdges:({nodes:L,edges:J}={})=>{let{edges:w,nodes:Q,nodeLookup:q,triggerNodeChanges:T,triggerEdgeChanges:O}=N(),Z=L?L:Q,E=J?J:w,D=[];for(let p of Z){if(!p.selected)continue;let V=q.get(p.id);if(V)V.selected=!1;D.push(lt(p.id,!1))}let Y=[];for(let p of E){if(!p.selected)continue;Y.push(lt(p.id,!1))}T(D),O(Y)},setMinZoom:(L)=>{let{panZoom:J,maxZoom:w}=N();J?.setScaleExtent([L,w]),U({minZoom:L})},setMaxZoom:(L)=>{let{panZoom:J,minZoom:w}=N();J?.setScaleExtent([w,L]),U({maxZoom:L})},setTranslateExtent:(L)=>{N().panZoom?.setTranslateExtent(L),U({translateExtent:L})},resetSelectedElements:()=>{let{edges:L,nodes:J,triggerNodeChanges:w,triggerEdgeChanges:Q,elementsSelectable:q}=N();if(!q)return;let T=J.reduce((Z,E)=>E.selected?[...Z,lt(E.id,!1)]:Z,[]),O=L.reduce((Z,E)=>E.selected?[...Z,lt(E.id,!1)]:Z,[]);w(T),Q(O)},setNodeExtent:(L)=>{let{nodes:J,nodeLookup:w,parentLookup:Q,nodeOrigin:q,elevateNodesOnSelect:T,nodeExtent:O,zIndexMode:Z}=N();if(L[0][0]===O[0][0]&&L[0][1]===O[0][1]&&L[1][0]===O[1][0]&&L[1][1]===O[1][1])return;KA(J,w,Q,{nodeOrigin:q,nodeExtent:L,elevateNodesOnSelect:T,checkEquality:!1,zIndexMode:Z}),U({nodeExtent:L})},panBy:(L)=>{let{transform:J,width:w,height:Q,panZoom:q,translateExtent:T}=N();return Uq({delta:L,panZoom:q,transform:J,translateExtent:T,width:w,height:Q})},setCenter:async(L,J,w)=>{let{width:Q,height:q,maxZoom:T,panZoom:O}=N();if(!O)return Promise.resolve(!1);let Z=typeof w?.zoom<"u"?w.zoom:T;return await O.setViewport({x:Q/2-L*Z,y:q/2-J*Z,zoom:Z},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{U({connection:{...m9}})},updateConnection:(L)=>{U({connection:L})},reset:()=>U({...$W()})}},Object.is);function rS({initialNodes:l,initialEdges:u,defaultNodes:r,defaultEdges:f,initialWidth:n,initialHeight:i,initialMinZoom:t,initialMaxZoom:y,initialFitViewOptions:c,fitView:$,nodeOrigin:A,nodeExtent:j,zIndexMode:F,children:U}){let[N]=yl.useState(()=>uS({nodes:l,edges:u,defaultNodes:r,defaultEdges:f,width:n,height:i,fitView:$,minZoom:t,maxZoom:y,fitViewOptions:c,nodeOrigin:A,nodeExtent:j,zIndexMode:F}));return nl.jsx(WD,{value:N,children:nl.jsx(bD,{children:U})})}function fS({children:l,nodes:u,edges:r,defaultNodes:f,defaultEdges:n,width:i,height:t,fitView:y,fitViewOptions:c,minZoom:$,maxZoom:A,nodeOrigin:j,nodeExtent:F,zIndexMode:U}){if(yl.useContext(DA))return nl.jsx(nl.Fragment,{children:l});return nl.jsx(rS,{initialNodes:u,initialEdges:r,defaultNodes:f,defaultEdges:n,initialWidth:i,initialHeight:t,fitView:y,initialFitViewOptions:c,initialMinZoom:$,initialMaxZoom:A,nodeOrigin:j,nodeExtent:F,zIndexMode:U,children:l})}var nS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function iS({nodes:l,edges:u,defaultNodes:r,defaultEdges:f,className:n,nodeTypes:i,edgeTypes:t,onNodeClick:y,onEdgeClick:c,onInit:$,onMove:A,onMoveStart:j,onMoveEnd:F,onConnect:U,onConnectStart:N,onConnectEnd:W,onClickConnectStart:L,onClickConnectEnd:J,onNodeMouseEnter:w,onNodeMouseMove:Q,onNodeMouseLeave:q,onNodeContextMenu:T,onNodeDoubleClick:O,onNodeDragStart:Z,onNodeDrag:E,onNodeDragStop:D,onNodesDelete:Y,onEdgesDelete:p,onDelete:V,onSelectionChange:B,onSelectionDragStart:m,onSelectionDrag:X,onSelectionDragStop:S,onSelectionContextMenu:b,onSelectionStart:z,onSelectionEnd:P,onBeforeDelete:s,connectionMode:k,connectionLineType:v=Gn.Bezier,connectionLineStyle:tl,connectionLineComponent:I,connectionLineContainerStyle:M,deleteKeyCode:rl="Backspace",selectionKeyCode:cl="Shift",selectionOnDrag:$l=!1,selectionMode:Tl=o0.Full,panActivationKeyCode:Ql="Space",multiSelectionKeyCode:Ol=Zy()?"Meta":"Control",zoomActivationKeyCode:h=Zy()?"Meta":"Control",snapToGrid:a,snapGrid:ul,onlyRenderVisibleElements:zl=!1,selectNodesOnDrag:o,nodesDraggable:ql,autoPanOnNodeFocus:pl,nodesConnectable:Bl,nodesFocusable:Il,nodeOrigin:nu=JW,edgesFocusable:Ml,edgesReconnectable:wu,elementsSelectable:Qr=!0,defaultViewport:Or=DD,minZoom:$r=0.5,maxZoom:ir=2,translateExtent:tr=my,preventScrolling:hr=!0,nodeExtent:jl,defaultMarkerColor:ol="#b1b1b7",zoomOnScroll:wr=!0,zoomOnPinch:hl=!0,panOnScroll:Yu=!1,panOnScrollSpeed:eu=0.5,panOnScrollMode:rf=ui.Free,zoomOnDoubleClick:Ar=!0,panOnDrag:Zr=!0,onPaneClick:Zn,onPaneMouseEnter:ff,onPaneMouseMove:ii,onPaneMouseLeave:Au,onPaneScroll:nt,onPaneContextMenu:fl,paneClickDistance:Dl=1,nodeClickDistance:Cl=0,children:dl,onReconnect:ju,onReconnectStart:ku,onReconnectEnd:$u,onEdgeContextMenu:qr,onEdgeDoubleClick:Yf,onEdgeMouseEnter:Ry,onEdgeMouseMove:mu,onEdgeMouseLeave:F_,reconnectRadius:c6=10,onNodesChange:Fu,onEdgesChange:bj,noDragClassName:Pu="nodrag",noWheelClassName:pr="nowheel",noPanClassName:it="nopan",fitView:xy,fitViewOptions:tt,connectOnClick:J_,attributionPosition:by,proOptions:U_,defaultEdgeOptions:N_,elevateNodesOnSelect:y0=!0,elevateEdgesOnSelect:yt=!1,disableKeyboardA11y:c0=!1,autoPanOnConnect:Rr,autoPanOnNodeDrag:Lf,autoPanSpeed:Q_,connectionRadius:ct,isValidConnection:vy,onError:w_,style:fn,id:sy,nodeDragThreshold:Cu,connectionDragThreshold:_6,viewport:q_,onViewportChange:Pf,width:_0,height:$0,colorMode:_t="light",debug:A0,onScroll:$t,ariaLabelConfig:vj,zIndexMode:ti="basic",...sj},W_){let ky=sy||"1",$6=YD(_t),A6=yl.useCallback((pn)=>{pn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),$t?.(pn)},[$t]);return nl.jsx("div",{"data-testid":"rf__wrapper",...sj,onScroll:A6,style:{...fn,...nS},ref:W_,className:bu(["react-flow",n,$6]),id:sy,role:"application",children:nl.jsxs(fS,{nodes:l,edges:u,width:_0,height:$0,fitView:xy,fitViewOptions:tt,minZoom:$r,maxZoom:ir,nodeOrigin:nu,nodeExtent:jl,zIndexMode:ti,children:[nl.jsx(XD,{nodes:l,edges:u,defaultNodes:r,defaultEdges:f,onConnect:U,onConnectStart:N,onConnectEnd:W,onClickConnectStart:L,onClickConnectEnd:J,nodesDraggable:ql,autoPanOnNodeFocus:pl,nodesConnectable:Bl,nodesFocusable:Il,edgesFocusable:Ml,edgesReconnectable:wu,elementsSelectable:Qr,elevateNodesOnSelect:y0,elevateEdgesOnSelect:yt,minZoom:$r,maxZoom:ir,nodeExtent:jl,onNodesChange:Fu,onEdgesChange:bj,snapToGrid:a,snapGrid:ul,connectionMode:k,translateExtent:tr,connectOnClick:J_,defaultEdgeOptions:N_,fitView:xy,fitViewOptions:tt,onNodesDelete:Y,onEdgesDelete:p,onDelete:V,onNodeDragStart:Z,onNodeDrag:E,onNodeDragStop:D,onSelectionDrag:X,onSelectionDragStart:m,onSelectionDragStop:S,onMove:A,onMoveStart:j,onMoveEnd:F,noPanClassName:it,nodeOrigin:nu,rfId:ky,autoPanOnConnect:Rr,autoPanOnNodeDrag:Lf,autoPanSpeed:Q_,onError:w_,connectionRadius:ct,isValidConnection:vy,selectNodesOnDrag:o,nodeDragThreshold:Cu,connectionDragThreshold:_6,onBeforeDelete:s,debug:A0,ariaLabelConfig:vj,zIndexMode:ti}),nl.jsx(lS,{onInit:$,onNodeClick:y,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:Q,onNodeMouseLeave:q,onNodeContextMenu:T,onNodeDoubleClick:O,nodeTypes:i,edgeTypes:t,connectionLineType:v,connectionLineStyle:tl,connectionLineComponent:I,connectionLineContainerStyle:M,selectionKeyCode:cl,selectionOnDrag:$l,selectionMode:Tl,deleteKeyCode:rl,multiSelectionKeyCode:Ol,panActivationKeyCode:Ql,zoomActivationKeyCode:h,onlyRenderVisibleElements:zl,defaultViewport:Or,translateExtent:tr,minZoom:$r,maxZoom:ir,preventScrolling:hr,zoomOnScroll:wr,zoomOnPinch:hl,zoomOnDoubleClick:Ar,panOnScroll:Yu,panOnScrollSpeed:eu,panOnScrollMode:rf,panOnDrag:Zr,onPaneClick:Zn,onPaneMouseEnter:ff,onPaneMouseMove:ii,onPaneMouseLeave:Au,onPaneScroll:nt,onPaneContextMenu:fl,paneClickDistance:Dl,nodeClickDistance:Cl,onSelectionContextMenu:b,onSelectionStart:z,onSelectionEnd:P,onReconnect:ju,onReconnectStart:ku,onReconnectEnd:$u,onEdgeContextMenu:qr,onEdgeDoubleClick:Yf,onEdgeMouseEnter:Ry,onEdgeMouseMove:mu,onEdgeMouseLeave:F_,reconnectRadius:c6,defaultMarkerColor:ol,noDragClassName:Pu,noWheelClassName:pr,noPanClassName:it,rfId:ky,disableKeyboardA11y:c0,nodeExtent:jl,viewport:q_,onViewportChange:Pf}),nl.jsx(BD,{onSelectionChange:B}),dl,nl.jsx(ED,{proOptions:U_,position:by}),nl.jsx(zD,{rfId:ky,disableKeyboardA11y:c0})]})})}var MW=NW(iS);var $s=Qf.error014();function tS({dimensions:l,lineWidth:u,variant:r,className:f}){return nl.jsx("path",{strokeWidth:u,d:`M${l[0]/2} 0 V${l[1]} M0 ${l[1]/2} H${l[0]}`,className:bu(["react-flow__background-pattern",r,f])})}function yS({radius:l,className:u}){return nl.jsx("circle",{cx:l,cy:l,r:l,className:bu(["react-flow__background-pattern","dots",u])})}var ai;(function(l){l.Lines="lines",l.Dots="dots",l.Cross="cross"})(ai||(ai={}));var cS={[ai.Dots]:1,[ai.Lines]:1,[ai.Cross]:6},_S=(l)=>({transform:l.transform,patternId:`pattern-${l.rfId}`});function hW({id:l,variant:u=ai.Dots,gap:r=20,size:f,lineWidth:n=1,offset:i=0,color:t,bgColor:y,style:c,className:$,patternClassName:A}){let j=yl.useRef(null),{transform:F,patternId:U}=yu(_S,Eu),N=f||cS[u],W=u===ai.Dots,L=u===ai.Cross,J=Array.isArray(r)?r:[r,r],w=[J[0]*F[2]||1,J[1]*F[2]||1],Q=N*F[2],q=Array.isArray(i)?i:[i,i],T=L?[Q,Q]:w,O=[q[0]*F[2]||1+T[0]/2,q[1]*F[2]||1+T[1]/2],Z=`${U}${l?l:""}`;return nl.jsxs("svg",{className:bu(["react-flow__background",$]),style:{...c,...SA,"--xy-background-color-props":y,"--xy-background-pattern-color-props":t},ref:j,"data-testid":"rf__background",children:[nl.jsx("pattern",{id:Z,x:F[0]%w[0],y:F[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${O[0]},-${O[1]})`,children:W?nl.jsx(yS,{radius:Q/2,className:A}):nl.jsx(tS,{dimensions:T,lineWidth:n,variant:u,className:A})}),nl.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${Z})`})]})}hW.displayName="Background";var RW=yl.memo(hW);function $S(){return nl.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:nl.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function AS(){return nl.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:nl.jsx("path",{d:"M0 0h32v4.2H0z"})})}function jS(){return nl.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:nl.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function FS(){return nl.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:nl.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function JS(){return nl.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:nl.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function HA({children:l,className:u,...r}){return nl.jsx("button",{type:"button",className:bu(["react-flow__controls-button",u]),...r,children:l})}var US=(l)=>({isInteractive:l.nodesDraggable||l.nodesConnectable||l.elementsSelectable,minZoomReached:l.transform[2]<=l.minZoom,maxZoomReached:l.transform[2]>=l.maxZoom,ariaLabelConfig:l.ariaLabelConfig});function xW({style:l,showZoom:u=!0,showFitView:r=!0,showInteractive:f=!0,fitViewOptions:n,onZoomIn:i,onZoomOut:t,onFitView:y,onInteractiveChange:c,className:$,children:A,position:j="bottom-left",orientation:F="vertical","aria-label":U}){let N=Zu(),{isInteractive:W,minZoomReached:L,maxZoomReached:J,ariaLabelConfig:w}=yu(US,Eu),{zoomIn:Q,zoomOut:q,fitView:T}=d9(),O=()=>{Q(),i?.()},Z=()=>{q(),t?.()},E=()=>{T(n),y?.()},D=()=>{N.setState({nodesDraggable:!W,nodesConnectable:!W,elementsSelectable:!W}),c?.(!W)};return nl.jsxs(VA,{className:bu(["react-flow__controls",F==="horizontal"?"horizontal":"vertical",$]),position:j,style:l,"data-testid":"rf__controls","aria-label":U??w["controls.ariaLabel"],children:[u&&nl.jsxs(nl.Fragment,{children:[nl.jsx(HA,{onClick:O,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:J,children:nl.jsx($S,{})}),nl.jsx(HA,{onClick:Z,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:L,children:nl.jsx(AS,{})})]}),r&&nl.jsx(HA,{className:"react-flow__controls-fitview",onClick:E,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:nl.jsx(jS,{})}),f&&nl.jsx(HA,{className:"react-flow__controls-interactive",onClick:D,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:W?nl.jsx(JS,{}):nl.jsx(FS,{})}),A]})}xW.displayName="Controls";var bW=yl.memo(xW);function NS({id:l,x:u,y:r,width:f,height:n,style:i,color:t,strokeColor:y,strokeWidth:c,className:$,borderRadius:A,shapeRendering:j,selected:F,onClick:U}){let{background:N,backgroundColor:W}=i||{},L=t||N||W;return nl.jsx("rect",{className:bu(["react-flow__minimap-node",{selected:F},$]),x:u,y:r,rx:A,ry:A,width:f,height:n,style:{fill:L,stroke:y,strokeWidth:c},shapeRendering:j,onClick:U?(J)=>U(J,l):void 0})}var QS=yl.memo(NS),wS=(l)=>l.nodes.map((u)=>u.id),I9=(l)=>l instanceof Function?l:()=>l;function qS({nodeStrokeColor:l,nodeColor:u,nodeClassName:r="",nodeBorderRadius:f=5,nodeStrokeWidth:n,nodeComponent:i=QS,onClick:t}){let y=yu(wS,Eu),c=I9(u),$=I9(l),A=I9(r),j=typeof window>"u"||!!window.chrome?"crispEdges":"geometricPrecision";return nl.jsx(nl.Fragment,{children:y.map((F)=>nl.jsx(LS,{id:F,nodeColorFunc:c,nodeStrokeColorFunc:$,nodeClassNameFunc:A,nodeBorderRadius:f,nodeStrokeWidth:n,NodeComponent:i,onClick:t,shapeRendering:j},F))})}function WS({id:l,nodeColorFunc:u,nodeStrokeColorFunc:r,nodeClassNameFunc:f,nodeBorderRadius:n,nodeStrokeWidth:i,shapeRendering:t,NodeComponent:y,onClick:c}){let{node:$,x:A,y:j,width:F,height:U}=yu((N)=>{let W=N.nodeLookup.get(l);if(!W)return{node:void 0,x:0,y:0,width:0,height:0};let L=W.internals.userNode,{x:J,y:w}=W.internals.positionAbsolute,{width:Q,height:q}=Tn(L);return{node:L,x:J,y:w,width:Q,height:q}},Eu);if(!$||$.hidden||!D9($))return null;return nl.jsx(y,{x:A,y:j,width:F,height:U,style:$.style,selected:!!$.selected,className:f($),color:u($),borderRadius:n,strokeColor:r($),strokeWidth:i,shapeRendering:t,onClick:c,id:$.id})}var LS=yl.memo(WS),GS=yl.memo(qS),TS=200,mS=150,KS=(l)=>!l.hidden,zS=(l)=>{let u={x:-l.transform[0]/l.transform[2],y:-l.transform[1]/l.transform[2],width:l.width/l.transform[2],height:l.height/l.transform[2]};return{viewBB:u,boundingRect:l.nodeLookup.size>0?p9(Ky(l.nodeLookup,{filter:KS}),u):u,rfId:l.rfId,panZoom:l.panZoom,translateExtent:l.translateExtent,flowWidth:l.width,flowHeight:l.height,ariaLabelConfig:l.ariaLabelConfig}},ES="react-flow__minimap-desc";function vW({style:l,className:u,nodeStrokeColor:r,nodeColor:f,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:t,nodeComponent:y,bgColor:c,maskColor:$,maskStrokeColor:A,maskStrokeWidth:j,position:F="bottom-right",onClick:U,onNodeClick:N,pannable:W=!1,zoomable:L=!1,ariaLabel:J,inversePan:w,zoomStep:Q=1,offsetScale:q=5}){let T=Zu(),O=yl.useRef(null),{boundingRect:Z,viewBB:E,rfId:D,panZoom:Y,translateExtent:p,flowWidth:V,flowHeight:B,ariaLabelConfig:m}=yu(zS,Eu),X=l?.width??TS,S=l?.height??mS,b=Z.width/X,z=Z.height/S,P=Math.max(b,z),s=P*X,k=P*S,v=q*P,tl=Z.x-(s-Z.width)/2-v,I=Z.y-(k-Z.height)/2-v,M=s+v*2,rl=k+v*2,cl=`${ES}-${D}`,$l=yl.useRef(0),Tl=yl.useRef();$l.current=P,yl.useEffect(()=>{if(O.current&&Y)return Tl.current=Gq({domNode:O.current,panZoom:Y,getTransform:()=>T.getState().transform,getViewScale:()=>$l.current}),()=>{Tl.current?.destroy()}},[Y]),yl.useEffect(()=>{Tl.current?.update({translateExtent:p,width:V,height:B,inversePan:w,pannable:W,zoomStep:Q,zoomable:L})},[W,L,w,Q,p,V,B]);let Ql=U?(a)=>{let[ul,zl]=Tl.current?.pointer(a)||[0,0];U(a,{x:ul,y:zl})}:void 0,Ol=N?yl.useCallback((a,ul)=>{let zl=T.getState().nodeLookup.get(ul).internals.userNode;N(a,zl)},[]):void 0,h=J??m["minimap.ariaLabel"];return nl.jsx(VA,{position:F,style:{...l,"--xy-minimap-background-color-props":typeof c==="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof $==="string"?$:void 0,"--xy-minimap-mask-stroke-color-props":typeof A==="string"?A:void 0,"--xy-minimap-mask-stroke-width-props":typeof j==="number"?j*P:void 0,"--xy-minimap-node-background-color-props":typeof f==="string"?f:void 0,"--xy-minimap-node-stroke-color-props":typeof r==="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof t==="number"?t:void 0},className:bu(["react-flow__minimap",u]),"data-testid":"rf__minimap",children:nl.jsxs("svg",{width:X,height:S,viewBox:`${tl} ${I} ${M} ${rl}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":cl,ref:O,onClick:Ql,children:[h&&nl.jsx("title",{id:cl,children:h}),nl.jsx(GS,{onClick:Ol,nodeColor:f,nodeStrokeColor:r,nodeBorderRadius:i,nodeClassName:n,nodeStrokeWidth:t,nodeComponent:y}),nl.jsx("path",{className:"react-flow__minimap-mask",d:`M${tl-v},${I-v}h${M+v*2}v${rl+v*2}h${-M-v*2}z + M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}vW.displayName="MiniMap";var As=yl.memo(vW),OS=(l)=>(u)=>l?`${Math.max(1/u.transform[2],1)}`:void 0,ZS={[Ii.Line]:"right",[Ii.Handle]:"bottom-right"};function pS({nodeId:l,position:u,variant:r=Ii.Handle,className:f,style:n=void 0,children:i,color:t,minWidth:y=10,minHeight:c=10,maxWidth:$=Number.MAX_VALUE,maxHeight:A=Number.MAX_VALUE,keepAspectRatio:j=!1,resizeDirection:F,autoScale:U=!0,shouldResize:N,onResizeStart:W,onResize:L,onResizeEnd:J}){let w=WW(),Q=typeof l==="string"?l:w,q=Zu(),T=yl.useRef(null),O=r===Ii.Handle,Z=yu(yl.useCallback(OS(O&&U),[O,U]),Eu),E=yl.useRef(null),D=u??ZS[r];yl.useEffect(()=>{if(!T.current||!Q)return;if(!E.current)E.current=Eq({domNode:T.current,nodeId:Q,getStoreItems:()=>{let{nodeLookup:p,transform:V,snapGrid:B,snapToGrid:m,nodeOrigin:X,domNode:S}=q.getState();return{nodeLookup:p,transform:V,snapGrid:B,snapToGrid:m,nodeOrigin:X,paneDomNode:S}},onChange:(p,V)=>{let{triggerNodeChanges:B,nodeLookup:m,parentLookup:X,nodeOrigin:S}=q.getState(),b=[],z={x:p.x,y:p.y},P=m.get(Q);if(P&&P.expandParent&&P.parentId){let s=P.origin??S,k=p.width??P.measured.width??0,v=p.height??P.measured.height??0,tl={id:P.id,parentId:P.parentId,rect:{width:k,height:v,...V9({x:p.x??P.position.x,y:p.y??P.position.y},{width:k,height:v},P.parentId,m,s)}},I=zA([tl],m,X,S);b.push(...I),z.x=p.x?Math.max(s[0]*k,p.x):void 0,z.y=p.y?Math.max(s[1]*v,p.y):void 0}if(z.x!==void 0&&z.y!==void 0){let s={id:Q,type:"position",position:{...z}};b.push(s)}if(p.width!==void 0&&p.height!==void 0){let k={id:Q,type:"dimensions",resizing:!0,setAttributes:!F?!0:F==="horizontal"?"width":"height",dimensions:{width:p.width,height:p.height}};b.push(k)}for(let s of V){let k={...s,type:"position"};b.push(k)}B(b)},onEnd:({width:p,height:V})=>{let B={id:Q,type:"dimensions",resizing:!1,dimensions:{width:p,height:V}};q.getState().triggerNodeChanges([B])}});return E.current.update({controlPosition:D,boundaries:{minWidth:y,minHeight:c,maxWidth:$,maxHeight:A},keepAspectRatio:j,resizeDirection:F,onResizeStart:W,onResize:L,onResizeEnd:J,shouldResize:N}),()=>{E.current?.destroy()}},[D,y,c,$,A,j,W,L,J,N]);let Y=D.split("-");return nl.jsx("div",{className:bu(["react-flow__resize-control","nodrag",...Y,r,f]),ref:T,style:{...n,scale:Z,...t&&{[O?"backgroundColor":"borderColor"]:t}},children:i})}var js=yl.memo(pS);var K=l0.default.createElement,{useEffect:zn}=l0.default,dr=l0.default.useState,ei=l0.default.useRef,r_=[{id:"in-left",side:"left",position:Kl.Left,style:{top:"50%"}},{id:"in-top-left",side:"top",slot:"left",slotIndex:-1,position:Kl.Top,style:{left:"28%"}},{id:"in-top-mid",side:"top",slot:"mid",slotIndex:0,position:Kl.Top,style:{left:"50%"}},{id:"in-top-right",side:"top",slot:"right",slotIndex:1,position:Kl.Top,style:{left:"72%"}},{id:"in-bottom-left",side:"bottom",slot:"left",slotIndex:-1,position:Kl.Bottom,style:{left:"28%"}},{id:"in-bottom-mid",side:"bottom",slot:"mid",slotIndex:0,position:Kl.Bottom,style:{left:"50%"}},{id:"in-bottom-right",side:"bottom",slot:"right",slotIndex:1,position:Kl.Bottom,style:{left:"72%"}}],ec=[{id:"out-right",position:Kl.Right,style:{top:"50%"}}],sW=["#4eb7a8","#d7a13a","#69aee8","#e0835f","#b7d86b","#d98bd2","#5fc6bf"],Vy=236,Sy=88,kW=15000,HS=10,lj=96,mn=72,uj=64,gW=12;function XA(){return typeof document>"u"||document.visibilityState!=="hidden"}function IW(l,u){let r=Number.parseFloat(String(l||""));return Number.isFinite(r)?r/100:u}function BS(l,u,r){let f=String(l.side||"");if(f!=="top"&&f!=="bottom")return 0;let n=Number(l.slotIndex||0),i=f==="top"?"in-top-mid":"in-bottom-mid",t=u.get(l.id)||0,y=u.get(i)||0;if(n===0)return y===0?-26:28+t*74;let c=r===0?Math.abs(n)*2:Math.sign(r)===Math.sign(n)?-3:3;if(y>0&&t===0)return-14+c;return 8+t*74+c}function YA(l){let u=l.filter((i,t)=>{let y=l[t-1];return!y||Math.abs(y.x-i.x)>0.5||Math.abs(y.y-i.y)>0.5});if(u.length<2)return"";let r=`M ${u[0].x},${u[0].y}`,f=u[0];for(let i=1;i<u.length-1;i+=1){let t=u[i-1],y=u[i],c=u[i+1],$=Math.hypot(y.x-t.x,y.y-t.y),A=Math.hypot(c.x-y.x,c.y-y.y),j=Math.min(64,$*0.42,A*0.42);if(j<2){r+=` L ${y.x},${y.y}`,f=y;continue}let F={x:y.x+(t.x-y.x)/$*j,y:y.y+(t.y-y.y)/$*j},U={x:y.x+(c.x-y.x)/A*j,y:y.y+(c.y-y.y)/A*j};if(Math.abs(F.x-f.x)>0.5||Math.abs(F.y-f.y)>0.5)r+=` L ${F.x},${F.y}`;r+=` Q ${y.x},${y.y} ${U.x},${U.y}`,f=U}let n=u[u.length-1];return`${r} L ${n.x},${n.y}`}function FL(l,u,r,f,n,i,t=""){let y=r>=l,c=Math.max(1,Math.abs(r-l)),$=Math.abs(f-u),A=Math.max(34,Math.min(118,c*0.26)),j=Math.min(280,Math.abs(i));if(y&&n===Kl.Left&&j<4&&$<28&&c<420)return`M ${l},${u} C ${l+A},${u} ${r-A},${f} ${r},${f}`;if(y&&n===Kl.Left&&(t==="direct-forward-left"||c<=260&&$<=210)){let J=Math.max(42,Math.min(140,c*0.48)),w=Math.max(-28,Math.min(28,i*0.18));return`M ${l},${u} C ${l+J},${u+w} ${r-J},${f} ${r},${f}`}if(y){let J=l+A;if(n===Kl.Top||n===Kl.Bottom){let q=n===Kl.Top?-1:1,T=f+q*(54+j*0.42);return YA([{x:l,y:u},{x:J,y:u},{x:J+Math.min(120,c*0.18),y:T},{x:r,y:T},{x:r,y:f+q*34},{x:r,y:f}])}let w=r-A,Q=(u+f)/2+i;return YA([{x:l,y:u},{x:J,y:u},{x:J+Math.min(110,c*0.16),y:Q},{x:w-Math.min(90,c*0.12),y:Q},{x:w,y:f},{x:r,y:f}])}let N=n===Kl.Bottom?1:n===Kl.Top?-1:i>=0?1:-1,W=Math.max(l,r)+92+Math.min(180,j*0.52),L=N<0?Math.min(u,f)-84-j*0.62:Math.max(u,f)+84+j*0.62;if(n===Kl.Top||n===Kl.Bottom)return YA([{x:l,y:u},{x:l+A,y:u},{x:W,y:L},{x:r,y:L},{x:r,y:f+N*38},{x:r,y:f}]);return YA([{x:l,y:u},{x:l+A,y:u},{x:W,y:L},{x:r-A,y:L},{x:r-A,y:f},{x:r,y:f}])}function DS({data:l}){return K("div",{className:"pipeline-flow-node-body"},r_.map((u)=>K(ut,{key:u.id,id:u.id,type:"target",position:u.position,isConnectable:!1,className:`pipeline-flow-handle input ${u.side} slot-${u.slot||"mid"}`,style:u.style})),ec.map((u)=>K(ut,{key:u.id,id:u.id,type:"source",position:u.position,isConnectable:!1,className:"pipeline-flow-handle output right",style:u.style})),l?.label)}function VS({id:l,sourceX:u,sourceY:r,targetX:f,targetY:n,targetPosition:i,markerEnd:t,markerStart:y,style:c,data:$}){let A=Number($?.laneOffset||0),j=FL(u,r,f,n,i,A,String($?.routeMode||""));return K(By,{id:l,path:j,markerEnd:t,markerStart:y,style:c,interactionWidth:28})}var SS={pipelineCurve:VS},XS={pipelineNode:DS};function hA(l){if(!l)return"--";let u=new Date(l);if(Number.isNaN(u.getTime()))return"--";return iu(u)}function Vf(l){let u=Number(l);if(!Number.isFinite(u)||u<0)return"--";let r=Math.round(u/1000);if(r<60)return`${r}s`;if(r<3600)return`${Math.floor(r/60)}m ${r%60}s`;return`${Math.floor(r/3600)}h ${Math.floor(r%3600/60)}m`}function rj(l){let u=Number(l);if(!Number.isFinite(u))return"--";return u.toLocaleString("zh-CN")}function aW(l){let u=Number(l);if(!Number.isFinite(u))return"--";return`${Math.round(Math.max(0,Math.min(1,u))*100)}%`}function Yl(l){return typeof l==="object"&&l!==null&&!Array.isArray(l)}function Sl(l){return Array.isArray(l)?l:[]}function al(l){if(!l)return null;let u=new Date(l);return Number.isNaN(u.getTime())?null:u.getTime()}function f_(l){return Number.isFinite(Number(l))?new Date(Number(l)).toISOString():""}function t_(...l){for(let u of l){let r=al(u);if(r!==null)return new Date(r).toISOString()}return""}function Qj(...l){let u=l.map(al).filter((r)=>r!==null);return u.length>0?new Date(Math.max(...u)).toISOString():""}function wj(l){return["succeeded","failed","skipped","cancelled","canceled","completed"].includes(String(l||"").toLowerCase())}function JL(l){let u=QL(l).toLowerCase();return["running","active","in-progress","in_progress"].includes(u)}function oW(l,u="status"){return l.reduce((r,f)=>{let n=String(f?.[u]||"unknown").toLowerCase();return r[n]=(r[n]||0)+1,r},{})}function UL(l){if(!l||typeof l!=="string")return null;try{let u=JSON.parse(l);return Yl(u)?u:null}catch{return null}}function fj(l){let u=l.map(UL).filter((i)=>Boolean(i)),r=u.flatMap((i)=>[i.timestamp,i.createdAt,i.updatedAt]).filter(Boolean),f=Qj(...r),n=Array.from(new Set(u.map((i)=>String(i.event||i.action||i.type||"")).filter(Boolean))).slice(0,3);return{total:l.length,parsed:u.length,lastAt:f,eventKinds:n}}function RA(l){if(l===null||l===void 0)return"--";if(typeof l==="boolean")return l?"是":"否";if(typeof l==="number")return String(l);if(typeof l==="string")return l.length>80?`${l.slice(0,77)}...`:l;if(Array.isArray(l))return`${l.length} 项`;if(typeof l==="object")return`${Object.keys(l).length} 字段`;return String(l)}function NL(l,u=280){if(l===null||l===void 0)return"";let f=(typeof l==="string"?l:String(l)).replace(/\r\n/gu,` +`).trim();return f.length>u?`${f.slice(0,Math.max(0,u-1))}...`:f}function QL(l){if(typeof l==="string")return l;if(Yl(l))return String(l.status||l.state||l.phase||"unknown");return"unknown"}function YS(l){return l.filter((u)=>u&&u.value!==void 0&&u.value!==null&&String(u.value)!=="")}function _j({items:l}){let u=YS(Sl(l));return K("div",{className:"pipeline-kv-grid"},u.map((r)=>K("span",{key:r.label},K("b",null,r.label),K("span",null,r.value))))}function qj({items:l}){let u=Sl(l).map((r)=>String(r||"")).filter(Boolean);if(u.length===0)return null;return K("div",{className:"pipeline-chip-row"},u.map((r,f)=>K("span",{key:`${f}-${r}`},r)))}function $j(l,u){let r=String(u?.procedureRunId||""),f=Sl(l?.procedureRuns);return f.find((n)=>String(Sf(n))===r)||f.at(-1)||null}function PS(l,u){let r=String(u||"");if(!r)return null;return Sl(l?.procedureRuns).find((f)=>Sf(f)===r)||null}function nj(l){return Sl(l?.attempts).length}function dW(l){return Sl(l?.attempts).reduce((u,r)=>u+IA(r).length,0)}function IA(l){return Sl(l?.opencodeMessages?.steps).filter(Yl)}function wL(l){let u=String(l?.status||"").toLowerCase();if(["error","failed","failure"].includes(u))return"failed";if(["completed","succeeded","success"].includes(u))return"succeeded";if(["running","started","in_progress"].includes(u))return"running";return"unknown"}function CS(l,u){let r=jj(l.map((i)=>i?.agent)).slice(0,3),f=jj(l.map((i)=>i?.model)).slice(0,3),n=u.length<=2?u.map((i)=>`session ${i}`):[`sessions ${u.length}`,...u.slice(0,2).map((i)=>`session ${i}`)];return[...r.map((i)=>`agent ${i}`),...f.map((i)=>`model ${i}`),...n]}function l_(l,u=0){return String(l?.messageId||l?.index||"")||`step-${u}`}function MS({steps:l,sessionIds:u,sessionFacts:r,matchedStepKey:f}){let n=Sl(l),i=n.findIndex((L,J)=>l_(L,J)===f),t=i>=0?n[i]:null,y=n.flatMap((L)=>[al(L?.createdAt),al(L?.completedAt)]).filter((L)=>L!==null),c=y.length>0?Math.min(...y):null,$=y.length>0?Math.max(...y):null,A=c!==null&&$!==null?Math.max(0,$-c):null,j=n.reduce((L,J)=>L+Sl(J?.parts).filter((w)=>String(w?.type||"").toLowerCase()==="tool").length,0),F=n.reduce((L,J)=>L+Sl(J?.parts).filter((w)=>["text","reasoning"].includes(String(w?.type||"").toLowerCase())).length,0),U=n.reduce((L,J)=>L+Sl(J?.parts).filter((w)=>String(w?.type||"").toLowerCase()==="tool"&&wL(w)==="failed").length,0),N=[`${n.length} steps`,`${u.length} sessions`,`${F} messages`,`${j} tools`,A!==null?`duration ${Vf(A)}`:"",U>0?`${U} failed tools`:""].filter(Boolean),W=t?[`Step ${t?.index??i+1}`,String(t?.role||"role --"),t?.model?`model ${t.model}`:"",t?.finish?`finish ${t.finish}`:"",t?.durationMs!==void 0&&t?.durationMs!==null?`duration ${Vf(t.durationMs)}`:""].filter(Boolean):[];return K("section",{className:"pipeline-trace-timeline","data-testid":"pipeline-step-timeline"},K("div",{className:"pipeline-trace-head"},K("div",null,K("b",null,"OpenCode Trace"),K("span",null,"Trace 使用 Code Queue 统一样式展示完整 agent loop;Pipeline 旧 step/message/tool 卡片样式已废弃。")),K("div",{className:"pipeline-trace-session-head","data-testid":"pipeline-step-timeline-session"},K("span",null,N.join(" / ")||"Trace"),r.length>0?K(qj,{items:r}):null)),t?K("div",{className:"pipeline-trace-focus","data-testid":"pipeline-trace-matched-step"},K("span",{className:"codex-output-channel"},"Matched"),K("strong",null,`Gantt selection -> ${W.join(" / ")}`),K("time",null,`${hA(t?.createdAt)} -> ${hA(t?.completedAt)}`)):null,K(n3,{port:pN,input:n,className:"codex-transcript pipeline-trace",testId:"pipeline-opencode-step-trace",emptyText:"暂无 OpenCode Trace 输出",keepRecentToolCalls:3}))}function Aj(l){return Sl(l).flatMap((u)=>{if(Yl(u))return[u];let r=UL(u);return r?[r]:[]})}function un(l){return String(l?.event||l?.action||l?.requestedAction||l?.type||"").toLowerCase()}function Dy(l){return t_(l?.timestamp,l?.createdAt,l?.updatedAt,l?.startedAt,l?.finishedAt)}function hS(l){return al(Dy(l))}function aA(l){return String(l?.attempt||l?.id||"")}function jj(l){let u=new Set,r=[];for(let f of l){let n=String(f||"");if(!n||u.has(n))continue;u.add(n),r.push(n)}return r}function eW(l){switch(String(l||"").toLowerCase()){case"monitor":return"monitor";case"webui":return"webui";case"cli":return"cli";case"system":return"runner";default:return String(l||"--")}}function rt(l){return String(l?.requestedAction||l?.action||"").toLowerCase()}function u_(l){switch(rt(l)){case"guide":return"引导";case"modify":return"修改";case"approve":return"审核通过";case"restart":return"重启";case"redo":return"重做";default:return String(l?.requestedAction||l?.action||"控制")}}function lL(l){switch(un(l)){case"initial-prompt-delivered":return"初始 prompt";case"append-prompt-delivered":return"追加 prompt";case"append-prompt-queued":return"追加 prompt 已排队";case"monitor-prompt-delivered":return"Monitor prompt";case"node-long-running-observation":return"长任务观察";case"node-finished":return"节点完成";case"oa-policy-downstream-evaluated":return"OA 下游策略";case"control-command-queued":return`${u_(l)} 已发起`;case"control-command-applied":return`${u_(l)} 已生效`;case"control-command-ignored":return`${u_(l)} 已忽略`;default:return String(l?.event||l?.action||l?.requestedAction||"event")}}function uL(l){return NL(l?.promptPreview||l?.reasonPreview||l?.prompt||l?.reason||"",240)}function RS(l){let u=String(l?.prompt||""),r=String(l?.reason||l?.restartReason||""),f=u?"":String(l?.promptPreview||""),n=r?"":String(l?.reasonPreview||"");return[u||f?{label:u?"prompt":"prompt preview",value:u||f}:null,r||n?{label:r?"reason":"reason preview",value:r||n}:null,Sl(l?.resetNodeIds).length>0?{label:"reset nodes",value:Sl(l.resetNodeIds).join(", ")}:null,Sl(l?.runningResetNodeIds).length>0?{label:"interrupted running nodes",value:Sl(l.runningResetNodeIds).join(", ")}:null,Sl(l?.interruptedProcedureRunIds).length>0?{label:"interrupted procedures",value:Sl(l.interruptedProcedureRunIds).join(", ")}:null,l?.interruptedProcedureRunId?{label:"interrupted procedure",value:String(l.interruptedProcedureRunId)}:null].filter(Boolean)}function ij(l){let u=IA(l),r=u.map((c)=>al(c?.createdAt)).filter((c)=>c!==null),f=u.map((c)=>al(c?.completedAt)??al(c?.createdAt)).filter((c)=>c!==null),n=Aj(l?.controlEventRecords).map((c)=>hS(c)).filter((c)=>c!==null),i=Sl(l?.assistantOutputs).map((c)=>al(c?.updatedAt)).filter((c)=>c!==null),t=r[0]??n[0]??i[0]??null,y=f.at(-1)??n.at(-1)??i.at(-1)??t;return{startMs:t,endMs:y}}function xS(l,u,r,f,n=""){let i=Sl(l?.procedureRuns).filter((y)=>oA(y,u)===r);if(i.length===0)return null;if(n){let y=i.find((c)=>Sf(c)===n);if(y)return y}if(f===null)return i.at(-1)||null;let t=i.find((y)=>{let c=al(PA(y,l)),$=al(CA(y,l))??c;return c!==null&&$!==null&&f>=c-1000&&f<=$+1000});if(t)return t;return i.slice().sort((y,c)=>{let $=al(PA(y,l))??f,A=al(CA(y,l))??$,j=al(PA(c,l))??f,F=al(CA(c,l))??j,U=Math.min(Math.abs($-f),Math.abs(A-f)),N=Math.min(Math.abs(j-f),Math.abs(F-f));return U-N})[0]||null}function qL(l,u){let r=Sl(l?.attempts).filter(Yl);if(r.length===0)return null;let f=String(u?.attempt||"");if(f){let t=r.find((y)=>aA(y)===f);if(t)return t}let n=Number.isFinite(Number(u?.ms))?Number(u.ms):null;if(n===null)return r.at(-1)||null;let i=r.find((t)=>{let y=ij(t);return Number.isFinite(y.startMs)&&Number.isFinite(y.endMs)&&n>=Number(y.startMs)-1000&&n<=Number(y.endMs)+1000});if(i)return i;return r.slice().sort((t,y)=>{let c=ij(t),$=ij(y),A=Math.min(Math.abs(Number(c.startMs??n)-n),Math.abs(Number(c.endMs??n)-n)),j=Math.min(Math.abs(Number($.startMs??n)-n),Math.abs(Number($.endMs??n)-n));return A-j})[0]||r.at(-1)||null}function WL(l,u){let r=IA(l);if(r.length===0)return{step:null,stepIndex:-1,stepKey:""};if(u===null){let i=r[0];return{step:i,stepIndex:0,stepKey:l_(i,0)}}for(let i=0;i<r.length;i+=1){let t=r[i],y=al(t?.createdAt)??al(t?.completedAt),c=al(t?.completedAt)??y;if(y!==null&&c!==null&&u>=y-1000&&u<=c+1000)return{step:t,stepIndex:i,stepKey:l_(t,i)}}let f=r.findIndex((i)=>{let t=al(i?.createdAt)??al(i?.completedAt);return t!==null&&t>=u});if(f>=0){let i=r[f];return{step:i,stepIndex:f,stepKey:l_(i,f)}}let n=Math.max(0,r.length-1);return{step:r[n],stepIndex:n,stepKey:l_(r[n],n)}}function bS(l,u){let r=String(u?.runId||l?.runId||"");if(String(u?.mode||"")==="interval"){let $=u?.interval||{},A=$j(l,$)||$.raw||{};return{mode:"interval",runId:r,interval:$,marker:null,nodeId:String($?.nodeId||oA(A,r)||""),procedure:A,attempt:null,matchedStep:null,matchedStepIndex:-1,matchedStepKey:""}}let f=Yl(u?.marker)?u.marker:{},n=Number.isFinite(Number(f?.ms))?Number(f.ms):null,i=String(f?.nodeId||""),t=i?xS(l,r,i,n,String(f?.procedureRunId||"")):null,y=t?qL(t,f):null,c=y?WL(y,n):{step:null,stepIndex:-1,stepKey:""};return{mode:"event",runId:r,interval:null,marker:f,nodeId:i,procedure:t,attempt:y,matchedStep:c.step,matchedStepIndex:c.stepIndex,matchedStepKey:c.stepKey}}function vS({procedure:l,matchedStepKey:u="",matchedAttemptId:r=""}){let f=Sl(l?.attempts);if(f.length===0)return K(qf,{title:"暂无 attempt 详情",text:"当前 procedure 还没有可展示的 attempt / OpenCode Trace;若刚点击甘特线,请等待 node 详情抓取完成。"});return f.map((n,i)=>{let t=n?.opencodeMessages||{},y=IA(n),c=Sl(t.sessionIds).map((F)=>String(F)).filter(Boolean),$=CS(y,c),A=aA(n)||`attempt-${i+1}`,j=y.reduce((F,U)=>F+Sl(U?.parts).filter((N)=>String(N?.type||"").toLowerCase()==="tool"&&wL(N)==="failed").length,0);return K("article",{key:A,className:`pipeline-attempt-card ${r===A?"matched":""}`},K("div",{className:"pipeline-attempt-head"},K("div",null,K("strong",null,A),K("span",null,t.source||"opencode")),K("div",{className:"pipeline-attempt-badges"},K("span",null,`${y.length} steps`),K("span",null,`${t.toolCallCount??"--"} tools`),j>0?K("span",{className:"danger"},`${j} failed`):null)),K(_j,{items:[{label:"messages",value:t.messageCount??"--"},{label:"steps",value:t.stepCount??"--"},{label:"tools",value:t.toolCallCount??"--"},{label:"updated",value:Wl(t.updatedAt)},{label:"sessions",value:c.join(", ")||"--"}]}),y.length===0?K("p",{className:"muted paragraph"},"当前 attempt 尚未返回 OpenCode Trace;请确认 D601 pipeline-control 已重建并重新抓取。"):K(MS,{steps:y,sessionIds:c,sessionFacts:$,matchedStepKey:u}))})}function tj(l,u){return`${l}::${u}`}function xA(l,u,r){if(!Yl(l))return null;return String(l.runId||"")===u&&String(l.nodeId||"")===r?l:null}function sS(l,u){let r=Yl(l)?l:{};if(!Yl(u))return r;let f=Sl(u.attempts),n=Sl(r.attempts);return{...r,...u,attempts:f.length>0?f:n}}function kS(l,u,r,f){if(!xA(u,r,f))return l;let n=Sl(u.procedureRuns),i=Yl(l)?l:{};return{...i,...u,controlEvents:Sl(u.controlEvents).length>0?u.controlEvents:i.controlEvents,procedureRuns:n.length>0?n:i.procedureRuns}}function gS({selection:l,runDetails:u,nodeDetails:r,nodeDetailsState:f,onRaw:n,onCollapse:i}){if(!l?.mode)return K("aside",{className:"pipeline-gantt-detail-panel empty","data-testid":"pipeline-gantt-detail-panel"},K("div",{className:"pipeline-gantt-detail-head"},K("div",null,K("span",{className:"panel-eyebrow"},"Gantt Detail"),K(fu,{title:"未选择元素",level:3})),K("button",{type:"button",className:"ghost-btn mini",onClick:i,"data-testid":"pipeline-gantt-sidebar-collapse"},"收起")),K(qf,{title:"选择一条执行线或一个控制点",text:"点击甘特图中的 node 执行线、prompt 点或控制点,在这里查看结构化过程和 OpenCode step。"}));let t=String(l?.runId||""),y=String(l?.interval?.nodeId||l?.marker?.nodeId||""),c=u?.runId===t?u.details:null,$=xA(r,t,y),A=String(f?.runId||"")===t&&String(f?.nodeId||"")===y,j=kS(c,$,t,y),F=(String(u?.runId||"")!==t||Boolean(u?.loading))&&!j,U=String(u?.runId||"")===t?String(u?.error||""):"",N=A?String(f?.error||""):"",W=j?bS(j,l):null,L=W?.interval||l?.interval||null,J=W?.marker||l?.marker||null,w=String(L?.procedureRunId||J?.procedureRunId||""),Q=$?PS($,w)||$j($,L||{procedureRunId:w}):null,q=W?.procedure||(j?$j(j,L||{procedureRunId:w}):null)||L?.raw||{};if(Q&&(nj(q)===0||dW(Q)>=dW(q)))q=sS(q,Q);let T=W?.attempt||null,O=String(W?.matchedStepKey||"");if(!T&&J&&nj(q)>0)T=qL(q,J),O=String(WL(T,Number.isFinite(Number(J?.ms))?Number(J.ms):null).stepKey||"");let Z=aA(T),E=nj(q)>0,D=A&&Boolean(f?.loading)&&!E,Y=Boolean(F||D),p=[E?"":U,N].filter(Boolean).join(" / "),V=A&&f?.fetchedAt?f.fetchedAt:u?.fetchedAt,B=QL(q?.status||L?.status||J?.status||J?.event),m=l?.mode==="event"?J?.label||lL(J?.raw||J)||"event":W?.nodeId||L?.nodeId||"node",X=J?RS(J?.raw||J):[],S=J?[un(J?.raw||J)?`event ${un(J?.raw||J)}`:"",J?.promptEvent?`prompt ${J.promptEvent}`:"",J?.action?`action ${J.action}`:"",J?.sourceKind?`source ${eW(J.sourceKind)}`:"",J?.sourceNodeId?`from ${J.sourceNodeId}`:"",J?.targetNodeId?`to ${J.targetNodeId}`:"",J?.snapReason?`draw ${J.snapReason}`:""].filter(Boolean):[];return K("aside",{className:"pipeline-gantt-detail-panel","data-testid":"pipeline-gantt-detail-panel"},K("div",{className:"pipeline-gantt-detail-head"},K("div",null,K("span",{className:"panel-eyebrow"},l?.mode==="event"?"Gantt Event Detail":"Gantt Line Detail"),K(fu,{title:m,level:3,loading:Y})),K("div",{className:"pipeline-gantt-detail-head-actions"},K(u0,{status:B},B),K("button",{type:"button",className:"ghost-btn mini",onClick:i,"data-testid":"pipeline-gantt-sidebar-collapse"},"收起"))),J?K("article",{className:"pipeline-event-card"},K("div",{className:"pipeline-event-card-head"},K("strong",null,J?.label||lL(J?.raw||J)),K(qj,{items:S})),K(_j,{items:[{label:"event time",value:Wl(J?.timestampIso||J?.timestamp||"--")},J?.snapped?{label:"drawn time",value:Wl(J?.renderedTimestampIso||J?.ms)}:null,{label:"node",value:J?.nodeId||"--"},{label:"procedure",value:J?.procedureRunId||Sf(q)||"--"},{label:"attempt",value:J?.attempt||Z||"--"},{label:"source kind",value:J?.sourceKind?eW(J.sourceKind):"--"},{label:"source node",value:J?.sourceNodeId||"--"},{label:"target node",value:J?.targetNodeId||"--"},{label:"command",value:J?.commandId||J?.eventId||"--"},J?.snapReason?{label:"placement",value:J.snapReason}:null]}),X.length>0?K("div",{className:"pipeline-event-blocks"},X.map((b,z)=>K("section",{key:`${b.label}-${z}`,className:"pipeline-event-text-block"},K("b",null,b.label),K("p",null,b.value)))):null,uL(J?.raw||J)?K("p",{className:"pipeline-text-preview"},uL(J?.raw||J)):null):null,K(_j,{items:[{label:"epoch",value:t||L?.runId||"--"},{label:"node",value:W?.nodeId||L?.nodeId||J?.nodeId||"--"},{label:"procedure",value:L?.procedureRunId||J?.procedureRunId||Sf(q)||"--"},{label:"started",value:Wl(L?.startedAt||q?.startedAt)},{label:"finished",value:Wl(L?.finishedAt||q?.finishedAt)},{label:"duration",value:Vf(L?.durationMs||q?.durationMs)},{label:"fetched",value:V?iu(V):"--"},W?.matchedStep?{label:"matched step",value:`Step ${W.matchedStep.index??W.matchedStepIndex+1}`}:null]}),K(lu,{error:p}),K("div",{className:"pipeline-gantt-detail-actions"},K(rn,{title:`Procedure ${L?.procedureRunId||J?.procedureRunId||W?.nodeId||"node"}`,data:q,onOpen:n,testId:"raw-pipeline-gantt-procedure"}),J?K(rn,{title:`Pipeline event ${J?.id||J?.commandId||J?.eventId||W?.nodeId||"event"}`,data:J?.raw||J,onOpen:n,testId:"raw-pipeline-gantt-event"}):null,j?K(rn,{title:`Pipeline run ${t||"--"}`,data:j,onOpen:n,testId:"raw-pipeline-gantt-node-details"}):null),!Y&&!Sf(q)&&!J?K(qf,{title:"暂无过程详情",text:"当前选择还没有可匹配的 procedure 运行记录。"}):null,!Y&&Sf(q)?K(vS,{procedure:q,matchedStepKey:O,matchedAttemptId:Z}):null)}function IS({value:l}){let r=String(l||"--").split(/([_-])/u);return K(l0.default.Fragment,null,r.map((f,n)=>f==="-"||f==="_"?K(l0.default.Fragment,{key:n},f,K("wbr",null)):K(l0.default.Fragment,{key:n},f)))}async function oi(l,u={}){return ml(l,{invalidJsonPrefix:"Pipeline 返回了无效 JSON",...u})}function u0({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return K("span",{className:`status-badge ${r}`},u||l||"unknown")}function Mr({label:l,value:u,hint:r,tone:f}){return K("article",{className:`metric-card ${f||""}`},K("div",{className:"metric-label"},l),K("div",{className:"metric-value"},u),K("div",{className:"metric-hint"},r))}function Kn({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return K("section",{className:`panel ${n||""}`},K("div",{className:"panel-head"},K("div",null,u?K("p",{className:"panel-eyebrow"},u):null,K(fu,{title:l,loading:i})),r?K("div",{className:"panel-actions"},r):null),K("div",{className:"panel-body"},f))}function rn({title:l,data:u,onOpen:r,testId:f}){return K("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function Df({title:l,subtitle:u,facts:r,data:f,onRaw:n,testId:i}){let t=Sl(r).map((y)=>String(y||"")).filter(Boolean);return K("article",{className:"pipeline-evidence-row"},K("div",{className:"pipeline-evidence-main"},K("strong",null,l),u?K("span",null,u):null),K("div",{className:"pipeline-evidence-facts"},t.map((y,c)=>K("span",{key:`${c}-${y.slice(0,16)}`},y))),f!==void 0?K(rn,{title:l,data:f,onOpen:n,testId:i}):null)}function qf({title:l,text:u}){return K("div",{className:"empty-state"},K("strong",null,l),K("span",null,u))}function aS(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function oS(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function dS(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function eS(l){return{components:Array.isArray(l?.registry?.components)?l.registry.components:[],pipelines:Array.isArray(l?.pipelines)?l.pipelines:[],runs:Array.isArray(l?.runs)?l.runs:[]}}function rL(l,u,r){let f=l?._unidesk?.arrayLimits?.[u],n=Number(f?.originalLength);return Number.isFinite(n)?n:r}function LL(l){if(!l||typeof l!=="object"||Array.isArray(l))return"--";return`${l.componentClass||"--"}/${l.id||"--"}`}function bA(l){if(!l||typeof l!=="object"||Array.isArray(l))return"";let u=String(l.componentClass||"").trim(),r=String(l.id||"").trim();return u&&r?`${u}/${r}`:""}function Wj(l){return l?.config&&typeof l.config==="object"&&!Array.isArray(l.config)?l.config:{}}function GL(l){let u=Wj(l),r=Array.isArray(u.nodes)?u.nodes:Array.isArray(l?.nodes)?l.nodes:[],f=new Map;for(let t of r){let y=String(t?.id||t?.nodeId||"");if(y)f.set(y,{...t,id:y})}let n=Lj(l),i=(t)=>{if(t&&!f.has(t))f.set(t,{id:t})};for(let t of Gj(l))n_(t).forEach(i);for(let t of n)i(String(t?.from||t?.source||"")),i(String(t?.to||t?.target||""));return Array.from(f.values())}function Lj(l){let u=Wj(l);return Array.isArray(u.edges)?u.edges:Array.isArray(l?.edges)?l.edges:[]}function Gj(l){let u=Wj(l);return Array.isArray(u.topologicalBatches)?u.topologicalBatches:Array.isArray(l?.topologicalBatches)?l.topologicalBatches:[]}function lX(l){let u=new Map;for(let r of l){let f=bA(r);if(f)u.set(f,r);let n=Array.isArray(r?.refs)?r.refs:[];for(let i of n){let t=bA(i);if(t)u.set(t,r)}}return u}function fL(l,u){let r=u.get(bA(l?.componentRef));if(r)return r;let f=bA({componentClass:l?.kind,id:l?.id});return f?u.get(f)||null:null}function nL(l,u){let r=TL(l,u);return String(r?.status||"pending")}function TL(l,u){return(Array.isArray(l?.nodes)?l.nodes:[]).find((f)=>f?.nodeId===u||f?.id===u)||null}function uX(l){return l.reduce((u,r)=>{let f=String(r?.status||"unknown").toLowerCase();return u[f]=(u[f]||0)+1,u},{})}function rX(l){if(Array.isArray(l?.scorers))return l.scorers.filter(Yl);if(Array.isArray(l?.summary?.scorers))return l.summary.scorers.filter(Yl);if(Array.isArray(l?.artifact?.summary?.scorers))return l.artifact.summary.scorers.filter(Yl);return[]}function fX(l){if(Yl(l?.run))return l.run;if(Yl(l?.runSummary))return l.runSummary;return null}function nX(l,u){if(!Yl(l)&&!Yl(u))return null;if(!Yl(l))return u;if(!Yl(u))return l;return{...l,...u,request:Yl(l.request)||Yl(u.request)?{...Yl(l.request)?l.request:{},...Yl(u.request)?u.request:{}}:u.request??l.request,artifact:Yl(l.artifact)||Yl(u.artifact)?{...Yl(l.artifact)?l.artifact:{},...Yl(u.artifact)?u.artifact:{}}:u.artifact??l.artifact,summary:Yl(l.summary)||Yl(u.summary)?{...Yl(l.summary)?l.summary:{},...Yl(u.summary)?u.summary:{}}:u.summary??l.summary}}function vA(l){let u=rX(l),r=u.find((A)=>Yl(A?.score))||u[0]||null,f=Yl(r?.score)?r.score:{},n=Number(f.passed),i=Number(f.total),t=Number(f.ratio),y=Number.isFinite(t)?t:Number.isFinite(n)&&Number.isFinite(i)&&i>0?n/i:null,c=y===null?null:Math.round(Math.max(0,Math.min(100,y<=1?y*100:y))),$=String(f.text||(Number.isFinite(n)&&Number.isFinite(i)?`${n}/${i}`:""));return{scorer:r,scorers:u,score:f,passed:Number.isFinite(n)?n:null,total:Number.isFinite(i)?i:null,percent:c,text:$}}function Fj(l){let u=vA(l);return u.text||(u.scorers.length>0?String(u.scorer?.status||"pending"):"--")}function Tj(l){let u=vA(l);if(u.total>0&&u.passed===u.total)return"succeeded";if(u.total>0&&u.passed>0)return"running";if(u.scorers.length>0)return"failed";return"pending"}function iX(l){return Array.isArray(l?.items)?l.items.filter(Yl):[]}function tX({run:l}){let u=Fj(l);return K("span",{className:`pipeline-score-badge ${Tj(l)}`},`score ${u}`)}function yX({run:l,onRaw:u}){let f=vA(l).scorers;if(!l)return K(qf,{title:"暂无评分",text:"选择一个 epoch 后会显示 scorer 结果。"});if(f.length===0)return K("div",{className:"pipeline-score-empty"},K("strong",null,"评分器等待中"),K("span",null,"DAG 完成后,Pipeline control backend 会把 scorer summary 追加到 run artifact,并通过 UniDesk 显示。"));return K("div",{className:"pipeline-score-board","data-testid":"pipeline-score-board"},f.map((n,i)=>{let t=vA({scorers:[n]}),y=iX(n),c=t.percent??0;return K("article",{key:`${n.scorerId||n.component||i}`,className:`pipeline-score-card ${Tj({scorers:[n]})}`},K("div",{className:"pipeline-score-head"},K("div",null,K("span",null,n.scorerId||n.component||"scorer"),K("strong",null,t.text||n.status||"--")),K(u0,{status:n.status||"unknown"},n.status||"unknown")),K("div",{className:"pipeline-score-meter","aria-label":`score ${c}%`},K("span",{style:{width:`${c}%`}})),K("div",{className:"pipeline-score-facts"},K("span",null,`${c}%`),K("span",null,n.component||"--"),K("span",null,n.applicationCheckoutRef||"--")),y.length>0?K("div",{className:"pipeline-score-items"},y.map(($)=>K("span",{key:`${$.id||$.filter}`,className:`pipeline-score-item ${String($.status||"").toLowerCase()}`,title:`${$.filter||"--"} / ran=${$.ran??"?"}`},K("b",null,$.id||"--"),K("small",null,$.status||"--")))):K("p",{className:"muted paragraph"},"当前 scorer 尚未返回 item 级结果。"),n.error?K("p",{className:"pipeline-score-error"},NL(n.error,360)):null,K("div",{className:"panel-actions inline-actions"},K(rn,{title:`Scorer ${n.scorerId||i}`,data:n,onOpen:u,testId:"raw-pipeline-score"})))}))}function cX(l){let u=l.reduce((r,f)=>{let n=String(f?.componentClass||"unknown");return r[n]=(r[n]||0)+1,r},{});return Object.entries(u).map(([r,f])=>({name:r,count:Number(f)})).sort((r,f)=>f.count-r.count||r.name.localeCompare(f.name))}function n_(l){if(Array.isArray(l))return l.map((u)=>typeof u==="string"?u:String(u?.id||u?.nodeId||"")).filter(Boolean);if(Array.isArray(l?.nodes))return n_(l.nodes);if(Array.isArray(l?.nodeIds))return n_(l.nodeIds);return[]}function _X(l){return Yl(l?.instanceInputs?.monitor)?l.instanceInputs.monitor:{}}function mL(l,u){if(String(l?.kind||"").toLowerCase()!=="procedure")return!1;let r=_X(l);if(l?.instanceInputs?.monitorMode===!0||r.enabled===!0)return!0;let f=LL(l?.componentRef);return String(u?.id||u?.config?.id||f||"").toLowerCase().includes("monitor")}function $X(l){return l.filter((u)=>mL(u)).map((u)=>String(u?.id||"")).filter(Boolean)}function AX(l,u){if(u.length===0)return l;let r=new Set(u),f=u.filter((n)=>l.includes(n));if(f.length===0)return l;return[...f,...l.filter((n)=>!r.has(n))]}function jX(l,u){if(u.length===0)return l;let r=new Set(u),f=u.filter((i)=>l.some((t)=>t.includes(i)));if(f.length===0)return l;let n=l.map((i)=>i.filter((t)=>!r.has(t))).filter((i)=>i.length>0);return[f,...n]}function FX(l,u,r){let n=Gj(l).map(n_).filter((F)=>F.length>0);if(n.length>0)return n;let i=u.map((F)=>String(F?.id||"")).filter(Boolean),t=new Set(i),y=new Map(i.map((F)=>[F,0])),c=new Map(i.map((F)=>[F,[]]));for(let F of r){let U=String(F?.from||F?.source||""),N=String(F?.to||F?.target||"");if(!t.has(U)||!t.has(N))continue;c.get(U)?.push(N),y.set(N,(y.get(N)||0)+1)}let $=new Map,A=i.filter((F)=>(y.get(F)||0)===0);for(let F of A)$.set(F,0);while(A.length>0){let F=A.shift(),U=($.get(F)||0)+1;for(let N of c.get(F)||[])if(y.set(N,Math.max(0,(y.get(N)||0)-1)),$.set(N,Math.max($.get(N)||0,U)),(y.get(N)||0)===0)A.push(N)}i.forEach((F)=>{if(!$.has(F))$.set(F,0)});let j=Math.max(0,...Array.from($.values()));return Array.from({length:j+1},(F,U)=>i.filter((N)=>$.get(N)===U)).filter((F)=>F.length>0)}function JX(l,u,r){let n=Gj(l).map(n_).filter((y)=>y.length>0),i=n.length>0?n.flatMap((y)=>y):(()=>{let y=u.map((W)=>String(W?.id||"")).filter(Boolean),c=new Set(y),$=r.filter((W)=>String(W?.edgeType||"").toLowerCase()!=="rework"),A=new Map(y.map((W)=>[W,0])),j=new Map(y.map((W)=>[W,[]]));for(let W of $){let L=String(W?.from||W?.source||""),J=String(W?.to||W?.target||"");if(!c.has(L)||!c.has(J))continue;j.get(L)?.push(J),A.set(J,(A.get(J)||0)+1)}let F=new Map,U=y.filter((W)=>(A.get(W)||0)===0);for(let W of U)F.set(W,0);while(U.length>0){let W=U.shift(),L=(F.get(W)||0)+1;for(let J of j.get(W)||[])if(A.set(J,Math.max(0,(A.get(J)||0)-1)),F.set(J,Math.max(F.get(J)||0,L)),(A.get(J)||0)===0)U.push(J)}y.forEach((W)=>{if(!F.has(W))F.set(W,0)});let N=Math.max(0,...Array.from(F.values()));return Array.from({length:N+1},(W,L)=>y.filter((J)=>F.get(J)===L)).flatMap((W)=>W)})(),t=new Set(i);for(let y of u){let c=String(y?.id||"");if(!c||t.has(c))continue;i.push(c),t.add(c)}return AX(i,$X(u))}function oc(l){return`${l.source}->${l.target}-${l.index}`}function iL(l,u,r){let f=GL(l),n=Lj(l),i=lX(r),t=new Map(f.map((B)=>[String(B?.id||""),B])),y=f.filter((B)=>mL(B,fL(B,i))).map((B)=>String(B?.id||"")).filter(Boolean),c=jX(FX(l,f,n),y),$=[],A=new Map,j=330,F=122;c.forEach((B,m)=>{let X=B.length*122;B.forEach((S,b)=>{let z=t.get(S)||{id:S},P=fL(z,i),s=nL(u,S).toLowerCase(),k=String(z.kind||P?.componentClass||"node").toLowerCase(),v=LL(z.componentRef||P),tl=String(P?.config?.version||P?.version||""),I=String(P?.config?.description||P?.description||""),M=b*122-Math.floor(X/2);A.set(S,{column:m,row:b,y:M}),$.push({id:S,type:"pipelineNode",position:{x:m*330,y:M},data:{exportLabel:{id:S,kind:k,componentRef:v,componentVersion:tl,componentDescription:I,status:s},label:K("div",{className:"flow-node-label"},K("strong",null,S),K("span",null,k),K("code",{title:I||v},tl?`${v}@${tl}`:v),K(u0,{status:s},s))},className:`pipeline-flow-node ${k} ${s}`})})});let U=n.flatMap((B,m)=>{let X=String(B?.from||B?.source||""),S=String(B?.to||B?.target||"");if(!t.has(X)||!t.has(S))return[];return[{source:X,target:S,index:m,condition:B?.condition,edgeType:B?.edgeType}]}),N=U.reduce((B,m)=>B.set(m.source,(B.get(m.source)||0)+1),new Map),W=U.reduce((B,m)=>B.set(m.target,(B.get(m.target)||0)+1),new Map),L=U.reduce((B,m)=>{let X=`${m.source}->${m.target}`;return B.set(X,(B.get(X)||0)+1)},new Map),J=new Map,w=new Map,Q=new Map,q=new Map,T=new Map,O=new Map,Z=U.reduce((B,m)=>{let X=A.get(m.source),S=A.get(m.target),b=(S?.column||0)-(X?.column||0);if(b<=0||String(m.edgeType||"").toLowerCase()==="rework"||b!==1)return B;let P=`${m.source}->column:${S?.column??""}`,s=B.get(P)||[];return s.push(m),B.set(P,s),B},new Map);for(let B of Z.values()){if(B.length<2)continue;B.slice().sort((m,X)=>{let S=A.get(m.target),b=A.get(X.target);return(S?.y||0)-(b?.y||0)||m.index-X.index}).forEach((m,X,S)=>{O.set(oc(m),{slot:X-(S.length-1)/2,count:S.length})})}[...U].sort((B,m)=>{let X=A.get(B.source),S=A.get(B.target),b=A.get(m.source),z=A.get(m.target),P=Math.abs((S?.column||0)-(X?.column||0))*330+Math.abs((S?.y||0)-(X?.y||0)),s=Math.abs((z?.column||0)-(b?.column||0))*330+Math.abs((z?.y||0)-(b?.y||0));return P-s||B.index-m.index}).forEach((B)=>{let m=A.get(B.source)||{column:0,row:0,y:0},X=A.get(B.target)||{column:0,row:0,y:0},S=X.column-m.column,b=Math.max(0,S),z=S<=0||String(B.edgeType||"").toLowerCase()==="rework",P=m.y-X.y,s=W.get(B.target)||1,k=O.has(oc(B)),v=!z&&b<=1&&(k||s===1),tl=T.get(B.target)||new Map;T.set(B.target,tl);let I=r_.slice().sort((M,rl)=>{let cl=(Ol)=>{let h=String(Ol.side),a=0;if(z){if(h==="left")a+=86;if(h==="top")a+=X.y<=0?-22:12;if(h==="bottom")a+=X.y>=0?-22:12;if(Math.abs(X.y)<12&&h!=="left")a+=B.index%2===0?h==="top"?-6:6:h==="bottom"?-6:6;return a}if(v){if(h==="left")a-=k?72:44;if(h!=="left")a+=k?72:44;return a+Math.abs(P)*0.02}if(h==="left")a+=b<=1?0:24;if(h==="top")a+=P<-36?-18:42;if(h==="bottom")a+=P>36?-18:42;if(b<=1&&Math.abs(P)<=82&&h!=="left")a+=38;if(b>1&&h!=="left")a-=10;return a},$l=m.y-X.y,Tl=$l!==0?$l:B.index%2===0?-1:1,Ql=(Ol)=>{let h=tl.get(Ol.id)||0;return cl(Ol)+h*64+BS(Ol,tl,Tl)};return Ql(M)-Ql(rl)||String(M.id).localeCompare(String(rl.id))})[0];tl.set(I.id,(tl.get(I.id)||0)+1),q.set(oc(B),I)});let D=U.map((B)=>{let m=nL(u,B.target).toLowerCase(),X=`${B.source}->${B.target}`,S=J.get(B.source)||0,b=w.get(B.target)||0,z=Q.get(X)||0;J.set(B.source,S+1),w.set(B.target,b+1),Q.set(X,z+1);let P=S-((N.get(B.source)||1)-1)/2,s=b-((W.get(B.target)||1)-1)/2,k=z-((L.get(X)||1)-1)/2,v=A.get(B.source),tl=A.get(B.target),I=(tl?.column||0)-(v?.column||0),M=Math.max(1,Math.abs(I)),rl=I<=0||String(B.edgeType||"").toLowerCase()==="rework",cl=Math.abs((tl?.y||0)-(v?.y||0)),$l=O.get(oc(B)),Tl=!rl&&I===1&&(W.get(B.target)||0)>1,Ql=$l?$l.slot:k*2+P+s*0.45,Ol=Ql===0?B.index%2===0?-1:1:Math.sign(Ql),h=q.get(oc(B))||r_[1],a=h.side==="top"?-1:h.side==="bottom"?1:Ol,ul=rl||M>1||cl>96||Math.abs(Ql)>0.2||h.side!=="left",zl=rl?118+M*18:22+M*16,o=h.side==="left"?0:28,ql=ul?Math.max(-280,Math.min(280,a*Math.min(180,zl+o+cl*0.22)+Ql*28)):0,pl=Math.max(0,Math.min(ec.length-1,Math.round(P+(ec.length-1)/2))),Bl=ec[pl]||ec[1],Il=m==="succeeded"?"var(--accent-2)":m==="running"?"var(--accent)":m==="failed"?"var(--danger)":"rgba(129, 147, 159, 0.78)",nu=v?.column||0,Ml=tl?.column||0,wu=ql===0?0:Math.sign(ql),Qr=rl?`feedback:${nu}->${Ml}:${wu}`:$l?`fanout:${nu}->${Ml}:${B.source}`:Tl?`fanin:${nu}->${Ml}:${B.target}`:h.side!=="left"||M>1?`corridor:${nu}->${Ml}:${h.side}:${wu}:${Math.round(Math.abs(ql)/56)}`:"";return{id:`${B.source}->${B.target}-${B.index}`,source:B.source,target:B.target,sourceHandle:Bl.id,targetHandle:h.id,type:"pipelineCurve",zIndex:12,animated:m==="running",data:{baseEdgeColor:Il,laneOffset:ql,routeMode:$l&&h.side==="left"?"direct-forward-left":"",targetSide:h.side,isFeedback:rl,overlapGroup:Qr},targetStatus:m}}),Y=D.reduce((B,m)=>{let X=String(m.data?.overlapGroup||"");return X?B.set(X,(B.get(X)||0)+1):B},new Map),p=new Map,V=D.map((B)=>{let m=String(B.targetStatus||"pending"),X={...B};delete X.targetStatus;let S=String(B.data?.overlapGroup||""),b=S?Y.get(S)||0:0,z=b>1?p.get(S)||0:-1;if(b>1)p.set(S,z+1);let P=z>=0?sW[z%sW.length]:String(B.data.baseEdgeColor),s={stroke:P};if(B.data.isFeedback)s.strokeDasharray="9 7";return{...X,data:{...B.data,edgeColor:P,overlapSlot:z,overlapCount:b},style:s,markerEnd:{type:ki.ArrowClosed,color:P},className:`pipeline-flow-edge ${m} ${B.data.isFeedback?"feedback":""} ${z>=0?"overlap-colored":""}`}});return{nodes:$,edges:V}}function er(l){return String(l??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function tL(l){let u=String(l||"");if(u.includes("--accent-2"))return"#4eb7a8";if(u.includes("--accent"))return"#d7a13a";if(u.includes("--danger"))return"#cf6a54";return u.startsWith("#")?u:"#81939f"}function sA(l){return`arrow-${l.replace(/[^a-zA-Z0-9_-]+/g,"")}`}function KL(l,u="pipeline"){return String(l||u).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-|-$/g,"")||u}function yL(l,u){let r=l.position.x,f=l.position.y,n=r_.find((i)=>i.id===u);if(n?.side==="top")return{x:r+Vy*IW(n.style?.left,0.5),y:f,position:Kl.Top};if(n?.side==="bottom")return{x:r+Vy*IW(n.style?.left,0.5),y:f+Sy,position:Kl.Bottom};return{x:r,y:f+Sy/2,position:Kl.Left}}function UX(l){return{x:l.position.x+Vy,y:l.position.y+Sy/2}}function NX(l,u){let r=Math.min(...l.nodes.map((W)=>W.position.x),0)-220,f=Math.min(...l.nodes.map((W)=>W.position.y),0)-220,n=Math.max(...l.nodes.map((W)=>W.position.x+Vy),1)+220,i=Math.max(...l.nodes.map((W)=>W.position.y+Sy),1)+220,t=Math.ceil(n-r),y=Math.ceil(i-f),c=new Map(l.nodes.map((W)=>[W.id,W])),$=l.edges.map((W)=>tL(W.data?.edgeColor||W.style?.stroke)),j=Array.from(new Set(["#4eb7a8","#d7a13a","#cf6a54","#81939f",...$])).map((W)=>`<marker id="${sA(W)}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="${W}"/></marker>`).join(""),F=l.edges.flatMap((W)=>{let L=c.get(W.source),J=c.get(W.target);if(!L||!J)return[];let w=UX(L),Q=yL(J,String(W.targetHandle||"in-left")),q=FL(w.x,w.y,Q.x,Q.y,Q.position,Number(W.data?.laneOffset||0),String(W.data?.routeMode||"")),T=tL(W.data?.edgeColor||W.style?.stroke),O=W.data?.isFeedback?' stroke-dasharray="9 7"':"";return`<path d="${er(q)}" fill="none" stroke="${T}" stroke-width="2.35" stroke-linecap="round" stroke-linejoin="round" opacity="0.82"${O} marker-end="url(#${sA(T)})"/>`}).join(` +`),U=l.nodes.map((W)=>{let L=W.data?.exportLabel||{},J=String(L.status||"pending").toLowerCase(),w=J==="succeeded"?"#4eb7a8":J==="running"?"#d7a13a":J==="failed"?"#cf6a54":"#81939f",Q=W.position.x,q=W.position.y,T=r_.map((O)=>{let Z=yL(W,O.id);if(O.side==="top"||O.side==="bottom")return`<rect x="${Z.x-9}" y="${Z.y-5}" width="18" height="10" rx="2" fill="#071016" stroke="#4eb7a8"/>`;return`<rect x="${Z.x-5}" y="${Z.y-9}" width="10" height="18" rx="2" fill="#071016" stroke="#4eb7a8"/>`}).join(` `);return`<g> - <rect x="${N}" y="${w}" width="${zy}" height="${Ey}" rx="2" fill="#0d171f" stroke="${q}" stroke-width="1.2"/> - ${G} - <rect x="${N+zy-5}" y="${w+Ey/2-9}" width="10" height="18" rx="2" fill="#071016" stroke="#d7a13a"/> - <text x="${N+12}" y="${w+22}" fill="#e5edf2" font-size="12" font-family="monospace" font-weight="700">${ur(L.id||W.id)}</text> - <text x="${N+12}" y="${w+42}" fill="#81939f" font-size="10" font-family="monospace">${ur(L.kind||"node")}</text> - <text x="${N+12}" y="${w+60}" fill="#d7a13a" font-size="10" font-family="monospace">${ur(L.componentRef||"--")}</text> - <text x="${N+12}" y="${w+78}" fill="${q}" font-size="10" font-family="monospace">${ur(U)}</text> + <rect x="${Q}" y="${q}" width="${Vy}" height="${Sy}" rx="2" fill="#0d171f" stroke="${w}" stroke-width="1.2"/> + ${T} + <rect x="${Q+Vy-5}" y="${q+Sy/2-9}" width="10" height="18" rx="2" fill="#071016" stroke="#d7a13a"/> + <text x="${Q+12}" y="${q+22}" fill="#e5edf2" font-size="12" font-family="monospace" font-weight="700">${er(L.id||W.id)}</text> + <text x="${Q+12}" y="${q+42}" fill="#81939f" font-size="10" font-family="monospace">${er(L.kind||"node")}</text> + <text x="${Q+12}" y="${q+60}" fill="#d7a13a" font-size="10" font-family="monospace">${er(L.componentRef||"--")}</text> + <text x="${Q+12}" y="${q+78}" fill="${w}" font-size="10" font-family="monospace">${er(J)}</text> </g>`}).join(` `);return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${y}" viewBox="0 0 ${t} ${y}"> <defs>${j}<pattern id="grid" width="22" height="22" patternUnits="userSpaceOnUse"><path d="M 22 0 L 0 0 0 22" fill="none" stroke="#18303a" stroke-width="0.6"/></pattern></defs> <rect width="100%" height="100%" fill="#081118"/> <rect width="100%" height="100%" fill="url(#grid)" opacity="0.55"/> - <text x="24" y="34" fill="#d7a13a" font-size="13" font-family="monospace" letter-spacing="2">${ur(l)}</text> - <g transform="translate(${-f} ${-r})">${J}<g>${F}</g></g> - </svg>`,width:t,height:y}}function PS(u){let l=String(u||"").toLowerCase();if(l==="succeeded"||l==="completed")return"#4eb7a8";if(l==="failed")return"#cf6a54";if(sW(l))return"#69aee8";return"#d7a13a"}function CS(u){let l=String(u?.kind||""),f=String(u?.tone||u?.status||"").toLowerCase();if(l==="prompt"&&f==="initial")return"#d7a13a";if(l==="prompt"&&f==="monitor")return"#69aee8";if(l==="prompt")return"#4eb7a8";if(f==="modify")return"#e0b95a";if(f==="approve"||f==="guide"||f==="monitor")return"#4eb7a8";if(f==="restart"||f==="redo")return"#d7a13a";if(f==="ignored")return"#81939f";if(f==="webui")return"#69aee8";if(f==="cli")return"#d7a13a";return"#a7bac5"}function hW(u){let l=String(u?.sourceKind||"").toLowerCase(),f=String(u?.action||"").toLowerCase(),r=String(u?.status||"").toLowerCase();if(f==="observe"||r==="observation"||l==="monitor")return"#4eb7a8";if(l==="webui")return"#69aee8";if(l==="cli")return"#d7a13a";if(r.includes("ignored"))return"#81939f";return"#8aa0ad"}function MS(u,l,f){let r=CS(u),n=String(u?.kind||"");if(n==="control-source")return`<rect x="${l-5.5}" y="${f-5.5}" width="11" height="11" rx="2" transform="rotate(45 ${l} ${f})" fill="${r}" stroke="rgba(255,255,255,0.26)" stroke-width="1"/>`;if(n==="control-target"){let t=String(u?.tone||"").toLowerCase()==="approve"?"rgba(78,183,168,0.22)":"#081118";return`<circle cx="${l}" cy="${f}" r="5.5" fill="${t}" stroke="${r}" stroke-width="2"/>`}return`<circle cx="${l}" cy="${f}" r="${n==="prompt"?4.5:5.5}" fill="${r}" stroke="rgba(255,255,255,0.24)" stroke-width="1"/>`}function RS(u){let l=Du(u.visibleNodeIds).map((z)=>String(z||"")).filter(Boolean),f=Du(u.intervals).filter(pu),r=Du(u.markers).filter(pu),n=Du(u.arrows).filter(pu),i=Du(u.ticks).filter(pu),t=pu(u.bounds)?u.bounds:{},y=pu(u.backendLayout)?u.backendLayout:null,c=Math.max(240,Math.round(Number(u.chartHeight||360))),$=Math.max(wn,108),A=128,j=24,F=58,J=56,Q=128+Math.max(1,l.length)*$,W=Math.max(760,Q+48),L=114+c+24,U=24,q=58,N=114,w=(z)=>152+z*$,G=(z)=>w(z)+$/2,Z=Du(u.meta).map((z)=>String(z||"")).filter(Boolean).slice(0,4).join(" · "),H=new Map(r.map((z)=>[String(z.id||""),z])),m=Array.from(new Set(["#4eb7a8","#69aee8","#d7a13a","#cf6a54","#8aa0ad",...n.map(hW)])).map((z)=>`<marker id="${pA(z)}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="${z}"/></marker>`).join(""),S=i.map((z)=>{let P=114+UL(z,t,c,y);return`<g> - <line x1="24" y1="${P}" x2="${24+Q}" y2="${P}" stroke="rgba(215,161,58,0.18)" stroke-width="1"/> - <text x="32" y="${P-4}" fill="#dce6ec" font-size="10" font-family="monospace">${ur(wu(z.ms))}</text> - <text x="32" y="${P+10}" fill="#81939f" font-size="9" font-family="monospace">+${ur(mr(Number(z.offsetMs??Number(z.ms)-Number(t.startMs))))}</text> + <text x="24" y="34" fill="#d7a13a" font-size="13" font-family="monospace" letter-spacing="2">${er(u)}</text> + <g transform="translate(${-r} ${-f})">${U}<g>${F}</g></g> + </svg>`,width:t,height:y}}function QX(l){let u=String(l||"").toLowerCase();if(u==="succeeded"||u==="completed")return"#4eb7a8";if(u==="failed")return"#cf6a54";if(JL(u))return"#69aee8";return"#d7a13a"}function wX(l){let u=String(l?.kind||""),r=String(l?.tone||l?.status||"").toLowerCase();if(u==="prompt"&&r==="initial")return"#d7a13a";if(u==="prompt"&&r==="monitor")return"#69aee8";if(u==="prompt")return"#4eb7a8";if(r==="modify")return"#e0b95a";if(r==="approve"||r==="guide"||r==="monitor")return"#4eb7a8";if(r==="restart"||r==="redo")return"#d7a13a";if(r==="ignored")return"#81939f";if(r==="webui")return"#69aee8";if(r==="cli")return"#d7a13a";return"#a7bac5"}function cL(l){let u=String(l?.sourceKind||"").toLowerCase(),r=String(l?.action||"").toLowerCase(),f=String(l?.status||"").toLowerCase();if(r==="observe"||f==="observation"||u==="monitor")return"#4eb7a8";if(u==="webui")return"#69aee8";if(u==="cli")return"#d7a13a";if(f.includes("ignored"))return"#81939f";return"#8aa0ad"}function qX(l,u,r){let f=wX(l),n=String(l?.kind||"");if(n==="control-source")return`<rect x="${u-5.5}" y="${r-5.5}" width="11" height="11" rx="2" transform="rotate(45 ${u} ${r})" fill="${f}" stroke="rgba(255,255,255,0.26)" stroke-width="1"/>`;if(n==="control-target"){let t=String(l?.tone||"").toLowerCase()==="approve"?"rgba(78,183,168,0.22)":"#081118";return`<circle cx="${u}" cy="${r}" r="5.5" fill="${t}" stroke="${f}" stroke-width="2"/>`}return`<circle cx="${u}" cy="${r}" r="${n==="prompt"?4.5:5.5}" fill="${f}" stroke="rgba(255,255,255,0.24)" stroke-width="1"/>`}function WX(l){let u=Sl(l.visibleNodeIds).map((z)=>String(z||"")).filter(Boolean),r=Sl(l.intervals).filter(Yl),f=Sl(l.markers).filter(Yl),n=Sl(l.arrows).filter(Yl),i=Sl(l.ticks).filter(Yl),t=Yl(l.bounds)?l.bounds:{},y=Yl(l.backendLayout)?l.backendLayout:null,c=Math.max(240,Math.round(Number(l.chartHeight||360))),$=Math.max(mn,108),A=128,j=24,F=58,U=56,N=128+Math.max(1,u.length)*$,W=Math.max(760,N+48),L=114+c+24,J=24,w=58,Q=114,q=(z)=>152+z*$,T=(z)=>q(z)+$/2,O=Sl(l.meta).map((z)=>String(z||"")).filter(Boolean).slice(0,4).join(" · "),Z=new Map(f.map((z)=>[String(z.id||""),z])),D=Array.from(new Set(["#4eb7a8","#69aee8","#d7a13a","#cf6a54","#8aa0ad",...n.map(cL)])).map((z)=>`<marker id="${sA(z)}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="${z}"/></marker>`).join(""),Y=i.map((z)=>{let P=114+DL(z,t,c,y);return`<g> + <line x1="24" y1="${P}" x2="${24+N}" y2="${P}" stroke="rgba(215,161,58,0.18)" stroke-width="1"/> + <text x="32" y="${P-4}" fill="#dce6ec" font-size="10" font-family="monospace">${er(Wl(z.ms))}</text> + <text x="32" y="${P+10}" fill="#81939f" font-size="9" font-family="monospace">+${er(Vf(Number(z.offsetMs??Number(z.ms)-Number(t.startMs))))}</text> </g>`}).join(` -`),B=['<rect x="24" y="58" width="128" height="56" fill="#101d25" stroke="rgba(255,255,255,0.08)"/>','<text x="34" y="78" fill="#d7a13a" font-size="10" font-family="monospace" letter-spacing="1.2">TIME</text>',...l.map((z,P)=>{let k=w(P),I=z.length>18?`${z.slice(0,16)}…`:z;return`<g> - <rect x="${k}" y="58" width="${$}" height="56" fill="#101d25" stroke="rgba(255,255,255,0.08)"/> - <text x="${k+$/2}" y="79" fill="#dce6ec" font-size="10" font-family="monospace" text-anchor="middle">${ur(I)}</text> - <text x="${k+$/2}" y="97" fill="#81939f" font-size="9" font-family="monospace" text-anchor="middle">node ${P+1}</text> +`),p=['<rect x="24" y="58" width="128" height="56" fill="#101d25" stroke="rgba(255,255,255,0.08)"/>','<text x="34" y="78" fill="#d7a13a" font-size="10" font-family="monospace" letter-spacing="1.2">TIME</text>',...u.map((z,P)=>{let s=q(P),k=z.length>18?`${z.slice(0,16)}…`:z;return`<g> + <rect x="${s}" y="58" width="${$}" height="56" fill="#101d25" stroke="rgba(255,255,255,0.08)"/> + <text x="${s+$/2}" y="79" fill="#dce6ec" font-size="10" font-family="monospace" text-anchor="middle">${er(k)}</text> + <text x="${s+$/2}" y="97" fill="#81939f" font-size="9" font-family="monospace" text-anchor="middle">node ${P+1}</text> </g>`})].join(` -`),D=l.map((z,P)=>{return`<rect x="${w(P)}" y="114" width="${$}" height="${c}" fill="${P%2===0?"rgba(255,255,255,0.018)":"rgba(255,255,255,0.008)"}" stroke="rgba(255,255,255,0.045)"/>`}).join(` -`),X=f.map((z)=>{let P=l.indexOf(String(z.nodeId||""));if(P<0)return"";let k=114+XA(z,t,c,y),I=Math.max(2,FL(z,t,c,y)),b=PS(z.status),d=G(P)-3.5,s=z.live?`<rect x="${d-1}" y="${k}" width="9" height="${I}" rx="5" fill="none" stroke="rgba(255,255,255,0.54)" stroke-width="1" stroke-dasharray="4 5"/>`:"",h=I>=28?`<text x="${d+12}" y="${k+12}" fill="${b}" font-size="9" font-family="monospace">${ur(String(z.status||"working"))}</text> - <text x="${d+12}" y="${k+24}" fill="#81939f" font-size="8" font-family="monospace">${ur(mr(z.durationMs))}</text>`:"";return`<g> - <rect x="${d}" y="${k}" width="7" height="${I}" rx="4" fill="${b}" stroke="rgba(0,0,0,0.42)" stroke-width="1"/> - ${s} - ${h} +`),V=u.map((z,P)=>{return`<rect x="${q(P)}" y="114" width="${$}" height="${c}" fill="${P%2===0?"rgba(255,255,255,0.018)":"rgba(255,255,255,0.008)"}" stroke="rgba(255,255,255,0.045)"/>`}).join(` +`),B=r.map((z)=>{let P=u.indexOf(String(z.nodeId||""));if(P<0)return"";let s=114+gA(z,t,c,y),k=Math.max(2,BL(z,t,c,y)),v=QX(z.status),tl=T(P)-3.5,I=z.live?`<rect x="${tl-1}" y="${s}" width="9" height="${k}" rx="5" fill="none" stroke="rgba(255,255,255,0.54)" stroke-width="1" stroke-dasharray="4 5"/>`:"",M=k>=28?`<text x="${tl+12}" y="${s+12}" fill="${v}" font-size="9" font-family="monospace">${er(String(z.status||"working"))}</text> + <text x="${tl+12}" y="${s+24}" fill="#81939f" font-size="8" font-family="monospace">${er(Vf(z.durationMs))}</text>`:"";return`<g> + <rect x="${tl}" y="${s}" width="7" height="${k}" rx="4" fill="${v}" stroke="rgba(0,0,0,0.42)" stroke-width="1"/> + ${I} + ${M} </g>`}).join(` -`),O=r.map((z)=>{let P=l.indexOf(String(z.nodeId||""));if(P<0)return"";let k=114+Qr(z,t,c,y);return MS(z,G(P),k)}).join(` -`),Y=n.map((z)=>{let P=H.get(String(z.targetMarkerId||""));if(!P)return"";let k=H.get(String(z.sourceMarkerId||"")),I=String(k?.nodeId||z.sourceNodeId||""),b=String(P.nodeId||z.targetNodeId||""),d=l.indexOf(I),s=l.indexOf(b);if(d<0||s<0)return"";let h=G(d)-24-128,lu=G(s)-24-128,cu=Oy(y)?pl(z.sourceY??z.y1)??(k?Qr(k,t,c,y):Qr(P,t,c,y)):k?Qr(k,t,c,y):Qr(P,t,c,y),_u=Oy(y)?pl(z.targetY??z.y2)??Qr(P,t,c,y):Qr(P,t,c,y),Fu=hW(z),zu=String(z.action||"").toLowerCase()==="observe"?"3 4":"6 5",Wu=ur(JL(h,cu,lu,_u));return`<path d="${Wu}" fill="none" stroke="rgba(8,17,24,0.92)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/> - <path d="${Wu}" fill="none" stroke="${Fu}" stroke-width="2.45" stroke-dasharray="${zu}" stroke-linecap="round" stroke-linejoin="round" opacity="0.96" marker-end="url(#${pA(Fu)})"/>`}).join(` -`),p=l.length===0?'<text x="176" y="156" fill="#81939f" font-size="12" font-family="monospace">No visible Gantt nodes</text>':"";return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${L}" viewBox="0 0 ${W} ${L}"> - <defs>${m}<pattern id="ganttGrid" width="32" height="32" patternUnits="userSpaceOnUse"><path d="M 32 0 L 0 0 0 32" fill="none" stroke="#18303a" stroke-width="0.55"/></pattern></defs> +`),m=f.map((z)=>{let P=u.indexOf(String(z.nodeId||""));if(P<0)return"";let s=114+wf(z,t,c,y);return qX(z,T(P),s)}).join(` +`),X=n.map((z)=>{let P=Z.get(String(z.targetMarkerId||""));if(!P)return"";let s=Z.get(String(z.sourceMarkerId||"")),k=String(s?.nodeId||z.sourceNodeId||""),v=String(P.nodeId||z.targetNodeId||""),tl=u.indexOf(k),I=u.indexOf(v);if(tl<0||I<0)return"";let M=T(tl)-24-128,rl=T(I)-24-128,cl=Xy(y)?Xu(z.sourceY??z.y1)??(s?wf(s,t,c,y):wf(P,t,c,y)):s?wf(s,t,c,y):wf(P,t,c,y),$l=Xy(y)?Xu(z.targetY??z.y2)??wf(P,t,c,y):wf(P,t,c,y),Tl=cL(z),Ql=String(z.action||"").toLowerCase()==="observe"?"3 4":"6 5",Ol=er(VL(M,cl,rl,$l));return`<path d="${Ol}" fill="none" stroke="rgba(8,17,24,0.92)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/> + <path d="${Ol}" fill="none" stroke="${Tl}" stroke-width="2.45" stroke-dasharray="${Ql}" stroke-linecap="round" stroke-linejoin="round" opacity="0.96" marker-end="url(#${sA(Tl)})"/>`}).join(` +`),S=u.length===0?'<text x="176" y="156" fill="#81939f" font-size="12" font-family="monospace">No visible Gantt nodes</text>':"";return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${L}" viewBox="0 0 ${W} ${L}"> + <defs>${D}<pattern id="ganttGrid" width="32" height="32" patternUnits="userSpaceOnUse"><path d="M 32 0 L 0 0 0 32" fill="none" stroke="#18303a" stroke-width="0.55"/></pattern></defs> <rect width="100%" height="100%" fill="#081118"/> <rect width="100%" height="100%" fill="url(#ganttGrid)" opacity="0.55"/> - <rect x="24" y="114" width="${Q}" height="${c}" fill="rgba(255,255,255,0.012)" stroke="rgba(78,183,168,0.24)"/> - <text x="24" y="26" fill="#d7a13a" font-size="13" font-family="monospace" font-weight="700" letter-spacing="1.4">${ur(u.title||"Pipeline Epoch Gantt")}</text> - <text x="24" y="45" fill="#81939f" font-size="10" font-family="monospace">${ur(Z)}</text> - ${B} - <rect x="24" y="114" width="128" height="${c}" fill="rgba(215,161,58,0.055)" stroke="rgba(215,161,58,0.2)"/> - ${D} - ${S} - ${X} - <g transform="translate(152 114)">${Y}</g> - ${O} + <rect x="24" y="114" width="${N}" height="${c}" fill="rgba(255,255,255,0.012)" stroke="rgba(78,183,168,0.24)"/> + <text x="24" y="26" fill="#d7a13a" font-size="13" font-family="monospace" font-weight="700" letter-spacing="1.4">${er(l.title||"Pipeline Epoch Gantt")}</text> + <text x="24" y="45" fill="#81939f" font-size="10" font-family="monospace">${er(O)}</text> ${p} - </svg>`,width:W,height:L}}function SA(u,l){let f=URL.createObjectURL(u),r=document.createElement("a");r.href=f,r.download=l,r.click(),setTimeout(()=>URL.revokeObjectURL(f),1000)}async function yL(u,l){let f=tL(l,"pipeline"),{svg:r,width:n,height:i}=YS(u,l),t=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),y=URL.createObjectURL(t);try{let c=new Image;await new Promise((F,J)=>{c.onload=()=>F(),c.onerror=()=>J(Error("svg image load failed")),c.src=y});let $=document.createElement("canvas");$.width=n,$.height=i;let A=$.getContext("2d");if(!A)throw Error("canvas unavailable");A.drawImage(c,0,0);let j=await new Promise((F)=>$.toBlob(F,"image/png"));if(!j)throw Error("png export failed");SA(j,`${f}.png`)}catch{SA(t,`${f}.svg`)}finally{URL.revokeObjectURL(y)}}async function xS(u){let l=tL(String(u?.title||"pipeline-gantt"),"pipeline-gantt"),{svg:f,width:r,height:n}=RS(u),i=new Blob([f],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(i);try{let y=new Image;await new Promise((j,F)=>{y.onload=()=>j(),y.onerror=()=>F(Error("gantt svg image load failed")),y.src=t});let c=document.createElement("canvas");c.width=r,c.height=n;let $=c.getContext("2d");if(!$)throw Error("canvas unavailable");$.drawImage(y,0,0);let A=await new Promise((j)=>c.toBlob(j,"image/png"));if(!A)throw Error("gantt png export failed");SA(A,`${l}.png`)}catch{SA(i,`${l}.svg`)}finally{URL.revokeObjectURL(t)}}async function hS(u){for(let l of u){if(l.flow.nodes.length===0)continue;await yL(l.flow,l.title),await new Promise((f)=>setTimeout(f,750))}}function bW(u,l){return u.find((f)=>String(f?.pipelineId||"")===l)||null}function vW(u){return su(u?.startedAt)??su(u?.artifact?.startedAt)??su(u?.request?.createdAt)??su(u?.updatedAt)??0}function bS(u,l){return u.filter((f)=>String(f?.pipelineId||"")===l).slice().sort((f,r)=>vW(f)-vW(r)||String(f?.runId||"").localeCompare(String(r?.runId||"")))}function o9(u,l){let f=String(l?.runId||""),r=u.findIndex((t)=>String(t?.runId||"")===f),n=r>=0?r+1:u.length,i=String(l?.status||"--");return`Epoch ${n} / ${f||"--"} / ${i}`}function Dr(u){return String(u?.procedureRunId||u?.runId||"")}function CA(u,l){let f=String(u?.nodeId||u?.request?.nodeId||"");if(f)return f;let r=Dr(u),n=`${l}__`;if(r.startsWith(n))return r.slice(n.length).replace(/__\d+$/u,"");return""}function EA(u,l){let f=pu(u?.artifact)?u.artifact:{},r=pu(u?.request)?u.request:{};return oc(u?.startedAt,f.startedAt,r.createdAt,r.startedAt,u?.createdAt,u?.updatedAt,l?.startedAt,l?.request?.createdAt)}function OA(u,l){let f=String(u?.status?.status||u?.artifact?.status||u?.status||"").toLowerCase(),r=pu(u?.artifact)?u.artifact:{},n=l7(f);return oc(u?.finishedAt,r.finishedAt,u?.completedAt,n?u?.updatedAt:void 0,n?r.updatedAt:void 0,n?l?.updatedAt:void 0)}function cL(u,l,f=Date.now()){let r=String(u?.runId||""),n=new Set(l.map((i)=>String(i?.id||"")).filter(Boolean));return Du(u?.procedureRuns).flatMap((i)=>{let t=CA(i,r);if(!t)return[];let y=String(i?.status?.status||i?.artifact?.status||i?.status||"unknown").toLowerCase(),c=EA(i,u),$=su(c);if($===null)return[];let A=OA(i,u),j=su(A)??(l7(y)?su(i?.updatedAt)??$+1000:f),F=Math.max($+1000,j);return[{nodeId:t,knownNode:n.has(t),procedureRunId:Dr(i),status:y,startMs:$,endMs:F,startedAt:gc($),finishedAt:gc(F),durationMs:F-$,runId:r,raw:i}]}).sort((i,t)=>i.startMs-t.startMs||i.endMs-t.endMs||i.nodeId.localeCompare(t.nodeId))}function vS(u,l,f=[]){let r=l.map((A)=>Number(A.startMs)).filter(Number.isFinite),n=l.map((A)=>Number(A.endMs)).filter(Number.isFinite);for(let A of f){let j=pl(A?.eventMs??A?.ms);if(j!==null)r.push(j),n.push(j)}let i=su(u?.startedAt)??su(u?.artifact?.startedAt)??su(u?.request?.createdAt),t=su(u?.finishedAt)??su(u?.artifact?.finishedAt)??su(u?.updatedAt);if(i!==null)r.push(i);if(t!==null)n.push(t);let y=Date.now(),c=r.length>0?Math.min(...r):y-60000,$=Math.max(c+60000,n.length>0?Math.max(...n):y);return{startMs:c,endMs:$,durationMs:$-c}}var ZA=12,_L=20,d9=100,kS=!1;function o0(u){let l=Number(u);if(!Number.isFinite(l))return 0;return Math.max(0,Math.min(100,Math.round(l*100)/100))}function IS(u){let l=Math.max(ZA,Number(u||ZA)),f=Math.log(l/ZA)/Math.log(_L);return o0(f*100)}var ac=IS(d9);function y7(u){let l=o0(u)/100,f=ZA*Math.pow(_L,l),r=l<0.24?"全局":l<0.64?"均衡":"细节";return{value:o0(l*100),pxPerMinute:f,label:r}}function b9(u){let l=Math.round(Number(u));return Math.abs(l-d9)<=1?d9:l}function gS(u,l=ac){let f=Math.max(1,Number(u.durationMs||0)/60000),r=y7(l);return Math.round(Math.max(360,Math.min(7200,f*Number(r.pxPerMinute||48))))}function sS(u,l=7){let f=Math.max(1,Number(u.endMs||0)-Number(u.startMs||0));return Array.from({length:l},(r,n)=>{let i=l===1?0:n/(l-1);return{ms:Number(u.startMs)+f*i,percent:i*100}})}function aS(u,l){let f=Math.max(1,Number(l.endMs)-Number(l.startMs));return Math.max(0,Math.min(100,(u-Number(l.startMs))/f*100))}function pl(u){let l=Number(u);return Number.isFinite(l)?l:null}function c7(u){return sW(u?.status)&&!l7(u?.status)}function $L(u,l,f,r){let n=Math.max(1,f-l),i=Math.max(0,Math.min(1,(u-l)/n));return Number((i*r).toFixed(3))}function kW(u,l){if(!l)return null;let f=pl(l?.startMs),r=pl(l?.endMs),n=pl(l?.chartHeight);if(f===null||r===null||n===null)return null;return $L(u,f,r,n)}function AL(u,l){let f=pl(u?.rawStartMs??u?.startMs)??pl(u?.startMs)??l,r=pl(u?.endMs)??f+1000;if(!c7(u))return Math.max(f+1000,r);return Math.max(f+1000,r,l)}function oS(u,l,f,r){let n=pl(u?.startMs)??r-60000,i=pl(u?.endMs)??r,t=f.reduce((Q,W)=>Math.max(Q,AL(W,r)),i),y=Math.max(n+60000,i,t),c=Math.max(1,y-n),$={startMs:n,endMs:y,durationMs:c},A=gS($,l),j=y7(l),F=Math.max(5,Math.min(18,Math.round(A/150))),J=sS($,F).map((Q)=>{let W=Number(Q.ms),L=$L(W,n,y,A);return{...Q,y:L,timestamp:gc(W),offsetMs:W-n}});return{source:"frontend-y",startMs:n,endMs:y,durationMs:c,chartHeight:A,scale:o0(l),normalizedScale:Number((o0(l)/100).toFixed(3)),pxPerMinute:Number(Number(j.pxPerMinute||0).toFixed(3)),ticks:J}}function dS(u,l,f){if(!c7(u))return u;let r=pl(u?.rawStartMs??u?.startMs)??pl(u?.startMs)??f,n=AL(u,f),i=kW(r,l),t=kW(n,l),y=pl(i??u?.y1??u?.startY)??0,c=pl(t??u?.y2??u?.endY)??y+10,$=Math.max(24,c-y);return{...u,live:!0,startMs:r,endMs:n,durationMs:Math.max(1000,n-r),finishedAt:gc(n),y1:y,y2:c,startY:y,endY:c,height:$}}function _7(u,l,f){return aS(u,l)/100*f}function Oy(u){return Boolean(u&&String(u?.source||"")!=="frontend-y")}function jL(u,l,f,r,n){if(Oy(r))for(let t of n){let y=pl(u?.[t]);if(y!==null)return y}let i=pl(u?.ms??u?.eventMs??u?.startMs);return _7(i??Number(l.startMs),l,f)}function XA(u,l,f,r){return jL(u,l,f,r,["y1","startY"])}function e9(u,l,f,r){if(Oy(r)){let i=pl(u?.y2??u?.endY);if(i!==null)return i}let n=pl(u?.endMs)??Number(l.endMs);return _7(n,l,f)}function FL(u,l,f,r){if(Oy(r)){let i=pl(u?.height);if(i!==null)return Math.max(1,i)}let n=u?.live?24:10;return Math.max(n,e9(u,l,f,r)-XA(u,l,f,r))}function Qr(u,l,f,r){return jL(u,l,f,r,["y","timeAxisY"])}function UL(u,l,f,r){if(Oy(r)||String(r?.source||"")==="frontend-y"){let t=pl(u?.y);if(t!==null)return t}let n=pl(u?.percent);if(n!==null)return n/100*f;let i=pl(u?.ms)??Number(l.startMs);return _7(i,l,f)}function eS(u){let l=String(u?.promptEvent||u?.raw?.promptEvent||u?.event||"").toLowerCase();if(!["node-long-running-observation","node-finished"].includes(l))return"";let f=String(u?.sourceNodeId||u?.raw?.sourceNodeId||u?.raw?.detail?.nodeId||""),r=String(u?.nodeId||u?.targetNodeId||"");return f&&f!==r?f:""}function uX(u,l){let f=new Set(l.map((n)=>[String(n.sourceNodeId||""),String(n.targetNodeId||""),String(n.targetMarkerId||""),String(n.action||"")].join(":"))),r=[...l];for(let n of u){let i=eS(n),t=String(n?.nodeId||""),y=String(n?.id||"");if(!i||!t||!y)continue;let c=[i,t,y,"observe"].join(":");if(f.has(c))continue;f.add(c),r.push({id:`observation-arrow:${y}:${i}:${t}`,commandId:String(n?.commandId||n?.eventId||y),sourceNodeId:i,targetNodeId:t,sourceMarkerId:"",targetMarkerId:y,sourceKind:"monitor",action:"observe",status:"observation"})}return{markers:u,arrows:r}}function lX(u){let l=un(u),f=String(u?.promptEvent||"");if(l==="initial-prompt-delivered")return"initial";if(f==="node-finished"||f==="node-long-running-observation"||f.startsWith("monitor-"))return"monitor";if(l==="monitor-prompt-delivered"||String(u?.sourceKind||"").toLowerCase()==="monitor")return"monitor";return"append"}function fX(u){return Du(u?.tags||u?.raw?.tags).map((l)=>String(l||"")).filter(Boolean)}function rX(u){let l=un(u),f=String(u?.promptEvent||"");if(l==="initial-prompt-delivered")return"初始 prompt";if(f==="node-long-running-observation")return"长任务观察";if(f==="node-finished")return fX(u).includes("monitor.audit")?"节点完成 / OA 审核":"节点完成";if(f==="monitor-interval")return"Monitor observation";if(f==="monitor-start")return"Monitor start";if(f==="monitor-stop")return"Monitor stop";if(l==="monitor-prompt-delivered")return"Monitor prompt";if(l==="append-prompt-queued")return"追加 prompt 已排队";return"追加 prompt"}function IW(u){let l=un(u);if(l==="control-command-applied")return 3;if(l==="control-command-ignored")return 2;if(l==="control-command-queued")return 1;return 0}function nX(u,l){let f=String(u?.commandId||"");if(f)return`command:${f}`;return["control-event",Gy(u)||oc(u?.createdAt,u?.timestamp)||`index-${l}`,String(u?.sourceKind||""),String(u?.sourceNodeId||""),String(u?.targetNodeId||""),ei(u)].join(":")}function iX(u){return s9([u?.targetNodeId,...Du(u?.resetNodeIds)])}function tX(u,l){let f=kc(u),r=un(u),n=String(u?.targetNodeId||""),i=Boolean(n)&&l!==n;if(r==="control-command-applied")return i?`${f} 波及`:`${f} 生效`;if(r==="control-command-ignored")return`${f} 忽略`;if(r==="control-command-queued")return`${f} 已发起`;return i?`${f} 波及`:f}function yX(u){if(un(u)==="control-command-ignored")return"ignored";let f=ei(u);if(f==="restart"||f==="redo")return"restart";if(f==="modify")return"modify";if(f==="approve")return"approve";if(f==="guide")return"guide";return"pending"}function cX(u){let l=String(u?.sourceKind||"").toLowerCase();if(l==="monitor")return"monitor";if(l==="webui")return"webui";if(l==="cli")return"cli";return"system"}function _X(u,l,f,r){let n=u.filter(($)=>String($.nodeId||"")===l).sort(($,A)=>Number($.startMs)-Number(A.startMs)),i=n.find(($)=>f>=Number($.startMs)-1000&&f<=Number($.endMs)+1000);if(i)return{ms:f,onInterval:!0,snapReason:"inside-interval",procedureRunId:String(i.procedureRunId||"")};let t=ei(r),y=n.slice().reverse().find(($)=>Number($.endMs)<=f+1000);if(y&&t==="approve")return{ms:Number(y.endMs),onInterval:!0,snapReason:"previous-interval-end",procedureRunId:String(y.procedureRunId||"")};let c=n.find(($)=>Number($.startMs)>=f-1000);if(c&&["guide","modify","restart","redo"].includes(t))return{ms:Number(c.startMs),onInterval:!0,snapReason:"next-interval-start",procedureRunId:String(c.procedureRunId||"")};return{ms:f,onInterval:!1,snapReason:"event-time",procedureRunId:String(r?.procedureRunId||"")}}function JL(u,l,f,r){let n=Math.hypot(f-u,r-l),i=n>HW?HW:0,t=i>0?f-(f-u)/n*i:f,y=i>0?r-(r-l)/n*i:r,c=t-u,$=Math.max(16,Math.min(42,Math.abs(c)*0.45+12)),A=c===0?1:Math.sign(c);return`M ${u},${l} C ${u+A*$},${l} ${t-A*$},${y} ${t},${y}`}function $X(u,l){let f=String(u?.runId||l?.runId||""),r=cL({...pu(l)?l:{},...pu(u)?u:{},runId:f,procedureRuns:Du(u?.procedureRuns).length>0?u.procedureRuns:l?.procedureRuns},[]),n=[],i=[],t=[],y=new Set,c=new Map,$=(F,J)=>{if(!F.nodeId||!Number.isFinite(Number(F.ms)))return;if(y.has(F.id))return;y.add(F.id),J.push(F)};for(let F of Du(u?.procedureRuns)){let J=CA(F,f),Q=Dr(F);if(!J)continue;for(let W of Du(F?.attempts)){let L=PA(W);for(let U of g9(W?.controlEventRecords)){let q=un(U);if(!["initial-prompt-delivered","append-prompt-delivered","monitor-prompt-delivered"].includes(q))continue;let N=Gy(U),w=su(N);if(w===null)continue;let G=String(U?.eventId||"");$({id:`prompt:${G||`${Q}:${L}:${q}:${w}`}`,runId:f,nodeId:J,procedureRunId:Q,attempt:L,kind:"prompt",tone:lX(U),status:"delivered",label:rX(U),ms:w,timestampIso:N,sourceKind:String(U?.sourceKind||""),sourceNodeId:String(U?.sourceNodeId||""),targetNodeId:J,action:"",eventId:G,commandId:String(U?.commandId||""),raw:U},n)}}}let A=new Map;g9(u?.controlEvents).forEach((F,J)=>{let Q=nX(F,J),W=A.get(Q)||{key:Q,events:[]};W.events.push(F),A.set(Q,W)});for(let F of A.values()){let J=Du(F.events).slice().sort((B,D)=>IW(D)-IW(B)),Q=Du(F.events).find((B)=>un(B)==="control-command-queued")||null,W=J[0]||Q;if(!Q&&!W)continue;let L=String(Q?.sourceNodeId||W?.sourceNodeId||""),U=String(Q?.sourceKind||W?.sourceKind||""),q=Gy(Q)||Gy(W)||oc(Q?.createdAt,W?.createdAt),N=su(q),w=String(W?.commandId||Q?.commandId||F.key),G=(un(W)||"control-command-queued").replace(/^control-command-/u,""),Z="";if(L&&N!==null)Z=`control-source:${w}:${L}`,c.set(w,Z),$({id:Z,runId:f,nodeId:L,procedureRunId:String(Q?.procedureRunId||W?.procedureRunId||""),attempt:"",kind:"control-source",tone:cX(Q||W),status:G,label:`${kc(Q||W)} 发起`,ms:N,timestampIso:q,action:ei(Q||W),sourceKind:U,sourceNodeId:L,targetNodeId:String(W?.targetNodeId||Q?.targetNodeId||""),commandId:w,raw:Q||W},i);let H=W||Q,E=Gy(H)||q,m=su(E);if(m===null)continue;let S=iX(H);for(let B of S){let D=_X(r,B,m,H),X=`control-target:${w}:${B}`;if($({id:X,runId:f,nodeId:B,procedureRunId:D.procedureRunId,attempt:"",kind:"control-target",tone:yX(H),status:G,label:tX(H,B),ms:D.ms,eventMs:m,onInterval:D.onInterval,snapReason:D.snapReason,snapped:Number(D.ms)!==m,timestampIso:E,renderedTimestampIso:gc(Number(D.ms)),action:ei(H),sourceKind:U,sourceNodeId:L,targetNodeId:B,commandId:w,raw:H},i),Z&&L&&L!==B)t.push({id:`control-arrow:${w}:${L}:${B}`,commandId:w,sourceNodeId:L,targetNodeId:B,sourceMarkerId:Z,targetMarkerId:X,sourceKind:U,action:ei(H),status:G})}}let j=[...n,...i].sort((F,J)=>Number(F.ms)-Number(J.ms)||String(F.nodeId).localeCompare(String(J.nodeId))||String(F.id).localeCompare(String(J.id)));return{...uX(j,t),sourceMarkerByCommand:c}}function AX({details:u,selectedNodeId:l,selectedNodeRuntime:f,control:r,onRaw:n}){if(!u)return K("span",{className:"muted"},"点击“抓取过程”读取 node 运行材料;主界面只显示结构化摘要,完整内容需点开原始 JSON。");let i=Du(u.procedureRuns),t=i.at(-1)||{},y=Du(t.attempts),c=y.at(-1)||{},$=Du(t.workerLogTail),A=Du(c.controlEventsTail),j=Du(c.controlPromptsTail),F=Du(c.monitorPromptsTail),J=M9(A),Q=M9(j),W=M9(F),L=c.opencodeMessages||{};return K("div",{className:"pipeline-evidence-list compact"},K(Vr,{title:"Node runtime",subtitle:l||"--",facts:[`status ${f?.status||"pending"}`,`attempts ${f?.attempts??y.length}`,`procedure ${f?.currentProcedureRunId||Dr(t)||"--"}`,r.fetchedAt?`fetched ${yl(r.fetchedAt)}`:"not fetched"],data:u.node||u,onRaw:n,testId:"raw-pipeline-node-runtime"}),K(Vr,{title:"Procedure runs",subtitle:`${i.length} groups`,facts:[`latest ${t.status?.status||t.status||"--"}`,`steps ${Du(t.recentSteps).length}`,`duration ${mr(su(t.finishedAt)&&su(t.startedAt)?Number(su(t.finishedAt))-Number(su(t.startedAt)):t.durationMs)}`],data:i,onRaw:n,testId:"raw-pipeline-node-procedures"}),K(Vr,{title:"OpenCode messages",subtitle:String(L.exists?"available":"not indexed"),facts:[`messages ${BA(L.messageCount)}`,`size ${BA(L.size)}`,`updated ${wu(L.updatedAt)}`],data:L,onRaw:n,testId:"raw-pipeline-node-messages"}),K(Vr,{title:"Control prompts",subtitle:"manual / monitor append queues",facts:[`manual tail ${Q.total}`,`monitor tail ${W.total}`,`last ${wu(u7(Q.lastAt,W.lastAt))}`],data:{controlPromptsTail:j,monitorPromptsTail:F},onRaw:n,testId:"raw-pipeline-node-prompts"}),K(Vr,{title:"Control events",subtitle:J.eventKinds.length>0?J.eventKinds.join(", "):"event tail",facts:[`tail ${J.total}`,`parsed ${J.parsed}`,`last ${wu(J.lastAt)}`],data:A,onRaw:n,testId:"raw-pipeline-node-events"}),K(Vr,{title:"Worker log",subtitle:"tail is hidden on main canvas",facts:[`tail ${$.length} lines`,"raw only via button",`procedure ${Dr(t)||"--"}`],data:$,onRaw:n,testId:"raw-pipeline-node-worker-log"}))}function jX({activeRun:u,onRaw:l}){if(!u)return K(Nr,{title:"暂无运行材料",text:"没有 Pipeline epoch 时不会展示运行材料索引。"});let f=Du(u.nodes),r=Du(u.procedureRuns),n=Du(u.submissions),i=Du(u.workerLogTail),t=mW(f),y=mW(r),c=r.filter((A)=>String(A?.status||"").toLowerCase()==="failed"),$=u7(...r.flatMap((A)=>[A.updatedAt,A.finishedAt,A.startedAt]));return K("div",{className:"pipeline-evidence-list"},K(Vr,{title:"Epoch overview",subtitle:u.runId||"--",facts:[`pipeline ${u.pipelineId||"--"}`,`status ${u.status||"--"}`,`started ${wu(u.startedAt)}`,`updated ${wu(u.updatedAt)}`],data:u,onRaw:l,testId:"raw-pipeline-run"}),K(Vr,{title:"Node states",subtitle:`${f.length} nodes`,facts:[`running ${t.running||0}`,`succeeded ${t.succeeded||0}`,`failed ${t.failed||0}`,`pending ${t.pending||0}`],data:f,onRaw:l,testId:"raw-pipeline-run-nodes"}),K(Vr,{title:"Procedure run index",subtitle:`${r.length} procedure records`,facts:[`succeeded ${y.succeeded||0}`,`failed ${y.failed||0}`,`latest ${wu($)}`,`errors ${c.length}`],data:r,onRaw:l,testId:"raw-pipeline-run-procedures"}),K(Vr,{title:"OA submissions",subtitle:`${n.length} submission files`,facts:[`records ${n.length}`,`task ${BA(u.task)}`,"raw grouped by run"],data:n,onRaw:l,testId:"raw-pipeline-run-submissions"}),K(Vr,{title:"Worker log tail",subtitle:"hidden from main interface",facts:[`tail ${i.length} lines`,"display raw only after click",`updated ${wu(u.updatedAt)}`],data:i,onRaw:l,testId:"raw-pipeline-run-worker-log"}))}function FX({diagnostics:u,onRaw:l}){let f=Du(u?.runs).filter(pu),r=Du(u?.forbiddenResiduals),n=pu(u?.guarantees)?u.guarantees:{},i=u?.hasNeutralNodeFinishedEvidence===!0&&u?.hasNoAuditPolicyEvidence===!0&&u?.hasAuditPolicyEvidence===!0,t=u?.ok===!0&&i&&r.length===0,y=f[0]||null,c=[{label:"中性完成事实",ok:n.neutralNodeFinished===!0,hint:"node-finished 不携带流程策略"},{label:"Config 策略判定",ok:n.auditPolicyFromConfig===!0,hint:"OA backend 读取当前 epoch 配置"},{label:"控制命令来自 OA",ok:n.runnerConsumesControlCommandsFromOaEvents===!0,hint:"runner 只消费 OA control.command"},{label:"无独立审核事件",ok:n.noIndependentAuditRequestEvent===!0,hint:"审核由 node-finished + policy 派生"},{label:"无批次门禁",ok:n.noBatchFinishedControlGate===!0,hint:"下游启动由每个 node 完成驱动"}];return K("div",{className:"pipeline-oa-panel","data-testid":"pipeline-oa-event-flow-panel"},K("div",{className:"metric-grid compact"},K(Cf,{label:"OA Flow",value:t?"100%":"--",hint:String(u?.mode||"waiting diagnostics"),tone:t?"ok":"warn"}),K(Cf,{label:"禁止残留",value:r.length,hint:r.length===0?"source scan clean":"needs cleanup",tone:r.length===0?"ok":"warn"}),K(Cf,{label:"No-audit",value:u?.hasNoAuditPolicyEvidence?"OK":"--",hint:"OA 下游策略证据",tone:u?.hasNoAuditPolicyEvidence?"ok":"warn"}),K(Cf,{label:"Monitor 审核",value:u?.hasAuditPolicyEvidence?"OK":"--",hint:"OA 控制事件闭环",tone:u?.hasAuditPolicyEvidence?"ok":"warn"})),K("div",{className:"pipeline-oa-guarantees"},c.map(($)=>K("article",{key:$.label,className:`pipeline-oa-guarantee ${$.ok?"ok":"warn"}`},K(a0,{status:$.ok?"online":"warn"},$.ok?"OK":"MISS"),K("div",null,K("strong",null,$.label),K("span",null,$.hint))))),K("div",{className:"pipeline-evidence-list compact"},f.slice(0,6).map(($)=>K(Vr,{key:$.runId,title:String($.runId||"--"),subtitle:[Number($.monitorAuditNodeFinishedCount||0)>0?"monitor audit":"",Number($.noAuditPolicyCount||0)>0?"no-audit policy":""].filter(Boolean).join(" / ")||"event evidence",facts:[`events ${$.eventCount||0}`,`node-finished ${$.nodeFinishedCount||0}`,`policy-in-detail ${$.nodeFinishedWithPolicyCount||0}`,`queued ${$.controlQueuedCount||0}`,`applied ${$.controlAppliedCount||0}`],data:$,onRaw:l,testId:`raw-pipeline-oa-run-${String($.runId||"run").replace(/[^a-zA-Z0-9_.-]+/g,"-")}`}))),y?K("p",{className:"muted paragraph"},`最新证据 ${y.runId}: ${y.nodeFinishedCount||0} 个 node-finished,${y.controlAppliedCount||0} 个控制结果。`):K(Nr,{title:"暂无 OA 事件流证据",text:"等待 Pipeline backend 暴露 diagnostics。"}),u?K("div",{className:"panel-actions inline-actions"},K(ln,{title:"Pipeline OA Event Flow Diagnostics",data:u,onOpen:l,testId:"raw-pipeline-oa-event-flow"})):null)}function UX({quota:u,onRaw:l}){let f=pu(u?.summary)?u.summary:{},r=pu(u?.target)?u.target:{},n=pu(u?.cache)?u.cache:{},i=u?.ok===!0,t=String(u?.modelId||f.modelName||r.modelName||"MiniMax-M2.7"),y=f.totalCount??r.currentIntervalTotalCount,c=f.usageCount??r.currentIntervalUsageCount,$=f.remainingCount??r.currentIntervalRemainingCount,A=f.remainingRatio??(Number.isFinite(Number(y))&&Number(y)>0&&Number.isFinite(Number($))?Number($)/Number(y):void 0),j=f.usageRatio??(Number.isFinite(Number(y))&&Number(y)>0&&Number.isFinite(Number(c))?Number(c)/Number(y):void 0),F=f.resetAt||r.endAt,J=f.remainsMs??r.remainsMs,Q=Number($),W=!i||Number.isFinite(Q)&&Q<=0?"warn":"ok",L=[i?`endpoint ${u?.endpoint||"--"}`:"quota unavailable",`fetched ${HA(u?.fetchedAt)}`,n.hit?`cache ${mr(n.ageMs)}`:"live quota"];return K("div",{className:"pipeline-minimax-quota-panel","data-testid":"pipeline-minimax-quota-panel"},K("div",{className:"metric-grid compact"},K(Cf,{label:"MiniMax",value:i?t:"--",hint:u?.modelComponent||u?.error||"model/minimax-m27",tone:W}),K(Cf,{label:"当前窗口",value:`${C9(c)}/${C9(y)}`,hint:`已用 ${VW(j)}`,tone:W}),K(Cf,{label:"剩余额度",value:C9($),hint:`剩余 ${VW(A)}`,tone:W}),K(Cf,{label:"重置时间",value:HA(F),hint:J!==void 0?`约 ${mr(J)}`:wu(F),tone:W})),K(f7,{items:L}),i?K("p",{className:"muted paragraph"},`MiniMax 限额来自 D601 Pipeline 后端实时查询;当前模型匹配 ${f.modelName||r.modelName||t}。`):K(nl,{error:u?.error||"MiniMax 限额查询失败"}),u?K("div",{className:"panel-actions inline-actions"},K(ln,{title:"Pipeline MiniMax Quota",data:u,onOpen:l,testId:"raw-pipeline-minimax-quota"})):null)}function JX({epochs:u,activeRun:l,activePipeline:f,pipelineNodes:r,pipelineEdges:n,runDetails:i,nodeDetails:t,nodeDetailsState:y,ganttScale:c=ac,onGanttScaleChange:$,onRunChange:A,onIntervalSelect:j,onMarkerSelect:F,selection:J,detailOpen:Q,onDetailOpenChange:W,onRaw:L}){let[U,q]=ef(kS),[N,w]=ef({startY:0,endY:0,startMs:0,endMs:0}),[G,Z]=ef(Date.now()),H=g0(null),E=String(l?.runId||""),m=Boolean(Q),S=($u)=>{if(typeof W==="function")W($u)},B=o0(c??ac),D=String(i?.runId||"")===E?i?.details:null,X=D?{...pu(l)?l:{},...pu(D)?D:{},runId:E,procedureRuns:Du(D?.procedureRuns).length>0?D.procedureRuns:l?.procedureRuns}:l,O=cL(X,r,G),Y=D?$X(D,X):{markers:[],arrows:[]},p=Du(Y.markers),v=vS(X,O,p),z=oS(v,B,O,G),P=String(z.source||"frontend-y"),k=O.map(($u)=>dS($u,z,G)),I={startMs:Number(z.startMs),endMs:Number(z.endMs),durationMs:Math.max(1,Number(z.durationMs??Number(z.endMs)-Number(z.startMs)))},b=y7(B),d={...b,pxPerMinute:Number(z.pxPerMinute??b.pxPerMinute)},s=Math.round(Number(z.chartHeight||360)),h=O.some(c7);Ln(()=>{if(!E||!h)return;let $u=window.setInterval(()=>Z(Date.now()),1000);return()=>window.clearInterval($u)},[E,h]);let lu=SS(f,r,Array.isArray(n)?n:[]),cu=r.map(($u)=>String($u?.id||"")).filter(Boolean),_u=k.map(($u)=>String($u.nodeId||"")).filter(Boolean),Fu=p.map(($u)=>String($u.nodeId||"")).filter(Boolean),zu=Array.from(new Set([...lu,...cu,..._u,...Fu])),Wu={startY:0,endY:s,startMs:Number(I.startMs),endMs:Number(I.endMs)},C=Number(N?.endY||0)>0?N:Wu,e=($u)=>{return XA($u,I,s,z)<=Number(C.endY)&&e9($u,I,s,z)>=Number(C.startY)},uu=($u)=>{let au=Qr($u,I,s,z);return au>=Number(C.startY)&&au<=Number(C.endY)},Gu=new Set(zu.filter(($u)=>k.some((au)=>au.nodeId===$u&&e(au))||p.some((au)=>au.nodeId===$u&&uu(au)))),a=U?zu.filter(($u)=>Gu.has($u)):zu,qu=`${Y9}px ${a.length>0?a.map(()=>`${wn}px`).join(" "):"minmax(160px, 1fr)"}`,Zu=Du(z.ticks).filter(pu),Bu=String(J?.mode==="interval"?J?.interval?.procedureRunId||"":""),gu=String(J?.mode==="event"?J?.marker?.id||"":""),ll=()=>{let $u=H.current;if(!$u){w(Wu);return}let au=Math.max(0,$u.scrollTop-P9),Nf=Math.max(120,$u.clientHeight-P9),Yu=Math.min(s,au+Nf),Sl={startY:au,endY:Yu,startMs:Number(I.startMs),endMs:Number(I.endMs)},dl=Math.max(0,Math.min(1,au/s)),rr=Math.max(dl,Math.min(1,Yu/s)),Af=Math.max(1,Number(I.endMs)-Number(I.startMs));Sl.startMs=Number(I.startMs)+Af*dl,Sl.endMs=Number(I.startMs)+Af*rr,w(Sl)};Ln(()=>{let $u=H.current,au=window.setTimeout(ll,0);return $u?.addEventListener("scroll",ll),window.addEventListener("resize",ll),()=>{window.clearTimeout(au),$u?.removeEventListener("scroll",ll),window.removeEventListener("resize",ll)}},[E,I.startMs,I.endMs,s]);let Pu=Math.max(0,zu.length-a.length),Nl=new Set(p.filter(($u)=>a.includes(String($u.nodeId||""))&&uu($u)).map(($u)=>String($u.id))),Qf=new Map(p.map(($u)=>[String($u.id),$u])),Zf=Du(Y.arrows).filter(($u)=>{if(!Nl.has(String($u.targetMarkerId||"")))return!1;if(String($u.action||"")==="observe")return a.includes(String($u.sourceNodeId||""));return Nl.has(String($u.sourceMarkerId||""))}),$f=Y9+Math.max(1,a.length)*wn,nf=($u)=>{let au=o0($u.target.value);if(typeof $==="function")$(au);window.setTimeout(ll,0)},tf=()=>xS({title:`${f?.id||"pipeline"}-${E||"epoch"}-gantt`,meta:[`run ${E||"--"}`,`${wu(I.startMs)} -> ${wu(I.endMs)}`,`duration ${mr(I.durationMs)}`,`${d.label} / ${b9(d.pxPerMinute)} px/min`,`${a.length}/${zu.length} nodes`,`${p.length} markers`],visibleNodeIds:a,intervals:k,markers:p.filter(($u)=>a.includes(String($u.nodeId||""))),arrows:Zf,ticks:Zu,bounds:I,chartHeight:s,backendLayout:z}),Mf=pu(D?.gantt?.diagnostics)?D.gantt.diagnostics:null;return K(Wn,{title:"Epoch 甘特图",eyebrow:`${f?.id||"pipeline"} / ${u.length} epochs`,className:"pipeline-wide-panel",loading:i?.loading,actions:K("div",{className:"pipeline-gantt-actions"},K("select",{value:E,disabled:u.length===0,onChange:($u)=>A($u.target.value),"data-testid":"pipeline-epoch-select"},u.map(($u)=>K("option",{key:$u.runId,value:$u.runId},o9(u,$u)))),K("label",{className:"pipeline-gantt-toggle"},K("input",{type:"checkbox","data-testid":"pipeline-gantt-auto-hide-idle",checked:U,onChange:($u)=>{q(Boolean($u.target.checked)),window.setTimeout(ll,0)}}),K("span",null,"自动隐藏空闲列")),K("label",{className:"pipeline-gantt-scale"},K("span",null,K("b",null,"时间尺度"),K("em",{"data-testid":"pipeline-gantt-scale-label"},`${d.label} · ${b9(d.pxPerMinute)} px/min`)),K("input",{type:"range",min:0,max:100,step:0.01,value:B,onChange:nf,"aria-label":"调整甘特图时间尺度","data-testid":"pipeline-gantt-time-scale"}),K("small",null,K("span",null,"全局"),K("span",null,"细节"))),l?K("button",{type:"button",className:"ghost-btn",onClick:tf,disabled:a.length===0,"data-testid":"pipeline-export-gantt"},"导出甘特图"):null,l?K(ln,{title:`Pipeline Epoch ${l.runId}`,data:l,onOpen:L,testId:"raw-pipeline-epoch-gantt"}):null)},!l?K(Nr,{title:"暂无 Epoch",text:"当前 pipeline 还没有完整运行记录。"}):k.length===0?K(Nr,{title:"暂无时间区间",text:"等待 D601 Pipeline backend 在 procedure summary 中返回 startedAt / finishedAt。"}):K("div",{className:"pipeline-gantt-wrap"},K("div",{className:`pipeline-gantt-detail-layout ${m?"detail-open":"detail-collapsed"}`,"data-testid":"pipeline-gantt-detail-layout","data-sidebar-open":m?"true":"false"},K("div",{className:"pipeline-gantt-main"},K("div",{className:"pipeline-gantt-main-head"},K("div",{className:"pipeline-gantt-meta"},K("span",null,`time ${wu(I.startMs)} -> ${wu(I.endMs)}`),K("span",null,`duration ${mr(I.durationMs)}`),K("span",null,`scale ${d.label} / ${b9(d.pxPerMinute)} px/min`),K("span",null,`layout ${P}`),Mf?K("span",null,`align ${Mf.timeAxisAlignmentOk===!1?"check":"ok"}`):null,K("span",null,`visible ${a.length}/${zu.length} nodes`),D?K("span",null,`markers ${p.length}`):null,U&&Pu>0?K("span",null,`hidden idle ${Pu}`):null),!m?K("button",{type:"button",className:"pipeline-sidecar-tab right",disabled:!J?.mode,onClick:()=>S(!0),"data-testid":"pipeline-gantt-sidebar-toggle"},J?.mode?"展开详情":"点击甘特图元素展开详情"):null),K("div",{className:"pipeline-gantt-viewport",ref:H,"data-testid":"pipeline-epoch-gantt","data-pipeline-id":f?.id||"","data-run-id":E,"data-layout-source":P,"data-start-ms":String(I.startMs),"data-end-ms":String(I.endMs),"data-chart-height":String(s)},K("div",{className:"pipeline-gantt-board",style:{gridTemplateColumns:qu,minWidth:`${$f}px`}},K("div",{className:"pipeline-gantt-head time"},"Time"),a.length===0?K("div",{className:"pipeline-gantt-head empty"},"当前时间窗无工作节点"):a.map(($u)=>K("div",{key:`head-${$u}`,className:"pipeline-gantt-head node",title:$u,"data-testid":"pipeline-gantt-head-node","data-node-id":$u},K(QS,{value:$u}))),K("div",{className:"pipeline-gantt-time-axis",style:{height:`${s}px`}},Zu.map(($u)=>{let au=UL($u,I,s,z);return K("div",{key:`tick-${$u.ms}-${au}`,className:"pipeline-gantt-tick",style:{top:`${au}px`},"data-testid":"pipeline-gantt-tick","data-ms":String($u.ms),"data-y":String(au)},K("b",null,wu($u.ms)),K("span",null,`+${mr(Number($u.offsetMs??Number($u.ms)-Number(I.startMs)))}`))})),a.length>0?K("svg",{className:"pipeline-gantt-arrow-layer",width:a.length*wn,height:s,viewBox:`0 0 ${a.length*wn} ${s}`,style:{left:`${Y9}px`,top:`${P9}px`,width:`${a.length*wn}px`,height:`${s}px`},"aria-hidden":"true"},K("defs",null,K("marker",{id:"pipeline-gantt-arrowhead",viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse"},K("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"}))),Zf.map(($u)=>{let au=Qf.get(String($u.targetMarkerId||""));if(!au)return null;let Nf=Qf.get(String($u.sourceMarkerId||"")),Yu=String(Nf?.nodeId||$u.sourceNodeId||""),Sl=a.indexOf(Yu),dl=a.indexOf(String(au.nodeId||""));if(Sl<0||dl<0)return null;let rr=Sl*wn+wn/2,Af=dl*wn+wn/2,Hf=Nf?Qr(Nf,I,s,z):Qr(au,I,s,z),Gn=Qr(au,I,s,z);return K("path",{key:$u.id,className:`pipeline-gantt-arrow ${String($u.sourceKind||"").toLowerCase()} ${String($u.status||"").toLowerCase()} ${String($u.action||"").toLowerCase()}`,d:JL(rr,Hf,Af,Gn),markerEnd:"url(#pipeline-gantt-arrowhead)","data-testid":String($u.action||"")==="observe"?"pipeline-gantt-observation-arrow":"pipeline-gantt-arrow","data-source-node-id":String($u.sourceNodeId||""),"data-target-node-id":String($u.targetNodeId||""),"data-target-marker-id":String($u.targetMarkerId||""),"data-action":String($u.action||""),"data-source-y":String(Hf),"data-target-y":String(Gn)})})):null,a.length===0?K("div",{className:"pipeline-gantt-empty-col",style:{height:`${s}px`}},"滚动到有活动的时间段后,相关 node 列会自动出现。"):a.map(($u)=>{let au=k.filter((Yu)=>Yu.nodeId===$u),Nf=p.filter((Yu)=>String(Yu.nodeId||"")===$u);return K("div",{key:`col-${$u}`,className:"pipeline-gantt-node-col",style:{height:`${s}px`}},au.map((Yu)=>{let Sl=XA(Yu,I,s,z),dl=e9(Yu,I,s,z),rr=FL(Yu,I,s,z),Af=String(Yu.procedureRunId||`${$u}-${Yu.startMs}`);return K("button",{key:Af,type:"button",className:`pipeline-gantt-bar ${Yu.status} ${Yu.live?"live":""} ${Bu===Af?"selected":""}`,style:{top:`${Sl}px`,height:`${rr}px`},title:`${$u} ${Yu.status} ${wu(Yu.startedAt||Yu.startMs)} -> ${wu(Yu.finishedAt||Yu.endMs)}`,onClick:()=>j(Yu),"data-testid":"pipeline-gantt-line","data-node-id":$u,"data-procedure-run-id":String(Yu.procedureRunId||""),"data-status":String(Yu.status||""),"data-live":Yu.live?"true":"false","data-start-ms":String(Yu.startMs||""),"data-end-ms":String(Yu.endMs||""),"data-y1":String(Sl),"data-y2":String(dl),"data-natural-height":String(Math.max(0,dl-Sl))},K("strong",null,Yu.status||"working"),K("span",null,mr(Yu.durationMs)))}),Nf.map((Yu)=>K("button",{key:Yu.id,type:"button",className:`pipeline-gantt-marker ${Yu.kind} ${Yu.tone||""} ${Yu.status||""} ${gu===String(Yu.id)?"selected":""}`,style:{top:`${Qr(Yu,I,s,z)}px`},title:`${Yu.label||"event"} / ${wu(Yu.timestampIso||Yu.timestamp||Yu.ms)}`,onClick:()=>F(Yu),"data-testid":Yu.kind==="prompt"?"pipeline-gantt-prompt-marker":"pipeline-gantt-control-marker","data-marker-id":String(Yu.id||""),"data-ms":String(Yu.ms??Yu.eventMs??""),"data-y":String(Qr(Yu,I,s,z))})))})))),m?K(JS,{selection:J,runDetails:i,nodeDetails:t,nodeDetailsState:y,onRaw:L,onCollapse:()=>S(!1)}):null)))}function on(){return{loading:!1,actionLoading:"",error:"",message:"",details:null,fetchedAt:null,appendPrompt:"",guidePrompt:"",modifyPrompt:"",approveReason:"",redoReason:""}}function I0(){return{mode:"",runId:"",interval:null,marker:null}}function v9(){return{runId:"",loading:!1,error:"",details:null,fetchedAt:null}}function hc(u,l){return`${u}/microservices/pipeline/proxy${l}`}function QX({activeRun:u,pipelineRuns:l,selectedRunId:f,onRunChange:r,selectedNodeId:n,selectedNodeConfig:i,selectedNodeRuntime:t,control:y,onControlChange:c,onFetch:$,onAction:A,onRaw:j,onCollapse:F}){let J=String(u?.runId||""),Q=String(t?.status||"pending"),W=!J||!n||y.loading||Boolean(y.actionLoading),L=(q)=>(N)=>c({[q]:N.target.value,error:"",message:""}),U=l.length>0?l:u?[u]:[];return K("aside",{className:"pipeline-node-control","data-testid":"pipeline-node-control"},K("div",{className:"pipeline-node-control-head"},K("div",null,K("p",{className:"panel-eyebrow"},"Manual Node Control"),K(rl,{title:n||"点击控制图中的 node",level:3,loading:y.loading||Boolean(y.actionLoading)})),K("div",{className:"pipeline-node-control-head-actions"},n?K(a0,{status:Q},Q):K(a0,{status:"pending"},"idle"),K("button",{type:"button",className:"ghost-btn mini",onClick:F,"data-testid":"pipeline-node-sidebar-collapse"},"收起"))),K("div",{className:"pipeline-control-runbar"},K("label",null,K("span",null,"目标 run"),K("select",{value:J||f,disabled:U.length===0,onChange:(q)=>r(q.target.value),"data-testid":"pipeline-node-run-select"},U.map((q)=>K("option",{key:q.runId,value:q.runId},`${q.runId||"--"} / ${q.status||"--"}`)))),K("button",{type:"button",className:"ghost-btn",disabled:W,onClick:$,"data-testid":"pipeline-node-fetch"},y.loading?"抓取中":"抓取过程"),y.details?K(ln,{title:`Pipeline Node ${n}`,data:y.details,onOpen:j,testId:"raw-pipeline-node-control"}):null),K("div",{className:"pipeline-control-meta"},K("span",null,K("b",null,"kind"),String(i?.kind||"--")),K("span",null,K("b",null,"procedure"),String(t?.currentProcedureRunId||"--")),K("span",null,K("b",null,"attempts"),String(t?.attempts??"--")),K("span",null,K("b",null,"updated"),wu(u?.updatedAt))),!n?K(Nr,{title:"未选择 node",text:"点击 React Flow 控制图中的任意 node 后,可抓取执行过程、追加 prompt、下发引导、增量修改、审核通过或重做。"}):null,K(nl,{error:y.error,wide:!0}),K("div",{className:"pipeline-control-actions"},K("label",null,K("span",null,"实时追加 prompt(仅 running node)"),K("textarea",{value:y.appendPrompt,onChange:L("appendPrompt"),placeholder:"让当前执行中的 agent 继续、补充检查或调整当前步骤...",rows:4,disabled:!n,"data-testid":"pipeline-node-append-input"}),K("button",{type:"button",className:"primary-btn compact",disabled:W||!String(y.appendPrompt||"").trim(),onClick:()=>A("append"),"data-testid":"pipeline-node-append-button"},y.actionLoading==="append"?"追加中":"追加到运行中 node")),K("label",null,K("span",null,"下次尝试引导 prompt"),K("textarea",{value:y.guidePrompt,onChange:L("guidePrompt"),placeholder:"给该 node 下一次 attempt 的执行提示;不会立即打断当前 session。",rows:4,disabled:!n,"data-testid":"pipeline-node-guide-input"}),K("button",{type:"button",className:"ghost-btn compact",disabled:W||!String(y.guidePrompt||"").trim(),onClick:()=>A("guide"),"data-testid":"pipeline-node-guide-button"},y.actionLoading==="guide"?"下发中":"下发 guide")),K("label",null,K("span",null,"完成后增量修改 prompt"),K("textarea",{value:y.modifyPrompt,onChange:L("modifyPrompt"),placeholder:"在该 node 已完成结果基础上追加修改要求;runner 会重跑目标 node,并保留同 node 既有 OA 输出作为上下文。",rows:4,disabled:!n,"data-testid":"pipeline-node-modify-input"}),K("button",{type:"button",className:"ghost-btn compact",disabled:W||!String(y.modifyPrompt||"").trim(),onClick:()=>A("modify"),"data-testid":"pipeline-node-modify-button"},y.actionLoading==="modify"?"排队中":"增量修改 node")),K("label",null,K("span",null,"Monitor 审核通过原因"),K("textarea",{value:y.approveReason,onChange:L("approveReason"),placeholder:"当流程配置开启 monitor 审核时,记录审核通过原因并释放后续 node。",rows:3,disabled:!n,"data-testid":"pipeline-node-approve-input"}),K("button",{type:"button",className:"primary-btn compact",disabled:W||!String(y.approveReason||"").trim(),onClick:()=>A("approve"),"data-testid":"pipeline-node-approve-button"},y.actionLoading==="approve"?"提交中":"审核通过")),K("label",null,K("span",null,"重做 / restart 原因"),K("textarea",{value:y.redoReason,onChange:L("redoReason"),placeholder:"说明为什么需要重做;runner 会重置目标 node 以及非 rework 下游 node。",rows:4,disabled:!n,"data-testid":"pipeline-node-redo-input"}),K("button",{type:"button",className:"danger-btn compact",disabled:W||!String(y.redoReason||"").trim(),onClick:()=>A("redo"),"data-testid":"pipeline-node-redo-button"},y.actionLoading==="redo"?"排队中":"重做 node"))),K("div",{className:"pipeline-control-evidence"},K("strong",null,"Node 过程索引"),K(AX,{details:y.details,selectedNodeId:n,selectedNodeRuntime:t,control:y,onRaw:j})))}function QL({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((fu)=>fu.id==="pipeline")||null,[n,i]=ef({loading:!1,error:"",health:null,snapshot:null,oaDiagnostics:null,minimaxQuota:null,refreshedAt:null}),[t,y]=ef(""),[c,$]=ef(""),[A,j]=ef(""),[F,J]=ef(on()),[Q,W]=ef({}),[L,U]=ef(I0()),[q,N]=ef(v9()),[w,G]=ef(ac),[Z,H]=ef(!1),[E,m]=ef(!1),S=g0(0),{addNotification:B}=Xf(),D=g0(!1),X=g0(0),O=g0(""),Y=g0({}),p=g0(""),v=g0("");async function z(fu={}){let Vu=fu.silent===!0;if(!r)return;if(D.current)return;D.current=!0;let Xu=S.current+1;if(S.current=Xu,!Vu)i((ou)=>({...ou,loading:!0,error:""}));try{let ou=`__unideskArrayLimit=registry.components:80,runs:${dp}`,[Al,kl,_l]=await Promise.all([k0(`${f}/microservices/pipeline/proxy/api/snapshot?${ou}`,{cache:"no-store"}),k0(`${f}/microservices/pipeline/proxy/api/oa-event-flow/diagnostics`,{cache:"no-store"}).catch((Sr)=>({ok:!1,error:Ou(Sr,"OA event flow diagnostics failed")})),k0(`${f}/microservices/pipeline/proxy/api/model-quota/minimax`,{cache:"no-store"}).catch((Sr)=>({ok:!1,error:Ou(Sr,"MiniMax quota failed")}))]);if(Xu!==S.current)return;let qf={ok:Al?.ok!==!1,service:"pipeline-v2-control snapshot"};i({loading:!1,error:"",health:qf,snapshot:Al,oaDiagnostics:kl,minimaxQuota:_l,refreshedAt:new Date})}catch(ou){if(Xu!==S.current)return;i((Al)=>({...Al,loading:!1,error:Ou(ou,"Pipeline 加载失败")}))}finally{D.current=!1}}Ln(()=>{if(z(),!r)return;let fu=()=>{if(GA())z({silent:!0})},Vu=window.setInterval(()=>{fu()},ZW),Xu=()=>{if(GA())fu()};return document.addEventListener("visibilitychange",Xu),()=>{window.clearInterval(Vu),document.removeEventListener("visibilitychange",Xu)}},[r?.id,r?.runtime?.providerStatus,f]);let P=NS(r),k=wS(r),I=qS(r),b=n.snapshot||{},d=n.oaDiagnostics||null,s=n.minimaxQuota||null,{components:h,pipelines:lu,runs:cu}=WS(b),_u=String(cu[0]?.pipelineId||""),Fu=(_u?lu.find((fu)=>String(fu.id||"")===_u):null)||lu[0]||{},zu=lu.find((fu)=>String(fu.id||"")===t)||Fu,Wu=String(zu.id||""),C=rL(zu),e=n7(zu),uu=bW(cu,Wu),Gu=bS(cu,Wu),a=Gu.find((fu)=>String(fu?.runId||"")===c)||uu,qu=String(q.runId||"")===String(a?.runId||"")?GS(q.details):null,Zu=zS(a,qu),Bu=String(Zu?.runId||""),gu=C.find((fu)=>String(fu?.id||"")===A)||null,ll=A?nL(Zu,A):null,Pu=TS(cu),Nl=HS(h),Qf=Number(n.health?.components)||YW(b,"registry.components",h.length),Zf=YW(b,"runs",cu.length),$f=MW(zu,Zu,h),nf={nodes:$f.nodes.map((fu)=>fu.id===A?{...fu,selected:!0,className:`${fu.className||""} selected-control-node`}:fu),edges:$f.edges},tf=lu.map((fu)=>{let Vu=String(fu.id||"pipeline"),Xu=bW(cu,Vu);return{title:`${Vu}-${Xu?.runId||"snapshot"}`,flow:MW(fu,Xu,h)}}),Mf=String(L?.runId||Bu||""),$u=String(L?.interval?.nodeId||L?.marker?.nodeId||""),au=Mf&&$u?Q[h9(Mf,$u)]||null:null,Nf=VA(F.details,Mf,$u),Yu=VA(au?.details,Mf,$u)||Nf,Sl=Mf&&$u?{...pu(au)?au:{},runId:Mf,nodeId:$u,details:Yu,loading:Boolean(au?.loading)||!Yu&&Boolean(F.loading)&&A===$u,error:String(au?.error||""),fetchedAt:au?.fetchedAt||(Nf?F.fetchedAt:null)}:null,dl=Gu.map((fu)=>String(fu?.runId||"")).filter(Boolean).join("|"),rr=C.map((fu)=>String(fu?.id||"")).filter(Boolean).join("|");Ln(()=>{p.current=A},[A]),Ln(()=>{v.current=Bu},[Bu]),Ln(()=>{if(!c||dl.split("|").includes(c))return;$("")},[c,dl]),Ln(()=>{if(!A||rr.split("|").includes(A))return;j(""),J(on()),U(I0()),H(!1),m(!1)},[A,rr]),Ln(()=>{if(!A)H(!1)},[A]),Ln(()=>{if(!L.mode)m(!1)},[L.mode]);async function Af(fu=Bu,Vu={}){if(!fu){N(v9());return}let Xu=o0(Vu.scale??w??ac),ou=`${fu}:timeline`;if(O.current===ou)return;O.current=ou;let Al=Vu.silent===!0,kl=X.current+1;X.current=kl,N((_l)=>({runId:fu,scale:Xu,loading:!Al||String(_l.runId||"")!==fu||!_l.details,error:"",details:Al&&_l.runId===fu?_l.details:_l.runId===fu?_l.details:null,fetchedAt:_l.runId===fu?_l.fetchedAt:null}));try{let[_l,qf]=await Promise.all([k0(hc(f,`/api/node-control/runs/${encodeURIComponent(fu)}?tail=160&view=timeline`),{cache:"no-store",strictJson:!0}),k0(hc(f,`/api/runs/${encodeURIComponent(fu)}`),{cache:"no-store"}).catch((Sr)=>({ok:!1,runSummaryError:Ou(Sr,"抓取评分失败")}))]);if(kl!==X.current)return;N({runId:fu,scale:Xu,loading:!1,error:"",details:{..._l,run:pu(qf?.run)?qf.run:void 0,runSummaryError:qf?.runSummaryError},fetchedAt:new Date})}catch(_l){if(kl!==X.current)return;N((qf)=>({runId:fu,scale:Xu,loading:!1,error:Ou(_l,"抓取 epoch 执行过程失败"),details:qf.runId===fu?qf.details:null,fetchedAt:qf.runId===fu?qf.fetchedAt:null}))}finally{if(O.current===ou)O.current=""}}function Hf(fu,Vu,Xu){let ou=h9(fu,Vu);W((Al)=>{let kl={...Al,[ou]:{...pu(Al?.[ou])?Al[ou]:{},runId:fu,nodeId:Vu,...Xu}},_l=Object.keys(kl);if(_l.length>32)for(let qf of _l.slice(0,_l.length-32))delete kl[qf];return kl})}async function Gn(fu,Vu){if(!fu||!Vu)return;let Xu=h9(fu,Vu),ou=Number(Y.current?.[Xu]||0)+1;Y.current={...Y.current,[Xu]:ou},Hf(fu,Vu,{loading:!0,error:""});try{let Al=await k0(hc(f,`/api/node-control/runs/${encodeURIComponent(fu)}/nodes/${encodeURIComponent(Vu)}?tail=160`),{cache:"no-store",strictJson:!0});if(Number(Y.current?.[Xu]||0)!==ou)return;let kl=new Date;if(Hf(fu,Vu,{loading:!1,details:Al,fetchedAt:kl,error:""}),p.current===Vu&&v.current===fu)J((_l)=>({..._l,loading:!1,details:Al,fetchedAt:kl,error:""}))}catch(Al){if(Number(Y.current?.[Xu]||0)!==ou)return;Hf(fu,Vu,{loading:!1,error:Ou(Al,"抓取 Gantt node 详情失败")})}}Ln(()=>{if(!Bu){N(v9());return}Af(Bu);let fu=()=>{if(GA())Af(Bu,{silent:!0})},Vu=window.setInterval(()=>{fu()},ZW),Xu=()=>{if(GA())fu()};return document.addEventListener("visibilitychange",Xu),()=>{window.clearInterval(Vu),document.removeEventListener("visibilitychange",Xu)}},[Bu,f]);async function nr(fu=Bu,Vu=A){if(!fu||!Vu){J((Xu)=>({...Xu,error:"请先选择 run 和 node",message:""}));return}J((Xu)=>({...Xu,loading:!0,error:"",message:""}));try{let Xu=await k0(hc(f,`/api/node-control/runs/${encodeURIComponent(fu)}/nodes/${encodeURIComponent(Vu)}?tail=160`),{cache:"no-store",strictJson:!0}),ou=new Date;J((Al)=>({...Al,loading:!1,details:Xu,fetchedAt:ou,error:""})),Hf(fu,Vu,{loading:!1,details:Xu,fetchedAt:ou,error:""})}catch(Xu){J((ou)=>({...ou,loading:!1,error:Ou(Xu,"抓取 node 执行过程失败")}))}}async function u0(fu){let Vu=String(fu?.runId||Bu||""),Xu=String(fu?.nodeId||"");if(U({mode:"interval",runId:Vu,interval:fu,marker:null}),m(!0),!Vu||!Xu)return;if(Vu!==Bu)$(Vu);j(Xu),J(on()),Af(Vu,{silent:!0}),Gn(Vu,Xu)}async function $l(fu){let Vu=String(fu?.runId||Bu||""),Xu=String(fu?.nodeId||"");if(U({mode:"event",runId:Vu,interval:null,marker:fu}),m(!0),!Vu)return;if(Vu!==Bu)$(Vu);if(Af(Vu,{silent:!0}),!Xu)return;j(Xu),J(on()),Gn(Vu,Xu)}async function lt(fu){if(!Bu||!A){J((ou)=>({...ou,error:"请先选择 run 和 node",message:""}));return}let Vu=fu==="append"?"prompts":fu,Xu=fu==="append"?F.appendPrompt:fu==="guide"?F.guidePrompt:fu==="modify"?F.modifyPrompt:fu==="approve"?F.approveReason:F.redoReason;if(!String(Xu||"").trim()){J((ou)=>({...ou,error:"操作内容不能为空",message:""}));return}J((ou)=>({...ou,actionLoading:fu,error:"",message:""}));try{let ou=fu==="redo"||fu==="approve"?{reason:Xu,source:"unidesk-frontend",sourceKind:"webui"}:{prompt:Xu,source:"unidesk-frontend",sourceKind:"webui"},Al=await k0(hc(f,`/api/node-control/runs/${encodeURIComponent(Bu)}/nodes/${encodeURIComponent(A)}/${Vu}`),{method:"POST",body:JSON.stringify(ou)});if(J((_l)=>({..._l,actionLoading:"",details:Al,fetchedAt:new Date,appendPrompt:fu==="append"?"":_l.appendPrompt,guidePrompt:fu==="guide"?"":_l.guidePrompt,modifyPrompt:fu==="modify"?"":_l.modifyPrompt,approveReason:fu==="approve"?"":_l.approveReason,redoReason:fu==="redo"?"":_l.redoReason,message:fu==="append"?"已追加到运行中 node":fu==="guide"?"已下发 guide,等待 runner 处理":fu==="modify"?"已排队增量修改命令":fu==="approve"?"已提交审核通过决策":"已排队重做命令"})),B("success",fu==="append"?"已追加到运行中 node":fu==="guide"?"已下发 guide,等待 runner 处理":fu==="modify"?"已排队增量修改命令":fu==="approve"?"已提交审核通过决策":"已排队重做命令"),await nr(Bu,A),await Af(Bu,{silent:!0}),fu!=="append")await z()}catch(ou){J((Al)=>({...Al,actionLoading:"",error:Ou(ou,"node 控制操作失败")}))}}if(!r)return K(Nr,{title:"Pipeline 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=pipeline"});return K("div",{className:"pipeline-page","data-testid":"pipeline-page"},K(Wn,{title:"Pipeline v2 工作台",eyebrow:"D601 Snapshot 用户服务",loading:n.loading,actions:K("div",{className:"panel-actions"},K("button",{type:"button",className:"ghost-btn",onClick:z,disabled:n.loading,"data-testid":"pipeline-refresh-button"},n.loading?"刷新中":"刷新"),K(ln,{title:"Pipeline 用户服务",data:r,onOpen:l,testId:"raw-pipeline-service"}))},K("div",{className:"pipeline-hero"},K("div",null,K("div",{className:"node-version-line"},K(a0,{status:P.providerStatus==="online"?"online":"warn"},P.providerStatus||"unknown"),K("span",null,r.providerId),K("span",null,I.public?"公网暴露":"仅 UniDesk frontend 代理访问")),K("p",{className:"muted paragraph"},r.description)),K("div",{className:"microservice-ref-card"},K("span",null,"Repo"),K("strong",null,k.url||"--"),K("code",null,k.commitId||"--")),K("div",{className:"microservice-ref-card"},K("span",null,"D601 Docker"),K("strong",null,`${I.nodeBindHost||"--"}:${I.nodePort||"--"}`),K("code",null,`${k.composeFile||"--"} / ${k.composeService||"--"}`))),K(nl,{error:n.error,wide:!0})),K("div",{className:"pipeline-grid"},K(Wn,{title:"控制图",eyebrow:`${zu.id||"pipeline"} / run ${Zu?.status||"--"}`,className:"pipeline-wide-panel",loading:n.loading,actions:K("div",{className:"pipeline-toolbar"},K("select",{value:Wu,disabled:lu.length===0,onChange:(fu)=>{y(fu.target.value),$(""),j(""),J(on()),U(I0()),H(!1),m(!1)},"data-testid":"pipeline-select"},lu.map((fu)=>K("option",{key:fu.id,value:fu.id},fu.id||fu.key))),K("select",{value:Bu,disabled:Gu.length===0,onChange:(fu)=>{if($(fu.target.value),J(on()),U(I0()),H(!1),m(!1),A)nr(fu.target.value,A)},"data-testid":"pipeline-run-select"},Gu.map((fu)=>K("option",{key:fu.runId,value:fu.runId},o9(Gu,fu)))),K("button",{type:"button",className:"ghost-btn",disabled:nf.nodes.length===0,onClick:()=>yL(nf,`${zu.id||"pipeline"}-${Zu?.runId||"snapshot"}`),"data-testid":"pipeline-export-graph"},"导出渲染图"),K("button",{type:"button",className:"ghost-btn",disabled:tf.every((fu)=>fu.flow.nodes.length===0),onClick:()=>hS(tf),"data-testid":"pipeline-export-all-graphs"},"批量导出"))},C.length===0?K(Nr,{title:"暂无控制图",text:"等待 D601 pipeline backend 返回 config.nodes / config.edges"}):K("div",{className:`pipeline-control-shell ${Z?"detail-open":"detail-collapsed"}`,"data-testid":"pipeline-control-shell","data-sidebar-open":Z?"true":"false"},K("div",{className:"pipeline-flow-frame","data-testid":"pipeline-react-flow"},K(LW,{nodes:nf.nodes,edges:nf.edges,nodeTypes:rS,edgeTypes:fS,fitView:!0,fitViewOptions:{padding:0.18},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,minZoom:0.25,maxZoom:1.4,proOptions:{hideAttribution:!0},onNodeClick:(fu,Vu)=>{let Xu=String(Vu.id);if(j(Xu),J(on()),H(!0),Bu)nr(Bu,Xu)}},K(KW,{gap:22,size:1,color:"rgba(215, 161, 58, 0.24)"}),K(zW,{showInteractive:!1})),!Z?K("button",{type:"button",className:"pipeline-sidecar-tab right",disabled:!A,onClick:()=>H(!0),"data-testid":"pipeline-node-sidebar-toggle"},A?"展开 node 控制":"点击 node 展开控制"):null),Z?K(QX,{activeRun:Zu,pipelineRuns:Gu,selectedRunId:c,onRunChange:(fu)=>{if($(fu),J(on()),U(I0()),A)nr(fu,A)},selectedNodeId:A,selectedNodeConfig:gu,selectedNodeRuntime:ll,control:F,onControlChange:(fu)=>J((Vu)=>({...Vu,...fu})),onFetch:()=>nr(),onAction:lt,onRaw:l,onCollapse:()=>H(!1)}):null),K("div",{className:"pipeline-flow-summary"},K("span",null,`${nf.nodes.length} nodes`),K("span",null,`${nf.edges.length} edges`),K("span",null,`${lu.length} pipelines`),K("span",null,`source config+components(${h.length})`),K("span",null,`run ${Zu?.runId||"--"}`),K("span",null,`score ${a9(Zu)}`),K("span",null,A?`selected ${A}`:"click node to control"))),K(JX,{epochs:Gu,activeRun:Zu,activePipeline:zu,pipelineNodes:C,pipelineEdges:e,selection:L,detailOpen:E,onDetailOpenChange:m,runDetails:q,nodeDetails:Yu,nodeDetailsState:Sl,ganttScale:w,onGanttScaleChange:G,onIntervalSelect:u0,onMarkerSelect:$l,onRunChange:(fu)=>{if($(fu),J(on()),U(I0()),m(!1),A)nr(fu,A)},onRaw:l}),K(Wn,{title:"观测指标",eyebrow:n.refreshedAt?`Updated ${yl(n.refreshedAt)}`:"Snapshot",loading:n.loading},K("div",{className:"metric-grid"},K(Cf,{label:"Health",value:n.health?.ok?"OK":"--",hint:n.health?.service||"D601 /health",tone:n.health?.ok?"ok":"warn"}),K(Cf,{label:"组件",value:Qf,hint:"components registry",tone:b?.registry?.ok===!1?"warn":"ok"}),K(Cf,{label:"Pipeline",value:lu.length,hint:`${C.length} nodes / ${e.length} edges`}),K(Cf,{label:"运行记录",value:Zf,hint:`${Pu.succeeded||0} succeeded / ${Pu.running||0} running`}),K(Cf,{label:"OA 记录",value:Array.isArray(uu?.submissions)?uu.submissions.length:0,hint:uu?.runId||"latest run"}),K(Cf,{label:"Procedure",value:Array.isArray(uu?.procedureRuns)?uu.procedureRuns.length:0,hint:uu?.status||"no run"}),K(Cf,{label:"Score",value:a9(Zu),hint:Zu?.runId||"selected epoch",tone:t7(Zu)})),K("div",{className:"panel-actions inline-actions"},K(ln,{title:"Pipeline Snapshot",data:b,onOpen:l,testId:"raw-pipeline-snapshot"}))),K(Wn,{title:"评分器",eyebrow:Zu?.runId||"selected epoch",loading:n.loading},K(ZS,{run:Zu,onRaw:l})),K(Wn,{title:"MiniMax 限额",eyebrow:"model/minimax-m27 quota",loading:n.loading},K(UX,{quota:s,onRaw:l})),K(Wn,{title:"OA 事件流",eyebrow:"100% event-driven diagnostics",className:"pipeline-wide-panel",loading:n.loading},K(FX,{diagnostics:d,onRaw:l})),K(Wn,{title:"组件矩阵",eyebrow:`${Nl.length} classes`,loading:n.loading},Nl.length===0?K(Nr,{title:"暂无组件",text:"等待 D601 pipeline backend 返回 registry.components"}):K("div",{className:"component-strata"},Nl.map((fu)=>K("article",{key:fu.name,className:"component-stratum"},K("span",null,fu.name),K("strong",null,fu.count)))),K("div",{className:"pipeline-component-list"},h.slice(0,12).map((fu)=>K("span",{key:fu.key,className:"data-chip"},K("b",null,fu.componentClass||"--"),K("span",null,fu.id||fu.key||"--"))))),K(Wn,{title:"Epoch 列表",eyebrow:`${Gu.length}/${Zf} preview`,loading:n.loading},Gu.length===0?K(Nr,{title:"暂无运行记录",text:"当前 pipeline 在 .state/pipeline-runs 中还没有 epoch。"}):K("div",{className:"pipeline-run-list"},Gu.map((fu)=>{let Vu=String(fu?.runId||"")===Bu?Zu:fu;return K("article",{key:fu.runId,className:`pipeline-run-card ${String(fu.runId||"")===Bu?"active":""}`,role:"button",tabIndex:0,onClick:()=>{$(String(fu.runId||"")),U(I0())},onKeyDown:(Xu)=>{if(Xu.key==="Enter"||Xu.key===" ")$(String(fu.runId||"")),U(I0())}},K("div",{className:"node-card-head"},K("strong",null,o9(Gu,fu)),K(a0,{status:fu.status},fu.status||"--")),K("div",{className:"docker-meta compact"},K("span",null,Vu?.pipelineId||"--"),K("span",null,`nodes ${Array.isArray(Vu?.nodes)?Vu.nodes.length:0}`),K("span",null,`oa ${Array.isArray(Vu?.submissions)?Vu.submissions.length:0}`),K("span",null,`procedures ${Array.isArray(Vu?.procedureRuns)?Vu.procedureRuns.length:0}`),K(OS,{run:Vu})),K("p",{className:"muted paragraph"},BA(Vu?.task)),K("span",{className:"pipeline-run-time"},wu(Vu?.updatedAt)))}))),K(Wn,{title:"运行材料索引",eyebrow:Zu?.runId||"selected epoch",className:"pipeline-wide-panel",loading:n.loading},K(jX,{activeRun:Zu,onRaw:l}))))}var xA=Cu(Jl(),1);var yu=xA.default.createElement,{useEffect:NX}=xA.default,MA=xA.default.useState,$7={id:"",sequenceNo:"",contractNo:"",name:"",currentStatus:"",pending:"",paymentStatus:"",notes:""};function qX({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return yu("span",{className:`status-badge ${f}`},l||u||"unknown")}function RA({label:u,value:l,hint:f,tone:r}){return yu("article",{className:`metric-card ${r||""}`},yu("div",{className:"metric-label"},u),yu("div",{className:"metric-value"},l),yu("div",{className:"metric-hint"},f))}function A7({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return yu("section",{className:`panel ${n||""}`},yu("div",{className:"panel-head"},yu("div",null,l?yu("p",{className:"panel-eyebrow"},l):null,yu(rl,{title:u,loading:i})),f?yu("div",{className:"panel-actions"},f):null),yu("div",{className:"panel-body"},r))}function NL({title:u,data:l,onOpen:f,testId:r}){return yu("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function qL({title:u,text:l}){return yu("div",{className:"empty-state"},yu("strong",null,u),yu("span",null,l))}function wX(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function WX(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function LX(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function Zy(u,l){return`${u}/microservices/project-manager/proxy${l}`}function TX(u){return{id:String(u.id||""),sequenceNo:u.sequenceNo===null||u.sequenceNo===void 0?"":String(u.sequenceNo),contractNo:String(u.contractNo||""),name:String(u.name||""),currentStatus:String(u.currentStatus||""),pending:String(u.pending||""),paymentStatus:String(u.paymentStatus||""),notes:String(u.notes||"")}}function KX(u){return{sequenceNo:u.sequenceNo===""?null:Number(u.sequenceNo),contractNo:String(u.contractNo||"").trim(),name:String(u.name||"").trim(),currentStatus:String(u.currentStatus||"").trim(),pending:String(u.pending||"").trim(),paymentStatus:String(u.paymentStatus||"").trim(),paymentRatio:String(u.paymentStatus||"").trim(),notes:String(u.notes||"").trim()}}function j7(u){return String(u||"item").replace(/[^A-Za-z0-9_-]+/g,"-")}function GX(u){let l=new Uint8Array(u),f="",r=32768;for(let n=0;n<l.length;n+=r)f+=String.fromCharCode(...l.subarray(n,n+r));return btoa(f)}function zX({projects:u,activeId:l,onSelect:f,onRaw:r}){if(!u.length)return yu(qL,{title:"暂无项目",text:"可以从 Excel 导入,或用右侧表单新建项目。"});return yu("div",{className:"table-wrap project-manager-table","data-testid":"project-manager-table"},yu("table",null,yu("thead",null,yu("tr",null,yu("th",null,"序号"),yu("th",null,"合同号"),yu("th",null,"项目名称"),yu("th",null,"当前状况"),yu("th",null,"待完成"),yu("th",null,"付款"),yu("th",null,"其它"),yu("th",null,"操作"))),yu("tbody",null,u.map((n)=>yu("tr",{key:n.id,className:l===n.id?"active-row":"","data-testid":`project-manager-row-${j7(n.id)}`},yu("td",null,n.sequenceNo??"--"),yu("td",null,yu("strong",null,n.contractNo||"--"),yu("code",null,n.id||"--")),yu("td",null,yu("strong",null,n.name||"--"),yu("span",{className:"muted block"},n.sourceFile||"--")),yu("td",null,n.currentStatus||"--"),yu("td",null,yu("span",{className:"preline"},n.pending||"--")),yu("td",null,yu(qX,{status:Number(n.paymentRatio||0)>=1?"online":"warn"},n.paymentStatus||"--")),yu("td",null,n.notes||"--"),yu("td",null,yu("div",{className:"inline-actions"},yu("button",{type:"button",className:"ghost-btn",onClick:()=>f(n),"data-testid":`project-manager-edit-${j7(n.id)}`},"编辑"),yu(NL,{title:`Project ${n.contractNo||n.id}`,data:n,onOpen:r,testId:`raw-project-${j7(n.id)}`}))))))))}function wL({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((E)=>E.id==="project-manager")||null,[n,i]=MA({loading:!1,saving:!1,importing:!1,exporting:!1,error:"",notice:"",health:null,list:null,refreshedAt:null}),[t,y]=MA({...$7}),[c,$]=MA(""),[A,j]=MA("all"),{addNotification:F}=Xf();async function J(E=c,m=A){if(!r)return;i((S)=>({...S,loading:!0,error:""}));try{let S=new URLSearchParams({pageSize:"200",status:m});if(E.trim())S.set("q",E.trim());let[B,D]=await Promise.all([Eu(`${f}/microservices/project-manager/health`),Eu(Zy(f,`/api/projects?${S.toString()}`))]);i((X)=>({...X,loading:!1,health:B,list:D,refreshedAt:new Date,error:""}))}catch(S){i((B)=>({...B,loading:!1,error:Ou(S,"Project Manager 加载失败")}))}}NX(()=>{J()},[r?.id,r?.runtime?.providerStatus]);async function Q(E){E.preventDefault(),i((m)=>({...m,saving:!0,error:"",notice:""}));try{let m=KX(t);if(t.id)await Eu(Zy(f,`/api/projects/${encodeURIComponent(t.id)}`),{method:"PUT",body:JSON.stringify(m)});else await Eu(Zy(f,"/api/projects"),{method:"POST",body:JSON.stringify(m)});let S=t.id?"项目已更新":"项目已创建";i((B)=>({...B,saving:!1,notice:S})),F("success",S),await J()}catch(m){i((S)=>({...S,saving:!1,error:Ou(m,"保存项目失败")}))}}async function W(){if(!t.id)return;if(!window.confirm(`删除项目 ${t.contractNo||t.name||t.id} ?`))return;i((E)=>({...E,saving:!0,error:"",notice:""}));try{await Eu(Zy(f,`/api/projects/${encodeURIComponent(t.id)}`),{method:"DELETE"}),y({...$7});let E="项目已删除";i((m)=>({...m,saving:!1,notice:E})),F("success",E),await J()}catch(E){i((m)=>({...m,saving:!1,error:Ou(E,"删除项目失败")}))}}async function L(E){let m=E.target.files?.[0];if(!m)return;i((S)=>({...S,importing:!0,error:"",notice:""}));try{let S=GX(await m.arrayBuffer()),D=`Excel 已导入 ${(await Eu(Zy(f,"/api/import/excel"),{method:"POST",body:JSON.stringify({fileName:m.name,contentBase64:S,replace:!1})})).imported||0} 条项目`;i((X)=>({...X,importing:!1,notice:D})),F("success",D),E.target.value="",await J()}catch(S){i((B)=>({...B,importing:!1,error:Ou(S,"Excel 导入失败")}))}}async function U(){i((E)=>({...E,exporting:!0,error:""}));try{let E=await mJ(Zy(f,"/api/projects/export.xlsx")),m=URL.createObjectURL(E),S=document.createElement("a");S.href=m,S.download=`project-manager-${$j()}.xlsx`,document.body.appendChild(S),S.click(),S.remove(),URL.revokeObjectURL(m),i((B)=>({...B,exporting:!1,notice:"Excel 已导出"}))}catch(E){i((m)=>({...m,exporting:!1,error:Ou(E,"Excel 导出失败")}))}}if(!r)return yu(qL,{title:"Project Manager 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=project-manager"});let q=wX(r),N=LX(r),w=WX(r),G=Array.isArray(n.list?.projects)?n.list.projects:[],Z=n.list?.summary||{},H=n.health||{};return yu("div",{className:"project-manager-page","data-testid":"project-manager-page"},yu(A7,{title:"项目管理工作台",eyebrow:"Main Server PostgreSQL 用户服务",loading:n.loading||n.exporting,actions:yu("div",{className:"panel-actions"},yu("button",{type:"button",className:"ghost-btn",disabled:n.loading,onClick:()=>J(),"data-testid":"project-manager-refresh-button"},n.loading?"刷新中":"刷新"),yu("button",{type:"button",className:"ghost-btn",disabled:n.exporting,onClick:U,"data-testid":"project-manager-export-button"},n.exporting?"导出中":"导出 Excel"),yu(NL,{title:"Project Manager 用户服务",data:r,onOpen:l,testId:"raw-project-manager-service"}))},yu("div",{className:"project-manager-hero"},yu(RA,{label:"项目总数",value:Z.total??G.length,hint:`PG 表 ${H.storage?.table||"project_manager_projects"}`,tone:"ok"}),yu(RA,{label:"进行中",value:Z.active??"--",hint:"当前状态未完全完成"}),yu(RA,{label:"已完成",value:Z.completed??"--",hint:"按 完成 关键字统计",tone:"ok"}),yu(RA,{label:"未全款",value:Z.unpaid??"--",hint:"付款比例 < 1",tone:Number(Z.unpaid||0)>0?"warn":"ok"})),yu(nl,{error:n.error}),n.notice?yu("div",{className:"form-success"},n.notice):null),yu("div",{className:"project-manager-hero"},yu("div",{className:"microservice-ref-card"},yu("span",null,"Repo"),yu("strong",null,N.url||"--"),yu("code",null,N.commitId||"--")),yu("div",{className:"microservice-ref-card"},yu("span",null,"Main Server Docker"),yu("strong",null,`${w.nodeBindHost||"--"}:${w.nodePort||"--"}`),yu("code",null,`${N.composeService||"--"} / ${N.containerName||"--"}`)),yu("div",{className:"microservice-ref-card"},yu("span",null,"Runtime"),yu("strong",null,q.providerName||r.providerId),yu("code",null,`Health ${H.ok?"OK":"--"} / ${n.refreshedAt?yl(n.refreshedAt):"--"}`)),yu("div",{className:"microservice-ref-card"},yu("span",null,"Import Source"),yu("strong",null,"D601 WeChat Excel"),yu("code",null,"合作项目列表_I_20260309.xlsx"))),yu("div",{className:"project-manager-layout"},yu(A7,{title:"项目清单",eyebrow:"CRUD + Excel Export",loading:n.loading||n.importing||n.exporting,actions:yu("div",{className:"inline-actions project-manager-filters"},yu("input",{value:c,onChange:(E)=>$(E.target.value),placeholder:"搜索合同号 / 项目名称 / 状态","data-testid":"project-manager-search"}),yu("select",{value:A,onChange:(E)=>{j(E.target.value),J(c,E.target.value)},"data-testid":"project-manager-status-filter"},yu("option",{value:"all"},"全部"),yu("option",{value:"active"},"进行中"),yu("option",{value:"completed"},"已完成"),yu("option",{value:"unpaid"},"未全款")),yu("button",{type:"button",className:"ghost-btn",onClick:()=>J(c,A)},"筛选"))},yu(zX,{projects:G,activeId:t.id,onSelect:(E)=>y(TX(E)),onRaw:l})),yu(A7,{title:t.id?"编辑项目":"新建项目",eyebrow:"PostgreSQL Write Path",loading:n.saving||n.importing},yu("form",{className:"stack-form project-manager-form",onSubmit:Q,"data-testid":"project-manager-form"},t.id?yu("label",null,"项目 ID",yu("input",{value:t.id,disabled:!0})):null,yu("label",null,"序号",yu("input",{type:"number",value:t.sequenceNo,onChange:(E)=>y((m)=>({...m,sequenceNo:E.target.value}))})),yu("label",null,"合同号",yu("input",{value:t.contractNo,onChange:(E)=>y((m)=>({...m,contractNo:E.target.value})),required:!0})),yu("label",null,"项目名称",yu("input",{value:t.name,onChange:(E)=>y((m)=>({...m,name:E.target.value})),required:!0})),yu("label",null,"当前状况",yu("textarea",{value:t.currentStatus,onChange:(E)=>y((m)=>({...m,currentStatus:E.target.value}))})),yu("label",null,"待完成",yu("textarea",{value:t.pending,onChange:(E)=>y((m)=>({...m,pending:E.target.value}))})),yu("label",null,"付款情况",yu("input",{value:t.paymentStatus,onChange:(E)=>y((m)=>({...m,paymentStatus:E.target.value})),placeholder:"例如 1 / 0.5 / 50%"})),yu("label",null,"其它",yu("input",{value:t.notes,onChange:(E)=>y((m)=>({...m,notes:E.target.value}))})),yu("div",{className:"inline-actions"},yu("button",{type:"submit",className:"primary-btn",disabled:n.saving,"data-testid":"project-manager-save-button"},n.saving?"保存中":t.id?"保存修改":"创建项目"),yu("button",{type:"button",className:"ghost-btn",onClick:()=>y({...$7})},"清空"),t.id?yu("button",{type:"button",className:"danger-btn",disabled:n.saving,onClick:W,"data-testid":"project-manager-delete-button"},"删除"):null)),yu("div",{className:"project-manager-import"},yu("p",{className:"muted paragraph"},"浏览器只访问 UniDesk frontend;后端通过同源用户服务代理写入主 PostgreSQL,不暴露 4233 公网端口。"),yu("label",{className:"file-import"},n.importing?"导入中...":"导入 Excel",yu("input",{type:"file",accept:".xlsx",onChange:L,disabled:n.importing,"data-testid":"project-manager-import-input"}))))))}var vA=Cu(Jl(),1);var Au=vA.default.createElement,{useEffect:EX}=vA.default,lr=vA.default.useState;function OX({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return Au("span",{className:`status-badge ${f}`},l||u||"unknown")}function hA({label:u,value:l,hint:f,tone:r}){return Au("article",{className:`metric-card ${r||""}`},Au("div",{className:"metric-label"},u),Au("div",{className:"metric-value"},l),Au("div",{className:"metric-hint"},f))}function F7({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return Au("section",{className:`panel ${n||""}`},Au("div",{className:"panel-head"},Au("div",null,l?Au("p",{className:"panel-eyebrow"},l):null,Au(rl,{title:u,loading:i})),f?Au("div",{className:"panel-actions"},f):null),Au("div",{className:"panel-body"},r))}function WL({title:u,data:l,onOpen:f,testId:r}){return Au("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f(u,l)},"查看原始JSON")}function bA({title:u,text:l}){return Au("div",{className:"empty-state"},Au("strong",null,u),Au("span",null,l))}function ZX(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function HX(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function BX(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function TL(u){return String(u).replace(/[^a-zA-Z0-9_-]/g,"_")}function VX(u){if(!Number.isFinite(u))return"--";return`${u.toFixed(1)}%`}function Hy(u,l){return`${u}/microservices/todo-note/proxy${l}`}function KL(u){return u.reduce((l,f)=>{let r=KL(Array.isArray(f.children)?f.children:[]),n=Boolean(f.completed);return{total:l.total+1+r.total,completed:l.completed+(n?1:0)+r.completed,active:l.active+(n?0:1)+r.active}},{total:0,completed:0,active:0})}function J7(u,l){let f=l==="all"||(l==="completed"?Boolean(u.completed):!u.completed),r=Array.isArray(u.children)?u.children:[];return f||r.some((n)=>J7(n,l))}function LL(u){return Array.isArray(u?.instances)?u.instances:[]}function U7(u,l){for(let f of u){if(f?.id===l)return Array.isArray(f.children)?f.children:[];let r=U7(Array.isArray(f?.children)?f.children:[],l);if(r.length>0)return r}return[]}function GL({microservices:u,onRaw:l,apiBaseUrl:f="/api"}){let r=u.find((a)=>a.id==="todo-note")||null,[n,i]=lr(null),[t,y]=lr(null),[c,$]=lr(""),[A,j]=lr(null),[F,J]=lr("all"),[Q,W]=lr(13),[L,U]=lr(""),[q,N]=lr(""),[w,G]=lr(""),[Z,H]=lr(""),[E,m]=lr(""),[S,B]=lr(!1),[D,X]=lr(""),[O,Y]=lr(null),p=LL(t),v=KL(Array.isArray(A?.todos)?A.todos:[]),z=r?ZX(r):{},P=r?BX(r):{},k=r?HX(r):{};async function I(a=c){let[qu,Zu]=await Promise.all([Eu(`${f}/microservices/todo-note/health`),Eu(Hy(f,"/api/instances"))]);i(qu),y(Zu);let Bu=LL(Zu),gu=Bu.some((ll)=>ll.id===a)?a:Bu[0]?.id||"";return $(gu),gu}async function b(a=c){if(!a){j(null);return}let qu=await Eu(Hy(f,`/api/instances/${encodeURIComponent(a)}`));j(qu)}async function d(a=c){if(!r)return;B(!0),X("");try{let qu=await I(a);await b(qu),Y(new Date)}catch(qu){X(Ou(qu,"Todo Note 加载失败"))}finally{B(!1)}}async function s(a){if(!c)return null;X("");try{let qu=await Eu(Hy(f,`/api/instances/${encodeURIComponent(c)}/actions`),{method:"POST",body:JSON.stringify({action:a})});return j(qu),await I(c),qu}catch(qu){return X(Ou(qu,"Todo 操作失败")),null}}async function h(a){a.preventDefault();let qu=L.trim();if(!qu)return;B(!0),X("");try{let Zu=await Eu(Hy(f,"/api/instances"),{method:"POST",body:JSON.stringify({name:qu})});U(""),await d(Zu.id)}catch(Zu){X(Ou(Zu,"创建清单失败"))}finally{B(!1)}}async function lu(a){if(!window.confirm("确认删除这个 Todo Note 清单?"))return;B(!0),X("");try{await Eu(Hy(f,`/api/instances/${encodeURIComponent(a)}`),{method:"DELETE"}),await d(c===a?"":c)}catch(qu){X(Ou(qu,"删除清单失败"))}finally{B(!1)}}async function cu(a){a.preventDefault();let qu=q.trim();if(!qu)return;N(""),await s({type:"addTodo",title:qu})}async function _u(a){if(!c)return;X("");try{let qu=await Eu(Hy(f,`/api/instances/${encodeURIComponent(c)}/${a}`),{method:"POST",body:JSON.stringify({})});j(qu),await I(c)}catch(qu){X(Ou(qu,`${a} 失败`))}}function Fu(a){G(a.id),H(String(a.title||""))}async function zu(a){let qu=Z.trim();if(G(""),H(""),qu)await s({type:"updateTodoTitle",todoId:a,title:qu})}async function Wu(a){let Zu=window.prompt("新增子任务标题")?.trim();if(!Zu)return;let Bu=U7(Array.isArray(A?.todos)?A.todos:[],a),gu=new Set(Bu.map((Qf)=>Qf.id)),ll=await s({type:"addTodo",title:Zu,parentId:a,targetIndex:0});if(!ll)return;let Pu=U7(Array.isArray(ll?.todos)?ll.todos:[],a),Nl=Pu.find((Qf)=>!gu.has(Qf.id));if(Nl&&Pu[0]?.id!==Nl.id)await s({type:"moveTodo",todoId:Nl.id,targetParentId:a,targetIndex:0})}async function C(a,qu){if(!E)return;let Zu={type:"moveTodo",todoId:E,targetIndex:qu};if(a)Zu.targetParentId=a;m(""),await s(Zu)}if(EX(()=>{d()},[r?.id,r?.runtime?.providerStatus]),!r)return Au(bA,{title:"Todo Note 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=todo-note"});let e=p.find((a)=>a.id===c)||null,uu=Array.isArray(A?.todos)?A.todos:[],Gu=uu.map((a,qu)=>({todo:a,index:qu})).filter((a)=>J7(a.todo,F));return Au("div",{className:"todo-note-page","data-testid":"todo-note-page"},Au(F7,{title:"Todo Note 工作台",eyebrow:"Main Server 用户服务",loading:S,actions:Au("div",{className:"panel-actions"},Au("button",{type:"button",className:"ghost-btn",disabled:S,onClick:()=>d(c),"data-testid":"todo-note-refresh-button"},S?"刷新中":"刷新"),Au(WL,{title:"Todo Note 用户服务",data:r,onOpen:l,testId:"raw-todo-note-service"}))},Au("div",{className:"todo-note-hero"},Au("div",null,Au("div",{className:"node-version-line"},Au(OX,{status:z.providerStatus==="online"?"online":"warn"},z.providerStatus||"unknown"),Au("span",null,r.providerId),Au("span",null,k.public?"公网暴露":"仅 UniDesk frontend 代理访问"),Au("span",null,n?.ok?"Health OK":"Health --")),Au("p",{className:"muted paragraph"},r.description)),Au("div",{className:"microservice-ref-card"},Au("span",null,"Repo"),Au("strong",null,P.url||"--"),Au("code",null,P.commitId||"--")),Au("div",{className:"microservice-ref-card"},Au("span",null,"Main Server Docker"),Au("strong",null,`${k.nodeBindHost||"--"}:${k.nodePort||"--"}`),Au("code",null,`${P.composeService||"--"} / ${P.containerName||"--"}`))),Au(nl,{error:D,wide:!0})),Au("div",{className:"todo-note-layout"},Au(F7,{title:"清单",eyebrow:`${p.length} Instances`,className:"todo-list-panel",loading:S},Au("form",{className:"todo-create-list",onSubmit:h},Au("input",{placeholder:"新清单名称",value:L,onChange:(a)=>U(a.target.value),"aria-label":"新清单名称"}),Au("button",{type:"submit",className:"ghost-btn",disabled:S||!L.trim()},"创建")),p.length===0?Au(bA,{title:"暂无清单",text:"迁移或创建清单后会出现在这里"}):Au("div",{className:"todo-instance-list"},p.map((a)=>Au("button",{key:a.id,type:"button",className:`todo-instance-row ${c===a.id?"active":""}`,onClick:()=>{$(a.id),b(a.id)},"data-testid":`todo-instance-${TL(a.id)}`},Au("strong",null,a.name),Au("span",null,`${a.completedCount??0}/${a.todoCount??0} 完成`),Au("code",null,a.id))))),Au("div",{className:"todo-main-stack"},Au(F7,{title:e?.name||"待选择清单",eyebrow:O?`Updated ${yl(O)}`:"Todo Tree",loading:S,actions:A?Au("div",{className:"panel-actions"},Au("button",{type:"button",className:"ghost-btn",onClick:()=>s({type:"renameInstance",name:window.prompt("清单新名称",A.name)||A.name})},"重命名"),Au("button",{type:"button",className:"ghost-btn danger",onClick:()=>lu(c)},"删除清单"),Au(WL,{title:`Todo Instance ${c}`,data:A,onOpen:l,testId:"raw-todo-instance"})):null},!A?Au(bA,{title:"未选择清单",text:"左侧选择一个 Todo Note 清单"}):Au("div",{className:"todo-workbench",style:{"--todo-font-size":`${Q}px`}},Au("div",{className:"todo-toolbar"},Au("form",{className:"todo-add-form",onSubmit:cu},Au("input",{placeholder:"新增根任务",value:q,onChange:(a)=>N(a.target.value),"aria-label":"新增根任务"}),Au("button",{type:"submit",className:"ghost-btn",disabled:!q.trim()},"新增")),Au("div",{className:"todo-filter-strip"},["all","active","completed"].map((a)=>Au("button",{key:a,type:"button",className:`todo-filter ${F===a?"active":""}`,onClick:()=>J(a)},a==="all"?"全部":a==="active"?"未完成":"已完成"))),Au("div",{className:"todo-toolbar-actions"},Au("button",{type:"button",className:"ghost-btn",onClick:()=>s({type:"setAllTodosExpanded",expanded:!0})},"全部展开"),Au("button",{type:"button",className:"ghost-btn",onClick:()=>s({type:"setAllTodosExpanded",expanded:!1})},"全部收起"),Au("button",{type:"button",className:"ghost-btn",onClick:()=>_u("undo")},"撤销"),Au("button",{type:"button",className:"ghost-btn",onClick:()=>_u("redo")},"重做"),Au("label",{className:"todo-font-control"},"字号",Au("input",{type:"range",min:11,max:18,value:Q,onChange:(a)=>W(Number(a.target.value))})))),Au("div",{className:"todo-stats-grid"},Au(hA,{label:"总任务",value:v.total,hint:`${p.length} lists`}),Au(hA,{label:"已完成",value:v.completed,hint:`${VX(v.total?v.completed/v.total*100:0)}`,tone:"ok"}),Au(hA,{label:"未完成",value:v.active,hint:F==="active"?"当前筛选":"active tasks",tone:v.active>0?"warn":"ok"}),Au(hA,{label:"历史指针",value:A.historyPointer??0,hint:"undo / redo"})),Au("div",{className:"todo-root-drop",onDragOver:(a)=>a.preventDefault(),onDrop:(a)=>{a.preventDefault(),C(null,uu.length)}},"拖到这里可移为根任务末尾"),Au("div",{className:"todo-tree","data-testid":"todo-note-tree"},Gu.length===0?Au(bA,{title:"没有匹配任务",text:"调整筛选或新增任务"}):Gu.map(({todo:a,index:qu})=>Au(zL,{key:a.id,todo:a,depth:0,parentId:null,index:qu,siblingCount:uu.length,filter:F,editingId:w,editingTitle:Z,setEditingTitle:H,beginEdit:Fu,saveEdit:zu,applyTodoAction:s,addChild:Wu,dragTodoId:E,setDragTodoId:m,dropTodo:C}))))))))}function zL(u){let{todo:l,depth:f,parentId:r,index:n,siblingCount:i,filter:t,editingId:y,editingTitle:c,setEditingTitle:$,beginEdit:A,saveEdit:j,applyTodoAction:F,addChild:J,dragTodoId:Q,setDragTodoId:W,dropTodo:L}=u,U=Array.isArray(l.children)?l.children:[],q=U.map((G,Z)=>({child:G,childIndex:Z})).filter((G)=>J7(G.child,t)),N=y===l.id,w=r||null;return Au("div",{className:"todo-row-wrap"},Au("article",{className:`todo-row ${l.completed?"completed":""} ${Q===l.id?"dragging":""}`,style:{"--todo-depth":f},draggable:!0,onDragStart:(G)=>{W(l.id),G.dataTransfer.effectAllowed="move"},onDragOver:(G)=>G.preventDefault(),onDrop:(G)=>{G.preventDefault(),L(l.id,U.length)},"data-testid":`todo-row-${TL(l.id)}`},Au("button",{type:"button",className:"todo-expand",disabled:U.length===0,onClick:()=>F({type:"toggleTodoExpanded",todoId:l.id})},U.length===0?"·":l.expanded?"▾":"▸"),Au("input",{type:"checkbox",checked:Boolean(l.completed),onChange:()=>F({type:"toggleTodoCompleted",todoId:l.id}),"aria-label":`完成 ${l.title}`}),Au("div",{className:"todo-title-cell",onDoubleClick:()=>A(l)},N?Au("div",{className:"todo-edit-inline"},Au("input",{value:c,autoFocus:!0,onChange:(G)=>$(G.target.value),onKeyDown:(G)=>{if(G.key==="Enter")j(l.id);if(G.key==="Escape")A({id:"",title:""})}}),Au("button",{type:"button",className:"ghost-btn",onClick:()=>j(l.id)},"保存")):Au("strong",null,l.title||"Untitled"),Au("div",{className:"todo-meta-line"},Au("span",null,`子项 ${U.length}`),Au("span",null,`更新 ${wu(l.updatedAt)}`),l.reminderAt?Au("span",{className:"todo-reminder"},`提醒 ${wu(l.reminderAt)}`):Au("span",null,"无提醒"))),Au("input",{className:"todo-reminder-input",type:"datetime-local",value:w6(l.reminderAt),onChange:(G)=>F({type:"setTodoReminder",todoId:l.id,reminderAt:Aj(G.target.value)})}),Au("div",{className:"todo-row-actions"},Au("button",{type:"button",className:"ghost-btn",onClick:()=>A(l)},"编辑"),Au("button",{type:"button",className:"ghost-btn",onClick:()=>J(l.id)},"子项"),Au("button",{type:"button",className:"ghost-btn",disabled:n<=0,onClick:()=>F({type:"moveTodo",todoId:l.id,...w?{targetParentId:w}:{},targetIndex:n-1})},"上移"),Au("button",{type:"button",className:"ghost-btn",disabled:n<=0,onClick:()=>F({type:"moveTodo",todoId:l.id,...w?{targetParentId:w}:{},targetIndex:0})},"置顶"),Au("button",{type:"button",className:"ghost-btn",disabled:n>=i-1,onClick:()=>F({type:"moveTodo",todoId:l.id,...w?{targetParentId:w}:{},targetIndex:n+1})},"下移"),Au("button",{type:"button",className:"ghost-btn",disabled:!r,onClick:()=>F({type:"moveTodo",todoId:l.id,targetIndex:9999})},"提升"),Au("button",{type:"button",className:"ghost-btn danger",onClick:()=>F({type:"deleteTodo",todoId:l.id})},"删除"))),l.expanded&&q.length>0?Au("div",{className:"todo-children"},q.map(({child:G,childIndex:Z})=>Au(zL,{key:G.id,todo:G,depth:f+1,parentId:l.id,index:Z,siblingCount:U.length,filter:t,editingId:y,editingTitle:c,setEditingTitle:$,beginEdit:A,saveEdit:j,applyTodoAction:F,addChild:J,dragTodoId:Q,setDragTodoId:W,dropTodo:L}))):null)}var EL=Cu(Jl(),1),d0=EL.default.createElement;function OL({title:u,items:l,actions:f,className:r,testId:n}){let i=Array.isArray(l)?l:[];return d0("section",{className:`top-status-bar ${r||""}`,"data-testid":n},d0("div",{className:"top-status-main"},u?d0("strong",{className:"top-status-title"},u):null,d0("div",{className:"top-status-chips"},i.map((t,y)=>d0("span",{key:t?.key||`${t?.label||"status"}-${y}`,className:`top-status-chip ${t?.tone||""}`,"data-testid":t?.testId},t?.label?d0("b",null,t.label):null,d0("span",null,t?.value??"--"))))),f?d0("div",{className:"top-status-actions"},f):null)}var dc=Cu(Jl(),1);var Nu=dc.default.createElement,{useEffect:mX,useMemo:DX}=dc.default,pX=dc.default.useState;function ZL({status:u,children:l,title:f}){let r=String(u||"unknown").toLowerCase();return Nu("span",{className:`status-badge ${r}`,title:f},l||u||"unknown")}function kA({label:u,value:l,hint:f,tone:r}){return Nu("article",{className:`metric-card ${r||""}`},Nu("div",{className:"metric-label"},u),Nu("div",{className:"metric-value"},l),Nu("div",{className:"metric-hint"},f))}function Q7({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){return Nu("section",{className:`panel ${n||""}`},Nu("div",{className:"panel-head"},Nu("div",null,l?Nu("p",{className:"panel-eyebrow"},l):null,Nu(rl,{title:u,loading:i})),f?Nu("div",{className:"panel-actions"},f):null),Nu("div",{className:"panel-body"},r))}function HL({title:u,data:l,onOpen:f,testId:r}){return Nu("button",{type:"button",className:"ghost-btn","data-testid":r,onClick:()=>f?.(u,l)},"查看原始JSON")}function N7({title:u,text:l}){return Nu("div",{className:"empty-state"},Nu("strong",null,u),Nu("span",null,l))}function By(u){return Array.isArray(u)?u:[]}function q7(u){return u&&typeof u==="object"&&!Array.isArray(u)?u:{}}function SX(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function XX(u,l){return`${u}/microservices/k3sctl-adapter/proxy${l}`}function YX(u){return u.find((l)=>String(l?.id||"")==="k3sctl-adapter")||null}function PX(u){if(u?.healthy===!0)return"online";if(String(u?.role||"")==="standby")return"warn";return"failed"}function CX(u){return u?.healthy===!0?"online":"failed"}function MX(u){if(u===!0)return"YES";if(u===!1)return"NO";return"--"}function RX(u){return Array.from(new Set(u.flatMap((l)=>By(l?.expectedNodeIds).map((f)=>String(f))))).filter(Boolean).sort()}function xX(u){let l=u.find((f)=>f?.id==="code-queue")||u[0];return String(l?.activeInstanceId||"--")}function hX(u){return Nu("article",{key:u?.id||u?.nodeId,className:"k3s-instance-card"},Nu("div",{className:"node-card-head"},Nu("strong",null,u?.nodeId||u?.id||"--"),Nu(ZL,{status:PX(u)},u?.healthy?"HEALTHY":"DEGRADED")),Nu("div",{className:"k3s-instance-role"},Nu("span",null,String(u?.role||"worker").toUpperCase()),Nu("code",null,u?.id||"--")),Nu("dl",{className:"k3s-kv"},Nu("dt",null,"Base URL"),Nu("dd",null,Nu("code",null,u?.baseUrl||"--")),Nu("dt",null,"Proxy"),Nu("dd",null,u?.proxyMode||"--"),Nu("dt",null,"Health"),Nu("dd",null,`${u?.upstreamStatus??"--"} / ${u?.status||"unknown"}`),Nu("dt",null,"Checked"),Nu("dd",null,wu(u?.checkedAt))))}function bX(u,l){let f=By(u?.instances),r=q7(u?.active);return Nu(Q7,{key:u?.id||"service",title:u?.id||"managed-service",eyebrow:`${u?.namespace||"unidesk"} / k3s managed service`,className:"k3s-service-panel",actions:Nu(HL,{title:`k3s service ${u?.id||""}`,data:u,onOpen:l,testId:`raw-k3s-service-${u?.id||"unknown"}`})},Nu("div",{className:"k3s-service-summary"},Nu("div",null,Nu("span",null,"状态"),Nu(ZL,{status:CX(u)},u?.status||"unknown")),Nu("div",null,Nu("span",null,"Active"),Nu("strong",null,u?.activeInstanceId||"--")),Nu("div",null,Nu("span",null,"Single Writer"),Nu("strong",null,MX(u?.singleWriter))),Nu("div",null,Nu("span",null,"Active Health"),Nu("strong",null,r?.upstreamStatus??"--"))),f.length===0?Nu(N7,{title:"暂无 k3s 实例",text:"adapter 没有返回该服务的 endpoint 列表"}):Nu("div",{className:"k3s-instance-grid"},f.map(hX)))}function BL({microservices:u,onRaw:l,apiBaseUrl:f,onNavigate:r}){let n=YX(Array.isArray(u)?u:[]),i=SX(n),[t,y]=pX({loading:!1,error:"",data:null,refreshedAt:null});async function c(){y((q)=>({...q,loading:!0,error:""}));try{let q=await Eu(XX(f,"/api/control-plane"));y({loading:!1,error:"",data:q,refreshedAt:new Date})}catch(q){y((N)=>({...N,loading:!1,error:Ou(q,"加载 k3s 控制平面失败")}))}}mX(()=>{c()},[f]);let $=DX(()=>By(t.data?.services),[t.data]),A=RX($),j=$.filter((q)=>q?.healthy===!0).length,F=$.reduce((q,N)=>q+By(N?.instances).length,0),J=$.reduce((q,N)=>q+By(N?.instances).filter((w)=>w?.healthy===!0).length,0),Q=xX($),W=q7(t.data?.kubectl),L=q7(t.data?.kubeApiProxy),U=By(t.data?.manifestPaths).map((q)=>String(q));if(!n)return Nu(N7,{title:"k3sctl-adapter 未登记",text:"请在 config.json 的 microservices 中登记 id=k3sctl-adapter,并通过该微服务连接 k3s 控制平面。"});return Nu("div",{className:"k3s-page","data-testid":"k3sctl-page"},Nu(Q7,{title:"k3s Control Plane",eyebrow:"Managed by k3sctl-adapter",className:"k3s-hero-panel",loading:t.loading,actions:Nu(dc.default.Fragment,null,Nu("button",{type:"button",className:"ghost-btn",onClick:c,disabled:t.loading,"data-testid":"k3s-refresh-button"},t.loading?"刷新中":"刷新"),r?Nu("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","code-queue"),"data-testid":"k3s-open-code-queue"},"打开 Code Queue"):null,Nu(HL,{title:"k3sctl-adapter microservice",data:n,onOpen:l,testId:"raw-k3s-adapter"}))},Nu("div",{className:"k3s-hero"},Nu("div",{className:"k3s-orb","aria-hidden":"true"},Nu("span",null,"k3s")),Nu("div",{className:"k3s-hero-copy"},Nu("p",{className:"eyebrow"},"D601 control plane / D518 managed node"),Nu("h2",null,"UniDesk 只管理 adapter;业务微服务交给 k3s 标准服务路由"),Nu("p",{className:"muted paragraph"},"Code Queue 的前端/API 请求进入 k3sctl-adapter,再由 adapter 转发到 k3s active service。provider-gateway 只用于维护 adapter 和节点诊断,不再直接管理 Code Queue 容器。"),Nu("div",{className:"k3s-route-strip"},Nu("span",null,"NO FALLBACK"),Nu("code",null,t.data?.runtimePath||"frontend -> backend-core -> k3sctl-adapter")))),Nu("div",{className:"metric-grid"},Nu(kA,{label:"控制面",value:t.data?.clusterId||"D601",hint:`adapter ${i.providerStatus||"unknown"}`,tone:i.providerStatus==="online"?"ok":"warn"}),Nu(kA,{label:"代管服务",value:$.length,hint:`${j}/${$.length||0} healthy`,tone:j===$.length&&$.length>0?"ok":"warn"}),Nu(kA,{label:"节点",value:A.join(" / ")||"--",hint:"expected k3s nodes"}),Nu(kA,{label:"实例",value:`${J}/${F}`,hint:`active ${Q}`,tone:J===F&&F>0?"ok":"warn"})),Nu("div",{className:"k3s-control-plane-grid"},Nu("article",{className:"k3s-control-plane-card"},Nu("span",null,"service proxy"),Nu("strong",null,L.configured===!0?"K8S API PROXY":"PROXY DEGRADED"),Nu("p",null,L.configured===!0?`${L.mode||"kubernetes-api-service-proxy"} via ${L.connectHost||"--"}`:"adapter 必须通过 k8s API service proxy 访问业务服务,不回退到业务容器直连。")),Nu("article",{className:"k3s-control-plane-card"},Nu("span",null,"manifests"),Nu("strong",null,U.length||"--"),Nu("p",null,U.join(" / ")||"未配置 manifest")),Nu("article",{className:"k3s-control-plane-card"},Nu("span",null,"cluster snapshot"),Nu("strong",null,W.enabled===!0?W.ok===!0?"KUBECTL OK":"KUBECTL DEGRADED":"API ONLY"),Nu("p",null,W.enabled===!0?`nodes ${W.nodeCount??"--"}`:"控制面页面以 adapter 返回的 k8s service proxy 状态为准;kubectl 只作为可选快照。"))),t.error?Nu(nl,{error:t.error}):null,t.refreshedAt?Nu("p",{className:"muted paragraph"},`最近刷新 ${yl(t.refreshedAt)}`):null),$.length===0?Nu(Q7,{title:"代管服务",eyebrow:"k3s services",loading:t.loading},Nu(N7,{title:"暂无 k3s 服务",text:"等待 k3sctl-adapter 返回 /api/services;Code Queue 切换后这里应显示 D601 和 D518 两个实例。"})):$.map((q)=>bX(q,l)))}var ec=Cu(Jl(),1);var al=ec.default.createElement;function VL({onClose:u}){let{notifications:l,removeNotification:f,clearNotifications:r}=Xf(),n=ec.default.useRef(null);if(ec.default.useEffect(()=>{let i=(t)=>{if(n.current&&!n.current.contains(t.target))u()};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[u]),l.length===0)return al("div",{className:"notification-popup",ref:n},al("div",{className:"notification-popup-header"},al("span",null,"通知"),al("button",{className:"notification-popup-close",onClick:u},"×")),al("div",{className:"notification-popup-empty"},"暂无通知"));return al("div",{className:"notification-popup",ref:n},al("div",{className:"notification-popup-header"},al("span",null,`通知 (${l.length})`),al("div",{className:"notification-popup-actions"},al("button",{className:"notification-popup-clear",onClick:r},"清空"),al("button",{className:"notification-popup-close",onClick:u},"×"))),al("div",{className:"notification-popup-list"},l.slice().reverse().map((i)=>al("div",{key:i.id,className:`notification-item ${i.type}`},al("span",{className:"notification-item-icon"},i.type==="success"?"✓":"×"),al("span",{className:"notification-item-message"},i.message),al("button",{className:"notification-item-dismiss",onClick:()=>f(i.id)},"×")))))}function mL({notification:u}){let{removeNotification:l}=Xf();return ec.default.useEffect(()=>{let f=setTimeout(()=>{l(u.id)},3000);return()=>clearTimeout(f)},[u.id,l]),al("div",{className:`notification-banner ${u.type}`,role:"alert"},al("span",{className:"notification-banner-icon"},u.type==="success"?"✓":"×"),al("span",{className:"notification-banner-message"},u.message),al("button",{className:"notification-banner-dismiss",onClick:()=>l(u.id)},"×"))}function bL(u,l){let f=document.getElementById("root")?.getAttribute(u);if(!f)return l;try{let r=JSON.parse(f);return typeof r==="object"&&r!==null&&!Array.isArray(r)?r:l}catch{return l}}var Iu=bL("data-config",{apiBaseUrl:"/api",authUsername:"admin"}),vX=bL("data-codex-overview",null),_=ui.default.createElement,{useEffect:Tn,useMemo:f_}=ui.default,bu=ui.default.useState,T7=ui.default.createContext(!1),pr=zN(q3),kX={id:"code-queue",name:"Code Queue",providerId:"D601",description:"Code Queue",repository:{containerName:"k3s:code-queue"},backend:{nodeBaseUrl:"k3s://code-queue",nodeBindHost:"k3s://unidesk/code-queue",nodePort:4222,proxyMode:"k3sctl-adapter-http",public:!1},deployment:{mode:"k3sctl-managed",adapterServiceId:"k3sctl-adapter",k3sServiceId:"code-queue"},runtime:{orchestrator:"k3sctl",providerStatus:"loading",providerName:"D601"}};function DL(){return typeof document>"u"||document.visibilityState!=="hidden"}function IX(u,l){if(u==="ops"&&l==="status")return 5000;if(u==="nodes"&&l==="monitor")return 5000;if(u==="tasks"&&(l==="dispatch"||l==="scheduled"||l==="pending"))return 5000;if(u==="nodes"||u==="ops")return 1e4;if(u==="apps")return 15000;if(u==="tasks")return 15000;return 30000}async function gX(u){if(!u?._summaryOnly||!u?.id)return u;return(await Eu(`${Iu.apiBaseUrl}/tasks/${encodeURIComponent(String(u.id))}`))?.task||u}function r_(u){return u?._summaryOnly?{...u,_loadRaw:()=>gX(u)}:u}function dn(u){if(!Number.isFinite(u))return"--";let l=Math.max(0,u);if(l===0)return"0s";if(l<0.01)return"<0.01s";if(l<0.1)return`${l.toFixed(2)}s`;if(l<1)return`${l.toFixed(1)}s`;if(l<10&&!Number.isInteger(l))return`${l.toFixed(1)}s`;if(l<60)return`${Math.round(l)}s`;let f=Math.floor(l);if(f<3600)return`${Math.floor(f/60)}m ${f%60}s`;return`${Math.floor(f/3600)}h ${Math.floor(f%3600/60)}m`}function qr(u){let l=Number(u);if(!Number.isFinite(l))return"--";if(l<1)return`${Math.max(0,l).toFixed(1)}ms`;if(l<10)return`${l.toFixed(1)}ms`;if(l<1000)return`${Math.round(l)}ms`;return dn(l/1000)}function Of(u){let l=Number(u);if(!Number.isFinite(l)||l<=0)return"--";let f=["B","KB","MB","GB","TB"],r=l,n=0;while(r>=1024&&n<f.length-1)r/=1024,n+=1;return`${r.toFixed(n===0?0:1)} ${f[n]}`}function e0(u){let l=Number(u);return Number.isFinite(l)?`${Math.max(0,Math.min(100,l)).toFixed(1)}%`:"--"}function sX(u){let l=Number(u);return Number.isFinite(l)?`${Math.max(0,l).toFixed(1)}%`:"--"}function w7(u){let l=Number(u);if(!Number.isFinite(l)||l<=0)return"0 B/s";return`${Of(l)}/s`}function Ru(u,l=0){let f=Number(u);return Number.isFinite(f)?f:l}function my(u){return["queued","dispatched","running"].includes(String(u?.status||"").toLowerCase())}function K7(u){if(!u)return"--";let l=new Date(u);if(Number.isNaN(l.getTime()))return"--";return dn(Math.max(0,Math.floor((Date.now()-l.getTime())/1000)))}function Kn(u){if(!u)return null;let l=new Date(u);return Number.isNaN(l.getTime())?null:l.getTime()}function vL(u){let l=Kn(u?.createdAt);if(l===null)return null;let r=["succeeded","failed"].includes(String(u?.status||"").toLowerCase())?Kn(u?.updatedAt):Date.now();if(r===null)return null;return Math.max(0,(r-l)/1000)}function kL(u){if(String(u?.status||"").toLowerCase()!=="failed")return"";let l=u?.result;if(typeof l==="string")return l;if(l&&typeof l==="object"&&!Array.isArray(l)){let f=l;for(let r of["error","reason","message","stderr","detail"])if(typeof f[r]==="string"&&f[r].length>0)return f[r]}return"任务失败但 provider 未返回明确原因"}function ut(u){if(u===null||u===void 0)return"--";if(typeof u==="boolean")return u?"是":"否";if(typeof u==="number")return String(u);if(typeof u==="string")return u.length>80?`${u.slice(0,77)}...`:u;if(Array.isArray(u))return`${u.length} 项`;if(typeof u==="object")return`${Object.keys(u).length} 字段`;return String(u)}function aX(u,l){let f=u.replace(/[-_\s]/g,"").toLowerCase(),r=f==="ts"||f.endsWith("at")||f.endsWith("timestamp")||f.endsWith("heartbeat");if((typeof l==="string"||typeof l==="number")&&r){let n=wu(l);if(n!=="--")return n}if(u==="bodyText"&&typeof l==="string")return`${/^\s*[{[]/.test(l)?"JSON":"HTTP"} body ${l.length} chars`;return ut(l)}function IL(u){if(!u||typeof u!=="object"||Array.isArray(u))return[];return Object.entries(u)}function fr(u){return String(u).replace(/[^a-zA-Z0-9_-]/g,"_")}function G7(u,l){return u&&typeof u==="object"&&!Array.isArray(u)?u[l]:void 0}function gA(u,l,f="未知"){let r=G7(u?.labels,l);return typeof r==="string"&&r.length>0?r:f}function gL(u){return gA(u,"providerGatewayVersion")}function l_(u){return gA(u,"providerGatewayUpgradePolicy")}function pL(u){return gA(u,"providerGatewayStartedAt","")}function sL(u){let l=G7(u?.labels,"unideskCapabilities");if(typeof l==="string")return l.split(",").map((f)=>f.trim()).filter(Boolean);return Array.isArray(l)?l.filter((f)=>typeof f==="string"):[]}function aL(u,l){return sL(u).includes(l)}function SL(u,l){let f=G7(u?.labels,l);return f===!0||f==="true"||f==="1"}function oX(u){if(!aL(u,"host.ssh"))return{tone:"fail",label:"不可用",detail:"未声明 host.ssh"};if(!SL(u,"hostSshConfigured"))return{tone:"warn",label:"未配置",detail:"缺少 SSH 环境变量"};if(!SL(u,"hostSshKeyPresent"))return{tone:"warn",label:"缺 key",detail:"私钥未挂载"};return{tone:"ok",label:"可用",detail:gA(u,"hostSshTarget","host.ssh ready")}}function dX(u){if(!aL(u,"provider.upgrade"))return{tone:"fail",label:"不可用",detail:"未声明 provider.upgrade"};let l=l_(u);if(l!=="always-enabled")return{tone:"warn",label:"待确认",detail:`策略 ${l}`};return{tone:"ok",label:"可用",detail:"always-enabled"}}function z7(u){let l=typeof u==="string"&&u.length>0?u:"未知";if(l==="未知")return"版本未知";return l.startsWith("v")?l:`v${l}`}function oL(u){return u?.payload&&typeof u.payload==="object"&&!Array.isArray(u.payload)?u.payload:{}}function sA(u){return u?.result&&typeof u.result==="object"&&!Array.isArray(u.result)?u.result:{}}function IA(u){let l=oL(u),f=sA(u);return(l.mode??f.mode)==="schedule"?"schedule":"plan"}function eX(u){let l=oL(u).source;return typeof l==="string"&&l.length>0?l:"unknown"}function uY(u){let l=sA(u),f=l.plan&&typeof l.plan==="object"&&!Array.isArray(l.plan)?l.plan:{},r=l.policy??f.policy;return typeof r==="string"&&r.length>0?r:"--"}function dL(u){let l=sA(u),f=l.plan&&typeof l.plan==="object"&&!Array.isArray(l.plan)?l.plan:{},r=l.targetProviderGatewayVersion??l.providerGatewayVersion??f.targetProviderGatewayVersion??f.providerGatewayVersion;return typeof r==="string"&&r.length>0?z7(r):"版本未知"}function eL(u){if(String(u?.status||"").toLowerCase()==="failed")return kL(u);if(my(u))return"等待 provider 回传升级终态";let f=sA(u);if(typeof f.updaterContainerId==="string"&&f.updaterContainerId.length>0)return`updater ${f.updaterContainerId.slice(0,18)}`;if(typeof f.message==="string"&&f.message.length>0)return f.message;if(f.plan)return"升级计划已生成";return"无升级结果摘要"}function uT(u,l){return u.filter((f)=>f?.providerId===l&&f?.command==="provider.upgrade").sort((f,r)=>(Kn(r.updatedAt)??0)-(Kn(f.updatedAt)??0))}function lY(u){return u.find((l)=>IA(l)==="schedule")||u[0]||null}function lT(u){return u?.runtime&&typeof u.runtime==="object"&&!Array.isArray(u.runtime)?u.runtime:{}}function XL(u){return u?.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{}}function fY(u){return u?.repository&&typeof u.repository==="object"&&!Array.isArray(u.repository)?u.repository:{}}function Tl({status:u,children:l}){let f=String(u||"unknown").toLowerCase();return _("span",{className:`status-badge ${f}`},l||u||"unknown")}function Fl({label:u,value:l,hint:f,tone:r,onClick:n,testId:i}){let t=typeof n==="function";return _("article",{className:`metric-card ${r||""} ${t?"clickable":""}`,role:t?"button":void 0,tabIndex:t?0:void 0,"data-testid":i,onClick:n,onKeyDown:t?(y)=>{if(y.key==="Enter"||y.key===" ")y.preventDefault(),n()}:void 0},_("div",{className:"metric-label"},u),_("div",{className:"metric-value"},l),_("div",{className:"metric-hint"},f))}function eu({title:u,eyebrow:l,actions:f,children:r,className:n,loading:i}){let t=ui.default.useContext(T7),y=Boolean(i)||t;return _("section",{className:`panel ${n||""}`},_("div",{className:"panel-head"},_("div",null,l?_("p",{className:"panel-eyebrow"},l):null,_(rl,{title:u,loading:y})),f?_("div",{className:"panel-actions"},f):null),_("div",{className:"panel-body"},r))}function ol({title:u,data:l,onOpen:f,testId:r}){let[n,i]=bu(!1),t=l&&typeof l==="object"&&typeof l._loadRaw==="function"?l._loadRaw:null;async function y(){if(!t){f(u,l);return}i(!0);try{f(u,await t())}catch(c){f(u,{ok:!1,error:Ou(c,"读取原始 JSON 失败"),fallback:l})}finally{i(!1)}}return _("button",{type:"button",className:"ghost-btn","data-testid":r,disabled:n,onClick:()=>void y()},n?"读取中":"查看原始JSON")}function rY({raw:u,onClose:l}){if(!u)return null;return _("div",{className:"modal-backdrop",role:"presentation"},_("section",{className:"raw-dialog",role:"dialog","aria-modal":"true","aria-label":u.title},_("div",{className:"raw-dialog-head"},_("h2",null,u.title),_("button",{type:"button",className:"ghost-btn",onClick:l},"关闭")),_("pre",{className:"raw-json","data-testid":"raw-json"},JSON.stringify(u.data,null,2))))}function fT({labels:u,limit:l=8}){let f=IL(u).slice(0,l);if(f.length===0)return _("span",{className:"muted"},"无标签");return _("div",{className:"chip-row"},f.map(([r,n])=>_("span",{key:r,className:"data-chip"},_("b",null,r),_("span",null,ut(n)))))}function Vy({node:u}){let l=gL(u);return _("span",{className:`version-chip ${l==="未知"?"unknown":""}`,"data-testid":`gateway-version-${fr(u?.providerId||"unknown")}`},z7(l))}function YL({title:u,state:l,testId:f}){return _("span",{className:`capability-badge ${l.tone}`,title:l.detail,"data-testid":f},_("b",null,u),_("strong",null,l.label),_("small",null,l.detail))}function E7({node:u}){let l=fr(u?.providerId||"unknown");return _("div",{className:"node-availability-strip"},_(YL,{title:"SSH 透传",state:oX(u),testId:`ssh-availability-${l}`}),_(YL,{title:"远程更新",state:dX(u),testId:`upgrade-availability-${l}`}))}function li({data:u,empty:l="无数据"}){if(u===null||u===void 0)return _("span",{className:"muted"},l);if(typeof u!=="object")return _("span",{className:"summary-value"},ut(u));if(Array.isArray(u))return _("span",{className:"summary-value"},`${u.length} 项列表`);let f=Object.entries(u).slice(0,5);if(f.length===0)return _("span",{className:"muted"},l);return _("div",{className:"summary-grid"},f.map(([r,n])=>_("span",{key:r,className:"summary-item"},_("b",null,r),_("span",null,aX(r,n)))))}function Ql({title:u,text:l}){return _("div",{className:"empty-state"},_("strong",null,u),_("span",null,l))}function nY({onLogin:u}){let[l,f]=bu(Iu.authUsername||"admin"),[r,n]=bu(""),[i,t]=bu(""),[y,c]=bu(!1);async function $(A){A.preventDefault(),c(!0),t("");try{let j=await Eu("/login",{method:"POST",body:JSON.stringify({username:l,password:r})});u(j)}catch(j){t(Ou(j,"登录失败"))}finally{c(!1)}}return _("main",{className:"login-screen","data-testid":"login-screen"},_("section",{className:"login-card"},_("div",{className:"login-brand"},_("span",{className:"brand-mark"},"UD"),_("div",null,_("h1",null,"UniDesk"),_("p",null,"Control Plane Login"))),_("form",{className:"login-form",onSubmit:$},_("label",null,"账号",_("input",{name:"username",autoComplete:"username",value:l,onChange:(A)=>f(A.target.value)})),_("label",null,"密码",_("input",{name:"password",type:"password",autoComplete:"current-password",value:r,onChange:(A)=>n(A.target.value)})),_(nl,{error:i}),_("button",{type:"submit",disabled:y},y?"登录中":"登录")),_("div",{className:"login-note"},"默认账号由 config.json 注入;公网入口只暴露前端登录面。")))}function iY({connection:u,lastRefresh:l,onRefresh:f,onLogout:r,session:n,clock:i,activeStatusItems:t=[],onNotificationToggle:y,unreadCount:c=0}){let $=[{key:"core",label:"核心",value:u.text,tone:u.ok?"ok":"fail",testId:"conn-text"},...Array.isArray(t)?t:[],{key:"refresh",label:"刷新",value:l?yl(l):"未刷新"},{key:"clock",label:W_,value:yl(i)},{key:"user",label:"用户",value:n?.user?.username||"--",tone:"user"}];return _("header",{className:"topbar"},_("div",null,_("p",{className:"eyebrow"},"Distributed Work Platform"),_("h1",null,"UniDesk 控制平面")),_(OL,{className:"global-top-status",title:"状态",items:$,actions:[_("button",{key:"notification",type:"button",className:`notification-icon-btn ${c>0?"has-unread":""}`,onClick:y,"aria-label":"通知"},"\uD83D\uDD14",c>0?_("span",{key:"badge",className:"notification-badge"},c>99?"99+":c):null),_("button",{key:"refresh",type:"button",className:"ghost-btn",onClick:f},"刷新"),_("button",{key:"logout",type:"button",className:"ghost-btn danger",onClick:r},"退出")]}))}function tY(u){return!u.defaultPrevented&&u.button===0&&!u.metaKey&&!u.altKey&&!u.ctrlKey&&!u.shiftKey&&u.currentTarget.target!=="_blank"}function rT({moduleId:u,tabId:l,className:f,active:r=!1,title:n,testId:i,onNavigate:t,children:y}){let c=w3(pr,u,l);return _("a",{href:c,role:"button",className:f,title:n,"aria-current":r?"page":void 0,"data-testid":i,"data-route":c,onClick:($)=>{if(!tY($))return;$.preventDefault(),t(u,l)}},y)}function yY({activeModule:u,activeTabs:l,onNavigate:f,collapsed:r,onToggle:n}){return _("aside",{className:`rail ${r?"collapsed":""}`,"aria-label":"主模块"},_("div",{className:"brand"},_("span",{className:"brand-mark"},"UD"),_("span",{className:"brand-text"},"UniDesk"),_("button",{type:"button",className:"rail-toggle",onClick:n,"aria-label":r?"展开左侧边栏":"收起左侧边栏","data-testid":"rail-toggle"},r?"»":"«")),q3.map((i)=>{let t=l[i.id]||yc[i.id]||i.tabs[0]?.id||"";return _(rT,{key:i.id,moduleId:i.id,tabId:t,className:`module ${u===i.id?"active":""}`,active:u===i.id,title:i.label,onNavigate:f},_("span",{className:"module-code"},i.code),_("span",null,i.label))}))}function cY({module:u,activeTab:l,onNavigate:f}){return _("nav",{className:"tabs","aria-label":`${u.label} 子功能`},u.tabs.map((r)=>_(rT,{key:r.id,moduleId:u.id,tabId:r.id,className:`tab ${l===r.id?"active":""}`,active:l===r.id,onNavigate:f},r.label)))}function _Y({data:u,onRaw:l,onNavigate:f}){let r=u.overview||{},n=u.nodes.filter((J)=>J.status==="online"),i=u.pendingTasks||u.tasks.filter(my),t=r.pendingTaskCount??i.length,y=u.tasks.slice(0,5),c=r.pgdata||{},$=r.microserviceAvailability||{},A=Ru($.totalCount),j=Ru($.healthyCount),F=Ru($.unhealthyCount);return _("div",{className:"page-grid overview-grid","data-testid":"overview-page"},_(eu,{title:"核心指标",eyebrow:"Control"},_("div",{className:"metric-grid"},_(Fl,{label:"数据库",value:r.dbReady?"READY":"WAIT",hint:"PostgreSQL internal network",tone:r.dbReady?"ok":"warn"}),_(Fl,{label:"PGDATA",value:Of(c.databaseBytes),hint:`${c.volumeName||"unidesk_pgdata_10gb"} / ${c.databasePretty||"--"}`,tone:"ok",testId:"pgdata-usage-card"}),_(Fl,{label:"在线节点",value:r.onlineNodeCount??0,hint:`${r.nodeCount??0} registered`,tone:"ok"}),_(Fl,{label:"WebSocket",value:r.activeSocketCount??0,hint:"Provider ingress sockets"}),_(Fl,{label:"用户服务可用",value:A>0?`${j}/${A}`:"--",hint:A>0?`healthyCount ${j} · unhealthyCount ${F}`:"strict /health probes",tone:A>0&&F===0?"ok":"warn",testId:"microservice-availability-card"}),_(Fl,{label:"待处理任务",value:t,hint:t>0?"点击查看具体任务":`timeout ${dn(Math.floor((r.taskPendingTimeoutMs??0)/1000))}`,tone:t>0?"warn":"ok",onClick:()=>f("tasks","pending"),testId:"pending-task-card"}))),_(eu,{title:"本机 Provider",eyebrow:"Self Connected"},n.length===0?_(Ql,{title:"暂无在线节点",text:"provider-gateway 未完成自接入"}):_("div",{className:"node-card-list"},n.slice(0,4).map((J)=>_($Y,{key:J.providerId,node:J,onRaw:l})))),_(eu,{title:"待处理任务明细",eyebrow:`${t} Pending`,actions:_("button",{type:"button",className:"ghost-btn",onClick:()=>f("tasks","pending"),"data-testid":"pending-task-detail-link"},"进入任务调度")},i.length===0?_(Ql,{title:"当前无待处理",text:"queued / dispatched / running 超时后会自动转为 failed,避免总览长期卡住"}):_("div",{className:"compact-list"},i.slice(0,5).map((J)=>_(RL,{key:J.id,task:J,onRaw:l})))),_(eu,{title:"最近任务",eyebrow:"Dispatch"},y.length===0?_(Ql,{title:"暂无任务",text:"可以在任务调度模块发起 docker.ps 或 echo"}):_("div",{className:"compact-list"},y.map((J)=>_(RL,{key:J.id,task:J,onRaw:l})))))}function $Y({node:u,onRaw:l}){return _("article",{className:"node-card"},_("div",{className:"node-card-head"},_("div",null,_("strong",null,u.name),_("code",null,u.providerId)),_(Tl,{status:u.status})),_("div",{className:"node-version-line"},_(Vy,{node:u}),_("span",null,`升级策略 ${l_(u)}`)),_(E7,{node:u}),_(fT,{labels:u.labels,limit:6}),_("div",{className:"node-card-foot"},_("span",null,`心跳 ${wu(u.lastHeartbeat)}`),_(ol,{title:`Provider ${u.providerId}`,data:u,onOpen:l,testId:`raw-node-${fr(u.providerId)}`})))}function AY({events:u,onRaw:l}){return _(eu,{title:"事件摘要",eyebrow:"Latest 100"},u.length===0?_(Ql,{title:"暂无事件",text:"Provider 注册、心跳超时和任务状态会写入事件流"}):_("div",{className:"table-wrap"},_("table",null,_("thead",null,_("tr",null,_("th",null,"ID"),_("th",null,"类型"),_("th",null,"来源"),_("th",null,"摘要"),_("th",null,"时间"),_("th",null,"操作"))),_("tbody",null,u.map((f)=>_("tr",{key:f.id},_("td",null,_("code",null,f.id)),_("td",null,_(Tl,{status:f.type},f.type)),_("td",null,_("code",null,f.source)),_("td",null,_(li,{data:f.payload})),_("td",null,wu(f.createdAt)),_("td",null,_(ol,{title:`Event ${f.id}`,data:f,onOpen:l}))))))))}function jY({logs:u,onRaw:l}){return _(eu,{title:"服务日志",eyebrow:"Core Recent"},u.length===0?_(Ql,{title:"暂无日志",text:"backend-core 内存日志会在请求和 provider 事件后出现"}):_("div",{className:"log-list"},u.slice(-80).reverse().map((f,r)=>_("article",{key:r,className:`log-row ${f.level||"info"}`},_("span",null,wu(f.ts)),_("b",null,f.level||"info"),_("strong",null,f.message||"log"),_(li,{data:f.data,empty:"无附加字段"}),_(ol,{title:`Log ${f.message||r}`,data:f,onOpen:l})))))}function FY({nodes:u,onRaw:l}){return _(eu,{title:"节点清单",eyebrow:`${u.length} Providers`},u.length===0?_(Ql,{title:"暂无 Provider 节点",text:"确认 provider-gateway 已连接 provider ingress"}):_("div",{className:"table-wrap"},_("table",{className:"node-list-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"Provider"),_("th",null,"网关版本"),_("th",null,"运维可用性"),_("th",null,"资源标签"),_("th",null,"连接时间"),_("th",null,"最后心跳"),_("th",null,"操作"))),_("tbody",null,u.map((f)=>_("tr",{key:f.providerId},_("td",null,_(Tl,{status:f.status})),_("td",null,_("strong",null,f.name),_("code",null,f.providerId)),_("td",null,_("div",{className:"gateway-cell"},_(Vy,{node:f}),_("span",null,l_(f)))),_("td",null,_(E7,{node:f})),_("td",null,_(fT,{labels:f.labels,limit:5})),_("td",null,wu(f.connectedAt)),_("td",null,wu(f.lastHeartbeat)),_("td",null,_(ol,{title:`Provider ${f.providerId}`,data:f,onOpen:l,testId:`raw-node-table-${fr(f.providerId)}`}))))))))}function UY({nodes:u}){let l=f_(()=>{let f=[];for(let r of u)for(let[n,i]of IL(r.labels))f.push({providerId:r.providerId,name:r.name,key:n,value:i});return f},[u]);return _(eu,{title:"资源标签",eyebrow:"Structured Labels"},l.length===0?_(Ql,{title:"暂无标签",text:"provider-gateway 注册消息会同步资源标签"}):_("div",{className:"label-matrix"},l.map((f)=>_("article",{key:`${f.providerId}-${f.key}`,className:"label-card"},_("span",null,f.key),_("strong",null,ut(f.value)),_("code",null,f.providerId)))))}function JY({nodes:u}){return _(eu,{title:"心跳状态",eyebrow:"Provider Liveness"},u.length===0?_(Ql,{title:"无心跳",text:"等待 provider 注册和 heartbeat"}):_("div",{className:"heartbeat-list"},u.map((l)=>_("article",{key:l.providerId,className:"heartbeat-row"},_("span",{className:`pulse ${l.status}`}),_("div",null,_("strong",null,l.name),_("code",null,l.providerId)),_("div",null,_("span",null,"connected"),_("b",null,wu(l.connectedAt))),_("div",null,_("span",null,"last heartbeat"),_("b",null,wu(l.lastHeartbeat)))))))}function QY({nodes:u,systemStatuses:l,tasks:f,onRaw:r,refresh:n}){let[i,t]=bu(""),y=f_(()=>u.map((W)=>{let L=l.find((U)=>U.providerId===W.providerId);return{...W,systemCurrent:L?.current||null,systemHistory:L?.history||[],systemUpdatedAt:L?.updatedAt||null}}),[u,l]),c=y.find((W)=>W.providerId===i)||y[0]||null;if(Tn(()=>{if(!i&&y[0])t(y[0].providerId)},[y.length,i]),!c)return _(Ql,{title:"暂无资源监控",text:"等待 provider 上报 CPU、内存和硬盘指标"});let $=c.systemCurrent,A=c.systemHistory||[],j=$?.cpu||{},F=$?.memory||{},J=$?.disk||{},Q=A.length>0?A:$?[{at:$.collectedAt,cpuPercent:Ru(j.percent),memoryPercent:Ru(F.percent),diskPercent:Ru(J.percent)}]:[];return _("div",{className:"monitor-page","data-testid":"node-monitor-page"},_("div",{className:"docker-node-strip"},y.map((W)=>_("button",{key:W.providerId,type:"button",className:`docker-node-tile ${c.providerId===W.providerId?"active":""}`,onClick:()=>t(W.providerId)},_("span",{className:`pulse ${W.status}`}),_("strong",null,W.name),_("code",null,W.providerId),_("span",null,W.systemCurrent?`CPU ${e0(W.systemCurrent.cpu?.percent)} / MEM ${e0(W.systemCurrent.memory?.percent)}`:"等待指标")))),_("div",{className:"monitor-layout"},_(eu,{title:"任务管理器视图",eyebrow:c.name,className:"monitor-main-panel",actions:$?_(ol,{title:`System ${c.providerId}`,data:{current:$,history:A},onOpen:r}):null},!$?_(Ql,{title:"系统指标未上报",text:"provider-gateway 会周期性采集 /proc 与 df,并保存历史曲线"}):_("div",null,_("div",{className:"monitor-hero"},_("div",null,_("p",{className:"panel-eyebrow"},"Node Performance"),_("h3",null,c.name),_("div",{className:"docker-meta"},_("span",null,`${j.cores||0} CPU cores`),_("span",null,`load ${Ru(j.load1).toFixed(2)} / ${Ru(j.load5).toFixed(2)} / ${Ru(j.load15).toFixed(2)}`),_("span",null,`memory actual ${Of(F.usedBytes)} / ${Of(F.totalBytes)}`),_("span",null,`disk ${Of(J.usedBytes)} / ${Of(J.totalBytes)}`))),_(Tl,{status:$.ok?"online":"warn"},$.ok?"METRICS READY":"METRICS DEGRADED")),_("div",{className:"monitor-chart-grid"},_(W7,{title:"CPU",metricKey:"cpuPercent",current:j.percent,points:Q,detail:`${j.cores||0} cores / load ${Ru(j.load1).toFixed(2)}`,tone:"cpu",testId:"metric-chart-cpu"}),_(W7,{title:"Memory",metricKey:"memoryPercent",current:F.percent,points:Q,detail:`${Of(F.usedBytes)} actual / ${Of(F.cacheBytes)} cache excluded`,tone:"memory",testId:"metric-chart-memory"}),_(W7,{title:"Disk",metricKey:"diskPercent",current:J.percent,points:Q,detail:`${J.path||"/"} mounted ${J.mount||"--"}`,tone:"disk",testId:"metric-chart-disk"})),_("div",{className:"monitor-summary-grid"},_(Fl,{label:"CPU 当前",value:e0(j.percent),hint:`history ${Q.length} samples`,tone:"ok"}),_(Fl,{label:"实际内存",value:Of(F.usedBytes),hint:`${e0(F.percent)} 不含缓存`}),_(Fl,{label:"硬盘已用",value:Of(J.usedBytes),hint:e0(J.percent)}),_(Fl,{label:"更新时间",value:wu(c.systemUpdatedAt||$.collectedAt),hint:c.providerId})),_(NY,{current:$,onRaw:r}))),_("div",{className:"monitor-side-stack"},_(zY,{provider:c,refresh:n,onRaw:r}),_(EY,{provider:c,tasks:f,onRaw:r,limit:5}),_(eu,{title:"采样说明",eyebrow:"Retention"},_("div",{className:"monitor-note-list"},_("article",null,_("b",null,"CPU"),_("span",null,"从 /proc/stat 计算相邻采样差值,首个采样用 load/cores 近似")),_("article",null,_("b",null,"Memory"),_("span",null,"实际内存 = MemTotal - MemFree - Buffers - Cached - SReclaimable + Shmem,不把 page cache / buffer 计入占用")),_("article",null,_("b",null,"Disk"),_("span",null,"使用 df -PB1 对配置路径采样,默认监控根文件系统")),_("article",null,_("b",null,"Process"),_("span",null,"从 /proc/[pid] 采集进程 CPU、实际内存 RSS、线程数和磁盘 I/O 速率;表格默认按内存占用降序")))))))}function PL(u,l){if(l==="memory")return Ru(u.rssBytes);if(l==="cpu")return Ru(u.cpuPercent);if(l==="disk")return Ru(u.readBytesPerSecond)+Ru(u.writeBytesPerSecond);if(l==="pid")return Ru(u.pid);if(l==="threads")return Ru(u.threads);if(l==="runtime")return Ru(u.elapsedSeconds);if(l==="user")return String(u.user||"");return String(u.name||u.command||"")}function CL({value:u,label:l,tone:f}){let r=Math.max(1,Math.min(100,Ru(u)));return _("div",{className:`process-meter ${f||""}`},_("span",{style:{width:`${r}%`}}),_("b",null,l))}function NY({current:u,onRaw:l}){let[f,r]=bu({key:"memory",direction:"desc"}),n=ui.default.useContext(T7),i=u?.processSummary&&typeof u.processSummary==="object"?u.processSummary:{},t=Array.isArray(u?.processes)?u.processes:[],y=f_(()=>{let $=f.direction==="asc"?1:-1;return[...t].sort((A,j)=>{let F=PL(A,f.key),J=PL(j,f.key);if(typeof F==="string"||typeof J==="string")return String(F).localeCompare(String(J),"zh-CN")*$;return(F-J)*$||Ru(A.pid)-Ru(j.pid)})},[t,f.key,f.direction]),c=($,A)=>{let j=f.key===A,F=j?f.direction==="asc"?"ascending":"descending":"none";return _("th",{"aria-sort":F},_("button",{type:"button",className:`process-sort-button ${j?"active":""}`,"data-testid":`process-sort-${A}`,onClick:()=>r((J)=>({key:A,direction:J.key===A&&J.direction==="desc"?"asc":"desc"}))},$,_("span",null,j?f.direction==="desc"?"↓":"↑":"↕")))};return _("section",{className:"process-resource-panel","data-testid":"process-resource-panel"},_("div",{className:"process-resource-head"},_("div",null,_("p",{className:"panel-eyebrow"},"Windows Resource Monitor Style"),_(rl,{title:"进程资源占用",level:3,loading:n})),_("div",{className:"process-resource-actions"},_("span",{className:"data-chip"},"默认按内存排序"),_("span",{className:"data-chip"},`${Ru(i.visible,y.length)} / ${Ru(i.total,y.length)} 进程`),_(ol,{title:"Process Resource Snapshot",data:{processSummary:i,processes:t},onOpen:l,testId:"raw-process-resources"}))),y.length===0?_(Ql,{title:"暂无进程资源数据",text:"等待 provider-gateway 上报 /proc/[pid] 采样;旧版 provider 需要先升级到支持进程资源表的版本"}):_("div",{className:"process-table-wrap"},_("table",{className:"process-resource-table","data-testid":"process-resource-table"},_("thead",null,_("tr",null,c("进程","name"),c("PID","pid"),c("用户","user"),_("th",null,"状态"),c("CPU","cpu"),c("内存","memory"),_("th",null,"RSS"),c("磁盘 I/O","disk"),c("线程","threads"),c("运行时长","runtime"))),_("tbody",null,y.map(($)=>{let A=Ru($.readBytesPerSecond)+Ru($.writeBytesPerSecond);return _("tr",{key:`${$.pid}-${$.startedAt}`,"data-testid":`process-row-${fr($.pid)}`,"data-memory-bytes":String(Ru($.rssBytes)),"data-cpu-percent":String(Ru($.cpuPercent)),"data-disk-bps":String(A),"data-pid":String(Ru($.pid))},_("td",null,_("div",{className:"process-name-cell"},_("strong",null,$.name||"--"),_("span",{className:"process-command"},$.command||"--"))),_("td",null,_("code",null,$.pid||"--")),_("td",null,$.user||`uid:${$.uid??"--"}`),_("td",null,_("span",{className:`process-state state-${fr($.state||"unknown")}`},$.state||"?")),_("td",null,_(CL,{value:$.cpuPercent,label:sX($.cpuPercent),tone:"cpu"})),_("td",null,_(CL,{value:$.memoryPercent,label:e0($.memoryPercent),tone:"memory"})),_("td",null,Of($.rssBytes)),_("td",null,_("div",{className:"process-io-cell"},_("strong",null,w7(A)),_("span",null,`R ${w7($.readBytesPerSecond)} / W ${w7($.writeBytesPerSecond)}`))),_("td",null,$.threads||0),_("td",null,dn(Ru($.elapsedSeconds))))})))))}function W7({title:u,metricKey:l,current:f,points:r,detail:n,tone:i,testId:t}){let y=r.map((F)=>Math.max(0,Math.min(100,Ru(F[l])))),c=y.length>1?y:[y[0]||0,y[0]||0],$=c.length<=1?100:100/(c.length-1),A=c.map((F,J)=>`${(J*$).toFixed(2)},${(46-F*0.42).toFixed(2)}`).join(" "),j=`0,48 ${A} 100,48`;return _("article",{className:`metric-chart ${i}`,"data-testid":t},_("div",{className:"metric-chart-head"},_("div",null,_("span",null,u),_("strong",null,e0(f))),_("code",null,`${r.length} pts`)),_("svg",{viewBox:"0 0 100 48",preserveAspectRatio:"none",role:"img","aria-label":`${u} usage curve`},_("polygon",{points:j}),_("polyline",{points:A}),_("line",{x1:"0",x2:"100",y1:"24",y2:"24"})),_("div",{className:"metric-chart-foot"},_("span",null,"0%"),_("span",null,n),_("span",null,"100%")))}function en(u){return Array.isArray(u)?u:[]}function qY(u){let l=en(u?.core?.requests?.componentSummary);return[...en(u?.frontend?.requests?.componentSummary),...l].sort((r,n)=>Ru(n.requestCount)-Ru(r.requestCount))}function wY(u){let l=en(u?.core?.operations?.summary);return[...en(u?.frontend?.operations?.summary),...l].sort((r,n)=>Ru(n.count)-Ru(r.count))}function WY(u){let l=en(u?.core?.requests?.recentFailures).map((r)=>({source:"backend",...r}));return[...en(u?.frontend?.requests?.recentFailures).map((r)=>({source:"frontend",...r})),...l].sort((r,n)=>(Kn(n.at)??0)-(Kn(r.at)??0)).slice(0,20)}function LY(u){let l=en(u?.core?.operations?.recentSlowOperations);return[...en(u?.frontend?.operations?.recentSlowOperations),...l].sort((r,n)=>Ru(n.durationMs)-Ru(r.durationMs)).slice(0,20)}function TY(u){let l=performance.memory,f=Number(l?.usedJSHeapSize);if(Number.isFinite(f)&&f>0)return f;let r=Number(u?.appBundleBytes);if(Number.isFinite(r)&&r>0)return r;return Ru(u?.process?.heapUsedBytes)}function KY({points:u}){let l=en(u),f=l.map((F)=>Ru(F.mb)),r=Math.max(1,...f),n=Math.max(0,Math.min(...f,0)),i=Math.max(1,r-n),t=l.length>1?l:[...l,...l],y=t.length<=1?100:100/(t.length-1),c=t.map((F,J)=>{let Q=Ru(F.mb);return`${(J*y).toFixed(2)},${(48-(Q-n)/i*42).toFixed(2)}`}).join(" "),$=`0,50 ${c} 100,50`,A=l.at(-1),j=l[0];return _("article",{className:"performance-memory-card","data-testid":"performance-memory-chart"},_("div",{className:"performance-memory-head"},_("strong",null,`Bwebui: ${A?`${Ru(A.mb).toFixed(1)}MB`:"--"}`),_("span",null,l.length>0?`${l.length} samples`:"等待采样")),_("svg",{viewBox:"0 0 100 50",preserveAspectRatio:"none",role:"img","aria-label":"Bwebui memory trend"},_("polygon",{points:$}),_("polyline",{points:c}),_("line",{x1:"0",x2:"100",y1:"25",y2:"25"})),_("div",{className:"performance-axis-row"},_("span",null,j?yl(new Date(j.at)):"--"),_("span",null,"时间"),_("span",null,A?yl(new Date(A.at)):"--")),_("div",{className:"performance-axis-row"},_("span",null,`${n.toFixed(1)}`),_("span",null,"(MB)"),_("span",null,`${r.toFixed(1)}`)))}function GY({onRaw:u}){let[l,f]=bu({core:null,frontend:null}),[r,n]=bu([]),[i,t]=bu(""),[y,c]=bu(!1),[$,A]=bu(null),[j,F]=bu(!1);async function J(){c(!0),t("");try{let[D,X]=await Promise.all([Eu(`${Iu.apiBaseUrl}/performance`,{cache:"no-store"}),Eu(`${Iu.apiBaseUrl}/frontend-performance`,{cache:"no-store"})]);f({core:D,frontend:X});let O=TY(X);n((Y)=>[...Y,{at:new Date().toISOString(),mb:O/1048576}].slice(-80))}catch(D){t(Ou(D,"性能指标加载失败"))}finally{c(!1)}}Tn(()=>{J();let D=setInterval(()=>void J(),5000);return()=>clearInterval(D)},[]);async function Q(){F(!0),t(""),A(null);try{let D=await Eu(`${Iu.apiBaseUrl}/code-queue-load-test`,{method:"POST",body:JSON.stringify({targetMs:1000,timeoutMs:90000,url:Iu.frontendPublicUrl||window.location.origin})});A(D),J()}catch(D){t(Ou(D,"Code Queue Playwright 测量失败"))}finally{F(!1)}}let W=qY(l),L=WY(l),U=wY(l),q=LY(l),N=l.core?.process||{},w=l.frontend?.process||{},G=l.core?.database?.codeQueueStorage||{},Z=Ru(G.total),H=$?.result||{},E=Ru(H.wallMs,NaN),m=Ru(H.networkIdleMs,NaN),S=H.withinTarget===!0,B=j?"running":$===null?"idle":$.measurementOk===!0?S?"passed":"slow":"failed";return _("div",{className:"performance-page","data-testid":"performance-page"},_("div",{className:"performance-hero"},_("div",null,_("p",{className:"panel-eyebrow"},"Unified Performance"),_(rl,{title:"性能面板",loading:y||j}),_("p",null,"按组件统计 HTTP 请求、失败率、P95 延迟,并汇总 backend/frontend 内部操作耗时。")),_("div",{className:"inline-actions"},_("button",{type:"button",className:"ghost-btn",onClick:()=>void Q(),disabled:j,"data-testid":"code-queue-load-test-button"},j?"测试中...":"测试 Code Queue 加载"),_("button",{type:"button",className:"ghost-btn",onClick:()=>void J(),disabled:y,"data-testid":"performance-refresh-button"},y?"刷新中":"刷新"),_(ol,{title:"Performance Snapshot",data:l,onOpen:u,testId:"raw-performance"}))),_(nl,{error:i}),_("div",{className:"performance-top-grid"},_(KY,{points:r}),_("div",{className:"performance-metric-stack"},_(Fl,{label:"backend RSS",value:Of(N.rssBytes),hint:`heap ${Of(N.heapUsedBytes)}`}),_(Fl,{label:"frontend RSS",value:Of(w.rssBytes),hint:`bundle ${Of(l.frontend?.appBundleBytes)}`}),_(Fl,{label:"Codex PG 任务",value:Z||"--",hint:G.ok?"unidesk_code_queue_tasks":"等待表初始化",tone:G.ok?"ok":"warn"}),_(Fl,{label:"请求样本",value:Ru(l.core?.requests?.sampleCount)+Ru(l.frontend?.requests?.sampleCount),hint:"rolling window 3000"}))),_(eu,{title:"Code Queue 加载基准",eyebrow:"Playwright / target <1s",className:"codex-load-test-panel",loading:j,actions:_("div",{className:"panel-actions"},_("button",{type:"button",className:"primary-btn",onClick:()=>void Q(),disabled:j,"data-testid":"code-queue-load-test-panel-button"},j?"正在运行 Playwright...":"手动触发测试"),$?_(ol,{title:"Code Queue Load Test",data:$,onOpen:u,testId:"raw-code-queue-load-test"}):null)},_("div",{className:"codex-load-test-grid","data-testid":"code-queue-load-test-result"},_(Fl,{label:"总耗时",value:j?"运行中":Number.isFinite(E)?qr(E):"--",hint:$===null?"点击按钮启动远端 Playwright":`目标 ${qr(H.targetMs||1000)} / ${H.url||"Code Queue"}`,tone:B==="passed"?"ok":B==="failed"||B==="slow"?"warn":""}),_(Fl,{label:"判定",value:j?"RUNNING":B==="passed"?"PASS <1s":B==="slow"?"SLOW":B==="failed"?"FAILED":"--",hint:$?.measurementOk===!1?String($.error||H.error||"measurement failed").slice(0,120):"导航开始 -> DOMContentLoaded -> data-load-state=complete",tone:B==="passed"?"ok":B==="idle"||B==="running"?"":"fail"}),_(Fl,{label:"Network idle",value:Number.isFinite(m)?qr(m):"--",hint:`DOMContentLoaded ${qr(H.domContentLoadedMs)} / ${H.networkIdleReached===!1?"未在 5s 内空闲":"已空闲"}`,tone:Number.isFinite(m)&&m<=1000?"ok":"warn"}),_(Fl,{label:"组件耗时",value:Number.isFinite(Ru(H.componentLoadMs,NaN))?qr(H.componentLoadMs):"--",hint:`queue ${qr(H.queueMs)} / detail ${qr(H.detailMs)}`,tone:Ru(H.componentLoadMs)>1000?"warn":"ok"}),_(Fl,{label:"Trace 规模",value:Number.isFinite(Ru(H.transcriptRows,NaN))?String(H.transcriptRows):"--",hint:`${H.visibleTaskCount??0} visible tasks / ${H.partial?"preview":"complete"}`})),j?_("div",{className:"performance-empty-line"},"正在通过 main-server Host SSH 启动 Playwright,完成后会显示 wall time、组件耗时和最慢 API。"):null,$&&Array.isArray(H.slowestApi)&&H.slowestApi.length>0?_("div",{className:"table-wrap performance-table-wrap compact codex-load-api-table"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["API","状态","耗时"].map((D)=>_("th",{key:D},D)))),_("tbody",null,H.slowestApi.slice(0,5).map((D,X)=>_("tr",{key:`${D.url}-${X}`},_("td",null,_("code",null,D.url)),_("td",null,D.status),_("td",null,qr(D.durationMs))))))):null),_("div",{className:"performance-grid"},_(eu,{title:"组件汇总",eyebrow:"Requests",loading:y},W.length===0?_(Ql,{title:"暂无请求样本",text:"刷新几次或打开页面后会自动形成组件统计"}):_("div",{className:"table-wrap performance-table-wrap"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["组件","请求数","失败数","失败率","平均延迟","P95"].map((D)=>_("th",{key:D},D)))),_("tbody",null,W.map((D)=>_("tr",{key:D.component},_("td",null,_("code",null,D.component)),_("td",null,D.requestCount),_("td",null,D.failureCount),_("td",null,e0(Ru(D.failureRate)*100)),_("td",null,qr(D.averageLatencyMs)),_("td",null,qr(D.p95LatencyMs)))))))),_(eu,{title:"最近失败请求",eyebrow:"Failures",loading:y},L.length===0?_("div",{className:"performance-empty-line"},"最近没有失败请求"):_("div",{className:"table-wrap performance-table-wrap compact"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["时间","来源","组件","状态","路径"].map((D)=>_("th",{key:D},D)))),_("tbody",null,L.map((D,X)=>_("tr",{key:`${D.at}-${X}`},_("td",null,wu(D.at)),_("td",null,D.source),_("td",null,_("code",null,D.component)),_("td",null,_(Tl,{status:"failed"},D.status)),_("td",null,_("code",null,D.path)))))))),_(eu,{title:"内部操作汇总",eyebrow:"Operations",loading:y},U.length===0?_(Ql,{title:"暂无内部操作样本",text:"API 查询和代理请求会自动记录内部操作耗时"}):_("div",{className:"table-wrap performance-table-wrap"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["服务","操作","次数","平均延迟","P95"].map((D)=>_("th",{key:D},D)))),_("tbody",null,U.map((D)=>_("tr",{key:`${D.service}-${D.operation}`},_("td",null,D.service),_("td",null,_("code",null,D.operation)),_("td",null,D.count),_("td",null,qr(D.averageLatencyMs)),_("td",null,qr(D.p95LatencyMs)))))))),_(eu,{title:"最近慢操作",eyebrow:"Slowest",loading:y},q.length===0?_(Ql,{title:"暂无慢操作",text:"后端会记录最近窗口内耗时最高的内部操作"}):_("div",{className:"table-wrap performance-table-wrap"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["时间","操作","耗时","结果","细节"].map((D)=>_("th",{key:D},D)))),_("tbody",null,q.map((D,X)=>_("tr",{key:`${D.at}-${D.operation}-${X}`},_("td",null,wu(D.at)),_("td",null,_("code",null,D.operation)),_("td",null,qr(D.durationMs)),_("td",null,D.ok?"成功":"失败"),_("td",null,D.detail||"-")))))))))}function zY({provider:u,refresh:l,onRaw:f}){let[r,n]=bu(""),[i,t]=bu(null),[y,c]=bu("");async function $(A){n(A),c("");try{let j=await Eu(`${Iu.apiBaseUrl}/dispatch`,{method:"POST",body:JSON.stringify({providerId:u.providerId,command:"provider.upgrade",payload:{mode:A,source:"frontend-resource-monitor",requestedAt:new Date().toISOString()}})});t({mode:A,...j}),await l()}catch(j){c(Ou(j,"升级命令下发失败"))}finally{n("")}}return _(eu,{title:"Provider Gateway 升级",eyebrow:"Remote Control",loading:Boolean(r)},_("div",{className:"upgrade-control","data-testid":"provider-upgrade-control"},_("p",null,"通过 UniDesk WebSocket 向当前计算节点下发 provider.upgrade;预检只生成升级计划,执行升级会调度节点本地 updater 容器。"),_("div",{className:"upgrade-target-line"},_("span",null,"指定 Provider"),_("code",null,u.providerId),_(Vy,{node:u})),_("div",{className:"upgrade-actions"},_("button",{type:"button",className:"ghost-btn",disabled:Boolean(r),onClick:()=>$("plan"),"data-testid":"upgrade-plan-button"},r==="plan"?"预检中":"预检升级"),_("button",{type:"button",className:"ghost-btn danger",disabled:Boolean(r),onClick:()=>$("schedule"),"data-testid":"upgrade-schedule-button"},r==="schedule"?"调度中":"执行升级")),_(nl,{error:y}),i?_("div",{className:"upgrade-result"},_(Tl,{status:i.status||"queued"},i.status||"queued"),_("span",null,`${i.mode==="schedule"?"执行升级":"预检升级"} 已下发`),_("span",null,`指定版本 ${z7(gL(u))}`),_("code",null,i.taskId||"--"),_(ol,{title:"Provider Upgrade Dispatch",data:i,onOpen:f})):_("span",{className:"muted"},"升级任务结果会进入任务历史;执行升级可能导致 provider 短暂重连。")))}function nT({records:u,onRaw:l,compact:f=!1}){if(u.length===0)return _(Ql,{title:"暂无远程更新记录",text:"该节点还没有 provider.upgrade 任务;执行预检或升级后会在这里形成结构化记录"});return _("div",{className:`upgrade-record-table-wrap table-wrap ${f?"compact":""}`},_("table",{className:"upgrade-record-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"模式"),_("th",null,"任务"),_("th",null,"来源"),_("th",null,"耗时"),_("th",null,"策略"),_("th",null,"Gateway 版本"),_("th",null,"结果记录"),_("th",null,"更新时间"),_("th",null,"操作"))),_("tbody",null,u.map((r)=>_("tr",{key:r.id,"data-testid":`gateway-upgrade-record-${fr(r.id)}`},_("td",null,_(Tl,{status:r.status})),_("td",null,_("span",{className:`mode-chip ${IA(r)}`},IA(r)==="schedule"?"执行升级":"预检")),_("td",null,_("strong",null,"provider.upgrade"),_("code",null,r.id)),_("td",null,eX(r)),_("td",null,_(tT,{task:r})),_("td",null,uY(r)),_("td",null,_("span",{className:"version-chip"},dL(r))),_("td",null,_("span",{className:`upgrade-outcome ${String(r.status||"").toLowerCase()}`},eL(r))),_("td",null,wu(r.updatedAt)),_("td",null,_(ol,{title:`Provider Upgrade Task ${r.id}`,data:r_(r),onOpen:l})))))))}function EY({provider:u,tasks:l,onRaw:f,limit:r=5}){let n=uT(l,u.providerId).slice(0,r);return _(eu,{title:"远程更新记录",eyebrow:u.providerId,actions:_(Vy,{node:u}),className:"provider-upgrade-records-panel"},_("div",{"data-testid":`provider-upgrade-records-${fr(u.providerId)}`},_(nT,{records:n,onRaw:f,compact:!0})))}function OY({nodes:u,tasks:l,onRaw:f}){let r=f_(()=>u.map((i)=>{let t=uT(l,i.providerId);return{node:i,records:t,latest:lY(t),capabilities:sL(i)}}),[u,l]),n=r.reduce((i,t)=>i+t.records.length,0);return _("div",{className:"gateway-page","data-testid":"gateway-version-page"},_(eu,{title:"Provider Gateway 版本",eyebrow:`${u.length} Providers / ${n} 更新记录`},u.length===0?_(Ql,{title:"暂无 Provider 节点",text:"等待 provider-gateway 注册后显示版本号和升级记录"}):_("div",{className:"table-wrap gateway-version-table-wrap"},_("table",{className:"gateway-version-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"Provider"),_("th",null,"Gateway 版本"),_("th",null,"升级策略"),_("th",null,"运维可用性"),_("th",null,"运行时间"),_("th",null,"能力"),_("th",null,"最近远程更新"),_("th",null,"操作"))),_("tbody",null,r.map((i)=>_("tr",{key:i.node.providerId},_("td",null,_(Tl,{status:i.node.status})),_("td",null,_("strong",null,i.node.name),_("code",null,i.node.providerId)),_("td",null,_(Vy,{node:i.node})),_("td",null,l_(i.node)),_("td",null,_(E7,{node:i.node})),_("td",null,pL(i.node)?wu(pL(i.node)):"待新版上报"),_("td",null,_("div",{className:"capability-row"},i.capabilities.length===0?_("span",{className:"muted"},"未声明"):i.capabilities.slice(0,5).map((t)=>_("span",{key:t,className:"data-chip"},t)))),_("td",null,i.latest?_("div",{className:"latest-upgrade-cell"},_(Tl,{status:i.latest.status}),_("span",null,`${IA(i.latest)==="schedule"?"执行升级":"预检"} / ${wu(i.latest.updatedAt)}`),_("small",null,`Gateway ${dL(i.latest)}`),_("small",null,eL(i.latest))):_("span",{className:"muted"},"暂无记录")),_("td",null,_(ol,{title:`Provider ${i.node.providerId}`,data:i.node,onOpen:f})))))))),_(eu,{title:"远程更新记录",eyebrow:"Structured provider.upgrade records"},u.length===0?_(Ql,{title:"暂无记录",text:"没有 provider 节点时不会生成远程更新记录"}):_("div",{className:"gateway-record-grid"},r.map((i)=>_("article",{key:i.node.providerId,className:"gateway-record-card","data-testid":`gateway-records-${fr(i.node.providerId)}`},_("div",{className:"gateway-record-head"},_("div",null,_("strong",null,i.node.name),_("code",null,i.node.providerId)),_(Vy,{node:i.node})),_("div",{className:"gateway-record-meta"},_("span",null,`心跳 ${wu(i.node.lastHeartbeat)}`),_("span",null,`策略 ${l_(i.node)}`),_("span",null,`${i.records.length} 条记录`)),_(nT,{records:i.records.slice(0,8),onRaw:f,compact:!0}))))))}function ZY(u){if(u==="running")return"online";if(u==="paused"||u==="restarting")return"warn";if(u==="exited"||u==="dead")return"offline";return"internal"}function iT(u){return/^[a-f0-9]{48,64}$/i.test(u)}function u_(u){let l=String(u?.name||""),f=String(u?.labels||"");return l==="unidesk_pgdata_10gb"||f.includes("com.docker.compose.volume=unidesk_pgdata_10gb")||l.toLowerCase().includes("pgdata")}function ML(u){let l=String(u?.name||""),f=String(u?.labels||"");if(u_(u))return 0;if(f.includes("com.docker.compose.project=unidesk"))return 1;if(!iT(l))return 2;return 3}function HY(u){return[...u].sort((l,f)=>{let r=ML(l)-ML(f);if(r!==0)return r;return String(l.name||"").localeCompare(String(f.name||""))})}function BY({nodes:u,dockerStatuses:l,onRaw:f}){let[r,n]=bu(""),i=f_(()=>u.map((q)=>{let N=l.find((w)=>w.providerId===q.providerId);return{...q,dockerStatus:N?.dockerStatus||null,dockerUpdatedAt:N?.updatedAt||null}}),[u,l]),t=i.find((q)=>q.providerId===r)||i[0]||null;if(Tn(()=>{if(!r&&i[0])n(i[0].providerId)},[i.length,r]),!t)return _(Ql,{title:"暂无 Docker 节点",text:"等待 provider 上报 Docker daemon 状态"});let y=t.dockerStatus,c=t.providerId==="main-server",$=y?.counts||{},A=y?.daemon||{},j=y?.containers||[],F=y?.images||[],J=HY(y?.volumes||[]),Q=c?J.find(u_):null,W=y?.networks||[],L=j.filter((q)=>q.state==="running"),U=j.filter((q)=>q.state!=="running");return _("div",{className:"docker-page","data-testid":"docker-status-page"},_("div",{className:"docker-node-strip"},i.map((q)=>_("button",{key:q.providerId,type:"button",className:`docker-node-tile ${t.providerId===q.providerId?"active":""}`,onClick:()=>n(q.providerId)},_("span",{className:`pulse ${q.status}`}),_("strong",null,q.name),_("code",null,q.providerId),_("span",null,q.dockerStatus?`Docker ${q.dockerStatus.ok?"ready":"degraded"}`:"等待上报")))),_("div",{className:"docker-layout"},_(eu,{title:"Docker Desktop 视图",eyebrow:t.name,className:"docker-main-panel",actions:y?_(ol,{title:`Docker ${t.providerId}`,data:y,onOpen:f}):null},!y?_(Ql,{title:"Docker 状态未上报",text:"provider-gateway 会在连接后周期性采集 docker info / ps / images / volume / network"}):_("div",null,_("div",{className:"docker-hero"},_("div",null,_("p",{className:"panel-eyebrow"},"Daemon"),_("h3",null,A.name||t.providerId),_("div",{className:"docker-meta"},_("span",null,A.serverVersion?`Engine ${A.serverVersion}`:"Engine --"),_("span",null,A.operatingSystem||"OS --"),_("span",null,A.architecture||"arch --"),_("span",null,`${A.cpus||0} CPU / ${Of(A.memoryBytes)}`))),_(Tl,{status:y.ok?"online":"warn"},y.ok?"Docker Ready":"Docker Degraded")),_("div",{className:"docker-metrics"},_(Fl,{label:"Containers",value:$.containers??j.length,hint:`${$.running??L.length} running / ${$.stopped??U.length} stopped`,tone:"ok"}),_(Fl,{label:"Images",value:$.images??F.length,hint:`${$.daemonImages??$.images??F.length} daemon images`}),_(Fl,{label:"Volumes",value:$.volumes??J.length,hint:c?Q?"database volume visible":"database volume missing":"node local volumes",tone:Q?"ok":""}),_(Fl,{label:"Networks",value:$.networks??W.length,hint:A.driver?`driver ${A.driver}`:"docker networks"})),c?_(VY,{volume:Q,volumeCount:J.length}):null,_("div",{className:"docker-section-head"},_("h3",null,"Containers"),_("span",null,`updated ${wu(t.dockerUpdatedAt||y.collectedAt)}`)),_("div",{className:"docker-container-table table-wrap","data-testid":"docker-container-table"},_("table",null,_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"容器"),_("th",null,"镜像"),_("th",null,"端口"),_("th",null,"运行时间"),_("th",null,"重启策略"),_("th",null,"PID"),_("th",null,"大小"))),_("tbody",null,j.length===0?_("tr",null,_("td",{colSpan:8},"暂无容器")):j.map((q)=>_("tr",{key:`${q.id}-${q.name}`},_("td",null,_(Tl,{status:ZY(q.state)},q.state||"unknown")),_("td",null,_("strong",null,q.name||"--"),_("code",null,q.id||"--")),_("td",null,q.image||"--"),_("td",null,q.ports||_("span",{className:"muted"},"未发布")),_("td",null,q.runningFor||q.status||"--"),_("td",null,q.restartPolicy?_(Tl,{status:q.restartPolicy==="always"?"online":"warn"},q.restartPolicy):"--"),_("td",null,q.pidMode?_("code",null,q.pidMode):"--"),_("td",null,q.size||"--")))))))),_("div",{className:"docker-side-stack"},_(L7,{title:"Images",items:F,render:(q)=>_("article",{key:`${q.id}-${q.repository}`,className:"docker-side-row"},_("strong",null,`${q.repository}:${q.tag}`),_("span",null,q.size||"--"),_("code",null,q.id||"--"))}),_(L7,{title:"Volumes",items:J,limit:J.length,render:(q)=>_("article",{key:q.name,className:`docker-side-row volume-row ${c&&u_(q)?"database-volume":""}`,"data-testid":c&&u_(q)?"database-volume-row":void 0},_("strong",null,q.name),_("span",null,c&&u_(q)?"PostgreSQL":iT(String(q.name||""))?"anonymous":"named"),_("code",null,q.mountpoint||q.driver||q.scope||"--"))}),_(L7,{title:"Networks",items:W,render:(q)=>_("article",{key:q.id||q.name,className:"docker-side-row"},_("strong",null,q.name),_("span",null,q.driver||"--"),_("code",null,q.id||"--"))}))))}function VY({volume:u,volumeCount:l}){return _("section",{className:`docker-volume-focus ${u?"ready":"missing"}`,"data-testid":"database-volume-card"},_("div",{className:"volume-focus-head"},_("span",{className:"panel-eyebrow"},"Database Named Volume"),_(Tl,{status:u?"online":"warn"},u?"FOUND":"MISSING")),u?_("div",{className:"volume-focus-body"},_("strong",null,u.name),_("span",null,"PostgreSQL data volume for unidesk-database"),_("div",{className:"volume-route"},_("code",null,u.mountpoint||"/var/lib/docker/volumes/unidesk_pgdata_10gb/_data"),_("span",null,"->"),_("code",null,"unidesk-database:/var/lib/postgresql/data")),_("div",{className:"docker-meta compact"},_("span",null,`driver ${u.driver||"--"}`),_("span",null,`scope ${u.scope||"--"}`),_("span",null,`${l} volumes reported`))):_("div",{className:"volume-focus-body"},_("strong",null,"unidesk_pgdata_10gb"),_("span",null,"当前 Docker 快照没有发现数据库命名卷;请检查 provider-gateway 的 Docker volume 上报。")))}function L7({title:u,items:l,render:f,limit:r}){let n=l.slice(0,r??12),i=Math.max(0,l.length-n.length);return _(eu,{title:u,eyebrow:`${l.length} items`,className:"docker-side-panel"},l.length===0?_(Ql,{title:`暂无 ${u}`,text:"等待 Docker 状态采集"}):_("div",{className:"docker-side-list"},n.map(f),i>0?_("div",{className:"docker-side-more"},`+ ${i} more`):null))}function mY({microservices:u,onRaw:l,onNavigate:f}){let r=u.filter((n)=>XL(n).public===!1);return _("div",{className:"microservice-page","data-testid":"microservice-catalog-page"},_(eu,{title:"用户服务目录",eyebrow:"Provider Mounted User Services"},_("div",{className:"metric-grid"},_(Fl,{label:"服务总数",value:u.length,hint:"config.json 用户服务登记"}),_(Fl,{label:"私有后端",value:r.length,hint:"不直接暴露公网",tone:"ok"}),_(Fl,{label:"D601 服务",value:u.filter((n)=>n.providerId==="D601").length,hint:"compute-node docker"}),_(Fl,{label:"集成前端",value:u.filter((n)=>n.frontend?.integrated).length,hint:"UniDesk React 页面"}))),_(eu,{title:"服务映射",eyebrow:"Repo Reference + Runtime"},u.length===0?_(Ql,{title:"暂无用户服务",text:"在 config.json 的 microservices 中登记用户服务的 provider、仓库引用和后端映射"}):_("div",{className:"table-wrap"},_("table",{className:"microservice-table"},_("thead",null,_("tr",null,_("th",null,"服务"),_("th",null,"Provider"),_("th",null,"代码引用"),_("th",null,"Docker 引用"),_("th",null,"后端映射"),_("th",null,"开发入口"),_("th",null,"运行态"),_("th",null,"操作"))),_("tbody",null,u.map((n)=>{let i=lT(n),t=fY(n),y=XL(n),c=i.availability||{},$=c.status||(i.providerStatus==="online"?"unknown":"unhealthy");return _("tr",{key:n.id,"data-testid":`microservice-row-${fr(n.id)}`},_("td",null,_("strong",null,n.name),_("code",null,n.id)),_("td",null,_("strong",null,i.providerName||n.providerId),_("code",null,n.providerId)),_("td",null,_("span",null,t.url||"--"),_("code",null,t.commitId||"--")),_("td",null,_("span",null,t.composeFile||"--"),_("code",null,`${t.composeService||"--"} / ${t.containerName||"--"}`)),_("td",null,_(Tl,{status:y.public?"warn":"online"},y.public?"public":"private"),_("code",null,`${y.nodeBindHost||"--"}:${y.nodePort||"--"} -> ${y.proxyMode||"--"}`)),_("td",null,_("span",null,n.development?.sshPassthrough?"SSH 透传":"未配置"),_("code",null,n.development?.worktreePath||"--")),_("td",null,_(Tl,{status:$==="healthy"?"online":$==="unknown"?"warn":"failed"},$),_("span",null,c.reason||i.providerStatus||"unknown"),_(li,{data:i.container,empty:"容器快照未上报"})),_("td",null,_("div",{className:"microservice-actions"},n.id==="findjob"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","findjob"),"data-testid":"open-findjob-button"},"打开"):null,n.id==="pipeline"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","pipeline"),"data-testid":"open-pipeline-button"},"打开"):null,n.id==="todo-note"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","todo-note"),"data-testid":"open-todo-note-button"},"打开"):null,n.id==="met-nonlinear"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","met-nonlinear"),"data-testid":"open-met-nonlinear-button"},"打开"):null,n.id==="claudeqq"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","claudeqq"),"data-testid":"open-claudeqq-button"},"打开"):null,n.id==="baidu-netdisk"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","baidu-netdisk"),"data-testid":"open-baidu-netdisk-button"},"打开"):null,n.id==="oa-event-flow"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","oa-event-flow"),"data-testid":"open-oa-event-flow-button"},"打开"):null,n.id==="k3sctl-adapter"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","k3sctl"),"data-testid":"open-k3sctl-button"},"打开"):null,n.id==="code-queue"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","code-queue"),"data-testid":"open-code-queue-button"},"打开"):null,n.id==="mdtodo"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","mdtodo"),"data-testid":"open-mdtodo-button"},"打开"):null,n.id==="project-manager"?_("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","project-manager"),"data-testid":"open-project-manager-button"},"打开"):null,_(ol,{title:`用户服务 ${n.id}`,data:n,onOpen:l}))))}))))))}function DY({nodes:u,onDispatched:l,onRaw:f}){let r=u.filter((B)=>B.status==="online"),[n,i]=bu(r[0]?.providerId||u[0]?.providerId||""),[t,y]=bu("docker.ps"),[c,$]=bu("frontend"),[A,j]=bu("operator-check"),[F,J]=bu("normal"),[Q,W]=bu(!1),[L,U]=bu(""),[q,N]=bu(!1),[w,G]=bu(null),[Z,H]=bu("");Tn(()=>{if(!n&&(r[0]?.providerId||u[0]?.providerId))i(r[0]?.providerId||u[0].providerId)},[u.length,r.length,n]);function E(){return{source:c,note:A,priority:F}}function m(){U(JSON.stringify(E(),null,2)),W(!0)}async function S(B){B.preventDefault(),N(!0),H("");try{let D=Q?JSON.parse(L||"{}"):E(),X=await Eu(`${Iu.apiBaseUrl}/dispatch`,{method:"POST",body:JSON.stringify({providerId:n,command:t,payload:D})});G(X),await l()}catch(D){H(Ou(D,"下发失败"))}finally{N(!1)}}return _("div",{className:"page-grid dispatch-grid"},_(eu,{title:"下发任务",eyebrow:"Real WebSocket Dispatch"},_("form",{className:"dispatch-form",onSubmit:S},_("label",null,"Provider",_("select",{value:n,onChange:(B)=>i(B.target.value)},u.map((B)=>_("option",{key:B.providerId,value:B.providerId},`${B.name} / ${B.providerId}`)))),_("label",null,"Command",_("select",{value:t,onChange:(B)=>y(B.target.value)},_("option",{value:"docker.ps"},"docker.ps"),_("option",{value:"host.ssh"},"host.ssh"),_("option",{value:"microservice.http"},"microservice.http"),_("option",{value:"echo"},"echo"))),_("label",null,"来源",_("input",{value:c,onChange:(B)=>$(B.target.value)})),_("label",null,"备注",_("input",{value:A,onChange:(B)=>j(B.target.value)})),_("label",null,"优先级",_("select",{value:F,onChange:(B)=>J(B.target.value)},_("option",{value:"normal"},"normal"),_("option",{value:"low"},"low"),_("option",{value:"urgent"},"urgent"))),_("div",{className:"dispatch-actions"},_("button",{type:"button",className:"ghost-btn",onClick:m},"查看原始JSON"),_("button",{type:"submit",disabled:q||!n},q?"下发中":"下发任务")),Q?_("label",{className:"raw-editor-label"},"高级 Payload",_("textarea",{className:"raw-editor",value:L,onChange:(B)=>U(B.target.value)})):null,_(nl,{error:Z,wide:!0}))),_(eu,{title:"下发结果",eyebrow:"Response"},w?_("div",{className:"result-card"},_(Tl,{status:w.status||"queued"},w.status||"queued"),_("dl",null,_("dt",null,"Task ID"),_("dd",null,_("code",null,w.taskId||"--")),_("dt",null,"Provider 在线"),_("dd",null,ut(w.providerOnline))),_(ol,{title:"Dispatch Response",data:w,onOpen:f})):_(Ql,{title:"等待操作",text:"任务响应会以结构化结果卡展示"})))}function RL({task:u,onRaw:l}){return _("article",{className:"compact-row"},_(Tl,{status:u.status}),_("div",null,_("strong",null,u.command),_("code",null,u.id)),_("span",null,my(u)?`已等待 ${K7(u.updatedAt)}`:`耗时 ${dn(vL(u)??0)}`),_(ol,{title:`Task ${u.id}`,data:r_(u),onOpen:l}))}function tT({task:u}){let l=vL(u),f=my(u);return _("div",{className:"task-duration"},_("strong",null,l===null?"--":dn(l)),_("span",null,f?`已运行 / 创建 ${wu(u.createdAt)}`:`创建 ${wu(u.createdAt)}`))}function pY({task:u}){let l=String(u?.status||"").toLowerCase(),f=u?.result,r=f&&typeof f==="object"&&!Array.isArray(f)?f:{},i=["exitCode","code","signal","timeoutMs","previousStatus","mode"].filter((t)=>r[t]!==void 0&&r[t]!==null);if(l==="failed"){let t=kL(u);return _("div",{className:"task-diagnostic failed"},_("b",null,"失败原因"),_("span",{className:"diagnostic-reason"},ut(t)),i.length>0?_("div",{className:"diagnostic-meta"},i.map((y)=>_("span",{key:y,className:"data-chip"},_("b",null,y),_("span",null,ut(r[y]))))):null)}if(my(u))return _("div",{className:"task-diagnostic warn"},_("b",null,"等待终态"),_("span",null,`最后更新 ${K7(u.updatedAt)} 前`));return _("div",{className:"task-diagnostic ok"},_("b",null,"完成摘要"),_(li,{data:f,empty:"无执行输出"}))}function SY({tasks:u,onRaw:l}){let f=u.filter(my);return _("div",{"data-testid":"pending-task-page"},_(eu,{title:"待处理任务",eyebrow:`${f.length} Pending`},f.length===0?_(Ql,{title:"当前无待处理任务",text:"queued / dispatched / running 会在超时后自动转为 failed;历史记录仍可在任务历史中查看"}):_("div",{className:"table-wrap","data-testid":"pending-task-table"},_("table",null,_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"任务"),_("th",null,"Provider"),_("th",null,"已等待"),_("th",null,"载荷摘要"),_("th",null,"操作"))),_("tbody",null,f.map((r)=>_("tr",{key:r.id},_("td",null,_(Tl,{status:r.status})),_("td",null,_("strong",null,r.command),_("code",null,r.id)),_("td",null,_("code",null,r.providerId)),_("td",null,K7(r.updatedAt)),_("td",null,_(li,{data:r.payload})),_("td",null,_(ol,{title:`Pending Task ${r.id}`,data:r_(r),onOpen:l})))))))))}function XY({tasks:u,onRaw:l}){return _("div",{"data-testid":"task-history-page"},_(eu,{title:"任务历史",eyebrow:`${u.length} Tasks`},u.length===0?_(Ql,{title:"暂无任务",text:"下发任务后会在这里看到生命周期"}):_("div",{className:"table-wrap"},_("table",{className:"task-history-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"任务"),_("th",null,"Provider"),_("th",null,"任务耗时"),_("th",null,"载荷摘要"),_("th",null,"诊断信息"),_("th",null,"更新时间"),_("th",null,"操作"))),_("tbody",null,u.map((f)=>_("tr",{key:f.id,"data-testid":`task-row-${fr(f.id)}`},_("td",null,_(Tl,{status:f.status})),_("td",null,_("strong",null,f.command),_("code",null,f.id)),_("td",null,_("code",null,f.providerId)),_("td",null,_(tT,{task:f})),_("td",null,_(li,{data:f.payload})),_("td",null,_(pY,{task:f})),_("td",null,wu(f.updatedAt)),_("td",null,_(ol,{title:`Task ${f.id}`,data:r_(f),onOpen:l})))))))))}function YY({tasks:u,onRaw:l}){let f=u.filter((r)=>["succeeded","failed"].includes(r.status));return _(eu,{title:"执行结果",eyebrow:"Finished Tasks"},f.length===0?_(Ql,{title:"暂无结果",text:"任务完成后展示 provider 返回的结构化摘要"}):_("div",{className:"result-grid"},f.map((r)=>_("article",{key:r.id,className:"result-card"},_("div",{className:"node-card-head"},_("strong",null,r.command),_(Tl,{status:r.status})),_("code",null,r.id),_(li,{data:r.result,empty:"无执行输出"}),_(ol,{title:`Task Result ${r.id}`,data:r_(r),onOpen:l})))))}function PY(u){if(!u||typeof u!=="object")return"--";if(u.type==="interval")return`每 ${dn(Number(u.everySeconds||0))}`;return`每天 ${u.timeOfDay||"03:00"} UTC`}function CY(u){if(!u||typeof u!=="object")return"--";if(u.type==="pgdata_backup")return`PGDATA -> ${u.remoteBaseDir||"/SERVER_DATA/UNIDESK_PG_DATA"}`;if(u.type==="dispatch")return`${u.providerId||"--"} / ${u.command||"--"}`;return String(u.type||"--")}function MY(u){let l=String(u||"").toLowerCase();if(l==="succeeded")return"online";if(l==="failed")return"failed";if(l==="running"||l==="queued")return"warn";return l}function RY(u){let l=Number(u?.durationMs);if(Number.isFinite(l)&&l>=0)return dn(l/1000);let f=Kn(u?.startedAt||u?.createdAt);if(f===null)return"--";let n=Kn(u?.finishedAt)??Date.now();return dn(Math.max(0,(n-f)/1000))}function xL(u){return{id:"unidesk-pgdata-baidu-daily",name:"PGDATA daily Baidu Netdisk backup",description:"Daily PostgreSQL physical base backup uploaded to Baidu Netdisk /SERVER_DATA with monthly rotation.",enabled:!0,timeOfDay:"03:30",actionType:"pgdata_backup",providerId:u[0]?.providerId||"main-server",command:"echo",payloadJson:JSON.stringify({source:"scheduled-task",message:"hello from scheduler"},null,2),remoteBaseDir:"/SERVER_DATA/UNIDESK_PG_DATA",stagingSubdir:"server-data/unidesk-pg-data",timeoutMs:"3600000"}}function xY({schedules:u,scheduleRuns:l,nodes:f,refresh:r,onRaw:n}){let[i,t]=bu(xL(f||[])),[y,c]=bu(!1),[$,A]=bu(""),[j,F]=bu(""),J=[...l||[]].sort((w,G)=>(Kn(G.updatedAt)??0)-(Kn(w.updatedAt)??0));function Q(w,G){t((Z)=>({...Z,[w]:G}))}function W(w){let G=w?.action||{};t({id:w?.id||"",name:w?.name||"",description:w?.description||"",enabled:w?.enabled!==!1,timeOfDay:w?.schedule?.timeOfDay||"03:30",actionType:G.type||"dispatch",providerId:G.providerId||f[0]?.providerId||"main-server",command:G.command||"echo",payloadJson:JSON.stringify(G.payload||{source:"scheduled-task"},null,2),remoteBaseDir:G.remoteBaseDir||"/SERVER_DATA/UNIDESK_PG_DATA",stagingSubdir:G.stagingSubdir||"server-data/unidesk-pg-data",timeoutMs:String(G.timeoutMs||3600000)}),F(`正在编辑 ${w?.id||""}`)}function L(){let w={id:i.id,name:i.name,description:i.description,enabled:i.enabled,concurrencyPolicy:"skip",schedule:{type:"daily",timeOfDay:i.timeOfDay,timezone:"Etc/UTC"}};if(i.actionType==="pgdata_backup")return{...w,action:{type:"pgdata_backup",volumeName:"unidesk_pgdata_10gb",remoteBaseDir:i.remoteBaseDir,stagingSubdir:i.stagingSubdir,timeoutMs:Number(i.timeoutMs)||3600000,cleanupLocal:!0}};return{...w,action:{type:"dispatch",providerId:i.providerId,command:i.command,payload:JSON.parse(i.payloadJson||"{}"),timeoutMs:Number(i.timeoutMs)||600000}}}async function U(w){w.preventDefault(),c(!0),A(""),F("");try{let G=L(),Z=encodeURIComponent(String(G.id));await Eu(`${Iu.apiBaseUrl}/schedules/${Z}`,{method:"PUT",body:JSON.stringify(G)}),F("定时任务已保存"),await r()}catch(G){A(Ou(G,"保存定时任务失败"))}finally{c(!1)}}async function q(w){if(!w?.id)return;c(!0),A(""),F("");try{await Eu(`${Iu.apiBaseUrl}/schedules/${encodeURIComponent(w.id)}`,{method:"DELETE"}),F(`已删除 ${w.id}`),await r()}catch(G){A(Ou(G,"删除定时任务失败"))}finally{c(!1)}}async function N(w){if(!w?.id)return;c(!0),A(""),F("");try{let G=await Eu(`${Iu.apiBaseUrl}/schedules/${encodeURIComponent(w.id)}/run`,{method:"POST",body:"{}"});F(`已触发 ${w.id} / ${G?.run?.id||"run"}`),await r()}catch(G){A(Ou(G,"触发定时任务失败"))}finally{c(!1)}}return _("div",{className:"page-grid scheduled-task-page","data-testid":"scheduled-task-page"},_(eu,{title:"定时任务",eyebrow:`${(u||[]).length} Schedules`},(u||[]).length===0?_(Ql,{title:"暂无定时任务",text:"创建 daily / dispatch / PGDATA backup 任务后会在这里展示下一次执行时间和最近结果"}):_("div",{className:"schedule-card-grid"},(u||[]).map((w)=>_("article",{key:w.id,className:"schedule-card","data-testid":`schedule-row-${fr(w.id)}`},_("div",{className:"node-card-head"},_("strong",null,w.name||w.id),_(Tl,{status:w.enabled?"online":"warn"},w.enabled?"enabled":"disabled")),_("code",null,w.id),_("dl",null,_("dt",null,"计划"),_("dd",null,PY(w.schedule)),_("dt",null,"动作"),_("dd",null,CY(w.action)),_("dt",null,"下次执行"),_("dd",null,wu(w.nextRunAt)),_("dt",null,"最近执行"),_("dd",null,w.lastRunAt?`${wu(w.lastRunAt)} / ${w.lastRunId||"--"}`:"--")),_("div",{className:"dispatch-actions"},_("button",{type:"button",className:"ghost-btn",disabled:y,onClick:()=>W(w)},"编辑"),_("button",{type:"button",className:"ghost-btn",disabled:y,onClick:()=>N(w),"data-testid":`schedule-run-${fr(w.id)}`},"手动触发"),_("button",{type:"button",className:"ghost-btn danger",disabled:y,onClick:()=>q(w)},"删除"),_(ol,{title:`Schedule ${w.id}`,data:w,onOpen:n})))))),_(eu,{title:i.id?"配置定时任务":"新建定时任务",eyebrow:"CRUD"},_("form",{className:"dispatch-form schedule-form",onSubmit:U},_("label",null,"ID",_("input",{value:i.id,onChange:(w)=>Q("id",w.target.value)})),_("label",null,"名称",_("input",{value:i.name,onChange:(w)=>Q("name",w.target.value)})),_("label",null,"每日执行时间 UTC",_("input",{value:i.timeOfDay,placeholder:"03:30",onChange:(w)=>Q("timeOfDay",w.target.value)})),_("label",null,"启用",_("select",{value:i.enabled?"true":"false",onChange:(w)=>Q("enabled",w.target.value==="true")},_("option",{value:"true"},"enabled"),_("option",{value:"false"},"disabled"))),_("label",null,"动作类型",_("select",{value:i.actionType,onChange:(w)=>Q("actionType",w.target.value)},_("option",{value:"pgdata_backup"},"PGDATA 备份到百度网盘"),_("option",{value:"dispatch"},"Provider Dispatch"))),i.actionType==="pgdata_backup"?[_("label",{key:"remote"},"网盘根目录",_("input",{value:i.remoteBaseDir,onChange:(w)=>Q("remoteBaseDir",w.target.value)})),_("label",{key:"staging"},"本地 staging 子目录",_("input",{value:i.stagingSubdir,onChange:(w)=>Q("stagingSubdir",w.target.value)}))]:[_("label",{key:"provider"},"Provider",_("select",{value:i.providerId,onChange:(w)=>Q("providerId",w.target.value)},(f||[]).map((w)=>_("option",{key:w.providerId,value:w.providerId},`${w.name} / ${w.providerId}`)))),_("label",{key:"command"},"Command",_("select",{value:i.command,onChange:(w)=>Q("command",w.target.value)},_("option",{value:"echo"},"echo"),_("option",{value:"docker.ps"},"docker.ps"),_("option",{value:"host.ssh"},"host.ssh"),_("option",{value:"microservice.http"},"microservice.http"))),_("label",{key:"payload",className:"raw-editor-label"},"Payload JSON",_("textarea",{className:"raw-editor",value:i.payloadJson,onChange:(w)=>Q("payloadJson",w.target.value)}))],_("label",null,"超时 ms",_("input",{value:i.timeoutMs,onChange:(w)=>Q("timeoutMs",w.target.value)})),_("label",{className:"raw-editor-label"},"描述",_("textarea",{className:"raw-editor compact",value:i.description,onChange:(w)=>Q("description",w.target.value)})),_("div",{className:"dispatch-actions"},_("button",{type:"button",className:"ghost-btn",disabled:y,onClick:()=>t(xL(f||[]))},"重置"),_("button",{type:"submit",disabled:y||!i.id},y?"保存中":"保存任务")),j?_("p",{className:"muted paragraph"},j):null,_(nl,{error:$,wide:!0}))),_(eu,{title:"历史执行记录",eyebrow:`${J.length} Runs`},J.length===0?_(Ql,{title:"暂无执行记录",text:"定时触发或手动触发后会生成 run history"}):_("div",{className:"table-wrap"},_("table",{className:"task-history-table schedule-run-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"任务"),_("th",null,"触发"),_("th",null,"耗时"),_("th",null,"结果摘要"),_("th",null,"更新时间"),_("th",null,"操作"))),_("tbody",null,J.map((w)=>_("tr",{key:w.id,"data-testid":`schedule-run-row-${fr(w.id)}`},_("td",null,_(Tl,{status:MY(w.status)},w.status)),_("td",null,_("strong",null,w.scheduleId),_("code",null,w.id),w.taskId?_("code",null,w.taskId):null),_("td",null,w.trigger||"--"),_("td",null,RY(w)),_("td",null,_(li,{data:w.result||w.error,empty:"无结果"})),_("td",null,wu(w.updatedAt)),_("td",null,_(ol,{title:`Schedule Run ${w.id}`,data:w,onOpen:n})))))))))}function hY({data:u}){let l=u.overview||{};return _("div",{className:"page-grid topology-grid"},_(eu,{title:"公开入口",eyebrow:"Public"},_("div",{className:"endpoint-list"},_("article",null,_("b",null,"Frontend"),_("span",null,Iu.frontendPublicUrl||window.location.origin),_(Tl,{status:"online"},"public")),_("article",null,_("b",null,"Provider Ingress"),_("span",null,Iu.providerIngressPublicUrl||"ws://public/ws/provider"),_(Tl,{status:"online"},"public")))),_(eu,{title:"内部服务",eyebrow:"Docker Network Only"},_("div",{className:"endpoint-list"},_("article",null,_("b",null,"backend-core API"),_("span",null,"http://backend-core:8080"),_(Tl,{status:"internal"},"internal")),_("article",null,_("b",null,"database"),_("span",null,"postgres://database:5432/unidesk"),_(Tl,{status:"internal"},"internal")))),_(eu,{title:"运行态",eyebrow:"Runtime"},_("div",{className:"metric-grid"},_(Fl,{label:"DB Ready",value:l.dbReady?"YES":"NO",hint:"internal health"}),_(Fl,{label:"Online Nodes",value:l.onlineNodeCount??0,hint:"provider-gateway self-link"}))))}function bY({session:u}){return _(eu,{title:"认证策略",eyebrow:"Frontend Login"},_("div",{className:"policy-grid"},_("article",null,_("span",null,"默认账号"),_("strong",null,Iu.authUsername||"admin")),_("article",null,_("span",null,"当前会话"),_("strong",null,u?.user?.username||"--")),_("article",null,_("span",null,"Session TTL"),_("strong",null,`${Iu.sessionTtlSeconds||0}s`)),_("article",null,_("span",null,"API 访问"),_("strong",null,"同源 Cookie 保护"))),_("p",{className:"muted paragraph"},"浏览器只访问 frontend 同源接口;frontend 容器使用 Docker 内网代理 backend-core API。"))}function vY(){return _(eu,{title:"安全边界",eyebrow:"Exposure Rule"},_("div",{className:"security-board"},_("article",{className:"allow"},_("b",null,"允许公网"),_("span",null,"frontend 登录入口"),_("span",null,"provider ingress WebSocket/health")),_("article",{className:"deny"},_("b",null,"禁止公网"),_("span",null,"backend-core REST API"),_("span",null,"PostgreSQL database")),_("article",null,_("b",null,"数据库卷"),_("span",null,"named volume unidesk_pgdata_10gb"),_("span",null,"CLI stop/start 不删除数据卷"))))}function kY({activeModule:u,activeTab:l,data:f,session:r,refresh:n,onRaw:i,onNavigate:t}){if(u==="ops"&&l==="status")return _(_Y,{data:f,onRaw:i,onNavigate:t});if(u==="ops"&&l==="performance")return _(GY,{onRaw:i});if(u==="ops"&&l==="events")return _(AY,{events:f.events,onRaw:i});if(u==="ops"&&l==="logs")return _(jY,{logs:f.logs,onRaw:i});if(u==="nodes"&&l==="list")return _(FY,{nodes:f.nodes,onRaw:i});if(u==="nodes"&&l==="monitor")return _(QY,{nodes:f.nodes,systemStatuses:f.systemStatuses,tasks:f.tasks,onRaw:i,refresh:n});if(u==="nodes"&&l==="docker")return _(BY,{nodes:f.nodes,dockerStatuses:f.dockerStatuses,onRaw:i});if(u==="nodes"&&l==="gateway")return _(OY,{nodes:f.nodes,tasks:f.tasks,onRaw:i});if(u==="nodes"&&l==="labels")return _(UY,{nodes:f.nodes});if(u==="nodes"&&l==="heartbeats")return _(JY,{nodes:f.nodes});if(u==="tasks"&&l==="dispatch")return _(DY,{nodes:f.nodes,onDispatched:n,onRaw:i});if(u==="tasks"&&l==="scheduled")return _(xY,{schedules:f.schedules,scheduleRuns:f.scheduleRuns,nodes:f.nodes,refresh:n,onRaw:i});if(u==="tasks"&&l==="pending")return _(SY,{tasks:f.pendingTasks,onRaw:i});if(u==="tasks"&&l==="history")return _(XY,{tasks:f.tasks,onRaw:i});if(u==="tasks"&&l==="results")return _(YY,{tasks:f.tasks,onRaw:i});if(u==="apps"&&l==="catalog")return _(mY,{microservices:f.microservices,onRaw:i,onNavigate:t});if(u==="apps"&&l==="todo-note")return _(GL,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="findjob")return _(FN,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="pipeline")return _(QL,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="met-nonlinear")return _(qN,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="claudeqq")return _(MJ,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="baidu-netdisk")return _(YJ,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="filebrowser")return _(jN,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="oa-event-flow")return _(HN,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="k3sctl")return _(BL,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl,onNavigate:t});if(u==="apps"&&l==="code-queue")return _(tN,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl,initialTasksData:vX});if(u==="apps"&&l==="mdtodo")return _(TN,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="apps"&&l==="project-manager")return _(wL,{microservices:f.microservices,onRaw:i,apiBaseUrl:Iu.apiBaseUrl});if(u==="config"&&l==="topology")return _(hY,{data:f});if(u==="config"&&l==="auth")return _(bY,{session:r});if(u==="config"&&l==="security")return _(vY);return _(Ql,{title:"未找到页面",text:"请选择左侧主模块和顶部子功能标签"})}function IY({session:u,onLogout:l}){let f=B2(pr,window.location.pathname),[r,n]=bu(f.moduleId),[i,t]=bu({...yc,[f.moduleId]:f.tabId}),[y,c]=bu({overview:null,nodes:[],systemStatuses:[],dockerStatuses:[],microservices:[],events:[],tasks:[],pendingTasks:[],schedules:[],scheduleRuns:[],logs:[]}),[$,A]=bu({ok:!1,text:"连接中"}),[j,F]=bu(null),[J,Q]=bu(new Date),[W,L]=bu(null),[U,q]=bu(!1),[N,w]=bu(!1),G=ui.default.useRef(!1),Z=pr.moduleById[r]||pr.modules[0],H=i[r]||yc[r]||Z.tabs[0].id,E=Array.isArray(y.microservices)?y.microservices:[],m=E.length===0&&r==="apps"&&H==="code-queue"?[kX]:E,S=m===E?y:{...y,microservices:m},B=r==="apps"?m.find((d)=>String(d?.id||"")===(H==="k3sctl"?"k3sctl-adapter":H)):null,D=B?lT(B):{},X=Z.tabs.find((d)=>d.id===H)?.label||H,O=B?[{key:"microservice",label:"用户服务",value:`${X} ${D.providerStatus==="online"?"在线":D.providerStatus||"未知"}`,tone:D.providerStatus==="online"?"ok":"warn",testId:"active-microservice-status"}]:[];async function Y(){if(G.current)return;G.current=!0,w(!0);try{let d=[],s=(Fu,zu)=>{d.push([Fu,Eu(zu)])},h=r==="ops"&&H==="status",lu=h||r==="config"&&H==="topology",cu=h||r==="nodes"||r==="tasks"&&(H==="dispatch"||H==="scheduled"),_u=r==="apps"&&H!=="code-queue";if(lu)s("overview",`${Iu.apiBaseUrl}/overview`);if(cu)s("nodes",`${Iu.apiBaseUrl}/nodes`);if(r==="nodes"&&H==="monitor")s("systemStatuses",`${Iu.apiBaseUrl}/nodes/system-status?limit=60`),s("tasks",`${Iu.apiBaseUrl}/tasks?limit=120&summary=1`);else if(r==="nodes"&&H==="docker")s("dockerStatuses",`${Iu.apiBaseUrl}/nodes/docker-status`);else if(r==="nodes"&&H==="gateway")s("tasks",`${Iu.apiBaseUrl}/tasks?limit=300&summary=1`);else if(r==="tasks"&&H==="scheduled")s("schedules",`${Iu.apiBaseUrl}/schedules?limit=100`),s("scheduleRuns",`${Iu.apiBaseUrl}/schedules/runs?limit=100`);else if(r==="tasks"&&H==="pending")s("pendingTasks",`${Iu.apiBaseUrl}/tasks?status=pending&limit=100&summary=1`);else if(r==="tasks"&&(H==="history"||H==="results"))s("tasks",`${Iu.apiBaseUrl}/tasks?limit=300&summary=1`);else if(h)s("tasks",`${Iu.apiBaseUrl}/tasks?limit=8&lite=1`),s("pendingTasks",`${Iu.apiBaseUrl}/tasks?status=pending&limit=20&lite=1`);if(_u)s("microservices",`${Iu.apiBaseUrl}/microservices`);if(r==="ops"&&H==="events")s("events",`${Iu.apiBaseUrl}/events?limit=100`);if(r==="ops"&&H==="logs")s("logs","/logs?limit=100");await Promise.all(d.map(async([Fu,zu])=>{let Wu=await zu,C={};if(Fu==="overview")C.overview=Wu;if(Fu==="nodes")C.nodes=Wu.nodes||[];if(Fu==="systemStatuses")C.systemStatuses=Wu.systemStatuses||[];if(Fu==="dockerStatuses")C.dockerStatuses=Wu.dockerStatuses||[];if(Fu==="microservices")C.microservices=Wu.microservices||[];if(Fu==="events")C.events=Wu.events||[];if(Fu==="tasks")C.tasks=Wu.tasks||[];if(Fu==="pendingTasks")C.pendingTasks=Wu.tasks||[];if(Fu==="schedules")C.schedules=Wu.schedules||[];if(Fu==="scheduleRuns")C.scheduleRuns=Wu.runs||[];if(Fu==="logs")C.logs=Wu.logs||[];c((e)=>({...e,...C}))})),A({ok:!0,text:"核心在线"}),F(new Date)}catch(d){if(A({ok:!1,text:Ou(d,"连接失败")}),d.status===401)l(!1)}finally{G.current=!1,w(!1)}}Tn(()=>{let d=()=>{if(!DL())return;Y()};d();let s=setInterval(d,IX(r,H)),h=()=>{if(DL())d()};return document.addEventListener("visibilitychange",h),()=>{clearInterval(s),document.removeEventListener("visibilitychange",h)}},[r,H]),Tn(()=>{let d=setInterval(()=>Q(new Date),1000);return()=>clearInterval(d)},[]),Tn(()=>{let d=EN(pr,window.location.pathname);if(d&&window.location.pathname!==d)window.history.replaceState(null,"",d)},[]),Tn(()=>{let d=()=>{let s=B2(pr,window.location.pathname);n(s.moduleId),t((h)=>({...h,[s.moduleId]:s.tabId})),L(null)};return window.addEventListener("popstate",d),()=>window.removeEventListener("popstate",d)},[]),Tn(()=>{window.scrollTo({top:0,left:0,behavior:"auto"})},[r,H]);function p(d,s,h="push"){let lu=pr.moduleById[d]?d:pr.fallbackTarget.moduleId,cu=pr.moduleById[lu]?.tabs.some((Fu)=>Fu.id===s)?s:yc[lu]||pr.moduleById[lu]?.tabs[0]?.id||pr.fallbackTarget.tabId;n(lu),t((Fu)=>({...Fu,[lu]:cu}));let _u=w3(pr,lu,cu);if(window.location.pathname!==_u){let Fu=h==="replace"?"replaceState":"pushState";window.history[Fu](null,"",_u)}}function v(d,s){L({title:d,data:s})}let[z,P]=bu(!1),{unreadCount:k,notifications:I}=Xf(),b=I.length>0?I[I.length-1]:null;return _("div",{className:`shell ${U?"rail-collapsed":""}`,"data-testid":"app-shell"},_(yY,{activeModule:r,activeTabs:i,onNavigate:p,collapsed:U,onToggle:()=>q((d)=>!d)}),_("main",{className:"workspace"},_(iY,{connection:$,lastRefresh:j,onRefresh:Y,onLogout:()=>l(!0),session:u,clock:J,activeStatusItems:O,onNotificationToggle:()=>P((d)=>!d),unreadCount:k}),_(cY,{module:Z,activeTab:H,onNavigate:p}),_(T7.Provider,{value:N},_(kY,{activeModule:r,activeTab:H,data:S,session:u,refresh:Y,onRaw:v,onNavigate:p}))),_(rY,{raw:W,onClose:()=>L(null)}),b&&_(mL,{key:b.id,notification:b}),z&&_(VL,{onClose:()=>P(!1)}))}function gY(){let[u,l]=bu(!0),[f,r]=bu(null);async function n(){l(!0);try{let t=await Eu("/api/session");r(t.authenticated?t:null)}catch{r(null)}finally{l(!1)}}async function i(t){if(t)try{await Eu("/logout",{method:"POST"})}catch{}r(null)}if(Tn(()=>{n()},[]),u)return _("main",{className:"loading-screen"},_("div",{className:"brand-mark"},"UD"),_("span",null,"加载会话"));if(!f)return _(nY,{onLogin:r});return _(XJ,null,_(IY,{session:f,onLogout:i}))}var yT=document.getElementById("root");if(yT===null)throw Error("root element not found");hL.createRoot(yT).render(_(gY));})(); + <rect x="24" y="114" width="128" height="${c}" fill="rgba(215,161,58,0.055)" stroke="rgba(215,161,58,0.2)"/> + ${V} + ${Y} + ${B} + <g transform="translate(152 114)">${X}</g> + ${m} + ${S} + </svg>`,width:W,height:L}}function kA(l,u){let r=URL.createObjectURL(l),f=document.createElement("a");f.href=r,f.download=u,f.click(),setTimeout(()=>URL.revokeObjectURL(r),1000)}async function zL(l,u){let r=KL(u,"pipeline"),{svg:f,width:n,height:i}=NX(l,u),t=new Blob([f],{type:"image/svg+xml;charset=utf-8"}),y=URL.createObjectURL(t);try{let c=new Image;await new Promise((F,U)=>{c.onload=()=>F(),c.onerror=()=>U(Error("svg image load failed")),c.src=y});let $=document.createElement("canvas");$.width=n,$.height=i;let A=$.getContext("2d");if(!A)throw Error("canvas unavailable");A.drawImage(c,0,0);let j=await new Promise((F)=>$.toBlob(F,"image/png"));if(!j)throw Error("png export failed");kA(j,`${r}.png`)}catch{kA(t,`${r}.svg`)}finally{URL.revokeObjectURL(y)}}async function LX(l){let u=KL(String(l?.title||"pipeline-gantt"),"pipeline-gantt"),{svg:r,width:f,height:n}=WX(l),i=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(i);try{let y=new Image;await new Promise((j,F)=>{y.onload=()=>j(),y.onerror=()=>F(Error("gantt svg image load failed")),y.src=t});let c=document.createElement("canvas");c.width=f,c.height=n;let $=c.getContext("2d");if(!$)throw Error("canvas unavailable");$.drawImage(y,0,0);let A=await new Promise((j)=>c.toBlob(j,"image/png"));if(!A)throw Error("gantt png export failed");kA(A,`${u}.png`)}catch{kA(i,`${u}.svg`)}finally{URL.revokeObjectURL(t)}}async function GX(l){for(let u of l){if(u.flow.nodes.length===0)continue;await zL(u.flow,u.title),await new Promise((r)=>setTimeout(r,750))}}function _L(l,u){return l.find((r)=>String(r?.pipelineId||"")===u)||null}function $L(l){return al(l?.startedAt)??al(l?.artifact?.startedAt)??al(l?.request?.createdAt)??al(l?.updatedAt)??0}function TX(l,u){return l.filter((r)=>String(r?.pipelineId||"")===u).slice().sort((r,f)=>$L(r)-$L(f)||String(r?.runId||"").localeCompare(String(f?.runId||"")))}function Jj(l,u){let r=String(u?.runId||""),f=l.findIndex((t)=>String(t?.runId||"")===r),n=f>=0?f+1:l.length,i=String(u?.status||"--");return`Epoch ${n} / ${r||"--"} / ${i}`}function Sf(l){return String(l?.procedureRunId||l?.runId||"")}function oA(l,u){let r=String(l?.nodeId||l?.request?.nodeId||"");if(r)return r;let f=Sf(l),n=`${u}__`;if(f.startsWith(n))return f.slice(n.length).replace(/__\d+$/u,"");return""}function PA(l,u){let r=Yl(l?.artifact)?l.artifact:{},f=Yl(l?.request)?l.request:{};return t_(l?.startedAt,r.startedAt,f.createdAt,f.startedAt,l?.createdAt,l?.updatedAt,u?.startedAt,u?.request?.createdAt)}function CA(l,u){let r=String(l?.status?.status||l?.artifact?.status||l?.status||"").toLowerCase(),f=Yl(l?.artifact)?l.artifact:{},n=wj(r);return t_(l?.finishedAt,f.finishedAt,l?.completedAt,n?l?.updatedAt:void 0,n?f.updatedAt:void 0,n?u?.updatedAt:void 0)}function EL(l,u,r=Date.now()){let f=String(l?.runId||""),n=new Set(u.map((i)=>String(i?.id||"")).filter(Boolean));return Sl(l?.procedureRuns).flatMap((i)=>{let t=oA(i,f);if(!t)return[];let y=String(i?.status?.status||i?.artifact?.status||i?.status||"unknown").toLowerCase(),c=PA(i,l),$=al(c);if($===null)return[];let A=CA(i,l),j=al(A)??(wj(y)?al(i?.updatedAt)??$+1000:r),F=Math.max($+1000,j);return[{nodeId:t,knownNode:n.has(t),procedureRunId:Sf(i),status:y,startMs:$,endMs:F,startedAt:f_($),finishedAt:f_(F),durationMs:F-$,runId:f,raw:i}]}).sort((i,t)=>i.startMs-t.startMs||i.endMs-t.endMs||i.nodeId.localeCompare(t.nodeId))}function mX(l,u,r=[]){let f=u.map((A)=>Number(A.startMs)).filter(Number.isFinite),n=u.map((A)=>Number(A.endMs)).filter(Number.isFinite);for(let A of r){let j=Xu(A?.eventMs??A?.ms);if(j!==null)f.push(j),n.push(j)}let i=al(l?.startedAt)??al(l?.artifact?.startedAt)??al(l?.request?.createdAt),t=al(l?.finishedAt)??al(l?.artifact?.finishedAt)??al(l?.updatedAt);if(i!==null)f.push(i);if(t!==null)n.push(t);let y=Date.now(),c=f.length>0?Math.min(...f):y-60000,$=Math.max(c+60000,n.length>0?Math.max(...n):y);return{startMs:c,endMs:$,durationMs:$-c}}var MA=12,OL=20,Uj=100,KX=!1;function r0(l){let u=Number(l);if(!Number.isFinite(u))return 0;return Math.max(0,Math.min(100,Math.round(u*100)/100))}function zX(l){let u=Math.max(MA,Number(l||MA)),r=Math.log(u/MA)/Math.log(OL);return r0(r*100)}var i_=zX(Uj);function mj(l){let u=r0(l)/100,r=MA*Math.pow(OL,u),f=u<0.24?"全局":u<0.64?"均衡":"细节";return{value:r0(u*100),pxPerMinute:r,label:f}}function yj(l){let u=Math.round(Number(l));return Math.abs(u-Uj)<=1?Uj:u}function EX(l,u=i_){let r=Math.max(1,Number(l.durationMs||0)/60000),f=mj(u);return Math.round(Math.max(360,Math.min(7200,r*Number(f.pxPerMinute||48))))}function OX(l,u=7){let r=Math.max(1,Number(l.endMs||0)-Number(l.startMs||0));return Array.from({length:u},(f,n)=>{let i=u===1?0:n/(u-1);return{ms:Number(l.startMs)+r*i,percent:i*100}})}function ZX(l,u){let r=Math.max(1,Number(u.endMs)-Number(u.startMs));return Math.max(0,Math.min(100,(l-Number(u.startMs))/r*100))}function Xu(l){let u=Number(l);return Number.isFinite(u)?u:null}function Kj(l){return JL(l?.status)&&!wj(l?.status)}function ZL(l,u,r,f){let n=Math.max(1,r-u),i=Math.max(0,Math.min(1,(l-u)/n));return Number((i*f).toFixed(3))}function AL(l,u){if(!u)return null;let r=Xu(u?.startMs),f=Xu(u?.endMs),n=Xu(u?.chartHeight);if(r===null||f===null||n===null)return null;return ZL(l,r,f,n)}function pL(l,u){let r=Xu(l?.rawStartMs??l?.startMs)??Xu(l?.startMs)??u,f=Xu(l?.endMs)??r+1000;if(!Kj(l))return Math.max(r+1000,f);return Math.max(r+1000,f,u)}function pX(l,u,r,f){let n=Xu(l?.startMs)??f-60000,i=Xu(l?.endMs)??f,t=r.reduce((N,W)=>Math.max(N,pL(W,f)),i),y=Math.max(n+60000,i,t),c=Math.max(1,y-n),$={startMs:n,endMs:y,durationMs:c},A=EX($,u),j=mj(u),F=Math.max(5,Math.min(18,Math.round(A/150))),U=OX($,F).map((N)=>{let W=Number(N.ms),L=ZL(W,n,y,A);return{...N,y:L,timestamp:f_(W),offsetMs:W-n}});return{source:"frontend-y",startMs:n,endMs:y,durationMs:c,chartHeight:A,scale:r0(u),normalizedScale:Number((r0(u)/100).toFixed(3)),pxPerMinute:Number(Number(j.pxPerMinute||0).toFixed(3)),ticks:U}}function HX(l,u,r){if(!Kj(l))return l;let f=Xu(l?.rawStartMs??l?.startMs)??Xu(l?.startMs)??r,n=pL(l,r),i=AL(f,u),t=AL(n,u),y=Xu(i??l?.y1??l?.startY)??0,c=Xu(t??l?.y2??l?.endY)??y+10,$=Math.max(24,c-y);return{...l,live:!0,startMs:f,endMs:n,durationMs:Math.max(1000,n-f),finishedAt:f_(n),y1:y,y2:c,startY:y,endY:c,height:$}}function zj(l,u,r){return ZX(l,u)/100*r}function Xy(l){return Boolean(l&&String(l?.source||"")!=="frontend-y")}function HL(l,u,r,f,n){if(Xy(f))for(let t of n){let y=Xu(l?.[t]);if(y!==null)return y}let i=Xu(l?.ms??l?.eventMs??l?.startMs);return zj(i??Number(u.startMs),u,r)}function gA(l,u,r,f){return HL(l,u,r,f,["y1","startY"])}function Nj(l,u,r,f){if(Xy(f)){let i=Xu(l?.y2??l?.endY);if(i!==null)return i}let n=Xu(l?.endMs)??Number(u.endMs);return zj(n,u,r)}function BL(l,u,r,f){if(Xy(f)){let i=Xu(l?.height);if(i!==null)return Math.max(1,i)}let n=l?.live?24:10;return Math.max(n,Nj(l,u,r,f)-gA(l,u,r,f))}function wf(l,u,r,f){return HL(l,u,r,f,["y","timeAxisY"])}function DL(l,u,r,f){if(Xy(f)||String(f?.source||"")==="frontend-y"){let t=Xu(l?.y);if(t!==null)return t}let n=Xu(l?.percent);if(n!==null)return n/100*r;let i=Xu(l?.ms)??Number(u.startMs);return zj(i,u,r)}function BX(l){let u=String(l?.promptEvent||l?.raw?.promptEvent||l?.event||"").toLowerCase();if(!["node-long-running-observation","node-finished"].includes(u))return"";let r=String(l?.sourceNodeId||l?.raw?.sourceNodeId||l?.raw?.detail?.nodeId||""),f=String(l?.nodeId||l?.targetNodeId||"");return r&&r!==f?r:""}function DX(l,u){let r=new Set(u.map((n)=>[String(n.sourceNodeId||""),String(n.targetNodeId||""),String(n.targetMarkerId||""),String(n.action||"")].join(":"))),f=[...u];for(let n of l){let i=BX(n),t=String(n?.nodeId||""),y=String(n?.id||"");if(!i||!t||!y)continue;let c=[i,t,y,"observe"].join(":");if(r.has(c))continue;r.add(c),f.push({id:`observation-arrow:${y}:${i}:${t}`,commandId:String(n?.commandId||n?.eventId||y),sourceNodeId:i,targetNodeId:t,sourceMarkerId:"",targetMarkerId:y,sourceKind:"monitor",action:"observe",status:"observation"})}return{markers:l,arrows:f}}function VX(l){let u=un(l),r=String(l?.promptEvent||"");if(u==="initial-prompt-delivered")return"initial";if(r==="node-finished"||r==="node-long-running-observation"||r.startsWith("monitor-"))return"monitor";if(u==="monitor-prompt-delivered"||String(l?.sourceKind||"").toLowerCase()==="monitor")return"monitor";return"append"}function SX(l){return Sl(l?.tags||l?.raw?.tags).map((u)=>String(u||"")).filter(Boolean)}function XX(l){let u=un(l),r=String(l?.promptEvent||"");if(u==="initial-prompt-delivered")return"初始 prompt";if(r==="node-long-running-observation")return"长任务观察";if(r==="node-finished")return SX(l).includes("monitor.audit")?"节点完成 / OA 审核":"节点完成";if(r==="monitor-interval")return"Monitor observation";if(r==="monitor-start")return"Monitor start";if(r==="monitor-stop")return"Monitor stop";if(u==="monitor-prompt-delivered")return"Monitor prompt";if(u==="append-prompt-queued")return"追加 prompt 已排队";return"追加 prompt"}function jL(l){let u=un(l);if(u==="control-command-applied")return 3;if(u==="control-command-ignored")return 2;if(u==="control-command-queued")return 1;return 0}function YX(l,u){let r=String(l?.commandId||"");if(r)return`command:${r}`;return["control-event",Dy(l)||t_(l?.createdAt,l?.timestamp)||`index-${u}`,String(l?.sourceKind||""),String(l?.sourceNodeId||""),String(l?.targetNodeId||""),rt(l)].join(":")}function PX(l){return jj([l?.targetNodeId,...Sl(l?.resetNodeIds)])}function CX(l,u){let r=u_(l),f=un(l),n=String(l?.targetNodeId||""),i=Boolean(n)&&u!==n;if(f==="control-command-applied")return i?`${r} 波及`:`${r} 生效`;if(f==="control-command-ignored")return`${r} 忽略`;if(f==="control-command-queued")return`${r} 已发起`;return i?`${r} 波及`:r}function MX(l){if(un(l)==="control-command-ignored")return"ignored";let r=rt(l);if(r==="restart"||r==="redo")return"restart";if(r==="modify")return"modify";if(r==="approve")return"approve";if(r==="guide")return"guide";return"pending"}function hX(l){let u=String(l?.sourceKind||"").toLowerCase();if(u==="monitor")return"monitor";if(u==="webui")return"webui";if(u==="cli")return"cli";return"system"}function RX(l,u,r,f){let n=l.filter(($)=>String($.nodeId||"")===u).sort(($,A)=>Number($.startMs)-Number(A.startMs)),i=n.find(($)=>r>=Number($.startMs)-1000&&r<=Number($.endMs)+1000);if(i)return{ms:r,onInterval:!0,snapReason:"inside-interval",procedureRunId:String(i.procedureRunId||"")};let t=rt(f),y=n.slice().reverse().find(($)=>Number($.endMs)<=r+1000);if(y&&t==="approve")return{ms:Number(y.endMs),onInterval:!0,snapReason:"previous-interval-end",procedureRunId:String(y.procedureRunId||"")};let c=n.find(($)=>Number($.startMs)>=r-1000);if(c&&["guide","modify","restart","redo"].includes(t))return{ms:Number(c.startMs),onInterval:!0,snapReason:"next-interval-start",procedureRunId:String(c.procedureRunId||"")};return{ms:r,onInterval:!1,snapReason:"event-time",procedureRunId:String(f?.procedureRunId||"")}}function VL(l,u,r,f){let n=Math.hypot(r-l,f-u),i=n>gW?gW:0,t=i>0?r-(r-l)/n*i:r,y=i>0?f-(f-u)/n*i:f,c=t-l,$=Math.max(16,Math.min(42,Math.abs(c)*0.45+12)),A=c===0?1:Math.sign(c);return`M ${l},${u} C ${l+A*$},${u} ${t-A*$},${y} ${t},${y}`}function xX(l,u){let r=String(l?.runId||u?.runId||""),f=EL({...Yl(u)?u:{},...Yl(l)?l:{},runId:r,procedureRuns:Sl(l?.procedureRuns).length>0?l.procedureRuns:u?.procedureRuns},[]),n=[],i=[],t=[],y=new Set,c=new Map,$=(F,U)=>{if(!F.nodeId||!Number.isFinite(Number(F.ms)))return;if(y.has(F.id))return;y.add(F.id),U.push(F)};for(let F of Sl(l?.procedureRuns)){let U=oA(F,r),N=Sf(F);if(!U)continue;for(let W of Sl(F?.attempts)){let L=aA(W);for(let J of Aj(W?.controlEventRecords)){let w=un(J);if(!["initial-prompt-delivered","append-prompt-delivered","monitor-prompt-delivered"].includes(w))continue;let Q=Dy(J),q=al(Q);if(q===null)continue;let T=String(J?.eventId||"");$({id:`prompt:${T||`${N}:${L}:${w}:${q}`}`,runId:r,nodeId:U,procedureRunId:N,attempt:L,kind:"prompt",tone:VX(J),status:"delivered",label:XX(J),ms:q,timestampIso:Q,sourceKind:String(J?.sourceKind||""),sourceNodeId:String(J?.sourceNodeId||""),targetNodeId:U,action:"",eventId:T,commandId:String(J?.commandId||""),raw:J},n)}}}let A=new Map;Aj(l?.controlEvents).forEach((F,U)=>{let N=YX(F,U),W=A.get(N)||{key:N,events:[]};W.events.push(F),A.set(N,W)});for(let F of A.values()){let U=Sl(F.events).slice().sort((p,V)=>jL(V)-jL(p)),N=Sl(F.events).find((p)=>un(p)==="control-command-queued")||null,W=U[0]||N;if(!N&&!W)continue;let L=String(N?.sourceNodeId||W?.sourceNodeId||""),J=String(N?.sourceKind||W?.sourceKind||""),w=Dy(N)||Dy(W)||t_(N?.createdAt,W?.createdAt),Q=al(w),q=String(W?.commandId||N?.commandId||F.key),T=(un(W)||"control-command-queued").replace(/^control-command-/u,""),O="";if(L&&Q!==null)O=`control-source:${q}:${L}`,c.set(q,O),$({id:O,runId:r,nodeId:L,procedureRunId:String(N?.procedureRunId||W?.procedureRunId||""),attempt:"",kind:"control-source",tone:hX(N||W),status:T,label:`${u_(N||W)} 发起`,ms:Q,timestampIso:w,action:rt(N||W),sourceKind:J,sourceNodeId:L,targetNodeId:String(W?.targetNodeId||N?.targetNodeId||""),commandId:q,raw:N||W},i);let Z=W||N,E=Dy(Z)||w,D=al(E);if(D===null)continue;let Y=PX(Z);for(let p of Y){let V=RX(f,p,D,Z),B=`control-target:${q}:${p}`;if($({id:B,runId:r,nodeId:p,procedureRunId:V.procedureRunId,attempt:"",kind:"control-target",tone:MX(Z),status:T,label:CX(Z,p),ms:V.ms,eventMs:D,onInterval:V.onInterval,snapReason:V.snapReason,snapped:Number(V.ms)!==D,timestampIso:E,renderedTimestampIso:f_(Number(V.ms)),action:rt(Z),sourceKind:J,sourceNodeId:L,targetNodeId:p,commandId:q,raw:Z},i),O&&L&&L!==p)t.push({id:`control-arrow:${q}:${L}:${p}`,commandId:q,sourceNodeId:L,targetNodeId:p,sourceMarkerId:O,targetMarkerId:B,sourceKind:J,action:rt(Z),status:T})}}let j=[...n,...i].sort((F,U)=>Number(F.ms)-Number(U.ms)||String(F.nodeId).localeCompare(String(U.nodeId))||String(F.id).localeCompare(String(U.id)));return{...DX(j,t),sourceMarkerByCommand:c}}function bX({details:l,selectedNodeId:u,selectedNodeRuntime:r,control:f,onRaw:n}){if(!l)return K("span",{className:"muted"},"点击“抓取过程”读取 node 运行材料;主界面只显示结构化摘要,完整内容需点开原始 JSON。");let i=Sl(l.procedureRuns),t=i.at(-1)||{},y=Sl(t.attempts),c=y.at(-1)||{},$=Sl(t.workerLogTail),A=Sl(c.controlEventsTail),j=Sl(c.controlPromptsTail),F=Sl(c.monitorPromptsTail),U=fj(A),N=fj(j),W=fj(F),L=c.opencodeMessages||{};return K("div",{className:"pipeline-evidence-list compact"},K(Df,{title:"Node runtime",subtitle:u||"--",facts:[`status ${r?.status||"pending"}`,`attempts ${r?.attempts??y.length}`,`procedure ${r?.currentProcedureRunId||Sf(t)||"--"}`,f.fetchedAt?`fetched ${iu(f.fetchedAt)}`:"not fetched"],data:l.node||l,onRaw:n,testId:"raw-pipeline-node-runtime"}),K(Df,{title:"Procedure runs",subtitle:`${i.length} groups`,facts:[`latest ${t.status?.status||t.status||"--"}`,`steps ${Sl(t.recentSteps).length}`,`duration ${Vf(al(t.finishedAt)&&al(t.startedAt)?Number(al(t.finishedAt))-Number(al(t.startedAt)):t.durationMs)}`],data:i,onRaw:n,testId:"raw-pipeline-node-procedures"}),K(Df,{title:"OpenCode messages",subtitle:String(L.exists?"available":"not indexed"),facts:[`messages ${RA(L.messageCount)}`,`size ${RA(L.size)}`,`updated ${Wl(L.updatedAt)}`],data:L,onRaw:n,testId:"raw-pipeline-node-messages"}),K(Df,{title:"Control prompts",subtitle:"manual / monitor append queues",facts:[`manual tail ${N.total}`,`monitor tail ${W.total}`,`last ${Wl(Qj(N.lastAt,W.lastAt))}`],data:{controlPromptsTail:j,monitorPromptsTail:F},onRaw:n,testId:"raw-pipeline-node-prompts"}),K(Df,{title:"Control events",subtitle:U.eventKinds.length>0?U.eventKinds.join(", "):"event tail",facts:[`tail ${U.total}`,`parsed ${U.parsed}`,`last ${Wl(U.lastAt)}`],data:A,onRaw:n,testId:"raw-pipeline-node-events"}),K(Df,{title:"Worker log",subtitle:"tail is hidden on main canvas",facts:[`tail ${$.length} lines`,"raw only via button",`procedure ${Sf(t)||"--"}`],data:$,onRaw:n,testId:"raw-pipeline-node-worker-log"}))}function vX({activeRun:l,onRaw:u}){if(!l)return K(qf,{title:"暂无运行材料",text:"没有 Pipeline epoch 时不会展示运行材料索引。"});let r=Sl(l.nodes),f=Sl(l.procedureRuns),n=Sl(l.submissions),i=Sl(l.workerLogTail),t=oW(r),y=oW(f),c=f.filter((A)=>String(A?.status||"").toLowerCase()==="failed"),$=Qj(...f.flatMap((A)=>[A.updatedAt,A.finishedAt,A.startedAt]));return K("div",{className:"pipeline-evidence-list"},K(Df,{title:"Epoch overview",subtitle:l.runId||"--",facts:[`pipeline ${l.pipelineId||"--"}`,`status ${l.status||"--"}`,`started ${Wl(l.startedAt)}`,`updated ${Wl(l.updatedAt)}`],data:l,onRaw:u,testId:"raw-pipeline-run"}),K(Df,{title:"Node states",subtitle:`${r.length} nodes`,facts:[`running ${t.running||0}`,`succeeded ${t.succeeded||0}`,`failed ${t.failed||0}`,`pending ${t.pending||0}`],data:r,onRaw:u,testId:"raw-pipeline-run-nodes"}),K(Df,{title:"Procedure run index",subtitle:`${f.length} procedure records`,facts:[`succeeded ${y.succeeded||0}`,`failed ${y.failed||0}`,`latest ${Wl($)}`,`errors ${c.length}`],data:f,onRaw:u,testId:"raw-pipeline-run-procedures"}),K(Df,{title:"OA submissions",subtitle:`${n.length} submission files`,facts:[`records ${n.length}`,`task ${RA(l.task)}`,"raw grouped by run"],data:n,onRaw:u,testId:"raw-pipeline-run-submissions"}),K(Df,{title:"Worker log tail",subtitle:"hidden from main interface",facts:[`tail ${i.length} lines`,"display raw only after click",`updated ${Wl(l.updatedAt)}`],data:i,onRaw:u,testId:"raw-pipeline-run-worker-log"}))}function sX({diagnostics:l,onRaw:u}){let r=Sl(l?.runs).filter(Yl),f=Sl(l?.forbiddenResiduals),n=Yl(l?.guarantees)?l.guarantees:{},i=l?.hasNeutralNodeFinishedEvidence===!0&&l?.hasNoAuditPolicyEvidence===!0&&l?.hasAuditPolicyEvidence===!0,t=l?.ok===!0&&i&&f.length===0,y=r[0]||null,c=[{label:"中性完成事实",ok:n.neutralNodeFinished===!0,hint:"node-finished 不携带流程策略"},{label:"Config 策略判定",ok:n.auditPolicyFromConfig===!0,hint:"OA backend 读取当前 epoch 配置"},{label:"控制命令来自 OA",ok:n.runnerConsumesControlCommandsFromOaEvents===!0,hint:"runner 只消费 OA control.command"},{label:"无独立审核事件",ok:n.noIndependentAuditRequestEvent===!0,hint:"审核由 node-finished + policy 派生"},{label:"无批次门禁",ok:n.noBatchFinishedControlGate===!0,hint:"下游启动由每个 node 完成驱动"}];return K("div",{className:"pipeline-oa-panel","data-testid":"pipeline-oa-event-flow-panel"},K("div",{className:"metric-grid compact"},K(Mr,{label:"OA Flow",value:t?"100%":"--",hint:String(l?.mode||"waiting diagnostics"),tone:t?"ok":"warn"}),K(Mr,{label:"禁止残留",value:f.length,hint:f.length===0?"source scan clean":"needs cleanup",tone:f.length===0?"ok":"warn"}),K(Mr,{label:"No-audit",value:l?.hasNoAuditPolicyEvidence?"OK":"--",hint:"OA 下游策略证据",tone:l?.hasNoAuditPolicyEvidence?"ok":"warn"}),K(Mr,{label:"Monitor 审核",value:l?.hasAuditPolicyEvidence?"OK":"--",hint:"OA 控制事件闭环",tone:l?.hasAuditPolicyEvidence?"ok":"warn"})),K("div",{className:"pipeline-oa-guarantees"},c.map(($)=>K("article",{key:$.label,className:`pipeline-oa-guarantee ${$.ok?"ok":"warn"}`},K(u0,{status:$.ok?"online":"warn"},$.ok?"OK":"MISS"),K("div",null,K("strong",null,$.label),K("span",null,$.hint))))),K("div",{className:"pipeline-evidence-list compact"},r.slice(0,6).map(($)=>K(Df,{key:$.runId,title:String($.runId||"--"),subtitle:[Number($.monitorAuditNodeFinishedCount||0)>0?"monitor audit":"",Number($.noAuditPolicyCount||0)>0?"no-audit policy":""].filter(Boolean).join(" / ")||"event evidence",facts:[`events ${$.eventCount||0}`,`node-finished ${$.nodeFinishedCount||0}`,`policy-in-detail ${$.nodeFinishedWithPolicyCount||0}`,`queued ${$.controlQueuedCount||0}`,`applied ${$.controlAppliedCount||0}`],data:$,onRaw:u,testId:`raw-pipeline-oa-run-${String($.runId||"run").replace(/[^a-zA-Z0-9_.-]+/g,"-")}`}))),y?K("p",{className:"muted paragraph"},`最新证据 ${y.runId}: ${y.nodeFinishedCount||0} 个 node-finished,${y.controlAppliedCount||0} 个控制结果。`):K(qf,{title:"暂无 OA 事件流证据",text:"等待 Pipeline backend 暴露 diagnostics。"}),l?K("div",{className:"panel-actions inline-actions"},K(rn,{title:"Pipeline OA Event Flow Diagnostics",data:l,onOpen:u,testId:"raw-pipeline-oa-event-flow"})):null)}function kX({quota:l,onRaw:u}){let r=Yl(l?.summary)?l.summary:{},f=Yl(l?.target)?l.target:{},n=Yl(l?.cache)?l.cache:{},i=l?.ok===!0,t=String(l?.modelId||r.modelName||f.modelName||"MiniMax-M2.7"),y=r.totalCount??f.currentIntervalTotalCount,c=r.usageCount??f.currentIntervalUsageCount,$=r.remainingCount??f.currentIntervalRemainingCount,A=r.remainingRatio??(Number.isFinite(Number(y))&&Number(y)>0&&Number.isFinite(Number($))?Number($)/Number(y):void 0),j=r.usageRatio??(Number.isFinite(Number(y))&&Number(y)>0&&Number.isFinite(Number(c))?Number(c)/Number(y):void 0),F=r.resetAt||f.endAt,U=r.remainsMs??f.remainsMs,N=Number($),W=!i||Number.isFinite(N)&&N<=0?"warn":"ok",L=[i?`endpoint ${l?.endpoint||"--"}`:"quota unavailable",`fetched ${hA(l?.fetchedAt)}`,n.hit?`cache ${Vf(n.ageMs)}`:"live quota"];return K("div",{className:"pipeline-minimax-quota-panel","data-testid":"pipeline-minimax-quota-panel"},K("div",{className:"metric-grid compact"},K(Mr,{label:"MiniMax",value:i?t:"--",hint:l?.modelComponent||l?.error||"model/minimax-m27",tone:W}),K(Mr,{label:"当前窗口",value:`${rj(c)}/${rj(y)}`,hint:`已用 ${aW(j)}`,tone:W}),K(Mr,{label:"剩余额度",value:rj($),hint:`剩余 ${aW(A)}`,tone:W}),K(Mr,{label:"重置时间",value:hA(F),hint:U!==void 0?`约 ${Vf(U)}`:Wl(F),tone:W})),K(qj,{items:L}),i?K("p",{className:"muted paragraph"},`MiniMax 限额来自 D601 Pipeline 后端实时查询;当前模型匹配 ${r.modelName||f.modelName||t}。`):K(lu,{error:l?.error||"MiniMax 限额查询失败"}),l?K("div",{className:"panel-actions inline-actions"},K(rn,{title:"Pipeline MiniMax Quota",data:l,onOpen:u,testId:"raw-pipeline-minimax-quota"})):null)}function gX({epochs:l,activeRun:u,activePipeline:r,pipelineNodes:f,pipelineEdges:n,runDetails:i,nodeDetails:t,nodeDetailsState:y,ganttScale:c=i_,onGanttScaleChange:$,onRunChange:A,onIntervalSelect:j,onMarkerSelect:F,selection:U,detailOpen:N,onDetailOpenChange:W,onRaw:L}){let[J,w]=dr(KX),[Q,q]=dr({startY:0,endY:0,startMs:0,endMs:0}),[T,O]=dr(Date.now()),Z=ei(null),E=String(u?.runId||""),D=Boolean(N),Y=(jl)=>{if(typeof W==="function")W(jl)},p=r0(c??i_),V=String(i?.runId||"")===E?i?.details:null,B=V?{...Yl(u)?u:{},...Yl(V)?V:{},runId:E,procedureRuns:Sl(V?.procedureRuns).length>0?V.procedureRuns:u?.procedureRuns}:u,m=EL(B,f,T),X=V?xX(V,B):{markers:[],arrows:[]},S=Sl(X.markers),b=mX(B,m,S),z=pX(b,p,m,T),P=String(z.source||"frontend-y"),s=m.map((jl)=>HX(jl,z,T)),k={startMs:Number(z.startMs),endMs:Number(z.endMs),durationMs:Math.max(1,Number(z.durationMs??Number(z.endMs)-Number(z.startMs)))},v=mj(p),tl={...v,pxPerMinute:Number(z.pxPerMinute??v.pxPerMinute)},I=Math.round(Number(z.chartHeight||360)),M=m.some(Kj);zn(()=>{if(!E||!M)return;let jl=window.setInterval(()=>O(Date.now()),1000);return()=>window.clearInterval(jl)},[E,M]);let rl=JX(r,f,Array.isArray(n)?n:[]),cl=f.map((jl)=>String(jl?.id||"")).filter(Boolean),$l=s.map((jl)=>String(jl.nodeId||"")).filter(Boolean),Tl=S.map((jl)=>String(jl.nodeId||"")).filter(Boolean),Ql=Array.from(new Set([...rl,...cl,...$l,...Tl])),Ol={startY:0,endY:I,startMs:Number(k.startMs),endMs:Number(k.endMs)},h=Number(Q?.endY||0)>0?Q:Ol,a=(jl)=>{return gA(jl,k,I,z)<=Number(h.endY)&&Nj(jl,k,I,z)>=Number(h.startY)},ul=(jl)=>{let ol=wf(jl,k,I,z);return ol>=Number(h.startY)&&ol<=Number(h.endY)},zl=new Set(Ql.filter((jl)=>s.some((ol)=>ol.nodeId===jl&&a(ol))||S.some((ol)=>ol.nodeId===jl&&ul(ol)))),o=J?Ql.filter((jl)=>zl.has(jl)):Ql,ql=`${lj}px ${o.length>0?o.map(()=>`${mn}px`).join(" "):"minmax(160px, 1fr)"}`,pl=Sl(z.ticks).filter(Yl),Bl=String(U?.mode==="interval"?U?.interval?.procedureRunId||"":""),Il=String(U?.mode==="event"?U?.marker?.id||"":""),nu=()=>{let jl=Z.current;if(!jl){q(Ol);return}let ol=Math.max(0,jl.scrollTop-uj),wr=Math.max(120,jl.clientHeight-uj),hl=Math.min(I,ol+wr),Yu={startY:ol,endY:hl,startMs:Number(k.startMs),endMs:Number(k.endMs)},eu=Math.max(0,Math.min(1,ol/I)),rf=Math.max(eu,Math.min(1,hl/I)),Ar=Math.max(1,Number(k.endMs)-Number(k.startMs));Yu.startMs=Number(k.startMs)+Ar*eu,Yu.endMs=Number(k.startMs)+Ar*rf,q(Yu)};zn(()=>{let jl=Z.current,ol=window.setTimeout(nu,0);return jl?.addEventListener("scroll",nu),window.addEventListener("resize",nu),()=>{window.clearTimeout(ol),jl?.removeEventListener("scroll",nu),window.removeEventListener("resize",nu)}},[E,k.startMs,k.endMs,I]);let Ml=Math.max(0,Ql.length-o.length),wu=new Set(S.filter((jl)=>o.includes(String(jl.nodeId||""))&&ul(jl)).map((jl)=>String(jl.id))),Qr=new Map(S.map((jl)=>[String(jl.id),jl])),Or=Sl(X.arrows).filter((jl)=>{if(!wu.has(String(jl.targetMarkerId||"")))return!1;if(String(jl.action||"")==="observe")return o.includes(String(jl.sourceNodeId||""));return wu.has(String(jl.sourceMarkerId||""))}),$r=lj+Math.max(1,o.length)*mn,ir=(jl)=>{let ol=r0(jl.target.value);if(typeof $==="function")$(ol);window.setTimeout(nu,0)},tr=()=>LX({title:`${r?.id||"pipeline"}-${E||"epoch"}-gantt`,meta:[`run ${E||"--"}`,`${Wl(k.startMs)} -> ${Wl(k.endMs)}`,`duration ${Vf(k.durationMs)}`,`${tl.label} / ${yj(tl.pxPerMinute)} px/min`,`${o.length}/${Ql.length} nodes`,`${S.length} markers`],visibleNodeIds:o,intervals:s,markers:S.filter((jl)=>o.includes(String(jl.nodeId||""))),arrows:Or,ticks:pl,bounds:k,chartHeight:I,backendLayout:z}),hr=Yl(V?.gantt?.diagnostics)?V.gantt.diagnostics:null;return K(Kn,{title:"Epoch 甘特图",eyebrow:`${r?.id||"pipeline"} / ${l.length} epochs`,className:"pipeline-wide-panel",loading:i?.loading,actions:K("div",{className:"pipeline-gantt-actions"},K("select",{value:E,disabled:l.length===0,onChange:(jl)=>A(jl.target.value),"data-testid":"pipeline-epoch-select"},l.map((jl)=>K("option",{key:jl.runId,value:jl.runId},Jj(l,jl)))),K("label",{className:"pipeline-gantt-toggle"},K("input",{type:"checkbox","data-testid":"pipeline-gantt-auto-hide-idle",checked:J,onChange:(jl)=>{w(Boolean(jl.target.checked)),window.setTimeout(nu,0)}}),K("span",null,"自动隐藏空闲列")),K("label",{className:"pipeline-gantt-scale"},K("span",null,K("b",null,"时间尺度"),K("em",{"data-testid":"pipeline-gantt-scale-label"},`${tl.label} · ${yj(tl.pxPerMinute)} px/min`)),K("input",{type:"range",min:0,max:100,step:0.01,value:p,onChange:ir,"aria-label":"调整甘特图时间尺度","data-testid":"pipeline-gantt-time-scale"}),K("small",null,K("span",null,"全局"),K("span",null,"细节"))),u?K("button",{type:"button",className:"ghost-btn",onClick:tr,disabled:o.length===0,"data-testid":"pipeline-export-gantt"},"导出甘特图"):null,u?K(rn,{title:`Pipeline Epoch ${u.runId}`,data:u,onOpen:L,testId:"raw-pipeline-epoch-gantt"}):null)},!u?K(qf,{title:"暂无 Epoch",text:"当前 pipeline 还没有完整运行记录。"}):s.length===0?K(qf,{title:"暂无时间区间",text:"等待 D601 Pipeline backend 在 procedure summary 中返回 startedAt / finishedAt。"}):K("div",{className:"pipeline-gantt-wrap"},K("div",{className:`pipeline-gantt-detail-layout ${D?"detail-open":"detail-collapsed"}`,"data-testid":"pipeline-gantt-detail-layout","data-sidebar-open":D?"true":"false"},K("div",{className:"pipeline-gantt-main"},K("div",{className:"pipeline-gantt-main-head"},K("div",{className:"pipeline-gantt-meta"},K("span",null,`time ${Wl(k.startMs)} -> ${Wl(k.endMs)}`),K("span",null,`duration ${Vf(k.durationMs)}`),K("span",null,`scale ${tl.label} / ${yj(tl.pxPerMinute)} px/min`),K("span",null,`layout ${P}`),hr?K("span",null,`align ${hr.timeAxisAlignmentOk===!1?"check":"ok"}`):null,K("span",null,`visible ${o.length}/${Ql.length} nodes`),V?K("span",null,`markers ${S.length}`):null,J&&Ml>0?K("span",null,`hidden idle ${Ml}`):null),!D?K("button",{type:"button",className:"pipeline-sidecar-tab right",disabled:!U?.mode,onClick:()=>Y(!0),"data-testid":"pipeline-gantt-sidebar-toggle"},U?.mode?"展开详情":"点击甘特图元素展开详情"):null),K("div",{className:"pipeline-gantt-viewport",ref:Z,"data-testid":"pipeline-epoch-gantt","data-pipeline-id":r?.id||"","data-run-id":E,"data-layout-source":P,"data-start-ms":String(k.startMs),"data-end-ms":String(k.endMs),"data-chart-height":String(I)},K("div",{className:"pipeline-gantt-board",style:{gridTemplateColumns:ql,minWidth:`${$r}px`}},K("div",{className:"pipeline-gantt-head time"},"Time"),o.length===0?K("div",{className:"pipeline-gantt-head empty"},"当前时间窗无工作节点"):o.map((jl)=>K("div",{key:`head-${jl}`,className:"pipeline-gantt-head node",title:jl,"data-testid":"pipeline-gantt-head-node","data-node-id":jl},K(IS,{value:jl}))),K("div",{className:"pipeline-gantt-time-axis",style:{height:`${I}px`}},pl.map((jl)=>{let ol=DL(jl,k,I,z);return K("div",{key:`tick-${jl.ms}-${ol}`,className:"pipeline-gantt-tick",style:{top:`${ol}px`},"data-testid":"pipeline-gantt-tick","data-ms":String(jl.ms),"data-y":String(ol)},K("b",null,Wl(jl.ms)),K("span",null,`+${Vf(Number(jl.offsetMs??Number(jl.ms)-Number(k.startMs)))}`))})),o.length>0?K("svg",{className:"pipeline-gantt-arrow-layer",width:o.length*mn,height:I,viewBox:`0 0 ${o.length*mn} ${I}`,style:{left:`${lj}px`,top:`${uj}px`,width:`${o.length*mn}px`,height:`${I}px`},"aria-hidden":"true"},K("defs",null,K("marker",{id:"pipeline-gantt-arrowhead",viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse"},K("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"}))),Or.map((jl)=>{let ol=Qr.get(String(jl.targetMarkerId||""));if(!ol)return null;let wr=Qr.get(String(jl.sourceMarkerId||"")),hl=String(wr?.nodeId||jl.sourceNodeId||""),Yu=o.indexOf(hl),eu=o.indexOf(String(ol.nodeId||""));if(Yu<0||eu<0)return null;let rf=Yu*mn+mn/2,Ar=eu*mn+mn/2,Zr=wr?wf(wr,k,I,z):wf(ol,k,I,z),Zn=wf(ol,k,I,z);return K("path",{key:jl.id,className:`pipeline-gantt-arrow ${String(jl.sourceKind||"").toLowerCase()} ${String(jl.status||"").toLowerCase()} ${String(jl.action||"").toLowerCase()}`,d:VL(rf,Zr,Ar,Zn),markerEnd:"url(#pipeline-gantt-arrowhead)","data-testid":String(jl.action||"")==="observe"?"pipeline-gantt-observation-arrow":"pipeline-gantt-arrow","data-source-node-id":String(jl.sourceNodeId||""),"data-target-node-id":String(jl.targetNodeId||""),"data-target-marker-id":String(jl.targetMarkerId||""),"data-action":String(jl.action||""),"data-source-y":String(Zr),"data-target-y":String(Zn)})})):null,o.length===0?K("div",{className:"pipeline-gantt-empty-col",style:{height:`${I}px`}},"滚动到有活动的时间段后,相关 node 列会自动出现。"):o.map((jl)=>{let ol=s.filter((hl)=>hl.nodeId===jl),wr=S.filter((hl)=>String(hl.nodeId||"")===jl);return K("div",{key:`col-${jl}`,className:"pipeline-gantt-node-col",style:{height:`${I}px`}},ol.map((hl)=>{let Yu=gA(hl,k,I,z),eu=Nj(hl,k,I,z),rf=BL(hl,k,I,z),Ar=String(hl.procedureRunId||`${jl}-${hl.startMs}`);return K("button",{key:Ar,type:"button",className:`pipeline-gantt-bar ${hl.status} ${hl.live?"live":""} ${Bl===Ar?"selected":""}`,style:{top:`${Yu}px`,height:`${rf}px`},title:`${jl} ${hl.status} ${Wl(hl.startedAt||hl.startMs)} -> ${Wl(hl.finishedAt||hl.endMs)}`,onClick:()=>j(hl),"data-testid":"pipeline-gantt-line","data-node-id":jl,"data-procedure-run-id":String(hl.procedureRunId||""),"data-status":String(hl.status||""),"data-live":hl.live?"true":"false","data-start-ms":String(hl.startMs||""),"data-end-ms":String(hl.endMs||""),"data-y1":String(Yu),"data-y2":String(eu),"data-natural-height":String(Math.max(0,eu-Yu))},K("strong",null,hl.status||"working"),K("span",null,Vf(hl.durationMs)))}),wr.map((hl)=>K("button",{key:hl.id,type:"button",className:`pipeline-gantt-marker ${hl.kind} ${hl.tone||""} ${hl.status||""} ${Il===String(hl.id)?"selected":""}`,style:{top:`${wf(hl,k,I,z)}px`},title:`${hl.label||"event"} / ${Wl(hl.timestampIso||hl.timestamp||hl.ms)}`,onClick:()=>F(hl),"data-testid":hl.kind==="prompt"?"pipeline-gantt-prompt-marker":"pipeline-gantt-control-marker","data-marker-id":String(hl.id||""),"data-ms":String(hl.ms??hl.eventMs??""),"data-y":String(wf(hl,k,I,z))})))})))),D?K(gS,{selection:U,runDetails:i,nodeDetails:t,nodeDetailsState:y,onRaw:L,onCollapse:()=>Y(!1)}):null)))}function ri(){return{loading:!1,actionLoading:"",error:"",message:"",details:null,fetchedAt:null,appendPrompt:"",guidePrompt:"",modifyPrompt:"",approveReason:"",redoReason:""}}function di(){return{mode:"",runId:"",interval:null,marker:null}}function cj(){return{runId:"",loading:!1,error:"",details:null,fetchedAt:null}}function dc(l,u){return`${l}/microservices/pipeline/proxy${u}`}function IX({activeRun:l,pipelineRuns:u,selectedRunId:r,onRunChange:f,selectedNodeId:n,selectedNodeConfig:i,selectedNodeRuntime:t,control:y,onControlChange:c,onFetch:$,onAction:A,onRaw:j,onCollapse:F}){let U=String(l?.runId||""),N=String(t?.status||"pending"),W=!U||!n||y.loading||Boolean(y.actionLoading),L=(w)=>(Q)=>c({[w]:Q.target.value,error:"",message:""}),J=u.length>0?u:l?[l]:[];return K("aside",{className:"pipeline-node-control","data-testid":"pipeline-node-control"},K("div",{className:"pipeline-node-control-head"},K("div",null,K("p",{className:"panel-eyebrow"},"Manual Node Control"),K(fu,{title:n||"点击控制图中的 node",level:3,loading:y.loading||Boolean(y.actionLoading)})),K("div",{className:"pipeline-node-control-head-actions"},n?K(u0,{status:N},N):K(u0,{status:"pending"},"idle"),K("button",{type:"button",className:"ghost-btn mini",onClick:F,"data-testid":"pipeline-node-sidebar-collapse"},"收起"))),K("div",{className:"pipeline-control-runbar"},K("label",null,K("span",null,"目标 run"),K("select",{value:U||r,disabled:J.length===0,onChange:(w)=>f(w.target.value),"data-testid":"pipeline-node-run-select"},J.map((w)=>K("option",{key:w.runId,value:w.runId},`${w.runId||"--"} / ${w.status||"--"}`)))),K("button",{type:"button",className:"ghost-btn",disabled:W,onClick:$,"data-testid":"pipeline-node-fetch"},y.loading?"抓取中":"抓取过程"),y.details?K(rn,{title:`Pipeline Node ${n}`,data:y.details,onOpen:j,testId:"raw-pipeline-node-control"}):null),K("div",{className:"pipeline-control-meta"},K("span",null,K("b",null,"kind"),String(i?.kind||"--")),K("span",null,K("b",null,"procedure"),String(t?.currentProcedureRunId||"--")),K("span",null,K("b",null,"attempts"),String(t?.attempts??"--")),K("span",null,K("b",null,"updated"),Wl(l?.updatedAt))),!n?K(qf,{title:"未选择 node",text:"点击 React Flow 控制图中的任意 node 后,可抓取执行过程、追加 prompt、下发引导、增量修改、审核通过或重做。"}):null,K(lu,{error:y.error,wide:!0}),K("div",{className:"pipeline-control-actions"},K("label",null,K("span",null,"实时追加 prompt(仅 running node)"),K("textarea",{value:y.appendPrompt,onChange:L("appendPrompt"),placeholder:"让当前执行中的 agent 继续、补充检查或调整当前步骤...",rows:4,disabled:!n,"data-testid":"pipeline-node-append-input"}),K("button",{type:"button",className:"primary-btn compact",disabled:W||!String(y.appendPrompt||"").trim(),onClick:()=>A("append"),"data-testid":"pipeline-node-append-button"},y.actionLoading==="append"?"追加中":"追加到运行中 node")),K("label",null,K("span",null,"下次尝试引导 prompt"),K("textarea",{value:y.guidePrompt,onChange:L("guidePrompt"),placeholder:"给该 node 下一次 attempt 的执行提示;不会立即打断当前 session。",rows:4,disabled:!n,"data-testid":"pipeline-node-guide-input"}),K("button",{type:"button",className:"ghost-btn compact",disabled:W||!String(y.guidePrompt||"").trim(),onClick:()=>A("guide"),"data-testid":"pipeline-node-guide-button"},y.actionLoading==="guide"?"下发中":"下发 guide")),K("label",null,K("span",null,"完成后增量修改 prompt"),K("textarea",{value:y.modifyPrompt,onChange:L("modifyPrompt"),placeholder:"在该 node 已完成结果基础上追加修改要求;runner 会重跑目标 node,并保留同 node 既有 OA 输出作为上下文。",rows:4,disabled:!n,"data-testid":"pipeline-node-modify-input"}),K("button",{type:"button",className:"ghost-btn compact",disabled:W||!String(y.modifyPrompt||"").trim(),onClick:()=>A("modify"),"data-testid":"pipeline-node-modify-button"},y.actionLoading==="modify"?"排队中":"增量修改 node")),K("label",null,K("span",null,"Monitor 审核通过原因"),K("textarea",{value:y.approveReason,onChange:L("approveReason"),placeholder:"当流程配置开启 monitor 审核时,记录审核通过原因并释放后续 node。",rows:3,disabled:!n,"data-testid":"pipeline-node-approve-input"}),K("button",{type:"button",className:"primary-btn compact",disabled:W||!String(y.approveReason||"").trim(),onClick:()=>A("approve"),"data-testid":"pipeline-node-approve-button"},y.actionLoading==="approve"?"提交中":"审核通过")),K("label",null,K("span",null,"重做 / restart 原因"),K("textarea",{value:y.redoReason,onChange:L("redoReason"),placeholder:"说明为什么需要重做;runner 会重置目标 node 以及非 rework 下游 node。",rows:4,disabled:!n,"data-testid":"pipeline-node-redo-input"}),K("button",{type:"button",className:"danger-btn compact",disabled:W||!String(y.redoReason||"").trim(),onClick:()=>A("redo"),"data-testid":"pipeline-node-redo-button"},y.actionLoading==="redo"?"排队中":"重做 node"))),K("div",{className:"pipeline-control-evidence"},K("strong",null,"Node 过程索引"),K(bX,{details:y.details,selectedNodeId:n,selectedNodeRuntime:t,control:y,onRaw:j})))}function SL({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((fl)=>fl.id==="pipeline")||null,[n,i]=dr({loading:!1,error:"",health:null,snapshot:null,oaDiagnostics:null,minimaxQuota:null,refreshedAt:null}),[t,y]=dr(""),[c,$]=dr(""),[A,j]=dr(""),[F,U]=dr(ri()),[N,W]=dr({}),[L,J]=dr(di()),[w,Q]=dr(cj()),[q,T]=dr(i_),[O,Z]=dr(!1),[E,D]=dr(!1),Y=ei(0),{addNotification:p}=Xr(),V=ei(!1),B=ei(0),m=ei(""),X=ei({}),S=ei(""),b=ei("");async function z(fl={}){let Dl=fl.silent===!0;if(!f)return;if(V.current)return;V.current=!0;let Cl=Y.current+1;if(Y.current=Cl,!Dl)i((dl)=>({...dl,loading:!0,error:""}));try{let dl=`__unideskArrayLimit=registry.components:80,runs:${HS}`,[ju,ku,$u]=await Promise.all([oi(`${r}/microservices/pipeline/proxy/api/snapshot?${dl}`,{cache:"no-store"}),oi(`${r}/microservices/pipeline/proxy/api/oa-event-flow/diagnostics`,{cache:"no-store"}).catch((Yf)=>({ok:!1,error:El(Yf,"OA event flow diagnostics failed")})),oi(`${r}/microservices/pipeline/proxy/api/model-quota/minimax`,{cache:"no-store"}).catch((Yf)=>({ok:!1,error:El(Yf,"MiniMax quota failed")}))]);if(Cl!==Y.current)return;let qr={ok:ju?.ok!==!1,service:"pipeline-v2-control snapshot"};i({loading:!1,error:"",health:qr,snapshot:ju,oaDiagnostics:ku,minimaxQuota:$u,refreshedAt:new Date})}catch(dl){if(Cl!==Y.current)return;i((ju)=>({...ju,loading:!1,error:El(dl,"Pipeline 加载失败")}))}finally{V.current=!1}}zn(()=>{if(z(),!f)return;let fl=()=>{if(XA())z({silent:!0})},Dl=window.setInterval(()=>{fl()},kW),Cl=()=>{if(XA())fl()};return document.addEventListener("visibilitychange",Cl),()=>{window.clearInterval(Dl),document.removeEventListener("visibilitychange",Cl)}},[f?.id,f?.runtime?.providerStatus,r]);let P=aS(f),s=dS(f),k=oS(f),v=n.snapshot||{},tl=n.oaDiagnostics||null,I=n.minimaxQuota||null,{components:M,pipelines:rl,runs:cl}=eS(v),$l=String(cl[0]?.pipelineId||""),Tl=($l?rl.find((fl)=>String(fl.id||"")===$l):null)||rl[0]||{},Ql=rl.find((fl)=>String(fl.id||"")===t)||Tl,Ol=String(Ql.id||""),h=GL(Ql),a=Lj(Ql),ul=_L(cl,Ol),zl=TX(cl,Ol),o=zl.find((fl)=>String(fl?.runId||"")===c)||ul,ql=String(w.runId||"")===String(o?.runId||"")?fX(w.details):null,pl=nX(o,ql),Bl=String(pl?.runId||""),Il=h.find((fl)=>String(fl?.id||"")===A)||null,nu=A?TL(pl,A):null,Ml=uX(cl),wu=cX(M),Qr=Number(n.health?.components)||rL(v,"registry.components",M.length),Or=rL(v,"runs",cl.length),$r=iL(Ql,pl,M),ir={nodes:$r.nodes.map((fl)=>fl.id===A?{...fl,selected:!0,className:`${fl.className||""} selected-control-node`}:fl),edges:$r.edges},tr=rl.map((fl)=>{let Dl=String(fl.id||"pipeline"),Cl=_L(cl,Dl);return{title:`${Dl}-${Cl?.runId||"snapshot"}`,flow:iL(fl,Cl,M)}}),hr=String(L?.runId||Bl||""),jl=String(L?.interval?.nodeId||L?.marker?.nodeId||""),ol=hr&&jl?N[tj(hr,jl)]||null:null,wr=xA(F.details,hr,jl),hl=xA(ol?.details,hr,jl)||wr,Yu=hr&&jl?{...Yl(ol)?ol:{},runId:hr,nodeId:jl,details:hl,loading:Boolean(ol?.loading)||!hl&&Boolean(F.loading)&&A===jl,error:String(ol?.error||""),fetchedAt:ol?.fetchedAt||(wr?F.fetchedAt:null)}:null,eu=zl.map((fl)=>String(fl?.runId||"")).filter(Boolean).join("|"),rf=h.map((fl)=>String(fl?.id||"")).filter(Boolean).join("|");zn(()=>{S.current=A},[A]),zn(()=>{b.current=Bl},[Bl]),zn(()=>{if(!c||eu.split("|").includes(c))return;$("")},[c,eu]),zn(()=>{if(!A||rf.split("|").includes(A))return;j(""),U(ri()),J(di()),Z(!1),D(!1)},[A,rf]),zn(()=>{if(!A)Z(!1)},[A]),zn(()=>{if(!L.mode)D(!1)},[L.mode]);async function Ar(fl=Bl,Dl={}){if(!fl){Q(cj());return}let Cl=r0(Dl.scale??q??i_),dl=`${fl}:timeline`;if(m.current===dl)return;m.current=dl;let ju=Dl.silent===!0,ku=B.current+1;B.current=ku,Q(($u)=>({runId:fl,scale:Cl,loading:!ju||String($u.runId||"")!==fl||!$u.details,error:"",details:ju&&$u.runId===fl?$u.details:$u.runId===fl?$u.details:null,fetchedAt:$u.runId===fl?$u.fetchedAt:null}));try{let[$u,qr]=await Promise.all([oi(dc(r,`/api/node-control/runs/${encodeURIComponent(fl)}?tail=160&view=timeline`),{cache:"no-store",strictJson:!0}),oi(dc(r,`/api/runs/${encodeURIComponent(fl)}`),{cache:"no-store"}).catch((Yf)=>({ok:!1,runSummaryError:El(Yf,"抓取评分失败")}))]);if(ku!==B.current)return;Q({runId:fl,scale:Cl,loading:!1,error:"",details:{...$u,run:Yl(qr?.run)?qr.run:void 0,runSummaryError:qr?.runSummaryError},fetchedAt:new Date})}catch($u){if(ku!==B.current)return;Q((qr)=>({runId:fl,scale:Cl,loading:!1,error:El($u,"抓取 epoch 执行过程失败"),details:qr.runId===fl?qr.details:null,fetchedAt:qr.runId===fl?qr.fetchedAt:null}))}finally{if(m.current===dl)m.current=""}}function Zr(fl,Dl,Cl){let dl=tj(fl,Dl);W((ju)=>{let ku={...ju,[dl]:{...Yl(ju?.[dl])?ju[dl]:{},runId:fl,nodeId:Dl,...Cl}},$u=Object.keys(ku);if($u.length>32)for(let qr of $u.slice(0,$u.length-32))delete ku[qr];return ku})}async function Zn(fl,Dl){if(!fl||!Dl)return;let Cl=tj(fl,Dl),dl=Number(X.current?.[Cl]||0)+1;X.current={...X.current,[Cl]:dl},Zr(fl,Dl,{loading:!0,error:""});try{let ju=await oi(dc(r,`/api/node-control/runs/${encodeURIComponent(fl)}/nodes/${encodeURIComponent(Dl)}?tail=160`),{cache:"no-store",strictJson:!0});if(Number(X.current?.[Cl]||0)!==dl)return;let ku=new Date;if(Zr(fl,Dl,{loading:!1,details:ju,fetchedAt:ku,error:""}),S.current===Dl&&b.current===fl)U(($u)=>({...$u,loading:!1,details:ju,fetchedAt:ku,error:""}))}catch(ju){if(Number(X.current?.[Cl]||0)!==dl)return;Zr(fl,Dl,{loading:!1,error:El(ju,"抓取 Gantt node 详情失败")})}}zn(()=>{if(!Bl){Q(cj());return}Ar(Bl);let fl=()=>{if(XA())Ar(Bl,{silent:!0})},Dl=window.setInterval(()=>{fl()},kW),Cl=()=>{if(XA())fl()};return document.addEventListener("visibilitychange",Cl),()=>{window.clearInterval(Dl),document.removeEventListener("visibilitychange",Cl)}},[Bl,r]);async function ff(fl=Bl,Dl=A){if(!fl||!Dl){U((Cl)=>({...Cl,error:"请先选择 run 和 node",message:""}));return}U((Cl)=>({...Cl,loading:!0,error:"",message:""}));try{let Cl=await oi(dc(r,`/api/node-control/runs/${encodeURIComponent(fl)}/nodes/${encodeURIComponent(Dl)}?tail=160`),{cache:"no-store",strictJson:!0}),dl=new Date;U((ju)=>({...ju,loading:!1,details:Cl,fetchedAt:dl,error:""})),Zr(fl,Dl,{loading:!1,details:Cl,fetchedAt:dl,error:""})}catch(Cl){U((dl)=>({...dl,loading:!1,error:El(Cl,"抓取 node 执行过程失败")}))}}async function ii(fl){let Dl=String(fl?.runId||Bl||""),Cl=String(fl?.nodeId||"");if(J({mode:"interval",runId:Dl,interval:fl,marker:null}),D(!0),!Dl||!Cl)return;if(Dl!==Bl)$(Dl);j(Cl),U(ri()),Ar(Dl,{silent:!0}),Zn(Dl,Cl)}async function Au(fl){let Dl=String(fl?.runId||Bl||""),Cl=String(fl?.nodeId||"");if(J({mode:"event",runId:Dl,interval:null,marker:fl}),D(!0),!Dl)return;if(Dl!==Bl)$(Dl);if(Ar(Dl,{silent:!0}),!Cl)return;j(Cl),U(ri()),Zn(Dl,Cl)}async function nt(fl){if(!Bl||!A){U((dl)=>({...dl,error:"请先选择 run 和 node",message:""}));return}let Dl=fl==="append"?"prompts":fl,Cl=fl==="append"?F.appendPrompt:fl==="guide"?F.guidePrompt:fl==="modify"?F.modifyPrompt:fl==="approve"?F.approveReason:F.redoReason;if(!String(Cl||"").trim()){U((dl)=>({...dl,error:"操作内容不能为空",message:""}));return}U((dl)=>({...dl,actionLoading:fl,error:"",message:""}));try{let dl=fl==="redo"||fl==="approve"?{reason:Cl,source:"unidesk-frontend",sourceKind:"webui"}:{prompt:Cl,source:"unidesk-frontend",sourceKind:"webui"},ju=await oi(dc(r,`/api/node-control/runs/${encodeURIComponent(Bl)}/nodes/${encodeURIComponent(A)}/${Dl}`),{method:"POST",body:JSON.stringify(dl)});if(U(($u)=>({...$u,actionLoading:"",details:ju,fetchedAt:new Date,appendPrompt:fl==="append"?"":$u.appendPrompt,guidePrompt:fl==="guide"?"":$u.guidePrompt,modifyPrompt:fl==="modify"?"":$u.modifyPrompt,approveReason:fl==="approve"?"":$u.approveReason,redoReason:fl==="redo"?"":$u.redoReason,message:fl==="append"?"已追加到运行中 node":fl==="guide"?"已下发 guide,等待 runner 处理":fl==="modify"?"已排队增量修改命令":fl==="approve"?"已提交审核通过决策":"已排队重做命令"})),p("success",fl==="append"?"已追加到运行中 node":fl==="guide"?"已下发 guide,等待 runner 处理":fl==="modify"?"已排队增量修改命令":fl==="approve"?"已提交审核通过决策":"已排队重做命令"),await ff(Bl,A),await Ar(Bl,{silent:!0}),fl!=="append")await z()}catch(dl){U((ju)=>({...ju,actionLoading:"",error:El(dl,"node 控制操作失败")}))}}if(!f)return K(qf,{title:"Pipeline 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=pipeline"});return K("div",{className:"pipeline-page","data-testid":"pipeline-page"},K(Kn,{title:"Pipeline v2 工作台",eyebrow:"D601 Snapshot 用户服务",loading:n.loading,actions:K("div",{className:"panel-actions"},K("button",{type:"button",className:"ghost-btn",onClick:z,disabled:n.loading,"data-testid":"pipeline-refresh-button"},n.loading?"刷新中":"刷新"),K(rn,{title:"Pipeline 用户服务",data:f,onOpen:u,testId:"raw-pipeline-service"}))},K("div",{className:"pipeline-hero"},K("div",null,K("div",{className:"node-version-line"},K(u0,{status:P.providerStatus==="online"?"online":"warn"},P.providerStatus||"unknown"),K("span",null,f.providerId),K("span",null,k.public?"公网暴露":"仅 UniDesk frontend 代理访问")),K("p",{className:"muted paragraph"},f.description)),K("div",{className:"microservice-ref-card"},K("span",null,"Repo"),K("strong",null,s.url||"--"),K("code",null,s.commitId||"--")),K("div",{className:"microservice-ref-card"},K("span",null,"D601 Docker"),K("strong",null,`${k.nodeBindHost||"--"}:${k.nodePort||"--"}`),K("code",null,`${s.composeFile||"--"} / ${s.composeService||"--"}`))),K(lu,{error:n.error,wide:!0})),K("div",{className:"pipeline-grid"},K(Kn,{title:"控制图",eyebrow:`${Ql.id||"pipeline"} / run ${pl?.status||"--"}`,className:"pipeline-wide-panel",loading:n.loading,actions:K("div",{className:"pipeline-toolbar"},K("select",{value:Ol,disabled:rl.length===0,onChange:(fl)=>{y(fl.target.value),$(""),j(""),U(ri()),J(di()),Z(!1),D(!1)},"data-testid":"pipeline-select"},rl.map((fl)=>K("option",{key:fl.id,value:fl.id},fl.id||fl.key))),K("select",{value:Bl,disabled:zl.length===0,onChange:(fl)=>{if($(fl.target.value),U(ri()),J(di()),Z(!1),D(!1),A)ff(fl.target.value,A)},"data-testid":"pipeline-run-select"},zl.map((fl)=>K("option",{key:fl.runId,value:fl.runId},Jj(zl,fl)))),K("button",{type:"button",className:"ghost-btn",disabled:ir.nodes.length===0,onClick:()=>zL(ir,`${Ql.id||"pipeline"}-${pl?.runId||"snapshot"}`),"data-testid":"pipeline-export-graph"},"导出渲染图"),K("button",{type:"button",className:"ghost-btn",disabled:tr.every((fl)=>fl.flow.nodes.length===0),onClick:()=>GX(tr),"data-testid":"pipeline-export-all-graphs"},"批量导出"))},h.length===0?K(qf,{title:"暂无控制图",text:"等待 D601 pipeline backend 返回 config.nodes / config.edges"}):K("div",{className:`pipeline-control-shell ${O?"detail-open":"detail-collapsed"}`,"data-testid":"pipeline-control-shell","data-sidebar-open":O?"true":"false"},K("div",{className:"pipeline-flow-frame","data-testid":"pipeline-react-flow"},K(MW,{nodes:ir.nodes,edges:ir.edges,nodeTypes:XS,edgeTypes:SS,fitView:!0,fitViewOptions:{padding:0.18},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,minZoom:0.25,maxZoom:1.4,proOptions:{hideAttribution:!0},onNodeClick:(fl,Dl)=>{let Cl=String(Dl.id);if(j(Cl),U(ri()),Z(!0),Bl)ff(Bl,Cl)}},K(RW,{gap:22,size:1,color:"rgba(215, 161, 58, 0.24)"}),K(bW,{showInteractive:!1})),!O?K("button",{type:"button",className:"pipeline-sidecar-tab right",disabled:!A,onClick:()=>Z(!0),"data-testid":"pipeline-node-sidebar-toggle"},A?"展开 node 控制":"点击 node 展开控制"):null),O?K(IX,{activeRun:pl,pipelineRuns:zl,selectedRunId:c,onRunChange:(fl)=>{if($(fl),U(ri()),J(di()),A)ff(fl,A)},selectedNodeId:A,selectedNodeConfig:Il,selectedNodeRuntime:nu,control:F,onControlChange:(fl)=>U((Dl)=>({...Dl,...fl})),onFetch:()=>ff(),onAction:nt,onRaw:u,onCollapse:()=>Z(!1)}):null),K("div",{className:"pipeline-flow-summary"},K("span",null,`${ir.nodes.length} nodes`),K("span",null,`${ir.edges.length} edges`),K("span",null,`${rl.length} pipelines`),K("span",null,`source config+components(${M.length})`),K("span",null,`run ${pl?.runId||"--"}`),K("span",null,`score ${Fj(pl)}`),K("span",null,A?`selected ${A}`:"click node to control"))),K(gX,{epochs:zl,activeRun:pl,activePipeline:Ql,pipelineNodes:h,pipelineEdges:a,selection:L,detailOpen:E,onDetailOpenChange:D,runDetails:w,nodeDetails:hl,nodeDetailsState:Yu,ganttScale:q,onGanttScaleChange:T,onIntervalSelect:ii,onMarkerSelect:Au,onRunChange:(fl)=>{if($(fl),U(ri()),J(di()),D(!1),A)ff(fl,A)},onRaw:u}),K(Kn,{title:"观测指标",eyebrow:n.refreshedAt?`Updated ${iu(n.refreshedAt)}`:"Snapshot",loading:n.loading},K("div",{className:"metric-grid"},K(Mr,{label:"Health",value:n.health?.ok?"OK":"--",hint:n.health?.service||"D601 /health",tone:n.health?.ok?"ok":"warn"}),K(Mr,{label:"组件",value:Qr,hint:"components registry",tone:v?.registry?.ok===!1?"warn":"ok"}),K(Mr,{label:"Pipeline",value:rl.length,hint:`${h.length} nodes / ${a.length} edges`}),K(Mr,{label:"运行记录",value:Or,hint:`${Ml.succeeded||0} succeeded / ${Ml.running||0} running`}),K(Mr,{label:"OA 记录",value:Array.isArray(ul?.submissions)?ul.submissions.length:0,hint:ul?.runId||"latest run"}),K(Mr,{label:"Procedure",value:Array.isArray(ul?.procedureRuns)?ul.procedureRuns.length:0,hint:ul?.status||"no run"}),K(Mr,{label:"Score",value:Fj(pl),hint:pl?.runId||"selected epoch",tone:Tj(pl)})),K("div",{className:"panel-actions inline-actions"},K(rn,{title:"Pipeline Snapshot",data:v,onOpen:u,testId:"raw-pipeline-snapshot"}))),K(Kn,{title:"评分器",eyebrow:pl?.runId||"selected epoch",loading:n.loading},K(yX,{run:pl,onRaw:u})),K(Kn,{title:"MiniMax 限额",eyebrow:"model/minimax-m27 quota",loading:n.loading},K(kX,{quota:I,onRaw:u})),K(Kn,{title:"OA 事件流",eyebrow:"100% event-driven diagnostics",className:"pipeline-wide-panel",loading:n.loading},K(sX,{diagnostics:tl,onRaw:u})),K(Kn,{title:"组件矩阵",eyebrow:`${wu.length} classes`,loading:n.loading},wu.length===0?K(qf,{title:"暂无组件",text:"等待 D601 pipeline backend 返回 registry.components"}):K("div",{className:"component-strata"},wu.map((fl)=>K("article",{key:fl.name,className:"component-stratum"},K("span",null,fl.name),K("strong",null,fl.count)))),K("div",{className:"pipeline-component-list"},M.slice(0,12).map((fl)=>K("span",{key:fl.key,className:"data-chip"},K("b",null,fl.componentClass||"--"),K("span",null,fl.id||fl.key||"--"))))),K(Kn,{title:"Epoch 列表",eyebrow:`${zl.length}/${Or} preview`,loading:n.loading},zl.length===0?K(qf,{title:"暂无运行记录",text:"当前 pipeline 在 .state/pipeline-runs 中还没有 epoch。"}):K("div",{className:"pipeline-run-list"},zl.map((fl)=>{let Dl=String(fl?.runId||"")===Bl?pl:fl;return K("article",{key:fl.runId,className:`pipeline-run-card ${String(fl.runId||"")===Bl?"active":""}`,role:"button",tabIndex:0,onClick:()=>{$(String(fl.runId||"")),J(di())},onKeyDown:(Cl)=>{if(Cl.key==="Enter"||Cl.key===" ")$(String(fl.runId||"")),J(di())}},K("div",{className:"node-card-head"},K("strong",null,Jj(zl,fl)),K(u0,{status:fl.status},fl.status||"--")),K("div",{className:"docker-meta compact"},K("span",null,Dl?.pipelineId||"--"),K("span",null,`nodes ${Array.isArray(Dl?.nodes)?Dl.nodes.length:0}`),K("span",null,`oa ${Array.isArray(Dl?.submissions)?Dl.submissions.length:0}`),K("span",null,`procedures ${Array.isArray(Dl?.procedureRuns)?Dl.procedureRuns.length:0}`),K(tX,{run:Dl})),K("p",{className:"muted paragraph"},RA(Dl?.task)),K("span",{className:"pipeline-run-time"},Wl(Dl?.updatedAt)))}))),K(Kn,{title:"运行材料索引",eyebrow:pl?.runId||"selected epoch",className:"pipeline-wide-panel",loading:n.loading},K(vX,{activeRun:pl,onRaw:u}))))}var l6=Rl(Ju(),1);var _l=l6.default.createElement,{useEffect:aX}=l6.default,dA=l6.default.useState,Ej={id:"",sequenceNo:"",contractNo:"",name:"",currentStatus:"",pending:"",paymentStatus:"",notes:""};function oX({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return _l("span",{className:`status-badge ${r}`},u||l||"unknown")}function eA({label:l,value:u,hint:r,tone:f}){return _l("article",{className:`metric-card ${f||""}`},_l("div",{className:"metric-label"},l),_l("div",{className:"metric-value"},u),_l("div",{className:"metric-hint"},r))}function Oj({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return _l("section",{className:`panel ${n||""}`},_l("div",{className:"panel-head"},_l("div",null,u?_l("p",{className:"panel-eyebrow"},u):null,_l(fu,{title:l,loading:i})),r?_l("div",{className:"panel-actions"},r):null),_l("div",{className:"panel-body"},f))}function XL({title:l,data:u,onOpen:r,testId:f}){return _l("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function YL({title:l,text:u}){return _l("div",{className:"empty-state"},_l("strong",null,l),_l("span",null,u))}function dX(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function eX(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function lY(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function Yy(l,u){return`${l}/microservices/project-manager/proxy${u}`}function uY(l){return{id:String(l.id||""),sequenceNo:l.sequenceNo===null||l.sequenceNo===void 0?"":String(l.sequenceNo),contractNo:String(l.contractNo||""),name:String(l.name||""),currentStatus:String(l.currentStatus||""),pending:String(l.pending||""),paymentStatus:String(l.paymentStatus||""),notes:String(l.notes||"")}}function rY(l){return{sequenceNo:l.sequenceNo===""?null:Number(l.sequenceNo),contractNo:String(l.contractNo||"").trim(),name:String(l.name||"").trim(),currentStatus:String(l.currentStatus||"").trim(),pending:String(l.pending||"").trim(),paymentStatus:String(l.paymentStatus||"").trim(),paymentRatio:String(l.paymentStatus||"").trim(),notes:String(l.notes||"").trim()}}function Zj(l){return String(l||"item").replace(/[^A-Za-z0-9_-]+/g,"-")}function fY(l){let u=new Uint8Array(l),r="",f=32768;for(let n=0;n<u.length;n+=f)r+=String.fromCharCode(...u.subarray(n,n+f));return btoa(r)}function nY({projects:l,activeId:u,onSelect:r,onRaw:f}){if(!l.length)return _l(YL,{title:"暂无项目",text:"可以从 Excel 导入,或用右侧表单新建项目。"});return _l("div",{className:"table-wrap project-manager-table","data-testid":"project-manager-table"},_l("table",null,_l("thead",null,_l("tr",null,_l("th",null,"序号"),_l("th",null,"合同号"),_l("th",null,"项目名称"),_l("th",null,"当前状况"),_l("th",null,"待完成"),_l("th",null,"付款"),_l("th",null,"其它"),_l("th",null,"操作"))),_l("tbody",null,l.map((n)=>_l("tr",{key:n.id,className:u===n.id?"active-row":"","data-testid":`project-manager-row-${Zj(n.id)}`},_l("td",null,n.sequenceNo??"--"),_l("td",null,_l("strong",null,n.contractNo||"--"),_l("code",null,n.id||"--")),_l("td",null,_l("strong",null,n.name||"--"),_l("span",{className:"muted block"},n.sourceFile||"--")),_l("td",null,n.currentStatus||"--"),_l("td",null,_l("span",{className:"preline"},n.pending||"--")),_l("td",null,_l(oX,{status:Number(n.paymentRatio||0)>=1?"online":"warn"},n.paymentStatus||"--")),_l("td",null,n.notes||"--"),_l("td",null,_l("div",{className:"inline-actions"},_l("button",{type:"button",className:"ghost-btn",onClick:()=>r(n),"data-testid":`project-manager-edit-${Zj(n.id)}`},"编辑"),_l(XL,{title:`Project ${n.contractNo||n.id}`,data:n,onOpen:f,testId:`raw-project-${Zj(n.id)}`}))))))))}function PL({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((E)=>E.id==="project-manager")||null,[n,i]=dA({loading:!1,saving:!1,importing:!1,exporting:!1,error:"",notice:"",health:null,list:null,refreshedAt:null}),[t,y]=dA({...Ej}),[c,$]=dA(""),[A,j]=dA("all"),{addNotification:F}=Xr();async function U(E=c,D=A){if(!f)return;i((Y)=>({...Y,loading:!0,error:""}));try{let Y=new URLSearchParams({pageSize:"200",status:D});if(E.trim())Y.set("q",E.trim());let[p,V]=await Promise.all([ml(`${r}/microservices/project-manager/health`),ml(Yy(r,`/api/projects?${Y.toString()}`))]);i((B)=>({...B,loading:!1,health:p,list:V,refreshedAt:new Date,error:""}))}catch(Y){i((p)=>({...p,loading:!1,error:El(Y,"Project Manager 加载失败")}))}}aX(()=>{U()},[f?.id,f?.runtime?.providerStatus]);async function N(E){E.preventDefault(),i((D)=>({...D,saving:!0,error:"",notice:""}));try{let D=rY(t);if(t.id)await ml(Yy(r,`/api/projects/${encodeURIComponent(t.id)}`),{method:"PUT",body:JSON.stringify(D)});else await ml(Yy(r,"/api/projects"),{method:"POST",body:JSON.stringify(D)});let Y=t.id?"项目已更新":"项目已创建";i((p)=>({...p,saving:!1,notice:Y})),F("success",Y),await U()}catch(D){i((Y)=>({...Y,saving:!1,error:El(D,"保存项目失败")}))}}async function W(){if(!t.id)return;if(!window.confirm(`删除项目 ${t.contractNo||t.name||t.id} ?`))return;i((E)=>({...E,saving:!0,error:"",notice:""}));try{await ml(Yy(r,`/api/projects/${encodeURIComponent(t.id)}`),{method:"DELETE"}),y({...Ej});let E="项目已删除";i((D)=>({...D,saving:!1,notice:E})),F("success",E),await U()}catch(E){i((D)=>({...D,saving:!1,error:El(E,"删除项目失败")}))}}async function L(E){let D=E.target.files?.[0];if(!D)return;i((Y)=>({...Y,importing:!0,error:"",notice:""}));try{let Y=fY(await D.arrayBuffer()),V=`Excel 已导入 ${(await ml(Yy(r,"/api/import/excel"),{method:"POST",body:JSON.stringify({fileName:D.name,contentBase64:Y,replace:!1})})).imported||0} 条项目`;i((B)=>({...B,importing:!1,notice:V})),F("success",V),E.target.value="",await U()}catch(Y){i((p)=>({...p,importing:!1,error:El(Y,"Excel 导入失败")}))}}async function J(){i((E)=>({...E,exporting:!0,error:""}));try{let E=await IU(Yy(r,"/api/projects/export.xlsx")),D=URL.createObjectURL(E),Y=document.createElement("a");Y.href=D,Y.download=`project-manager-${E7()}.xlsx`,document.body.appendChild(Y),Y.click(),Y.remove(),URL.revokeObjectURL(D),i((p)=>({...p,exporting:!1,notice:"Excel 已导出"}))}catch(E){i((D)=>({...D,exporting:!1,error:El(E,"Excel 导出失败")}))}}if(!f)return _l(YL,{title:"Project Manager 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=project-manager"});let w=dX(f),Q=lY(f),q=eX(f),T=Array.isArray(n.list?.projects)?n.list.projects:[],O=n.list?.summary||{},Z=n.health||{};return _l("div",{className:"project-manager-page","data-testid":"project-manager-page"},_l(Oj,{title:"项目管理工作台",eyebrow:"Main Server PostgreSQL 用户服务",loading:n.loading||n.exporting,actions:_l("div",{className:"panel-actions"},_l("button",{type:"button",className:"ghost-btn",disabled:n.loading,onClick:()=>U(),"data-testid":"project-manager-refresh-button"},n.loading?"刷新中":"刷新"),_l("button",{type:"button",className:"ghost-btn",disabled:n.exporting,onClick:J,"data-testid":"project-manager-export-button"},n.exporting?"导出中":"导出 Excel"),_l(XL,{title:"Project Manager 用户服务",data:f,onOpen:u,testId:"raw-project-manager-service"}))},_l("div",{className:"project-manager-hero"},_l(eA,{label:"项目总数",value:O.total??T.length,hint:`PG 表 ${Z.storage?.table||"project_manager_projects"}`,tone:"ok"}),_l(eA,{label:"进行中",value:O.active??"--",hint:"当前状态未完全完成"}),_l(eA,{label:"已完成",value:O.completed??"--",hint:"按 完成 关键字统计",tone:"ok"}),_l(eA,{label:"未全款",value:O.unpaid??"--",hint:"付款比例 < 1",tone:Number(O.unpaid||0)>0?"warn":"ok"})),_l(lu,{error:n.error}),n.notice?_l("div",{className:"form-success"},n.notice):null),_l("div",{className:"project-manager-hero"},_l("div",{className:"microservice-ref-card"},_l("span",null,"Repo"),_l("strong",null,Q.url||"--"),_l("code",null,Q.commitId||"--")),_l("div",{className:"microservice-ref-card"},_l("span",null,"Main Server Docker"),_l("strong",null,`${q.nodeBindHost||"--"}:${q.nodePort||"--"}`),_l("code",null,`${Q.composeService||"--"} / ${Q.containerName||"--"}`)),_l("div",{className:"microservice-ref-card"},_l("span",null,"Runtime"),_l("strong",null,w.providerName||f.providerId),_l("code",null,`Health ${Z.ok?"OK":"--"} / ${n.refreshedAt?iu(n.refreshedAt):"--"}`)),_l("div",{className:"microservice-ref-card"},_l("span",null,"Import Source"),_l("strong",null,"D601 WeChat Excel"),_l("code",null,"合作项目列表_I_20260309.xlsx"))),_l("div",{className:"project-manager-layout"},_l(Oj,{title:"项目清单",eyebrow:"CRUD + Excel Export",loading:n.loading||n.importing||n.exporting,actions:_l("div",{className:"inline-actions project-manager-filters"},_l("input",{value:c,onChange:(E)=>$(E.target.value),placeholder:"搜索合同号 / 项目名称 / 状态","data-testid":"project-manager-search"}),_l("select",{value:A,onChange:(E)=>{j(E.target.value),U(c,E.target.value)},"data-testid":"project-manager-status-filter"},_l("option",{value:"all"},"全部"),_l("option",{value:"active"},"进行中"),_l("option",{value:"completed"},"已完成"),_l("option",{value:"unpaid"},"未全款")),_l("button",{type:"button",className:"ghost-btn",onClick:()=>U(c,A)},"筛选"))},_l(nY,{projects:T,activeId:t.id,onSelect:(E)=>y(uY(E)),onRaw:u})),_l(Oj,{title:t.id?"编辑项目":"新建项目",eyebrow:"PostgreSQL Write Path",loading:n.saving||n.importing},_l("form",{className:"stack-form project-manager-form",onSubmit:N,"data-testid":"project-manager-form"},t.id?_l("label",null,"项目 ID",_l("input",{value:t.id,disabled:!0})):null,_l("label",null,"序号",_l("input",{type:"number",value:t.sequenceNo,onChange:(E)=>y((D)=>({...D,sequenceNo:E.target.value}))})),_l("label",null,"合同号",_l("input",{value:t.contractNo,onChange:(E)=>y((D)=>({...D,contractNo:E.target.value})),required:!0})),_l("label",null,"项目名称",_l("input",{value:t.name,onChange:(E)=>y((D)=>({...D,name:E.target.value})),required:!0})),_l("label",null,"当前状况",_l("textarea",{value:t.currentStatus,onChange:(E)=>y((D)=>({...D,currentStatus:E.target.value}))})),_l("label",null,"待完成",_l("textarea",{value:t.pending,onChange:(E)=>y((D)=>({...D,pending:E.target.value}))})),_l("label",null,"付款情况",_l("input",{value:t.paymentStatus,onChange:(E)=>y((D)=>({...D,paymentStatus:E.target.value})),placeholder:"例如 1 / 0.5 / 50%"})),_l("label",null,"其它",_l("input",{value:t.notes,onChange:(E)=>y((D)=>({...D,notes:E.target.value}))})),_l("div",{className:"inline-actions"},_l("button",{type:"submit",className:"primary-btn",disabled:n.saving,"data-testid":"project-manager-save-button"},n.saving?"保存中":t.id?"保存修改":"创建项目"),_l("button",{type:"button",className:"ghost-btn",onClick:()=>y({...Ej})},"清空"),t.id?_l("button",{type:"button",className:"danger-btn",disabled:n.saving,onClick:W,"data-testid":"project-manager-delete-button"},"删除"):null)),_l("div",{className:"project-manager-import"},_l("p",{className:"muted paragraph"},"浏览器只访问 UniDesk frontend;后端通过同源用户服务代理写入主 PostgreSQL,不暴露 4233 公网端口。"),_l("label",{className:"file-import"},n.importing?"导入中...":"导入 Excel",_l("input",{type:"file",accept:".xlsx",onChange:L,disabled:n.importing,"data-testid":"project-manager-import-input"}))))))}var f6=Rl(Ju(),1);var Fl=f6.default.createElement,{useEffect:iY}=f6.default,lf=f6.default.useState;function tY({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return Fl("span",{className:`status-badge ${r}`},u||l||"unknown")}function u6({label:l,value:u,hint:r,tone:f}){return Fl("article",{className:`metric-card ${f||""}`},Fl("div",{className:"metric-label"},l),Fl("div",{className:"metric-value"},u),Fl("div",{className:"metric-hint"},r))}function pj({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return Fl("section",{className:`panel ${n||""}`},Fl("div",{className:"panel-head"},Fl("div",null,u?Fl("p",{className:"panel-eyebrow"},u):null,Fl(fu,{title:l,loading:i})),r?Fl("div",{className:"panel-actions"},r):null),Fl("div",{className:"panel-body"},f))}function CL({title:l,data:u,onOpen:r,testId:f}){return Fl("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r(l,u)},"查看原始JSON")}function r6({title:l,text:u}){return Fl("div",{className:"empty-state"},Fl("strong",null,l),Fl("span",null,u))}function yY(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function cY(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function _Y(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function hL(l){return String(l).replace(/[^a-zA-Z0-9_-]/g,"_")}function $Y(l){if(!Number.isFinite(l))return"--";return`${l.toFixed(1)}%`}function Py(l,u){return`${l}/microservices/todo-note/proxy${u}`}function RL(l){return l.reduce((u,r)=>{let f=RL(Array.isArray(r.children)?r.children:[]),n=Boolean(r.completed);return{total:u.total+1+f.total,completed:u.completed+(n?1:0)+f.completed,active:u.active+(n?0:1)+f.active}},{total:0,completed:0,active:0})}function Bj(l,u){let r=u==="all"||(u==="completed"?Boolean(l.completed):!l.completed),f=Array.isArray(l.children)?l.children:[];return r||f.some((n)=>Bj(n,u))}function ML(l){return Array.isArray(l?.instances)?l.instances:[]}function Hj(l,u){for(let r of l){if(r?.id===u)return Array.isArray(r.children)?r.children:[];let f=Hj(Array.isArray(r?.children)?r.children:[],u);if(f.length>0)return f}return[]}function xL({microservices:l,onRaw:u,apiBaseUrl:r="/api"}){let f=l.find((o)=>o.id==="todo-note")||null,[n,i]=lf(null),[t,y]=lf(null),[c,$]=lf(""),[A,j]=lf(null),[F,U]=lf("all"),[N,W]=lf(13),[L,J]=lf(""),[w,Q]=lf(""),[q,T]=lf(""),[O,Z]=lf(""),[E,D]=lf(""),[Y,p]=lf(!1),[V,B]=lf(""),[m,X]=lf(null),S=ML(t),b=RL(Array.isArray(A?.todos)?A.todos:[]),z=f?yY(f):{},P=f?_Y(f):{},s=f?cY(f):{};async function k(o=c){let[ql,pl]=await Promise.all([ml(`${r}/microservices/todo-note/health`),ml(Py(r,"/api/instances"))]);i(ql),y(pl);let Bl=ML(pl),Il=Bl.some((nu)=>nu.id===o)?o:Bl[0]?.id||"";return $(Il),Il}async function v(o=c){if(!o){j(null);return}let ql=await ml(Py(r,`/api/instances/${encodeURIComponent(o)}`));j(ql)}async function tl(o=c){if(!f)return;p(!0),B("");try{let ql=await k(o);await v(ql),X(new Date)}catch(ql){B(El(ql,"Todo Note 加载失败"))}finally{p(!1)}}async function I(o){if(!c)return null;B("");try{let ql=await ml(Py(r,`/api/instances/${encodeURIComponent(c)}/actions`),{method:"POST",body:JSON.stringify({action:o})});return j(ql),await k(c),ql}catch(ql){return B(El(ql,"Todo 操作失败")),null}}async function M(o){o.preventDefault();let ql=L.trim();if(!ql)return;p(!0),B("");try{let pl=await ml(Py(r,"/api/instances"),{method:"POST",body:JSON.stringify({name:ql})});J(""),await tl(pl.id)}catch(pl){B(El(pl,"创建清单失败"))}finally{p(!1)}}async function rl(o){if(!window.confirm("确认删除这个 Todo Note 清单?"))return;p(!0),B("");try{await ml(Py(r,`/api/instances/${encodeURIComponent(o)}`),{method:"DELETE"}),await tl(c===o?"":c)}catch(ql){B(El(ql,"删除清单失败"))}finally{p(!1)}}async function cl(o){o.preventDefault();let ql=w.trim();if(!ql)return;Q(""),await I({type:"addTodo",title:ql})}async function $l(o){if(!c)return;B("");try{let ql=await ml(Py(r,`/api/instances/${encodeURIComponent(c)}/${o}`),{method:"POST",body:JSON.stringify({})});j(ql),await k(c)}catch(ql){B(El(ql,`${o} 失败`))}}function Tl(o){T(o.id),Z(String(o.title||""))}async function Ql(o){let ql=O.trim();if(T(""),Z(""),ql)await I({type:"updateTodoTitle",todoId:o,title:ql})}async function Ol(o){let pl=window.prompt("新增子任务标题")?.trim();if(!pl)return;let Bl=Hj(Array.isArray(A?.todos)?A.todos:[],o),Il=new Set(Bl.map((Qr)=>Qr.id)),nu=await I({type:"addTodo",title:pl,parentId:o,targetIndex:0});if(!nu)return;let Ml=Hj(Array.isArray(nu?.todos)?nu.todos:[],o),wu=Ml.find((Qr)=>!Il.has(Qr.id));if(wu&&Ml[0]?.id!==wu.id)await I({type:"moveTodo",todoId:wu.id,targetParentId:o,targetIndex:0})}async function h(o,ql){if(!E)return;let pl={type:"moveTodo",todoId:E,targetIndex:ql};if(o)pl.targetParentId=o;D(""),await I(pl)}if(iY(()=>{tl()},[f?.id,f?.runtime?.providerStatus]),!f)return Fl(r6,{title:"Todo Note 未登记",text:"请在 config.json 的 microservices 中登记用户服务 id=todo-note"});let a=S.find((o)=>o.id===c)||null,ul=Array.isArray(A?.todos)?A.todos:[],zl=ul.map((o,ql)=>({todo:o,index:ql})).filter((o)=>Bj(o.todo,F));return Fl("div",{className:"todo-note-page","data-testid":"todo-note-page"},Fl(pj,{title:"Todo Note 工作台",eyebrow:"Main Server 用户服务",loading:Y,actions:Fl("div",{className:"panel-actions"},Fl("button",{type:"button",className:"ghost-btn",disabled:Y,onClick:()=>tl(c),"data-testid":"todo-note-refresh-button"},Y?"刷新中":"刷新"),Fl(CL,{title:"Todo Note 用户服务",data:f,onOpen:u,testId:"raw-todo-note-service"}))},Fl("div",{className:"todo-note-hero"},Fl("div",null,Fl("div",{className:"node-version-line"},Fl(tY,{status:z.providerStatus==="online"?"online":"warn"},z.providerStatus||"unknown"),Fl("span",null,f.providerId),Fl("span",null,s.public?"公网暴露":"仅 UniDesk frontend 代理访问"),Fl("span",null,n?.ok?"Health OK":"Health --")),Fl("p",{className:"muted paragraph"},f.description)),Fl("div",{className:"microservice-ref-card"},Fl("span",null,"Repo"),Fl("strong",null,P.url||"--"),Fl("code",null,P.commitId||"--")),Fl("div",{className:"microservice-ref-card"},Fl("span",null,"Main Server Docker"),Fl("strong",null,`${s.nodeBindHost||"--"}:${s.nodePort||"--"}`),Fl("code",null,`${P.composeService||"--"} / ${P.containerName||"--"}`))),Fl(lu,{error:V,wide:!0})),Fl("div",{className:"todo-note-layout"},Fl(pj,{title:"清单",eyebrow:`${S.length} Instances`,className:"todo-list-panel",loading:Y},Fl("form",{className:"todo-create-list",onSubmit:M},Fl("input",{placeholder:"新清单名称",value:L,onChange:(o)=>J(o.target.value),"aria-label":"新清单名称"}),Fl("button",{type:"submit",className:"ghost-btn",disabled:Y||!L.trim()},"创建")),S.length===0?Fl(r6,{title:"暂无清单",text:"迁移或创建清单后会出现在这里"}):Fl("div",{className:"todo-instance-list"},S.map((o)=>Fl("button",{key:o.id,type:"button",className:`todo-instance-row ${c===o.id?"active":""}`,onClick:()=>{$(o.id),v(o.id)},"data-testid":`todo-instance-${hL(o.id)}`},Fl("strong",null,o.name),Fl("span",null,`${o.completedCount??0}/${o.todoCount??0} 完成`),Fl("code",null,o.id))))),Fl("div",{className:"todo-main-stack"},Fl(pj,{title:a?.name||"待选择清单",eyebrow:m?`Updated ${iu(m)}`:"Todo Tree",loading:Y,actions:A?Fl("div",{className:"panel-actions"},Fl("button",{type:"button",className:"ghost-btn",onClick:()=>I({type:"renameInstance",name:window.prompt("清单新名称",A.name)||A.name})},"重命名"),Fl("button",{type:"button",className:"ghost-btn danger",onClick:()=>rl(c)},"删除清单"),Fl(CL,{title:`Todo Instance ${c}`,data:A,onOpen:u,testId:"raw-todo-instance"})):null},!A?Fl(r6,{title:"未选择清单",text:"左侧选择一个 Todo Note 清单"}):Fl("div",{className:"todo-workbench",style:{"--todo-font-size":`${N}px`}},Fl("div",{className:"todo-toolbar"},Fl("form",{className:"todo-add-form",onSubmit:cl},Fl("input",{placeholder:"新增根任务",value:w,onChange:(o)=>Q(o.target.value),"aria-label":"新增根任务"}),Fl("button",{type:"submit",className:"ghost-btn",disabled:!w.trim()},"新增")),Fl("div",{className:"todo-filter-strip"},["all","active","completed"].map((o)=>Fl("button",{key:o,type:"button",className:`todo-filter ${F===o?"active":""}`,onClick:()=>U(o)},o==="all"?"全部":o==="active"?"未完成":"已完成"))),Fl("div",{className:"todo-toolbar-actions"},Fl("button",{type:"button",className:"ghost-btn",onClick:()=>I({type:"setAllTodosExpanded",expanded:!0})},"全部展开"),Fl("button",{type:"button",className:"ghost-btn",onClick:()=>I({type:"setAllTodosExpanded",expanded:!1})},"全部收起"),Fl("button",{type:"button",className:"ghost-btn",onClick:()=>$l("undo")},"撤销"),Fl("button",{type:"button",className:"ghost-btn",onClick:()=>$l("redo")},"重做"),Fl("label",{className:"todo-font-control"},"字号",Fl("input",{type:"range",min:11,max:18,value:N,onChange:(o)=>W(Number(o.target.value))})))),Fl("div",{className:"todo-stats-grid"},Fl(u6,{label:"总任务",value:b.total,hint:`${S.length} lists`}),Fl(u6,{label:"已完成",value:b.completed,hint:`${$Y(b.total?b.completed/b.total*100:0)}`,tone:"ok"}),Fl(u6,{label:"未完成",value:b.active,hint:F==="active"?"当前筛选":"active tasks",tone:b.active>0?"warn":"ok"}),Fl(u6,{label:"历史指针",value:A.historyPointer??0,hint:"undo / redo"})),Fl("div",{className:"todo-root-drop",onDragOver:(o)=>o.preventDefault(),onDrop:(o)=>{o.preventDefault(),h(null,ul.length)}},"拖到这里可移为根任务末尾"),Fl("div",{className:"todo-tree","data-testid":"todo-note-tree"},zl.length===0?Fl(r6,{title:"没有匹配任务",text:"调整筛选或新增任务"}):zl.map(({todo:o,index:ql})=>Fl(bL,{key:o.id,todo:o,depth:0,parentId:null,index:ql,siblingCount:ul.length,filter:F,editingId:q,editingTitle:O,setEditingTitle:Z,beginEdit:Tl,saveEdit:Ql,applyTodoAction:I,addChild:Ol,dragTodoId:E,setDragTodoId:D,dropTodo:h}))))))))}function bL(l){let{todo:u,depth:r,parentId:f,index:n,siblingCount:i,filter:t,editingId:y,editingTitle:c,setEditingTitle:$,beginEdit:A,saveEdit:j,applyTodoAction:F,addChild:U,dragTodoId:N,setDragTodoId:W,dropTodo:L}=l,J=Array.isArray(u.children)?u.children:[],w=J.map((T,O)=>({child:T,childIndex:O})).filter((T)=>Bj(T.child,t)),Q=y===u.id,q=f||null;return Fl("div",{className:"todo-row-wrap"},Fl("article",{className:`todo-row ${u.completed?"completed":""} ${N===u.id?"dragging":""}`,style:{"--todo-depth":r},draggable:!0,onDragStart:(T)=>{W(u.id),T.dataTransfer.effectAllowed="move"},onDragOver:(T)=>T.preventDefault(),onDrop:(T)=>{T.preventDefault(),L(u.id,J.length)},"data-testid":`todo-row-${hL(u.id)}`},Fl("button",{type:"button",className:"todo-expand",disabled:J.length===0,onClick:()=>F({type:"toggleTodoExpanded",todoId:u.id})},J.length===0?"·":u.expanded?"▾":"▸"),Fl("input",{type:"checkbox",checked:Boolean(u.completed),onChange:()=>F({type:"toggleTodoCompleted",todoId:u.id}),"aria-label":`完成 ${u.title}`}),Fl("div",{className:"todo-title-cell",onDoubleClick:()=>A(u)},Q?Fl("div",{className:"todo-edit-inline"},Fl("input",{value:c,autoFocus:!0,onChange:(T)=>$(T.target.value),onKeyDown:(T)=>{if(T.key==="Enter")j(u.id);if(T.key==="Escape")A({id:"",title:""})}}),Fl("button",{type:"button",className:"ghost-btn",onClick:()=>j(u.id)},"保存")):Fl("strong",null,u.title||"Untitled"),Fl("div",{className:"todo-meta-line"},Fl("span",null,`子项 ${J.length}`),Fl("span",null,`更新 ${Wl(u.updatedAt)}`),u.reminderAt?Fl("span",{className:"todo-reminder"},`提醒 ${Wl(u.reminderAt)}`):Fl("span",null,"无提醒"))),Fl("input",{className:"todo-reminder-input",type:"datetime-local",value:D6(u.reminderAt),onChange:(T)=>F({type:"setTodoReminder",todoId:u.id,reminderAt:O7(T.target.value)})}),Fl("div",{className:"todo-row-actions"},Fl("button",{type:"button",className:"ghost-btn",onClick:()=>A(u)},"编辑"),Fl("button",{type:"button",className:"ghost-btn",onClick:()=>U(u.id)},"子项"),Fl("button",{type:"button",className:"ghost-btn",disabled:n<=0,onClick:()=>F({type:"moveTodo",todoId:u.id,...q?{targetParentId:q}:{},targetIndex:n-1})},"上移"),Fl("button",{type:"button",className:"ghost-btn",disabled:n<=0,onClick:()=>F({type:"moveTodo",todoId:u.id,...q?{targetParentId:q}:{},targetIndex:0})},"置顶"),Fl("button",{type:"button",className:"ghost-btn",disabled:n>=i-1,onClick:()=>F({type:"moveTodo",todoId:u.id,...q?{targetParentId:q}:{},targetIndex:n+1})},"下移"),Fl("button",{type:"button",className:"ghost-btn",disabled:!f,onClick:()=>F({type:"moveTodo",todoId:u.id,targetIndex:9999})},"提升"),Fl("button",{type:"button",className:"ghost-btn danger",onClick:()=>F({type:"deleteTodo",todoId:u.id})},"删除"))),u.expanded&&w.length>0?Fl("div",{className:"todo-children"},w.map(({child:T,childIndex:O})=>Fl(bL,{key:T.id,todo:T,depth:r+1,parentId:u.id,index:O,siblingCount:J.length,filter:t,editingId:y,editingTitle:c,setEditingTitle:$,beginEdit:A,saveEdit:j,applyTodoAction:F,addChild:U,dragTodoId:N,setDragTodoId:W,dropTodo:L}))):null)}var vL=Rl(Ju(),1),f0=vL.default.createElement;function sL({title:l,items:u,actions:r,className:f,testId:n}){let i=Array.isArray(u)?u:[];return f0("section",{className:`top-status-bar ${f||""}`,"data-testid":n},f0("div",{className:"top-status-main"},l?f0("strong",{className:"top-status-title"},l):null,f0("div",{className:"top-status-chips"},i.map((t,y)=>f0("span",{key:t?.key||`${t?.label||"status"}-${y}`,className:`top-status-chip ${t?.tone||""}`,"data-testid":t?.testId},t?.label?f0("b",null,t.label):null,f0("span",null,t?.value??"--"))))),r?f0("div",{className:"top-status-actions"},r):null)}var y_=Rl(Ju(),1);var wl=y_.default.createElement,{useEffect:AY,useMemo:jY}=y_.default,FY=y_.default.useState;function kL({status:l,children:u,title:r}){let f=String(l||"unknown").toLowerCase();return wl("span",{className:`status-badge ${f}`,title:r},u||l||"unknown")}function n6({label:l,value:u,hint:r,tone:f}){return wl("article",{className:`metric-card ${f||""}`},wl("div",{className:"metric-label"},l),wl("div",{className:"metric-value"},u),wl("div",{className:"metric-hint"},r))}function Dj({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){return wl("section",{className:`panel ${n||""}`},wl("div",{className:"panel-head"},wl("div",null,u?wl("p",{className:"panel-eyebrow"},u):null,wl(fu,{title:l,loading:i})),r?wl("div",{className:"panel-actions"},r):null),wl("div",{className:"panel-body"},f))}function gL({title:l,data:u,onOpen:r,testId:f}){return wl("button",{type:"button",className:"ghost-btn","data-testid":f,onClick:()=>r?.(l,u)},"查看原始JSON")}function Vj({title:l,text:u}){return wl("div",{className:"empty-state"},wl("strong",null,l),wl("span",null,u))}function Cy(l){return Array.isArray(l)?l:[]}function Sj(l){return l&&typeof l==="object"&&!Array.isArray(l)?l:{}}function JY(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function UY(l,u){return`${l}/microservices/k3sctl-adapter/proxy${u}`}function NY(l){return l.find((u)=>String(u?.id||"")==="k3sctl-adapter")||null}function QY(l){if(l?.healthy===!0)return"online";if(String(l?.role||"")==="standby")return"warn";return"failed"}function wY(l){return l?.healthy===!0?"online":"failed"}function qY(l){if(l===!0)return"YES";if(l===!1)return"NO";return"--"}function WY(l){return Array.from(new Set(l.flatMap((u)=>Cy(u?.expectedNodeIds).map((r)=>String(r))))).filter(Boolean).sort()}function LY(l){let u=l.find((r)=>r?.id==="code-queue")||l[0];return String(u?.activeInstanceId||"--")}function GY(l){return wl("article",{key:l?.id||l?.nodeId,className:"k3s-instance-card"},wl("div",{className:"node-card-head"},wl("strong",null,l?.nodeId||l?.id||"--"),wl(kL,{status:QY(l)},l?.healthy?"HEALTHY":"DEGRADED")),wl("div",{className:"k3s-instance-role"},wl("span",null,String(l?.role||"worker").toUpperCase()),wl("code",null,l?.id||"--")),wl("dl",{className:"k3s-kv"},wl("dt",null,"Base URL"),wl("dd",null,wl("code",null,l?.baseUrl||"--")),wl("dt",null,"Proxy"),wl("dd",null,l?.proxyMode||"--"),wl("dt",null,"Health"),wl("dd",null,`${l?.upstreamStatus??"--"} / ${l?.status||"unknown"}`),wl("dt",null,"Checked"),wl("dd",null,Wl(l?.checkedAt))))}function TY(l,u){let r=Cy(l?.instances),f=Sj(l?.active);return wl(Dj,{key:l?.id||"service",title:l?.id||"managed-service",eyebrow:`${l?.namespace||"unidesk"} / k3s managed service`,className:"k3s-service-panel",actions:wl(gL,{title:`k3s service ${l?.id||""}`,data:l,onOpen:u,testId:`raw-k3s-service-${l?.id||"unknown"}`})},wl("div",{className:"k3s-service-summary"},wl("div",null,wl("span",null,"状态"),wl(kL,{status:wY(l)},l?.status||"unknown")),wl("div",null,wl("span",null,"Active"),wl("strong",null,l?.activeInstanceId||"--")),wl("div",null,wl("span",null,"Single Writer"),wl("strong",null,qY(l?.singleWriter))),wl("div",null,wl("span",null,"Active Health"),wl("strong",null,f?.upstreamStatus??"--"))),r.length===0?wl(Vj,{title:"暂无 k3s 实例",text:"adapter 没有返回该服务的 endpoint 列表"}):wl("div",{className:"k3s-instance-grid"},r.map(GY)))}function IL({microservices:l,onRaw:u,apiBaseUrl:r,onNavigate:f}){let n=NY(Array.isArray(l)?l:[]),i=JY(n),[t,y]=FY({loading:!1,error:"",data:null,refreshedAt:null});async function c(){y((w)=>({...w,loading:!0,error:""}));try{let w=await ml(UY(r,"/api/control-plane"));y({loading:!1,error:"",data:w,refreshedAt:new Date})}catch(w){y((Q)=>({...Q,loading:!1,error:El(w,"加载 k3s 控制平面失败")}))}}AY(()=>{c()},[r]);let $=jY(()=>Cy(t.data?.services),[t.data]),A=WY($),j=$.filter((w)=>w?.healthy===!0).length,F=$.reduce((w,Q)=>w+Cy(Q?.instances).length,0),U=$.reduce((w,Q)=>w+Cy(Q?.instances).filter((q)=>q?.healthy===!0).length,0),N=LY($),W=Sj(t.data?.kubectl),L=Sj(t.data?.kubeApiProxy),J=Cy(t.data?.manifestPaths).map((w)=>String(w));if(!n)return wl(Vj,{title:"k3sctl-adapter 未登记",text:"请在 config.json 的 microservices 中登记 id=k3sctl-adapter,并通过该微服务连接 k3s 控制平面。"});return wl("div",{className:"k3s-page","data-testid":"k3sctl-page"},wl(Dj,{title:"k3s Control Plane",eyebrow:"Managed by k3sctl-adapter",className:"k3s-hero-panel",loading:t.loading,actions:wl(y_.default.Fragment,null,wl("button",{type:"button",className:"ghost-btn",onClick:c,disabled:t.loading,"data-testid":"k3s-refresh-button"},t.loading?"刷新中":"刷新"),f?wl("button",{type:"button",className:"ghost-btn",onClick:()=>f("apps","code-queue"),"data-testid":"k3s-open-code-queue"},"打开 Code Queue"):null,wl(gL,{title:"k3sctl-adapter microservice",data:n,onOpen:u,testId:"raw-k3s-adapter"}))},wl("div",{className:"k3s-hero"},wl("div",{className:"k3s-orb","aria-hidden":"true"},wl("span",null,"k3s")),wl("div",{className:"k3s-hero-copy"},wl("p",{className:"eyebrow"},"D601 native control plane"),wl("h2",null,"UniDesk 只管理 adapter;业务微服务交给 k3s 标准服务路由"),wl("p",{className:"muted paragraph"},"Code Queue 的前端/API 请求进入 k3sctl-adapter,再由 adapter 转发到 k3s active service。provider-gateway 只用于维护 adapter 和节点诊断,不再直接管理 Code Queue 容器。"),wl("div",{className:"k3s-route-strip"},wl("span",null,"NO FALLBACK"),wl("code",null,t.data?.runtimePath||"frontend -> backend-core -> k3sctl-adapter")))),wl("div",{className:"metric-grid"},wl(n6,{label:"控制面",value:t.data?.clusterId||"D601",hint:`adapter ${i.providerStatus||"unknown"}`,tone:i.providerStatus==="online"?"ok":"warn"}),wl(n6,{label:"代管服务",value:$.length,hint:`${j}/${$.length||0} healthy`,tone:j===$.length&&$.length>0?"ok":"warn"}),wl(n6,{label:"节点",value:A.join(" / ")||"--",hint:"expected k3s nodes"}),wl(n6,{label:"实例",value:`${U}/${F}`,hint:`active ${N}`,tone:U===F&&F>0?"ok":"warn"})),wl("div",{className:"k3s-control-plane-grid"},wl("article",{className:"k3s-control-plane-card"},wl("span",null,"service proxy"),wl("strong",null,L.configured===!0?"K8S API PROXY":"PROXY DEGRADED"),wl("p",null,L.configured===!0?`${L.mode||"kubernetes-api-service-proxy"} via ${L.connectHost||"--"}`:"adapter 必须通过 k8s API service proxy 访问业务服务,不回退到业务容器直连。")),wl("article",{className:"k3s-control-plane-card"},wl("span",null,"manifests"),wl("strong",null,J.length||"--"),wl("p",null,J.join(" / ")||"未配置 manifest")),wl("article",{className:"k3s-control-plane-card"},wl("span",null,"cluster snapshot"),wl("strong",null,W.enabled===!0?W.ok===!0?"KUBECTL OK":"KUBECTL DEGRADED":"API ONLY"),wl("p",null,W.enabled===!0?`nodes ${W.nodeCount??"--"}`:"控制面页面以 adapter 返回的 k8s service proxy 状态为准;kubectl 只作为可选快照。"))),t.error?wl(lu,{error:t.error}):null,t.refreshedAt?wl("p",{className:"muted paragraph"},`最近刷新 ${iu(t.refreshedAt)}`):null),$.length===0?wl(Dj,{title:"代管服务",eyebrow:"k3s services",loading:t.loading},wl(Vj,{title:"暂无 k3s 服务",text:"等待 k3sctl-adapter 返回 /api/services;Code Queue 应显示 D601 scheduler/read/write 服务实例。"})):$.map((w)=>TY(w,u)))}var c_=Rl(Ju(),1);var ou=c_.default.createElement;function aL({onClose:l}){let{notifications:u,removeNotification:r,clearNotifications:f}=Xr(),n=c_.default.useRef(null);if(c_.default.useEffect(()=>{let i=(t)=>{if(n.current&&!n.current.contains(t.target))l()};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[l]),u.length===0)return ou("div",{className:"notification-popup",ref:n},ou("div",{className:"notification-popup-header"},ou("span",null,"通知"),ou("button",{className:"notification-popup-close",onClick:l},"×")),ou("div",{className:"notification-popup-empty"},"暂无通知"));return ou("div",{className:"notification-popup",ref:n},ou("div",{className:"notification-popup-header"},ou("span",null,`通知 (${u.length})`),ou("div",{className:"notification-popup-actions"},ou("button",{className:"notification-popup-clear",onClick:f},"清空"),ou("button",{className:"notification-popup-close",onClick:l},"×"))),ou("div",{className:"notification-popup-list"},u.slice().reverse().map((i)=>ou("div",{key:i.id,className:`notification-item ${i.type}`},ou("span",{className:"notification-item-icon"},i.type==="success"?"✓":"×"),ou("span",{className:"notification-item-message"},i.message),ou("button",{className:"notification-item-dismiss",onClick:()=>r(i.id)},"×")))))}function oL({notification:l}){let{removeNotification:u}=Xr();return c_.default.useEffect(()=>{let r=setTimeout(()=>{u(l.id)},3000);return()=>clearTimeout(r)},[l.id,u]),ou("div",{className:`notification-banner ${l.type}`,role:"alert"},ou("span",{className:"notification-banner-icon"},l.type==="success"?"✓":"×"),ou("span",{className:"notification-banner-message"},l.message),ou("button",{className:"notification-banner-dismiss",onClick:()=>u(l.id)},"×"))}function $G(l,u){let r=document.getElementById("root")?.getAttribute(l);if(!r)return u;try{let f=JSON.parse(r);return typeof f==="object"&&f!==null&&!Array.isArray(f)?f:u}catch{return u}}var sl=$G("data-config",{apiBaseUrl:"/api",authUsername:"admin"}),dL=sl.environment&&typeof sl.environment==="object"?sl.environment:{},mY=$G("data-codex-overview",null),_=i0.default.createElement,{useEffect:En,useMemo:A_}=i0.default,kl=i0.default.useState,Cj=i0.default.createContext(!1),Xf=bQ(p3),KY={id:"code-queue",name:"Code Queue",providerId:"D601",description:"Code Queue",repository:{containerName:"k3s:code-queue"},backend:{nodeBaseUrl:"k3s://code-queue",nodeBindHost:"k3s://unidesk/code-queue",nodePort:4222,proxyMode:"k3sctl-adapter-http",public:!1},deployment:{mode:"k3sctl-managed",adapterServiceId:"k3sctl-adapter",k3sServiceId:"code-queue"},runtime:{orchestrator:"k3sctl",providerStatus:"loading",providerName:"D601"}};function eL(){return typeof document>"u"||document.visibilityState!=="hidden"}function AG(l){return l?.environment==="dev"||l?.namespace==="unidesk-dev"}function zY(l){let u=typeof l==="string"?l:"";return u.length>=7?u.slice(0,7):u||"unknown"}function EY(l,u){if(l==="ops"&&u==="status")return 5000;if(l==="nodes"&&u==="monitor")return 5000;if(l==="tasks"&&(u==="dispatch"||u==="scheduled"||u==="pending"))return 5000;if(l==="nodes"||l==="ops")return 1e4;if(l==="apps")return 15000;if(l==="tasks")return 15000;return 30000}async function OY(l){if(!l?._summaryOnly||!l?.id)return l;return(await ml(`${sl.apiBaseUrl}/tasks/${encodeURIComponent(String(l.id))}`))?.task||l}function j_(l){return l?._summaryOnly?{...l,_loadRaw:()=>OY(l)}:l}function fi(l){if(!Number.isFinite(l))return"--";let u=Math.max(0,l);if(u===0)return"0s";if(u<0.01)return"<0.01s";if(u<0.1)return`${u.toFixed(2)}s`;if(u<1)return`${u.toFixed(1)}s`;if(u<10&&!Number.isInteger(u))return`${u.toFixed(1)}s`;if(u<60)return`${Math.round(u)}s`;let r=Math.floor(u);if(r<3600)return`${Math.floor(r/60)}m ${r%60}s`;return`${Math.floor(r/3600)}h ${Math.floor(r%3600/60)}m`}function Wf(l){let u=Number(l);if(!Number.isFinite(u))return"--";if(u<1)return`${Math.max(0,u).toFixed(1)}ms`;if(u<10)return`${u.toFixed(1)}ms`;if(u<1000)return`${Math.round(u)}ms`;return fi(u/1000)}function Nr(l){let u=Number(l);if(!Number.isFinite(u)||u<=0)return"--";let r=["B","KB","MB","GB","TB"],f=u,n=0;while(f>=1024&&n<r.length-1)f/=1024,n+=1;return`${f.toFixed(n===0?0:1)} ${r[n]}`}function n0(l){let u=Number(l);return Number.isFinite(u)?`${Math.max(0,Math.min(100,u)).toFixed(1)}%`:"--"}function ZY(l){let u=Number(l);return Number.isFinite(u)?`${Math.max(0,u).toFixed(1)}%`:"--"}function Xj(l){let u=Number(l);if(!Number.isFinite(u)||u<=0)return"0 B/s";return`${Nr(u)}/s`}function vl(l,u=0){let r=Number(l);return Number.isFinite(r)?r:u}function hy(l){return["queued","dispatched","running"].includes(String(l?.status||"").toLowerCase())}function Mj(l){if(!l)return"--";let u=new Date(l);if(Number.isNaN(u.getTime()))return"--";return fi(Math.max(0,Math.floor((Date.now()-u.getTime())/1000)))}function On(l){if(!l)return null;let u=new Date(l);return Number.isNaN(u.getTime())?null:u.getTime()}function jG(l){let u=On(l?.createdAt);if(u===null)return null;let f=["succeeded","failed"].includes(String(l?.status||"").toLowerCase())?On(l?.updatedAt):Date.now();if(f===null)return null;return Math.max(0,(f-u)/1000)}function FG(l){if(String(l?.status||"").toLowerCase()!=="failed")return"";let u=l?.result;if(typeof u==="string")return u;if(u&&typeof u==="object"&&!Array.isArray(u)){let r=u;for(let f of["error","reason","message","stderr","detail"])if(typeof r[f]==="string"&&r[f].length>0)return r[f]}return"任务失败但 provider 未返回明确原因"}function ft(l){if(l===null||l===void 0)return"--";if(typeof l==="boolean")return l?"是":"否";if(typeof l==="number")return String(l);if(typeof l==="string")return l.length>80?`${l.slice(0,77)}...`:l;if(Array.isArray(l))return`${l.length} 项`;if(typeof l==="object")return`${Object.keys(l).length} 字段`;return String(l)}function pY(l,u){let r=l.replace(/[-_\s]/g,"").toLowerCase(),f=r==="ts"||r.endsWith("at")||r.endsWith("timestamp")||r.endsWith("heartbeat");if((typeof u==="string"||typeof u==="number")&&f){let n=Wl(u);if(n!=="--")return n}if(l==="bodyText"&&typeof u==="string")return`${/^\s*[{[]/.test(u)?"JSON":"HTTP"} body ${u.length} chars`;return ft(u)}function JG(l){if(!l||typeof l!=="object"||Array.isArray(l))return[];return Object.entries(l)}function uf(l){return String(l).replace(/[^a-zA-Z0-9_-]/g,"_")}function hj(l,u){return l&&typeof l==="object"&&!Array.isArray(l)?l[u]:void 0}function t6(l,u,r="未知"){let f=hj(l?.labels,u);return typeof f==="string"&&f.length>0?f:r}function UG(l){return t6(l,"providerGatewayVersion")}function $_(l){return t6(l,"providerGatewayUpgradePolicy")}function lG(l){return t6(l,"providerGatewayStartedAt","")}function NG(l){let u=hj(l?.labels,"unideskCapabilities");if(typeof u==="string")return u.split(",").map((r)=>r.trim()).filter(Boolean);return Array.isArray(u)?u.filter((r)=>typeof r==="string"):[]}function QG(l,u){return NG(l).includes(u)}function uG(l,u){let r=hj(l?.labels,u);return r===!0||r==="true"||r==="1"}function HY(l){if(!QG(l,"host.ssh"))return{tone:"fail",label:"不可用",detail:"未声明 host.ssh"};if(!uG(l,"hostSshConfigured"))return{tone:"warn",label:"未配置",detail:"缺少 SSH 环境变量"};if(!uG(l,"hostSshKeyPresent"))return{tone:"warn",label:"缺 key",detail:"私钥未挂载"};return{tone:"ok",label:"可用",detail:t6(l,"hostSshTarget","host.ssh ready")}}function BY(l){if(!QG(l,"provider.upgrade"))return{tone:"fail",label:"不可用",detail:"未声明 provider.upgrade"};let u=$_(l);if(u!=="always-enabled")return{tone:"warn",label:"待确认",detail:`策略 ${u}`};return{tone:"ok",label:"可用",detail:"always-enabled"}}function Rj(l){let u=typeof l==="string"&&l.length>0?l:"未知";if(u==="未知")return"版本未知";return u.startsWith("v")?u:`v${u}`}function wG(l){return l?.payload&&typeof l.payload==="object"&&!Array.isArray(l.payload)?l.payload:{}}function y6(l){return l?.result&&typeof l.result==="object"&&!Array.isArray(l.result)?l.result:{}}function i6(l){let u=wG(l),r=y6(l);return(u.mode??r.mode)==="schedule"?"schedule":"plan"}function DY(l){let u=wG(l).source;return typeof u==="string"&&u.length>0?u:"unknown"}function VY(l){let u=y6(l),r=u.plan&&typeof u.plan==="object"&&!Array.isArray(u.plan)?u.plan:{},f=u.policy??r.policy;return typeof f==="string"&&f.length>0?f:"--"}function qG(l){let u=y6(l),r=u.plan&&typeof u.plan==="object"&&!Array.isArray(u.plan)?u.plan:{},f=u.targetProviderGatewayVersion??u.providerGatewayVersion??r.targetProviderGatewayVersion??r.providerGatewayVersion;return typeof f==="string"&&f.length>0?Rj(f):"版本未知"}function WG(l){if(String(l?.status||"").toLowerCase()==="failed")return FG(l);if(hy(l))return"等待 provider 回传升级终态";let r=y6(l);if(typeof r.updaterContainerId==="string"&&r.updaterContainerId.length>0)return`updater ${r.updaterContainerId.slice(0,18)}`;if(typeof r.message==="string"&&r.message.length>0)return r.message;if(r.plan)return"升级计划已生成";return"无升级结果摘要"}function LG(l,u){return l.filter((r)=>r?.providerId===u&&r?.command==="provider.upgrade").sort((r,f)=>(On(f.updatedAt)??0)-(On(r.updatedAt)??0))}function SY(l){return l.find((u)=>i6(u)==="schedule")||l[0]||null}function GG(l){return l?.runtime&&typeof l.runtime==="object"&&!Array.isArray(l.runtime)?l.runtime:{}}function rG(l){return l?.backend&&typeof l.backend==="object"&&!Array.isArray(l.backend)?l.backend:{}}function XY(l){return l?.repository&&typeof l.repository==="object"&&!Array.isArray(l.repository)?l.repository:{}}function Tu({status:l,children:u}){let r=String(l||"unknown").toLowerCase();return _("span",{className:`status-badge ${r}`},u||l||"unknown")}function Nu({label:l,value:u,hint:r,tone:f,onClick:n,testId:i}){let t=typeof n==="function";return _("article",{className:`metric-card ${f||""} ${t?"clickable":""}`,role:t?"button":void 0,tabIndex:t?0:void 0,"data-testid":i,onClick:n,onKeyDown:t?(y)=>{if(y.key==="Enter"||y.key===" ")y.preventDefault(),n()}:void 0},_("div",{className:"metric-label"},l),_("div",{className:"metric-value"},u),_("div",{className:"metric-hint"},r))}function uu({title:l,eyebrow:u,actions:r,children:f,className:n,loading:i}){let t=i0.default.useContext(Cj),y=Boolean(i)||t;return _("section",{className:`panel ${n||""}`},_("div",{className:"panel-head"},_("div",null,u?_("p",{className:"panel-eyebrow"},u):null,_(fu,{title:l,loading:y})),r?_("div",{className:"panel-actions"},r):null),_("div",{className:"panel-body"},f))}function du({title:l,data:u,onOpen:r,testId:f}){let[n,i]=kl(!1),t=u&&typeof u==="object"&&typeof u._loadRaw==="function"?u._loadRaw:null;async function y(){if(!t){r(l,u);return}i(!0);try{r(l,await t())}catch(c){r(l,{ok:!1,error:El(c,"读取原始 JSON 失败"),fallback:u})}finally{i(!1)}}return _("button",{type:"button",className:"ghost-btn","data-testid":f,disabled:n,onClick:()=>void y()},n?"读取中":"查看原始JSON")}function YY({raw:l,onClose:u}){if(!l)return null;return _("div",{className:"modal-backdrop",role:"presentation"},_("section",{className:"raw-dialog",role:"dialog","aria-modal":"true","aria-label":l.title},_("div",{className:"raw-dialog-head"},_("h2",null,l.title),_("button",{type:"button",className:"ghost-btn",onClick:u},"关闭")),_("pre",{className:"raw-json","data-testid":"raw-json"},JSON.stringify(l.data,null,2))))}function TG({labels:l,limit:u=8}){let r=JG(l).slice(0,u);if(r.length===0)return _("span",{className:"muted"},"无标签");return _("div",{className:"chip-row"},r.map(([f,n])=>_("span",{key:f,className:"data-chip"},_("b",null,f),_("span",null,ft(n)))))}function My({node:l}){let u=UG(l);return _("span",{className:`version-chip ${u==="未知"?"unknown":""}`,"data-testid":`gateway-version-${uf(l?.providerId||"unknown")}`},Rj(u))}function fG({title:l,state:u,testId:r}){return _("span",{className:`capability-badge ${u.tone}`,title:u.detail,"data-testid":r},_("b",null,l),_("strong",null,u.label),_("small",null,u.detail))}function xj({node:l}){let u=uf(l?.providerId||"unknown");return _("div",{className:"node-availability-strip"},_(fG,{title:"SSH 透传",state:HY(l),testId:`ssh-availability-${u}`}),_(fG,{title:"远程更新",state:BY(l),testId:`upgrade-availability-${u}`}))}function t0({data:l,empty:u="无数据"}){if(l===null||l===void 0)return _("span",{className:"muted"},u);if(typeof l!=="object")return _("span",{className:"summary-value"},ft(l));if(Array.isArray(l))return _("span",{className:"summary-value"},`${l.length} 项列表`);let r=Object.entries(l).slice(0,5);if(r.length===0)return _("span",{className:"muted"},u);return _("div",{className:"summary-grid"},r.map(([f,n])=>_("span",{key:f,className:"summary-item"},_("b",null,f),_("span",null,pY(f,n)))))}function Qu({title:l,text:u}){return _("div",{className:"empty-state"},_("strong",null,l),_("span",null,u))}function PY({onLogin:l}){let[u,r]=kl(sl.authUsername||"admin"),[f,n]=kl(""),[i,t]=kl(""),[y,c]=kl(!1);async function $(A){A.preventDefault(),c(!0),t("");try{let j=await ml("/login",{method:"POST",body:JSON.stringify({username:u,password:f})});l(j)}catch(j){t(El(j,"登录失败"))}finally{c(!1)}}return _("main",{className:"login-screen","data-testid":"login-screen"},_("section",{className:"login-card"},_("div",{className:"login-brand"},_("span",{className:"brand-mark"},"UD"),_("div",null,_("h1",null,"UniDesk"),_("p",null,"Control Plane Login"))),_("form",{className:"login-form",onSubmit:$},_("label",null,"账号",_("input",{name:"username",autoComplete:"username",value:u,onChange:(A)=>r(A.target.value)})),_("label",null,"密码",_("input",{name:"password",type:"password",autoComplete:"current-password",value:f,onChange:(A)=>n(A.target.value)})),_(lu,{error:i}),_("button",{type:"submit",disabled:y},y?"登录中":"登录")),_("div",{className:"login-note"},"默认账号由 config.json 注入;公网入口只暴露前端登录面。")))}function CY({connection:l,lastRefresh:u,onRefresh:r,onLogout:f,session:n,clock:i,activeStatusItems:t=[],onNotificationToggle:y,unreadCount:c=0,environment:$={}}){let A=AG($),j=[...A?[{key:"environment",label:"环境",value:`${$.namespace||"unidesk-dev"}`,tone:"warn"}]:[],{key:"core",label:"核心",value:l.text,tone:l.ok?"ok":"fail",testId:"conn-text"},...Array.isArray(t)?t:[],{key:"refresh",label:"刷新",value:u?iu(u):"未刷新"},{key:"clock",label:Z_,value:iu(i)},{key:"user",label:"用户",value:n?.user?.username||"--",tone:"user"}];return _("header",{className:"topbar"},_("div",null,_("p",{className:"eyebrow"},"Distributed Work Platform"),_("h1",null,"UniDesk 控制平面"),A?_("div",{className:"dev-env-ribbon","data-testid":"dev-environment-ribbon"},_("b",null,"DEV"),_("span",null,$.namespace||"unidesk-dev"),_("span",null,$.deployRef||"origin/deploy/dev"),_("span",null,zY($.commit||$.requestedCommit))):null),_(sL,{className:"global-top-status",title:"状态",items:j,actions:[_("button",{key:"notification",type:"button",className:`notification-icon-btn ${c>0?"has-unread":""}`,onClick:y,"aria-label":"通知"},"\uD83D\uDD14",c>0?_("span",{key:"badge",className:"notification-badge"},c>99?"99+":c):null),_("button",{key:"refresh",type:"button",className:"ghost-btn",onClick:r},"刷新"),_("button",{key:"logout",type:"button",className:"ghost-btn danger",onClick:f},"退出")]}))}function MY(l){return!l.defaultPrevented&&l.button===0&&!l.metaKey&&!l.altKey&&!l.ctrlKey&&!l.shiftKey&&l.currentTarget.target!=="_blank"}function mG({moduleId:l,tabId:u,className:r,active:f=!1,title:n,testId:i,onNavigate:t,children:y}){let c=H3(Xf,l,u);return _("a",{href:c,role:"button",className:r,title:n,"aria-current":f?"page":void 0,"data-testid":i,"data-route":c,onClick:($)=>{if(!MY($))return;$.preventDefault(),t(l,u)}},y)}function hY({activeModule:l,activeTabs:u,onNavigate:r,collapsed:f,onToggle:n}){return _("aside",{className:`rail ${f?"collapsed":""}`,"aria-label":"主模块"},_("div",{className:"brand"},_("span",{className:"brand-mark"},"UD"),_("span",{className:"brand-text"},"UniDesk"),_("button",{type:"button",className:"rail-toggle",onClick:n,"aria-label":f?"展开左侧边栏":"收起左侧边栏","data-testid":"rail-toggle"},f?"»":"«")),p3.map((i)=>{let t=u[i.id]||Nc[i.id]||i.tabs[0]?.id||"";return _(mG,{key:i.id,moduleId:i.id,tabId:t,className:`module ${l===i.id?"active":""}`,active:l===i.id,title:i.label,onNavigate:r},_("span",{className:"module-code"},i.code),_("span",null,i.label))}))}function RY({module:l,activeTab:u,onNavigate:r}){return _("nav",{className:"tabs","aria-label":`${l.label} 子功能`},l.tabs.map((f)=>_(mG,{key:f.id,moduleId:l.id,tabId:f.id,className:`tab ${u===f.id?"active":""}`,active:u===f.id,onNavigate:r},f.label)))}function xY({data:l,onRaw:u,onNavigate:r}){let f=l.overview||{},n=l.nodes.filter((U)=>U.status==="online"),i=l.pendingTasks||l.tasks.filter(hy),t=f.pendingTaskCount??i.length,y=l.tasks.slice(0,5),c=f.pgdata||{},$=f.microserviceAvailability||{},A=vl($.totalCount),j=vl($.healthyCount),F=vl($.unhealthyCount);return _("div",{className:"page-grid overview-grid","data-testid":"overview-page"},_(uu,{title:"核心指标",eyebrow:"Control"},_("div",{className:"metric-grid"},_(Nu,{label:"数据库",value:f.dbReady?"READY":"WAIT",hint:"PostgreSQL internal network",tone:f.dbReady?"ok":"warn"}),_(Nu,{label:"PGDATA",value:Nr(c.databaseBytes),hint:`${c.volumeName||"unidesk_pgdata_10gb"} / ${c.databasePretty||"--"} / budget ${c.volumeSize||"--"}`,tone:"ok",testId:"pgdata-usage-card"}),_(Nu,{label:"在线节点",value:f.onlineNodeCount??0,hint:`${f.nodeCount??0} registered`,tone:"ok"}),_(Nu,{label:"WebSocket",value:f.activeSocketCount??0,hint:"Provider ingress sockets"}),_(Nu,{label:"用户服务可用",value:A>0?`${j}/${A}`:"--",hint:A>0?`healthyCount ${j} · unhealthyCount ${F}`:"strict /health probes",tone:A>0&&F===0?"ok":"warn",testId:"microservice-availability-card"}),_(Nu,{label:"待处理任务",value:t,hint:t>0?"点击查看具体任务":`timeout ${fi(Math.floor((f.taskPendingTimeoutMs??0)/1000))}`,tone:t>0?"warn":"ok",onClick:()=>r("tasks","pending"),testId:"pending-task-card"}))),_(uu,{title:"本机 Provider",eyebrow:"Self Connected"},n.length===0?_(Qu,{title:"暂无在线节点",text:"provider-gateway 未完成自接入"}):_("div",{className:"node-card-list"},n.slice(0,4).map((U)=>_(bY,{key:U.providerId,node:U,onRaw:u})))),_(uu,{title:"待处理任务明细",eyebrow:`${t} Pending`,actions:_("button",{type:"button",className:"ghost-btn",onClick:()=>r("tasks","pending"),"data-testid":"pending-task-detail-link"},"进入任务调度")},i.length===0?_(Qu,{title:"当前无待处理",text:"queued / dispatched / running 超时后会自动转为 failed,避免总览长期卡住"}):_("div",{className:"compact-list"},i.slice(0,5).map((U)=>_(yG,{key:U.id,task:U,onRaw:u})))),_(uu,{title:"最近任务",eyebrow:"Dispatch"},y.length===0?_(Qu,{title:"暂无任务",text:"可以在任务调度模块发起 docker.ps 或 echo"}):_("div",{className:"compact-list"},y.map((U)=>_(yG,{key:U.id,task:U,onRaw:u})))))}function bY({node:l,onRaw:u}){return _("article",{className:"node-card"},_("div",{className:"node-card-head"},_("div",null,_("strong",null,l.name),_("code",null,l.providerId)),_(Tu,{status:l.status})),_("div",{className:"node-version-line"},_(My,{node:l}),_("span",null,`升级策略 ${$_(l)}`)),_(xj,{node:l}),_(TG,{labels:l.labels,limit:6}),_("div",{className:"node-card-foot"},_("span",null,`心跳 ${Wl(l.lastHeartbeat)}`),_(du,{title:`Provider ${l.providerId}`,data:l,onOpen:u,testId:`raw-node-${uf(l.providerId)}`})))}function vY({events:l,onRaw:u}){return _(uu,{title:"事件摘要",eyebrow:"Latest 100"},l.length===0?_(Qu,{title:"暂无事件",text:"Provider 注册、心跳超时和任务状态会写入事件流"}):_("div",{className:"table-wrap"},_("table",null,_("thead",null,_("tr",null,_("th",null,"ID"),_("th",null,"类型"),_("th",null,"来源"),_("th",null,"摘要"),_("th",null,"时间"),_("th",null,"操作"))),_("tbody",null,l.map((r)=>_("tr",{key:r.id},_("td",null,_("code",null,r.id)),_("td",null,_(Tu,{status:r.type},r.type)),_("td",null,_("code",null,r.source)),_("td",null,_(t0,{data:r.payload})),_("td",null,Wl(r.createdAt)),_("td",null,_(du,{title:`Event ${r.id}`,data:r,onOpen:u}))))))))}function sY({logs:l,onRaw:u}){return _(uu,{title:"服务日志",eyebrow:"Core Recent"},l.length===0?_(Qu,{title:"暂无日志",text:"backend-core 内存日志会在请求和 provider 事件后出现"}):_("div",{className:"log-list"},l.slice(-80).reverse().map((r,f)=>_("article",{key:f,className:`log-row ${r.level||"info"}`},_("span",null,Wl(r.ts)),_("b",null,r.level||"info"),_("strong",null,r.message||"log"),_(t0,{data:r.data,empty:"无附加字段"}),_(du,{title:`Log ${r.message||f}`,data:r,onOpen:u})))))}function kY({nodes:l,onRaw:u}){return _(uu,{title:"节点清单",eyebrow:`${l.length} Providers`},l.length===0?_(Qu,{title:"暂无 Provider 节点",text:"确认 provider-gateway 已连接 provider ingress"}):_("div",{className:"table-wrap"},_("table",{className:"node-list-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"Provider"),_("th",null,"网关版本"),_("th",null,"运维可用性"),_("th",null,"资源标签"),_("th",null,"连接时间"),_("th",null,"最后心跳"),_("th",null,"操作"))),_("tbody",null,l.map((r)=>_("tr",{key:r.providerId},_("td",null,_(Tu,{status:r.status})),_("td",null,_("strong",null,r.name),_("code",null,r.providerId)),_("td",null,_("div",{className:"gateway-cell"},_(My,{node:r}),_("span",null,$_(r)))),_("td",null,_(xj,{node:r})),_("td",null,_(TG,{labels:r.labels,limit:5})),_("td",null,Wl(r.connectedAt)),_("td",null,Wl(r.lastHeartbeat)),_("td",null,_(du,{title:`Provider ${r.providerId}`,data:r,onOpen:u,testId:`raw-node-table-${uf(r.providerId)}`}))))))))}function gY({nodes:l}){let u=A_(()=>{let r=[];for(let f of l)for(let[n,i]of JG(f.labels))r.push({providerId:f.providerId,name:f.name,key:n,value:i});return r},[l]);return _(uu,{title:"资源标签",eyebrow:"Structured Labels"},u.length===0?_(Qu,{title:"暂无标签",text:"provider-gateway 注册消息会同步资源标签"}):_("div",{className:"label-matrix"},u.map((r)=>_("article",{key:`${r.providerId}-${r.key}`,className:"label-card"},_("span",null,r.key),_("strong",null,ft(r.value)),_("code",null,r.providerId)))))}function IY({nodes:l}){return _(uu,{title:"心跳状态",eyebrow:"Provider Liveness"},l.length===0?_(Qu,{title:"无心跳",text:"等待 provider 注册和 heartbeat"}):_("div",{className:"heartbeat-list"},l.map((u)=>_("article",{key:u.providerId,className:"heartbeat-row"},_("span",{className:`pulse ${u.status}`}),_("div",null,_("strong",null,u.name),_("code",null,u.providerId)),_("div",null,_("span",null,"connected"),_("b",null,Wl(u.connectedAt))),_("div",null,_("span",null,"last heartbeat"),_("b",null,Wl(u.lastHeartbeat)))))))}function aY({nodes:l,systemStatuses:u,tasks:r,onRaw:f,refresh:n}){let[i,t]=kl(""),y=A_(()=>l.map((W)=>{let L=u.find((J)=>J.providerId===W.providerId);return{...W,systemCurrent:L?.current||null,systemHistory:L?.history||[],systemUpdatedAt:L?.updatedAt||null}}),[l,u]),c=y.find((W)=>W.providerId===i)||y[0]||null;if(En(()=>{if(!i&&y[0])t(y[0].providerId)},[y.length,i]),!c)return _(Qu,{title:"暂无资源监控",text:"等待 provider 上报 CPU、内存和硬盘指标"});let $=c.systemCurrent,A=c.systemHistory||[],j=$?.cpu||{},F=$?.memory||{},U=$?.disk||{},N=A.length>0?A:$?[{at:$.collectedAt,cpuPercent:vl(j.percent),memoryPercent:vl(F.percent),diskPercent:vl(U.percent)}]:[];return _("div",{className:"monitor-page","data-testid":"node-monitor-page"},_("div",{className:"docker-node-strip"},y.map((W)=>_("button",{key:W.providerId,type:"button",className:`docker-node-tile ${c.providerId===W.providerId?"active":""}`,onClick:()=>t(W.providerId)},_("span",{className:`pulse ${W.status}`}),_("strong",null,W.name),_("code",null,W.providerId),_("span",null,W.systemCurrent?`CPU ${n0(W.systemCurrent.cpu?.percent)} / MEM ${n0(W.systemCurrent.memory?.percent)}`:"等待指标")))),_("div",{className:"monitor-layout"},_(uu,{title:"任务管理器视图",eyebrow:c.name,className:"monitor-main-panel",actions:$?_(du,{title:`System ${c.providerId}`,data:{current:$,history:A},onOpen:f}):null},!$?_(Qu,{title:"系统指标未上报",text:"provider-gateway 会周期性采集 /proc 与 df,并保存历史曲线"}):_("div",null,_("div",{className:"monitor-hero"},_("div",null,_("p",{className:"panel-eyebrow"},"Node Performance"),_("h3",null,c.name),_("div",{className:"docker-meta"},_("span",null,`${j.cores||0} CPU cores`),_("span",null,`load ${vl(j.load1).toFixed(2)} / ${vl(j.load5).toFixed(2)} / ${vl(j.load15).toFixed(2)}`),_("span",null,`memory actual ${Nr(F.usedBytes)} / ${Nr(F.totalBytes)}`),_("span",null,`disk ${Nr(U.usedBytes)} / ${Nr(U.totalBytes)}`))),_(Tu,{status:$.ok?"online":"warn"},$.ok?"METRICS READY":"METRICS DEGRADED")),_("div",{className:"monitor-chart-grid"},_(Yj,{title:"CPU",metricKey:"cpuPercent",current:j.percent,points:N,detail:`${j.cores||0} cores / load ${vl(j.load1).toFixed(2)}`,tone:"cpu",testId:"metric-chart-cpu"}),_(Yj,{title:"Memory",metricKey:"memoryPercent",current:F.percent,points:N,detail:`${Nr(F.usedBytes)} actual / ${Nr(F.cacheBytes)} cache excluded`,tone:"memory",testId:"metric-chart-memory"}),_(Yj,{title:"Disk",metricKey:"diskPercent",current:U.percent,points:N,detail:`${U.path||"/"} mounted ${U.mount||"--"}`,tone:"disk",testId:"metric-chart-disk"})),_("div",{className:"monitor-summary-grid"},_(Nu,{label:"CPU 当前",value:n0(j.percent),hint:`history ${N.length} samples`,tone:"ok"}),_(Nu,{label:"实际内存",value:Nr(F.usedBytes),hint:`${n0(F.percent)} 不含缓存`}),_(Nu,{label:"硬盘已用",value:Nr(U.usedBytes),hint:n0(U.percent)}),_(Nu,{label:"更新时间",value:Wl(c.systemUpdatedAt||$.collectedAt),hint:c.providerId})),_(oY,{current:$,onRaw:f}))),_("div",{className:"monitor-side-stack"},_(iP,{provider:c,refresh:n,onRaw:f}),_(tP,{provider:c,tasks:r,onRaw:f,limit:5}),_(uu,{title:"采样说明",eyebrow:"Retention"},_("div",{className:"monitor-note-list"},_("article",null,_("b",null,"CPU"),_("span",null,"从 /proc/stat 计算相邻采样差值,首个采样用 load/cores 近似")),_("article",null,_("b",null,"Memory"),_("span",null,"实际内存 = MemTotal - MemFree - Buffers - Cached - SReclaimable + Shmem,不把 page cache / buffer 计入占用")),_("article",null,_("b",null,"Disk"),_("span",null,"使用 df -PB1 对配置路径采样,默认监控根文件系统")),_("article",null,_("b",null,"Process"),_("span",null,"从 /proc/[pid] 采集进程 CPU、实际内存 PSS、RSS、线程数和磁盘 I/O 速率;PSS 不重复计算共享内存,表格默认按内存占用降序")))))))}function KG(l){return vl(l.memoryBytes,vl(l.pssBytes,vl(l.rssBytes)))}function nG(l,u){if(u==="memory")return KG(l);if(u==="cpu")return vl(l.cpuPercent);if(u==="disk")return vl(l.readBytesPerSecond)+vl(l.writeBytesPerSecond);if(u==="pid")return vl(l.pid);if(u==="threads")return vl(l.threads);if(u==="runtime")return vl(l.elapsedSeconds);if(u==="user")return String(l.user||"");return String(l.name||l.command||"")}function iG({value:l,label:u,tone:r}){let f=Math.max(1,Math.min(100,vl(l)));return _("div",{className:`process-meter ${r||""}`},_("span",{style:{width:`${f}%`}}),_("b",null,u))}function oY({current:l,onRaw:u}){let[r,f]=kl({key:"memory",direction:"desc"}),n=i0.default.useContext(Cj),i=l?.processSummary&&typeof l.processSummary==="object"?l.processSummary:{},t=Array.isArray(l?.processes)?l.processes:[],y=String(i.memoryMode||""),c=y.includes("pss_smaps_rollup")?"PSS":y==="rss_minus_shared_fallback"?"RSS-shared":"RSS fallback",$=A_(()=>{let j=r.direction==="asc"?1:-1;return[...t].sort((F,U)=>{let N=nG(F,r.key),W=nG(U,r.key);if(typeof N==="string"||typeof W==="string")return String(N).localeCompare(String(W),"zh-CN")*j;return(N-W)*j||vl(F.pid)-vl(U.pid)})},[t,r.key,r.direction]),A=(j,F)=>{let U=r.key===F,N=U?r.direction==="asc"?"ascending":"descending":"none";return _("th",{"aria-sort":N},_("button",{type:"button",className:`process-sort-button ${U?"active":""}`,"data-testid":`process-sort-${F}`,onClick:()=>f((W)=>({key:F,direction:W.key===F&&W.direction==="desc"?"asc":"desc"}))},j,_("span",null,U?r.direction==="desc"?"↓":"↑":"↕")))};return _("section",{className:"process-resource-panel","data-testid":"process-resource-panel"},_("div",{className:"process-resource-head"},_("div",null,_("p",{className:"panel-eyebrow"},"Windows Resource Monitor Style"),_(fu,{title:"进程资源占用",level:3,loading:n})),_("div",{className:"process-resource-actions"},_("span",{className:"data-chip"},"默认按内存排序"),_("span",{className:"data-chip"},`内存口径 ${c}`),_("span",{className:"data-chip"},`${vl(i.visible,$.length)} / ${vl(i.total,$.length)} 进程`),_(du,{title:"Process Resource Snapshot",data:{processSummary:i,processes:t},onOpen:u,testId:"raw-process-resources"}))),$.length===0?_(Qu,{title:"暂无进程资源数据",text:"等待 provider-gateway 上报 /proc/[pid] 采样;旧版 provider 需要先升级到支持进程资源表的版本"}):_("div",{className:"process-table-wrap"},_("table",{className:"process-resource-table","data-testid":"process-resource-table"},_("thead",null,_("tr",null,A("进程","name"),A("PID","pid"),A("用户","user"),_("th",null,"状态"),A("CPU","cpu"),A("内存","memory"),_("th",null,"PSS / RSS"),A("磁盘 I/O","disk"),A("线程","threads"),A("运行时长","runtime"))),_("tbody",null,$.map((j)=>{let F=vl(j.readBytesPerSecond)+vl(j.writeBytesPerSecond),U=KG(j);return _("tr",{key:`${j.pid}-${j.startedAt}`,"data-testid":`process-row-${uf(j.pid)}`,"data-memory-bytes":String(U),"data-cpu-percent":String(vl(j.cpuPercent)),"data-disk-bps":String(F),"data-pid":String(vl(j.pid))},_("td",null,_("div",{className:"process-name-cell"},_("strong",null,j.name||"--"),_("span",{className:"process-command"},j.command||"--"))),_("td",null,_("code",null,j.pid||"--")),_("td",null,j.user||`uid:${j.uid??"--"}`),_("td",null,_("span",{className:`process-state state-${uf(j.state||"unknown")}`},j.state||"?")),_("td",null,_(iG,{value:j.cpuPercent,label:ZY(j.cpuPercent),tone:"cpu"})),_("td",null,_(iG,{value:j.memoryPercent,label:n0(j.memoryPercent),tone:"memory"})),_("td",null,_("div",{className:"process-io-cell"},_("strong",null,Nr(U)),_("span",null,`RSS ${Nr(j.rssBytes)}`))),_("td",null,_("div",{className:"process-io-cell"},_("strong",null,Xj(F)),_("span",null,`R ${Xj(j.readBytesPerSecond)} / W ${Xj(j.writeBytesPerSecond)}`))),_("td",null,j.threads||0),_("td",null,fi(vl(j.elapsedSeconds))))})))))}function Yj({title:l,metricKey:u,current:r,points:f,detail:n,tone:i,testId:t}){let y=f.map((F)=>Math.max(0,Math.min(100,vl(F[u])))),c=y.length>1?y:[y[0]||0,y[0]||0],$=c.length<=1?100:100/(c.length-1),A=c.map((F,U)=>`${(U*$).toFixed(2)},${(46-F*0.42).toFixed(2)}`).join(" "),j=`0,48 ${A} 100,48`;return _("article",{className:`metric-chart ${i}`,"data-testid":t},_("div",{className:"metric-chart-head"},_("div",null,_("span",null,l),_("strong",null,n0(r))),_("code",null,`${f.length} pts`)),_("svg",{viewBox:"0 0 100 48",preserveAspectRatio:"none",role:"img","aria-label":`${l} usage curve`},_("polygon",{points:j}),_("polyline",{points:A}),_("line",{x1:"0",x2:"100",y1:"24",y2:"24"})),_("div",{className:"metric-chart-foot"},_("span",null,"0%"),_("span",null,n),_("span",null,"100%")))}function ni(l){return Array.isArray(l)?l:[]}function dY(l){let u=ni(l?.core?.requests?.componentSummary);return[...ni(l?.frontend?.requests?.componentSummary),...u].sort((f,n)=>vl(n.requestCount)-vl(f.requestCount))}function eY(l){let u=ni(l?.core?.operations?.summary);return[...ni(l?.frontend?.operations?.summary),...u].sort((f,n)=>vl(n.count)-vl(f.count))}function lP(l){let u=ni(l?.core?.requests?.recentFailures).map((f)=>({source:"backend",...f}));return[...ni(l?.frontend?.requests?.recentFailures).map((f)=>({source:"frontend",...f})),...u].sort((f,n)=>(On(n.at)??0)-(On(f.at)??0)).slice(0,20)}function uP(l){let u=ni(l?.core?.operations?.recentSlowOperations);return[...ni(l?.frontend?.operations?.recentSlowOperations),...u].sort((f,n)=>vl(n.durationMs)-vl(f.durationMs)).slice(0,20)}function rP(l){let u=performance.memory,r=Number(u?.usedJSHeapSize);if(Number.isFinite(r)&&r>0)return r;let f=Number(l?.appBundleBytes);if(Number.isFinite(f)&&f>0)return f;return vl(l?.process?.heapUsedBytes)}function fP({points:l}){let u=ni(l),r=u.map((F)=>vl(F.mb)),f=Math.max(1,...r),n=Math.max(0,Math.min(...r,0)),i=Math.max(1,f-n),t=u.length>1?u:[...u,...u],y=t.length<=1?100:100/(t.length-1),c=t.map((F,U)=>{let N=vl(F.mb);return`${(U*y).toFixed(2)},${(48-(N-n)/i*42).toFixed(2)}`}).join(" "),$=`0,50 ${c} 100,50`,A=u.at(-1),j=u[0];return _("article",{className:"performance-memory-card","data-testid":"performance-memory-chart"},_("div",{className:"performance-memory-head"},_("strong",null,`Bwebui: ${A?`${vl(A.mb).toFixed(1)}MB`:"--"}`),_("span",null,u.length>0?`${u.length} samples`:"等待采样")),_("svg",{viewBox:"0 0 100 50",preserveAspectRatio:"none",role:"img","aria-label":"Bwebui memory trend"},_("polygon",{points:$}),_("polyline",{points:c}),_("line",{x1:"0",x2:"100",y1:"25",y2:"25"})),_("div",{className:"performance-axis-row"},_("span",null,j?iu(new Date(j.at)):"--"),_("span",null,"时间"),_("span",null,A?iu(new Date(A.at)):"--")),_("div",{className:"performance-axis-row"},_("span",null,`${n.toFixed(1)}`),_("span",null,"(MB)"),_("span",null,`${f.toFixed(1)}`)))}function nP({onRaw:l}){let[u,r]=kl({core:null,frontend:null}),[f,n]=kl([]),[i,t]=kl(""),[y,c]=kl(!1),[$,A]=kl(null),[j,F]=kl(!1);async function U(){c(!0),t("");try{let[V,B]=await Promise.all([ml(`${sl.apiBaseUrl}/performance`,{cache:"no-store"}),ml(`${sl.apiBaseUrl}/frontend-performance`,{cache:"no-store"})]);r({core:V,frontend:B});let m=rP(B);n((X)=>[...X,{at:new Date().toISOString(),mb:m/1048576}].slice(-80))}catch(V){t(El(V,"性能指标加载失败"))}finally{c(!1)}}En(()=>{U();let V=setInterval(()=>void U(),5000);return()=>clearInterval(V)},[]);async function N(){F(!0),t(""),A(null);try{let V=await ml(`${sl.apiBaseUrl}/code-queue-load-test`,{method:"POST",body:JSON.stringify({targetMs:1000,timeoutMs:90000,url:sl.frontendPublicUrl||window.location.origin})});A(V),U()}catch(V){t(El(V,"Code Queue Playwright 测量失败"))}finally{F(!1)}}let W=dY(u),L=lP(u),J=eY(u),w=uP(u),Q=u.core?.process||{},q=u.frontend?.process||{},T=u.core?.database?.codeQueueStorage||{},O=vl(T.total),Z=$?.result||{},E=vl(Z.wallMs,NaN),D=vl(Z.networkIdleMs,NaN),Y=Z.withinTarget===!0,p=j?"running":$===null?"idle":$.measurementOk===!0?Y?"passed":"slow":"failed";return _("div",{className:"performance-page","data-testid":"performance-page"},_("div",{className:"performance-hero"},_("div",null,_("p",{className:"panel-eyebrow"},"Unified Performance"),_(fu,{title:"性能面板",loading:y||j}),_("p",null,"按组件统计 HTTP 请求、失败率、P95 延迟,并汇总 backend/frontend 内部操作耗时。")),_("div",{className:"inline-actions"},_("button",{type:"button",className:"ghost-btn",onClick:()=>void N(),disabled:j,"data-testid":"code-queue-load-test-button"},j?"测试中...":"测试 Code Queue 加载"),_("button",{type:"button",className:"ghost-btn",onClick:()=>void U(),disabled:y,"data-testid":"performance-refresh-button"},y?"刷新中":"刷新"),_(du,{title:"Performance Snapshot",data:u,onOpen:l,testId:"raw-performance"}))),_(lu,{error:i}),_("div",{className:"performance-top-grid"},_(fP,{points:f}),_("div",{className:"performance-metric-stack"},_(Nu,{label:"backend RSS",value:Nr(Q.rssBytes),hint:`heap ${Nr(Q.heapUsedBytes)}`}),_(Nu,{label:"frontend RSS",value:Nr(q.rssBytes),hint:`bundle ${Nr(u.frontend?.appBundleBytes)}`}),_(Nu,{label:"Codex PG 任务",value:O||"--",hint:T.ok?"unidesk_code_queue_tasks":"等待表初始化",tone:T.ok?"ok":"warn"}),_(Nu,{label:"请求样本",value:vl(u.core?.requests?.sampleCount)+vl(u.frontend?.requests?.sampleCount),hint:"rolling window 3000"}))),_(uu,{title:"Code Queue 加载基准",eyebrow:"Playwright / target <1s",className:"codex-load-test-panel",loading:j,actions:_("div",{className:"panel-actions"},_("button",{type:"button",className:"primary-btn",onClick:()=>void N(),disabled:j,"data-testid":"code-queue-load-test-panel-button"},j?"正在运行 Playwright...":"手动触发测试"),$?_(du,{title:"Code Queue Load Test",data:$,onOpen:l,testId:"raw-code-queue-load-test"}):null)},_("div",{className:"codex-load-test-grid","data-testid":"code-queue-load-test-result"},_(Nu,{label:"总耗时",value:j?"运行中":Number.isFinite(E)?Wf(E):"--",hint:$===null?"点击按钮启动远端 Playwright":`目标 ${Wf(Z.targetMs||1000)} / ${Z.url||"Code Queue"}`,tone:p==="passed"?"ok":p==="failed"||p==="slow"?"warn":""}),_(Nu,{label:"判定",value:j?"RUNNING":p==="passed"?"PASS <1s":p==="slow"?"SLOW":p==="failed"?"FAILED":"--",hint:$?.measurementOk===!1?String($.error||Z.error||"measurement failed").slice(0,120):"导航开始 -> DOMContentLoaded -> data-load-state=complete",tone:p==="passed"?"ok":p==="idle"||p==="running"?"":"fail"}),_(Nu,{label:"Network idle",value:Number.isFinite(D)?Wf(D):"--",hint:`DOMContentLoaded ${Wf(Z.domContentLoadedMs)} / ${Z.networkIdleReached===!1?"未在 5s 内空闲":"已空闲"}`,tone:Number.isFinite(D)&&D<=1000?"ok":"warn"}),_(Nu,{label:"组件耗时",value:Number.isFinite(vl(Z.componentLoadMs,NaN))?Wf(Z.componentLoadMs):"--",hint:`queue ${Wf(Z.queueMs)} / detail ${Wf(Z.detailMs)}`,tone:vl(Z.componentLoadMs)>1000?"warn":"ok"}),_(Nu,{label:"Trace 规模",value:Number.isFinite(vl(Z.transcriptRows,NaN))?String(Z.transcriptRows):"--",hint:`${Z.visibleTaskCount??0} visible tasks / ${Z.partial?"preview":"complete"}`})),j?_("div",{className:"performance-empty-line"},"正在通过 main-server Host SSH 启动 Playwright,完成后会显示 wall time、组件耗时和最慢 API。"):null,$&&Array.isArray(Z.slowestApi)&&Z.slowestApi.length>0?_("div",{className:"table-wrap performance-table-wrap compact codex-load-api-table"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["API","状态","耗时"].map((V)=>_("th",{key:V},V)))),_("tbody",null,Z.slowestApi.slice(0,5).map((V,B)=>_("tr",{key:`${V.url}-${B}`},_("td",null,_("code",null,V.url)),_("td",null,V.status),_("td",null,Wf(V.durationMs))))))):null),_("div",{className:"performance-grid"},_(uu,{title:"组件汇总",eyebrow:"Requests",loading:y},W.length===0?_(Qu,{title:"暂无请求样本",text:"刷新几次或打开页面后会自动形成组件统计"}):_("div",{className:"table-wrap performance-table-wrap"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["组件","请求数","失败数","失败率","平均延迟","P95"].map((V)=>_("th",{key:V},V)))),_("tbody",null,W.map((V)=>_("tr",{key:V.component},_("td",null,_("code",null,V.component)),_("td",null,V.requestCount),_("td",null,V.failureCount),_("td",null,n0(vl(V.failureRate)*100)),_("td",null,Wf(V.averageLatencyMs)),_("td",null,Wf(V.p95LatencyMs)))))))),_(uu,{title:"最近失败请求",eyebrow:"Failures",loading:y},L.length===0?_("div",{className:"performance-empty-line"},"最近没有失败请求"):_("div",{className:"table-wrap performance-table-wrap compact"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["时间","来源","组件","状态","路径"].map((V)=>_("th",{key:V},V)))),_("tbody",null,L.map((V,B)=>_("tr",{key:`${V.at}-${B}`},_("td",null,Wl(V.at)),_("td",null,V.source),_("td",null,_("code",null,V.component)),_("td",null,_(Tu,{status:"failed"},V.status)),_("td",null,_("code",null,V.path)))))))),_(uu,{title:"内部操作汇总",eyebrow:"Operations",loading:y},J.length===0?_(Qu,{title:"暂无内部操作样本",text:"API 查询和代理请求会自动记录内部操作耗时"}):_("div",{className:"table-wrap performance-table-wrap"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["服务","操作","次数","平均延迟","P95"].map((V)=>_("th",{key:V},V)))),_("tbody",null,J.map((V)=>_("tr",{key:`${V.service}-${V.operation}`},_("td",null,V.service),_("td",null,_("code",null,V.operation)),_("td",null,V.count),_("td",null,Wf(V.averageLatencyMs)),_("td",null,Wf(V.p95LatencyMs)))))))),_(uu,{title:"最近慢操作",eyebrow:"Slowest",loading:y},w.length===0?_(Qu,{title:"暂无慢操作",text:"后端会记录最近窗口内耗时最高的内部操作"}):_("div",{className:"table-wrap performance-table-wrap"},_("table",{className:"performance-table"},_("thead",null,_("tr",null,["时间","操作","耗时","结果","细节"].map((V)=>_("th",{key:V},V)))),_("tbody",null,w.map((V,B)=>_("tr",{key:`${V.at}-${V.operation}-${B}`},_("td",null,Wl(V.at)),_("td",null,_("code",null,V.operation)),_("td",null,Wf(V.durationMs)),_("td",null,V.ok?"成功":"失败"),_("td",null,V.detail||"-")))))))))}function iP({provider:l,refresh:u,onRaw:r}){let[f,n]=kl(""),[i,t]=kl(null),[y,c]=kl("");async function $(A){n(A),c("");try{let j=await ml(`${sl.apiBaseUrl}/dispatch`,{method:"POST",body:JSON.stringify({providerId:l.providerId,command:"provider.upgrade",payload:{mode:A,source:"frontend-resource-monitor",requestedAt:new Date().toISOString()}})});t({mode:A,...j}),await u()}catch(j){c(El(j,"升级命令下发失败"))}finally{n("")}}return _(uu,{title:"Provider Gateway 升级",eyebrow:"Remote Control",loading:Boolean(f)},_("div",{className:"upgrade-control","data-testid":"provider-upgrade-control"},_("p",null,"通过 UniDesk WebSocket 向当前计算节点下发 provider.upgrade;预检只生成升级计划,执行升级会调度节点本地 updater 容器。"),_("div",{className:"upgrade-target-line"},_("span",null,"指定 Provider"),_("code",null,l.providerId),_(My,{node:l})),_("div",{className:"upgrade-actions"},_("button",{type:"button",className:"ghost-btn",disabled:Boolean(f),onClick:()=>$("plan"),"data-testid":"upgrade-plan-button"},f==="plan"?"预检中":"预检升级"),_("button",{type:"button",className:"ghost-btn danger",disabled:Boolean(f),onClick:()=>$("schedule"),"data-testid":"upgrade-schedule-button"},f==="schedule"?"调度中":"执行升级")),_(lu,{error:y}),i?_("div",{className:"upgrade-result"},_(Tu,{status:i.status||"queued"},i.status||"queued"),_("span",null,`${i.mode==="schedule"?"执行升级":"预检升级"} 已下发`),_("span",null,`指定版本 ${Rj(UG(l))}`),_("code",null,i.taskId||"--"),_(du,{title:"Provider Upgrade Dispatch",data:i,onOpen:r})):_("span",{className:"muted"},"升级任务结果会进入任务历史;执行升级可能导致 provider 短暂重连。")))}function zG({records:l,onRaw:u,compact:r=!1}){if(l.length===0)return _(Qu,{title:"暂无远程更新记录",text:"该节点还没有 provider.upgrade 任务;执行预检或升级后会在这里形成结构化记录"});return _("div",{className:`upgrade-record-table-wrap table-wrap ${r?"compact":""}`},_("table",{className:"upgrade-record-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"模式"),_("th",null,"任务"),_("th",null,"来源"),_("th",null,"耗时"),_("th",null,"策略"),_("th",null,"Gateway 版本"),_("th",null,"结果记录"),_("th",null,"更新时间"),_("th",null,"操作"))),_("tbody",null,l.map((f)=>_("tr",{key:f.id,"data-testid":`gateway-upgrade-record-${uf(f.id)}`},_("td",null,_(Tu,{status:f.status})),_("td",null,_("span",{className:`mode-chip ${i6(f)}`},i6(f)==="schedule"?"执行升级":"预检")),_("td",null,_("strong",null,"provider.upgrade"),_("code",null,f.id)),_("td",null,DY(f)),_("td",null,_(OG,{task:f})),_("td",null,VY(f)),_("td",null,_("span",{className:"version-chip"},qG(f))),_("td",null,_("span",{className:`upgrade-outcome ${String(f.status||"").toLowerCase()}`},WG(f))),_("td",null,Wl(f.updatedAt)),_("td",null,_(du,{title:`Provider Upgrade Task ${f.id}`,data:j_(f),onOpen:u})))))))}function tP({provider:l,tasks:u,onRaw:r,limit:f=5}){let n=LG(u,l.providerId).slice(0,f);return _(uu,{title:"远程更新记录",eyebrow:l.providerId,actions:_(My,{node:l}),className:"provider-upgrade-records-panel"},_("div",{"data-testid":`provider-upgrade-records-${uf(l.providerId)}`},_(zG,{records:n,onRaw:r,compact:!0})))}function yP({nodes:l,tasks:u,onRaw:r}){let f=A_(()=>l.map((i)=>{let t=LG(u,i.providerId);return{node:i,records:t,latest:SY(t),capabilities:NG(i)}}),[l,u]),n=f.reduce((i,t)=>i+t.records.length,0);return _("div",{className:"gateway-page","data-testid":"gateway-version-page"},_(uu,{title:"Provider Gateway 版本",eyebrow:`${l.length} Providers / ${n} 更新记录`},l.length===0?_(Qu,{title:"暂无 Provider 节点",text:"等待 provider-gateway 注册后显示版本号和升级记录"}):_("div",{className:"table-wrap gateway-version-table-wrap"},_("table",{className:"gateway-version-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"Provider"),_("th",null,"Gateway 版本"),_("th",null,"升级策略"),_("th",null,"运维可用性"),_("th",null,"运行时间"),_("th",null,"能力"),_("th",null,"最近远程更新"),_("th",null,"操作"))),_("tbody",null,f.map((i)=>_("tr",{key:i.node.providerId},_("td",null,_(Tu,{status:i.node.status})),_("td",null,_("strong",null,i.node.name),_("code",null,i.node.providerId)),_("td",null,_(My,{node:i.node})),_("td",null,$_(i.node)),_("td",null,_(xj,{node:i.node})),_("td",null,lG(i.node)?Wl(lG(i.node)):"待新版上报"),_("td",null,_("div",{className:"capability-row"},i.capabilities.length===0?_("span",{className:"muted"},"未声明"):i.capabilities.slice(0,5).map((t)=>_("span",{key:t,className:"data-chip"},t)))),_("td",null,i.latest?_("div",{className:"latest-upgrade-cell"},_(Tu,{status:i.latest.status}),_("span",null,`${i6(i.latest)==="schedule"?"执行升级":"预检"} / ${Wl(i.latest.updatedAt)}`),_("small",null,`Gateway ${qG(i.latest)}`),_("small",null,WG(i.latest))):_("span",{className:"muted"},"暂无记录")),_("td",null,_(du,{title:`Provider ${i.node.providerId}`,data:i.node,onOpen:r})))))))),_(uu,{title:"远程更新记录",eyebrow:"Structured provider.upgrade records"},l.length===0?_(Qu,{title:"暂无记录",text:"没有 provider 节点时不会生成远程更新记录"}):_("div",{className:"gateway-record-grid"},f.map((i)=>_("article",{key:i.node.providerId,className:"gateway-record-card","data-testid":`gateway-records-${uf(i.node.providerId)}`},_("div",{className:"gateway-record-head"},_("div",null,_("strong",null,i.node.name),_("code",null,i.node.providerId)),_(My,{node:i.node})),_("div",{className:"gateway-record-meta"},_("span",null,`心跳 ${Wl(i.node.lastHeartbeat)}`),_("span",null,`策略 ${$_(i.node)}`),_("span",null,`${i.records.length} 条记录`)),_(zG,{records:i.records.slice(0,8),onRaw:r,compact:!0}))))))}function cP(l){if(l==="running")return"online";if(l==="paused"||l==="restarting")return"warn";if(l==="exited"||l==="dead")return"offline";return"internal"}function EG(l){return/^[a-f0-9]{48,64}$/i.test(l)}function __(l){let u=String(l?.name||""),r=String(l?.labels||"");return u==="unidesk_pgdata_10gb"||r.includes("com.docker.compose.volume=unidesk_pgdata_10gb")||u.toLowerCase().includes("pgdata")}function tG(l){let u=String(l?.name||""),r=String(l?.labels||"");if(__(l))return 0;if(r.includes("com.docker.compose.project=unidesk"))return 1;if(!EG(u))return 2;return 3}function _P(l){return[...l].sort((u,r)=>{let f=tG(u)-tG(r);if(f!==0)return f;return String(u.name||"").localeCompare(String(r.name||""))})}function $P({nodes:l,dockerStatuses:u,onRaw:r}){let[f,n]=kl(""),i=A_(()=>l.map((w)=>{let Q=u.find((q)=>q.providerId===w.providerId);return{...w,dockerStatus:Q?.dockerStatus||null,dockerUpdatedAt:Q?.updatedAt||null}}),[l,u]),t=i.find((w)=>w.providerId===f)||i[0]||null;if(En(()=>{if(!f&&i[0])n(i[0].providerId)},[i.length,f]),!t)return _(Qu,{title:"暂无 Docker 节点",text:"等待 provider 上报 Docker daemon 状态"});let y=t.dockerStatus,c=t.providerId==="main-server",$=y?.counts||{},A=y?.daemon||{},j=y?.containers||[],F=y?.images||[],U=_P(y?.volumes||[]),N=c?U.find(__):null,W=y?.networks||[],L=j.filter((w)=>w.state==="running"),J=j.filter((w)=>w.state!=="running");return _("div",{className:"docker-page","data-testid":"docker-status-page"},_("div",{className:"docker-node-strip"},i.map((w)=>_("button",{key:w.providerId,type:"button",className:`docker-node-tile ${t.providerId===w.providerId?"active":""}`,onClick:()=>n(w.providerId)},_("span",{className:`pulse ${w.status}`}),_("strong",null,w.name),_("code",null,w.providerId),_("span",null,w.dockerStatus?`Docker ${w.dockerStatus.ok?"ready":"degraded"}`:"等待上报")))),_("div",{className:"docker-layout"},_(uu,{title:"Docker Desktop 视图",eyebrow:t.name,className:"docker-main-panel",actions:y?_(du,{title:`Docker ${t.providerId}`,data:y,onOpen:r}):null},!y?_(Qu,{title:"Docker 状态未上报",text:"provider-gateway 会在连接后周期性采集 docker info / ps / images / volume / network"}):_("div",null,_("div",{className:"docker-hero"},_("div",null,_("p",{className:"panel-eyebrow"},"Daemon"),_("h3",null,A.name||t.providerId),_("div",{className:"docker-meta"},_("span",null,A.serverVersion?`Engine ${A.serverVersion}`:"Engine --"),_("span",null,A.operatingSystem||"OS --"),_("span",null,A.architecture||"arch --"),_("span",null,`${A.cpus||0} CPU / ${Nr(A.memoryBytes)}`))),_(Tu,{status:y.ok?"online":"warn"},y.ok?"Docker Ready":"Docker Degraded")),_("div",{className:"docker-metrics"},_(Nu,{label:"Containers",value:$.containers??j.length,hint:`${$.running??L.length} running / ${$.stopped??J.length} stopped`,tone:"ok"}),_(Nu,{label:"Images",value:$.images??F.length,hint:`${$.daemonImages??$.images??F.length} daemon images`}),_(Nu,{label:"Volumes",value:$.volumes??U.length,hint:c?N?"database volume visible":"database volume missing":"node local volumes",tone:N?"ok":""}),_(Nu,{label:"Networks",value:$.networks??W.length,hint:A.driver?`driver ${A.driver}`:"docker networks"})),c?_(AP,{volume:N,volumeCount:U.length}):null,_("div",{className:"docker-section-head"},_("h3",null,"Containers"),_("span",null,`updated ${Wl(t.dockerUpdatedAt||y.collectedAt)}`)),_("div",{className:"docker-container-table table-wrap","data-testid":"docker-container-table"},_("table",null,_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"容器"),_("th",null,"镜像"),_("th",null,"端口"),_("th",null,"运行时间"),_("th",null,"重启策略"),_("th",null,"PID"),_("th",null,"大小"))),_("tbody",null,j.length===0?_("tr",null,_("td",{colSpan:8},"暂无容器")):j.map((w)=>_("tr",{key:`${w.id}-${w.name}`},_("td",null,_(Tu,{status:cP(w.state)},w.state||"unknown")),_("td",null,_("strong",null,w.name||"--"),_("code",null,w.id||"--")),_("td",null,w.image||"--"),_("td",null,w.ports||_("span",{className:"muted"},"未发布")),_("td",null,w.runningFor||w.status||"--"),_("td",null,w.restartPolicy?_(Tu,{status:w.restartPolicy==="always"?"online":"warn"},w.restartPolicy):"--"),_("td",null,w.pidMode?_("code",null,w.pidMode):"--"),_("td",null,w.size||"--")))))))),_("div",{className:"docker-side-stack"},_(Pj,{title:"Images",items:F,render:(w)=>_("article",{key:`${w.id}-${w.repository}`,className:"docker-side-row"},_("strong",null,`${w.repository}:${w.tag}`),_("span",null,w.size||"--"),_("code",null,w.id||"--"))}),_(Pj,{title:"Volumes",items:U,limit:U.length,render:(w)=>_("article",{key:w.name,className:`docker-side-row volume-row ${c&&__(w)?"database-volume":""}`,"data-testid":c&&__(w)?"database-volume-row":void 0},_("strong",null,w.name),_("span",null,c&&__(w)?"PostgreSQL":EG(String(w.name||""))?"anonymous":"named"),_("code",null,w.mountpoint||w.driver||w.scope||"--"))}),_(Pj,{title:"Networks",items:W,render:(w)=>_("article",{key:w.id||w.name,className:"docker-side-row"},_("strong",null,w.name),_("span",null,w.driver||"--"),_("code",null,w.id||"--"))}))))}function AP({volume:l,volumeCount:u}){return _("section",{className:`docker-volume-focus ${l?"ready":"missing"}`,"data-testid":"database-volume-card"},_("div",{className:"volume-focus-head"},_("span",{className:"panel-eyebrow"},"Database Named Volume"),_(Tu,{status:l?"online":"warn"},l?"FOUND":"MISSING")),l?_("div",{className:"volume-focus-body"},_("strong",null,l.name),_("span",null,"PostgreSQL data volume for unidesk-database"),_("div",{className:"volume-route"},_("code",null,l.mountpoint||"/var/lib/docker/volumes/unidesk_pgdata_10gb/_data"),_("span",null,"->"),_("code",null,"unidesk-database:/var/lib/postgresql/data")),_("div",{className:"docker-meta compact"},_("span",null,`driver ${l.driver||"--"}`),_("span",null,`scope ${l.scope||"--"}`),_("span",null,`${u} volumes reported`))):_("div",{className:"volume-focus-body"},_("strong",null,"unidesk_pgdata_10gb"),_("span",null,"当前 Docker 快照没有发现数据库命名卷;请检查 provider-gateway 的 Docker volume 上报。")))}function Pj({title:l,items:u,render:r,limit:f}){let n=u.slice(0,f??12),i=Math.max(0,u.length-n.length);return _(uu,{title:l,eyebrow:`${u.length} items`,className:"docker-side-panel"},u.length===0?_(Qu,{title:`暂无 ${l}`,text:"等待 Docker 状态采集"}):_("div",{className:"docker-side-list"},n.map(r),i>0?_("div",{className:"docker-side-more"},`+ ${i} more`):null))}function jP({microservices:l,onRaw:u,onNavigate:r}){let f=l.filter((n)=>rG(n).public===!1);return _("div",{className:"microservice-page","data-testid":"microservice-catalog-page"},_(uu,{title:"用户服务目录",eyebrow:"Provider Mounted User Services"},_("div",{className:"metric-grid"},_(Nu,{label:"服务总数",value:l.length,hint:"config.json 用户服务登记"}),_(Nu,{label:"私有后端",value:f.length,hint:"不直接暴露公网",tone:"ok"}),_(Nu,{label:"D601 服务",value:l.filter((n)=>n.providerId==="D601").length,hint:"compute-node docker"}),_(Nu,{label:"集成前端",value:l.filter((n)=>n.frontend?.integrated).length,hint:"UniDesk React 页面"}))),_(uu,{title:"服务映射",eyebrow:"Repo Reference + Runtime"},l.length===0?_(Qu,{title:"暂无用户服务",text:"在 config.json 的 microservices 中登记用户服务的 provider、仓库引用和后端映射"}):_("div",{className:"table-wrap"},_("table",{className:"microservice-table"},_("thead",null,_("tr",null,_("th",null,"服务"),_("th",null,"Provider"),_("th",null,"代码引用"),_("th",null,"Docker 引用"),_("th",null,"后端映射"),_("th",null,"开发入口"),_("th",null,"运行态"),_("th",null,"操作"))),_("tbody",null,l.map((n)=>{let i=GG(n),t=XY(n),y=rG(n),c=i.availability||{},$=c.status||(i.providerStatus==="online"?"unknown":"unhealthy");return _("tr",{key:n.id,"data-testid":`microservice-row-${uf(n.id)}`},_("td",null,_("strong",null,n.name),_("code",null,n.id)),_("td",null,_("strong",null,i.providerName||n.providerId),_("code",null,n.providerId)),_("td",null,_("span",null,t.url||"--"),_("code",null,t.commitId||"--")),_("td",null,_("span",null,t.composeFile||"--"),_("code",null,`${t.composeService||"--"} / ${t.containerName||"--"}`)),_("td",null,_(Tu,{status:y.public?"warn":"online"},y.public?"public":"private"),_("code",null,`${y.nodeBindHost||"--"}:${y.nodePort||"--"} -> ${y.proxyMode||"--"}`)),_("td",null,_("span",null,n.development?.sshPassthrough?"SSH 透传":"未配置"),_("code",null,n.development?.worktreePath||"--")),_("td",null,_(Tu,{status:$==="healthy"?"online":$==="unknown"?"warn":"failed"},$),_("span",null,c.reason||i.providerStatus||"unknown"),_(t0,{data:i.container,empty:"容器快照未上报"})),_("td",null,_("div",{className:"microservice-actions"},n.id==="findjob"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","findjob"),"data-testid":"open-findjob-button"},"打开"):null,n.id==="pipeline"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","pipeline"),"data-testid":"open-pipeline-button"},"打开"):null,n.id==="todo-note"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","todo-note"),"data-testid":"open-todo-note-button"},"打开"):null,n.id==="met-nonlinear"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","met-nonlinear"),"data-testid":"open-met-nonlinear-button"},"打开"):null,n.id==="claudeqq"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","claudeqq"),"data-testid":"open-claudeqq-button"},"打开"):null,n.id==="baidu-netdisk"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","baidu-netdisk"),"data-testid":"open-baidu-netdisk-button"},"打开"):null,n.id==="oa-event-flow"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","oa-event-flow"),"data-testid":"open-oa-event-flow-button"},"打开"):null,n.id==="k3sctl-adapter"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","k3sctl"),"data-testid":"open-k3sctl-button"},"打开"):null,n.id==="code-queue"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","code-queue"),"data-testid":"open-code-queue-button"},"打开"):null,n.id==="mdtodo"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","mdtodo"),"data-testid":"open-mdtodo-button"},"打开"):null,n.id==="decision-center"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","decision-center"),"data-testid":"open-decision-center-button"},"打开"):null,n.id==="project-manager"?_("button",{type:"button",className:"ghost-btn",onClick:()=>r("apps","project-manager"),"data-testid":"open-project-manager-button"},"打开"):null,_(du,{title:`用户服务 ${n.id}`,data:n,onOpen:u}))))}))))))}function FP({nodes:l,onDispatched:u,onRaw:r}){let f=l.filter((p)=>p.status==="online"),[n,i]=kl(f[0]?.providerId||l[0]?.providerId||""),[t,y]=kl("docker.ps"),[c,$]=kl("frontend"),[A,j]=kl("operator-check"),[F,U]=kl("normal"),[N,W]=kl(!1),[L,J]=kl(""),[w,Q]=kl(!1),[q,T]=kl(null),[O,Z]=kl("");En(()=>{if(!n&&(f[0]?.providerId||l[0]?.providerId))i(f[0]?.providerId||l[0].providerId)},[l.length,f.length,n]);function E(){return{source:c,note:A,priority:F}}function D(){J(JSON.stringify(E(),null,2)),W(!0)}async function Y(p){p.preventDefault(),Q(!0),Z("");try{let V=N?JSON.parse(L||"{}"):E(),B=await ml(`${sl.apiBaseUrl}/dispatch`,{method:"POST",body:JSON.stringify({providerId:n,command:t,payload:V})});T(B),await u()}catch(V){Z(El(V,"下发失败"))}finally{Q(!1)}}return _("div",{className:"page-grid dispatch-grid"},_(uu,{title:"下发任务",eyebrow:"Real WebSocket Dispatch"},_("form",{className:"dispatch-form",onSubmit:Y},_("label",null,"Provider",_("select",{value:n,onChange:(p)=>i(p.target.value)},l.map((p)=>_("option",{key:p.providerId,value:p.providerId},`${p.name} / ${p.providerId}`)))),_("label",null,"Command",_("select",{value:t,onChange:(p)=>y(p.target.value)},_("option",{value:"docker.ps"},"docker.ps"),_("option",{value:"host.ssh"},"host.ssh"),_("option",{value:"microservice.http"},"microservice.http"),_("option",{value:"echo"},"echo"))),_("label",null,"来源",_("input",{value:c,onChange:(p)=>$(p.target.value)})),_("label",null,"备注",_("input",{value:A,onChange:(p)=>j(p.target.value)})),_("label",null,"优先级",_("select",{value:F,onChange:(p)=>U(p.target.value)},_("option",{value:"normal"},"normal"),_("option",{value:"low"},"low"),_("option",{value:"urgent"},"urgent"))),_("div",{className:"dispatch-actions"},_("button",{type:"button",className:"ghost-btn",onClick:D},"查看原始JSON"),_("button",{type:"submit",disabled:w||!n},w?"下发中":"下发任务")),N?_("label",{className:"raw-editor-label"},"高级 Payload",_("textarea",{className:"raw-editor",value:L,onChange:(p)=>J(p.target.value)})):null,_(lu,{error:O,wide:!0}))),_(uu,{title:"下发结果",eyebrow:"Response"},q?_("div",{className:"result-card"},_(Tu,{status:q.status||"queued"},q.status||"queued"),_("dl",null,_("dt",null,"Task ID"),_("dd",null,_("code",null,q.taskId||"--")),_("dt",null,"Provider 在线"),_("dd",null,ft(q.providerOnline))),_(du,{title:"Dispatch Response",data:q,onOpen:r})):_(Qu,{title:"等待操作",text:"任务响应会以结构化结果卡展示"})))}function yG({task:l,onRaw:u}){return _("article",{className:"compact-row"},_(Tu,{status:l.status}),_("div",null,_("strong",null,l.command),_("code",null,l.id)),_("span",null,hy(l)?`已等待 ${Mj(l.updatedAt)}`:`耗时 ${fi(jG(l)??0)}`),_(du,{title:`Task ${l.id}`,data:j_(l),onOpen:u}))}function OG({task:l}){let u=jG(l),r=hy(l);return _("div",{className:"task-duration"},_("strong",null,u===null?"--":fi(u)),_("span",null,r?`已运行 / 创建 ${Wl(l.createdAt)}`:`创建 ${Wl(l.createdAt)}`))}function JP({task:l}){let u=String(l?.status||"").toLowerCase(),r=l?.result,f=r&&typeof r==="object"&&!Array.isArray(r)?r:{},i=["exitCode","code","signal","timeoutMs","previousStatus","mode"].filter((t)=>f[t]!==void 0&&f[t]!==null);if(u==="failed"){let t=FG(l);return _("div",{className:"task-diagnostic failed"},_("b",null,"失败原因"),_("span",{className:"diagnostic-reason"},ft(t)),i.length>0?_("div",{className:"diagnostic-meta"},i.map((y)=>_("span",{key:y,className:"data-chip"},_("b",null,y),_("span",null,ft(f[y]))))):null)}if(hy(l))return _("div",{className:"task-diagnostic warn"},_("b",null,"等待终态"),_("span",null,`最后更新 ${Mj(l.updatedAt)} 前`));return _("div",{className:"task-diagnostic ok"},_("b",null,"完成摘要"),_(t0,{data:r,empty:"无执行输出"}))}function UP({tasks:l,onRaw:u}){let r=l.filter(hy);return _("div",{"data-testid":"pending-task-page"},_(uu,{title:"待处理任务",eyebrow:`${r.length} Pending`},r.length===0?_(Qu,{title:"当前无待处理任务",text:"queued / dispatched / running 会在超时后自动转为 failed;历史记录仍可在任务历史中查看"}):_("div",{className:"table-wrap","data-testid":"pending-task-table"},_("table",null,_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"任务"),_("th",null,"Provider"),_("th",null,"已等待"),_("th",null,"载荷摘要"),_("th",null,"操作"))),_("tbody",null,r.map((f)=>_("tr",{key:f.id},_("td",null,_(Tu,{status:f.status})),_("td",null,_("strong",null,f.command),_("code",null,f.id)),_("td",null,_("code",null,f.providerId)),_("td",null,Mj(f.updatedAt)),_("td",null,_(t0,{data:f.payload})),_("td",null,_(du,{title:`Pending Task ${f.id}`,data:j_(f),onOpen:u})))))))))}function NP({tasks:l,onRaw:u}){return _("div",{"data-testid":"task-history-page"},_(uu,{title:"任务历史",eyebrow:`${l.length} Tasks`},l.length===0?_(Qu,{title:"暂无任务",text:"下发任务后会在这里看到生命周期"}):_("div",{className:"table-wrap"},_("table",{className:"task-history-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"任务"),_("th",null,"Provider"),_("th",null,"任务耗时"),_("th",null,"载荷摘要"),_("th",null,"诊断信息"),_("th",null,"更新时间"),_("th",null,"操作"))),_("tbody",null,l.map((r)=>_("tr",{key:r.id,"data-testid":`task-row-${uf(r.id)}`},_("td",null,_(Tu,{status:r.status})),_("td",null,_("strong",null,r.command),_("code",null,r.id)),_("td",null,_("code",null,r.providerId)),_("td",null,_(OG,{task:r})),_("td",null,_(t0,{data:r.payload})),_("td",null,_(JP,{task:r})),_("td",null,Wl(r.updatedAt)),_("td",null,_(du,{title:`Task ${r.id}`,data:j_(r),onOpen:u})))))))))}function QP({tasks:l,onRaw:u}){let r=l.filter((f)=>["succeeded","failed"].includes(f.status));return _(uu,{title:"执行结果",eyebrow:"Finished Tasks"},r.length===0?_(Qu,{title:"暂无结果",text:"任务完成后展示 provider 返回的结构化摘要"}):_("div",{className:"result-grid"},r.map((f)=>_("article",{key:f.id,className:"result-card"},_("div",{className:"node-card-head"},_("strong",null,f.command),_(Tu,{status:f.status})),_("code",null,f.id),_(t0,{data:f.result,empty:"无执行输出"}),_(du,{title:`Task Result ${f.id}`,data:j_(f),onOpen:u})))))}function wP(l){if(!l||typeof l!=="object")return"--";if(l.type==="interval")return`每 ${fi(Number(l.everySeconds||0))}`;return`每天 ${l.timeOfDay||"03:00"} UTC`}function qP(l){if(!l||typeof l!=="object")return"--";if(l.type==="pgdata_backup")return`PGDATA -> ${l.remoteBaseDir||"/SERVER_DATA/UNIDESK_PG_DATA"}`;if(l.type==="dispatch")return`${l.providerId||"--"} / ${l.command||"--"}`;return String(l.type||"--")}function WP(l){let u=String(l||"").toLowerCase();if(u==="succeeded")return"online";if(u==="failed")return"failed";if(u==="running"||u==="queued")return"warn";return u}function LP(l){let u=Number(l?.durationMs);if(Number.isFinite(u)&&u>=0)return fi(u/1000);let r=On(l?.startedAt||l?.createdAt);if(r===null)return"--";let n=On(l?.finishedAt)??Date.now();return fi(Math.max(0,(n-r)/1000))}function cG(l){return{id:"unidesk-pgdata-baidu-daily",name:"PGDATA daily Baidu Netdisk backup",description:"Daily PostgreSQL physical base backup uploaded to Baidu Netdisk /SERVER_DATA with monthly rotation.",enabled:!0,timeOfDay:"03:30",actionType:"pgdata_backup",providerId:l[0]?.providerId||"main-server",command:"echo",payloadJson:JSON.stringify({source:"scheduled-task",message:"hello from scheduler"},null,2),remoteBaseDir:"/SERVER_DATA/UNIDESK_PG_DATA",stagingSubdir:"server-data/unidesk-pg-data",timeoutMs:"3600000"}}function GP({schedules:l,scheduleRuns:u,nodes:r,refresh:f,onRaw:n}){let[i,t]=kl(cG(r||[])),[y,c]=kl(!1),[$,A]=kl(""),[j,F]=kl(""),U=[...u||[]].sort((q,T)=>(On(T.updatedAt)??0)-(On(q.updatedAt)??0));function N(q,T){t((O)=>({...O,[q]:T}))}function W(q){let T=q?.action||{};t({id:q?.id||"",name:q?.name||"",description:q?.description||"",enabled:q?.enabled!==!1,timeOfDay:q?.schedule?.timeOfDay||"03:30",actionType:T.type||"dispatch",providerId:T.providerId||r[0]?.providerId||"main-server",command:T.command||"echo",payloadJson:JSON.stringify(T.payload||{source:"scheduled-task"},null,2),remoteBaseDir:T.remoteBaseDir||"/SERVER_DATA/UNIDESK_PG_DATA",stagingSubdir:T.stagingSubdir||"server-data/unidesk-pg-data",timeoutMs:String(T.timeoutMs||3600000)}),F(`正在编辑 ${q?.id||""}`)}function L(){let q={id:i.id,name:i.name,description:i.description,enabled:i.enabled,concurrencyPolicy:"skip",schedule:{type:"daily",timeOfDay:i.timeOfDay,timezone:"Etc/UTC"}};if(i.actionType==="pgdata_backup")return{...q,action:{type:"pgdata_backup",volumeName:"unidesk_pgdata_10gb",remoteBaseDir:i.remoteBaseDir,stagingSubdir:i.stagingSubdir,timeoutMs:Number(i.timeoutMs)||3600000,cleanupLocal:!0}};return{...q,action:{type:"dispatch",providerId:i.providerId,command:i.command,payload:JSON.parse(i.payloadJson||"{}"),timeoutMs:Number(i.timeoutMs)||600000}}}async function J(q){q.preventDefault(),c(!0),A(""),F("");try{let T=L(),O=encodeURIComponent(String(T.id));await ml(`${sl.apiBaseUrl}/schedules/${O}`,{method:"PUT",body:JSON.stringify(T)}),F("定时任务已保存"),await f()}catch(T){A(El(T,"保存定时任务失败"))}finally{c(!1)}}async function w(q){if(!q?.id)return;c(!0),A(""),F("");try{await ml(`${sl.apiBaseUrl}/schedules/${encodeURIComponent(q.id)}`,{method:"DELETE"}),F(`已删除 ${q.id}`),await f()}catch(T){A(El(T,"删除定时任务失败"))}finally{c(!1)}}async function Q(q){if(!q?.id)return;c(!0),A(""),F("");try{let T=await ml(`${sl.apiBaseUrl}/schedules/${encodeURIComponent(q.id)}/run`,{method:"POST",body:"{}"});F(`已触发 ${q.id} / ${T?.run?.id||"run"}`),await f()}catch(T){A(El(T,"触发定时任务失败"))}finally{c(!1)}}return _("div",{className:"page-grid scheduled-task-page","data-testid":"scheduled-task-page"},_(uu,{title:"定时任务",eyebrow:`${(l||[]).length} Schedules`},(l||[]).length===0?_(Qu,{title:"暂无定时任务",text:"创建 daily / dispatch / PGDATA backup 任务后会在这里展示下一次执行时间和最近结果"}):_("div",{className:"schedule-card-grid"},(l||[]).map((q)=>_("article",{key:q.id,className:"schedule-card","data-testid":`schedule-row-${uf(q.id)}`},_("div",{className:"node-card-head"},_("strong",null,q.name||q.id),_(Tu,{status:q.enabled?"online":"warn"},q.enabled?"enabled":"disabled")),_("code",null,q.id),_("dl",null,_("dt",null,"计划"),_("dd",null,wP(q.schedule)),_("dt",null,"动作"),_("dd",null,qP(q.action)),_("dt",null,"下次执行"),_("dd",null,Wl(q.nextRunAt)),_("dt",null,"最近执行"),_("dd",null,q.lastRunAt?`${Wl(q.lastRunAt)} / ${q.lastRunId||"--"}`:"--")),_("div",{className:"dispatch-actions"},_("button",{type:"button",className:"ghost-btn",disabled:y,onClick:()=>W(q)},"编辑"),_("button",{type:"button",className:"ghost-btn",disabled:y,onClick:()=>Q(q),"data-testid":`schedule-run-${uf(q.id)}`},"手动触发"),_("button",{type:"button",className:"ghost-btn danger",disabled:y,onClick:()=>w(q)},"删除"),_(du,{title:`Schedule ${q.id}`,data:q,onOpen:n})))))),_(uu,{title:i.id?"配置定时任务":"新建定时任务",eyebrow:"CRUD"},_("form",{className:"dispatch-form schedule-form",onSubmit:J},_("label",null,"ID",_("input",{value:i.id,onChange:(q)=>N("id",q.target.value)})),_("label",null,"名称",_("input",{value:i.name,onChange:(q)=>N("name",q.target.value)})),_("label",null,"每日执行时间 UTC",_("input",{value:i.timeOfDay,placeholder:"03:30",onChange:(q)=>N("timeOfDay",q.target.value)})),_("label",null,"启用",_("select",{value:i.enabled?"true":"false",onChange:(q)=>N("enabled",q.target.value==="true")},_("option",{value:"true"},"enabled"),_("option",{value:"false"},"disabled"))),_("label",null,"动作类型",_("select",{value:i.actionType,onChange:(q)=>N("actionType",q.target.value)},_("option",{value:"pgdata_backup"},"PGDATA 备份到百度网盘"),_("option",{value:"dispatch"},"Provider Dispatch"))),i.actionType==="pgdata_backup"?[_("label",{key:"remote"},"网盘根目录",_("input",{value:i.remoteBaseDir,onChange:(q)=>N("remoteBaseDir",q.target.value)})),_("label",{key:"staging"},"本地 staging 子目录",_("input",{value:i.stagingSubdir,onChange:(q)=>N("stagingSubdir",q.target.value)}))]:[_("label",{key:"provider"},"Provider",_("select",{value:i.providerId,onChange:(q)=>N("providerId",q.target.value)},(r||[]).map((q)=>_("option",{key:q.providerId,value:q.providerId},`${q.name} / ${q.providerId}`)))),_("label",{key:"command"},"Command",_("select",{value:i.command,onChange:(q)=>N("command",q.target.value)},_("option",{value:"echo"},"echo"),_("option",{value:"docker.ps"},"docker.ps"),_("option",{value:"host.ssh"},"host.ssh"),_("option",{value:"microservice.http"},"microservice.http"))),_("label",{key:"payload",className:"raw-editor-label"},"Payload JSON",_("textarea",{className:"raw-editor",value:i.payloadJson,onChange:(q)=>N("payloadJson",q.target.value)}))],_("label",null,"超时 ms",_("input",{value:i.timeoutMs,onChange:(q)=>N("timeoutMs",q.target.value)})),_("label",{className:"raw-editor-label"},"描述",_("textarea",{className:"raw-editor compact",value:i.description,onChange:(q)=>N("description",q.target.value)})),_("div",{className:"dispatch-actions"},_("button",{type:"button",className:"ghost-btn",disabled:y,onClick:()=>t(cG(r||[]))},"重置"),_("button",{type:"submit",disabled:y||!i.id},y?"保存中":"保存任务")),j?_("p",{className:"muted paragraph"},j):null,_(lu,{error:$,wide:!0}))),_(uu,{title:"历史执行记录",eyebrow:`${U.length} Runs`},U.length===0?_(Qu,{title:"暂无执行记录",text:"定时触发或手动触发后会生成 run history"}):_("div",{className:"table-wrap"},_("table",{className:"task-history-table schedule-run-table"},_("thead",null,_("tr",null,_("th",null,"状态"),_("th",null,"任务"),_("th",null,"触发"),_("th",null,"耗时"),_("th",null,"结果摘要"),_("th",null,"更新时间"),_("th",null,"操作"))),_("tbody",null,U.map((q)=>_("tr",{key:q.id,"data-testid":`schedule-run-row-${uf(q.id)}`},_("td",null,_(Tu,{status:WP(q.status)},q.status)),_("td",null,_("strong",null,q.scheduleId),_("code",null,q.id),q.taskId?_("code",null,q.taskId):null),_("td",null,q.trigger||"--"),_("td",null,LP(q)),_("td",null,_(t0,{data:q.result||q.error,empty:"无结果"})),_("td",null,Wl(q.updatedAt)),_("td",null,_(du,{title:`Schedule Run ${q.id}`,data:q,onOpen:n})))))))))}function TP({data:l}){let u=l.overview||{};return _("div",{className:"page-grid topology-grid"},_(uu,{title:"公开入口",eyebrow:"Public"},_("div",{className:"endpoint-list"},_("article",null,_("b",null,"Frontend"),_("span",null,sl.frontendPublicUrl||window.location.origin),_(Tu,{status:"online"},"public")),_("article",null,_("b",null,"Provider Ingress"),_("span",null,sl.providerIngressPublicUrl||"ws://public/ws/provider"),_(Tu,{status:"online"},"public")))),_(uu,{title:"内部服务",eyebrow:"Docker Network Only"},_("div",{className:"endpoint-list"},_("article",null,_("b",null,"backend-core API"),_("span",null,"http://backend-core:8080"),_(Tu,{status:"internal"},"internal")),_("article",null,_("b",null,"database"),_("span",null,"postgres://database:5432/unidesk"),_(Tu,{status:"internal"},"internal")))),_(uu,{title:"运行态",eyebrow:"Runtime"},_("div",{className:"metric-grid"},_(Nu,{label:"DB Ready",value:u.dbReady?"YES":"NO",hint:"internal health"}),_(Nu,{label:"Online Nodes",value:u.onlineNodeCount??0,hint:"provider-gateway self-link"}))))}function mP({session:l}){return _(uu,{title:"认证策略",eyebrow:"Frontend Login"},_("div",{className:"policy-grid"},_("article",null,_("span",null,"默认账号"),_("strong",null,sl.authUsername||"admin")),_("article",null,_("span",null,"当前会话"),_("strong",null,l?.user?.username||"--")),_("article",null,_("span",null,"Session TTL"),_("strong",null,`${sl.sessionTtlSeconds||0}s`)),_("article",null,_("span",null,"API 访问"),_("strong",null,"同源 Cookie 保护"))),_("p",{className:"muted paragraph"},"浏览器只访问 frontend 同源接口;frontend 容器使用 Docker 内网代理 backend-core API。"))}function KP(){return _(uu,{title:"安全边界",eyebrow:"Exposure Rule"},_("div",{className:"security-board"},_("article",{className:"allow"},_("b",null,"允许公网"),_("span",null,"frontend 登录入口"),_("span",null,"provider ingress WebSocket/health")),_("article",{className:"deny"},_("b",null,"禁止公网"),_("span",null,"backend-core REST API"),_("span",null,"PostgreSQL database")),_("article",null,_("b",null,"数据库卷"),_("span",null,"named volume unidesk_pgdata_10gb"),_("span",null,"CLI stop/start 不删除数据卷"))))}function zP({activeModule:l,activeTab:u,data:r,session:f,refresh:n,onRaw:i,onNavigate:t}){if(l==="ops"&&u==="status")return _(xY,{data:r,onRaw:i,onNavigate:t});if(l==="ops"&&u==="performance")return _(nP,{onRaw:i});if(l==="ops"&&u==="events")return _(vY,{events:r.events,onRaw:i});if(l==="ops"&&u==="logs")return _(sY,{logs:r.logs,onRaw:i});if(l==="nodes"&&u==="list")return _(kY,{nodes:r.nodes,onRaw:i});if(l==="nodes"&&u==="monitor")return _(aY,{nodes:r.nodes,systemStatuses:r.systemStatuses,tasks:r.tasks,onRaw:i,refresh:n});if(l==="nodes"&&u==="docker")return _($P,{nodes:r.nodes,dockerStatuses:r.dockerStatuses,onRaw:i});if(l==="nodes"&&u==="gateway")return _(yP,{nodes:r.nodes,tasks:r.tasks,onRaw:i});if(l==="nodes"&&u==="labels")return _(gY,{nodes:r.nodes});if(l==="nodes"&&u==="heartbeats")return _(IY,{nodes:r.nodes});if(l==="tasks"&&u==="dispatch")return _(FP,{nodes:r.nodes,onDispatched:n,onRaw:i});if(l==="tasks"&&u==="scheduled")return _(GP,{schedules:r.schedules,scheduleRuns:r.scheduleRuns,nodes:r.nodes,refresh:n,onRaw:i});if(l==="tasks"&&u==="pending")return _(UP,{tasks:r.pendingTasks,onRaw:i});if(l==="tasks"&&u==="history")return _(NP,{tasks:r.tasks,onRaw:i});if(l==="tasks"&&u==="results")return _(QP,{tasks:r.tasks,onRaw:i});if(l==="apps"&&u==="catalog")return _(jP,{microservices:r.microservices,onRaw:i,onNavigate:t});if(l==="apps"&&u==="todo-note")return _(xL,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="findjob")return _(BQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="pipeline")return _(SL,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="met-nonlinear")return _(YQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="claudeqq")return _(fN,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="baidu-netdisk")return _(lN,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="filebrowser")return _(HQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="oa-event-flow")return _(gQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="k3sctl")return _(IL,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl,onNavigate:t});if(l==="apps"&&u==="code-queue")return _(GQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl,initialTasksData:mY});if(l==="apps"&&u==="mdtodo")return _(hQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="decision-center")return _(KQ,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="apps"&&u==="project-manager")return _(PL,{microservices:r.microservices,onRaw:i,apiBaseUrl:sl.apiBaseUrl});if(l==="config"&&u==="topology")return _(TP,{data:r});if(l==="config"&&u==="auth")return _(mP,{session:f});if(l==="config"&&u==="security")return _(KP);return _(Qu,{title:"未找到页面",text:"请选择左侧主模块和顶部子功能标签"})}function EP({session:l,onLogout:u}){let r=k2(Xf,window.location.pathname),[f,n]=kl(r.moduleId),[i,t]=kl({...Nc,[r.moduleId]:r.tabId}),[y,c]=kl({overview:null,nodes:[],systemStatuses:[],dockerStatuses:[],microservices:[],events:[],tasks:[],pendingTasks:[],schedules:[],scheduleRuns:[],logs:[]}),[$,A]=kl({ok:!1,text:"连接中"}),[j,F]=kl(null),[U,N]=kl(new Date),[W,L]=kl(null),[J,w]=kl(!1),[Q,q]=kl(!1),T=i0.default.useRef(!1),O=Xf.moduleById[f]||Xf.modules[0],Z=i[f]||Nc[f]||O.tabs[0].id,E=Array.isArray(y.microservices)?y.microservices:[],D=E.length===0&&f==="apps"&&Z==="code-queue"?[KY]:E,Y=D===E?y:{...y,microservices:D},p=f==="apps"?D.find((I)=>String(I?.id||"")===(Z==="k3sctl"?"k3sctl-adapter":Z)):null,V=p?GG(p):{},B=O.tabs.find((I)=>I.id===Z)?.label||Z,m=p?[{key:"microservice",label:"用户服务",value:`${B} ${V.providerStatus==="online"?"在线":V.providerStatus||"未知"}`,tone:V.providerStatus==="online"?"ok":"warn",testId:"active-microservice-status"}]:[];async function X(){if(T.current)return;T.current=!0,q(!0);try{let I=[],M=(Ql,Ol)=>{I.push([Ql,ml(Ol)])},rl=f==="ops"&&Z==="status",cl=rl||f==="config"&&Z==="topology",$l=rl||f==="nodes"||f==="tasks"&&(Z==="dispatch"||Z==="scheduled"),Tl=f==="apps"&&Z!=="code-queue";if(cl)M("overview",`${sl.apiBaseUrl}/overview`);if($l)M("nodes",`${sl.apiBaseUrl}/nodes`);if(f==="nodes"&&Z==="monitor")M("systemStatuses",`${sl.apiBaseUrl}/nodes/system-status?limit=60`),M("tasks",`${sl.apiBaseUrl}/tasks?limit=120&summary=1`);else if(f==="nodes"&&Z==="docker")M("dockerStatuses",`${sl.apiBaseUrl}/nodes/docker-status`);else if(f==="nodes"&&Z==="gateway")M("tasks",`${sl.apiBaseUrl}/tasks?limit=300&summary=1`);else if(f==="tasks"&&Z==="scheduled")M("schedules",`${sl.apiBaseUrl}/schedules?limit=100`),M("scheduleRuns",`${sl.apiBaseUrl}/schedules/runs?limit=100`);else if(f==="tasks"&&Z==="pending")M("pendingTasks",`${sl.apiBaseUrl}/tasks?status=pending&limit=100&summary=1`);else if(f==="tasks"&&(Z==="history"||Z==="results"))M("tasks",`${sl.apiBaseUrl}/tasks?limit=300&summary=1`);else if(rl)M("tasks",`${sl.apiBaseUrl}/tasks?limit=8&lite=1`),M("pendingTasks",`${sl.apiBaseUrl}/tasks?status=pending&limit=20&lite=1`);if(Tl)M("microservices",`${sl.apiBaseUrl}/microservices`);if(f==="ops"&&Z==="events")M("events",`${sl.apiBaseUrl}/events?limit=100`);if(f==="ops"&&Z==="logs")M("logs","/logs?limit=100");await Promise.all(I.map(async([Ql,Ol])=>{let h=await Ol,a={};if(Ql==="overview")a.overview=h;if(Ql==="nodes")a.nodes=h.nodes||[];if(Ql==="systemStatuses")a.systemStatuses=h.systemStatuses||[];if(Ql==="dockerStatuses")a.dockerStatuses=h.dockerStatuses||[];if(Ql==="microservices")a.microservices=h.microservices||[];if(Ql==="events")a.events=h.events||[];if(Ql==="tasks")a.tasks=h.tasks||[];if(Ql==="pendingTasks")a.pendingTasks=h.tasks||[];if(Ql==="schedules")a.schedules=h.schedules||[];if(Ql==="scheduleRuns")a.scheduleRuns=h.runs||[];if(Ql==="logs")a.logs=h.logs||[];c((ul)=>({...ul,...a}))})),A({ok:!0,text:"核心在线"}),F(new Date)}catch(I){if(A({ok:!1,text:El(I,"连接失败")}),I.status===401)u(!1)}finally{T.current=!1,q(!1)}}En(()=>{let I=()=>{if(!eL())return;X()};I();let M=setInterval(I,EY(f,Z)),rl=()=>{if(eL())I()};return document.addEventListener("visibilitychange",rl),()=>{clearInterval(M),document.removeEventListener("visibilitychange",rl)}},[f,Z]),En(()=>{let I=setInterval(()=>N(new Date),1000);return()=>clearInterval(I)},[]),En(()=>{let I=vQ(Xf,window.location.pathname);if(I&&window.location.pathname!==I)window.history.replaceState(null,"",I)},[]),En(()=>{let I=()=>{let M=k2(Xf,window.location.pathname);n(M.moduleId),t((rl)=>({...rl,[M.moduleId]:M.tabId})),L(null)};return window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)},[]),En(()=>{window.scrollTo({top:0,left:0,behavior:"auto"})},[f,Z]);function S(I,M,rl="push"){let cl=Xf.moduleById[I]?I:Xf.fallbackTarget.moduleId,$l=Xf.moduleById[cl]?.tabs.some((Ql)=>Ql.id===M)?M:Nc[cl]||Xf.moduleById[cl]?.tabs[0]?.id||Xf.fallbackTarget.tabId;n(cl),t((Ql)=>({...Ql,[cl]:$l}));let Tl=H3(Xf,cl,$l);if(window.location.pathname!==Tl){let Ql=rl==="replace"?"replaceState":"pushState";window.history[Ql](null,"",Tl)}}function b(I,M){L({title:I,data:M})}let[z,P]=kl(!1),{unreadCount:s,notifications:k}=Xr(),v=k.length>0?k[k.length-1]:null,tl=AG(dL);return _("div",{className:`shell ${J?"rail-collapsed":""} ${tl?"dev-shell":""}`,"data-testid":"app-shell"},_(hY,{activeModule:f,activeTabs:i,onNavigate:S,collapsed:J,onToggle:()=>w((I)=>!I)}),_("main",{className:"workspace"},_(CY,{connection:$,lastRefresh:j,onRefresh:X,onLogout:()=>u(!0),session:l,clock:U,activeStatusItems:m,onNotificationToggle:()=>P((I)=>!I),unreadCount:s,environment:dL}),_(RY,{module:O,activeTab:Z,onNavigate:S}),_(Cj.Provider,{value:Q},_(zP,{activeModule:f,activeTab:Z,data:Y,session:l,refresh:X,onRaw:b,onNavigate:S}))),_(YY,{raw:W,onClose:()=>L(null)}),v&&_(oL,{key:v.id,notification:v}),z&&_(aL,{onClose:()=>P(!1)}))}function OP(){let[l,u]=kl(!0),[r,f]=kl(null);async function n(){u(!0);try{let t=await ml("/api/session");f(t.authenticated?t:null)}catch{f(null)}finally{u(!1)}}async function i(t){if(t)try{await ml("/logout",{method:"POST"})}catch{}f(null)}if(En(()=>{n()},[]),l)return _("main",{className:"loading-screen"},_("div",{className:"brand-mark"},"UD"),_("span",null,"加载会话"));if(!r)return _(PY,{onLogin:f});return _(eU,null,_(EP,{session:r,onLogout:i}))}var ZG=document.getElementById("root");if(ZG===null)throw Error("root element not found");_G.createRoot(ZG).render(_(OP));})(); diff --git a/src/components/frontend/public/style.css b/src/components/frontend/public/style.css index d0b572a4..443d31b0 100644 --- a/src/components/frontend/public/style.css +++ b/src/components/frontend/public/style.css @@ -6672,6 +6672,80 @@ input:focus, select:focus, textarea:focus { border-color: var(--accent-2); } gap: 10px; align-items: start; } +.decision-tabs { + display: flex; + flex-wrap: wrap; + gap: 8px; + align-items: center; +} +.decision-tabs button { + min-height: 34px; + padding: 0 12px; + border: 1px solid var(--line-soft); + color: var(--muted); + background: var(--panel-3); + cursor: pointer; +} +.decision-tabs button.active, +.decision-tabs button:hover { + border-color: rgba(78, 183, 168, 0.5); + color: var(--text); + background: rgba(78, 183, 168, 0.12); +} +.diary-layout { + display: grid; + grid-template-columns: minmax(320px, 0.42fr) minmax(0, 1fr); + gap: 10px; + align-items: start; +} +.diary-entry-list { + display: grid; + gap: 8px; + max-height: calc(100vh - 250px); + overflow: auto; + padding-right: 2px; +} +.diary-entry-card { + display: grid; + gap: 8px; + min-width: 0; + padding: 9px; + border: 1px solid var(--line-soft); + background: rgba(0,0,0,0.14); +} +.diary-entry-card.selected { + border-color: rgba(78, 183, 168, 0.55); + background: rgba(78, 183, 168, 0.09); +} +.diary-entry-main { + display: grid; + gap: 4px; + width: 100%; + padding: 0; + border: 0; + color: inherit; + background: transparent; + text-align: left; + cursor: pointer; +} +.diary-date { + color: var(--accent-2); + font-size: 11px; + letter-spacing: 0.12em; + text-transform: uppercase; +} +.diary-entry-main strong { + min-width: 0; + overflow-wrap: anywhere; + font-size: 14px; +} +.diary-entry-main span:last-child { + color: var(--muted); + line-height: 1.45; +} +.diary-markdown { + max-height: calc(100vh - 250px); +} .decision-card-list { display: grid; gap: 8px; @@ -6761,7 +6835,12 @@ input:focus, select:focus, textarea:focus { border-color: var(--accent-2); } .mdtodo-layout, .decision-hero, .decision-filter-bar, - .decision-default-grid { + .decision-default-grid, + .diary-layout { grid-template-columns: 1fr; } + .diary-entry-list, + .diary-markdown { + max-height: none; + } } diff --git a/src/components/frontend/src/decision-center.tsx b/src/components/frontend/src/decision-center.tsx index 4e1ba735..a09c0f7f 100644 --- a/src/components/frontend/src/decision-center.tsx +++ b/src/components/frontend/src/decision-center.tsx @@ -164,10 +164,37 @@ function filteredQuery(filters: AnyRecord): string { return params.toString(); } +function diaryQuery(filters: AnyRecord): string { + const params = new URLSearchParams(); + if (filters.month !== "all") params.set("month", filters.month); + if (filters.from.trim()) params.set("from", filters.from.trim()); + if (filters.to.trim()) params.set("to", filters.to.trim()); + params.set("limit", "180"); + return params.toString(); +} + +function DiaryEntryCard({ entry, selected, onSelect, onRaw }: AnyRecord) { + return h("article", { className: `diary-entry-card ${selected ? "selected" : ""}`, "data-testid": `diary-entry-${String(entry.date || entry.id || "").replace(/[^A-Za-z0-9_-]+/g, "-")}` }, + h("button", { type: "button", className: "diary-entry-main", onClick: () => onSelect(entry) }, + h("span", { className: "diary-date" }, entry.date || "--"), + h("strong", null, entry.title || entry.markdownPath || "--"), + h("span", null, shortText(entry.summary || entry.body, 180)), + ), + h("div", { className: "decision-record-foot" }, + h("code", null, entry.markdownPath || "--"), + h("span", null, fmtRecordTime(entry.updatedAt || entry.importedAt)), + h(RawButton, { title: `Diary ${entry.date || entry.id}`, data: entry, onOpen: onRaw }), + ), + ); +} + export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" }: AnyRecord) { const service = microservices.find((item: any) => item.id === "decision-center") || null; const [state, setState] = useState({ loading: false, error: "", health: null, records: [], refreshedAt: null }); const [filters, setFilters] = useState({ type: "all", status: "all", level: "all", linkedGoalId: "" }); + const [activeView, setActiveView] = useState("records"); + const [diaryState, setDiaryState] = useState({ loading: false, error: "", entries: [], months: [], selected: null, refreshedAt: null }); + const [diaryFilters, setDiaryFilters] = useState({ month: "all", from: "", to: "" }); async function load(): Promise<void> { if (!service) return; @@ -175,6 +202,7 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } try { const query = filteredQuery(filters); const records = await requestJson(decisionApi(apiBaseUrl, `/api/records?${query}`)); + const months = await requestJson(decisionApi(apiBaseUrl, "/api/diary/months")); let health: any = state.health; let healthError = ""; try { @@ -183,11 +211,42 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } healthError = errorMessage(err, "Decision Center health 检查失败"); } setState({ loading: false, error: healthError, health, records: Array.isArray(records.records) ? records.records : [], refreshedAt: new Date() }); + setDiaryState((prev: any) => ({ ...prev, months: Array.isArray(months.months) ? months.months : [] })); } catch (err) { setState((prev: any) => ({ ...prev, loading: false, error: errorMessage(err, "Decision Center 加载失败") })); } } + async function loadDiary(): Promise<void> { + if (!service) return; + setDiaryState((prev: any) => ({ ...prev, loading: true, error: "" })); + try { + const entriesResponse = await requestJson(decisionApi(apiBaseUrl, `/api/diary/entries?${diaryQuery(diaryFilters)}`)); + const monthsResponse = await requestJson(decisionApi(apiBaseUrl, "/api/diary/months")); + const entries = Array.isArray(entriesResponse.entries) ? entriesResponse.entries : []; + setDiaryState((prev: any) => ({ + loading: false, + error: "", + entries, + months: Array.isArray(monthsResponse.months) ? monthsResponse.months : prev.months, + selected: prev.selected && entries.some((entry: any) => entry.id === prev.selected?.id) ? prev.selected : entries[0] || null, + refreshedAt: new Date(), + })); + } catch (err) { + setDiaryState((prev: any) => ({ ...prev, loading: false, error: errorMessage(err, "日记加载失败") })); + } + } + + async function selectDiaryEntry(entry: any): Promise<void> { + setDiaryState((prev: any) => ({ ...prev, selected: entry })); + try { + const response = await requestJson(decisionApi(apiBaseUrl, `/api/diary/entries/${encodeURIComponent(entry.date || entry.id)}`)); + setDiaryState((prev: any) => ({ ...prev, selected: response.entry || entry })); + } catch (err) { + setDiaryState((prev: any) => ({ ...prev, error: errorMessage(err, "日记正文加载失败") })); + } + } + useEffect(() => { load(); }, [service?.id, service?.runtime?.providerStatus]); @@ -197,6 +256,12 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } return () => clearTimeout(timer); }, [filters.type, filters.status, filters.level, filters.linkedGoalId]); + useEffect(() => { + if (activeView !== "diary") return; + const timer = setTimeout(() => void loadDiary(), 120); + return () => clearTimeout(timer); + }, [activeView, diaryFilters.month, diaryFilters.from, diaryFilters.to, service?.id, service?.runtime?.providerStatus]); + if (!service) return h(EmptyState, { title: "Decision Center 未登记", text: "请在 config.json 的 microservices 中登记用户服务 id=decision-center" }); const runtime = microserviceRuntime(service); @@ -207,6 +272,10 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } const blockers = records.filter((record: any) => record.type === "blocker" && ["P0", "P1"].includes(record.level) && record.status !== "done").slice(0, 8); const parked = records.filter((record: any) => record.status === "parked").slice(0, 8); const recentMeetings = records.filter((record: any) => record.type === "meeting" || record.type === "decision").slice(0, 12); + const diaryEntries = Array.isArray(diaryState.entries) ? diaryState.entries : []; + const diaryMonths = Array.isArray(diaryState.months) ? diaryState.months : []; + const selectedDiary = diaryState.selected; + const diaryCount = Number(state.health?.diaryEntryCount ?? 0); return h("div", { className: "decision-center-page", "data-testid": "decision-center-page" }, h(Panel, { title: "Decision Center", eyebrow: "Authority Records", loading: state.loading, actions: h("div", { className: "inline-actions" }, @@ -216,9 +285,9 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } h("div", { className: "decision-hero" }, h("div", { className: "metric-grid" }, h(MetricCard, { label: "记录数", value: records.length, hint: `PostgreSQL / ${state.health?.storage || "postgres"}`, tone: "ok" }), + h(MetricCard, { label: "日记", value: diaryCount, hint: "按月 Markdown", tone: diaryCount > 0 ? "ok" : "warn" }), h(MetricCard, { label: "G0/G1 目标", value: goals.length, hint: "active authority goals", tone: "ok" }), h(MetricCard, { label: "P0/P1 Blocker", value: blockers.length, hint: "requires decision", tone: blockers.length > 0 ? "warn" : "ok" }), - h(MetricCard, { label: "Parked", value: parked.length, hint: "停放事项", tone: parked.length > 0 ? "warn" : "ok" }), ), h("div", { className: "microservice-ref-card" }, h("span", null, "Runtime"), @@ -229,6 +298,39 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } ), h(UniDeskErrorBanner, { error: state.error, title: "Decision Center 请求失败" }), ), + h("div", { className: "decision-tabs", role: "tablist" }, + h("button", { type: "button", className: activeView === "records" ? "active" : "", onClick: () => setActiveView("records") }, "权威记录"), + h("button", { type: "button", className: activeView === "diary" ? "active" : "", onClick: () => setActiveView("diary") }, "工作日记"), + ), + activeView === "diary" ? h(React.Fragment, null, + h(Panel, { title: "日记筛选", eyebrow: "Markdown by Month", loading: diaryState.loading, actions: h("div", { className: "inline-actions" }, + h("button", { type: "button", className: "ghost-btn", onClick: () => void loadDiary(), disabled: diaryState.loading }, diaryState.loading ? "刷新中" : "刷新"), + h(RawButton, { title: "Diary Months", data: diaryMonths, onOpen: onRaw, testId: "raw-decision-center-diary-months" }), + ) }, + h("div", { className: "decision-filter-bar" }, + h("label", null, "月份", h("select", { value: diaryFilters.month, onChange: (event: any) => setDiaryFilters((prev: any) => ({ ...prev, month: event.target.value })) }, + h("option", { value: "all" }, "all"), + diaryMonths.map((month: any) => h("option", { key: month.month, value: month.month }, `${month.month} (${month.count})`)), + )), + h("label", null, "开始日期", h("input", { type: "date", value: diaryFilters.from, onChange: (event: any) => setDiaryFilters((prev: any) => ({ ...prev, from: event.target.value })) })), + h("label", null, "结束日期", h("input", { type: "date", value: diaryFilters.to, onChange: (event: any) => setDiaryFilters((prev: any) => ({ ...prev, to: event.target.value })) })), + h("label", null, "存储", h("input", { value: "PostgreSQL / YYYY-MM/YYYY-MM-DD.md", readOnly: true })), + ), + h(UniDeskErrorBanner, { error: diaryState.error, title: "日记请求失败" }), + ), + h("div", { className: "diary-layout" }, + h(Panel, { title: "按天条目", eyebrow: `${diaryEntries.length} Entries`, loading: diaryState.loading }, + diaryEntries.length === 0 + ? h(EmptyState, { title: "暂无日记", text: "使用 CLI 导入按日期标题拆分的工作日志 Markdown。" }) + : h("div", { className: "diary-entry-list" }, diaryEntries.map((entry: any) => h(DiaryEntryCard, { key: entry.id, entry, selected: selectedDiary?.id === entry.id, onSelect: selectDiaryEntry, onRaw }))), + ), + h(Panel, { title: selectedDiary?.title || "日记正文", eyebrow: selectedDiary?.markdownPath || "Daily Markdown", actions: selectedDiary ? h(RawButton, { title: `Diary ${selectedDiary.date}`, data: selectedDiary, onOpen: onRaw, testId: "raw-decision-center-diary-selected" }) : null }, + selectedDiary + ? h(MarkdownBody, { markdown: selectedDiary.body || selectedDiary.summary || "", className: "decision-markdown diary-markdown" }) + : h(EmptyState, { title: "未选择日记", text: "从左侧选择一天查看 Markdown 正文。" }), + ), + ), + ) : h(React.Fragment, null, h(Panel, { title: "筛选", eyebrow: "Type / Status / Level" }, h("div", { className: "decision-filter-bar", "data-testid": "decision-center-filters" }, h("label", null, "类型", h("select", { value: filters.type, onChange: (event: any) => setFilters((prev: any) => ({ ...prev, type: event.target.value })) }, selectOptions(recordTypes))), @@ -258,5 +360,6 @@ export function DecisionCenterPage({ microservices, onRaw, apiBaseUrl = "/api" } h(Panel, { title: "全部记录", eyebrow: `${records.length} Records`, actions: state.refreshedAt ? h("span", { className: "muted" }, `刷新 ${fmtClock(state.refreshedAt)}`) : null }, h(RecordTable, { records, onRaw }), ), + ), ); } diff --git a/src/components/microservices/decision-center/src/index.ts b/src/components/microservices/decision-center/src/index.ts index 22f3b4c5..3b42aca4 100644 --- a/src/components/microservices/decision-center/src/index.ts +++ b/src/components/microservices/decision-center/src/index.ts @@ -1,4 +1,4 @@ -import { randomUUID } from "node:crypto"; +import { createHash, randomUUID } from "node:crypto"; import postgres from "postgres"; import { createHourlyJsonlWriter, logRetentionBytesForService } from "../../../shared/src/rotating-jsonl"; @@ -52,6 +52,50 @@ interface DecisionRecord extends JsonRecord { updatedAt: string; } +interface DiaryEntryRow { + id: string; + entry_date: Date | string; + month: string; + title: string; + body: string; + source_file: string; + markdown_path: string; + tags: JsonValue; + content_hash: string; + created_at: Date | string; + updated_at: Date | string; + imported_at: Date | string; +} + +interface DiaryEntry extends JsonRecord { + id: string; + date: string; + month: string; + title: string; + summary: string; + body: string; + sourceFile: string; + markdownPath: string; + tags: string[]; + contentHash: string; + createdAt: string; + updatedAt: string; + importedAt: string; +} + +interface DiaryDraft { + date: string; + month: string; + title: string; + body: string; + markdownPath: string; +} + +interface DiaryUpsertRow extends DiaryEntryRow { + inserted: boolean; + changed: boolean; +} + class HttpError extends Error { readonly status: number; readonly detail: JsonRecord; @@ -271,7 +315,7 @@ function titleFromMarkdown(markdown: string, fallback: string): string { async function readJsonBody(req: Request): Promise<Record<string, unknown>> { const text = await req.text(); - if (text.length > 1_000_000) throw new HttpError(413, "request body is too large", { maxBytes: 1_000_000 }); + if (text.length > 5_000_000) throw new HttpError(413, "request body is too large", { maxBytes: 5_000_000 }); if (!text.trim()) return {}; try { const parsed = JSON.parse(text) as unknown; @@ -310,6 +354,27 @@ async function ensureSchema(): Promise<void> { await sql`CREATE INDEX IF NOT EXISTS idx_decision_center_records_type_status_level ON decision_center_records(type, status, level)`; await sql`CREATE INDEX IF NOT EXISTS idx_decision_center_records_linked_goal ON decision_center_records(linked_goal_id)`; await sql`CREATE INDEX IF NOT EXISTS idx_decision_center_records_updated ON decision_center_records(updated_at DESC)`; + await sql` + CREATE TABLE IF NOT EXISTS decision_center_diary_entries ( + id TEXT PRIMARY KEY, + entry_date DATE NOT NULL, + month TEXT NOT NULL, + title TEXT NOT NULL, + body TEXT NOT NULL DEFAULT '', + source_file TEXT NOT NULL DEFAULT '', + markdown_path TEXT NOT NULL, + tags JSONB NOT NULL DEFAULT '[]'::jsonb, + content_hash TEXT NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT now(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), + imported_at TIMESTAMPTZ NOT NULL DEFAULT now(), + CONSTRAINT decision_center_diary_entries_month_check CHECK (month ~ '^[0-9]{4}-[0-9]{2}$'), + CONSTRAINT decision_center_diary_entries_path_check CHECK (markdown_path ~ '^[0-9]{4}-[0-9]{2}/[0-9]{4}-[0-9]{2}-[0-9]{2}[.]md$'), + CONSTRAINT decision_center_diary_entries_source_date_unique UNIQUE (source_file, entry_date) + ) + `; + await sql`CREATE INDEX IF NOT EXISTS idx_decision_center_diary_entries_month_date ON decision_center_diary_entries(month DESC, entry_date DESC)`; + await sql`CREATE INDEX IF NOT EXISTS idx_decision_center_diary_entries_updated ON decision_center_diary_entries(updated_at DESC)`; }, { retryRead: true }); } @@ -335,11 +400,16 @@ async function refreshDatabaseHealth(): Promise<void> { if (databaseHealthRefreshInFlight) return; databaseHealthRefreshInFlight = true; try { - const rows = await withDatabaseRecovery("refresh_database_health", () => sql<{ count: string | number }[]>`SELECT count(*) AS count FROM decision_center_records`, { retryRead: true }); + const rows = await withDatabaseRecovery("refresh_database_health", () => sql<{ record_count: string | number; diary_entry_count: string | number }[]>` + SELECT + (SELECT count(*) FROM decision_center_records) AS record_count, + (SELECT count(*) FROM decision_center_diary_entries) AS diary_entry_count + `, { retryRead: true }); const checkedAt = new Date().toISOString(); databaseHealth = { ok: true, - recordCount: Number(rows[0]?.count ?? 0), + recordCount: Number(rows[0]?.record_count ?? 0), + diaryEntryCount: Number(rows[0]?.diary_entry_count ?? 0), checkedAt, lastOkAt: checkedAt, degraded: false, @@ -353,6 +423,7 @@ async function refreshDatabaseHealth(): Promise<void> { databaseHealth = { ok: withinGrace, recordCount: Number(databaseHealth.recordCount ?? 0), + diaryEntryCount: Number(databaseHealth.diaryEntryCount ?? 0), checkedAt, lastOkAt, degraded: withinGrace, @@ -382,6 +453,7 @@ function health(): JsonRecord { storage: "postgres", schemaReady, recordCount: Number(databaseHealth.recordCount ?? 0), + diaryEntryCount: Number(databaseHealth.diaryEntryCount ?? 0), database: databaseHealth, deploy: deployInfo(), }; @@ -528,6 +600,258 @@ async function deleteRecord(id: string): Promise<JsonRecord> { return { ok: true, deleted: recordFromRow(rows[0]!) }; } +function dateOnly(value: Date | string | null | undefined): string { + if (value === null || value === undefined) return ""; + if (typeof value === "string") { + const match = value.match(/^(\d{4}-\d{2}-\d{2})/u); + if (match !== null) return match[1] ?? ""; + } + return iso(value).slice(0, 10); +} + +function pad2(value: number): string { + return String(value).padStart(2, "0"); +} + +function normalizedDate(year: number, month: number, day: number): string | null { + if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) return null; + if (year < 1970 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31) return null; + const date = new Date(Date.UTC(year, month - 1, day)); + if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) return null; + return `${year}-${pad2(month)}-${pad2(day)}`; +} + +function parseDiaryHeadingDate(line: string): string | null { + const trimmed = line.trim(); + if (!trimmed) return null; + const heading = trimmed.match(/^#{1,6}\s+(.+)$/u); + const candidate = heading === null ? trimmed : heading[1]?.trim() ?? ""; + if (heading === null && !/^\d{4}/u.test(candidate)) return null; + const match = candidate.match(/^(\d{4})\s*(?:年|[-/.])\s*(\d{1,2})\s*(?:月|[-/.])\s*(\d{1,2})\s*(?:日)?(?:\s*(?:[((].*[))]|星期[一二三四五六日天]|周[一二三四五六日天]|[-–—::].*))?$/u); + if (match === null) return null; + return normalizedDate(Number(match[1]), Number(match[2]), Number(match[3])); +} + +function contentHash(value: string): string { + return createHash("sha256").update(value).digest("hex"); +} + +function diaryEntryFromRow(row: DiaryEntryRow, options: { includeBody?: boolean } = {}): DiaryEntry { + const includeBody = options.includeBody !== false; + const body = row.body || ""; + return { + id: row.id, + date: dateOnly(row.entry_date), + month: row.month, + title: row.title, + summary: summaryFromBody(body), + body: includeBody ? body : "", + sourceFile: row.source_file, + markdownPath: row.markdown_path, + tags: Array.isArray(row.tags) ? row.tags.map(String) : [], + contentHash: row.content_hash, + createdAt: iso(row.created_at), + updatedAt: iso(row.updated_at), + importedAt: iso(row.imported_at), + }; +} + +function splitDiaryMarkdown(markdown: string): DiaryDraft[] { + const normalized = markdown.replace(/\r\n?/gu, "\n"); + const lines = normalized.split("\n"); + const entries = new Map<string, DiaryDraft>(); + let currentDate = ""; + let currentLines: string[] = []; + + const flush = (): void => { + if (!currentDate) return; + const body = currentLines.join("\n").trim(); + if (!body) return; + const month = currentDate.slice(0, 7); + const existing = entries.get(currentDate); + const title = titleFromMarkdown(body, `${currentDate} 工作日志`); + const draft: DiaryDraft = { + date: currentDate, + month, + title, + body: existing === undefined ? body : `${existing.body}\n\n---\n\n${body}`, + markdownPath: `${month}/${currentDate}.md`, + }; + entries.set(currentDate, draft); + }; + + for (const line of lines) { + const date = parseDiaryHeadingDate(line); + if (date !== null) { + flush(); + currentDate = date; + currentLines = [line]; + continue; + } + if (currentDate) currentLines.push(line); + } + flush(); + + return [...entries.values()].sort((left, right) => left.date.localeCompare(right.date)); +} + +function validDateFilter(value: string, field: string): string { + if (!/^\d{4}-\d{2}-\d{2}$/u.test(value)) throw new HttpError(400, `${field} must use YYYY-MM-DD`, { value }); + const [year, month, day] = value.split("-").map(Number); + if (normalizedDate(year ?? 0, month ?? 0, day ?? 0) !== value) throw new HttpError(400, `${field} is not a valid date`, { value }); + return value; +} + +function validMonthFilter(value: string): string { + if (!/^\d{4}-\d{2}$/u.test(value)) throw new HttpError(400, "month must use YYYY-MM", { value }); + const [year, month] = value.split("-").map(Number); + if (normalizedDate(year ?? 0, month ?? 0, 1)?.slice(0, 7) !== value) throw new HttpError(400, "month is not valid", { value }); + return value; +} + +async function upsertDiaryEntry(draft: DiaryDraft, sourceFile: string, tags: string[]): Promise<{ entry: DiaryEntry; action: "created" | "updated" | "unchanged" }> { + if (draft.body.length > 300_000) throw new HttpError(400, "diary day body must be at most 300000 characters", { date: draft.date, length: draft.body.length }); + const hash = contentHash(draft.body); + const rows = await withDatabaseRecovery("upsert_diary_entry", () => sql<DiaryUpsertRow[]>` + WITH existing AS ( + SELECT content_hash + FROM decision_center_diary_entries + WHERE source_file = ${sourceFile} AND entry_date = ${draft.date}::date + ), + upsert AS ( + INSERT INTO decision_center_diary_entries ( + id, entry_date, month, title, body, source_file, markdown_path, tags, content_hash + ) VALUES ( + ${`diary_${randomUUID()}`}, + ${draft.date}::date, + ${draft.month}, + ${draft.title}, + ${draft.body}, + ${sourceFile}, + ${draft.markdownPath}, + ${sql.json(tags)}, + ${hash} + ) + ON CONFLICT (source_file, entry_date) DO UPDATE + SET + month = EXCLUDED.month, + title = EXCLUDED.title, + body = EXCLUDED.body, + markdown_path = EXCLUDED.markdown_path, + tags = EXCLUDED.tags, + content_hash = EXCLUDED.content_hash, + imported_at = now(), + updated_at = CASE + WHEN decision_center_diary_entries.content_hash IS DISTINCT FROM EXCLUDED.content_hash THEN now() + ELSE decision_center_diary_entries.updated_at + END + RETURNING * + ) + SELECT + upsert.*, + NOT EXISTS(SELECT 1 FROM existing) AS inserted, + EXISTS(SELECT 1 FROM existing WHERE existing.content_hash IS DISTINCT FROM upsert.content_hash) AS changed + FROM upsert + `); + const row = rows[0]; + if (row === undefined) throw new HttpError(500, "diary upsert returned no row", { date: draft.date }); + return { + entry: diaryEntryFromRow(row, { includeBody: false }), + action: row.inserted ? "created" : row.changed ? "updated" : "unchanged", + }; +} + +async function importDiary(input: Record<string, unknown>): Promise<JsonRecord> { + const markdown = asString(input.markdown ?? input.body); + if (!markdown) throw new HttpError(400, "markdown is required"); + if (markdown.length > 4_500_000) throw new HttpError(400, "markdown must be at most 4500000 characters"); + const sourceFile = asString(input.sourceFile ?? input.sourcePath ?? input.source) || "inline"; + const tags = asStringArray(input.tags, "tags"); + const drafts = splitDiaryMarkdown(markdown); + if (drafts.length === 0) { + throw new HttpError(400, "no dated diary sections found", { + expectedHeading: "# 2025年2月12日 or # 2025-02-12", + }); + } + const entries: DiaryEntry[] = []; + let createdCount = 0; + let updatedCount = 0; + let unchangedCount = 0; + for (const draft of drafts) { + const result = await upsertDiaryEntry(draft, sourceFile, tags); + entries.push(result.entry); + if (result.action === "created") createdCount += 1; + else if (result.action === "updated") updatedCount += 1; + else unchangedCount += 1; + } + log("info", "diary_imported", { sourceFile, days: drafts.length, createdCount, updatedCount, unchangedCount }); + return { + ok: true, + sourceFile, + totalDays: drafts.length, + createdCount, + updatedCount, + unchangedCount, + firstDate: entries[0]?.date ?? "", + lastDate: entries[entries.length - 1]?.date ?? "", + pathPattern: "YYYY-MM/YYYY-MM-DD.md", + entries, + }; +} + +async function listDiaryEntries(url: URL): Promise<DiaryEntry[]> { + const month = asString(url.searchParams.get("month")); + const from = asString(url.searchParams.get("from")); + const to = asString(url.searchParams.get("to")); + const sourceFile = asString(url.searchParams.get("sourceFile")); + const includeBody = url.searchParams.get("includeBody") === "true"; + const limit = Math.max(1, Math.min(1000, Number(url.searchParams.get("limit") || 240) || 240)); + if (month) validMonthFilter(month); + if (from) validDateFilter(from, "from"); + if (to) validDateFilter(to, "to"); + const rows = await withDatabaseRecovery("list_diary_entries", () => sql<DiaryEntryRow[]>` + SELECT * + FROM decision_center_diary_entries + WHERE (${month || null}::text IS NULL OR month = ${month || null}) + AND (${from || null}::date IS NULL OR entry_date >= ${from || null}::date) + AND (${to || null}::date IS NULL OR entry_date <= ${to || null}::date) + AND (${sourceFile || null}::text IS NULL OR source_file = ${sourceFile || null}) + ORDER BY entry_date DESC, updated_at DESC + LIMIT ${limit} + `, { retryRead: true }); + return rows.map((row) => diaryEntryFromRow(row, { includeBody })); +} + +async function listDiaryMonths(): Promise<JsonRecord[]> { + const rows = await withDatabaseRecovery("list_diary_months", () => sql<Array<{ month: string; count: string | number; first_date: Date | string; last_date: Date | string; updated_at: Date | string }>>` + SELECT month, count(*) AS count, min(entry_date) AS first_date, max(entry_date) AS last_date, max(updated_at) AS updated_at + FROM decision_center_diary_entries + GROUP BY month + ORDER BY month DESC + `, { retryRead: true }); + return rows.map((row) => ({ + month: row.month, + count: Number(row.count), + firstDate: dateOnly(row.first_date), + lastDate: dateOnly(row.last_date), + updatedAt: iso(row.updated_at), + })); +} + +async function getDiaryEntry(key: string): Promise<DiaryEntry> { + const date = /^\d{4}-\d{2}-\d{2}$/u.test(key) ? validDateFilter(key, "date") : ""; + const rows = await withDatabaseRecovery("get_diary_entry", () => sql<DiaryEntryRow[]>` + SELECT * + FROM decision_center_diary_entries + WHERE (${date || null}::date IS NOT NULL AND entry_date = ${date || null}::date) + OR (${date || null}::date IS NULL AND id = ${key}) + ORDER BY imported_at DESC + LIMIT 1 + `, { retryRead: true }); + if (rows.length === 0) throw new HttpError(404, "diary entry not found", { key }); + return diaryEntryFromRow(rows[0]!); +} + async function route(req: Request): Promise<Response> { const url = new URL(req.url); const method = req.method.toUpperCase(); @@ -542,6 +866,16 @@ async function route(req: Request): Promise<Response> { if (url.pathname === "/api/records" && method === "GET") return jsonResponse({ ok: true, records: await listRecords(url) }); if (url.pathname === "/api/records" && method === "POST") return jsonResponse({ ok: true, record: await createRecord(await readJsonBody(req)) }, 201); if (url.pathname === "/api/meetings/import" && method === "POST") return jsonResponse(await importMeeting(await readJsonBody(req)), 201); + if (url.pathname === "/api/diary/months" && method === "GET") return jsonResponse({ ok: true, months: await listDiaryMonths() }); + if (url.pathname === "/api/diary/entries" && method === "GET") return jsonResponse({ ok: true, entries: await listDiaryEntries(url) }); + if (url.pathname === "/api/diary/import" && method === "POST") return jsonResponse(await importDiary(await readJsonBody(req)), 201); + const diaryMatch = url.pathname.match(/^\/api\/diary\/entries\/([^/]+)$/u); + if (diaryMatch !== null) { + const key = decodeURIComponent(diaryMatch[1] ?? ""); + if (!key) throw new HttpError(400, "diary entry id or date is required"); + if (method === "GET") return jsonResponse({ ok: true, entry: await getDiaryEntry(key) }); + throw new HttpError(405, "diary entry route supports GET", { method }); + } const recordMatch = url.pathname.match(/^\/api\/records\/([^/]+)$/u); if (recordMatch !== null) { const id = decodeURIComponent(recordMatch[1] ?? "");