@evandu/super-pi-server 0.0.0-stage → 0.1.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -3
- package/agents/code-auditor.md +64 -0
- package/agents/code-designer.md +64 -0
- package/agents/coder.md +24 -0
- package/agents/critic.md +24 -0
- package/agents/document-organizer.md +48 -0
- package/agents/patcher.md +27 -0
- package/agents/planner.md +30 -0
- package/agents/project-leader.md +28 -0
- package/agents/reviewer.md +27 -0
- package/agents/scout.md +27 -0
- package/agents/solution-designer.md +62 -0
- package/agents/super-pi-documents/index.ts +92 -0
- package/agents/super-pi-feishu/index.ts +88 -0
- package/agents/super-pi-knowledge/index.ts +70 -0
- package/agents/super-pi-managed-model/index.ts +9 -0
- package/agents/super-pi-memory/index.ts +75 -0
- package/agents/super-pi-native-tools/index.ts +1 -0
- package/agents/super-pi-task/core.ts +2262 -0
- package/agents/super-pi-task/index.ts +814 -0
- package/agents/super-pi-task/workflow-schema.ts +34 -0
- package/agents/super-pi-web/index.ts +32 -0
- package/agents/verifier.md +25 -0
- package/assets/fonts/LICENSE +92 -0
- package/assets/fonts/NotoSansSC-Bold.otf +0 -0
- package/assets/fonts/NotoSansSC-Regular.otf +0 -0
- package/assets/knowledge-model/README.md +37 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/config.json +31 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/onnx/model_quantized.onnx +0 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/special_tokens_map.json +7 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer.json +21278 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer_config.json +15 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/vocab.txt +21128 -0
- package/bin/npm-prefix.d.ts +1 -0
- package/bin/npm-prefix.js +10 -0
- package/bin/super-pi.js +349 -0
- package/dist/client/.super-pi-client-sources.json +82 -0
- package/dist/client/assets/CodeMirrorEditor-mi9rGUce.js +2 -0
- package/dist/client/assets/GitDiffEditor-CpoDDQrA.css +1 -0
- package/dist/client/assets/GitDiffEditor-FQBfGxOY.js +29 -0
- package/dist/client/assets/diff-ChtP43wD.js +1 -0
- package/dist/client/assets/dist-AW5lyI3I.js +1 -0
- package/dist/client/assets/dist-B3-a6uF0.js +7 -0
- package/dist/client/assets/dist-BGxkyh6e.js +1 -0
- package/dist/client/assets/dist-BJxfd7yb.js +11 -0
- package/dist/client/assets/dist-BRVQKlcp.js +1 -0
- package/dist/client/assets/dist-BV64A9Ji.js +1 -0
- package/dist/client/assets/dist-BXAOrsjq.js +1 -0
- package/dist/client/assets/dist-CKF2Jksy.js +1 -0
- package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
- package/dist/client/assets/dist-Cus6_oaF.js +2 -0
- package/dist/client/assets/dist-Cx00EZKR.js +23 -0
- package/dist/client/assets/dist-D71y2EI1.js +1 -0
- package/dist/client/assets/dist-D978o95T.js +5 -0
- package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
- package/dist/client/assets/dist-Dds-qLxY.js +9 -0
- package/dist/client/assets/dist-DeD9copn.js +1 -0
- package/dist/client/assets/dist-DuvGReu-.js +6 -0
- package/dist/client/assets/dist-Dvb0SqcK.js +2 -0
- package/dist/client/assets/dist-J6XWqRpB.js +3 -0
- package/dist/client/assets/dist-QzbOCAU6.js +1 -0
- package/dist/client/assets/dist-moiMRpw_.js +1 -0
- package/dist/client/assets/dist-scBkrwv-.js +2 -0
- package/dist/client/assets/dockerfile-BDePf5PZ.js +1 -0
- package/dist/client/assets/index-Cn7hdrDw.js +350 -0
- package/dist/client/assets/index-UfzqdECL.css +1 -0
- package/dist/client/assets/powershell-D8WpQPaX.js +1 -0
- package/dist/client/assets/properties-C357ku5U.js +1 -0
- package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/client/assets/ruby-ChfNwlCY.js +1 -0
- package/dist/client/assets/shell-DwuoZtxw.js +1 -0
- package/dist/client/assets/swift-DKB6_1j6.js +1 -0
- package/dist/client/assets/toml-BPTmHmyx.js +1 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/favicon.png +0 -0
- package/dist/client/favicon.svg +10 -0
- package/dist/client/index.html +18 -0
- package/dist/extension.d.ts +15 -0
- package/dist/extension.js +126 -0
- package/dist/server/active-memory.d.ts +247 -0
- package/dist/server/active-memory.js +669 -0
- package/dist/server/agents.d.ts +245 -0
- package/dist/server/agents.js +701 -0
- package/dist/server/application/catalog-service.d.ts +98 -0
- package/dist/server/application/catalog-service.js +245 -0
- package/dist/server/application/conversation-service.d.ts +245 -0
- package/dist/server/application/conversation-service.js +654 -0
- package/dist/server/application/document-service.d.ts +68 -0
- package/dist/server/application/document-service.js +120 -0
- package/dist/server/application/extension-ui-service.d.ts +44 -0
- package/dist/server/application/extension-ui-service.js +135 -0
- package/dist/server/application/feishu-service.d.ts +179 -0
- package/dist/server/application/feishu-service.js +358 -0
- package/dist/server/application/group-chat-service.d.ts +75 -0
- package/dist/server/application/group-chat-service.js +953 -0
- package/dist/server/application/group-execution.d.ts +15 -0
- package/dist/server/application/group-execution.js +77 -0
- package/dist/server/application/project-service.d.ts +464 -0
- package/dist/server/application/project-service.js +2523 -0
- package/dist/server/application/provider-service.d.ts +174 -0
- package/dist/server/application/provider-service.js +510 -0
- package/dist/server/application/run-service.d.ts +547 -0
- package/dist/server/application/run-service.js +2683 -0
- package/dist/server/application/scheduled-task-service.d.ts +184 -0
- package/dist/server/application/scheduled-task-service.js +391 -0
- package/dist/server/application/session-orchestrator-service.d.ts +388 -0
- package/dist/server/application/session-orchestrator-service.js +1146 -0
- package/dist/server/application/session-reminder-service.d.ts +59 -0
- package/dist/server/application/session-reminder-service.js +141 -0
- package/dist/server/application/session-watchdog.d.ts +171 -0
- package/dist/server/application/session-watchdog.js +284 -0
- package/dist/server/application/workspace-service.d.ts +52 -0
- package/dist/server/application/workspace-service.js +186 -0
- package/dist/server/application/worktree-service.d.ts +13 -0
- package/dist/server/application/worktree-service.js +76 -0
- package/dist/server/browser-access.d.ts +34 -0
- package/dist/server/browser-access.js +89 -0
- package/dist/server/capability.d.ts +105 -0
- package/dist/server/capability.js +170 -0
- package/dist/server/command-handler.d.ts +93 -0
- package/dist/server/command-handler.js +540 -0
- package/dist/server/content-search.d.ts +16 -0
- package/dist/server/content-search.js +235 -0
- package/dist/server/conversation-usage.d.ts +22 -0
- package/dist/server/conversation-usage.js +43 -0
- package/dist/server/documents.d.ts +152 -0
- package/dist/server/documents.js +998 -0
- package/dist/server/engineering-learning.d.ts +30 -0
- package/dist/server/engineering-learning.js +106 -0
- package/dist/server/exec-service.d.ts +45 -0
- package/dist/server/exec-service.js +167 -0
- package/dist/server/explicit-file-open.d.ts +34 -0
- package/dist/server/explicit-file-open.js +105 -0
- package/dist/server/failure-text.d.ts +18 -0
- package/dist/server/failure-text.js +44 -0
- package/dist/server/feishu-cli.d.ts +223 -0
- package/dist/server/feishu-cli.js +464 -0
- package/dist/server/file-changes.d.ts +119 -0
- package/dist/server/file-changes.js +280 -0
- package/dist/server/file-diff.d.ts +41 -0
- package/dist/server/file-diff.js +97 -0
- package/dist/server/file-index.d.ts +100 -0
- package/dist/server/file-index.js +296 -0
- package/dist/server/file-name-index.d.ts +160 -0
- package/dist/server/file-name-index.js +411 -0
- package/dist/server/files.d.ts +269 -0
- package/dist/server/files.js +748 -0
- package/dist/server/git.d.ts +245 -0
- package/dist/server/git.js +903 -0
- package/dist/server/http-server.d.ts +45 -0
- package/dist/server/http-server.js +3830 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +485 -0
- package/dist/server/inline-thinking.d.ts +90 -0
- package/dist/server/inline-thinking.js +181 -0
- package/dist/server/json-comments.d.ts +14 -0
- package/dist/server/json-comments.js +71 -0
- package/dist/server/knowledge-embedding-worker.d.ts +1 -0
- package/dist/server/knowledge-embedding-worker.js +27 -0
- package/dist/server/knowledge-vectors.d.ts +150 -0
- package/dist/server/knowledge-vectors.js +385 -0
- package/dist/server/knowledge.d.ts +273 -0
- package/dist/server/knowledge.js +848 -0
- package/dist/server/length-continuation.d.ts +83 -0
- package/dist/server/length-continuation.js +118 -0
- package/dist/server/logging.d.ts +32 -0
- package/dist/server/logging.js +185 -0
- package/dist/server/managed-http-tunnel.d.ts +6 -0
- package/dist/server/managed-http-tunnel.js +85 -0
- package/dist/server/managed-http.d.ts +4 -0
- package/dist/server/managed-http.js +85 -0
- package/dist/server/managed-model-adapter.d.ts +17 -0
- package/dist/server/managed-model-adapter.js +75 -0
- package/dist/server/managed-model-gateway.d.ts +49 -0
- package/dist/server/managed-model-gateway.js +73 -0
- package/dist/server/managed-servers.d.ts +55 -0
- package/dist/server/managed-servers.js +392 -0
- package/dist/server/managed-ssh.d.ts +26 -0
- package/dist/server/managed-ssh.js +73 -0
- package/dist/server/manager-vault.d.ts +11 -0
- package/dist/server/manager-vault.js +67 -0
- package/dist/server/memory-recall.d.ts +25 -0
- package/dist/server/memory-recall.js +45 -0
- package/dist/server/memory.d.ts +67 -0
- package/dist/server/memory.js +216 -0
- package/dist/server/message-media.d.ts +7 -0
- package/dist/server/message-media.js +54 -0
- package/dist/server/model-context-window.d.ts +186 -0
- package/dist/server/model-context-window.js +444 -0
- package/dist/server/model-filter.d.ts +23 -0
- package/dist/server/model-filter.js +48 -0
- package/dist/server/models-store.d.ts +36 -0
- package/dist/server/models-store.js +132 -0
- package/dist/server/native-tool-settings.d.ts +25 -0
- package/dist/server/native-tool-settings.js +41 -0
- package/dist/server/native-tools-extension.d.ts +2 -0
- package/dist/server/native-tools-extension.js +39 -0
- package/dist/server/native-tools-service.d.ts +39 -0
- package/dist/server/native-tools-service.js +240 -0
- package/dist/server/persistence/app-state-repository.d.ts +65 -0
- package/dist/server/persistence/app-state-repository.js +1 -0
- package/dist/server/persistence/json-state-repository.d.ts +14 -0
- package/dist/server/persistence/json-state-repository.js +43 -0
- package/dist/server/persistence/open-state-store.d.ts +3 -0
- package/dist/server/persistence/open-state-store.js +35 -0
- package/dist/server/persistence/rename.d.ts +22 -0
- package/dist/server/persistence/rename.js +44 -0
- package/dist/server/persistence/sqlite-state-repository.d.ts +12 -0
- package/dist/server/persistence/sqlite-state-repository.js +264 -0
- package/dist/server/pi-command.d.ts +94 -0
- package/dist/server/pi-command.js +265 -0
- package/dist/server/pi-native.d.ts +12 -0
- package/dist/server/pi-native.js +16 -0
- package/dist/server/pi-session-events.d.ts +158 -0
- package/dist/server/pi-session-events.js +373 -0
- package/dist/server/pi-session-pool.d.ts +233 -0
- package/dist/server/pi-session-pool.js +382 -0
- package/dist/server/pi-session.d.ts +642 -0
- package/dist/server/pi-session.js +655 -0
- package/dist/server/presentations/schema.d.ts +120 -0
- package/dist/server/presentations/schema.js +128 -0
- package/dist/server/provider-network.d.ts +16 -0
- package/dist/server/provider-network.js +106 -0
- package/dist/server/provider-proxy.d.ts +18 -0
- package/dist/server/provider-proxy.js +200 -0
- package/dist/server/providers.d.ts +333 -0
- package/dist/server/providers.js +989 -0
- package/dist/server/remote-bootstrap.d.ts +17 -0
- package/dist/server/remote-bootstrap.js +119 -0
- package/dist/server/rpc-channel.d.ts +131 -0
- package/dist/server/rpc-channel.js +135 -0
- package/dist/server/runtime.d.ts +1393 -0
- package/dist/server/runtime.js +3286 -0
- package/dist/server/scheduled-tasks.d.ts +101 -0
- package/dist/server/scheduled-tasks.js +138 -0
- package/dist/server/server-context.d.ts +119 -0
- package/dist/server/server-context.js +1 -0
- package/dist/server/session-cwd.d.ts +19 -0
- package/dist/server/session-cwd.js +58 -0
- package/dist/server/session-ledger.d.ts +67 -0
- package/dist/server/session-ledger.js +76 -0
- package/dist/server/session-memory-scope.d.ts +4 -0
- package/dist/server/session-memory-scope.js +30 -0
- package/dist/server/session-repository.d.ts +100 -0
- package/dist/server/session-repository.js +246 -0
- package/dist/server/session-tree-scope.d.ts +125 -0
- package/dist/server/session-tree-scope.js +337 -0
- package/dist/server/skills.d.ts +23 -0
- package/dist/server/skills.js +190 -0
- package/dist/server/store.d.ts +1062 -0
- package/dist/server/store.js +3305 -0
- package/dist/server/subagent-runs.d.ts +185 -0
- package/dist/server/subagent-runs.js +383 -0
- package/dist/server/subagents.d.ts +200 -0
- package/dist/server/subagents.js +619 -0
- package/dist/server/task-tool.d.ts +282 -0
- package/dist/server/task-tool.js +507 -0
- package/dist/server/tavily.d.ts +32 -0
- package/dist/server/tavily.js +136 -0
- package/dist/server/team-context.d.ts +12 -0
- package/dist/server/team-context.js +180 -0
- package/dist/server/terminal.d.ts +163 -0
- package/dist/server/terminal.js +557 -0
- package/dist/server/thinking-level-discovery.d.ts +38 -0
- package/dist/server/thinking-level-discovery.js +183 -0
- package/dist/server/time-zone.d.ts +20 -0
- package/dist/server/time-zone.js +32 -0
- package/dist/server/tool-calls.d.ts +130 -0
- package/dist/server/tool-calls.js +341 -0
- package/dist/server/tool-llm.d.ts +72 -0
- package/dist/server/tool-llm.js +146 -0
- package/dist/server/tool-registry.d.ts +129 -0
- package/dist/server/tool-registry.js +249 -0
- package/dist/server/tool-runner.d.ts +112 -0
- package/dist/server/tool-runner.js +306 -0
- package/dist/server/turn-failure.d.ts +48 -0
- package/dist/server/turn-failure.js +148 -0
- package/dist/server/types.d.ts +2315 -0
- package/dist/server/types.js +11 -0
- package/dist/server/update-status.d.ts +14 -0
- package/dist/server/update-status.js +69 -0
- package/dist/server/update.d.ts +46 -0
- package/dist/server/update.js +104 -0
- package/dist/server/upload.d.ts +35 -0
- package/dist/server/upload.js +177 -0
- package/dist/server/version.d.ts +33 -0
- package/dist/server/version.js +111 -0
- package/dist/server/web.d.ts +27 -0
- package/dist/server/web.js +183 -0
- package/dist/server/workflow-engine.d.ts +47 -0
- package/dist/server/workflow-engine.js +255 -0
- package/dist/server/workflow.d.ts +329 -0
- package/dist/server/workflow.js +469 -0
- package/dist/server/workspace-file-indexes.d.ts +2 -0
- package/dist/server/workspace-file-indexes.js +61 -0
- package/dist/server/workspace-file-operations.d.ts +36 -0
- package/dist/server/workspace-file-operations.js +281 -0
- package/dist/server/workspace-file-response.d.ts +7 -0
- package/dist/server/workspace-file-response.js +79 -0
- package/dist/server/ws-server.d.ts +149 -0
- package/dist/server/ws-server.js +640 -0
- package/dist/shared/agent-order.d.ts +44 -0
- package/dist/shared/agent-order.js +50 -0
- package/dist/shared/archive-decisions.d.ts +44 -0
- package/dist/shared/archive-decisions.js +98 -0
- package/dist/shared/background-task.d.ts +25 -0
- package/dist/shared/background-task.js +183 -0
- package/dist/shared/child-session-lock.d.ts +37 -0
- package/dist/shared/child-session-lock.js +59 -0
- package/dist/shared/content-search.d.ts +22 -0
- package/dist/shared/content-search.js +1 -0
- package/dist/shared/conversation-title.d.ts +4 -0
- package/dist/shared/conversation-title.js +4 -0
- package/dist/shared/file-mentions.d.ts +17 -0
- package/dist/shared/file-mentions.js +91 -0
- package/dist/shared/git-commit.d.ts +11 -0
- package/dist/shared/git-commit.js +1 -0
- package/dist/shared/git-graph.d.ts +42 -0
- package/dist/shared/git-graph.js +30 -0
- package/dist/shared/group-chat.d.ts +132 -0
- package/dist/shared/group-chat.js +6 -0
- package/dist/shared/managed-servers.d.ts +36 -0
- package/dist/shared/managed-servers.js +1 -0
- package/dist/shared/message-media.d.ts +12 -0
- package/dist/shared/message-media.js +27 -0
- package/dist/shared/model-window-label.d.ts +39 -0
- package/dist/shared/model-window-label.js +55 -0
- package/dist/shared/native-tools.d.ts +43 -0
- package/dist/shared/native-tools.js +1 -0
- package/dist/shared/pi-cache-warming.d.ts +9 -0
- package/dist/shared/pi-cache-warming.js +4 -0
- package/dist/shared/project-overview.d.ts +107 -0
- package/dist/shared/project-overview.js +92 -0
- package/dist/shared/project-presentation.d.ts +55 -0
- package/dist/shared/project-presentation.js +111 -0
- package/dist/shared/provider-network.d.ts +30 -0
- package/dist/shared/provider-network.js +1 -0
- package/dist/shared/session-reporting.d.ts +40 -0
- package/dist/shared/session-reporting.js +97 -0
- package/dist/shared/session-search.d.ts +14 -0
- package/dist/shared/session-search.js +1 -0
- package/dist/shared/team-context-view.d.ts +33 -0
- package/dist/shared/team-context-view.js +49 -0
- package/dist/shared/team-context.d.ts +59 -0
- package/dist/shared/team-context.js +3 -0
- package/dist/shared/terminal-protocol.d.ts +71 -0
- package/dist/shared/terminal-protocol.js +1 -0
- package/dist/shared/thinking-levels.d.ts +53 -0
- package/dist/shared/thinking-levels.js +85 -0
- package/dist/shared/tool-glyph.d.ts +7 -0
- package/dist/shared/tool-glyph.js +19 -0
- package/dist/shared/transcript-order.d.ts +7 -0
- package/dist/shared/transcript-order.js +12 -0
- package/dist/shared/update-status.d.ts +28 -0
- package/dist/shared/update-status.js +1 -0
- package/dist/shared/workspace-file-preview.d.ts +4 -0
- package/dist/shared/workspace-file-preview.js +28 -0
- package/package.json +448 -4
- package/scripts/diagnose.mjs +603 -0
- package/scripts/patch-brace-expansion.mjs +260 -0
- package/scripts/restart-server.mjs +104 -0
- package/skills/presentation/SKILL.md +30 -0
- package/skills/presentation/references/data.md +10 -0
- package/skills/presentation/references/quality.md +12 -0
- package/skills/presentation/references/story.md +12 -0
- package/skills/presentation/references/templates-and-editing.md +11 -0
- package/skills/presentation/references/visual-system.md +10 -0
- package/skills/super-pi-agent-development/SKILL.md +25 -0
- package/skills/super-pi-development/SKILL.md +31 -0
- package/skills/super-pi-tool-development/SKILL.md +39 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-B3-a6uF0.js","assets/CodeMirrorEditor-mi9rGUce.js","assets/GitDiffEditor-FQBfGxOY.js","assets/dist-Cus6_oaF.js","assets/dist-J6XWqRpB.js","assets/GitDiffEditor-CpoDDQrA.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function ee(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function te(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ee(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ee(a,u),c+=te(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ee(a,u++),c+=te(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return te(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function N(e,t,n){if(e==null)return e;var r=[],i=0;return te(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var re=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function ie(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,re)}catch(e){re(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ae(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ie(ae.bind(null,e))}var oe={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=oe,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ae,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ie,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),r=t(((e,t)=>{t.exports=n()})),i=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),s=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=a(),n=r(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(o(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case M:return`Profiler`;case ee:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case N:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function Ce(e,t){be++,ye[be]=e.current,e.current=t}var we=xe(null),Te=xe(null),Ee=xe(null),De=xe(null);function Oe(e,t){switch(Ce(Ee,t),Ce(Te,e),Ce(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?fp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=fp(t),e=pp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(we),Ce(we,e)}function ke(){Se(we),Se(Te),Se(Ee)}function Ae(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,Ce(De,e)),t=we.current;var n=pp(t,e.type);t!==n&&(Ce(Te,e),Ce(we,n))}function je(e){Te.current===e&&(Se(we),Se(Te)),De.current===e&&(Se(De),lh._currentValue=ve)}var Me,Ne;function Pe(e){if(Me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Me=t&&t[1]||``,Ne=-1<e.stack.indexOf(`
|
|
3
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
+
`+Me+e+Ne}var Fe=!1;function Ie(e,t){if(!e||Fe)return``;Fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
|
+
`),l=s.split(`
|
|
6
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
7
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Pe(n):``}function F(e,t){switch(e.tag){case 26:case 27:case 5:return Pe(e.type);case 16:return Pe(`Lazy`);case 13:return e.child!==t&&t!==null?Pe(`Suspense Fallback`):Pe(`Suspense`);case 19:return Pe(`SuspenseList`);case 0:case 15:return Ie(e.type,!1);case 11:return Ie(e.type.render,!1);case 1:return Ie(e.type,!0);case 31:return Pe(`Activity`);case 30:return Pe(`ViewTransition`);default:return``}}function Le(e){try{var t=``,n=null;do t+=F(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
+
Error generating stack: `+e.message+`
|
|
9
|
+
`+e.stack}}var Re=Object.prototype.hasOwnProperty,ze=t.unstable_scheduleCallback,Be=t.unstable_cancelCallback,Ve=t.unstable_shouldYield,He=t.unstable_requestPaint,Ue=t.unstable_now,We=t.unstable_getCurrentPriorityLevel,I=t.unstable_ImmediatePriority,Ge=t.unstable_UserBlockingPriority,Ke=t.unstable_NormalPriority,qe=t.unstable_LowPriority,Je=t.unstable_IdlePriority,Ye=t.log,Xe=t.unstable_setDisableYieldValue,Ze=null,Qe=null;function $e(e){if(typeof Ye==`function`&&Xe(e),Qe&&typeof Qe.setStrictMode==`function`)try{Qe.setStrictMode(Ze,e)}catch{}}var et=Math.clz32?Math.clz32:rt,tt=Math.log,nt=Math.LN2;function rt(e){return e>>>=0,e===0?32:31-(tt(e)/nt|0)|0}var it=256,at=262144,ot=4194304;function st(e){var t=e&42;if(t!==0)return t;switch(e&-e){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ct(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=st(n))):i=st(o):i=st(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=st(n))):i=st(o)):i=st(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function lt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ut(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-et(n),i=1<<r;t|=e[r],n&=~i}return t}function dt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ft(){var e=ot;return ot<<=1,!(ot&62914560)&&(ot=4194304),e}function pt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ht(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-et(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&>(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function gt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-et(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function _t(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-et(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function vt(e,t){var n=t&-t;return n=n&42?1:yt(n),(n&(e.suspendedLanes|t))===0?n:0}function yt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function bt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function xt(){var e=_e.p;return e===0?(e=window.event,e===void 0?32:Th(e.type)):e}function St(e,t){var n=_e.p;try{return _e.p=e,t()}finally{_e.p=n}}var Ct=Math.random().toString(36).slice(2),wt=`__reactFiber$`+Ct,Tt=`__reactProps$`+Ct,Et=`__reactContainer$`+Ct,Dt=`__reactEvents$`+Ct,Ot=`__reactListeners$`+Ct,kt=`__reactHandles$`+Ct,At=`__reactResources$`+Ct,jt=`__reactMarker$`+Ct,Mt=`__reactLoad$`+Ct;function Nt(e){delete e[wt],delete e[Tt],delete e[Ot],delete e[kt]}function Pt(e){var t;if(t=e[wt])return t;for(var n=e.parentNode;n;){if(t=n[Et]||n[wt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mm(e);e!==null;){if(n=e[wt])return n;e=mm(e)}return t}e=n,n=e.parentNode}return null}function Ft(e){if(e=e[wt]||e[Et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function It(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function Lt(e){var t=e[At];return t||=e[At]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Rt(e){e[jt]=!0}function zt(e){e[Mt]=void 0}var Bt=new Set,Vt={};function Ht(e,t){Ut(e,t),Ut(e+`Capture`,t)}function Ut(e,t){for(Vt[e]=t,e=0;e<t.length;e++)Bt.add(t[e])}var Wt=RegExp(`^[: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]*$`),Gt={},Kt={};function qt(e){return Re.call(Kt,e)?!0:Re.call(Gt,e)?!1:Wt.test(e)?Kt[e]=!0:(Gt[e]=!0,!1)}var Jt=!1;function Yt(){var e=Jt;return Jt=!1,e}function Xt(e,t,n){if(qt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Zt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Qt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function $t(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function en(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function tn(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function nn(e){if(!e._valueTracker){var t=en(e)?`checked`:`value`;e._valueTracker=tn(e,t,``+e[t])}}function rn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=en(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var an=/[\n"\\]/g;function on(e){return e.replace(an,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function sn(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+$t(t)):e.value!==``+$t(t)&&(e.value=``+$t(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):ln(e,$t(n)):o===`number`&&e.value==t?ln(e,$t(e.value)):ln(e,$t(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+$t(s):e.removeAttribute(`name`)}function cn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){nn(e);return}n=n==null?``:``+$t(n),t=t==null?n:``+$t(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),nn(e)}function ln(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function un(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+$t(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function dn(e,t,n){t!=null&&(t=``+$t(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+$t(n)}function fn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(ge(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=$t(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),nn(e)}function pn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var mn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function hn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||mn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function gn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Jt=!0);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&(hn(e,i,r),Jt=!0)}else for(var a in t)t.hasOwnProperty(a)&&hn(e,a,t[a])}function _n(e){if(e.indexOf(`-`)===-1)return!1;switch(e){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 vn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),yn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function bn(e){return yn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function xn(){}var Sn=null;function Cn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var wn=null,Tn=null;function En(e){var t=Ft(e);if(t&&(e=t.stateNode)){var n=e[Tt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(sn(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+on(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[Tt]||null;if(!i)throw Error(o(90));sn(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&rn(r)}break a;case`textarea`:dn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&un(e,!!n.multiple,t,!1)}}}var Dn=!1;function On(e,t,n){if(Dn)return e(t,n);Dn=!0;try{return e(t)}finally{if(Dn=!1,(wn!==null||Tn!==null)&&(Rd(),wn&&(t=wn,e=Tn,Tn=wn=null,En(t),e)))for(t=0;t<e.length;t++)En(e[t])}}function kn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Tt]||null;if(r===null)return null;n=r[t];a:switch(t){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)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(o(231,t,typeof n));return n}var An=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,jn=!1;if(An)try{var Mn={};Object.defineProperty(Mn,"passive",{get:function(){jn=!0}}),window.addEventListener(`test`,Mn,Mn),window.removeEventListener(`test`,Mn,Mn)}catch{jn=!1}var Nn=null,Pn=null,Fn=null;function In(){if(Fn)return Fn;var e,t=Pn,n=t.length,r,i=`value`in Nn?Nn.value:Nn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Fn=i.slice(e,1<r?1-r:void 0)}function Ln(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Rn(){return!0}function zn(){return!1}function Bn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Rn:zn,this.isPropagationStopped=zn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Rn)},persist:function(){},isPersistent:Rn}),t}var Vn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hn=Bn(Vn),Un=D({},Vn,{view:0,detail:0}),Wn=Bn(Un),Gn,Kn,qn,Jn=D({},Un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ar,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==qn&&(qn&&e.type===`mousemove`?(Gn=e.screenX-qn.screenX,Kn=e.screenY-qn.screenY):Kn=Gn=0,qn=e),Gn)},movementY:function(e){return`movementY`in e?e.movementY:Kn}}),Yn=Bn(Jn),Xn=Bn(D({},Jn,{dataTransfer:0})),Zn=Bn(D({},Un,{relatedTarget:0})),Qn=Bn(D({},Vn,{animationName:0,elapsedTime:0,pseudoElement:0})),$n=Bn(D({},Vn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),er=Bn(D({},Vn,{data:0})),tr={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},nr={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`},rr={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function ir(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rr[e])?!!t[e]:!1}function ar(){return ir}var or=Bn(D({},Un,{key:function(e){if(e.key){var t=tr[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Ln(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?nr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ar,charCode:function(e){return e.type===`keypress`?Ln(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Ln(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),sr=Bn(D({},Jn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),cr=Bn(D({},Vn,{submitter:0})),lr=Bn(D({},Un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ar})),ur=Bn(D({},Vn,{propertyName:0,elapsedTime:0,pseudoElement:0})),dr=Bn(D({},Jn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),fr=Bn(D({},Vn,{newState:0,oldState:0,source:0})),pr=[9,13,27,32],mr=An&&`CompositionEvent`in window,hr=null;An&&`documentMode`in document&&(hr=document.documentMode);var gr=An&&`TextEvent`in window&&!hr,_r=An&&(!mr||hr&&8<hr&&11>=hr),vr=` `,yr=!1;function br(e,t){switch(e){case`keyup`:return pr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function xr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Sr=!1;function Cr(e,t){switch(e){case`compositionend`:return xr(t);case`keypress`:return t.which===32?(yr=!0,vr):null;case`textInput`:return e=t.data,e===vr&&yr?null:e;default:return null}}function wr(e,t){if(Sr)return e===`compositionend`||!mr&&br(e,t)?(e=In(),Fn=Pn=Nn=null,Sr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return _r&&t.locale!==`ko`?null:t.data;default:return null}}var Tr={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 Er(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Tr[e.type]:t===`textarea`}function Dr(e,t,n,r){wn?Tn?Tn.push(r):Tn=[r]:wn=r,t=Yf(t,`onChange`),0<t.length&&(n=new Hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Or=null,kr=null;function Ar(e){Vf(e,0)}function jr(e){if(rn(It(e)))return e}function Mr(e,t){if(e===`change`)return t}var Nr=!1;if(An){var Pr;if(An){var Fr=`oninput`in document;if(!Fr){var Ir=document.createElement(`div`);Ir.setAttribute(`oninput`,`return;`),Fr=typeof Ir.oninput==`function`}Pr=Fr}else Pr=!1;Nr=Pr&&(!document.documentMode||9<document.documentMode)}function Lr(){Or&&(Or.detachEvent(`onpropertychange`,Rr),kr=Or=null)}function Rr(e){if(e.propertyName===`value`&&jr(kr)){var t=[];Dr(t,kr,e,Cn(e)),On(Ar,t)}}function zr(e,t,n){e===`focusin`?(Lr(),Or=t,kr=n,Or.attachEvent(`onpropertychange`,Rr)):e===`focusout`&&Lr()}function Br(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return jr(kr)}function L(e,t){if(e===`click`)return jr(t)}function Vr(e,t){if(e===`input`||e===`change`)return jr(t)}function Hr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Ur=typeof Object.is==`function`?Object.is:Hr;function Wr(e,t){if(Ur(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Re.call(t,i)||!Ur(e[i],t[i]))return!1}return!0}function Gr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Kr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function qr(e,t){var n=Kr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Kr(n)}}function Jr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Jr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Gr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gr(e.document)}return t}function Xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var R=An&&`documentMode`in document&&11>=document.documentMode,Zr=null,Qr=null,$r=null,ei=!1;function ti(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ei||Zr==null||Zr!==Gr(r)||(r=Zr,`selectionStart`in r&&Xr(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}),$r&&Wr($r,r)||($r=r,r=Yf(Qr,`onSelect`),0<r.length&&(t=new Hn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Zr)))}function ni(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ri={animationend:ni(`Animation`,`AnimationEnd`),animationiteration:ni(`Animation`,`AnimationIteration`),animationstart:ni(`Animation`,`AnimationStart`),transitionrun:ni(`Transition`,`TransitionRun`),transitionstart:ni(`Transition`,`TransitionStart`),transitioncancel:ni(`Transition`,`TransitionCancel`),transitionend:ni(`Transition`,`TransitionEnd`)},ii={},ai={};An&&(ai=document.createElement(`div`).style,`AnimationEvent`in window||(delete ri.animationend.animation,delete ri.animationiteration.animation,delete ri.animationstart.animation),`TransitionEvent`in window||delete ri.transitionend.transition);function oi(e){if(ii[e])return ii[e];if(!ri[e])return e;var t=ri[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ai)return ii[e]=t[n];return e}var si=oi(`animationend`),ci=oi(`animationiteration`),li=oi(`animationstart`),ui=oi(`transitionrun`),di=oi(`transitionstart`),fi=oi(`transitioncancel`),pi=oi(`transitionend`),mi=new Map,hi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError 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(` `);hi.push(`scrollEnd`);function gi(e,t){mi.set(e,t),Ht(t,[e])}var _i=0;function vi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=yd.identifierPrefix;var n=_i++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function yi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Dd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function bi(e,t){return e=yi(e),t=yi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var xi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Si=[],Ci=0,wi=0;function Ti(){for(var e=Ci,t=wi=Ci=0;t<e;){var n=Si[t];Si[t++]=null;var r=Si[t];Si[t++]=null;var i=Si[t];Si[t++]=null;var a=Si[t];if(Si[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ki(n,i,a)}}function Ei(e,t,n,r){Si[Ci++]=e,Si[Ci++]=t,Si[Ci++]=n,Si[Ci++]=r,wi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Di(e,t,n,r){return Ei(e,t,n,r),Ai(e)}function Oi(e,t){return Ei(e,null,null,t),Ai(e)}function ki(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-et(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Ai(e){if(50<Od)throw Od=0,kd=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ji={};function Mi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,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 Ni(e,t,n,r){return new Mi(e,t,n,r)}function Pi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Fi(e,t){var n=e.alternate;return n===null?(n=Ni(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Ii(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Li(e,t,n,r,i,a){var s=0;if(r=e,typeof r==`function`)Pi(r)&&(s=1);else if(typeof r==`string`)s=Ym(e,n,we.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case se:return e=Ni(31,n,t,i),e.elementType=se,e.lanes=a,e;case j:return Ri(n.children,i,a,t);case ee:s=8,i|=24;break;case M:return e=Ni(12,n,t,i|2),e.elementType=M,e.lanes=a,e;case re:return e=Ni(13,n,t,i),e.elementType=re,e.lanes=a,e;case ie:return e=Ni(19,n,t,i),e.elementType=ie,e.lanes=a,e;case ce:case ue:return e=i|32,e=Ni(30,n,t,e),e.elementType=ue,e.lanes=a,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case N:s=10;break a;case te:s=9;break a;case ne:s=11;break a;case ae:s=14;break a;case oe:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=Ni(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function Ri(e,t,n,r){return e=Ni(7,e,r,t),e.lanes=n,e}function zi(e,t,n){return e=Ni(6,e,null,t),e.lanes=n,e}function Bi(e){var t=Ni(18,null,null,0);return t.stateNode=e,t}function Vi(e,t,n){return t=Ni(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Hi=new WeakMap;function Ui(e,t){if(typeof e==`object`&&e){var n=Hi.get(e);return n===void 0?(t={value:e,source:t,stack:Le(t)},Hi.set(e,t),t):n}return{value:e,source:t,stack:Le(t)}}var Wi=[],Gi=0,Ki=null,qi=0,Ji=[],Yi=0,Xi=null,z=1,Zi=``;function Qi(e,t){Wi[Gi++]=qi,Wi[Gi++]=Ki,Ki=e,qi=t}function $i(e,t,n){Ji[Yi++]=z,Ji[Yi++]=Zi,Ji[Yi++]=Xi,Xi=e;var r=z;e=Zi;var i=32-et(r)-1;r&=~(1<<i),n+=1;var a=32-et(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,z=1<<32-et(t)+i|n<<i|r,Zi=a+e}else z=1<<a|n<<i|r,Zi=e}function ea(e){e.return!==null&&(Qi(e,1),$i(e,1,0))}function ta(e){for(;e===Ki;)Ki=Wi[--Gi],Wi[Gi]=null,qi=Wi[--Gi],Wi[Gi]=null;for(;e===Xi;)Xi=Ji[--Yi],Ji[Yi]=null,Zi=Ji[--Yi],Ji[Yi]=null,z=Ji[--Yi],Ji[Yi]=null}function na(e,t){Ji[Yi++]=z,Ji[Yi++]=Zi,Ji[Yi++]=Xi,z=t.id,Zi=t.overflow,Xi=e}var ra=null,ia=null,aa=!1,oa=null,sa=!1,ca=Error(o(519));function la(e){throw ha(Ui(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ca}function ua(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[wt]=e,t[Tt]=r,n){case`dialog`:Hf(`cancel`,t),Hf(`close`,t);break;case`iframe`:case`object`:case`embed`:Hf(`load`,t);break;case`video`:case`audio`:for(n=0;n<zf.length;n++)Hf(zf[n],t);break;case`source`:Hf(`error`,t);break;case`img`:case`image`:case`link`:Hf(`error`,t),Hf(`load`,t);break;case`details`:Hf(`toggle`,t);break;case`input`:Hf(`invalid`,t),cn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Hf(`invalid`,t);break;case`textarea`:Hf(`invalid`,t),fn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||tp(t.textContent,n)?(r.popover!=null&&(Hf(`beforetoggle`,t),Hf(`toggle`,t)),r.onScroll!=null&&Hf(`scroll`,t),r.onScrollEnd!=null&&Hf(`scrollend`,t),r.onClick!=null&&(t.onclick=xn),t=!0):t=!1,t||la(e,!0)}function da(e){for(ra=e.return;ra;)switch(ra.tag){case 5:case 31:case 13:sa=!1;return;case 27:case 3:sa=!0;return;default:ra=ra.return}}function fa(e){if(e!==ra)return!1;if(!aa)return da(e),aa=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||hp(e.type,e.memoizedProps)),n=!n),n&&ia&&la(e),da(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));ia=pm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));ia=pm(e)}else t===27?(t=ia,wp(e.type)?(e=fm,fm=null,ia=e):ia=t):ia=ra?dm(e.stateNode.nextSibling):null;return!0}function pa(){ia=ra=null,aa=!1}function ma(){var e=oa;return e!==null&&(dd===null?dd=e:dd.push.apply(dd,e),oa=null),e}function ha(e){oa===null?oa=[e]:oa.push(e)}var ga=xe(null),_a=null,va=null;function ya(e,t,n){Ce(ga,t._currentValue),t._currentValue=n}function ba(e){e._currentValue=ga.current,Se(ga)}function xa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function B(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),xa(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),xa(s,n,e),s=null}else i.tag===13&&i.memoizedState!==null&&i.memoizedState.dehydrated===null?(i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),xa(i.return,n,e),s=i.child,s=s===null?null:s.sibling):s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function V(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;Ur(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===De.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[lh]:e.push(lh))}i=i.return}return e!==null&&B(t,e,n,r),t.flags|=262144,e!==null}function H(e){for(e=e.firstContext;e!==null;){if(!Ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function U(e){_a=e,va=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function W(e){return Ca(_a,e)}function Sa(e,t){return _a===null&&U(e),Ca(e,t)}function Ca(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},va===null){if(e===null)throw Error(o(308));va=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else va=va.next=t;return n}var wa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ta=t.unstable_scheduleCallback,Ea=t.unstable_NormalPriority,Da={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oa(){return{controller:new wa,data:new Map,refCount:0}}function ka(e){e.refCount--,e.refCount===0&&Ta(Ea,function(){e.controller.abort()})}function G(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Aa=null;function K(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var ja=null,Ma=0,Na=0,Pa=null;function Fa(e,t){if(ja===null){var n=ja=[];Ma=0,Na=Pf(),Pa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ma++,t.then(Ia,Ia),t}function Ia(){if(--Ma===0&&(Aa=null,ja!==null)){Pa!==null&&(Pa.status=`fulfilled`);var e=ja;ja=null,Na=0,Pa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function La(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ra=P.S;P.S=function(e,t){if(md=Ue(),typeof t==`object`&&t&&typeof t.then==`function`&&Fa(e,t),Aa!==null)for(var n=bf;n!==null;)G(n,Aa),n=n.next;if(n=e.types,n!==null){for(var r=bf;r!==null;)G(r,n),r=r.next;if(Na!==0){r=Aa,r===null&&(r=Aa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ra!==null&&Ra(e,t)};var za=xe(null);function Ba(){var e=za.current;return e===null?Yu.pooledCache:e}function Va(e,t){t===null?Ce(za,za.current):Ce(za,t.pool)}function Ha(){var e=Ba();return e===null?null:{parent:Da._currentValue,pool:e}}var Ua=Error(o(460)),Wa=Error(o(474)),Ga=Error(o(542)),Ka={then:function(){}};function qa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ja(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(xn,xn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Qa(e),e===void 0&&!(`reason`in t)?Error(o(600)):e;default:if(typeof t.status==`string`)t.then(xn,xn);else{if(e=Yu,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Qa(e),e}throw Xa=t,Ua}}function Ya(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Xa=e,Ua):e}}var Xa=null;function Za(){if(Xa===null)throw Error(o(459));var e=Xa;return Xa=null,e}function Qa(e){if(e===Ua||e===Ga)throw Error(o(483))}var $a=null,eo=0;function to(e){var t=eo;return eo+=1,$a===null&&($a=[]),Ja($a,e,t)}function no(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ro(e,t){throw t.$$typeof===O?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function io(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=Fi(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=zi(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===j?(e=d(e,t,n.props.children,r,n.key),no(e,n),e):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===oe&&Ya(a)===t.type)?(t=i(t,n.props),no(t,n),t.return=e,t):(t=Li(n.type,n.key,n.props,null,e.mode,r),no(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Vi(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=Ri(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=zi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Li(t.type,t.key,t.props,null,e.mode,n),no(n,t),n.return=e,n;case A:return t=Vi(t,e.mode,n),t.return=e,t;case oe:return t=Ya(t),f(e,t,n)}if(ge(t)||pe(t))return t=Ri(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,to(t),n);if(t.$$typeof===N)return f(e,Sa(e,t),n);ro(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case oe:return n=Ya(n),p(e,t,n,r)}if(ge(n)||pe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,to(n),r);if(n.$$typeof===N)return p(e,t,Sa(e,n),r);ro(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case oe:return r=Ya(r),m(e,t,n,r,i)}if(ge(r)||pe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,to(r),i);if(r.$$typeof===N)return m(e,t,n,Sa(t,r),i);ro(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),aa&&Qi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return aa&&Qi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),aa&&Qi(i,h),l}function g(i,s,c,l){if(c==null)throw Error(o(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),aa&&Qi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return aa&&Qi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),aa&&Qi(i,g),u}function _(e,r,a,c){if(typeof a==`object`&&a&&a.type===j&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case k:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===j){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),no(c,a),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===oe&&Ya(l)===r.type){n(e,r.sibling),c=i(r,a.props),no(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===j?(c=Ri(a.props.children,e.mode,c,a.key),no(c,a),c.return=e,e=c):(c=Li(a.type,a.key,a.props,null,e.mode,c),no(c,a),c.return=e,e=c)}return s(e);case A:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Vi(a,e.mode,c),c.return=e,e=c}return s(e);case oe:return a=Ya(a),_(e,r,a,c)}if(ge(a))return h(e,r,a,c);if(pe(a)){if(l=pe(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return _(e,r,to(a),c);if(a.$$typeof===N)return _(e,r,Sa(e,a),c);ro(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=zi(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{eo=0;var i=_(e,t,n,r);return $a=null,i}catch(t){if(t===Ua||t===Ga)throw t;var a=Ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ao=io(!0),oo=io(!1),so=!1;function co(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function uo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function fo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ju&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ai(e),ki(e,null,n),t}return Ei(e,r,t,n),Ai(e)}function po(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}function mo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ho=!1;function go(){if(ho){var e=Pa;if(e!==null)throw e}}function _o(e,t,n,r){ho=!1;var i=e.updateQueue;so=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Zu&f)===f:(r&f)===f){f!==0&&f===Na&&(ho=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:so=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),ad|=o,e.lanes=o,e.memoizedState=d}}function vo(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function yo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)vo(n[e],t)}var q=xe(null),bo=xe(0);function xo(e,t){e=rd,Ce(bo,e),Ce(q,t),rd=e|t.baseLanes}function So(){Ce(bo,rd),Ce(q,q.current)}function Co(){rd=bo.current,Se(q),Se(bo)}var wo=xe(null),To=null;function Eo(e){var t=e.alternate;Ce(jo,jo.current&1),Ce(wo,e),To===null&&(t===null||q.current!==null||t.memoizedState!==null)&&(To=e)}function Do(e){Ce(jo,jo.current),Ce(wo,e),To===null&&(To=e)}function Oo(e){e.tag===22?(Ce(jo,jo.current),Ce(wo,e),To===null&&(To=e)):ko()}function ko(){Ce(jo,jo.current),Ce(wo,wo.current)}function Ao(e){Se(wo),To===e&&(To=null),Se(jo)}var jo=xe(0);function Mo(e,t){Ce(wo,wo.current),Ce(jo,t)}function No(e){Se(jo),Se(wo),To===e&&(To=null)}function Po(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||cm(n)||lm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Fo=0,Io=null,Lo=null,Ro=null,zo=!1,J=!1,Bo=!1,Vo=0,Ho=0,Uo=null,Wo=0;function Go(){throw Error(o(321))}function Ko(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ur(e[n],t[n]))return!1;return!0}function qo(e,t,n,r,i,a){return Fo=a,Io=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?cc:lc,Bo=!1,a=n(r,i),Bo=!1,J&&(a=Yo(t,n,r,i)),Jo(e),a}function Jo(e){P.H=sc;var t=Lo!==null&&Lo.next!==null;if(Fo=0,Ro=Lo=Io=null,zo=!1,Ho=0,Uo=null,t)throw Error(o(300));e===null||Ec||(e=e.dependencies,e!==null&&H(e)&&(Ec=!0))}function Yo(e,t,n,r){Io=e;var i=0;do{if(J&&(Uo=null),Ho=0,J=!1,25<=i)throw Error(o(301));if(i+=1,Ro=Lo=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}P.H=uc,a=t(n,r)}while(J);return a}function Xo(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?X(t):t,e=e.useState()[0],(Lo===null?null:Lo.memoizedState)!==e&&(Io.flags|=1024),t}function Zo(){var e=Vo!==0;return Vo=0,e}function Qo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Y(e){if(zo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}zo=!1}Fo=0,Ro=Lo=Io=null,J=!1,Ho=Vo=0,Uo=null}function $o(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ro===null?Io.memoizedState=Ro=e:Ro=Ro.next=e,Ro}function es(){if(Lo===null){var e=Io.alternate;e=e===null?null:e.memoizedState}else e=Lo.next;var t=Ro===null?Io.memoizedState:Ro.next;if(t!==null)Ro=t,Lo=e;else{if(e===null)throw Io.alternate===null?Error(o(467)):Error(o(310));Lo=e,e={memoizedState:Lo.memoizedState,baseState:Lo.baseState,baseQueue:Lo.baseQueue,queue:Lo.queue,next:null},Ro===null?Io.memoizedState=Ro=e:Ro=Ro.next=e}return Ro}function ts(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function X(e){var t=Ho;return Ho+=1,Uo===null&&(Uo=[]),e=Ja(Uo,e,t),t=Io,(Ro===null?t.memoizedState:Ro.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?cc:lc),e}function ns(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return X(e);if(e.$$typeof===de)return;if(e.$$typeof===N)return W(e)}throw Error(o(438,String(e)))}function rs(e){var t=null,n=Io.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Io.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ts(),Io.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=le;return t.index++,n}function is(e,t){return typeof t==`function`?t(e):t}function as(e){return os(es(),Lo,e)}function os(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Fo&f)===f:(Zu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Na&&(d=!0);else if((Fo&p)===p){u=u.next,p===Na&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=a):l=l.next=f,Io.lanes|=p,ad|=p;f=u.action,Bo&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=a):l=l.next=p,Io.lanes|=f,ad|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!Ur(a,e.memoizedState)&&(Ec=!0,d&&(n=Pa,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function ss(e){var t=es(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);Ur(a,t.memoizedState)||(Ec=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function cs(e,t,n){var r=Io,i=es(),a=aa;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!Ur((Lo||i).memoizedState,n);if(s&&(i.memoizedState=n,Ec=!0),i=i.queue,Ns(ds.bind(null,r,i,e),[e]),e=i.getSnapshot!==t||s||Ro!==null&&!!(Ro.memoizedState.tag&1),Os(e?9:8,{destroy:void 0},us.bind(null,r,i,n,t),null),e){if(r.flags|=2048,Yu===null)throw Error(o(349));a||Fo&127||ls(r,t,n)}return n}function ls(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Io.updateQueue,t===null?(t=ts(),Io.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function us(e,t,n,r){t.value=n,t.getSnapshot=r,fs(t)&&ps(e)}function ds(e,t,n){return n(function(){fs(t)&&ps(e)})}function fs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ur(e,n)}catch{return!0}}function ps(e){var t=Oi(e,2);t!==null&&Nd(t,e,2)}function ms(e){var t=$o();if(typeof e==`function`){var n=e;if(e=n(),Bo){$e(!0);try{n()}finally{$e(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:e},t}function hs(e,t,n,r){return e.baseState=n,os(e,Lo,typeof r==`function`?r:is)}function gs(e,t,n,r,i){if(ic(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};P.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,_s(t,a)):(a.next=n.next,t.pending=n.next=a)}}function _s(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};o.types=a===null?null:a.types,P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),vs(e,t,s)}catch(n){bs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),vs(e,t,a)}catch(n){bs(e,t,n)}}function vs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ys(e,t,n)},function(n){return bs(e,t,n)}):ys(e,t,n)}function ys(e,t,n){t.status=`fulfilled`,t.value=n,xs(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,_s(e,n)))}function bs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,xs(t),t=t.next;while(t!==r)}e.action=null}function xs(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ss(e,t){return t}function Cs(e,t){if(aa){var n=Yu.formState;if(n!==null){a:{var r=Io;if(aa){if(ia){b:{for(var i=ia,a=sa;i.nodeType!==8;)if(!a||(i=dm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ia=dm(i.nextSibling),r=i.data===`F!`;break a}}la(r)}r=!1}r&&(t=n[0])}}return n=$o(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ss,lastRenderedState:t},n.queue=r,n=tc.bind(null,Io,r),r.dispatch=n,r=ms(!1),a=rc.bind(null,Io,!1,r.queue),r=$o(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=gs.bind(null,Io,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function ws(e){return Ts(es(),Lo,e)}function Ts(e,t,n){if(t=os(e,t,Ss)[0],e=as(is)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=X(t)}catch(e){throw e===Ua?Ga:e}else r=t;t=es();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Io.flags|=2048,Os(9,{destroy:void 0},Es.bind(null,i,n),null)),[r,a,e]}function Es(e,t){e.action=t}function Ds(e){var t=es(),n=Lo;if(n!==null)return Ts(t,n,e);es(),t=t.memoizedState,n=es();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Os(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Io.updateQueue,t===null&&(t=ts(),Io.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ks(){return es().memoizedState}function As(e,t,n,r){var i=$o();Io.flags|=e,i.memoizedState=Os(1|t,{destroy:void 0},n,r===void 0?null:r)}function js(e,t,n,r){var i=es();r=r===void 0?null:r;var a=i.memoizedState.inst;Lo!==null&&r!==null&&Ko(r,Lo.memoizedState.deps)?i.memoizedState=Os(t,a,n,r):(Io.flags|=e,i.memoizedState=Os(1|t,a,n,r))}function Ms(e,t){As(8390656,8,e,t)}function Ns(e,t){js(2048,8,e,t)}function Ps(e){Io.flags|=4;var t=Io.updateQueue;if(t===null)t=ts(),Io.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Fs(e){var t=es().memoizedState;return Ps({ref:t,nextImpl:e}),function(){if(Ju&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Is(e,t){return js(4,2,e,t)}function Ls(e,t){return js(4,4,e,t)}function Rs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function zs(e,t,n){n=n==null?null:n.concat([e]),js(4,4,Rs.bind(null,t,e),n)}function Bs(){}function Vs(e,t){var n=es();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Ko(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Hs(e,t){var n=es();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Ko(t,r[1]))return r[0];if(r=e(),Bo){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r}function Us(e,t,n){return n===void 0||Fo&1073741824&&!(Zu&261930)?e.memoizedState=t:(e.memoizedState=n,e=jd(),Io.lanes|=e,ad|=e,n)}function Ws(e,t,n,r){return Ur(n,t)?n:q.current===null?!(Fo&106)||Fo&1073741824&&!(Zu&261930)?(Ec=!0,e.memoizedState=n):(e=jd(),Io.lanes|=e,ad|=e,t):(e=Us(e,n,r),Ur(e,t)||(Ec=!0),e)}function Gs(e,t,n,r,i){var a=_e.p;_e.p=a!==0&&8>a?a:8;var o=P.T,s={};s.types=o===null?null:o.types,P.T=s,rc(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?nc(e,t,La(c,r),Ad(e)):nc(e,t,r,Ad(e))}catch(n){nc(e,t,{then:function(){},status:`rejected`,reason:n},Ad())}finally{_e.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function Ks(){}function qs(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Js(e).queue;Gs(e,i,t,ve,n===null?Ks:function(){return Ys(e),n(r)})}function Js(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ve,baseState:ve,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:ve},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ys(e){var t=Js(e);t.next===null&&(t=e.alternate.memoizedState),nc(e,t.next.queue,{},Ad())}function Xs(){return W(lh)}function Zs(){return es().memoizedState}function Qs(){return es().memoizedState}function $s(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ad();e=uo(n);var r=fo(t,e,n);r!==null&&(Nd(r,t,n),po(r,t,n)),t={cache:Oa()},e.payload=t;return}t=t.return}}function ec(e,t,n){var r=Ad();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ic(e)?ac(t,n):(n=Di(e,t,n,r),n!==null&&(Nd(n,e,r),oc(n,t,r)))}function tc(e,t,n){nc(e,t,n,Ad())}function nc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ic(e))ac(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Ur(s,o))return Ei(e,t,i,0),Yu===null&&Ti(),!1}catch{}if(n=Di(e,t,i,r),n!==null)return Nd(n,e,r),oc(n,t,r),!0}return!1}function rc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ic(e)){if(t)throw Error(o(479))}else t=Di(e,n,r,2),t!==null&&Nd(t,e,2)}function ic(e){var t=e.alternate;return e===Io||t!==null&&t===Io}function ac(e,t){J=zo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function oc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}var sc={readContext:W,use:ns,useCallback:Go,useContext:Go,useEffect:Go,useImperativeHandle:Go,useLayoutEffect:Go,useInsertionEffect:Go,useMemo:Go,useReducer:Go,useRef:Go,useState:Go,useDebugValue:Go,useDeferredValue:Go,useTransition:Go,useSyncExternalStore:Go,useId:Go,useHostTransitionStatus:Go,useFormState:Go,useActionState:Go,useOptimistic:Go,useMemoCache:Go,useCacheRefresh:Go,useEffectEvent:Go},cc={readContext:W,use:ns,useCallback:function(e,t){return $o().memoizedState=[e,t===void 0?null:t],e},useContext:W,useEffect:Ms,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),As(4194308,4,Rs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return As(4194308,4,e,t)},useInsertionEffect:function(e,t){As(4,2,e,t)},useMemo:function(e,t){var n=$o();t=t===void 0?null:t;var r=e();if(Bo){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=$o();if(n!==void 0){var i=n(t);if(Bo){$e(!0);try{n(t)}finally{$e(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=ec.bind(null,Io,e),[r.memoizedState,e]},useRef:function(e){var t=$o();return e={current:e},t.memoizedState=e},useState:function(e){e=ms(e);var t=e.queue,n=tc.bind(null,Io,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Bs,useDeferredValue:function(e,t){return Us($o(),e,t)},useTransition:function(){var e=ms(!1);return e=Gs.bind(null,Io,e.queue,!0,!1),$o().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Io,i=$o();if(aa){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Yu===null)throw Error(o(349));Zu&127||ls(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Ms(ds.bind(null,r,a,e),[e]),r.flags|=2048,Os(9,{destroy:void 0},us.bind(null,r,a,n,t),null),n},useId:function(){var e=$o(),t=Yu.identifierPrefix;if(aa){var n=Zi,r=z;n=(r&~(1<<32-et(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Vo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Wo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Xs,useFormState:Cs,useActionState:Cs,useOptimistic:function(e){var t=$o();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=rc.bind(null,Io,!0,n),n.dispatch=t,[e,t]},useMemoCache:rs,useCacheRefresh:function(){return $o().memoizedState=$s.bind(null,Io)},useEffectEvent:function(e){var t=$o(),n={impl:e};return t.memoizedState=n,function(){if(Ju&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},lc={readContext:W,use:ns,useCallback:Vs,useContext:W,useEffect:Ns,useImperativeHandle:zs,useInsertionEffect:Is,useLayoutEffect:Ls,useMemo:Hs,useReducer:as,useRef:ks,useState:function(){return as(is)},useDebugValue:Bs,useDeferredValue:function(e,t){return Ws(es(),Lo.memoizedState,e,t)},useTransition:function(){var e=as(is)[0],t=es().memoizedState;return[typeof e==`boolean`?e:X(e),t]},useSyncExternalStore:cs,useId:Zs,useHostTransitionStatus:Xs,useFormState:ws,useActionState:ws,useOptimistic:function(e,t){return hs(es(),Lo,e,t)},useMemoCache:rs,useCacheRefresh:Qs,useEffectEvent:Fs},uc={readContext:W,use:ns,useCallback:Vs,useContext:W,useEffect:Ns,useImperativeHandle:zs,useInsertionEffect:Is,useLayoutEffect:Ls,useMemo:Hs,useReducer:ss,useRef:ks,useState:function(){return ss(is)},useDebugValue:Bs,useDeferredValue:function(e,t){var n=es();return Lo===null?Us(n,e,t):Ws(n,Lo.memoizedState,e,t)},useTransition:function(){var e=ss(is)[0],t=es().memoizedState;return[typeof e==`boolean`?e:X(e),t]},useSyncExternalStore:cs,useId:Zs,useHostTransitionStatus:Xs,useFormState:Ds,useActionState:Ds,useOptimistic:function(e,t){var n=es();return Lo===null?(n.baseState=e,[e,n.queue.dispatch]):hs(n,Lo,e,t)},useMemoCache:rs,useCacheRefresh:Qs,useEffectEvent:Fs};function dc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var fc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=uo(r);i.payload=t,n!=null&&(i.callback=n),t=fo(e,i,r),t!==null&&(Nd(t,e,r),po(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=uo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=fo(e,i,r),t!==null&&(Nd(t,e,r),po(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ad(),r=uo(n);r.tag=2,t!=null&&(r.callback=t),t=fo(e,r,n),t!==null&&(Nd(t,e,n),po(t,e,n))}};function pc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Wr(n,r)||!Wr(i,a):!0}function mc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&fc.enqueueReplaceState(t,t.state,null)}function hc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function gc(e){xi(e)}function _c(e){console.error(e)}function vc(e){xi(e)}function yc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function bc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function xc(e,t,n){return n=uo(n),n.tag=3,n.payload={element:null},n.callback=function(){yc(e,t)},n}function Sc(e){return e=uo(e),e.tag=3,e}function Cc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){bc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){bc(t,n,r),typeof i!=`function`&&(_d===null?_d=new Set([this]):_d.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function wc(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&V(t,n,i,!0),n=wo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return To===null?Gd():n.alternate===null&&id===0&&(id=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===Ka?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),mf(e,r,i)),!1;case 22:return n.flags|=65536,r===Ka?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),mf(e,r,i)),!1}throw Error(o(435,n.tag))}return mf(e,r,i),Gd(),!1}if(aa)return t=wo.current,t===null?(r!==ca&&(t=Error(o(423),{cause:r}),ha(Ui(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Ui(r,n),i=xc(e.stateNode,r,i),mo(e,i),id!==4&&(id=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==ca&&(e=Error(o(422),{cause:r}),ha(Ui(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=Ui(a,n),ud===null?ud=[a]:ud.push(a),id!==4&&(id=2),t===null)return!0;r=Ui(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=xc(n.stateNode,r,e),mo(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(_d===null||!_d.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Sc(i),Cc(i,e,n,r),mo(n,i),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Tc=Error(o(461)),Ec=!1;function Dc(e,t,n,r){t.child=e===null?oo(t,null,n,r):ao(t,e.child,n,r)}function Oc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return U(t),r=qo(e,t,n,o,a,i),s=Zo(),e!==null&&!Ec?(Qo(e,t,i),tl(e,t,i)):(aa&&s&&ea(t),t.flags|=1,Dc(e,t,r,i),t.child)}function kc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Pi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Ac(e,t,a,r,i)):(e=Li(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!nl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Wr:n,n(o,r)&&e.ref===t.ref)return tl(e,t,i)}return t.flags|=1,e=Fi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Ac(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Wr(a,r)&&e.ref===t.ref){if(Ec=!1,t.pendingProps=r=a,nl(e,i))e.flags&131072&&(Ec=!0);else return t.lanes=e.lanes,tl(e,t,i)}}return Rc(e,t,n,r,i)}function jc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Va(t,a===null?null:a.cachePool),a===null?So():xo(t,a),Oo(t);else return r=t.lanes=536870912,Nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Va(t,null),So(),ko()):(Va(t,a.cachePool),xo(t,a),ko(),t.memoizedState=null);return Dc(e,t,i,n),t.child}function Mc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Nc(e,t,n,r,i){var a=Ba();return a=a===null?null:{parent:Da._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Va(t,null),So(),Oo(t),e!==null&&V(e,t,r,!0),t.childLanes=i,null}function Pc(e,t){return t=Kc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Fc(e,t,n){return ao(t,e.child,null,n),e=Pc(t,t.pendingProps),e.flags|=2,Ao(t),t.memoizedState=null,e}function Ic(e,t,n){var r=t.pendingProps,i=!!(t.flags&128);if(t.flags&=-129,e===null){if(aa){if(r.mode===`hidden`)return e=Pc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Mc(null,e);if(Do(t),(e=ia)?(e=sm(e,sa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Xi===null?null:{id:z,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=Bi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw la(t);return t.lanes=536870912,null}return Pc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if(Do(t),i){if(t.flags&256)t.flags&=-257,t=Fc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558))}else if(Ec||V(e,t,n,!1),i=(n&e.childLanes)!==0,Ec||i){if(q.current===null){if(r=Yu,r!==null&&(s=vt(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,Oi(e,s),Nd(r,e,s),Tc;Gd()}t=Fc(e,t,n)}else e=a.treeContext,ia=dm(s.nextSibling),ra=t,aa=!0,oa=null,sa=!1,e!==null&&na(t,e),t=Pc(t,r),t.flags|=134221824;return t}return e=Fi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Lc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Rc(e,t,n,r,i){return U(t),n=qo(e,t,n,r,void 0,i),r=Zo(),e!==null&&!Ec?(Qo(e,t,i),tl(e,t,i)):(aa&&r&&ea(t),t.flags|=1,Dc(e,t,n,i),t.child)}function Z(e,t,n,r,i,a){return U(t),t.updateQueue=null,n=Yo(t,r,n,i),Jo(e),r=Zo(),e!==null&&!Ec?(Qo(e,t,a),tl(e,t,a)):(aa&&r&&ea(t),t.flags|=1,Dc(e,t,n,a),t.child)}function zc(e,t,n,r,i){if(U(t),t.stateNode===null){var a=ji,o=n.contextType;typeof o==`object`&&o&&(a=W(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=fc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},co(t),o=n.contextType,a.context=typeof o==`object`&&o?W(o):ji,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(dc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&fc.enqueueReplaceState(a,a.state,null),_o(t,r,a,i),go(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=hc(n,s);a.props=c;var l=a.context,u=n.contextType;o=ji,typeof u==`object`&&u&&(o=W(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&mc(t,a,r,o),so=!1;var f=t.memoizedState;a.state=f,_o(t,r,a,i),go(),l=t.memoizedState,s||f!==l||so?(typeof d==`function`&&(dc(t,n,d,r),l=t.memoizedState),(c=so||pc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,lo(e,t),o=t.memoizedProps,u=hc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ji,typeof l==`object`&&l&&(c=W(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&mc(t,a,r,c),so=!1,f=t.memoizedState,a.state=f,_o(t,r,a,i),go();var p=t.memoizedState;o!==d||f!==p||so||e!==null&&e.dependencies!==null&&H(e.dependencies)?(typeof s==`function`&&(dc(t,n,s,r),p=t.memoizedState),(u=so||pc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&H(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Lc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=ao(t,e.child,null,i),t.child=ao(t,null,n,i)):Dc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=tl(e,t,i),e}function Bc(e,t,n,r){return pa(),t.flags|=256,Dc(e,t,n,r),t.child}var Vc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hc(e){return{baseLanes:e,cachePool:Ha()}}function Uc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cd),e}function Wc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(jo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(aa){if(i?Eo(t):ko(),(e=ia)?(e=sm(e,sa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Xi===null?null:{id:z,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=Bi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw la(t);return t.lanes=lm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(ko(),i=t.mode,a=Kc({mode:`hidden`,children:a},i),r=Ri(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Hc(n),r.childLanes=Uc(e,o,n),t.memoizedState=Vc,Mc(null,r)):(Eo(t),Gc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Jc(e,t,a,o,r,c,s,n)}return i?(ko(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Fi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Ri(i,a,n,null),i.flags|=2):i=Fi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Mc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Hc(n):(a=i.cachePool,a===null?a=Ha():(s=Da._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Uc(e,o,n),t.memoizedState=Vc,Mc(e.child,r)):(Eo(t),n=e.child,e=n.sibling,n=Fi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Gc(e,t){return t=Kc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Kc(e,t){return e=Ni(22,e,null,t),e.lanes=0,e}function qc(e,t,n){return ao(t,e.child,null,n),e=Gc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Jc(e,t,n,r,i,a,s,c){if(n)return t.flags&256?(Eo(t),t.flags&=-257,qc(e,t,c)):t.memoizedState===null?(ko(),a=i.fallback,s=t.mode,i=Kc({mode:`visible`,children:i.children},s),a=Ri(a,s,c,null),a.flags|=2,i.return=t,a.return=t,i.sibling=a,t.child=i,ao(t,e.child,null,c),i=t.child,i.memoizedState=Hc(c),i.childLanes=Uc(e,r,c),t.memoizedState=Vc,Mc(null,i)):(ko(),t.child=e.child,t.flags|=128,null);if(Eo(t),lm(a)){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(i=Error(o(419)),i.stack=``,i.digest=r,ha({value:i,source:null,stack:null})),qc(e,t,c)}if(Ec||V(e,t,c,!1),r=(c&e.childLanes)!==0,Ec||r){if(q.current!==null)return qc(e,t,c);if(r=Yu,r!==null&&(i=vt(r,c),i!==0&&i!==s.retryLane))throw s.retryLane=i,Oi(e,i),Nd(r,e,i),Tc;return cm(a)||Gd(),qc(e,t,c)}return cm(a)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ia=dm(a.nextSibling),ra=t,aa=!0,oa=null,sa=!1,e!==null&&na(t,e),t=Gc(t,i.children),t.flags|=134221824,t)}function Yc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),xa(e.return,t,n)}function Xc(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Po(n)===null&&(t=e),e=e.sibling}return t}function Zc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Qc(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function $c(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=jo.current;if(t.flags&128)return Mo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Mo(t,o),i===`backwards`&&e!==null?(Qc(e),Dc(e,t,r,n),Qc(e)):Dc(e,t,r,n),r=aa?qi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Yc(e,n,t);else if(e.tag===19)Yc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Xc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,Qc(t)),Zc(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Po(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Zc(t,!0,n,null,a,r);break;case`together`:Zc(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Xc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Zc(t,!1,i,n,a,r)}return t.child}function el(e,t,n){var r=t.pendingProps;return ya(t,t.type,r.value),Dc(e,t,r.children,n),t.child}function tl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ad|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(V(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Fi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Fi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function nl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&H(e)))}function rl(e,t,n){switch(t.tag){case 3:Oe(t,t.stateNode.containerInfo),ya(t,Da,e.memoizedState.cache),pa();break;case 27:case 5:Ae(t);break;case 4:Oe(t,t.stateNode.containerInfo);break;case 10:ya(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Do(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Eo(t),t.flags|=128,null;r=V(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Wc(e,t,n):(Eo(t),e=tl(e,t,n),e===null?null:e.sibling)}Eo(t);break;case 19:if(t.flags&128)return $c(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(V(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return $c(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Mo(t,jo.current),r)break;return null;case 22:return t.lanes=0,jc(e,t,n,t.pendingProps);case 24:ya(t,Da,e.memoizedState.cache)}return tl(e,t,n)}function il(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Ec=!0;else{if(!nl(e,n)&&!(t.flags&128))return Ec=!1,rl(e,t,n);Ec=!!(e.flags&131072)}}else Ec=!1,aa&&t.flags&1048576&&$i(t,qi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ya(t.elementType),t.type=e,typeof e==`function`)Pi(e)?(r=hc(e,r),t.tag=1,t=zc(null,t,e,r,n)):(t.tag=0,t=Rc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===ne){t.tag=11,t=Oc(null,t,e,r,n);break a}if(i===ae){t.tag=14,t=kc(null,t,e,r,n);break a}if(i===N){t.tag=10,t.type=e,t=el(null,t,n);break a}}throw t=he(e)||e,Error(o(306,t,``))}}return t;case 0:return Rc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=hc(r,t.pendingProps),zc(e,t,r,i,n);case 3:a:{if(Oe(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,lo(e,t),_o(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ya(t,Da,r),r!==a.cache&&B(t,[Da],n,!0),go(),r=s.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=Bc(e,t,r,n);break a}if(r!==i){i=Ui(Error(o(424)),t),ha(i),t=Bc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ia=dm(e.firstChild),ra=t,aa=!0,oa=null,sa=!0,n=oo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(pa(),r===i){t=tl(e,t,n);break a}Dc(e,t,r,n)}t=t.child}return t;case 26:return Lc(e,t),e===null?(n=Fm(t.type,null,t.pendingProps,null))?t.memoizedState=n:aa||(t.stateNode=mp(t.type,t.pendingProps,Ee.current,t)):t.memoizedState=Fm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ae(t),e===null&&aa&&(r=t.stateNode=_m(t.type,t.pendingProps,Ee.current),ra=t,sa=!0,i=ia,wp(t.type)?(fm=i,ia=dm(r.firstChild)):ia=i),Dc(e,t,t.pendingProps.children,n),Lc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&aa&&((i=r=ia)&&(r=am(r,t.type,t.pendingProps,sa),r===null?i=!1:(t.stateNode=r,ra=t,ia=dm(r.firstChild),sa=!1,i=!0)),i||la(t)),Ae(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,hp(i,a)?r=null:s!==null&&hp(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=qo(e,t,Xo,null,null,n),lh._currentValue=i),Lc(e,t),Dc(e,t,r,n),t.child;case 6:return e===null&&aa&&((e=n=ia)&&(n=om(n,t.pendingProps,sa),n===null?e=!1:(t.stateNode=n,ra=t,ia=null,e=!0)),e||la(t)),null;case 13:return Wc(e,t,n);case 4:return Oe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ao(t,null,r,n):Dc(e,t,r,n),t.child;case 11:return Oc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Lc(e,t),Dc(e,t,r,n),t.child;case 8:return Dc(e,t,t.pendingProps.children,n),t.child;case 12:return Dc(e,t,t.pendingProps.children,n),t.child;case 10:return el(e,t,n);case 9:return i=t.type._context,r=t.pendingProps.children,U(t),i=W(i),r=r(i),t.flags|=1,Dc(e,t,r,n),t.child;case 14:return kc(e,t,t.type,t.pendingProps,n);case 15:return Ac(e,t,t.type,t.pendingProps,n);case 19:return $c(e,t,n);case 31:return Ic(e,t,n);case 22:return jc(e,t,n,t.pendingProps);case 24:return U(t),r=W(Da),e===null?(i=Ba(),i===null&&(i=Yu,a=Oa(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},co(t),ya(t,Da,i)):((e.lanes&n)!==0&&(lo(e,t),_o(t,null,null,n),go()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,ya(t,Da,r),r!==i.cache&&B(t,[Da],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),ya(t,Da,r))),Dc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:aa&&ea(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Lc(e,t),Dc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function al(e){e.flags|=4}function ol(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Xm(t,r):Xm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Hd())e.flags|=8192;else throw Xa=Ka,Wa}}else e.flags&=-16777217}function sl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Zm(t)){if(Hd())e.flags|=8192;else throw Xa=Ka,Wa}}function cl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:ft(),e.lanes|=t,ld|=t)}function ll(e,t){if(!aa)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function ul(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function dl(e,t,n){var r=t.pendingProps;switch(ta(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ul(t),null;case 1:return ul(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ba(Da),ke(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(fa(t)?al(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ma())),ul(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(al(t),a===null?(ul(t),ol(t,i,null,r,n)):(ul(t),sl(t,a))):a?a===e.memoizedState?(ul(t),t.flags&=-16777217):(al(t),ul(t),sl(t,a)):(e=e.memoizedProps,e!==r&&al(t),ul(t),ol(t,i,e,r,n)),null;case 27:if(je(t),n=Ee.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&al(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return ul(t),t.subtreeFlags&=-33554433,null}e=we.current,fa(t)?ua(t,e):(e=_m(i,r,n),t.stateNode=e,al(t))}return ul(t),t.subtreeFlags&=-33554433,null;case 5:if(je(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&al(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return ul(t),t.subtreeFlags&=-33554433,null}if(a=we.current,fa(t))ua(t,a);else{var s=dp(Ee.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[wt]=t,a[Tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(ip(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&al(t)}}return ul(t),t.subtreeFlags&=-33554433,ol(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&al(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=Ee.current,fa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ra,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[wt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||tp(e.nodeValue,n)),e||la(t,!0)}else e=dp(e).createTextNode(r),e[wt]=t,t.stateNode=e}return ul(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=fa(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[wt]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ul(t),e=!1}else n=ma(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ao(t),t):(Ao(t),null);if(t.flags&128)throw Error(o(558))}return ul(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=fa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[wt]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ul(t),i=!1}else i=ma(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Ao(t),t):(Ao(t),null)}return Ao(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),cl(t,t.updateQueue),ul(t),null);case 4:return ke(),e===null&&Gf(t.stateNode.containerInfo),t.flags|=67108864,ul(t),null;case 10:return ba(t.type),ul(t),null;case 19:if(No(t),r=t.memoizedState,r===null)return ul(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)ll(r,!1);else{if(id!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Po(e),a!==null){for(t.flags|=128,ll(r,!1),e=a.updateQueue,t.updateQueue=e,cl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ii(n,e),n=n.sibling;return Mo(t,jo.current&1|2),aa&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ue()>hd&&(t.flags|=128,i=!0,ll(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Po(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,cl(t,e),ll(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!a.alternate&&!aa)return ul(t),null}else 2*Ue()-r.renderingStartTime>hd&&n!==536870912&&(t.flags|=128,i=!0,ll(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ue(),e.sibling=null,a=jo.current,a=i?a&1|2:a&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||aa?Mo(t,a):(n=a,Ce(wo,t),Ce(jo,n),To===null&&(To=t)),aa&&Qi(t,r.treeForkCount),e}return ul(t),null;case 22:case 23:return Ao(t),Co(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(ul(t),t.subtreeFlags&6&&(t.flags|=8192)):ul(t),n=t.updateQueue,n!==null&&cl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Se(za),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ba(Da),ul(t),null;case 25:return null;case 30:return t.flags|=33554432,ul(t),null}throw Error(o(156,t.tag))}function fl(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ba(Da),ke(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return je(t),null;case 31:if(t.memoizedState!==null){if(Ao(t),t.alternate===null)throw Error(o(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ao(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return No(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ke(),null;case 10:return ba(t.type),null;case 22:case 23:return Ao(t),Co(),e!==null&&Se(za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ba(Da),null;case 25:return null;default:return null}}function pl(e,t){switch(ta(t),t.tag){case 3:ba(Da),ke();break;case 26:case 27:case 5:je(t);break;case 4:ke();break;case 31:t.memoizedState!==null&&Ao(t);break;case 13:Ao(t);break;case 19:No(t);break;case 10:ba(t.type);break;case 22:case 23:Ao(t),Co(),e!==null&&Se(za);break;case 24:ba(Da)}}function ml(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){pf(t,t.return,e)}}function hl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){pf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){pf(t,t.return,e)}}function gl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{yo(t,n)}catch(t){pf(e,e.return,t)}}}function _l(e,t,n){n.props=hc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pf(e,t,n)}}function vl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=vi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Ip(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Lp(e);h(e.child,!1,em,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){pf(e,t,n)}}function yl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){pf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){pf(e,t,n)}else n.current=null}}function bl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)nm(e.stateNode,t[n])}function xl(e){for(var t=e.return;t!==null&&(wl(t)&&nm(e.stateNode,t.stateNode),!Cl(t));)t=t.return}function Sl(e){for(var t=e.return;t!==null&&(wl(t)&&rm(e.stateNode,t.stateNode),!Cl(t));)t=t.return}function Cl(e){return e.tag===5||e.tag===3||e.tag===27}function wl(e){return e&&e.tag===7&&e.stateNode!==null}function Tl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){pf(e,e.return,t)}}function El(e,t,n){try{var r=e.stateNode;op(r,e.type,n,t),r[Tt]=t}catch(t){pf(e,e.return,t)}}function Dl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&wp(e.type)||e.tag===4}function Ol(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Dl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&wp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function kl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=xn)),bl(e,r),Jt=!0;else if(i!==4&&(i===27&&(bl(e,r),r=null,wp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(kl(e,t,n,r),e=e.sibling;e!==null;)kl(e,t,n,r),e=e.sibling}function Al(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),bl(e,r),Jt=!0;else if(i!==4&&(i===27&&(bl(e,r),r=null,wp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Al(e,t,n,r),e=e.sibling;e!==null;)Al(e,t,n,r),e=e.sibling}function jl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ip(t,r,n),t[wt]=e,t[Tt]=n}catch(t){pf(e,e.return,t)}}var Ml=!1,Nl=null;function Pl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Ml=!0)}var Fl=null;function Il(){var e=Fl;return Fl=null,e}var Ll=0;function Rl(e,t,n,r,i){return Ll=0,zl(e.child,t,n,r,i)}function zl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Ap(o);r.push(s),s.view&&(a=!0)}else a||Ap(o).view&&(a=!0);Ml=!0,Dp(o,Ll===0?t:t+`_`+Ll,n),Ll++}else(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&i||zl(e.child,t,n,r,i)&&(a=!0));e=e.sibling}return a}function Bl(e,t){for(;e!==null;)e.tag===5?Op(e.stateNode,e.memoizedProps):(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&t||Bl(e.child,t)),e=e.sibling}function Vl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Vl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(o(544));var n=t.name;t=bi(t.default,t.share),t!==`none`&&(Rl(e,n,t,null,!1)||Bl(e.child,!1))}e=e.sibling}}function Hl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=vi(r,n),a=bi(r.default,n.paired?r.share:r.enter);a===`none`?Vl(e):Rl(e,i,a,null,!1)?(Vl(e),n.paired||t||Md(e,r.onEnter)):Bl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Hl(e,t),e=e.sibling;else Vl(e)}function Ul(e){if(Nl!==null&&Nl.size!==0){var t=Nl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=bi(n.default,n.share);if(a!==`none`&&(Rl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Md(e,n.onShare)):Bl(e.child,!1)),t.delete(r),t.size===0)break}}}Ul(e)}e=e.sibling}}}function Wl(e){if(e.tag===30){var t=e.memoizedProps,n=vi(t,e.stateNode),r=Nl===null?void 0:Nl.get(n),i=bi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Rl(e,n,i,null,!1)?r===void 0?Md(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Nl.delete(n),Md(e,t.onShare)):Bl(e.child,!1)),Nl!==null&&Ul(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Wl(e),e=e.sibling;else Nl!==null&&Ul(e)}function Gl(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=vi(t,e.stateNode);t=bi(t.default,t.update),e.flags&=-5,t!==`none`&&Rl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Gl(e);e=e.sibling}}function Kl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Bl(e.child,!1))}Kl(e)}e=e.sibling}}function ql(e){if(e.tag===30)e.stateNode.paired=null,Bl(e.child,!1),Kl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)ql(e),e=e.sibling;else Kl(e)}function Jl(e){for(e=e.child;e!==null;)e.tag===30?Bl(e.child,!1):e.subtreeFlags&33554432&&Jl(e),e=e.sibling}function Yl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Ll<a.length){var l=a[Ll],u=Ap(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Dp(c,Ll===0?n:n+`_`+Ll,i),s&&e.flags&4||(Fl===null&&(Fl=[]),Fl.push(c,Ll===0?r:r+`_`+Ll,t.memoizedProps)),Ll++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Yl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Xl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=vi(n,r),a=bi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(jp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Ll=0,i=Yl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Md(e,n.onUpdate))}else e.subtreeFlags&33554432&&Xl(e,t);e=e.sibling}}var Zl=!1,Ql=!1,$l=!1,eu=!1,tu=typeof WeakSet==`function`?WeakSet:Set,nu=null,ru=!1,iu=!1,au=!1,ou=!1;function su(e,t,n){if(e=e.containerInfo,lp=vh,e=Yr(e),Xr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(up={focusedElem:e,selectionRange:r},vh=!1,n=(n&335544064)===n,nu=t,t=n?9270:1024;nu!==null;){if(e=nu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Wl(r[a]);if(e.alternate===null&&e.flags&2)n&&Pl(e),cu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Wl(r),cu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Pl(e),cu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,nu=r):(n&&Gl(e),cu(n))}}Nl=null}function cu(e){for(;nu!==null;){var t=nu,n=e,r=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(i&1024&&r!==null){n=void 0,i=r.memoizedProps,r=r.memoizedState;var a=t.stateNode;try{var s=hc(t.type,i);n=a.getSnapshotBeforeUpdate(s,r),a.__reactInternalSnapshotBeforeUpdate=n}catch(e){pf(t,t.return,e)}}break;case 3:if(i&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)im(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:im(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=vi(r.memoizedProps,r.stateNode),i=t.memoizedProps,i=bi(i.default,i.update),i!==`none`&&Rl(r,n,i,r.memoizedState=[],!0));break;default:if(i&1024)throw Error(o(163))}if(r=t.sibling,r!==null){r.return=t.return,nu=r;break}nu=t.return}}function lu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ku(e,n),r&4&&ml(5,n);break;case 1:if(ku(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){pf(n,n.return,e)}else{var i=hc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pf(n,n.return,e)}}}r&64&&gl(n),r&512&&vl(n,n.return);break;case 3:if(ku(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{yo(e,t)}catch(e){pf(n,n.return,e)}}break;case 27:t===null&&r&4&&jl(n);case 26:case 5:ku(e,n),t===null&&r&4&&Tl(n),r&512&&vl(n,n.return);break;case 12:ku(e,n);break;case 31:ku(e,n),r&4&&vu(e,n);break;case 13:ku(e,n),r&4&&yu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=_f.bind(null,n),um(e,n))));break;case 22:if(r=n.memoizedState!==null||Zl,!r){var a=t!==null&&t.memoizedState!==null||Ql;t=Zl,i=Ql,Zl=r,(Ql=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),ju(e,n,r)):ku(e,n),Zl=t,Ql=i}break;case 30:ku(e,n),r&512&&vl(n,n.return);break;case 7:r&512&&vl(n,n.return);default:ku(e,n)}}function uu(e,t){for(e=e.child;e!==null;)du(e,t),e=e.sibling}function du(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){pf(e,e.return,t)}fu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Jt=!0}catch(t){pf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Ep(s,!0):Ep(e.stateNode,!1)}catch(t){pf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&uu(e,t);break;default:uu(e,t)}}function fu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:du(n,r);break a;case 22:n.memoizedState===null&&fu(n,r);break a;default:fu(n,r)}}e=e.sibling}}function pu(e){var t=e.alternate;t!==null&&(e.alternate=null,pu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Nt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var mu=null,hu=!1;function gu(e,t,n){for(n=n.child;n!==null;)_u(e,t,n),n=n.sibling}function _u(e,t,n){if(Qe&&typeof Qe.onCommitFiberUnmount==`function`)try{Qe.onCommitFiberUnmount(Ze,n)}catch{}switch(n.tag){case 26:Ql||yl(n,t),gu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!Ql&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Ql||yl(n,t),Sl(n);var r=mu,i=hu;wp(n.type)&&(mu=n.stateNode,hu=!1),gu(e,t,n),vm(n.stateNode,n.type,n.memoizedProps),mu=r,hu=i;break;case 5:Ql||yl(n,t),Sl(n);case 6:if(n.tag===6&&Sl(n),r=mu,i=hu,mu=null,gu(e,t,n),mu=r,hu=i,mu!==null){if(hu)try{(mu.nodeType===9?mu.body:mu.nodeName===`HTML`?mu.ownerDocument.body:mu).removeChild(n.stateNode),Jt=!0}catch(e){pf(n,t,e)}else try{mu.removeChild(n.stateNode),Jt=!0}catch(e){pf(n,t,e)}}break;case 18:mu!==null&&(hu?(e=mu,Tp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Wh(e)):Tp(mu,n.stateNode));break;case 4:r=mu,i=hu,mu=n.stateNode.containerInfo,hu=!0,gu(e,t,n),mu=r,hu=i;break;case 0:case 11:case 14:case 15:hl(2,n,t),Ql||hl(4,n,t),gu(e,t,n);break;case 1:Ql||(yl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&_l(n,t,r)),gu(e,t,n);break;case 21:gu(e,t,n);break;case 22:Ql=(r=Ql)||n.memoizedState!==null,gu(e,t,n),Ql=r;break;case 30:yl(n,t),gu(e,t,n);break;case 7:Ql||yl(n,t),gu(e,t,n);break;default:gu(e,t,n)}}function vu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wh(e)}catch(e){pf(t,t.return,e)}}}function yu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wh(e)}catch(e){pf(t,t.return,e)}}function bu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new tu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new tu),t;default:throw Error(o(435,e.tag))}}function xu(e,t){var n=bu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=vf.bind(null,e,t);t.then(r,r)}})}function Su(e,t,n){var r=t.deletions;if(r!==null)for(var i=0;i<r.length;i++){var a=r[i],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(wp(l.type)){mu=l.stateNode,hu=!1;break a}break;case 5:mu=l.stateNode,hu=!1;break a;case 3:case 4:mu=l.stateNode.containerInfo,hu=!0;break a}l=l.return}if(mu===null)throw Error(o(160));_u(s,c,a),mu=null,hu=!1,s=a.alternate,s!==null&&(s.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)wu(t,e,n),t=t.sibling}var Cu=null;function wu(e,t,n){var r=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(i&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var a=0;a<r.length;a++){var s=r[a];s.ref.impl=s.nextImpl}Su(t,e,n),Tu(e),i&4&&(hl(3,e,e.return),ml(3,e),hl(5,e,e.return));break;case 1:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||yl(r,r.return)),i&64&&Zl&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(a=Cu,Su(t,e,n),Tu(e),i&512&&(Ql||r===null||yl(r,r.return)),i&4){if(i=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(Zl)e.stateNode=mp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,i=a.ownerDocument||a;b:switch(t){case`title`:r=i.getElementsByTagName(`title`)[0],(!r||r[jt]||r[wt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=i.createElement(t),i.head.insertBefore(r,i.querySelector(`head > title`))),ip(r,t,n),r[wt]=e,Rt(r),t=r;break a;case`link`:if(a=qm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;s<a.length;s++)if(r=a[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){a.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;case`meta`:if(a=qm(`meta`,`content`,i).get(t+(n.content||``))){for(s=0;s<a.length;s++)if(r=a[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){a.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;default:throw Error(o(468,t))}r[wt]=e,Rt(r),t=r}e.stateNode=t}}else Zl||Jm(a,e.type,e.stateNode)}else e.stateNode=Hm(a,n,e.memoizedProps)}else i===n?n===null&&e.stateNode!==null&&El(e,e.memoizedProps,r.memoizedProps):(i===null?(t=r.stateNode,t===null||Ql||t.parentNode.removeChild(t)):i.count--,n===null?Zl||Jm(a,e.type,e.stateNode):Hm(a,n,e.memoizedProps))}break;case 27:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||yl(r,r.return)),r!==null&&i&4&&El(e,e.memoizedProps,r.memoizedProps);break;case 5:if(a=$l,$l=!1,Su(t,e,n),$l=a,Tu(e),i&512&&(Ql||r===null||yl(r,r.return)),e.flags&32){t=e.stateNode;try{pn(t,``),Jt=!0}catch(t){pf(e,e.return,t)}}i&4&&e.stateNode!=null&&(t=e.memoizedProps,El(e,t,r===null?t:r.memoizedProps)),i&1024&&(eu=!0);break;case 6:if(Su(t,e,n),Tu(e),i&4){if(e.stateNode===null)throw Error(o(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Jt=!0}catch(t){pf(e,e.return,t)}}break;case 3:if(Jt=!1,Km=null,a=Cu,Cu=Sm(t.containerInfo),Su(t,e,n),Cu=a,Tu(e),i&4&&r!==null&&r.memoizedState.isDehydrated)try{Wh(t.containerInfo)}catch(t){pf(e,e.return,t)}eu&&(eu=!1,Eu(e)),Jt=!1;break;case 4:i=$l,$l=Zl,r=Yt(),a=Cu,Cu=Sm(e.stateNode.containerInfo),Su(t,e,n),Tu(e),Cu=a,Jt&&iu&&(au=!0),Jt=r,$l=i;break;case 12:Su(t,e,n),Tu(e);break;case 31:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 13:Su(t,e,n),Tu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(pd=Ue()),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 22:a=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Zl,l=Ql,u=$l;Zl=c||a,$l=u||a,Ql=l||s,Su(t,e,n),Ql=l,$l=u,Zl=c,Tu(e),i&8192&&(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,!a||r===null||s||Zl||Ql||(t=s||Ql,n=Zl,r=Ql,Zl=a||Zl,Ql=t,Au(e,2),Zl=n,Ql=r),!a&&$l||uu(e,a)),i&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,xu(e,n))));break;case 19:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 30:i&512&&(Ql||r===null||yl(r,r.return)),i=Yt(),a=iu,s=(n&335544064)===n,c=e.memoizedProps,iu=s&&bi(c.default,c.update)!==`none`,Su(t,e,n),Tu(e),s&&r!==null&&Jt&&(e.flags|=4),iu=a,Jt=i;break;case 21:break;case 7:i&512&&(Ql||r===null||yl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Su(t,e,n),Tu(e)}}function Tu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Dl(r)){n=r;break}r=r.return}r=null;for(var i=e.return;i!==null;){if(wl(i)){var a=i.stateNode;r===null?r=[a]:r.push(a)}if(Cl(i))break;i=i.return}var s=r;if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode;Al(e,Ol(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(pn(l,``),n.flags&=-33),Al(e,Ol(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;kl(e,Ol(e),u,s);break;default:throw Error(o(161))}}catch(t){pf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Eu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Eu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,vh=!0,t.reset(),vh=!1),e=e.sibling}}function Du(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Ou(t,e),t=t.sibling;else Xl(t,!1)}function Ou(e,t){var n=e.alternate;if(n===null)Hl(e,!1);else switch(e.tag){case 3:if(ou=ru=!1,Il(),Du(t,e),!ru&&!au){if(e=Fl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Op(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),ou=!0}Fl=null;break;case 5:Du(t,e);break;case 4:r=ru,ru=!1,Du(t,e),ru&&(au=!0),ru=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Du(t,e):Hl(e,!1));break;case 30:r=ru,i=Il(),ru=!1,Du(t,e),ru&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=vi(a,o),o=vi(n.memoizedProps,o);var s=bi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Ll=0,t=Yl(e,n,t,o,s,a,!0),Ll!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Md(e,e.memoizedProps.onUpdate),Fl=i):i!==null&&(i.push.apply(i,Fl),Fl=i),ru=e.flags&32?!0:r;break;default:Du(t,e)}}function ku(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)lu(e,t.alternate,t),t=t.sibling}function Au(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:hl(4,n,n.return),Au(n,r);break;case 1:yl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&_l(n,n.return,i),Au(n,r);break;case 27:r&2&&vm(n.stateNode,n.type,n.memoizedProps);case 5:yl(n,n.return),n.tag!==5&&n.tag!==27||Sl(n),Au(n,r);break;case 6:Sl(n);break;case 26:yl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||Ql||i.parentNode.removeChild(i),Au(n,r);break;case 22:n.memoizedState===null&&Au(n,r);break;case 30:yl(n,n.return),Au(n,r);break;case 7:yl(n,n.return);default:Au(n,r)}e=e.sibling}}function ju(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:ju(i,a,n),ml(4,a);break;case 1:if(ju(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){pf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)vo(l[i],c)}catch(e){pf(r,r.return,e)}}s&&o&64&&gl(a),vl(a,a.return);break;case 27:n&2&&jl(a);case 5:a.tag!==5&&a.tag!==27||xl(a),ju(i,a,n),s&&r===null&&o&4&&Tl(a),vl(a,a.return);break;case 6:xl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Zl||Jm(Sm(c.ownerDocument),a.type,c),ju(i,a,n),s&&r===null&&o&4&&Tl(a),vl(a,a.return);break;case 12:ju(i,a,n);break;case 31:ju(i,a,n),s&&o&4&&vu(i,a);break;case 13:ju(i,a,n),s&&o&4&&yu(i,a);break;case 22:a.memoizedState===null&&ju(i,a,n),vl(a,a.return);break;case 30:ju(i,a,n),vl(a,a.return);break;case 7:vl(a,a.return);default:ju(i,a,n)}t=t.sibling}}function Mu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ka(n))}function Nu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ka(e))}function Pu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Fu(e,t,n,r),t=t.sibling;else i&&Jl(t)}function Fu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&ql(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Pu(e,t,n,r),a&2048&&ml(9,t);break;case 1:Pu(e,t,n,r);break;case 3:Pu(e,t,n,r),i&&ou&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&ka(a)));break;case 12:if(a&2048){Pu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){pf(t,t.return,e)}}else Pu(e,t,n,r);break;case 31:Pu(e,t,n,r);break;case 13:Pu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&ql(t),o._visibility&2?Pu(e,t,n,r):(o._visibility|=2,Iu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&ql(s),o._visibility&2?Pu(e,t,n,r):Lu(e,t)),a&2048&&Mu(s,t);break;case 24:Pu(e,t,n,r),a&2048&&Nu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Bl(a.child,!0),Bl(t.child,!0))),Pu(e,t,n,r);break;default:Pu(e,t,n,r)}}function Iu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Iu(a,o,s,c,i),ml(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Iu(a,o,s,c,i)):u._visibility&2?Iu(a,o,s,c,i):Lu(a,o),i&&l&2048&&Mu(o.alternate,o);break;case 24:Iu(a,o,s,c,i),i&&l&2048&&Nu(o.alternate,o);break;default:Iu(a,o,s,c,i)}t=t.sibling}}function Lu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Lu(n,r),i&2048&&Mu(r.alternate,r);break;case 24:Lu(n,r),i&2048&&Nu(r.alternate,r);break;default:Lu(n,r)}t=t.sibling}}var Ru=8192;function zu(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)Bu(e,t,n),e=e.sibling}function Bu(e,t,n){switch(e.tag){case 26:zu(e,t,n),e.flags&Ru&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&$m(n,e)):eh(n,Cu,e.memoizedState,e.memoizedProps));break;case 5:zu(e,t,n),e.flags&Ru&&(e=e.stateNode,(t&335544128)===t&&$m(n,e));break;case 3:case 4:var r=Cu;Cu=Sm(e.stateNode.containerInfo),zu(e,t,n),Cu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ru,Ru=16777216,zu(e,t,n),Ru=r):zu(e,t,n));break;case 30:if((e.flags&Ru)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Nl===null&&(Nl=new Map),Nl.set(r,i)}zu(e,t,n);break;default:zu(e,t,n)}}function Vu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nu=r,Gu(r,e)}Vu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uu(e),e=e.sibling}function Uu(e){switch(e.tag){case 0:case 11:case 15:Hu(e),e.flags&2048&&hl(9,e,e.return);break;case 3:Hu(e);break;case 12:Hu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wu(e)):Hu(e);break;default:Hu(e)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nu=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:hl(8,t,t.return),Wu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wu(t));break;default:Wu(t)}e=e.sibling}}function Gu(e,t){for(;nu!==null;){var n=nu;switch(n.tag){case 0:case 11:case 15:hl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ka(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,nu=r;else a:for(n=e;nu!==null;){r=nu;var i=r.sibling,a=r.return;if(pu(r),r===n){nu=null;break a}if(i!==null){i.return=a,nu=i;break a}nu=a}}}var Ku={getCacheForType:function(e){var t=W(Da),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return W(Da).controller.signal}},qu=typeof WeakMap==`function`?WeakMap:Map,Ju=0,Yu=null,Xu=null,Zu=0,Qu=0,$u=null,ed=!1,td=!1,nd=!1,rd=0,id=0,ad=0,od=0,sd=0,cd=0,ld=0,ud=null,dd=null,fd=!1,pd=0,md=0,hd=1/0,gd=null,_d=null,vd=0,yd=null,bd=null,xd=0,Sd=0,Cd=null,wd=null,Td=null,Ed=null,Dd=null,Od=0,kd=null;function Ad(){return Ju&2&&Zu!==0?Zu&-Zu:P.T===null?xt():Pf()}function jd(){if(cd===0){if(!(Zu&536870912)||aa){var e=at;at<<=1,!(at&3932160)&&(at=262144),cd=e}else cd=536870912}return e=wo.current,e!==null&&(e.flags|=32),cd}function Md(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Ip(vi(e.memoizedProps,n))),Ed===null&&(Ed=[]),Ed.push(t.bind(null,r))}}function Nd(e,t,n){(e===Yu&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)&&(Bd(e,0),Ld(e,Zu,cd,!1)),mt(e,n),(!(Ju&2)||e!==Yu)&&(e===Yu&&(!(Ju&2)&&(od|=n),id===4&&Ld(e,Zu,cd,!1)),Ef(e))}function Pd(e,t,n){if(Ju&6)throw Error(o(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||lt(e,t),i=r?Jd(e,t):Kd(e,t,!0),a=r;do{if(i===0){td&&!r&&Ld(e,t,0,!1);break}if(n=e.current.alternate,a&&!Id(n))i=Kd(e,t,!1),a=!1;else{if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=ud;var l=c.current.memoizedState.isDehydrated;if(l&&(Bd(c,s).flags|=256),s=Kd(c,s,!1),s!==2&&s!==6){if(nd&&!l){c.errorRecoveryDisabledLanes|=a,od|=a,i=4;break a}a=dd,dd=i,a!==null&&(dd===null?dd=a:dd.push.apply(dd,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){Bd(e,0),Ld(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Ld(r,t,cd,!ed);break a;case 2:dd=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=pd+300-Ue(),10<i)){if(Ld(r,t,cd,!ed),ct(r,0,!0)!==0)break a;xd=t,r.timeoutHandle=vp(Fd.bind(null,r,n,dd,gd,fd,t,cd,od,ld,ed,a,`Throttled`,-0,0),i);break a}Fd(r,n,dd,gd,fd,t,cd,od,ld,ed,a,null,-0,0)}break}}while(1);Ef(e)}function Fd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:xn},Nl=null,Bu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=ih.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?pd-Ue():(a&4194048)===a?md-Ue():0,m=nh(d,m),m!==null)?(xd=a,e.cancelPendingCommit=m(tf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Ld(e,a,o,!l)):tf(e,t,a,n,r,i,o,s,c,l,u,d)}function Id(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ur(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ld(e,t,n,r){t=ut(e,t),t&=~sd,t&=~od,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-et(i),o=1<<a;r[a]=-1,i&=~o}n!==0&>(e,n,t)}function Rd(){return Ju&6?!0:(Df(0,!1),!1)}function zd(){if(Xu!==null){if(Qu===0)var e=Xu.return;else e=Xu,va=_a=null,Y(e),$a=null,eo=0,e=Xu;for(;e!==null;)pl(e.alternate,e),e=e.return;Xu=null}}function Bd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,yp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),xd=0,zd(),Yu=e,Xu=n=Fi(e.current,null),Zu=t,Qu=0,$u=null,ed=!1,td=lt(e,t),nd=!1,ld=cd=sd=od=ad=id=0,dd=ud=null,fd=!1,rd=ut(e,t),Ti(),n}function Vd(e,t){Io=null,P.H=sc,t===Ua||t===Ga?(t=Za(),Qu=3):t===Wa?(t=Za(),Qu=4):Qu=t===Tc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$u=t,Xu===null&&(id=1,yc(e,Ui(t,e.current)))}function Hd(){var e=wo.current;return e===null?!0:(Zu&4194048)===Zu?To===null:(Zu&62914560)===Zu||Zu&536870912?e===To:!1}function Ud(){var e=P.H;return P.H=sc,e===null?sc:e}function Wd(){var e=P.A;return P.A=Ku,e}function Gd(){id=4,ed||(Zu&4194048)!==Zu&&wo.current!==null||(td=!0),!(ad&134217727)&&!(od&134217727)||Yu===null||Ld(Yu,Zu,cd,!1)}function Kd(e,t,n){var r=Ju;Ju|=2;var i=Ud(),a=Wd();(Yu!==e||Zu!==t)&&(gd=null,Bd(e,t)),t=!1;var o=id;a:do try{if(Qu!==0&&Xu!==null){var s=Xu,c=$u;switch(Qu){case 8:zd(),o=6;break a;case 3:case 2:case 9:case 6:wo.current===null&&(t=!0);var l=Qu;if(Qu=0,$u=null,Qd(e,s,c,l),n&&td){o=0;break a}break;default:l=Qu,Qu=0,$u=null,Qd(e,s,c,l)}}qd(),o=id;break}catch(t){Vd(e,t)}while(1);return t&&e.shellSuspendCounter++,va=_a=null,Ju=r,P.H=i,P.A=a,Xu===null&&(Yu=null,Zu=0,Ti()),o}function qd(){for(;Xu!==null;)Xd(Xu)}function Jd(e,t){var n=Ju;Ju|=2;var r=Ud(),i=Wd();Yu!==e||Zu!==t?(gd=null,hd=Ue()+500,Bd(e,t)):td=lt(e,t);a:do try{if(Qu!==0&&Xu!==null){t=Xu;var a=$u;b:switch(Qu){case 1:Qu=0,$u=null,Qd(e,t,a,1);break;case 2:case 9:if(qa(a)){Qu=0,$u=null,Zd(t);break}t=function(){Qu!==2&&Qu!==9||Yu!==e||(Qu=7),Ef(e)},a.then(t,t);break a;case 3:Qu=7;break a;case 4:Qu=5;break a;case 7:qa(a)?(Qu=0,$u=null,Zd(t)):(Qu=0,$u=null,Qd(e,t,a,7));break;case 5:var s=null;switch(Xu.tag){case 26:s=Xu.memoizedState;case 5:case 27:var c=Xu;if(s?Zm(s):c.stateNode.complete){Qu=0,$u=null;var l=c.sibling;if(l!==null)Xu=l;else{var u=c.return;u===null?Xu=null:(Xu=u,$d(u))}break b}}Qu=0,$u=null,Qd(e,t,a,5);break;case 6:Qu=0,$u=null,Qd(e,t,a,6);break;case 8:zd(),id=6;break a;default:throw Error(o(462))}}Yd();break}catch(t){Vd(e,t)}while(1);return va=_a=null,P.H=r,P.A=i,Ju=n,Xu===null?(Yu=null,Zu=0,Ti(),id):0}function Yd(){for(;Xu!==null&&!Ve();)Xd(Xu)}function Xd(e){var t=il(e.alternate,e,rd);e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Zd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Z(n,t,t.pendingProps,t.type,void 0,Zu);break;case 11:t=Z(n,t,t.pendingProps,t.type.render,t.ref,Zu);break;case 5:Y(t);var r=t;r===ra&&(aa?(da(r),r.tag===5&&r.stateNode!=null&&(ia=r.stateNode)):(da(r),aa=!0));default:pl(n,t),t=Xu=Ii(t,rd),t=il(n,t,rd)}e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Qd(e,t,n,r){va=_a=null,Y(t),$a=null,eo=0;var i=t.return;try{if(wc(e,i,t,n,Zu)){id=1,yc(e,Ui(n,e.current)),Xu=null;return}}catch(t){if(i!==null)throw Xu=i,t;id=1,yc(e,Ui(n,e.current)),Xu=null;return}t.flags&32768?(aa||r===1?e=!0:td||Zu&536870912?e=!1:(ed=e=!0,(r===2||r===9||r===3||r===6)&&(r=wo.current,r!==null&&r.tag===13&&(r.flags|=16384))),ef(t,e)):$d(t)}function $d(e){var t=e;do{if(t.flags&32768){ef(t,ed);return}e=t.return;var n=dl(t.alternate,t,rd);if(n!==null){Xu=n;return}if(t=t.sibling,t!==null){Xu=t;return}Xu=t=e}while(t!==null);id===0&&(id=5)}function ef(e,t){do{var n=fl(e.alternate,e);if(n!==null){n.flags&=32767,Xu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Xu=e;return}Xu=e=n}while(e!==null);id=6,Xu=null}function tf(e,t,n,r,i,a,s,c,l,u,d,f){e.cancelPendingCommit=null;do uf();while(vd!==0);if(Ju&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));e===Yu&&(Xu=Yu=null,Zu=0),bd=t,yd=e,xd=n,Cd=i,wd=r,nf(e,t,n,s,c,l,f)}}function nf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Sd=s,s|=wi,ht(e,n,s,r,i,a),Ed=null,(n&335544064)===n?(Dd=K(e),r=10262):(Dd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,yf(Ke,function(){return df(),null})):(e.callbackNode=null,e.callbackPriority=0),Ml=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=P.T,P.T=null,i=_e.p,_e.p=2,a=Ju,Ju|=4;try{su(e,t,n)}finally{Ju=a,_e.p=i,P.T=r}}vd=1,Ml?Td=Pp(o,e.containerInfo,Dd,of,sf,af,cf,df,rf,null,null):(of(),sf(),cf())}function rf(e){if(vd!==0){var t=yd.onRecoverableError;t(e,{componentStack:null})}}function af(){vd===3&&(vd=0,Ou(bd,yd),vd=4)}function of(){if(vd===1){vd=0;var e=yd,t=bd,n=xd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=P.T,P.T=null;var i=_e.p;_e.p=2;var a=Ju;Ju|=4;try{iu=au=!1,wu(t,e,n),n=up;var o=Yr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Jr(s.ownerDocument.documentElement,s)){if(c!==null&&Xr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=qr(s,h),v=qr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vh=!!lp,up=lp=null}finally{Ju=a,_e.p=i,P.T=r}}e.current=t,vd=2}}function sf(){if(vd===2){vd=0;var e=yd,t=bd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=_e.p;_e.p=2;var i=Ju;Ju|=4;try{lu(e,t.alternate,t)}finally{Ju=i,_e.p=r,P.T=n}}vd=3}}function cf(){if(vd===4||vd===3){vd=0;var e=Td;Td=null,He();var t=yd,n=bd,r=xd,i=wd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?vd=5:(vd=0,bd=yd=null,lf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(_d=null),bt(r),n=n.stateNode,Qe&&typeof Qe.onCommitFiberRoot==`function`)try{Qe.onCommitFiberRoot(Ze,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=P.T,a=_e.p,_e.p=2,P.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{P.T=n,_e.p=a}}if(i=Ed,o=Dd,Dd=null,i!==null&&(Ed=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);xd&3&&uf(),Ef(t),a=t.pendingLanes,r&261930&&a&42?t===kd?Od++:(Od=0,kd=t):(Od=0,kd=null),Df(0,!1)}}function lf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ka(t)))}function uf(){return Td!==null&&(Td.skipTransition(),Td=null),of(),sf(),cf(),df()}function df(){if(vd!==5)return!1;var e=yd,t=Sd;Sd=0;var n=bt(xd),r=P.T,i=_e.p;try{_e.p=32>n?32:n,P.T=null,n=Cd,Cd=null;var a=yd,s=xd;if(vd=0,bd=yd=null,xd=0,Ju&6)throw Error(o(331));var c=Ju;if(Ju|=4,Uu(a.current),Fu(a,a.current,s,n),Ju=c,Df(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot==`function`)try{Qe.onPostCommitFiberRoot(Ze,a)}catch{}return!0}finally{_e.p=i,P.T=r,lf(e,t)}}function ff(e,t,n){t=Ui(n,t),t=xc(e.stateNode,t,2),e=fo(e,t,2),e!==null&&(mt(e,2),Ef(e))}function pf(e,t,n){if(e.tag===3)ff(e,e,n);else for(;t!==null;){if(t.tag===3){ff(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(_d===null||!_d.has(r))){e=Ui(n,e),n=Sc(2),r=fo(t,n,2),r!==null&&(Cc(n,r,t,e),mt(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(nd=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Yu===e&&(Zu&n)===n&&(id===4||id===3&&(Zu&62914560)===Zu&&300>Ue()-pd?Ju&2?sd|=n:Bd(e,0):sd|=n,ld===Zu&&(ld=0)),Ef(e)}function gf(e,t){t===0&&(t=ft()),e=Oi(e,t),e!==null&&(mt(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return ze(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-et(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=Zu,a=ct(r,r===Yu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||lt(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&_p()&&(e=Tf);for(var t=Ue(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}vd!==0&&vd!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-et(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=dt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Yu,n=Zu,n=ct(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Be(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||lt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Be(r),bt(n)){case 2:case 8:n=Ge;break;case 32:n=Ke;break;case 268435456:n=Je;break;default:n=Ke}return r=jf.bind(null,e),n=ze(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Be(r),e.callbackPriority=2,e.callbackNode=null,2}function jf(e,t){if(vd!==0&&vd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(uf()&&e.callbackNode!==n)return null;var r=Zu;return r=ct(e,e===Yu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Pd(e,r,t),Af(e,Ue()),e.callbackNode!=null&&e.callbackNode===n?jf.bind(null,e):null)}function Mf(e,t){if(uf())return null;Pd(e,t,!0)}function Nf(){Sp(function(){Ju&6?ze(I,Of):kf()})}function Pf(){if(Tf===0){var e=Na;e===0&&(e=it,it<<=1,!(it&261888)&&(it=256)),Tf=e}return Tf}function Ff(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:bn(e)}function If(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ff((i[Tt]||null).action),o=r.submitter;o&&(t=(t=o[Tt]||null)?Ff(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Hn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Tf!==0){var e=new FormData(i,o);qs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),qs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Lf=0;Lf<hi.length;Lf++){var Rf=hi[Lf];gi(Rf.toLowerCase(),`on`+(Rf[0].toUpperCase()+Rf.slice(1)))}gi(si,`onAnimationEnd`),gi(ci,`onAnimationIteration`),gi(li,`onAnimationStart`),gi(`dblclick`,`onDoubleClick`),gi(`focusin`,`onFocus`),gi(`focusout`,`onBlur`),gi(ui,`onTransitionRun`),gi(di,`onTransitionStart`),gi(fi,`onTransitionCancel`),gi(pi,`onTransitionEnd`),Ut(`onMouseEnter`,[`mouseout`,`mouseover`]),Ut(`onMouseLeave`,[`mouseout`,`mouseover`]),Ut(`onPointerEnter`,[`pointerout`,`pointerover`]),Ut(`onPointerLeave`,[`pointerout`,`pointerover`]),Ht(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ht(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ht(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ht(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var zf=`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(` `),Bf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(zf));function Vf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){xi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){xi(e)}i.currentTarget=null,a=c}}}}function Hf(e,t){var n=t[Dt];n===void 0&&(n=t[Dt]=new Set);var r=e+`__bubble`;n.has(r)||(Kf(t,e,2,!1),n.add(r))}function Uf(e,t,n){var r=0;t&&(r|=4),Kf(n,e,r,t)}var Wf=`_reactListening`+Math.random().toString(36).slice(2);function Gf(e){if(!e[Wf]){e[Wf]=!0,Bt.forEach(function(t){t!==`selectionchange`&&(Bf.has(t)||Uf(t,!1,e),Uf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Wf]||(t[Wf]=!0,Uf(`selectionchange`,!1,t))}}function Kf(e,t,n,r){switch(Th(t)){case 2:var i=yh;break;case 8:i=bh;break;default:i=xh}n=i.bind(null,t,n,e),i=void 0,!jn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function qf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=Pt(s),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=a=o;continue a}s=s.parentNode}}r=r.return}On(function(){var r=a,i=Cn(n),o=[];a:{var s=mi.get(e);if(s!==void 0){var c=Hn,u=e;switch(e){case`keypress`:if(Ln(n)===0)break a;case`keydown`:case`keyup`:c=or;break;case`focusin`:u=`focus`,c=Zn;break;case`focusout`:u=`blur`,c=Zn;break;case`beforeblur`:case`afterblur`:c=Zn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Yn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Xn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=lr;break;case si:case ci:case li:c=Qn;break;case pi:c=ur;break;case`scroll`:case`scrollend`:c=Wn;break;case`wheel`:c=dr;break;case`copy`:case`cut`:case`paste`:c=$n;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=sr;break;case`submit`:c=cr;break;case`toggle`:case`beforetoggle`:c=fr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=kn(m,p),g!=null&&d.push(Jf(m,g,h))),f)break;m=m.return}0<d.length&&(s=new c(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,s=e===`mouseout`||e===`pointerout`,c&&n!==Sn&&(u=n.relatedTarget||n.fromElement)&&(Pt(u)||u[Et]))break a;(s||c)&&(u=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,s?(c=n.relatedTarget||n.toElement,s=r,c=c?Pt(c):null,c!==null&&(f=l(c),d=c.tag,c!==f||d!==5&&d!==27&&d!==6)&&(c=null)):(s=null,c=r),s!==c&&(d=Yn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=sr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:It(s),h=c==null?u:It(c),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Pt(i)===r&&(d=new d(p,m+`enter`,c,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=s&&c?E(s,c,Xf):null,s!==null&&Zf(o,u,s,d,!1),c!==null&&f!==null&&Zf(o,f,c,d,!0)))}a:{if(s=r?It(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var _=Mr;else if(Er(s)){if(Nr)_=Vr;else{_=Br;var v=zr}}else c=s.nodeName,!c||c.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&_n(r.elementType)&&(_=Mr):_=L;if(_&&=_(e,r)){Dr(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?It(r):window,e){case`focusin`:(Er(v)||v.contentEditable===`true`)&&(Zr=v,Qr=r,$r=null);break;case`focusout`:$r=Qr=Zr=null;break;case`mousedown`:ei=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:ei=!1,ti(o,n,i);break;case`selectionchange`:if(R)break;case`keydown`:case`keyup`:ti(o,n,i)}var y;if(mr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else Sr?br(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(_r&&n.locale!==`ko`&&(Sr||b!==`onCompositionStart`?b===`onCompositionEnd`&&Sr&&(y=In()):(Nn=i,Pn=`value`in Nn?Nn.value:Nn.textContent,Sr=!0)),v=Yf(r,b),0<v.length&&(b=new er(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=xr(n),y!==null&&(b.data=y)))),(y=gr?Cr(e,n):wr(e,n))&&(b=Yf(r,`onBeforeInput`),0<b.length&&(v=new er(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:v,listeners:b}),v.data=y)),If(o,e,r,n,i)}Vf(o,t)})}function Jf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Yf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=kn(e,n),i!=null&&r.unshift(Jf(e,i,a)),i=kn(e,t),i!=null&&r.push(Jf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Xf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Zf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=kn(n,a),l!=null&&o.unshift(Jf(n,l,c))):i||(l=kn(n,a),l!=null&&o.push(Jf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Qf=/\r\n?/g,$f=/\u0000|\uFFFD/g;function ep(e){return(typeof e==`string`?e:``+e).replace(Qf,`
|
|
10
|
+
`).replace($f,``)}function tp(e,t){return t=ep(t),ep(e)===t}function np(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||pn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&pn(e,``+r);else return;break;case`className`:Zt(e,`class`,r);break;case`tabIndex`:Zt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Zt(e,n,r);break;case`style`:gn(e,r,a);return;case`data`:if(t!==`object`){Zt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=bn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&np(e,t,`name`,i.name,i,null),np(e,t,`formEncType`,i.formEncType,i,null),np(e,t,`formMethod`,i.formMethod,i,null),np(e,t,`formTarget`,i.formTarget,i,null)):(np(e,t,`encType`,i.encType,i,null),np(e,t,`method`,i.method,i,null),np(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=bn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=xn);return;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=bn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Xt(e,`popover`,r);break;case`xlinkActuate`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Xt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=vn.get(n)||n,Xt(e,n,r);else return}Jt=!0}function rp(e,t,n,r,i,a){switch(n){case`style`:gn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)pn(e,r);else if(typeof r==`number`||typeof r==`bigint`)pn(e,``+r);else return;break;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=xn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),a=n.slice(2,i?n.length-7:void 0),t=e[Tt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(a,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(a,r,i);break a}Jt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Xt(e,n,r)}return}Jt=!0}function ip(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Hf(`error`,e),Hf(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,a,s,n,null)}}i&&np(e,t,`srcSet`,n.srcSet,n,null),r&&np(e,t,`src`,n.src,n,null);return;case`input`:Hf(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:np(e,t,r,d,n,null)}}cn(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Hf(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:np(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&un(e,!!r,n,!0):un(e,!!r,t,!1);return;case`textarea`:for(s in Hf(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:np(e,t,s,c,n,null)}fn(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:np(e,t,l,r,n,null)}return;case`dialog`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Hf(`cancel`,e),Hf(`close`,e);break;case`iframe`:case`object`:Hf(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Hf(zf[r],e);break;case`image`:Hf(`error`,e),Hf(`load`,e);break;case`details`:Hf(`toggle`,e);break;case`embed`:case`source`:case`link`:Hf(`error`,e),Hf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,u,r,n,null)}return;default:if(_n(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&rp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&np(e,t,c,r,n,null))}var ap={};function op(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||np(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Jt=!0),a=m;break;case`name`:m!==f&&(Jt=!0),i=m;break;case`checked`:m!==f&&(Jt=!0),u=m;break;case`defaultChecked`:m!==f&&(Jt=!0),d=m;break;case`value`:m!==f&&(Jt=!0),s=m;break;case`defaultValue`:m!==f&&(Jt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&np(e,t,p,m,r,f)}}sn(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||np(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:a!==l&&(Jt=!0),p=a;break;case`defaultValue`:a!==l&&(Jt=!0),c=a;break;case`multiple`:a!==l&&(Jt=!0),s=a;default:a!==l&&np(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?un(e,!!n,n?[]:``,!1):un(e,!!n,t,!0)):un(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:np(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:i!==a&&(Jt=!0),p=i;break;case`defaultValue`:i!==a&&(Jt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&np(e,t,s,i,r,a)}dn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:np(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Jt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:np(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&np(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:np(e,t,u,p,r,m)}return;default:if(_n(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&rp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||rp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&np(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||np(e,t,f,p,r,m)}function sp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function cp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&sp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&sp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var lp=null,up=null;function dp(e){return e.nodeType===9?e:e.ownerDocument}function fp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function pp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function mp(e,t,n,r){return n=dp(n).createElement(e),n[wt]=r,n[Tt]=t,ip(n,e,t),Rt(n),n}function hp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gp=null;function _p(){var e=window.event;return e&&e.type===`popstate`?e!==gp&&(gp=e,!0):(gp=null,!1)}var vp=typeof setTimeout==`function`?setTimeout:void 0,yp=typeof clearTimeout==`function`?clearTimeout:void 0,bp=typeof Promise==`function`?Promise:void 0,xp=typeof requestAnimationFrame==`function`?requestAnimationFrame:vp,Sp=typeof queueMicrotask==`function`?queueMicrotask:bp===void 0?vp:function(e){return bp.resolve(null).then(e).catch(Cp)};function Cp(e){setTimeout(function(){throw e})}function wp(e){return e===`head`}function Tp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)ym(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,ym(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[jt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&ym(e.ownerDocument.body)}n=i}while(n);Wh(t)}function Ep(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Dp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Op(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function kp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Ap(e){return kp(e.getBoundingClientRect(),getComputedStyle(e),e)}function jp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return kp(t,n,e)}function Mp(e){return e.documentElement.clientHeight}function Np(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Pp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Mp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Qm(f),u>th){s.length=o;break}f=new Promise(Np.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Fp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Fp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Fp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Fp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Ip(e){return{name:e,group:new Fp(`group`,e),imagePair:new Fp(`image-pair`,e),old:new Fp(`old`,e),new:new Fp(`new`,e)}}function Lp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Lp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Bp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Rp,e,s,r)}this._eventListeners=a}};function Rp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Lp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Bp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,zp,e,n,i),r.splice(t,1),a!==null&&a()}};function zp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Bp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Vp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Vp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Vp(a.optionsOrUseCapture)===r)return i}return-1}Lp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Lp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),hm(e,t))}Lp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}Lp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=dp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Lp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Lp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,gm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Lp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Lp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Lp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=Pt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Lp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(o(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function rm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function im(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:im(n),Nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function am(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[jt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=dm(e.nextSibling),e===null)break}return null}function om(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=dm(e.nextSibling),e===null))return null;return e}function sm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=dm(e.nextSibling),e===null))return null;return e}function cm(e){return e.data===`$?`||e.data===`$~`}function lm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function um(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function dm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var fm=null;function pm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return dm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function gm(e){xp(function(){xp(function(t){return e(t)})})}function _m(e,t,n){switch(t=dp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function vm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&np(e,t,r,null,ap,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===xn&&(e.onclick=null),Nt(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Nt(e)}var bm=new Map,xm=new Set;function Sm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Cm=_e.d;_e.d={f:wm,r:Tm,D:Om,C:km,L:Am,m:jm,X:Nm,S:Mm,M:Pm};function wm(){var e=Cm.f(),t=Rd();return e||t}function Tm(e){var t=Ft(e);t!==null&&t.tag===5&&t.type===`form`?Ys(t):Cm.r(e)}var Em=typeof document>`u`?null:document;function Dm(e,t,n){var r=Em;if(r&&typeof t==`string`&&t){var i=on(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),xm.has(i)||(xm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ip(t,`link`,e),Rt(t),r.head.appendChild(t)))}}function Om(e){Cm.D(e),Dm(`dns-prefetch`,e,null)}function km(e,t){Cm.C(e,t),Dm(`preconnect`,e,t)}function Am(e,t,n){Cm.L(e,t,n);var r=Em;if(r&&e&&t){var i=`link[rel="preload"][as="`+on(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+on(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+on(n.imageSizes)+`"]`)):i+=`[href="`+on(e)+`"]`;var a=i;switch(t){case`style`:a=Im(e);break;case`script`:a=Bm(e)}if(!(bm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),bm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Lm(a))||t===`script`&&r.querySelector(Vm(a))))){var o=r.createElement(`link`);ip(o,`link`,e),t===`style`&&(o[Mt]=!0,o.onload=o.onerror=function(){zt(o)}),Rt(o),r.head.appendChild(o)}}}function jm(e,t){Cm.m(e,t);var n=Em;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+on(r)+`"][href="`+on(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Bm(e)}if(!bm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),bm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Vm(a)))return}r=n.createElement(`link`),ip(r,`link`,e),Rt(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=Lt(r).hoistableStyles,a=Im(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Lm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=bm.get(a))&&Wm(e,n);var c=o=r.createElement(`link`);Rt(c),ip(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Um(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Nm(e,t){Cm.X(e,t);var n=Em;if(n&&e){var r=Lt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Rt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t){Cm.M(e,t);var n=Em;if(n&&e){var r=Lt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Rt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Fm(e,t,n,r){var i=(i=Ee.current)?Sm(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Im(n.href),t=Lt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Im(n.href);var a=Lt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Lm(e)))?a._p||(s.instance=a,s.state.loading=5):(a=bm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},bm.set(e,a)),zm(i,e,a,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Bm(n),t=Lt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Im(e){return`href="`+on(e)+`"`}function Lm(e){return`link[rel="stylesheet"][`+e+`]`}function Rm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function zm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Mt]){r.loading=1;return}}else t=e.createElement(`link`),t[Mt]=!0,t.onload=t.onerror=zt.bind(null,t),ip(t,`link`,n),Rt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Bm(e){return`[src="`+on(e)+`"]`}function Vm(e){return`script[async]`+e}function Hm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+on(n.href)+`"]`);if(r)return t.instance=r,Rt(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Rt(r),ip(r,`style`,i),Um(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Im(n.href);var a=e.querySelector(Lm(i));if(a)return t.state.loading|=4,t.instance=a,Rt(a),a;r=Rm(n),(i=bm.get(i))&&Wm(r,i),a=(e.ownerDocument||e).createElement(`link`),Rt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ip(a,`link`,r),t.state.loading|=4,Um(a,n.precedence,e),t.instance=a;case`script`:return a=Bm(n.src),(i=e.querySelector(Vm(a)))?(t.instance=i,Rt(i),i):(r=n,(i=bm.get(a))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Rt(i),ip(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Um(r,n.precedence,e));return t.instance}function Um(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Gm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Km=null;function qm(e,t,n){if(Km===null){var r=new Map,i=Km=new Map;i.set(n,r)}else i=Km,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[jt]||a[wt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Jm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Ym(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Xm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Zm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function $m(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Qm(t),e.suspenseyImages.push(t)),e=ah.bind(e),t.decode().then(e,e))}function eh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Im(r.href),a=t.querySelector(Lm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ih.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Rt(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),Rt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ip(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ih.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var th=0;function nh(e,t){return e.stylesheets&&e.count===0&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&th===0&&(th=62500*cp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>th?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)sh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ih(){this.count--,rh(this)}function ah(){this.imgCount--,rh(this)}var oh=null;function sh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oh=new Map,t.forEach(ch,e),oh=null,ih.call(e))}function ch(e,t){if(!(t.state.loading&4)){var n=oh.get(e);if(n)var r=n.get(null);else{n=new Map,oh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ih.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lh={$$typeof:N,Provider:null,Consumer:null,_currentValue:ve,_currentValue2:ve,_threadCount:0};function uh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function dh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new uh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ni(3,null,null,t),e.current=a,a.stateNode=e,t=Oa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},co(a),e}function fh(e){return e?(e=ji,e):ji}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=uo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=fo(e,r,t),n!==null&&(Nd(n,e,t),po(n,e,t))}function mh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hh(e,t){mh(e,t),(e=e.alternate)&&mh(e,t)}function gh(e){if(e.tag===13||e.tag===31){var t=Oi(e,67108864);t!==null&&Nd(t,e,67108864),hh(e,67108864)}}function _h(e){if(e.tag===13||e.tag===31){var t=Ad();t=yt(t);var n=Oi(e,t);n!==null&&Nd(n,e,t),hh(e,t)}}var vh=!0;function yh(e,t,n,r){var i=P.T;P.T=null;var a=_e.p;try{_e.p=2,xh(e,t,n,r)}finally{_e.p=a,P.T=i}}function bh(e,t,n,r){var i=P.T;P.T=null;var a=_e.p;try{_e.p=8,xh(e,t,n,r)}finally{_e.p=a,P.T=i}}function xh(e,t,n,r){if(vh){var i=Sh(r);if(i===null)qf(e,t,r,Ch,n),Ph(e,r);else if(Ih(i,e,t,n,r))r.stopPropagation();else if(Ph(e,r),t&4&&-1<Nh.indexOf(e)){for(;i!==null;){var a=Ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=st(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-et(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Ue()+500,Df(0,!1))}}break;case 31:case 13:s=Oi(a,2),s!==null&&Nd(s,a,2),Rd(),hh(a,2)}if(a=Sh(r),a===null&&qf(e,t,r,Ch,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else qf(e,t,r,null,n)}}function Sh(e){return e=Cn(e),wh(e)}var Ch=null;function wh(e){if(Ch=null,e=Pt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ch=e,null}function Th(e){switch(e){case`beforetoggle`: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`seeked`:case`submit`:case`toggle`: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`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(We()){case I:return 2;case Ge:return 8;case Ke:case qe:return 32;case Je:return 268435456;default:return 32}default:return 32}}var Eh=!1,Dh=null,Oh=null,kh=null,Ah=new Map,jh=new Map,Mh=[],Nh=`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`.split(` `);function Ph(e,t){switch(e){case`focusin`:case`focusout`:Dh=null;break;case`dragenter`:case`dragleave`:Oh=null;break;case`mouseover`:case`mouseout`:kh=null;break;case`pointerover`:case`pointerout`:Ah.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jh.delete(t.pointerId)}}function Fh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ft(t),t!==null&&gh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ih(e,t,n,r,i){switch(t){case`focusin`:return Dh=Fh(Dh,e,t,n,r,i),!0;case`dragenter`:return Oh=Fh(Oh,e,t,n,r,i),!0;case`mouseover`:return kh=Fh(kh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ah.set(a,Fh(Ah.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jh.set(a,Fh(jh.get(a)||null,e,t,n,r,i)),!0}return!1}function Lh(e){var t=Pt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,St(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,St(e.priority,function(){_h(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Sn=r,n.target.dispatchEvent(r),Sn=null}else return t=Ft(n),t!==null&&gh(t),e.blockedOn=n,!1;t.shift()}return!0}function zh(e,t,n){Rh(e)&&n.delete(t)}function Bh(){Eh=!1,Dh!==null&&Rh(Dh)&&(Dh=null),Oh!==null&&Rh(Oh)&&(Oh=null),kh!==null&&Rh(kh)&&(kh=null),Ah.forEach(zh),jh.forEach(zh)}function Vh(e,n){e.blockedOn===n&&(e.blockedOn=null,Eh||(Eh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bh)))}var Hh=null;function Uh(e){Hh!==e&&(Hh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hh===e&&(Hh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wh(r||n)===null)continue;break}var a=Ft(n);a!==null&&(e.splice(t,3),t-=3,qs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wh(e){function t(t){return Vh(t,e)}Dh!==null&&Vh(Dh,e),Oh!==null&&Vh(Oh,e),kh!==null&&Vh(kh,e),Ah.forEach(t),jh.forEach(t);for(var n=0;n<Mh.length;n++){var r=Mh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mh.length&&(n=Mh[0],n.blockedOn===null);)Lh(n),n.blockedOn===null&&Mh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Tt]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Tt]||null)s=o.formAction;else if(wh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Uh(n)}}}function Gh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kh(e){this._internalRoot=e}qh.prototype.render=Kh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;ph(n,Ad(),e,t,null,null)},qh.prototype.unmount=Kh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ph(e.current,2,null,e,null,null),Rd(),t[Et]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=xt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mh.length&&t!==0&&t<Mh[n].priority;n++);Mh.splice(n,0,e),n===0&&Lh(e)}};var Jh=n.version;if(Jh!==`19.3.1`)throw Error(o(527,Jh,`19.3.1`));_e.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Yh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xh.isDisabled&&Xh.supportsFiber)try{Ze=Xh.inject(Yh),Qe=Xh}catch{}}e.createRoot=function(e,t){if(!c(e))throw Error(o(299));var n=!1,r=``,i=gc,a=_c,s=vc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=dh(e,1,!1,null,null,n,r,null,i,a,s,Gh),e[Et]=t.current,Gf(e),new Kh(t)}})),l=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=c()})),u=e(r(),1),d=l(),f=`entry`,p=`sp-remote:`;function m(e,t){return e===`entry`?t:`${p}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function h(e){if(!e.startsWith(p))return{server:f,id:e};let t=e.indexOf(`:`,10);if(t<0)throw Error(`服务器资源标识无效`);return{server:decodeURIComponent(e.slice(10,t)),id:decodeURIComponent(e.slice(t+1))}}var g=new Set([`workspaceId`,`conversationId`,`contextConversationId`,`messageId`,`sessionId`,`runId`,`taskId`,`parentConversationId`,`originMessageId`,`followedWorktreeId`,`worktreeOf`,`ownerConversationId`,`parentRunId`,`projectId`,`roomId`,`topicId`,`entityId`,`sourceConversationId`,`targetConversationId`,`forkedId`,`checkoutId`,`replyToMessageId`,`parentMessageId`,`replyTo`,`activate`]),_=new Set([`workspaces`,`conversations`,`messages`,`subagentRuns`,`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`rooms`,`topics`,`run`,`workflow`,`room`,`task`,`conversation`,`workspace`,`withdrawn`,`terminals`,`sessions`,`tools`,`projects`]),v=new Set([`collapsedConversationIds`,`unlockedChildConversationIds`,`stoppingConversationIds`,`conversationIds`,`workspaceIds`,`messageIds`]),y=new Set([`todosByConversation`,`pendingUserDecisionsByConversation`]),b=new Set([`args`,`arguments`,`parameters`,`schema`,`result`,`providers`,`images`,`attachments`,`toolCalls`,`defaultModel`,`model`,`agents`]);function x(e,t,n=``){return Array.isArray(e)?e.map(e=>x(e,t,n)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([r,i])=>typeof i==`string`&&i.length>0&&(g.has(r)||(r===`id`||r===`execution`)&&i.startsWith(p)||r===`id`&&(_.has(n)||`workspaceId`in e||`conversationId`in e||e.type===`group.activity`))?[r,t(i)]:v.has(r)&&Array.isArray(i)?[r,i.map(e=>typeof e==`string`?t(e):e)]:y.has(r)&&i&&typeof i==`object`?[r,Object.fromEntries(Object.entries(i).map(([e,n])=>[t(e),n]))]:b.has(r)?[r,i]:[r,x(i,t,r)]))}function S(e){let t=new Set;return x(e,e=>(t.add(h(e).server),e)),t}var C=`super-pi.server-connections.v1`,w=`super-pi.server-credentials.v1`,T=globalThis.fetch.bind(globalThis),E=typeof location>`u`?`http://localhost`:location.origin,D=[{id:f,name:`当前入口`,url:E,enabled:!0}],O={};try{let e=JSON.parse(localStorage.getItem(C)??`[]`);D=[{...D[0],name:e.find(e=>e.id===`entry`)?.name||`当前入口`},...e.filter(e=>e.id!==f)],O=JSON.parse(localStorage.getItem(w)??`{}`)}catch{}var k=f,A=f,j=!1,ee=new Map,M=new Set;function te(e){if(!e)return!1;let t=h(e).server;return D.some(e=>e.id===t)&&!M.has(t)}var N=0,ne=new Set,re=new Map,ie=new Map,ae=()=>{N++;for(let e of ne)e()},oe=e=>(ne.add(e),()=>{ne.delete(e)});function se(){return(0,u.useSyncExternalStore)(oe,()=>N),{connections:D,statuses:re,activeServer:k,settingsServer:A,settingsSnapshot:ee.get(A)}}function ce(e){return e?h(e).server:k}function le(){return k}function ue(){return A}function de(e){if(!D.some(t=>t.id===e))throw Error(`目标服务器已移除`);A!==e&&(A=e,ae(),window.dispatchEvent(new Event(`super-pi-settings-server`)))}function fe(){j=!0,de(k)}function pe(){j=!1,de(k)}function me(e){return D.find(t=>t.id===e)?.name??`未知服务器`}function he(e){return me(h(e).server)}function ge(e){if(e!==k){if(!D.some(t=>t.id===e))throw Error(`服务器已被移除`);k=e,j||de(e),ae(),window.dispatchEvent(new Event(`super-pi-active-server`))}}function P(){localStorage.setItem(C,JSON.stringify(D)),localStorage.setItem(w,JSON.stringify(O)),ae(),window.dispatchEvent(new Event(`super-pi-server-connections`))}function _e(e,t){if(!t.trim())throw Error(`服务器名称不能为空`);if(D.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在,请使用容易区分的名称`);D=D.map(n=>n.id===e?{...n,name:t.trim()}:n),P()}function ve(e){if(e===`entry`)return;let t=k===e;D=D.filter(t=>t.id!==e),delete O[e],ie.delete(e),t&&(k=f),A===e&&de(f),P(),t&&window.dispatchEvent(new Event(`super-pi-active-server`))}function ye(e,t){D=D.map(n=>n.id===e?{...n,enabled:t}:n),P()}async function be(e,t,n){let r=new URL(t);if(![`http:`,`https:`].includes(r.protocol)||r.username||r.password||r.search||r.hash||r.pathname!==`/`)throw Error(`请输入 http(s)://主机:端口,不能包含路径或凭证`);if(location.protocol===`https:`&&r.protocol===`http:`)throw Error(`HTTPS 页面无法连接 HTTP 服务,请为目标服务启用 HTTPS,或从 HTTP 入口访问`);if(!e.trim()||!n.trim())throw Error(`请填写服务器名称和连接密钥`);if(D.some(t=>t.name===e.trim()))throw Error(`服务器名称已存在,请使用不同的名称`);let i=await xe(r.origin,n.trim());if(!i.ok)throw Error(`连接失败(${i.status}),请检查服务版本、地址和连接密钥`);let a=await i.json();if(a.protocol!==1||typeof a.id!=`string`)throw Error(`目标服务不支持多服务端协议,请先更新目标服务`);if(D.some(e=>e.url===r.origin||e.identity===a.id))throw Error(`这台服务器已经添加`);let o=await T(`/api/browser-access`).then(e=>e.json()).catch(()=>void 0);if(a.id===o?.id)throw Error(`这是当前入口服务器,无需重复添加`);let s=crypto.randomUUID();return O[s]=n.trim(),D=[...D,{id:s,name:e.trim(),url:r.origin,enabled:!0,identity:a.id}],P(),s}async function xe(e,t){try{return await T(`${e}/api/browser-access`,{headers:{authorization:`Bearer ${t}`},signal:AbortSignal.timeout(15e3),credentials:`omit`})}catch(e){throw Error(e instanceof Error&&e.name===`TimeoutError`?`连接超时,请检查目标服务器是否启动、端口是否开放`:`浏览器无法连接目标服务器,请检查地址、网络可达性、HTTPS 证书,以及目标是否已更新到支持多服务端的版本`)}}async function Se(e,t,n,r){let i=Ce(e),a=new URL(n);if(![`http:`,`https:`].includes(a.protocol)||a.username||a.password||a.search||a.hash||a.pathname!==`/`)throw Error(`请输入不包含路径或凭证的 HTTP(S) 服务地址`);if(location.protocol===`https:`&&a.protocol===`http:`)throw Error(`HTTPS 页面不能连接 HTTP 服务`);if(!t.trim())throw Error(`请输入服务器名称`);if(D.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在`);let o=r.trim()||O[e],s=await xe(a.origin,o);if(!s.ok)throw Error(`连接失败(${s.status}),请检查地址和密钥`);let c=await s.json();if(c.protocol!==1||c.id!==i.identity)throw Error(`地址指向另一台服务器,请使用“添加服务器”,以保护现有资源和标签的归属`);O[e]=o,D=D.map(n=>n.id===e?{...n,name:t.trim(),url:a.origin,revision:(n.revision??0)+1}:n),ie.delete(e),P()}function Ce(e){let t=D.find(t=>t.id===e);if(!t||!t.enabled)throw Error(`目标服务器已移除或停用,操作未发送`);return t}function we(e,t){return new URL(`${e.url.replace(/\/$/,``)}${t.startsWith(`/`)?t:`/${t}`}`)}async function Te(){try{let e=await T(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)});if(!e.ok)return;let t=await e.json();if(!t.available||!Array.isArray(t.connections))return;let n=t.connections.map(e=>({...e,url:new URL(e.url,E).href})),r=[...D.filter(e=>!e.managed),...n];if(JSON.stringify(r)!==JSON.stringify(D)){D=r;let e=!D.some(e=>e.id===k);e&&(k=f),D.some(e=>e.id===A)||de(f),P(),e&&window.dispatchEvent(new Event(`super-pi-active-server`))}}catch{}}function Ee(e,t=k){let n=S(e);if(n.size>1)throw Error(`一次操作不能混用不同服务器的资源`);return[...n][0]??t}function De(e,t){return x(e,e=>{let n=h(e);if(n.server!==t)throw Error(`资源不属于目标服务器`);return n.id})}function Oe(e){let t=/^(\/api\/upload\/|\/api\/projects\/|\/tools\/)([^/]+)(.*)$/.exec(e.pathname);if(!t)return{path:e.pathname};let n=h(decodeURIComponent(t[2]));return{server:n.server,path:`${t[1]}${encodeURIComponent(n.id)}${t[3]}`}}function ke(e){let t=new URL(e,location.origin);if(D.some(e=>e.managed&&t.href.startsWith(`${e.url}/`))||t.origin!==location.origin)return e;let n=Object.fromEntries(t.searchParams),r=Oe(t),i=Ee(n,r.server??k),a=Ce(i);for(let[e,r]of Object.entries(De(n,i)))t.searchParams.set(e,r);if(i===`entry`)return`${r.path}${t.search}${t.hash}`;let o=we(a,`${r.path}${t.search}${t.hash}`),s=ie.get(i);return s&&!a.managed&&o.searchParams.set(`browserAsset`,s),o.href}async function Ae(e,t,n){if(typeof e!=`string`&&!(e instanceof URL))throw Error(`服务器请求必须使用明确的 URL`);let r=new URL(String(e),location.origin),i=D.find(e=>e.managed&&r.href.startsWith(`${e.url}/`));if(i){if(n&&n!==i.id)throw Error(`资源不属于指定的服务器`);return Me(i.id,r,t)}if(r.origin!==location.origin){let n=D.find(e=>e.url===r.origin);return n?(r.searchParams.delete(`browserAsset`),Me(n.id,r,t)):T(e,t)}if(!r.pathname.startsWith(`/api/`))return T(e,t);let a;if(typeof t?.body==`string`)try{a=JSON.parse(t.body)}catch{}t?.body instanceof FormData&&(a=Object.fromEntries([...t.body].filter(([,e])=>typeof e==`string`)));let o=Oe(r),s=Ee({...Object.fromEntries(r.searchParams),payload:a},o.server??n??k);if(n&&n!==s)throw Error(`资源不属于指定的服务器`);if(o.server&&o.server!==s)throw Error(`路径和参数属于不同服务器`);let c=Ce(s);for(let[e,t]of Object.entries(De(Object.fromEntries(r.searchParams),s)))r.searchParams.set(e,t);let l=t;if(typeof t?.body==`string`&&a&&(l={...t,body:JSON.stringify(De(a,s))}),t?.body instanceof FormData){let e=new FormData,n=De(a,s);for(let[r,i]of t.body)e.append(r,typeof i==`string`?n[r]:i);l={...t,body:e}}return Me(s,we(c,`${o.path}${r.search}`),l)}function je(e,t){return Ae(e,t,A)}async function Me(e,t,n){let r=Ce(e),i=new Headers(n?.headers);e!==`entry`&&!r.managed&&i.set(`authorization`,`Bearer ${O[e]??``}`);let a=await T(e===`entry`?`${t.pathname}${t.search}`:t.href,{...n,headers:i,...e!==`entry`&&!r.managed?{credentials:`omit`}:{}});if(e===`entry`||!a.headers.get(`content-type`)?.includes(`application/json`))return a;let o=a.json.bind(a);return a.json=async()=>x(await o(),t=>m(e,t)),a}var Ne=new Set([`model.catalog`,`model.catalog.all`,`providers.list`,`agent.catalog`,`prompt.catalog`,`subagent.catalog`,`server.version`,`terminal.status`,`exec.status`]),Pe=class{focus;onserveropen=null;ondisconnect=null;onopen=null;onclose=null;onmessage=null;onerror=null;sockets=new Map;snapshots=new Map;catalogs=new Map;timers=new Map;connecting=new Set;socketRevisions=new Map;leaseTimers=new Map;terminalServer=f;stopped=!1;constructor(e){this.focus=e,window.addEventListener(`super-pi-server-connections`,this.reconfigure),window.addEventListener(`super-pi-active-server`,this.activate),window.addEventListener(`super-pi-settings-server`,this.activateSettings),queueMicrotask(this.reconfigure),Te(),this.managementTimer=setInterval(()=>{Te()},3e3)}managementTimer;get readyState(){return this.sockets.get(k)?.readyState??WebSocket.CLOSED}deliver(e){this.onmessage?.({data:JSON.stringify(e)})}aggregate(){let e=this.snapshots.get(k),t=[...this.snapshots.values()],n={...e,workspaces:t.flatMap(e=>e.workspaces),conversations:t.flatMap(e=>e.conversations),subagentRuns:t.flatMap(e=>e.subagentRuns)};for(let e of[`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`extensionUi`,`stoppingConversationIds`,`collapsedConversationIds`,`unlockedChildConversationIds`])n[e]=t.flatMap(t=>t[e]??[]);for(let e of[`todosByConversation`,`pendingUserDecisionsByConversation`])n[e]=Object.assign({},...t.map(t=>t[e]));t.length&&this.deliver({type:`state`,state:n})}activate=()=>{this.aggregate(),this.deliver({type:`server.version`,version:{runningVersion:``,diskVersion:``,needsRestart:!1}});let e={source:`unavailable`,models:[],levels:[],agents:[],problems:[],directory:``,prompts:[],workspaceId:``,skills:[],commands:[],fetchedAt:new Date().toISOString()};for(let t of[`model.catalog`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`,`prompt.catalog`])this.deliver({type:t,catalog:e});for(let[e,t]of this.catalogs.get(k)??[])[`providers.list`,`model.catalog.all`].includes(e)||this.deliver({...t,sourceServerId:k});let t=this.sockets.get(k);if(t?.readyState===WebSocket.OPEN){this.onopen?.();for(let e of[`catalog.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])t.send(JSON.stringify({type:e}))}this.activateSettings()};activateSettings=()=>{for(let e of[`agent.catalog`,`subagent.catalog`])this.deliver({type:e,catalog:{source:`unavailable`,agents:[],problems:[],directory:``,fetchedAt:``},sourceServerId:A});this.deliver({type:`model.catalog.all`,catalog:{source:`unavailable`,models:[],levels:[],fetchedAt:``},sourceServerId:A}),this.deliver({type:`providers.list`,providers:[],apis:[],sourceServerId:A});for(let[e,t]of this.catalogs.get(A)??[])[`providers.list`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`].includes(e)&&this.deliver({...t,sourceServerId:A});let e=this.sockets.get(A);if(e?.readyState===WebSocket.OPEN)for(let t of[`catalog.fetchAll`,`providers.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])e.send(JSON.stringify({type:t}))};reconfigure=()=>{for(let e of this.snapshots.keys())D.some(t=>t.id===e)||(this.snapshots.delete(e),ee.delete(e),this.catalogs.delete(e),re.delete(e),M.delete(e));for(let[e,t]of this.sockets)D.some(t=>t.id===e&&t.enabled&&(t.revision??0)===this.socketRevisions.get(e))||(this.sockets.delete(e),t.close(),clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),D.some(t=>t.id===e)||(this.snapshots.delete(e),M.delete(e)));for(let e of D)e.enabled||re.set(e.id,{state:`disabled`}),e.enabled&&!this.sockets.has(e.id)&&!this.connecting.has(e.id)&&this.connect(e.id);this.aggregate()};async connect(e,t=0){if(!(this.stopped||this.sockets.has(e)||!D.some(t=>t.id===e&&t.enabled))){this.connecting.add(e),re.set(e,{state:`connecting`}),ae();try{let n=Ce(e);if(e!==`entry`){let t=await Me(e,we(n,`/api/browser-access`),{signal:AbortSignal.timeout(15e3)});if(!t.ok)throw Error(`授权或连接失败(${t.status})`);let r=await t.json();if(r.id!==n.identity||r.protocol!==1)throw Error(`服务器身份或协议发生变化,请重新添加连接`);ie.set(e,r.assetLease)}if(this.stopped||!D.some(t=>t.id===e&&t.enabled))return;let r=we(n,`/ws?state=focused`);r.protocol=r.protocol===`https:`?`wss:`:`ws:`,this.focus&&h(this.focus).server===e&&r.searchParams.set(`conversationId`,h(this.focus).id);let i=e===`entry`||n.managed?new WebSocket(r):new WebSocket(r,[`super-pi`,`super-pi-key.${O[e]}`]),a=!1;this.sockets.set(e,i),this.socketRevisions.set(e,n.revision??0),i.onopen=()=>{a=!0,re.set(e,{state:`online`}),ae(),i.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),e===k&&this.onopen?.(),this.onserveropen?.(e),e!==`entry`&&this.leaseTimers.set(e,setInterval(()=>{Me(e,we(n,`/api/browser-access`)).then(e=>e.json()).then(t=>{t.assetLease&&(ie.set(e,t.assetLease),ae())}).catch(()=>{})},9e5))},i.onmessage=({data:t})=>{let n=x(JSON.parse(String(t)),t=>m(e,t));if(n.type===`state`)M.add(e),this.snapshots.set(e,n.state),ee.set(e,n.state),this.aggregate();else{if(Ne.has(n.type)){let t=this.catalogs.get(e)??new Map;t.set(n.type,n),this.catalogs.set(e,t);let r=[`providers.list`,`model.catalog.all`].includes(n.type),i=[`agent.catalog`,`subagent.catalog`].includes(n.type);if(r?e!==A:e!==k&&!(i&&e===A))return}this.deliver({...n,sourceServerId:e})}},i.onclose=()=>{this.stopped||this.sockets.get(e)!==i||(clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),this.sockets.delete(e),re.set(e,{state:`offline`,error:`连接中断,正在重连`}),ae(),a&&this.ondisconnect?.(e),this.retry(e,a?1:t+1))},i.onerror=()=>{}}catch(n){re.set(e,{state:`offline`,error:n instanceof Error?n.message:`连接失败`}),ae(),this.retry(e,t+1)}finally{this.connecting.delete(e)}}}retry(e,t){clearTimeout(this.timers.get(e)),this.timers.set(e,setTimeout(()=>{this.timers.delete(e),this.connect(e,t)},Math.min(3e4,1e3*2**Math.min(t,5))))}send(e){let t=JSON.parse(e),n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`,r=typeof t._server==`string`?t._server:void 0,i=Ee(t,r??(n?this.terminalServer:k));if(r&&i!==r)throw Error(`命令资源不属于指定服务器`);delete t._server;let a=this.sockets.get(i);if(!a||a.readyState!==WebSocket.OPEN)throw Error(`${me(i)} 未连接,操作未发送`);t.type===`state.subscribe`&&(this.focus=t.conversationId),t.type===`terminal.sync`&&(this.terminalServer=i),a.send(JSON.stringify(De(t,i)))}canSend(e){try{let t=e,n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`?this.terminalServer:k,r=Ee(e,t._server??n);return(!t._server||r===t._server)&&this.sockets.get(r)?.readyState===WebSocket.OPEN}catch{return!1}}close(){this.stopped=!0,clearInterval(this.managementTimer),window.removeEventListener(`super-pi-server-connections`,this.reconfigure),window.removeEventListener(`super-pi-active-server`,this.activate),window.removeEventListener(`super-pi-settings-server`,this.activateSettings);for(let e of this.timers.values())clearTimeout(e);for(let e of this.leaseTimers.values())clearInterval(e);for(let e of this.sockets.values())e.close()}},Fe=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ie=t(((e,t)=>{t.exports=Fe()})),F=Ie(),Le=()=>({name:``,host:``,sshPort:22,username:``,servicePort:3080,authentication:`password`}),Re={offline:`未连接`,connecting:`连接中`,online:`已连接`,needsTrust:`等待确认指纹`};function ze(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(Le),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(new Set),g=async()=>{let e=await Ae(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)},f),n=await e.json();return r(e.ok&&n.available===!0),Array.isArray(n.profiles)&&t(n.profiles),n};(0,u.useEffect)(()=>{let e=!1,t=()=>{e||g().catch(()=>{e||r(!1)})};t();let n=setInterval(t,2e3);return()=>{e=!0,clearInterval(n)}},[]);let _=async e=>{let n=await Ae(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(3e4)},f),r=await n.json();if(Array.isArray(r.profiles)&&t(r.profiles),Te(),!n.ok)throw Error(r.error??`操作失败`);return r},v=async(e,t,n={})=>{s(!0),l(``);try{await _({id:e,action:t,...n})}catch(e){l(e instanceof Error?e.message:`操作失败`)}finally{s(!1)}},y=e=>{a({id:e.id,name:e.name,host:e.host,username:e.username,sshPort:e.sshPort,servicePort:e.servicePort,authentication:e.authentication,identityFile:e.identityFile}),p(!0),l(``)};return n===!1?(0,F.jsxs)(`div`,{className:`server-managed-unavailable`,children:[(0,F.jsx)(`h4`,{children:`请使用本地完整安装开启 SSH 托管`}),(0,F.jsxs)(`p`,{children:[`运行 `,(0,F.jsx)(`code`,{children:`super_pi desktop`}),` 打开桌面端,或在自己的电脑启动完整包,再通过本机网页访问。纯服务包只负责远端执行,不保存其他服务器的 SSH 资料。`]})]}):(0,F.jsxs)(`div`,{className:`managed-servers-panel`,"data-managed-servers":`1`,children:[(0,F.jsx)(`p`,{className:`server-description`,children:`预览功能:SSH 自动部署仍在完善跨平台兼容性。部署失败时可查看下方日志并重试;已有服务也可以使用“已有服务直接连接”。`}),(0,F.jsxs)(`div`,{className:`managed-overview`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{children:`本地配置,统一接入`}),(0,F.jsx)(`p`,{children:`填写 SSH 信息后,自动安装轻量服务、建立隧道并接入工作台。远端使用本地配置和登录的模型,无需逐台打开网页。`}),(0,F.jsx)(`small`,{children:`SSH 资料保存在当前入口服务所在的电脑;推荐通过桌面端或本机网页管理。模型调用时本地管理服务需在线。`})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{de(f),window.dispatchEvent(new Event(`super-pi-open-local-model-settings`))},children:`配置本地模型`})]}),(0,F.jsxs)(`div`,{className:`managed-toolbar`,children:[(0,F.jsxs)(`span`,{children:[e.length,` 台服务器`]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void v(``,`syncAll`),children:`同步全部模型目录`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{a(Le()),p(!0)},children:`+ 添加 SSH 服务器`})]})]}),n===void 0&&(0,F.jsx)(`p`,{role:`status`,children:`正在读取本地托管配置…`}),e.length===0&&!d&&(0,F.jsxs)(`div`,{className:`managed-empty`,children:[(0,F.jsx)(`strong`,{children:`尚未添加服务器`}),(0,F.jsx)(`p`,{children:`只需要提供 SSH 访问方式和希望使用的服务端口。通过 SSH 隧道访问时,无需向外网开放这个端口。`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>p(!0),children:`添加并部署第一台服务器`})]}),(0,F.jsx)(`div`,{className:`managed-server-list`,children:e.map(e=>(0,F.jsxs)(`section`,{className:`managed-server-card`,"data-managed-server":e.id,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{children:e.name}),(0,F.jsxs)(`small`,{children:[e.username,`@`,e.host,`:`,e.sshPort,` · Super Pi `,e.servicePort]})]}),(0,F.jsx)(`span`,{className:`managed-phase`,"data-phase":e.phase,children:e.enabled?e.phase===`deploying`?`部署中`:e.phase===`ready`?`可使用`:e.phase===`needsTrust`?`待确认`:e.phase===`failed`?`需要处理`:e.enabled?`待连接`:`已停用`:`已停用`})]}),(0,F.jsxs)(`dl`,{className:`managed-connectivity`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`SSH`}),(0,F.jsx)(`dd`,{children:Re[e.ssh]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`远端服务`}),(0,F.jsx)(`dd`,{children:e.service===`online`?`已启动`:e.service===`offline`?`不可达`:`尚未部署`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`模型通道`}),(0,F.jsx)(`dd`,{children:e.modelChannel===`online`?`已连接本地`:`未连接`})]})]}),e.phase===`deploying`&&(0,F.jsxs)(`div`,{className:`managed-progress`,role:`status`,children:[(0,F.jsx)(`progress`,{"aria-label":`远端部署进度`}),(0,F.jsx)(`span`,{children:e.step})]}),e.error&&(0,F.jsx)(`p`,{className:`server-connection-error`,role:`status`,children:e.error}),e.observedFingerprint&&(0,F.jsxs)(`div`,{className:`managed-host-trust`,children:[(0,F.jsx)(`strong`,{children:e.fingerprint?`主机指纹已变化`:`首次连接:确认 SSH 主机指纹`}),(0,F.jsx)(`code`,{children:e.observedFingerprint}),(0,F.jsx)(`small`,{children:`请与服务器管理员或已有 SSH 记录核对;确认后才会安装或执行远端命令。`}),(0,F.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0),l(``);try{await _({action:`trust`,id:e.id,fingerprint:e.observedFingerprint}),m.has(e.id)&&(await _({action:`deploy`,id:e.id}),h(t=>new Set([...t].filter(t=>t!==e.id))))}catch(e){l(e instanceof Error?e.message:`连接失败`)}finally{s(!1)}},children:m.has(e.id)?`确认指纹并继续部署`:`信任此主机并连接`})]}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`||!e.fingerprint,onClick:()=>void v(e.id,`deploy`),children:e.deployedAt?`重新部署/升级`:`一键安装并接入`}),(0,F.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void v(e.id,e.enabled&&e.ssh===`online`?`disconnect`:`connect`),children:e.enabled&&e.ssh===`online`?`断开 SSH`:`检测/连接`}),(0,F.jsx)(`button`,{type:`button`,disabled:o||e.service!==`online`,onClick:()=>void v(e.id,`sync`),children:`同步模型`}),(0,F.jsx)(`button`,{type:`button`,disabled:e.phase===`deploying`,onClick:()=>y(e),children:`编辑`}),(0,F.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void v(e.id,`remove`),children:`移除连接`})]}),(e.log?.length||e.remoteRoot)&&(0,F.jsxs)(`details`,{className:`managed-diagnostics`,children:[(0,F.jsx)(`summary`,{children:`部署记录与日志位置`}),e.remoteRoot&&(0,F.jsxs)(`p`,{children:[`远端目录:`,(0,F.jsx)(`code`,{children:e.remoteRoot}),(0,F.jsx)(`br`,{}),`服务日志:`,(0,F.jsxs)(`code`,{children:[e.remoteRoot,`/service.log`]})]}),e.log?.length?(0,F.jsx)(`pre`,{children:e.log.join(`
|
|
11
|
+
`)}):null]})]},e.id))}),d&&(0,F.jsxs)(`form`,{className:`managed-server-form`,onSubmit:async e=>{e.preventDefault(),s(!0),l(``);try{let e=(await _({action:`save`,profile:i})).profiles.find(e=>e.name===i.name.trim());h(t=>new Set(t).add(e.id)),p(!1),a(Le()),await _({action:`test`,id:e.id}),await _({action:`deploy`,id:e.id}),h(t=>new Set([...t].filter(t=>t!==e.id)))}catch(e){l(e instanceof Error?e.message:`无法保存连接`)}finally{s(!1)}},children:[(0,F.jsx)(`h4`,{children:i.id?`编辑 SSH 连接`:`添加 SSH 服务器`}),(0,F.jsxs)(`div`,{className:`managed-form-grid`,children:[(0,F.jsxs)(`label`,{children:[`显示名称`,(0,F.jsx)(`input`,{required:!0,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:`例如:开发服务器`})]}),(0,F.jsxs)(`label`,{children:[`SSH 地址`,(0,F.jsx)(`input`,{required:!0,value:i.host,onChange:e=>a({...i,host:e.target.value}),placeholder:`IP 或主机名`})]}),(0,F.jsxs)(`label`,{children:[`SSH 端口`,(0,F.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.sshPort,onChange:e=>a({...i,sshPort:Number(e.target.value)})})]}),(0,F.jsxs)(`label`,{children:[`SSH 用户名`,(0,F.jsx)(`input`,{required:!0,value:i.username,onChange:e=>a({...i,username:e.target.value}),autoComplete:`off`})]}),(0,F.jsxs)(`label`,{children:[`Super Pi 端口`,(0,F.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.servicePort,onChange:e=>a({...i,servicePort:Number(e.target.value)})}),(0,F.jsx)(`small`,{children:`远端回环端口,不需要额外开放防火墙。`})]}),(0,F.jsxs)(`label`,{children:[`认证方式`,(0,F.jsxs)(`select`,{value:i.authentication,onChange:e=>a({...i,authentication:e.target.value}),children:[(0,F.jsx)(`option`,{value:`password`,children:`SSH 密码`}),(0,F.jsx)(`option`,{value:`privateKey`,children:`SSH 私钥`}),(0,F.jsx)(`option`,{value:`agent`,children:`本地 SSH Agent`})]})]})]}),i.authentication===`password`&&(0,F.jsxs)(`label`,{children:[`SSH 密码`,(0,F.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.password??``,placeholder:i.id?`留空保留已有密码`:``,required:!i.id,onChange:e=>a({...i,password:e.target.value})})]}),i.authentication===`privateKey`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{children:[`本地私钥文件路径`,(0,F.jsx)(`input`,{value:i.identityFile??``,placeholder:`管理电脑上的私钥绝对路径`,onChange:e=>a({...i,identityFile:e.target.value})})]}),(0,F.jsxs)(`details`,{children:[(0,F.jsx)(`summary`,{children:`或者粘贴私钥`}),(0,F.jsx)(`textarea`,{rows:4,value:i.privateKey??``,onChange:e=>a({...i,privateKey:e.target.value}),spellCheck:!1})]}),(0,F.jsxs)(`label`,{children:[`私钥口令(如有)`,(0,F.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.passphrase??``,onChange:e=>a({...i,passphrase:e.target.value})})]})]}),i.authentication===`agent`&&(0,F.jsx)(`small`,{children:`使用管理电脑当前用户的 SSH Agent;需提前将对应密钥加入 Agent。`}),(0,F.jsx)(`small`,{children:`认证资料在本地管理服务加密保存,不返回浏览器。远端安装在用户目录,不需要 sudo;当前自动部署支持 Linux/macOS 的 x64、arm64。`}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`submit`,disabled:o,children:o?`正在保存和检测…`:`保存并部署`}),(0,F.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(Le()),p(!1)},children:`取消`})]})]}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`server-connection-error`,children:c})]})}function Be({workspaces:e}){let{connections:t}=se();return(0,F.jsx)(F.Fragment,{children:t.map(t=>{let n=e.filter(e=>h(e.id).server===t.id);return n.length?(0,F.jsx)(`optgroup`,{label:t.name,children:n.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))},t.id):null})})}function Ve(){let{connections:e,settingsServer:t,statuses:n}=se();return(0,F.jsxs)(`div`,{className:`server-settings-scope`,children:[(0,F.jsxs)(`label`,{children:[`设置目标服务器 `,(0,F.jsx)(`select`,{"aria-label":`设置目标服务器`,value:t,onChange:e=>de(e.target.value),children:e.filter(e=>e.enabled).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,F.jsxs)(`small`,{children:[`服务端设置仅应用于此服务器;外观和通知属于当前浏览器。`,n.get(t)?.state===`offline`?` 当前服务器离线。`:``]})]})}function He(){let{connections:e,statuses:t,settingsServer:n}=se(),r=e.find(e=>e.id===n)?.managed,[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(!1);(0,u.useEffect)(()=>{v(``),g(``),je(`/api/browser-access`).then(e=>e.json()).then(e=>b(e.enabled)).catch(()=>g(`无法读取服务器授权设置`))},[n]);let x=async e=>{m(!0),g(``);try{let t=await je(`/api/browser-access`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:e})}),n=await t.json();if(!t.ok)throw Error(n.error);b(n.enabled),v(n.key??``)}catch(e){g(e instanceof Error?e.message:`授权设置失败`)}finally{m(!1)}};return(0,F.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,F.jsx)(`p`,{className:`server-description`,children:`当前浏览器直接连接每台服务器。关闭一个连接不会停止那台服务器上的任务。连接配置仅保存在当前浏览器。`}),(0,F.jsx)(`div`,{className:`server-connection-list`,children:e.filter(e=>!e.managed).map(e=>(0,F.jsxs)(`section`,{className:`server-connection-card`,children:[(0,F.jsxs)(`div`,{className:`server-connection-heading`,children:[(0,F.jsx)(`strong`,{children:e.name}),(0,F.jsx)(`span`,{"data-server-status":t.get(e.id)?.state??`disabled`,children:e.enabled?{online:`已连接`,connecting:`连接中`,offline:`离线`,disabled:`已停用`}[t.get(e.id)?.state??`connecting`]:`已停用`})]}),(0,F.jsxs)(`small`,{children:[e.url,e.id===`entry`?` · 网页入口`:``]}),t.get(e.id)?.error&&e.enabled&&(0,F.jsx)(`p`,{role:`status`,children:t.get(e.id)?.error}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>de(e.id),disabled:!e.enabled||n===e.id,children:n===e.id?`当前设置目标`:`管理此服务器`}),(0,F.jsxs)(`label`,{children:[`名称 `,(0,F.jsx)(`input`,{"aria-label":`${e.name}的服务器名称`,defaultValue:e.name,onBlur:t=>{try{_e(e.id,t.target.value),g(``)}catch(n){g(n instanceof Error?n.message:`名称修改失败`),t.target.value=e.name}}})]}),e.id!==`entry`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>ye(e.id,!e.enabled),children:e.enabled?`断开`:`连接`}),(0,F.jsx)(`button`,{type:`button`,disabled:!e.enabled,onClick:()=>{a(e.id),s(e.name),l(e.url),f(``)},children:`编辑连接`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>ve(e.id),children:`移除连接`})]})]})]},e.id))}),(0,F.jsxs)(`form`,{className:`server-connect-form`,onSubmit:async e=>{e.preventDefault(),m(!0),g(``);try{i?await Se(i,o,c,d):await be(o,c,d),a(void 0),s(``),l(``),f(``)}catch(e){g(e instanceof Error?e.message:`连接失败`)}finally{m(!1)}},children:[(0,F.jsx)(`h4`,{children:i?`编辑服务器连接`:`添加服务器`}),(0,F.jsxs)(`label`,{children:[`显示名称`,(0,F.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`例如:开发服务器`,required:!0})]}),(0,F.jsxs)(`label`,{children:[`服务地址`,(0,F.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`http://主机:端口`,required:!0})]}),(0,F.jsxs)(`label`,{children:[`连接密钥`,(0,F.jsx)(`input`,{type:`password`,autoComplete:`off`,value:d,onChange:e=>f(e.target.value),required:!i,placeholder:i?`留空保留已保存的密钥`:void 0})]}),(0,F.jsx)(`small`,{children:`先在目标服务器的“服务器连接”设置中生成连接密钥,再粘贴到这里。密钥具有该服务器的操作权限。`}),(0,F.jsx)(`button`,{type:`submit`,disabled:p,children:p?`正在连接…`:i?`验证并保存`:`验证并添加`}),i&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{a(void 0),s(``),l(``),f(``)},children:`取消编辑`})]}),r?(0,F.jsx)(`p`,{children:`SSH 托管连接由本地入口管理,无需手动生成或更换连接密钥。`}):(0,F.jsxs)(`section`,{className:`server-access-settings`,children:[(0,F.jsxs)(`h4`,{children:[`允许其他浏览器连接 · `,me(n)]}),(0,F.jsx)(`p`,{children:y?`已开启。重新生成会使原连接密钥失效。`:`尚未开启远程浏览器授权。`}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`rotate`),children:y?`重新生成连接密钥`:`生成连接密钥`}),y&&(0,F.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`revoke`),children:`撤销授权`})]}),_&&(0,F.jsxs)(`label`,{children:[`连接密钥(仅本次显示,请妥善保存)`,(0,F.jsx)(`textarea`,{readOnly:!0,rows:3,value:_,onFocus:e=>e.target.select()})]})]}),h&&(0,F.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:h})]})}function Ue(){let[e,t]=(0,u.useState)(`managed`);return(0,F.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,F.jsxs)(`div`,{className:`server-connection-modes`,role:`tablist`,"aria-label":`服务器接入方式`,children:[(0,F.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`managed`,"data-server-mode":`managed`,onClick:()=>t(`managed`),children:`SSH 托管`}),(0,F.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`direct`,"data-server-mode":`direct`,onClick:()=>t(`direct`),children:`已有服务直接连接`})]}),e===`managed`?(0,F.jsx)(ze,{}):(0,F.jsx)(He,{})]})}var We=s(),I=`操作没有完成。`,Ge=`操作没有完成,没有拿到失败原因。可以重试,或查看服务端日志。`,Ke=160,qe=/[\u3400-\u9fff]/,Je=/^(?:bad request|\{\s*"detail"\s*:\s*"bad request"\s*\})$/i,Ye=/failed to fetch|fetch failed|network\s*error|econnrefused|econnreset|enotfound|eai_again|socket hang up|connection refused|connection reset|broken pipe|load failed/i,Xe=/timeout|timed out|etimedout/i,Ze=/aborterror|aborted|the user aborted a request|operation was aborted/i,Qe=/node-pty|pty unavailable|terminal unavailable/i,$e=/could not find[^\n]*\bpi\b|pi command not found|pi (?:is )?not (?:installed|found)|not recognized as an internal or external command/i,et=/\b401\b|\b403\b|unauthorized|forbidden|invalid api key|incorrect api key|authentication failed|insufficient permission/i,tt=/\b5(?:00|01|02|03|04)\b|internal server error|bad gateway|service unavailable|gateway timeout/i,nt=/\bhttp\s*(?:status\s*)?[:=]?\s*(\d{3})\b|\bstatus(?:\s*code)?\s*[:=]\s*(\d{3})\b/i,rt=/\b(ENOENT|EACCES|EPERM|EBUSY|EISDIR|ENOTDIR|EMFILE|ENOSPC)\b/;function it(e){let t=``;if(e==null)t=``;else if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message;else if(typeof e==`object`&&typeof e.message==`string`)t=e.message;else try{t=String(e)}catch{t=``}return t.trim().replace(/^error:\s*/i,``).replace(/^\[object object\]$/i,``).trim()}var at=/^\{[\s{}]*\}$|^\[[\s[\]]*\]$|^(undefined|null|NaN)$|^\[object [\w\s]+\]$/i;function ot(e){let t=e.replace(/\s+/g,` `).trim().replace(/\bsk-[A-Za-z0-9_-]{6,}/g,`sk-***`).replace(/([?&](?:api[_-]?key|access[_-]?token|token)=)[^&\s]+/gi,`$1***`);return t.length>Ke?`${t.slice(0,Ke)}…`:t}function st(e,t){return e.toLowerCase().includes(t.toLowerCase())?e:`${e}(${ot(t)})`}function ct(e,t){let n=it(e);if(!n||at.test(n))return t??Ge;if(qe.test(n))return n;if(Je.test(n))return`请求被拒绝(Bad Request)。返回方没有提供具体原因。`;if(Ye.test(n))return st(`连接不上 Super Pi 服务,请稍后再试。`,n);if(Xe.test(n))return st(`等待服务响应超时,请稍后再试。`,n);if(Ze.test(n))return st(`请求被中断,请重试。`,n);if(Qe.test(n))return st(`终端组件没有加载,请重启 Super Pi 后再试。`,n);if($e.test(n))return st(`找不到 Pi 命令,请确认 Pi 已安装并且在命令行里可用。`,n);let r=Number(nt.exec(n)?.[1]??nt.exec(n)?.[2]??0);if(r===401||r===403)return st(`没有权限完成这个操作,请检查鉴权配置。`,n);if(r>=500)return st(`服务端没有完成这次请求(HTTP ${r}),请稍后再试。`,n);if(r>=400)return st(`请求被拒绝(HTTP ${r})。`,n);if(et.test(n))return st(`鉴权失败,请检查对应的 key 或权限配置。`,n);if(tt.test(n))return st(`服务端出错了,请稍后再试。`,n);let i=rt.exec(n)?.[1];return st(i===`ENOENT`?`找不到对应的文件或目录。`:i===`EACCES`||i===`EPERM`?`没有访问这个文件的权限。`:i===`EBUSY`?`文件正被其他程序占用,请稍后再试。`:i===`ENOSPC`?`磁盘空间不足,这个操作没有完成。`:i?`文件操作没有完成,请检查路径后重试。`:t??I,n)}function lt(e){let t=it(e);if(t&&!at.test(t))return ct(e).includes(t)?void 0:t}function ut(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}var dt={ts:`code`,tsx:`code`,js:`code`,jsx:`code`,mjs:`code`,cjs:`code`,mts:`code`,cts:`code`,py:`code`,rb:`code`,go:`code`,rs:`code`,java:`code`,kt:`code`,kts:`code`,scala:`code`,c:`code`,h:`code`,cc:`code`,cpp:`code`,hpp:`code`,cs:`code`,swift:`code`,m:`code`,mm:`code`,php:`code`,pl:`code`,pm:`code`,lua:`code`,r:`code`,jl:`code`,ex:`code`,exs:`code`,erl:`code`,hs:`code`,dart:`code`,nim:`code`,zig:`code`,vue:`code`,svelte:`code`,astro:`code`,sh:`code`,bash:`code`,zsh:`code`,fish:`code`,ps1:`code`,bat:`code`,cmd:`code`,sql:`code`,graphql:`code`,gql:`code`,proto:`code`,tf:`code`,tfvars:`code`,hcl:`code`,sol:`code`,md:`markup`,mdx:`markup`,markdown:`markup`,txt:`markup`,text:`markup`,rst:`markup`,adoc:`markup`,org:`markup`,yaml:`config`,yml:`config`,toml:`config`,ini:`config`,cfg:`config`,conf:`config`,xml:`config`,env:`config`,properties:`config`,gitignore:`config`,editorconfig:`config`,eslintrc:`config`,prettierrc:`config`,css:`style`,scss:`style`,sass:`style`,less:`style`,stylus:`style`,pcss:`style`,postcss:`style`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,bmp:`image`,webp:`image`,avif:`image`,ico:`image`,svg:`image`,tif:`image`,tiff:`image`,heic:`image`,psd:`image`,ai:`image`,json:`data`,jsonc:`data`,json5:`data`,csv:`data`,tsv:`data`,parquet:`data`,db:`data`,sqlite:`data`,sqlite3:`data`,ndjson:`data`,zip:`archive`,tar:`archive`,gz:`archive`,tgz:`archive`,bz2:`archive`,xz:`archive`,"7z":`archive`,rar:`archive`,zst:`archive`,jar:`archive`,war:`archive`,whl:`archive`,woff:`font`,woff2:`font`,ttf:`font`,otf:`font`,eot:`font`,exe:`binary`,dll:`binary`,so:`binary`,dylib:`binary`,bin:`binary`,o:`binary`,obj:`binary`,a:`binary`,lib:`binary`,class:`binary`,node:`binary`,pyc:`binary`,pyo:`binary`,pack:`binary`,idx:`binary`,iso:`binary`,dmg:`binary`,msi:`binary`,apk:`binary`,deb:`binary`,rpm:`binary`,pdf:`binary`,doc:`binary`,docx:`binary`,xls:`binary`,xlsx:`binary`,ppt:`binary`,pptx:`binary`,odt:`binary`,ods:`binary`,odp:`binary`,wasm:`binary`},ft={dockerfile:`config`,containerfile:`config`,makefile:`code`,cmakelists:`code`,rakefile:`code`,gemfile:`config`,procfile:`config`,license:`markup`,licence:`markup`,notice:`markup`,readme:`markup`,changelog:`markup`,authors:`markup`,contributing:`markup`,".gitignore":`config`,".gitattributes":`config`,".gitmodules":`config`,".npmrc":`config`,".nvmrc":`config`,".env":`config`};function pt(e){let t=ft[e.slice(e.lastIndexOf(`/`)+1).toLowerCase()];if(t)return t;let n=ut(e);return n?dt[n]??`generic`:`generic`}var mt={code:[`M6 4.5 2.5 8 6 11.5`,`M10 4.5 13.5 8 10 11.5`,`M9.2 3.5 6.8 12.5`],markup:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`,`M5.5 8.5h5`,`M5.5 11h3.5`],config:[`M8 10.2a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4z`,`M8 1.8v1.6`,`M8 12.6v1.6`,`M1.8 8h1.6`,`M12.6 8h1.6`,`M3.6 3.6l1.1 1.1`,`M11.3 11.3l1.1 1.1`,`M12.4 3.6l-1.1 1.1`,`M4.7 11.3l-1.1 1.1`],style:[`M8 13.5a5.5 5.5 0 1 1 0-11c3 0 5.5 2 5.5 4.5 0 1.4-1.1 2.2-2.3 2.2h-1c-.9 0-1.6.7-1.6 1.5 0 .4.2.7.4 1 .2.3.4.6.4 1a1.3 1.3 0 0 1-1.4.8z`,`M5.6 6.8h.01`,`M8.4 5.2h.01`,`M11 6.9h.01`],image:[`M2.5 4.5a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-7z`,`M2.5 10.5 6 7.5l2.5 2 2-1.5 3 2.5`,`M5.8 6.4h.01`],data:[`M2.5 3.5h11v9h-11z`,`M2.5 8h11`,`M8 3.5v9`],archive:[`M2.5 5.5h11v8h-11z`,`M1.5 2.5h13v3h-13z`,`M6.8 8.5h2.4`],font:[`M3.5 13 8 3l4.5 10`,`M5.4 9.6h5.2`],binary:[`M2.5 4.5h11v7h-11z`,`M5 7h.01`,`M8 7h.01`,`M11 7h.01`,`M5 9.5h.01`,`M8 9.5h.01`],generic:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`],folder:[`M2.5 4.5a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-8z`],"folder-open":[`M2.5 12.5v-8a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v1`,`M2.5 12.5 4.6 6.8a1 1 0 0 1 .95-.7h8.1a.6.6 0 0 1 .55.85L12.9 12.5a1 1 0 0 1-.95.7H3.5a1 1 0 0 1-1-1z`]};function ht({path:e,category:t,size:n=14}){let r=t??pt(e??``),i=mt[r]??mt.generic;return(0,F.jsx)(`svg`,{className:`file-icon file-icon-${r}`,"data-file-icon":r,width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:i.map((e,t)=>(0,F.jsx)(`path`,{d:e},t))})}var gt={sessions:`会话`,files:`资源管理器`,terminal:`终端`,git:`Git`,main:`任务`,projects:`项目`,tools:`工具`},_t={sessions:`left`,files:`left`,terminal:`right`,git:`right`,main:`right`,projects:`right`,tools:`right`},vt=[`sessions`,`files`,`main`,`terminal`,`git`,`projects`,`tools`],yt=`super-pi.workbench.layout.v1`,bt=e=>typeof e==`string`&&vt.includes(e);function xt(){return{sides:{..._t},order:[...vt],unpinned:[],leftView:`sessions`,leftClosed:!1,rightClosed:!1}}function St(){let e=xt();try{let t=JSON.parse(window.localStorage.getItem(yt)??`null`);if(!t)return e;let n={..._t};for(let e of vt)e!==`sessions`&&(t.sides?.[e]===`left`||t.sides?.[e]===`right`)&&(n[e]=t.sides[e]);let r=Array.isArray(t.order)?t.order.filter(bt):[];return{sides:n,order:[...new Set([...r,...vt])],unpinned:Array.isArray(t.unpinned)?t.unpinned.filter(bt).filter(e=>e!==`sessions`):[],leftView:bt(t.leftView)?t.leftView:`sessions`,leftClosed:t.leftClosed===!0,rightClosed:t.rightClosed===!0}}catch{return e}}function Ct(e){try{window.localStorage.setItem(yt,JSON.stringify(e))}catch{}}var wt={sessions:`M4 4h16v12H9l-5 4V4zM8 8h8m-8 4h5`,group:`M3 4h14v10H8l-5 4V4zM8 9h4m7 0h2v10h-7l-3 2v-4`,"group-add":`M3 4h14v10H8l-5 4V4zM8 9h4m6 7v6m-3-3h6`,archive:`M4 4h16v5H4zM6 9v11h12V9M10 13h4`,delete:`M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 10v7m4-7v7`,files:`M3 6h7l2 2h9v11H3zM3 9h18`,terminal:`M3 4h18v16H3zM7 8l4 4-4 4m7 0h4`,git:`M7 7v10m10-10v3a4 4 0 0 1-4 4H7M7 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4zm0 14a2 2 0 1 0 0 4 2 2 0 1 0 0-4zM17 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4z`,main:`m4 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8`,projects:`M3 4h18v16H3zM3 8h18M9 8v12M15 8v12`,worktree:`M3 5h8l2 2h8v5M3 5v14h8m3-9v8m0-4h6m-3-3 3 3-3 3`,tools:`M4 4h6v6H4zm10 0h6v6h-6zM4 14h6v6H4zm10 0h6v6h-6z`,search:`M11 3a7 7 0 1 0 0 14 7 7 0 1 0 0-14zm5 12 5 5`,settings:`M10 3h4l.6 2.5 2 .9L19 5l2 3.5-1.9 1.7v2.4l1.9 1.8-2 3.4-2.4-.9-2 .9L14 21h-4l-.6-2.6-2-.9-2.4.9-2-3.4 1.9-1.8v-2.4L3 8.5 5 5l2.4 1.4 2-.9zM12 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z`,help:`M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zm-2.8 6.3a2.8 2.8 0 0 1 5.6 0c0 2-2.8 2.3-2.8 4M12 17h.01`,update:`M12 3v12m-4-4 4 4 4-4M4 15v5h16v-5`,restart:`M12 3v9M6 6a8 8 0 1 0 12 0`,more:`M5 12h.01M12 12h.01M19 12h.01`,close:`M6 6l12 12M18 6 6 18`,back:`M19 12H5m7-7-7 7 7 7`,forward:`M5 12h14m-7-7 7 7-7 7`,split:`M3 4h18v16H3zM12 4v16`,pin:`m14 3 7 7-3 1-3 4-1 3-8-8 3-1 4-3zm-4 11-6 6`};function Tt({name:e}){return(0,F.jsx)(`svg`,{className:`workbench-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.55`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,F.jsx)(`path`,{d:wt[e]})})}function Et({side:e,views:t,unpinned:n,active:r,previous:i,onSelect:a,onSearch:o,onArrange:s,onReorder:c,onReset:l,children:d}){let f=t.filter(e=>n.includes(e)),p=t.filter(e=>!n.includes(e)),[m,h]=(0,u.useState)(),g=m&&p.includes(m)?m:r&&p.includes(r)?r:p[0],_=(0,u.useRef)(new Map),v=(0,u.useRef)(null),[y,b]=(0,u.useState)(),x=(0,u.useRef)(null),S=(0,u.useRef)(void 0),[C,w]=(0,u.useState)();return(0,u.useEffect)(()=>{if(!y)return;let e=()=>b(void 0),t=t=>{t.target instanceof Node&&!x.current?.contains(t.target)&&e()},n=t=>{t.key!==`Escape`||t.defaultPrevented||(t.preventDefault(),e(),_.current.get(y.view)?.focus())};return x.current?.querySelector(`button`)?.focus(),window.addEventListener(`pointerdown`,t),window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e)}},[y]),(0,u.useEffect)(()=>{let e=e=>{let t=v.current;t?.open&&e.target instanceof Node&&!t.contains(e.target)&&(t.open=!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]),(0,F.jsxs)(`div`,{className:`workbench-activity workbench-activity-${e}`,"data-workbench-activity":e,children:[(0,F.jsx)(`div`,{className:`workbench-activity-views`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":e===`left`?`左侧视图`:`右侧视图`,children:p.map((t,n)=>(0,F.jsx)(`button`,{type:`button`,role:`tab`,id:t===`sessions`?`workbench-sessions-tab`:`right-tab-${t}`,className:`right-tab workbench-activity-button${r===t?` right-tab-active`:``}`,"data-workbench-view":t,"data-right-tab":t===`sessions`?void 0:t,"data-right-rail-open":e===`right`&&!r&&i===t?`1`:void 0,"aria-controls":t===`sessions`?`workbench-sessions`:`right-panel-${t}`,"aria-selected":r===t,tabIndex:t===g?0:-1,draggable:t!==`sessions`,"data-workbench-drop":C===t?`1`:void 0,onContextMenu:n=>{if(t===`sessions`)return;n.preventDefault();let r=n.currentTarget.getBoundingClientRect();b({view:t,x:Math.max(4,Math.min(window.innerWidth-200,n.clientX||(e===`left`?r.right:r.left-196))),y:Math.max(4,Math.min(window.innerHeight-146,n.clientY||r.top))})},onDragStart:e=>{t!==`sessions`&&(S.current=t,e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`)},onDragOver:e=>{S.current&&t!==`sessions`&&S.current!==t&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,w(t))},onDragLeave:()=>w(e=>e===t?void 0:e),onDrop:e=>{let n=S.current;n&&t!==`sessions`&&(e.preventDefault(),c(n,t),S.current=void 0,w(void 0))},onDragEnd:()=>{S.current=void 0,w(void 0)},ref:e=>{e?_.current.set(t,e):_.current.delete(t)},title:gt[t],"aria-label":gt[t],onFocus:()=>h(t),onClick:()=>a(t),onKeyDown:r=>{if(t!==`sessions`&&(r.key===`ContextMenu`||r.shiftKey&&r.key===`F10`)){r.preventDefault();let n=r.currentTarget.getBoundingClientRect();b({view:t,x:Math.max(4,e===`left`?n.right:n.left-196),y:Math.max(4,Math.min(window.innerHeight-146,n.top))});return}let i=r.key===`Home`?p[0]:r.key===`End`?p.at(-1):r.key===`ArrowDown`?p[(n+1)%p.length]:r.key===`ArrowUp`?p[(n+p.length-1)%p.length]:void 0;i&&(r.preventDefault(),_.current.get(i)?.focus())},children:(0,F.jsx)(Tt,{name:t})},t))}),o&&(0,F.jsx)(`button`,{type:`button`,className:`workbench-activity-button`,"data-workbench-search":`1`,title:`搜索`,"aria-label":`搜索`,onClick:o,children:(0,F.jsx)(Tt,{name:`search`})}),(f.length>0||e===`right`)&&(0,F.jsxs)(`details`,{className:`workbench-menu workbench-more`,ref:v,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,F.jsx)(`summary`,{className:`workbench-activity-button`,title:`更多视图`,"aria-label":`更多视图`,children:(0,F.jsx)(Tt,{name:`more`})}),(0,F.jsxs)(`div`,{className:`workbench-menu-items`,children:[f.map(e=>(0,F.jsxs)(`button`,{type:`button`,"data-workbench-extra":e,"aria-pressed":r===e,onClick:t=>{t.currentTarget.closest(`details`)?.removeAttribute(`open`),r===e?v.current?.querySelector(`summary`)?.focus():a(e)},children:[(0,F.jsx)(Tt,{name:e}),gt[e]]},e)),e===`right`&&(0,F.jsx)(`button`,{type:`button`,"data-workbench-reset":`1`,onClick:()=>{v.current&&(v.current.open=!1),l()},children:`恢复默认布局`})]})]}),y&&(0,We.createPortal)((0,F.jsx)(`div`,{ref:x,className:`workbench-menu-items workbench-context-menu`,style:{left:y.x,top:y.y},"aria-label":`${gt[y.view]}布局`,children:Dt(e,!0).map(([e,t])=>(0,F.jsx)(`button`,{type:`button`,"data-workbench-context-action":e,onClick:()=>{b(void 0),s(y.view,e),e!==`move`&&e!==`pin`&&_.current.get(y.view)?.focus()},children:t},e))}),document.body),d&&(0,F.jsx)(`div`,{className:`workbench-activity-utilities`,children:d})]})}var Dt=(e,t)=>[[`move`,e===`left`?`移到右侧`:`移到左侧`],[`pin`,t?`从活动栏取消固定`:`固定到活动栏`],[`up`,`在活动栏上移`],[`down`,`在活动栏下移`]];function Ot({view:e,side:t,pinned:n,onArrange:r}){let i=Dt(t,n);return(0,F.jsxs)(`details`,{className:`workbench-menu workbench-panel-menu`,children:[(0,F.jsx)(`summary`,{title:`视图布局`,"aria-label":`${gt[e]}布局`,"data-workbench-panel-menu":e,children:(0,F.jsx)(Tt,{name:`more`})}),(0,F.jsx)(`div`,{className:`workbench-menu-items`,children:i.map(([t,n])=>(0,F.jsx)(`button`,{type:`button`,"data-workbench-arrange":t,onClick:n=>{n.currentTarget.closest(`details`)?.removeAttribute(`open`),r(e,t)},children:n},t))})]})}var kt=`default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'self'; object-src 'none'; form-action 'none'; base-uri 'none'`,At={png:{kind:`image`,mime:`image/png`},jpg:{kind:`image`,mime:`image/jpeg`},jpeg:{kind:`image`,mime:`image/jpeg`},gif:{kind:`image`,mime:`image/gif`},webp:{kind:`image`,mime:`image/webp`},svg:{kind:`image`,mime:`image/svg+xml`},html:{kind:`html`,mime:`text/html; charset=utf-8`},htm:{kind:`html`,mime:`text/html; charset=utf-8`}};function jt(e){return At[/\.([a-z]+)$/i.exec(e)?.[1].toLowerCase()??``]}function Mt(e){if(!(!e||/[\u0000-\u001f\u007f]/.test(e)||/^[\\/]{2}/.test(e))&&(!/^[a-z][a-z\d+.-]*:/i.test(e)||/^[a-z]:[\\/]/i.test(e)))return jt(e)?.kind}function Nt(e,t,n){return`/api/message-artifact?${new URLSearchParams({workspaceId:e,conversationId:t,path:n})}`}function Pt(e){let t=/(\/\/.*|#[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:const|let|var|function|return|if|else|for|while|class|import|from|export|def|fn|true|false|null|undefined|async|await|try|catch|throw|switch|case|break|continue|new|this|static|public|private|interface|type|enum|struct|impl|pub|mod|use|as|where|match|loop|mut|ref|self|Self)\b|\b\d+(?:\.\d+)?\b)/g,n=[],r=0,i;for(;i=t.exec(e);){i.index>r&&n.push({text:e.slice(r,i.index),kind:`plain`});let t=i[0],a=/^(\/\/|#)/.test(t)?`comment`:/^["']/.test(t)?`string`:/^\d/.test(t)?`number`:`keyword`;n.push({text:t,kind:a}),r=i.index+t.length}return r<e.length&&n.push({text:e.slice(r),kind:`plain`}),n}var Ft=new Set([`http`,`https`,`mailto`]),It=e=>{let t=e.codePointAt(0)??0;return t<=32||t===127||/\s/.test(e)},Lt=/^([a-z][a-z0-9+.-]*):/i;function Rt(e){let t=[...e].filter(e=>!It(e)).join(``);if(!t)return;let n=Lt.exec(t);return n?Ft.has(n[1].toLowerCase())?e:void 0:e}var zt=/[!-/:-@[-`{-~]/,Bt=e=>e!==void 0&&/[\p{L}\p{N}]/u.test(e);function Vt(e,t,n){let r=0;for(;e[t+r]===n;)r+=1;return r}function Ht(e){let t=e.replace(/\n/g,` `);return t.length>2&&t.startsWith(` `)&&t.endsWith(` `)&&t.trim()!==``?t.slice(1,-1):t}function Ut(e,t,n){for(let r=t;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]!=="`")continue;let t=Vt(e,r,"`");if(t===n)return r;r+=t-1}return-1}function Wt(e,t,n,r){for(let i=t;i<e.length;i+=1){if(n===`$`){if(e[i]===`
|
|
12
|
+
`)break;if(e[i]==="`"){let t=Vt(e,i,"`");if(Ut(e,i+t,t)!==-1)break}}if(e.startsWith(n,i)||r&&e.startsWith(r,i))return i;e[i]===`\\`&&(i+=1)}return-1}function Gt(e,t){if(e[t]!==`(`)return;let n=1,r=-1;for(let i=t+1;i<e.length;i+=1){let t=e[i];if(t===`\\`)i+=1;else if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0)){r=i;break}}if(r===-1)return;let i=e.slice(t+1,r).trim();if(i.length>1&&i.startsWith(`<`)&&i.endsWith(`>`))return{href:i.slice(1,-1),next:r+1};let a=/^(.*?)\s+"([^"]*)"$/.exec(i);if(a)return{href:a[1],title:a[2],next:r+1};if(!/\s/.test(i))return{href:i,next:r+1}}function Kt(e,t){let n=1;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`\\`)r+=1;else if(t===`[`)n+=1;else if(t===`]`&&(--n,n===0))return r}return-1}function qt(e,t,n,r){for(let i=t;i<e.length;i+=1){let t=Zt(e,i);if(t)i=t.next-1;else if(e[i]===`\\`)i+=1;else if(e[i]==="`"){let t=Vt(e,i,"`"),n=Ut(e,i+t,t);if(n!==-1){i=n+t-1;continue}i+=t-1}else if(e[i]===r&&!(Vt(e,i,r)<n.length)&&!(r===`_`&&Bt(e[i-1])&&Bt(e[i+1])))return i}return-1}var Jt=/^<([a-z][a-z0-9+.-]*:[^<>\s]*)>/i,Yt=/[\s(\[{,:;=+\/|(【「『]/,Xt=/[\u2E80-\u9FFF\uF900-\uFAFF\u3000-\uFF60\uFFE0-\uFFE6]/;function Zt(e,t){let n=e[t],r=e[t+1],i=n===`$`&&r===`$`||n===`\\`&&r===`[`,a=n===`\\`&&r===`(`,o=n===`$`&&!i;if(!i&&!a&&!o||o&&t>0&&!Yt.test(e[t-1])&&!Xt.test(e[t-1]))return;let s=n===`\\`?a?`\\)`:`\\]`:i?`$$`:`$`,c=t+s.length,l=Wt(e,c,s);if(l===-1)return;let u=e.slice(c,l);if(u.trim()&&!(o&&(/^\s|\s$/.test(u)||/[0-9$]/.test(e[l+1]??``)||/^\d[\d.,]*[\s,、:;。?!]*\p{Script=Han}/u.test(u))))return{node:{type:`math`,source:u,display:i},next:l+s.length}}function Qt(e,t={}){let n=[],r=``,i=()=>{r&&=(n.push({type:`text`,value:r}),``)},a=e=>{i(),n.push(e)};for(let o=0;o<e.length;){let s=e[o],c=Zt(e,o);if(c){a(c.node),o=c.next;continue}let l=e.slice(o,o+2);if(l===`$$`||l===`\\(`||l===`\\[`||l===`\\)`||l===`\\]`)r+=l,o+=2;else if(s===`\\`&&zt.test(e[o+1]??``))r+=e[o+1],o+=2;else if(s==="`"){let t=Vt(e,o,"`"),n=Ut(e,o+t,t);if(n!==-1){a({type:`code`,value:Ht(e.slice(o+t,n))}),o=n+t;continue}r+="`".repeat(t),o+=t}else if(s===`<`){let t=Jt.exec(e.slice(o));if(t){let e=Rt(t[1]);if(e){a({type:`link`,href:e,children:[{type:`text`,value:t[1]}]}),o+=t[0].length;continue}}r+=s,o+=1}else if(s===`!`&&e[o+1]===`[`||s===`[`){let n=s===`!`,i=o+(n?2:1),c=Kt(e,i),l=c===-1?void 0:Gt(e,c+1);if(l){let r=Mt(l.href);if(r&&(n||r===`html`)){a({type:`artifact`,kind:r,path:l.href,label:e.slice(i,c)}),o=l.next;continue}let s=Rt(l.href);if(s){a({type:`link`,href:s,...l.title===void 0?{}:{title:l.title},children:Qt(e.slice(i,c),t)}),o=l.next;continue}}r+=s,o+=1}else if(t.strikethrough!==!1&&s===`~`&&e[o+1]===`~`){let n=qt(e,o+2,`~~`,`~`);if(n>o+2){a({type:`del`,children:Qt(e.slice(o+2,n),t)}),o=n+2;continue}r+=`~~`,o+=2}else if(s===`*`||s===`_`){let n=Vt(e,o,s);if((n>=2?t.bold:t.italic)===!1){r+=s.repeat(n),o+=n;continue}let i=n>=2?s.repeat(2):s,c=s===`_`&&Bt(e[o-1])&&Bt(e[o+n])?-1:qt(e,o+i.length,i,s);if(c>o+i.length){let r=Qt(e.slice(o+i.length,c),t);a(n>=2?{type:`strong`,children:r}:{type:`em`,children:r}),o=c+i.length;continue}r+=i,o+=i.length}else s===`
|
|
13
|
+
`?(/[ \t]{2,}$/.test(r)||r.endsWith(`\\`)?(r=r.replace(/(?:[ \t]+|\\)$/,``),i(),n.push({type:`break`})):r+=s,o+=1):(r+=s,o+=1)}return i(),n}var $t=/^(\s*)(`{3,}|~{3,})\s*([^`\s]*)\s*$/,en=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,tn=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,nn=/^(\s*)([-*+])(\s+)(.*)$/,rn=/^(\s*)(\d{1,9})([.)])(\s+)(.*)$/,an=/^ {0,3}>\s?(.*)$/,on=/^ {0,3}\|?\s*:?-{1,}:?\s*(?:\|\s*:?-{1,}:?\s*)*\|?\s*$/,sn=/^\s*(\$\$(?!\$)|\\\[|\\begin\{((?:equation|align|alignat|gather|multline|flalign|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|Bmatrix|cases)\*?|aligned|alignedat|gathered|split|array|smallmatrix|dcases|rcases)\})/;function cn(e,t){let n=sn.exec(e[t]);if(!n)return;let r=n[1],i=n[2],a=i?`\\end{`+i+`}`:r===`$$`?`$$`:`\\]`,o=[],s=1;for(let c=t;c<e.length;c+=1){let l=e[c];if(c!==t&&($t.test(l)||en.test(l)||l.trimStart().startsWith(`\\[`)))return;let u=c===t?n[0].length:0,d=Wt(l,u,a,i&&r);for(;i&&d!==-1;){let e=l.startsWith(r,d);if(s+=e?1:-1,!s)break;d=Wt(l,d+(e?r:a).length,a,r)}if(d===-1){o.push(l.slice(u));continue}if(l.slice(d+a.length).trim())return;o.push(l.slice(u,d));let f=o.join(`
|
|
14
|
+
`).trim();return f?{node:{type:`math-block`,source:i?r+o.join(`
|
|
15
|
+
`)+a:f},next:c+1}:void 0}}var ln=(e,t)=>RegExp(`^\\s*${e==="`"?"`":`~`}{${t},}\\s*$`);function un(e,t={}){let n=e.replace(/\r\n?/g,`
|
|
16
|
+
`).split(`
|
|
17
|
+
`),r=[],i=0;for(;i<n.length;){let e=n[i];if(!e.trim()){i+=1;continue}let a=$t.exec(e);if(a){let e=ln(a[2][0],a[2].length),t=[];for(i+=1;i<n.length&&!e.test(n[i]);)t.push(n[i].startsWith(a[1])?n[i].slice(a[1].length):n[i]),i+=1;let o=i<n.length;i+=1;let s=t.join(`
|
|
18
|
+
`);r.push(a[3]?.toLowerCase()===`math`&&o&&s.trim()?{type:`math-block`,source:s}:{type:`code-block`,lang:a[3]??``,value:s});continue}let o=cn(n,i);if(o){r.push(o.node),i=o.next;continue}if(tn.test(e)){r.push({type:`rule`}),i+=1;continue}let s=en.exec(e);if(s){r.push({type:`heading`,level:s[1].length,children:Qt(s[2]??``,t)}),i+=1;continue}if(an.test(e)){let e=[];for(;i<n.length;){let t=an.exec(n[i]);if(t)e.push(t[1]),i+=1;else{if(e.length===0||!n[i].trim()||fn(n,i))break;e.push(n[i].trim()),i+=1}}r.push({type:`blockquote`,children:un(e.join(`
|
|
19
|
+
`),t)});continue}let c=dn(n,i);if(c){c.prefix&&r.push({type:`paragraph`,children:Qt(c.prefix,t)});let e=mn(c.header),a=mn(n[i+1]).map(hn),o=[];for(i+=2;i<n.length&&n[i].trim()&&n[i].includes(`|`);)o.push(gn(mn(n[i]),e.length).map(e=>Qt(e,t))),i+=1;r.push({type:`table`,head:e.map(e=>Qt(e,t)),align:a,rows:o});continue}if(nn.test(e)||rn.test(e)){let e=pn(n,i,t);r.push(e.node),i=e.next;continue}let l=[];for(;i<n.length&&n[i].trim()&&!fn(n,i);)l.push(n[i]),i+=1;l.length||(l.push(n[i]),i+=1),r.push({type:`paragraph`,children:Qt(l.join(`
|
|
20
|
+
`),t)})}return r}function dn(e,t){let n=e[t],r=e[t+1];if(!n?.includes(`|`)||!r||!on.test(r)||!r.includes(`-`))return;if(mn(n).length===mn(r).length)return{header:n};let i=n.indexOf(`|`);if(i<=0)return{header:n};let a=n.slice(0,i).trim(),o=n.slice(i);if(a&&mn(o).length===mn(r).length)return{header:o,prefix:a}}function fn(e,t){let n=e[t];return $t.test(n)||en.test(n)||tn.test(n)||an.test(n)||!!dn(e,t)||nn.test(n)||rn.test(n)||sn.test(n)}function pn(e,t,n){let r=rn.test(e[t]),i=r?rn.exec(e[t]):nn.exec(e[t]),a=i[1].length,o=[],s=t;for(;s<e.length;){let t=nn.exec(e[s]),i=rn.exec(e[s]),c=r?i:t;if(!c)break;let l=c[1].length;if(l<a)break;let u=[c[c.length-1]];for(s+=1;s<e.length;){let n=e[s];if(!n.trim()){let t=e[s+1]??``;if(!t.trim()||t.search(/\S/)<=l)break;u.push(``),s+=1;continue}let r=n.search(/\S/);if(r===0&&t||r===0&&i)break;if(r>l)u.push(n.slice(Math.min(r,l+2))),s+=1;else if(r===l){if(fn(e,s))break;u.push(n),s+=1}else break}o.push(un(u.join(`
|
|
21
|
+
`),n))}return{node:{type:`list`,ordered:r,start:r?Number(i[2]):1,items:o},next:s}}function mn(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e+=1){let i=Zt(t,e);if(i)r+=t.slice(e,i.next),e=i.next-1;else if(t[e]==="`"){let n=Vt(t,e,"`"),i=Ut(t,e+n,n),a=i===-1?e+n:i+n;r+=t.slice(e,a),e=a-1}else t[e]===`\\`&&t[e+1]===`|`?(r+=`|`,e+=1):t[e]===`|`?(n.push(r.trim()),r=``):r+=t[e]}return n.push(r.trim()),n}function hn(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:n?`right`:t?`left`:null}function gn(e,t){let n=e.slice(0,t);for(;n.length<t;)n.push(``);return n}var _n=[{kind:`calculator`,name:`计算器`,glyph:`∑`,blurb:`算术表达式,四则运算与乘方。除零会明确报错。`},{kind:`timestamp`,name:`时间戳`,glyph:`◷`,blurb:`Unix 时间戳与日期互转,本地计算,不联网。`}],vn=[{id:`preset_calculator`,kind:`calculator`,name:`计算器`,glyph:`∑`}],yn=40,bn=2048,xn=`super-pi:tools:v1`;function Sn(e){return typeof e==`string`?e.replace(/\s+/g,` `).trim().slice(0,yn):``}function Cn(e){let t=e.trim();if(!t)return{ok:!1,reason:`请填写网址。`};if(t.length>bn)return{ok:!1,reason:`网址太长了,请控制在 ${bn} 个字符以内。`};let n=Rt(t);return n?{ok:!0,url:n}:{ok:!1,reason:`这个网址不是允许的协议。只支持 http / https / mailto 开头的网址。`}}function wn(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[],r=new Set;for(let e of t){if(n.length>=32)break;if(typeof e!=`object`||!e)continue;let t=e,i=t.kind;if(typeof i!=`string`||i!==`calculator`&&i!==`timestamp`&&i!==`link`)continue;let a=Sn(t.name);if(!a)continue;let o=typeof t.glyph==`string`&&t.glyph.trim()?t.glyph.trim().slice(0,4):``;if(!o)continue;let s=typeof t.id==`string`&&t.id.trim()?t.id.trim().slice(0,64):``;if(s&&!r.has(s)){if(i===`link`){let e=Rt(typeof t.url==`string`?t.url:``);if(!e)continue;r.add(s),n.push({id:s,kind:`link`,name:a,glyph:o,url:e})}else r.add(s),n.push({id:s,kind:i,name:a,glyph:o})}}return n}function Tn(e){return JSON.stringify(e.map(e=>e.kind===`link`?{...e}:{id:e.id,kind:e.kind,name:e.name,glyph:e.glyph}))}function En(){let e=typeof globalThis<`u`?globalThis.crypto:void 0;return typeof e?.randomUUID==`function`?e.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Dn(e,t){let n=e===`link`?`link`:`preset_${e}`,r=En().replace(/-/g,``).slice(0,8),i=`${n}_${r}`,a=1;for(;t.includes(i);)i=`${n}_${r}_${a}`,a+=1;return i}function On(e,t){if(e.some(e=>e.kind===t))return e.slice();let n=_n.find(e=>e.kind===t);return n?[...e,{id:Dn(t,e.map(e=>e.id)),kind:t,name:n.name,glyph:n.glyph}]:e.slice()}function kn(e,t){return e.filter(e=>e.id!==t)}var An=e=>({ok:!1,reason:e}),jn=`除数不能为 0:除以零没有结果,请换一个非零的除数。`,Mn=new Set([`/`,`%`]),Nn=e=>e!==void 0&&e>=`0`&&e<=`9`,Pn=e=>e!==void 0&&/\s/.test(e);function Fn(e){for(;Pn(e.source[e.at]);)e.at+=1}function In(e){let t=e.at,n=0;for(;Nn(e.source[e.at]);)e.at+=1,n+=1;if(e.source[e.at]===`.`)for(e.at+=1;Nn(e.source[e.at]);)e.at+=1,n+=1;if(!n)return e.at=t,An(`「${e.source[t]}」不是有效的数字。`);let r=Number(e.source.slice(t,e.at));return Number.isFinite(r)?{ok:!0,value:r}:An(`数字太长了,无法表示。`)}function Ln(e){Fn(e);let t=e.source[e.at];if(t===void 0)return An(`算式不完整:末尾还缺一个数字或右括号。`);if(t===`(`){e.at+=1;let t=Vn(e);return t.ok?(Fn(e),e.source[e.at]===`)`?(e.at+=1,t):An(`括号不匹配:少了一个右括号「)」。`)):t}return Nn(t)||t===`.`?In(e):An(`无法识别的字符「${t}」。`)}function Rn(e){let t=Ln(e);if(!t.ok||(Fn(e),e.source[e.at]!==`^`))return t;e.at+=1;let n=zn(e);if(!n.ok)return n;let r=t.value**n.value;return Number.isFinite(r)?{ok:!0,value:r}:An(`结果超出了可计算的数值范围。`)}function zn(e){Fn(e);let t=e.source[e.at];if(t!==`+`&&t!==`-`)return Rn(e);e.at+=1;let n=zn(e);if(!n.ok)return n;let r=t===`-`?-n.value:n.value;return Number.isFinite(r)?{ok:!0,value:r}:An(`结果超出了可计算的数值范围。`)}function Bn(e){let t=zn(e);if(!t.ok)return t;for(;;){Fn(e);let n=e.source[e.at];if(n!==`*`&&!Mn.has(n))return t;e.at+=1;let r=zn(e);if(!r.ok)return r;if(Mn.has(n)&&r.value===0)return An(jn);let i=n===`*`?t.value*r.value:n===`%`?t.value%r.value:t.value/r.value;if(!Number.isFinite(i))return An(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function Vn(e){let t=Bn(e);if(!t.ok)return t;for(;;){Fn(e);let n=e.source[e.at];if(n!==`+`&&n!==`-`)return t;e.at+=1;let r=Bn(e);if(!r.ok)return r;let i=n===`+`?t.value+r.value:t.value-r.value;if(!Number.isFinite(i))return An(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function Hn(e){let t=e.trim();if(!t)return An(`请输入算式。`);if(t.length>200)return An(`算式太长了,请控制在 200 个字符以内。`);let n={source:t,at:0},r=Vn(n);return r.ok?(Fn(n),n.at===t.length?Number.isFinite(r.value)?r:An(`结果不是有限数字。`):An(`「${t[n.at]}」后面的内容无法识别,请检查是否漏了运算符。`)):r}function Un(e){return String(!Number.isFinite(e)||Number.isInteger(e)&&Math.abs(e)<1e21?e:Number(e.toPrecision(12)))}function Wn(e){let t=e.trim();if(!t)return{ok:!1,reason:`请输入时间戳或日期。`};if(/^-?\d+$/.test(t)){let e=Number(t);if(!Number.isFinite(e))return{ok:!1,reason:`这个数字太大,无法表示。`};let n=t.replace(`-`,``).length<=11?e*1e3:e;return!Number.isFinite(n)||Math.abs(n)>864e13?{ok:!1,reason:`这个时间戳超出了日期能表示的范围。`}:{ok:!0,ms:n}}let n=Date.parse(t);return Number.isNaN(n)?{ok:!1,reason:`看不懂这个日期。试试 1757000000、2026-10-08 或 2026-10-08T09:00:00。`}:{ok:!0,ms:n}}var Gn=e=>String(Math.abs(e)).padStart(2,`0`);function Kn(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:{local:`${t.getFullYear()}-${Gn(t.getMonth()+1)}-${Gn(t.getDate())} ${Gn(t.getHours())}:${Gn(t.getMinutes())}:${Gn(t.getSeconds())}`,iso:t.toISOString(),seconds:String(Math.floor(e/1e3)),milliseconds:String(e)}}function qn(e){let t=new Map,n=[],r=0,i=1,a=(e,t)=>{let r=t??n.indexOf(!1),a=r<0?n.length:r;return n[a]=!0,i=Math.max(i,a+1),{index:a,color:e}},o=e.map(({hash:e,parents:i})=>{let o=t.get(e),s=o??a(r++);t.delete(e),n[s.index]=!1;let c=[...t.values()],l=[...new Set(i)].map((e,n)=>{let i=t.get(e);return i||(i=n===0?a(s.color,s.index):a(r++),t.set(e,i)),{hash:e,lane:i}});return{node:s,incoming:o!==void 0,through:c,parents:l}});return{columns:i,rows:o}}function Jn(e,t){if(t===`untracked`||e.startsWith(`?`))return{label:`?`,kind:`untracked`,slot:`index`};let n=(t===`staged`?e[0]:e[1])||e[0]||`M`;return n===`A`?{label:`A`,kind:`added`,slot:t===`staged`?`index`:`worktree`}:n===`D`?{label:`D`,kind:`deleted`,slot:t===`staged`?`index`:`worktree`}:n===`R`?{label:`R`,kind:`renamed`,slot:t===`staged`?`index`:`worktree`}:{label:`M`,kind:`modified`,slot:t===`staged`?`index`:`worktree`}}var Yn=e=>e.path.endsWith(`/`),Xn=[{id:`changes`,title:`工作区改动`,search:`搜索文件名或路径`,icon:`main`},{id:`log`,title:`提交历史`,search:`搜索提交说明或哈希`,icon:`update`},{id:`graph`,title:`提交图`,search:``,icon:`git`},{id:`branches`,title:`分支`,search:`搜索本地或远程分支`,icon:`git`},{id:`stash`,title:`Stash`,search:`搜索贮藏记录`,icon:`files`},{id:`worktrees`,title:`工作树`,search:``,icon:`worktree`}],Zn=`请选择具体 session 以确定工作区`,Qn=e=>e===`changes`||e===`log`||e===`stash`,$n=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},er=15e3,tr=(e,t)=>new $n(408,{error:`请求超时:${t/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function nr(e,t,n=er){let r=new AbortController,i=setTimeout(()=>r.abort(),n);try{let n=t?.signal?AbortSignal.any([t.signal,r.signal]):r.signal,i=await Ae(e,{...t,signal:n}),a;try{a=await i.json()}catch(e){if(i.ok)throw e}if(!i.ok)throw new $n(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw r.signal.aborted?tr(e,n):t}finally{clearTimeout(i)}}var rr=e=>e instanceof $n?e:new $n(0,{error:e instanceof Error?e.message:`读取失败`}),ir=e=>encodeURIComponent(e),ar=e=>e?`&cwd=${ir(e)}`:``,or=(e,t)=>`/api/git?workspaceId=${ir(e)}&op=status${ar(t)}`,sr=(e,t,n,r)=>`/api/git?workspaceId=${ir(e)}&op=diff&path=${ir(t)}${n?`&staged=1`:``}${ar(r)}`;async function cr(e,t,n={},r){let i=t===`draft`?35e3:[`fetch`,`pull`,`push`].includes(t)?65e3:er;return nr(`/api/git?workspaceId=${ir(e)}&op=${ir(t)}${ar(r)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)},i)}var lr=20,ur=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`})},dr=e=>e.detached||e.branch===null?`(未在任何分支上)`:e.unborn?`${e.branch}(起始提交)`:e.branch,fr=e=>{let t=[];return e.ahead!==null&&t.push(`↑${e.ahead}`),e.behind!==null&&t.push(`↓${e.behind}`),t.length===0?null:t.join(` `)},pr=[{key:`staged`,title:`已暂存`},{key:`unstaged`,title:`未暂存`},{key:`untracked`,title:`未跟踪`}];function mr({path:e,onCancel:t,onConfirm:n}){let r=(0,u.useRef)(null),i=(0,u.useRef)(null);(0,u.useEffect)(()=>{i.current?.focus();let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,F.jsx)(`div`,{className:`overlay git-confirm-overlay`,"data-git-confirm-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,F.jsxs)(`div`,{className:`picker git-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`git-confirm-title`,tabIndex:-1,ref:r,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=r.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let i=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())},"data-git-confirm-dialog":`1`,children:[(0,F.jsx)(`h2`,{id:`git-confirm-title`,className:`git-confirm-title`,children:`确认丢弃更改?`}),(0,F.jsx)(`p`,{className:`git-confirm-desc`,children:`即将丢弃以下文件的所有未暂存修改:`}),(0,F.jsx)(`div`,{className:`git-confirm-path`,"data-git-confirm-path":e,title:e,children:e}),(0,F.jsx)(`p`,{className:`git-confirm-warning`,"data-git-confirm-warning":`1`,children:`⚠ 丢弃后不可撤销,此文件的本地未暂存修改将永久丢失(无法找回)。`}),(0,F.jsxs)(`div`,{className:`git-confirm-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel git-confirm-cancel`,"data-git-confirm-cancel":`1`,ref:i,onClick:t,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`git-confirm-danger`,"data-git-confirm-ok":`1`,onClick:n,children:`确认丢弃`})]})]})});return typeof document>`u`?a:(0,We.createPortal)(a,document.body)}function hr(e,t,n){let r=e?or(e,t):``,[i,a]=(0,u.useState)(),o=(0,u.useRef)({scope:r,ticket:0,busy:!1});o.current.scope!==r&&(o.current={scope:r,ticket:0,busy:!1});let s=(0,u.useCallback)((e=!1)=>{let t=o.current;if(!r||t.scope!==r||!n||t.busy&&!e)return;t.busy=!0;let i=++t.ticket,s=()=>o.current===t&&t.ticket===i;nr(r).then(e=>{s()&&(Sr(vr,r,e,16),a({scope:r,status:e,error:null}))}).catch(e=>{s()&&a({scope:r,status:null,error:rr(e)})}).finally(()=>{s()&&(t.busy=!1)})},[r,n]);(0,u.useEffect)(()=>{let e=o.current;s(!0);let t=()=>{document.visibilityState===`visible`&&s()},n=window.setInterval(t,15e3);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t),e.ticket++,e.busy=!1}},[s]);let c=(0,u.useCallback)(e=>{r&&o.current.scope===r&&(o.current.ticket++,o.current.busy=!1,Sr(vr,r,e,16),a({scope:r,status:e,error:null}))},[r]),l=i?.scope===r?i:void 0;return{status:l?l.status:vr.get(r)??null,error:l?.error??null,refresh:s,publish:c}}function gr(e,t,n={}){return`/api/git?${new URLSearchParams({workspaceId:e,op:t,...n})}`}function _r(e,t,n,r,i){return gr(e,i===void 0?`commit-detail`:`commit-diff`,{hash:n,...t?{cwd:t}:{},...r?{worktreeId:r}:{},...i===void 0?{}:{path:i}})}var vr=new Map,yr=new Map,br=new Map,xr=new Map;function Sr(e,t,n,r){if(e.delete(t),e.set(t,n),e.size>r){let t=e.keys().next().value;t!==void 0&&e.delete(t)}}function Cr(e){return e.length?`${e.length>1?`第一父提交`:`父提交`} ${e[0].slice(0,8)}`:`空树`}var wr={A:`新增`,M:`修改`,D:`删除`,R:`重命名`,C:`复制`,T:`类型更改`};function Tr({commits:e,workspaceId:t,cwd:n,worktreeId:r,onDiff:i,graph:a}){let[o,s]=(0,u.useState)(),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(0),p=o&&e.some(e=>e.hash===o)?_r(t,n,o,r):``;(0,u.useEffect)(()=>{if(!p||br.has(p))return;let e=new AbortController;return nr(p,{signal:e.signal}).then(t=>{e.signal.aborted||(Sr(br,p,t,40),l({url:p,detail:t}))}).catch(t=>{e.signal.aborted||l({url:p,error:rr(t).message})}),()=>e.abort()},[p,d]);let m=br.get(p),h=c?.url===p?c:m?{detail:m}:void 0;return(0,F.jsx)(F.Fragment,{children:e.map((e,t)=>{let n=o===e.hash,c=n?h?.detail:void 0,u=c?Cr(c.parents):``,d=a?.rows[t],p=`refs`in e?e.refs:[],m=`parents`in e&&e.parents.length>1;return(0,F.jsxs)(`div`,{className:d?`git-history-item git-graph-item`:`git-history-item`,style:d&&a?{minWidth:a.columns*Er+142}:void 0,children:[d&&a&&(0,F.jsx)(kr,{row:d,columns:a.columns,merge:m}),(0,F.jsxs)(`button`,{type:`button`,className:`git-log-row`,"data-git-commit":e.hash,"aria-expanded":n,onClick:()=>{s(n?void 0:e.hash),l(void 0)},children:[(0,F.jsx)(`span`,{className:`git-log-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`git-log-subject`,title:e.subject,children:e.subject||`(无提交说明)`}),(0,F.jsxs)(`span`,{className:`git-log-meta`,children:[(0,F.jsx)(`span`,{className:`git-log-hash`,title:e.hash,children:e.short}),(0,F.jsx)(`span`,{className:`git-log-author`,title:e.author,children:e.author}),(0,F.jsx)(`time`,{className:`git-log-date`,dateTime:e.date,title:e.date,children:ur(e.date)})]}),(m||p.length>0)&&(0,F.jsxs)(`span`,{className:`git-graph-refs`,children:[m&&(0,F.jsx)(`span`,{className:`git-graph-ref`,children:`合并`}),p.slice(0,3).map(e=>(0,F.jsx)(Or,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`)),p.length>3&&(0,F.jsxs)(`span`,{className:`git-graph-ref`,title:`展开提交查看全部引用`,children:[`+`,p.length-3]})]})]}),n&&(0,F.jsxs)(`div`,{className:`git-commit-changes`,"data-git-commit-changes":e.hash,children:[!h&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交中的文件…`}),h?.error&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,children:ct(h.error,`读取提交失败。`)}),(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>{l(void 0),f(e=>e+1)},children:`重试`})]}),c&&(0,F.jsxs)(F.Fragment,{children:[p.length>3&&(0,F.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,F.jsxs)(`summary`,{children:[p.length,` 个引用`]}),(0,F.jsx)(`div`,{className:`git-graph-refs`,children:p.map(e=>(0,F.jsx)(Or,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`))})]}),c.message.includes(`
|
|
22
|
+
`)&&(0,F.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,F.jsx)(`summary`,{children:`完整提交说明`}),(0,F.jsx)(`pre`,{children:c.message})]}),(0,F.jsxs)(`p`,{className:`git-scope-note`,title:c.parents[0],children:[c.files.length,` 个文件 · 对比`,u]}),!c.files.length&&(0,F.jsx)(`p`,{className:`git-scope-note`,children:`当前目录内没有文件改动。`}),c.files.map(t=>{let n=t.path.split(`/`).at(-1)??t.path,a=t.previousPath===void 0?t.path:`${t.previousPath} → ${t.path}`,o=wr[t.status[0]]??t.status;return(0,F.jsxs)(`button`,{type:`button`,className:`git-worktree-file git-commit-file`,"data-git-commit-file":t.path,title:`${o} · ${a}`,onClick:()=>i({hash:e.hash,base:u,file:t,worktreeId:r}),children:[(0,F.jsx)(ht,{path:t.path,size:15}),(0,F.jsxs)(`span`,{className:`git-commit-file-label`,children:[(0,F.jsx)(`span`,{children:n}),a!==n&&(0,F.jsx)(`small`,{children:a})]}),(0,F.jsx)(`span`,{className:`git-commit-file-status`,"aria-label":o,children:t.status[0]})]},t.path)})]})]})]},e.hash)})})}var Er=14,Dr={head:`当前检出`,worktree:`工作树`,branch:`本地分支`,remote:`远程跟踪分支`,tag:`标签`,stash:`贮藏`};function Or({refItem:e}){let{kind:t,name:n}=e;return(0,F.jsxs)(`span`,{className:`git-graph-ref`,"data-git-graph-ref":t,title:`${Dr[t]} · ${n}`,children:[t===`tag`||t===`worktree`?`${Dr[t]} `:``,n]})}function kr({row:e,columns:t,merge:n}){let r=e=>e*Er+Er/2,i=r(e.node.index),a=t*Er;return(0,F.jsxs)(`div`,{className:`git-graph-lines`,"aria-hidden":`true`,"data-git-graph-lane":e.node.index,"data-git-graph-incoming":e.incoming||void 0,children:[(0,F.jsxs)(`svg`,{className:`git-graph-top`,width:a,height:`32`,viewBox:`0 0 ${a} 32`,children:[e.through.map(e=>(0,F.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 32`},e.index)),e.incoming&&(0,F.jsx)(`path`,{"data-color":e.node.color%5,d:`M ${i} 0 V 16`}),e.parents.map(({hash:e,lane:t},n)=>(0,F.jsx)(`path`,{"data-git-graph-parent":e,"data-color":t.color%5,d:`M ${i} 16 C ${i} 24 ${r(t.index)} 22 ${r(t.index)} 32`},n)),n?(0,F.jsx)(`rect`,{"data-color":e.node.color%5,x:i-3.5,y:`12.5`,width:`7`,height:`7`,rx:`1`}):(0,F.jsx)(`circle`,{"data-color":e.node.color%5,cx:i,cy:`16`,r:`3.5`})]}),(0,F.jsx)(`svg`,{className:`git-graph-tail`,width:a,viewBox:`0 0 ${a} 1`,preserveAspectRatio:`none`,children:[...e.through,...e.parents.map(e=>e.lane).filter(t=>!e.through.some(e=>e.index===t.index))].map(e=>(0,F.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 1`},e.index))})]})}function Ar({workspaceId:e,cwd:t,revision:n,onDiff:r}){let i=gr(e,`graph`,t?{cwd:t}:{}),[a,o]=(0,u.useState)(()=>({page:yr.get(i),loading:!0})),s=(0,u.useRef)(void 0),c=(0,u.useCallback)(e=>{s.current?.abort();let t=new AbortController;s.current=t;let n=yr.get(i);o(t=>({page:e??n??t.page,loading:!0}));let r=new URLSearchParams(e?{offset:String(e.commits.length),snapshot:e.snapshot,after:e.commits.at(-1)?.hash??``}:n?{knownSnapshot:n.snapshot}:{});nr(`${i}&${r}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;let a=`unchanged`in r?yr.get(i)??n:e?{...r,commits:[...e.commits,...r.commits]}:r;a&&Sr(yr,i,a,8),o({page:a,loading:!1})}).catch(n=>{t.signal.aborted||o(t=>({page:t.page,error:rr(n),loading:!1,append:!!e}))})},[i]);(0,u.useEffect)(()=>(c(),()=>s.current?.abort()),[c,n]);let l=a.page,d=(0,u.useMemo)(()=>l&&qn(l.commits),[l]),f=a.error?.body.code===`graph_changed`;return(0,F.jsxs)(`section`,{className:`git-graph`,"data-git-graph":!0,"aria-label":`提交图`,"aria-busy":a.loading,children:[(0,F.jsx)(`p`,{className:`git-scope-note`,children:`仓库历史 · 文件差异按当前会话目录`}),l&&d&&l.commits.length>0&&(0,F.jsx)(`div`,{className:`git-graph-list`,tabIndex:0,role:`region`,"aria-label":`提交关系`,children:(0,F.jsx)(Tr,{commits:l.commits,workspaceId:e,cwd:t,onDiff:r,graph:d})}),l&&!l.commits.length&&(0,F.jsx)(`p`,{className:`rail-empty`,children:`暂无提交记录。`}),a.error&&(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,children:ct(a.error,`读取提交图失败。`)}),a.loading&&!l&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交图…`}),(a.error||l?.hasMore)&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action git-graph-more`,"data-git-graph-more":!0,disabled:a.loading,onClick:()=>c(f||a.error&&!a.append?void 0:l),children:a.loading?`读取中…`:f?`重新加载提交图`:a.error?`重试`:`加载更早的提交`})]})}function jr({workspaceId:e,conversationId:t,followedWorktreeId:n,revision:r,onDiff:i,onCommitDiff:a,onOpenConversation:o,repositoryOnly:s=!1}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),p=`super-pi.git-worktree:${JSON.stringify([e,t])}`,[m,h]=(0,u.useState)(()=>{try{return window.sessionStorage.getItem(p)??n??``}catch{return n??``}}),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(0),O=(0,u.useRef)(n),k=c?.find(e=>e.current),A=m?c?.find(e=>e.id===m):k??c?.[0],j=e=>{h(e);try{window.sessionStorage.setItem(p,e)}catch{}};(0,u.useEffect)(()=>{n&&n!==O.current&&j(n),O.current=n},[n,p]);let ee=async(n,r)=>{if(!(S||s&&n!==`open`)){C(n),T(``);try{let i={action:n,requestId:En(),worktreeId:r,...t&&!t.startsWith(`pending:`)?{conversationId:t}:{},...n===`create`?{branch:v.trim(),base:b.trim()}:{}},a=await nr(gr(e,`worktree-manage`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)},65e3);j(a.worktree.id),D(e=>e+1),n===`create`&&(y(``),x(``)),a.conversationId&&o?.(a.conversationId,a.workspaceId)}catch(e){T(rr(e).message)}finally{C(``)}}};(0,u.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await nr(gr(e,`worktrees`));t&&(l(n.worktrees),f(``))}catch(e){t&&f(rr(e).message)}finally{n=!1}}};r();let i=window.setInterval(()=>{document.visibilityState===`visible`&&r()},1e4);return()=>{t=!1,window.clearInterval(i)}},[e,r,E]),(0,u.useEffect)(()=>{if(s||!A||A.missing)return;let t=A.id,n=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await nr(gr(e,`worktree-inspect`,{worktreeId:t}));n&&_({id:t,value:r})}catch(e){n&&_({id:t,error:rr(e).message})}finally{r=!1}}};i();let a=window.setInterval(()=>{document.visibilityState===`visible`&&i()},5e3);return()=>{n=!1,window.clearInterval(a)}},[e,A?.id,A?.missing,r,E,s]);let M=!s&&g?.id===A?.id?g:void 0,te=M?.value?.comparison,N=M?.value?.status,ne=N?pr.map(e=>({...e,files:N[e.key]})):[],re=(e,t)=>(0,F.jsxs)(`button`,{type:`button`,className:`git-worktree-file`,title:e.path,"data-git-worktree-file":e.path,onClick:()=>i({...t,label:A?.branch??A?.name??`关联工作树`}),children:[(0,F.jsx)(ht,{path:e.path,size:15}),` `,(0,F.jsx)(`span`,{children:e.path}),(0,F.jsx)(`small`,{children:e.xy.trim()})]},e.path);return(0,F.jsxs)(`section`,{className:`git-worktrees`,"data-git-worktrees":!0,"aria-label":`仓库工作树`,children:[d&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:d}),!c&&!d&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树…`}),c&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`select`,{className:`git-view-search`,"aria-label":`选择要查看的工作树`,value:A?.id??``,onChange:e=>j(e.target.value),children:[!A&&(0,F.jsx)(`option`,{value:``,children:`选择工作树`}),c.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[e.branch??(e.head.slice(0,8)||e.name),` · `,e.name,e.primary?` · 主检出`:``,e.current?` · 当前`:``,e.missing?` · 已丢失`:``,e.locked?` · 已锁定`:``]},e.id))]}),A&&(0,F.jsx)(`p`,{className:`git-worktree-path`,title:A.path,"data-git-worktree-path":!0,children:A.path}),(0,F.jsxs)(`div`,{className:`git-worktree-actions`,children:[A&&!A.missing&&o&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-open":!0,disabled:!!S,onClick:()=>void ee(`open`,A.id),children:`在此新建会话`}),A&&!A.missing&&t&&!t.startsWith(`pending:`)&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-follow":!0,disabled:!!S||A.id===n,onClick:()=>void ee(`follow`,A.id),children:A.id===n?`会话已跟随`:`会话跟随`})]}),(0,F.jsxs)(`details`,{className:`git-worktree-create`,children:[(0,F.jsx)(`summary`,{title:s?Zn:void 0,children:`新建工作树`}),(0,F.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ee(`create`)},children:[(0,F.jsx)(`input`,{disabled:s,title:s?Zn:void 0,className:`git-view-search`,"aria-label":`工作树起点分支`,placeholder:`起点分支(默认当前提交)`,value:b,onChange:e=>x(e.target.value),maxLength:180}),(0,F.jsx)(`input`,{disabled:s,title:s?Zn:void 0,className:`git-view-search`,"aria-label":`工作树的新分支`,placeholder:`新分支(可选)`,value:v,onChange:e=>y(e.target.value),maxLength:180}),(0,F.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-worktree-create":!0,title:s?Zn:void 0,disabled:s||!!S,children:S===`create`?`创建中…`:`创建工作树`})]})]}),w&&(0,F.jsx)(`p`,{className:`tool-error`,"data-git-worktree-error":!0,role:`alert`,children:w}),A?.missing&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`此工作树目录已丢失。`}),!s&&A&&!A.missing&&!M&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树状态…`}),M?.error&&!A?.missing&&(0,F.jsx)(`p`,{className:`git-scope-note`,role:`alert`,children:M.error}),A&&!A.missing&&M?.value&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`git-worktree-summary`,"data-git-worktree-status":!0,children:[M.value.status.branch??`分离 HEAD`,A.current?` · 当前会话检出`:` · 仅查看`]}),ne.every(e=>!e.files.length)&&(0,F.jsx)(`p`,{className:`git-scope-note`,children:`无未提交改动。`}),ne.filter(e=>e.files.length).map(e=>(0,F.jsxs)(`div`,{className:`git-worktree-group`,children:[(0,F.jsxs)(`strong`,{children:[e.title,` · `,e.files.length]}),e.files.map(t=>re(t,{worktreeId:A.id,path:t.path,staged:e.key===`staged`}))]},e.key)),te&&!A.primary&&(0,F.jsxs)(`div`,{className:`git-worktree-group`,"data-git-worktree-comparison":!0,children:[(0,F.jsxs)(`strong`,{children:[`相对 `,te.base,` · ↑`,te.ahead,` ↓`,te.behind]}),te.files.map(e=>re(e,{worktreeId:A.id,path:e.path,staged:!1,comparison:`committed`})),(0,F.jsx)(Tr,{commits:te.commits,workspaceId:e,cwd:``,worktreeId:A.id,onDiff:e=>a({...e,worktreeLabel:A.branch??A.name})},A.id),te.truncated&&(0,F.jsx)(`p`,{className:`git-scope-note`,children:`显示最近 20 条独有提交。`})]})]})]})]})}function Mr({workspaceId:e,conversationId:t,cwd:n=``,followedWorktreeId:r,onOpenDiff:i,activeDiffUrl:a,onOpenConversation:o,sharedGit:s,repositoryOnly:c=!1}){let[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=s?s.status:l,h=s?s.error:f,g=s?.refresh,_=s?.publish,[v,y]=(0,u.useState)(()=>c||r?`worktrees`:`changes`),b=c&&Qn(v)?`worktrees`:v;(0,u.useEffect)(()=>{r&&y(`worktrees`)},[r]);let[x,S]=(0,u.useState)(``),[C,w]=(0,u.useState)(0),[T,E]=(0,u.useState)(0),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)({}),[j,ee]=(0,u.useState)(``),[M,te]=(0,u.useState)(null),[N,ne]=(0,u.useState)(``),[re,ie]=(0,u.useState)(``),[ae,oe]=(0,u.useState)(null),[se,ce]=(0,u.useState)(null),le=(0,u.useRef)(0),ue=(0,u.useCallback)(e=>{let t=++le.current;p(null),ie(``),E(e=>e+1),g?g(!0):nr(or(e,n)).then(e=>{t===le.current&&d(e)}).catch(e=>{t===le.current&&(d(null),p(rr(e)))})},[n,g]);(0,u.useEffect)(()=>{if(e)return ue(e),()=>{le.current++}},[e,n,ue]);let de=e=>{c&&Qn(e)||e!==b&&(y(e),S(``),w(0))},fe=Xn.find(e=>e.id===b)??Xn[0],pe=b===`log`||b===`branches`||b===`stash`,me=e&&m&&pe?`/api/git?workspaceId=${ir(e)}&op=${b}&limit=${lr}${ar(n)}&q=${ir(x.trim())}&offset=${C}`:``;(0,u.useEffect)(()=>{if(!me)return;let e=!0;O({url:me,result:xr.get(me)});let t=window.setTimeout(()=>{nr(me).then(t=>{e&&(Sr(xr,me,t,32),O({url:me,result:t}),`branches`in t&&A(e=>({...e,branches:t.total})),`stashes`in t&&A(e=>({...e,stash:t.total})))}).catch(t=>{e&&O({url:me,result:xr.get(me),error:rr(t).message})})},x.trim()?180:0);return()=>{e=!1,window.clearTimeout(t)}},[me,x,T]);let he=(t,r,a,o=!1)=>{if(!e||c)return;let s=a?.comparison?`共同祖先 → 工作树 HEAD`:o?`未跟踪文件`:r?`HEAD → 暂存区`:`暂存区 → 工作区`,l=a?.comparison?`已提交`:o?`未跟踪`:r?`已暂存`:`未暂存`;i({url:a?gr(e,`worktree-diff`,{worktreeId:a.worktreeId,path:t,staged:r?`1`:`0`,...a.comparison?{comparison:a.comparison}:{}}):sr(e,t,r,n),path:t,label:a?`${a.label} · ${l}`:l,comparison:a?`${a.label} · ${s}`:s})},ge=t=>{if(!e)return;let r=t.file.path,a=t.hash.slice(0,8);i({url:_r(e,t.worktreeId?``:n,t.hash,t.worktreeId,r),path:r,label:t.worktreeLabel?`${t.worktreeLabel} · ${a}`:a,comparison:`提交 ${a} · 对比${t.base}`,previousPath:t.file.previousPath,commitHash:t.hash})},P=(0,u.useCallback)(async(t,r={})=>{if(!e||ae||c&&t!==`fetch`)return!1;oe(t),ie(``);try{if(t===`draft`)return te(await cr(e,t,r,n)),!0;let i=await cr(e,t,r,n);return _?_(i):d(i),t!==`fetch`&&t!==`push`&&te(null),(t===`stash-save`||t===`switch`)&&w(0),E(e=>e+1),!0}catch(n){let r=rr(n);return t===`stash-apply`&&ue(e),ie(r.body?.error||r.message||`操作失败`),!1}finally{oe(null)}},[e,n,_,ae,ue,c]),_e=(0,u.useCallback)(()=>{if(!se)return;let e=se;ce(null),P(`discard`,{path:e})},[se,P]),ve=(0,u.useCallback)(()=>{ce(null)},[]),ye=m===null?null:fr(m),be=x.trim().toLowerCase(),xe=m===null?[]:pr.map(e=>({...e,entries:m[e.key].filter(e=>e.path.toLowerCase().includes(be))})),Se=m?new Set(pr.flatMap(e=>m[e.key].map(e=>e.path))).size:0,Ce=D?.url===me?D.result:void 0,we=D?.url===me?D.error:void 0,Te=Ce&&`commits`in Ce?Ce:null,Ee=Ce&&`branches`in Ce?Ce:null,De=Ce&&`stashes`in Ce?Ce:null,Oe=b===`log`?lr:50,ke=Ee??De,Ae=Te?Te.truncated:ke?C+Oe<ke.matches:!1;return e?(0,F.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,"data-git-scope":c?`repository`:`checkout`,children:[c&&(0,F.jsxs)(`p`,{className:`git-scope-note`,role:`status`,children:[`仓库浏览 · `,Zn]}),m===null&&h===null&&(0,F.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),h!==null&&(0,F.jsxs)(`div`,{className:`git-state-card${h.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":h.body.code??``,children:[(0,F.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:h.body.code===`not_a_repo`?`⌁`:`!`}),(0,F.jsx)(`strong`,{children:h.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,F.jsx)(`p`,{children:h.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,F.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>ue(e),children:`重新检查`})]}),m!==null&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`git-branch`,"data-git-branch":`1`,title:c?`查看仓库分支`:dr(m),"aria-label":c?`查看仓库分支`:`当前分支 ${dr(m)},查看分支`,onClick:()=>de(`branches`),children:[(0,F.jsx)(Tt,{name:`git`}),(0,F.jsx)(`span`,{children:c?`仓库分支`:dr(m)})]}),!c&&ye!==null&&(0,F.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:ye}),(0,F.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>ue(e),children:(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),(0,F.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,F.jsx)(`button`,{type:`button`,"data-git-action":`fetch`,onClick:()=>void P(`fetch`),disabled:ae!==null,title:`从上游获取远程引用`,children:ae===`fetch`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`获取中…`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),` Fetch`]})}),(0,F.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void P(`pull`),disabled:c||ae!==null,title:c?Zn:void 0,children:ae===`pull`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,F.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void P(`push`),disabled:c||ae!==null,title:c?Zn:void 0,children:ae===`push`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`})]}),(0,F.jsx)(`nav`,{className:`git-view-nav`,"aria-label":`源代码管理视图`,children:Xn.map(e=>{let t=c&&Qn(e.id),n=t?void 0:e.id===`changes`?Se:e.id===`branches`||e.id===`stash`?k[e.id]:void 0;return(0,F.jsxs)(`button`,{type:`button`,disabled:t,title:t?Zn:void 0,"data-git-view":e.id,"aria-pressed":e.id===b,onClick:()=>de(e.id),children:[(0,F.jsx)(Tt,{name:e.icon}),(0,F.jsx)(`span`,{className:`git-view-label`,children:e.title}),n!==void 0&&(0,F.jsx)(`span`,{className:`git-view-count`,children:n})]},e.id)})}),fe.search&&(0,F.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":fe.search,placeholder:fe.search,value:x,maxLength:160,onChange:e=>{S(e.target.value),w(0)}}),b===`worktrees`&&(0,F.jsx)(jr,{repositoryOnly:c,workspaceId:e,conversationId:t,followedWorktreeId:r,revision:T,onOpenConversation:o,onDiff:e=>he(e.path,e.staged,e),onCommitDiff:ge}),b===`graph`&&m&&(0,F.jsx)(Ar,{workspaceId:e,cwd:n,revision:T,onDiff:ge}),re&&(0,F.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,role:`alert`,children:re}),b===`changes`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,F.jsxs)(`form`,{className:`git-commit-input`,onSubmit:async e=>{e.preventDefault(),await P(`commit`,{message:j})&&ee(``)},children:[(0,F.jsx)(`input`,{value:j,onChange:e=>ee(e.target.value),placeholder:`提交说明…`,"aria-label":`提交消息`,disabled:ae!==null}),(0,F.jsx)(`button`,{type:`submit`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!m.staged.length||!j.trim()||ae!==null,children:ae===`commit`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):`提交`})]}),(0,F.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,F.jsxs)(`span`,{children:[m.staged.length,` 个已暂存`]}),(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`draft`,"aria-label":`用 AI 根据当前目录的暂存差异生成提交信息`,title:`用 AI 根据当前目录的暂存差异生成提交信息`,disabled:!m.staged.length||ae!==null,onClick:()=>void P(`draft`),children:ae===`draft`?`生成中…`:`✧ AI 生成`})]}),M&&(0,F.jsxs)(`div`,{className:`git-draft`,"data-git-draft":!0,children:[(0,F.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,F.jsx)(`strong`,{children:M.truncated?`提交说明建议 · 差异已截断`:`提交说明建议`}),(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"aria-label":`关闭提交说明建议`,onClick:()=>te(null),children:`×`})]}),(0,F.jsx)(`p`,{children:M.message}),(0,F.jsx)(`button`,{type:`button`,"data-git-draft-apply":!0,onClick:()=>{ee(M.message.replace(/\s*\n\s*/g,` `)),te(null)},children:`替换输入`})]})]}),xe.map(t=>(0,F.jsxs)(`div`,{className:`git-group`,"data-git-group":t.key,children:[(0,F.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":t.key,children:[(0,F.jsx)(`span`,{className:`git-group-title`,children:t.title}),(0,F.jsx)(`span`,{className:`git-group-count`,"data-git-count":t.key,children:t.entries.length}),!be&&t.key===`staged`&&t.entries.length>0&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:ae!==null,onClick:()=>void P(`unstage-all`),children:`全部取消暂存`}),!be&&t.key===`unstaged`&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stage-all`,disabled:ae!==null||!m.unstaged.length&&!m.untracked.length,onClick:()=>void P(`stage-all`),children:`全部暂存`})]}),(0,F.jsx)(`div`,{className:`git-group-body`,children:t.entries.length===0?(0,F.jsx)(`p`,{className:`git-group-empty`,"data-git-empty":t.key,children:be?`无匹配文件。`:`无${t.title}变更。`}):t.entries.map(r=>{let i=Jn(r.xy,t.key),o=Yn(r),s=a===sr(e,r.path,t.key===`staged`,n);return(0,F.jsxs)(`div`,{className:`git-file-row${s?` is-active`:``}`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":r.path,"data-git-kind":o?`dir`:`file`,title:r.path,onClick:()=>he(r.path,t.key===`staged`,void 0,t.key===`untracked`),children:[(0,F.jsx)(ht,{path:r.path,category:o?`folder`:void 0,size:15}),(0,F.jsx)(`span`,{className:`git-path`,children:o?`${r.name}/`:r.name}),r.path.includes(`/`)&&!o&&(0,F.jsx)(`span`,{className:`git-parent-path`,children:r.path.slice(0,r.path.lastIndexOf(`/`))})]}),(0,F.jsxs)(`span`,{className:`git-file-actions`,children:[t.key===`staged`?(0,F.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:ae!==null,onClick:e=>{e.stopPropagation(),P(`unstage`,{path:r.path})},children:`−`}):(0,F.jsx)(`button`,{type:`button`,title:`暂存`,disabled:ae!==null,onClick:e=>{e.stopPropagation(),P(`stage`,{path:r.path})},children:`+`}),t.key===`unstaged`&&(0,F.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${r.path} 的更改`,"aria-label":`丢弃更改 ${r.path}`,disabled:se!==null||ae!==null,onClick:e=>{e.stopPropagation(),ce(r.path)},children:`↶`})]}),(0,F.jsx)(`span`,{className:`git-badge git-badge-${i.kind} git-badge-slot-${i.slot}`,"data-git-badge":i.kind,"data-git-badge-slot":i.slot,children:i.label})]},r.path)})})]},t.key))]}),pe&&!Ce&&!we&&(0,F.jsxs)(`p`,{className:`rail-empty`,"data-git-log-loading":b===`log`?`1`:void 0,role:`status`,children:[`读取`,fe.title,`…`]}),pe&&we&&(0,F.jsxs)(`div`,{className:`git-page-error`,"data-git-log-error":b===`log`?`1`:void 0,children:[(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,title:lt(we),children:ct(we,`读取 Git 列表失败。`)}),(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>E(e=>e+1),children:`重试`})]}),b===`log`&&Te&&(0,F.jsx)(`div`,{className:`git-log`,"data-git-log":`1`,children:Te.commits.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:x.trim()?`没有匹配的提交。`:`暂无提交记录。`}):(0,F.jsx)(Tr,{commits:Te.commits,workspaceId:e,cwd:n,onDiff:ge})}),b===`branches`&&Ee&&(0,F.jsxs)(`div`,{className:`git-index-list`,"data-git-branches":!0,children:[!Ee.canWrite&&(0,F.jsx)(`p`,{className:`git-scope-note`,children:`切换分支会改变整个工作树,请在仓库根目录操作。`}),Ee.branches.length===0&&(0,F.jsx)(`p`,{className:`rail-empty`,children:x.trim()?`没有匹配的分支。`:`暂无分支。`}),Ee.branches.map(e=>(0,F.jsxs)(`div`,{className:`git-index-row`,"data-git-ref":e.name,children:[(0,F.jsx)(`span`,{className:`git-index-name`,title:e.name,children:e.name}),e.current?!c&&(0,F.jsx)(`span`,{className:`git-index-current`,children:`当前`}):e.local?Ee.canWrite&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`switch`,"aria-label":`切换到 ${e.name}`,disabled:c||ae!==null,title:c?Zn:void 0,onClick:()=>void P(`switch`,{target:e.name}),children:`切换`}):(0,F.jsx)(`span`,{className:`git-index-meta`,children:`远程`})]},`${e.local}:${e.name}`))]}),b===`stash`&&De&&(0,F.jsxs)(`div`,{className:`git-index-list`,"data-git-stashes":!0,children:[De.canWrite?(0,F.jsxs)(`form`,{className:`git-stash-form`,onSubmit:async e=>{e.preventDefault(),await P(`stash-save`,{message:N})&&ne(``)},children:[(0,F.jsxs)(`div`,{className:`git-commit-input`,children:[(0,F.jsx)(`input`,{className:`git-view-search`,value:N,onChange:e=>ne(e.target.value),maxLength:200,"aria-label":`贮藏说明`,placeholder:`贮藏说明(可选)`}),(0,F.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-action":`stash-save`,disabled:!Se||ae!==null,children:`贮藏改动`})]}),(0,F.jsx)(`p`,{className:`git-scope-note`,children:`保存整个工作树的改动,包括未跟踪文件。`})]}):(0,F.jsx)(`p`,{className:`git-scope-note`,children:`贮藏影响整个工作树,请在仓库根目录操作。`}),De.stashes.length===0&&(0,F.jsx)(`p`,{className:`rail-empty`,children:x.trim()?`没有匹配的贮藏。`:`暂无贮藏记录。`}),De.stashes.map(e=>(0,F.jsxs)(`div`,{className:`git-index-row`,"data-git-stash":e.hash,children:[(0,F.jsxs)(`div`,{className:`git-index-name`,title:e.subject,children:[e.subject,(0,F.jsxs)(`small`,{className:`git-index-meta`,children:[e.ref,` · `,ur(e.date)]})]}),De.canWrite&&(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stash-apply`,"aria-label":`恢复 ${e.ref}`,title:`恢复改动并保留贮藏记录`,disabled:ae!==null,onClick:()=>void P(`stash-apply`,{target:e.hash}),children:`恢复`})]},`${e.ref}:${e.hash}`))]}),b!==`changes`&&Ce&&(C>0||Ae)&&(0,F.jsxs)(`div`,{className:`git-pages`,children:[(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,disabled:!C,onClick:()=>w(Math.max(0,C-Oe)),children:`上一页`}),(0,F.jsxs)(`span`,{children:[`第 `,C/Oe+1,` 页`,ke?` · ${ke.matches} 项`:``]}),(0,F.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-log-truncated":Te?.truncated?`1`:void 0,disabled:!Ae,onClick:()=>w(C+Oe),children:`下一页`})]}),se!==null&&(0,F.jsx)(mr,{path:se,onCancel:ve,onConfirm:_e})]})]}):(0,F.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})})}var Nr=e=>e?.phase===`installing`||e?.phase===`restarting`;async function Pr(e){let t=await e.json().catch(()=>null);if(!t||!e.ok&&!(e.status===409&&t.operation))throw Error(typeof t?.error==`string`?t.error:`更新服务未返回有效状态(HTTP ${e.status})`);return t}async function Fr(e,t={},n){return Pr(await Ae(e,{...t,cache:`no-store`,signal:t.signal??AbortSignal.timeout(12e3)},n))}async function Ir(e,t){let n;for(let r=0;r<2;r++)try{let n=AbortSignal.any([e,AbortSignal.timeout(8e3)]),r=await Ae(`/api/update-status`,{cache:`no-store`,signal:n},t);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`)){let e=await Fr(`/api/health`,{signal:n},t);return{runningVersion:e.runningVersion,diskVersion:e.diskVersion,needsRestart:e.needsRestart,operation:null}}return await Pr(r)}catch(t){if(n=t,e.aborted||r===1)break;await new Promise(e=>window.setTimeout(e,400))}throw n instanceof Error?n:Error(`无法连接到服务。`)}var Lr=()=>AbortSignal.timeout(7e4),Rr=e=>e instanceof TypeError||e instanceof Error&&/fetch failed|failed to fetch|network|timeout|aborted/i.test(e.message),zr=`super-pi.update-legacy-receipt`;function Br(e){try{let t=JSON.parse(sessionStorage.getItem(e===`entry`?zr:`${zr}:${e}`)??`null`);if(t?.id&&Date.now()-Date.parse(t.startedAt)<18e5)return t}catch{}return null}function L(e,t){try{e?sessionStorage.setItem(t===`entry`?zr:`${zr}:${t}`,JSON.stringify(e)):sessionStorage.removeItem(t===`entry`?zr:`${zr}:${t}`)}catch{}}function Vr(e){let t=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));return Number.isFinite(t)?t<60?`已用时 ${t} 秒`:`已用时 ${Math.floor(t/60)} 分 ${t%60} 秒`:``}var Hr=e=>e?`v${e}`:`—`;function Ur(e){let{activeServer:t,connections:n}=se(),r=n.some(e=>e.id===t&&e.managed),i=(0,u.useRef)(t);i.current=t;let[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(),[b,x]=(0,u.useState)(),S=(0,u.useRef)(null),C=(0,u.useId)(),w=(0,u.useRef)(0),T=(0,u.useRef)(!1),E=(0,u.useRef)(!1),[D]=(0,u.useState)(()=>Br(t)),O=(0,u.useRef)(D);(0,u.useEffect)(()=>{w.current++,T.current=!1,E.current=!1,o(void 0),c(void 0),d(!1),p(!1),h(void 0),_(!1),y(void 0),x(void 0),O.current=Br(t)},[t]);let k=a?a.operation:O.current,A=a??e,j=Nr(k),ee=A?.needsRestart===!0,M=!!(s&&A&&s!==A.diskVersion),te=j||m!==void 0||f,N=g&&k?.phase===`restarting`,ne=k?.phase===`completed`&&k.targetVersion===A?.runningVersion,re=j||ee||!s&&k?.phase===`failed`,ie=j?k?.targetVersion:ee?A?.diskVersion:re?k?.targetVersion:s,ae=k&&Date.now()-Date.parse(k.changedAt)<3e5,oe=f?`checking`:m?`starting`:j?k?.phase??`idle`:ee?`needs-restart`:k?.phase===`failed`?`failed`:ne?`completed`:`idle`,ce=N?`等待服务上线`:oe===`checking`?`检查更新中`:oe===`starting`?`正在提交…`:oe===`installing`?`安装更新中`:oe===`restarting`?`重启服务中`:ee?`待重启`:oe===`failed`?`更新有异常`:M?`有可用更新`:ne&&ae?`更新完成`:`软件更新`;(0,u.useEffect)(()=>{let e=new AbortController,n,r=async()=>{let i=w.current;if(!T.current)try{let n=await Ir(e.signal,t);if(!e.signal.aborted&&i===w.current){let e=O.current;n.operation&&e?(O.current=null,L(null,t)):e&&(Nr(e)&&e.targetVersion===n.runningVersion&&!n.needsRestart?(O.current={...e,phase:`completed`,changedAt:new Date().toISOString()},L(O.current,t)):e.phase===`restarting`&&Date.now()-Date.parse(e.startedAt)>15e4&&(O.current={...e,phase:`failed`,changedAt:new Date().toISOString(),failure:{step:`restarting`,message:`等待重启超时,服务仍在运行旧版本。可以重试或查看服务日志。`}},L(O.current,t)),n.operation=O.current),o(e=>!j&&e?.runningVersion===n.runningVersion&&e.diskVersion===n.diskVersion&&e.needsRestart===n.needsRestart&&e.operation?.id===n.operation?.id&&e.operation?.phase===n.operation?.phase&&e.operation?.changedAt===n.operation?.changedAt?e:n),_(!1),x(void 0)}}catch(t){!e.signal.aborted&&i===w.current&&(_(!0),x(Rr(t)?`服务连接暂时中断,正在自动重试。`:t instanceof Error?t.message:`无法连接到服务。`))}e.signal.aborted||(n=window.setTimeout(r,l||j?1600:5e3))};return r(),()=>{e.abort(),window.clearTimeout(n)}},[l,j,t]),(0,u.useEffect)(()=>{l&&!S.current?.open?S.current?.showModal():!l&&S.current?.open&&S.current.close()},[l]);async function le(){if(!(T.current||E.current||j)){E.current=!0,p(!0),y(void 0);try{let e=await Fr(`/api/update-check`,{signal:Lr()},t);if(i.current!==t)return;o(e),c(e.latestVersion),_(!1),x(void 0)}catch(e){if(i.current!==t)return;y(e instanceof Error?e.message:`检查更新失败,请重试。`)}finally{if(i.current!==t)return;E.current=!1,p(!1)}}}async function ue(e){if(!(te||T.current||!a||g||e===`update`&&!M)){T.current=!0,w.current+=1,h(e),y(void 0);try{let n=await Fr(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e===`restart`?{restartOnly:!0}:{version:s})},t);if(i.current!==t)return;if(n.operation)O.current=null,L(null,t),o(n);else{let n=new Date().toISOString(),r={id:n,action:e,phase:e===`restart`?`restarting`:`installing`,fromVersion:a.runningVersion,targetVersion:e===`restart`?a.diskVersion:s,startedAt:n,changedAt:n};O.current=r,L(r,t),o({...a,operation:r})}}catch(e){if(i.current!==t)return;y(e instanceof Error?e.message:`无法确认请求是否送达,请检查当前状态。`)}finally{if(i.current!==t)return;T.current=!1,h(void 0)}}}let de=ee||k?.phase===`restarting`||m===`restart`,fe=e=>(0,F.jsxs)(`button`,{type:`button`,className:`software-update-entry ${e}`,"data-software-update-entry":oe,"aria-haspopup":`dialog`,title:r?`通过本地入口部署更新`:ce,"aria-label":r?`更新托管服务`:ce,onClick:()=>{r?window.dispatchEvent(new Event(`super-pi-open-server-management`)):(d(!0),!s&&!ee&&!j&&!(ne&&ae)&&le())},children:[(0,F.jsx)(Tt,{name:de?`restart`:`update`}),(0,F.jsx)(`span`,{children:r?`更新托管服务`:ce})]}),pe=N?`等待服务重新上线`:f?`正在检查可用版本`:m?m===`restart`?`正在请求重启`:`正在提交安装`:k?.phase===`installing`?`正在下载并安装更新`:k?.phase===`restarting`?`正在重启服务`:ee?`${Hr(A?.diskVersion)} 已安装,等待重启`:k?.phase===`failed`?k.failure?.step===`restarting`?`服务重启失败`:`更新安装失败`:ne?k?.action===`restart`?`服务已重启`:`更新完成`:M?`有新版本可安装`:s?`当前已是最新版本`:`检查是否有新版本`;return{entry:fe,panel:(0,F.jsx)(`dialog`,{ref:S,className:`software-update-dialog`,"aria-labelledby":C,onClose:()=>d(!1),onClick:e=>{e.target===e.currentTarget&&d(!1)},children:(0,F.jsxs)(`div`,{className:`software-update-content`,children:[(0,F.jsxs)(`div`,{className:`software-update-header`,children:[(0,F.jsxs)(`h2`,{id:C,children:[(0,F.jsx)(Tt,{name:`update`}),`软件更新 · `,me(t)]}),(0,F.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"aria-label":`关闭软件更新`,onClick:()=>d(!1),children:(0,F.jsx)(Tt,{name:`close`})})]}),(0,F.jsxs)(`dl`,{className:`software-update-versions`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`运行版本`}),(0,F.jsx)(`dd`,{"data-update-version":`running`,children:Hr(A?.runningVersion)})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`已安装`}),(0,F.jsx)(`dd`,{"data-update-version":`disk`,children:Hr(A?.diskVersion)})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:re?`目标版本`:`最新版本`}),(0,F.jsx)(`dd`,{"data-update-version":`target`,children:Hr(ie)})]})]}),(0,F.jsxs)(`div`,{className:`software-update-progress`,"data-update-progress":oe,children:[(0,F.jsx)(`div`,{className:`software-update-summary`,role:`status`,children:pe}),te&&(0,F.jsx)(`progress`,{"aria-label":pe}),k&&(j||ne)&&(0,F.jsx)(`small`,{"aria-hidden":`true`,children:j?Vr(k.startedAt):`当前运行 ${Hr(A?.runningVersion)}`}),N&&(0,F.jsx)(`small`,{children:k&&Date.now()-Date.parse(k.changedAt)>15e4?`服务暂未恢复,页面仍在尝试连接。可检查服务日志。`:`连接恢复后会核对运行版本。`}),g&&!N&&(0,F.jsx)(`small`,{children:b??`更新状态连接已中断,正在重新连接。`}),k?.phase===`failed`&&k.failure&&(0,F.jsx)(`p`,{role:`alert`,children:k.failure.message}),v&&!j&&(0,F.jsx)(`p`,{role:`alert`,children:v})]}),!te&&(ee||M)&&(0,F.jsx)(`p`,{className:`software-update-note`,children:`重启会短暂断开连接,正在运行的任务和终端可能中断。`}),(0,F.jsxs)(`div`,{className:`software-update-actions`,children:[!ee&&(0,F.jsx)(`button`,{type:`button`,className:`software-update-secondary`,"data-update-check":!0,disabled:te,onClick:()=>void le(),children:`检查更新`}),ee&&(0,F.jsxs)(`button`,{type:`button`,className:`software-update-primary`,"data-update-restart":!0,disabled:te||g||!a,onClick:()=>void ue(`restart`),children:[(0,F.jsx)(Tt,{name:`restart`}),`重启服务`]}),!ee&&M&&(0,F.jsxs)(`button`,{type:`button`,className:`software-update-primary`,"data-update-install":!0,disabled:te||g||!a,onClick:()=>void ue(`update`),children:[(0,F.jsx)(Tt,{name:`update`}),`安装 `,Hr(s),` 并重启`]})]})]})}),status:a}}function Wr(e){let t=0;return e.map(e=>e.key.startsWith(`m:`)?(t=Math.max(t,Number.isFinite(e.at)?e.at:0),{...e,at:t}):e).sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)}var Gr=new Set,Kr=new Map;function qr(){return typeof window>`u`||!(`Notification`in window)?`unsupported`:window.isSecureContext?Notification.permission:`insecure`}async function Jr(){return`Notification`in window?Notification.requestPermission():`denied`}function Yr(e,t,n,r,i){if(!Gr.has(e)){Gr.add(e);try{let t=`super-pi.notification.${e}`;if(localStorage.getItem(t))return;localStorage.setItem(t,`shown`)}catch{}if(!r&&`Notification`in window&&Notification.permission===`granted`)try{let r=new Notification(t,{body:n,tag:e,icon:new URL(`/favicon.png`,location.origin).href});Kr.set(e,r),r.onclick=()=>{window.focus(),i(),r.close(),Kr.delete(e)}}catch{}}}function Xr(e){for(let[t,n]of Kr)e.has(t)||(n.close(),Kr.delete(t))}var R=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15<s.length?s.slice(a,a+15)+`…`:s.slice(a);r+=l+c+u}super(r),this.name=`ParseError`,this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,e.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=t}},Zr=/([A-Z])/g,Qr=e=>e.replace(Zr,`-$1`).toLowerCase(),$r={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},ei=/[&><"']/g,ti=e=>String(e).replace(ei,e=>$r[e]),ni=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?ni(e.body[0]):e:e.type===`font`?ni(e.body):e,ri=new Set([`mathord`,`textord`,`atom`]),ii=e=>ri.has(ni(e).type),ai=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},oi={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format <type>`},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color <color>`,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro <def>`,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness <size>`,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size <n>`,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand <n>`,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function si(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function ci(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:si(Array.isArray(e.type)?e.type[0]:e.type)}function li(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?ci(r):a?a(i):i}var ui=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(oi)){var n=oi[t];n&&li(this,t,e,n)}}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=ai(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},di=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return bi[xi[this.id]]}sub(){return bi[Si[this.id]]}fracNum(){return bi[Ci[this.id]]}fracDen(){return bi[wi[this.id]]}cramp(){return bi[Ti[this.id]]}text(){return bi[Ei[this.id]]}isTight(){return this.size>=2}},fi=0,pi=1,mi=2,hi=3,gi=4,_i=5,vi=6,yi=7,bi=[new di(fi,0,!1),new di(pi,0,!0),new di(mi,1,!1),new di(hi,1,!0),new di(gi,2,!1),new di(_i,2,!0),new di(vi,3,!1),new di(yi,3,!0)],xi=[gi,_i,gi,_i,vi,yi,vi,yi],Si=[_i,_i,_i,_i,yi,yi,yi,yi],Ci=[mi,hi,gi,_i,vi,yi,vi,yi],wi=[hi,hi,_i,_i,yi,yi,yi,yi],Ti=[pi,pi,hi,hi,_i,_i,yi,yi],Ei=[fi,pi,mi,hi,mi,hi,mi,hi],Di={DISPLAY:bi[fi],TEXT:bi[mi],SCRIPT:bi[gi],SCRIPTSCRIPT:bi[vi]},Oi=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function ki(e){for(var t=0;t<Oi.length;t++)for(var n=Oi[t],r=0;r<n.blocks.length;r++){var i=n.blocks[r];if(e>=i[0]&&e<=i[1])return n.name}return null}var Ai=[];Oi.forEach(e=>e.blocks.forEach(e=>Ai.push(...e)));function ji(e){for(var t=0;t<Ai.length;t+=2)if(e>=Ai[t]&&e<=Ai[t+1])return!0;return!1}var Mi=e=>e+` `+e,Ni=80,Pi=function(e,t){return`M95,`+(622+e+t)+`
|
|
23
|
+
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
24
|
+
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
25
|
+
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
26
|
+
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
27
|
+
c69,-144,104.5,-217.7,106.5,-221
|
|
28
|
+
l`+e/2.075+` -`+e+`
|
|
29
|
+
c5.3,-9.3,12,-14,20,-14
|
|
30
|
+
H400000v`+(40+e)+`H845.2724
|
|
31
|
+
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
32
|
+
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
33
|
+
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},Fi=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
|
|
34
|
+
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
|
|
35
|
+
c340,-704.7,510.7,-1060.3,512,-1067
|
|
36
|
+
l`+e/2.084+` -`+e+`
|
|
37
|
+
c4.7,-7.3,11,-11,19,-11
|
|
38
|
+
H40000v`+(40+e)+`H1012.3
|
|
39
|
+
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
|
|
40
|
+
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
|
|
41
|
+
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
|
|
42
|
+
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
|
|
43
|
+
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},Ii=function(e,t){return`M983 `+(10+e+t)+`
|
|
44
|
+
l`+e/3.13+` -`+e+`
|
|
45
|
+
c4,-6.7,10,-10,18,-10 H400000v`+(40+e)+`
|
|
46
|
+
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
|
|
47
|
+
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
|
|
48
|
+
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
|
|
49
|
+
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
|
|
50
|
+
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
|
|
51
|
+
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
|
|
52
|
+
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},Li=function(e,t){return`M424,`+(2398+e+t)+`
|
|
53
|
+
c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
|
|
54
|
+
c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
|
|
55
|
+
s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
|
|
56
|
+
s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081
|
|
57
|
+
l`+e/4.223+` -`+e+`c4,-6.7,10,-10,18,-10 H400000
|
|
58
|
+
v`+(40+e)+`H1014.6
|
|
59
|
+
s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
|
|
60
|
+
c-2,6,-10,9,-24,9
|
|
61
|
+
c-8,0,-12,-0.7,-12,-2z M`+(1001+e)+` `+t+`
|
|
62
|
+
h400000v`+(40+e)+`h-400000z`},Ri=function(e,t){return`M473,`+(2713+e+t)+`
|
|
63
|
+
c339.3,-1799.3,509.3,-2700,510,-2702 l`+e/5.298+` -`+e+`
|
|
64
|
+
c3.3,-7.3,9.3,-11,18,-11 H400000v`+(40+e)+`H1017.7
|
|
65
|
+
s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9
|
|
66
|
+
c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200
|
|
67
|
+
c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26
|
|
68
|
+
s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,
|
|
69
|
+
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},zi=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},Bi=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
|
|
70
|
+
H742v`+r+`l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1
|
|
71
|
+
h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170
|
|
72
|
+
c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667
|
|
73
|
+
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},Vi=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=Pi(t,Ni);break;case`sqrtSize1`:r=Fi(t,Ni);break;case`sqrtSize2`:r=Ii(t,Ni);break;case`sqrtSize3`:r=Li(t,Ni);break;case`sqrtSize4`:r=Ri(t,Ni);break;case`sqrtTall`:r=Bi(t,Ni,n)}return r},Hi=function(e,t){switch(e){case`⎜`:return Mi(`M291 0 H417 V`+t+` H291z`);case`∣`:return Mi(`M145 0 H188 V`+t+` H145z`);case`∥`:return Mi(`M145 0 H188 V`+t+` H145z`)+Mi(`M367 0 H410 V`+t+` H367z`);case`⎟`:return Mi(`M457 0 H583 V`+t+` H457z`);case`⎢`:return Mi(`M319 0 H403 V`+t+` H319z`);case`⎥`:return Mi(`M263 0 H347 V`+t+` H263z`);case`⎪`:return Mi(`M384 0 H504 V`+t+` H384z`);case`⏐`:return Mi(`M312 0 H355 V`+t+` H312z`);case`‖`:return Mi(`M257 0 H300 V`+t+` H257z`)+Mi(`M478 0 H521 V`+t+` H478z`);default:return``}},Ui={doubleleftarrow:`M262 157
|
|
74
|
+
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
|
|
75
|
+
0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
|
|
76
|
+
14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
|
|
77
|
+
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
|
|
78
|
+
157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
|
|
79
|
+
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
|
|
80
|
+
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
|
|
81
|
+
m8 0v40h399730v-40zm0 194v40h399730v-40z`,doublerightarrow:`M399738 392l
|
|
82
|
+
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
|
|
83
|
+
14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
|
|
84
|
+
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
|
|
85
|
+
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
|
|
86
|
+
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
|
|
87
|
+
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
|
|
88
|
+
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`,leftarrow:`M400000 241H110l3-3c68.7-52.7 113.7-120
|
|
89
|
+
135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
|
|
90
|
+
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
|
|
91
|
+
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
|
|
92
|
+
490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
|
|
93
|
+
1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
|
|
94
|
+
l-3-3h399890zM100 241v40h399900v-40z`,leftbrace:`M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
|
|
95
|
+
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
|
|
96
|
+
5-6 9-10 13-.7 1-7.3 1-20 1H6z`,leftbraceunder:`M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
|
|
97
|
+
35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
|
|
98
|
+
0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
|
|
99
|
+
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`,leftgroup:`M400000 80
|
|
100
|
+
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
|
|
101
|
+
435 0h399565z`,leftgroupunder:`M400000 262
|
|
102
|
+
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
|
|
103
|
+
435 219h399565z`,leftharpoon:`M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
|
|
104
|
+
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
|
|
105
|
+
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
|
|
106
|
+
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`,leftharpoonplus:`M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
|
|
107
|
+
20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
|
|
108
|
+
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
|
|
109
|
+
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
|
|
110
|
+
m0 0v40h400000v-40z`,leftharpoondown:`M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
|
|
111
|
+
5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
|
|
112
|
+
1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
|
|
113
|
+
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`,leftharpoondownplus:`M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
|
|
114
|
+
10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
|
|
115
|
+
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
|
|
116
|
+
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,lefthook:`M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
|
|
117
|
+
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
|
|
118
|
+
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
|
|
119
|
+
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:Mi(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:Mi(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:Mi(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:Mi(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
|
|
120
|
+
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
|
|
121
|
+
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
|
|
122
|
+
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:Mi(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
|
|
123
|
+
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
|
|
124
|
+
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
|
|
125
|
+
311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
|
|
126
|
+
12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`,midbraceunder:`M199572 214
|
|
127
|
+
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
|
|
128
|
+
53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
|
|
129
|
+
11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
|
|
130
|
+
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`,oiintSize1:`M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
|
|
131
|
+
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
|
|
132
|
+
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
|
|
133
|
+
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`,oiintSize2:`M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8
|
|
134
|
+
-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z
|
|
135
|
+
m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2
|
|
136
|
+
c0 110 84 276 504 276s502.4-166 502.4-276z`,oiiintSize1:`M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
|
|
137
|
+
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
|
|
138
|
+
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
|
|
139
|
+
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`,oiiintSize2:`M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8
|
|
140
|
+
-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z
|
|
141
|
+
m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1
|
|
142
|
+
c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`,rightarrow:`M0 241v40h399891c-47.3 35.3-84 78-110 128
|
|
143
|
+
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
|
|
144
|
+
11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
|
|
145
|
+
39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
|
|
146
|
+
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
|
|
147
|
+
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
|
|
148
|
+
151.7 139 205zm0 0v40h399900v-40z`,rightbrace:`M400000 542l
|
|
149
|
+
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
|
|
150
|
+
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
|
|
151
|
+
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`,rightbraceunder:`M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
|
|
152
|
+
28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
|
|
153
|
+
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`,rightgroup:`M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
|
|
154
|
+
3-1 3-3v-38c-76-158-257-219-435-219H0z`,rightgroupunder:`M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
|
|
155
|
+
0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`,rightharpoon:`M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
|
|
156
|
+
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
|
|
157
|
+
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
|
|
158
|
+
69.2 92 94.5zm0 0v40h399900v-40z`,rightharpoonplus:`M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
|
|
159
|
+
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
|
|
160
|
+
2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
|
|
161
|
+
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,rightharpoondown:`M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
|
|
162
|
+
8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
|
|
163
|
+
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
|
|
164
|
+
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`,rightharpoondownplus:`M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
|
|
165
|
+
15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
|
|
166
|
+
8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
|
|
167
|
+
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
|
|
168
|
+
m0-194v40h400000v-40zm0 0v40h400000v-40z`,righthook:`M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
|
|
169
|
+
15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
|
|
170
|
+
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
|
|
171
|
+
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:Mi(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:Mi(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:Mi(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
|
|
172
|
+
1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
|
|
173
|
+
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
|
|
174
|
+
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,twoheadleftarrow:`M0 167c68 40
|
|
175
|
+
115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
|
|
176
|
+
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
|
|
177
|
+
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
|
|
178
|
+
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
|
|
179
|
+
10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`,twoheadrightarrow:`M400000 167
|
|
180
|
+
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
|
|
181
|
+
41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
|
|
182
|
+
18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
|
|
183
|
+
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
|
|
184
|
+
101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`,tilde1:`M200 55.538c-77 0-168 73.953-177 73.953-3 0-7
|
|
185
|
+
-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0
|
|
186
|
+
114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0
|
|
187
|
+
4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128
|
|
188
|
+
-68.267.847-113-73.952-191-73.952z`,tilde2:`M344 55.266c-142 0-300.638 81.316-311.5 86.418
|
|
189
|
+
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
|
|
190
|
+
31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
|
|
191
|
+
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
|
|
192
|
+
181.476 676 181.476c-149 0-189-126.21-332-126.21z`,tilde3:`M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457
|
|
193
|
+
-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0
|
|
194
|
+
411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697
|
|
195
|
+
16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696
|
|
196
|
+
-338 0-409-156.573-744-156.573z`,tilde4:`M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345
|
|
197
|
+
-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409
|
|
198
|
+
177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9
|
|
199
|
+
14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409
|
|
200
|
+
-175.236-744-175.236z`,vec:`M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
|
|
201
|
+
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
|
|
202
|
+
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
|
|
203
|
+
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
|
|
204
|
+
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
|
|
205
|
+
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
|
|
206
|
+
c-16-25.333-24-45-24-59z`,widehat1:`M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22
|
|
207
|
+
c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`,widehat2:`M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
|
|
208
|
+
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widehat3:`M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10
|
|
209
|
+
-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widehat4:`M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10
|
|
210
|
+
-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widecheck1:`M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,
|
|
211
|
+
-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`,widecheck2:`M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
|
212
|
+
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,widecheck3:`M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
|
213
|
+
-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,widecheck4:`M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
|
214
|
+
-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,baraboveleftarrow:`M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202
|
|
215
|
+
c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5
|
|
216
|
+
c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130
|
|
217
|
+
s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47
|
|
218
|
+
121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6
|
|
219
|
+
s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11
|
|
220
|
+
c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z
|
|
221
|
+
M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`,rightarrowabovebar:`M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32
|
|
222
|
+
-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0
|
|
223
|
+
13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39
|
|
224
|
+
-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5
|
|
225
|
+
-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
|
|
226
|
+
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
|
|
227
|
+
151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`,baraboveshortleftharpoon:`M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
|
|
228
|
+
c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17
|
|
229
|
+
c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21
|
|
230
|
+
c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40
|
|
231
|
+
c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z
|
|
232
|
+
M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`,rightharpoonaboveshortbar:`M0,241 l0,40c399126,0,399993,0,399993,0
|
|
233
|
+
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
|
234
|
+
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
|
235
|
+
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
|
236
|
+
M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`,shortbaraboveleftharpoon:`M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
|
|
237
|
+
c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,
|
|
238
|
+
1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,
|
|
239
|
+
-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z
|
|
240
|
+
M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`,shortrightharpoonabovebar:`M53,241l0,40c398570,0,399437,0,399437,0
|
|
241
|
+
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
|
242
|
+
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
|
243
|
+
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
|
244
|
+
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},Wi=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
|
|
245
|
+
H403z M403 1759 V0 H319 V1759 v`+t+` v1759 v84 h84z`;case`rbrack`:return`M347 1759 V0 H0 V84 H263 V1759 v`+t+` v1759 H0 v84 H347z
|
|
246
|
+
M347 1759 V0 H263 V1759 v`+t+` v1759 h84z`;case`vert`:return`M145 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
|
|
247
|
+
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
248
|
+
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v`+t+` v585 h43z`;case`doublevert`:return`M145 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
|
|
249
|
+
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
250
|
+
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v`+t+` v585 h43z
|
|
251
|
+
M367 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
|
|
252
|
+
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
253
|
+
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v`+t+` v585 h43z`;case`lfloor`:return`M319 602 V0 H403 V602 v`+t+` v1715 h263 v84 H319z
|
|
254
|
+
MM319 602 V0 H403 V602 v`+t+` v1715 H319z`;case`rfloor`:return`M319 602 V0 H403 V602 v`+t+` v1799 H0 v-84 H319z
|
|
255
|
+
MM319 602 V0 H403 V602 v`+t+` v1715 H319z`;case`lceil`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v602 h84z
|
|
256
|
+
M403 1759 V0 H319 V1759 v`+t+` v602 h84z`;case`rceil`:return`M347 1759 V0 H0 V84 H263 V1759 v`+t+` v602 h84z
|
|
257
|
+
M347 1759 V0 h-84 V1759 v`+t+` v602 h84z`;case`lparen`:return`M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1
|
|
258
|
+
c-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,
|
|
259
|
+
-36,557 l0,`+(t+84)+`c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,
|
|
260
|
+
949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9
|
|
261
|
+
c0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,
|
|
262
|
+
-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189
|
|
263
|
+
l0,-`+(t+92)+`c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,
|
|
264
|
+
-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z`;case`rparen`:return`M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,
|
|
265
|
+
63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5
|
|
266
|
+
c11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,`+(t+9)+`
|
|
267
|
+
c-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664
|
|
268
|
+
c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11
|
|
269
|
+
c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
|
|
270
|
+
c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
|
|
271
|
+
l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
272
|
+
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function Gi(e){return`toText`in e}var Ki=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(Gi(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},qi={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},Ji={ex:!0,em:!0,mu:!0},Yi=function(e){return typeof e!=`string`&&(e=e.unit),e in qi||e in Ji||e===`ex`},Xi=function(e,t){var n;if(e.unit in qi)n=qi[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new R(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},z=function(e){return+e.toFixed(4)+`em`},Zi=function(e){return e.filter(e=>e).join(` `)},Qi=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=Qr(n)+`:`+r+`;`)}return t},$i=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},ea=function(e){var t=document.createElement(e);t.className=Zi(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},ta=/[\s"'>/=\x00-\x1f]/,na=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+ti(Zi(this.classes))+`"`);var n=Qi(this.style);n&&(t+=` style="`+ti(n)+`"`);for(var r of Object.keys(this.attributes)){if(ta.test(r))throw new R(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+ti(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},ra=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,$i.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return ea.call(this,`span`)}toMarkup(){return na.call(this,`span`)}},ia=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,$i.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return ea.call(this,`a`)}toMarkup(){return na.call(this,`a`)}},aa=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+ti(this.src)+`"`+(` alt="`+ti(this.alt)+`"`),t=Qi(this.style);return t&&(e+=` style="`+ti(t)+`"`),e+=`'/>`,e}},oa={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},sa=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=ki(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=oa[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=z(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=Zi(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=ti(Zi(this.classes)),t+=`"`);var n=``;this.italic>0&&(n+=`margin-right:`+z(this.italic)+`;`),n+=Qi(this.style),n&&(e=!0,t+=` style="`+ti(n)+`"`);var r=ti(this.text);return e?(t+=`>`,t+=r,t+=`</span>`,t):r}},ca=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(var n=0;n<this.children.length;n++)e.appendChild(this.children[n].toNode());return e}toMarkup(){var e=`<svg xmlns="http://www.w3.org/2000/svg"`;for(var t of Object.keys(this.attributes))e+=` `+t+`="`+ti(this.attributes[t])+`"`;e+=`>`;for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+=`</svg>`,e}},la=class{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return this.alternate?e.setAttribute(`d`,this.alternate):e.setAttribute(`d`,Ui[this.pathName]),e}toMarkup(){return this.alternate?`<path d="`+ti(this.alternate)+`"/>`:`<path d="`+ti(Ui[this.pathName])+`"/>`}},ua=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){var e=`<line`;for(var t of Object.keys(this.attributes))e+=` `+t+`="`+ti(this.attributes[t])+`"`;return e+=`/>`,e}};function da(e){if(e instanceof sa)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function fa(e){if(e instanceof ra)return e;throw Error(`Expected span<HtmlDomNode> but got `+String(e)+`.`)}var pa=e=>e instanceof ra||e instanceof ia||e instanceof Ki,ma={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},ha={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},ga={Å:`A`,Ð:`D`,Þ:`o`,å:`a`,ð:`d`,þ:`o`,А:`A`,Б:`B`,В:`B`,Г:`F`,Д:`A`,Е:`E`,Ж:`K`,З:`3`,И:`N`,Й:`N`,К:`K`,Л:`N`,М:`M`,Н:`H`,О:`O`,П:`N`,Р:`P`,С:`C`,Т:`T`,У:`y`,Ф:`O`,Х:`X`,Ц:`U`,Ч:`h`,Ш:`W`,Щ:`W`,Ъ:`B`,Ы:`X`,Ь:`B`,Э:`3`,Ю:`X`,Я:`R`,а:`a`,б:`b`,в:`a`,г:`r`,д:`y`,е:`e`,ж:`m`,з:`e`,и:`n`,й:`n`,к:`n`,л:`n`,м:`m`,н:`n`,о:`o`,п:`n`,р:`p`,с:`c`,т:`o`,у:`y`,ф:`b`,х:`x`,ц:`n`,ч:`n`,ш:`w`,щ:`w`,ъ:`a`,ы:`m`,ь:`a`,э:`e`,ю:`m`,я:`r`};function _a(e,t){ma[e]=t}function va(e,t,n){if(!ma[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=ma[t][r];if(!i&&e[0]in ga&&(r=ga[e[0]].charCodeAt(0),i=ma[t][r]),!i&&n===`text`&&ji(r)&&(i=ma[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var ya={};function ba(e){var t=e>=5?0:e>=3?1:2;if(!ya[t]){var n=ya[t]={cssEmPerMu:ha.quad[t]/18};for(var r of Object.keys(ha))n[r]=ha[r][t]}return ya[t]}var xa={math:{},text:{}};function B(e,t,n,r,i,a){xa[e][i]={font:t,group:n,replace:r},a&&r&&(xa[e][r]=xa[e][i])}var V=`math`,H=`text`,U=`main`,W=`ams`,Sa=`accent-token`,Ca=`bin`,wa=`close`,Ta=`inner`,Ea=`mathord`,Da=`op-token`,Oa=`open`,ka=`punct`,G=`rel`,Aa=`spacing`,K=`textord`;B(V,U,G,`≡`,`\\equiv`,!0),B(V,U,G,`≺`,`\\prec`,!0),B(V,U,G,`≻`,`\\succ`,!0),B(V,U,G,`∼`,`\\sim`,!0),B(V,U,G,`⊥`,`\\perp`),B(V,U,G,`⪯`,`\\preceq`,!0),B(V,U,G,`⪰`,`\\succeq`,!0),B(V,U,G,`≃`,`\\simeq`,!0),B(V,U,G,`∣`,`\\mid`,!0),B(V,U,G,`≪`,`\\ll`,!0),B(V,U,G,`≫`,`\\gg`,!0),B(V,U,G,`≍`,`\\asymp`,!0),B(V,U,G,`∥`,`\\parallel`),B(V,U,G,`⋈`,`\\bowtie`,!0),B(V,U,G,`⌣`,`\\smile`,!0),B(V,U,G,`⊑`,`\\sqsubseteq`,!0),B(V,U,G,`⊒`,`\\sqsupseteq`,!0),B(V,U,G,`≐`,`\\doteq`,!0),B(V,U,G,`⌢`,`\\frown`,!0),B(V,U,G,`∋`,`\\ni`,!0),B(V,U,G,`∝`,`\\propto`,!0),B(V,U,G,`⊢`,`\\vdash`,!0),B(V,U,G,`⊣`,`\\dashv`,!0),B(V,U,G,`∋`,`\\owns`),B(V,U,ka,`.`,`\\ldotp`),B(V,U,ka,`⋅`,`\\cdotp`),B(V,U,ka,`⋅`,`·`),B(H,U,K,`⋅`,`·`),B(V,U,K,`#`,`\\#`),B(H,U,K,`#`,`\\#`),B(V,U,K,`&`,`\\&`),B(H,U,K,`&`,`\\&`),B(V,U,K,`ℵ`,`\\aleph`,!0),B(V,U,K,`∀`,`\\forall`,!0),B(V,U,K,`ℏ`,`\\hbar`,!0),B(V,U,K,`∃`,`\\exists`,!0),B(V,U,K,`∇`,`\\nabla`,!0),B(V,U,K,`♭`,`\\flat`,!0),B(V,U,K,`ℓ`,`\\ell`,!0),B(V,U,K,`♮`,`\\natural`,!0),B(V,U,K,`♣`,`\\clubsuit`,!0),B(V,U,K,`℘`,`\\wp`,!0),B(V,U,K,`♯`,`\\sharp`,!0),B(V,U,K,`♢`,`\\diamondsuit`,!0),B(V,U,K,`ℜ`,`\\Re`,!0),B(V,U,K,`♡`,`\\heartsuit`,!0),B(V,U,K,`ℑ`,`\\Im`,!0),B(V,U,K,`♠`,`\\spadesuit`,!0),B(V,U,K,`§`,`\\S`,!0),B(H,U,K,`§`,`\\S`),B(V,U,K,`¶`,`\\P`,!0),B(H,U,K,`¶`,`\\P`),B(V,U,K,`†`,`\\dag`),B(H,U,K,`†`,`\\dag`),B(H,U,K,`†`,`\\textdagger`),B(V,U,K,`‡`,`\\ddag`),B(H,U,K,`‡`,`\\ddag`),B(H,U,K,`‡`,`\\textdaggerdbl`),B(V,U,wa,`⎱`,`\\rmoustache`,!0),B(V,U,Oa,`⎰`,`\\lmoustache`,!0),B(V,U,wa,`⟯`,`\\rgroup`,!0),B(V,U,Oa,`⟮`,`\\lgroup`,!0),B(V,U,Ca,`∓`,`\\mp`,!0),B(V,U,Ca,`⊖`,`\\ominus`,!0),B(V,U,Ca,`⊎`,`\\uplus`,!0),B(V,U,Ca,`⊓`,`\\sqcap`,!0),B(V,U,Ca,`∗`,`\\ast`),B(V,U,Ca,`⊔`,`\\sqcup`,!0),B(V,U,Ca,`◯`,`\\bigcirc`,!0),B(V,U,Ca,`∙`,`\\bullet`,!0),B(V,U,Ca,`‡`,`\\ddagger`),B(V,U,Ca,`≀`,`\\wr`,!0),B(V,U,Ca,`⨿`,`\\amalg`),B(V,U,Ca,`&`,`\\And`),B(V,U,G,`⟵`,`\\longleftarrow`,!0),B(V,U,G,`⇐`,`\\Leftarrow`,!0),B(V,U,G,`⟸`,`\\Longleftarrow`,!0),B(V,U,G,`⟶`,`\\longrightarrow`,!0),B(V,U,G,`⇒`,`\\Rightarrow`,!0),B(V,U,G,`⟹`,`\\Longrightarrow`,!0),B(V,U,G,`↔`,`\\leftrightarrow`,!0),B(V,U,G,`⟷`,`\\longleftrightarrow`,!0),B(V,U,G,`⇔`,`\\Leftrightarrow`,!0),B(V,U,G,`⟺`,`\\Longleftrightarrow`,!0),B(V,U,G,`↦`,`\\mapsto`,!0),B(V,U,G,`⟼`,`\\longmapsto`,!0),B(V,U,G,`↗`,`\\nearrow`,!0),B(V,U,G,`↩`,`\\hookleftarrow`,!0),B(V,U,G,`↪`,`\\hookrightarrow`,!0),B(V,U,G,`↘`,`\\searrow`,!0),B(V,U,G,`↼`,`\\leftharpoonup`,!0),B(V,U,G,`⇀`,`\\rightharpoonup`,!0),B(V,U,G,`↙`,`\\swarrow`,!0),B(V,U,G,`↽`,`\\leftharpoondown`,!0),B(V,U,G,`⇁`,`\\rightharpoondown`,!0),B(V,U,G,`↖`,`\\nwarrow`,!0),B(V,U,G,`⇌`,`\\rightleftharpoons`,!0),B(V,W,G,`≮`,`\\nless`,!0),B(V,W,G,``,`\\@nleqslant`),B(V,W,G,``,`\\@nleqq`),B(V,W,G,`⪇`,`\\lneq`,!0),B(V,W,G,`≨`,`\\lneqq`,!0),B(V,W,G,``,`\\@lvertneqq`),B(V,W,G,`⋦`,`\\lnsim`,!0),B(V,W,G,`⪉`,`\\lnapprox`,!0),B(V,W,G,`⊀`,`\\nprec`,!0),B(V,W,G,`⋠`,`\\npreceq`,!0),B(V,W,G,`⋨`,`\\precnsim`,!0),B(V,W,G,`⪹`,`\\precnapprox`,!0),B(V,W,G,`≁`,`\\nsim`,!0),B(V,W,G,``,`\\@nshortmid`),B(V,W,G,`∤`,`\\nmid`,!0),B(V,W,G,`⊬`,`\\nvdash`,!0),B(V,W,G,`⊭`,`\\nvDash`,!0),B(V,W,G,`⋪`,`\\ntriangleleft`),B(V,W,G,`⋬`,`\\ntrianglelefteq`,!0),B(V,W,G,`⊊`,`\\subsetneq`,!0),B(V,W,G,``,`\\@varsubsetneq`),B(V,W,G,`⫋`,`\\subsetneqq`,!0),B(V,W,G,``,`\\@varsubsetneqq`),B(V,W,G,`≯`,`\\ngtr`,!0),B(V,W,G,``,`\\@ngeqslant`),B(V,W,G,``,`\\@ngeqq`),B(V,W,G,`⪈`,`\\gneq`,!0),B(V,W,G,`≩`,`\\gneqq`,!0),B(V,W,G,``,`\\@gvertneqq`),B(V,W,G,`⋧`,`\\gnsim`,!0),B(V,W,G,`⪊`,`\\gnapprox`,!0),B(V,W,G,`⊁`,`\\nsucc`,!0),B(V,W,G,`⋡`,`\\nsucceq`,!0),B(V,W,G,`⋩`,`\\succnsim`,!0),B(V,W,G,`⪺`,`\\succnapprox`,!0),B(V,W,G,`≆`,`\\ncong`,!0),B(V,W,G,``,`\\@nshortparallel`),B(V,W,G,`∦`,`\\nparallel`,!0),B(V,W,G,`⊯`,`\\nVDash`,!0),B(V,W,G,`⋫`,`\\ntriangleright`),B(V,W,G,`⋭`,`\\ntrianglerighteq`,!0),B(V,W,G,``,`\\@nsupseteqq`),B(V,W,G,`⊋`,`\\supsetneq`,!0),B(V,W,G,``,`\\@varsupsetneq`),B(V,W,G,`⫌`,`\\supsetneqq`,!0),B(V,W,G,``,`\\@varsupsetneqq`),B(V,W,G,`⊮`,`\\nVdash`,!0),B(V,W,G,`⪵`,`\\precneqq`,!0),B(V,W,G,`⪶`,`\\succneqq`,!0),B(V,W,G,``,`\\@nsubseteqq`),B(V,W,Ca,`⊴`,`\\unlhd`),B(V,W,Ca,`⊵`,`\\unrhd`),B(V,W,G,`↚`,`\\nleftarrow`,!0),B(V,W,G,`↛`,`\\nrightarrow`,!0),B(V,W,G,`⇍`,`\\nLeftarrow`,!0),B(V,W,G,`⇏`,`\\nRightarrow`,!0),B(V,W,G,`↮`,`\\nleftrightarrow`,!0),B(V,W,G,`⇎`,`\\nLeftrightarrow`,!0),B(V,W,G,`△`,`\\vartriangle`),B(V,W,K,`ℏ`,`\\hslash`),B(V,W,K,`▽`,`\\triangledown`),B(V,W,K,`◊`,`\\lozenge`),B(V,W,K,`Ⓢ`,`\\circledS`),B(V,W,K,`®`,`\\circledR`),B(H,W,K,`®`,`\\circledR`),B(V,W,K,`∡`,`\\measuredangle`,!0),B(V,W,K,`∄`,`\\nexists`),B(V,W,K,`℧`,`\\mho`),B(V,W,K,`Ⅎ`,`\\Finv`,!0),B(V,W,K,`⅁`,`\\Game`,!0),B(V,W,K,`‵`,`\\backprime`),B(V,W,K,`▲`,`\\blacktriangle`),B(V,W,K,`▼`,`\\blacktriangledown`),B(V,W,K,`■`,`\\blacksquare`),B(V,W,K,`⧫`,`\\blacklozenge`),B(V,W,K,`★`,`\\bigstar`),B(V,W,K,`∢`,`\\sphericalangle`,!0),B(V,W,K,`∁`,`\\complement`,!0),B(V,W,K,`ð`,`\\eth`,!0),B(H,U,K,`ð`,`ð`),B(V,W,K,`╱`,`\\diagup`),B(V,W,K,`╲`,`\\diagdown`),B(V,W,K,`□`,`\\square`),B(V,W,K,`□`,`\\Box`),B(V,W,K,`◊`,`\\Diamond`),B(V,W,K,`¥`,`\\yen`,!0),B(H,W,K,`¥`,`\\yen`,!0),B(V,W,K,`✓`,`\\checkmark`,!0),B(H,W,K,`✓`,`\\checkmark`),B(V,W,K,`ℶ`,`\\beth`,!0),B(V,W,K,`ℸ`,`\\daleth`,!0),B(V,W,K,`ℷ`,`\\gimel`,!0),B(V,W,K,`ϝ`,`\\digamma`,!0),B(V,W,K,`ϰ`,`\\varkappa`),B(V,W,Oa,`┌`,`\\@ulcorner`,!0),B(V,W,wa,`┐`,`\\@urcorner`,!0),B(V,W,Oa,`└`,`\\@llcorner`,!0),B(V,W,wa,`┘`,`\\@lrcorner`,!0),B(V,W,G,`≦`,`\\leqq`,!0),B(V,W,G,`⩽`,`\\leqslant`,!0),B(V,W,G,`⪕`,`\\eqslantless`,!0),B(V,W,G,`≲`,`\\lesssim`,!0),B(V,W,G,`⪅`,`\\lessapprox`,!0),B(V,W,G,`≊`,`\\approxeq`,!0),B(V,W,Ca,`⋖`,`\\lessdot`),B(V,W,G,`⋘`,`\\lll`,!0),B(V,W,G,`≶`,`\\lessgtr`,!0),B(V,W,G,`⋚`,`\\lesseqgtr`,!0),B(V,W,G,`⪋`,`\\lesseqqgtr`,!0),B(V,W,G,`≑`,`\\doteqdot`),B(V,W,G,`≓`,`\\risingdotseq`,!0),B(V,W,G,`≒`,`\\fallingdotseq`,!0),B(V,W,G,`∽`,`\\backsim`,!0),B(V,W,G,`⋍`,`\\backsimeq`,!0),B(V,W,G,`⫅`,`\\subseteqq`,!0),B(V,W,G,`⋐`,`\\Subset`,!0),B(V,W,G,`⊏`,`\\sqsubset`,!0),B(V,W,G,`≼`,`\\preccurlyeq`,!0),B(V,W,G,`⋞`,`\\curlyeqprec`,!0),B(V,W,G,`≾`,`\\precsim`,!0),B(V,W,G,`⪷`,`\\precapprox`,!0),B(V,W,G,`⊲`,`\\vartriangleleft`),B(V,W,G,`⊴`,`\\trianglelefteq`),B(V,W,G,`⊨`,`\\vDash`,!0),B(V,W,G,`⊪`,`\\Vvdash`,!0),B(V,W,G,`⌣`,`\\smallsmile`),B(V,W,G,`⌢`,`\\smallfrown`),B(V,W,G,`≏`,`\\bumpeq`,!0),B(V,W,G,`≎`,`\\Bumpeq`,!0),B(V,W,G,`≧`,`\\geqq`,!0),B(V,W,G,`⩾`,`\\geqslant`,!0),B(V,W,G,`⪖`,`\\eqslantgtr`,!0),B(V,W,G,`≳`,`\\gtrsim`,!0),B(V,W,G,`⪆`,`\\gtrapprox`,!0),B(V,W,Ca,`⋗`,`\\gtrdot`),B(V,W,G,`⋙`,`\\ggg`,!0),B(V,W,G,`≷`,`\\gtrless`,!0),B(V,W,G,`⋛`,`\\gtreqless`,!0),B(V,W,G,`⪌`,`\\gtreqqless`,!0),B(V,W,G,`≖`,`\\eqcirc`,!0),B(V,W,G,`≗`,`\\circeq`,!0),B(V,W,G,`≜`,`\\triangleq`,!0),B(V,W,G,`∼`,`\\thicksim`),B(V,W,G,`≈`,`\\thickapprox`),B(V,W,G,`⫆`,`\\supseteqq`,!0),B(V,W,G,`⋑`,`\\Supset`,!0),B(V,W,G,`⊐`,`\\sqsupset`,!0),B(V,W,G,`≽`,`\\succcurlyeq`,!0),B(V,W,G,`⋟`,`\\curlyeqsucc`,!0),B(V,W,G,`≿`,`\\succsim`,!0),B(V,W,G,`⪸`,`\\succapprox`,!0),B(V,W,G,`⊳`,`\\vartriangleright`),B(V,W,G,`⊵`,`\\trianglerighteq`),B(V,W,G,`⊩`,`\\Vdash`,!0),B(V,W,G,`∣`,`\\shortmid`),B(V,W,G,`∥`,`\\shortparallel`),B(V,W,G,`≬`,`\\between`,!0),B(V,W,G,`⋔`,`\\pitchfork`,!0),B(V,W,G,`∝`,`\\varpropto`),B(V,W,G,`◀`,`\\blacktriangleleft`),B(V,W,G,`∴`,`\\therefore`,!0),B(V,W,G,`∍`,`\\backepsilon`),B(V,W,G,`▶`,`\\blacktriangleright`),B(V,W,G,`∵`,`\\because`,!0),B(V,W,G,`⋘`,`\\llless`),B(V,W,G,`⋙`,`\\gggtr`),B(V,W,Ca,`⊲`,`\\lhd`),B(V,W,Ca,`⊳`,`\\rhd`),B(V,W,G,`≂`,`\\eqsim`,!0),B(V,U,G,`⋈`,`\\Join`),B(V,W,G,`≑`,`\\Doteq`,!0),B(V,W,Ca,`∔`,`\\dotplus`,!0),B(V,W,Ca,`∖`,`\\smallsetminus`),B(V,W,Ca,`⋒`,`\\Cap`,!0),B(V,W,Ca,`⋓`,`\\Cup`,!0),B(V,W,Ca,`⩞`,`\\doublebarwedge`,!0),B(V,W,Ca,`⊟`,`\\boxminus`,!0),B(V,W,Ca,`⊞`,`\\boxplus`,!0),B(V,W,Ca,`⋇`,`\\divideontimes`,!0),B(V,W,Ca,`⋉`,`\\ltimes`,!0),B(V,W,Ca,`⋊`,`\\rtimes`,!0),B(V,W,Ca,`⋋`,`\\leftthreetimes`,!0),B(V,W,Ca,`⋌`,`\\rightthreetimes`,!0),B(V,W,Ca,`⋏`,`\\curlywedge`,!0),B(V,W,Ca,`⋎`,`\\curlyvee`,!0),B(V,W,Ca,`⊝`,`\\circleddash`,!0),B(V,W,Ca,`⊛`,`\\circledast`,!0),B(V,W,Ca,`⋅`,`\\centerdot`),B(V,W,Ca,`⊺`,`\\intercal`,!0),B(V,W,Ca,`⋒`,`\\doublecap`),B(V,W,Ca,`⋓`,`\\doublecup`),B(V,W,Ca,`⊠`,`\\boxtimes`,!0),B(V,W,G,`⇢`,`\\dashrightarrow`,!0),B(V,W,G,`⇠`,`\\dashleftarrow`,!0),B(V,W,G,`⇇`,`\\leftleftarrows`,!0),B(V,W,G,`⇆`,`\\leftrightarrows`,!0),B(V,W,G,`⇚`,`\\Lleftarrow`,!0),B(V,W,G,`↞`,`\\twoheadleftarrow`,!0),B(V,W,G,`↢`,`\\leftarrowtail`,!0),B(V,W,G,`↫`,`\\looparrowleft`,!0),B(V,W,G,`⇋`,`\\leftrightharpoons`,!0),B(V,W,G,`↶`,`\\curvearrowleft`,!0),B(V,W,G,`↺`,`\\circlearrowleft`,!0),B(V,W,G,`↰`,`\\Lsh`,!0),B(V,W,G,`⇈`,`\\upuparrows`,!0),B(V,W,G,`↿`,`\\upharpoonleft`,!0),B(V,W,G,`⇃`,`\\downharpoonleft`,!0),B(V,U,G,`⊶`,`\\origof`,!0),B(V,U,G,`⊷`,`\\imageof`,!0),B(V,W,G,`⊸`,`\\multimap`,!0),B(V,W,G,`↭`,`\\leftrightsquigarrow`,!0),B(V,W,G,`⇉`,`\\rightrightarrows`,!0),B(V,W,G,`⇄`,`\\rightleftarrows`,!0),B(V,W,G,`↠`,`\\twoheadrightarrow`,!0),B(V,W,G,`↣`,`\\rightarrowtail`,!0),B(V,W,G,`↬`,`\\looparrowright`,!0),B(V,W,G,`↷`,`\\curvearrowright`,!0),B(V,W,G,`↻`,`\\circlearrowright`,!0),B(V,W,G,`↱`,`\\Rsh`,!0),B(V,W,G,`⇊`,`\\downdownarrows`,!0),B(V,W,G,`↾`,`\\upharpoonright`,!0),B(V,W,G,`⇂`,`\\downharpoonright`,!0),B(V,W,G,`⇝`,`\\rightsquigarrow`,!0),B(V,W,G,`⇝`,`\\leadsto`),B(V,W,G,`⇛`,`\\Rrightarrow`,!0),B(V,W,G,`↾`,`\\restriction`),B(V,U,K,`‘`,"`"),B(V,U,K,`$`,`\\$`),B(H,U,K,`$`,`\\$`),B(H,U,K,`$`,`\\textdollar`),B(V,U,K,`%`,`\\%`),B(H,U,K,`%`,`\\%`),B(V,U,K,`_`,`\\_`),B(H,U,K,`_`,`\\_`),B(H,U,K,`_`,`\\textunderscore`),B(V,U,K,`∠`,`\\angle`,!0),B(V,U,K,`∞`,`\\infty`,!0),B(V,U,K,`′`,`\\prime`),B(V,U,K,`△`,`\\triangle`),B(V,U,K,`Γ`,`\\Gamma`,!0),B(V,U,K,`Δ`,`\\Delta`,!0),B(V,U,K,`Θ`,`\\Theta`,!0),B(V,U,K,`Λ`,`\\Lambda`,!0),B(V,U,K,`Ξ`,`\\Xi`,!0),B(V,U,K,`Π`,`\\Pi`,!0),B(V,U,K,`Σ`,`\\Sigma`,!0),B(V,U,K,`Υ`,`\\Upsilon`,!0),B(V,U,K,`Φ`,`\\Phi`,!0),B(V,U,K,`Ψ`,`\\Psi`,!0),B(V,U,K,`Ω`,`\\Omega`,!0),B(V,U,K,`A`,`Α`),B(V,U,K,`B`,`Β`),B(V,U,K,`E`,`Ε`),B(V,U,K,`Z`,`Ζ`),B(V,U,K,`H`,`Η`),B(V,U,K,`I`,`Ι`),B(V,U,K,`K`,`Κ`),B(V,U,K,`M`,`Μ`),B(V,U,K,`N`,`Ν`),B(V,U,K,`O`,`Ο`),B(V,U,K,`P`,`Ρ`),B(V,U,K,`T`,`Τ`),B(V,U,K,`X`,`Χ`),B(V,U,K,`¬`,`\\neg`,!0),B(V,U,K,`¬`,`\\lnot`),B(V,U,K,`⊤`,`\\top`),B(V,U,K,`⊥`,`\\bot`),B(V,U,K,`∅`,`\\emptyset`),B(V,W,K,`∅`,`\\varnothing`),B(V,U,Ea,`α`,`\\alpha`,!0),B(V,U,Ea,`β`,`\\beta`,!0),B(V,U,Ea,`γ`,`\\gamma`,!0),B(V,U,Ea,`δ`,`\\delta`,!0),B(V,U,Ea,`ϵ`,`\\epsilon`,!0),B(V,U,Ea,`ζ`,`\\zeta`,!0),B(V,U,Ea,`η`,`\\eta`,!0),B(V,U,Ea,`θ`,`\\theta`,!0),B(V,U,Ea,`ι`,`\\iota`,!0),B(V,U,Ea,`κ`,`\\kappa`,!0),B(V,U,Ea,`λ`,`\\lambda`,!0),B(V,U,Ea,`μ`,`\\mu`,!0),B(V,U,Ea,`ν`,`\\nu`,!0),B(V,U,Ea,`ξ`,`\\xi`,!0),B(V,U,Ea,`ο`,`\\omicron`,!0),B(V,U,Ea,`π`,`\\pi`,!0),B(V,U,Ea,`ρ`,`\\rho`,!0),B(V,U,Ea,`σ`,`\\sigma`,!0),B(V,U,Ea,`τ`,`\\tau`,!0),B(V,U,Ea,`υ`,`\\upsilon`,!0),B(V,U,Ea,`ϕ`,`\\phi`,!0),B(V,U,Ea,`χ`,`\\chi`,!0),B(V,U,Ea,`ψ`,`\\psi`,!0),B(V,U,Ea,`ω`,`\\omega`,!0),B(V,U,Ea,`ε`,`\\varepsilon`,!0),B(V,U,Ea,`ϑ`,`\\vartheta`,!0),B(V,U,Ea,`ϖ`,`\\varpi`,!0),B(V,U,Ea,`ϱ`,`\\varrho`,!0),B(V,U,Ea,`ς`,`\\varsigma`,!0),B(V,U,Ea,`φ`,`\\varphi`,!0),B(V,U,Ca,`∗`,`*`,!0),B(V,U,Ca,`+`,`+`),B(V,U,Ca,`−`,`-`,!0),B(V,U,Ca,`⋅`,`\\cdot`,!0),B(V,U,Ca,`∘`,`\\circ`,!0),B(V,U,Ca,`÷`,`\\div`,!0),B(V,U,Ca,`±`,`\\pm`,!0),B(V,U,Ca,`×`,`\\times`,!0),B(V,U,Ca,`∩`,`\\cap`,!0),B(V,U,Ca,`∪`,`\\cup`,!0),B(V,U,Ca,`∖`,`\\setminus`,!0),B(V,U,Ca,`∧`,`\\land`),B(V,U,Ca,`∨`,`\\lor`),B(V,U,Ca,`∧`,`\\wedge`,!0),B(V,U,Ca,`∨`,`\\vee`,!0),B(V,U,K,`√`,`\\surd`),B(V,U,Oa,`⟨`,`\\langle`,!0),B(V,U,Oa,`∣`,`\\lvert`),B(V,U,Oa,`∥`,`\\lVert`),B(V,U,wa,`?`,`?`),B(V,U,wa,`!`,`!`),B(V,U,wa,`⟩`,`\\rangle`,!0),B(V,U,wa,`∣`,`\\rvert`),B(V,U,wa,`∥`,`\\rVert`),B(V,U,G,`=`,`=`),B(V,U,G,`:`,`:`),B(V,U,G,`≈`,`\\approx`,!0),B(V,U,G,`≅`,`\\cong`,!0),B(V,U,G,`≥`,`\\ge`),B(V,U,G,`≥`,`\\geq`,!0),B(V,U,G,`←`,`\\gets`),B(V,U,G,`>`,`\\gt`,!0),B(V,U,G,`∈`,`\\in`,!0),B(V,U,G,``,`\\@not`),B(V,U,G,`⊂`,`\\subset`,!0),B(V,U,G,`⊃`,`\\supset`,!0),B(V,U,G,`⊆`,`\\subseteq`,!0),B(V,U,G,`⊇`,`\\supseteq`,!0),B(V,W,G,`⊈`,`\\nsubseteq`,!0),B(V,W,G,`⊉`,`\\nsupseteq`,!0),B(V,U,G,`⊨`,`\\models`),B(V,U,G,`←`,`\\leftarrow`,!0),B(V,U,G,`≤`,`\\le`),B(V,U,G,`≤`,`\\leq`,!0),B(V,U,G,`<`,`\\lt`,!0),B(V,U,G,`→`,`\\rightarrow`,!0),B(V,U,G,`→`,`\\to`),B(V,W,G,`≱`,`\\ngeq`,!0),B(V,W,G,`≰`,`\\nleq`,!0),B(V,U,Aa,`\xA0`,`\\ `),B(V,U,Aa,`\xA0`,`\\space`),B(V,U,Aa,`\xA0`,`\\nobreakspace`),B(H,U,Aa,`\xA0`,`\\ `),B(H,U,Aa,`\xA0`,` `),B(H,U,Aa,`\xA0`,`\\space`),B(H,U,Aa,`\xA0`,`\\nobreakspace`),B(V,U,Aa,``,`\\nobreak`),B(V,U,Aa,``,`\\allowbreak`),B(V,U,ka,`,`,`,`),B(V,U,ka,`;`,`;`),B(V,W,Ca,`⊼`,`\\barwedge`,!0),B(V,W,Ca,`⊻`,`\\veebar`,!0),B(V,U,Ca,`⊙`,`\\odot`,!0),B(V,U,Ca,`⊕`,`\\oplus`,!0),B(V,U,Ca,`⊗`,`\\otimes`,!0),B(V,U,K,`∂`,`\\partial`,!0),B(V,U,Ca,`⊘`,`\\oslash`,!0),B(V,W,Ca,`⊚`,`\\circledcirc`,!0),B(V,W,Ca,`⊡`,`\\boxdot`,!0),B(V,U,Ca,`△`,`\\bigtriangleup`),B(V,U,Ca,`▽`,`\\bigtriangledown`),B(V,U,Ca,`†`,`\\dagger`),B(V,U,Ca,`⋄`,`\\diamond`),B(V,U,Ca,`⋆`,`\\star`),B(V,U,Ca,`◃`,`\\triangleleft`),B(V,U,Ca,`▹`,`\\triangleright`),B(V,U,Oa,`{`,`\\{`),B(H,U,K,`{`,`\\{`),B(H,U,K,`{`,`\\textbraceleft`),B(V,U,wa,`}`,`\\}`),B(H,U,K,`}`,`\\}`),B(H,U,K,`}`,`\\textbraceright`),B(V,U,Oa,`{`,`\\lbrace`),B(V,U,wa,`}`,`\\rbrace`),B(V,U,Oa,`[`,`\\lbrack`,!0),B(H,U,K,`[`,`\\lbrack`,!0),B(V,U,wa,`]`,`\\rbrack`,!0),B(H,U,K,`]`,`\\rbrack`,!0),B(V,U,Oa,`(`,`\\lparen`,!0),B(V,U,wa,`)`,`\\rparen`,!0),B(H,U,K,`<`,`\\textless`,!0),B(H,U,K,`>`,`\\textgreater`,!0),B(V,U,Oa,`⌊`,`\\lfloor`,!0),B(V,U,wa,`⌋`,`\\rfloor`,!0),B(V,U,Oa,`⌈`,`\\lceil`,!0),B(V,U,wa,`⌉`,`\\rceil`,!0),B(V,U,K,`\\`,`\\backslash`),B(V,U,K,`∣`,`|`),B(V,U,K,`∣`,`\\vert`),B(H,U,K,`|`,`\\textbar`,!0),B(V,U,K,`∥`,`\\|`),B(V,U,K,`∥`,`\\Vert`),B(H,U,K,`∥`,`\\textbardbl`),B(H,U,K,`~`,`\\textasciitilde`),B(H,U,K,`\\`,`\\textbackslash`),B(H,U,K,`^`,`\\textasciicircum`),B(V,U,G,`↑`,`\\uparrow`,!0),B(V,U,G,`⇑`,`\\Uparrow`,!0),B(V,U,G,`↓`,`\\downarrow`,!0),B(V,U,G,`⇓`,`\\Downarrow`,!0),B(V,U,G,`↕`,`\\updownarrow`,!0),B(V,U,G,`⇕`,`\\Updownarrow`,!0),B(V,U,Da,`∐`,`\\coprod`),B(V,U,Da,`⋁`,`\\bigvee`),B(V,U,Da,`⋀`,`\\bigwedge`),B(V,U,Da,`⨄`,`\\biguplus`),B(V,U,Da,`⋂`,`\\bigcap`),B(V,U,Da,`⋃`,`\\bigcup`),B(V,U,Da,`∫`,`\\int`),B(V,U,Da,`∫`,`\\intop`),B(V,U,Da,`∬`,`\\iint`),B(V,U,Da,`∭`,`\\iiint`),B(V,U,Da,`∏`,`\\prod`),B(V,U,Da,`∑`,`\\sum`),B(V,U,Da,`⨂`,`\\bigotimes`),B(V,U,Da,`⨁`,`\\bigoplus`),B(V,U,Da,`⨀`,`\\bigodot`),B(V,U,Da,`∮`,`\\oint`),B(V,U,Da,`∯`,`\\oiint`),B(V,U,Da,`∰`,`\\oiiint`),B(V,U,Da,`⨆`,`\\bigsqcup`),B(V,U,Da,`∫`,`\\smallint`),B(H,U,Ta,`…`,`\\textellipsis`),B(V,U,Ta,`…`,`\\mathellipsis`),B(H,U,Ta,`…`,`\\ldots`,!0),B(V,U,Ta,`…`,`\\ldots`,!0),B(V,U,Ta,`⋯`,`\\@cdots`,!0),B(V,U,Ta,`⋱`,`\\ddots`,!0),B(V,U,K,`⋮`,`\\varvdots`),B(H,U,K,`⋮`,`\\varvdots`),B(V,U,Sa,`ˊ`,`\\acute`),B(V,U,Sa,`ˋ`,`\\grave`),B(V,U,Sa,`¨`,`\\ddot`),B(V,U,Sa,`~`,`\\tilde`),B(V,U,Sa,`ˉ`,`\\bar`),B(V,U,Sa,`˘`,`\\breve`),B(V,U,Sa,`ˇ`,`\\check`),B(V,U,Sa,`^`,`\\hat`),B(V,U,Sa,`⃗`,`\\vec`),B(V,U,Sa,`˙`,`\\dot`),B(V,U,Sa,`˚`,`\\mathring`),B(V,U,Ea,``,`\\@imath`),B(V,U,Ea,``,`\\@jmath`),B(V,U,K,`ı`,`ı`),B(V,U,K,`ȷ`,`ȷ`),B(H,U,K,`ı`,`\\i`,!0),B(H,U,K,`ȷ`,`\\j`,!0),B(H,U,K,`ß`,`\\ss`,!0),B(H,U,K,`æ`,`\\ae`,!0),B(H,U,K,`œ`,`\\oe`,!0),B(H,U,K,`ø`,`\\o`,!0),B(H,U,K,`Æ`,`\\AE`,!0),B(H,U,K,`Œ`,`\\OE`,!0),B(H,U,K,`Ø`,`\\O`,!0),B(H,U,Sa,`ˊ`,`\\'`),B(H,U,Sa,`ˋ`,"\\`"),B(H,U,Sa,`ˆ`,`\\^`),B(H,U,Sa,`˜`,`\\~`),B(H,U,Sa,`ˉ`,`\\=`),B(H,U,Sa,`˘`,`\\u`),B(H,U,Sa,`˙`,`\\.`),B(H,U,Sa,`¸`,`\\c`),B(H,U,Sa,`˚`,`\\r`),B(H,U,Sa,`ˇ`,`\\v`),B(H,U,Sa,`¨`,`\\"`),B(H,U,Sa,`˝`,`\\H`),B(H,U,Sa,`◯`,`\\textcircled`);var ja={"--":!0,"---":!0,"``":!0,"''":!0};B(H,U,K,`–`,`--`,!0),B(H,U,K,`–`,`\\textendash`),B(H,U,K,`—`,`---`,!0),B(H,U,K,`—`,`\\textemdash`),B(H,U,K,`‘`,"`",!0),B(H,U,K,`‘`,`\\textquoteleft`),B(H,U,K,`’`,`'`,!0),B(H,U,K,`’`,`\\textquoteright`),B(H,U,K,`“`,"``",!0),B(H,U,K,`“`,`\\textquotedblleft`),B(H,U,K,`”`,`''`,!0),B(H,U,K,`”`,`\\textquotedblright`),B(V,U,K,`°`,`\\degree`,!0),B(H,U,K,`°`,`\\degree`),B(H,U,K,`°`,`\\textdegree`,!0),B(V,U,K,`£`,`\\pounds`),B(V,U,K,`£`,`\\mathsterling`,!0),B(H,U,K,`£`,`\\pounds`),B(H,U,K,`£`,`\\textsterling`,!0),B(V,W,K,`✠`,`\\maltese`),B(H,W,K,`✠`,`\\maltese`);for(var Ma=`0123456789/@."`,Na=0;Na<Ma.length;Na++){var Pa=Ma.charAt(Na);B(V,U,K,Pa,Pa)}for(var Fa=`0123456789!@*()-=+";:?/.,`,Ia=0;Ia<Fa.length;Ia++){var La=Fa.charAt(Ia);B(H,U,K,La,La)}for(var Ra=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,za=0;za<Ra.length;za++){var Ba=Ra.charAt(za);B(V,U,Ea,Ba,Ba),B(H,U,K,Ba,Ba)}B(V,W,K,`C`,`ℂ`),B(H,W,K,`C`,`ℂ`),B(V,W,K,`H`,`ℍ`),B(H,W,K,`H`,`ℍ`),B(V,W,K,`N`,`ℕ`),B(H,W,K,`N`,`ℕ`),B(V,W,K,`P`,`ℙ`),B(H,W,K,`P`,`ℙ`),B(V,W,K,`Q`,`ℚ`),B(H,W,K,`Q`,`ℚ`),B(V,W,K,`R`,`ℝ`),B(H,W,K,`R`,`ℝ`),B(V,W,K,`Z`,`ℤ`),B(H,W,K,`Z`,`ℤ`),B(V,U,Ea,`h`,`ℎ`),B(H,U,Ea,`h`,`ℎ`);for(var Va,Ha=0;Ha<Ra.length;Ha++){var Ua=Ra.charAt(Ha);Va=String.fromCharCode(55349,56320+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56372+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56424+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56580+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56684+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56736+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56788+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56840+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56944+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Ha<26&&(Va=String.fromCharCode(55349,56632+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va),Va=String.fromCharCode(55349,56476+Ha),B(V,U,Ea,Ua,Va),B(H,U,K,Ua,Va))}Va=String.fromCharCode(55349,56668),B(V,U,Ea,`k`,Va),B(H,U,K,`k`,Va);for(var Wa=0;Wa<10;Wa++){var Ga=Wa.toString();Va=String.fromCharCode(55349,57294+Wa),B(V,U,Ea,Ga,Va),B(H,U,K,Ga,Va),Va=String.fromCharCode(55349,57314+Wa),B(V,U,Ea,Ga,Va),B(H,U,K,Ga,Va),Va=String.fromCharCode(55349,57324+Wa),B(V,U,Ea,Ga,Va),B(H,U,K,Ga,Va),Va=String.fromCharCode(55349,57334+Wa),B(V,U,Ea,Ga,Va),B(H,U,K,Ga,Va)}for(var Ka=`ÐÞþ`,qa=0;qa<Ka.length;qa++){var Ja=Ka.charAt(qa);B(V,U,Ea,Ja,Ja),B(H,U,K,Ja,Ja)}var Ya={mathClass:`mathbf`,textClass:`textbf`,font:`Main-Bold`},Xa={mathClass:`mathnormal`,textClass:`textit`,font:`Math-Italic`},Za={mathClass:`boldsymbol`,textClass:`boldsymbol`,font:`Main-BoldItalic`},Qa={mathClass:`mathscr`,textClass:`textscr`,font:`Script-Regular`},$a={mathClass:``,textClass:``,font:``},eo={mathClass:`mathfrak`,textClass:`textfrak`,font:`Fraktur-Regular`},to={mathClass:`mathbb`,textClass:`textbb`,font:`AMS-Regular`},no={mathClass:`mathboldfrak`,textClass:`textboldfrak`,font:`Fraktur-Regular`},ro={mathClass:`mathsf`,textClass:`textsf`,font:`SansSerif-Regular`},io={mathClass:`mathboldsf`,textClass:`textboldsf`,font:`SansSerif-Bold`},ao={mathClass:`mathitsf`,textClass:`textitsf`,font:`SansSerif-Italic`},oo={mathClass:`mathtt`,textClass:`texttt`,font:`Typewriter-Regular`},so=[Ya,Ya,Xa,Xa,Za,Za,Qa,$a,$a,$a,eo,eo,to,to,no,no,ro,ro,io,io,ao,ao,$a,$a,oo,oo],co=[Ya,$a,ro,io,oo],lo=e=>{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return so[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return co[Math.floor((r-120782)/10)];if(r===120485||r===120486)return so[0];if(120486<r&&r<120782)return $a;throw new R(`Unsupported character: `+e)};function uo(e){var t=e.strict,n=e.errorCode,r=e.errorMsg,i=e.token,a=e.report,o=t;if(typeof t==`function`){if(a)o=t(n,r,i);else try{o=t(n,r,i)}catch{o=`error`}}switch(o){case!0:case`error`:if(a)throw new R(`LaTeX-incompatible input and strict mode is set to 'error': `+(r+` [`+n+`]`),i);return!0;case!1:case`ignore`:if(!a)return!1;break;default:if(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(r+` [`+n+`]`)),!a)return!1}}var fo=function(e,t,n){if(xa[n][e]){var r=xa[n][e].replace;r&&(e=r)}return{value:e,metrics:va(e,t,n)}},po=function(e,t,n,r,i){var a=fo(e,t,n),o=a.metrics;e=a.value;var s;if(o){var c=o.italic;(n===`text`||r&&r.font===`mathit`)&&(c=0),s=new sa(e,o.height,o.depth,c,o.skew,o.width,i)}else uo({strict:r.strict,errorCode:`symbolNotInFont`,errorMsg:`No character metrics for '`+e+`' in style '`+t+`' and mode '`+n+`'`,report:!0}),s=new sa(e,0,0,0,0,0,i);s.maxFontSize=r.sizeMultiplier,r.style.isTight()&&s.classes.push(`mtight`);var l=r.getColor();return l&&(s.style.color=l),s},mo=function(e,t,n,r){return r===void 0&&(r=[]),n.font===`boldsymbol`&&fo(e,`Main-Bold`,t).metrics?po(e,`Main-Bold`,t,n,r.concat([`mathbf`])):e===`\\`||xa[t][e].font===`main`?po(e,`Main-Regular`,t,n,r):po(e,`AMS-Regular`,t,n,r.concat([`amsrm`]))},ho=function(e,t,n){return n!==`textord`&&fo(e,`Math-BoldItalic`,t).metrics?{fontName:`Math-BoldItalic`,fontClass:`boldsymbol`}:{fontName:`Main-Bold`,fontClass:`mathbf`}},go=function(e,t){var n=e.type===`mathord`?`mathord`:`textord`,r=e.mode,i=e.text,a=[`mord`],o=t.font,s=t.fontFamily,c=t.fontWeight,l=t.fontShape,u=r===`math`||r===`text`&&!!o,d=u?o:s,f=``,p=``;if(i.charCodeAt(0)===55349){var m=lo(i);f=m.font,p=m[r+`Class`]}if(f)return po(i,f,r,t,a.concat(p));if(d){var h,g;if(d===`boldsymbol`){var _=ho(i,r,n);h=_.fontName,g=[_.fontClass]}else u?(h=ko[o].fontName,g=[o]):(h=Oo(s,c,l),g=[s,c,l]);if(fo(i,h,r).metrics)return po(i,h,r,t,a.concat(g));if(Object.prototype.hasOwnProperty.call(ja,i)&&h.slice(0,10)===`Typewriter`){for(var v=[],y=0;y<i.length;y++)v.push(po(i[y],h,r,t,a.concat(g)));return Co(v)}}if(n===`mathord`)return po(i,`Math-Italic`,r,t,a.concat([`mathnormal`]));if(n===`textord`){var b=xa[r][i]&&xa[r][i].font;if(b===`ams`)return po(i,Oo(`amsrm`,c,l),r,t,a.concat(`amsrm`,c,l));if(b===`main`||!b)return po(i,Oo(`textrm`,c,l),r,t,a.concat(c,l));var x=Oo(b,c,l);return po(i,x,r,t,a.concat(x,c,l))}throw Error(`unexpected type: `+n+` in makeOrd`)},_o=(e,t)=>{if(Zi(e.classes)!==Zi(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||e.italic!==0&&e.hasClass(`mathnormal`))return!1;if(e.classes.length===1){var n=e.classes[0];if(n===`mbin`||n===`mord`)return!1}for(var r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(var i of Object.keys(t.style))if(e.style[i]!==t.style[i])return!1;return!0},vo=e=>{for(var t=0;t<e.length-1;t++){var n=e[t],r=e[t+1];n instanceof sa&&r instanceof sa&&_o(n,r)&&(n.text+=r.text,n.height=Math.max(n.height,r.height),n.depth=Math.max(n.depth,r.depth),n.italic=r.italic,e.splice(t+1,1),t--)}return e},yo=function(e){for(var t=0,n=0,r=0,i=0;i<e.children.length;i++){var a=e.children[i];a.height>t&&(t=a.height),a.depth>n&&(n=a.depth),a.maxFontSize>r&&(r=a.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=r},q=function(e,t,n,r){var i=new ra(e,t,n,r);return yo(i),i},bo=(e,t,n,r)=>new ra(e,t,n,r),xo=function(e,t,n){var r=q([e],[],t);return r.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),r.style.borderBottomWidth=z(r.height),r.maxFontSize=1,r},So=function(e,t,n,r){var i=new ia(e,t,n,r);return yo(i),i},Co=function(e){var t=new Ki(e);return yo(t),t},wo=function(e,t){return e instanceof Ki?q([],[e],t):e},To=function(e){if(e.positionType===`individualShift`){for(var t=e.children,n=[t[0]],r=-t[0].shift-t[0].elem.depth,i=r,a=1;a<t.length;a++){var o=-t[a].shift-i-t[a].elem.depth,s=o-(t[a-1].elem.height+t[a-1].elem.depth);i+=o,n.push({type:`kern`,size:s}),n.push(t[a])}return{children:n,depth:r}}var c;if(e.positionType===`top`){for(var l=e.positionData,u=0;u<e.children.length;u++){var d=e.children[u];l-=d.type===`kern`?d.size:d.elem.height+d.elem.depth}c=l}else if(e.positionType===`bottom`)c=-e.positionData;else{var f=e.children[0];if(f.type!==`elem`)throw Error(`First child must have type "elem".`);if(e.positionType===`shift`)c=-f.elem.depth-e.positionData;else if(e.positionType===`firstBaseline`)c=-f.elem.depth;else throw Error(`Invalid positionType `+e.positionType+`.`)}return{children:e.children,depth:c}},Eo=function(e,t){for(var n=To(e),r=n.children,i=n.depth,a=0,o=0;o<r.length;o++){var s=r[o];if(s.type===`elem`){var c=s.elem;a=Math.max(a,c.maxFontSize,c.height)}}a+=2;var l=q([`pstrut`],[]);l.style.height=z(a);for(var u=[],d=i,f=i,p=i,m=0;m<r.length;m++){var h=r[m];if(h.type===`kern`)p+=h.size;else{var g=h.elem,_=h.wrapperClasses||[],v=h.wrapperStyle||{},y=q(_,[l,g],void 0,v);y.style.top=z(-a-p-g.depth),h.marginLeft&&(y.style.marginLeft=h.marginLeft),h.marginRight&&(y.style.marginRight=h.marginRight),u.push(y),p+=g.height+g.depth}d=Math.min(d,p),f=Math.max(f,p)}var b=q([`vlist`],u);b.style.height=z(f);var x;if(d<0){var S=q([`vlist`],[q([],[])]);S.style.height=z(-d),x=[q([`vlist-r`],[b,q([`vlist-s`],[new sa(``)])]),q([`vlist-r`],[S])]}else x=[q([`vlist-r`],[b])];var C=q([`vlist-t`],x);return x.length===2&&C.classes.push(`vlist-t2`),C.height=f,C.depth=-d,C},Do=(e,t)=>{var n=q([`mspace`],[],t),r=Xi(e,t);return n.style.marginRight=z(r),n},Oo=(e,t,n)=>{var r,i;switch(e){case`amsrm`:r=`AMS`;break;case`textrm`:r=`Main`;break;case`textsf`:r=`SansSerif`;break;case`texttt`:r=`Typewriter`;break;default:r=e}return i=t===`textbf`&&n===`textit`?`BoldItalic`:t===`textbf`?`Bold`:n===`textit`?`Italic`:`Regular`,r+`-`+i},ko={mathbf:{variant:`bold`,fontName:`Main-Bold`},mathrm:{variant:`normal`,fontName:`Main-Regular`},textit:{variant:`italic`,fontName:`Main-Italic`},mathit:{variant:`italic`,fontName:`Main-Italic`},mathnormal:{variant:`italic`,fontName:`Math-Italic`},mathsfit:{variant:`sans-serif-italic`,fontName:`SansSerif-Italic`},mathbb:{variant:`double-struck`,fontName:`AMS-Regular`},mathcal:{variant:`script`,fontName:`Caligraphic-Regular`},mathfrak:{variant:`fraktur`,fontName:`Fraktur-Regular`},mathscr:{variant:`script`,fontName:`Script-Regular`},mathsf:{variant:`sans-serif`,fontName:`SansSerif-Regular`},mathtt:{variant:`monospace`,fontName:`Typewriter-Regular`}},Ao={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},jo=function(e,t){var n=Ao[e],r=n[0],i=n[1],a=n[2],o=bo([`katex-overlay`],[new ca([new la(r)],{width:z(i),height:z(a),style:`width:`+z(i),viewBox:`0 0 `+1e3*i+` `+1e3*a,preserveAspectRatio:`xMinYMin`})],t);return o.height=a,o.style.height=z(a),o.style.width=z(i),o},Mo={number:3,unit:`mu`},No={number:4,unit:`mu`},Po={number:5,unit:`mu`},Fo={mord:{mop:Mo,mbin:No,mrel:Po,minner:Mo},mop:{mord:Mo,mop:Mo,mrel:Po,minner:Mo},mbin:{mord:No,mop:No,mopen:No,minner:No},mrel:{mord:Po,mop:Po,mopen:Po,minner:Po},mopen:{},mclose:{mop:Mo,mbin:No,mrel:Po,minner:Mo},mpunct:{mord:Mo,mop:Mo,mrel:Po,mopen:Mo,mclose:Mo,mpunct:Mo,minner:Mo},minner:{mord:Mo,mop:Mo,mbin:No,mrel:Po,mopen:Mo,mpunct:Mo,minner:Mo}},Io={mord:{mop:Mo},mop:{mord:Mo,mop:Mo},mbin:{},mrel:{},mopen:{},mclose:{mop:Mo},mpunct:{},minner:{mop:Mo}},Lo={},Ro={},zo={};function J(e){for(var t=e.type,n=e.names,r=e.htmlBuilder,i=e.mathmlBuilder,a=0;a<n.length;++a)Lo[n[a]]=e;t&&(r&&(Ro[t]=r),i&&(zo[t]=i))}function Bo(e){var t=e.type,n=e.htmlBuilder,r=e.mathmlBuilder;n&&(Ro[t]=n),r&&(zo[t]=r)}var Vo=function(e){return e.type===`ordgroup`&&e.body.length===1?e.body[0]:e},Ho=function(e){return e.type===`ordgroup`?e.body:[e]},Uo=new Set([`leftmost`,`mbin`,`mopen`,`mrel`,`mop`,`mpunct`]),Wo=new Set([`rightmost`,`mrel`,`mclose`,`mpunct`]),Go={display:Di.DISPLAY,text:Di.TEXT,script:Di.SCRIPT,scriptscript:Di.SCRIPTSCRIPT},Ko={mord:`mord`,mop:`mop`,mbin:`mbin`,mrel:`mrel`,mopen:`mopen`,mclose:`mclose`,mpunct:`mpunct`,minner:`minner`},qo=function(e,t,n,r){r===void 0&&(r=[null,null]);for(var i=[],a=0;a<e.length;a++){var o=Y(e[a],t);if(o instanceof Ki){var s=o.children;i.push(...s)}else i.push(o)}if(vo(i),!n)return i;var c=t;if(e.length===1){var l=e[0];l.type===`sizing`?c=t.havingSize(l.size):l.type===`styling`&&(c=t.havingStyle(Go[l.style]))}var u=q([r[0]||`leftmost`],[],t),d=q([r[1]||`rightmost`],[],t),f=n===`root`;return Jo(i,(e,t)=>{var n=t.classes[0],r=e.classes[0];n===`mbin`&&Wo.has(r)?t.classes[0]=`mord`:r===`mbin`&&Uo.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),Jo(i,(e,t)=>{var n=Zo(t),r=Zo(e),i=n&&r?e.hasClass(`mtight`)?Io[n]?.[r]:Fo[n]?.[r]:null;if(i)return Do(i,c)},{node:u},d,f),i},Jo=function(e,t,n,r,i){r&&e.push(r);for(var a=0;a<e.length;a++){var o=e[a],s=Yo(o);if(s)Jo(s.children,t,n,null,i);else{var c=!o.hasClass(`mspace`);if(c){var l=t(o,n.node);l&&(n.insertAfter?n.insertAfter(l):(e.unshift(l),a++))}c?n.node=o:i&&o.hasClass(`katex-newline`)&&(n.node=q([`leftmost`])),n.insertAfter=(t=>n=>{e.splice(t+1,0,n),a++})(a)}}r&&e.pop()},Yo=function(e){return e instanceof Ki||e instanceof ia||e instanceof ra&&e.hasClass(`enclosing`)?e:null},Xo=function(e,t){var n=Yo(e);if(n){var r=n.children;if(r.length){if(t===`right`)return Xo(r[r.length-1],`right`);if(t===`left`)return Xo(r[0],`left`)}}return e},Zo=function(e,t){return e?(t&&(e=Xo(e,t)),Ko[e.classes[0]]||null):null},Qo=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return q(t.concat(n))},Y=function(e,t,n){if(!e)return q();if(Ro[e.type]){var r=Ro[e.type](e,t);if(n&&t.size!==n.size){r=q(t.sizingClasses(n),[r],t);var i=t.sizeMultiplier/n.sizeMultiplier;r.height*=i,r.depth*=i}return r}throw new R(`Got group of unknown type: '`+e.type+`'`)};function $o(e,t){var n=q([`katex-base`],e,t),r=q([`katex-strut`]);return r.style.height=z(n.height+n.depth),n.depth&&(r.style.verticalAlign=z(-n.depth)),n.children.unshift(r),n}function es(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=qo(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s<r.length;s++)if(o.push(r[s]),r[s].hasClass(`mbin`)||r[s].hasClass(`mrel`)||r[s].hasClass(`allowbreak`)){for(var c=!1;s<r.length-1&&r[s+1].hasClass(`mspace`)&&!r[s+1].hasClass(`katex-newline`);)s++,o.push(r[s]),r[s].hasClass(`nobreak`)&&(c=!0);c||(a.push($o(o,t)),o=[])}else r[s].hasClass(`katex-newline`)&&(o.pop(),o.length>0&&(a.push($o(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push($o(o,t));var l;n?(l=$o(qo(n,t,!0),t),l.classes=[`katex-tag`],a.push(l)):i&&a.push(i);var u=q([`katex-html`],a);if(u.setAttribute(`aria-hidden`,`true`),l){var d=l.children[0];d.style.height=z(u.height+u.depth),u.depth&&(d.style.verticalAlign=z(-u.depth))}return u}function ts(e){return new Ki(e)}var X=class{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(var t of Object.entries(this.attributes)){var n=t[0],r=t[1];e.setAttribute(n,r)}this.classes.length>0&&(e.className=Zi(this.classes));for(var i=0;i<this.children.length;i++)if(this.children[i]instanceof ns&&this.children[i+1]instanceof ns){for(var a=this.children[i].toText()+this.children[++i].toText();this.children[i+1]instanceof ns;)a+=this.children[++i].toText();e.appendChild(new ns(a).toNode())}else e.appendChild(this.children[i].toNode());return e}toMarkup(){var e=`<`+this.type;for(var t of Object.entries(this.attributes)){var n=t[0],r=t[1];e+=` `+n+`="`,e+=ti(r),e+=`"`}this.classes.length>0&&(e+=` class ="`+ti(Zi(this.classes))+`"`),e+=`>`;for(var i=0;i<this.children.length;i++)e+=this.children[i].toMarkup();return e+=`</`+this.type+`>`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},ns=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return ti(this.toText())}toText(){return this.text}},rs=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?` `:e>=-.05556&&e<=-.05555?` `:e>=-.1667&&e<=-.1666?` `:e>=-.2223&&e<=-.2222?` `:e>=-.2778&&e<=-.2777?` `:null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mspace`);return e.setAttribute(`width`,z(this.width)),e}toMarkup(){return this.character?`<mtext>`+this.character+`</mtext>`:`<mspace width="`+z(this.width)+`"/>`}toText(){return this.character?this.character:` `}},is=new Set([`\\imath`,`\\jmath`]),as=new Set([`mrow`,`mtable`]),os=function(e,t,n){var r,i;return xa[t][e]&&xa[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(ja,e)||(n==null||(r=n.fontFamily)==null?void 0:r.slice(4,6))!==`tt`&&(n==null||(i=n.font)==null?void 0:i.slice(4,6))!==`tt`)&&(e=xa[t][e].replace),new ns(e)},ss=function(e){return e.length===1?e[0]:new X(`mrow`,e)},cs={mathit:`italic`,boldsymbol:e=>e.type===`textord`?`bold`:`bold-italic`,mathbf:`bold`,mathbb:`double-struck`,mathsfit:`sans-serif-italic`,mathfrak:`fraktur`,mathscr:`script`,mathcal:`script`,mathsf:`sans-serif`,mathtt:`monospace`},ls=(e,t)=>{if(e.mode===`text`){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`bold-sans-serif`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`}var n=t.font;if(!n||n===`mathnormal`)return null;var r=e.mode,i=cs[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(is.has(a))return null;if(xa[r][a]){var o=xa[r][a].replace;o&&(a=o)}var s=ko[n].fontName;return va(a,s,r)?ko[n].variant:null};function us(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof ns&&t.text===`.`}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){var n=e.children[0];return n instanceof ns&&n.text===`,`}return!1}var ds=function(e,t,n){if(e.length===1){var r=ps(e[0],t);return n&&r instanceof X&&r.type===`mo`&&(r.setAttribute(`lspace`,`0em`),r.setAttribute(`rspace`,`0em`)),[r]}for(var i=[],a,o=0;o<e.length;o++){var s=ps(e[o],t);if(s instanceof X&&a instanceof X){if(s.type===`mtext`&&a.type===`mtext`&&s.getAttribute(`mathvariant`)===a.getAttribute(`mathvariant`)||s.type===`mn`&&a.type===`mn`||us(s)&&a.type===`mn`){a.children.push(...s.children);continue}if(s.type===`mn`&&us(a))s.children=[...a.children,...s.children],i.pop();else if((s.type===`msup`||s.type===`msub`)&&s.children.length>=1&&(a.type===`mn`||us(a))){var c=s.children[0];c instanceof X&&c.type===`mn`&&(c.children=[...a.children,...c.children],i.pop())}else if(a.type===`mi`&&a.children.length===1){var l=a.children[0];if(l instanceof ns&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof ns&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},fs=function(e,t,n){return ss(ds(e,t,n))},ps=function(e,t){if(!e)return new X(`mrow`);if(zo[e.type])return zo[e.type](e,t);throw new R(`Got group of unknown type: '`+e.type+`'`)};function ms(e,t,n,r,i){var a=ds(e,n),o=a.length===1&&a[0]instanceof X&&as.has(a[0].type)?a[0]:new X(`mrow`,a),s=new X(`annotation`,[new ns(t)]);s.setAttribute(`encoding`,`application/x-tex`);var c=new X(`math`,[new X(`semantics`,[o,s])]);return c.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r&&c.setAttribute(`display`,`block`),q([i?`katex`:`katex-mathml`],[c])}var hs=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],gs=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],_s=function(e,t){return t.size<2?e:hs[e-1][t.size-1]},vs=class e{constructor(t){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.strict=void 0,this.style=t.style,this.color=t.color,this.size=t.size||e.BASESIZE,this.textSize=t.textSize||this.size,this.phantom=!!t.phantom,this.font=t.font||``,this.fontFamily=t.fontFamily||``,this.fontWeight=t.fontWeight||``,this.fontShape=t.fontShape||``,this.sizeMultiplier=gs[this.size-1],this.maxSize=t.maxSize,this.minRuleThickness=t.minRuleThickness,this.strict=t.strict,this._fontMetrics=void 0}extend(t){var n={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness,strict:this.strict};return Object.assign(n,t),new e(n)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:_s(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:gs[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=_s(e.BASESIZE,t);return this.size===n&&this.textSize===e.BASESIZE&&this.style===t?this:this.extend({style:t,size:n})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}sizingClasses(e){return e.size===this.size?[]:[`katex-sizing`,`reset-size`+e.size,`size`+this.size]}baseSizingClasses(){return this.size===e.BASESIZE?[]:[`katex-sizing`,`reset-size`+this.size,`size`+e.BASESIZE]}fontMetrics(){return this._fontMetrics||=ba(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};vs.BASESIZE=6;var ys=e=>new vs({style:e.displayMode?Di.DISPLAY:Di.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness,strict:e.strict}),bs=function(e,t){if(t.displayMode){var n=[`katex-display`];t.leqno&&n.push(`leqno`),t.fleqn&&n.push(`fleqn`),e=q(n,[e])}return e},xs=function(e,t,n){var r=ys(n),i;return n.output===`mathml`?ms(e,t,r,n.displayMode,!0):(i=n.output===`html`?q([`katex`],[es(e,r)]):q([`katex`],[ms(e,t,r,n.displayMode,!1),es(e,r)]),bs(i,n))},Ss=function(e,t){return bs(q([`katex`],[es(e,ys(t))]),t)},Cs={widehat:`^`,widecheck:`ˇ`,widetilde:`~`,utilde:`~`,overleftarrow:`←`,underleftarrow:`←`,xleftarrow:`←`,overrightarrow:`→`,underrightarrow:`→`,xrightarrow:`→`,underbrace:`⏟`,overbrace:`⏞`,underbracket:`⎵`,overbracket:`⎴`,overgroup:`⏠`,undergroup:`⏡`,overleftrightarrow:`↔`,underleftrightarrow:`↔`,xleftrightarrow:`↔`,Overrightarrow:`⇒`,xRightarrow:`⇒`,overleftharpoon:`↼`,xleftharpoonup:`↼`,overrightharpoon:`⇀`,xrightharpoonup:`⇀`,xLeftarrow:`⇐`,xLeftrightarrow:`⇔`,xhookleftarrow:`↩`,xhookrightarrow:`↪`,xmapsto:`↦`,xrightharpoondown:`⇁`,xleftharpoondown:`↽`,xrightleftharpoons:`⇌`,xleftrightharpoons:`⇋`,xtwoheadleftarrow:`↞`,xtwoheadrightarrow:`↠`,xlongequal:`=`,xtofrom:`⇄`,xrightleftarrows:`⇄`,xrightequilibrium:`⇌`,xleftequilibrium:`⇋`,"\\cdrightarrow":`→`,"\\cdleftarrow":`←`,"\\cdlongequal":`=`},ws=function(e){var t=new X(`mo`,[new ns(Cs[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},Ts={overrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],overleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],underrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],underleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],xrightarrow:[[`rightarrow`],1.469,522,`xMaxYMin`],"\\cdrightarrow":[[`rightarrow`],3,522,`xMaxYMin`],xleftarrow:[[`leftarrow`],1.469,522,`xMinYMin`],"\\cdleftarrow":[[`leftarrow`],3,522,`xMinYMin`],Overrightarrow:[[`doublerightarrow`],.888,560,`xMaxYMin`],xRightarrow:[[`doublerightarrow`],1.526,560,`xMaxYMin`],xLeftarrow:[[`doubleleftarrow`],1.526,560,`xMinYMin`],overleftharpoon:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoonup:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoondown:[[`leftharpoondown`],.888,522,`xMinYMin`],overrightharpoon:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoonup:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoondown:[[`rightharpoondown`],.888,522,`xMaxYMin`],xlongequal:[[`longequal`],.888,334,`xMinYMin`],"\\cdlongequal":[[`longequal`],3,334,`xMinYMin`],xtwoheadleftarrow:[[`twoheadleftarrow`],.888,334,`xMinYMin`],xtwoheadrightarrow:[[`twoheadrightarrow`],.888,334,`xMaxYMin`],overleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],overbrace:[[`leftbrace`,`midbrace`,`rightbrace`],1.6,548],underbrace:[[`leftbraceunder`,`midbraceunder`,`rightbraceunder`],1.6,548],underleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],xleftrightarrow:[[`leftarrow`,`rightarrow`],1.75,522],xLeftrightarrow:[[`doubleleftarrow`,`doublerightarrow`],1.75,560],xrightleftharpoons:[[`leftharpoondownplus`,`rightharpoonplus`],1.75,716],xleftrightharpoons:[[`leftharpoonplus`,`rightharpoondownplus`],1.75,716],xhookleftarrow:[[`leftarrow`,`righthook`],1.08,522],xhookrightarrow:[[`lefthook`,`rightarrow`],1.08,522],overlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],underlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],overbracket:[[`leftbracketover`,`rightbracketover`],1.6,440],underbracket:[[`leftbracketunder`,`rightbracketunder`],1.6,410],overgroup:[[`leftgroup`,`rightgroup`],.888,342],undergroup:[[`leftgroupunder`,`rightgroupunder`],.888,342],xmapsto:[[`leftmapsto`,`rightarrow`],1.5,522],xtofrom:[[`leftToFrom`,`rightToFrom`],1.75,528],xrightleftarrows:[[`baraboveleftarrow`,`rightarrowabovebar`],1.75,901],xrightequilibrium:[[`baraboveshortleftharpoon`,`rightharpoonaboveshortbar`],1.75,716],xleftequilibrium:[[`shortbaraboveleftharpoon`,`shortrightharpoonabovebar`],1.75,716]},Es=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),Ds=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(Es.has(r)&&`base`in e){var i=e.base.type===`ordgroup`?e.base.body.length:1,a,o,s;if(i>5)r===`widehat`||r===`widecheck`?(a=420,n=2364,s=.42,o=r+`4`):(a=312,n=2340,s=.34,o=`tilde4`);else{var c=[1,1,2,2,3,3][i];r===`widehat`||r===`widecheck`?(n=[0,1062,2364,2364,2364][c],a=[0,239,300,360,420][c],s=[0,.24,.3,.3,.36,.42][c],o=r+c):(n=[0,600,1033,2339,2340][c],a=[0,260,286,306,312][c],s=[0,.26,.286,.3,.306,.34][c],o=`tilde`+c)}return{span:bo([],[new ca([new la(o)],{width:`100%`,height:z(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=Ts[r];if(!u)throw Error(`No SVG data for "`+r+`".`);var d=u[0],f=u[1],p=u[2],m=p/1e3,h=d.length,g,_;if(h===1){if(u.length!==4)throw Error(`Expected 4-tuple for single-path SVG data "`+r+`".`);g=[`hide-tail`],_=[u[3]]}else if(h===2)g=[`halfarrow-left`,`halfarrow-right`],_=[`xMinYMin`,`xMaxYMin`];else if(h===3)g=[`brace-left`,`brace-center`,`brace-right`],_=[`xMinYMin`,`xMidYMin`,`xMaxYMin`];else throw Error(`Correct katexImagesData or update code here to support
|
|
273
|
+
`+h+` children.`);for(var v=0;v<h;v++){var y=new ca([new la(d[v])],{width:`400em`,height:z(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=bo([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=z(m),l.push(b)}return{span:q([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=z(o),a>0&&(i.style.minWidth=z(a)),i},Os=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=q([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new ua({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new ua({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=bo([],[new ca(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},ks=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],As=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],js=new Set(ks),Ms=new Set(As);function Ns(e){return js.has(e)}function Ps(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function Fs(e){var t=Is(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function Is(e){return e.type===`atom`||Ms.has(e.type)?e:null}function Ls(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new R(t,e);return r}var Rs=e=>{if(e instanceof sa)return e;if(pa(e)&&e.children.length===1)return Rs(e.children[0])},zs=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Ps(e.base,`accent`),n=r.base,e.base=n,i=fa(Y(e,t)),e.base=r):(r=Ps(e,`accent`),n=r.base);var a=Y(n,t.havingCrampedStyle()),o=r.isShifty&&ii(n),s=0;o&&(s=Rs(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=Ds(r,t),u=Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+z(2*s)+`)`,marginLeft:z(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=jo(`vec`,t),f=Ao.vec[1]):(d=go({type:`textord`,mode:r.mode,text:r.label},t),d=da(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=q([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=z(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=q([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},Bs=(e,t)=>{var n=e.isStretchy?ws(e.label):new X(`mo`,[os(e.label,e.mode)]),r=new X(`mover`,[ps(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},Vs=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));J({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=Vo(t[0]),r=!Vs.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:zs,mathmlBuilder:Bs}),J({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(uo({strict:e.parser.settings.strict,errorCode:`mathVsTextAccents`,errorMsg:`LaTeX's accent `+e.funcName+` works only in text mode`,report:!0}),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),J({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=Y(e.base,t),r=Ds(e,t),i=e.label===`\\utilde`?.12:0;return q([`mord`,`accentunder`],[Eo({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=ws(e.label),r=new X(`munder`,[ps(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var Hs=e=>{var t=new X(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};J({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrightarrow`,`\\xLeftrightarrow`,`\\xhookleftarrow`,`\\xhookrightarrow`,`\\xmapsto`,`\\xrightharpoondown`,`\\xrightharpoonup`,`\\xleftharpoondown`,`\\xleftharpoonup`,`\\xrightleftharpoons`,`\\xleftrightharpoons`,`\\xlongequal`,`\\xtwoheadrightarrow`,`\\xtwoheadleftarrow`,`\\xtofrom`,`\\xrightleftarrows`,`\\xrightequilibrium`,`\\xleftequilibrium`,`\\\\cdrightarrow`,`\\\\cdleftarrow`,`\\\\cdlongequal`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=e.funcName;return{type:`xArrow`,mode:r.mode,label:i,body:t[0],below:n[0]}},htmlBuilder(e,t){var n=t.style,r=t.havingStyle(n.sup()),i=wo(Y(e.body,r,t),t),a=e.label.slice(0,2)===`\\x`?`x`:`cd`;i.classes.push(a+`-arrow-pad`);var o;e.below&&(r=t.havingStyle(n.sub()),o=wo(Y(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=Ds(e,t),c=-t.fontMetrics().axisHeight+.5*s.height,l=-t.fontMetrics().axisHeight-.5*s.height-.111;(i.depth>.25||e.label===`\\xleftequilibrium`)&&(l-=i.depth);var u;if(o){var d=-t.fontMetrics().axisHeight+o.height+.5*s.height+.111;u=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]},{type:`elem`,elem:o,shift:d}]})}else u=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]}]});return q([`mrel`,`x-arrow`],[u],t)},mathmlBuilder(e,t){var n=ws(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=Hs(ps(e.body,t));r=e.below?new X(`munderover`,[n,Hs(ps(e.below,t)),i]):new X(`mover`,[n,i])}else e.below?r=new X(`munder`,[n,Hs(ps(e.below,t))]):(r=Hs(),r=new X(`mover`,[n,r]));return r}});function Us(e,t){var n=qo(e.body,t,!0);return q([e.mclass],n,t)}function Ws(e,t){var n,r=ds(e.body,t);return e.mclass===`minner`?n=new X(`mpadded`,r):e.mclass===`mord`?e.isCharacterBox?(n=r[0],n.type=`mi`):n=new X(`mi`,r):(e.isCharacterBox?(n=r[0],n.type=`mo`):n=new X(`mo`,r),e.mclass===`mbin`?(n.attributes.lspace=`0.22em`,n.attributes.rspace=`0.22em`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0.17em`):(e.mclass===`mopen`||e.mclass===`mclose`)&&(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`)),n}J({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],numArgs:1,primitive:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`mclass`,mode:n.mode,mclass:`m`+r.slice(5),body:Ho(i),isCharacterBox:ii(i)}},htmlBuilder:Us,mathmlBuilder:Ws});var Gs=e=>{var t=e.type===`ordgroup`&&e.body.length?e.body[0]:e;return t.type===`atom`&&(t.family===`bin`||t.family===`rel`)?`m`+t.family:`mord`};J({type:`mclass`,names:[`\\@binrel`],numArgs:2,handler(e,t){return{type:`mclass`,mode:e.parser.mode,mclass:Gs(t[0]),body:Ho(t[1]),isCharacterBox:ii(t[1])}}}),J({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],numArgs:2,handler(e,t){var n=e.parser,r=e.funcName,i=t[1],a=t[0],o=r===`\\stackrel`?`mrel`:Gs(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:Ho(i)},c=r===`\\underset`?{type:`supsub`,mode:a.mode,base:s,sub:a}:{type:`supsub`,mode:a.mode,base:s,sup:a};return{type:`mclass`,mode:n.mode,mclass:o,body:[c],isCharacterBox:ii(c)}}}),J({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:Gs(t[0]),body:Ho(t[0])}},htmlBuilder(e,t){var n=qo(e.body,t,!0),r=q([e.mclass],n,t);return r.style.textShadow=`0.02em 0.01em 0.04px`,r},mathmlBuilder(e,t){var n=new X(`mstyle`,ds(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var Ks={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},qs=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),Js=e=>e.type===`textord`&&e.text===`@`,Ys=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function Xs(e,t,n){var r=Ks[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:var i=n.callFunction(`\\\\cdleft`,[t[0]],[]),a={type:`atom`,text:r,mode:`math`,family:`rel`},o={type:`ordgroup`,mode:`math`,body:[i,n.callFunction(`\\Big`,[a],[]),n.callFunction(`\\\\cdright`,[t[1]],[])]};return n.callFunction(`\\\\cdparent`,[o],[]);case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function Zs(e){var t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();var n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new R(`Expected \\\\ or \\cr or \\end`,e.nextToken)}for(var r=[],i=[r],a=0;a<t.length;a++){for(var o=t[a],s=qs(),c=0;c<o.length;c++)if(!Js(o[c]))s.body.push(o[c]);else{r.push(s),c+=1;var l=Fs(o[c]).text,u=[,,];if(u[0]={type:`ordgroup`,mode:`math`,body:[]},u[1]={type:`ordgroup`,mode:`math`,body:[]},!`=|.`.includes(l)){if(`<>AV`.includes(l))for(var d=0;d<2;d++){for(var f=!0,p=c+1;p<o.length;p++){if(Ys(o[p],l)){f=!1,c=p;break}if(Js(o[p]))throw new R(`Missing a `+l+` character to complete a CD arrow.`,o[p]);u[d].body.push(o[p])}if(f)throw new R(`Missing a `+l+` character to complete a CD arrow.`,o[c])}else throw new R(`Expected one of "<>AV=|." after @`,o[c])}var m={type:`styling`,body:[Xs(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=qs()}a%2==0?r.push(s):r.shift(),r=[],i.push(r)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:Array(i[0].length).fill({type:`align`,align:`c`,pregap:.25,postgap:.25}),colSeparationType:`CD`,hLinesBeforeRow:Array(i.length+1).fill([])}}J({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`cdlabel`,mode:n.mode,side:r.slice(4),label:t[0]}},htmlBuilder(e,t){var n=t.havingStyle(t.style.sup()),r=wo(Y(e.label,n,t),t);return r.classes.push(`cd-label-`+e.side),r.style.bottom=z(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(e,t){var n=new X(`mrow`,[ps(e.label,t)]);return n=new X(`mpadded`,[n]),n.setAttribute(`width`,`0`),e.side===`left`&&n.setAttribute(`lspace`,`-1width`),n.setAttribute(`voffset`,`0.7em`),n=new X(`mstyle`,[n]),n.setAttribute(`displaystyle`,`false`),n.setAttribute(`scriptlevel`,`1`),n}}),J({type:`cdlabelparent`,names:[`\\\\cdparent`],numArgs:1,handler(e,t){return{type:`cdlabelparent`,mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){var n=wo(Y(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new X(`mrow`,[ps(e.fragment,t)])}}),J({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=Ls(Ps(t[0],`ordgroup`),`\\@char has non-numeric argument`),i=parseInt(r),a;if(isNaN(i))throw new R(`\\@char has non-numeric argument `+r);if(i<0||i>1114111)throw new R(`\\@char with invalid code point `+r);return i<=65535?a=String.fromCharCode(i):(i-=65536,a=String.fromCharCode((i>>10)+55296,(i&1023)+56320)),{type:`textord`,mode:n.mode,text:a}}}),J({type:`color`,names:[`\\textcolor`],numArgs:2,allowedInText:!0,argTypes:[`color`,`original`],handler(e,t){var n=e.parser,r=Ps(t[0],`color-token`).color,i=t[1];return{type:`color`,mode:n.mode,color:r,body:Ho(i)}},htmlBuilder:(e,t)=>Co(qo(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new X(`mstyle`,ds(e.body,t.withColor(e.color)));return n.setAttribute(`mathcolor`,e.color),n}}),J({type:`color`,names:[`\\color`],numArgs:1,allowedInText:!0,argTypes:[`color`],handler(e,t){var n=e.parser,r=e.breakOnTokenText,i=Ps(t[0],`color-token`).color;n.gullet.macros.set(`\\current@color`,i);var a=n.parseExpression(!0,r);return{type:`color`,mode:n.mode,color:i,body:a}}}),J({type:`cr`,names:[`\\\\`],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e){var t=e.parser,n=t.gullet.future().text===`[`?t.parseSizeGroup(!0):null,r=!t.settings.displayMode||!uo({strict:t.settings.strict,errorCode:`newLineInDisplayMode`,errorMsg:`In LaTeX, \\\\ or \\newline does nothing in display mode`,report:!1});return{type:`cr`,mode:t.mode,newLine:r,size:n&&Ps(n,`size`).value}},htmlBuilder(e,t){var n=q([`mspace`],[],t);return e.newLine&&(n.classes.push(`katex-newline`),e.size&&(n.style.marginTop=z(Xi(e.size,t)))),n},mathmlBuilder(e,t){var n=new X(`mspace`);return e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size&&n.setAttribute(`height`,z(Xi(e.size,t)))),n}});var Qs={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},$s=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new R(`Expected a control sequence`,e);return t},ec=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},tc=(e,t,n,r)=>{var i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};J({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],numArgs:0,allowedInText:!0,handler(e){var t=e.parser,n=e.funcName;t.consumeSpaces();var r=t.fetch();if(Qs[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=Qs[r.text]),Ps(t.parseFunction(),`internal`);throw new R(`Invalid token after macro prefix`,r)}}),J({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=t.gullet.popToken(),i=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new R(`Expected a control sequence`,r);for(var a=0,o,s=[[]];t.gullet.future().text!==`{`;)if(r=t.gullet.popToken(),r.text===`#`){if(t.gullet.future().text===`{`){o=t.gullet.future(),s[a].push(`{`);break}if(r=t.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new R(`Invalid argument number "`+r.text+`"`);if(parseInt(r.text)!==a+1)throw new R(`Argument number "`+r.text+`" out of order`);a++,s.push([])}else if(r.text===`EOF`)throw new R(`Expected a macro definition`);else s[a].push(r.text);var c=t.gullet.consumeArg().tokens;return o&&c.unshift(o),(n===`\\edef`||n===`\\xdef`)&&(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(i,{tokens:c,numArgs:a,delimiters:s},n===Qs[n]),{type:`internal`,mode:t.mode}}}),J({type:`internal`,names:[`\\let`,`\\\\globallet`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=$s(t.gullet.popToken());return t.gullet.consumeSpaces(),tc(t,r,ec(t),n===`\\\\globallet`),{type:`internal`,mode:t.mode}}}),J({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=$s(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return tc(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var nc=function(e,t,n){var r=va(xa.math[e]&&xa.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},rc=function(e,t,n,r){var i=n.havingBaseStyle(t),a=q(r.concat(i.sizingClasses(n)),[e],n),o=i.sizeMultiplier/n.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=i.sizeMultiplier,a},ic=function(e,t,n){var r=t.havingBaseStyle(n),i=(1-t.sizeMultiplier/r.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push(`delimcenter`),e.style.top=z(i),e.height-=i,e.depth+=i},ac=function(e,t,n,r,i,a){var o=rc(po(e,`Main-Regular`,i,r),t,r,a);return n&&ic(o,r,t),o},oc=function(e,t,n,r){return po(e,`Size`+t+`-Regular`,n,r)},sc=function(e,t,n,r,i,a){var o=oc(e,t,i,r),s=rc(q([`delimsizing`,`size`+t],[o],r),Di.TEXT,r,a);return n&&ic(s,r,Di.TEXT),s},cc=function(e,t,n,r){return{type:`elem`,elem:q([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[q([],[po(e,t,n,r)])])}},lc=function(e,t,n){var r=ma[`Size4-Regular`][e.charCodeAt(0)]?ma[`Size4-Regular`][e.charCodeAt(0)][4]:ma[`Size1-Regular`][e.charCodeAt(0)][4],i=bo([],[new ca([new la(`inner`,Hi(e,Math.round(1e3*t)))],{width:z(r),height:z(t),style:`width:`+z(r),viewBox:`0 0 `+1e3*r+` `+Math.round(1e3*t),preserveAspectRatio:`xMinYMin`})],n);return i.height=t,i.style.height=z(t),i.style.width=z(r),{type:`elem`,elem:i}},uc=.008,dc={type:`kern`,size:-1*uc},fc=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),pc=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),mc=function(e,t,n,r,i,a){var o,s,c,l,u=``,d=0;o=c=l=e,s=null;var f=`Size1-Regular`;e===`\\uparrow`?c=l=`⏐`:e===`\\Uparrow`?c=l=`‖`:e===`\\downarrow`?o=c=`⏐`:e===`\\Downarrow`?o=c=`‖`:e===`\\updownarrow`?(o=`\\uparrow`,c=`⏐`,l=`\\downarrow`):e===`\\Updownarrow`?(o=`\\Uparrow`,c=`‖`,l=`\\Downarrow`):fc.has(e)?(c=`∣`,u=`vert`,d=333):pc.has(e)?(c=`∥`,u=`doublevert`,d=556):e===`[`||e===`\\lbrack`?(o=`⎡`,c=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lbrack`,d=667):e===`]`||e===`\\rbrack`?(o=`⎤`,c=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rbrack`,d=667):e===`\\lfloor`||e===`⌊`?(c=o=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lfloor`,d=667):e===`\\lceil`||e===`⌈`?(o=`⎡`,c=l=`⎢`,f=`Size4-Regular`,u=`lceil`,d=667):e===`\\rfloor`||e===`⌋`?(c=o=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rfloor`,d=667):e===`\\rceil`||e===`⌉`?(o=`⎤`,c=l=`⎥`,f=`Size4-Regular`,u=`rceil`,d=667):e===`(`||e===`\\lparen`?(o=`⎛`,c=`⎜`,l=`⎝`,f=`Size4-Regular`,u=`lparen`,d=875):e===`)`||e===`\\rparen`?(o=`⎞`,c=`⎟`,l=`⎠`,f=`Size4-Regular`,u=`rparen`,d=875):e===`\\{`||e===`\\lbrace`?(o=`⎧`,s=`⎨`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\}`||e===`\\rbrace`?(o=`⎫`,s=`⎬`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lgroup`||e===`⟮`?(o=`⎧`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\rgroup`||e===`⟯`?(o=`⎫`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lmoustache`||e===`⎰`?(o=`⎧`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):(e===`\\rmoustache`||e===`⎱`)&&(o=`⎫`,l=`⎩`,c=`⎪`,f=`Size4-Regular`);var p=nc(o,f,i),m=p.height+p.depth,h=nc(c,f,i),g=h.height+h.depth,_=nc(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=nc(s,f,i);y=x.height+x.depth,b=2}var S=m+v+y,C=S+Math.max(0,Math.ceil((t-S)/(b*g)))*b*g,w=r.fontMetrics().axisHeight;n&&(w*=r.sizeMultiplier);var T=C/2-w,E=[];if(u.length>0){var D=C-m-v,O=Math.round(C*1e3),k=Wi(u,Math.round(D*1e3)),A=new la(u,k),j=z(d/1e3),ee=z(O/1e3),M=bo([],[new ca([A],{width:j,height:ee,viewBox:`0 0 `+d+` `+O})],r);M.height=O/1e3,M.style.width=j,M.style.height=ee,E.push({type:`elem`,elem:M})}else{if(E.push(cc(l,f,i,r)),E.push(dc),s===null){var te=C-m-v+2*uc;E.push(lc(c,te,r))}else{var N=(C-m-v-y)/2+2*uc;E.push(lc(c,N,r)),E.push(dc),E.push(cc(s,f,i,r)),E.push(dc),E.push(lc(c,N,r))}E.push(dc),E.push(cc(o,f,i,r))}var ne=r.havingBaseStyle(Di.TEXT);return rc(q([`delimsizing`,`mult`],[Eo({positionType:`bottom`,positionData:T,children:E})],ne),Di.TEXT,r,a)},hc=80,gc=.08,_c=function(e,t,n,r,i){return bo([`hide-tail`],[new ca([new la(e,Vi(e,r,n))],{width:`400em`,height:z(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},vc=function(e,t){var n=t.havingBaseSizing(),r=Oc(`\\surd`,e*n.sizeMultiplier,Ec,n),i=n.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,s,c,l,u;return r.type===`small`?(l=1e3+1e3*a+hc,e<1?i=1:e<1.4&&(i=.7),s=(1+a+gc)/i,c=(1+a)/i,o=_c(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+hc)*Sc[r.size],c=(Sc[r.size]+a)/i,s=(Sc[r.size]+a+gc)/i,o=_c(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+gc,c=e+a,l=Math.floor(1e3*e+a)+hc,o=_c(`sqrtTall`,s,l,a,t),o.style.minWidth=`0.742em`,u=1.056),o.height=c,o.style.height=z(s),{span:o,advanceWidth:u,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*i}},yc=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),bc=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),xc=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),Sc=[0,1.2,1.8,2.4,3],Cc=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),yc.has(e)||xc.has(e))return sc(e,t,!1,n,r,i);if(bc.has(e))return mc(e,Sc[t],!1,n,r,i);throw new R(`Illegal delimiter: '`+e+`'`)},wc=[{type:`small`,style:Di.SCRIPTSCRIPT},{type:`small`,style:Di.SCRIPT},{type:`small`,style:Di.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4}],Tc=[{type:`small`,style:Di.SCRIPTSCRIPT},{type:`small`,style:Di.SCRIPT},{type:`small`,style:Di.TEXT},{type:`stack`}],Ec=[{type:`small`,style:Di.SCRIPTSCRIPT},{type:`small`,style:Di.SCRIPT},{type:`small`,style:Di.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4},{type:`stack`}],Dc=function(e){if(e.type===`small`)return`Main-Regular`;if(e.type===`large`)return`Size`+e.size+`-Regular`;if(e.type===`stack`)return`Size4-Regular`;var t=e.type;throw Error(`Add support for delim type '`+t+`' here.`)},Oc=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);i<n.length;i++){var a=n[i];if(a.type===`stack`)break;var o=nc(e,Dc(a),`math`),s=o.height+o.depth;if(a.type===`small`){var c=r.havingBaseStyle(a.style);s*=c.sizeMultiplier}if(s>t)return a}return n[n.length-1]},kc=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=xc.has(e)?wc:yc.has(e)?Ec:Tc,s=Oc(e,t,o,r);return s.type===`small`?ac(e,s.style,n,r,i,a):s.type===`large`?sc(e,s.size,n,r,i,a):mc(e,t,n,r,i,a)},Ac=function(e,t,n,r,i,a){var o=r.fontMetrics().axisHeight*r.sizeMultiplier,s=901,c=5/r.fontMetrics().ptPerEm,l=Math.max(t-o,n+o);return kc(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},jc={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},Mc=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,/,\\backslash,|,\\vert,\\|,\\Vert,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`));function Nc(e){return`isMiddle`in e}function Pc(e,t){var n=Is(e);if(n&&Mc.has(n.text))return n;throw n?new R(`Invalid delimiter '`+n.text+`' after '`+t.funcName+`'`,e):new R(`Invalid delimiter type '`+e.type+`'`,e)}J({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],numArgs:1,argTypes:[`primitive`],handler:(e,t)=>{var n=Pc(Vo(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:jc[e.funcName].size,mclass:jc[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?q([e.mclass]):Cc(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(os(e.delim,e.mode));var n=new X(`mo`,t);e.mclass===`mopen`||e.mclass===`mclose`?n.setAttribute(`fence`,`true`):n.setAttribute(`fence`,`false`),n.setAttribute(`stretchy`,`true`);var r=z(Sc[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function Fc(e){if(!e.body)throw Error(`Bug: The leftright ParseNode wasn't fully parsed.`)}J({type:`leftright-right`,names:[`\\right`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser.gullet.macros.get(`\\current@color`);if(n&&typeof n!=`string`)throw new R(`\\current@color set to non-string in \\right`);return{type:`leftright-right`,mode:e.parser.mode,delim:Pc(t[0],e).text,color:n}}}),J({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=Pc(t[0],e),r=e.parser;++r.leftrightDepth;var i=r.parseExpression(!1);--r.leftrightDepth,r.expect(`\\right`,!1);var a=Ps(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:a.delim,rightColor:a.color}},htmlBuilder:(e,t)=>{Fc(e);for(var n=qo(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o<n.length;o++){var s=n[o];Nc(s)?a=!0:(r=Math.max(n[o].height,r),i=Math.max(n[o].depth,i))}r*=t.sizeMultiplier,i*=t.sizeMultiplier;var c=e.left===`.`?Qo(t,[`mopen`]):Ac(e.left,r,i,t,e.mode,[`mopen`]);if(n.unshift(c),a)for(var l=1;l<n.length;l++){var u=n[l];if(Nc(u)){var d=u.isMiddle;n[l]=Ac(d.delim,r,i,d.options,e.mode,[])}}var f;if(e.right===`.`)f=Qo(t,[`mclose`]);else{var p=e.rightColor?t.withColor(e.rightColor):t;f=Ac(e.right,r,i,p,e.mode,[`mclose`])}return n.push(f),q([`minner`],n,t)},mathmlBuilder:(e,t)=>{Fc(e);var n=ds(e.body,t);if(e.left!==`.`){var r=new X(`mo`,[os(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new X(`mo`,[os(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return ss(n)}}),J({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=Pc(t[0],e);if(!e.parser.leftrightDepth)throw new R(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},htmlBuilder:(e,t)=>{var n;return e.delim===`.`?n=Qo(t,[]):(n=Cc(e.delim,1,t,e.mode,[]),n.isMiddle={delim:e.delim,options:t}),n},mathmlBuilder:(e,t)=>{var n=new X(`mo`,[e.delim===`\\vert`||e.delim===`|`?os(`|`,`text`):os(e.delim,e.mode)]);return n.setAttribute(`fence`,`true`),n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`),n}}),J({type:`enclose`,names:[`\\colorbox`],numArgs:2,allowedInText:!0,argTypes:[`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=Ps(t[0],`color-token`).color,o=t[1];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:a,body:o}},htmlBuilder:(e,t)=>{var n=wo(Y(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=ii(e.body);if(r===`sout`)a=q([`katex-stretchy`,`katex-sout`]),a.height=t.fontMetrics().defaultRuleThickness/i,o=-.5*t.fontMetrics().xHeight;else if(r===`phase`){var c=Xi({number:.6,unit:`pt`},t),l=Xi({number:.35,unit:`ex`},t),u=t.havingBaseSizing();i/=u.sizeMultiplier;var d=n.height+n.depth+c+l;n.style.paddingLeft=z(d/2+c);var f=Math.floor(1e3*d*i);a=bo([`hide-tail`],[new ca([new la(`phase`,zi(f))],{width:`400em`,height:z(f/1e3),viewBox:`0 0 400000 `+f,preserveAspectRatio:`xMinYMin slice`})],t),a.style.height=z(d),o=n.depth+c+l}else{/cancel/.test(r)?s||n.classes.push(`cancel-pad`):r===`angl`?n.classes.push(`anglpad`):n.classes.push(`boxpad`);var p,m,h=0;/box/.test(r)?(h=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),p=t.fontMetrics().fboxsep+(r===`colorbox`?0:h),m=p):r===`angl`?(h=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),p=4*h,m=Math.max(0,.25-n.depth)):(p=s?.2:0,m=p),a=Os(n,r,p,m,t),/fbox|boxed|fcolorbox/.test(r)?(a.style.borderStyle=`solid`,a.style.borderWidth=z(h)):r===`angl`&&h!==.049&&(a.style.borderTopWidth=z(h),a.style.borderRightWidth=z(h)),o=n.depth+m,e.backgroundColor&&(a.style.backgroundColor=e.backgroundColor,e.borderColor&&(a.style.borderColor=e.borderColor))}var g;if(e.backgroundColor)g=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:n,shift:0},{type:`elem`,elem:a,shift:o,wrapperClasses:_}]})}return/cancel/.test(r)&&(g.height=n.height,g.depth=n.depth),/cancel/.test(r)&&!s?q([`mord`,`cancel-lap`],[g],t):q([`mord`],[g],t)},mathmlBuilder:(e,t)=>{var n,r=new X(e.label.includes(`colorbox`)?`mpadded`:`menclose`,[ps(e.body,t)]);switch(e.label){case`\\cancel`:r.setAttribute(`notation`,`updiagonalstrike`);break;case`\\bcancel`:r.setAttribute(`notation`,`downdiagonalstrike`);break;case`\\phase`:r.setAttribute(`notation`,`phasorangle`);break;case`\\sout`:r.setAttribute(`notation`,`horizontalstrike`);break;case`\\fbox`:r.setAttribute(`notation`,`box`);break;case`\\angl`:r.setAttribute(`notation`,`actuarial`);break;case`\\fcolorbox`:case`\\colorbox`:if(n=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,r.setAttribute(`width`,`+`+2*n+`pt`),r.setAttribute(`height`,`+`+2*n+`pt`),r.setAttribute(`lspace`,n+`pt`),r.setAttribute(`voffset`,n+`pt`),e.label===`\\fcolorbox`){var i=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);r.setAttribute(`style`,`border: `+z(i)+` solid `+e.borderColor)}break;case`\\xcancel`:r.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`)}return e.backgroundColor&&r.setAttribute(`mathbackground`,e.backgroundColor),r}}),J({type:`enclose`,names:[`\\fcolorbox`],numArgs:3,allowedInText:!0,argTypes:[`color`,`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=Ps(t[0],`color-token`).color,o=Ps(t[1],`color-token`).color,s=t[2];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:o,borderColor:a,body:s}}}),J({type:`enclose`,names:[`\\fbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\fbox`,body:t[0]}}}),J({type:`enclose`,names:[`\\cancel`,`\\bcancel`,`\\xcancel`,`\\phase`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),J({type:`enclose`,names:[`\\sout`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName;n.mode===`math`&&uo({strict:n.settings.strict,errorCode:`mathVsSout`,errorMsg:`LaTeX's \\sout works only in text mode`,report:!0});var i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),J({type:`enclose`,names:[`\\angl`],numArgs:1,argTypes:[`hbox`],allowedInText:!1,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\angl`,body:t[0]}}});var Ic={};function Lc(e){for(var t=e.type,n=e.names,r=e.props,i=e.handler,a=e.htmlBuilder,o=e.mathmlBuilder,s={type:t,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},c=0;c<n.length;++c)Ic[n[c]]=s;a&&(Ro[t]=a),o&&(zo[t]=o)}var Rc={};function Z(e,t){Rc[e]=t}var zc=class e{constructor(e,t,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=n}static range(t,n){return n?!t||!t.loc||!n.loc||t.loc.lexer!==n.loc.lexer?null:new e(t.loc.lexer,t.loc.start,n.loc.end):t&&t.loc}},Bc=class e{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(t,n){return new e(n,zc.range(this,t))}};function Vc(e){var t=[];e.consumeSpaces();var n=e.fetch().text;for(n===`\\relax`&&(e.consume(),e.consumeSpaces(),n=e.fetch().text);n===`\\hline`||n===`\\hdashline`;)e.consume(),t.push(n===`\\hdashline`),e.consumeSpaces(),n=e.fetch().text;return t}var Hc=e=>{if(!e.parser.settings.displayMode)throw new R(`{`+e.envName+`} can be used only in display mode.`)},Uc=new Set([`gather`,`gather*`]);function Wc(e){if(!e.includes(`ed`))return!e.includes(`*`)}function Gc(e,t,n){var r=t.hskipBeforeAndAfter,i=t.addJot,a=t.cols,o=t.arraystretch,s=t.colSeparationType,c=t.autoTag,l=t.singleRow,u=t.emptySingleRow,d=t.maxNumCols,f=t.leqno;if(e.gullet.beginGroup(),l||e.gullet.macros.set(`\\cr`,`\\\\\\relax`),!o){var p=e.gullet.expandMacroAsText(`\\arraystretch`);if(p==null)o=1;else if(o=parseFloat(p),!o||o<0)throw new R(`Invalid \\arraystretch: `+p)}e.gullet.beginGroup();var m=[],h=[m],g=[],_=[],v=c==null?void 0:[];function y(){c&&e.gullet.macros.set(`\\@eqnsw`,`1`,!0)}function b(){v&&(e.gullet.macros.get(`\\df@tag`)?(v.push(e.subparse([new Bc(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(Vc(e));;){var x=e.parseExpression(!1,l?`\\end`:`\\\\`);e.gullet.endGroup(),e.gullet.beginGroup();var S={type:`ordgroup`,mode:e.mode,body:x};n&&(S={type:`styling`,mode:e.mode,style:n,resetFont:!0,body:[S]}),m.push(S);var C=e.fetch().text;if(C===`&`){if(d&&m.length===d){if(l||s)throw new R(`Too many tab characters: &`,e.nextToken);uo({strict:e.settings.strict,errorCode:`textEnv`,errorMsg:`Too few columns specified in the {array} column argument.`,report:!0})}e.consume()}else if(C===`\\end`){b(),m.length===1&&S.type===`styling`&&S.body.length===1&&S.body[0].type===`ordgroup`&&S.body[0].body.length===0&&(h.length>1||!u)&&!Array.isArray(v?.[v.length-1])&&!(c&&v?.[v.length-1]===!0)&&h.pop(),_.length<h.length+1&&_.push([]);break}else if(C===`\\\\`){e.consume();var w=void 0;e.gullet.future().text!==` `&&(w=e.parseSizeGroup(!0)),g.push(w?w.value:null),b(),_.push(Vc(e)),m=[],h.push(m),y()}else throw new R(`Expected & or \\\\ or \\cr or \\end`,e.nextToken)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:e.mode,addJot:i,arraystretch:o,body:h,cols:a,rowGaps:g,hskipBeforeAndAfter:r,hLinesBeforeRow:_,colSeparationType:s,tags:v,leqno:f}}function Kc(e){return e.slice(0,1)===`d`?`display`:`text`}var qc=function(e,t){var n,r,i=e.body.length,a=e.hLinesBeforeRow,o=0,s=Array(i),c=[],l=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),u=1/t.fontMetrics().ptPerEm,d=5*u;e.colSeparationType&&e.colSeparationType===`small`&&(d=.2778*(t.havingStyle(Di.SCRIPT).sizeMultiplier/t.sizeMultiplier));var f=e.colSeparationType===`CD`?Xi({number:3,unit:`ex`},t):12*u,p=3*u,m=e.arraystretch*f,h=.7*m,g=.3*m,_=0;function v(e){for(var t=0;t<e.length;++t)t>0&&(_+=.25),c.push({pos:_,isDashed:e[t]})}for(v(a[0]),n=0;n<e.body.length;++n){var y=e.body[n],b=h,x=g;o<y.length&&(o=y.length);var S={cells:Array(y.length),height:0,depth:0,pos:0};for(r=0;r<y.length;++r){var C=Y(y[r],t);x<C.depth&&(x=C.depth),b<C.height&&(b=C.height),S.cells[r]=C}var w=e.rowGaps[n],T=0;w&&(T=Xi(w,t),T>0&&(T+=g,x<T&&(x=T),T=0)),e.addJot&&n<e.body.length-1&&(x+=p),S.height=b,S.depth=x,_+=b,S.pos=_,_+=x+T,s[n]=S,v(a[n+1])}var E=_/2+t.fontMetrics().axisHeight,D=e.cols||[],O=[],k,A,j=[];if(e.tags&&e.tags.some(e=>e))for(n=0;n<i;++n){var ee=s[n],M=ee.pos-E,te=e.tags[n],N=void 0;N=te===!0?q([`eqn-num`],[],t):te===!1?q([],[],t):q([],qo(te,t,!0),t),N.depth=ee.depth,N.height=ee.height,j.push({type:`elem`,elem:N,shift:M})}for(r=0,A=0;r<o||A<D.length;++r,++A){for(var ne=D[A],re=!0;(ie=ne)?.type===`separator`;){var ie;if(re||(k=q([`arraycolsep`],[]),k.style.width=z(t.fontMetrics().doubleRuleSep),O.push(k)),ne.separator===`|`||ne.separator===`:`){var ae=ne.separator===`|`?`solid`:`dashed`,oe=q([`vertical-separator`],[],t);oe.style.height=z(_),oe.style.borderRightWidth=z(l),oe.style.borderRightStyle=ae,oe.style.margin=`0 `+z(-l/2);var se=_-E;se&&(oe.style.verticalAlign=z(-se)),O.push(oe)}else throw new R(`Invalid separator type: `+ne.separator);A++,ne=D[A],re=!1}if(!(r>=o)){var ce=void 0;(r>0||e.hskipBeforeAndAfter)&&(ce=ne?.pregap??d,ce!==0&&(k=q([`arraycolsep`],[]),k.style.width=z(ce),O.push(k)));var le=[];for(n=0;n<i;++n){var ue=s[n],de=ue.cells[r];if(de){var fe=ue.pos-E;de.depth=ue.depth,de.height=ue.height,le.push({type:`elem`,elem:de,shift:fe})}}var pe=Eo({positionType:`individualShift`,children:le}),me=q([`col-align-`+(ne?.align||`c`)],[pe]);O.push(me),(r<o-1||e.hskipBeforeAndAfter)&&(ce=ne?.postgap??d,ce!==0&&(k=q([`arraycolsep`],[]),k.style.width=z(ce),O.push(k)))}}var he=q([`mtable`],O);if(c.length>0){for(var ge=xo(`katex-hline`,t,l),P=xo(`katex-hdashline`,t,l),_e=[{type:`elem`,elem:he,shift:0}];c.length>0;){var ve=c.pop(),ye=ve.pos-E;ve.isDashed?_e.push({type:`elem`,elem:P,shift:ye}):_e.push({type:`elem`,elem:ge,shift:ye})}he=Eo({positionType:`individualShift`,children:_e})}if(j.length===0)return q([`mord`],[he],t);var be=q([`katex-tag`],[Eo({positionType:`individualShift`,children:j})],t);return Co([he,be])},Jc={c:`center `,l:`left `,r:`right `},Yc=function(e,t){for(var n=[],r=new X(`mtd`,[],[`mtr-glue`]),i=new X(`mtd`,[],[`mml-eqn-num`]),a=0;a<e.body.length;a++){for(var o=e.body[a],s=[],c=0;c<o.length;c++)s.push(new X(`mtd`,[ps(o[c],t)]));e.tags&&e.tags[a]&&(s.unshift(r),s.push(r),e.leqno?s.unshift(i):s.push(i)),n.push(new X(`mtr`,s))}var l=new X(`mtable`,n),u=e.arraystretch===.5?.1:.16+e.arraystretch-1+(e.addJot?.09:0);l.setAttribute(`rowspacing`,z(u));var d=``,f=``;if(e.cols&&e.cols.length>0){var p=e.cols,m=``,h=!1,g=0,_=p.length;p[0].type===`separator`&&(d+=`top `,g=1),p[p.length-1].type===`separator`&&(d+=`bottom `,--_);for(var v=g;v<_;v++){var y=p[v];y.type===`align`?(f+=Jc[y.align],h&&(m+=`none `),h=!0):y.type===`separator`&&(h&&=(m+=y.separator===`|`?`solid `:`dashed `,!1))}l.setAttribute(`columnalign`,f.trim()),/[sd]/.test(m)&&l.setAttribute(`columnlines`,m.trim())}if(e.colSeparationType===`align`){for(var b=e.cols||[],x=``,S=1;S<b.length;S++)x+=S%2?`0em `:`1em `;l.setAttribute(`columnspacing`,x.trim())}else e.colSeparationType===`alignat`||e.colSeparationType===`gather`?l.setAttribute(`columnspacing`,`0em`):e.colSeparationType===`small`?l.setAttribute(`columnspacing`,`0.2778em`):e.colSeparationType===`CD`?l.setAttribute(`columnspacing`,`0.5em`):l.setAttribute(`columnspacing`,`1em`);var C=``,w=e.hLinesBeforeRow;d+=w[0].length>0?`left `:``,d+=w[w.length-1].length>0?`right `:``;for(var T=1;T<w.length-1;T++)C+=w[T].length===0?`none `:w[T][0]?`dashed `:`solid `;return/[sd]/.test(C)&&l.setAttribute(`rowlines`,C.trim()),d!==``&&(l=new X(`menclose`,[l]),l.setAttribute(`notation`,d.trim())),e.arraystretch&&e.arraystretch<1&&(l=new X(`mstyle`,[l]),l.setAttribute(`scriptlevel`,`1`)),l},Xc=function(e,t){e.envName.includes(`ed`)||Hc(e);var n=[],r=e.envName===`split`,i=Gc(e.parser,{cols:n,addJot:!0,autoTag:r?void 0:Wc(e.envName),emptySingleRow:!0,colSeparationType:e.envName.includes(`at`)?`alignat`:`align`,maxNumCols:r?2:void 0,leqno:e.parser.settings.leqno},`display`),a=0,o=0,s={type:`ordgroup`,mode:e.mode,body:[]};if(t[0]&&t[0].type===`ordgroup`){var c=`Number of columns should be a positive integer`,l=Ls(t[0],c);if(!/^[0-9]+$/.test(l)||Number(l)<1)throw new R(c,t[0]);a=Number(l),o=a*2}var u=!o;i.body.forEach(function(e){for(var t=1;t<e.length;t+=2)Ps(Ps(e[t],`styling`).body[0],`ordgroup`).body.unshift(s);if(u)o<e.length&&(o=e.length);else{var n=e.length/2;if(a<n)throw new R(`Too many math in a row: `+(`expected `+a+`, but got `+n),e[0])}});for(var d=0;d<o;++d){var f=`r`,p=0;d%2==1?f=`l`:d>0&&u&&(p=1),n[d]={type:`align`,align:f,pregap:p,postgap:0}}return i.colSeparationType=u?`align`:`alignat`,i};Lc({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(Is(t[0])?[t[0]]:Ps(t[0],`ordgroup`).body).map(function(e){var t=Fs(e).text;if(`lcr`.includes(t))return{type:`align`,align:t};if(t===`|`)return{type:`separator`,separator:`|`};if(t===`:`)return{type:`separator`,separator:`:`};throw new R(`Unknown column alignment: `+t,e)}),r={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return Gc(e.parser,r,Kc(e.envName))},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`matrix`,`pmatrix`,`bmatrix`,`Bmatrix`,`vmatrix`,`Vmatrix`,`matrix*`,`pmatrix*`,`bmatrix*`,`Bmatrix*`,`vmatrix*`,`Vmatrix*`],props:{numArgs:0},handler(e){var t={matrix:null,pmatrix:[`(`,`)`],bmatrix:[`[`,`]`],Bmatrix:[`\\{`,`\\}`],vmatrix:[`|`,`|`],Vmatrix:[`\\Vert`,`\\Vert`]}[e.envName.replace(`*`,``)],n=`c`,r={hskipBeforeAndAfter:!1,cols:[{type:`align`,align:n}]};if(e.envName.charAt(e.envName.length-1)===`*`){var i=e.parser;if(i.consumeSpaces(),i.fetch().text===`[`){if(i.consume(),i.consumeSpaces(),n=i.fetch().text,!`lcr`.includes(n))throw new R(`Expected l or c or r`,i.nextToken);i.consume(),i.consumeSpaces(),i.expect(`]`),i.consume(),r.cols=[{type:`align`,align:n}]}}var a=Gc(e.parser,r,Kc(e.envName)),o=Math.max(0,...a.body.map(e=>e.length));return a.cols=Array(o).fill({type:`align`,align:n}),t?{type:`leftright`,mode:e.mode,body:[a],left:t[0],right:t[1],rightColor:void 0}:a},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=Gc(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(Is(t[0])?[t[0]]:Ps(t[0],`ordgroup`).body).map(function(e){var t=Fs(e).text;if(`lc`.includes(t))return{type:`align`,align:t};throw new R(`Unknown column alignment: `+t,e)});if(n.length>1)throw new R(`{subarray} can contain only one column`);var r={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5},i=Gc(e.parser,r,`script`);if(i.body.length>0&&i.body[0].length>1)throw new R(`{subarray} can contain only one column`);return i},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=Gc(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},Kc(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:Xc,htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){Uc.has(e.envName)&&Hc(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:Wc(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return Gc(e.parser,t,`display`)},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:Xc,htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){Hc(e);var t={autoTag:Wc(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return Gc(e.parser,t,`display`)},htmlBuilder:qc,mathmlBuilder:Yc}),Lc({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return Hc(e),Zs(e.parser)},htmlBuilder:qc,mathmlBuilder:Yc}),Z(`\\nonumber`,`\\gdef\\@eqnsw{0}`),Z(`\\notag`,`\\nonumber`),J({type:`text`,names:[`\\hline`,`\\hdashline`],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new R(e.funcName+` valid only within array environment`)}});var Zc=Ic;J({type:`environment`,names:[`\\begin`,`\\end`],numArgs:1,argTypes:[`text`],handler(e,t){var n=e.parser,r=e.funcName,i=t[0];if(i.type!==`ordgroup`)throw new R(`Invalid environment name`,i);var a=Ls(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call(Zc,a))throw new R(`No such environment: `+a,i);var o=Zc[a],s=n.parseArguments(`\\begin{`+a+`}`,o),c=s.args,l=s.optArgs,u={mode:n.mode,envName:a,parser:n},d=o.handler(u,c,l);n.expect(`\\end`,!1);var f=n.nextToken,p=Ps(n.parseFunction(),`environment`);if(p.name!==a)throw new R(`Mismatch: \\begin{`+a+`} matched by \\end{`+p.name+`}`,f);return d}return{type:`environment`,mode:n.mode,name:a,nameGroup:i}}});var Qc=(e,t)=>{var n=e.font,r=t.withFont(n);return Y(e.body,r)},$c=(e,t)=>{var n=e.font,r=t.withFont(n);return ps(e.body,r)},el={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`};J({type:`font`,names:[`\\mathrm`,`\\mathit`,`\\mathbf`,`\\mathnormal`,`\\mathsfit`,`\\mathbb`,`\\mathcal`,`\\mathfrak`,`\\mathscr`,`\\mathsf`,`\\mathtt`,`\\Bbb`,`\\bold`,`\\frak`],numArgs:1,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=Vo(t[0]),a=r in el?el[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:Qc,mathmlBuilder:$c}),J({type:`mclass`,names:[`\\boldsymbol`,`\\bm`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`mclass`,mode:n.mode,mclass:Gs(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:ii(r)}}}),J({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],numArgs:0,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=e.breakOnTokenText,a=n.mode,o=n.parseExpression(!0,i);return{type:`font`,mode:a,font:`math`+r.slice(1),body:{type:`ordgroup`,mode:n.mode,body:o}}}});var tl=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=Y(e.numer,a,t);if(e.continued){var s=8.5/t.fontMetrics().ptPerEm,c=3.5/t.fontMetrics().ptPerEm;o.height=o.height<s?s:o.height,o.depth=o.depth<c?c:o.depth}a=t.havingStyle(i);var l=Y(e.denom,a,t),u,d,f;e.hasBarLine?(e.barSize?(d=Xi(e.barSize,t),u=xo(`frac-line`,t,d)):u=xo(`frac-line`,t),d=u.height,f=u.height):(u=null,d=0,f=t.fontMetrics().defaultRuleThickness);var p,m,h;n.size===Di.DISPLAY.size?(p=t.fontMetrics().num1,m=d>0?3*f:7*f,h=t.fontMetrics().denom1):(d>0?(p=t.fontMetrics().num2,m=f):(p=t.fontMetrics().num3,m=3*f),h=t.fontMetrics().denom2);var g;if(u){var _=t.fontMetrics().axisHeight;p-o.depth-(_+.5*d)<m&&(p+=m-(p-o.depth-(_+.5*d))),_-.5*d-(l.height-h)<m&&(h+=m-(_-.5*d-(l.height-h)));var v=-(_-.5*d);g=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:l,shift:h},{type:`elem`,elem:u,shift:v},{type:`elem`,elem:o,shift:-p}]})}else{var y=p-o.depth-(l.height-h);y<m&&(p+=.5*(m-y),h+=.5*(m-y)),g=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:l,shift:h},{type:`elem`,elem:o,shift:-p}]})}a=t.havingStyle(n),g.height*=a.sizeMultiplier/t.sizeMultiplier,g.depth*=a.sizeMultiplier/t.sizeMultiplier;var b=n.size===Di.DISPLAY.size?t.fontMetrics().delim1:n.size===Di.SCRIPTSCRIPT.size?t.havingStyle(Di.SCRIPT).fontMetrics().delim2:t.fontMetrics().delim2,x=e.leftDelim==null?Qo(t,[`mopen`]):kc(e.leftDelim,b,!0,t.havingStyle(n),e.mode,[`mopen`]),S=e.continued?q([]):e.rightDelim==null?Qo(t,[`mclose`]):kc(e.rightDelim,b,!0,t.havingStyle(n),e.mode,[`mclose`]);return q([`mord`].concat(a.sizingClasses(t)),[x,q([`mfrac`],[g]),S],t)},nl=(e,t)=>{var n=new X(`mfrac`,[ps(e.numer,t),ps(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=Xi(e.barSize,t);n.setAttribute(`linethickness`,z(r))}if(e.leftDelim!=null||e.rightDelim!=null){var i=[];if(e.leftDelim!=null){var a=new X(`mo`,[new ns(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new X(`mo`,[new ns(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return ss(i)}return n},rl=(e,t)=>t?{type:`styling`,mode:e.mode,style:t,body:[e]}:e;J({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0],a=t[1],o,s=null,c=null;switch(r){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:o=!0;break;case`\\\\atopfrac`:o=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=!1,s=`(`,c=`)`;break;case`\\\\bracefrac`:o=!1,s=`\\{`,c=`\\}`;break;case`\\\\brackfrac`:o=!1,s=`[`,c=`]`;break;default:throw Error(`Unrecognized genfrac command`)}var l=r===`\\cfrac`,u=null;return l||r.startsWith(`\\d`)?u=`display`:r.startsWith(`\\t`)&&(u=`text`),rl({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:tl,mathmlBuilder:nl}),J({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],numArgs:0,infix:!0,handler(e){var t=e.parser,n=e.funcName,r=e.token,i;switch(n){case`\\over`:i=`\\frac`;break;case`\\choose`:i=`\\binom`;break;case`\\atop`:i=`\\\\atopfrac`;break;case`\\brace`:i=`\\\\bracefrac`;break;case`\\brack`:i=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:t.mode,replaceWith:i,token:r}}});var il=[`display`,`text`,`script`,`scriptscript`],al=function(e){var t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};J({type:`genfrac`,names:[`\\genfrac`],numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`],handler(e,t){var n=e.parser,r=t[4],i=t[5],a=Vo(t[0]),o=a.type===`atom`&&a.family===`open`?al(a.text):null,s=Vo(t[1]),c=s.type===`atom`&&s.family===`close`?al(s.text):null,l=Ps(t[2],`size`),u,d=null;l.isBlank?u=!0:(d=l.value,u=d.number>0);var f=null,p=t[3];if(p.type===`ordgroup`){if(p.body.length>0){var m=Ps(p.body[0],`textord`);f=il[Number(m.text)]}}else p=Ps(p,`textord`),f=il[Number(p.text)];return rl({type:`genfrac`,mode:n.mode,numer:r,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:o,rightDelim:c},f)}}),J({type:`infix`,names:[`\\above`],numArgs:1,argTypes:[`size`],infix:!0,handler(e,t){var n=e.parser;e.funcName;var r=e.token;return{type:`infix`,mode:n.mode,replaceWith:`\\\\abovefrac`,size:Ps(t[0],`size`).value,token:r}}}),J({type:`genfrac`,names:[`\\\\abovefrac`],numArgs:3,argTypes:[`math`,`size`,`math`],handler:(e,t)=>{var n=e.parser;e.funcName;var r=t[0],i=Ps(t[1],`infix`).size;if(!i)throw Error(`\\\\abovefrac expected size, but got `+String(i));var a=t[2],o=i.number>0;return{type:`genfrac`,mode:n.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null}}});var ol=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?Y(e.sup,t.havingStyle(n.sup()),t):Y(e.sub,t.havingStyle(n.sub()),t),i=Ps(e.base,`horizBrace`)):i=Ps(e,`horizBrace`);var a=Y(i.base,t.havingBaseStyle(Di.DISPLAY)),o=Ds(i,t),s=i.isOver?Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):Eo({positionType:`bottom`,positionData:a.depth+.1+o.height,children:[{type:`elem`,elem:o,wrapperClasses:[`svg-align`]},{type:`kern`,size:.1},{type:`elem`,elem:a}]});if(r){var c=q([`minner`,i.isOver?`mover`:`munder`],[s],t);s=i.isOver?Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):Eo({positionType:`bottom`,positionData:c.depth+.2+r.height+r.depth,children:[{type:`elem`,elem:r},{type:`kern`,size:.2},{type:`elem`,elem:c}]})}return q([`minner`,i.isOver?`mover`:`munder`],[s],t)};J({type:`horizBrace`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`horizBrace`,mode:n.mode,label:r,isOver:r.includes(`\\over`),base:t[0]}},htmlBuilder:ol,mathmlBuilder:(e,t)=>{var n=ws(e.label);return new X(e.isOver?`mover`:`munder`,[ps(e.base,t),n])}}),J({type:`href`,names:[`\\href`],numArgs:2,argTypes:[`url`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[1],i=Ps(t[0],`url`).url;return n.settings.isTrusted({command:`\\href`,url:i})?{type:`href`,mode:n.mode,href:i,body:Ho(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=qo(e.body,t,!1);return So(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=fs(e.body,t);return n instanceof X||(n=new X(`mrow`,[n])),n.setAttribute(`href`,e.href),n}}),J({type:`href`,names:[`\\url`],numArgs:1,argTypes:[`url`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=Ps(t[0],`url`).url;if(!n.settings.isTrusted({command:`\\url`,url:r}))return n.formatUnsupportedCmd(`\\url`);for(var i=[],a=0;a<r.length;a++){var o=r[a];o===`~`&&(o=`\\textasciitilde`),i.push({type:`textord`,mode:`text`,text:o})}var s={type:`text`,mode:n.mode,font:`\\texttt`,body:i};return{type:`href`,mode:n.mode,href:r,body:Ho(s)}}}),J({type:`hbox`,names:[`\\hbox`],numArgs:1,argTypes:[`text`],allowedInText:!0,primitive:!0,handler(e,t){return{type:`hbox`,mode:e.parser.mode,body:Ho(t[0])}},htmlBuilder(e,t){return Co(qo(e.body,t.withFont(``),!1))},mathmlBuilder(e,t){return new X(`mrow`,ds(e.body,t.withFont(``)))}}),J({type:`html`,names:[`\\htmlClass`,`\\htmlId`,`\\htmlStyle`,`\\htmlData`],numArgs:2,argTypes:[`raw`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName;e.token;var i=Ps(t[0],`raw`).string,a=t[1];n.settings.strict&&uo({strict:n.settings.strict,errorCode:`htmlExtension`,errorMsg:`HTML extension is disabled on strict mode`,report:!0});var o,s={};switch(r){case`\\htmlClass`:s.class=i,o={command:`\\htmlClass`,class:i};break;case`\\htmlId`:s.id=i,o={command:`\\htmlId`,id:i};break;case`\\htmlStyle`:s.style=i,o={command:`\\htmlStyle`,style:i};break;case`\\htmlData`:for(var c=`{,}`,l=[],u=``,d=0;d<i.length;d++)i.startsWith(c,d)?(u+=`,`,d+=c.length-1):i[d]===`,`?(l.push(u),u=``):u+=i[d];l.push(u);for(var f=0;f<l.length;f++){var p=l[f],m=p.indexOf(`=`);if(m<0)throw new R(`\\htmlData key/value '`+p+`' missing equals sign`);var h=p.slice(0,m),g=p.slice(m+1);s[`data-`+h.trim()]=g}o={command:`\\htmlData`,attributes:s};break;default:throw Error(`Unrecognized html command`)}return n.settings.isTrusted(o)?{type:`html`,mode:n.mode,attributes:s,body:Ho(a)}:n.formatUnsupportedCmd(r)},htmlBuilder:(e,t)=>{var n=qo(e.body,t,!1),r=[`enclosing`];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/));var i=q(r,n,t);for(var a of Object.entries(e.attributes)){var o=a[0],s=a[1];o!==`class`&&i.setAttribute(o,s)}return i},mathmlBuilder:(e,t)=>fs(e.body,t)}),J({type:`htmlmathml`,names:[`\\html@mathml`],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:`htmlmathml`,mode:e.parser.mode,html:Ho(t[0]),mathml:Ho(t[1])}),htmlBuilder:(e,t)=>Co(qo(e.html,t,!1)),mathmlBuilder:(e,t)=>fs(e.mathml,t)});var sl=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new R(`Invalid size: '`+e+`' in \\includegraphics`);var n={number:+(t[1]+t[2]),unit:t[3]};if(!Yi(n))throw new R(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n};J({type:`includegraphics`,names:[`\\includegraphics`],numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1,handler:(e,t,n)=>{var r=e.parser,i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(n[0])for(var c=Ps(n[0],`raw`).string.split(`,`),l=0;l<c.length;l++){var u=c[l].split(`=`);if(u.length===2){var d=u[1].trim();switch(u[0].trim()){case`alt`:s=d;break;case`width`:i=sl(d);break;case`height`:a=sl(d);break;case`totalheight`:o=sl(d);break;default:throw new R(`Invalid key: '`+u[0]+`' in \\includegraphics.`)}}}var f=Ps(t[0],`url`).url;return s===``&&(s=f,s=s.replace(/^.*[\\/]/,``),s=s.substring(0,s.lastIndexOf(`.`))),r.settings.isTrusted({command:`\\includegraphics`,url:f})?{type:`includegraphics`,mode:r.mode,alt:s,width:i,height:a,totalheight:o,src:f}:r.formatUnsupportedCmd(`\\includegraphics`)},htmlBuilder:(e,t)=>{var n=Xi(e.height,t),r=0;e.totalheight.number>0&&(r=Xi(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=Xi(e.width,t));var a={height:z(n+r)};i>0&&(a.width=z(i)),r>0&&(a.verticalAlign=z(-r));var o=new aa(e.src,e.alt,a);return o.height=n,o.depth=r,o},mathmlBuilder:(e,t)=>{var n=new X(`mglyph`,[]);n.setAttribute(`alt`,e.alt);var r=Xi(e.height,t),i=0;if(e.totalheight.number>0&&(i=Xi(e.totalheight,t)-r,n.setAttribute(`valign`,z(-i))),n.setAttribute(`height`,z(r+i)),e.width.number>0){var a=Xi(e.width,t);n.setAttribute(`width`,z(a))}return n.setAttribute(`src`,e.src),n}}),J({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=Ps(t[0],`size`);if(n.settings.strict){var a=r[1]===`m`,o=i.value.unit===`mu`;a?(o||uo({strict:n.settings.strict,errorCode:`mathVsTextUnits`,errorMsg:`LaTeX's `+r+` supports only mu units, `+(`not `+i.value.unit+` units`),report:!0}),n.mode!==`math`&&uo({strict:n.settings.strict,errorCode:`mathVsTextUnits`,errorMsg:`LaTeX's `+r+` works only in math mode`,report:!0})):o&&uo({strict:n.settings.strict,errorCode:`mathVsTextUnits`,errorMsg:`LaTeX's `+r+` doesn't support mu units`,report:!0})}return{type:`kern`,mode:n.mode,dimension:i.value}},htmlBuilder(e,t){return Do(e.dimension,t)},mathmlBuilder(e,t){return new rs(Xi(e.dimension,t))}}),J({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`lap`,mode:n.mode,alignment:r.slice(5),body:i}},htmlBuilder:(e,t)=>{var n;e.alignment===`clap`?(n=q([],[Y(e.body,t)]),n=q([`katex-inner`],[n],t)):n=q([`katex-inner`],[Y(e.body,t)]);var r=q([`katex-fix`],[]),i=q([e.alignment],[n,r],t),a=q([`katex-strut`]);return a.style.height=z(i.height+i.depth),i.depth&&(a.style.verticalAlign=z(-i.depth)),i.children.unshift(a),i=q([`katex-thinbox`],[i],t),q([`mord`,`katex-vbox`],[i],t)},mathmlBuilder:(e,t)=>{var n=new X(`mpadded`,[ps(e.body,t)]);if(e.alignment!==`rlap`){var r=e.alignment===`llap`?`-1`:`-0.5`;n.setAttribute(`lspace`,r+`width`)}return n.setAttribute(`width`,`0px`),n}}),J({type:`styling`,names:[`\\(`,`$`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){var n=e.funcName,r=e.parser,i=r.mode;r.switchMode(`math`);var a=n===`\\(`?`\\)`:`$`,o=r.parseExpression(!1,a);return r.expect(a),r.switchMode(i),{type:`styling`,mode:r.mode,style:`text`,resetFont:!0,body:o}}}),J({type:`text`,names:[`\\)`,`\\]`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new R(`Mismatched `+e.funcName)}});var cl=(e,t)=>{switch(t.style.size){case Di.DISPLAY.size:return e.display;case Di.TEXT.size:return e.text;case Di.SCRIPT.size:return e.script;case Di.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};J({type:`mathchoice`,names:[`\\mathchoice`],numArgs:4,primitive:!0,handler:(e,t)=>({type:`mathchoice`,mode:e.parser.mode,display:Ho(t[0]),text:Ho(t[1]),script:Ho(t[2]),scriptscript:Ho(t[3])}),htmlBuilder:(e,t)=>Co(qo(cl(e,t),t,!1)),mathmlBuilder:(e,t)=>fs(cl(e,t),t)});var ll=(e,t,n,r,i,a,o)=>{e=q([],[e]);var s=n&&ii(n),c,l;if(t){var u=Y(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=Y(n,r.havingStyle(i.sub()),r);c={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-d.height)}}var f;if(l&&c)f=Eo({positionType:`bottom`,positionData:r.fontMetrics().bigOpSpacing5+c.elem.height+c.elem.depth+c.kern+e.depth+o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else if(c)f=Eo({positionType:`top`,positionData:e.height-o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e}]});else if(l)f=Eo({positionType:`bottom`,positionData:e.depth+o,children:[{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else return e;var p=[f];if(c&&a!==0&&!s){var m=q([`mspace`],[],r);m.style.marginRight=z(a),p.unshift(m)}return q([`mop`,`op-limits`],p,r)},ul=new Set([`\\smallint`]),dl=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=Ps(e.base,`op`),i=!0):a=Ps(e,`op`);var o=t.style,s=!1;o.size===Di.DISPLAY.size&&a.symbol&&!ul.has(a.name)&&(s=!0);var c,l;if(a.symbol){var u=s?`Size2-Regular`:`Size1-Regular`,d=``;if((a.name===`\\oiint`||a.name===`\\oiiint`)&&(d=a.name.slice(1),a.name=d===`oiint`?`\\iint`:`\\iiint`),c=po(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=jo(d+`Size`+(s?`2`:`1`),t);c=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:0},{type:`elem`,elem:f,shift:s?.08:0}]}),a.name=`\\`+d,c.classes.unshift(`mop`),c.italic=l}}else if(a.body){var p=qo(a.body,t,!0);p.length===1&&p[0]instanceof sa?(c=p[0],c.classes[0]=`mop`):c=q([`mop`],p,t)}else{for(var m=[],h=1;h<a.name.length;h++)m.push(mo(a.name[h],a.mode,t));c=q([`mop`],m,t)}var g=0,_=0;return(c instanceof sa||a.name===`\\oiint`||a.name===`\\oiiint`)&&!a.suppressBaseShift&&(g=(c.height-c.depth)/2-t.fontMetrics().axisHeight,_=c.italic??0),i?ll(c,n,r,t,o,_,g):(g&&(c.style.position=`relative`,c.style.top=z(g)),c)},fl=(e,t)=>{var n;if(e.symbol)n=new X(`mo`,[os(e.name,e.mode)]),ul.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new X(`mo`,ds(e.body,t));else{n=new X(`mi`,[new ns(e.name.slice(1))]);var r=new X(`mo`,[os(``,`text`)]);n=e.parentIsSupSub?new X(`mrow`,[n,r]):ts([n,r])}return n},pl={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨆":`\\bigsqcup`};J({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcap.\\bigcup.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcup.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨄.⨆`.split(`.`),numArgs:0,handler:(e,t)=>{var n=e.parser,r=e.funcName;return r.length===1&&(r=pl[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:dl,mathmlBuilder:fl}),J({type:`op`,names:[`\\mathop`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`op`,mode:n.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:Ho(r)}}});var ml={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`};J({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\tan.\\tanh.\\tg.\\th`.split(`.`),numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:n}}}),J({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:n}}}),J({type:`op`,names:[`\\int`,`\\iint`,`\\iiint`,`\\oint`,`\\oiint`,`\\oiiint`,`∫`,`∬`,`∭`,`∮`,`∯`,`∰`],numArgs:0,allowedInArgument:!0,handler(e){var t=e.parser,n=e.funcName;return n.length===1&&(n=ml[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var hl=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=Ps(e.base,`operatorname`),i=!0):a=Ps(e,`operatorname`);var o;if(a.body.length>0){for(var s=qo(a.body.map(e=>{var t=`text`in e?e.text:void 0;return typeof t==`string`?{type:`textord`,mode:e.mode,text:t}:e}),t.withFont(`mathrm`),!0),c=0;c<s.length;c++){var l=s[c];l instanceof sa&&(l.text=l.text.replace(/\u2212/,`-`).replace(/\u2217/,`*`))}o=q([`mop`],s,t)}else o=q([`mop`],[],t);return i?ll(o,n,r,t,t.style,0,0):o};J({type:`operatorname`,names:[`\\operatorname@`,`\\operatornamewithlimits`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`operatorname`,mode:n.mode,body:Ho(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:hl,mathmlBuilder:(e,t)=>{for(var n=ds(e.body,t.withFont(`mathrm`)),r=!0,i=0;i<n.length;i++){var a=n[i];if(!(a instanceof rs)){if(a instanceof X)switch(a.type){case`mi`:case`mn`:case`mspace`:case`mtext`:break;case`mo`:var o=a.children[0];a.children.length===1&&o instanceof ns?o.text=o.text.replace(/\u2212/,`-`).replace(/\u2217/,`*`):r=!1;break;default:r=!1}else r=!1}}r&&(n=[new ns(n.map(e=>e.toText()).join(``))]);var s=new X(`mi`,n);s.setAttribute(`mathvariant`,`normal`);var c=new X(`mo`,[os(``,`text`)]);return e.parentIsSupSub?new X(`mrow`,[s,c]):ts([s,c])}}),Z(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),Bo({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?Co(qo(e.body,t,!1)):q([`mord`],qo(e.body,t,!0),t)},mathmlBuilder(e,t){return fs(e.body,t,!0)}}),J({type:`overline`,names:[`\\overline`],numArgs:1,handler(e,t){var n=e.parser,r=t[0];return{type:`overline`,mode:n.mode,body:r}},htmlBuilder(e,t){var n=Y(e.body,t.havingCrampedStyle()),r=xo(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return q([`mord`,`katex-overline`],[Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:n},{type:`kern`,size:3*i},{type:`elem`,elem:r},{type:`kern`,size:i}]})],t)},mathmlBuilder(e,t){var n=new X(`mo`,[new ns(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new X(`mover`,[ps(e.body,t),n]);return r.setAttribute(`accent`,`true`),r}}),J({type:`phantom`,names:[`\\phantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`phantom`,mode:n.mode,body:Ho(r)}},htmlBuilder:(e,t)=>Co(qo(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new X(`mphantom`,ds(e.body,t))}),Z(`\\hphantom`,`\\smash{\\phantom{#1}}`),J({type:`vphantom`,names:[`\\vphantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`vphantom`,mode:n.mode,body:r}},htmlBuilder:(e,t)=>q([`mord`,`rlap`],[q([`katex-inner`],[Y(e.body,t.withPhantom())]),q([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new X(`mpadded`,[new X(`mphantom`,ds(Ho(e.body),t))]);return n.setAttribute(`width`,`0px`),n}}),J({type:`raisebox`,names:[`\\raisebox`],numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0,handler(e,t){var n=e.parser,r=Ps(t[0],`size`).value,i=t[1];return{type:`raisebox`,mode:n.mode,dy:r,body:i}},htmlBuilder(e,t){var n=Y(e.body,t);return Eo({positionType:`shift`,positionData:-Xi(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new X(`mpadded`,[ps(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var gl=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});J({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:gl,htmlBuilder(e,t){return q([`mord`,`reflectbox`],[Y(e.body,t)],t)},mathmlBuilder(e,t){return ps(e.body,t)}}),J({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:gl}),J({type:`internal`,names:[`\\relax`],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){return{type:`internal`,mode:e.parser.mode}}}),J({type:`rule`,names:[`\\rule`],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`],handler(e,t,n){var r=e.parser,i=n[0],a=Ps(t[0],`size`),o=Ps(t[1],`size`);return{type:`rule`,mode:r.mode,shift:i&&Ps(i,`size`).value,width:a.value,height:o.value}},htmlBuilder(e,t){var n=q([`mord`,`katex-rule`],[],t),r=Xi(e.width,t),i=Xi(e.height,t),a=e.shift?Xi(e.shift,t):0;return n.style.borderRightWidth=z(r),n.style.borderTopWidth=z(i),n.style.bottom=z(a),n.width=r,n.height=i+a,n.depth=-a,n.maxFontSize=i*1.125*t.sizeMultiplier,n},mathmlBuilder(e,t){var n=Xi(e.width,t),r=Xi(e.height,t),i=e.shift?Xi(e.shift,t):0,a=t.color&&t.getColor()||`black`,o=new X(`mspace`);o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,z(n)),o.setAttribute(`height`,z(r));var s=new X(`mpadded`,[o]);return i>=0?s.setAttribute(`height`,z(i)):(s.setAttribute(`height`,z(i)),s.setAttribute(`depth`,z(-i))),s.setAttribute(`voffset`,z(i)),s}});function _l(e,t,n){for(var r=qo(e,t,!1),i=t.sizeMultiplier/n.sizeMultiplier,a=0;a<r.length;a++){var o=r[a].classes.indexOf(`katex-sizing`);o<0?Array.prototype.push.apply(r[a].classes,t.sizingClasses(n)):r[a].classes[o+1]===`reset-size`+t.size&&(r[a].classes[o+1]=`reset-size`+n.size),r[a].height*=i,r[a].depth*=i}return Co(r)}var vl=[`\\tiny`,`\\sixptsize`,`\\scriptsize`,`\\footnotesize`,`\\small`,`\\normalsize`,`\\large`,`\\Large`,`\\LARGE`,`\\huge`,`\\Huge`];J({type:`sizing`,names:vl,numArgs:0,allowedInText:!0,handler:(e,t)=>{var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!1,n);return{type:`sizing`,mode:i.mode,size:vl.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return _l(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new X(`mstyle`,ds(e.body,n));return r.setAttribute(`mathsize`,z(n.sizeMultiplier)),r}}),J({type:`smash`,names:[`\\smash`],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,n)=>{var r=e.parser,i=!1,a=!1,o=n[0]&&Ps(n[0],`ordgroup`);if(o)for(var s,c=0;c<o.body.length;++c){var l=o.body[c];if(s=Fs(l).text,s===`t`)i=!0;else if(s===`b`)a=!0;else{i=!1,a=!1;break}}else i=!0,a=!0;var u=t[0];return{type:`smash`,mode:r.mode,body:u,smashHeight:i,smashDepth:a}},htmlBuilder:(e,t)=>{var n=q([],[Y(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return n;if(e.smashHeight&&(n.height=0),e.smashDepth&&(n.depth=0),e.smashHeight&&e.smashDepth)return q([`mord`,`katex-smash`],[n],t);if(n.children)for(var r=0;r<n.children.length;r++)e.smashHeight&&(n.children[r].height=0),e.smashDepth&&(n.children[r].depth=0);return q([`mord`],[Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=new X(`mpadded`,[ps(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}}),J({type:`sqrt`,names:[`\\sqrt`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=n[0],a=t[0];return{type:`sqrt`,mode:r.mode,body:a,index:i}},htmlBuilder(e,t){var n=Y(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=wo(n,t);var r=t.fontMetrics().defaultRuleThickness,i=r;t.style.id<Di.TEXT.id&&(i=t.fontMetrics().xHeight);var a=r+i/4,o=vc(n.height+n.depth+a+r,t),s=o.span,c=o.ruleWidth,l=o.advanceWidth,u=s.height-c;u>n.height+n.depth+a&&(a=(a+u-n.height-n.depth)/2);var d=s.height-n.height-a-c;n.style.paddingLeft=z(l);var f=Eo({positionType:`firstBaseline`,children:[{type:`elem`,elem:n,wrapperClasses:[`svg-align`]},{type:`kern`,size:-(n.height+d)},{type:`elem`,elem:s},{type:`kern`,size:c}]});if(e.index){var p=t.havingStyle(Di.SCRIPTSCRIPT),m=Y(e.index,p,t);return q([`mord`,`sqrt`],[q([`katex-root`],[Eo({positionType:`shift`,positionData:-(.6*(f.height-f.depth)),children:[{type:`elem`,elem:m}]})]),f],t)}return q([`mord`,`sqrt`],[f],t)},mathmlBuilder(e,t){var n=e.body,r=e.index;return r?new X(`mroot`,[ps(n,t),ps(r,t)]):new X(`msqrt`,[ps(n,t)])}});var yl={display:Di.DISPLAY,text:Di.TEXT,script:Di.SCRIPT,scriptscript:Di.SCRIPTSCRIPT};function bl(e){return e in yl}J({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!0,n),o=r.slice(1,r.length-5);if(!bl(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=yl[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),_l(e.body,r,t)},mathmlBuilder(e,t){var n=yl[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new X(`mstyle`,ds(e.body,r)),a={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]}[e.style];return i.setAttribute(`scriptlevel`,a[0]),i.setAttribute(`displaystyle`,a[1]),i}});var xl=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===Di.DISPLAY.size||n.alwaysHandleSupSub)?dl:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===Di.DISPLAY.size||n.limits)?hl:null:n.type===`accent`?ii(n.base)?zs:null:n.type===`horizBrace`&&!e.sub===n.isOver?ol:null:null};Bo({type:`supsub`,htmlBuilder(e,t){var n=xl(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=Y(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&ii(r);if(i){var p=t.havingStyle(t.style.sup());s=Y(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=Y(a,m,t),f||(d=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier)}var h=t.style===Di.DISPLAY?l.sup1:t.style.cramped?l.sup3:l.sup2,g=t.sizeMultiplier,_=z(.5/l.ptPerEm/g),v=null;if(c){var y=e.base&&e.base.type===`op`&&e.base.name&&(e.base.name===`\\oiint`||e.base.name===`\\oiiint`);(o instanceof sa||y)&&(v=z(-(o.italic??0)))}var b;if(s&&c){u=Math.max(u,h,s.depth+.25*l.xHeight),d=Math.max(d,l.sub2);var x=4*l.defaultRuleThickness;if(u-s.depth-(c.height-d)<x){d=x-(u-s.depth)+c.height;var S=.8*l.xHeight-(u-s.depth);S>0&&(u+=S,d-=S)}b=Eo({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:d,marginRight:_,marginLeft:v},{type:`elem`,elem:s,shift:-u,marginRight:_}]})}else if(c)d=Math.max(d,l.sub1,c.height-.8*l.xHeight),b=Eo({positionType:`shift`,positionData:d,children:[{type:`elem`,elem:c,marginLeft:v,marginRight:_}]});else if(s)u=Math.max(u,h,s.depth+.25*l.xHeight),b=Eo({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return q([Zo(o,`right`)||`mord`],[o,q([`msupsub`],[b])],t)},mathmlBuilder(e,t){var n=!1,r,i;e.base&&e.base.type===`horizBrace`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0);var a=[ps(e.base,t)];e.sub&&a.push(ps(e.sub,t)),e.sup&&a.push(ps(e.sup,t));var o;if(n)o=r?`mover`:`munder`;else if(!e.sub){var s=e.base;o=s&&s.type===`op`&&s.limits&&(t.style===Di.DISPLAY||s.alwaysHandleSupSub)||s&&s.type===`operatorname`&&s.alwaysHandleSupSub&&(s.limits||t.style===Di.DISPLAY)?`mover`:`msup`}else if(e.sup){var c=e.base;o=c&&c.type===`op`&&c.limits&&t.style===Di.DISPLAY||c&&c.type===`operatorname`&&c.alwaysHandleSupSub&&(t.style===Di.DISPLAY||c.limits)?`munderover`:`msubsup`}else{var l=e.base;o=l&&l.type===`op`&&l.limits&&(t.style===Di.DISPLAY||l.alwaysHandleSupSub)||l&&l.type===`operatorname`&&l.alwaysHandleSupSub&&(l.limits||t.style===Di.DISPLAY)?`munder`:`msub`}return new X(o,a)}}),Bo({type:`atom`,htmlBuilder(e,t){return mo(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new X(`mo`,[os(e.text,e.mode)]);if(e.family===`bin`){var r=ls(e,t);r===`bold-italic`&&n.setAttribute(`mathvariant`,r)}else e.family===`punct`?n.setAttribute(`separator`,`true`):(e.family===`open`||e.family===`close`)&&n.setAttribute(`stretchy`,`false`);return n}});var Sl={mi:`italic`,mn:`normal`,mtext:`normal`};Bo({type:`mathord`,htmlBuilder(e,t){return go(e,t)},mathmlBuilder(e,t){var n=new X(`mi`,[os(e.text,e.mode,t)]),r=ls(e,t)||`italic`;return r!==Sl[n.type]&&n.setAttribute(`mathvariant`,r),n}}),Bo({type:`textord`,htmlBuilder(e,t){return go(e,t)},mathmlBuilder(e,t){var n=os(e.text,e.mode,t),r=ls(e,t)||`normal`,i=e.mode===`text`?new X(`mtext`,[n]):/[0-9]/.test(e.text)?new X(`mn`,[n]):e.text===`\\prime`?new X(`mo`,[n]):new X(`mi`,[n]);return r!==Sl[i.type]&&i.setAttribute(`mathvariant`,r),i}});var Cl=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),wl=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);Bo({type:`spacing`,htmlBuilder(e,t){var n=wl.get(e.text),r=Cl.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=go(e,t);return a.classes.push(i),a}return q([`mspace`,i],[mo(e.text,e.mode,t)],t)}if(r)return q([`mspace`,r],[],t);throw new R(`Unknown type of space "`+e.text+`"`)},mathmlBuilder(e,t){var n;if(wl.has(e.text))n=new X(`mtext`,[new ns(`\xA0`)]);else if(Cl.has(e.text))return new X(`mspace`);else throw new R(`Unknown type of space "`+e.text+`"`);return n}});var Tl=()=>{var e=new X(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};Bo({type:`tag`,mathmlBuilder(e,t){var n=new X(`mtable`,[new X(`mtr`,[Tl(),new X(`mtd`,[fs(e.body,t)]),Tl(),new X(`mtd`,[fs(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var El={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},Dl={"\\textbf":`textbf`,"\\textmd":`textmd`},Ol={"\\textit":`textit`,"\\textup":`textup`},kl=(e,t)=>{var n=e.font;return n?El[n]?t.withTextFontFamily(El[n]):Dl[n]?t.withTextFontWeight(Dl[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(Ol[n]):t};J({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`text`,mode:n.mode,body:Ho(i),font:r}},htmlBuilder(e,t){var n=kl(e,t);return q([`mord`,`text`],qo(e.body,n,!0),n)},mathmlBuilder(e,t){var n=kl(e,t);return fs(e.body,n)}}),J({type:`underline`,names:[`\\underline`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`underline`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=Y(e.body,t),r=xo(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return q([`mord`,`katex-underline`],[Eo({positionType:`top`,positionData:n.height,children:[{type:`kern`,size:i},{type:`elem`,elem:r},{type:`kern`,size:3*i},{type:`elem`,elem:n}]})],t)},mathmlBuilder(e,t){var n=new X(`mo`,[new ns(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new X(`munder`,[ps(e.body,t),n]);return r.setAttribute(`accentunder`,`true`),r}}),J({type:`vcenter`,names:[`\\vcenter`],numArgs:1,argTypes:[`original`],allowedInText:!1,handler(e,t){return{type:`vcenter`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=Y(e.body,t),r=t.fontMetrics().axisHeight;return Eo({positionType:`shift`,positionData:.5*(n.height-r-(n.depth+r)),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){return new X(`mrow`,[new X(`mpadded`,[ps(e.body,t)],[`vcenter`])])}}),J({type:`verb`,names:[`\\verb`],numArgs:0,allowedInText:!0,handler(e,t,n){throw new R(`\\verb ended by end of line instead of matching delimiter`)},htmlBuilder(e,t){for(var n=Al(e),r=[],i=t.havingStyle(t.style.text()),a=0;a<n.length;a++){var o=n[a];o===`~`&&(o=`\\textasciitilde`),r.push(po(o,`Typewriter-Regular`,e.mode,i,[`mord`,`texttt`]))}return q([`mord`,`text`].concat(i.sizingClasses(t)),vo(r),i)},mathmlBuilder(e,t){var n=new X(`mtext`,[new ns(Al(e))]);return n.setAttribute(`mathvariant`,`monospace`),n}});var Al=e=>e.body.replace(/ /g,e.star?`␣`:`\xA0`),jl=Lo,Ml=`[ \r
|
|
274
|
+
]`,Nl=`\\\\[a-zA-Z@]+`,Pl=`\\\\[^\ud800-\udfff]`,Fl=`(`+Nl+`)`+Ml+`*`,Il=`\\\\(
|
|
275
|
+
|[ \r ]+
|
|
276
|
+
?)[ \r ]*`,Ll=`[̀-ͯ]`,Rl=RegExp(Ll+`+$`),zl=`(`+Ml+`+)|`+(Il+`|`)+`([!-\\[\\]-‧-豈-]`+(Ll+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(Ll+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+Fl)+(`|`+Pl+`)`),Bl=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(zl,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Bc(`EOF`,new zc(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new R(`Unexpected character: '`+e[t]+`'`,new Bc(e[t],new zc(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
|
|
277
|
+
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,uo({strict:this.settings.strict,errorCode:`commentAtEnd`,errorMsg:`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`,report:!0})):this.tokenRegex.lastIndex=i+1,this.lex()}return new Bc(r,new zc(this,t,this.tokenRegex.lastIndex))}},Vl=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new R(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},Hl=Rc;Z(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Z(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Z(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Z(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Z(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Z(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),Z(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Ul={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Z(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new R("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=Ul[t.text],r==null||r>=n)throw new R(`Invalid base-`+n+` digit `+t.text);for(var i;(i=Ul[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var Wl=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new R(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new R(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new R(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new R(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};Z(`\\newcommand`,e=>Wl(e,!1,!0,!1)),Z(`\\renewcommand`,e=>Wl(e,!0,!1,!1)),Z(`\\providecommand`,e=>Wl(e,!0,!0,!0)),Z(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),Z(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),Z(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),jl[n],xa.math[n],xa.text[n]),``}),Z(`\\bgroup`,`{`),Z(`\\egroup`,`}`),Z(`~`,`\\nobreakspace`),Z(`\\lq`,"`"),Z(`\\rq`,`'`),Z(`\\aa`,`\\r a`),Z(`\\AA`,`\\r A`),Z(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),Z(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),Z(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),Z(`ℬ`,`\\mathscr{B}`),Z(`ℰ`,`\\mathscr{E}`),Z(`ℱ`,`\\mathscr{F}`),Z(`ℋ`,`\\mathscr{H}`),Z(`ℐ`,`\\mathscr{I}`),Z(`ℒ`,`\\mathscr{L}`),Z(`ℳ`,`\\mathscr{M}`),Z(`ℛ`,`\\mathscr{R}`),Z(`ℭ`,`\\mathfrak{C}`),Z(`ℌ`,`\\mathfrak{H}`),Z(`ℨ`,`\\mathfrak{Z}`),Z(`\\Bbbk`,`\\Bbb{k}`),Z(`\\llap`,`\\mathllap{\\textrm{#1}}`),Z(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),Z(`\\clap`,`\\mathclap{\\textrm{#1}}`),Z(`\\mathstrut`,`\\vphantom{(}`),Z(`\\underbar`,`\\underline{\\text{#1}}`),Z(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),Z(`\\neq`,"\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),Z(`\\ne`,`\\neq`),Z(`≠`,`\\neq`),Z(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),Z(`∉`,`\\notin`),Z(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),Z(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),Z(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),Z(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),Z(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),Z(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),Z(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),Z(`⟂`,`\\perp`),Z(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),Z(`∌`,`\\notni`),Z(`⌜`,`\\ulcorner`),Z(`⌝`,`\\urcorner`),Z(`⌞`,`\\llcorner`),Z(`⌟`,`\\lrcorner`),Z(`©`,`\\copyright`),Z(`®`,`\\textregistered`),Z(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),Z(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),Z(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),Z(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),Z(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),Z(`⋮`,`\\vdots`),Z(`\\varGamma`,`\\mathit{\\Gamma}`),Z(`\\varDelta`,`\\mathit{\\Delta}`),Z(`\\varTheta`,`\\mathit{\\Theta}`),Z(`\\varLambda`,`\\mathit{\\Lambda}`),Z(`\\varXi`,`\\mathit{\\Xi}`),Z(`\\varPi`,`\\mathit{\\Pi}`),Z(`\\varSigma`,`\\mathit{\\Sigma}`),Z(`\\varUpsilon`,`\\mathit{\\Upsilon}`),Z(`\\varPhi`,`\\mathit{\\Phi}`),Z(`\\varPsi`,`\\mathit{\\Psi}`),Z(`\\varOmega`,`\\mathit{\\Omega}`),Z(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),Z(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),Z(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),Z(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),Z(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),Z(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),Z(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),Z(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var Gl={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},Kl=new Set([`bin`,`rel`]);Z(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in Gl?t=Gl[n]:(n.slice(0,4)===`\\not`||n in xa.math&&Kl.has(xa.math[n].group))&&(t=`\\dotsb`),t});var ql={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};Z(`\\dotso`,function(e){return e.future().text in ql?`\\ldots\\,`:`\\ldots`}),Z(`\\dotsc`,function(e){var t=e.future().text;return t in ql&&t!==`,`?`\\ldots\\,`:`\\ldots`}),Z(`\\cdots`,function(e){return e.future().text in ql?`\\@cdots\\,`:`\\@cdots`}),Z(`\\dotsb`,`\\cdots`),Z(`\\dotsm`,`\\cdots`),Z(`\\dotsi`,`\\!\\cdots`),Z(`\\dotsx`,`\\ldots\\,`),Z(`\\DOTSI`,`\\relax`),Z(`\\DOTSB`,`\\relax`),Z(`\\DOTSX`,`\\relax`),Z(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),Z(`\\,`,`\\tmspace+{3mu}{.1667em}`),Z(`\\thinspace`,`\\,`),Z(`\\>`,`\\mskip{4mu}`),Z(`\\:`,`\\tmspace+{4mu}{.2222em}`),Z(`\\medspace`,`\\:`),Z(`\\;`,`\\tmspace+{5mu}{.2777em}`),Z(`\\thickspace`,`\\;`),Z(`\\!`,`\\tmspace-{3mu}{.1667em}`),Z(`\\negthinspace`,`\\!`),Z(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),Z(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),Z(`\\enspace`,`\\kern.5em `),Z(`\\enskip`,`\\hskip.5em\\relax`),Z(`\\quad`,`\\hskip1em\\relax`),Z(`\\qquad`,`\\hskip2em\\relax`),Z(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),Z(`\\tag@paren`,`\\tag@literal{({#1})}`),Z(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new R(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),Z(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),Z(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),Z(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),Z(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),Z(`\\newline`,`\\\\\\relax`),Z(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var Jl=z(ma[`Main-Regular`][84][1]-.7*ma[`Main-Regular`][65][1]);Z(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+Jl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),Z(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+Jl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),Z(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),Z(`\\@hspace`,`\\hskip #1\\relax`),Z(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),Z(`\\ordinarycolon`,`:`),Z(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),Z(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),Z(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),Z(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),Z(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),Z(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),Z(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),Z(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),Z(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),Z(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),Z(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),Z(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),Z(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),Z(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),Z(`∷`,`\\dblcolon`),Z(`∹`,`\\eqcolon`),Z(`≔`,`\\coloneqq`),Z(`≕`,`\\eqqcolon`),Z(`⩴`,`\\Coloneqq`),Z(`\\ratio`,`\\vcentcolon`),Z(`\\coloncolon`,`\\dblcolon`),Z(`\\colonequals`,`\\coloneqq`),Z(`\\coloncolonequals`,`\\Coloneqq`),Z(`\\equalscolon`,`\\eqqcolon`),Z(`\\equalscoloncolon`,`\\Eqqcolon`),Z(`\\colonminus`,`\\coloneq`),Z(`\\coloncolonminus`,`\\Coloneq`),Z(`\\minuscolon`,`\\eqcolon`),Z(`\\minuscoloncolon`,`\\Eqcolon`),Z(`\\coloncolonapprox`,`\\Colonapprox`),Z(`\\coloncolonsim`,`\\Colonsim`),Z(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),Z(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),Z(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),Z(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),Z(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),Z(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),Z(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),Z(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),Z(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),Z(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),Z(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),Z(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),Z(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),Z(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),Z(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),Z(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),Z(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),Z(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),Z(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),Z(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),Z(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),Z(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),Z(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),Z(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),Z(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),Z(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),Z(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),Z(`\\imath`,`\\html@mathml{\\@imath}{ı}`),Z(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),Z(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),Z(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),Z(`⟦`,`\\llbracket`),Z(`⟧`,`\\rrbracket`),Z(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),Z(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),Z(`↤`,`\\mapsfrom`),Z(`\\mapsfrom`,"\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`↤}}"),Z(`⦃`,`\\lBrace`),Z(`⦄`,`\\rBrace`),Z(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),Z(`⦵`,`\\minuso`),Z(`\\darr`,`\\downarrow`),Z(`\\dArr`,`\\Downarrow`),Z(`\\Darr`,`\\Downarrow`),Z(`\\lang`,`\\langle`),Z(`\\rang`,`\\rangle`),Z(`\\uarr`,`\\uparrow`),Z(`\\uArr`,`\\Uparrow`),Z(`\\Uarr`,`\\Uparrow`),Z(`\\N`,`\\mathbb{N}`),Z(`\\R`,`\\mathbb{R}`),Z(`\\Z`,`\\mathbb{Z}`),Z(`\\alef`,`\\aleph`),Z(`\\alefsym`,`\\aleph`),Z(`\\Alpha`,`\\mathrm{A}`),Z(`\\Beta`,`\\mathrm{B}`),Z(`\\bull`,`\\bullet`),Z(`\\Chi`,`\\mathrm{X}`),Z(`\\clubs`,`\\clubsuit`),Z(`\\cnums`,`\\mathbb{C}`),Z(`\\Complex`,`\\mathbb{C}`),Z(`\\Dagger`,`\\ddagger`),Z(`\\diamonds`,`\\diamondsuit`),Z(`\\empty`,`\\emptyset`),Z(`\\Epsilon`,`\\mathrm{E}`),Z(`\\Eta`,`\\mathrm{H}`),Z(`\\exist`,`\\exists`),Z(`\\harr`,`\\leftrightarrow`),Z(`\\hArr`,`\\Leftrightarrow`),Z(`\\Harr`,`\\Leftrightarrow`),Z(`\\hearts`,`\\heartsuit`),Z(`\\image`,`\\Im`),Z(`\\infin`,`\\infty`),Z(`\\Iota`,`\\mathrm{I}`),Z(`\\isin`,`\\in`),Z(`\\Kappa`,`\\mathrm{K}`),Z(`\\larr`,`\\leftarrow`),Z(`\\lArr`,`\\Leftarrow`),Z(`\\Larr`,`\\Leftarrow`),Z(`\\lrarr`,`\\leftrightarrow`),Z(`\\lrArr`,`\\Leftrightarrow`),Z(`\\Lrarr`,`\\Leftrightarrow`),Z(`\\Mu`,`\\mathrm{M}`),Z(`\\natnums`,`\\mathbb{N}`),Z(`\\Nu`,`\\mathrm{N}`),Z(`\\Omicron`,`\\mathrm{O}`),Z(`\\plusmn`,`\\pm`),Z(`\\rarr`,`\\rightarrow`),Z(`\\rArr`,`\\Rightarrow`),Z(`\\Rarr`,`\\Rightarrow`),Z(`\\real`,`\\Re`),Z(`\\reals`,`\\mathbb{R}`),Z(`\\Reals`,`\\mathbb{R}`),Z(`\\Rho`,`\\mathrm{P}`),Z(`\\sdot`,`\\cdot`),Z(`\\sect`,`\\S`),Z(`\\spades`,`\\spadesuit`),Z(`\\sub`,`\\subset`),Z(`\\sube`,`\\subseteq`),Z(`\\supe`,`\\supseteq`),Z(`\\Tau`,`\\mathrm{T}`),Z(`\\thetasym`,`\\vartheta`),Z(`\\weierp`,`\\wp`),Z(`\\Zeta`,`\\mathrm{Z}`),Z(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),Z(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),Z(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),Z(`\\bra`,`\\mathinner{\\langle{#1}|}`),Z(`\\ket`,`\\mathinner{|{#1}\\rangle}`),Z(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),Z(`\\Bra`,`\\left\\langle#1\\right|`),Z(`\\Ket`,`\\left|#1\\right\\rangle`);var Yl=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};Z(`\\bra@ket`,Yl(!1)),Z(`\\bra@set`,Yl(!0)),Z(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),Z(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),Z(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),Z(`\\angln`,`{\\angl n}`),Z(`\\blue`,`\\textcolor{##6495ed}{#1}`),Z(`\\orange`,`\\textcolor{##ffa500}{#1}`),Z(`\\pink`,`\\textcolor{##ff00af}{#1}`),Z(`\\red`,`\\textcolor{##df0030}{#1}`),Z(`\\green`,`\\textcolor{##28ae7b}{#1}`),Z(`\\gray`,`\\textcolor{gray}{#1}`),Z(`\\purple`,`\\textcolor{##9d38bd}{#1}`),Z(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),Z(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),Z(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),Z(`\\blueD`,`\\textcolor{##11accd}{#1}`),Z(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),Z(`\\tealA`,`\\textcolor{##94fff5}{#1}`),Z(`\\tealB`,`\\textcolor{##26edd5}{#1}`),Z(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),Z(`\\tealD`,`\\textcolor{##01a995}{#1}`),Z(`\\tealE`,`\\textcolor{##208170}{#1}`),Z(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),Z(`\\greenB`,`\\textcolor{##8af281}{#1}`),Z(`\\greenC`,`\\textcolor{##74cf70}{#1}`),Z(`\\greenD`,`\\textcolor{##1fab54}{#1}`),Z(`\\greenE`,`\\textcolor{##0d923f}{#1}`),Z(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),Z(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),Z(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),Z(`\\goldD`,`\\textcolor{##e07d10}{#1}`),Z(`\\goldE`,`\\textcolor{##a75a05}{#1}`),Z(`\\redA`,`\\textcolor{##fca9a9}{#1}`),Z(`\\redB`,`\\textcolor{##ff8482}{#1}`),Z(`\\redC`,`\\textcolor{##f9685d}{#1}`),Z(`\\redD`,`\\textcolor{##e84d39}{#1}`),Z(`\\redE`,`\\textcolor{##bc2612}{#1}`),Z(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),Z(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),Z(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),Z(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),Z(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),Z(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),Z(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),Z(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),Z(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),Z(`\\purpleE`,`\\textcolor{##543b78}{#1}`),Z(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),Z(`\\mintB`,`\\textcolor{##edf2df}{#1}`),Z(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),Z(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),Z(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),Z(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),Z(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),Z(`\\grayE`,`\\textcolor{##babec2}{#1}`),Z(`\\grayF`,`\\textcolor{##888d93}{#1}`),Z(`\\grayG`,`\\textcolor{##626569}{#1}`),Z(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),Z(`\\grayI`,`\\textcolor{##21242c}{#1}`),Z(`\\kaBlue`,`\\textcolor{##314453}{#1}`),Z(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var Xl={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Zl=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Vl(Hl,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Bl(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new Bc(`EOF`,n.loc)),this.pushTokens(r),new Bc(``,zc.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new R(`Extra }`,i)}else if(i.text===`EOF`)throw new R(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new R(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;r<n.length;r++){var i=this.popToken();if(n[r]!==i.text)throw new R(`Use of the macro doesn't match its definition`,i)}}for(var a=[],o=0;o<e;o++)a.push(this.consumeArg(t&&t[o+1]).tokens);return a}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new R(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new R(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new R(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new R(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Bc(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new Bl(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(jl,e)||Object.prototype.hasOwnProperty.call(xa.math,e)||Object.prototype.hasOwnProperty.call(xa.text,e)||Object.prototype.hasOwnProperty.call(Xl,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(jl,e)&&!jl[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},Ql=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,$l=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),eu={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},tu={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},nu=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new Zl(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new R(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Bc(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&jl[i.text]&&jl[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r<e.length;r++){var i=e[r];if(i.type===`infix`){if(t!==-1)throw new R(`only one infix operator per group`,i.token);t=r,n=i.replaceWith}}if(t!==-1&&n){var a,o,s=e.slice(0,t),c=e.slice(t+1);return a=s.length===1&&s[0].type===`ordgroup`?s[0]:{type:`ordgroup`,mode:this.mode,body:s},o=c.length===1&&c[0].type===`ordgroup`?c[0]:{type:`ordgroup`,mode:this.mode,body:c},[n===`\\\\abovefrac`?this.callFunction(n,[a,e[t],o],[]):this.callFunction(n,[a,o],[])]}return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var r;do r=this.parseGroup(e);while(r?.type===`internal`);if(!r)throw new R(`Expected group after '`+n+`'`,t);return r}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:`textord`,mode:`text`,text:e[n]});var r={type:`text`,mode:this.mode,body:t};return{type:`color`,mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(e){var t=this.parseGroup(`atom`,e);if(t?.type===`internal`||this.mode===`text`)return t;for(var n,r;;){this.consumeSpaces();var i=this.fetch();if(i.text===`\\limits`||i.text===`\\nolimits`){if(t&&t.type===`op`)t.limits=i.text===`\\limits`,t.alwaysHandleSupSub=!0;else if(t&&t.type===`operatorname`)t.alwaysHandleSupSub&&(t.limits=i.text===`\\limits`);else throw new R(`Limit controls must follow a math operator`,i);this.consume()}else if(i.text===`^`){if(n)throw new R(`Double superscript`,i);n=this.handleSupSubscript(`superscript`)}else if(i.text===`_`){if(r)throw new R(`Double subscript`,i);r=this.handleSupSubscript(`subscript`)}else if(i.text===`'`){if(n)throw new R(`Double superscript`,i);var a={type:`textord`,mode:this.mode,text:`\\prime`},o=[a];for(this.consume();this.fetch().text===`'`;)o.push(a),this.consume();this.fetch().text===`^`&&o.push(this.handleSupSubscript(`superscript`)),n={type:`ordgroup`,mode:this.mode,body:o}}else if($l[i.text]){var s=Ql.test(i.text),c=[];for(c.push(new Bc($l[i.text])),this.consume();;){var l=this.fetch().text;if(!$l[l]||Ql.test(l)!==s)break;c.unshift(new Bc($l[l])),this.consume()}var u=this.subparse(c);s?r={type:`ordgroup`,mode:`math`,body:u}:n={type:`ordgroup`,mode:`math`,body:u}}else break}return n&&r?{type:`supsub`,mode:this.mode,base:t,sup:n,sub:r}:n?{type:`supsub`,mode:this.mode,base:t,sup:n}:r?{type:`supsub`,mode:this.mode,base:t,sub:r}:t}parseFunction(e,t){var n=this.fetch(),r=n.text,i=jl[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new R(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new R(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new R(`Can't use function '`+r+`' in math mode`,n);var a=this.parseArguments(r,i),o=a.args,s=a.optArgs;return this.callFunction(r,o,s,n,e)}callFunction(e,t,n,r,i){var a={funcName:e,parser:this,token:r,breakOnTokenText:i},o=jl[e];if(o&&o.handler)return o.handler(a,t,n);throw new R(`No function handler for `+e)}parseArguments(e,t){var n=t.numOptionalArgs??0,r=t.numArgs+n;if(r===0)return{args:[],optArgs:[]};for(var i=[],a=[],o=0;o<r;o++){var s=t.argTypes?.[o],c=o<n;(`primitive`in t&&t.primitive&&s==null||t.type===`sqrt`&&o===1&&a[0]==null)&&(s=`primitive`);var l=this.parseGroupOfType(`argument to '`+e+`'`,s,c);if(c)a.push(l);else if(l!=null)i.push(l);else throw new R(`Null argument, please report this as a bug`)}return{args:i,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case`color`:return this.parseColorGroup(n);case`size`:return this.parseSizeGroup(n);case`url`:return this.parseUrlGroup(n);case`math`:case`text`:return this.parseArgumentGroup(n,t);case`hbox`:var r=this.parseArgumentGroup(n,`text`);return r==null?null:{type:`styling`,mode:r.mode,body:[r],style:`text`,resetFont:!0};case`raw`:this.gullet.consumeSpaces();var i=this.gullet.lexer.catcodes[`%`];this.gullet.lexer.setCatcode(`%`,12);var a=this.parseStringGroup(n);return this.gullet.lexer.setCatcode(`%`,i),a==null?null:{type:`raw`,mode:`text`,string:a.text};case`primitive`:if(n)throw new R(`A primitive argument cannot be optional`);var o=this.parseGroup(e);if(o==null)throw new R(`Expected group as `+e,this.fetch());return o;case`original`:case void 0:return this.parseArgumentGroup(n);default:throw new R(`Unknown group type as `+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===` `;)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n=``,r;(r=this.fetch()).text!==`EOF`;)n+=r.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),r=n,i=``,a;(a=this.fetch()).text!==`EOF`&&e.test(i+a.text);)r=a,i+=r.text,this.consume();if(i===``)throw new R(`Invalid `+t+`: '`+n.text+`'`,n);return n.range(r,i)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new R(`Invalid color: '`+t.text+`'`,t);var r=n[0];return/^[0-9a-f]{6}$/i.test(r)&&(r=`#`+r),{type:`color-token`,mode:this.mode,color:r}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),t=!e&&this.gullet.future().text!==`{`?this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,`size`):this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text=`0pt`,n=!0);var r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!r)throw new R(`Invalid size: '`+t.text+`'`,t);var i={number:+(r[1]+r[2]),unit:r[3]};if(!Yi(i))throw new R(`Invalid unit: '`+i.unit+`'`,t);return{type:`size`,mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){var t=this.gullet.lexer.catcodes[`%`],n=this.gullet.lexer.catcodes[`~`];this.gullet.lexer.setCatcode(`%`,13),this.gullet.lexer.setCatcode(`~`,12);var r=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode(`%`,t),this.gullet.lexer.setCatcode(`~`,n),r==null)return null;var i=r.text.replace(/\\([#$%&~_^{}])/g,`$1`);return{type:`url`,mode:this.mode,url:i}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var r=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var i=this.parseExpression(!1,`EOF`);this.expect(`EOF`),this.gullet.endGroup();var a={type:`ordgroup`,mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(r),a}parseGroup(e,t){var n=this.fetch(),r=n.text,i;if(r===`{`||r===`\\begingroup`){this.consume();var a=r===`{`?`}`:`\\endgroup`;this.gullet.beginGroup();var o=this.parseExpression(!1,a),s=this.fetch();this.expect(a),this.gullet.endGroup(),i={type:`ordgroup`,mode:this.mode,loc:zc.range(n,s),body:o,semisimple:r===`\\begingroup`||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&r[0]===`\\`&&!Object.prototype.hasOwnProperty.call(Xl,r)){if(this.settings.throwOnError)throw new R(`Undefined control sequence: `+r,n);i=this.formatUnsupportedCmd(r),this.consume()}return i}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var r=e[n];if(r.type===`textord`){var i=r.text,a=e[n+1];if(a&&a.type===`textord`){if(i===`-`&&a.text===`-`){var o=e[n+2];n+1<t&&o&&o.type===`textord`&&o.text===`-`?(e.splice(n,3,{type:`textord`,mode:`text`,loc:zc.range(r,o),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:zc.range(r,a),text:`--`}),--t)}(i===`'`||i==="`")&&a.text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:zc.range(r,a),text:i+i}),--t)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),r=n.charAt(0)===`*`;if(r&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new R(`\\verb assertion failed --
|
|
278
|
+
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(tu,t[0])&&!xa[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&uo({strict:this.settings.strict,errorCode:`unicodeTextInMathMode`,errorMsg:`Accented Unicode text character "`+t[0]+`" used in math mode`,report:!0,token:e}),t=tu[t[0]]+t.slice(1));var i=Rl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(xa[this.mode][t]){this.settings.strict&&this.mode===`math`&&Ka.includes(t)&&uo({strict:this.settings.strict,errorCode:`unicodeTextInMathMode`,errorMsg:`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,report:!0,token:e});var o=xa[this.mode][t].group,s=zc.range(e);a=Ns(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(ji(t.charCodeAt(0))?this.mode===`math`&&uo({strict:this.settings.strict,errorCode:`unicodeTextInMathMode`,errorMsg:`Unicode text character "`+t[0]+`" used in math mode`,report:!0,token:e}):uo({strict:this.settings.strict,errorCode:`unknownSymbol`,errorMsg:`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),report:!0,token:e})),a={type:`textord`,mode:`text`,loc:zc.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!eu[l])throw new R(`Unknown accent ' `+l+`'`,e);var u=eu[l][this.mode]||eu[l].text;if(!u)throw new R(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:zc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};nu.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var ru=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new nu(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new R(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Bc(`\\df@tag`)])}]}return r},iu=function(e,t,n){t.textContent=``;var r=cu(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),iu=function(){throw new R(`KaTeX doesn't work in quirks mode.`)});var au=function(e,t){return cu(e,t).toMarkup()},ou=function(e,t){return ru(e,new ui(t))},su=function(e,t,n){if(n.throwOnError||!(e instanceof R))throw e;var r=q([`katex-error`],[new sa(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},cu=function(e,t){var n=new ui(t);try{return xs(ru(e,n),e,n)}catch(t){return su(t,e,n)}},lu={version:`0.19.1`,render:iu,renderToString:au,ParseError:R,SETTINGS_SCHEMA:oi,__parse:ou,__renderToDomTree:cu,__renderToHTMLTree:function(e,t){var n=new ui(t);try{return Ss(ru(e,n),n)}catch(t){return su(t,e,n)}},__setFontMetrics:_a,__defineSymbol:B,__defineFunction:J,__defineMacro:Z,__domTree:{Span:ra,Anchor:ia,SymbolNode:sa,SvgNode:ca,PathNode:la,LineNode:ua}},uu=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CHAR=`
|
|
279
|
+
\r --�𐀀-`,e.S=` \r
|
|
280
|
+
`,e.NAME_START_CHAR=`:A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,e.NAME_CHAR=`-`+e.NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,e.CHAR_RE=RegExp(`^[`+e.CHAR+`]$`,`u`),e.S_RE=RegExp(`^[`+e.S+`]+$`,`u`),e.NAME_START_CHAR_RE=RegExp(`^[`+e.NAME_START_CHAR+`]$`,`u`),e.NAME_CHAR_RE=RegExp(`^[`+e.NAME_CHAR+`]$`,`u`),e.NAME_RE=RegExp(`^[`+e.NAME_START_CHAR+`][`+e.NAME_CHAR+`]*$`,`u`),e.NMTOKEN_RE=RegExp(`^[`+e.NAME_CHAR+`]+$`,`u`);var t=9,n=10,r=13,i=32;e.S_LIST=[i,n,r,t];function a(e){return e>=i&&e<=55295||e===n||e===r||e===t||e>=57344&&e<=65533||e>=65536&&e<=1114111}e.isChar=a;function o(e){return e===i||e===n||e===r||e===t}e.isS=o;function s(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}e.isNameStartChar=s;function c(e){return s(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}e.isNameChar=c})),du=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CHAR=`--�𐀀-`,e.RESTRICTED_CHAR=`-\b\v\f---`,e.S=` \r
|
|
281
|
+
`,e.NAME_START_CHAR=`:A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,e.NAME_CHAR=`-`+e.NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,e.CHAR_RE=RegExp(`^[`+e.CHAR+`]$`,`u`),e.RESTRICTED_CHAR_RE=RegExp(`^[`+e.RESTRICTED_CHAR+`]$`,`u`),e.S_RE=RegExp(`^[`+e.S+`]+$`,`u`),e.NAME_START_CHAR_RE=RegExp(`^[`+e.NAME_START_CHAR+`]$`,`u`),e.NAME_CHAR_RE=RegExp(`^[`+e.NAME_CHAR+`]$`,`u`),e.NAME_RE=RegExp(`^[`+e.NAME_START_CHAR+`][`+e.NAME_CHAR+`]*$`,`u`),e.NMTOKEN_RE=RegExp(`^[`+e.NAME_CHAR+`]+$`,`u`);var t=9,n=10,r=13,i=32;e.S_LIST=[i,n,r,t];function a(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}e.isChar=a;function o(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159}e.isRestrictedChar=o;function s(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}e.isCharAndNotRestricted=s;function c(e){return e===i||e===n||e===r||e===t}e.isS=c;function l(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}e.isNameStartChar=l;function u(e){return l(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}e.isNameChar=u})),fu=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NC_NAME_START_CHAR=`A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,e.NC_NAME_CHAR=`-`+e.NC_NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,e.NC_NAME_START_CHAR_RE=RegExp(`^[`+e.NC_NAME_START_CHAR+`]$`,`u`),e.NC_NAME_CHAR_RE=RegExp(`^[`+e.NC_NAME_CHAR+`]$`,`u`),e.NC_NAME_RE=RegExp(`^[`+e.NC_NAME_START_CHAR+`][`+e.NC_NAME_CHAR+`]*$`,`u`);function t(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}e.isNCNameStartChar=t;function n(e){return t(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}e.isNCNameChar=n})),pu=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SaxesParser=e.EVENTS=void 0;var t=uu(),n=du(),r=fu(),i=t.isS,a=t.isChar,o=t.isNameStartChar,s=t.isNameChar,c=t.S_LIST,l=t.NAME_RE,u=n.isChar,d=r.isNCNameStartChar,f=r.isNCNameChar,p=r.NC_NAME_RE,m=`http://www.w3.org/XML/1998/namespace`,h=`http://www.w3.org/2000/xmlns/`,g={__proto__:null,xml:m,xmlns:h},_={__proto__:null,amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`},v=-1,y=-2,b=0,x=1,S=2,C=3,w=4,T=5,E=6,D=7,O=8,k=9,A=10,j=11,ee=12,M=13,te=14,N=15,ne=16,re=17,ie=18,ae=19,oe=20,se=21,ce=22,le=23,ue=24,de=25,fe=26,pe=27,me=28,he=29,ge=30,P=31,_e=32,ve=33,ye=34,be=35,xe=36,Se=37,Ce=38,we=39,Te=40,Ee=41,De=42,Oe=43,ke=44,Ae=9,je=10,Me=13,Ne=32,Pe=33,Fe=34,Ie=38,F=39,Le=45,Re=47,ze=59,Be=60,Ve=61,He=62,Ue=63,We=91,I=93,Ge=133,Ke=8232,qe=e=>e===Fe||e===F,Je=[Fe,F],Ye=[...Je,We,He],Xe=[...Je,Be,I],Ze=[Ve,Ue,...c],Qe=[...c,He,Ie,Be];function $e(e,t,n){switch(t){case`xml`:n!==m&&e.fail(`xml prefix must be bound to ${m}.`);break;case`xmlns`:n!==h&&e.fail(`xmlns prefix must be bound to ${h}.`)}switch(n){case h:e.fail(t===``?`the default namespace may not be set to ${n}.`:`may not assign a prefix (even "xmlns") to the URI \
|
|
282
|
+
${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namespace may not be set to ${n}.`);break;default:e.fail(`may not assign the xml namespace to another prefix.`)}}}function et(e,t){for(let n of Object.keys(t))$e(e,n,t[n])}var tt=e=>p.test(e),nt=e=>l.test(e),rt=0,it=1,at=2;e.EVENTS=[`xmldecl`,`text`,`processinginstruction`,`doctype`,`comment`,`opentagstart`,`attribute`,`opentag`,`closetag`,`cdata`,`error`,`end`,`ready`];var ot={xmldecl:`xmldeclHandler`,text:`textHandler`,processinginstruction:`piHandler`,doctype:`doctypeHandler`,comment:`commentHandler`,opentagstart:`openTagStartHandler`,attribute:`attributeHandler`,opentag:`openTagHandler`,closetag:`closeTagHandler`,cdata:`cdataHandler`,error:`errorHandler`,end:`endHandler`,ready:`readyHandler`};e.SaxesParser=class{constructor(e){this.opt=e??{},this.fragmentOpt=!!this.opt.fragment;let t=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,t){this.nameStartCheck=d,this.nameCheck=f,this.isName=tt,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},g);let e=this.opt.additionalNamespaces;e!=null&&(et(this,e),Object.assign(this.ns,e))}else this.nameStartCheck=o,this.nameCheck=s,this.isName=nt,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var e;this.openWakaBang=``,this.text=``,this.name=``,this.piTarget=``,this.entity=``,this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk=``,this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=rt,this.attribList=[];let{fragmentOpt:t}=this;this.state=t?M:b,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=t,this.xmlDeclPossible=!t,this.xmlDeclExpects=[`version`],this.entityReturnState=void 0;let{defaultXMLVersion:n}=this.opt;if(n===void 0){if(this.opt.forceXMLVersion===!0)throw Error(`forceXMLVersion set but defaultXMLVersion is not set`);n=`1.0`}this.setXMLVersion(n),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(_),(e=this.readyHandler)==null||e.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(e,t){this[ot[e]]=t}off(e){this[ot[e]]=void 0}makeError(e){let t=this.fileName??``;return this.trackPosition&&(t.length>0&&(t+=`:`),t+=`${this.line}:${this.column}`),t.length>0&&(t+=`: `),Error(t+e)}fail(e){let t=this.makeError(e),n=this.errorHandler;if(n===void 0)throw t;return n(t),this}write(e){if(this.closed)return this.fail(`cannot write after close; assign an onready handler.`);let t=!1;e===null?(t=!0,e=``):typeof e==`object`&&(e=e.toString()),this.carriedFromPrevious!==void 0&&(e=`${this.carriedFromPrevious}${e}`,this.carriedFromPrevious=void 0);let n=e.length,r=e.charCodeAt(n-1);!t&&(r===Me||r>=55296&&r<=56319)&&(this.carriedFromPrevious=e[n-1],n--,e=e.slice(0,n));let{stateTable:i}=this;for(this.chunk=e,this.i=0;this.i<n;)i[this.state].call(this);return this.chunkPosition+=n,t?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return v;let n=e.charCodeAt(t);if(this.column++,n<55296){if(n>=Ne||n===Ae)return n;switch(n){case je:return this.line++,this.column=0,this.positionAtNewLine=this.position,je;case Me:return e.charCodeAt(t+1)===je&&(this.i=t+2),this.line++,this.column=0,this.positionAtNewLine=this.position,y;default:return this.fail(`disallowed character.`),n}}if(n>56319)return n>=57344&&n<=65533||this.fail(`disallowed character.`),n;let r=65536+(n-55296)*1024+(e.charCodeAt(t+1)-56320);return this.i=t+2,r>1114111&&this.fail(`disallowed character.`),r}getCode11(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return v;let n=e.charCodeAt(t);if(this.column++,n<55296){if(n>31&&n<127||n>159&&n!==Ke||n===Ae)return n;switch(n){case je:return this.line++,this.column=0,this.positionAtNewLine=this.position,je;case Me:{let n=e.charCodeAt(t+1);(n===je||n===Ge)&&(this.i=t+2)}case Ge:case Ke:return this.line++,this.column=0,this.positionAtNewLine=this.position,y;default:return this.fail(`disallowed character.`),n}}if(n>56319)return n>=57344&&n<=65533||this.fail(`disallowed character.`),n;let r=65536+(n-55296)*1024+(e.charCodeAt(t+1)-56320);return this.i=t+2,r>1114111&&this.fail(`disallowed character.`),r}getCodeNorm(){let e=this.getCode();return e===y?je:e}unget(){this.i=this.prevI,this.column--}captureTo(e){let{i:t}=this,{chunk:n}=this;for(;;){let r=this.getCode(),i=r===y,a=i?je:r;if(a===v||e.includes(a))return this.text+=n.slice(t,this.prevI),a;i&&(this.text+=`${n.slice(t,this.prevI)}\n`,t=this.i)}}captureToChar(e){let{i:t}=this,{chunk:n}=this;for(;;){let r=this.getCode();switch(r){case y:this.text+=`${n.slice(t,this.prevI)}\n`,t=this.i,r=je;break;case v:return this.text+=n.slice(t),!1}if(r===e)return this.text+=n.slice(t,this.prevI),!0}}captureNameChars(){let{chunk:e,i:t}=this;for(;;){let n=this.getCode();if(n===v)return this.name+=e.slice(t),v;if(!s(n))return this.name+=e.slice(t,this.prevI),n===y?je:n}}skipSpaces(){for(;;){let e=this.getCodeNorm();if(e===v||!i(e))return e}}setXMLVersion(e){this.currentXMLVersion=e,e===`1.0`?(this.isChar=a,this.getCode=this.getCode10):(this.isChar=u,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=x}sBeginWhitespace(){let e=this.i,t=this.skipSpaces();switch(this.prevI!==e&&(this.xmlDeclPossible=!1),t){case Be:if(this.state=N,this.text.length!==0)throw Error(`no-empty text at start`);break;case v:break;default:this.unget(),this.state=M,this.xmlDeclPossible=!1}}sDoctype(){var e;let t=this.captureTo(Ye);switch(t){case He:(e=this.doctypeHandler)==null||e.call(this,this.text),this.text=``,this.state=M,this.doctype=!0;break;case v:break;default:this.text+=String.fromCodePoint(t),t===We?this.state=w:qe(t)&&(this.state=C,this.q=t)}}sDoctypeQuote(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.q=null,this.state=S)}sDTD(){let e=this.captureTo(Xe);e!==v&&(this.text+=String.fromCodePoint(e),e===I?this.state=S:e===Be?this.state=E:qe(e)&&(this.state=T,this.q=e))}sDTDQuoted(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.state=w,this.q=null)}sDTDOpenWaka(){let e=this.getCodeNorm();switch(this.text+=String.fromCodePoint(e),e){case Pe:this.state=D,this.openWakaBang=``;break;case Ue:this.state=j;break;default:this.state=w}}sDTDOpenWakaBang(){let e=String.fromCodePoint(this.getCodeNorm()),t=this.openWakaBang+=e;this.text+=e,t!==`-`&&(this.state=t===`--`?O:w,this.openWakaBang=``)}sDTDComment(){this.captureToChar(Le)&&(this.text+=`-`,this.state=k)}sDTDCommentEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),this.state=e===Le?A:O}sDTDCommentEnded(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===He?this.state=w:(this.fail(`malformed comment.`),this.state=O)}sDTDPI(){this.captureToChar(Ue)&&(this.text+=`?`,this.state=ee)}sDTDPIEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===He&&(this.state=w)}sText(){this.tags.length===0?this.handleTextOutsideRoot():this.handleTextInRoot()}sEntity(){let{i:e}=this,{chunk:t}=this;loop:for(;;)switch(this.getCode()){case y:this.entity+=`${t.slice(e,this.prevI)}\n`,e=this.i;break;case ze:{let{entityReturnState:n}=this,r=this.entity+t.slice(e,this.prevI);this.state=n;let i;r===``?(this.fail(`empty entity name.`),i=`&;`):(i=this.parseEntity(r),this.entity=``),(n!==M||this.textHandler!==void 0)&&(this.text+=i);break loop}case v:this.entity+=t.slice(e);break loop}}sOpenWaka(){let e=this.getCode();if(o(e))this.state=ye,this.unget(),this.xmlDeclPossible=!1;else switch(e){case Re:this.state=Oe,this.xmlDeclPossible=!1;break;case Pe:this.state=ne,this.openWakaBang=``,this.xmlDeclPossible=!1;break;case Ue:this.state=le;break;default:this.fail(`disallowed character in tag name`),this.state=M,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case`[CDATA[`:!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0),this.state=oe,this.openWakaBang=``;break;case`--`:this.state=re,this.openWakaBang=``;break;case`DOCTYPE`:this.state=S,(this.doctype||this.sawRoot)&&this.fail(`inappropriately located doctype declaration.`),this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&this.fail(`incorrect syntax.`)}}sComment(){this.captureToChar(Le)&&(this.state=ie)}sCommentEnding(){var e;let t=this.getCodeNorm();t===Le?(this.state=ae,(e=this.commentHandler)==null||e.call(this,this.text),this.text=``):(this.text+=`-${String.fromCodePoint(t)}`,this.state=re)}sCommentEnded(){let e=this.getCodeNorm();e===He?this.state=M:(this.fail(`malformed comment.`),this.text+=`--${String.fromCodePoint(e)}`,this.state=re)}sCData(){this.captureToChar(I)&&(this.state=se)}sCDataEnding(){let e=this.getCodeNorm();e===I?this.state=ce:(this.text+=`]${String.fromCodePoint(e)}`,this.state=oe)}sCDataEnding2(){var e;let t=this.getCodeNorm();switch(t){case He:(e=this.cdataHandler)==null||e.call(this,this.text),this.text=``,this.state=M;break;case I:this.text+=`]`;break;default:this.text+=`]]${String.fromCodePoint(t)}`,this.state=oe}}sPIFirstChar(){let e=this.getCodeNorm();this.nameStartCheck(e)?(this.piTarget+=String.fromCodePoint(e),this.state=ue):e===Ue||i(e)?(this.fail(`processing instruction without a target.`),this.state=e===Ue?fe:de):(this.fail(`disallowed character in processing instruction name.`),this.piTarget+=String.fromCodePoint(e),this.state=ue)}sPIRest(){let{chunk:e,i:t}=this;for(;;){let n=this.getCodeNorm();if(n===v){this.piTarget+=e.slice(t);return}if(!this.nameCheck(n)){this.piTarget+=e.slice(t,this.prevI);let r=n===Ue;r||i(n)?this.piTarget===`xml`?(this.xmlDeclPossible||this.fail(`an XML declaration must be at the start of the document.`),this.state=r?ve:pe):this.state=r?fe:de:(this.fail(`disallowed character in processing instruction name.`),this.piTarget+=String.fromCodePoint(n));break}}}sPIBody(){if(this.text.length===0){let e=this.getCodeNorm();e===Ue?this.state=fe:i(e)||(this.text=String.fromCodePoint(e))}else this.captureToChar(Ue)&&(this.state=fe)}sPIEnding(){var e;let t=this.getCodeNorm();if(t===He){let{piTarget:t}=this;t.toLowerCase()===`xml`&&this.fail(`the XML declaration must appear at the start of the document.`),(e=this.piHandler)==null||e.call(this,{target:t,body:this.text}),this.piTarget=this.text=``,this.state=M}else t===Ue?this.text+=`?`:(this.text+=`?${String.fromCodePoint(t)}`,this.state=de);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let e=this.skipSpaces();e===Ue?this.state=ve:e!==v&&(this.state=me,this.name=String.fromCodePoint(e))}sXMLDeclName(){let e=this.captureTo(Ze);if(e===Ue)this.state=ve,this.name+=this.text,this.text=``,this.fail(`XML declaration is incomplete.`);else if(i(e)||e===Ve){if(this.name+=this.text,this.text=``,!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail(`did not expect any more name/value pairs.`);break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(`, `)}`)}this.state=e===Ve?ge:he}}sXMLDeclEq(){let e=this.getCodeNorm();e===Ue?(this.state=ve,this.fail(`XML declaration is incomplete.`)):i(e)||(e!==Ve&&this.fail(`value required.`),this.state=ge)}sXMLDeclValueStart(){let e=this.getCodeNorm();e===Ue?(this.state=ve,this.fail(`XML declaration is incomplete.`)):i(e)||(qe(e)?this.q=e:(this.fail(`value must be quoted.`),this.q=Ne),this.state=P)}sXMLDeclValue(){let e=this.captureTo([this.q,Ue]);if(e===Ue){this.state=ve,this.text=``,this.fail(`XML declaration is incomplete.`);return}if(e===v)return;let t=this.text;switch(this.text=``,this.name){case`version`:{this.xmlDeclExpects=[`encoding`,`standalone`];let e=t;this.xmlDecl.version=e,/^1\.[0-9]+$/.test(e)?this.opt.forceXMLVersion||this.setXMLVersion(e):this.fail(`version number must match /^1\\.[0-9]+$/.`);break}case`encoding`:/^[A-Za-z][A-Za-z0-9._-]*$/.test(t)||this.fail(`encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/.`),this.xmlDeclExpects=[`standalone`],this.xmlDecl.encoding=t;break;case`standalone`:t!==`yes`&&t!==`no`&&this.fail(`standalone value must match "yes" or "no".`),this.xmlDeclExpects=[],this.xmlDecl.standalone=t}this.name=``,this.state=_e}sXMLDeclSeparator(){let e=this.getCodeNorm();e===Ue?this.state=ve:(i(e)||(this.fail(`whitespace required.`),this.unget()),this.state=pe)}sXMLDeclEnding(){var e;this.getCodeNorm()===He?(this.piTarget===`xml`?this.name!==`version`&&this.xmlDeclExpects.includes(`version`)&&this.fail(`XML declaration must contain a version.`):this.fail(`processing instructions are not allowed before root.`),(e=this.xmldeclHandler)==null||e.call(this,this.xmlDecl),this.name=``,this.piTarget=this.text=``,this.state=M):this.fail(`The character ? is disallowed anywhere in XML declarations.`),this.xmlDeclPossible=!1}sOpenTag(){var e;let t=this.captureNameChars();if(t===v)return;let n=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name=``,this.xmlnsOpt&&(this.topNS=n.ns=Object.create(null)),(e=this.openTagStartHandler)==null||e.call(this,n),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail(`documents may contain only one root.`),t){case He:this.openTag();break;case Re:this.state=be;break;default:i(t)||this.fail(`disallowed character in tag name.`),this.state=xe}}sOpenTagSlash(){this.getCode()===He?this.openSelfClosingTag():(this.fail(`forward-slash in opening tag not followed by >.`),this.state=xe)}sAttrib(){let e=this.skipSpaces();e!==v&&(o(e)?(this.unget(),this.state=Se):e===He?this.openTag():e===Re?this.state=be:this.fail(`disallowed character in attribute name.`))}sAttribName(){let e=this.captureNameChars();e===Ve?this.state=we:i(e)?this.state=Ce:e===He?(this.fail(`attribute without value.`),this.pushAttrib(this.name,this.name),this.name=this.text=``,this.openTag()):e!==v&&this.fail(`disallowed character in attribute name.`)}sAttribNameSawWhite(){let e=this.skipSpaces();switch(e){case v:return;case Ve:this.state=we;break;default:this.fail(`attribute without value.`),this.text=``,this.name=``,e===He?this.openTag():o(e)?(this.unget(),this.state=Se):(this.fail(`disallowed character in attribute name.`),this.state=xe)}}sAttribValue(){let e=this.getCodeNorm();qe(e)?(this.q=e,this.state=Te):i(e)||(this.fail(`unquoted attribute value.`),this.state=De,this.unget())}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;)switch(this.getCode()){case e:this.pushAttrib(this.name,this.text+t.slice(n,this.prevI)),this.name=this.text=``,this.q=null,this.state=Ee;return;case Ie:this.text+=t.slice(n,this.prevI),this.state=te,this.entityReturnState=Te;return;case je:case y:case Ae:this.text+=`${t.slice(n,this.prevI)} `,n=this.i;break;case Be:this.text+=t.slice(n,this.prevI),this.fail(`disallowed character.`);return;case v:this.text+=t.slice(n);return}}sAttribValueClosed(){let e=this.getCodeNorm();i(e)?this.state=xe:e===He?this.openTag():e===Re?this.state=be:o(e)?(this.fail(`no whitespace between attributes.`),this.unget(),this.state=Se):this.fail(`disallowed character in attribute name.`)}sAttribValueUnquoted(){let e=this.captureTo(Qe);switch(e){case Ie:this.state=te,this.entityReturnState=De;break;case Be:this.fail(`disallowed character.`);break;case v:break;default:this.text.includes(`]]>`)&&this.fail(`the string "]]>" is disallowed in char data.`),this.pushAttrib(this.name,this.text),this.name=this.text=``,e===He?this.openTag():this.state=xe}}sCloseTag(){let e=this.captureNameChars();e===He?this.closeTag():i(e)?this.state=ke:e!==v&&this.fail(`disallowed character in closing tag.`)}sCloseTagSawWhite(){switch(this.skipSpaces()){case He:this.closeTag();break;case v:break;default:this.fail(`disallowed character in closing tag.`)}}handleTextInRoot(){let{i:e,forbiddenState:t}=this,{chunk:n,textHandler:r}=this;scanLoop:for(;;)switch(this.getCode()){case Be:if(this.state=N,r!==void 0){let{text:t}=this,i=n.slice(e,this.prevI);t.length===0?i.length!==0&&r(i):(r(t+i),this.text=``)}t=rt;break scanLoop;case Ie:this.state=te,this.entityReturnState=M,r!==void 0&&(this.text+=n.slice(e,this.prevI)),t=rt;break scanLoop;case I:switch(t){case rt:t=it;break;case it:t=at;break;case at:break;default:throw Error(`impossible state`)}break;case He:t===at&&this.fail(`the string "]]>" is disallowed in char data.`),t=rt;break;case y:r!==void 0&&(this.text+=`${n.slice(e,this.prevI)}\n`),e=this.i,t=rt;break;case v:r!==void 0&&(this.text+=n.slice(e));break scanLoop;default:t=rt}this.forbiddenState=t}handleTextOutsideRoot(){let{i:e}=this,{chunk:t,textHandler:n}=this,r=!1;outRootLoop:for(;;){let a=this.getCode();switch(a){case Be:if(this.state=N,n!==void 0){let{text:r}=this,i=t.slice(e,this.prevI);r.length===0?i.length!==0&&n(i):(n(r+i),this.text=``)}break outRootLoop;case Ie:this.state=te,this.entityReturnState=M,n!==void 0&&(this.text+=t.slice(e,this.prevI)),r=!0;break outRootLoop;case y:n!==void 0&&(this.text+=`${t.slice(e,this.prevI)}\n`),e=this.i;break;case v:n!==void 0&&(this.text+=t.slice(e));break outRootLoop;default:i(a)||(r=!0)}}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}pushAttribNS(e,t){var n;let{prefix:r,local:i}=this.qname(e),a={name:e,prefix:r,local:i,value:t};if(this.attribList.push(a),(n=this.attributeHandler)==null||n.call(this,a),r===`xmlns`){let e=t.trim();this.currentXMLVersion===`1.0`&&e===``&&this.fail(`invalid attempt to undefine prefix in XML 1.0`),this.topNS[i]=e,$e(this,i,e)}else if(e===`xmlns`){let e=t.trim();this.topNS[``]=e,$e(this,``,e)}}pushAttribPlain(e,t){var n;let r={name:e,value:t};this.attribList.push(r),(n=this.attributeHandler)==null||n.call(this,r)}end(){var e,t;this.sawRoot||this.fail(`document must contain a root element.`);let{tags:n}=this;for(;n.length>0;){let e=n.pop();this.fail(`unclosed tag: ${e.name}`)}this.state!==b&&this.state!==M&&this.fail(`unexpected end.`);let{text:r}=this;return r.length!==0&&((e=this.textHandler)==null||e.call(this,r),this.text=``),this._closed=!0,(t=this.endHandler)==null||t.call(this),this._init(),this}resolve(e){var t;let n=this.topNS[e];if(n!==void 0)return n;let{tags:r}=this;for(let t=r.length-1;t>=0;t--)if(n=r[t].ns[e],n!==void 0)return n;return n=this.ns[e],n===void 0?(t=this.opt).resolvePrefix?.call(t,e):n}qname(e){let t=e.indexOf(`:`);if(t===-1)return{prefix:``,local:e};let n=e.slice(t+1),r=e.slice(0,t);return(r===``||n===``||n.includes(`:`))&&this.fail(`malformed name: ${e}.`),{prefix:r,local:n}}processAttribsNS(){let{attribList:e}=this,t=this.tag;{let{prefix:e,local:n}=this.qname(t.name);t.prefix=e,t.local=n;let r=t.uri=this.resolve(e)??``;e!==``&&(e===`xmlns`&&this.fail(`tags may not have "xmlns" as prefix.`),r===``&&(this.fail(`unbound namespace prefix: ${JSON.stringify(e)}.`),t.uri=e))}if(e.length===0)return;let{attributes:n}=t,r=new Set;for(let t of e){let{name:e,prefix:i,local:a}=t,o,s;i===``?(o=e===`xmlns`?h:``,s=e):(o=this.resolve(i),o===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(i)}.`),o=i),s=`{${o}}${a}`),r.has(s)&&this.fail(`duplicate attribute: ${s}.`),r.add(s),t.uri=o,n[e]=t}this.attribList=[]}processAttribsPlain(){let{attribList:e}=this,t=this.tag.attributes;for(let{name:n,value:r}of e)t[n]!==void 0&&this.fail(`duplicate attribute: ${n}.`),t[n]=r;this.attribList=[]}openTag(){var e;this.processAttribs();let{tags:t}=this,n=this.tag;n.isSelfClosing=!1,(e=this.openTagHandler)==null||e.call(this,n),t.push(n),this.state=M,this.name=``}openSelfClosingTag(){var e,t;this.processAttribs();let{tags:n}=this,r=this.tag;r.isSelfClosing=!0,(e=this.openTagHandler)==null||e.call(this,r),(t=this.closeTagHandler)==null||t.call(this,r),(this.tag=n[n.length-1]??null)===null&&(this.closedRoot=!0),this.state=M,this.name=``}closeTag(){let{tags:e,name:t}=this;if(this.state=M,this.name=``,t===``){this.fail(`weird empty close tag.`),this.text+=`</>`;return}let n=this.closeTagHandler,r=e.length;for(;r-->0;){let r=this.tag=e.pop();if(this.topNS=r.ns,n?.(r),r.name===t)break;this.fail(`unexpected close tag.`)}r===0?this.closedRoot=!0:r<0&&(this.fail(`unmatched closing tag: ${t}.`),this.text+=`</${t}>`)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(this.isName(e)?`undefined entity.`:`disallowed character in entity name.`),`&${e};`):t}let t=NaN;return e[1]===`x`&&/^#x[0-9a-f]+$/i.test(e)?t=parseInt(e.slice(2),16):/^#[0-9]+$/.test(e)&&(t=parseInt(e.slice(1),10)),this.isChar(t)?String.fromCodePoint(t):(this.fail(`malformed character entity.`),`&${e};`)}}}))(),mu=new Set(`math.semantics.annotation.mrow.mi.mn.mo.mtext.mspace.mstyle.msub.msup.msubsup.munder.mover.munderover.mfrac.msqrt.mroot.mtable.mtr.mtd.mlabeledtr.menclose.mpadded.mphantom.mmultiscripts.mprescripts.none`.split(`.`)),hu=new Set(`xmlns.display.encoding.mathvariant.displaystyle.scriptlevel.fence.separator.form.stretchy.symmetric.maxsize.minsize.largeop.movablelimits.lspace.rspace.accent.accentunder.linethickness.height.width.depth.voffset.notation.columnalign.columnlines.columnspacing.columnspan.rowalign.rowlines.rowspacing.rowspan`.split(`.`)),gu=new Set([`box`,`top`,`right`,`bottom`,`left`,`updiagonalstrike`,`downdiagonalstrike`,`horizontalstrike`]),_u={bold:[119808,119834,120782],italic:[119860,119886],"bold-italic":[119912,119938],script:[119964,119990],"bold-script":[120016,120042],fraktur:[120068,120094],"double-struck":[120120,120146,120792],"bold-fraktur":[120172,120198],"sans-serif":[120224,120250,120802],"bold-sans-serif":[120276,120302,120812],"sans-serif-italic":[120328,120354],"sans-serif-bold-italic":[120380,120406],monospace:[120432,120458,120822]},vu={italic:{h:`ℎ`},script:{B:`ℬ`,E:`ℰ`,F:`ℱ`,H:`ℋ`,I:`ℐ`,L:`ℒ`,M:`ℳ`,R:`ℛ`,e:`ℯ`,g:`ℊ`,o:`ℴ`},fraktur:{C:`ℭ`,H:`ℌ`,I:`ℑ`,R:`ℜ`,Z:`ℨ`},"double-struck":{C:`ℂ`,H:`ℍ`,N:`ℕ`,P:`ℙ`,Q:`ℚ`,R:`ℝ`,Z:`ℤ`}},yu=`ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡϴΣΤΥΦΧΨΩ∇αβγδεζηθικλμνξοπρςστυφχψω∂ϵϑϰϕϱϖ`,bu={bold:120488,italic:120546,"bold-italic":120604,"bold-sans-serif":120662,"sans-serif-bold-italic":120720};function xu(e,t){let n=_u[t];if(!n)return e;let[r,i,a]=n,o=bu[t];return e.replace(/[A-Za-z0-9\p{Script=Greek}∂∇]/gu,e=>{let n=vu[t]?.[e];if(n)return n;if(e.length!==1||e.charCodeAt(0)>127){let t=yu.indexOf(e);return o&&t>=0?String.fromCodePoint(o+t):e}let s=e.charCodeAt(0);return s>=97?String.fromCodePoint(i+s-97):s>=65?String.fromCodePoint(r+s-65):a?String.fromCodePoint(a+s-48):e})}function Su(e,t){let n=lu.renderToString(e,{output:`mathml`,displayMode:t,throwOnError:!0,strict:`ignore`,maxSize:24,maxExpand:1e3,trust:()=>{throw Error(`TeX command requires trust`)}}),r=[],i=null,a=new pu.SaxesParser;return a.on(`opentag`,({name:e,attributes:t})=>{if(e===`span`&&!r.length)return;if(!mu.has(e))throw Error(`Unexpected MathML element`);let n=Object.fromEntries(Object.entries(t).filter(([e])=>hu.has(e)));if(e===`mtd`&&!t.class){let e=r.at(-1),t=r.at(-2)?.props.columnalign?.split(/\s+/)[e.columns++];(t===`left`||t===`right`)&&(n[`data-md-math-align`]=t)}r.push({props:n,children:[],columns:0})}),a.on(`text`,e=>r.at(-1)?.children.push(e)),a.on(`closetag`,({name:e})=>{if(e===`span`&&!r.length)return;let{props:t,children:n}=r.pop();if(t.mathvariant){let e=t.mathvariant;for(let t=0;t<n.length;t+=1){let r=n[t];typeof r==`string`&&(n[t]=xu(r,e))}}let a=r.at(-1),o=e===`menclose`&&t.notation?.split(/\s+/).every(e=>gu.has(e)),s=(0,u.createElement)(o?`mrow`:e,{...t,...o?{"data-md-math-notation":t.notation}:{},key:a?.children.length},...n);a?a.children.push(s):i=s}),a.write(n).close(),i}function Cu({source:e,display:t,block:n=!1}){let r=(0,u.useMemo)(()=>{try{return Su(e,t)}catch{return null}},[e,t]);return(0,F.jsx)(n?`div`:`span`,{className:t?`md-math md-math-block`:`md-math md-math-inline`,"data-md-math":t?`block`:`inline`,"data-md-math-source":e,children:r??(0,F.jsx)(`span`,{className:`md-m-unsupported`,"data-md-math-unsupported":`1`,title:`这段 LaTeX 无法排版`,children:e})})}var wu=(0,u.createContext)(void 0);function Tu({path:e,label:t}){let n=Rt(e);return n?(0,F.jsx)(`a`,{className:`md-link`,href:n,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}):(0,F.jsx)(`span`,{children:t})}function Eu({path:e,label:t}){let n=(0,u.useContext)(wu),[r,i]=(0,u.useState)(!1);if((0,u.useEffect)(()=>i(!1),[e,n?.workspaceId,n?.conversationId]),!n)return(0,F.jsx)(Tu,{path:e,label:t});let a=ke(Nt(n.workspaceId,n.conversationId,e));return r?(0,F.jsxs)(`span`,{className:`message-media-error`,role:`status`,children:[`图片不可用:`,t||e,` `,(0,F.jsx)(`a`,{href:`${a}&download=1`,download:!0,children:`查看文件`})]}):(0,F.jsx)(`button`,{className:`message-media-image`,type:`button`,"aria-label":`查看图片:${t||e}`,onClick:()=>n.onImageOpen?.({url:a,name:t||e}),children:(0,F.jsx)(`img`,{src:a,alt:t,loading:`lazy`,referrerPolicy:`no-referrer`,onError:()=>i(!0)})})}function Du({path:e,label:t,inline:n=!1}){let r=(0,u.useContext)(wu),[i,a]=(0,u.useState)(`正在加载预览…`),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(0),[d,f]=(0,u.useState)(!1),p=r?ke(Nt(r.workspaceId,r.conversationId,e)):void 0,m=typeof HTMLIFrameElement<`u`&&`csp`in HTMLIFrameElement.prototype;return(0,u.useEffect)(()=>{if(!p||n||!m)return;let e=new AbortController;return s(!1),a(`正在加载预览…`),Ae(`${p}&meta=1`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`文件不可用`);if(t.kind!==`html`)throw Error(`文件类型不是 HTML`);s(!0)}).catch(t=>{e.signal.aborted||a(String(t.message||t))}),()=>e.abort()},[p,n,m,c]),p?n?(0,F.jsx)(`a`,{className:`md-link`,href:`${p}&download=1`,download:!0,children:t||e}):(0,F.jsxs)(`section`,{className:`message-media-html${d?` expanded`:``}`,"aria-label":`HTML 预览:${t||e}`,children:[(0,F.jsxs)(`div`,{className:`message-media-toolbar`,children:[(0,F.jsx)(`span`,{title:e,children:t||e}),(0,F.jsxs)(`div`,{children:[m&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>l(e=>e+1),children:`重新加载`}),(0,F.jsx)(`button`,{type:`button`,"aria-pressed":d,onClick:()=>f(e=>!e),children:d?`收起`:`展开`}),(0,F.jsx)(`button`,{type:`button`,"data-message-html-window":!0,disabled:!o,title:`在独立窗口中打开 HTML 预览`,onClick:()=>window.open(`${p}&frame=1`,`_blank`,`popup,noopener,noreferrer,width=1100,height=800`),children:`独立窗口`})]}),(0,F.jsx)(`a`,{href:`${p}&download=1`,download:!0,children:`下载 HTML`})]})]}),m?o?(0,F.jsx)(`iframe`,{src:`${p}&frame=1&revision=${c}`,title:t||e,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,csp:kt},`${p}:${c}`):(0,F.jsx)(`p`,{role:`status`,children:i}):(0,F.jsx)(`p`,{role:`status`,children:`当前浏览器不支持安全的交互预览,请下载后打开。`})]}):(0,F.jsx)(Tu,{path:e,label:t})}function Ou(e){let t=/^<team-context-data>[\t ]*\r?\n([\s\S]*?)\r?\n<\/team-context-data>[\t ]*(?=\r?\n|$)/gm,n=[],r=0;for(let i of e.matchAll(t)){let t;for(let n of e.slice(0,i.index).split(/\r?\n/)){let e=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec(n);e&&(t?e[1][0]===t.mark&&e[1].length>=t.length&&!e[2].trim()&&(t=void 0):t={mark:e[1][0],length:e[1].length})}if(t||new TextEncoder().encode(i[0]).length>16e3)continue;let a;try{a=JSON.parse(i[1])}catch{continue}if(!a||typeof a!=`object`||Array.isArray(a))continue;let o=a;typeof o.projectId!=`string`||!o.projectId||!Number.isInteger(o.revision)||o.revision<0||!Array.isArray(o.entries)||o.entries.length>32||o.entries.some(e=>!e||typeof e.id!=`string`||typeof e.title!=`string`||typeof e.content!=`string`||!Number.isInteger(e.revision)||e.revision<1||e.evidenceRefs!==void 0&&(!Array.isArray(e.evidenceRefs)||e.evidenceRefs.some(e=>typeof e!=`string`)))||(o.project===void 0||o.project&&typeof o.project==`object`&&(o.project.title===void 0||typeof o.project.title==`string`))&&(o.task===void 0||o.task&&typeof o.task==`object`&&(o.task.title===void 0||typeof o.task.title==`string`))&&(o.handoff===void 0||typeof o.handoff==`string`)&&(o.ownedPaths===void 0||Array.isArray(o.ownedPaths)&&!o.ownedPaths.some(e=>typeof e!=`string`))&&(r<i.index&&n.push({kind:`markdown`,source:e.slice(r,i.index)}),n.push({kind:`handoff`,raw:i[0],packet:o}),r=i.index+i[0].length)}return(r<e.length||!n.length)&&n.push({kind:`markdown`,source:e.slice(r)}),n}var ku={finding:`发现`,decision:`决定`,pitfall:`已排除路线`,hypothesis:`待验证假设`};function Au({packet:e,raw:t}){return(0,F.jsxs)(`details`,{className:`message-team-handoff`,"data-team-handoff-card":e.projectId,children:[(0,F.jsxs)(`summary`,{children:[(0,F.jsx)(`strong`,{children:e.project?.title||`项目交接`}),(0,F.jsxs)(`span`,{children:[`共享快照第 `,e.revision,` 版 · `,e.entries.length,` 条记录`]})]}),(0,F.jsxs)(`div`,{className:`message-team-handoff-body`,children:[e.task?.title&&(0,F.jsxs)(`p`,{children:[`任务:`,e.task.title]}),e.handoff&&(0,F.jsx)(`p`,{children:e.handoff}),e.ownedPaths?.length?(0,F.jsxs)(`p`,{children:[e.readOnly?`只读范围`:`写入范围`,`:`,e.ownedPaths.join(`、`)]}):null,e.entries.map(e=>(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`strong`,{children:[e.title,` · 第 `,e.revision,` 版`]}),(0,F.jsx)(`span`,{className:`message-team-handoff-kind`,children:ku[e.kind]??`记录`}),(0,F.jsx)(`p`,{children:e.content}),e.evidenceRefs?.length?(0,F.jsx)(`ul`,{children:e.evidenceRefs.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.jsx)(`code`,{children:e})},t))}):null]},e.id)),!e.entries.length&&(0,F.jsx)(`p`,{children:`此次没有相关共享条目,任务要求保留在派发说明中。`}),typeof e.omitted==`number`&&e.omitted>0?(0,F.jsxs)(`p`,{children:[`另有 `,e.omitted,` 条未自动带入,完整记录保存在项目中。`]}):null,(0,F.jsxs)(`details`,{className:`message-team-handoff-raw`,children:[(0,F.jsx)(`summary`,{children:`查看原始快照`}),(0,F.jsx)(`pre`,{"data-team-handoff-raw":!0,children:t})]})]})]})}async function ju(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let t=document.activeElement,n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.cssText=`position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:0;opacity:0;pointer-events:none`,document.body.appendChild(n);try{return n.focus({preventScroll:!0}),n.select(),n.setSelectionRange(0,n.value.length),document.execCommand(`copy`)}catch{return!1}finally{n.remove(),t?.isConnected&&t.focus({preventScroll:!0})}}var Mu=`super-pi:markdown-syntax:v1`,Nu=Object.freeze({italic:!0,bold:!0,strikethrough:!0});function Pu(e){let t=e&&typeof e==`object`?e:{};return Object.fromEntries(Object.entries(Nu).map(([e,n])=>[e,typeof t[e]==`boolean`?t[e]:n]))}var Fu=Nu,Iu,Lu=!1,Ru=new Set;function zu(){if(typeof window>`u`||Lu)return Fu;try{let e=window.localStorage.getItem(Mu);if(e!==Iu){Iu=e;try{Fu=Pu(e?JSON.parse(e):void 0)}catch{Fu=Nu}}}catch{}return Fu}function Bu(e){Fu=Pu({...zu(),...e});let t=JSON.stringify(Fu);try{window.localStorage.setItem(Mu,t),Iu=t,Lu=!1}catch{Lu=!0}for(let e of Ru)e()}var Vu=e=>{if(e.key===`super-pi:markdown-syntax:v1`||e.key===null){Iu=void 0,Lu=!1,zu();for(let e of Ru)e()}},Hu=e=>(Ru.size||window.addEventListener(`storage`,Vu),Ru.add(e),()=>{Ru.delete(e),Ru.size||window.removeEventListener(`storage`,Vu)}),Uu=()=>(0,u.useSyncExternalStore)(Hu,zu,()=>Nu);function Wu({source:e,media:t,handoffs:n=!0}){let r=Uu(),i=(0,u.useMemo)(()=>un(e,r),[e,r]),a=(0,u.useMemo)(()=>n?Ou(e):[],[e,n]);return a.some(e=>e.kind===`handoff`)?(0,F.jsx)(wu.Provider,{value:t,children:(0,F.jsx)(`div`,{className:`md`,"data-md":`1`,children:a.map((e,n)=>e.kind===`handoff`?(0,F.jsx)(Au,{packet:e.packet,raw:e.raw},`handoff:${n}`):(0,F.jsx)(Wu,{source:e.source,media:t,handoffs:!1},`text:${n}`))})}):(0,F.jsx)(wu.Provider,{value:t,children:(0,F.jsx)(`div`,{className:`md`,"data-md":`1`,children:i.map((e,t)=>Ju(e,t))})})}function Gu({source:e}){let t=Uu(),n=(0,u.useMemo)(()=>Qt(e,t),[e,t]);return(0,F.jsx)(`span`,{className:`md md-inline`,children:n.map((e,t)=>Xu(e,t))})}function Ku(e){return Pt(e).map((e,t)=>e.kind===`plain`?(0,F.jsx)(`span`,{children:e.text},t):(0,F.jsx)(`span`,{className:`code-token-${e.kind}`,children:e.text},t))}function qu({value:e,lang:t}){let[n,r]=(0,u.useState)(`idle`),i=(0,u.useRef)(0),a=(0,u.useRef)(void 0),o=(0,u.useMemo)(()=>Ku(e),[e]);(0,u.useEffect)(()=>(i.current++,r(`idle`),()=>{i.current++,window.clearTimeout(a.current)}),[e]);let s=async()=>{let t=++i.current,n=await ju(e);i.current===t&&(window.clearTimeout(a.current),r(n?`copied`:`failed`),a.current=window.setTimeout(()=>r(`idle`),2e3))};return(0,F.jsxs)(`div`,{className:`md-code-block`,"data-code-block":!0,children:[(0,F.jsxs)(`div`,{className:`md-code-toolbar`,children:[(0,F.jsx)(`span`,{className:`md-code-language`,title:t,children:t||`代码`}),(0,F.jsxs)(`button`,{type:`button`,"data-code-copy":!0,disabled:!e,"aria-label":t?`复制 ${t} 代码`:`复制代码`,onClick:()=>void s(),children:[(0,F.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,"aria-hidden":`true`,children:[(0,F.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`13`,rx:`2`}),(0,F.jsx)(`path`,{d:`M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3`})]}),(0,F.jsx)(`span`,{"aria-live":`polite`,children:n===`copied`?`已复制`:n===`failed`?`复制失败`:`复制`})]})]}),(0,F.jsx)(`pre`,{className:`md-pre`,"data-md-lang":t||void 0,children:(0,F.jsx)(`code`,{className:`md-code`,children:o})})]})}function Ju(e,t){switch(e.type){case`paragraph`:return e.children.length===1&&e.children[0].type===`artifact`&&e.children[0].kind===`html`?(0,F.jsx)(Du,{path:e.children[0].path,label:e.children[0].label},t):(0,F.jsx)(`p`,{className:`md-p`,children:e.children.map((e,t)=>Xu(e,t))},t);case`heading`:{let n=`h${Math.min(6,Math.max(1,e.level))}`;return(0,F.jsx)(n,{className:`md-h md-h${e.level}`,children:e.children.map((e,t)=>Xu(e,t))},t)}case`code-block`:return(0,F.jsx)(qu,{value:e.value,lang:e.lang},t);case`list`:{let n=e.items.map((e,t)=>(0,F.jsx)(`li`,{className:`md-li`,children:e.map((e,t)=>Ju(e,t))},t));return e.ordered?(0,F.jsx)(`ol`,{className:`md-ol`,start:e.start>1?e.start:void 0,children:n},t):(0,F.jsx)(`ul`,{className:`md-ul`,children:n},t)}case`blockquote`:return(0,F.jsx)(`blockquote`,{className:`md-quote`,children:e.children.map((e,t)=>Ju(e,t))},t);case`rule`:return(0,F.jsx)(`hr`,{className:`md-rule`},t);case`table`:return(0,F.jsx)(`div`,{className:`md-table-wrap`,children:(0,F.jsxs)(`table`,{className:`md-table`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsx)(`tr`,{children:e.head.map((t,n)=>(0,F.jsx)(`th`,{style:Yu(e.align[n]),children:t.map((e,t)=>Xu(e,t))},n))})}),(0,F.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,F.jsx)(`tr`,{children:t.map((t,n)=>(0,F.jsx)(`td`,{style:Yu(e.align[n]),children:t.map((e,t)=>Xu(e,t))},n))},n))})]})},t);case`math-block`:return(0,F.jsx)(Cu,{source:e.source,display:!0,block:!0},t);default:return null}}var Yu=e=>e?{textAlign:e}:void 0;function Xu(e,t){switch(e.type){case`text`:return(0,F.jsx)(u.Fragment,{children:e.value},t);case`code`:return(0,F.jsx)(`code`,{className:`md-code-inline`,children:e.value},t);case`strong`:return(0,F.jsx)(`strong`,{className:`md-strong`,children:e.children.map((e,t)=>Xu(e,t))},t);case`em`:return(0,F.jsx)(`em`,{className:`md-em`,children:e.children.map((e,t)=>Xu(e,t))},t);case`del`:return(0,F.jsx)(`del`,{className:`md-del`,children:e.children.map((e,t)=>Xu(e,t))},t);case`break`:return(0,F.jsx)(`br`,{className:`md-break`},t);case`math`:return(0,F.jsx)(Cu,{source:e.source,display:e.display},t);case`artifact`:return e.kind===`image`?(0,F.jsx)(Eu,{path:e.path,label:e.label},t):(0,F.jsx)(Du,{path:e.path,label:e.label,inline:!0},t);case`link`:{let n=Rt(e.href);return n?(0,F.jsx)(`a`,{className:`md-link`,href:n,title:e.title,target:`_blank`,rel:`noopener noreferrer nofollow`,children:e.children.map((e,t)=>Xu(e,t))},t):(0,F.jsx)(u.Fragment,{children:e.children.map((e,t)=>Xu(e,t))},t)}default:return null}}var Zu=[[`help`,`Show help`],[`model`,`Choose model`],[`settings`,`Open settings`],[`clear`,`Clear session`],[`compact`,`Compact context`],[`reload`,`Reload agents`],[`new`,`New session`],[`fork`,`Fork session`],[`resume`,`Resume session`],[`stop`,`Stop run`],[`skill`,`Workspace skill`]].map(([e,t])=>({id:e,label:t,description:t,scope:`builtin`})),Qu=e=>e.normalize(`NFKD`).replace(/\p{M}/gu,``).toLowerCase();function $u(e,t){let n=Qu(t.trim());return e.examples?.find(t=>Qu(t).includes(n)&&t!==e.id)??e.id}function ed(e,t){let n=Qu(t.trim());return n?e.filter(e=>Qu(e.id).includes(n)||Qu(e.label).includes(n)||Qu(e.description).includes(n)||e.examples?.some(e=>Qu(e).includes(n))):e}function td(e,t){let n=t.startsWith(`skill:`)?`/${t}`:`/skill:${t}`;return e.split(/\s+/).includes(n)}function nd({query:e,anchorRect:t,command:n,workspaceId:r,promptCatalog:i,onSelect:a,onClose:o}){let[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(Zu),f=(0,u.useRef)(null),p=(0,u.useRef)([]);(0,u.useEffect)(()=>{r&&n({type:`prompt.catalog.fetch`,workspaceId:r})},[r,n]),(0,u.useEffect)(()=>{let e=!1;return Ae(r?`/api/skills?workspaceId=${encodeURIComponent(r)}`:`/api/skills`).then(e=>e.ok?e.json():void 0).then(t=>{if(e||!Array.isArray(t?.skills))return;let n=t.skills.map(e=>{let t=e.id?.startsWith(`skill:`)?e.id:`skill:${e.name}`,n=e.description?.trim()||(e.scope===`workspace`?`工作区技能`:`技能`);return{id:t,label:n,description:n,examples:[t]}});d([...Zu.filter(e=>e.id!==`skill`),...n])}).catch(()=>{}),()=>{e=!0}},[r]);let m=[{id:`start`,label:`start — 打开浏览器`,description:`在浏览器中打开 Super Pi 控制台`,action:()=>n({type:`super_pi.start`})},{id:`restart`,label:`restart — 重启 Super Pi 服务`,description:`停掉并重新启动服务,加载磁盘上的新代码`,action:()=>n({type:`super_pi.restart`})},{id:`update`,label:`update — 更新 Super Pi`,description:`运行 npm install -g @evandu/super-pi 然后重启`,action:()=>n({type:`super_pi.update`})}],h=(i&&i.workspaceId===r?i.prompts:[]).map(e=>({id:e.name,label:e.description,description:e.description,argumentHint:e.argumentHint,scope:e.scope,shadowed:[...m,...l].some(t=>t.id===e.name)})),g=ed([...m,...l,...h],e),_=g.length===0?-1:Math.min(Math.max(s,0),g.length-1),v=e=>c(t=>g.length?Math.min(Math.max(t+e,0),g.length-1):0);(0,u.useEffect)(()=>{let e=e=>{f.current?.contains(e.target)||o()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[o]),(0,u.useEffect)(()=>{c(0)},[e]),(0,u.useLayoutEffect)(()=>{_>=0&&p.current[_]?.scrollIntoView({block:`nearest`})},[_]);let y={position:`fixed`,left:Math.max(8,Math.min(t.left,window.innerWidth-360)),bottom:Math.max(8,window.innerHeight-t.top+6),zIndex:200},b=e=>{if(e.key===`Escape`)e.preventDefault(),o();else if(e.key===`ArrowDown`)e.preventDefault(),v(1);else if(e.key===`ArrowUp`)e.preventDefault(),v(-1);else if(e.key===`Home`)e.preventDefault(),c(0);else if(e.key===`End`)e.preventDefault(),c(g.length-1);else if(e.key===`Enter`){e.preventDefault();let t=g[_];if(!t)return;t.action?(t.action(),o()):a(t)}};return(0,u.useEffect)(()=>(window.addEventListener(`keydown`,b),()=>window.removeEventListener(`keydown`,b))),(0,F.jsx)(`div`,{ref:f,className:`slash-menu`,style:y,role:`listbox`,"aria-label":`斜杠命令`,children:g.length===0?(0,F.jsxs)(`div`,{className:`slash-menu-empty`,children:[`没有匹配「`,e,`」的命令`]}):g.map((e,t)=>(0,F.jsxs)(`button`,{ref:e=>{p.current[t]=e},type:`button`,role:`option`,"aria-selected":t===_,className:`slash-menu-item${t===_?` selected`:``}`,"data-slash-command":e.id,onClick:()=>{e.action?(e.action(),o()):a(e)},onMouseEnter:()=>c(t),children:[(0,F.jsxs)(`span`,{className:`slash-menu-item-id`,children:[`/`,e.id,e.argumentHint?` `+e.argumentHint:``]}),(0,F.jsx)(`span`,{className:`slash-menu-item-sep`,"aria-hidden":`true`,children:` — `}),(0,F.jsx)(`span`,{className:`slash-menu-item-label`,children:e.label}),(0,F.jsx)(`span`,{className:`slash-menu-item-scope`,"data-slash-command-scope":e.scope??`builtin`,children:e.shadowed?`Built-in command wins`:e.scope===`project`?`Project prompt`:e.scope===`user`?`User prompt`:`Pi built-in`}),e.examples?.length?(0,F.jsx)(`span`,{className:`slash-menu-item-examples`,children:e.examples.slice(0,2).join(` · `)}):null]},e.id))})}var rd=(0,u.forwardRef)(function({workspaceId:e,cwd:t,query:n,anchor:r,onChoose:i,onClose:a,onActive:o},s){let c=JSON.stringify([e,t,n]),[l,d]=(0,u.useState)(),f=l?.key===c?l:void 0,[p,m]=(0,u.useState)(0),h=(0,u.useRef)(null),g=(0,u.useRef)(null);(0,u.useEffect)(()=>{let r=new AbortController;d(void 0),m(0);let i,a=()=>{Ae(`/api/files/mentions?${new URLSearchParams({workspaceId:e,cwd:t,q:n})}`,{signal:r.signal}).then(async e=>{if(!e.ok)throw Error(`文件搜索失败,请稍后重试`);return e.json()}).then(e=>{r.signal.aborted||(d({...e,key:c}),e.indexed||(i=window.setTimeout(a,700)))}).catch(()=>{r.signal.aborted||d({key:c,hits:[],indexed:!1,incomplete:!1,error:`文件搜索失败,请稍后重试`})})};return i=window.setTimeout(a,100),()=>{clearTimeout(i),r.abort()}},[e,t,n,c]);let _=f?.hits??[];(0,u.useEffect)(()=>{o(_[p]?`file-mention-option-${p}`:void 0)},[f,p,o]),(0,u.useImperativeHandle)(s,()=>({handleKey:e=>e.nativeEvent.isComposing||e.keyCode===229||![`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)?!1:(e.preventDefault(),e.stopPropagation(),e.key===`Escape`?a():e.key===`ArrowDown`?m(e=>Math.min(e+1,Math.max(0,_.length-1))):e.key===`ArrowUp`?m(e=>Math.max(0,e-1)):_[p]&&i(_[p]),!0)})),(0,u.useLayoutEffect)(()=>{g.current?.scrollIntoView({block:`nearest`})},[p,f]),(0,u.useEffect)(()=>{let e=e=>{!h.current?.contains(e.target)&&e.target.tagName!==`TEXTAREA`&&a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]);let v=r.top-12,y=window.innerHeight-r.bottom-12,b=v>=Math.min(200,y),x=Math.min(460,window.innerWidth-16),S={position:`fixed`,zIndex:200,width:x,left:Math.max(8,Math.min(r.left,window.innerWidth-x-8)),maxHeight:Math.max(40,Math.min(320,b?v:y)),...b?{bottom:window.innerHeight-r.top+6}:{top:r.bottom+6}};return(0,F.jsxs)(`div`,{ref:h,className:`file-mention-menu`,style:S,"data-file-mention-menu":`1`,onMouseDown:e=>e.preventDefault(),children:[(0,F.jsxs)(`div`,{className:`file-mention-heading`,children:[`引用文件或目录 `,(0,F.jsx)(`small`,{children:`↑↓ 选择 · Enter / Tab 插入 · Esc 关闭`})]}),(0,F.jsx)(`div`,{role:`listbox`,id:`file-mention-menu`,"aria-label":`项目文件与目录`,children:_.map((e,t)=>(0,F.jsxs)(`button`,{ref:t===p?g:void 0,type:`button`,role:`option`,id:`file-mention-option-${t}`,"aria-selected":t===p,"data-file-mention-path":e.path,className:t===p?`file-mention-option selected`:`file-mention-option`,onMouseMove:()=>m(t),onClick:()=>i(e),children:[(0,F.jsx)(`span`,{className:`file-mention-kind`,children:e.kind===`directory`?`目录`:`文件`}),(0,F.jsxs)(`span`,{className:`file-mention-path`,children:[e.path===`.`?`当前目录`:e.path,e.kind===`directory`?`/`:``]})]},e.path))}),(!f||!_.length||f.incomplete||!f.indexed)&&(0,F.jsx)(`p`,{className:`file-mention-status`,role:`status`,children:f?f.error??(_.length?`索引尚不完整,当前显示已找到的结果`:f.indexed?`没有匹配的文件或目录`:`正在建立文件索引…`):`搜索中…`})]})});function id(e,t,n=t){if(t!==n||t<0||t>e.length)return;let r=/(?:^|[\s([{])@(?:"([^"\n]*)|([^\s@"\n]*))$/u.exec(e.slice(0,t));if(!r)return;let i=r.index+r[0].indexOf(`@`),a=e.slice(t);return{start:i,end:t+((r[1]===void 0?/^[^\s@"\n]*/u.exec(a)?.[0]:/^[^"\n]*(?:"|$)/u.exec(a)?.[0])?.length??0),query:r[1]??r[2]??``}}function ad(e,t,n){let r=n.path+(n.kind===`directory`&&!n.path.endsWith(`/`)?`/`:``),i=`@`+(/^[^\s@"\\]+$/u.test(r)?r:JSON.stringify(r))+` `;return{text:e.slice(0,t.start)+i+e.slice(t.end),caret:t.start+i.length}}var od={file:`M8 3h6l4 4v13H6V3h2m6 0v5h4M9 13h6m-3-3v6`,folder:`M3 7V5h7l2 2h9v12H3V7m6 6h6m-3-3v6`,refresh:`M19 9a7 7 0 0 0-12-3L4 9m0-5v5h5m-4 6a7 7 0 0 0 12 3l3-3m0 5v-5h-5`,collapse:`M8 5h12v12M4 9h12v12H4zm3 6h6`,locate:`M12 2v4m0 12v4M2 12h4m12 0h4M7 12a5 5 0 1 0 10 0 5 5 0 1 0-10 0`,upload:`M12 15V4m-4 4 4-4 4 4M4 14v5h16v-5`,download:`M12 4v11m-4-4 4 4 4-4M4 15v5h16v-5`,more:`M5 12h.01M12 12h.01M19 12h.01`,search:`M11 5a6 6 0 1 0 0 12 6 6 0 1 0 0-12m4.5 10.5L20 20`,right:`m9 6 6 6-6 6`,down:`m6 9 6 6 6-6`,close:`m6 6 12 12M18 6 6 18`,trash:`M4 6h16M9 6V3h6v3m3 0-1 14H7L6 6m4 4v6m4-6v6`,copy:`M8 8h12v12H8zm8-4H4v12`,reference:`M15 12a3 3 0 1 0-6 0 3 3 0 0 0 6 0m0-3v5c0 2 5 3 5-2a8 8 0 1 0-3 6`,rename:`M4 7h6m4 0h6v10h-6m-4 0H4zm8-11v12m-2-12h4m-4 12h4`,move:`M3 7V5h7l2 2h9v12H3zm6 6h6m-3-3 3 3-3 3`,changes:`M7 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 0v10m0 4a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm10-12a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 0c0 5-5 5-10 5`,save:`M4 4h13l3 3v13H4zm4 0v6h8V4M8 20v-6h8v6`};function sd({name:e}){return(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:e===`more`?3.3:1.65,strokeLinecap:`round`,strokeLinejoin:`round`,className:`explorer-glyph`,"aria-hidden":`true`,children:(0,F.jsx)(`path`,{d:od[e]})})}function cd(e){let t=e.getBoundingClientRect();return{x:t.right,y:t.bottom+4,origin:e,alignEnd:!0,initialFocus:!0}}function ld({label:e,anchor:t,close:n,children:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(n);a.current=n;let[o,s]=(0,u.useState)({left:t.x,top:t.y});return(0,u.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let n=e.getBoundingClientRect();s({left:Math.max(6,Math.min(t.alignEnd?t.x-n.width:t.x,window.innerWidth-n.width-6)),top:Math.max(6,Math.min(t.y,window.innerHeight-n.height-6))}),t.initialFocus?e.querySelector(`[role="menuitem"]`)?.focus({preventScroll:!0}):e.focus({preventScroll:!0});let r=n=>{let r=n.target;!e.contains(r)&&!t.origin.contains(r)&&a.current(!1)},o=()=>a.current(!1),c=n=>{let r=n.target;r instanceof Element&&!e.contains(r)&&r.contains(t.origin)&&a.current(!1)};return window.addEventListener(`pointerdown`,r,!0),window.addEventListener(`resize`,o),window.addEventListener(`scroll`,c,!0),()=>{window.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`resize`,o),window.removeEventListener(`scroll`,c,!0)}},[t]),(0,We.createPortal)((0,F.jsx)(`div`,{className:`file-context-menu`,"data-file-context-menu":`1`,ref:i,style:o,role:`menu`,"aria-label":e,tabIndex:-1,onContextMenu:e=>e.preventDefault(),onKeyDown:e=>{if(e.key===`Escape`||e.key===`Tab`){e.preventDefault(),e.stopPropagation(),n(!0);return}let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],r=t.indexOf(document.activeElement),i=t.length;i&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&(e.preventDefault(),t[e.key===`Home`?0:e.key===`End`?i-1:e.key===`ArrowDown`?(r+1)%i:r<=0?i-1:r-1]?.focus())},children:r}),document.body)}function ud({root:e,path:t,reveal:n}){let r=t.split(`/`),i=r.at(-1)??t,a=r.slice(0,-1);return(0,F.jsxs)(`nav`,{className:`file-breadcrumbs`,"aria-label":`文件路径`,title:t,children:[(0,F.jsxs)(`button`,{className:`file-crumb file-crumb-root`,type:`button`,onClick:()=>n(``,!0),title:`定位 ${e}`,children:[(0,F.jsx)(ht,{category:`folder`}),(0,F.jsx)(`span`,{children:e})]}),a.map((e,t)=>{let r=a.slice(0,t+1).join(`/`);return(0,F.jsxs)(`span`,{className:`file-crumb-step`,children:[(0,F.jsx)(sd,{name:`right`}),(0,F.jsx)(`button`,{className:`file-crumb`,type:`button`,title:`定位 ${r}`,"data-file-crumb":r,onClick:()=>n(r,!0),children:e})]},r)}),(0,F.jsxs)(`span`,{className:`file-crumb-step file-crumb-leaf`,children:[(0,F.jsx)(sd,{name:`right`}),(0,F.jsxs)(`button`,{className:`file-crumb`,type:`button`,"aria-current":`location`,"data-file-crumb":t,onClick:()=>n(t,!1),title:`定位 ${t}`,children:[(0,F.jsx)(ht,{path:t}),(0,F.jsx)(`span`,{children:i})]})]})]})}function dd(e,t,n,r,i={}){return ke(`/api/files/${e}?${new URLSearchParams({workspaceId:t,cwd:n,path:r,...i})}`)}function fd(e,t,n,r,i={}){return ke(`/api/files/open-${e}?${new URLSearchParams({workspaceId:t,cwd:n,ticket:r,...i})}`)}function pd(e,t){let n=[],r=[],i=``,a=!1,o=!1;for(let s=0;s<e.length;s+=1){let c=e[s];if(c===`"`&&(a||!i))a&&e[s+1]===`"`?(i+=`"`,s+=1):a=!a;else if(!a&&(c===t||c===`
|
|
283
|
+
`||c===`\r`)){if(r.length<50?r.push(i):o=!0,i=``,c!==t&&(n.push(r),r=[],c===`\r`&&e[s+1]===`
|
|
284
|
+
`&&(s+=1),n.length===500&&s<e.length-1))return{rows:n,clipped:!0}}else i+=c}return(i||r.length)&&(r.length<50?r.push(i):o=!0,n.push(r)),{rows:n,clipped:o}}function md({workspaceId:e,cwd:t,path:n,name:r,kind:i,content:a,source:o,version:s,sourceRequest:c,external:l,navigation:d,assetTicket:f,onReload:p}){let[m,h]=(0,u.useState)(c!==void 0),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(!1),b=(r,i)=>f?fd(r,e,t,f,i):dd(r,e,t,n,i),x=b(`asset`,{v:s}),S=b(`asset`,{download:`1`}),C=b(`document`);(0,u.useEffect)(()=>{c!==void 0&&h(!0)},[c]),(0,u.useEffect)(()=>{y(!1)},[x]),(0,u.useEffect)(()=>{if(i!==`document`)return;let e=new AbortController;return Ae(C,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`无法读取文档。`);_(t)}).catch(t=>{e.signal.aborted||_({error:String(t.message??t)})}),()=>e.abort()},[C,i,s]);let w=(0,u.useMemo)(()=>i===`table`&&!m?pd(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,m]);return(0,F.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,"data-file-readonly":f?`1`:void 0,children:[(0,F.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[d,(0,F.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[f&&(0,F.jsx)(`span`,{children:`外部文件 · 只读`}),f&&p&&(0,F.jsx)(`button`,{type:`button`,onClick:p,children:`重新读取`}),o&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),children:m?`查看表格`:f?`查看原文`:`编辑原文`}),(0,F.jsxs)(`a`,{href:S,download:r,children:[(0,F.jsx)(sd,{name:`download`}),`下载`]})]})]}),l&&!m&&(0,F.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),m?o:v?(0,F.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,F.jsxs)(F.Fragment,{children:[i===`download`&&(0,F.jsx)(`p`,{children:`此文件可以下载。`}),i===`image`&&(0,F.jsx)(`img`,{src:x,alt:r,onError:()=>y(!0)}),i===`pdf`&&(0,F.jsx)(`iframe`,{src:x,title:r}),i===`audio`&&(0,F.jsx)(`audio`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`video`&&(0,F.jsx)(`video`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`document`&&(g?.error?(0,F.jsx)(`p`,{role:`alert`,children:g.error}):g?(0,F.jsxs)(F.Fragment,{children:[g.warnings?.map(e=>(0,F.jsx)(`p`,{children:e},e)),(0,F.jsx)(`pre`,{children:g.text||`此文档没有可显示的文字。`})]}):(0,F.jsx)(`p`,{children:`正在读取文档…`})),w&&(w.rows.length?(0,F.jsx)(`div`,{className:`workspace-file-table`,children:(0,F.jsx)(`table`,{children:(0,F.jsx)(`tbody`,{children:w.rows.map((e,t)=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,F.jsx)(`td`,{children:e},t))]},t))})})}):(0,F.jsx)(`p`,{children:`文件为空。`})),w?.clipped&&(0,F.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var hd={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,pdf:`application/pdf`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,webm:`video/webm`,ogv:`video/ogg`};function gd(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function _d(e){let t=gd(e);return Object.hasOwn(hd,t)?hd[t]:void 0}function vd(e){let t=_d(e);if(t===`application/pdf`)return`pdf`;if(t?.startsWith(`image/`))return`image`;if(t?.startsWith(`audio/`))return`audio`;if(t?.startsWith(`video/`))return`video`;if(/\.(csv|tsv)$/i.test(e))return`table`;if(/\.docx$/i.test(e))return`document`}var yd=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),bd=(e,t)=>!t||e===t||e.startsWith(`${t}/`),xd=e=>e.split(`/`).at(-1)??e;function Sd(e){if(!(e instanceof Element))return;let t=e.closest(`[data-file-dir], [data-file-entry], [data-file-hit]`);if(!t)return;let n=t.dataset.fileDir??t.dataset.fileEntry??t.dataset.fileHit;if(n!==void 0)return{path:n,directory:t.dataset.fileDir!==void 0,linked:t.dataset.linked===`true`||t.dataset.fileOutside!==void 0}}function Cd({title:e,cancel:t,children:n}){let r=(0,u.useRef)(null);return(0,u.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t?.isConnected&&t.focus()}},[]),(0,F.jsx)(`dialog`,{ref:r,className:`file-explorer-dialog`,"aria-label":e,onCancel:e=>{e.preventDefault(),t()},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,F.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,F.jsx)(`h2`,{children:e}),n]})})}function wd({target:e,label:t,initial:n,busy:r,error:i,depth:a,submit:o,close:s}){let c=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=c.current;if(!t)return;t.focus();let r=n.lastIndexOf(`.`);t.setSelectionRange(0,!e.directory&&r>0?r:n.length)},[n,e.directory]),(0,F.jsxs)(`form`,{className:`file-inline-edit`,"data-file-inline-edit":e.path,"aria-label":t,style:{paddingInlineStart:23+a*15},onSubmit:o,onKeyDown:e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},children:[(0,F.jsxs)(`div`,{className:`file-inline-row`,children:[(0,F.jsx)(ht,{path:e.path,category:e.directory?`folder`:void 0}),(0,F.jsx)(`input`,{ref:c,name:`name`,required:!0,defaultValue:n,placeholder:t,"aria-label":t,"aria-invalid":!!i,readOnly:r,autoComplete:`off`,spellCheck:!1}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,F.jsx)(sd,{name:`right`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,F.jsx)(sd,{name:`close`})})]}),i&&(0,F.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function Td({files:e,source:t,scopeName:n}){let[r,i]=(0,u.useState)(yd(t.path)),a=e.listings[r],o=e.loadDirectory;(0,u.useEffect)(()=>{a||o(r)},[r,a,o]);let s=a&&`entries`in a?a.entries.filter(e=>e.kind===`directory`&&!e.symlink&&!(t.directory&&bd(e.path,t.path))):[];return(0,F.jsxs)(`div`,{className:`file-move-picker`,children:[(0,F.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,F.jsxs)(`div`,{className:`file-move-location`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i(yd(r)),children:`↑`}),(0,F.jsx)(`span`,{title:r||n,children:r||n})]}),(0,F.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,F.jsx)(`li`,{children:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,F.jsx)(ht,{category:`folder`}),(0,F.jsx)(`span`,{children:e.name}),(0,F.jsx)(sd,{name:`right`})]})},e.path))}),!s.length&&(0,F.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function Ed({workspaceId:e,scopeName:t,cwd:n,files:r,onOpen:i,onReference:a,onMoved:o,onSearchFolder:s}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(),x=(0,u.useRef)(null),S=(0,u.useRef)(``),C=(0,u.useRef)(void 0),w=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let e={controller:new AbortController};return w.current=e,l(void 0),f(void 0),m(void 0),b(void 0),g(!1),v(``),()=>{e.controller.abort(),w.current===e&&(w.current=void 0)}},[e,n]);let T=(t,r=``,i)=>dd(t,e??``,n,r,i);async function E(e,t){let n=await Ae(e,{...t,signal:w.current?.controller.signal}),r=await n.json();if(!n.ok)throw Error(r.error??`操作失败(${n.status})`);return r}function D(e,t){c?.anchor.origin===t.origin&&c.target.path===e.path?l(void 0):l({target:e,anchor:t})}function O(e){l(void 0),e&&c?.anchor.origin.isConnected&&c.anchor.origin.focus({preventScroll:!0})}function k(e,t,n,i){C.current=i??c?.anchor.origin??(document.activeElement instanceof HTMLElement?document.activeElement:void 0),l(void 0),v(``),f({action:e,target:t,move:n}),e===`create-file`||e===`create-directory`?t.path?r.revealPath(`${t.path}/`):r.setQuery(``):e===`move`&&!n&&r.revealPath(t.path)}function A(){f(void 0);let e=C.current;requestAnimationFrame(()=>{e?.isConnected&&e.offsetParent?e.focus({preventScroll:!0}):d?.target.path&&r.locatePath(d.target.path,d.target.directory)})}async function j(t){let a=w.current;g(!0),v(``);try{let s=await E(T(`tree`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(w.current!==a)return;if(s.previousPath&&s.previousPath!==s.path?(r.movePath(s.previousPath,s.path,s.text),o?.(s.previousPath,s.path)):s.removed||r.revealPath(s.path),r.invalidateTree(e??``,[s.path,...s.previousPath?[s.previousPath]:[]].map(e=>n?`${n}/${e}`:e)),s.removed){for(let e of r.open)bd(e.path,s.path)&&!e.dirty&&r.closeFile(e.path);r.locatePath(yd(s.path),!0)}f(void 0),t.action===`restore`&&m(e=>e?.filter(e=>e.id!==t.id)),t.action===`create-file`&&s.text!==!1&&i({path:s.path,name:xd(s.path),text:!0},!0),t.action!==`restore`&&!s.removed&&r.locatePath(s.path,!!s.directory),r.setNotice(s.removed?`已移到回收站:${s.path}`:t.action===`restore`?`已恢复:${s.path}`:``)}catch(e){if(w.current===a){let t=e instanceof Error?e.message:String(e);v(t),d||r.setNotice(t)}}finally{w.current===a&&g(!1)}}function ee(e){if(e.preventDefault(),!d||h)return;let{action:t,target:n}=d;if((t===`move`||t===`trash`)&&Object.entries(r.saves).some(([e,t])=>bd(e,n.path)&&t.state===`saving`)){v(`文件正在保存,等保存结束后再操作。`);return}if(t===`trash`&&r.open.some(e=>e.dirty&&bd(e.path,n.path))){v(`这里有未保存的草稿,请先保存。`);return}let i=new FormData(e.currentTarget),a=String(i.get(`name`)??xd(n.path));if(t===`move`&&!n.directory&&gd(n.path)!==gd(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){v(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?yd(n.path):n.path));d.move&&o===yd(n.path)?v(`请选择另一个文件夹。`):j({action:t,path:n.path,parent:o,name:a})}async function M(){let e=w.current;l(void 0),v(``);try{let t=await E(T(`tree`));w.current===e&&m(t.entries)}catch(t){w.current===e&&r.setNotice(String(t.message))}}function te(e){S.current=e,O(!0),x.current?.click()}async function N(t,i,a){let o=w.current;if(!e||!o||!i.length||h)return;g(!0),v(``),b(void 0);let s=[],c=[],l=[];try{for(let e of i){if(o!==w.current)return;try{let n=a?.find(t=>t.file===e)?.etag;if(!a){let n=await E(T(`upload-check`,t,{name:e.name}));if(n.exists){!n.replaceable||!n.meta?c.push(`${e.name}:同名目录或链接`):s.push({file:e,etag:n.meta.etag});continue}}let r=await E(T(`upload`,t,{name:e.name}),{method:`POST`,headers:{"content-type":`application/octet-stream`,...n?{"if-match":n}:{}},body:e});l.push(r.path)}catch(t){c.push(`${e.name}:${t.message}`)}}if(w.current!==o)return;l[0]&&r.revealPath(l[0]),l.length&&r.invalidateTree(e,l.map(e=>n?`${n}/${e}`:e)),s.length&&b({parent:t,items:s}),r.setNotice([l.length?`已上传 ${l.length} 个文件`:``,...c].filter(Boolean).join(`。`))}finally{w.current===o&&g(!1)}}function ne(e,t){l(void 0),a?.(e||`.`,t)}function re(e){O(!0),ju(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let ie=d?.action===`create-file`?`新建文件`:d?.action===`create-directory`?`新建文件夹`:d?.action===`trash`?`移到回收站`:d?.move?`移动到文件夹`:`重命名`,ae={path:``,directory:!0},oe=d?.action===`create-file`||d?.action===`create-directory`,se=d?.action===`move`&&!d.move,ce=(e,t,n)=>!d||d.target.path!==e||(t===`child`?!oe:!se)?null:(0,F.jsx)(wd,{target:{...d.target,directory:oe?d.action===`create-directory`:d.target.directory},label:ie,initial:se?xd(e):``,busy:h,error:_,depth:n,submit:ee,close:A},`${d.action}:${e}`),le=(e,t)=>{h||e.linked||e.directory&&bd(t,e.path)||t===yd(e.path)||(Object.entries(r.saves).some(([t,n])=>bd(t,e.path)&&n.state===`saving`)?r.setNotice(`文件正在保存,等保存结束后再移动。`):j({action:`move`,path:e.path,parent:t,name:xd(e.path)}))},ue=(0,F.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>k(`create-file`,ae,!1,e.currentTarget),disabled:!e||h,children:(0,F.jsx)(sd,{name:`file`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>k(`create-directory`,ae,!1,e.currentTarget),disabled:!e||h,children:(0,F.jsx)(sd,{name:`folder`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,F.jsx)(sd,{name:`refresh`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-collapse-all":`1`,title:`折叠所有文件夹`,"aria-label":`折叠所有文件夹`,onClick:r.collapseDirectories,disabled:!r.expanded.size,children:(0,F.jsx)(sd,{name:`collapse`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":c?.target.path===``,onClick:e=>D(ae,cd(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||h,children:(0,F.jsx)(sd,{name:`more`})})]}),de=(e,t,n,r,i)=>(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,F.jsx)(sd,{name:t}),(0,F.jsx)(`span`,{children:e}),i&&(0,F.jsx)(`kbd`,{children:i})]});return{controls:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,N(S.current,t)}}),c&&(0,F.jsxs)(ld,{label:c.target.path||t,anchor:c.anchor,close:O,children:[c.target.directory&&!c.target.linked&&(0,F.jsxs)(F.Fragment,{children:[s&&de(`在此文件夹中搜索`,`search`,()=>{let e=c.target.path;O(!1),s(e)},`search-folder`),de(`新建文件`,`file`,()=>k(`create-file`,c.target),`new-file`),de(`新建文件夹`,`folder`,()=>k(`create-directory`,c.target),`new-directory`),de(`上传到此处`,`upload`,()=>te(c.target.path),`upload`),(0,F.jsx)(`div`,{role:`separator`})]}),c.target.path&&!c.target.linked&&(0,F.jsxs)(F.Fragment,{children:[de(`重命名`,`rename`,()=>k(`move`,c.target),`rename`,`F2`),de(`移动到文件夹`,`move`,()=>k(`move`,c.target,!0),`move`),(0,F.jsx)(`div`,{role:`separator`})]}),!c.target.linked&&a&&de(`引用到会话`,`reference`,()=>ne(c.target.path,c.target.directory),`reference`),de(`复制相对路径`,`copy`,()=>re(c.target.path)),!c.target.directory&&!c.target.linked&&(0,F.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:T(`asset`,c.target.path,{download:`1`}),download:xd(c.target.path),onClick:()=>O(!0),children:[(0,F.jsx)(sd,{name:`download`}),(0,F.jsx)(`span`,{children:`下载`})]}),!c.target.path&&de(`打开回收站`,`trash`,()=>void M(),`trash-list`),!!c.target.path&&!c.target.linked&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{role:`separator`}),de(`移到回收站`,`trash`,()=>k(`trash`,c.target),`trash`,`Delete`)]})]}),d&&!oe&&!se&&(0,F.jsx)(Cd,{title:ie,cancel:()=>{h||A()},children:(0,F.jsxs)(`form`,{onSubmit:ee,className:`file-explorer-form`,children:[d.action===`trash`?(0,F.jsxs)(`p`,{children:[`将「`,d.target.path,`」移到回收站?`]}):(0,F.jsx)(Td,{files:r,source:d.target,scopeName:t}),_&&(0,F.jsx)(`p`,{role:`alert`,children:_}),(0,F.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:h,onClick:A,children:`取消`}),(0,F.jsx)(`button`,{type:`submit`,disabled:h,children:d.move?`移动到此处`:ie})]})]})}),p&&(0,F.jsxs)(Cd,{title:`回收站`,cancel:()=>{h||m(void 0)},children:[_&&(0,F.jsx)(`p`,{role:`alert`,children:_}),p.length?(0,F.jsx)(`ul`,{className:`file-explorer-trash`,children:p.map(e=>(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`span`,{children:e.path}),(0,F.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:h,onClick:()=>void j({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,F.jsx)(`p`,{children:`回收站为空。`}),(0,F.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>m(void 0),children:`关闭`})]}),y&&(0,F.jsxs)(Cd,{title:`同名文件`,cancel:()=>b(void 0),children:[(0,F.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,F.jsx)(`ul`,{children:y.items.map(e=>(0,F.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,F.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${y.items.length} 个同名文件。`),b(void 0)},children:`跳过`}),(0,F.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void N(y.parent,y.items.map(e=>e.file),y.items),children:`替换`})]})]})]}),toolbar:ue,inline:ce,editing:oe||se,busy:h,openMenu:D,showAction:k,upload:N,moveTo:le}}var Dd=[{id:`path`,label:`文件名 / 路径`,shortcut:`Ctrl+P`},{id:`content`,label:`文件内容`,shortcut:`Ctrl+Shift+F`},{id:`session`,label:`会话消息`}];function Od({mode:e,query:t,onClose:n,onMode:r,children:i}){return(0,F.jsx)(`div`,{className:`quick-open-backdrop`,...e===`path`?{"data-quick-open":`1`}:e===`content`?{"data-content-search":`1`}:{"data-session-search":`1`},role:`presentation`,onMouseDown:n,children:(0,F.jsxs)(`div`,{className:e===`path`?`quick-open`:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":Dd.find(t=>t.id===e)?.label,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),n())},children:[(0,F.jsx)(`div`,{className:`workbench-search-modes`,role:`group`,"aria-label":`搜索范围`,children:Dd.map(n=>(0,F.jsx)(`button`,{type:`button`,"data-workbench-search-mode":n.id,"aria-pressed":n.id===e,title:n.shortcut,onClick:()=>{n.id!==e&&r(n.id,t)},children:n.label},n.id))}),i]})})}function kd({workspaceId:e,initialQuery:t=``,onClose:n,onMode:r,onOpen:i}){let[a,o]=(0,u.useState)(t),[s,c]=(0,u.useState)(),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(0),[m,h]=(0,u.useState)(!1),g=(0,u.useRef)(null),_=(0,u.useRef)(null);return(0,u.useEffect)(()=>{g.current?.focus()},[]),(0,u.useEffect)(()=>{_.current?.scrollIntoView({block:`nearest`})},[f]),(0,u.useEffect)(()=>{let t=a.trim();if(c(void 0),p(0),d(``),h(!1),!e||!t)return;if(t.length>256){d(`搜索词不能超过 256 个字符。`);return}let n=new AbortController;h(!0);let r=setTimeout(()=>{Ae(`/api/session-search?${new URLSearchParams({workspaceId:e,q:t})}`,{signal:n.signal}).then(async e=>{if(!e.ok)throw Error(`会话搜索没有完成。`);return await e.json()}).then(e=>{n.signal.aborted||c(e)}).catch(e=>{n.signal.aborted||d(ct(e,`会话搜索没有完成。`))}).finally(()=>{n.signal.aborted||h(!1)})},180);return()=>{clearTimeout(r),n.abort()}},[a,e]),(0,F.jsxs)(Od,{mode:`session`,query:a,onMode:r,onClose:n,children:[(0,F.jsx)(`input`,{ref:g,className:`quick-open-input`,"data-session-search-input":!0,value:a,"aria-label":`搜索会话消息`,placeholder:`输入要在会话消息中查找的文字`,onChange:e=>o(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.min(e+1,Math.max(0,(s?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(0,e-1))),e.key===`Enter`)){e.preventDefault();let t=s?.hits[f];t&&i(t)}}}),(0,F.jsx)(`p`,{className:`quick-open-status`,role:`status`,"data-session-search-status":!0,children:l||(m?`搜索中…`:e?s?s.truncated?`显示前 60 条命中`:`${s.hits.length} 条命中`:`当前工作区的未归档会话 · 用户和 Agent 消息`:`请选择工作区`)}),(0,F.jsx)(`ul`,{className:`quick-open-results content-search-results`,"aria-label":`会话搜索结果`,children:s?.hits.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.jsxs)(`button`,{ref:t===f?_:void 0,type:`button`,"data-session-search-result":e.messageId,className:`quick-open-result content-search-result${f===t?` quick-open-result-active`:``}`,onMouseEnter:()=>p(t),onClick:()=>i(e),children:[(0,F.jsxs)(`span`,{children:[e.title,` · `,e.role===`user`?`用户`:`Agent`]}),(0,F.jsxs)(`small`,{children:[e.before,(0,F.jsx)(`mark`,{children:e.match}),e.after]})]})},`${e.conversationId}:${e.messageId}`))})]})}var Ad=class extends u.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[SuperPi ErrorBoundary captured error]:`,e,t)}reset=()=>{this.setState({error:null})};render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):(0,F.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,F.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,F.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,F.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,F.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,F.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function jd(){}jd.prototype={diff:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.callback;typeof n==`function`&&(r=n,n={}),this.options=n;var i=this;function a(e){return r?(setTimeout(function(){r(void 0,e)},0),!0):e}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var o=t.length,s=e.length,c=1,l=o+s;n.maxEditLength&&(l=Math.min(l,n.maxEditLength));var u=n.timeout??1/0,d=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(f[0],t,e,0);if(f[0].oldPos+1>=s&&p+1>=o)return a([{value:this.join(t),count:t.length}]);var m=-1/0,h=1/0;function g(){for(var n=Math.max(m,-c);n<=Math.min(h,c);n+=2){var r=void 0,l=f[n-1],u=f[n+1];l&&(f[n-1]=void 0);var d=!1;if(u){var g=u.oldPos-n;d=u&&0<=g&&g<o}var _=l&&l.oldPos+1<s;if(!d&&!_)f[n]=void 0;else{if(r=!_||d&&l.oldPos+1<u.oldPos?i.addToPath(u,!0,void 0,0):i.addToPath(l,void 0,!0,1),p=i.extractCommon(r,t,e,n),r.oldPos+1>=s&&p+1>=o)return a(Md(i,r.lastComponent,t,e,i.useLongestToken));f[n]=r,r.oldPos+1>=s&&(h=Math.min(h,n-1)),p+1>=o&&(m=Math.max(m,n+1))}}c++}if(r)(function e(){setTimeout(function(){if(c>l||Date.now()>d)return r();g()||e()},0)})();else for(;c<=l&&Date.now()<=d;){var _=g();if(_)return _}},addToPath:function(e,t,n,r){var i=e.lastComponent;return i&&i.added===t&&i.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:i.count+1,added:t,removed:n,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:i}}},extractCommon:function(e,t,n,r){for(var i=t.length,a=n.length,o=e.oldPos,s=o-r,c=0;s+1<i&&o+1<a&&this.equals(t[s+1],n[o+1]);)s++,o++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=o,s},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},castInput:function(e){return e},tokenize:function(e){return e.split(``)},join:function(e){return e.join(``)}};function Md(e,t,n,r,i){for(var a=[],o;t;)a.push(t),o=t.previousComponent,delete t.previousComponent,t=o;a.reverse();for(var s=0,c=a.length,l=0,u=0;s<c;s++){var d=a[s];if(!d.removed){if(!d.added&&i){var f=n.slice(l,l+d.count);f=f.map(function(e,t){var n=r[u+t];return n.length>e.length?n:e}),d.value=e.join(f)}else d.value=e.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}else if(d.value=e.join(r.slice(u,u+d.count)),u+=d.count,s&&a[s-1].added){var p=a[s-1];a[s-1]=a[s],a[s]=p}}var m=a[c-1];return c>1&&typeof m.value==`string`&&(m.added||m.removed)&&e.equals(``,m.value)&&(a[c-2].value+=m.value,a.pop()),a}new jd;var Nd=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Pd=/\S/,Fd=new jd;Fd.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!Pd.test(e)&&!Pd.test(t)},Fd.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&Nd.test(t[n])&&Nd.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var Id=new jd;Id.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
285
|
+
`));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var i=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),t.push(i))}return t};function Ld(e,t,n){return Id.diff(e,t,n)}var Rd=new jd;Rd.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var zd=new jd;zd.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Bd(e){"@babel/helpers - typeof";return Bd=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Bd(e)}var Vd=Object.prototype.toString,Hd=new jd;Hd.useLongestToken=!0,Hd.tokenize=Id.tokenize,Hd.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,i=r===void 0?function(e,t){return t===void 0?n:t}:r;return typeof e==`string`?e:JSON.stringify(Ud(e,null,null,i),i,` `)},Hd.equals=function(e,t){return jd.prototype.equals.call(Hd,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Ud(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i,e));for(var a=0;a<t.length;a+=1)if(t[a]===e)return n[a];var o;if(Vd.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ud(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),Bd(e)===`object`&&e!==null){t.push(e),o={},n.push(o);var s=[],c;for(c in e)e.hasOwnProperty(c)&&s.push(c);for(s.sort(),a=0;a<s.length;a+=1)c=s[a],o[c]=Ud(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var Wd=new jd;Wd.tokenize=function(e){return e.slice()},Wd.join=Wd.removeEmpty=function(e){return e};function Gd(e,t){let n=Ld(e??``,t??``),r=[],i=0,a=0,o=1,s=1;for(let e of n){let t=e.value.split(`
|
|
286
|
+
`),n=t.length>0&&t[t.length-1]===``;n&&t.pop();for(let c=0;c<t.length;c+=1){let l=t[c],u=c===t.length-1&&!n;e.added?(r.push({kind:`added`,text:l,newLine:s,noNewline:u}),s+=1,i+=1):e.removed?(r.push({kind:`removed`,text:l,oldLine:o,noNewline:u}),o+=1,a+=1):(r.push({kind:`same`,text:l,oldLine:o,newLine:s,noNewline:u}),o+=1,s+=1)}}return{lines:r,added:i,removed:a,identical:i===0&&a===0}}function Kd(e,t=3){let n=new Set;e.lines.forEach((r,i)=>{if(r.kind!==`same`)for(let r=-t;r<=t;r+=1){let t=i+r;t>=0&&t<e.lines.length&&n.add(t)}});let r=[],i=0,a=!1;return e.lines.forEach((e,t)=>{n.has(t)?(a&&=(r.push({kind:`fold`,text:`⋯ 省略未改动的行`}),!1),r.push(e)):a||(a=!0,i+=1)}),a&&r.push({kind:`fold`,text:`⋯ 省略未改动的行`}),{lines:r,folded:i}}var qd=`super-pi.outbox.v1.`,Jd=e=>qd+JSON.stringify([e.conversationId,e.clientId]);function Yd(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(qd)))try{let n=JSON.parse(window.localStorage.getItem(t)??`null`),r=n?.send;r?.type===`message.send`&&typeof r.conversationId==`string`&&/^message_[0-9a-f-]{36}$/.test(r.clientId)&&typeof r.content==`string`&&t===Jd(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function Xd(e){try{return window.localStorage.setItem(Jd(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function Zd(e,t){try{window.localStorage.removeItem(Jd({conversationId:e,clientId:t}))}catch{}}function Qd(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId);if(!r||r.messages.some(e=>e.id===t.clientId))return e;let i=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...i?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:t.clientId,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...i?{delivery:`waiting`}:{}}]}:e)}}function $d(e,t){try{return JSON.parse(window.sessionStorage.getItem(e)??`null`)??t}catch{return t}}function ef(e,t){try{return window.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}}var tf=`modulepreload`,nf=function(e){return`/`+e},rf={},af=function(e){return e.pathname.endsWith(`.css`)},of=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},sf=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=nf(t,n);let r=s(t),i=af(r);return of(rf,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:tf,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},cf=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},lf=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},uf=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function df(e,t,n={}){if(n.signal?.aborted)throw new lf;let r=n.timeoutMs??15e3,i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},r),s=()=>i.abort();n.signal?.addEventListener(`abort`,s,{once:!0});try{let r=await Ae(uf(e,t,n.cwd),{signal:i.signal}),a;try{a=await r.json()}catch{a=void 0}if(!r.ok){let e=a??{};throw new cf(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new lf:a?new cf(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var ff=`\0`,pf=(e,t,n)=>[e,t,n??``].join(ff),mf=24,hf=new Map;function gf(e){let t=hf.get(e);if(t)return hf.delete(e),hf.set(e,t),t}function _f(e,t){for(hf.delete(e),hf.set(e,t);hf.size>mf;){let e=hf.keys().next();if(e.done)break;hf.delete(e.value)}}var vf={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},yf=`此工作区不是 Git 仓库`;function bf(e){return e&&vf[e]?{code:e,text:vf[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function xf(e){return e instanceof cf&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:yf}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var Sf=`${ff}uncommitted`;function Cf(e){let t=new Map,n=0;for(let r of e.lines)t.has(r.line)||t.set(r.line,r),r.line>n&&(n=r.line);let r=[],i=null,a=0;for(let e=1;e<=n;e+=1){let n=t.get(e);if(!n){r.push({line:e,kind:`missing`,data:null}),i=null,a=e;continue}let o=n.isUncommitted?Sf:n.commit??`${ff}none`,s=o===i&&e===a+1?`continuation`:n.isUncommitted?`uncommitted`:`commit`;r.push({line:e,kind:s,data:n}),i=o,a=e}if(e.truncated)for(let t=n+1;t<=e.totalLines;t+=1)r.push({line:t,kind:`truncated`,data:null});return r}function wf(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function Tf(e){switch(e.kind){case`commit`:{let t=e.data,n=t?.shortCommit??t?.commit?.slice(0,8)??`?`,r=t?.author?.trim();return r?`${n} · ${r}`:n}case`continuation`:return`│`;case`uncommitted`:return`● 未提交`;case`missing`:return`?`;case`truncated`:return`…`;default:return``}}function Ef(e){if(e.kind===`uncommitted`||e.data?.isUncommitted)return[`未提交`,`这行尚不属于任何 Git 提交`];if(e.kind===`missing`)return[`没有 Blame 信息`,`这一行没有对应的提交记录`];if(e.kind===`truncated`)return[`Blame 数据已截断`,`文件太长,只显示了前面一部分的提交信息`];let t=e.data;if(!t)return[`没有 Blame 信息`];let n=t.shortCommit??t.commit?.slice(0,8)??`未知提交`,r=t.author?.trim()||`未知作者`;return[n,t.authorEmail?`${r} <${t.authorEmail}>`:r,Df(t.date),t.summary?.trim()||`(没有提交摘要)`]}function Df(e){if(!e)return`不详`;let t=new Date(e);if(!Number.isFinite(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Of(e){if(e.length===0)return 0;let t=1;for(let n=0;n<e.length;n+=1)e.charCodeAt(n)===10&&(t+=1);return e.charCodeAt(e.length-1)===10&&--t,t}function kf(e,t,n=!1){return!t||!t.supported?!1:n||Of(e)!==t.totalLines}var Af=new WeakMap;function jf(e){let t=Af.get(e);if(t)return t;let n={response:e,models:Cf(e),covered:wf(e)};return Af.set(e,n),n}function Mf(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var Nf=`a1b2c3d · Author`;async function Pf(){let[e,t]=await Promise.all([sf(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),sf(()=>import(`./dist-B3-a6uF0.js`).then(e=>e.s),__vite__mapDeps([2,1,0]))]),n=e.StateEffect.define(),r=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(n))return e.value;return e}}),i=e.StateEffect.define(),a=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(i))return e.value;return e}}),o=t.GutterMarker;class s extends o{model;constructor(e){super(),this.model=e}eq(e){let t=e.model;return t?t.line===this.model.line&&t.kind===this.model.kind&&t.data?.commit===this.model.data?.commit&&t.data?.summary===this.model.data?.summary&&t.data?.author===this.model.data?.author:!1}toDOM(){let e=document.createElement(`span`);e.className=`cm-blame-marker cm-blame-${this.model.kind}`,e.setAttribute(`data-file-blame-line`,String(this.model.line)),e.setAttribute(`data-file-blame-kind`,this.model.kind),this.model.data?.commit&&e.setAttribute(`data-file-blame-commit`,this.model.data.commit);let t=Ef(this.model);return e.setAttribute(`title`,t.join(`
|
|
287
|
+
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Tf(this.model),e}}class c extends o{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-blame-marker cm-blame-spacer`,e.textContent=Nf,e}}let l=t.gutter({class:`cm-blame-gutter`,initialSpacer:()=>new c,lineMarker:(e,t)=>{let n=e.state.field(r);if(!n)return null;let i=e.state.doc.lineAt(t.from).number,a=Mf(n,i);return new s(a??{line:i,kind:`missing`,data:null})},lineMarkerChange:e=>e.startState.field(r)!==e.state.field(r)}),u=t.ViewPlugin.fromClass(class{line=null;editorView;constructor(e){this.editorView=e,this.editorView.dom.addEventListener(`mousemove`,this.onMove),this.editorView.dom.addEventListener(`mouseleave`,this.onLeave)}destroy(){this.editorView.dom.removeEventListener(`mousemove`,this.onMove),this.editorView.dom.removeEventListener(`mouseleave`,this.onLeave)}update(e){e.startState.field(r)!==e.state.field(r)&&this.line!==null&&(this.line=null,this.editorView.dispatch({effects:i.of(null)}))}onMove=e=>{let t=this.lineAt(e);if(t===this.line)return;if(this.line=t,t===null){this.editorView.dispatch({effects:i.of(null)});return}let n=Mf(this.editorView.state.field(r),t);if(!n){this.editorView.dispatch({effects:i.of(null)});return}let a=this.editorView.state.doc,o=a.line(Math.min(t,a.lines));this.editorView.dispatch({effects:i.of({pos:o.from,above:!0,create:()=>({dom:Ff(n)})})})};onLeave=()=>{this.line=null,this.editorView.dispatch({effects:i.of(null)})};lineAt(e){let t=e.target,n=t?.closest?.(`[data-file-blame-line]`);if(n){let e=Number(n.getAttribute(`data-file-blame-line`));return Number.isInteger(e)&&e>0?e:null}if(t?.closest?.(`.cm-blame-gutter`))return null;let r=this.editorView.posAtCoords({x:e.clientX,y:e.clientY});return r==null?null:this.editorView.state.doc.lineAt(r).number}});return{field:r,setBlame:n,base:[r,a,t.showTooltip.from(a),u],gutter:l}}function Ff(e){let t=document.createElement(`div`);t.className=`cm-blame-tooltip`,t.setAttribute(`data-file-blame-tooltip`,`1`),t.setAttribute(`data-file-blame-kind`,e.kind),e.data?.commit&&t.setAttribute(`data-file-blame-commit`,e.data.commit);for(let n of Ef(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function If(e,t){let n=(0,u.useRef)(null),r=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let e=r.current;r.current=void 0;let i=n.current;if(!i||!e)return;let a=i.querySelectorAll(t)[e.index];a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top-e.offset)},[e,t]),{scrollBox:n,capture:()=>{let e=n.current;if(!e)return;let i=e.getBoundingClientRect().top,a;e.querySelectorAll(t).forEach((e,t)=>{let n=e.getBoundingClientRect().top-i;(!a||Math.abs(n)<Math.abs(a.offset))&&(a={index:t,offset:n})}),r.current=a}}}var Lf=4e3,Rf=(0,u.lazy)(()=>sf(()=>import(`./CodeMirrorEditor-mi9rGUce.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),zf=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Bf=15e3,Vf=e=>new zf(408,{error:`请求超时:${Bf/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Hf(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Bf);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await Ae(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new zf(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?Vf(e):t}finally{clearTimeout(r)}}var Uf=e=>e instanceof zf?e:new zf(0,{error:e instanceof Error?e.message:`读取失败`}),Wf=e=>encodeURIComponent(e),Gf=e=>e?`&cwd=${Wf(e)}`:``,Kf=(e,t,n)=>`/api/files?workspaceId=${Wf(e)}&path=${Wf(t)}${Gf(n)}`,qf=`//workspace/`,Jf=e=>e.startsWith(qf)?e.slice(12):void 0,Yf=(e,t,n)=>{let r=Jf(t);return`/api/file?workspaceId=${Wf(e)}&path=${Wf(r??t)}${Gf(r?``:n)}`},Xf=(e,t,n)=>Yf(e,t,n)+`&meta=1`,Zf=(e,t,n)=>`/api/files?workspaceId=${Wf(e)}&q=${Wf(t)}${Gf(n)}`;async function Qf(e,t,n){let r=t.current;if(!r)return t.current=Hf(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return Hf(e,{cache:`no-store`})}function $f(e){let t=e.trim();if(/^(["']).*\1$/u.test(t)&&(t=t.slice(1,-1)),!/^file:\/\//iu.test(t))return t;try{let e=new URL(t);return e.hostname||e.search||e.hash?t:decodeURIComponent(e.pathname).replace(/^\/(?=[a-z]:[\\/])/iu,``)}catch{return t}}function ep(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function tp(e){let t=$f(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return ep(t)}function np(e){return $f(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function rp(e,t,n){if(n.openLink){let r=await Hf(`/api/files/open?workspaceId=${Wf(e)}${Gf(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n.path})}),{path:i,name:a,text:o,ticket:s,content:c,meta:l}=r,u=vd(r.targetName??i),d=o===!1&&u===`table`?`download`:u??(o===!1?`download`:void 0);return{path:i,name:a,content:c??``,etag:l.etag,dirty:!1,view:d,assetTicket:s}}let{path:r,name:i,text:a}=n,o=vd(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await Hf(Xf(e,r,t))).etag,dirty:!1,view:o};try{let n=await Hf(Yf(e,r,t));return{path:Jf(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof zf)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await Hf(Xf(e,r,t))).etag,dirty:!1,view:`download`}}}var ip=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function ap({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,F.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,F.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,F.jsx)(sd,{name:g?`down`:`right`})}),(0,F.jsx)(ht,{category:g?`folder-open`:`folder`}),(0,F.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,F.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,F.jsx)(sd,{name:`more`})})]}),_,g&&(0,F.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,F.jsx)(`li`,{children:v}),h===void 0?(0,F.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,F.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:lt(h.error.message),children:ct(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,F.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,F.jsxs)(F.Fragment,{children:[h.truncated&&(0,F.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,F.jsx)(ap,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,F.jsx)(op,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function op({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,F.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),(0,F.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=vd(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,F.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,F.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(ht,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,F.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,F.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,F.jsx)(sd,{name:`more`})})]}),f]})}function sp({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m}){let[h,g]=(0,u.useState)(!0),_=(0,u.useRef)(null),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),S=(0,u.useRef)(0),C=!!e.assetTicket,w=!C&&v[e.path]===!0&&!!l,T=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++S.current;if(!w||!l){x(null);return}let n=new AbortController,i=pf(T,e.path,e.etag),a=r?void 0:gf(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:bf(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=Jf(e.path);return df(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||_f(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:bf(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof lf)return;let r=xf(n);x({state:r.state,response:null,path:e.path,workspaceId:T,note:r.note})}),()=>{n.abort()}},[w,l,d,T,e.path,e.etag,r]);let E=b&&b.path===e.path&&b.workspaceId===T?b:null,D=w?E?.state??`loading`:`off`,O=D===`ready`&&kf(e.content,E?.response??null,e.dirty||r),k=[];E?.note&&k.push(E.note),D===`ready`&&E?.response?.truncated&&k.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${E.response.totalLines} 行)`}),O&&k.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let A=D===`loading`?`⌛ Blame`:D===`ready`?`✓ Blame`:D===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&g(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=_.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
288
|
+
`).length),n=e.value.split(`
|
|
289
|
+
`),r=n.slice(0,t-1).reduce((e,t)=>e+t.length+1,0),a=n[t-1].length;e.focus(),e.setSelectionRange(r+Math.min(a,(i.column??1)-1),r+a);let o=parseFloat(getComputedStyle(e).lineHeight);e.scrollTop=Math.max(0,(t-1)*o-e.clientHeight/2),e.scrollLeft=0;let s=e.previousElementSibling;s instanceof HTMLElement&&(s.scrollTop=e.scrollTop,s.scrollLeft=0)},[e.path,i,h]);let j=/\.md$/i.test(e.path);return(0,F.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,"data-file-readonly":C?`1`:void 0,children:[(0,F.jsxs)(`div`,{className:`file-editor-head`,children:[f??(!p&&(0,F.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,F.jsxs)(`span`,{className:`file-editor-flags`,children:[j&&(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>g(e=>!e),children:h?`原文`:`预览`}),e.assetTicket&&l&&!p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{children:`外部文件 · 只读`}),(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:s,children:`重新读取`}),(0,F.jsx)(`a`,{className:`file-preview-toggle`,href:fd(`asset`,l,d,e.assetTicket,{download:`1`}),download:e.name,children:`下载`})]}),!C&&(0,F.jsx)(`button`,{type:`button`,className:`file-blame-toggle`,"data-file-blame-toggle":e.path,"data-file-blame-state":D,"aria-pressed":w,"aria-label":w?`关闭 Git Blame`:`显示 Git Blame`,onClick:()=>y(t=>({...t,[e.path]:t[e.path]!==!0})),children:A}),e.dirty&&(0,F.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),!C&&(0,F.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,F.jsx)(sd,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),k.length>0&&(0,F.jsx)(`p`,{className:`file-blame-note`,"data-file-blame-reason":k.map(e=>e.code).join(` `),role:`status`,children:k.map(e=>e.text).join(`;`)}),r&&t!==`conflict`&&(0,F.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,F.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,F.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,F.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,F.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,F.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,F.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,F.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,F.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),j&&h?(0,F.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,F.jsx)(Wu,{source:e.content})}):(0,F.jsx)(Ad,{fallback:(t,n)=>(0,F.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,F.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,F.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,F.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,F.jsx)(`textarea`,{className:`file-textarea`,readOnly:C,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,F.jsx)(u.Suspense,{fallback:(0,F.jsx)(`div`,{className:`file-cm-wrap`,"data-file-text":e.path,"data-file-content":e.content,"data-file-selection":`0,0`,"data-file-editor-ready":`0`,children:(0,F.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,F.jsx)(Rf,{path:e.path,value:e.content,onChange:a,jumpToLine:i,onSave:o,readOnly:C,workspaceId:l,onPosition:m,blame:w&&E&&!O?{state:E.state,response:E.response,path:E.path,workspaceId:l??``}:void 0})})})]})}function cp({line:e}){if(e.kind===`fold`)return(0,F.jsx)(`div`,{className:`file-diff-line file-diff-fold`,"data-diff-kind":`fold`,children:e.text});let t=e.kind===`added`?`+`:e.kind===`removed`?`-`:` `;return(0,F.jsxs)(`div`,{className:`file-diff-line file-diff-${e.kind}`,"data-diff-kind":e.kind,"data-diff-no-newline":e.noNewline?`1`:void 0,children:[(0,F.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,F.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,F.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,F.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,F.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function lp({diff:e,loading:t,error:n,bufferContent:r,mode:i,onMode:a}){let[o,s]=(0,u.useState)(),c=JSON.stringify([e?.path,i]),l=o===c,{scrollBox:d,capture:f}=If(l,`.file-diff-added, .file-diff-removed`);if(t)return(0,F.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,F.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:lt(n),children:ct(n,`这个文件的差异读取失败。`)})});if(!e)return(0,F.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let p=typeof r==`string`,m=i===`buffer`&&p,h=m?e.after:e.before,g=m?r:e.after,_=m?`我未保存的修改`:e.label,v=m?`buffer`:e.baseline,y=p&&e.baseline!==`none`?(0,F.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,F.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${m?``:` file-diff-switch-active`}`,"data-file-diff-base":`server`,"aria-pressed":!m,onClick:()=>a(`server`),children:`agent 的改动`}),(0,F.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${m?` file-diff-switch-active`:``}`,"data-file-diff-base":`buffer`,"aria-pressed":m,onClick:()=>a(`buffer`),children:`我的修改`})]}):null;if(v===`none`)return(0,F.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":v,children:[(0,F.jsxs)(`div`,{className:`file-editor-head`,children:[(0,F.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,F.jsx)(`span`,{className:`file-editor-flags`,children:y})]}),(0,F.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:_})]});let b=Gd(h,g),x=Kd(b);return(0,F.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`ready`,"data-file-diff-baseline":v,"data-file-diff-added":b.added,"data-file-diff-removed":b.removed,children:[(0,F.jsxs)(`div`,{className:`file-editor-head`,children:[(0,F.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,F.jsxs)(`span`,{className:`file-editor-flags`,children:[y,(0,F.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:_}),(0,F.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,b.added,` / -`,b.removed]}),!b.identical&&x.folded>0&&(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-context":!0,"aria-pressed":l,onClick:()=>{f(),s(l?void 0:c)},children:l?`折叠未改动行`:`显示全文`})]})]}),e.beforeUnknown&&!m&&(0,F.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!m&&(0,F.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),b.identical?(0,F.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,F.jsx)(`div`,{ref:d,className:`file-diff-body`,"data-file-diff-body":`1`,"data-file-diff-context-mode":l?`full`:`compact`,children:(l?b.lines:x.lines).map((e,t)=>(0,F.jsx)(cp,{line:e},t))})]})}function up({error:e}){let t=e.body.code,n=typeof e.body.details?.path==`string`?e.body.details.path:``,r=t===`workspace_missing`?`missing`:t===`timeout`?`timeout`:`failed`;return(0,F.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,F.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,F.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||ct(e.message,`路径未知`)})]}),r===`timeout`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,F.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,Bf/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,F.jsx)(`p`,{className:`file-problem-hint`,title:lt(e.message),children:ct(e.message,`读取失败,请稍后重试。`)})]})]})}function dp(e,t=``,{navigation:n,showingFile:r=!1,splitFilePath:i}={}){let a=t.trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``),o=e?a?`${e}:${a}`:e:void 0,s=(0,u.useRef)(o);s.current=o;let[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(e),p=(0,u.useRef)(c);p.current=c;let[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)({}),[S,C]=(0,u.useState)({}),[w,T]=(0,u.useState)(()=>new Set),[E,D]=(0,u.useState)(),O=(0,u.useRef)(w);O.current=w;let k=(0,u.useRef)(new Map),A=(0,u.useRef)(new Map),[j,ee]=(0,u.useState)(0),[M,te]=(0,u.useState)(``),[N,ne]=(0,u.useState)(null),[re,ie]=(0,u.useState)(null),[ae,oe]=(0,u.useState)(!1),[se,ce]=(0,u.useState)({});(0,u.useEffect)(()=>{if(f(e),k.current=new Map,l([]),h(void 0),_(``),y({}),x({}),C({}),T(new Set),D(void 0),ne(null),ie(null),te(``),oe(!1),!e)return;let t=!0;return Hf(Kf(e,``,a)).then(e=>{t&&C({"":e})}).catch(e=>{t&&C({"":{error:Uf(e)}})}),()=>{if(t=!1,o&&s.current!==o){let e=p.current.filter(e=>e.dirty);e.length?A.current.set(o,e):A.current.delete(o),ef(`super-pi.file-drafts.v1.`+o,e),hp(o)}}},[e,a,o]);let[le,ue]=(0,u.useState)(),[de,fe]=(0,u.useState)(void 0);(0,u.useEffect)(()=>{if(!e||!o)return;let t=!0;fe(void 0),ue(void 0);let r=pp()[o]??{expanded:[],open:[]},i=e=>({path:e,name:e.split(/[\\/]/).at(-1)||e,text:!0,openLink:r.explicit?.includes(e)?!0:void 0}),a=$d(`super-pi.file-drafts.v1.`+o,[]),c=new Map((A.current.get(o)??a).map(e=>[e.path,e]));r.expanded.length&&T(new Set(r.expanded)),typeof r.listHeight==`number`&&ne(r.listHeight);let u=new Set([...r.open,...c.keys()]);if(!u.size){ue(o);return}let d=r.active??[...c.keys()].at(-1),f=n?.current,p=()=>t&&n?.current===f;return(async()=>{let e,n=r.preview&&!c.has(r.preview)?r.preview:void 0;for(let r of u){if(r===n)continue;let a=c.get(r);a&&l(e=>e.some(e=>e.path===r)?e:[...e,a]);let u=a?.path??await we(i(r),{activate:!1,isCurrent:()=>t});if(!t||s.current!==o)return;r===d&&(e=u)}if(n&&p()&&(e=await we(i(n),{activate:!1,isCurrent:p})),e&&s.current===o&&p()){let t=e;r.preview===r.active&&l(e=>e.map(e=>e.path===t&&!e.dirty?{...e,preview:!0}:e)),h(t),fe(t)}})().finally(()=>{t&&s.current===o&&ue(o)}),()=>{t=!1}},[e,a,o,n]),(0,u.useEffect)(()=>{if(!e||!o)return;let t=setTimeout(()=>{let e=pp();e[o]={open:c.map(e=>e.path),explicit:c.filter(e=>e.assetTicket).map(e=>e.path),expanded:[...w],...r&&m?{active:m}:{},...r&&m&&c.some(e=>e.path===m&&e.preview)?{preview:m}:{},...N===null?{}:{listHeight:N}},mp(e)},400);return()=>{clearTimeout(t)}},[e,o,c,w,m,N,r]),(0,u.useEffect)(()=>{if(!o||le!==o)return;let e=()=>{if(s.current!==o)return;let e=p.current.filter(e=>e.dirty);return ef(`super-pi.file-drafts.v1.`+o,e)||e.length===0},t=window.setTimeout(()=>{e()===!1&&_(`浏览器无法保存文件草稿,刷新前请先保存修改。`)},250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[o,le,c]);let pe=(0,u.useCallback)(async(t,n=!1)=>{if(!e)return;let r={},i=k.current;i.set(t,r);let c=()=>s.current===o&&k.current===i&&i.get(t)===r;await Hf(Kf(e,t,a)+(n?`&revalidate=1`:``)).then(e=>{c()&&C(n=>({...n,[t]:e}))}).catch(e=>{c()&&C(n=>({...n,[t]:{error:Uf(e)}}))}).finally(()=>{c()&&i.delete(t)})},[e,a,o]),me=(0,u.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=(0,u.useCallback)(t=>{if(!e)return;let n=new Set([``,...O.current]),r=t&&new Set(t.map(yd)),i=e=>!r||r.has(e)||t.some(t=>bd(e,t));C(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e)||!i(e))));for(let e of k.current.keys())!n.has(e)&&i(e)&&k.current.delete(e);Promise.all([...n].filter(i).map(e=>pe(e,!t&&!e))).then(()=>{s.current===o&&ee(e=>e+1)})},[e,o,pe]),ge=(0,u.useCallback)(()=>he(),[he]),P=(0,u.useRef)(void 0),_e=(0,u.useRef)(new Set);(0,u.useEffect)(()=>()=>{clearTimeout(P.current),P.current=void 0,_e.current=new Set},[o]);let ve=(0,u.useCallback)((t,n)=>{if(t!==e)return;let r=a?`${a}/`:``,i=n?.flatMap(e=>e.startsWith(r)?[e.slice(r.length)]:[]);if(i?.length===0){if(!n?.some(e=>bd(a,e)))return;_e.current=null}else if(!i)_e.current=null;else for(let e of i)_e.current?.add(e);P.current||=setTimeout(()=>{P.current=void 0;let e=_e.current;_e.current=new Set,he(e?[...e]:void 0)},100)},[e,a,he]),ye=(0,u.useCallback)(e=>{let t=new Set;for(let n=yd(e);n;n=yd(n))t.add(n);te(``),T(e=>new Set([...e,...t]))},[]),be=(0,u.useCallback)((e,t)=>{ye(t&&e?`${e}/`:e),D({path:e,directory:t})},[ye]),xe=(0,u.useCallback)(()=>T(new Set),[]),Se=(0,u.useCallback)((e,t,n)=>{let r=n=>bd(n,e)?t+n.slice(e.length):n,i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[r(e),t]));l(t=>t.map(t=>{let i=r(t.path);if(i===t.path)return t;let a=vd(i),o=t.view&&t.view!==`table`&&(!a||a===`table`)||t.path===e&&n===!1&&!a?`download`:a;return{...t,path:i,view:o,name:i.split(`/`).at(-1)??t.name}})),h(e=>e&&r(e)),T(e=>new Set([...e].map(r))),y(i),x(i);for(let t of k.current.keys())bd(t,e)&&k.current.delete(t);C(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!bd(t,e)))),ye(t)},[ye]),Ce=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{Ce.current=void 0},[e,a]),(0,u.useEffect)(()=>{let t=np(M);if(!e||!t||tp(M)){Ce.current=void 0,ie(null),oe(!1);return}let n=!0,r,i=async()=>{try{let o=await Qf(Zf(e,t,a),Ce,()=>n);if(!n||!o)return;ie(o),oe(!1),o.indexed||(r=setTimeout(()=>void i(),400))}catch(e){if(!n)return;ie(null),oe(!1),_(ct(e,`文件查找没有完成`))}};return oe(!0),r=setTimeout(()=>void i(),80),()=>{n=!1,clearTimeout(r)}},[M,e,a,j]);let we=(0,u.useCallback)(async(t,{preview:n=!1,activate:r=!0,isCurrent:i,throwOnError:c,requireText:u}={})=>{if(!(!e||i&&!i())){_(``);try{let c=p.current.find(e=>e.path===t.path),d=c??await rp(e,a,t);if(s.current!==o||i&&!i())return;if(u&&d.view&&d.view!==`table`)throw Error(`已找到匹配行,但此文件无法在文本编辑器中定位。可以在搜索结果中查看这一行。`);return c?(r&&h(t.path),t.path):(l(e=>e.some(e=>e.path===d.path)?e:[...e,{...d,...n?{preview:n}:{}}]),r&&h(d.path),x(e=>({...e,[d.path]:!1})),d.path)}catch(e){if(s.current!==o||i&&!i())return;if(c)throw e;_(`打不开「${t.name}」:${e instanceof Error?e.message:`未知错误`}`)}}},[e,a,o]),Te=(0,u.useCallback)(e=>{o&&p.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&hp(o,e),l(t=>{let n=t.find(t=>t.path===e);if(n?.dirty&&!window.confirm(`「${n.name}」有未保存的修改,关掉就丢了。仍然关闭?`))return t;let r=t.findIndex(t=>t.path===e),i=t.filter(t=>t.path!==e);return e===m&&h(i.length===0?void 0:i[Math.min(r,i.length-1)]?.path),i})},[m,o]),Ee=(0,u.useCallback)(e=>{l(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),De=(0,u.useCallback)(e=>{l(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),h(t=>t===e?void 0:t),o&&hp(o,e)},[o]),Oe=(0,u.useCallback)((e,t)=>{l(n=>n.map(n=>n.path===e&&!n.assetTicket&&n.content!==t?{...n,content:t,dirty:!0,preview:!1}:n))},[]);(0,u.useEffect)(()=>{if(!e||c.length===0)return;let t=!0,n=setInterval(()=>{for(let{path:n,assetTicket:r}of p.current)r||Hf(Xf(e,n,a)).then(e=>{if(!t)return;let r=p.current.find(e=>e.path===n);r?.view&&r.view!==`table`&&e.etag!==r.etag?l(t=>t.map(t=>t.path===n&&t.etag===r.etag?{...t,etag:e.etag}:t)):r&&e.etag!==r.etag&&x(e=>({...e,[n]:!0}))}).catch(e=>{t&&Uf(e).status===404&&x(e=>({...e,[n]:!0}))})},Lf);return()=>{t=!1,clearInterval(n)}},[e,a,c.length]);let ke=(0,u.useCallback)(async(t,n)=>{if(!e)return;let r=c.find(e=>e.path===t);if(!r||r.assetTicket)return;y(e=>({...e,[t]:{state:`saving`,message:``}}));let i=r.etag;if(n)try{i=(await Hf(Xf(e,t,a))).etag}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:`无法读取磁盘上的最新版本:${e instanceof Error?e.message:`未知错误`}`}}));return}let u=r.content;try{let n=await Hf(Yf(e,t,a),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:Jf(t)??t,content:u,baseEtag:i})});if(s.current!==o)return;let r=p.current.find(e=>e.path===t),c=r!==void 0&&r.content!==u;l(e=>e.map(e=>e.path===t?{...e,etag:n.meta.etag,dirty:e.content!==u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:c?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${ip(n.meta.modifiedAt)}`}}))}catch(e){if(s.current!==o)return;let n=e instanceof zf&&e.body.code===`stale`;y(r=>({...r,[t]:{state:n?`conflict`:`error`,message:e instanceof Error?e.message:`保存失败`}})),n&&x(e=>({...e,[t]:!0}))}},[e,a,o,c]),Ae=(0,u.useCallback)(async t=>{if(!e)return;let n=p.current.find(e=>e.path===t),r=n?.content;try{if(n?.assetTicket){let r=await rp(e,a,{path:t,name:n.name,text:null,openLink:!0});if(!r.assetTicket||r.path!==t)throw Error(`链接目标已变化,请关闭后重新打开。`);s.current===o&&(l(e=>e.map(e=>e.path===t?{...r,preview:e.preview}:e)),y(e=>({...e,[t]:{state:`idle`,message:``}})));return}let i=await Hf(Yf(e,t,a));if(s.current!==o)return;let c=p.current.find(e=>e.path===t),u=c!==void 0&&c.content!==r;l(e=>e.map(e=>e.path===t?{...e,content:u?e.content:i.content,etag:i.meta.etag,dirty:u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:u?`已读取磁盘版本;你后来输入的修改仍未保存`:`已重新载入磁盘版本`}}))}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:e instanceof Error?e.message:`重新载入失败`}}))}},[e,a,o]),je=c.find(e=>e.path===m),Me=(0,u.useMemo)(()=>c.map(e=>({id:e.path,label:e.name,title:Jf(e.path)??e.path,closable:!0,badge:e.dirty?(0,F.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[c]),Ne=(0,u.useMemo)(()=>new Set(c.map(e=>e.path)),[c]),Pe=(0,u.useCallback)((e,t,n)=>{ce(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Fe=e?se[e]:void 0,Ie=(0,u.useMemo)(()=>{let e=Fe?.changes??[];if(!a)return e;let t=`${a}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Fe,a]),Le=Fe?.dropped??0,Re=(0,u.useMemo)(()=>new Set(Ie.map(e=>e.path)),[Ie]),ze=(0,u.useMemo)(()=>{let e=new Set;for(let t of Ie){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[Ie]);return{ownerWorkspaceId:d,open:c,activePath:m,visiblePath:r?m:i,location:E,active:je,tabItems:Me,openPaths:Ne,notice:g,setNotice:_,saves:v,external:b,restoringWorkbench:!!(o&&le!==o),openFile:we,setActivePath:h,closeFile:Te,pinFile:Ee,discardPreview:De,updateBuffer:Oe,save:ke,reload:Ae,listings:S,expanded:w,toggleDirectory:me,loadDirectory:pe,refreshTree:ge,invalidateTree:ve,revealPath:ye,locatePath:be,collapseDirectories:xe,movePath:Se,listHeight:N,setListHeight:ne,query:M,setQuery:te,hits:re,searching:ae,changed:Ie,changedPaths:Re,changedDirs:ze,changedDropped:Le,setChangedFor:Pe,restoredActive:de}}var fp=`super-pi.file-workbench.v1`;function pp(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.file-workbench.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`)continue;let e=r,i=Array.isArray(e.open)?e.open.filter(e=>typeof e==`string`):[],a=typeof e.preview==`string`?e.preview:void 0;a&&a!==e.active&&(i=i.filter(e=>e!==a));let o=Array.isArray(e.expanded)?e.expanded.filter(e=>typeof e==`string`):[],s=typeof e.listHeight==`number`&&Number.isFinite(e.listHeight)&&e.listHeight>0?Math.round(e.listHeight):void 0,c=Array.isArray(e.explicit)?e.explicit.filter(e=>typeof e==`string`):[];t[n]={open:i,expanded:o,explicit:c,...typeof e.active==`string`?{active:e.active}:{},...a&&a===e.active?{preview:a}:{},...s?{listHeight:s}:{}}}return t}catch{return{}}}function mp(e){try{typeof window<`u`&&window.localStorage.setItem(fp,JSON.stringify(e))}catch{}}function hp(e,t){let n=pp(),r=n[e];!r?.preview||t&&r.preview!==t||(n[e]={...r,open:r.open.filter(e=>e!==r.preview),active:void 0,preview:void 0},mp(n))}function gp({height:e,onHeight:t,panelRef:n,min:r=120}){let[i,a]=(0,u.useState)(!1),o=()=>{let e=n.current?.querySelector(`.files-tree`)??null;return{list:e,height:e?.getBoundingClientRect().height??0}},s=e=>{e.preventDefault(),e.currentTarget.focus();let n=e.clientY,{height:i}=o();a(!0);let s=document.body,c=s.style.cursor,l=s.style.userSelect;s.style.cursor=`row-resize`,s.style.userSelect=`none`;let u=e=>{let a=Math.round(i+(e.clientY-n));t(Math.max(r,a))},d=()=>{s.style.cursor=c,s.style.userSelect=l,a(!1),window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d)};window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},c=e=>e.shiftKey?96:24;return(0,F.jsx)(`div`,{className:`files-splitter${i?` files-splitter-dragging`:``}`,"data-file-splitter":`1`,"data-file-splitter-dragging":i?`true`:`false`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整文件列表高度`,"aria-valuenow":e??void 0,"aria-valuemin":r,tabIndex:0,onMouseDown:s,onKeyDown:e=>{let i=c(e);if(e.key===`ArrowDown`){e.preventDefault();let{height:n}=o();t(Math.max(r,Math.round(n)+i))}else if(e.key===`ArrowUp`){e.preventDefault();let{height:n}=o(),a=Math.round(n)-i;t(a<=r?null:a)}else if(e.key===`Home`)e.preventDefault(),t(null);else if(e.key===`End`){e.preventDefault();let i=n.current?.querySelector(`.files-tree`)?.parentElement?.clientHeight??0;t(Math.max(r,i))}}})}var _p=()=>null,vp=`application/x-super-pi-workspace-file`;function yp({workspaceId:e,workspaceName:t,cwd:n=``,files:r,onOpenFile:i,onOpenChanged:a,onReference:o,onMoved:s,onSearchFolder:c}){let{open:l,openPaths:d,notice:f,setNotice:p,openFile:m,listings:h,expanded:g,toggleDirectory:_,loadDirectory:v,refreshTree:y,listHeight:b,setListHeight:x,query:S,setQuery:C,hits:w,searching:T,changed:E,changedPaths:D,changedDirs:O,changedDropped:k}=r,A=(0,u.useCallback)((e,t)=>{i?i(e,t):m(e)},[i,m]),j=n.split(`/`).at(-1)||t||`工作目录`,ee=Ed({workspaceId:e,cwd:n,scopeName:j,files:r,onOpen:A,onReference:o,onMoved:s,onSearchFolder:c}),[M,te]=(0,u.useState)(),N=(0,u.useRef)(void 0),[ne,re]=(0,u.useState)(!1),ie=ee.editing?ee.inline:_p,ae=(0,u.useMemo)(()=>({currentPath:r.visiblePath,dropPath:M,inline:ie}),[r.visiblePath,M,ie]);(0,u.useEffect)(()=>{y();function e(){y()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]),(0,u.useEffect)(()=>{te(void 0),N.current=void 0,re(!1)},[e,n]);let oe=h[``],se=S.trim(),ce=e?tp(S):void 0,le=(0,u.useRef)(null),ue=(0,u.useRef)(null),de=(0,u.useRef)(void 0);function fe(e){let t=ue.current;t&&(de.current&&de.current!==e&&(de.current.tabIndex=-1),de.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let pe=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let{location:e}=r;if(!e||pe.current===e)return;let t=le.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(pe.current=e,t.focus({preventScroll:!0}),t.scrollIntoView({block:`nearest`}))},[r.location,h,g,S]),(0,u.useEffect)(()=>{if(!M||g.has(M))return;let e=window.setTimeout(()=>_(M),650);return()=>window.clearTimeout(e)},[M,g,_]);let me=(0,u.useCallback)(e=>{let t=le.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=Sd(n);if(r&&!ee.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),ee.openMenu(r,cd(n));return}if(!r.linked&&e.key===`F2`){e.preventDefault(),ee.showAction(`move`,r,!1,n);return}if(!r.linked&&e.key===`Delete`){e.preventDefault(),ee.showAction(`trash`,r,!1,n);return}}let i=[...(n.closest(`.files-tree, .files-changed`)??t).querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),a=i.indexOf(n);if(a<0)return;let o=e=>{let t=Math.max(0,Math.min(i.length-1,e));i[t]?.focus()};if(e.key===`ArrowDown`)e.preventDefault(),o(a+1);else if(e.key===`ArrowUp`)e.preventDefault(),o(a-1);else if(e.key===`Home`)e.preventDefault(),o(0);else if(e.key===`End`)e.preventDefault(),o(i.length-1);else if(e.key===`ArrowRight`){let t=n.getAttribute(`data-file-dir-toggle`);if(t&&n.getAttribute(`aria-expanded`)===`false`)e.preventDefault(),_(t);else if(t){let t=n.closest(`.file-node`)?.querySelector(`.file-children .file-row:not(:disabled)`);t&&(e.preventDefault(),t.focus())}}else if(e.key===`ArrowLeft`){let r=n.getAttribute(`data-file-dir-toggle`);if(r&&n.getAttribute(`aria-expanded`)===`true`){e.preventDefault(),_(r);return}let i=n.getAttribute(`data-file-open`)??n.getAttribute(`data-file-hit`)??r;if(i){e.preventDefault();let n=i.lastIndexOf(`/`),r=n<0?``:i.slice(0,n);(r?t.querySelector(`[data-file-dir-toggle="${CSS.escape(r)}"]`):null)?.focus()}}},[_,ee]),[he,ge]=(0,u.useState)(200);(0,u.useEffect)(()=>{ge(200)},[se,e]);let P=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(se===``)return;let e=P.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&ge(e=>e>=(w?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[se,w]);let _e=(0,u.useMemo)(()=>{if(ce)return(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-exact-path":ce.path,title:ce.path,onClick:()=>A(ce),children:[(0,F.jsx)(ht,{path:ce.path}),(0,F.jsxs)(`span`,{className:`file-name`,children:[`打开 `,ce.name]})]});if(se){if(T)return(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(!w)return null;if(w.hits.length===0)return(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:w.indexed?`没有匹配「${se}」的文件。`:`正在建立索引…`});let e=w.hits.slice(0,he),t=[],n=new Map;for(let r of e){let e=n.get(r.directory);if(e)e.push(r);else{let e=[r];n.set(r.directory,e),t.push({directory:r.directory,hits:e})}}return(0,F.jsxs)(F.Fragment,{children:[t.map(e=>(0,F.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,F.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,F.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,F.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,F.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,F.jsxs)(`li`,{className:`file-explorer-row`,"data-file-entry":e.path,"data-linked":e.openLink,"data-file-current":r.visiblePath===e.path?`1`:void 0,children:[(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-hit":e.path,tabIndex:-1,"aria-current":r.visiblePath===e.path?`true`:void 0,"data-file-hit-open":d.has(e.path)?`1`:`0`,onClick:()=>A({...e,text:!0}),children:[(0,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(ht,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),d.has(e.path)&&(0,F.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),!e.openLink&&(0,F.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${e.name} 的文件操作`,children:(0,F.jsx)(sd,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<w.hits.length&&(0,F.jsx)(`div`,{ref:P,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?oe===void 0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in oe?(0,F.jsx)(up,{error:oe.error}):(0,F.jsxs)(F.Fragment,{children:[oe.truncated&&(0,F.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),oe.entries.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,F.jsx)(`ul`,{className:`file-list`,children:oe.entries.map(t=>t.kind===`directory`?(0,F.jsx)(ap,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:h,expanded:g,toggle:_,loadDirectory:v,openPaths:d,changedDirs:O,changedPaths:D,onOpen:A,depth:0,presentation:ae},t.path):(0,F.jsx)(op,{entry:t,depth:0,openPaths:d,changedPaths:D,onOpen:A,presentation:ae},t.path))})]}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[ce,se,T,w,he,e,oe,h,g,_,v,A,d,O,D,ae,r.visiblePath]),ve=e=>{let t=Sd(e);if(!t?.linked)return t?t.directory?t.path:yd(t.path):``},ye=(e,t)=>e!==yd(t.path)&&!(t.directory&&bd(e,t.path));return(0,u.useLayoutEffect)(()=>{let e=ue.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=de.current;fe(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[_e,ee.editing]),(0,F.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":l.length,"data-files-changed-count":E.length,ref:le,onKeyDown:me,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=Sd(t??null);t&&n&&!ee.busy&&ee.openMenu(n,cd(t))},onContextMenu:e=>{let t=Sd(e.target),n=e.target instanceof Element?e.target.closest(`.file-row, [data-explorer-action]`):void 0;t&&n&&!ee.busy&&(e.preventDefault(),ee.openMenu(t,{x:e.clientX,y:e.clientY,origin:n}))},onDragStart:e=>{let t=Sd(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||ee.busy||se||(N.current=t,e.dataTransfer.setData(vp,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{N.current=void 0,te(void 0)},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&te(void 0)},onDragOver:t=>{let n=t.dataTransfer.types.includes(`Files`),r=N.current&&t.dataTransfer.types.includes(vp)?N.current:void 0;if(!e||ee.busy||!n&&!r)return;t.preventDefault();let i=ve(t.target),a=i!==void 0&&(!r||ye(i,r));t.dataTransfer.dropEffect=a?r?`move`:`copy`:`none`,te(a?i:void 0)},onDrop:t=>{te(void 0);let n=t.dataTransfer.types.includes(vp)?N.current:void 0;if(N.current=void 0,!e||ee.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ve(t.target);if(r===void 0){p(`请选择工作区里的普通文件夹。`);return}if(n){ye(r,n)&&ee.moveTo(n,r);return}let i=Array.from(t.dataTransfer.items).filter(e=>!e.webkitGetAsEntry?.()?.isDirectory).map(e=>e.getAsFile()).filter(e=>e!==null);i.length?ee.upload(r,i):t.dataTransfer.files.length&&!t.dataTransfer.items.length?ee.upload(r,Array.from(t.dataTransfer.files)):p(`请选择要上传的文件。`)},children:[(0,F.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":M===``?`1`:void 0,children:[(0,F.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:j,children:[(0,F.jsx)(ht,{category:`folder-open`}),(0,F.jsx)(`span`,{children:j})]}),ee.toolbar]}),(0,F.jsxs)(`div`,{className:`files-search`,children:[(0,F.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,F.jsx)(sd,{name:`search`})}),(0,F.jsx)(`input`,{type:`search`,className:`files-search-input`,"data-file-search-input":`1`,value:S,placeholder:`筛选文件或输入绝对路径`,"aria-label":`按文件名搜索`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),C(``)):e.key===`Enter`&&ce&&(e.preventDefault(),A(ce))},onChange:e=>C(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath||!!Jf(r.activePath)||!!(r.active?.assetTicket&&tp(r.activePath)),onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,F.jsx)(sd,{name:`locate`})})]}),ee.controls,!ce&&se&&w&&!T&&(0,F.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,F.jsx)(`b`,{children:w.total.toLocaleString(`zh-CN`)}),` 个结果`,w.indexed===!1&&(0,F.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`}),w.indexed&&w.incomplete&&(0,F.jsx)(`span`,{className:`files-count-note`,children:`索引不完整`})]}),f&&(0,F.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:f}),ee.busy&&(0,F.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,F.jsx)(`div`,{className:`files-tree`,ref:ue,"data-file-tree":se?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&fe(e.target)},style:b===null?void 0:{height:`${b}px`,flex:`0 0 auto`},children:(0,F.jsxs)(`div`,{className:`files-tree-body`,children:[ee.inline(``,`child`,0),_e]})}),(0,F.jsx)(gp,{height:b,onHeight:x,panelRef:le}),(0,F.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":ne,onClick:()=>re(e=>!e),children:[(0,F.jsx)(sd,{name:ne?`down`:`right`}),(0,F.jsx)(sd,{name:`changes`}),(0,F.jsx)(`span`,{children:`改动`}),(0,F.jsx)(`span`,{className:`files-change-count`,children:E.length})]}),ne&&(0,F.jsxs)(`div`,{className:`files-change-list`,children:[k>0&&(0,F.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,k,` 个改动没有记录(超过保留上限)。`]}),!E.length&&(0,F.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,F.jsx)(`ul`,{className:`file-list`,children:E.map(e=>(0,F.jsx)(`li`,{children:(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-changed-open":e.path,title:`${e.path}(点击查看改动)`,onClick:()=>a?.(e.path),children:[(0,F.jsx)(ht,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,F.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function bp(e,t){let[n,r]=(0,u.useState)(!1),[i,a]=(0,u.useState)(``);return{choose:async(i,o,s)=>{if(i&&!n){r(!0),a(``);try{await e(i,o,s)&&t()}catch(e){a(ct(e,`文件无法打开`))}finally{r(!1)}}},openError:i,opening:n,setOpenError:a}}var xp=200;async function Sp(e,t,n){let r=await Ae(e,{signal:t,cache:`no-store`});if(!r.ok)throw new zf(r.status,await r.json());if(!r.body)throw Error(`服务端没有返回搜索结果。`);let i=r.body.pipeThrough(new TextDecoderStream).getReader(),a=``,o=!1;try{for(;;){let e=await i.read();if(e.done)break;let t=(a+e.value).split(`
|
|
290
|
+
`);a=t.pop();for(let e of t){if(!e)continue;let t=JSON.parse(e);if(t.type===`error`)throw Error(t.error);n(t),t.type===`done`&&(o=!0)}}if(!o)throw Error(`搜索连接提前断开,结果可能不完整。`)}finally{await i.cancel().catch(()=>void 0),i.releaseLock()}}function Cp(e,t,n){let r=t?t+`/`+e.path:e.path;return{path:n?r.startsWith(n+`/`)?r.slice(n.length+1):qf+r:r,name:e.name,text:!0}}function wp({workspaceId:e,cwd:t=``,directory:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o}){let[s,c]=(0,u.useState)(r),[l,d]=(0,u.useState)(n??``),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(!0),[v,y]=(0,u.useState)([]),[b,x]=(0,u.useState)(),[S,C]=(0,u.useState)(xp),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(!1),[A,j]=(0,u.useState)(0),{choose:ee,openError:M,opening:te,setOpenError:N}=bp(i,a),ne=!!tp(s),re=(0,u.useRef)(null),ie=(0,u.useRef)(null),ae=(0,u.useRef)(void 0),oe=(0,u.useId)();(0,u.useEffect)(()=>{re.current?.focus()},[]),(0,u.useEffect)(()=>{ie.current?.scrollIntoView({block:`nearest`})},[A]),(0,u.useEffect)(()=>{let t=s.trim(),n=new AbortController;if(ae.current=n,y([]),x(void 0),T(``),k(!1),C(xp),j(0),!e||!t){D(!1);return}if(t.length>256){T(`搜索词不能超过 256 个字符。`),D(!1);return}let r=new URLSearchParams({workspaceId:e,q:t,stream:`1`,ignore:g?`1`:`0`});l&&r.set(`cwd`,l),f.trim()&&r.set(`include`,f.trim()),m.trim()&&r.set(`exclude`,m.trim()),D(!0);let i=setTimeout(()=>{n.signal.aborted||Sp(`/api/files/search?`+r,n.signal,e=>{n.signal.aborted||(e.type===`matches`?y(t=>[...t,...e.hits]):e.type===`done`&&x(e.summary))}).catch(e=>{n.signal.aborted||T(ct(e,`搜索没有完成`))}).finally(()=>{n.signal.aborted||D(!1)})},220);return()=>{n.abort(),clearTimeout(i)}},[s,e,l,f,m,g]);let se=(0,u.useMemo)(()=>{let e=new Map;return v.slice(0,S).forEach((t,n)=>{let r=e.get(t.path);r?r.push({hit:t,row:n}):e.set(t.path,[{hit:t,row:n}])}),[...e]},[v,S]),ce=e=>{e&&ee(Cp(e,l,t),e.line,e.column)},le=b?.complete===!1,ue={time:`搜索超时`,results:`达到全局结果上限`,line:`部分行太长`,encoding:`部分文件的编码无法读取`,unreadable:`部分文件无法读取`};return(0,F.jsxs)(Od,{mode:`content`,query:s,onMode:o,onClose:a,children:[(0,F.jsx)(`input`,{ref:re,className:`quick-open-input`,"data-content-search-input":`1`,value:s,readOnly:te,placeholder:`内容搜索(区分大小写,按字面匹配)`,role:`combobox`,"aria-label":`内容搜索`,"aria-autocomplete":`list`,"aria-controls":oe,"aria-expanded":v.length>0,"aria-activedescendant":v[A]?`${oe}-${A}`:void 0,onChange:e=>{c(e.target.value),N(``)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),j(e=>Math.min(e+1,Math.max(0,Math.min(S,v.length)-1)))):e.key===`ArrowUp`?(e.preventDefault(),j(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),ce(v[A])))}}),(0,F.jsxs)(`div`,{className:`content-search-controls`,children:[(0,F.jsxs)(`label`,{children:[`范围 `,(0,F.jsxs)(`select`,{value:l,"aria-label":`搜索范围`,onChange:e=>d(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`整个工作区`}),t&&(0,F.jsxs)(`option`,{value:t,children:[`当前目录 · `,t]}),n&&n!==t&&(0,F.jsxs)(`option`,{value:n,children:[`文件夹 · `,n]})]})]}),E&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{ae.current?.abort(),re.current?.focus(),D(!1),k(!0)},children:`取消搜索`})]}),(0,F.jsxs)(`details`,{className:`content-search-filters`,children:[(0,F.jsx)(`summary`,{children:`文件筛选`}),(0,F.jsxs)(`label`,{children:[`包含 `,(0,F.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`例如 **/*.cpp`})]}),(0,F.jsxs)(`label`,{children:[`排除 `,(0,F.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`例如 **/generated/**`})]}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),` 遵循忽略文件和默认排除`]})]}),(0,F.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":w?`error`:E?`searching`:O?`cancelled`:le?`partial`:`complete`,children:[w?`搜索失败:`+w:E?`搜索中…`:O?`已取消`:e?le?`结果不完整`:b?`搜索完成`:`输入要搜索的内容`:`请先选择工作区`,(v.length>0||b)&&` · ${v.length} 条命中`]}),ne&&(0,F.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>o(`path`,s),children:`按文件路径打开`}),le&&(0,F.jsx)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:b.reasons.map(e=>ue[e]??e).join(`;`)}),b?.complete&&!v.length&&(0,F.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`没有匹配的行`}),M&&(0,F.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:M}),(0,F.jsx)(`ul`,{id:oe,className:`quick-open-results content-search-results`,role:`listbox`,"aria-label":`正文搜索结果`,children:se.map(([e,t])=>(0,F.jsxs)(`li`,{className:`content-search-group`,role:`presentation`,children:[(0,F.jsx)(`div`,{className:`content-search-file`,title:e,children:e}),t.map(({hit:e,row:t})=>(0,F.jsxs)(`button`,{id:`${oe}-${t}`,ref:t===A?ie:void 0,type:`button`,role:`option`,tabIndex:-1,"data-content-search-result":`${e.path}:${e.line}`,className:`quick-open-result content-search-result${A===t?` quick-open-result-active`:``}`,"aria-selected":A===t,"aria-label":`${e.path}:${e.line}:${e.column} ${e.text}`,onMouseEnter:()=>j(t),onClick:()=>ce(e),children:[(0,F.jsxs)(`span`,{title:`${e.path}:${e.line}:${e.column}`,className:`content-search-result-position`,children:[e.line,`:`,e.column]}),(0,F.jsx)(`small`,{title:e.text,children:e.text})]},e.line))]},e))}),v.length>S&&(0,F.jsxs)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-content-search-more":`1`,onClick:()=>{S+xp>=v.length&&re.current?.focus(),C(e=>e+xp)},children:[`显示更多结果(已显示 `,S,` / `,v.length,`)`]})]})}function Tp({workspaceId:e,cwd:t=``,connected:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o}){let[s,c]=(0,u.useState)(r),[l,d]=(0,u.useState)(0),[f,p]=(0,u.useState)(0),[m,h]=(0,u.useState)(),g=(0,u.useRef)(void 0),_=(0,u.useRef)(void 0),{choose:v,openError:y,opening:b,setOpenError:x}=bp(i,a),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=np(s),T=e?tp(s):void 0,E=!!T;(0,u.useEffect)(()=>{if(!n||!e)return;let r=new AbortController,i=Zf(e,``,t)+`&quick=1&refresh=1`;return g.current=Hf(i,{cache:`no-store`,signal:r.signal}).catch(()=>void 0),()=>{r.abort(),g.current=void 0}},[n,e,t]),(0,u.useEffect)(()=>{if(!n||!e||E)return;let r=new AbortController,i=r.signal,a=Zf(e,w,t)+`&quick=1&page=${f}`,o,s=async e=>{try{let t=e?await g.current:void 0;if(i.aborted)return;let n=e&&!w&&t?t:await Hf(a,{cache:`no-store`,signal:i});if(i.aborted)return;h({query:w,page:f,response:n}),n.indexed||(o=setTimeout(()=>void s(!1),350))}catch(e){i.aborted||h({query:w,page:f,error:ct(e,`文件查找没有完成`)})}};return o=setTimeout(()=>void s(!0),w?120:0),()=>{r.abort(),clearTimeout(o)}},[n,e,t,w,E,f]);let D=m?.query===w&&m.page===f?m:void 0,O=D?.response,k=(0,u.useMemo)(()=>{if(T)return[T];let t=O?.hits.map(e=>({...e,text:null}))??[];return f>0||e&&w.includes(`/`)&&!w.endsWith(`/`)&&!w.split(`/`).includes(`..`)&&!t.some(e=>e.path.toLowerCase()===w.toLowerCase())&&(O?.total?t.push(ep(w)):t.unshift(ep(w))),t},[T,w,O,f,e]),A=e=>{_.current=void 0,p(e),h(void 0),d(0),x(``),S.current?.focus()},j=!E&&!(!e||D?.error||O?.indexed);return(0,u.useEffect)(()=>{let e=_.current;e===void 0||j||(_.current=void 0,v(k[Math.min(e,k.length-1)]))},[j,k,v]),(0,u.useEffect)(()=>{S.current?.focus()},[]),(0,u.useEffect)(()=>{C.current?.scrollIntoView({block:`nearest`})},[l]),(0,F.jsxs)(Od,{mode:`path`,query:s,onMode:o,onClose:a,children:[(0,F.jsx)(`input`,{ref:S,className:`quick-open-input`,"data-quick-open-input":`1`,value:s,readOnly:b,placeholder:`快速打开:输入文件名或路径`,"aria-label":`快速打开文件路径`,onChange:e=>{let t=e.target.value;_.current=void 0,(np(t)!==w||f!==0)&&h(void 0),c(t),p(0),d(0),x(``)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`)e.preventDefault(),d(e=>Math.min(e+1,Math.max(0,k.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),d(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=k[Math.min(l,k.length-1)],n=O?.hits.some(e=>e.path===t?.path&&[e.name,e.path].some(e=>e.toLowerCase()===w.toLowerCase()));j&&!n?_.current=l:v(t)}}}}),(0,F.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"aria-live":`polite`,"data-quick-open-status":E||O?.indexed&&!O.incomplete?`complete`:`partial`,children:[E?`按 Enter 打开指定文件`:e?n?D?.error||(j?`正在检查文件索引…`:w?O?.incomplete?`索引不完整 · ${O.total} 条命中`:O?.total?`${O.total} 条命中${f?` · 第 ${f+1} 页`:``}`:k.length?`近似路径`:`没有匹配的文件名或路径`:`输入文件名或路径以查找当前目录中的文件`):`等待连接…`:`请先选择工作区`,` · Esc 关闭`]}),y&&(0,F.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:y}),(0,F.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:k.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.jsxs)(`button`,{ref:t===l?C:void 0,type:`button`,"data-quick-open-result":e.path,className:t===l?`quick-open-result quick-open-result-active`:`quick-open-result`,"aria-selected":t===l,onMouseMove:()=>d(t),onClick:()=>{_.current=void 0,v(e)},children:[(0,F.jsx)(`span`,{title:e.name,children:e.name}),(0,F.jsx)(`small`,{title:e.path,children:e.path})]})},e.path))}),w&&O?.indexed&&(f>0||O.truncated)&&(0,F.jsxs)(`div`,{className:`quick-open-pages`,"aria-label":`文件搜索翻页`,children:[f>0&&(0,F.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>A(f-1),children:`上一页`}),O.truncated&&(0,F.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-quick-open-next-page":!0,onClick:()=>A(f+1),children:`下一页`})]})]})}function Ep(e,t,n=88,r=200){let i=Math.max(0,Math.floor(e));if(!Number.isFinite(t)||t<=0)return{perRow:Math.max(1,i),width:n};if(i===0)return{perRow:1,width:n};if(i===1)return{perRow:1,width:Math.min(r,t)};let a=t/i;if(a>=n)return{perRow:i,width:Math.min(a,r)};for(let e=2;e<=i;e+=1){let a=Math.ceil(i/e),o=t/a;if(o>=n)return{perRow:a,width:Math.min(o,r)}}return{perRow:1,width:n}}function Dp(e,t){let n=Math.max(1,Math.floor(t)),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function Op(e,t,n=88,r=200){let[i,a]=(0,u.useState)(()=>Ep(e,0,n,r)),[o,s]=(0,u.useState)(null),c=(0,u.useCallback)(()=>{let i=Ep(e,t,n,r);s({count:e,containerWidth:t}),a(e=>e.perRow===i.perRow&&e.width===i.width?e:i)},[e,t,n,r]),l=(0,u.useRef)(t);(0,u.useLayoutEffect)(()=>{t<=0||l.current!==t&&(l.current=t,c())},[t,c]);let d=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=d.current;d.current=e,t!==null&&e>t&&c()},[e,c]),{layout:i,frozen:o!==null&&o.count!==e,recompute:c}}function kp({tabs:e,activeId:t,onSelect:n,onClose:r,onActivate:i,ariaLabel:a,minWidth:o=88,maxWidth:s=200,prefix:c=`workspace-tab`,idPrefix:l=c,className:d}){let f=(0,u.useRef)(null),[p,m]=(0,u.useState)(0),{layout:h,frozen:g,recompute:_}=Op(e.length,p,o,s);(0,u.useLayoutEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.clientWidth;t>0&&m(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let v=Dp(e,h.perRow),y=(e,t)=>t===void 0?{}:{[`data-${c}-${e}`]:t},b=e.filter(e=>e.kind===`file`).length,x=e.filter(e=>e.kind===`session`||!e.kind).length,S=t=>({[`data-${t}-strip`]:`1`,...g?{[`data-${t}-frozen`]:`1`}:{},[`data-${t}-count`]:t===`file-tab`?b:t===`session-tab`?x:e.length,[`data-${t}-min`]:o,[`data-${t}-max`]:s,[`data-${t}-per-row`]:h.perRow,[`data-${t}-width`]:Math.round(h.width*100)/100}),C=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()},w=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()};(0,u.useEffect)(()=>{if(!g)return;let e=f.current;if(!e)return;let t=t=>{let n=e.getBoundingClientRect();t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top&&t.clientY<=n.bottom||_()};return document.addEventListener(`mousemove`,t,!0),()=>document.removeEventListener(`mousemove`,t,!0)},[g,_]);let T=[`${c}-strip`,`workspace-tab-strip`,`session-tab-strip`,`file-tab-strip`,d].filter(Boolean).join(` `);return(0,F.jsx)(`div`,{ref:f,className:T,role:`tablist`,"aria-label":a??`工作区标签页`,...y(`strip`,`1`),...S(`workspace-tab`),...S(`session-tab`),...S(`file-tab`),style:{"--tab-w":`${h.width}px`},onMouseEnter:C,onMouseLeave:w,children:v.map((a,o)=>(0,F.jsx)(`div`,{className:`${c}-row workspace-tab-row session-tab-row file-tab-row`,role:`presentation`,...y(`row`,o),children:a.map(a=>{let o=a.id===t||a.rawId!==void 0&&a.rawId===t,s=a.title??a.label,u=a.kind,d=a.rawId??a.id,f=e.findIndex(e=>e.id===a.id),p=[c,o?`${c}-active`:``,`workspace-tab`,o?`workspace-tab-active`:``,u?`${u}-tab`:``,u&&o?`${u}-tab-active`:``,a.preview?`${c}-preview`:``,a.preview?`workspace-tab-preview`:``,a.preview&&u?`${u}-tab-preview`:``].filter(Boolean).join(` `);return(0,F.jsxs)(`div`,{role:`tab`,id:`${l}-${a.id}`,"aria-selected":o,"aria-controls":`${l}-panel-${a.id}`,tabIndex:o?0:-1,className:p,...y(`id`,d),...y(`index`,f),...o?y(`active`,`1`):{},...y(`closable`,a.closable===!1?`0`:`1`),...u?{"data-tab-kind":u}:{},...a.preview?{"data-tab-preview":`1`}:{},...u===`session`||!u?{"data-session-tab-id":d,"data-session-tab-index":f,...o?{"data-session-tab-active":`1`}:{},"data-session-tab-closable":a.closable===!1?`0`:`1`,...a.preview?{"data-session-tab-preview":`1`}:{}}:{},...u===`file`?{"data-file-tab-id":d,"data-file-tab-index":f,...o?{"data-file-tab-active":`1`}:{},"data-file-tab-closable":a.closable===!1?`0`:`1`}:{},...u===`diff`?{"data-diff-tab-id":d,"data-diff-tab-index":f,...o?{"data-diff-tab-active":`1`}:{},"data-diff-tab-closable":a.closable===!1?`0`:`1`}:{},title:s,style:{width:h.width,boxSizing:`border-box`},onClick:()=>n?.(a.id),onDoubleClick:i?()=>i(a.id):void 0,onAuxClick:e=>{e.button===1&&(e.preventDefault(),e.stopPropagation(),a.closable!==!1&&r&&r(a.id))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let r=t.key===`ArrowRight`?1:-1,i=e[(e.findIndex(e=>e.id===a.id)+r+e.length)%e.length];i&&(document.getElementById(`${l}-${i.id}`)?.focus(),n?.(i.id))},children:[a.icon&&(0,F.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,F.jsx)(`span`,{className:`${c}-label workspace-tab-label ${u?`${u}-tab-label`:``}`,...y(`label`,d),...u===`session`||!u?{"data-session-tab-label":d}:{},...u===`file`?{"data-file-tab-label":d}:{},...u===`diff`?{"data-diff-tab-label":d}:{},children:a.label}),a.closable!==!1&&r&&(0,F.jsx)(`button`,{type:`button`,className:`${c}-close workspace-tab-close ${u?`${u}-tab-close`:``}`,...y(`close`,d),...u===`session`||!u?{"data-session-tab-close":d}:{},...u===`file`?{"data-file-tab-close":d}:{},...u===`diff`?{"data-diff-tab-close":d}:{},onClick:e=>{e.stopPropagation(),r(a.id)},onDoubleClick:e=>{e.stopPropagation()},title:`关闭 ${s}`,"aria-label":`关闭 ${s}`,children:`×`})]},a.id)})},`row_${o}`))})}var Ap=25,jp=75;function Mp({share:e,onShare:t}){let n=(0,u.useRef)(null),[r,i]=(0,u.useState)(!1),a=e=>t(Math.round(Math.min(jp,Math.max(Ap,e))));return(0,u.useLayoutEffect)(()=>{let e=n.current?.parentElement;if(!e)return;let t=()=>i(getComputedStyle(e).flexDirection===`column`);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]),(0,F.jsx)(`div`,{ref:n,className:`workbench-split-divider`,"data-workbench-split-divider":!0,role:`separator`,"aria-label":`调整拆分大小`,"aria-orientation":r?`horizontal`:`vertical`,"aria-valuenow":e,"aria-valuemin":Ap,"aria-valuemax":jp,tabIndex:0,onPointerDown:e=>{e.button===0&&(e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!e.currentTarget.hasPointerCapture(e.pointerId))return;let t=e.currentTarget.parentElement?.getBoundingClientRect();t&&a(r?(e.clientY-t.top)/t.height*100:(e.clientX-t.left)/t.width*100)},onKeyDown:t=>{let n=t.key===(r?`ArrowDown`:`ArrowRight`),i=t.key===(r?`ArrowUp`:`ArrowLeft`);if(n||i)a(e+(n?5:-5));else if(t.key===`Home`)a(Ap);else if(t.key===`End`)a(jp);else return;t.preventDefault()}})}function Np({tabs:e,selected:t,onSelect:n,onPin:r,onCloseTab:i,onClose:a,children:o}){let s=e.find(e=>e.id===t);return(0,F.jsxs)(`section`,{className:`workbench-split-pane`,"data-workbench-split-pane":!0,"aria-label":`拆分区`,children:[(0,F.jsxs)(`div`,{className:`workbench-split-bar`,children:[(0,F.jsxs)(`select`,{"aria-label":`拆分区标签页`,"data-workbench-split-tabs":!0,value:t??``,onChange:e=>n(e.target.value),title:s?.title,"data-workbench-split-preview":s?.preview||void 0,children:[(0,F.jsx)(`option`,{value:``,disabled:!0,children:`选择文件或差异`}),e.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),t&&s?.preview&&(0,F.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`固定标签页`,"aria-label":`固定拆分区标签页`,onClick:()=>r(t),children:(0,F.jsx)(Tt,{name:`pin`})}),t&&(0,F.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`关闭此标签页`,"aria-label":`关闭拆分区标签页`,onClick:()=>i(t),children:(0,F.jsx)(Tt,{name:`close`})}),(0,F.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,"data-close-workbench-split":!0,title:`合并主区`,"aria-label":`合并主区`,onClick:a,children:(0,F.jsx)(Tt,{name:`split`})})]}),o??(0,F.jsx)(`p`,{className:`rail-empty`,children:`从文件或 Git 面板打开一个文件或差异。`})]})}function Pp(e,t){if(e.entries[e.index]?.key===t.key)return e;let n=[...e.entries.slice(0,e.index+1),t].slice(-100);return{entries:n,index:n.length-1}}function Fp(e,t,n,r){for(let i=t+n;i>=0&&i<e.entries.length;i+=n)if(r(e.entries[i]))return i;return-1}var Ip={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},Lp={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},Rp={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},zp={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function Bp(e){let t=Math.max(0,Math.round(e/1e3)),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),a=e=>String(e).padStart(2,`0`);return i>0?`${i}h ${a(r)}:${a(n)}`:`${r}:${a(n)}`}function Vp(e){let t=e.status===`running`,[n,r]=(0,u.useState)(0);(0,u.useEffect)(()=>{if(!t)return;r(Date.now());let e=window.setInterval(()=>r(Date.now()),200);return()=>window.clearInterval(e)},[t,e.startedAt]);let i=Date.parse(e.startedAt);if(Number.isFinite(i)){if(!t){let t=Date.parse(e.finishedAt??``);return Number.isFinite(t)?t-i:void 0}return n>0?n-i:void 0}}function Hp({step:e,names:t}){let n=e.attempts.length,r=e.attempts[n-1],i=t.get(e.agentId)||e.agentId,a=e.label?.trim()||i;return(0,F.jsxs)(`li`,{className:`workflow-step workflow-step-${e.status}`,"data-workflow-step":e.index+1,"data-workflow-step-status":e.status,"data-workflow-step-agent":e.agentId,"data-workflow-step-attempts":n,children:[(0,F.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:Rp[e.status]}),(0,F.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,F.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,F.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,F.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,F.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:Ip[e.status]}),e.status===`failed`&&r?.error&&(0,F.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:lt(r.error),children:ct(r.error,`这一步没有完成。`)})]})}function Up({nodes:e,steps:t,names:n}){return(0,F.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,F.jsx)(Hp,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,F.jsxs)(`li`,{className:`workflow-node workflow-loop`,"data-workflow-loop":!0,"data-workflow-loop-rounds":e.rounds.length,"data-workflow-loop-max":e.max,"data-workflow-until":e.until,children:[(0,F.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,F.jsx)(`strong`,{children:`循环`}),(0,F.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,F.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,F.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,F.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,F.jsx)(Up,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,F.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,F.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,F.jsx)(`strong`,{children:`逐项执行`}),(0,F.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,F.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,F.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,F.jsx)(Up,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function Wp({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=Vp(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,F.jsxs)(`article`,{className:`workflow-card workflow-${e.status}`,"data-workflow-card":e.id,"data-workflow-status":e.status,"data-workflow-steps":e.steps.length,"data-workflow-current":e.currentIndex+1,children:[(0,F.jsxs)(`div`,{className:`workflow-head`,children:[(0,F.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,F.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,F.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,F.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:Lp[e.status]??`未知状态`}),(0,F.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:zp[e.onFailure]??e.onFailure}),a!==void 0&&(0,F.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,Bp(a)]}),i&&(0,F.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,F.jsx)(Up,{nodes:e.nodes,steps:e.steps,names:t}):(0,F.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,F.jsx)(Hp,{step:e,names:t},e.index))})]})}var Gp=[{id:`agents`,label:`智能体与创建`,icon:`🤖`,title:`Agent 智能体系统与创建指南`,description:`了解 Super Pi 的角色设定机制,以及如何一步步创建你自己的自定义 Agent。`},{id:`workspace`,label:`工作区与会话`,icon:`🗂️`,title:`工作区与多会话管理`,description:`高效管理本地代码仓库、独立会话标签页与多模态图文输入。`},{id:`subagents`,label:`子任务与编排`,icon:`⚡`,title:`子智能体委托与顺序编排使用指南`,description:`让主 Agent 安排分工、交接结果,并查看进度、处理失败与停止任务。`},{id:`model-policy`,label:`模型使用规则`,icon:`🔒`,title:`模型过滤规则(按工作区限制可用模型)`,description:`用正则规则限定哪些工作区只能用哪些模型,防止敏感代码被发到不该用的模型上。`},{id:`memory`,label:`主动记忆`,icon:`🧠`,title:`主动记忆与技能经验`,description:`让 Super Pi 在得到明确证据后保存长期事实、用户偏好和可复用工作方法。`},{id:`knowledge`,label:`知识库`,icon:`📚`,title:`工作区知识库`,description:`导入规范与设计文档,让 Agent 检索原文作答,而不是凭记忆编造。`},{id:`feishu`,label:`飞书`,icon:`📄`,title:`飞书云文档的读写`,description:`让 Agent 读一篇飞书文档、写回结论。接入方式、连接步骤与常见问题。`},{id:`tools`,label:`侧边栏工具`,icon:`🧩`,title:`全局工具:开发、导出与导入`,description:`让 Agent 写一个工具,用一个文件分享给别人,导入前先看清它会做什么。`},{id:`cli`,label:`指令与快捷键`,icon:`⌨️`,title:`Pi 终端命令与键盘快捷操作`,description:`利用 Pi 终端斜杠指令控制服务生命周期,掌握常用快捷键提升效率。`},{id:`themes`,label:`外观与主题`,icon:`🎨`,title:`界面主题与个性化显示`,description:`内置 4 款专业高对比度主题,针对不同环境提供舒适体验。`}];function Kp({onClose:e}){let[t,n]=(0,u.useState)(`agents`);(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!t.defaultPrevented&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let r=Gp.find(e=>e.id===t)??Gp[0];return(0,F.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,F.jsxs)(`div`,{className:`picker settings-window help-window`,"data-help-window":`1`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-window-title`,children:[(0,F.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,F.jsxs)(`div`,{className:`help-head-title`,children:[(0,F.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,F.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,F.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,F.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,F.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),Gp.map(e=>(0,F.jsxs)(`button`,{type:`button`,id:`help-tab-${e.id}`,className:`settings-category help-category`,role:`tab`,"aria-selected":e.id===r.id,"aria-controls":`help-panel`,tabIndex:e.id===r.id?0:-1,onClick:()=>n(e.id),children:[(0,F.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,F.jsx)(`span`,{children:e.label})]},e.id))]}),(0,F.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,F.jsxs)(`div`,{className:`help-panel-header`,children:[(0,F.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,F.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,F.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,F.jsx)(Yp,{}),r.id===`workspace`&&(0,F.jsx)(Xp,{}),r.id===`subagents`&&(0,F.jsx)(Qp,{}),r.id===`model-policy`&&(0,F.jsx)(Zp,{}),r.id===`memory`&&(0,F.jsx)(qp,{}),r.id===`knowledge`&&(0,F.jsx)(Jp,{}),r.id===`feishu`&&(0,F.jsx)($p,{}),r.id===`tools`&&(0,F.jsx)(em,{}),r.id===`cli`&&(0,F.jsx)(tm,{}),r.id===`themes`&&(0,F.jsx)(nm,{})]}),(0,F.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function qp(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,F.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,F.jsx)(`code`,{children:`memory`}),` 和 `,(0,F.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,F.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,F.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`权限与审批`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,F.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,F.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function Jp(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,F.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`怎么用`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,F.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,F.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,F.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,F.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,F.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`语义检索是内置的`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,F.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,F.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,F.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`它不知道的事`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,F.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,F.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,F.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,F.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function Yp(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,F.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,F.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,F.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,F.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,F.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,F.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,F.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,F.jsxs)(`div`,{className:`help-steps`,children:[(0,F.jsxs)(`div`,{className:`help-step`,children:[(0,F.jsx)(`span`,{className:`step-num`,children:`1`}),(0,F.jsxs)(`div`,{className:`step-body`,children:[(0,F.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,F.jsxs)(`p`,{children:[`在 `,(0,F.jsx)(`code`,{children:`agents/`}),` 或 `,(0,F.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,F.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-step`,children:[(0,F.jsx)(`span`,{className:`step-num`,children:`2`}),(0,F.jsxs)(`div`,{className:`step-body`,children:[(0,F.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,F.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,F.jsx)(`pre`,{className:`help-code-block`,children:(0,F.jsx)(`code`,{children:`---
|
|
291
|
+
name: 系统架构师
|
|
292
|
+
description: 专注于系统架构拆解、模块解耦与技术选型分析
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
你是一位拥有丰富大型工程经验的资深系统架构师。
|
|
296
|
+
在回答技术方案或重构建议时,请遵循以下原则:
|
|
297
|
+
1. 始终优先保障系统模块边界清晰与职责单一;
|
|
298
|
+
2. 提出方案时提供利弊分析(Trade-offs)与选型依据;
|
|
299
|
+
3. 输出高内聚、低耦合的设计图表与步骤。`})})]})]}),(0,F.jsxs)(`div`,{className:`help-step`,children:[(0,F.jsx)(`span`,{className:`step-num`,children:`3`}),(0,F.jsxs)(`div`,{className:`step-body`,children:[(0,F.jsx)(`strong`,{children:`在工作区中直接选择使用`}),(0,F.jsxs)(`p`,{children:[`文件保存后,刷新页面或点击左侧工作区标题旁的 `,(0,F.jsx)(`strong`,{children:`⚙ 设置`}),` 按钮, 在「默认 Agent」下拉菜单中就能直接看到新加入的「系统架构师」!`]})]})]})]})]})]})}function Xp(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🗂️ 工作区(Workspace)管理`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`绑定真实目录:`}),`每个工作区对应本地机器的一个具体项目路径。代码操作与工具调用均以该路径为上下文根目录。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`独立偏好配置:`}),`点击工作区标题右侧的 `,(0,F.jsx)(`strong`,{children:`⚙ 齿轮图标`}),`,可为该工作区单独配置其专属的「默认 Agent」、「默认模型」与「思考深度等级」。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`多工作区折叠:`}),`点击工作区名称即可折叠或展开会话列表,界面清爽高效。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`💬 多会话与标签页(Tabs)`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`顶部标签页流转:`}),`打开的会话会作为标签页显示在消息区顶部,方便在不同任务与思路之间瞬间切换。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`会话归档:`}),`不再活跃的会话可以归档,归档列表独立折叠收纳在底部,随时可还原。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`图文多模态输入:`}),`在模型选择器中带有「图文」标签的模型(如 Claude 3.7 / GPT-4o 等),支持在输入框直接上传或拖拽图片,协同分析 UI 与架构图。`]})]})]})]})}function Zp(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🔒 它解决什么问题`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`按工作区限定可用模型:`}),`一条规则 =「工作区名匹配某个正则」时,这个工作区的会话`,(0,F.jsx)(`strong`,{children:`只允许`}),`使用模型名匹配另一个正则的模型。例如「名称含 `,(0,F.jsx)(`code`,{children:`sensitive`}),` 的工作区,只能用名称含 `,(0,F.jsx)(`code`,{children:`internal`}),` 的模型」。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`为什么要按工作区而不是按会话:`}),`敏感程度取决于代码在哪儿,而不是取决于是哪一次提问。规则写在工作区上,新增工作区自动受管,不会因为新开了个会话就绕过去。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`不是纯界面限制:`}),`模型下拉里只会列出允许的模型;但即使绕过界面(第二个标签页、过期窗口、手写指令),`,(0,F.jsx)(`strong`,{children:`服务端也会拒绝运行`}),`并说明是哪个工作区命中了哪条规则。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`⚙️ 怎么配置`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`位置:`}),`左侧栏 `,(0,F.jsx)(`strong`,{children:`⚙ 设置 → 模型过滤`}),`,全局生效,对所有工作区统一管理。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`两条正则各管一件事:`}),`左边匹配`,(0,F.jsx)(`strong`,{children:`工作区名称`}),`(不区分大小写),右边匹配`,(0,F.jsx)(`strong`,{children:`模型名称`}),`(同时匹配模型显示名和 `,(0,F.jsx)(`code`,{children:`provider/modelId`}),`,任一命中即算允许)。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`多条规则同时命中时取交集:`}),`一个模型必须被`,(0,F.jsx)(`strong`,{children:`每一条`}),`命中的规则都允许,才算允许。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`正则写错不会拖垮服务:`}),`填表时当场校验,写错立刻标红并阻止保存;万一有非法规则进了配置,服务端会跳过它并在日志里说明,`,(0,F.jsx)(`strong`,{children:`不会`}),`被当成「全部禁止」。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`没有规则 = 不过滤:`}),`不配置任何规则时行为和以前完全一样。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🛡️ 到底拦住了哪些路径`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`模型下拉列表:`}),`被禁用的模型根本不会出现在选择器里。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`切换模型 / 选 Agent / 改工作区默认模型:`}),`都会在服务端校验,违规直接拒绝,不会静默换成别的模型。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`Agent 自己声明的模型:`}),`在 `,(0,F.jsx)(`code`,{children:`agents/*.md`}),` 里写死的 `,(0,F.jsx)(`code`,{children:`model:`}),` 同样受约束——选一个声明了禁用模型的 Agent 会被拒绝,而不是偷偷按那个模型跑。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`子智能体(Sub-agent):`}),`派发子任务时使用的模型,`,(0,F.jsx)(`strong`,{children:`包括从父 Agent 继承下来的那个`}),`,一样按会话所属工作区校验。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`已有会话复查:`}),`会话配好之后你才新增规则的话,下次真正开始跑之前会重新校验一次。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`跟随 Pi 默认的情况:`}),`会话没有显式选模型时,Pi 会用它自己的全局默认模型。这个默认模型`,(0,F.jsx)(`strong`,{children:`同样会被检查`}),`——如果它正好被规则禁用,运行会被拒绝。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`💡 怎么写正则`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`大小写不敏感:`}),(0,F.jsx)(`code`,{children:`/sensitive/i`}),` 和 `,(0,F.jsx)(`code`,{children:`/SENSITIVE/i`}),` 效果一样,不用在小写和大写之间纠结。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`常用写法:`}),(0,F.jsx)(`code`,{children:`/敏感|sensitive/i`}),` 匹配多个关键词;`,(0,F.jsx)(`code`,{children:`/^客户-/i`}),` 只匹配以「客户-」开头的;`,(0,F.jsx)(`code`,{children:`/internal|private/i`}),` 匹配任一即可。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`模型名两种写法都认:`}),`规则右边写 `,(0,F.jsx)(`code`,{children:`internal`}),` 能匹配显示名为「Internal」的模型,写 `,(0,F.jsx)(`code`,{children:`minimax-cn/internal`}),` 也能精确匹配同一个模型。`]})]})]})]})}function Qp(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card`,"data-help-workflow":`start`,children:[(0,F.jsx)(`h4`,{children:`如何开始一次编排`}),(0,F.jsxs)(`p`,{children:[`选择工作区和主 Agent,在消息框里说明目标、希望参与的子 Agent、执行顺序和验收条件。主 Agent 会使用 `,(0,F.jsx)(`code`,{children:`workflow`}),` 工具提交计划;你不需要手写 JSON,也没有需要点击的“启动编排”按钮。`]}),(0,F.jsxs)(`p`,{children:[`先在设置的“智能体”分类确认这些角色已被发现。主 Agent 使用 `,(0,F.jsx)(`code`,{children:`mode: primary`}),`,参与步骤的角色使用 `,(0,F.jsx)(`code`,{children:`mode: subagent`}),`;指令中的角色 ID 对应定义文件名(不带 .md)。主 Agent 的工具权限需要允许 `,(0,F.jsx)(`code`,{children:`workflow`}),`,单独委托则需要允许 `,(0,F.jsx)(`code`,{children:`task`}),`。`]}),(0,F.jsx)(`pre`,{className:`help-code-block`,children:(0,F.jsx)(`code`,{children:`请修复这个工作区的登录失败问题,用 workflow 顺序编排:
|
|
300
|
+
1. scout:定位原因,输出相关文件、复现步骤和修复建议。
|
|
301
|
+
2. coder:根据 scout 的结果实现修复,不修改无关代码。
|
|
302
|
+
3. verifier:根据修复结果运行测试,检查回归并给出结论。
|
|
303
|
+
运行失败时最多重试 1 次,仍失败就停止。
|
|
304
|
+
最后由你汇总修改、测试结果和剩余问题。`})}),(0,F.jsx)(`p`,{children:`上例使用内置角色;自定义角色请换成你实际配置的 ID。若主 Agent 没有调用编排工具,可明确补充“请调用 workflow 工具执行,而不是只列计划”。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,"data-help-workflow":`choices`,children:[(0,F.jsx)(`h4`,{children:`选择单独委托、后台任务还是顺序编排`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`单独委托(task):`}),`适合一两个子任务,或需要主 Agent 看完结果再决定下一步。直接说“让 scout 先调查,拿到结果后再决定怎么修”。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`顺序编排(workflow):`}),`适合多个有依赖的步骤,例如调查 → 实现 → 验证。步骤依次执行,每个子 Agent 从新上下文开始,服务端自动把前序产出交给后续步骤。一次调用会等待整个计划结束,再把结果交回主 Agent。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`后台任务:`}),`适合互不依赖的工作。可说“并行委托两个独立调查任务,使用 task 的 background 模式”;它们完成后会回传结果,不保证执行顺序。`]})]}),(0,F.jsx)(`p`,{children:`当前 workflow 不支持条件分支、步骤并行或自动回跳。若验证发现问题,可让主 Agent 阅读结论后安排新一轮修复与验证。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,"data-help-workflow":`progress`,children:[(0,F.jsx)(`h4`,{children:`查看进度、处理失败与停止`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`进度:`}),`对话正文会出现编排卡片,显示完整步骤、当前步骤、状态和尝试次数。各步骤的子 Agent 卡片显示输出和工具活动;刷新页面后仍可查看已保存记录。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`失败策略:`}),`默认 `,(0,F.jsx)(`code`,{children:`stop`}),` 在步骤运行失败后停止;`,(0,F.jsx)(`code`,{children:`retry:N`}),` 最多追加 N 次尝试,并携带上次失败证据;`,(0,F.jsx)(`code`,{children:`skip`}),` 跳过失败步骤并告知后续角色输入缺失。可以用自然语言要求主 Agent 选择策略。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`验证结论:`}),`步骤“已完成”表示子进程正常结束,不代表它的报告说“验证通过”。主 Agent 需要阅读报告再判断是否达到验收条件。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`停止:`}),`编排卡片的“停止”会取消当前子任务并阻止后续步骤;停止主任务也会停止其编排。点击后显示“停止中”,实际取消确认后才显示停止状态。停止当前步骤的子 Agent 也会终止该计划。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`继续:`}),`停止或服务重启后不会自动续跑。已完成的输出仍保留;请让主 Agent 根据这些记录重新安排剩余步骤,先检查已有修改,避免重复执行。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`⚡ 子任务分工与委托机制`}),(0,F.jsxs)(`p`,{children:[`当面对复杂工程任务时,Super Pi 支持通过 `,(0,F.jsx)(`code`,{children:`task`}),` 工具将子任务派发给专精子智能体。`]}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`Scout(侦察兵):`}),`负责快速穿透仓库搜寻相关文件与代码位置。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`Coder(编码专家):`}),`专注于高精度实现与代码变更。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`Verifier(验证官):`}),`负责运行自动化测试与编译校验,确保修改零回归。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`📊 右侧抽屉栏(Right Rail)`}),(0,F.jsx)(`p`,{children:`右侧边栏集成了三大核心实时监控面板:`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`任务清单(Task List):`}),`跟踪长任务规划执行进度与各步骤完成状态。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`后台任务(Tasks):`}),`实时追踪并发子任务的祖先链路、状态流转与执行产物。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`文件工作台(Files):`}),`免切窗口直接浏览、检索与阅读当前工作区的文件内容。`]})]})]})]})}function $p(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,"data-help-feishu":`what`,children:[(0,F.jsx)(`h4`,{children:`📄 它能做什么`}),(0,F.jsxs)(`p`,{children:[`主 Agent 多出两个工具,直接读写飞书(Feishu)云文档:`,(0,F.jsx)(`code`,{children:`feishu_doc_read`}),` 把一篇文档读成 Markdown(标题、列表、表格、代码都保留),`,(0,F.jsx)(`code`,{children:`feishu_doc_write`}),` 往文档里写。`]}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`读取:`}),`给文档链接(`,(0,F.jsx)(`code`,{children:`https://…feishu.cn/docx/…`}),` 或知识库的 `,(0,F.jsx)(`code`,{children:`/wiki/…`}),`)或文档 token 即可。知识库链接会自动解析。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`追加:`}),`在文末追加一段内容,不会动到已有内容。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`新建:`}),`用 Markdown 新建一篇文档,并给它一个标题。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`覆盖:`}),`整篇替换。这是唯一会丢失内容的模式,Agent 必须先读一次、再把读到的版本号带回来;这期间文档被别人改过,写入会被拒绝。`]})]}),(0,F.jsx)(`p`,{children:`用法就是直接说人话:「把这篇飞书文档读一下」「把结论整理成周报写回文档」。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,"data-help-feishu":`requirements`,children:[(0,F.jsx)(`h4`,{children:`🔑 需要什么`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`飞书官方的 CLI`}),`(`,(0,F.jsx)(`code`,{children:`@larksuite/cli`}),`,命令名 `,(0,F.jsx)(`code`,{children:`lark-cli`}),`)。Super Pi 通过它访问飞书,因此飞书那边有什么新能力,这里立刻就有。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`两次浏览器确认`}),`:第一次确认创建应用,第二次授权你的账号。`,(0,F.jsx)(`strong`,{children:`全程不用打开飞书开发者后台`}),`,不用申请权限点,也不用逐篇给文档加协作者。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`你的飞书账号`}),`:授权之后 Agent 以你的身份操作,所以你的文档天然可读可写。`]})]}),(0,F.jsxs)(`p`,{children:[`凭据由官方 CLI 保管在`,(0,F.jsx)(`strong`,{children:`系统钥匙串`}),`里。Super Pi 不保存、不显示、也不经手任何飞书密钥。`]})]}),(0,F.jsxs)(`div`,{className:`help-card`,"data-help-feishu":`connect`,children:[(0,F.jsx)(`h4`,{children:`🧭 怎么连上`}),(0,F.jsxs)(`p`,{children:[`在`,(0,F.jsx)(`strong`,{children:`设置 → 飞书`}),`里,面板会告诉你现在卡在哪一步,三步分别是:`]}),(0,F.jsxs)(`ol`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`装官方 CLI`}),`(已经装过就跳过):在终端运行 `,(0,F.jsx)(`code`,{children:`npm i -g @larksuite/cli`}),`。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`连接账号`}),`:点「连接飞书账号」,面板会给出确认链接;浏览器里确认后回到面板点「我已完成」。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`开始用`}),`:在对话里直接说「读一下这篇飞书文档」。`]})]}),(0,F.jsxs)(`p`,{children:[`面板上的`,(0,F.jsx)(`strong`,{children:`「测试连接」`}),`会真的去飞书问一次,能用就告诉你能用,不能用就告诉你卡在哪一步、该跑哪条命令。`]})]}),(0,F.jsxs)(`div`,{className:`help-card`,"data-help-feishu":`troubleshoot`,children:[(0,F.jsx)(`h4`,{children:`🛠 遇到问题`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`「没有检测到官方飞书 CLI」:`}),`先确认装过(`,(0,F.jsx)(`code`,{children:`lark-cli --version`}),` 能出版本号)。装过却找不到,是两边的 PATH 不一样——用环境变量 `,(0,F.jsx)(`code`,{children:`SUPER_PI_FEISHU_CLI`}),` 指向它的完整路径,再重启 Super Pi。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`「应用的凭据已经失效」:`}),`说明 CLI 里那个应用的 App Secret 过期或被撤了。点「重新连接」,CLI 会走一遍确认流程建一个新的可用应用,旧的之后可以在开发者后台删掉。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`「还没有登录你的账号」:`}),`点「连接飞书账号」用浏览器授权。授权之后就不用逐篇给文档加协作者了。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`读文档被拒绝:`}),`以你的身份连接时,你的文档应当直接可读;若仍被拒,多半是文档本身设置了访问限制,或连的是应用身份(面板里身份写着「应用」而不是「你的账号」)。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`覆盖被拒绝:`}),`文档在你读过之后被别人改了。重新读一次,把新的版本号再带回来即可。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,"data-help-feishu":`limits`,children:[(0,F.jsx)(`h4`,{children:`🚧 目前不覆盖的`}),(0,F.jsx)(`p`,{children:`这一版只做「读一篇文档、写一篇文档」。电子表格、多维表格、评论、附件与图片、消息与群聊,官方 CLI 都有对应命令,但这里没有把它们变成工具——需要时用官方 CLI 或官方技能更合适。`})]})]})}function em(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`🧩 工具是全局的`}),(0,F.jsxs)(`p`,{children:[`工具不属于某一个工作区,写好之后在每个工作区的“工具”Tab 里都能用。直接告诉 Agent 你想要什么,它会通过内置开发技能和 `,(0,F.jsx)(`code`,{children:`tool_register`}),` 一次性提交完整文件(index.html、JS/CSS,需要时再加 .py)。工具可以指定弹窗宽高;设置里的备用提示词适用于技能不可用的环境。`]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`本地计算怎么跑`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`工具页面里加载 `,(0,F.jsx)(`code`,{children:`./super-pi-tool.js`}),`,用 `,(0,F.jsx)(`code`,{children:`SuperPiTool.run(params)`}),`、`,(0,F.jsx)(`code`,{children:`get`}),`、`,(0,F.jsx)(`code`,{children:`wait`}),`、`,(0,F.jsx)(`code`,{children:`cancel`}),` 操作自己的 Python 任务。这些都是绑定本工具身份的相对接口,不要自己猜 id、不要调用 `,(0,F.jsx)(`code`,{children:`/api/exec`}),`。`]}),(0,F.jsxs)(`li`,{children:[`脚本参数以 JSON 从 stdin 传入,stdout 必须只输出一个 JSON 对象;页面通过 `,(0,F.jsx)(`code`,{children:`./api/runs/<id>`}),` 查看状态和日志。`]}),(0,F.jsxs)(`li`,{children:[`第三方 Python 包写进 `,(0,F.jsx)(`code`,{children:`environment.requires`}),`,并且必须钉死成 `,(0,F.jsx)(`code`,{children:`pkg==version`}),`;没钉死的会被拒绝并告诉你哪一个。它们装进`,(0,F.jsx)(`strong`,{children:`这个工具自己的虚拟环境`}),`,第一次真正运行时自动安装,装包过程就是这次运行的日志。`]}),(0,F.jsx)(`li`,{children:`环境对不上时不会拦住你运行,只会在工具列表里标出来。工具设置里的“环境就绪 / 缺少可用的 Python / 与导出方环境不一致”说的是事实,不是保证。`})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🤖 工具可以问模型`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`需要摘要、改写、抽取、分类时调用 `,(0,F.jsx)(`code`,{children:`SuperPiTool.llmText({ prompt, system })`}),`(或 `,(0,F.jsx)(`code`,{children:`llm`}),` + `,(0,F.jsx)(`code`,{children:`llmWait`}),` 两步、可取消),不用自己写客户端,也不用自己保管密钥——凭据和模型选择都在 Super Pi 这边。`]}),(0,F.jsxs)(`li`,{children:[`这是`,(0,F.jsx)(`strong`,{children:`补全,不是 Agent`}),`:回答问题的那个模型没有工具、拿不到你的文件、也读不到会话历史。`]}),(0,F.jsxs)(`li`,{children:[`必须显式授权:工具注册时声明 `,(0,F.jsx)(`code`,{children:`permissions: { llm: true }`}),`,否则服务端直接拒绝。这条授权会随工具文件一起分享,所以对方在导入之前就能看到“这个工具可以调用模型”,导入之后工具列表里也一直标着。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`📤 导出与导入`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`两个入口都在`,(0,F.jsx)(`strong`,{children:`工具设置`}),`里:上面一节列出已安装的全局工具(带环境状态),可以逐个导出;下面一节从文件导入。`]}),(0,F.jsxs)(`li`,{children:[`导出得到一个 `,(0,F.jsx)(`code`,{children:`xxx.super-pi-tool.json`}),`,文件名可以改(缺后缀会自动补上)。这个文件就是工具本身,可以直接发给别人。`]}),(0,F.jsxs)(`li`,{children:[`导入是`,(0,F.jsx)(`strong`,{children:`两步`}),`:先选文件,审阅卡会告诉你这个包里有哪些文件、含不含 Python 脚本、运行它要装什么、要哪些模型权限。你可以展开“查看文件”把每个文件读完——包括对方那个 `,(0,F.jsx)(`code`,{children:`.py`}),` 的原文——再决定要不要导入。`]}),(0,F.jsxs)(`li`,{children:[`如果 slug 和本机已有的工具重了,卡片上会多一个改名框;不改名(点取消)就是`,(0,F.jsx)(`strong`,{children:`不导入`}),`,不会悄悄换个名字装上。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`⚠️ 导入一个工具,等于接受一段代码`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`工具页面跑在不带 `,(0,F.jsx)(`code`,{children:`allow-same-origin`}),` 的 iframe 里,拿不到本站的登录态和 localStorage,也连不上外网。`]}),(0,F.jsxs)(`li`,{children:[`但 Python 那一侧`,(0,F.jsx)(`strong`,{children:`没有沙箱`}),`:脚本是以你的身份在你的机器上执行的,能读你的文件、能联网。所以含 Python 脚本的工具,审阅卡会明确写出这一点。`]}),(0,F.jsx)(`li`,{children:`工具里也没有作者署名和校验和——没有可信第三方,一个假的“已验证”标记比没有更糟。工具文件本身、加上你能读到的原文,就是全部依据。`}),(0,F.jsx)(`li`,{children:`删除工具会连同它的虚拟环境一起删掉。`})]})]})]})}function tm(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`⌨️ Pi 终端斜杠指令`}),(0,F.jsx)(`p`,{children:`在安装了 Super Pi 扩展的 Pi 终端会话内,支持以下指令:`}),(0,F.jsxs)(`div`,{className:`help-command-table`,children:[(0,F.jsxs)(`div`,{className:`cmd-row`,children:[(0,F.jsx)(`code`,{children:`/super_pi`}),(0,F.jsx)(`span`,{children:`后台守护启动 Super Pi 服务(端口 3080)并自动在默认浏览器中打开`})]}),(0,F.jsxs)(`div`,{className:`cmd-row`,children:[(0,F.jsx)(`code`,{children:`/super_pi restart`}),(0,F.jsx)(`span`,{children:`重启后台 Super Pi Web 控制平面服务`})]}),(0,F.jsxs)(`div`,{className:`cmd-row`,children:[(0,F.jsx)(`code`,{children:`/super_pi stop`}),(0,F.jsx)(`span`,{children:`安全停止后台常驻的 Super Pi 服务`})]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`📦 扩展包安装与更新`}),(0,F.jsx)(`pre`,{className:`help-code-block`,children:(0,F.jsx)(`code`,{children:`# 在 Pi 中一键安装 Super Pi 扩展
|
|
305
|
+
pi install npm:@evandu/super-pi
|
|
306
|
+
|
|
307
|
+
# 检查已安装插件列表
|
|
308
|
+
pi list
|
|
309
|
+
|
|
310
|
+
# 升级 Super Pi 到最新版本
|
|
311
|
+
pi update npm:@evandu/super-pi
|
|
312
|
+
|
|
313
|
+
# 独立启动(无需 Pi 环境)
|
|
314
|
+
npx @evandu/super-pi`})})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🎯 键盘快捷键`}),(0,F.jsxs)(`div`,{className:`help-command-table`,children:[(0,F.jsxs)(`div`,{className:`cmd-row`,children:[(0,F.jsx)(`code`,{children:`Enter`}),(0,F.jsx)(`span`,{children:`发送对话消息`})]}),(0,F.jsxs)(`div`,{className:`cmd-row`,children:[(0,F.jsx)(`code`,{children:`Shift + Enter`}),(0,F.jsx)(`span`,{children:`输入框内换行`})]}),(0,F.jsxs)(`div`,{className:`cmd-row`,children:[(0,F.jsx)(`code`,{children:`Esc`}),(0,F.jsx)(`span`,{children:`快速关闭当前顶层弹窗(使用指南、设置、工作区选择器等)`})]})]})]})]})}function nm(){return(0,F.jsx)(`div`,{className:`help-section-group`,children:(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🎨 4 款主题,来自 VSCode 流行主题`}),(0,F.jsxs)(`div`,{className:`help-theme-list`,children:[(0,F.jsxs)(`div`,{className:`help-theme-item`,children:[(0,F.jsx)(`strong`,{children:`🟣 Dracula`}),(0,F.jsx)(`p`,{children:`紫调暗色,饱满对比,适合夜间专注编程。`})]}),(0,F.jsxs)(`div`,{className:`help-theme-item`,children:[(0,F.jsx)(`strong`,{children:`🟠 Monokai`}),(0,F.jsx)(`p`,{children:`暖调暗色,橙红点缀,经典编辑器风格。`})]}),(0,F.jsxs)(`div`,{className:`help-theme-item`,children:[(0,F.jsx)(`strong`,{children:`🟡 Solarized Light`}),(0,F.jsx)(`p`,{children:`暖黄米色调,柔和护眼,适合长时间阅读。`})]}),(0,F.jsxs)(`div`,{className:`help-theme-item`,children:[(0,F.jsx)(`strong`,{children:`🔵 GitHub Light`}),(0,F.jsx)(`p`,{children:`冷调浅色,中性清晰,日常办公首选。`})]})]}),(0,F.jsxs)(`p`,{className:`help-hint`,children:[`可在左侧栏底部的 `,(0,F.jsx)(`strong`,{children:`⚙ 设置`}),` 中一键切换主题,设置会自动持久化保存在本地。`]})]})})}function rm(){let[e,t]=(0,u.useState)(),[n,r]=(0,u.useState)(``),[i,a]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{window.superPiDesktop?.status().then(t).catch(()=>r(`无法读取桌面运行状态`))},[]),(0,F.jsx)(`div`,{className:`server-connections-panel`,children:(0,F.jsxs)(`section`,{className:`server-connection-card`,children:[(0,F.jsx)(`h4`,{children:window.superPiDesktop?`Super Pi 桌面端`:`桌面端与浏览器共用同一套工作台`}),(0,F.jsx)(`p`,{children:`完整 npm 包已包含桌面端,无需另装增强包。桌面窗口和浏览器连接同一本地入口时,共用 SSH 托管列表、模型配置、会话与文件;已有服务的直接连接列表保存在各自浏览器中。`}),e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:e.autoStart,disabled:i,onChange:async n=>{let i=n.target.checked;a(!0),r(``);try{let n=await window.superPiDesktop.setAutoStart(i);t({...e,autoStart:n.autoStart})}catch{r(`无法修改开机自启,请检查系统权限`)}finally{a(!1)}}}),`登录系统后自动启动并保持后台运行`]}),(0,F.jsx)(`p`,{children:`关闭窗口会隐藏到托盘;本地管理服务与 SSH 连接继续运行。`}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>void window.superPiDesktop?.openBrowser(),children:`在浏览器打开同一工作台`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void window.superPiDesktop?.minimize(),children:`隐藏到托盘`})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{children:`在管理电脑运行:`}),(0,F.jsx)(`code`,{children:`super_pi desktop`}),(0,F.jsxs)(`p`,{children:[`首次启动需要下载桌面运行时。服务器只需要安装轻量的 `,(0,F.jsx)(`code`,{children:`@evandu/super-pi-server`}),`;通过 SSH 托管时会自动选择轻量包。`]})]}),n&&(0,F.jsx)(`p`,{role:`alert`,className:`server-connection-error`,children:n})]})})}function im({workspaceId:e,onClose:t}){let[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(`memory`),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)([]),C=`${e}:${h}:${_}`,w=(0,u.useRef)(C);w.current=C;let T=(0,u.useRef)(0);async function E(t){if(!e)return;let n=++T.current;s(!0),a(``);try{let i=await je(`/api/memory?workspaceId=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t??{},contextConversationId:h||void 0,includeArchived:_})}),a=await i.json();if(!i.ok)throw Error(a.error);return w.current!==C||n!==T.current?!1:(r(a),(c===`role`&&!a.context.agentId||c===`tree`&&!a.context.treeId||c===`session`&&!a.context.conversationId)&&l(`memory`),!0)}catch(e){return w.current===C&&n===T.current&&a(ct(e,`记忆读取失败。`)),!1}finally{w.current===C&&n===T.current&&s(!1)}}return(0,u.useEffect)(()=>{g(``)},[e]),(0,u.useEffect)(()=>{r(void 0),m(void 0),f(``),S([]),b(!1),!h&&[`role`,`tree`,`session`].includes(c)&&l(`memory`),E()},[e,h,_]),e?(0,F.jsxs)(`section`,{"data-memory-panel":`1`,className:`settings-panel-container`,children:[(0,F.jsx)(`div`,{className:`settings-agents-header`,children:(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`工程经验跨项目共享,每条附来源和适用条件。任务结论在会话树内共享,会话笔记保持独立。每轮按相关性召回。`})}),i&&(0,F.jsx)(`div`,{className:`settings-dir-error`,role:`alert`,children:i}),n&&(0,F.jsxs)(`fieldset`,{disabled:o,className:`settings-memory-fieldset`,children:[(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`主动记忆机制配置`}),(0,F.jsxs)(`div`,{className:`settings-memory-switches`,children:[(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:n.settings.enabled,onChange:e=>void E({action:`configure`,settings:{...n.settings,enabled:e.target.checked}})}),`启用主动记忆`]}),(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:n.settings.writeApproval,onChange:e=>void E({action:`configure`,settings:{...n.settings,writeApproval:e.target.checked}})}),`Agent 写入均需审批`]})]}),(0,F.jsxs)(`label`,{className:`settings-memory-interval-label`,children:[`每轮召回预算(token 上限估算)`,(0,F.jsx)(`input`,{"aria-label":`召回预算`,type:`number`,min:`2048`,max:`16000`,className:`settings-dir-input settings-interval-input`,value:n.settings.recallBudgetTokens,onChange:e=>r({...n,settings:{...n.settings,recallBudgetTokens:Number(e.target.value)}})}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,onClick:()=>void E({action:`configure`,settings:n.settings}),children:`保存预算`})]}),(0,F.jsxs)(`div`,{className:`settings-memory-interval-row`,style:{marginTop:10},children:[(0,F.jsxs)(`label`,{className:`settings-memory-interval-label`,children:[`复盘间隔(用户回合,0 为关闭):`,(0,F.jsx)(`input`,{"aria-label":`复盘间隔`,type:`number`,min:`0`,className:`settings-dir-input settings-interval-input`,value:n.settings.reviewInterval,onChange:e=>r({...n,settings:{...n.settings,reviewInterval:Number(e.target.value)}})})]}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,onClick:()=>void E({action:`configure`,settings:n.settings}),children:`保存间隔`})]})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsxs)(`label`,{className:`settings-memory-interval-label`,children:[`记忆上下文`,(0,F.jsxs)(`select`,{"aria-label":`记忆上下文`,className:`settings-memory-select`,value:h,onChange:e=>g(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`工作区与全局`}),n.contexts.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[e.title,e.agentId?` · ${e.agentId}`:``]},e.id))]})]}),(0,F.jsxs)(`div`,{className:`settings-memory-category-header`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`记忆条目管理`}),(0,F.jsxs)(`select`,{"aria-label":`记忆类别`,className:`settings-memory-select`,value:c,onChange:e=>{l(e.target.value),m(void 0),f(``),S([]),b(!1)},children:[(0,F.jsx)(`option`,{value:`user`,children:`用户档案(全局共享)`}),(0,F.jsx)(`option`,{value:`experience`,children:`工程经验(全局参考)`}),(0,F.jsx)(`option`,{value:`memory`,children:`工作区事实(当前工作区)`}),(0,F.jsx)(`option`,{value:`skills`,children:`技能(当前工作区)`}),(0,F.jsx)(`option`,{value:`role`,disabled:!n.context.agentId,children:`角色笔记(所选会话角色)`}),(0,F.jsx)(`option`,{value:`tree`,disabled:!n.context.treeId,children:`共享任务记忆(所选会话树)`}),(0,F.jsx)(`option`,{value:`session`,disabled:!n.context.conversationId,children:`工作笔记(所选会话)`})]})]}),(0,F.jsxs)(`p`,{className:`settings-agents-desc`,"data-memory-usage":`1`,children:[`活跃内容 `,n.usage[c]?.used??0,` / `,n.usage[c]?.limit??0,` 字符;存储配额与每轮召回预算独立。`]}),(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{"aria-label":`显示归档记忆`,type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),`显示归档条目`]}),(n.entries[c]??[]).length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`当前类别暂无条目。在下方输入内容即可添加。`}):(0,F.jsx)(`div`,{className:`settings-memory-entries-list`,children:(n.entries[c]??[]).map(e=>(0,F.jsxs)(`article`,{"data-memory-entry":e.id,className:`settings-memory-card`,children:[(0,F.jsxs)(`div`,{className:`settings-memory-card-main`,children:[(0,F.jsx)(`pre`,{className:`settings-memory-content`,children:e.content}),e.experience&&(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[`来源 `,e.experience.projectName??e.experience.workspaceName,` · 适用条件 `,e.experience.applicability]}),(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[e.archivedAt?`已归档`:e.pinned?`核心记忆`:`按需召回`,` · 版本 `,e.revision??1,e.conversationId?` · 来源 ${e.conversationId}`:``]})]}),(0,F.jsxs)(`div`,{className:`settings-memory-card-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-edit-btn`,disabled:!!e.archivedAt,onClick:()=>{m(e.id),f(e.content),b(!!e.pinned),S([])},children:`编辑`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-edit-btn`,onClick:()=>void E({action:`write`,operation:{target:c,action:e.archivedAt?`restore`:`archive`,id:e.id,expectedRevision:e.revision??1}}),children:e.archivedAt?`恢复`:`归档`}),!e.archivedAt&&(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{"aria-label":`选择整理 ${e.id}`,type:`checkbox`,checked:x.includes(e.id),onChange:t=>S(t.target.checked?[...x,e.id]:x.filter(t=>t!==e.id))}),`选择整理`]}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-remove-btn`,onClick:()=>void E({action:`write`,operation:{target:c,action:`remove`,id:e.id,expectedRevision:e.revision??1}}),children:`删除`})]})]},e.id))}),(0,F.jsxs)(`div`,{className:`settings-memory-editor`,style:{marginTop:12},children:[(0,F.jsx)(`h5`,{className:`settings-memory-editor-title`,children:p?`编辑条目`:`添加新条目`}),(0,F.jsx)(`textarea`,{"aria-label":`记忆内容`,className:`settings-memory-textarea`,placeholder:c===`skills`?`# 技能名称
|
|
315
|
+
已验证的步骤、命令和注意事项`:`输入长期有效的事实或偏好`,value:d,onChange:e=>f(e.target.value)}),(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{"aria-label":`核心记忆`,type:`checkbox`,checked:y,onChange:e=>b(e.target.checked)}),`核心记忆(预算内优先召回)`]}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`settings-dir-add-btn`,disabled:!d.trim(),onClick:async()=>{await E({action:`write`,operation:{target:c,action:p?`replace`:`add`,id:p,content:d,pinned:y,expectedRevision:n.entries[c]?.find(e=>e.id===p)?.revision??1}})&&(m(void 0),f(``),b(!1))},children:[`保存`,p?`修改`:`新条目`]}),x.length>=2&&(0,F.jsxs)(`button`,{type:`button`,className:`settings-dir-add-btn`,disabled:!d.trim(),onClick:async()=>{await E({action:`write`,operation:{target:c,action:`consolidate`,ids:x,content:d,pinned:y,expectedRevisions:Object.fromEntries(n.entries[c].filter(e=>x.includes(e.id)).map(e=>[e.id,e.revision??1]))}})&&(S([]),f(``),m(void 0))},children:[`合并所选 `,x.length,` 条并归档原文`]}),p&&(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-cancel-btn`,onClick:()=>{m(void 0),f(``)},children:`取消编辑`})]})]})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsxs)(`h4`,{className:`settings-section-title`,children:[`待审批提案(共 `,n.pending.length,` 个)`]}),n.pending.length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`暂无待审批提案。`}):(0,F.jsx)(`div`,{className:`settings-dirs-list`,children:n.pending.map(e=>(0,F.jsxs)(`article`,{"data-memory-proposal":e.id,className:`settings-proposal-card`,children:[(0,F.jsxs)(`div`,{className:`settings-proposal-header`,children:[(0,F.jsx)(`span`,{className:`settings-proposal-badge`,children:e.operation.target}),(0,F.jsx)(`span`,{className:`settings-proposal-action`,children:e.operation.action})]}),e.previous&&(0,F.jsxs)(`pre`,{className:`settings-proposal-diff old`,children:[`原内容:`,e.previous]}),(0,F.jsx)(`pre`,{className:`settings-proposal-diff new`,children:e.operation.content}),(0,F.jsxs)(`div`,{className:`settings-proposal-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-edit-btn`,onClick:()=>void E({action:`approve`,proposalId:e.id}),children:`批准`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-remove-btn`,onClick:()=>void E({action:`discard`,proposalId:e.id}),children:`拒绝`})]})]},e.id))})]})]}),t&&(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:t,children:`完成`})})]}):(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`请先在主界面选择工作区以管理其专属记忆与技能。`})}function am({workspaceId:e,onClose:t,onPick:n}){let[r,i]=(0,u.useState)(),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(),m=(0,u.useRef)(0);async function h(t){let n=++m.current;o(!0),c(``);try{let r=await je(`/api/files?workspaceId=${encodeURIComponent(e)}${t?`&path=${encodeURIComponent(t)}`:``}`),a=await r.json();if(!r.ok)throw Error(a.error??`HTTP ${r.status}`);if(n!==m.current)return;i(a),p(void 0)}catch(e){n===m.current&&c(ct(e,`这个目录读取失败。`))}finally{n===m.current&&o(!1)}}(0,u.useEffect)(()=>{h()},[e]),(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.isComposing&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let g=l.trim().toLocaleLowerCase(),_=(0,u.useMemo)(()=>(r?.entries??[]).filter(e=>e.kind===`directory`||e.kind===`file`&&(e.text||e.document)&&!e.outside),[r]),v=g?_.filter(e=>e.name.toLocaleLowerCase().includes(g)):_;return(0,F.jsx)(`div`,{className:`overlay`,onClick:t,children:(0,F.jsxs)(`div`,{className:`picker knowledge-picker`,"data-knowledge-picker":`1`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-label":`选择要导入的文档`,children:[(0,F.jsx)(`h2`,{children:`选择要导入的文档`}),(0,F.jsxs)(`div`,{className:`picker-path-bar`,children:[(0,F.jsx)(`input`,{"aria-label":`按文件名过滤`,className:`picker-path-input`,placeholder:`按文件名过滤…`,value:l,onChange:e=>d(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,className:`picker-up-btn`,disabled:!r||r.parent===null||a,onClick:()=>void h(r?.parent??void 0),"aria-label":`上一级`,children:`↑`})]}),(0,F.jsx)(`div`,{className:`picker-status`,"data-knowledge-picker-path":r?.path??``,children:r?r.path||`工作区根目录`:`读取中…`}),s&&(0,F.jsx)(`div`,{className:`picker-error`,role:`alert`,children:s}),(0,F.jsx)(`div`,{className:`picker-list`,"data-knowledge-picker-list":v.length,children:v.length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:g?`没有匹配的文件。`:`这个目录里没有可导入的文件。`}):v.map(e=>e.kind===`directory`?(0,F.jsxs)(`button`,{type:`button`,className:`picker-dir`,"data-knowledge-picker-dir":e.path,onClick:()=>void h(e.path),children:[`📁 `,e.name]},e.path):(0,F.jsxs)(`button`,{type:`button`,className:`picker-dir`,"data-knowledge-picker-file":e.path,"data-knowledge-picker-document":e.document?`1`:void 0,"aria-pressed":f===e.path,onClick:()=>p(e.path),onDoubleClick:()=>n(e.path),children:[e.document?`📕 文档`:`📄`,` `,e.name]},e.path))}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:t,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-ok`,disabled:!f,"data-knowledge-picker-ok":f??``,onClick:()=>{f&&n(f)},children:`导入这个文档`})]})]})})}function om({workspaceId:e,onClose:t}){let[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!1),y=(0,u.useRef)(e);y.current=e;let b=(0,u.useRef)(0);async function x(t){if(!e)return;let n=++b.current;s(!0),a(``);try{let i=await je(`/api/knowledge?workspaceId=${encodeURIComponent(e)}`,{method:t?`POST`:`GET`,headers:{"Content-Type":`application/json`},...t?{body:JSON.stringify(t)}:{}}),a=await i.json();if(!i.ok)throw Error(a.error);return y.current!==e||n!==b.current?!1:(r(a),!0)}catch(t){return y.current===e&&n===b.current&&a(ct(t,`知识库读取失败。`)),!1}finally{y.current===e&&n===b.current&&s(!1)}}if((0,u.useEffect)(()=>{r(void 0),l(``),f(``),m(``),g(``),x()},[e]),!e)return(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`请先在主界面选择工作区以管理它的知识库。`});let S=n?.documents??[],C=S.reduce((e,t)=>e+t.characters,0),w=n?.semantic,T=w?w.enabled?w.error?`不可用:${ct(w.error,`本地语义模型没有加载成功`)};已退回关键词检索`:w.ready?`已就绪,已索引 ${w.indexed} 个片段`:w.bundled===!1?`随包分发的模型缺失;已退回关键词检索`:`首次检索时加载本地模型,之后一直可用`:`已关闭(SUPER_PI_KNOWLEDGE_EMBEDDINGS=0)`:`未启用`;return(0,F.jsxs)(`section`,{"data-knowledge-panel":`1`,className:`settings-panel-container`,children:[(0,F.jsx)(`div`,{className:`settings-agents-header`,children:(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[(0,F.jsx)(`strong`,{children:`项目自己的文档。`}),` 浏览工作区里的规范、设计稿、会议纪要导入进来,Agent 就能在回答前检索原文,而不是凭记忆编造。文档按当前工作区隔离,检索结果只回传片段而不回传全文。关键词检索始终可用;语义检索能在用词不同的情况下找到片段,但代价是首次使用要下载一个本地模型。`]})}),(0,F.jsxs)(`div`,{className:`settings-dir-info`,"data-knowledge-semantic":w?w.error?`unavailable`:w.ready?`ready`:`loading`:`off`,title:w?.error,children:[`语义检索:`,T]}),i&&(0,F.jsx)(`div`,{className:`settings-dir-error`,role:`alert`,children:i}),n&&(0,F.jsxs)(`fieldset`,{disabled:o,className:`settings-memory-fieldset`,children:[(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsxs)(`h4`,{className:`settings-section-title`,children:[`从工作区文件导入(`,S.length,` 篇,共 `,C,` 字符)`]}),(0,F.jsxs)(`div`,{className:`settings-add-dir-form`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-knowledge-browse":`1`,onClick:()=>v(!0),children:`浏览工作区文件…`}),(0,F.jsx)(`span`,{className:`settings-dir-info`,children:`在工作区里挑选一个 Markdown 或文本文件`})]}),(0,F.jsxs)(`div`,{className:`settings-add-dir-form`,style:{marginTop:8},children:[(0,F.jsx)(`input`,{"aria-label":`文档路径`,className:`settings-dir-input`,placeholder:`或直接填写相对路径,例如 docs/design.md`,value:c,onChange:e=>l(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,disabled:!c.trim(),onClick:async()=>{await x({action:`add`,path:c})&&l(``)},children:`导入`})]}),(0,F.jsxs)(`div`,{className:`settings-memory-editor`,style:{marginTop:12},children:[(0,F.jsx)(`h5`,{className:`settings-memory-editor-title`,children:`或者直接粘贴正文`}),(0,F.jsx)(`input`,{"aria-label":`文档标题`,className:`settings-dir-input`,placeholder:`标题(留空则取正文首行)`,value:d,onChange:e=>f(e.target.value)}),(0,F.jsx)(`textarea`,{"aria-label":`文档正文`,className:`settings-memory-textarea`,placeholder:`以 # 开头的标题会成为检索结果里的段落归属`,value:p,onChange:e=>m(e.target.value)}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,disabled:!p.trim(),onClick:async()=>{await x({action:`add`,title:d,text:p})&&(f(``),m(``))},children:`保存文档`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-cancel-btn`,onClick:()=>{f(``),m(``)},children:`清空`})]})]})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`已导入文档`}),S.length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`还没有文档。导入后,下一条消息起 Agent 就能检索到它们。`}):(0,F.jsx)(`div`,{className:`settings-dirs-list`,children:S.map(e=>(0,F.jsxs)(`article`,{"data-knowledge-document":e.id,className:`settings-memory-card`,children:[(0,F.jsxs)(`div`,{className:`settings-dir-row`,children:[(0,F.jsx)(`span`,{className:`settings-dir-tag`,children:e.format||`txt`}),(0,F.jsx)(`span`,{className:`settings-dir-path`,children:e.title}),(0,F.jsxs)(`span`,{className:`settings-dir-count`,children:[e.characters,` 字符`]})]}),(0,F.jsx)(`div`,{className:`settings-dir-info`,children:e.source}),(0,F.jsx)(`div`,{className:`settings-memory-card-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-remove-btn`,onClick:()=>void x({action:`remove`,documentId:e.id}),children:`删除`})})]},e.id))})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`试检索`}),(0,F.jsxs)(`div`,{className:`settings-add-dir-form`,children:[(0,F.jsx)(`input`,{"aria-label":`检索词`,className:`settings-dir-input`,placeholder:`用和提问时相同的措辞试试`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h.trim()&&x({action:`search`,query:h})}}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,disabled:!h.trim(),onClick:()=>void x({action:`search`,query:h}),children:`检索`})]}),h.trim()&&(n?.hits?.length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`没有命中。知识库确实没有这段内容——Agent 也会得到同样的空结果。`}):(0,F.jsx)(`div`,{className:`settings-memory-entries-list`,children:(n?.hits??[]).map(e=>(0,F.jsxs)(`article`,{"data-knowledge-hit":`${e.documentId}#${e.chunk}`,className:`settings-memory-card`,children:[(0,F.jsxs)(`div`,{className:`settings-dir-row`,children:[(0,F.jsx)(`span`,{className:`settings-dir-tag`,children:e.title}),(0,F.jsxs)(`span`,{className:`settings-dir-count`,title:`相关度(越高越接近)`,children:[`相关度 `,e.score.toFixed(2)]})]}),e.heading&&(0,F.jsx)(`div`,{className:`settings-dir-info`,children:e.heading}),(0,F.jsx)(`pre`,{className:`settings-memory-content`,children:e.text})]},`${e.documentId}#${e.chunk}`))}))]})]}),t&&(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:t,children:`完成`})}),_&&(0,F.jsx)(am,{workspaceId:e,onClose:()=>v(!1),onPick:async e=>{v(!1),await x({action:`add`,path:e})&&l(``)}})]})}function sm(){let[e,t]=(0,u.useState)(),[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(!1),d=(0,u.useCallback)(async()=>{try{let e=await je(`/api/feishu/status`),n=await e.json();if(!e.ok)throw Error(n.error??`读取飞书状态失败`);t(n)}catch(e){s(ct(e,`读取飞书状态失败。`))}},[]);(0,u.useEffect)(()=>{d()},[d]);let f=async()=>{l(!0),a(``),s(``),r(void 0);try{let e=await je(`/api/feishu/connect`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.message??`连接失败`);r(t)}catch(e){s(ct(e,`连接飞书账号失败。`))}finally{l(!1)}},p=async()=>{l(!0),a(``),s(``);try{let e=await je(`/api/feishu/connect/complete`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.message??`完成连接失败`);r(void 0),a(t.message),await d()}catch(e){s(ct(e,`完成连接失败。`))}finally{l(!1)}},m=async()=>{l(!0),a(``),s(``);try{let e=await je(`/api/feishu/verify`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.message??`测试失败`);a(t.ok?t.message:`还没连上:${t.message}`),!t.ok&&t.hint&&s(t.hint),await d()}catch(e){s(ct(e,`测试飞书连接失败。`))}finally{l(!1)}},h=e?.step??1,g=e?.installed===!0,_=e?.connected===!0,v=e=>e<h?`done`:e===h?`current`:`pending`;return(0,F.jsxs)(`section`,{"data-feishu-panel":`1`,className:`settings-panel-container`,children:[(0,F.jsx)(`div`,{className:`settings-agents-header`,children:(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[(0,F.jsx)(`strong`,{children:`让 Agent 直接读写飞书云文档。`}),` 通过飞书官方的 CLI(`,(0,F.jsx)(`code`,{children:`lark-cli`}),`)接入:授权一次之后,Agent 就能用 feishu_doc_read 读一篇飞书文档、用 feishu_doc_write 追加或改写它。凭据由官方 CLI 保管在系统钥匙串里,Super Pi 不接触、不保存、也不显示。`]})}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`连接状态`}),(0,F.jsxs)(`div`,{className:`settings-dir-info`,"data-feishu-status":e?_?`connected`:g?`not-connected`:`not-installed`:void 0,children:[e?.message??`正在读取飞书 CLI 的状态…`,e?.version?`(CLI ${e.version})`:``,e?.appId?` 应用 ${e.appId}`:``,e?.identity?` 身份 ${e.identity===`user`?`你的账号`:`应用`}`:``]}),e?.detail&&(0,F.jsx)(`div`,{className:`settings-dir-info`,"data-feishu-detail":`1`,children:e.detail}),e?.hint&&(0,F.jsx)(`div`,{className:`settings-dir-info`,"data-feishu-hint":`1`,children:e.hint}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,style:{marginTop:8},children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-feishu-connect":`1`,disabled:c||!g,onClick:()=>void f(),children:e?.rebuild?`重新连接`:`连接飞书账号`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-feishu-verify":`1`,disabled:c||!g,onClick:()=>void m(),children:`测试连接`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-cancel-btn`,"data-feishu-refresh":`1`,disabled:c,onClick:()=>void d(),children:`刷新状态`})]}),i&&(0,F.jsx)(`div`,{className:`settings-dir-info`,"data-feishu-message":`1`,children:i}),o&&(0,F.jsx)(`div`,{className:`settings-dir-error`,role:`alert`,"data-feishu-error":`1`,children:o})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`怎么连上`}),(0,F.jsxs)(`ol`,{className:`settings-agents-desc`,children:[(0,F.jsxs)(`li`,{"data-feishu-step":`1`,"data-feishu-step-state":v(1),children:[(0,F.jsx)(`b`,{children:`装官方 CLI。`}),`在终端里运行一次:`,(0,F.jsx)(`div`,{className:`settings-dir-input`,"data-feishu-install":`1`,children:`npm i -g @larksuite/cli`}),`已经装过就跳过这步。若 Super Pi 找不到它(两边的 PATH 不一样),用环境变量 `,(0,F.jsx)(`code`,{children:`SUPER_PI_FEISHU_CLI`}),` 指向它的完整路径再重启 Super Pi。`]}),(0,F.jsxs)(`li`,{"data-feishu-step":`2`,"data-feishu-step-state":v(2),children:[(0,F.jsx)(`b`,{children:`连上你的账号。`}),`点上面的「连接飞书账号」:浏览器里会打开一个确认链接(第一次是确认创建应用,之后是授权你的账号),确认完回到这里点「我已完成」。整个过程不用打开飞书开发者后台。`]}),(0,F.jsxs)(`li`,{"data-feishu-step":`3`,"data-feishu-step-state":v(3),children:[(0,F.jsx)(`b`,{children:`开始用。`}),`在对话里直接说「把这篇飞书文档读一下」「把结论写回文档」就行。Agent 以你的身份操作,你自己的文档不需要逐篇授权。`]})]}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`完整说明和常见问题在右侧「使用指南 → 飞书」里。`})]}),n&&(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:n.step===`app`?`确认创建应用`:`确认授权`}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:n.message}),n.verificationUri&&(0,F.jsx)(`a`,{className:`settings-dir-add-btn`,"data-feishu-verify-link":`1`,href:n.verificationUri,target:`_blank`,rel:`noreferrer`,children:`打开授权链接`}),n.hint&&(0,F.jsx)(`div`,{className:`settings-dir-info`,children:n.hint}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,style:{marginTop:8},children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-feishu-complete":`1`,disabled:c,onClick:()=>void p(),children:`我已完成`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-cancel-btn`,disabled:c,onClick:()=>r(void 0),children:`取消`})]})]})]})}var cm=e=>![`google`,`google-vertex`].includes(e.id)&&![`google-generative-ai`,`google-vertex`].includes(e.api);async function lm(e){let t=await e.json();if(!e.ok)throw Error(t.error||`代理设置请求失败`);return t}function um({providers:e}){let[t,n]=(0,u.useState)(),[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)([]),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(!1),g=`/api/providers/network`,_=e=>{n(e),i(e.hasAuth?``:e.httpProxy),c(e.providers),o(!1)};(0,u.useEffect)(()=>{let e=new AbortController;return je(g,{signal:e.signal}).then(lm).then(t=>{e.signal.aborted||_(t)}).catch(t=>{e.signal.aborted||p(t instanceof Error?t.message:`读取失败`)}),()=>e.abort()},[]);let v=async()=>{if(l||!t)return;d(!0),p(``),h(!1);let n={providers:s.filter(t=>e.some(e=>e.id===t&&cm(e))),...a?{httpProxy:r}:{}};try{_(await je(g,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}).then(lm)),h(!0)}catch(e){p(e instanceof Error?e.message:`保存失败`)}finally{d(!1)}};return(0,F.jsxs)(`section`,{className:`provider-network`,"data-provider-network":!0,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`代理`}),(0,F.jsxs)(`div`,{className:`provider-network-form`,children:[(0,F.jsx)(`p`,{children:`地址只需填写一次,再勾选使用代理的供应商。保存后,未勾选的供应商直连。`}),(0,F.jsx)(`p`,{children:`支持 HTTP / HTTPS 代理,模型的 HTTP 和 HTTPS 请求共用此地址。127.0.0.1 指 Super Pi 服务端本机。`}),!t&&!f&&(0,F.jsx)(`p`,{role:`status`,children:`正在读取代理设置…`}),t&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`代理地址`}),(0,F.jsx)(`input`,{className:`settings-dir-input`,"data-provider-network-http":!0,autoComplete:`off`,value:r,disabled:l,placeholder:t.hasAuth?`已配置认证代理 ${t.httpProxy},留空保留`:`http://127.0.0.1:7890`,onChange:e=>{i(e.target.value),o(!0),h(!1)}})]}),(0,F.jsxs)(`fieldset`,{className:`provider-network-providers`,disabled:l,children:[(0,F.jsx)(`legend`,{children:`使用代理的供应商`}),e.length===0&&(0,F.jsx)(`p`,{children:`添加供应商后即可在这里勾选。`}),e.map(e=>(0,F.jsxs)(`label`,{className:`provider-network-choice`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-provider-network-choice":e.id,disabled:!cm(e),checked:cm(e)&&s.includes(e.id),onChange:t=>{c(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),h(!1)}}),(0,F.jsxs)(`span`,{children:[e.name||e.id,e.name&&e.name!==e.id?` (${e.id})`:``,e.disabled?` · 已停用`:``,cm(e)?``:` · 原生 SDK 暂不支持此代理`]})]},e.id))]}),(0,F.jsx)(`div`,{className:`provider-network-actions`,children:(0,F.jsx)(`button`,{type:`button`,"data-provider-network-save":!0,disabled:l,onClick:()=>void v(),children:l?`正在保存…`:`保存代理设置`})})]}),f&&(0,F.jsx)(`p`,{className:`provider-network-warning`,role:`alert`,children:f}),m&&(0,F.jsx)(`p`,{role:`status`,"data-provider-network-saved":!0,children:`已保存,后续请求使用新设置。`})]})]})}async function dm(e){let t=await e.json();if(!e.ok)throw Error(t.error??`Tavily 设置请求失败。`);return t}function fm(){let[e,t]=(0,u.useState)(),[n,r]=(0,u.useState)(``),[i,a]=(0,u.useState)(!1),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(``),d=(0,u.useCallback)(async()=>{s(``);try{t(await je(`/api/tavily/settings`,{cache:`no-store`}).then(dm))}catch(e){s(e instanceof Error?e.message:`读取 Tavily 状态失败。`)}},[]);(0,u.useEffect)(()=>{d()},[d]);let f=async e=>{if(e.preventDefault(),!i&&n.trim()){a(!0),s(``),l(``);try{let e=await je(`/api/tavily/settings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`connect`,apiKey:n})}).then(dm);r(``),t(e),l(`Tavily 已连接。后续 Agent 会自动获得网页搜索工具。`)}catch(e){s(e instanceof Error?e.message:`连接 Tavily 失败。`)}finally{a(!1)}}},p=async()=>{if(!i){a(!0),s(``),l(``);try{let e=await je(`/api/tavily/settings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`disconnect`})}).then(dm);t(e),l(`已断开 Tavily,网页搜索工具已从 Agent 工具列表中移除。`)}catch(e){s(e instanceof Error?e.message:`断开 Tavily 失败。`)}finally{a(!1)}}};return(0,F.jsxs)(`section`,{className:`tavily-settings`,"data-tavily-panel":!0,children:[(0,F.jsx)(`p`,{className:`tavily-description`,children:`连接自己的 Tavily 账号,让 Agent 使用你的搜索额度。API key 保存在 Super Pi 服务端,不会交给 Agent。`}),(0,F.jsxs)(`section`,{className:`tavily-section`,children:[(0,F.jsxs)(`div`,{className:`tavily-section-heading`,children:[(0,F.jsx)(`h4`,{children:`连接状态`}),(0,F.jsxs)(`div`,{className:`tavily-actions`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:i||!e,onClick:()=>void d(),children:`刷新状态`}),e?.configured&&(0,F.jsx)(`button`,{type:`button`,"data-tavily-disconnect":!0,disabled:i,onClick:()=>void p(),children:`断开并删除 key`})]})]}),(0,F.jsx)(`p`,{className:`tavily-status`,role:`status`,"data-tavily-status":e?e.connected?`connected`:e.configured?`invalid`:`disconnected`:`loading`,children:e?e.connected?`已连接${e.keyHint?`(${e.keyHint})`:``}`:e.configured?`已保存的 key 暂时无法验证`:`未连接;Agent 不会看到网页搜索工具`:`正在读取 Tavily 状态…`}),e?.usage&&(0,F.jsxs)(`p`,{className:`tavily-description`,"data-tavily-usage":!0,children:[e.usage.plan?`${e.usage.plan} · `:``,`已用 `,e.usage.used.toLocaleString(),` / `,e.usage.limit.toLocaleString(),` credits,剩余 `,e.usage.remaining.toLocaleString()]}),e?.error&&(0,F.jsx)(`p`,{className:`tavily-feedback`,role:`status`,children:e.error})]}),!e?.configured&&(0,F.jsxs)(`section`,{className:`tavily-section`,children:[(0,F.jsx)(`h4`,{children:`连接你的账号`}),(0,F.jsxs)(`ol`,{className:`tavily-steps`,children:[(0,F.jsx)(`li`,{children:(0,F.jsx)(`a`,{href:`https://app.tavily.com`,target:`_blank`,rel:`noopener noreferrer`,children:`注册或登录 Tavily ↗`})}),(0,F.jsx)(`li`,{children:`在 Tavily 控制台复制你的 API key。`}),(0,F.jsx)(`li`,{children:`粘贴到下方。Super Pi 会先用不消耗搜索额度的用量接口验证 key。`})]}),(0,F.jsxs)(`form`,{className:`tavily-connect-form`,onSubmit:e=>void f(e),children:[(0,F.jsx)(`label`,{htmlFor:`tavily-api-key`,children:`Tavily API key`}),(0,F.jsx)(`input`,{id:`tavily-api-key`,"aria-describedby":`tavily-key-hint`,"data-tavily-key":!0,type:`password`,autoComplete:`new-password`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`粘贴 Tavily API key`,disabled:i}),(0,F.jsx)(`p`,{id:`tavily-key-hint`,className:`tavily-hint`,children:`使用你自己的额度;付费方案由你在 Tavily 管理。`}),(0,F.jsx)(`div`,{className:`tavily-actions`,children:(0,F.jsx)(`button`,{type:`submit`,"data-tavily-connect":!0,disabled:i||!n.trim(),children:i?`正在验证…`:`连接 Tavily`})})]})]}),e?.configured&&(0,F.jsxs)(`section`,{className:`tavily-section`,children:[(0,F.jsx)(`h4`,{children:`Agent 搜索额度`}),(0,F.jsx)(`p`,{children:`Agent 使用 Tavily Basic Search。可在 Tavily 控制台查看用量、调整方案或管理付费。`}),(0,F.jsx)(`a`,{href:`https://app.tavily.com`,target:`_blank`,rel:`noopener noreferrer`,children:`打开 Tavily 控制台 ↗`})]}),o&&(0,F.jsx)(`p`,{className:`tavily-feedback`,role:`alert`,"data-tavily-error":!0,children:o}),c&&(0,F.jsx)(`p`,{className:`tavily-feedback`,role:`status`,"data-tavily-notice":!0,children:c})]})}async function pm(e){let t=await e.json();if(!e.ok)throw Error(t.error||`缓存设置请求失败`);return t}function mm(){let[e,t]=(0,u.useState)(),[n,r]=(0,u.useState)(`off`),[i,a]=(0,u.useState)(!1),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(!1),d=(0,u.useRef)(!1),f=(0,u.useRef)(!1),p=(0,u.useRef)(0),m=`/api/pi/cache-warming`;(0,u.useEffect)(()=>{let e=new AbortController,n=()=>{if(f.current)return;let n=++p.current;je(m,{signal:e.signal}).then(pm).then(i=>{e.signal.aborted||n!==p.current||(t(i),d.current||(r(i.mode),d.current=!0,s(``)))}).catch(t=>{!e.signal.aborted&&!d.current&&s(t instanceof Error?t.message:`读取失败`)})};n();let i=window.setInterval(n,5e3);return()=>{e.abort(),window.clearInterval(i)}},[]);let h=async()=>{a(!0),s(``),l(!1),f.current=!0,p.current++;try{let e=await je(m,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:n})}).then(pm);t(e),r(e.mode),l(!0)}catch(e){s(e instanceof Error?e.message:`保存失败`)}finally{f.current=!1,a(!1)}};return(0,F.jsxs)(`section`,{className:`settings-section`,"data-cache-warming":!0,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`模型缓存预热`}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`让支持缓存的模型保留最近请求的缓存,减少下一次回答的等待。预热可能产生额外请求和费用,用量计入对应会话总量。此设置在服务端运行,对所有工作区生效。`}),!e&&!o&&(0,F.jsx)(`p`,{role:`status`,children:`正在读取缓存设置…`}),(0,F.jsxs)(`label`,{className:`settings-model-group`,children:[(0,F.jsx)(`span`,{className:`settings-model-label`,children:`预热模式`}),(0,F.jsxs)(`select`,{className:`settings-model-select`,"data-cache-warming-mode":!0,disabled:i||!e,value:n,onChange:e=>{r(e.target.value),l(!1)},children:[(0,F.jsx)(`option`,{value:`off`,children:`关闭`}),(0,F.jsx)(`option`,{value:`streaming`,children:`仅回答期间`}),(0,F.jsx)(`option`,{value:`idle`,children:`回答及空闲期间`})]})]}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`空闲预热最多持续约 30 分钟,Pi 会按模型支持情况和成本决定是否继续;切换到空闲模式后,从下一次模型请求开始生效。`}),e&&(0,F.jsxs)(`p`,{className:`settings-agents-desc`,"data-cache-warming-status":!0,children:[`已加载 `,e.liveSessions,` 个会话 · `,e.scheduled,` 个等待预热 · `,e.refreshing,` 个正在预热`]}),(0,F.jsx)(`div`,{className:`settings-rule-form-buttons`,children:(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-cache-warming-save":!0,disabled:i||!e||n===e.mode,onClick:()=>void h(),children:i?`正在保存…`:`保存预热设置`})}),o&&(0,F.jsx)(`p`,{className:`settings-dir-error`,role:`alert`,children:o}),c&&(0,F.jsx)(`p`,{className:`settings-agents-desc`,role:`status`,"data-cache-warming-saved":!0,children:`已保存,现有会话已同步。`})]})}var hm={deferred:`按需搜索`,direct:`直接提供`,codemode:`通过编排调用`,hidden:`隐藏工具`},gm={connected:`测试通过`,connecting:`连接中`,failed:`连接失败`,"needs-auth":`需要登录`,disabled:`已停用`,disconnected:`连接已断开`,closed:`已关闭`},_m=[[`mcp`,`MCP 外部服务`,`连接服务端命令或远程 HTTP 服务,使用其工具和资源。`],[`toolSearch`,`按需发现工具`,`工具多时先搜索再调用,减少每轮请求携带的工具说明。`],[`codemode`,`批量编排调用`,`合并多次工具调用、并行读取或筛选结果,减少来回等待。`]];function vm({workspaceId:e}){let[t,n]=(0,u.useState)(),[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(`http`),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(`deferred`),[w,T]=(0,u.useState)({}),E=(0,u.useRef)(!1),D=(0,u.useRef)(0),O=async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`外部工具请求失败。`);return t};(0,u.useEffect)(()=>{let e=new AbortController,t=()=>{if(E.current)return;let t=++D.current;je(`/api/native-tools`,{signal:e.signal}).then(O).then(r=>{!e.signal.aborted&&t===D.current&&(n(r),c(``))}).catch(t=>{e.signal.aborted||c(t instanceof Error?t.message:`读取失败。`)})};t();let r=window.setInterval(t,2e3);return()=>{e.abort(),window.clearInterval(r)}},[]);let k=async(t,r,a=``)=>{if(E.current)return!1;E.current=!0,D.current++,i(t),o(``),d(``);try{let t=await je(`/api/native-tools`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...r,workspaceId:e})}).then(O);return n(t),d(a),!0}catch(e){return o(e instanceof Error?e.message:`操作失败。`),!1}finally{E.current=!1,i(``)}},A=async e=>{e.preventDefault();let t;try{if(t=b.trim()?JSON.parse(b):{},!t||typeof t!=`object`||Array.isArray(t))throw Error()}catch{o(`高级配置须为 JSON 对象。`);return}let n={...t,...m===`http`?{url:g.trim()}:{command:g.trim(),args:v.split(/\r?\n/).filter(Boolean)},exposure:S};await k(`save`,{action:`save`,name:f.trim(),config:n},`已保存,下一轮执行生效。`)&&(p(``),_(``),y(``),x(``))},j=t?.servers.some(e=>e.name===f.trim());return(0,F.jsxs)(`section`,{className:`settings-panel-container native-tools`,"data-native-tools":!0,children:[(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`让 Agent 查询外部资料、处理服务数据,或把多次工具调用合并执行。主会话、工具型群成员和后台子 Agent 使用同一套权限;自定义 Agent 保留原来的工具授权。`}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`这里管理服务端的全局配置,与 Pi 共用 mcp.json。项目自己的配置继续按 Pi 的信任规则加载。保存后下一轮执行采用新配置,当前工作继续运行。`}),(a||s)&&(0,F.jsx)(`p`,{className:`settings-dir-error`,role:`alert`,"data-native-error":!0,children:a||s}),l&&(0,F.jsx)(`p`,{role:`status`,"data-native-notice":!0,children:l}),!t&&!a&&!s&&(0,F.jsx)(`p`,{role:`status`,children:`正在读取外部工具…`}),t&&(0,F.jsxs)(F.Fragment,{children:[t.configurationWarning&&(0,F.jsx)(`p`,{role:`alert`,children:t.configurationWarning}),(0,F.jsx)(`section`,{className:`settings-section native-tool-flags`,"aria-label":`工具能力`,children:_m.map(([e,n,i])=>(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-native-flag":e,checked:t.settings[e],disabled:!!r,onChange:t=>void k(e,{action:`settings`,settings:{[e]:t.target.checked}},`已保存工具开关。`)}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{children:n}),(0,F.jsx)(`small`,{children:i})]})]},e))}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsxs)(`div`,{className:`native-tools-heading`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`MCP 服务`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-mcp-diagnose":!0,disabled:!!r||t.diagnostics?.running||!e||!t.servers.length,onClick:()=>void k(`diagnose`,{action:`diagnose`}),children:t.diagnostics?.running?`正在测试 ${t.diagnostics.servers.length}/${t.diagnostics.total}…`:`测试连接`})]}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`连接测试会临时连接后关闭;实际执行时由会话保持连接。命令运行在 Super Pi 服务端,环境变量和请求头中的已有值不回显。`}),!t.servers.length&&(0,F.jsx)(`p`,{className:`settings-empty-hint`,children:`还没有全局 MCP 服务,在下方添加第一个。`}),t.servers.map(n=>{let i=t.diagnostics?.servers.find(e=>e.name===n.name);return(0,F.jsxs)(`article`,{className:`native-server`,"data-mcp-server":n.name,children:[(0,F.jsxs)(`div`,{className:`native-server-title`,children:[(0,F.jsx)(`strong`,{children:n.name}),(0,F.jsx)(`span`,{children:n.transport===`http`?`HTTP`:`命令`}),(0,F.jsx)(`span`,{"data-mcp-state":i?.state??`untested`,children:n.enabled?i?gm[i.state]??i.state:`尚未测试`:`已停用`})]}),n.description&&(0,F.jsx)(`p`,{children:n.description}),(0,F.jsxs)(`div`,{className:`native-server-actions`,children:[(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-mcp-enabled":!0,checked:n.enabled,disabled:!!r,onChange:e=>void k(n.name,{action:`patch`,name:n.name,enabled:e.target.checked})}),`启用`]}),(0,F.jsx)(`select`,{"aria-label":`${n.name} 的工具提供方式`,"data-mcp-exposure":!0,value:n.exposure,disabled:!!r,onChange:e=>void k(n.name,{action:`patch`,name:n.name,exposure:e.target.value}),children:Object.entries(hm).map(([e,t])=>(0,F.jsx)(`option`,{value:e,children:t},e))}),n.supportsLogin&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-mcp-login":!0,disabled:!!r||!e,onClick:()=>void k(n.name,{action:`login`,name:n.name}),children:n.authenticated?`重新登录`:`登录`}),n.authenticated&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,disabled:!!r,onClick:()=>void k(n.name,{action:`logout`,name:n.name},`已移除 MCP 网页登录凭据。`),children:`退出登录`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-mcp-remove":!0,disabled:!!r,onClick:()=>{window.confirm(`删除 MCP 服务 ${n.name}?`)&&k(n.name,{action:`delete`,name:n.name})},children:`删除`})]}),i?.error&&(0,F.jsx)(`p`,{role:`status`,children:i.error}),i&&i.tools.length>0&&(0,F.jsxs)(`details`,{"data-mcp-tools":!0,children:[(0,F.jsxs)(`summary`,{children:[i.tools.length,` 个可用工具`]}),(0,F.jsx)(`ul`,{children:i.tools.map(e=>(0,F.jsx)(`li`,{children:(0,F.jsx)(`code`,{children:e})},e))})]})]},n.name)}),t.diagnostics?.error&&(0,F.jsx)(`p`,{role:`status`,children:t.diagnostics.error})]}),t.logins.map(e=>(0,F.jsxs)(`section`,{className:`settings-section native-login`,"data-mcp-login-state":e.state,children:[(0,F.jsxs)(`h4`,{className:`settings-section-title`,children:[e.name,` · `,e.state===`completed`?`登录完成`:e.state===`starting`?`正在连接授权服务`:e.state===`authorizing`?`等待网页授权`:e.state===`cancelled`?`登录已取消`:`登录未完成`]}),e.url&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`a`,{className:`settings-oauth-open-link native-login-open`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`打开授权页面 ↗`}),(0,F.jsx)(`p`,{children:`如果远程浏览器无法打开回调页面,可复制地址栏里的完整回调地址粘贴到下方。`}),(0,F.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),k(e.id,{action:`redirect`,id:e.id,url:w[e.id]}).then(t=>{t&&T(t=>({...t,[e.id]:``}))})},children:[(0,F.jsx)(`input`,{className:`settings-oauth-input`,type:`password`,"aria-label":`完整回调地址`,autoComplete:`off`,placeholder:`粘贴完整回调地址`,value:w[e.id]??``,onChange:t=>T(n=>({...n,[e.id]:t.target.value}))}),(0,F.jsx)(`button`,{className:`settings-dir-add-btn settings-oauth-continue`,disabled:!!r||!w[e.id],type:`submit`,children:`完成授权`})]})]}),e.error&&(0,F.jsx)(`p`,{role:`status`,children:e.error}),[`starting`,`authorizing`].includes(e.state)&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,onClick:()=>void k(e.id,{action:`cancel-login`,id:e.id}),children:`取消登录`})]},e.id))]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`添加服务`}),(0,F.jsxs)(`form`,{onSubmit:e=>void A(e),className:`native-server-form`,children:[(0,F.jsxs)(`div`,{className:`settings-model-grid`,children:[(0,F.jsxs)(`label`,{children:[`服务名`,(0,F.jsx)(`input`,{className:`settings-dir-input`,"data-mcp-name":!0,required:!0,value:f,onChange:e=>p(e.target.value)})]}),(0,F.jsxs)(`label`,{children:[`连接方式`,(0,F.jsxs)(`select`,{className:`settings-model-select`,"data-mcp-type":!0,value:m,onChange:e=>{h(e.target.value),_(``)},children:[(0,F.jsx)(`option`,{value:`http`,children:`远程 HTTP`}),(0,F.jsx)(`option`,{value:`stdio`,children:`服务端命令`})]})]})]}),(0,F.jsxs)(`label`,{children:[m===`http`?`服务地址`:`可执行命令`,(0,F.jsx)(`input`,{className:`settings-dir-input`,"data-mcp-address":!0,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:m===`http`?`https://example.com/mcp`:`npx`})]}),m===`stdio`&&(0,F.jsxs)(`label`,{children:[`参数(每行一个)`,(0,F.jsx)(`textarea`,{className:`settings-dir-input`,"data-mcp-args":!0,value:v,onChange:e=>y(e.target.value),spellCheck:!1})]}),(0,F.jsxs)(`label`,{children:[`工具提供方式`,(0,F.jsx)(`select`,{className:`settings-model-select`,value:S,onChange:e=>C(e.target.value),children:Object.entries(hm).map(([e,t])=>(0,F.jsx)(`option`,{value:e,children:t},e))})]}),(0,F.jsxs)(`details`,{children:[(0,F.jsx)(`summary`,{children:`环境变量、请求头与高级配置`}),(0,F.jsx)(`p`,{children:`填写单个服务配置的 JSON 字段,例如 env、headers、oauth、toolExposure。可以使用环境变量引用;保存后清空此输入。`}),(0,F.jsx)(`textarea`,{className:`settings-dir-input`,"data-mcp-extra":!0,value:b,onChange:e=>x(e.target.value),spellCheck:!1,placeholder:'{"env":{"SERVICE_KEY":"${SERVICE_KEY}"}}'})]}),j&&(0,F.jsx)(`p`,{children:`同名服务已存在,本次保存将完整替换其配置。调整开关或提供方式可直接使用上方操作,保留已有凭据。`}),(0,F.jsx)(`button`,{type:`submit`,className:`settings-dir-add-btn`,"data-mcp-save":!0,disabled:!!r||!t,children:r===`save`?`正在保存…`:j?`替换服务配置`:`添加服务`})]})]})]})}function ym(){let e=Uu();return(0,F.jsxs)(`fieldset`,{className:`markdown-syntax-settings`,"data-markdown-syntax-settings":`1`,children:[(0,F.jsx)(`legend`,{children:`消息 Markdown 语法`}),(0,F.jsx)(`p`,{children:`关闭后按原样显示符号。讨论 A* 算法时可关闭斜体;代码块不受影响。`}),[{key:`italic`,label:`斜体`,example:`*文字* / _文字_`},{key:`bold`,label:`粗体`,example:`**文字** / __文字__`},{key:`strikethrough`,label:`删除线`,example:`~~文字~~`}].map(t=>(0,F.jsxs)(`label`,{className:`markdown-syntax-row`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-markdown-syntax-setting":t.key,checked:e[t.key],onChange:e=>Bu({[t.key]:e.target.checked})}),(0,F.jsx)(`span`,{children:t.label}),(0,F.jsx)(`code`,{children:t.example})]},t.key)),(0,F.jsxs)(`div`,{className:`markdown-syntax-footer`,children:[(0,F.jsx)(`span`,{children:`仅影响当前浏览器的显示,立即生效。`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>Bu(Nu),"data-markdown-syntax-reset":`1`,children:`恢复默认`})]})]})}var bm=e=>+(e===`subagent`);function xm(e){return[...e].sort((e,t)=>{let n=+!e.builtin,r=+!t.builtin;if(n!==r)return n-r;let i=bm(e.mode)-bm(t.mode);return i===0?e.id.localeCompare(t.id):i})}var Sm=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function Cm(e,t){let n=e.trim(),r=n.replace(/\/+$/,``);try{let e=new URL(n);r=`${e.origin}${e.pathname.replace(/\/+$/,``)}${e.search}`}catch{}return`${r}|${t.trim()||`openai-completions`}`}function wm(e){return e?Sm.filter(t=>e[t]!=null):[]}function Tm(e){return wm(e).join(` / `)}var Em=e=>e.nativeEvent.isComposing||e.keyCode===229,Dm=`super-pi.theme`,Om=[{id:`dracula`,name:`Dracula`,blurb:`冷灰深底,柔紫选中和焦点。`},{id:`monokai`,name:`Monokai`,blurb:`暖灰深底,琥珀色操作和焦点。`},{id:`solarized-light`,name:`Solarized Light`,blurb:`米白正文,鼠尾草绿选中。`},{id:`github-light`,name:`GitHub Light`,blurb:`白色正文,冷灰侧栏和蓝色选中。`}],km=`dracula`,Am=e=>typeof e==`string`&&Om.some(t=>t.id===e);function jm(){try{let e=window.localStorage.getItem(Dm);if(!e)return km;let t=JSON.parse(e),n=typeof t==`string`?t:t?.id;return Am(n)?n:km}catch{return km}}function Mm(e){document.documentElement.setAttribute(`data-theme`,e);try{window.localStorage.setItem(Dm,JSON.stringify({id:e,version:1}))}catch{}}function Nm(){let[e,t]=(0,u.useState)(km);return(0,u.useEffect)(()=>{t(jm());let e=e=>{if(e.key===`super-pi.theme`&&e.newValue)try{let n=JSON.parse(e.newValue),r=typeof n==`string`?n:n?.id;Am(r)&&(document.documentElement.setAttribute(`data-theme`,r),t(r))}catch{}};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{theme:e,setTheme:(0,u.useCallback)(e=>{Mm(e),t(e)},[])}}function Pm({theme:e,onChooseTheme:t,onClose:n}){let r=Om.find(t=>t.id===e);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`settings-scope`,children:`主题只影响这台设备的显示,不改变任何内容;切换立即生效。`}),(0,F.jsx)(ym,{}),Om.length===0?(0,F.jsx)(`div`,{className:`theme-empty`,"data-theme-empty":`1`,children:`没有可用的主题。界面将继续使用默认配色,你可以在主题文件恢复后重试。`}):(0,F.jsx)(`div`,{className:`theme-options`,role:`radiogroup`,"aria-label":`主题`,children:Om.map(n=>{let r=n.id===e;return(0,F.jsxs)(`button`,{type:`button`,className:`theme-option`,role:`radio`,"aria-checked":r,"aria-pressed":r,"data-theme-option":n.id,"data-theme-current":r?`1`:`0`,onClick:()=>t(n.id),children:[(0,F.jsx)(`span`,{className:`theme-preview-strip`,"data-preview":n.id,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{className:`theme-option-name`,children:[n.name,r&&(0,F.jsx)(`span`,{className:`theme-option-current`,children:`当前 ✓`})]}),(0,F.jsx)(`span`,{className:`theme-option-blurb`,children:n.blurb})]},n.id)})}),(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-theme-close":`1`,onClick:n,children:`完成`})}),(0,F.jsxs)(`div`,{className:`settings-scope theme-current-line`,children:[`当前:`,r?`${r.name}(${r.id})`:`默认`]})]})}function Fm({userNickname:e,onSetUserNickname:t,onClose:n}){return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`settings-scope`,children:`昵称会显示在消息时间戳旁和头像上,替代默认的「你」。留空恢复默认。`}),(0,F.jsxs)(`div`,{className:`general-nickname`,children:[(0,F.jsx)(`label`,{className:`general-nickname-label`,htmlFor:`general-nickname-input`,children:`昵称`}),(0,F.jsx)(`input`,{id:`general-nickname-input`,type:`text`,className:`general-nickname-input`,"data-general-nickname":`1`,maxLength:24,placeholder:`你`,value:e??``,onChange:e=>t?.(e.target.value)}),(0,F.jsx)(`span`,{className:`general-nickname-hint`,"data-general-nickname-preview":`1`,title:`当前显示`,children:e?.trim()?`将显示为:${e.trim()}`:`将显示为:你`})]}),(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:n,children:`完成`})})]})}function Im(e){return(0,F.jsx)(Lm,{context:e})}function Lm({context:e}){let[t,n]=(0,u.useState)(``),[r,i]=(0,u.useState)();(0,u.useEffect)(()=>{e.onCheckBrowserNotifications?.()},[e.onCheckBrowserNotifications]),(0,u.useEffect)(()=>()=>r?.close(),[r]);let a=!!e.browserNotificationsEnabled,o=e.browserNotificationPermission??`unsupported`,s=o!==`unsupported`&&o!==`insecure`,c=o===`granted`?`浏览器已授权通知。`:o===`denied`?`浏览器已阻止此站点发送通知。请在地址栏的站点设置中允许通知,然后返回这里重新检测。`:o===`insecure`?`当前连接不是安全来源。浏览器通知需要 HTTPS 或 localhost。`:o===`unsupported`?`当前浏览器不支持系统通知。`:`尚未授权。点击按钮后,浏览器会询问是否允许 Super Pi 发送通知。`,l=a&&o===`granted`;return(0,F.jsxs)(`section`,{className:`settings-panel-container`,"data-browser-notifications":`1`,children:[(0,F.jsx)(`div`,{className:`settings-scope`,children:`当页面处于后台或没有焦点时,Agent 完成一轮工作或等待你回答问题,会通过浏览器系统通知提醒。通知不会包含问题全文或代码。`}),(0,F.jsxs)(`div`,{className:`settings-notification-row`,children:[(0,F.jsxs)(`div`,{className:`settings-notification-copy`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`Agent 状态提醒`}),(0,F.jsx)(`p`,{children:`仅提醒顶层会话;后台子会话不会逐个打断你。点击通知会打开对应会话。`})]}),(0,F.jsx)(`button`,{type:`button`,className:`settings-agent-rescan-btn`,"data-browser-notifications-toggle":`1`,"aria-pressed":a,disabled:!a&&(!s||o===`denied`),onClick:()=>e.onSetBrowserNotifications?.(!a),children:a?`关闭通知`:o===`granted`?`启用通知`:`授权并启用`})]}),(0,F.jsxs)(`section`,{className:`settings-notification-check`,"aria-label":`通知权限检测`,"data-browser-notification-permission":o,children:[(0,F.jsxs)(`dl`,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`Super Pi 通知开关`}),(0,F.jsx)(`dd`,{children:a?`已开启`:`已关闭`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`当前浏览器站点权限`}),(0,F.jsx)(`dd`,{"data-notification-permission-label":!0,children:o===`granted`?`已允许`:o===`denied`?`已阻止`:o==="default"?`尚未授权`:o===`insecure`?`需要 HTTPS 或 localhost`:`浏览器不支持`})]})]}),(0,F.jsxs)(`p`,{role:`status`,"data-notification-effective":l?`enabled`:a?`blocked`:`disabled`,children:[(0,F.jsx)(`strong`,{children:l?`浏览器通知已就绪`:a?`通知尚未生效`:`通知未启用`}),a&&o!==`granted`?`:平台开关已开启,但浏览器尚不允许发送通知。`:``]}),(0,F.jsx)(`p`,{children:c}),(0,F.jsxs)(`div`,{className:`settings-notification-check-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-agent-rescan-btn`,"data-notification-recheck":!0,onClick:()=>{e.onCheckBrowserNotifications?.(),n(`已重新读取当前浏览器的站点通知权限。`)},children:`重新检测`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-agent-rescan-btn`,"data-notification-test":!0,disabled:!l,onClick:()=>{if(e.onCheckBrowserNotifications?.(),!(`Notification`in window)||Notification.permission!==`granted`)n(`浏览器当前未允许通知,请先调整站点权限。`);else try{i(new Notification(`Super Pi · 测试通知`,{body:`如果你看到这条系统通知,说明当前浏览器的通知可以正常显示。`,tag:`super-pi-permission-test`})),n(`已请求发送测试通知;若没有看到,请检查系统对浏览器的通知权限及勿扰模式。`)}catch{n(`浏览器未能发送测试通知,请检查站点和系统通知设置。`)}},children:`发送测试通知`})]}),(0,F.jsx)(`p`,{className:`settings-notification-help`,children:`此检测反映当前站点的浏览器授权。操作系统的通知开关、勿扰模式也可能拦截显示,可用测试通知确认。`}),t&&(0,F.jsx)(`p`,{role:`status`,children:t})]}),(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e.onClose,children:`完成`})})]})}function Rm({context:e}){let[t,n]=(0,u.useState)(``),[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(!1),s=e.agentCatalog,c=e.subagentCatalog,l=s?.agents??[],d=c?.agents??[],f=xm([...l,...d]),p=[...s?.problems??[],...c?.problems??[]],m=[...new Set([...s?.directories??(s?.directory?[s.directory]:[]),...e.customAgentDirs??[]])],h=e.customAgentDirs??[],g=r=>{if(r.preventDefault(),e.pendingSettings)return;let a=t.trim();a&&(h.includes(a)?i(`该路径已存在于自定义目录列表中`):(e.onSetCustomAgentDirs?.([...h,a]),n(``),i(``)))},_=t=>{let n=h.filter(e=>e!==t);e.onSetCustomAgentDirs?.(n)};return(0,F.jsxs)(`div`,{className:`settings-agents-container`,children:[(0,F.jsxs)(`div`,{className:`settings-agents-header`,children:[(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`Super Pi 支持多目录发现智能体。系统会按优先级自上而下合并扫描目录;若存在同名配置,高优先级目录的文件将覆盖低优先级目录。`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-agent-rescan-btn`,onClick:()=>{o(!0),e.onRescanAgents?.(),setTimeout(()=>o(!1),600)},disabled:a,title:`重新扫描所有目录中的智能体定义文件`,children:a?`正在扫描…`:`🔄 立即重新扫描`})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`发现路径清单(按优先级自高到低)`}),(0,F.jsx)(`div`,{className:`settings-dirs-list`,children:m.length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`暂无活跃的发现路径`}):m.map((t,n)=>{let r=h.includes(t),i=t.includes(`.super_pi`)||t.includes(`.super-pi`)||t.includes(`.pi`),a=!r&&!i,o=f.filter(e=>e.sourceDir===t).length;return(0,F.jsxs)(`div`,{className:`settings-dir-row`,children:[(0,F.jsxs)(`div`,{className:`settings-dir-info`,children:[(0,F.jsxs)(`span`,{className:`settings-dir-priority`,children:[`#`,n+1]}),(0,F.jsx)(`span`,{className:`settings-dir-path`,title:t,children:t}),(0,F.jsx)(`span`,{className:`settings-dir-tag`,children:r?`自定义`:i?`用户全局`:a?`内置`:`环境`}),(0,F.jsxs)(`span`,{className:`settings-dir-count`,children:[`(发现 `,o,` 个智能体)`]})]}),r&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-remove-btn`,disabled:e.pendingSettings,onClick:()=>_(t),title:`移除此自定义扫描路径`,children:`移除`})]},t)})})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`添加自定义路径`}),(0,F.jsxs)(`form`,{onSubmit:g,className:`settings-add-dir-form`,children:[(0,F.jsx)(`input`,{type:`text`,className:`settings-dir-input`,value:t,onChange:e=>{n(e.target.value),r&&i(``)},onKeyDown:e=>{e.key===`Enter`&&Em(e)&&e.preventDefault()},placeholder:`输入本地目录绝对路径或 ~/ 开头路径,如 D:\\agents 或 ~/.super_pi/agents`}),(0,F.jsx)(`button`,{type:`submit`,className:`settings-dir-add-btn`,disabled:e.pendingSettings||!t.trim(),children:`添加目录`})]}),r&&(0,F.jsx)(`div`,{className:`settings-dir-error`,children:r})]}),p.length>0&&(0,F.jsxs)(`section`,{className:`settings-section settings-problems-section`,children:[(0,F.jsxs)(`h4`,{className:`settings-problems-title`,children:[`⚠️ 发现 `,p.length,` 个文件解析问题`]}),(0,F.jsx)(`div`,{className:`settings-problems-list`,children:p.map((e,t)=>(0,F.jsxs)(`div`,{className:`settings-problem-row`,children:[(0,F.jsx)(`span`,{className:`settings-problem-file`,children:e.file}),`: `,e.message]},t))})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsxs)(`h4`,{className:`settings-section-title`,children:[`已发现的智能体(共 `,f.length,` 个)`]}),f.length===0?(0,F.jsxs)(`div`,{className:`settings-empty-hint`,children:[`当前未发现任何智能体。请在上述目录中添加 `,(0,F.jsx)(`code`,{children:`.md`}),` 文件(需包含 YAML frontmatter)。`]}):(0,F.jsx)(`div`,{className:`settings-agent-grid`,children:f.map(e=>(0,F.jsxs)(`div`,{className:`settings-agent-card`,children:[(0,F.jsxs)(`div`,{className:`settings-agent-card-header`,children:[(0,F.jsx)(`span`,{className:`settings-agent-name`,children:e.name}),(0,F.jsxs)(`span`,{className:`settings-agent-id`,children:[`(`,e.id,`)`]}),(0,F.jsx)(`span`,{className:`settings-agent-mode-badge ${e.mode}`,children:e.mode===`primary`?`主智能体`:`子智能体`})]}),e.sourceDir&&(0,F.jsxs)(`div`,{className:`settings-agent-source`,title:e.sourceDir,children:[`来源:`,e.sourceDir]}),e.description&&(0,F.jsx)(`div`,{className:`settings-agent-desc`,children:e.description}),(0,F.jsxs)(`div`,{className:`settings-agent-footer`,children:[(0,F.jsx)(`span`,{className:`settings-agent-tools`,children:e.toolSummary}),e.model&&(0,F.jsxs)(`span`,{className:`settings-agent-model`,children:[e.model.provider,`/`,e.model.modelId]})]})]},`${e.sourceDir}-${e.id}`))})]}),(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e.onClose,children:`完成`})})]})}function zm(e){return(0,F.jsx)(Rm,{context:e})}function Bm({context:e}){let[t,n]=(0,u.useState)({enabled:!1}),[r,i]=(0,u.useState)(``),a=(0,u.useCallback)(async e=>{try{let[t,r]=await Promise.all([je(`/api/terminal`).then(e=>e.json()),je(`/api/terminal-shell`).then(e=>e.json())]);n({...r,enabled:t.enabled}),e&&i(r.shell?[r.shell.file,...r.shell.args].map(e=>/\s/.test(e)?`"${e}"`:e).join(` `):``)}catch{}},[]);(0,u.useEffect)(()=>{a(!0)},[a]);let o=(0,u.useRef)(e.terminalShell);return(0,u.useEffect)(()=>{o.current!==e.terminalShell&&(o.current=e.terminalShell,a(!1))},[e.terminalShell,a]),t.enabled?(0,F.jsx)(`section`,{className:`settings-panel-container`,"data-terminal-settings":`1`,children:(0,F.jsxs)(`div`,{className:`settings-section`,children:[(0,F.jsxs)(`p`,{className:`settings-empty-hint`,children:[`当前生效:`,(0,F.jsx)(`code`,{children:t.shell?[t.shell.file,...t.shell.args].join(` `):``}),`(来自`,t.source,`)。只影响新开的终端。`]}),(0,F.jsx)(`label`,{className:`settings-section-title`,children:`默认 shell`}),(0,F.jsx)(`input`,{className:`settings-dir-input`,"data-terminal-shell-input":`1`,value:r,onChange:e=>i(e.target.value),placeholder:`例如 wsl.exe -e zsh`}),(0,F.jsx)(`div`,{className:`settings-dirs-list`,children:(t.candidates??[]).map(e=>(0,F.jsx)(`button`,{type:`button`,className:`settings-agent-rescan-btn`,onClick:()=>i([e.file,...e.args].map(e=>/\s/.test(e)?`"${e}"`:e).join(` `)),children:e.label},`${e.file}:${e.args.join(` `)}`))}),(0,F.jsx)(`div`,{children:(0,F.jsx)(`button`,{type:`button`,className:`settings-agent-rescan-btn`,"data-terminal-shell-save":`1`,onClick:()=>e.onSetTerminalShell?.(r.trim()||null),children:`保存`})})]})}):(0,F.jsx)(`section`,{className:`settings-panel-container`,"data-terminal-settings":`disabled`,children:(0,F.jsx)(`p`,{className:`settings-empty-hint`,children:`终端没有启用,无法设置默认 shell。`})})}function Vm({context:e}){let[t,n]=(0,u.useState)(``),[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(),s=e=>{try{return new RegExp(e,`i`),!1}catch{return!0}},c=s(t),l=s(r),d=e.modelFilterRules??[];return(0,F.jsxs)(`section`,{"data-model-rules":`1`,className:`settings-panel-container`,children:[(0,F.jsx)(`div`,{className:`settings-agents-header`,children:(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[(0,F.jsx)(`strong`,{children:`按工作区约束可用模型。`}),`当工作区名称匹配指定正则表达式时,会话中仅可选择符合模型正则的模型(匹配模型名称或 `,(0,F.jsx)(`code`,{children:`provider/modelId`}),`)。多条命中规则必须全部满足。`]})}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsxs)(`h4`,{className:`settings-section-title`,children:[`已配置的过滤规则(共 `,d.length,` 条)`]}),d.length===0?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`暂无模型过滤规则。所有工作区默认可使用全部已配置模型。`}):(0,F.jsx)(`div`,{className:`settings-dirs-list`,children:d.map(t=>{let r=a===t.id;return(0,F.jsxs)(`div`,{className:`settings-rule-card ${r?`editing`:``}`,children:[(0,F.jsx)(`div`,{className:`settings-rule-info`,children:(0,F.jsxs)(`div`,{className:`settings-rule-patterns`,children:[(0,F.jsxs)(`span`,{className:`settings-rule-pill`,children:[(0,F.jsx)(`span`,{className:`settings-rule-pill-tag`,children:`工作区`}),(0,F.jsx)(`code`,{className:`settings-rule-code`,title:t.workspacePattern,children:t.workspacePattern})]}),(0,F.jsx)(`span`,{className:`settings-rule-arrow`,"aria-hidden":`true`,children:`→`}),(0,F.jsxs)(`span`,{className:`settings-rule-pill`,children:[(0,F.jsx)(`span`,{className:`settings-rule-pill-tag`,children:`允许模型`}),(0,F.jsx)(`code`,{className:`settings-rule-code`,title:t.modelPattern,children:t.modelPattern})]})]})}),(0,F.jsxs)(`div`,{className:`settings-rule-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-edit-btn`,onClick:()=>{o(t.id),n(t.workspacePattern),i(t.modelPattern)},children:r?`编辑中`:`编辑`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-remove-btn`,onClick:()=>{a===t.id&&(o(void 0),n(``),i(``)),e.onSetModelRules?.(d.filter(e=>e.id!==t.id))},children:`删除`})]})]},t.id)})})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:a?`编辑过滤规则`:`添加新规则`}),(0,F.jsxs)(`fieldset`,{disabled:e.pendingSettings,className:`model-rules-fields settings-rule-fieldset`,children:[(0,F.jsxs)(`div`,{className:`settings-rule-form-grid`,children:[(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`工作区名正则表达式`}),(0,F.jsx)(`input`,{type:`text`,"data-rule-workspace":`1`,className:`settings-dir-input`,value:t,"aria-invalid":c,placeholder:`如 ^proj- 或 my-workspace`,onChange:e=>n(e.target.value)})]}),(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`允许的模型名正则表达式`}),(0,F.jsx)(`input`,{type:`text`,"data-rule-model":`1`,className:`settings-dir-input`,value:r,"aria-invalid":l,placeholder:`如 anthropic/.* 或 gpt-4o|claude`,onChange:e=>i(e.target.value)})]})]}),(c||l)&&(0,F.jsx)(`div`,{className:`settings-dir-error`,role:`alert`,children:`⚠️ 正则表达式语法不合法,请检查后修正。`}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,"data-rule-save":`1`,className:`settings-dir-add-btn`,disabled:!t.trim()||!r.trim()||c||l,onClick:()=>{let s={id:a??En(),workspacePattern:t.trim(),modelPattern:r.trim()};e.onSetModelRules?.([...d.filter(e=>e.id!==s.id),s]),n(``),i(``),o(void 0)},children:a?`保存修改`:`添加规则`}),a&&(0,F.jsx)(`button`,{type:`button`,className:`settings-rule-cancel-btn`,onClick:()=>{o(void 0),n(``),i(``)},children:`取消编辑`})]})]})]}),(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e.onClose,children:`完成`})})]})}function Hm({catalog:e,customProviders:t,onEditModel:n}){let[r,i]=(0,u.useState)(!1),a=e?.models??[];if(a.length===0)return null;let o={};for(let e of a){let t=e.provider||`other`;o[t]||(o[t]=[]),o[t].push(e)}let s=Object.keys(o).sort(),c=new Set((t??[]).filter(e=>e.builtin).map(e=>e.id));return(0,F.jsxs)(`div`,{className:`settings-system-models`,"data-system-models":`1`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`settings-system-models-toggle`,onClick:()=>i(!r),"aria-expanded":!r,children:[(0,F.jsx)(`span`,{className:`settings-system-models-icon`,children:r?`▸`:`▾`}),(0,F.jsxs)(`span`,{className:`settings-system-models-title`,children:[`已发现的可用模型清单(共 `,a.length,` 个模型 · `,s.length,` 个供应商)`]})]}),!r&&(0,F.jsxs)(`div`,{className:`settings-system-models-content`,children:[(0,F.jsx)(`p`,{className:`settings-agents-desc settings-system-models-note`,children:`Pi 现在实际提供这些模型。改动和删除请在下方「Pi 的供应商与模型」里做——那里编辑的就是 Pi 自己的配置,这里只是它被 Pi 读出来的结果。`}),s.map(e=>{let t=o[e],r=c.has(e);return(0,F.jsxs)(`div`,{className:`settings-system-group`,children:[(0,F.jsxs)(`div`,{className:`settings-system-group-head`,children:[(0,F.jsx)(`span`,{className:`settings-system-group-name`,children:e}),(0,F.jsxs)(`span`,{className:`settings-system-group-count`,children:[`(`,t.length,` 个模型)`]}),(0,F.jsx)(`span`,{className:`settings-system-badge ${r?`system`:`custom`}`,children:r?`Pi 提供`:`models.json 定义`})]}),(0,F.jsx)(`div`,{className:`settings-system-model-list`,children:t.map(t=>(0,F.jsxs)(`div`,{className:`settings-system-model-row`,children:[(0,F.jsxs)(`div`,{className:`settings-system-model-info`,children:[(0,F.jsx)(`span`,{className:`settings-system-model-name`,children:t.label||t.modelId}),(0,F.jsx)(`code`,{className:`settings-system-model-id`,children:t.modelId})]}),(0,F.jsx)(`div`,{className:`settings-system-model-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link`,"data-system-model-edit":`${e}:${t.modelId}`,onClick:()=>n?.(e,t.modelId,t.label),children:`编辑配置`})})]},t.modelId))})]},e)})]})]})}var Um=e=>{try{let t=e.trim();if(!t)return`custom-provider`;let n=new URL(t.startsWith(`http`)?t:`https://${t}`),r=n.hostname.toLowerCase();if(r.includes(`openai`))return`openai`;if(r.includes(`anthropic`))return`anthropic`;if(r.includes(`deepseek`))return`deepseek`;if(r.includes(`google`)||r.includes(`gemini`))return`google`;if(r.includes(`groq`))return`groq`;if(r.includes(`mistral`))return`mistral`;if(r.includes(`moonshot`)||r.includes(`kimi`))return`moonshot`;if(r.includes(`ollama`)||n.port===`11434`)return`ollama`;let i=r.split(`.`).filter(e=>e!==`api`&&e!==`v1`&&e!==`com`&&e!==`org`&&e!==`net`&&e!==`cn`&&e!==`ai`&&e!==`io`);return i.length>0&&i[0]&&i[0].replace(/[^a-z0-9_-]/g,``)||`custom-provider`}catch{return`custom-provider`}};function Wm({context:e,externalEditModel:t,offered:n}){let r=e.providers??[],i=e.providerApis??[],[a,o]=(0,u.useState)({kind:`add`}),[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(!1),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(``),[A,j]=(0,u.useState)(``),[ee,M]=(0,u.useState)(!0),[te,N]=(0,u.useState)(!0),[ne,re]=(0,u.useState)(),[ie,ae]=(0,u.useState)(``),[oe,se]=(0,u.useState)(!1),[ce,le]=(0,u.useState)(),[ue,de]=(0,u.useState)([]),[fe,pe]=(0,u.useState)(``),[me,he]=(0,u.useState)(new Set),[ge,P]=(0,u.useState)(),_e=(0,u.useRef)(``);_e.current=Cm(f,m),(0,u.useEffect)(()=>{if(!t)return;let{provider:e,modelId:n,label:a}=t;ye.current=!0;let s=r.find(t=>t.id===e);if(s){Ce(s);let t=s.models.find(e=>e.id===n);t?(we(t,Cm(s.baseUrl,s.api)),o({kind:`editModel`,providerId:e,modelId:n})):(we(void 0,``),x(n),C(a&&a!==n?a:``),o({kind:`addModel`,providerId:e}))}else c(e),d(e),p(``),h(i[0]??`openai-completions`),_(``),y(!1),x(n),C(a&&a!==n?a:``),T(!1),D(!1),k(``),j(``),o({kind:`add`});document.querySelector(`.settings-provider-form`)?.scrollIntoView({behavior:`smooth`})},[t]);let ve=a.kind===`add`?void 0:r.find(e=>e.id===a.providerId),ye=(0,u.useRef)(!1),be=()=>{ye.current=!0},xe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{xe.current&&(xe.current=!1,!ye.current&&Se())},[r]);let Se=()=>{o({kind:`add`}),ye.current=!1,c(``),d(``),p(``),h(i[0]??`openai-completions`),_(``),y(!1),x(``),C(``),T(!1),D(!1),k(``),j(``),M(!0),N(!0),re(void 0),ae(``),se(!1),le(void 0),de([]),pe(``),he(new Set),P(void 0)},Ce=e=>{c(e.id),d(e.name===e.id?``:e.name),p(e.baseUrl),h(e.api),_(``),y(!1)},we=(e,t)=>{x(e?.id??``),C(!e||e.name===e.id?``:e.name),T(e?.reasoning??!1),D(e?.imageInput??!1),k(e?String(e.contextWindow):``),j(e?String(e.maxTokens):``),M(!0),N(!0),re(e?.thinkingLevelMap?{map:{...e.thinkingLevelMap},endpoint:t,modelId:e.id}:void 0)},Te=e=>{let t=r.find(t=>t.id===e);t&&(be(),o({kind:`addModel`,providerId:e}),Ce(t),we(void 0,``))},Ee=(e,t)=>{let n=r.find(t=>t.id===e),i=n?.models.find(e=>e.id===t);n&&i&&(be(),o({kind:`editModel`,providerId:e,modelId:t}),Ce(n),we(i,Cm(n.baseUrl,n.api)))},De=(e,t)=>{let n=r.find(t=>t.id===e),i=n?.models.find(e=>e.id===t);if(n&&i?.thinkingLevelMap)return{map:i.thinkingLevelMap,endpoint:Cm(n.baseUrl,n.api),reasoning:i.reasoning}},Oe=(e,t,n)=>{let r=De(e,t.id);we(r?.endpoint===n?{...t,reasoning:r.reasoning}:t,n)},ke=(e,t,n)=>{let r=Cm(f,m),i=De(e,t);if(i?.endpoint!==r){if(n)return ie===r?{...n}:null;if(i)return null}},Ae=(e,t)=>{let n=Cm(f,m),r=De(e,t);if(r&&r.endpoint===n)return{...r.map};if(ne&&ne.modelId===t&&ne.endpoint===n)return ne.map;if(r)return null},Me=e=>e===void 0?{}:{thinkingLevelMap:e},Ne=ie===Cm(f,m),Pe=async()=>{if(!f.trim()){le(`请先填写 API 地址`);return}if(!s.trim()){let e=Um(f);c(e),l.trim()||d(e)}se(!0),le(void 0);let e=Cm(f,m);try{let t=s.trim()||Um(f),n=await je(`/api/providers/fetch-models`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({baseUrl:f.trim(),apiKey:g.trim(),api:m,providerId:t})}),r=await n.json();if(!n.ok||!r.ok)throw Error(r.error||`获取模型失败`);if(_e.current!==e){de([]),he(new Set),le(`API 地址已改动,这次探测的结果没有采用`);return}let i=r.models||[];de(i),he(new Set(i.map(e=>e.id))),ae(e),i.length===1&&Oe(t,i[0],e)}catch(e){le(e instanceof Error?e.message:String(e))}finally{se(!1)}},Fe=()=>{if(me.size===0||!f.trim()||ie!==Cm(f,m))return;let t=s.trim()||Um(f);s.trim()||c(t);let n=ue.filter(e=>me.has(e.id));n.length&&(xe.current=!0,ye.current=!1,e.onSetProvider?.({id:t,...l.trim()?{name:l.trim()}:{name:t},baseUrl:f.trim(),api:m.trim()||`openai-completions`,...g.trim()?{apiKey:g.trim()}:{},models:n.map(e=>({id:e.id,name:e.name||e.id,reasoning:e.reasoning,imageInput:e.imageInput,contextWindow:e.contextWindow,maxTokens:e.maxTokens,supportsDeveloperRole:!0,supportsReasoningEffort:!0,...Me(ke(t,e.id,e.thinkingLevelMap))}))}),de([]))},Ie=s.trim()||(f.trim()?Um(f):``),Le=f.trim()&&b.trim()&&!e.pendingSettings,Re=r.filter(e=>!e.disabled),ze=r.filter(e=>e.disabled);return(0,F.jsxs)(`section`,{className:`settings-section`,"data-settings-providers":`1`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`Pi 的供应商与模型`}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`停用后保留配置,随时可以重新启用。`}),(0,F.jsx)(um,{providers:r}),(0,F.jsx)(Gm,{providers:r}),Re.length>0?(0,F.jsx)(`div`,{className:`settings-provider-list`,children:Re.map(t=>(0,F.jsxs)(`div`,{className:`settings-provider-card`,"data-provider-row":t.id,children:[(0,F.jsxs)(`div`,{className:`settings-provider-head`,children:[(0,F.jsx)(`span`,{className:`settings-provider-id`,children:t.id}),t.name!==t.id&&(0,F.jsx)(`span`,{className:`settings-provider-name`,children:t.name}),t.hasKey&&t.authType!==`oauth`&&(0,F.jsx)(`span`,{className:`settings-provider-badge`,children:`已设置 key`}),t.authType===`oauth`&&(0,F.jsx)(`span`,{className:`settings-provider-badge`,children:t.authenticated?`已授权登录`:`OAuth 授权`}),t.keyInModelsJson&&(0,F.jsx)(`span`,{className:`settings-provider-badge`,children:`key 在 models.json`}),t.builtin&&(0,F.jsx)(`span`,{className:`settings-provider-badge settings-provider-badge-builtin`,children:`Pi 内置`})]}),t.builtin?(0,F.jsx)(`div`,{className:`settings-provider-meta`,children:`模型由 Pi 提供,可停用`}):(0,F.jsxs)(`div`,{className:`settings-provider-meta`,children:[t.baseUrl,` · `,t.api]}),t.invalidFields&&t.invalidFields.length>0&&(0,F.jsxs)(`div`,{className:`settings-provider-note settings-provider-note-warn`,children:[`这个条目的 `,t.invalidFields.join(`、`),` 是空字符串,Pi 的 schema 不接受, 于是它拒绝整个 models.json —— 文件里所有自定义供应商都不会出现在选择器里。`]}),t.authType!==`oauth`&&!t.hasKey&&!t.keyInModelsJson&&(0,F.jsx)(`div`,{className:`settings-provider-note settings-provider-note-warn`,children:`没有可用凭据,Pi 不会提供这个供应商的模型 —— 它不会出现在任何模型选择器里。编辑里填一个 key 就能恢复。`}),t.authType!==`oauth`&&t.keyInModelsJson&&!t.hasKey&&(0,F.jsx)(`div`,{className:`settings-provider-note`,children:`key 写在 models.json 里(Pi 按其中的写法解析,例如 $VAR)。解析不到时 Pi 不会提供它。`}),n&&(n.has(t.id)?(0,F.jsx)(`div`,{className:`settings-provider-note`,children:`Pi 正在提供它的模型。`}):!t.hasKey&&!t.keyInModelsJson?null:(0,F.jsx)(`div`,{className:`settings-provider-note settings-provider-note-warn`,children:`Pi 现在没有提供它的模型(凭据可能已失效,或环境变量没解析到)。`})),(0,F.jsxs)(`div`,{className:`settings-provider-models`,children:[t.models.map(n=>(0,F.jsxs)(`div`,{className:`settings-provider-model-row`,"data-model-row":`${t.id}:${n.id}`,children:[(0,F.jsx)(`span`,{className:`settings-provider-model`,children:n.name}),(0,F.jsx)(`code`,{className:`settings-provider-model-id`,children:n.id}),!t.builtin&&(0,F.jsxs)(`div`,{className:`settings-provider-model-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link`,"data-model-edit":`${t.id}:${n.id}`,onClick:()=>Ee(t.id,n.id),children:`编辑`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link danger`,"data-model-delete":`${t.id}:${n.id}`,onClick:()=>e.onRemoveProviderModel?.(t.id,n.id),children:`删除`})]})]},n.id)),t.builtin&&t.models.length===0&&(0,F.jsx)(`div`,{className:`settings-provider-empty-note`,children:`暂未读取到模型清单`})]}),(0,F.jsxs)(`div`,{className:`settings-provider-actions`,children:[!t.builtin&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-provider-add-model":t.id,onClick:()=>Te(t.id),children:`添加模型`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-provider-disable":t.id,onClick:()=>e.onToggleProvider?.(t.id,!1),children:`停用`}),ge===t.id?(0,F.jsxs)(`div`,{className:`settings-provider-delete-confirm`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn danger-confirm`,onClick:()=>{P(void 0),e.onRemoveProvider?.(t.id)},children:`确定删除?`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,onClick:()=>P(void 0),children:`取消`})]}):(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-provider-delete":t.id,onClick:()=>P(t.id),children:`删除供应商`})]})]},t.id))}):(0,F.jsx)(`div`,{className:`settings-empty-hint settings-provider-empty-note`,children:`暂无已启用的供应商。可在下方添加,或直接选用上方系统已有的内置模型。`}),ze.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`已停用的供应商`}),(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[`这些供应商已经从 Pi 的配置里拿掉,所以不会出现在任何模型选择器里。启用会把`,(0,F.jsx)(`code`,{children:`models.json`}),` 定义和凭据原样放回去。`]}),(0,F.jsx)(`div`,{className:`settings-provider-list`,children:ze.map(t=>(0,F.jsxs)(`div`,{className:`settings-provider-card settings-provider-card-off`,"data-provider-off-row":t.id,children:[(0,F.jsxs)(`div`,{className:`settings-provider-head`,children:[(0,F.jsx)(`span`,{className:`settings-provider-id`,children:t.id}),t.name!==t.id&&(0,F.jsx)(`span`,{className:`settings-provider-name`,children:t.name}),(0,F.jsx)(`span`,{className:`settings-provider-badge settings-provider-badge-off`,children:`已停用`}),t.builtin&&(0,F.jsx)(`span`,{className:`settings-provider-badge settings-provider-badge-builtin`,children:`Pi 内置`})]}),(0,F.jsx)(`div`,{className:`settings-provider-meta`,children:t.models.length?`原模型:${t.models.map(e=>e.name).join(`、`)}`:t.hasKey?`已保留凭据`:`无模型记录`}),(0,F.jsxs)(`div`,{className:`settings-provider-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-provider-enable":t.id,onClick:()=>e.onToggleProvider?.(t.id,!0),children:`启用`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-provider-forget":t.id,onClick:()=>e.onRemoveProvider?.(t.id),children:`彻底删除`})]})]},t.id))})]}),(0,F.jsxs)(`h4`,{className:`settings-section-title`,children:[a.kind===`add`&&`添加供应商与模型`,a.kind===`addModel`&&`为供应商「${a.providerId}」添加模型`,a.kind===`editModel`&&`编辑模型「${a.modelId}」`]}),a.kind!==`add`&&(0,F.jsxs)(`p`,{className:`settings-agents-desc`,"data-provider-shared-note":`1`,children:[`上面这些是这个供应商下`,(0,F.jsx)(`b`,{children:`所有模型共用`}),`的(地址、API 类型、key)。改动会同时影响它下面的每个模型。`]}),(0,F.jsxs)(`div`,{className:`settings-provider-form`,onChange:be,children:[(0,F.jsxs)(`div`,{className:`settings-rule-form-grid`,children:[(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`供应商 id`}),(0,F.jsx)(`input`,{type:`text`,"data-provider-id":`1`,className:`settings-dir-input`,value:s,placeholder:`如 my-proxy`,readOnly:a.kind!==`add`,onChange:e=>c(e.target.value)})]}),(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`显示名称`}),(0,F.jsx)(`input`,{type:`text`,"data-provider-name":`1`,className:`settings-dir-input`,value:l,placeholder:`如 公司中转`,onChange:e=>d(e.target.value)})]})]}),(0,F.jsxs)(`div`,{className:`settings-rule-form-grid`,children:[(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`API 地址`}),(0,F.jsx)(`input`,{type:`text`,"data-provider-base-url":`1`,className:`settings-dir-input`,value:f,placeholder:`如 https://api.example.com/v1`,onBlur:()=>{if(f.trim()&&!s.trim()){let e=Um(f);c(e),l.trim()||d(e)}},onChange:e=>p(e.target.value)})]}),(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`API 类型`}),(0,F.jsx)(`select`,{"data-provider-api":`1`,className:`settings-model-select`,value:m,onChange:e=>h(e.target.value),children:(i.length?i:[`openai-completions`]).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`settings-rule-form-grid`,children:[(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`API key`}),(0,F.jsx)(`input`,{type:`password`,"data-provider-api-key":`1`,className:`settings-dir-input`,value:g,autoComplete:`off`,placeholder:ve?.hasKey?`已设置,留空表示不修改`:`如 sk-...`,onChange:e=>_(e.target.value)})]}),(0,F.jsxs)(`div`,{className:`settings-rule-input-group settings-fetch-models-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`智能探测`}),(0,F.jsx)(`div`,{className:`settings-fetch-models-row`,children:(0,F.jsx)(`button`,{type:`button`,className:`settings-fetch-models-btn`,"data-fetch-models-btn":`1`,disabled:!f.trim()||oe,onClick:Pe,children:oe?`正在连接并获取模型列表…`:`🔍 自动获取可用模型`})})]})]}),ce&&(0,F.jsx)(`div`,{className:`settings-fetch-models-error`,children:ce}),ue.length>0&&(0,F.jsxs)(`div`,{className:`settings-discovered-box`,"data-discovered-box":`1`,children:[(0,F.jsxs)(`div`,{className:`settings-discovered-head`,children:[(0,F.jsxs)(`span`,{className:`settings-discovered-title`,children:[`从远程接口探测到 `,ue.length,` 个可用模型`]}),(0,F.jsxs)(`div`,{className:`settings-discovered-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link`,onClick:()=>he(new Set(ue.map(e=>e.id))),children:`全选`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link`,onClick:()=>he(new Set),children:`清空`}),(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link danger`,onClick:()=>de([]),children:`收起列表`})]})]}),(0,F.jsx)(`input`,{type:`text`,className:`settings-dir-input settings-discovered-search`,placeholder:`搜索模型名称或 ID…`,value:fe,onChange:e=>pe(e.target.value)}),(0,F.jsx)(`div`,{className:`settings-discovered-list`,children:ue.filter(e=>!fe||e.id.toLowerCase().includes(fe.toLowerCase())).map(e=>{let t=me.has(e.id);return(0,F.jsxs)(`div`,{className:`settings-discovered-item`,children:[(0,F.jsxs)(`label`,{className:`settings-discovered-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>{let n=new Set(me);t.target.checked?n.add(e.id):n.delete(e.id),he(n)}}),(0,F.jsx)(`span`,{className:`settings-discovered-name`,children:e.name}),e.reasoning&&(0,F.jsx)(`span`,{className:`settings-discovered-tag reasoning`,children:`推理`}),e.imageInput&&(0,F.jsx)(`span`,{className:`settings-discovered-tag vision`,children:`视觉`}),e.thinkingLevelMap&&(0,F.jsxs)(`span`,{className:`settings-discovered-tag levels`,"data-discovered-levels":e.id,children:[`档位 `,Tm(e.thinkingLevelMap)]})]}),(0,F.jsx)(`button`,{type:`button`,className:`settings-provider-link`,title:`将此模型的参数填入下方单个编辑表单`,onClick:()=>Oe(Ie,e,ie),children:`填入下方`})]},e.id)})}),(0,F.jsx)(`div`,{className:`settings-discovered-footer`,children:(0,F.jsxs)(`button`,{type:`button`,className:`settings-dir-add-btn`,"data-discovered-import":`1`,disabled:me.size===0||!f.trim()||oe||!Ne,onClick:Fe,children:[`批量导入选中的 `,me.size,` 个模型并保存`]})}),!Ne&&(0,F.jsx)(`div`,{className:`settings-fetch-models-error`,"data-discovered-stale":`1`,children:`API 地址已改动,下面这些候选是旧地址的,不能导入。改回原地址,或重新探测一次。`})]}),(0,F.jsxs)(`div`,{className:`settings-rule-form-grid`,children:[(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`模型 id`}),(0,F.jsx)(`input`,{type:`text`,"data-model-id":`1`,className:`settings-dir-input`,value:b,placeholder:`如 gpt-4o 或点击上方自动探测填入`,onChange:e=>x(e.target.value)})]}),(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`模型显示名`}),(0,F.jsx)(`input`,{type:`text`,"data-model-name":`1`,className:`settings-dir-input`,value:S,placeholder:`留空则用模型 id`,onChange:e=>C(e.target.value)})]})]}),(0,F.jsx)(`div`,{className:`settings-rule-form-grid`,children:(0,F.jsxs)(`label`,{className:`settings-rule-input-group`,children:[(0,F.jsx)(`span`,{className:`settings-rule-label-text`,children:`上下文窗口 / 最大输出`}),(0,F.jsxs)(`div`,{className:`settings-provider-numbers`,children:[(0,F.jsx)(`input`,{type:`number`,"data-model-context-window":`1`,className:`settings-dir-input`,value:O,placeholder:`128000`,onChange:e=>k(e.target.value)}),(0,F.jsx)(`input`,{type:`number`,"data-model-max-tokens":`1`,className:`settings-dir-input`,value:A,placeholder:`16384`,onChange:e=>j(e.target.value)})]})]})}),(0,F.jsxs)(`div`,{className:`settings-provider-switches`,children:[(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-model-reasoning":`1`,checked:w,onChange:e=>T(e.target.checked)}),`推理模型`]}),(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-model-image-input":`1`,checked:E,onChange:e=>D(e.target.checked)}),`支持图片输入`]}),(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-model-developer-role":`1`,checked:ee,onChange:e=>M(e.target.checked)}),`支持 developer 角色`]}),(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-model-reasoning-effort":`1`,checked:te,onChange:e=>N(e.target.checked)}),`支持 reasoning_effort`]}),ve?.hasKey&&(0,F.jsxs)(`label`,{className:`settings-checkbox-label`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-provider-clear-key":`1`,checked:v,onChange:e=>y(e.target.checked)}),`清除已保存的 key`]})]}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,"data-provider-save":`1`,className:`settings-dir-add-btn`,disabled:!Le,onClick:()=>{xe.current=!0,ye.current=!1;let t=s.trim()||Ie;e.onSetProvider?.({id:t,...l.trim()?{name:l.trim()}:{name:t},baseUrl:f.trim(),api:m.trim()||`openai-completions`,...g.trim()?{apiKey:g.trim()}:{},...v?{clearKey:!0}:{},models:[{id:b.trim(),...S.trim()?{name:S.trim()}:{},reasoning:w,...E?{imageInput:!0}:{},...O.trim()?{contextWindow:Number(O)}:{},...A.trim()?{maxTokens:Number(A)}:{},...ee?{}:{supportsDeveloperRole:!1},...te?{}:{supportsReasoningEffort:!1},...Me(Ae(t,b.trim()))}]})},children:a.kind===`add`?`添加单个模型`:a.kind===`addModel`?`添加模型`:`保存修改`}),a.kind!==`add`&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-provider-cancel":`1`,onClick:Se,children:`取消`})]})]})]})}function Gm({providers:e}){let[t,n]=(0,u.useState)([]),[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)({}),l=e.filter(e=>e.authType===`oauth`&&!e.disabled),d=async e=>{let t=await je(`/api/providers/oauth`,{...e?{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}:{}}),r=await t.json();if(!t.ok)throw Error(r.error||`OAuth 授权失败。`);n(r.jobs??[])};(0,u.useEffect)(()=>{let e=!0,t=()=>{je(`/api/providers/oauth`).then(async t=>{let r=await t.json();if(!t.ok)throw Error(r.error);e&&(n(r.jobs??[]),o(``))}).catch(t=>{e&&o(t instanceof Error?t.message:`无法读取登录状态。`)})};t();let r=window.setInterval(t,1200);return()=>{e=!1,window.clearInterval(r)}},[]);let f=async(e,t)=>{i(e),o(``);try{await d(t)}catch(e){o(e instanceof Error?e.message:`OAuth 操作失败。`)}finally{i(``)}};return l.length?(0,F.jsxs)(`section`,{className:`settings-section`,"data-provider-oauth":`1`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`授权登录`}),(0,F.jsx)(`p`,{className:`settings-agents-desc`,children:`使用 Pi 内置的 OAuth 流程登录订阅或账号授权。令牌保存在服务端 Pi 凭据目录,不会显示在此页面。`}),a&&(0,F.jsx)(`p`,{className:`settings-dir-error`,role:`alert`,children:a}),(0,F.jsx)(`div`,{className:`settings-provider-list`,children:l.map(e=>{let n=[...t].reverse().find(t=>t.providerId===e.id),i=n&&[`starting`,`authorizing`,`prompt`].includes(n.state);return(0,F.jsxs)(`article`,{className:`settings-provider-card settings-oauth-card`,"data-oauth-provider":e.id,"data-oauth-state":n?.state??`idle`,children:[(0,F.jsxs)(`div`,{className:`settings-oauth-provider-head`,children:[(0,F.jsx)(`span`,{className:`settings-oauth-provider-mark`,"aria-hidden":`true`,children:e.name.trim().slice(0,1).toUpperCase()}),(0,F.jsxs)(`div`,{className:`settings-oauth-provider-copy`,children:[(0,F.jsx)(`span`,{className:`settings-provider-id`,children:e.name}),(0,F.jsx)(`span`,{className:`settings-oauth-provider-id`,children:e.id})]}),(0,F.jsxs)(`div`,{className:`settings-oauth-badges`,children:[e.oauthSubscription&&(0,F.jsx)(`span`,{className:`settings-provider-badge settings-provider-badge-builtin`,children:`订阅授权`}),(0,F.jsx)(`span`,{className:`settings-provider-badge ${e.authenticated?`settings-oauth-badge-connected`:``}`,children:e.authenticated?`已登录`:`未登录`})]})]}),(0,F.jsx)(`div`,{className:`settings-provider-meta settings-oauth-provider-meta`,children:e.oauthLoginLabel||`Pi 内置 OAuth`}),(0,F.jsxs)(`div`,{className:`settings-provider-actions settings-oauth-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-add-btn`,disabled:!!r||!!i,onClick:()=>void f(e.id,{action:`login`,providerId:e.id}),children:i?`授权处理中…`:e.authenticated?`重新登录`:`登录`}),e.authenticated&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,disabled:!!r,onClick:()=>void f(e.id,{action:`logout`,providerId:e.id}),children:`退出登录`}),i&&(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,onClick:()=>void f(n.id,{action:`cancel`,id:n.id}),children:`取消`})]}),n?.event?.type===`auth_url`&&(0,F.jsxs)(`div`,{className:`settings-oauth-step`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`strong`,{children:`下一步:在浏览器中授权`}),n.event.instructions&&(0,F.jsx)(`p`,{children:String(n.event.instructions)})]}),(0,F.jsx)(`a`,{className:`settings-oauth-open-link`,href:String(n.event.url),target:`_blank`,rel:`noopener noreferrer`,children:`打开授权页面 ↗`})]}),n?.event?.type===`device_code`&&(0,F.jsxs)(`div`,{className:`settings-oauth-step settings-oauth-device-step`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`strong`,{children:`在另一台设备上完成授权`}),(0,F.jsxs)(`p`,{children:[`访问 `,(0,F.jsx)(`a`,{href:String(n.event.verificationUri),target:`_blank`,rel:`noopener noreferrer`,children:String(n.event.verificationUri)}),`,并输入此设备码。`]})]}),(0,F.jsx)(`code`,{className:`settings-oauth-device-code`,children:String(n.event.userCode)})]}),n?.event?.type===`info`&&(0,F.jsx)(`p`,{className:`settings-oauth-message`,children:String(n.event.message??``)}),n?.event?.type===`progress`&&(0,F.jsxs)(`p`,{className:`settings-oauth-message`,role:`status`,children:[(0,F.jsx)(`span`,{className:`settings-oauth-progress-dot`}),String(n.event.message??`授权处理中`)]}),n?.prompt&&(0,F.jsxs)(`form`,{className:`settings-oauth-prompt`,onSubmit:e=>{e.preventDefault(),f(n.id,{action:`answer`,id:n.id,answer:s[n.id]??``})},children:[(0,F.jsxs)(`div`,{className:`settings-oauth-prompt-heading`,children:[(0,F.jsx)(`strong`,{children:`继续登录`}),(0,F.jsx)(`span`,{children:`完成身份验证所需的信息`})]}),n.prompt.type===`select`?(0,F.jsxs)(`label`,{className:`settings-oauth-field`,children:[(0,F.jsx)(`span`,{children:n.prompt.message}),(0,F.jsxs)(`select`,{className:`settings-oauth-select`,value:s[n.id]??``,onChange:e=>c(t=>({...t,[n.id]:e.target.value})),children:[(0,F.jsx)(`option`,{value:``,children:`请选择`}),n.prompt.options?.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),n.prompt.options?.find(e=>e.id===s[n.id])?.description&&(0,F.jsx)(`small`,{className:`settings-oauth-field-help`,children:n.prompt.options.find(e=>e.id===s[n.id]).description})]}):(0,F.jsxs)(`label`,{className:`settings-oauth-field`,children:[(0,F.jsx)(`span`,{children:n.prompt.message}),(0,F.jsx)(`input`,{className:`settings-oauth-input`,type:n.prompt.type===`secret`?`password`:`text`,autoComplete:`off`,placeholder:n.prompt.placeholder,value:s[n.id]??``,onChange:e=>c(t=>({...t,[n.id]:e.target.value}))})]}),(0,F.jsx)(`button`,{className:`settings-dir-add-btn settings-oauth-continue`,type:`submit`,disabled:!!r||!s[n.id],children:`继续`})]}),n?.state===`completed`&&(0,F.jsx)(`p`,{role:`status`,children:`登录完成,Pi 模型清单已刷新。`}),n?.error&&(0,F.jsx)(`p`,{className:`settings-provider-note-warn`,role:`status`,children:n.error})]},e.id)})})]}):null}function Km({context:e}){let t=e.modelCatalog,n=e.defaultModel,r=t?.models??[],i=r.reduce((e,t)=>e.includes(t.provider)?e:[...e,t.provider],[]),a=n?`${n.provider}/${n.modelId}`:``,[o,s]=(0,u.useState)(n?.provider??``),[c,l]=(0,u.useState)(n?.modelId??``),d=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{d.current!==a&&(d.current=a,s(n?.provider??``),l(n?.modelId??``))},[a,n]);let f=n&&!i.includes(n.provider)?[...i,n.provider]:i,p=f.includes(o)?o:f[0]??``,m=r.filter(e=>e.provider===p),h=n&&n.provider===p&&!m.some(e=>e.modelId===n.modelId)?[...m,{provider:n.provider,modelId:n.modelId,label:n.label}]:m,g=h.some(e=>e.modelId===c)?c:h[0]?.modelId??``,_=!n||r.some(e=>e.provider===n.provider&&e.modelId===n.modelId),v=p&&g?`${p}/${g}`:``,y=v!==a,b=!t,x=t?.source===`unavailable`,[S,C]=(0,u.useState)(),w=e=>{s(e);let t=r.filter(t=>t.provider===e);l(e=>t.some(t=>t.modelId===e)?e:t[0]?.modelId??``)};return(0,F.jsxs)(`section`,{"data-settings-model":`1`,className:`settings-panel-container`,children:[(0,F.jsx)(`div`,{className:`settings-agents-header`,children:(0,F.jsxs)(`p`,{className:`settings-agents-desc`,children:[(0,F.jsx)(`strong`,{children:`设置新建会话的默认模型。`}),`这里的选择对所有工作区生效,但优先级低于工作区自己的默认模型;两者都没有时,跟随 Pi 的默认模型。 默认值只在会话创建时复制一次,之后改这里不会改动已经存在的会话。`]})}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`当前默认模型`}),(0,F.jsx)(`div`,{className:`settings-model-current`,"data-model-current":`1`,children:n?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`settings-model-current-name`,children:n.label}),(0,F.jsxs)(`code`,{className:`settings-model-current-pair`,children:[n.provider,`/`,n.modelId]})]}):(0,F.jsx)(`span`,{className:`settings-model-current-none`,children:`跟随 Pi 默认模型`})}),n&&!_&&(0,F.jsx)(`div`,{className:`settings-dir-error`,role:`alert`,children:`⚠️ Pi 当前不再提供这个模型,新会话会改用 Pi 的默认模型。`})]}),(0,F.jsxs)(`section`,{className:`settings-section`,children:[(0,F.jsx)(`h4`,{className:`settings-section-title`,children:`修改默认模型`}),b?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`正在读取 Pi 的模型列表…`}):x?(0,F.jsx)(`div`,{className:`settings-empty-hint`,children:`无法读取 Pi 的模型列表,暂时不能设置默认模型。`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`settings-model-grid`,children:[(0,F.jsxs)(`label`,{className:`settings-model-group`,children:[(0,F.jsx)(`span`,{className:`settings-model-label`,children:`供应商`}),(0,F.jsx)(`select`,{"data-model-provider":`1`,className:`settings-model-select`,value:p,disabled:e.pendingSettings||f.length===0,onChange:e=>w(e.target.value),children:f.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]}),(0,F.jsxs)(`label`,{className:`settings-model-group`,children:[(0,F.jsx)(`span`,{className:`settings-model-label`,children:`模型`}),(0,F.jsx)(`select`,{"data-model-select":`1`,className:`settings-model-select`,value:g,disabled:e.pendingSettings||h.length===0,onChange:e=>l(e.target.value),children:h.map(e=>(0,F.jsx)(`option`,{value:e.modelId,children:e.label},e.modelId))})]})]}),(0,F.jsxs)(`div`,{className:`settings-rule-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,"data-model-save":`1`,className:`settings-dir-add-btn`,disabled:!y||e.pendingSettings||!v,onClick:()=>{let t=r.find(e=>e.provider===p&&e.modelId===g);t&&e.onSetDefaultModel?.({provider:t.provider,modelId:t.modelId,label:t.label})},children:`保存默认模型`}),(0,F.jsx)(`button`,{type:`button`,"data-model-clear":`1`,className:`settings-dir-cancel-btn`,disabled:!n||e.pendingSettings,onClick:()=>e.onSetDefaultModel?.(null),children:`清除默认模型`})]})]})]}),e.modelCatalog?.configError&&(0,F.jsxs)(`div`,{className:`settings-provider-note settings-provider-note-warn settings-provider-config-error`,"data-provider-config-error":`1`,children:[(0,F.jsx)(`div`,{children:`Pi 拒绝了自己的模型配置,因此它不提供文件里的任何自定义供应商:`}),(0,F.jsx)(`pre`,{className:`settings-provider-config-error-text`,children:e.modelCatalog.configError}),(0,F.jsx)(`button`,{type:`button`,className:`settings-dir-cancel-btn`,"data-provider-repair":`1`,onClick:()=>e.onRepairProviders?.(),children:`修好这个文件`})]}),(0,F.jsx)(mm,{}),(0,F.jsx)(Wm,{context:e,externalEditModel:S,offered:new Set((e.modelCatalog?.models??[]).map(e=>e.provider))}),(0,F.jsx)(Hm,{catalog:e.modelCatalog,customProviders:e.providers,onEditModel:(e,t,n)=>C({provider:e,modelId:t,label:n})}),(0,F.jsx)(`div`,{className:`picker-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e.onClose,children:`完成`})})]})}var qm=[{id:`appearance`,label:`外观`,render:Pm},{id:`general`,label:`通用`,render:Fm},{id:`desktop`,label:`桌面与后台`,render:()=>(0,F.jsx)(rm,{})},{id:`notifications`,label:`通知`,render:Im},{id:`memory`,label:`主动记忆`,render:e=>(0,F.jsx)(im,{workspaceId:e.workspaceId,onClose:e.onClose})},{id:`knowledge`,label:`知识库`,render:e=>(0,F.jsx)(om,{workspaceId:e.workspaceId,onClose:e.onClose})},{id:`feishu`,label:`飞书`,render:()=>(0,F.jsx)(sm,{})},{id:`tavily`,label:`Tavily 搜索`,render:()=>(0,F.jsx)(fm,{})},{id:`servers`,label:`服务器连接`,render:()=>(0,F.jsx)(Ue,{})},{id:`agents`,label:`智能体`,render:zm},{id:`model`,label:`模型`,render:e=>(0,F.jsx)(Km,{context:e})},{id:`native-tools`,label:`外部工具`,render:e=>(0,F.jsx)(vm,{workspaceId:e.workspaceId})},{id:`model-rules`,label:`模型过滤`,render:e=>(0,F.jsx)(Vm,{context:e})},{id:`terminal`,label:`终端`,render:e=>(0,F.jsx)(Bm,{context:e})}],Jm=qm[0]?.id;function Ym({initialCategory:e,workspaceId:t,theme:n,onChooseTheme:r,onClose:i,agentCatalog:a,subagentCatalog:o,modelFilterRules:s,onSetModelRules:c,defaultModel:l,modelCatalog:d,onSetDefaultModel:f,providers:p,providerApis:m,onSetProvider:h,onRemoveProvider:g,onToggleProvider:_,onRepairProviders:v,onRemoveProviderModel:y,customAgentDirs:b,pendingSettings:x,onSetCustomAgentDirs:S,onRescanAgents:C,userNickname:w,onSetUserNickname:T,terminalShell:E,onSetTerminalShell:D,browserNotificationsEnabled:O,browserNotificationPermission:k,onSetBrowserNotifications:A,onCheckBrowserNotifications:j}){let[ee,M]=(0,u.useState)(e??Jm);(0,u.useEffect)(()=>{let e=()=>M(`servers`);return window.addEventListener(`super-pi-open-server-management`,e),()=>window.removeEventListener(`super-pi-open-server-management`,e)},[]),(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let{settingsServer:te,connections:N}=se(),ne=N.find(e=>e.id===te)?.managed;(0,u.useEffect)(()=>{let e=()=>{de(`entry`),M(`model`)};return window.addEventListener(`super-pi-open-local-model-settings`,e),()=>window.removeEventListener(`super-pi-open-local-model-settings`,e)},[]);let re=qm.find(e=>e.id===ee)??qm[0];return(0,F.jsx)(`div`,{className:`overlay`,onClick:i,children:(0,F.jsxs)(`div`,{className:`picker settings-window`,"data-theme-dialog":`1`,"data-settings-window":`1`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`settings-window-head`,children:[(0,F.jsx)(`h2`,{children:`设置`}),(0,F.jsx)(Ve,{})]}),(0,F.jsxs)(`div`,{className:`settings-window-body`,children:[(0,F.jsxs)(`nav`,{className:`settings-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`设置分类`,"data-settings-nav":`1`,children:[(0,F.jsx)(`div`,{className:`settings-nav-label`,children:`分类`}),qm.map(e=>(0,F.jsx)(`button`,{type:`button`,id:`settings-tab-${e.id}`,className:`settings-category`,role:`tab`,"aria-selected":e.id===re?.id,"aria-controls":`settings-panel`,tabIndex:e.id===re?.id?0:-1,"data-settings-category":e.id,onClick:()=>M(e.id),children:e.label},e.id))]}),re&&(0,F.jsxs)(`div`,{className:`settings-panel`,id:`settings-panel`,role:`tabpanel`,"aria-labelledby":`settings-tab-${re.id}`,"data-settings-panel":re.id,children:[(0,F.jsx)(`h3`,{className:`settings-panel-title`,"data-settings-panel-title":re.id,children:re.label}),re.id===`model`&&ne?(0,F.jsxs)(`div`,{className:`managed-model-notice`,children:[(0,F.jsx)(`h4`,{children:`此服务器使用本地统一模型配置`}),(0,F.jsx)(`p`,{children:`模型、API key 和授权登录由本地入口管理,无需在远端重复配置。`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>de(`entry`),children:`管理本地模型与登录`})]}):re.render({workspaceId:t&&ce(t)===te?t:void 0,theme:n,onChooseTheme:r,onClose:i,agentCatalog:a,subagentCatalog:o,modelFilterRules:s,onSetModelRules:c,defaultModel:l,modelCatalog:d,onSetDefaultModel:f,providers:p,providerApis:m,onSetProvider:h,onRemoveProvider:g,onToggleProvider:_,onRepairProviders:v,onRemoveProviderModel:y,customAgentDirs:b,pendingSettings:x,onSetCustomAgentDirs:S,onRescanAgents:C,userNickname:w,onSetUserNickname:T,terminalShell:E,onSetTerminalShell:D,browserNotificationsEnabled:O,browserNotificationPermission:k,onSetBrowserNotifications:A,onCheckBrowserNotifications:j})]},te)]})]})})}var Xm=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Qm=(e,t)=>{for(var n in t)Xm(e,n,{get:t[n],enumerable:!0})},$m=(e,t,n,r)=>{for(var i=r>1?void 0:r?Zm(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Xm(t,n,i),i},eh=(e,t)=>(n,r)=>t(n,r,e),th=`Terminal input`,nh={get:()=>th,set:e=>th=e},rh=`Too much output to announce, navigate to rows manually to read`,ih={get:()=>rh,set:e=>rh=e};function ah(e){return e.replace(/\r?\n/g,`\r`)}function oh(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function sh(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ch(e,t,n,r){e.stopPropagation(),e.clipboardData&&lh(e.clipboardData.getData(`text/plain`),t,n,r)}function lh(e,t,n,r){e=ah(e),e=oh(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function uh(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function dh(e,t,n,r,i){uh(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function fh(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ph(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var mh=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},hh=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},gh=``,_h=` `,vh=class e{constructor(){this.fg=0,this.bg=0,this.extended=new yh}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},yh=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},bh=class e extends vh{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new yh,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?fh(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},xh=`di$target`,Sh=`di$dependencies`,Ch=new Map;function wh(e){return e[Sh]||[]}function Th(e){if(Ch.has(e))return Ch.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Eh(t,e,r)};return t._id=e,Ch.set(e,t),t}function Eh(e,t,n){t[xh]===t?t[Sh].push({id:e,index:n}):(t[Sh]=[{id:e,index:n}],t[xh]=t)}var Dh=Th(`BufferService`),Oh=Th(`CoreMouseService`),kh=Th(`CoreService`),Ah=Th(`CharsetService`),jh=Th(`InstantiationService`),Mh=Th(`LogService`),Nh=Th(`OptionsService`),Ph=Th(`OscLinkService`),Fh=Th(`UnicodeService`),Ih=Th(`DecorationService`),Lh=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new bh,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Rh(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Lh=$m([eh(0,Dh),eh(1,Nh),eh(2,Ph)],Lh);function Rh(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
316
|
+
|
|
317
|
+
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var zh=Th(`CharSizeService`),Bh=Th(`CoreBrowserService`),Vh=Th(`MouseService`),Hh=Th(`RenderService`),Uh=Th(`SelectionService`),Wh=Th(`CharacterJoinerService`),Gh=Th(`ThemeService`),Kh=Th(`LinkProviderService`),qh=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$h.isErrorNoTelemetry(e)?new $h(e.message+`
|
|
318
|
+
|
|
319
|
+
`+e.stack):Error(e.message+`
|
|
320
|
+
|
|
321
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Jh(e){Xh(e)||qh.onUnexpectedError(e)}var Yh=`Canceled`;function Xh(e){return e instanceof Zh||e instanceof Error&&e.name===Yh&&e.message===Yh}var Zh=class extends Error{constructor(){super(Yh),this.name=this.message}};function Qh(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var $h=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},eg=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function tg(e,t=0){return e[e.length-(1+t)]}var ng;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(ng||={});var rg=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||ng.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};rg.empty=new rg(e=>{});function ig(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var ag;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(ag||={});var og=null;function sg(e){return og?.trackDisposable(e),e}function cg(e){og?.markAsDisposed(e)}function lg(e,t){og?.setParent(e,t)}function ug(e){return og?.markAsSingleton(e),e}function dg(e){if(ag.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function fg(...e){return pg(()=>dg(e))}function pg(e){let t=sg({dispose:ig(()=>{cg(t),e()})});return t}var mg=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,sg(this)}dispose(){this._isDisposed||(cg(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{dg(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return lg(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),lg(e,null))}};mg.DISABLE_DISPOSED_WARNING=!1;var hg=mg,gg=class{constructor(){this._store=new hg,sg(this),lg(this._store,this)}dispose(){cg(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};gg.None=Object.freeze({dispose(){}});var _g=class{constructor(){this._isDisposed=!1,sg(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&lg(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,cg(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&lg(e,null),e}},vg=typeof window==`object`?window:globalThis,yg=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};yg.Undefined=new yg(void 0);var bg=yg,xg=class{constructor(){this._first=bg.Undefined,this._last=bg.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===bg.Undefined}clear(){let e=this._first;for(;e!==bg.Undefined;){let t=e.next;e.prev=bg.Undefined,e.next=bg.Undefined,e=t}this._first=bg.Undefined,this._last=bg.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new bg(e);if(this._first===bg.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==bg.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==bg.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==bg.Undefined&&e.next!==bg.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===bg.Undefined&&e.next===bg.Undefined?(this._first=bg.Undefined,this._last=bg.Undefined):e.next===bg.Undefined?(this._last=this._last.prev,this._last.next=bg.Undefined):e.prev===bg.Undefined&&(this._first=this._first.next,this._first.prev=bg.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==bg.Undefined;)yield e.element,e=e.next}},Sg=globalThis.performance&&typeof globalThis.performance.now==`function`,Cg=class e{static create(t){return new e(t)}constructor(e){this._now=Sg&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},wg;(e=>{e.None=()=>gg.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(fg(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof hg?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(wg||={});var Tg=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Cg,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Tg.all=new Set,Tg._idPool=0;var Eg=Tg,Dg=-1,Og=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new jg(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};Og._idPool=1;var kg=Og,Ag=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
322
|
+
`).slice(2).join(`
|
|
323
|
+
`))}},jg=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Mg=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Ng=0,Pg=class{constructor(e){this.value=e,this.id=Ng++}},Fg=2,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Dg>0||this._options?.leakWarningThreshold?new kg(e?.onListenerError??Jh,this._options?.leakWarningThreshold??Dg):void 0,this._perfMon=this._options?._profName?new Eg(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Mg(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Jh)(n),gg.None}if(this._disposed)return gg.None;t&&(e=e.bind(t));let r=new Pg(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Ag.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Pg?(this._deliveryQueue??=new Ig,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=pg(()=>{i?.(),this._removeListener(r)});return n instanceof hg?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Fg<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Jh;if(!n)e.value(t);else try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof Pg)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},Ig=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Lg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Lg.INSTANCE=new Lg;var Rg=Lg;function zg(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Rg.INSTANCE.onDidChangeZoomLevel;function Bg(e){return Rg.INSTANCE.getZoomFactor(e)}Rg.INSTANCE.onDidChangeFullscreen;var Vg=typeof navigator==`object`?navigator.userAgent:``,Hg=Vg.indexOf(`Firefox`)>=0,Ug=Vg.indexOf(`AppleWebKit`)>=0,Wg=Vg.indexOf(`Chrome`)>=0,Gg=!Wg&&Vg.indexOf(`Safari`)>=0;Vg.indexOf(`Electron/`),Vg.indexOf(`Android`);var Kg=!1;if(typeof vg.matchMedia==`function`){let e=vg.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=vg.matchMedia(`(display-mode: fullscreen)`);Kg=e.matches,zg(vg,e,({matches:e})=>{Kg&&t.matches||(Kg=e)})}function qg(){return Kg}var Jg=`en`,Yg=!1,Xg=!1,Zg=!1,Qg=!1,$g=!1,e_=Jg,t_,n_=globalThis,r_;typeof n_.vscode<`u`&&typeof n_.vscode.process<`u`?r_=n_.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(r_=process);var i_=typeof r_?.versions?.electron==`string`&&r_?.type===`renderer`;if(typeof r_==`object`){Yg=r_.platform===`win32`,Xg=r_.platform===`darwin`,Zg=r_.platform===`linux`,Zg&&r_.env.SNAP&&r_.env.SNAP_REVISION,r_.env.CI||r_.env.BUILD_ARTIFACTSTAGINGDIRECTORY,e_=Jg;let e=r_.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,e_=t.resolvedLanguage||Jg,t.languagePack?.translationsConfigFile}catch{}Qg=!0}else typeof navigator==`object`&&!i_?(t_=navigator.userAgent,Yg=t_.indexOf(`Windows`)>=0,Xg=t_.indexOf(`Macintosh`)>=0,(t_.indexOf(`Macintosh`)>=0||t_.indexOf(`iPad`)>=0||t_.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Zg=t_.indexOf(`Linux`)>=0,t_?.indexOf(`Mobi`),$g=!0,e_=globalThis._VSCODE_NLS_LANGUAGE||Jg,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var a_=Yg,o_=Xg,s_=Zg,c_=Qg;$g&&typeof n_.importScripts==`function`&&n_.origin;var l_=t_,u_=e_,d_;(e=>{function t(){return u_}e.value=t;function n(){return u_.length===2?u_===`en`:u_.length>=3&&u_[0]===`e`&&u_[1]===`n`&&u_[2]===`-`}e.isDefaultVariant=n;function r(){return u_===`en`}e.isDefault=r})(d_||={});var f_=typeof n_.postMessage==`function`&&!n_.importScripts;(()=>{if(f_){let e=[];n_.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),n_.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var p_=!!(l_&&l_.indexOf(`Chrome`)>=0);l_&&l_.indexOf(`Firefox`),!p_&&l_&&l_.indexOf(`Safari`),l_&&l_.indexOf(`Edg/`),l_&&l_.indexOf(`Android`);var m_=typeof navigator==`object`?navigator:{};c_||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||m_&&m_.clipboard&&m_.clipboard.writeText,c_||m_&&m_.clipboard&&m_.clipboard.readText,c_||qg()||m_.keyboard,`ontouchstart`in vg||m_.maxTouchPoints,vg.PointerEvent&&(`ontouchstart`in vg||navigator.maxTouchPoints);var h_=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},g_=new h_,__=new h_,v_=new h_,y_=Array(230),b_;(e=>{function t(e){return g_.keyCodeToStr(e)}e.toString=t;function n(e){return g_.strToKeyCode(e)}e.fromString=n;function r(e){return __.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return v_.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return __.strToKeyCode(e)||v_.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return g_.keyCodeToStr(e)}e.toElectronAccelerator=o})(b_||={});var x_=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new S_([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},S_=class{constructor(e){if(e.length===0)throw Qh(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function C_(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return b_.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(Hg)switch(t){case 59:return 85;case 60:if(s_)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(o_)return 57}else if(Ug&&(o_&&t===93||!o_&&t===92))return 57;return y_[t]||0}var w_=o_?256:2048,T_=512,E_=1024,D_=o_?2048:256,O_=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=C_(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=w_),this.altKey&&(t|=T_),this.shiftKey&&(t|=E_),this.metaKey&&(t|=D_),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new x_(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},k_=new WeakMap;function A_(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var j_=class{static getSameOriginWindowChain(e){let t=k_.get(e);if(!t){t=[],k_.set(e,t);let n=e,r;do r=A_(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},M_=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=j_.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},N_=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(Wg){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?Hg&&!o_?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=Gg&&a_?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?Hg&&!o_?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},P_=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),F_;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof I_?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:wg.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:P_})})(F_||={});var I_=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?P_:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},L_=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new eg(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new eg(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},R_=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new eg(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=pg(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var z_;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(z_||={});var B_=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await wg.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};B_.EMPTY=B_.fromArray([]);function V_(e){return H_(e,0)}function H_(e,t){switch(typeof e){case`object`:return e===null?U_(349,t):Array.isArray(e)?K_(e,t):q_(e,t);case`string`:return G_(e,t);case`boolean`:return W_(e,t);case`number`:return U_(e,t);case`undefined`:return U_(937,t);default:return U_(617,t)}}function U_(e,t){return(t<<5)-t+e|0}function W_(e,t){return U_(e?433:863,t)}function G_(e,t){t=U_(149417,t);for(let n=0,r=e.length;n<r;n++)t=U_(e.charCodeAt(n),t);return t}function K_(e,t){return t=U_(104579,t),e.reduce((e,t)=>H_(t,e),t)}function q_(e,t){return t=U_(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=G_(n,t),H_(e[n],t)),t)}var{registerWindow:J_,getWindow:Y_,getDocument:X_,getWindows:Z_,getWindowsCount:Q_,getWindowId:$_,getWindowById:ev,hasWindow:tv,onDidRegisterWindow:nv,onWillUnregisterWindow:rv,onDidUnregisterWindow:iv}=function(){let e=new Map,t={window:vg,disposables:new hg};e.set(vg.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return gg.None;let a=new hg,o={window:t,disposables:a.add(new hg)};return e.set(t.vscodeWindowId,o),a.add(pg(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(ov(t,hv.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:vg},getDocument(e){return Y_(e).document}}}(),av=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function ov(e,t,n,r){return new av(e,t,n,r)}function sv(e,t){return function(n){return t(new M_(e,n))}}function cv(e){return function(t){return e(new O_(t))}}var lv=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=sv(Y_(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=cv(n)),ov(e,t,i,r)},uv,dv=class extends R_{constructor(e){super(),this.defaultTarget=e&&Y_(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},fv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Jh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(fv.sort),a.shift().execute();r.set(i,!1)};uv=(t,r,a=0)=>{let o=$_(t),s=new fv(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var pv=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};pv.None=new pv(0,0);function mv(e){let t=e.getBoundingClientRect(),n=Y_(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=V_(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(pg(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var hv={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:Ug?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Ug?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Ug?`webkitAnimationIteration`:`animationiteration`},gv=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=_v(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=_v(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=_v(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=_v(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=_v(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=_v(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=_v(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=_v(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=_v(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=_v(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=_v(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=_v(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=_v(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=_v(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function _v(e){return typeof e==`number`?`${e}px`:e}function vv(e){return new gv(e)}var yv=class{constructor(){this._hooks=new hg,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(pg(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Y_(e)}this._hooks.add(ov(a,hv.POINTER_MOVE,e=>{e.buttons===n?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(ov(a,hv.POINTER_UP,e=>this.stopMonitoring(!0)))}};function bv(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var xv;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(xv||={});var Sv=class e extends gg{constructor(){super(),this.dispatched=!1,this.targets=new xg,this.ignoreTargets=new xg,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(wg.runAndSubscribe(nv,({window:e,disposables:t})=>{t.add(ov(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(ov(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(ov(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:vg,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=ug(new e),pg(e.INSTANCE.targets.push(t))):gg.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=ug(new e),pg(e.INSTANCE.ignoreTargets.push(t))):gg.None}static isTouchDevice(){return`ontouchstart`in vg||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(xv.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-tg(s.rollingPageX))<30&&Math.abs(s.initialPageY-tg(s.rollingPageY))<30){let e=this.newGestureEvent(xv.Tap,s.initialTarget);e.pageX=tg(s.rollingPageX),e.pageY=tg(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-tg(s.rollingPageX))<30&&Math.abs(s.initialPageY-tg(s.rollingPageY))<30){let e=this.newGestureEvent(xv.Contextmenu,s.initialTarget);e.pageX=tg(s.rollingPageX),e.pageY=tg(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=tg(s.rollingPageX),n=tg(s.rollingPageY),i=tg(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(xv.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===xv.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===xv.Change||t.type===xv.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=uv(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(xv.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(xv.Change,i.initialTarget);a.translationX=r.pageX-tg(i.rollingPageX),a.translationY=r.pageY-tg(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Sv.SCROLL_FRICTION=-.005,Sv.HOLD_DELAY=700,Sv.CLEAR_TAP_COUNT_TIME=400,$m([bv],Sv,`isTouchDevice`,1);var Cv=Sv,wv=class extends gg{onclick(e,t){this._register(ov(e,hv.CLICK,n=>t(new M_(Y_(e),n))))}onmousedown(e,t){this._register(ov(e,hv.MOUSE_DOWN,n=>t(new M_(Y_(e),n))))}onmouseover(e,t){this._register(ov(e,hv.MOUSE_OVER,n=>t(new M_(Y_(e),n))))}onmouseleave(e,t){this._register(ov(e,hv.MOUSE_LEAVE,n=>t(new M_(Y_(e),n))))}onkeydown(e,t){this._register(ov(e,hv.KEY_DOWN,e=>t(new O_(e))))}onkeyup(e,t){this._register(ov(e,hv.KEY_UP,e=>t(new O_(e))))}oninput(e,t){this._register(ov(e,hv.INPUT,t))}onblur(e,t){this._register(ov(e,hv.BLUR,t))}onfocus(e,t){this._register(ov(e,hv.FOCUS,t))}onchange(e,t){this._register(ov(e,hv.CHANGE,t))}ignoreGesture(e){return Cv.ignoreTarget(e)}},Tv=11,Ev=class extends wv{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=Tv+`px`,this.domNode.style.height=Tv+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new yv),this._register(lv(this.bgDomNode,hv.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(lv(this.domNode,hv.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new dv),this._pointerdownScheduleRepeatTimer=this._register(new L_)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Y_(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Dv=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Ov=class extends gg{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Dv(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new Mv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=Mv.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},kv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Av(e,t){let n=t-e;return function(t){return e+n*Pv(t)}}function jv(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var Mv=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),jv(Av(e,r),Av(i,t),.33)}return Av(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new kv(this.scrollLeft(t),this.scrollTop(t),!1):new kv(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function Nv(e){return e**3}function Pv(e){return 1-Nv(1-e)}var Fv=class extends gg{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new L_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},Iv=140,Lv=class extends wv{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Fv(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new yv),this._shouldRender=!0,this.domNode=vv(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(ov(this.domNode.domNode,hv.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Ev(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=vv(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ov(this.slider.domNode,hv.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=mv(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(a_&&a>Iv){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Rv=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},zv=class extends Lv{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Rv(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Bv=class extends Lv{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Rv(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Vv=500,Hv=50,Uv=!0,Wv=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Gv=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(1);return t<=.5}acceptStandardWheelEvent(e){if(Wg){let t=Bg(Y_(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new Wv(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Gv.INSTANCE=new Gv;var Kv=Gv,qv=class extends wv{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=Yv(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Bv(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new zv(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vv(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vv(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vv(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new L_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=dg(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,o_&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new N_(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=dg(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(ov(this._listenOnDomNode,hv.MOUSE_WHEEL,e=>{this._onMouseWheel(new N_(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=Kv.INSTANCE;Uv&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!o_&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=Hv*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=Hv*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(Uv&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Vv)}},Jv=class extends qv{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Yv(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,o_&&(t.className+=` mac`),t}var Xv=class extends gg{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Ov({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>uv(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Jv(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(wg.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(pg(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(pg(()=>this._styleElement.remove())),this._register(wg.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
324
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xv=$m([eh(2,Dh),eh(3,Bh),eh(4,Oh),eh(5,Gh),eh(6,Nh),eh(7,Hh)],Xv);var Zv=class extends gg{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(pg(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Zv=$m([eh(1,Dh),eh(2,Bh),eh(3,Ih),eh(4,Hh)],Zv);var Qv=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},$v={full:0,left:0,center:0,right:0},ey={full:0,left:0,center:0,right:0},ty={full:0,left:0,center:0,right:0},ny=class extends gg{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new Qv,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(pg(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ey.full=this._canvas.width,ey.left=e,ey.center=t,ey.right=e,this._refreshDrawHeightConstants(),ty.full=1,ty.left=1,ty.center=1+ey.left,ty.right=1+ey.left+ey.center}_refreshDrawHeightConstants(){$v.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);$v.left=t,$v.center=t,$v.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$v.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$v.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$v.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$v.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(ty[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-$v[e.position||`full`]/2),ey[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+$v[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ny=$m([eh(2,Dh),eh(3,Ih),eh(4,Hh),eh(5,Nh),eh(6,Gh),eh(7,Bh)],ny);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
325
|
+
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var ry;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(ry||={});var iy;(e=>e.ST=`${$.ESC}\\`)(iy||={});var ay=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};ay=$m([eh(2,Dh),eh(3,Nh),eh(4,kh),eh(5,Hh)],ay);var oy=0,sy=0,cy=0,ly=0,uy={css:`#00000000`,rgba:0},dy;(e=>{function t(e,t,n,r){return r===void 0?`#${gy(e)}${gy(t)}${gy(n)}`:`#${gy(e)}${gy(t)}${gy(n)}${gy(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(dy||={});var fy;(e=>{function t(e,t){if(ly=(t.rgba&255)/255,ly===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return oy=a+Math.round((n-a)*ly),sy=o+Math.round((r-o)*ly),cy=s+Math.round((i-s)*ly),{css:dy.toCss(oy,sy,cy),rgba:dy.toRgba(oy,sy,cy)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=hy.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return dy.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[oy,sy,cy]=hy.toChannels(t),{css:dy.toCss(oy,sy,cy),rgba:t}}e.opaque=i;function a(e,t){return ly=Math.round(t*255),[oy,sy,cy]=hy.toChannels(e.rgba),{css:dy.toCss(oy,sy,cy,ly),rgba:dy.toRgba(oy,sy,cy,ly)}}e.opacity=a;function o(e,t){return ly=e.rgba&255,a(e,ly*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(fy||={});var py;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return oy=parseInt(e.slice(1,2).repeat(2),16),sy=parseInt(e.slice(2,3).repeat(2),16),cy=parseInt(e.slice(3,4).repeat(2),16),dy.toColor(oy,sy,cy);case 5:return oy=parseInt(e.slice(1,2).repeat(2),16),sy=parseInt(e.slice(2,3).repeat(2),16),cy=parseInt(e.slice(3,4).repeat(2),16),ly=parseInt(e.slice(4,5).repeat(2),16),dy.toColor(oy,sy,cy,ly);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return oy=parseInt(r[1]),sy=parseInt(r[2]),cy=parseInt(r[3]),ly=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),dy.toColor(oy,sy,cy,ly);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[oy,sy,cy,ly]=t.getImageData(0,0,1,1).data,ly!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:dy.toRgba(oy,sy,cy,ly),css:e}}e.toColor=r})(py||={});var my;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(my||={});var hy;(e=>{function t(e,t){if(ly=(t&255)/255,ly===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return oy=a+Math.round((n-a)*ly),sy=o+Math.round((r-o)*ly),cy=s+Math.round((i-s)*ly),dy.toRgba(oy,sy,cy)}e.blend=t;function n(e,t,n){let a=my.relativeLuminance(e>>8),o=my.relativeLuminance(t>>8);if(_y(a,o)<n){if(o<a){let o=r(e,t,n),s=_y(a,my.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>_y(a,my.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=_y(a,my.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>_y(a,my.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=_y(my.relativeLuminance2(o,s,c),my.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=_y(my.relativeLuminance2(o,s,c),my.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=_y(my.relativeLuminance2(o,s,c),my.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=_y(my.relativeLuminance2(o,s,c),my.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(hy||={});function gy(e){let t=e.toString(16);return t.length<2?`0`+t:t}function _y(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var vy=class extends vh{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},yy=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new bh}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||_h.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)yy._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||_h.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};yy=$m([eh(0,Dh)],yy);function by(e){return 57508<=e&&e<=57558}function xy(e){return 9472<=e&&e<=9631}function Sy(e){return by(e)||xy(e)}function Cy(){return{css:{canvas:wy(),cell:wy()},device:{canvas:wy(),cell:wy(),char:{width:0,height:0,left:0,top:0}}}}function wy(){return{width:0,height:0}}var Ty=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new bh,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,ee=k,M=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,M=new vy(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ee=r[1]-1,m=M.getWidth()):E=r[1]}let te=this._isCellInSelection(k,t),N=n&&k===a,ne=O&&k>=l&&k<=u,re=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{re=!0});let ie=M.getChars()||_h;if(ie===` `&&(M.isUnderline()||M.isOverline())&&(ie=`\xA0`),T=m*s-c.get(ie,M.isBold(),M.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(te&&w||!te&&!w&&M.bg===y)&&(te&&w&&p.selectionForeground||M.fg===b)&&M.extended.ext===x&&ne===S&&T===C&&!N&&!A&&!re&&j){M.isInvisible()?_+=_h:_+=ie,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=M.bg,b=M.fg,x=M.extended.ext,S=ne,C=T,w=te,A&&a>=k&&a<=ee&&(a=k),!this._coreService.isCursorHidden&&N&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(M.isBold()&&D.push(`xterm-bold`),M.isItalic()&&D.push(`xterm-italic`),M.isDim()&&D.push(`xterm-dim`),_=M.isInvisible()?_h:M.getChars()||_h,M.isUnderline()&&(D.push(`xterm-underline-${M.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!M.isUnderlineColorDefault())){if(M.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${vh.toColorRGB(M.getUnderlineColor()).join(`,`)})`;else{let e=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}M.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),M.isStrikethrough()&&D.push(`xterm-strikethrough`),ne&&(h.style.textDecoration=`underline`);let ae=M.getFgColor(),oe=M.getFgColorMode(),se=M.getBgColor(),ce=M.getBgColorMode(),le=!!M.isInverse();if(le){let e=ae;ae=se,se=e;let t=oe;oe=ce,ce=t}let ue,de,fe=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&fe||(e.backgroundColorRGB&&(ce=50331648,se=e.backgroundColorRGB.rgba>>8&16777215,ue=e.backgroundColorRGB),e.foregroundColorRGB&&(oe=50331648,ae=e.foregroundColorRGB.rgba>>8&16777215,de=e.foregroundColorRGB),fe=e.options.layer===`top`)}),!fe&&te&&(ue=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,se=ue.rgba>>8&16777215,ce=50331648,fe=!0,p.selectionForeground&&(oe=50331648,ae=p.selectionForeground.rgba>>8&16777215,de=p.selectionForeground)),fe&&D.push(`xterm-decoration-top`);let pe;switch(ce){case 16777216:case 33554432:pe=p.ansi[se],D.push(`xterm-bg-${se}`);break;case 50331648:pe=dy.toColor(se>>16,se>>8&255,se&255),this._addStyle(h,`background-color:#${Ey((se>>>0).toString(16),`0`,6)}`);break;default:le?(pe=p.foreground,D.push(`xterm-bg-257`)):pe=p.background}switch(ue||M.isDim()&&(ue=fy.multiplyOpacity(pe,.5)),oe){case 16777216:case 33554432:M.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(h,pe,p.ansi[ae],M,ue,void 0)||D.push(`xterm-fg-${ae}`);break;case 50331648:let e=dy.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(h,pe,e,M,ue,de)||this._addStyle(h,`color:#${Ey(ae.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,pe,p.foreground,M,ue,de)||le&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!N&&!A&&!re&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=ee}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Sy(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=fy.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Ty=$m([eh(1,Wh),eh(2,Nh),eh(3,Bh),eh(4,kh),eh(5,Ih),eh(6,Gh)],Ty);function Ey(e,t,n){for(;e.length<n;)e=t+e;return e}var Dy=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Oy=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function ky(){return new Oy}var Ay=`xterm-dom-renderer-owner-`,jy=`xterm-rows`,My=`xterm-fg-`,Ny=`xterm-bg-`,Py=`xterm-focus`,Fy=`xterm-selection`,Iy=1,Ly=class extends gg{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=Iy++,this._rowElements=[],this._selectionRenderModel=ky(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(jy),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(Fy),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Cy(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Ty,document),this._element.classList.add(Ay+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(pg(()=>{this._element.classList.remove(Ay+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Dy(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${jy} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${jy} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${jy} .xterm-dim { color: ${fy.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${jy}.${Py} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${jy}.${Py} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${jy}.${Py} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${jy} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${jy} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${jy} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${jy} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${jy} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fy} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fy} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fy} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${My}${n} { color: ${r.css}; }${this._terminalSelector} .${My}${n}.xterm-dim { color: ${fy.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Ny}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${My}257 { color: ${fy.opaque(e.background).css}; }${this._terminalSelector} .${My}257.xterm-dim { color: ${fy.multiplyOpacity(fy.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ny}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Py),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Py),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ay}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};Ly=$m([eh(7,jh),eh(8,zh),eh(9,Nh),eh(10,Dh),eh(11,kh),eh(12,Bh),eh(13,Gh)],Ly);var Ry=class extends gg{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Vy(this._optionsService))}catch{this._measureStrategy=this._register(new By(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Ry=$m([eh(2,Nh)],Ry);var zy=class extends gg{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},By=class extends zy{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Vy=class extends zy{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Hy=class extends gg{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Uy(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(wg.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ov(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(ov(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Uy=class extends gg{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new _g),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(pg(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ov(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Wy=class extends gg{constructor(){super(),this.linkProviders=[],this._register(pg(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Gy(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function Ky(e,t,n,r,i,a,o,s,c){if(!a)return;let l=Gy(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var qy=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Ky(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=Gy(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};qy=$m([eh(0,Hh),eh(1,zh)],qy);var Jy=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Yy={};Qm(Yy,{getSafariVersion:()=>nb,isChromeOS:()=>cb,isFirefox:()=>$y,isIpad:()=>ib,isIphone:()=>ab,isLegacyEdge:()=>eb,isLinux:()=>sb,isMac:()=>rb,isNode:()=>Xy,isSafari:()=>tb,isWindows:()=>ob});var Xy=typeof process<`u`&&`title`in process,Zy=Xy?`node`:navigator.userAgent,Qy=Xy?`node`:navigator.platform,$y=Zy.includes(`Firefox`),eb=Zy.includes(`Edge`),tb=/^((?!chrome|android).)*safari/i.test(Zy);function nb(){if(!tb)return 0;let e=Zy.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var rb=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Qy),ib=Qy===`iPad`,ab=Qy===`iPhone`,ob=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Qy),sb=Qy.indexOf(`Linux`)>=0,cb=/\bCrOS\b/.test(Zy),lb=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},ub=class extends lb{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},db=class extends lb{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fb=!Xy&&`requestIdleCallback`in window?db:ub,pb=class{constructor(){this._queue=new fb}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},mb=class extends gg{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new _g),this._pausedResizeTask=new pb,this._observerDisposable=this._register(new _g),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Jy((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new hb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(pg(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=pg(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};mb=$m([eh(2,Nh),eh(3,zh),eh(4,kh),eh(5,Ih),eh(6,Dh),eh(7,Bh),eh(8,Gh)],mb);var hb=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function gb(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return yb(i,a,e,t,n,r)+bb(a,t,n,r)+xb(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,Ob(Math.abs(i-e),Db(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return Ob(vb(a>t?e:i,n)+(s-1)*n.cols+1+_b(a>t?i:e,n),Db(o,r))}function _b(e,t){return e-1}function vb(e,t){return t.cols-e}function yb(e,t,n,r,i,a){return bb(t,r,i,a).length===0?``:Ob(Eb(e,t,e,t-Cb(t,i),!1,i).length,Db(`D`,a))}function bb(e,t,n,r){let i=e-Cb(e,n),a=t-Cb(t,n);return Ob(Math.abs(i-a)-Sb(e,t,n),Db(Tb(e,t),r))}function xb(e,t,n,r,i,a){let o;o=bb(t,r,i,a).length>0?r-Cb(r,i):t;let s=r,c=wb(e,t,n,r,i,a);return Ob(Eb(e,o,n,s,c===`C`,i).length,Db(c,a))}function Sb(e,t,n){let r=0,i=e-Cb(e,n),a=t-Cb(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=Tb(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function Cb(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function wb(e,t,n,r,i,a){let o;return o=bb(n,r,i,a).length>0?r-Cb(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function Tb(e,t){return e>t?`A`:`B`}function Eb(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function Db(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function Ob(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var kb=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Ab(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var jb=50,Mb=15,Nb=50,Pb=500,Fb=RegExp(`\xA0`,`g`),Ib=class extends gg{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new bh,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new kb(this._bufferService),this._activeSelectionMode=0,this._register(pg(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(Fb,` `)).join(ob?`\r
|
|
326
|
+
`:`
|
|
327
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),sb&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Ab(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Gy(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-jb),jb),t/=jb,t/Math.abs(t)+Math.round(t*(Mb-1)))}shouldForceSelection(e){return rb?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Nb)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(rb&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Pb&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=gb(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);n?!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Ab(n,this._bufferService.cols)}};Ib=$m([eh(3,Dh),eh(4,kh),eh(5,Vh),eh(6,Nh),eh(7,Hh),eh(8,Bh)],Ib);var Lb=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Rb=class{constructor(){this._color=new Lb,this._css=new Lb}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},zb=Object.freeze((()=>{let e=[py.toColor(`#2e3436`),py.toColor(`#cc0000`),py.toColor(`#4e9a06`),py.toColor(`#c4a000`),py.toColor(`#3465a4`),py.toColor(`#75507b`),py.toColor(`#06989a`),py.toColor(`#d3d7cf`),py.toColor(`#555753`),py.toColor(`#ef2929`),py.toColor(`#8ae234`),py.toColor(`#fce94f`),py.toColor(`#729fcf`),py.toColor(`#ad7fa8`),py.toColor(`#34e2e2`),py.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:dy.toCss(r,i,a),rgba:dy.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:dy.toCss(n,n,n),rgba:dy.toRgba(n,n,n)})}return e})()),Bb=py.toColor(`#ffffff`),Vb=py.toColor(`#000000`),Hb=py.toColor(`#ffffff`),Ub=Vb,Wb={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},Gb=Bb,Kb=class extends gg{constructor(e){super(),this._optionsService=e,this._contrastCache=new Rb,this._halfContrastCache=new Rb,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Bb,background:Vb,cursor:Hb,cursorAccent:Ub,selectionForeground:void 0,selectionBackgroundTransparent:Wb,selectionBackgroundOpaque:fy.blend(Vb,Wb),selectionInactiveBackgroundTransparent:Wb,selectionInactiveBackgroundOpaque:fy.blend(Vb,Wb),scrollbarSliderBackground:fy.opacity(Bb,.2),scrollbarSliderHoverBackground:fy.opacity(Bb,.4),scrollbarSliderActiveBackground:fy.opacity(Bb,.5),overviewRulerBorder:Bb,ansi:zb.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=qb(e.foreground,Bb),t.background=qb(e.background,Vb),t.cursor=fy.blend(t.background,qb(e.cursor,Hb)),t.cursorAccent=fy.blend(t.background,qb(e.cursorAccent,Ub)),t.selectionBackgroundTransparent=qb(e.selectionBackground,Wb),t.selectionBackgroundOpaque=fy.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=qb(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=fy.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?qb(e.selectionForeground,uy):void 0,t.selectionForeground===uy&&(t.selectionForeground=void 0),fy.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=fy.opacity(t.selectionBackgroundTransparent,.3)),fy.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=fy.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=qb(e.scrollbarSliderBackground,fy.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=qb(e.scrollbarSliderHoverBackground,fy.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=qb(e.scrollbarSliderActiveBackground,fy.opacity(t.foreground,.5)),t.overviewRulerBorder=qb(e.overviewRulerBorder,Gb),t.ansi=zb.slice(),t.ansi[0]=qb(e.black,zb[0]),t.ansi[1]=qb(e.red,zb[1]),t.ansi[2]=qb(e.green,zb[2]),t.ansi[3]=qb(e.yellow,zb[3]),t.ansi[4]=qb(e.blue,zb[4]),t.ansi[5]=qb(e.magenta,zb[5]),t.ansi[6]=qb(e.cyan,zb[6]),t.ansi[7]=qb(e.white,zb[7]),t.ansi[8]=qb(e.brightBlack,zb[8]),t.ansi[9]=qb(e.brightRed,zb[9]),t.ansi[10]=qb(e.brightGreen,zb[10]),t.ansi[11]=qb(e.brightYellow,zb[11]),t.ansi[12]=qb(e.brightBlue,zb[12]),t.ansi[13]=qb(e.brightMagenta,zb[13]),t.ansi[14]=qb(e.brightCyan,zb[14]),t.ansi[15]=qb(e.brightWhite,zb[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=qb(e.extendedAnsi[r],zb[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0)for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];else switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Kb=$m([eh(0,Nh)],Kb);function qb(e,t){if(e!==void 0)try{return py.toColor(e)}catch{}return t}var Jb=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Yb=class{constructor(){this._services=new Jb,this._services.set(jh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=wh(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Xb={trace:0,debug:1,info:2,warn:3,error:4,off:5},Zb=`xterm.js: `,Qb=class extends gg{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),$b=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Xb[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:Zb)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Qb=$m([eh(0,Nh)],Qb);var $b,ex=class extends gg{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},tx=3,nx=Object.freeze(new vh),rx=0,ix=2,ax=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*tx);let r=t||bh.fromCharData([0,gh,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*tx+0],n=t&2097151;return[this._data[e*tx+1],t&2097152?this._combined[e]:n?fh(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*tx+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*tx+0]=e|2097152|t[2]<<22):this._data[e*tx+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*tx+0]>>22}hasWidth(e){return this._data[e*tx+0]&12582912}getFg(e){return this._data[e*tx+1]}getBg(e){return this._data[e*tx+2]}hasContent(e){return this._data[e*tx+0]&4194303}getCodePoint(e){let t=this._data[e*tx+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*tx+0]&2097152}getString(e){let t=this._data[e*tx+0];return t&2097152?this._combined[e]:t&2097151?fh(t&2097151):``}isProtected(e){return this._data[e*tx+2]&536870912}loadCell(e,t){return rx=e*tx,t.content=this._data[rx+0],t.fg=this._data[rx+1],t.bg=this._data[rx+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*tx+0]=t.content,this._data[e*tx+1]=t.fg,this._data[e*tx+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*tx+0]=t|n<<22,this._data[e*tx+1]=r.fg,this._data[e*tx+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*tx+0];r&2097152?this._combined[e]+=fh(t):r&2097151?(this._combined[e]=fh(r&2097151)+fh(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*tx+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new bh;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new bh;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*ix<this._data.buffer.byteLength;let n=e*tx;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*ix<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ix<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*tx+0]&4194303)return e+(this._data[e*tx+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*tx+0]&4194303||this._data[e*tx+2]&50331648)return e+(this._data[e*tx+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<tx;e++)this._data[(n+i)*tx+e]=a[(t+i)*tx+e];a[(t+i)*tx+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<tx;e++)this._data[(n+i)*tx+e]=a[(t+i)*tx+e];a[(t+i)*tx+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*tx+0],n=e&2097151,a=e&2097152?this._combined[t]:n?fh(n):_h;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function ox(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=ux(u,d,t),p=1,m=0;for(;p<u.length;){let e=ux(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function sx(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function cx(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function lx(e,t,n){let r=[],i=e.map((n,r)=>ux(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=ux(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function ux(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var dx=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),dg(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};dx._nextId=1;var fx=dx,px={},mx=px.B;px[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},px.A={"#":`£`},px.B=void 0,px[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},px.C=px[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},px.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},px.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},px.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},px.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},px.E=px[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},px.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},px.H=px[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},px[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var hx=4294967295,gx=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=nx.clone(),this.savedCharset=mx,this.markers=[],this._nullCell=bh.fromCharData([0,gh,1,0]),this._whitespaceCell=bh.fromCharData([0,_h,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fb,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ex(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new yh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new yh),this._whitespaceCell}getBlankLine(e,t){return new ax(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>hx?hx:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=nx);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ex(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(nx),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ax(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new ax(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=ox(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(nx),n);if(r.length>0){let n=sx(this.lines,r);cx(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(nx),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ax(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(nx),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=lx(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(nx,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=ux(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new fx(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},_x=class extends gg{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new gx(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new gx(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},vx=2,yx=1,bx=class extends gg{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,vx),this.rows=Math.max(e.rawOptions.rows||0,yx),this.buffers=this._register(new _x(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};bx=$m([eh(0,Nh)],bx);var xx={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:rb,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Sx=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Cx=class extends gg{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...xx};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(pg(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in xx))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in xx))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=xx[e],!wx(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=xx[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Sx.includes(t)?t:xx[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function wx(e){return e===`block`||e===`underline`||e===`bar`}function Tx(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Tx(e[r],t-1);return n}var Ex=Object.freeze({insertMode:!1}),Dx=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ox=class extends gg{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Tx(Ex),this.decPrivateModes=Tx(Dx)}reset(){this.modes=Tx(Ex),this.decPrivateModes=Tx(Dx)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Ox=$m([eh(0,Dh),eh(1,Mh),eh(2,Nh)],Ox);var kx={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function Ax(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var jx=String.fromCharCode,Mx={DEFAULT:e=>{let t=[Ax(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${jx(t[0])}${jx(t[1])}${jx(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Ax(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Ax(e,!0)};${e.x};${e.y}${t}`}},Nx=class extends gg{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(kx))this.addProtocol(e,kx[e]);for(let e of Object.keys(Mx))this.addEncoding(e,Mx[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};Nx=$m([eh(0,Dh),eh(1,kh),eh(2,Nh)],Nx);var Px=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Fx=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ix;function Lx(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var Rx=class{constructor(){if(this.version=`6`,!Ix){Ix=new Uint8Array(65536),Ix.fill(1),Ix[0]=0,Ix.fill(0,1,32),Ix.fill(0,127,160),Ix.fill(2,4352,4448),Ix[9001]=2,Ix[9002]=2,Ix.fill(2,11904,42192),Ix[12351]=1,Ix.fill(2,44032,55204),Ix.fill(2,63744,64256),Ix.fill(2,65040,65050),Ix.fill(2,65072,65136),Ix.fill(2,65280,65377),Ix.fill(2,65504,65511);for(let e=0;e<Px.length;++e)Ix.fill(0,Px[e][0],Px[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ix[e]:Lx(e,Fx)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=zx.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return zx.createPropertyValue(0,n,r)}},zx=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new Rx;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Bx=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Vx(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Hx=2147483647,Ux=256,Wx=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>Ux)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Hx?Hx:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>Hx?Hx:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,Hx):e}},Gx=[],Kx=class{constructor(){this._state=0,this._active=Gx,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gx}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Gx,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Gx,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,ph(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=Gx,this._id=-1,this._state=0}}},qx=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ph(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},Jx=[],Yx=class{constructor(){this._handlers=Object.create(null),this._active=Jx,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Jx}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Jx,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Jx,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,ph(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Jx,this._ident=0}},Xx=new Wx;Xx.addParam(0);var Zx=class{constructor(e){this._handler=e,this._data=``,this._params=Xx,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Xx,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ph(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=Xx,this._data=``,this._hitLimit=!1,e));return this._params=Xx,this._data=``,this._hitLimit=!1,t}},Qx=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},$x=160,eS=function(){let e=new Qx(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add($x,0,2,0),e.add($x,8,5,8),e.add($x,6,0,6),e.add($x,11,0,11),e.add($x,13,13,13),e}(),tS=class extends gg{constructor(e=eS){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wx,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(pg(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Kx),this._dcsParser=this._register(new Yx),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:$x)],i>>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r<$x||++i>=t||(r=e[i])<32||r>126&&r<$x||++i>=t||(r=e[i])<32||r>126&&r<$x||++i>=t||(r=e[i])<32||r>126&&r<$x){this._printHandler(e,n,i),n=i-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<$x){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<$x){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},nS=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,rS=/^[\da-f]+$/;function iS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=nS.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),rS.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function aS(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function oS(e,t=16){let[n,r,i]=e;return`rgb:${aS(n,t)}/${aS(r,t)}/${aS(i,t)}`}var sS={"(":0,")":1,"*":2,"+":3,"-":1,".":2},cS=131072,lS=10;function uS(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var dS=5e3,fS=0,pS=class extends gg{constructor(e,t,n,r,i,a,o,s,c=new tS){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new mh,this._utf8Decoder=new hh,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=nx.clone(),this._eraseAttrDataInternal=nx.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new mS(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ry.IND,()=>this.index()),this._parser.setExecuteHandler(ry.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ry.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qx(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new qx(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new qx(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new qx(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new qx(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new qx(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new qx(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new qx(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new qx(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new qx(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new qx(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new qx(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in px)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new Zx((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),dS))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${dS} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>cS&&(a=this._parseStack.position+cS)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<cS&&(this._parseBuffer=new Uint32Array(Math.min(e.length,cS))),o||this._dirtyRowTracker.clearRange(),e.length>cS)for(let t=a;t<e.length;t+=cS){let a=t+cS<e.length?t+cS:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=zx.extractWidth(t);let n=zx.extractShouldJoin(t),m=n?zx.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(fh(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof ax&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!uS(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Zx(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qx(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(nx));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=zx.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,mx),this._charsetService.setgCharset(1,mx),this._charsetService.setgCharset(2,mx),this._charsetService.setgCharset(3,mx);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=vh.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=nx.fg,e.bg=nx.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=nx.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=nx.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=nx.fg&16777215,r.bg&=-67108864,r.bg|=nx.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=nx.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!uS(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>lS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>lS&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(hS(n)){if(r===`?`)t.push({type:0,index:n});else{let e=iS(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=iS(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);hS(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,mx),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(sS[e[0]],px[e[1]]||mx),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=nx.clone(),this._eraseAttrDataInternal=nx.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new bh;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},mS=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(fS=e,e=t,t=fS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};mS=$m([eh(0,Dh)],mS);function hS(e){return 0<=e&&e<256}var gS=5e7,_S=12,vS=50,yS=class extends gg{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>gS)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=_S?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=_S)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vS&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},bS=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};bS=$m([eh(0,Dh)],bS);var xS=!1,SS=class extends gg{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new _g),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new Yb,this.optionsService=this._register(new Cx(e)),this._instantiationService.setService(Nh,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(bx)),this._instantiationService.setService(Dh,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Qb)),this._instantiationService.setService(Mh,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ox)),this._instantiationService.setService(kh,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Nx)),this._instantiationService.setService(Oh,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(zx)),this._instantiationService.setService(Fh,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Bx),this._instantiationService.setService(Ah,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(bS),this._instantiationService.setService(Ph,this._oscLinkService),this._inputHandler=this._register(new pS(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(wg.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(wg.forward(this._bufferService.onResize,this._onResize)),this._register(wg.forward(this.coreService.onData,this._onData)),this._register(wg.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new yS((e,t)=>this._inputHandler.parse(e,t))),this._register(wg.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!xS&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),xS=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,vx),t=Math.max(t,yx),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Vx.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Vx(this._bufferService),!1))),this._windowsWrappingHeuristics.value=pg(()=>{for(let t of e)t.dispose()})}}},CS={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function wS(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=CS[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var TS=0,ES=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fb,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fb,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(TS=this._search(t),TS===-1)||this._getKey(this._array[TS])!==t)return!1;do if(this._array[TS]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(TS),!0;while(++TS<this._array.length&&this._getKey(this._array[TS])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(TS=this._search(e),!(TS<0||TS>=this._array.length)&&this._getKey(this._array[TS])===e))do yield this._array[TS];while(++TS<this._array.length&&this._getKey(this._array[TS])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(TS=this._search(e),!(TS<0||TS>=this._array.length)&&this._getKey(this._array[TS])===e))do t(this._array[TS]);while(++TS<this._array.length&&this._getKey(this._array[TS])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},DS=0,OS=0,kS=class extends gg{constructor(){super(),this._decorations=new ES(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(pg(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new AS(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{DS=t.options.x??0,OS=DS+(t.options.width??1),e>=DS&&e<OS&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},AS=class extends hg{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?py.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?py.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},jS=1e3,MS=class{constructor(e,t=jS){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},NS=20,PS=class extends gg{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new MS(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
328
|
+
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ov(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(pg(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<NS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
329
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===NS+1&&(this._liveRegion.textContent+=ih.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};PS=$m([eh(1,jh),eh(2,Bh),eh(3,Hh)],PS);var FS=class extends gg{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(pg(()=>{dg(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ov(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ov(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(ov(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(ov(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&IS(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,dg(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};FS=$m([eh(1,Vh),eh(2,Hh),eh(3,Dh),eh(4,Kh)],FS);function IS(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var LS=class extends SS{constructor(e={}){super(e),this._linkifier=this._register(new _g),this.browser=Yy,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new _g),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(kS),this._instantiationService.setService(Ih,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Wy),this._instantiationService.setService(Kh,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Lh)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(wg.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(wg.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(wg.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(wg.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(pg(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=fy.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${oS(r)}${iy.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=dy.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=dy.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(PS,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(ov(this.element,`copy`,e=>{this.hasSelection()&&sh(e,this._selectionService)}));let e=e=>ch(e,this.textarea,this.coreService,this.optionsService);this._register(ov(this.textarea,`paste`,e)),this._register(ov(this.element,`paste`,e)),$y?this._register(ov(this.element,`mousedown`,e=>{e.button===2&&dh(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ov(this.element,`contextmenu`,e=>{dh(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sb&&this._register(ov(this.element,`auxclick`,e=>{e.button===1&&uh(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ov(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(ov(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(ov(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(ov(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(ov(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(ov(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(ov(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(ov(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,nh.get()),cb||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Hy,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Bh,this._coreBrowserService),this._register(ov(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(ov(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ry,this._document,this._helperContainer),this._instantiationService.setService(zh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Kb),this._instantiationService.setService(Gh,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(yy),this._instantiationService.setService(Wh,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(mb,this.rows,this.screenElement)),this._instantiationService.setService(Hh,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(ay,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(qy),this._instantiationService.setService(Vh,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(FS,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xv,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ib,this.element,this.screenElement,r)),this._instantiationService.setService(Uh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(wg.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Zv,this.screenElement)),this._register(ov(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(PS,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ny,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ny,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ly,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ov(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(ov(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){lh(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=wS(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(RS(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(nx));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function RS(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var zS=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},BS=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new bh)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},VS=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new BS(t)}getNullCell(){return new bh}},HS=class extends gg{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new VS(this._core.buffers.normal,`normal`),this._alternate=new VS(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},US=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},WS=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},GS=[`cols`,`rows`],KS=0,qS=class extends gg{constructor(e){super(),this._core=this._register(new LS(e)),this._addonManager=this._register(new zS),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(GS.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new US(this._core),this._parser}get unicode(){return this._checkProposedApi(),new WS(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new HS(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
330
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return nh.get()},set promptLabel(e){nh.set(e)},get tooMuchOutput(){return ih.get()},set tooMuchOutput(e){ih.set(e)}}}_verifyIntegers(...e){for(KS of e)if(KS===1/0||isNaN(KS)||KS%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(KS of e)if(KS&&(KS===1/0||isNaN(KS)||KS%1!=0||KS<0))throw Error(`This API only accepts positive integers`)}},JS=2,YS=1,XS=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(JS,Math.floor(u/e.css.cell.width)),rows:Math.max(YS,Math.floor(l/e.css.cell.height))}}},ZS=`super-pi.terminal-owner.v1`,QS=`super-pi.terminal-selection.v1.`,$S=20,eC=5,tC=240,nC=120,rC={checking:`正在连接`,unavailable:`不可用`,starting:`启动中`,running:`运行中`,exited:`已结束`,empty:`没有打开的终端`},iC;function aC(){if(iC)return iC;try{let e=window.localStorage.getItem(ZS);if(e&&/^[0-9a-f]{32}$/.test(e))return iC=e}catch{}iC=Array.from(window.crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);try{window.localStorage.setItem(ZS,iC)}catch{}return iC}function oC(e){try{return window.sessionStorage.getItem(e)??void 0}catch{return}}function sC({workspaceId:e,workspaceLabel:t,cwd:n=``,connected:r,sendCommand:i,registerSink:a,conversationId:o,terminalShell:s}){let c=QS+JSON.stringify([e,o]),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(()=>oC(c)??``),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),S=(0,u.useRef)(new Map),C=(0,u.useRef)(new Map),w=(0,u.useRef)(new Map),T=(0,u.useRef)(new Map),E=(0,u.useRef)(!1),D=(0,u.useRef)(f);D.current=f;let O=(0,u.useRef)(!1),k=(0,u.useRef)(void 0),A=(0,u.useCallback)(e=>{let t=C.current.get(e);if(!t||!t.host.clientWidth||!t.host.clientHeight||T.current.has(e))return;let{terminal:n,fitAddon:r}=t,a=r.proposeDimensions();if(!a||!Number.isFinite(a.cols)||!Number.isFinite(a.rows))return;let o=Math.max($S,Math.min(tC,a.cols)),s=Math.max(eC,Math.min(nC,a.rows));(n.cols!==o||n.rows!==s)&&n.resize(o,s);let c=S.current.get(e);E.current&&c&&c.exitCode===void 0&&(c.cols!==o||c.rows!==s)&&i({type:`terminal.resize`,sessionId:e,cols:o,rows:s})},[i]),j=(0,u.useCallback)((e,t)=>{let n=e.sessionId;if(e.type===`terminal.output`){t.write(e.data);return}let r=S.current.get(n),i=T.current.get(n);r&&t.resize(r.cols,r.rows),t.write(`\x1Bc\x1B[3J`+e.data,()=>{T.current.get(n)===i&&(T.current.delete(n),D.current===n&&A(n))})},[A]),ee=(0,u.useCallback)((e,t)=>{if(!t||C.current.has(e))return;let n=getComputedStyle(t),r=(e,t)=>n.getPropertyValue(e).trim()||t,a=S.current.get(e),o=new qS({cols:a?.cols,rows:a?.rows,cursorBlink:!0,convertEol:!1,scrollback:5e3,fontFamily:`Consolas, 'Cascadia Mono', 'DejaVu Sans Mono', monospace`,fontSize:12,lineHeight:1.35,theme:{background:`#00000000`,foreground:r(`--term-fg`,`#dbe4f0`),cursor:r(`--term-fg`,`#dbe4f0`),selectionBackground:r(`--term-selection`,`#3a4f6b`)},allowProposedApi:!0}),s=new XS;o.loadAddon(s),o.open(t),o.onData(t=>{E.current&&!T.current.has(e)&&S.current.get(e)?.exitCode===void 0&&i({type:`terminal.input`,sessionId:e,data:t})}),C.current.set(e,{terminal:o,fitAddon:s,host:t});for(let t of w.current.get(e)??[])j(t,o);w.current.delete(e),requestAnimationFrame(()=>A(e))},[A,i,j]),M=(0,u.useCallback)(t=>{if(t.type===`terminal.sessions`){if(t.workspaceId!==e||t.conversationId!==o)return;let n=new Map(t.sessions.map(e=>[e.id,e]));for(let[e,r]of C.current)n.has(e)?!t.replay&&S.current.get(e)?.exitCode!==void 0&&n.get(e)?.exitCode===void 0&&r.terminal.write(`\x1Bc\x1B[3J`):(r.terminal.dispose(),C.current.delete(e));for(let e of w.current.keys())(!n.has(e)||t.replay)&&w.current.delete(e);if(t.replay){T.current.clear();for(let e of n.keys())T.current.set(e,Symbol())}!t.replay&&O.current&&t.activate&&n.has(t.activate)&&(k.current=t.activate,O.current=!1),S.current=n,E.current=!0,d(t.sessions),p(e=>t.activate??(n.has(e)?e:t.sessions[0]?.id??``)),_(void 0),h(!0)}else if(t.type===`terminal.output`||t.type===`terminal.replay`){if(!S.current.has(t.sessionId))return;let e=C.current.get(t.sessionId)?.terminal;if(e)j(t,e);else{let e=w.current.get(t.sessionId)??[];e.push(t),w.current.set(t.sessionId,e)}}else if(t.type===`terminal.size`){let e=S.current.get(t.sessionId);e&&(Object.assign(e,{cols:t.cols,rows:t.rows}),C.current.get(e.id)?.terminal.resize(e.cols,e.rows))}else if(t.type===`terminal.exit`){let e=S.current.get(t.sessionId);if(!e)return;let n={...e,exitCode:t.exitCode,reason:t.reason};S.current.set(n.id,n),d(e=>e.map(e=>e.id===n.id?n:e))}else(t.type===`terminal.error`||t.type===`terminal.status`&&!t.enabled)&&(O.current=!1,_(void 0),y(t.type===`terminal.error`?t.message:t.reason||`终端未启用`))},[o,e,j]);(0,u.useEffect)(()=>(a(M),()=>a(void 0)),[M,a]);let te=(0,u.useCallback)(()=>{E.current=!1,h(!1),_(void 0),y(``),r&&e&&i({type:`terminal.sync`,ownerId:aC(),workspaceId:e,conversationId:o,cwd:n,initialize:oC(c)===void 0})},[r,e,o,n,c,i]);(0,u.useEffect)(()=>(te(),()=>{r&&i({type:`terminal.detach`})}),[r,i,te]),(0,u.useEffect)(()=>()=>{for(let e of C.current.values())e.terminal.dispose();C.current.clear()},[]),(0,u.useEffect)(()=>{if(m)try{window.sessionStorage.setItem(c,f)}catch{}},[f,m,c]),(0,u.useEffect)(()=>{let e=!1;return Ae(`/api/terminal-shell`).then(e=>e.json()).then(t=>{let n=t.shell;!e&&n&&x(n.file+(n.args.length?` `+n.args.join(` `):``)+`(`+(t.source??``)+`)`)}).catch(()=>void 0),()=>{e=!0}},[s?.file,s?.args.join(`\0`)]),(0,u.useLayoutEffect)(()=>{let e=C.current.get(f);if(!e)return;let t=new ResizeObserver(()=>A(f));if(t.observe(e.host),A(f),k.current===f){let e=f;requestAnimationFrame(()=>{k.current===e&&(C.current.get(e)?.terminal.focus(),k.current=void 0)})}return()=>t.disconnect()},[f,A,l]);let N=e=>!r||!m||g?!1:i(e)?(y(``),_(e.type===`terminal.open`?`open`:`close`),!0):!1,ne=e=>{let t=C.current.get(f)?.terminal;O.current=!0,N({type:`terminal.open`,sessionId:e,cols:t?.cols,rows:t?.rows})||(O.current=!1)},re=l.find(e=>e.id===f),ie=r&&m&&!g,ae=e?r?m?g===`open`?`starting`:re?re.exitCode===void 0?`running`:`exited`:`empty`:v?`unavailable`:`checking`:`checking`:`unavailable`,oe=v||re?.reason;return(0,F.jsxs)(`div`,{className:`terminal-panel`,"data-terminal-panel":`1`,"data-terminal-phase":ae,children:[(0,F.jsxs)(`div`,{className:`terminal-strip`,role:`tablist`,"aria-label":`终端会话`,"data-terminal-strip":`1`,children:[l.map(e=>(0,F.jsxs)(`div`,{className:`terminal-tab${e.id===f?` is-active`:``}`,children:[(0,F.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f,className:`terminal-tab-btn`,"data-terminal-slot":e.id,onClick:()=>p(e.id),title:rC[e.exitCode===void 0?`running`:`exited`],children:[(0,F.jsx)(`span`,{className:`terminal-tab-dot terminal-tab-dot-${e.exitCode===void 0?`running`:`exited`}`,"aria-hidden":`true`}),e.title]}),(0,F.jsx)(`button`,{type:`button`,className:`terminal-tab-close`,disabled:!ie,"aria-label":`关闭终端 ${e.title}`,"data-terminal-slot-close":e.id,onClick:()=>N({type:`terminal.close`,sessionId:e.id}),children:`×`})]},e.id)),l.length<5&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-strip-add`,disabled:!ie,"data-terminal-add":`1`,onClick:()=>ne(),title:`新建终端`,"aria-label":`新建终端`,children:`+`})]}),(0,F.jsxs)(`div`,{className:`terminal-toolbar`,children:[(0,F.jsxs)(`span`,{className:`terminal-status terminal-status-${ae}`,"data-terminal-status":ae,children:[(0,F.jsx)(`span`,{className:`terminal-status-dot`,"aria-hidden":`true`}),rC[ae]]}),(0,F.jsxs)(`span`,{className:`terminal-toolbar-right`,children:[b&&(0,F.jsx)(`span`,{className:`terminal-cwd`,"data-terminal-shell-hint":`1`,title:b,children:b}),t&&(0,F.jsx)(`span`,{className:`terminal-cwd`,"data-terminal-hint":`1`,title:t,children:t}),re?.exitCode!==void 0&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-restart-btn`,"data-terminal-restart":`1`,disabled:!ie,onClick:()=>ne(re.id),children:`重新打开`}),!m&&v&&r&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-restart-btn`,onClick:te,children:`重试连接`})]})]}),oe&&(0,F.jsx)(`p`,{className:`tool-error`,"data-terminal-error":`1`,role:`alert`,title:lt(oe),children:ct(oe,`终端出错了。`)}),re?.exitCode!==void 0&&re.exitCode!==0&&(0,F.jsxs)(`p`,{className:`tool-error`,"data-terminal-exit":`1`,children:[`会话已结束,退出码 `,re.exitCode,`。`]}),(0,F.jsxs)(`div`,{className:`terminal-surface`,"data-terminal-surface":`1`,children:[l.map(e=>(0,F.jsx)(`div`,{ref:t=>ee(e.id,t),className:`terminal-xterm-host`,"data-terminal-xterm":e.id,style:{display:e.id===f?`block`:`none`}},e.id)),ae===`empty`&&(0,F.jsx)(`div`,{className:`terminal-surface-empty`,"data-terminal-empty":`1`,children:(0,F.jsx)(`p`,{className:`rail-empty`,children:rC.empty})}),!re&&ae===`checking`&&(0,F.jsx)(`p`,{className:`rail-empty terminal-surface-message`,"data-terminal-phase":`checking`,children:`正在连接终端…`}),!e&&(0,F.jsx)(`p`,{className:`rail-empty terminal-surface-message`,children:`选择一个工作区后即可打开终端。`})]})]})}function cC({id:e,title:t,icon:n,count:r,actions:i,children:a}){let o=(0,u.useId)();return(0,F.jsxs)(`section`,{className:`rail-card`,"data-rail-section":e,"aria-labelledby":o,children:[(0,F.jsxs)(`div`,{className:`rail-section-head`,children:[(0,F.jsxs)(`h2`,{className:`rail-section-title`,id:o,children:[(0,F.jsx)(lC,{kind:n}),t]}),r&&(0,F.jsx)(`span`,{className:`rail-section-count`,children:r}),i]}),(0,F.jsx)(`div`,{className:`rail-card-body`,children:a})]})}function lC({kind:e}){return(0,F.jsx)(`svg`,{className:`rail-section-icon`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e===`tasks`?(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`path`,{d:`m3 6 2 2 3-4M11 6h10M3 13h5m3 0h10M3 20h5m3 0h10`})}):e===`clock`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,F.jsx)(`path`,{d:`M12 7v5l3 2`})]}):(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`path`,{d:`M3 12h4l3-7 4 14 3-7h4`})})})}var uC=[{day:1,label:`一`},{day:2,label:`二`},{day:3,label:`三`},{day:4,label:`四`},{day:5,label:`五`},{day:6,label:`六`},{day:0,label:`日`}];function dC(e){return e.kind===`interval`?`每隔 ${e.everyMinutes} 分钟`:e.kind===`daily`?`每天 ${e.time}`:e.kind===`weekly`?`每周${e.weekdays.map(e=>uC.find(t=>t.day===e)?.label??`?`).join(`、`)} ${e.time}`:`仅一次:${fC(e.at)}`}function fC(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function pC(){return typeof Intl<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0}function mC(e,t){let n=new Date(e);if(!t){let e=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())} ${e(n.getHours())}:${e(n.getMinutes())}`}let r=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`year`)}-${i(`month`)}-${i(`day`)} ${i(`hour`)}:${i(`minute`)}`}function hC(e,t){let n=new Date(e);if(!t){let e=e=>String(e).padStart(2,`0`);return`${e(n.getHours())}:${e(n.getMinutes())}`}let r=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`hour`)}:${i(`minute`)}`}function gC(e,t){if(!e)return``;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(t).find(e=>e.type===`timeZoneName`)?.value??e}catch{return e}}function _C(e,t,n){let r=hC(e,n),i=vC(e,t,n);return i===0?`今天 ${r}`:i===1?`明天 ${r}`:mC(e,n)}function vC(e,t,n){let r=e=>{let[t]=mC(e,n).split(` `),[r,i,a]=t.split(`-`).map(Number);return Date.UTC(r,i-1,a)},i=Math.round((r(e)-r(t))/864e5);return Number.isFinite(i)?i:0}function yC(e,t,n){if(!e||!t||e===t)return``;let r=gC(e,n),i=gC(t,n);return hC(n,e)===hC(n,t)?`服务器在 ${r} 时区,你的时区也是 ${i},下面的时间按你的时区显示`:`服务器在 ${r} 时区,下面的时间按你的时区(${i})显示`}function bC(e,t,n){return e.enabled?e.nextRunAt===void 0?{glyph:`✓`,word:`已结束`,detail:``}:{glyph:`●`,word:`启用中`,detail:`下次 ${_C(e.nextRunAt,t,n)}`}:e.schedule.kind===`once`&&e.lastRunAt!==void 0?{glyph:`✓`,word:`已结束`,detail:e.lastRunAt?`上次 ${mC(e.lastRunAt,n)}`:``}:{glyph:`○`,word:`已停用`,detail:``}}function xC(e,t){if(e.lastRunAt===void 0)return``;let n=mC(e.lastRunAt,t);return e.lastRunStatus===`failed`?`上次 ${n} · 失败${e.lastRunMessage?`:${e.lastRunMessage}`:``}`:`上次 ${n} · 成功`}function SC({tasks:e,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,serverTimeZone:o}){let[s,c]=(0,u.useState)(()=>Date.now()),[l,d]=(0,u.useState)();(0,u.useEffect)(()=>{let e=window.setInterval(()=>c(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let f=pC(),p=yC(o,f,s),m=e=>{i({type:`scheduledTask.toggle`,id:e.id,enabled:!e.enabled})},h=e=>{i({type:`scheduledTask.trigger`,id:e.id}),a(`已触发「${e.name}」,结果会出现在它自己的会话里。`,`info`)},g=e=>{i({type:`scheduledTask.delete`,id:e.id}),a(`已删除定时任务「${e.name}」,它的会话和结果保留着。`,`info`)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(cC,{id:`scheduled`,title:`定时任务`,icon:`clock`,count:(0,F.jsx)(`span`,{"data-sched-count":`1`,children:e.length?`${e.length} 个`:`0 个`}),actions:(0,F.jsx)(`button`,{type:`button`,className:`scheduled-add`,"data-sched-add":`1`,title:`新建定时任务`,onClick:()=>d(`new`),children:`+ 新建`}),children:[p&&(0,F.jsx)(`p`,{className:`scheduled-zone-note`,"data-sched-zone-note":`1`,children:p}),e.length>0?(0,F.jsx)(`ul`,{className:`scheduled-list`,"data-sched-list":`1`,children:e.map(e=>{let t=bC(e,s,f),n=xC(e,f);return(0,F.jsxs)(`li`,{className:`scheduled-item`,"data-scheduled-task":e.id,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-toggle`,"data-sched-toggle":`1`,title:e.enabled?`点击停用`:`点击启用`,"aria-label":e.enabled?`停用 ${e.name}`:`启用 ${e.name}`,onClick:()=>m(e),children:t.glyph}),(0,F.jsxs)(`div`,{className:`scheduled-main`,children:[(0,F.jsxs)(`div`,{className:`scheduled-name-row`,children:[(0,F.jsx)(`span`,{className:`scheduled-name`,children:e.name}),(0,F.jsx)(`span`,{className:`scheduled-status-word`,"data-sched-word":`1`,children:t.word}),e.createdBy===`agent`&&(0,F.jsx)(`span`,{className:`scheduled-by`,title:`这个定时任务是 agent 创建的,你可以像编辑自己建的一样编辑它`,children:`agent`})]}),(0,F.jsxs)(`div`,{className:`scheduled-meta`,"data-sched-meta":`1`,children:[dC(e.schedule),t.detail?` · ${t.detail}`:``]}),n&&(0,F.jsx)(`div`,{className:`scheduled-last`,"data-sched-last":`1`,children:n})]}),(0,F.jsxs)(`div`,{className:`scheduled-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action`,"data-sched-trigger":`1`,title:`立即执行一次(不改变周期)`,"aria-label":`立即执行 ${e.name}`,onClick:()=>h(e),children:`⚡`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action`,"data-sched-edit":`1`,title:`编辑`,"aria-label":`编辑 ${e.name}`,onClick:()=>d(e),children:`✎`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action scheduled-action-danger`,"data-sched-delete":`1`,title:`删除(会话与结果保留)`,"aria-label":`删除 ${e.name}`,onClick:()=>g(e),children:`✕`})]})]},e.id)})}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-sched-empty":`1`,children:`还没有定时任务。可以新建周期任务,或让 AI 安排。`})]}),l!==void 0&&(0,F.jsx)(EC,{task:l===`new`?void 0:l,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,onClose:()=>d(void 0)},l===`new`?`new`:l.id)]})}function CC(e){let t=e?.schedule;return{name:e?.name??``,prompt:e?.prompt??``,kind:t?.kind??`daily`,everyMinutes:t?.kind===`interval`?String(t.everyMinutes):`30`,time:t&&(t.kind===`daily`||t.kind===`weekly`)?t.time:`09:00`,weekdays:t?.kind===`weekly`?[...t.weekdays]:[1],onceAt:t?.kind===`once`?wC(t.at):``,modelKey:e?.model?`${e.model.provider}/${e.model.modelId}`:``,agentId:e?.agentId??``}}function wC(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function TC(e){if(e.kind===`interval`){let t=Number(e.everyMinutes);return!Number.isInteger(t)||t<1||t>10080?{ok:!1,reason:`间隔分钟数要是一个 1 到 10080 之间的整数。`}:{ok:!0,schedule:{kind:`interval`,everyMinutes:t}}}if(e.kind===`daily`||e.kind===`weekly`){let t=/^(\d{1,2}):(\d{2})$/.exec(e.time.trim()),n=t?Number(t[1]):NaN,r=t?Number(t[2]):NaN;if(!t||n>23||r>59)return{ok:!1,reason:`触发时刻要写成 HH:MM,比如 09:00。`};let i=`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`;return e.kind===`daily`?{ok:!0,schedule:{kind:`daily`,time:i}}:e.weekdays.length?{ok:!0,schedule:{kind:`weekly`,weekdays:[...e.weekdays].sort((e,t)=>e-t),time:i}}:{ok:!1,reason:`每周任务至少要选一天。`}}if(!e.onceAt)return{ok:!1,reason:`选一下这一次的运行时刻。`};let t=new Date(e.onceAt).getTime();return Number.isNaN(t)?{ok:!1,reason:`这一次的运行时刻不是有效时间。`}:{ok:!0,schedule:{kind:`once`,at:t}}}function EC({task:e,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,onClose:o}){let[s,c]=(0,u.useState)(()=>CC(e)),[l,d]=(0,u.useState)();(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let f=e=>{c(t=>({...t,...e})),d(void 0)};return(0,We.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay`,"data-sched-dialog-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&o()},children:(0,F.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`scheduled-dialog-title`,"data-sched-dialog":`1`,children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title`,id:`scheduled-dialog-title`,children:e?`编辑定时任务`:`新建定时任务`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-sched-dialog-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭定时任务编辑`,onClick:o,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`tool-dialog-body scheduled-form`,children:[(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`名称`}),(0,F.jsx)(`input`,{className:`scheduled-input`,"data-sched-field":`name`,value:s.name,placeholder:`留空则取提示词首句`,onChange:e=>f({name:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`提示词`}),(0,F.jsx)(`textarea`,{className:`scheduled-textarea`,"data-sched-field":`prompt`,rows:5,value:s.prompt,placeholder:`到点时这段话会作为用户消息发给 agent,所以它要是一条完整、自包含的指令`,onChange:e=>f({prompt:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`周期`}),(0,F.jsx)(`div`,{className:`scheduled-kind-row`,role:`radiogroup`,"aria-label":`周期类型`,children:[[`interval`,`每隔 N 分钟`],[`daily`,`每天`],[`weekly`,`每周`],[`once`,`仅一次`]].map(([e,t])=>(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":s.kind===e,className:`scheduled-kind${s.kind===e?` scheduled-kind-active`:``}`,"data-sched-kind":e,onClick:()=>f({kind:e}),children:t},e))})]}),s.kind===`interval`&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`间隔`}),(0,F.jsx)(`input`,{className:`scheduled-input scheduled-input-narrow`,"data-sched-field":`everyMinutes`,inputMode:`numeric`,value:s.everyMinutes,onChange:e=>f({everyMinutes:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`分钟(1 – 10080)`})]}),(s.kind===`daily`||s.kind===`weekly`)&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`时刻`}),(0,F.jsx)(`input`,{className:`scheduled-input scheduled-input-narrow`,"data-sched-field":`time`,inputMode:`numeric`,placeholder:`09:00`,value:s.time,onChange:e=>f({time:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`服务器本地时间,每天/每周的这一天到点触发`})]}),s.kind===`weekly`&&(0,F.jsxs)(`div`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`星期`}),(0,F.jsx)(`div`,{className:`scheduled-weekdays`,children:uC.map(({day:e,label:t})=>{let n=s.weekdays.includes(e);return(0,F.jsx)(`button`,{type:`button`,"aria-pressed":n,className:`scheduled-weekday${n?` scheduled-weekday-on`:``}`,"data-sched-weekday":e,onClick:()=>f({weekdays:n?s.weekdays.filter(t=>t!==e):[...s.weekdays,e]}),children:t},e)})})]}),s.kind===`once`&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`时刻`}),(0,F.jsx)(`input`,{className:`scheduled-input`,type:`datetime-local`,"data-sched-field":`onceAt`,value:s.onceAt,onChange:e=>f({onceAt:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`这一次运行之后就结束`})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`模型`}),(0,F.jsxs)(`select`,{className:`scheduled-input`,"data-sched-field":`model`,value:s.modelKey,onChange:e=>f({modelKey:e.target.value}),children:[(0,F.jsx)(`option`,{value:``,children:`跟随工作区默认`}),(n?.models??[]).map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.modelId}`,children:[e.label,`(`,e.detail,`)`]},`${e.provider}/${e.modelId}`))]})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`Agent`}),(0,F.jsxs)(`select`,{className:`scheduled-input`,"data-sched-field":`agent`,value:s.agentId,onChange:e=>f({agentId:e.target.value}),children:[(0,F.jsx)(`option`,{value:``,children:`跟随工作区默认`}),(r?.agents??[]).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),l&&(0,F.jsx)(`p`,{className:`scheduled-error`,"data-sched-error":`1`,role:`alert`,children:l}),(0,F.jsxs)(`div`,{className:`scheduled-actions-row`,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-cancel`,onClick:o,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-save`,"data-sched-save":`1`,onClick:()=>{let r=s.prompt.trim();if(!r){d(`定时任务需要一段提示词:到点时这段话会被当作用户消息发给 agent。`);return}if(!t){d(`先选一个工作区,再建定时任务。`);return}let c=TC(s);if(!c.ok){d(c.reason);return}let l=n?.models.find(e=>`${e.provider}/${e.modelId}`===s.modelKey),u=l?{provider:l.provider,modelId:l.modelId,label:l.label}:null,f=s.agentId||null,p=s.name.trim()||void 0;i(e?{type:`scheduledTask.update`,id:e.id,name:p,prompt:r,schedule:c.schedule,model:u,agentId:f}:{type:`scheduledTask.create`,name:p,prompt:r,schedule:c.schedule,workspaceId:t,model:u,agentId:f})?(a(e?`已保存对「${s.name.trim()||e.name}」的修改。`:`定时任务已创建,到点会自动运行。`,`info`),o()):d(`连接已断开,没能保存。等重连后再试一次。`)},children:e?`保存修改`:`创建任务`})]})]})]})}),document.body)}function DC(e){return e.status===`open`&&(e.audience===`boss`||e.audience===void 0)}function OC(e){return(e.escalations??[]).filter(DC)}function kC(e){let t=e.filter(e=>OC(e).length>0);return{projects:t.length,cases:t.reduce((e,t)=>e+OC(t).length,0)}}function AC(e,t=!1){return[`cancelled`,`failed`].includes(e.status??``)?!0:t}function jC(e,t,n){let r=AC(e,t),i=OC(e).length>0;return n===`history`?r&&!i:!r||i}function MC(e){return(e.reports??[]).filter(t=>!t.taskId&&[`progress`,`delivery`].includes(t.kind??``)&&(t.authorConversationId===e.ownerConversationId&&!!e.ownerConversationId||t.kind===`delivery`&&!t.authorConversationId))}function NC(e){return[...e.reports??[]].reverse().find(t=>t.kind===`delivery`&&!t.taskId&&(!t.authorConversationId||t.authorConversationId===e.ownerConversationId))}function PC(e){let t=OC(e),n=[...MC(e)].reverse().find(e=>e.kind===`progress`),r=NC(e),i=[`cancelled`,`failed`].includes(e.status),a=e.resources?.sessions?.find(t=>t.id===e.ownerConversationId),o=(e.resources?.activeWorkers??0)>0||[`running`,`waiting`,`awaiting_background`].includes(a?.status??``);return{label:e.status===`cancelled`?`已取消`:e.status===`failed`?`执行暂停`:t.length?`需要你决定`:o?`正在推进`:e.ownerConversationId?[`failed`,`stopped`].includes(a?.status??``)?`执行暂停`:r?`待继续`:`未交付`:`待启动`,summary:n?.progress?.trim()||n?.summary?.trim()||(i?`项目已结束,已有记录会保留。`:r?`可继续安排新任务或追加验证。`:`已交由负责人推进,进展和成果会在这里汇总。`),progress:n,delivery:r,decisions:t,ended:i,deliveryLabel:e.mode===`lightweight`?`自评交付`:`交付成果`}}var FC=/\.[A-Za-z][A-Za-z0-9]{0,9}$/,IC=new Set([`makefile`,`dockerfile`,`license`,`readme`,`changelog`]),LC=/^[A-Za-z]:/;function RC(e){let t=(e??``).trim();if(!t||/\s/.test(t)||t.includes(`://`)||t.startsWith(`/`)||t.startsWith(`\\`)||LC.test(t))return;let n=t.split(/[\\/]/);if(n.some(e=>e===``||e===`.`||e===`..`))return;let r=n[n.length-1];if(FC.test(r)||IC.has(r.toLowerCase()))return n.join(`/`)}function zC(e){return/\s/.test(e)||e.includes(`://`)||e.startsWith(`/`)||e.startsWith(`\\`)||LC.test(e)?!1:!e.split(/[\\/]/).some(e=>e===``||e===`.`||e===`..`)}function BC(e){let t=e.split(/[\\/]/);return t[t.length-1]||e}function VC(e,t){let n=RC(e);if(!n)return;let r=(t??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!r)return n;if(zC(r))return n===r||n.startsWith(`${r}/`)?n:`${r}/${n}`}function HC(e,t){let n=(e??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!n)return;let r=(t??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!r)return n;if(n!==r&&n.startsWith(`${r}/`))return n.slice(r.length+1)}function UC(e){return[`cancelled`,`failed`].includes(e.status??``)}function WC(e,t){return e.filter(e=>jC(e,e.ownerArchived===!0,t?`history`:`current`))}function GC(e){let[t,n]=(0,u.useState)(0),r=(0,u.useRef)(null),i=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=i.current;if(!e||!t)return;let a=getComputedStyle(e),o=Number.parseFloat(a.lineHeight)||Number.parseFloat(a.fontSize)*1.6||16,s=t.getBoundingClientRect().height;n(Math.max(1,Math.round(s/o)))};e();let t=typeof ResizeObserver==`function`?new ResizeObserver(()=>e()):null;return t&&(r.current&&t.observe(r.current),i.current&&t.observe(i.current)),window.addEventListener(`resize`,e),()=>{t?.disconnect(),window.removeEventListener(`resize`,e)}},[e]),{lines:t,visible:r,measured:i}}function KC({text:e,what:t}){let[n,r]=(0,u.useState)(!1),{lines:i,visible:a,measured:o}=GC(e),s=Math.max(0,i-2);return e?(0,F.jsxs)(`div`,{className:`project-prose-wrap`,children:[(0,F.jsx)(`p`,{className:`project-prose${n?` project-prose-open`:``}`,"data-prose-text":!0,ref:a,children:e}),(0,F.jsx)(`span`,{className:`project-prose-measure`,"aria-hidden":`true`,ref:o,children:e}),s>0?(0,F.jsx)(`button`,{type:`button`,className:`project-prose-expand`,"data-prose-expand":!0,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`收起${t}`:`展开完整${t}(还有 ${s} 行)`}):null]}):null}function qC({refs:e,baseCwd:t,cwd:n,onOpenFile:r}){return(0,F.jsx)(`ul`,{children:e.map((e,i)=>{let a=VC(e,t),o=a?HC(a,n):void 0;return(0,F.jsx)(`li`,{children:o&&r?(0,F.jsx)(`button`,{type:`button`,className:`project-evidence-path`,"data-team-evidence-file":o,onClick:()=>r({path:o,name:BC(o),text:null}),children:e}):e},i)})})}function JC(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));return n<60?`刚刚`:n<3600?`${Math.floor(n/60)} 分钟前`:n<86400?`${Math.floor(n/3600)} 小时前`:`${Math.floor(n/86400)} 天前`}async function YC(e){let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(typeof t?.error==`string`?t.error:`请求失败(${e.status})`);return t}async function XC(e){let t=(await e.text().catch(()=>``)).trim();if(!t)return`报告打不开(${e.status})`;try{let n=JSON.parse(t);return n&&typeof n==`object`&&typeof n.error==`string`&&n.error.trim()?n.error.trim():`报告打不开(${e.status})`}catch{return t}}function ZC(e,t){return`/api/projects/${encodeURIComponent(e)}/report?workspaceId=${encodeURIComponent(t??``)}`}function QC(e,t=60){let n=(e??``).replace(/\s+/g,` `).trim();return n?n.length<=t?n:`${n.slice(0,t-1)}…`:``}function $C(e){let t=(e.title??``).trim();if(t)return t;let n=(e.reason??``).trim();return n?n.match(/^[\s\S]*?[。!?!?]/)?.[0]?.trim()||n:`需要处理`}var ew={decision:0,delivery:1},tw=5;function nw(e,t){let n=OC(e)[0],r={projectId:e.id,projectTitle:e.title,updatedAt:Date.parse(e.updatedAt??``)||0};if(n)return{...r,reminderId:`${e.id}:decision:${OC(e).map(e=>e.id).join(`,`)}`,kind:`decision`,label:`要你决定`,detail:QC(n.title||n.reason||`需要你的决定`,UC(e)?36:60)+(UC(e)?`(项目已结束:记录后不会唤醒任何人)`:``),actionLabel:`去看看`,target:{kind:`exception`,escalationId:n.id}};let i=PC(e).delivery,a=Date.parse(i?.createdAt??``);return!i||!Number.isFinite(a)||t-a>864e5?null:{...r,updatedAt:a,reminderId:`${e.id}:delivery:${i.id}`,kind:`delivery`,label:`阶段交付`,detail:QC(i.progress||i.summary||`已提交阶段成果`),actionLabel:`查看交付`,target:{kind:`top`}}}function rw({text:e}){let[t,n]=(0,u.useState)(!1),{lines:r,visible:i,measured:a}=GC(e),o=Math.max(0,r-2);return e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`project-exception-reason-wrap`,children:[(0,F.jsx)(`p`,{className:`project-exception-reason${t?` project-exception-reason-open`:``}`,"data-project-exception-reason":!0,ref:i,children:e}),(0,F.jsx)(`span`,{className:`project-exception-reason-measure`,"aria-hidden":`true`,ref:a,children:e})]}),o>0&&(0,F.jsx)(`button`,{type:`button`,className:`project-exception-expand`,"data-project-exception-expand":!0,"aria-expanded":t,onClick:()=>n(e=>!e),children:t?`收起理由`:`展开完整理由(还有 ${o} 行)`})]}):null}function iw({item:e,project:t,busy:n,onResolve:r,onReturn:i}){let[a,o]=(0,u.useState)(``),s=UC(t);return(0,F.jsxs)(`li`,{className:`project-exception`,"data-project-exception":e.id,children:[(0,F.jsx)(`strong`,{className:`project-exception-title`,"data-project-exception-title":!0,children:$C(e)}),e.reason&&(0,F.jsx)(rw,{text:e.reason}),s&&(0,F.jsx)(`p`,{className:`project-exception-ended`,"data-project-exception-ended":!0,"data-project-exception-ended-note":!0,children:`项目已结束:你的处理意见会记进项目记录,但不会唤醒任何人。`}),(0,F.jsxs)(`label`,{className:`project-decision-label`,children:[`你的决定`,(0,F.jsx)(`textarea`,{"data-project-decision":e.id,"data-project-exception-decision":!0,value:a,onChange:e=>o(e.target.value),disabled:n})]}),(0,F.jsxs)(`div`,{className:`project-detail-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-project-decision-submit":e.id,"data-project-exception-resolve":!0,disabled:n||!a.trim(),onClick:()=>r(a.trim()),children:s?`记录处理意见`:`记录决定并答复主会话`}),(0,F.jsx)(`button`,{type:`button`,"data-project-decision-return":e.id,"data-project-exception-return":!0,disabled:n||!a.trim(),onClick:()=>i(a.trim()),children:`退回补充`})]})]})}function aw({project:e,workspaceId:t,notify:n,onOpenSession:r,onOpenFile:i,cwd:a,onChanged:o}){let s=PC(e),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),y=(0,u.useRef)(``);(0,u.useEffect)(()=>()=>{y.current&&URL.revokeObjectURL(y.current)},[]);let b=async(r,i,a={})=>{if(t&&!c){l(!0),f(``);try{await Ae(`/api/projects/${encodeURIComponent(e.id)}/${r}`,{method:i,headers:{"content-type":`application/json`},body:JSON.stringify({...a,workspaceId:t})}).then(YC),await o?.(),n?.(`已记录并交给负责人`,`info`)}catch(e){f(e instanceof Error?e.message:`操作失败`)}finally{l(!1)}}},x=async()=>{if(t&&!p){m(!0),g(``);try{let n=await Ae(ZC(e.id,t));if(!n.ok){g(await XC(n));return}let r=await n.text();y.current&&URL.revokeObjectURL(y.current);let i=URL.createObjectURL(new Blob([r],{type:`text/plain;charset=utf-8`}));y.current=i,v(i),window.open(i,`_blank`,`noopener`)}catch(e){g(e instanceof Error?e.message:`报告打不开`)}finally{m(!1)}}},S=e.resources?.usage,C=s.delivery?.evidenceRefs??[],w=e.resources?.sessions?.find(t=>t.id===e.ownerConversationId),T=!e.ownerConversationId||!!(w&&[`failed`,`stopped`].includes(w.status??``)&&!e.resources?.activeWorkers);return(0,F.jsxs)(`div`,{className:`project-detail project-overview`,"data-project-detail":e.id,children:[e.objective&&(0,F.jsxs)(`div`,{className:`project-goal`,children:[(0,F.jsx)(`span`,{children:`项目目标`}),(0,F.jsx)(`p`,{className:`project-detail-objective`,children:e.objective})]}),(0,F.jsxs)(`section`,{className:`project-section`,"data-project-owner-summary":!0,children:[(0,F.jsx)(`h3`,{children:`当前进展`}),(0,F.jsx)(KC,{text:s.summary,what:`进展`}),e.updatedAt&&(0,F.jsxs)(`p`,{className:`project-overview-time`,children:[JC(e.updatedAt),`更新`]})]}),s.delivery&&(0,F.jsxs)(`section`,{className:`project-section`,"data-project-stage-delivery":!0,children:[(0,F.jsx)(`h3`,{children:s.deliveryLabel}),(0,F.jsx)(KC,{text:s.delivery.progress||s.delivery.summary||`已提交阶段成果`,what:`交付`}),C.length?(0,F.jsx)(qC,{refs:C,baseCwd:e.resources?.ownerCwd??w?.cwd,cwd:a,onOpenFile:i}):(0,F.jsx)(`p`,{"data-project-no-evidence":!0,children:`未附可核对的交付证据。`})]}),s.decisions.length>0&&(0,F.jsxs)(`section`,{className:`project-section`,"data-project-exception-section":!0,children:[(0,F.jsx)(`h3`,{"data-project-exception-heading":!0,children:`需要你决定`}),(0,F.jsx)(`ul`,{className:`project-exception-list`,children:s.decisions.map(t=>(0,F.jsx)(iw,{item:t,project:e,busy:c,onResolve:e=>void b(`escalations/${encodeURIComponent(t.id)}`,`PATCH`,{decision:e,status:`resolved`}),onReturn:e=>void b(`escalations/${encodeURIComponent(t.id)}`,`PATCH`,{decision:e,status:`returned`})},t.id))})]}),d&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,children:d}),(0,F.jsxs)(`div`,{className:`project-detail-actions project-overview-actions`,children:[w&&r&&(0,F.jsx)(`button`,{type:`button`,className:T&&!s.ended?``:`project-primary-action`,"data-project-open-owner":!0,onClick:()=>r(w.id),children:`查看负责人会话`}),!s.ended&&T&&(0,F.jsx)(`button`,{type:`button`,className:`project-primary-action`,disabled:c,"data-project-resume":!0,onClick:()=>void b(`start`,`POST`),children:`让负责人继续`}),!s.ended&&(0,F.jsx)(`button`,{type:`button`,className:`project-stop-action`,disabled:c,"data-project-stop":!0,onClick:()=>void b(``,`PATCH`,{status:`cancelled`}),children:`停止项目`}),(0,F.jsx)(`button`,{type:`button`,disabled:p,"data-project-report":e.id,onClick:()=>void x(),children:p?`正在读取…`:`导出记录`})]}),h&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,"data-project-report-error":!0,children:h}),_&&(0,F.jsx)(`a`,{href:_,target:`_blank`,rel:`noopener noreferrer`,"data-project-report-link":!0,children:`打开已读取的记录`}),e.resources&&(0,F.jsxs)(`details`,{className:`project-section project-secondary`,"data-project-usage":!0,children:[(0,F.jsx)(`summary`,{children:`查看用量`}),(0,F.jsxs)(`div`,{"data-project-budget":e.id,children:[(0,F.jsxs)(`p`,{"data-project-budget-used":e.id,children:[`等效 Token `,e.resources.usageKnown?e.resources.tokens.toLocaleString():`未知`]}),S&&(0,F.jsxs)(`p`,{"data-project-budget-raw":e.id,children:[`原始口径 `,(e.resources.rawTokens??S.input+S.output+S.cacheRead+S.cacheWrite).toLocaleString(),`;输入 `,S.input.toLocaleString(),`;输出 `,S.output.toLocaleString(),`;缓存写入 `,S.cacheWrite.toLocaleString(),`;缓存读取 `,S.cacheRead.toLocaleString()]}),(0,F.jsx)(`p`,{"data-project-budget-basis":`1`,children:`等效 Token = 输入 + 输出 + 缓存写入×1.25 + 缓存读取×0.1`})]})]})]})}function ow({project:e,workspaceId:t,notify:n,onOpenSession:r,onOpenFile:i,cwd:a,onChanged:o,onClose:s}){let c=(0,u.useId)(),l=(0,u.useRef)(null),d=(0,u.useRef)(s);return d.current=s,(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,u.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[e.id]),(0,We.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay project-dialog-overlay`,"data-project-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&s()},children:(0,F.jsxs)(`div`,{ref:l,className:`tool-dialog project-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":c,"data-project-dialog":e.id,tabIndex:-1,onKeyDown:e=>{if(e.key!==`Tab`)return;let t=l.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), a[href], select:not([disabled]), input:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex='-1'])`)).filter(e=>e.offsetParent!==null||e.getClientRects().length>0);if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey?(document.activeElement===r||document.activeElement===t)&&(e.preventDefault(),i.focus()):document.activeElement===i&&(e.preventDefault(),r.focus())},children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head project-dialog-head`,children:[(0,F.jsxs)(`div`,{className:`project-dialog-title-group`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title project-dialog-title`,id:c,children:e.title}),(0,F.jsx)(`span`,{className:`project-detail-flags`,children:(0,F.jsx)(`span`,{className:`project-status project-status-${e.status}`,children:PC(e).label})})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close project-dialog-close`,"data-project-dialog-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭 ${e.title}`,onClick:s,children:`✕`})]}),(0,F.jsx)(`div`,{className:`tool-dialog-body project-dialog-body`,children:(0,F.jsx)(aw,{project:e,workspaceId:t,notify:n,onOpenSession:r?e=>{s(),r(e)}:void 0,onOpenFile:i?e=>{s(),i(e)}:void 0,cwd:a,onChanged:o})})]})}),document.body)}function sw({workspaceId:e,notify:t,onOpenSession:n,onOpenFile:r,cwd:i}){let[a,o]=(0,u.useState)([]),[s,c]=(0,u.useState)(!1),l=(0,u.useMemo)(()=>WC(a,s),[a,s]),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(null),y=(0,u.useRef)(null),[b,x]=(0,u.useState)([]),S=(0,u.useCallback)(async t=>{if(!e)o([]);else{f(!0),g(``);try{let n=await Ae(`/api/projects?workspaceId=${encodeURIComponent(e)}${s?`&view=history`:``}`,{signal:t}).then(YC),r=Array.isArray(n)?n:Array.isArray(n.projects)?n.projects:[];o(r)}catch(e){e.name!==`AbortError`&&g(e instanceof Error?e.message:`项目列表加载失败`)}finally{t?.aborted||(f(!1),m(!0))}}},[e,s]);(0,u.useEffect)(()=>{let e=new AbortController;return S(e.signal),()=>e.abort()},[S]),(0,u.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>void S(),5e3);return()=>window.clearInterval(t)},[S,e]);let C=(0,u.useMemo)(()=>{let e=Date.now();return l.map(t=>nw(t,e)).filter(e=>!!e).filter(e=>!b.includes(e.reminderId)).sort((e,t)=>ew[e.kind]-ew[t.kind]||t.updatedAt-e.updatedAt)},[l,b]),w=(0,u.useMemo)(()=>l.flatMap(e=>OC(e).map(t=>({project:e,decision:t}))),[l]),T=(0,u.useMemo)(()=>kC(l).projects,[l]),E=(0,u.useMemo)(()=>C.slice(0,tw),[C]),D=C.length-E.length,[O,k]=(0,u.useState)(!1),A=O?C:E,[j,ee]=(0,u.useState)(!1),M=(0,u.useMemo)(()=>{let e=new Set;for(let t of C)e.add(t.projectId);return e},[l,C]),te=(0,u.useMemo)(()=>j?l.filter(e=>M.has(e.id)):l,[j,l,M]),N=(0,u.useMemo)(()=>_?l.find(e=>e.id===_)??null:null,[l,_]),ne=(0,u.useRef)(null),[re,ie]=(0,u.useState)(0),ae=(0,u.useCallback)((e,t,n)=>{y.current=t??document.querySelector(`[data-project-row="${e}"]`),v(e),n&&(ne.current={projectId:e,target:n},ie(e=>e+1))},[]),oe=(0,u.useCallback)(()=>{let e=_,t=y.current;y.current=null,v(null),window.requestAnimationFrame(()=>{(t?.isConnected?t:e?document.querySelector(`[data-project-row="${e}"]`):null)?.focus()})},[_]),se=e=>{let t=document.querySelector(`[data-project-row="${e.projectId}"]`);ae(e.projectId,t,e.target)};return(0,u.useEffect)(()=>{if(!re)return;let e=ne.current;if(ne.current=null,!e)return;let t=document.querySelector(`[data-project-detail="${e.projectId}"]`);if(!t)return;let n=null;if(e.target.kind===`exception`){let e=t.querySelector(`[data-project-exception-section]`);e&&(e.open=!0,n=e.querySelector(`[data-project-exception-heading]`)??e)}let r=n??t,i=window.requestAnimationFrame(()=>{r.scrollIntoView({block:e.target.kind===`top`?`start`:`center`,inline:`nearest`})});return()=>window.cancelAnimationFrame(i)},[re,N?.id]),(0,F.jsxs)(`section`,{className:`project-panel`,"data-project-panel":`1`,children:[(0,F.jsx)(`div`,{className:`rail-section-head project-panel-head`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`项目进展`}),(0,F.jsx)(`p`,{className:`project-panel-subtitle`,children:`查看负责人汇总的进展、成果和需要你决定的事。`})]})}),w.length>0&&(0,F.jsxs)(`div`,{className:`warning`,role:`status`,"data-project-team-notice":`1`,"data-project-team-notice-count":T,children:[(0,F.jsxs)(`span`,{"data-project-team-notice-text":!0,children:[T===1?`有 1 个项目的事需要你决定`:`有 ${T} 个项目的事需要你决定`,`:`,QC($C(w[0].decision),48)]}),(0,F.jsx)(`button`,{type:`button`,"data-project-team-notice-action":`1`,onClick:()=>ae(w[0].project.id,void 0,{kind:`exception`,escalationId:w[0].decision.id}),children:`去看看`})]}),C.length>0&&(0,F.jsxs)(`div`,{className:`project-pending`,"data-project-pending":`1`,"data-project-pending-count":C.length,children:[A.map(e=>(0,F.jsxs)(`div`,{className:`project-pending-item`,"data-project-pending-item":e.projectId,"data-project-pending-kind":e.kind,children:[(0,F.jsxs)(`div`,{className:`project-pending-row`,children:[(0,F.jsx)(`span`,{className:`project-pending-kind project-pending-kind-${e.kind}`,"data-project-pending-label":e.kind,children:e.label}),(0,F.jsx)(`span`,{className:`project-pending-title`,"data-project-pending-title":e.projectId,children:e.projectTitle}),(0,F.jsx)(`button`,{type:`button`,className:`project-pending-action`,"data-project-pending-action":e.projectId,onClick:()=>se(e),children:e.actionLabel}),(0,F.jsx)(`button`,{type:`button`,className:`project-pending-close`,"data-project-pending-dismiss":e.projectId,"aria-label":`关闭「${e.projectTitle}」的这条提醒`,title:`关闭这条提醒(不改变项目状态)`,onClick:()=>x(t=>[...t,e.reminderId]),children:`×`})]}),(0,F.jsx)(`p`,{className:`project-pending-detail`,"data-project-pending-detail":e.projectId,children:e.detail})]},`${e.projectId}:${e.kind}`)),D>0&&(0,F.jsx)(`button`,{type:`button`,className:`project-pending-more`,"data-project-pending-more":`1`,"aria-expanded":O,onClick:()=>k(e=>!e),children:O?`收起`:`还有 ${D} 个`})]}),(0,F.jsxs)(`label`,{className:`project-pending-filter`,"data-project-pending-only-label":`1`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-project-pending-only":`1`,checked:j,onChange:e=>ee(e.target.checked)}),(0,F.jsx)(`span`,{className:`project-pending-filter-name`,children:`只看提醒`}),(0,F.jsx)(`span`,{className:`project-pending-filter-state`,"data-project-pending-only-state":j?`on`:`off`,children:j?`已开启`:`已关闭`})]}),(0,F.jsxs)(`label`,{className:`project-pending-filter`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-project-history":`1`,checked:s,onChange:e=>{c(e.target.checked),ee(!1),v(null)}}),(0,F.jsx)(`span`,{className:`project-pending-filter-name`,children:`查看历史项目`})]}),h&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,"data-project-error":`1`,children:h}),e?d&&!p&&l.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,children:`正在加载项目…`}):l.length===0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`rail-empty`,"data-project-empty":`1`,children:s?`没有已结束的项目。`:`当前没有进行中的项目。`}),(0,F.jsx)(`p`,{className:`project-empty-hint`,"data-project-empty-hint":`1`,children:`在对话里告诉 AI 你要完成什么,负责人会推进工作并向你交付。`})]}):te.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-project-pending-empty":`1`,children:`没有需要关注的项目。`}):(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`div`,{className:`project-list`,"data-project-count":te.length,children:te.map(e=>{let t=N?.id===e.id;return(0,F.jsxs)(`button`,{type:`button`,className:`project-row`,"data-project-row":e.id,"data-project-block":e.id,"data-project-summary":e.id,"aria-haspopup":`dialog`,"aria-expanded":t,onClick:t=>ae(e.id,t.currentTarget),children:[(0,F.jsx)(`span`,{className:`project-list-title`,title:e.title,children:e.title}),(0,F.jsx)(`span`,{className:`project-status project-status-${e.status}`,children:PC(e).label}),(0,F.jsx)(`span`,{className:`project-row-summary`,children:PC(e).summary}),e.updatedAt&&(0,F.jsxs)(`span`,{className:`project-row-updated`,children:[JC(e.updatedAt),`更新`]})]},e.id)})})}):(0,F.jsx)(`p`,{className:`rail-empty`,children:`请先选择工作区。`}),N?(0,F.jsx)(ow,{project:N,workspaceId:e,notify:t,onOpenSession:n,onOpenFile:r,cwd:i,onChanged:()=>S(),onClose:oe}):null]})}var cw=`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`;function lw(e,t){return e?!(!t||t.id!==e||t.archivedAt):!1}function uw(e){let{conversation:t,parent:n,directChildren:r,isTopLevelUnread:i=!1}=e;return t.hasOpenEscalation?`awaiting_decision`:r.some(e=>{if(e.archivedAt)return!1;let t=e.status===`running`||e.status===`waiting`||e.status===`awaiting_background`,n=!!e.hasOpenEscalation;return t||n})?`awaiting_subordinates`:lw(t.parentConversationId,n)?t.hasPendingResult?`pending_report`:null:i?`unread`:null}function dw(e){let{conversation:t,directChildren:n}=e,r=t.hasOpenEscalation&&!t.parentConversationId&&t.escalationAudience===`boss`;return uw({...e,conversation:{...t,hasOpenEscalation:r},directChildren:n.map(e=>e.hasOpenEscalation?{...e,hasOpenEscalation:!1}:e)})}function fw(e){let{status:t,reportingState:n,awaitingQuestion:r,quietWhenRead:i=!1}=e;return r?`question`:t===`failed`?`failed`:n===`awaiting_decision`?`awaiting_decision`:t===`waiting`?`waiting`:t===`running`?`running`:t===`awaiting_background`?`awaiting_background`:n===`pending_report`?`pending_report`:n===`awaiting_subordinates`?`awaiting_subordinates`:n===`unread`?t===`completed`?`completed`:`unread`:i?`idle`:t===`completed`?`completed`:`idle`}var pw=[`solution-designer`,`code-designer`,`code-auditor`,`document-organizer`];function mw(e,t){return fw({status:e.status,quietWhenRead:!0,reportingState:e.lastReplyAt&&e.lastReplyAt>(t??``)?`unread`:null})}var hw=`super-pi-active-group-workspace`,gw=e=>`super-pi-group-room:${e}`;function _w(){try{let e=localStorage.getItem(hw),t=e&&localStorage.getItem(gw(e));if(e&&t)return{workspaceId:e,roomId:t}}catch{}}function vw(e){try{e?.roomId?(localStorage.setItem(gw(e.workspaceId),e.roomId),localStorage.setItem(hw,e.workspaceId)):localStorage.removeItem(hw)}catch{}}var yw=({workspaceId:e,roomId:t})=>`group:${JSON.stringify([e,t])}`;function bw(e){if(e.startsWith(`group:`))try{let t=JSON.parse(e.slice(6));if(Array.isArray(t)&&typeof t[0]==`string`&&typeof t[1]==`string`)return{workspaceId:t[0],roomId:t[1]}}catch{}}function xw(e,t,n,r){let i=new URLSearchParams({workspaceId:e});return t&&i.set(`id`,t),n&&i.set(`revision`,n),r&&i.set(`execution`,r),`/api/group-chats?${i}`}var Sw=class extends Error{status;constructor(e,t){super(e),this.status=t}};async function Cw(e,t){let n=await Ae(e,t);if(n.status===204)return;let r=await n.json().catch(()=>void 0);if(!n.ok)throw new Sw(r?.error||`群聊请求失败(${n.status})。`,n.status);return r}function ww(e,t){return Cw(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}function Tw(e,t){return e.archivedAt?`idle`:t&&t.revision>=e.activity.revision?t.status:e.activity.status}function Ew(e,t,n){return e.archivedAt?`idle`:mw(t&&t.revision>=e.activity.revision?t:e.activity,n)}function Dw(e,t){let n=JSON.stringify(e.filter(e=>!e.closedAt&&!e.id.startsWith(`pending:`)).map(e=>e.id)),[r,i]=(0,u.useState)({}),[a,o]=(0,u.useState)({}),[s,c]=(0,u.useState)(0),l=(0,u.useRef)(new Map),d=(0,u.useRef)(new Set),f=(0,u.useRef)(0),p=(0,u.useCallback)(()=>{f.current+=1,c(e=>e+1)},[]);(0,u.useEffect)(()=>{if(!t)return;let e=JSON.parse(n),r=new AbortController,a=f.current,o=()=>!r.signal.aborted&&a===f.current;for(let t of e)Cw(xw(t),{signal:r.signal}).then(e=>{if(!o()||!e)return;for(let t of e)l.current.delete(t.id);let n=[...l.current.values()].filter(e=>e.workspaceId===t);i(r=>({...r,[t]:{rooms:[...n.reverse(),...e],loaded:!0}}))}).catch(()=>{o()&&i(e=>({...e,[t]:{...e[t],rooms:e[t]?.rooms??[],failed:!0}}))});return window.addEventListener(`focus`,p),()=>{window.removeEventListener(`focus`,p),r.abort()}},[n,t,s,p]);let m=(0,u.useCallback)(({id:e,workspaceId:t,activity:n,cloneRequests:r})=>{d.current.has(e)||(r&&i(i=>{let a=i[t];return a?{...i,[t]:{...a,rooms:a.rooms.map(t=>t.id===e&&t.activity.revision<=n.revision?{...t,activity:n,cloneRequests:r}:t)}}:i}),o(t=>t[e]&&t[e].revision>=n.revision?t:{...t,[e]:n}))},[]);return{index:r,reload:p,remember:(0,u.useCallback)((e,t=!1)=>{if(d.current.has(e.id))return;let{id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c}=e,u={id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c};m(u),t&&l.current.set(u.id,u),i(t=>{let n=t[e.workspaceId],r=n?.rooms??[],i=r.find(t=>t.id===e.id);return i&&(i.updatedAt>u.updatedAt||i.title===u.title&&i.archivedAt===u.archivedAt)?t:{...t,[e.workspaceId]:{...n,rooms:i?r.map(t=>t.id===e.id?u:t):[u,...r]}}})},[m]),forget:(0,u.useCallback)(({workspaceId:e,roomId:t})=>{d.current.add(t),l.current.delete(t),o(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),i(n=>{let r=n[e];return r?{...n,[e]:{...r,rooms:r.rooms.filter(e=>e.id!==t)}}:n})},[]),activities:a,recordActivity:m}}var Ow={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,cancelled:`已停止`,interrupted:`已中断`},kw=new Map([[`read`,`读取文件`],[`write`,`写入文件`],[`edit`,`编辑文件`],[`grep`,`搜索内容`],[`find`,`查找文件`],[`ls`,`列出目录`],[`bash`,`运行命令`],[`powershell`,`运行命令`]]),Aw=new Map([[`solution-designer`,`案`],[`code-designer`,`码`],[`code-auditor`,`审`],[`document-organizer`,`文`]]),jw=e=>e.status===`queued`||e.status===`running`,Mw=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Nw=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function Pw(e,t=!1){let n=Date.parse(e);return Number.isFinite(n)?(t?Nw:Mw).format(n):``}function Fw({name:e,memberId:t,busy:n}){let r=e.trim(),i=t&&Aw.get(t)||(/\p{Script=Han}/u.test(r)?Array.from(r).slice(-2).join(``):r.split(/\s+/u).filter(Boolean).map(e=>Array.from(e)[0]).slice(0,2).join(``).toUpperCase())||`?`,a=pw.findIndex(e=>e===t),o=a>=0?a:Array.from(t??``).reduce((e,t)=>(e*31+(t.codePointAt(0)??0))%4,0);return(0,F.jsx)(`span`,{className:`group-avatar`,"data-avatar-tone":t?o:`self`,"data-avatar-busy":n||void 0,"aria-hidden":`true`,children:i})}function Iw({step:e}){return e.kind===`thinking`?(0,F.jsxs)(`details`,{className:`group-execution-step`,"data-execution-kind":`thinking`,"data-execution-status":e.status,open:!0,children:[(0,F.jsxs)(`summary`,{children:[(0,F.jsx)(`span`,{children:e.status===`running`?`正在思考`:`思考摘要`}),(0,F.jsx)(`time`,{dateTime:e.startedAt,children:Pw(e.startedAt,!0)})]}),e.text?(0,F.jsx)(`div`,{className:`message-body`,children:(0,F.jsx)(Wu,{source:e.text,handoffs:!1})}):(0,F.jsx)(`p`,{className:`group-execution-muted`,children:e.status===`running`?`正在等待模型返回摘要。`:`模型未提供可显示的摘要。`}),e.status===`interrupted`&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:`思考已中断`})]}):(0,F.jsxs)(`li`,{className:`group-execution-step`,"data-execution-kind":`tool`,"data-execution-status":e.status,children:[(0,F.jsxs)(`div`,{className:`group-execution-tool`,children:[(0,F.jsx)(`strong`,{children:kw.get(e.name)??`工具调用`}),(0,F.jsx)(`code`,{children:e.name}),(0,F.jsx)(`span`,{className:`group-execution-step-status`,children:Ow[e.status]})]}),e.detail&&(0,F.jsx)(`p`,{className:`group-execution-target`,children:(0,F.jsx)(`code`,{children:e.detail})}),(0,F.jsxs)(`div`,{className:`group-execution-muted`,children:[(0,F.jsx)(`time`,{dateTime:e.startedAt,children:Pw(e.startedAt,!0)}),e.durationMs===void 0?e.status===`running`&&e.lastUpdateAt?` · 最近更新 ${Pw(e.lastUpdateAt,!0)}`:null:` · ${(e.durationMs/1e3).toFixed(1)} 秒`]})]})}function Lw({workspaceId:e,roomId:t,memberId:n,name:r,runs:i,postId:a,onSelect:o,onClose:s}){let c=(0,u.useId)(),l=(0,u.useRef)(null),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(),h=i.find(e=>e.id===a)??i.find(e=>e.status===`running`)??i[0],g=h?.id,_=d?.id===g?d?.value:void 0,v=p?.id===g?p?.message:void 0;return(0,u.useLayoutEffect)(()=>{l.current?.focus()},[]),(0,u.useEffect)(()=>{if(!g)return;let n=new AbortController,r,i,a=!1,o=async()=>{try{let r=await Cw(xw(e,t,i,g),{signal:n.signal});if(n.signal.aborted)return;m(void 0),r&&(i=r.revision,a=!jw(r),f({id:g,value:r}))}catch(e){n.signal.aborted||m({id:g,message:e instanceof Error?e.message:`暂时无法读取执行记录。`})}finally{!n.signal.aborted&&!a&&(r=window.setTimeout(o,500))}};return o(),()=>{n.abort(),window.clearTimeout(r)}},[g,e,t]),(0,F.jsxs)(`aside`,{className:`group-execution`,"aria-labelledby":c,"data-group-execution":n,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),s())},children:[(0,F.jsxs)(`header`,{className:`group-execution-header`,children:[(0,F.jsx)(Fw,{name:r,memberId:n,busy:i.some(jw)}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{id:c,children:r}),(0,F.jsx)(`p`,{children:`执行详情`})]}),(0,F.jsx)(`button`,{ref:l,type:`button`,className:`group-close-execution`,"data-close-group-execution":!0,"aria-label":`关闭执行详情`,title:`关闭执行详情`,onClick:s,children:(0,F.jsx)(Tt,{name:`close`})})]}),h?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`group-execution-summary`,children:[i.length>1&&(0,F.jsx)(`select`,{"aria-label":`选择执行记录`,value:g,onChange:e=>o(e.target.value),children:i.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[Pw(e.createdAt,!0),` · `,e.assignment??Ow[e.status]]},e.id))}),(0,F.jsx)(`div`,{"aria-live":`polite`,"data-execution-run-status":_?.status??h.status,children:Ow[_?.status??h.status]}),h.assignment&&(0,F.jsx)(`p`,{children:h.assignment}),h.error&&(0,F.jsx)(`p`,{className:`group-error`,children:h.error})]}),(0,F.jsxs)(`div`,{className:`group-execution-scroll`,children:[v&&(0,F.jsx)(`p`,{className:`group-error`,role:`alert`,children:v}),_?.steps.length?(0,F.jsx)(`ol`,{className:`group-execution-steps`,children:_.steps.map(e=>e.kind===`thinking`?(0,F.jsx)(`li`,{children:(0,F.jsx)(Iw,{step:e})},e.id):(0,F.jsx)(Iw,{step:e},e.id))}):!v&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:_?jw(_)?`等待模型或工具事件。`:`这次发言没有可查看的执行明细。`:`正在读取执行记录…`}),_?.truncated&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:`部分执行记录超过保留长度,已省略。`})]})]}):(0,F.jsx)(`p`,{className:`group-execution-scroll group-execution-muted`,children:`该成员还没有执行记录。`})]})}var Rw=e=>JSON.stringify([e.provider,e.modelId]),zw=`super-pi.group-moderator-prompt-presets.v1`;function Bw(){try{let e=JSON.parse(localStorage.getItem(zw)??`[]`);return Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&typeof e.prompt==`string`).slice(0,100).map(e=>({id:e.id.slice(0,100),name:e.name.slice(0,80),prompt:e.prompt.slice(0,8e3)})):[]}catch{return[]}}var Vw=e=>/\s/u.test(e)?`@"${e}"`:`@${e}`,Hw=e=>new Set([...e.matchAll(/(?:^|[\s([{])(@(?:"(?:[^"\\]|\\.)+"|[^\s,。;、!?,::;!?,)\]}]+))/gu)].map(e=>e[1])),Uw=ww;function Ww({workspaceId:e,roomId:t,agents:n,catalog:r,userLabel:i,archivedAt:a,restoring:o,onRestore:s,onRoomSeen:c,onRoomRead:l,onRoomMissing:d,onCreated:f,onCancelCreate:p,onEnableNotifications:m}){let[h,g]=(0,u.useState)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(``),[C,w]=(0,u.useState)(!1),[T,E]=(0,u.useState)({}),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)(``),[j,ee]=(0,u.useState)(``),[M,te]=(0,u.useState)(),[N,ne]=(0,u.useState)(),[re,ie]=(0,u.useState)([]),[ae,oe]=(0,u.useState)([]),[se,ce]=(0,u.useState)([]),[le,ue]=(0,u.useState)(0),[de,fe]=(0,u.useState)(),pe=(0,u.useRef)(null),me=(0,u.useRef)(null),he=(0,u.useRef)(void 0),ge=(0,u.useRef)(null),P=(0,u.useRef)(!0),_e=(0,u.useRef)(void 0),ve=(0,u.useRef)(!1),ye=(0,u.useRef)(void 0),be=h?.id===t?h:void 0,xe=!!(a||be?.archivedAt),Se=be?.messages.find(e=>e.id===M),Ce=e=>be?.members.find(t=>t.id===e)?.name??e,we=e=>e.role===`user`?i:e.memberName??Ce(e.memberId),Te=xe?void 0:N?.query,Ee=N?[...(be?.members??[]).filter(e=>`${e.name} ${e.id}`.toLocaleLowerCase().includes(N.query.toLocaleLowerCase())).map(e=>({kind:`member`,member:e})),...se.map(e=>({kind:`file`,file:e}))]:[],De=e=>{if(e.id!==t)return;let n=_e.current;if(n?.id===e.id){let[t,r]=n.revision.split(`:`).map(Number),[i,a]=e.revision.split(`:`).map(Number);if(t>i||t===i&&r>a)return}_e.current=e,g(e),e.archivedAt&&v(!1),(n?.title!==e.title||n?.archivedAt!==e.archivedAt||n?.activity.status!==e.activity.status||n?.activity.lastReplyAt!==e.activity.lastReplyAt)&&c(e)};(0,u.useEffect)(()=>{let e=ge.current;if(!be||_||!e)return;let t=!0,n=()=>{let n=e.getBoundingClientRect();t&&document.visibilityState===`visible`&&getComputedStyle(e).visibility===`visible`&&n.width>0&&n.height>0&&n.bottom>0&&n.top<window.innerHeight&&n.right>0&&n.left<window.innerWidth&&l(be)};n();let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n()});return r.observe(e),document.addEventListener(`visibilitychange`,n),()=>{t=!1,r.disconnect(),document.removeEventListener(`visibilitychange`,n)}},[be?.id,be?.activity.lastReplyAt,_,de?.memberId,de?.postId,l]),(0,u.useEffect)(()=>(ve.current=!0,()=>{ve.current=!1}),[]),(0,u.useEffect)(()=>{if(!t)return;let n=new AbortController,r,i=!1,a=async()=>{try{let r=await Cw(xw(e,t,_e.current?.revision),{signal:n.signal});n.signal.aborted||(S(``),r&&De(r))}catch(r){n.signal.aborted||(r instanceof Sw&&r.status===404?(i=!0,d({workspaceId:e,roomId:t})):S(_e.current?`群聊连接暂时中断,正在重试。`:String(r.message??r)))}finally{!n.signal.aborted&&!i&&(r=window.setTimeout(a,_e.current?.messages.some(jw)?450:1600))}};return a(),()=>{n.abort(),window.clearTimeout(r)}},[e,t,d]),(0,u.useEffect)(()=>{if(ce([]),!Te)return;let t=new AbortController,n,r=()=>{Cw(`/api/files/mentions?${new URLSearchParams({workspaceId:e,cwd:``,q:Te})}`,{signal:t.signal}).then(e=>{!t.signal.aborted&&e&&(ce(e.hits.filter(e=>e.kind===`file`).slice(0,8)),e.indexed||(n=window.setTimeout(r,650)))}).catch(()=>{})};return n=window.setTimeout(r,160),()=>{window.clearTimeout(n),t.abort()}},[Te,e]),(0,u.useLayoutEffect)(()=>{ge.current&&P.current&&(ge.current.scrollTop=ge.current.scrollHeight)},[be?.revision]),(0,u.useLayoutEffect)(()=>{let e=he.current;e!==void 0&&me.current&&(he.current=void 0,me.current.focus(),me.current.setSelectionRange(e,e))},[j]);async function Oe(n){w(!0),b(``);try{let r=await Uw(xw(e,t),t?{action:`configure`,memberIds:n.memberIds,...n.moderator}:n);if(!r)throw Error(`服务没有返回群聊。`);t?(De(r),v(!1)):f(r,ve.current)}catch(e){b(String(e.message??e))}finally{w(!1)}}async function ke(n){if(n.preventDefault(),!be||xe||!j.trim()||C)return;let r=j.trim(),i=Hw(r),a=re.filter(e=>i.has(e.text)),o=be.members.filter(e=>a.some(t=>t.memberId===e.id)||i.has(Vw(e.name))&&be.members.filter(t=>t.name===e.name).length===1).map(e=>e.id),s=ae.filter(e=>i.has(e.text)).map(e=>e.path),c=JSON.stringify([be.id,r,o,M,s]);ye.current?.signature!==c&&(ye.current={signature:c,clientId:En()}),w(!0),b(``);try{let n=await Uw(xw(e,be.id),{action:`send`,content:r,memberIds:o,replyTo:M,filePaths:s,clientId:ye.current.clientId});if(!n)throw Error(`服务没有确认收到消息。`);P.current=!0,De(n),ve.current&&t===n.id&&(ee(``),te(void 0),ie([]),oe([]),ne(void 0)),ye.current=void 0}catch(e){b(String(e.message??e))}finally{w(!1)}}function Ae(e){if(!N)return;let t;if(e.kind===`member`){let n=e.member,r=Vw(n.name);ee(j.slice(0,N.start)+r+` `+j.slice(N.end)),ie(e=>[...e.filter(e=>e.text!==r),{memberId:n.id,text:r}]),t=N.start+r.length+1}else{let n=e.file,r=ad(j,N,n),i=r.text.slice(N.start,r.caret).trimEnd();ee(r.text),oe(e=>[...e.filter(e=>e.path!==n.path),{path:n.path,text:i}]),t=r.caret}he.current=t,ne(void 0)}async function je(n){try{let r=await Uw(xw(e,t),{action:`stop`,postId:n});r&&De(r)}catch(e){b(String(e.message??e))}}async function Me(n,r,i){O(n),b(``);try{let a=await Uw(xw(e,t),{action:`clone.resolve`,requestId:n,choice:r,name:i});a&&De(a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{O(void 0)}}function Ne(e,t,n,r){let i=n.closest(`[data-group-post-id]`)?.querySelector(`[data-group-message-avatar]`)??void 0;pe.current={origin:n,avatar:i},fe({memberId:e,name:t,postId:r})}function Pe(){fe(void 0);let e=pe.current;requestAnimationFrame(()=>(e?.origin.isConnected?e.origin:e?.avatar)?.focus({preventScroll:!0}))}let Fe=be?.messages??[],Ie=new Map(Fe.map(e=>[e.id,e])),Le=new Set(Fe.flatMap(e=>e.role===`assistant`&&jw(e)?[e.memberId]:[])),Re=de?Fe.filter(e=>e.role===`assistant`&&e.memberId===de.memberId).reverse():[],ze;return(0,F.jsxs)(`section`,{className:`group-chat`,"data-group-chat":t,children:[(y||x)&&(0,F.jsx)(`div`,{className:`group-error`,role:`alert`,children:y||x}),!t||_&&!xe?(0,F.jsx)(Gw,{room:_?be:void 0,agents:n,catalog:r,saving:C,onSave:Oe,onCancel:t?()=>v(!1):p}):be?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`group-members`,children:[(0,F.jsx)(`div`,{className:`group-roster`,"aria-label":`群成员`,children:be.members.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`group-roster-member`,"data-group-member-avatar":e.id,"aria-label":`查看 ${e.name} 的执行详情${Le.has(e.id)?`,工作中`:``}`,title:`${e.name}${e.agentId?` · 分身 · ${e.worktreePath??e.agentId}`:``}`,"aria-pressed":de?.memberId===e.id,onClick:t=>Ne(e.id,e.name,t.currentTarget),children:[(0,F.jsx)(Fw,{name:e.name,memberId:e.id,busy:Le.has(e.id)}),(0,F.jsxs)(`span`,{children:[e.name,e.agentId?` · 分身`:``]})]},e.id))}),!xe&&(0,F.jsx)(`button`,{type:`button`,"data-group-settings":!0,disabled:C,onClick:()=>{b(``),fe(void 0),v(!0)},children:`群聊设置`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{m?m():Jr().then(e=>A(e===`granted`?`系统通知已开启`:`请在浏览器站点设置中允许通知`))},children:`系统通知`})]}),k&&(0,F.jsx)(`p`,{role:`status`,children:k}),(be.cloneRequests??[]).filter((e,t,n)=>e.status===`pending`||t>=n.length-3).map(e=>{let t=be.members.find(t=>t.id===e.memberId),n=2;for(;be.members.some(e=>e.name===`${t?.name??`Agent`} ${n}`);)n+=1;let r=T[e.id]??`${t?.name??`Agent`} ${n}`;return(0,F.jsx)(`section`,{className:`group-clone-request`,"data-clone-request":e.id,"aria-label":`创建 Agent 分身`,children:e.status===`pending`&&e.automatic?(0,F.jsx)(`span`,{children:`主持人正在准备独立分身…`}):e.status===`pending`&&!xe?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`strong`,{children:[t?.name??`Agent`,` 正在工作,是否创建分身?`]}),(0,F.jsx)(`p`,{children:e.reason}),(0,F.jsx)(`p`,{children:e.assignment}),(0,F.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),Me(e.id,`create`,r)},children:[(0,F.jsxs)(`label`,{children:[`分身名字`,(0,F.jsx)(`input`,{maxLength:80,required:!0,value:r,onChange:t=>E(n=>({...n,[e.id]:t.target.value}))})]}),(0,F.jsx)(`button`,{disabled:!!D||!r.trim(),children:D===e.id?`正在准备…`:`创建分身并处理`}),(0,F.jsx)(`button`,{type:`button`,disabled:!!D,onClick:()=>void Me(e.id,`wait`,``),children:`等待空闲`})]}),(0,F.jsx)(`small`,{children:`分身共享源 Agent 的能力与经验,在独立 Git 工作树处理此 case。`})]}):(0,F.jsx)(`span`,{children:e.status===`created`?`已安排 ${be.members.find(t=>t.id===e.cloneId)?.name??`分身`}`:e.status===`waiting`?`已选择等待原成员`:`成员或任务状态已变化,无需创建分身`})},e.id)}),(0,F.jsxs)(`div`,{className:`group-stage${de?` group-stage-inspecting`:``}`,children:[(0,F.jsxs)(`div`,{className:`group-dialogue`,children:[(0,F.jsxs)(`div`,{className:`group-thread`,ref:ge,onScroll:e=>{let t=e.currentTarget;P.current=t.scrollHeight-t.clientHeight-t.scrollTop<64},children:[!Fe.length&&(0,F.jsx)(`p`,{className:`group-empty`,children:xe?`这个群聊没有消息。`:`发条消息开始讨论。用 @ 点名一个或多个成员。`}),Fe.map(e=>{let t=e.replyTo?Ie.get(e.replyTo):void 0;e.role===`user`&&(ze=e.id);let n=t&&(e.role===`user`||t.id!==e.topicId||e.topicId!==ze)?t:void 0,r=we(e),i=e.role===`assistant`&&e.background&&e.status===`running`?`后台进行中`:Ow[e.status],a=e.role===`assistant`&&de?.postId===e.id;return(0,F.jsxs)(`article`,{className:`group-post group-post-${e.role}`,"data-group-post":e.role,"data-group-status":e.status,"data-group-post-id":e.id,children:[e.role===`assistant`?(0,F.jsx)(`button`,{className:`group-post-avatar`,type:`button`,"data-group-message-avatar":e.memberId,"aria-label":`查看 ${r} 这次发言的执行详情`,title:`${r} · 执行详情`,"aria-pressed":a,onClick:t=>Ne(e.memberId,r,t.currentTarget,e.id),children:(0,F.jsx)(Fw,{name:r,memberId:e.memberId,busy:jw(e)})}):(0,F.jsx)(Fw,{name:r}),(0,F.jsxs)(`div`,{className:`group-post-content`,children:[(0,F.jsxs)(`div`,{className:`group-post-head`,children:[(0,F.jsx)(`strong`,{children:r}),e.status!==`completed`&&(0,F.jsx)(`span`,{className:`group-post-state`,children:i}),(0,F.jsx)(`time`,{dateTime:e.createdAt,children:Pw(e.createdAt)}),!xe&&(0,F.jsxs)(`div`,{className:`group-post-actions`,children:[!jw(e)&&(0,F.jsx)(`button`,{type:`button`,className:`group-reply-action`,disabled:C,onClick:()=>{te(e.id),me.current?.focus()},children:`回复`}),jw(e)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>void je(e.id),children:`停止`})]})]}),(n||e.content||e.error||e.role===`user`&&e.memoryNotice)&&(0,F.jsxs)(`div`,{className:`group-bubble`,children:[n&&(0,F.jsxs)(`div`,{className:`group-quote`,children:[we(n),` · `,n.content.slice(0,120)]}),e.content&&(0,F.jsx)(`div`,{className:`message-body`,children:(0,F.jsx)(Wu,{source:e.content,handoffs:!1})}),e.role===`user`&&e.memoryNotice&&(0,F.jsx)(`div`,{className:`group-route`,children:e.memoryNotice}),e.error&&(0,F.jsx)(`p`,{className:`group-error`,children:e.error})]}),e.role===`assistant`&&e.routeReason&&(0,F.jsxs)(`details`,{className:`group-route group-post-footer`,children:[(0,F.jsx)(`summary`,{children:`接话原因`}),e.routeReason]})]})]},e.id)})]}),xe?(0,F.jsxs)(`div`,{className:`group-archive-notice`,"data-group-archive-notice":!0,children:[(0,F.jsx)(`p`,{children:`群聊已归档。恢复后可继续发消息。`}),(0,F.jsx)(`button`,{type:`button`,"data-group-restore":!0,disabled:o,onClick:()=>s(be),children:`恢复群聊`})]}):(0,F.jsxs)(`form`,{className:`group-composer`,onSubmit:ke,children:[Se&&(0,F.jsxs)(`div`,{className:`group-quote`,children:[`回复 `,we(Se),` · `,Se.content.slice(0,60),` `,(0,F.jsx)(`button`,{type:`button`,onClick:()=>te(void 0),"aria-label":`取消引用`,children:`×`})]}),Ee.length>0&&(0,F.jsx)(`div`,{className:`group-suggestions`,role:`listbox`,"aria-label":`点名群成员或引用文件`,children:Ee.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===le,"data-group-member-option":e.kind===`member`?e.member.id:void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>Ae(e),children:e.kind===`member`?e.member.name:`文件 · ${e.file.path}`},e.kind===`member`?`member:${e.member.id}`:`file:${e.file.path}`))}),(0,F.jsx)(`textarea`,{ref:me,"data-group-composer":!0,"aria-label":`群聊消息`,placeholder:`输入消息,@ 点名或引用文件`,value:j,maxLength:32e3,readOnly:C,onChange:e=>{ee(e.target.value),ne(id(e.target.value,e.target.selectionStart,e.target.selectionEnd)),ue(0)},onSelect:e=>{let t=e.currentTarget;ne(id(t.value,t.selectionStart,t.selectionEnd))},onKeyDown:e=>{e.nativeEvent.isComposing||(Ee.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`)?(e.preventDefault(),ue(t=>(t+Ee.length+(e.key===`ArrowDown`?1:-1))%Ee.length)):Ee.length&&(e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey?(e.preventDefault(),Ae(Ee[le]??Ee[0])):e.key===`Escape`?ne(void 0):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit()))}}),(0,F.jsx)(`button`,{type:`submit`,"data-group-send":!0,disabled:!j.trim()||C,children:`发送`})]})]}),de&&(0,F.jsx)(Lw,{workspaceId:e,roomId:t,memberId:de.memberId,name:de.name,runs:Re,postId:de.postId,onSelect:e=>fe({...de,postId:e}),onClose:Pe},de.memberId)]})]}):!x&&(0,F.jsx)(`p`,{className:`group-empty`,children:`正在加载群聊…`})]})}function Gw({room:e,agents:t,catalog:n,saving:r,onSave:i,onCancel:a}){let[o,s]=(0,u.useState)(e?.title??``),[c,l]=(0,u.useState)({}),d=t.filter(e=>e.mode===`primary`&&!e.hidden),f=[...d,...e?.members.filter(e=>!d.some(t=>t.id===e.id))??[]],p=e?.members.map(e=>e.id)??pw,m=[...new Set([...p,...f.map(e=>e.id)])].filter(e=>f.some(t=>t.id===e)&&(c[e]??p.includes(e))),[h,g]=(0,u.useState)(e?.moderator.model?Rw(e.moderator.model):``),[_,v]=(0,u.useState)(e?.moderator.prompt??``),[y,b]=(0,u.useState)(e?.moderator.cloneLimit??0),[x,S]=(0,u.useState)(Bw),[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``);(0,u.useEffect)(()=>{try{localStorage.setItem(zw,JSON.stringify(x))}catch{O(`浏览器无法保存预设,请检查本地存储空间或隐私设置。`)}},[x]);let k=[...n?.models??[]];if(e?.moderator.model&&!k.some(t=>Rw(t)===Rw(e.moderator.model))){let t=e.moderator.model;n||k.push(t)}return(0,F.jsxs)(`form`,{className:`group-settings`,onSubmit:e=>{e.preventDefault();let t=k.find(e=>Rw(e)===h);(!h||t)&&i({title:o,memberIds:m,moderator:{prompt:_,cloneLimit:y||void 0,model:t&&{provider:t.provider,modelId:t.modelId,label:t.label}}})},children:[e&&(0,F.jsx)(`h2`,{children:`群聊设置`}),!e&&(0,F.jsxs)(`label`,{children:[`群名`,(0,F.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),maxLength:100,required:!0})]}),(0,F.jsxs)(`fieldset`,{children:[(0,F.jsx)(`legend`,{children:`群成员`}),f.map(e=>(0,F.jsxs)(`label`,{className:`group-choice`,title:e.description,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-group-member-choice":e.id,checked:m.includes(e.id),disabled:!m.includes(e.id)&&m.length>=8,onChange:t=>{let n=t.target.checked;l(t=>({...t,[e.id]:n}))}}),` `,e.name]},e.id))]}),(0,F.jsx)(`p`,{className:`group-settings-hint`,children:`取消勾选可移除成员。请选择 2 到 8 位主 Agent。`}),(0,F.jsxs)(`details`,{open:!!e,children:[(0,F.jsx)(`summary`,{children:`主持人设置`}),(0,F.jsxs)(`label`,{children:[`同类 Agent 分身`,(0,F.jsxs)(`select`,{value:y,onChange:e=>b(Number(e.target.value)),children:[(0,F.jsx)(`option`,{value:0,children:`创建前询问我`}),[2,3,4,8].map(e=>(0,F.jsxs)(`option`,{value:e,children:[`允许自动创建 · 同类最多 `,e,` 人`]},e))]})]}),(0,F.jsxs)(`label`,{children:[`主持人模型`,(0,F.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`继承工作区模型`}),h&&!k.some(e=>Rw(e)===h)&&(0,F.jsx)(`option`,{value:h,disabled:!0,children:`当前模型不可用`}),k.map(e=>(0,F.jsx)(`option`,{value:Rw(e),children:e.label},Rw(e)))]})]}),(0,F.jsxs)(`label`,{children:[`主持人 Prompt`,(0,F.jsx)(`textarea`,{value:_,maxLength:8e3,onChange:e=>v(e.target.value),placeholder:`例如:先请最熟悉模块的成员回答,结论足够时结束。`})]}),(0,F.jsxs)(`div`,{className:`group-prompt-presets`,"data-moderator-prompt-presets":!0,children:[(0,F.jsxs)(`label`,{children:[`加载已保存的 Prompt`,(0,F.jsxs)(`select`,{"aria-label":`加载主持人 Prompt 预设`,value:C,onChange:e=>{let t=x.find(t=>t.id===e.target.value);w(e.target.value),t?(v(t.prompt),E(t.name),O(`已加载「${t.name}」,可继续修改后用于当前群聊。`)):O(``)},children:[(0,F.jsx)(`option`,{value:``,children:`选择预设…`}),x.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,F.jsxs)(`div`,{className:`group-prompt-preset-actions`,children:[(0,F.jsx)(`input`,{"aria-label":`Prompt 预设名称`,value:T,maxLength:80,onChange:e=>E(e.target.value),placeholder:`预设名称`}),(0,F.jsx)(`button`,{type:`button`,disabled:!T.trim()||!_.trim(),onClick:()=>{let e=T.trim(),t=x.find(t=>t.name.toLocaleLowerCase()===e.toLocaleLowerCase()),n={id:t?.id??En(),name:e,prompt:_};S(e=>t?e.map(e=>e.id===t.id?n:e):[n,...e].slice(0,100)),w(n.id),O(`已保存「${e}」。`)},children:`保存预设`}),C&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{let e=x.find(e=>e.id===C);S(e=>e.filter(e=>e.id!==C)),w(``),E(``),O(e?`已删除「${e.name}」。`:`预设已删除。`)},children:`删除预设`})]}),D&&(0,F.jsx)(`p`,{className:`group-settings-hint`,role:`status`,children:D})]})]}),(0,F.jsxs)(`div`,{className:`group-settings-actions`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:r,onClick:a,children:`取消`}),(0,F.jsx)(`button`,{type:`submit`,disabled:r||!o.trim()||m.length<2||m.length>8||!(!h||k.some(e=>Rw(e)===h)),children:e?`保存`:`创建群聊`})]})]})}var Kw=`__pi_default__`;function qw({workspaces:e,catalog:t,onClose:n,onSave:r}){let[i,a]=(0,u.useState)(Kw),[o,s]=(0,u.useState)(Kw);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let c=t.models.find(e=>`${e.provider}/${e.modelId}`===i),l=c?.provider===t.defaultModel?.provider&&c?.modelId===t.defaultModel?.modelId,d=c?.thinkingLevels??(l?t.levels:[]),f=c?{provider:c.provider,modelId:c.modelId,label:c.label}:void 0;return(0,F.jsx)(`div`,{className:`overlay`,onClick:n,children:(0,F.jsxs)(`div`,{className:`picker settings-dialog bulk-workspace-settings`,"data-bulk-workspace-settings":`1`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`h2`,{children:`批量设置工作区`}),(0,F.jsxs)(`div`,{className:`settings-scope`,children:[`将统一修改 `,e.length,` 个现存工作区的默认模型与思考等级,只影响之后新建的会话。`]}),(0,F.jsxs)(`label`,{className:`bulk-settings-field`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,F.jsxs)(`select`,{className:`bulk-settings-select`,"aria-label":`批量默认模型`,value:i,disabled:t.source!==`pi`,onChange:e=>{a(e.target.value),s(Kw)},children:[(0,F.jsx)(`option`,{value:Kw,children:`跟随 Pi 默认`}),t.models.map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.modelId}`,children:[e.label,` · `,e.provider]},`${e.provider}/${e.modelId}`))]})]}),(0,F.jsxs)(`label`,{className:`bulk-settings-field`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认思考等级`}),(0,F.jsxs)(`select`,{className:`bulk-settings-select`,"aria-label":`批量默认思考等级`,value:o,disabled:!c||t.source!==`pi`,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:Kw,children:`跟随 Pi 默认`}),d.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),c&&d.length===0&&(0,F.jsx)(`p`,{className:`bulk-settings-note`,children:`Pi 没有为此模型提供可选择的思考等级;新会话会使用 Pi 默认值。`}),(0,F.jsxs)(`div`,{className:`bulk-settings-workspaces`,"aria-label":`将被更新的工作区`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`应用到`}),(0,F.jsx)(`div`,{children:e.map(e=>(0,F.jsx)(`span`,{children:e.name},e.id))})]}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:n,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-ok`,disabled:!e.length||t.source!==`pi`,onClick:()=>r(f,o===Kw?void 0:o),children:`应用到全部工作区`})]})]})})}function Jw({glyph:e,className:t}){return(0,F.jsx)(`span`,{className:t,"data-tool-glyph-length":Math.min(4,Math.max(1,Array.from(e).length)),"aria-hidden":`true`,children:e})}function Yw(e){if(e!==void 0){if(typeof e!=`string`||!e.trim()||Array.from(e.trim()).length>4||/[<>\u0000-\u001f\u007f]/.test(e))throw Error(`工具图标须为 1 至 4 个字符的文字或符号`);return e.trim()}}function Xw(e){try{let t=Yw(e.glyph);if(t)return t}catch{}let t=`${e.name} ${e.slug??``}`.toLowerCase();return[[/json/,`{}`],[/正则|regex/,`.*`],[/计算|calc/,`∑`],[/时间|timestamp|date/,`◷`],[/差异|diff/,`±`],[/markdown/,`M↓`],[/图像|图片|image/,`▧`],[/表格|csv|excel/,`▦`],[/颜色|color/,`◐`],[/base64/,`64`],[/hash|哈希/,`#`],[/git/,`⑂`]].find(([e])=>e.test(t))?.[1]??(Array.from(e.name.trim()).slice(0,2).join(``)||`◇`)}function Zw(e){return!!(e&&typeof e==`object`&&e.type===`message.send`)}function Qw(e){let t=[],n=[];for(let r of e)(r.retry?t:n).push(r);return{retry:t,failed:n}}function $w(e){let t=new Map;for(let[n,r]of e.entries())t.has(r.id)||t.set(r.id,n);return t}function eT(e,t){if(!t||t.length===0)return e;let n=new Map(t.map((e,t)=>[e,t])),r=e.filter(e=>n.has(e.id)).sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0));return[...e.filter(e=>!n.has(e.id)),...r]}function tT(e,t,n){if(e.indexOf(t)<0)return[...e];let r=e.filter(e=>e!==t),i=Math.max(0,Math.min(n,r.length));return[...r.slice(0,i),t,...r.slice(i)]}var nT=`super-pi.session-order.v1`;function rT(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.session-order.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}function iT(e){try{typeof window<`u`&&window.localStorage.setItem(nT,JSON.stringify(e))}catch{}}function aT(e,t,n){let r=new Set(e.map(e=>e.id)),i=$w(e),a=(e,t)=>(i.get(e.id)??2**53-1)-(i.get(t.id)??2**53-1),o=new Map,s=[];for(let t of e){let e=t.parentConversationId;if(e&&r.has(e)){let n=o.get(e);n?n.push(t):o.set(e,[t])}else s.push(t)}for(let e of o.values())e.sort(a);let c=eT(s.sort(a),n?.manualRoots),l=[],u=new Set,d=(e,n,r,i=!0)=>{if(u.has(e.id))return;u.add(e.id);let a=o.get(e.id)??[];i&&l.push({conversation:e,depth:Math.min(n,8),childCount:a.length,isLastSibling:r});let s=!i||t.has(e.id);for(let[e,t]of a.entries())d(t,n+1,e===a.length-1,!s)};for(let e of c)d(e,0,!1);let f=e.filter(e=>!u.has(e.id)).sort(a);for(let e of f)d(e,0,!1);return l}var oT=`super-pi:tool-shortcuts:v1`,sT=new Set([`Control`,`Alt`,`Shift`,`Meta`,`AltGraph`,`CapsLock`,`Fn`,`FnLock`,`Hyper`,`Super`,`Symbol`,`SymbolLock`]),cT=new Set([`Escape`]),lT=new Set([`Enter`,` `,`Tab`]),uT={" ":`Space`,ArrowUp:`↑`,ArrowDown:`↓`,ArrowLeft:`←`,ArrowRight:`→`,Escape:`Esc`},dT={ctrl:`⌃`,alt:`⌥`,shift:`⇧`,meta:`⌘`};function fT(e){if(e===` `)return` `;let t=e.trim();return t?t.length===1?t.toLowerCase():t:``}function pT(e){return sT.has(e)}function mT(e){let t=e.key;if(!t||t===`Unidentified`||t===`Dead`||pT(t))return;let n=fT(t);if(!n)return;let r=!!e.shiftKey;if(r&&n.length===1&&!/[a-z]/.test(n)){let t=/^Digit([0-9])$/.exec(e.code??``);t&&(n=t[1])}let i={key:n};return e.ctrlKey&&(i.ctrl=!0),e.altKey&&(i.alt=!0),r&&(i.shift=!0),e.metaKey&&(i.meta=!0),i}function hT(e){return uT[e]||(e.length===1||/^f\d{1,2}$/.test(e)?e.toUpperCase():e)}function gT(e){let t=[];return e.ctrl&&t.push(`Ctrl`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),e.meta&&t.push(`Meta`),t.push(hT(e.key)),t.join(`+`)}function _T(e){let t=``;return e.ctrl&&(t+=dT.ctrl),e.alt&&(t+=dT.alt),e.shift&&(t+=dT.shift),e.meta&&(t+=dT.meta),t+hT(e.key)}function vT(e,t){return e.key===t.key&&!!e.ctrl==!!t.ctrl&&!!e.alt==!!t.alt&&!!e.shift==!!t.shift&&!!e.meta==!!t.meta}function yT(e){return!!(e.ctrl||e.alt||e.shift||e.meta)}function bT(e){return e.key?cT.has(e.key)?{ok:!1,reason:`Esc 是所有弹窗的退出键,不能拿来当工具快捷键。`}:!yT(e)&&lT.has(e.key)?{ok:!1,reason:`「${xT(e.key)}」是当前焦点控件的激活键,加一个修饰键(Ctrl / Alt / Shift)才能当快捷键用。`}:{ok:!0}:{ok:!1,reason:`这个组合键不完整,请按一个具体的键。`}}function xT(e){return hT(e)}function ST(e){let t=e;if(!t||typeof t!=`object`)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable===!0}function CT(e,t){if(t.isComposing||t.defaultPrevented)return!1;let n=mT(t);return!(!n||!vT(e,n)||!yT(e)&&ST(t.target??null))}function wT(e){if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||typeof r!=`object`||!r)continue;let t=r,i=fT(typeof t.key==`string`?t.key:``);if(!i)continue;let a={key:i};t.ctrl===!0&&(a.ctrl=!0),t.alt===!0&&(a.alt=!0),t.shift===!0&&(a.shift=!0),t.meta===!0&&(a.meta=!0),bT(a).ok&&(n[e]=a)}return n}function TT(e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];if(!r)continue;let i={key:r.key};r.ctrl&&(i.ctrl=!0),r.alt&&(i.alt=!0),r.shift&&(i.shift=!0),r.meta&&(i.meta=!0),t[n]=i}return JSON.stringify(t)}function ET(e,t,n){for(let[r,i]of Object.entries(e))if(r!==n&&vT(i,t))return r}var DT=`super-pi:tool-settings-size:v1`,OT={width:480,height:320};function kT(){try{if(typeof window>`u`)return vn.slice();let e=wn(window.localStorage.getItem(xn));return window.localStorage.getItem(`super-pi:tools:v1`)===null?vn.slice():e}catch{return vn.slice()}}function AT(e){try{if(typeof window>`u`)return;window.localStorage.setItem(xn,Tn(e))}catch{}}function jT(){try{return typeof window>`u`?{}:wT(window.localStorage.getItem(oT))}catch{return{}}}function MT(e){try{if(typeof window>`u`)return;window.localStorage.setItem(oT,TT(e))}catch{}}function NT(e,t,n){let r={};for(let n of t)e[n.id]&&(r[n.id]=e[n.id]);for(let e of n)e.shortcut&&(r[e.id]=e.shortcut);return r}function PT(){try{if(typeof window>`u`)return;let e=window.localStorage.getItem(DT);if(!e)return;let t=JSON.parse(e);return typeof t?.width!=`number`||typeof t?.height!=`number`||!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<OT.width||t.height<OT.height?void 0:{width:Math.round(t.width),height:Math.round(t.height)}}catch{return}}function FT(e){try{if(typeof window>`u`)return;e?window.localStorage.setItem(DT,JSON.stringify({width:Math.round(e.width),height:Math.round(e.height)})):window.localStorage.removeItem(DT)}catch{}}function IT(e,t,n){let r=Math.max(OT.width,t-32),i=Math.max(OT.height,n-32);return{width:Math.round(Math.min(Math.max(e.width,OT.width),r)),height:Math.round(Math.min(Math.max(e.height,OT.height),i))}}var LT=jT(),RT={tools:kT(),mountedTools:[],settingsOpen:!1,shortcuts:{}};RT.shortcuts=NT(LT,RT.tools,RT.mountedTools);var zT=new Set;function BT(e){RT={...RT,...e};for(let e of zT)e()}function VT(e){return zT.add(e),()=>{zT.delete(e)}}var HT=()=>RT;function UT(){return(0,u.useSyncExternalStore)(VT,HT,HT)}var WT={setTools(e){AT(e);let t=new Set(e.map(e=>e.id));LT=Object.fromEntries(Object.entries(LT).filter(([e])=>t.has(e))),MT(LT),BT({tools:e,shortcuts:NT(LT,e,RT.mountedTools)})},removeTool(e){let t=kn(RT.tools,e);LT[e]&&(LT={...LT},delete LT[e],MT(LT)),AT(t),BT({tools:t,shortcuts:NT(LT,t,RT.mountedTools),openToolId:RT.openToolId===e?void 0:RT.openToolId})},setMountedTools(e){let t=new Set(RT.tools.map(e=>e.id));LT=Object.fromEntries(Object.entries(LT).filter(([e])=>t.has(e))),MT(LT),BT({mountedTools:e,shortcuts:NT(LT,RT.tools,e)})},openTool(e){BT({openToolId:e,settingsOpen:!1})},closeTool(){BT({openToolId:void 0})},toggleTool(e){RT.openToolId===e?WT.closeTool():WT.openTool(e)},openSettings(){BT({settingsOpen:!0,openToolId:void 0})},closeSettings(){BT({settingsOpen:!1})},async setShortcut(e,t){let n=RT.mountedTools.find(t=>t.id===e);if(n){try{let e=await Ae(`/api/tools/shortcut`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({slug:n.slug,shortcut:t})}),r=await e.json();if(!e.ok)return r.error??`快捷键保存失败(HTTP ${e.status})。`}catch(e){return e instanceof Error?e.message:String(e)}BT({mountedTools:RT.mountedTools.map(n=>n.id===e?{...n,shortcut:t}:n),shortcuts:{...RT.shortcuts,[e]:t}})}else LT={...LT,[e]:t},MT(LT),BT({shortcuts:NT(LT,RT.tools,RT.mountedTools)})},async clearShortcut(e){if(!RT.shortcuts[e])return;let t=RT.mountedTools.find(t=>t.id===e);if(t){try{let e=await Ae(`/api/tools/shortcut`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({slug:t.slug,shortcut:null})}),n=await e.json();if(!e.ok)return n.error??`快捷键清除失败(HTTP ${e.status})。`}catch(e){return e instanceof Error?e.message:String(e)}BT({mountedTools:RT.mountedTools.map(t=>t.id===e?{...t,shortcut:void 0}:t),shortcuts:Object.fromEntries(Object.entries(RT.shortcuts).filter(([t])=>t!==e))})}else LT={...LT},delete LT[e],MT(LT),BT({shortcuts:NT(LT,RT.tools,RT.mountedTools)})},persistTools(){AT(RT.tools)}};async function GT(){let e=le();try{let t=await Ae(`/api/tools`),n=await t.json();le()===e&&t.ok&&Array.isArray(n.tools)&&WT.setMountedTools(n.tools.filter(e=>e.enabled))}catch{}}async function KT(e){try{let t=await Ae(`/api/tools?id=${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);WT.closeTool(),await GT();return}catch(e){return e instanceof Error?e.message:String(e)}}var qT=`.super-pi-tool.json`,JT=512e3,YT=/^[a-z0-9][a-z0-9-]{0,63}$/,XT=/^[A-Za-z0-9][A-Za-z0-9_.-]*==[^=\s,;<>|'"`\\]{1,80}$/;function ZT(e,t){let n;try{n=JSON.parse(e)}catch{return{ok:!1,reason:`「${t}」不是 JSON。确认一下选的是别人分享的工具文件(${qT})。`}}if(!n||typeof n!=`object`||Array.isArray(n))return{ok:!1,reason:`这个 JSON 不是一个工具包。`};let r=n,i;try{i=Yw(r.glyph)}catch{return{ok:!1,reason:`工具图标须为 1 至 4 个字符的文字或符号。`}}let a=typeof r.format==`string`?r.format:void 0;if(a!==void 0&&a!==`super-pi.tool`)return{ok:!1,reason:`这不是 Super Pi 的工具文件(format: ${a})。`};if(typeof r.version==`number`&&r.version>1)return{ok:!1,reason:`这个工具文件是更新版本的 Super Pi 导出的(version: ${r.version}),当前版本读不了。`};let o=typeof r.slug==`string`?r.slug.trim():``,s=typeof r.name==`string`?r.name.trim():``;if(!o)return{ok:!1,reason:`这个工具包里没有 slug(那是它的短名字,也是它在磁盘上的目录名)。`};if(!s)return{ok:!1,reason:`这个工具包里没有名字。`};if(!Array.isArray(r.files)||!r.files.length)return{ok:!1,reason:`这个工具包里没有文件。`};if(r.files.length>32)return{ok:!1,reason:`文件太多了:${r.files.length} 个,上限 32 个。`};let c=[],l=0;for(let e of r.files){let t=e;if(!t||typeof t.path!=`string`||typeof t.content!=`string`)return{ok:!1,reason:`工具包里的文件项格式不对(每一项都要有 path 和 content)。`};let n=t.path.trim();if(!n||n.startsWith(`/`)||n.includes(`\\`)||n.includes(`\0`)||n.split(`/`).includes(`..`))return{ok:!1,reason:`文件路径「${n}」不合法:不能是绝对路径,也不能跳出工具自己的目录。`};if(c.some(e=>e.path===n))return{ok:!1,reason:`工具包里有重复的文件:${n}`};if(l+=new TextEncoder().encode(t.content).length,l>512e3)return{ok:!1,reason:`工具文件合计超过 ${aE(JT)} 的上限。`};c.push({path:n,content:t.content})}let u=typeof r.entrypoint==`string`&&r.entrypoint.trim()?r.entrypoint.trim():`index.html`;if(!u.endsWith(`.html`))return{ok:!1,reason:`入口文件必须是一个 HTML 文件。`};if(!c.some(e=>e.path===u))return{ok:!1,reason:`工具包里没有包含入口文件 ${u}。`};let d;if(r.script!==void 0&&r.script!==null){let e=r.script,t=typeof e.path==`string`?e.path.trim():``;if(!t.endsWith(`.py`))return{ok:!1,reason:`工具包声明的脚本必须是一个 .py 文件。`};if(!c.some(e=>e.path===t))return{ok:!1,reason:`工具包里没有包含它声明的脚本 ${t}。`};d={path:t,timeoutMs:typeof e.timeoutMs==`number`?e.timeoutMs:void 0,parameters:typeof e.parameters==`object`&&e.parameters!==null?e.parameters:void 0}}let f;if(r.environment!==void 0&&r.environment!==null){let e=r.environment,t=e.requires;if(t!==void 0&&!Array.isArray(t))return{ok:!1,reason:`工具包声明的依赖列表格式不对(requires 必须是数组)。`};if(Array.isArray(t)){for(let e of t)if(typeof e!=`string`||!XT.test(e.trim()))return{ok:!1,reason:`依赖必须钉死到精确版本(写成 pkg==version):${String(e).slice(0,60)}。`}}let n=e.fingerprint&&typeof e.fingerprint==`object`?e.fingerprint:void 0;f={requiresPython:typeof e.requiresPython==`string`?e.requiresPython:void 0,requires:Array.isArray(t)?t.map(e=>String(e).trim()):void 0,fingerprint:n}}let p=r.permissions&&typeof r.permissions==`object`&&r.permissions.llm===!0?{llm:!0}:void 0;return{ok:!0,unnamedFormat:a===void 0,bundle:{...a===void 0?{}:{format:a},...typeof r.version==`number`?{version:r.version}:{},...typeof r.exportedAt==`string`?{exportedAt:r.exportedAt}:{},slug:o,name:s,...i?{glyph:i}:{},...typeof r.description==`string`&&r.description.trim()?{description:r.description.trim().slice(0,500)}:{},entrypoint:u,files:c,script:d,environment:f,...p?{permissions:p}:{}}}}function QT(e){let t=e.trim().toLowerCase();return t?YT.test(t)?{ok:!0,slug:t}:{ok:!1,reason:`slug 只能用小写字母、数字和连字符,且要以字母或数字开头。`}:{ok:!1,reason:`请填写 slug(工具的短名字,只能用小写字母、数字和连字符)。`}}function $T(e,t){let n=e.trim().toLowerCase().slice(0,60).replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``)||`tool`;if(!t.includes(n))return n;for(let e=2;e<100;e+=1){let r=`${n}-${e}`;if(!t.includes(r))return r}return n}function eE(e){return`${e.slug}${qT}`}function tE(e){let t=e.trim().replace(/[\\/:*?"<>|]/g,``).replace(/\.+$/,``).trim();return t?t.length>80?{ok:!1,reason:`文件名太长了,请控制在 80 个字符以内。`}:{ok:!0,name:t.endsWith(`.super-pi-tool.json`)?t:`${t}${qT}`}:{ok:!1,reason:`请填写文件名。`}}function nE(e){if(e.permissions?.llm)return{tone:`warn`,text:`这个工具可以调用模型:它能把内容发给你的模型回答,每次调用都会用你的模型额度`}}function rE(e){let t=e.environment?.requires??[];return!e.script&&t.length===0?{tone:`ok`,text:`纯页面工具 · 导入即用,不需要 Python`}:t.length===0?{tone:`ok`,text:`只用 Python 标准库 · 导入即用,不需要安装任何包${e.environment?.requiresPython?`(需要 Python ${e.environment.requiresPython})`:``}`}:{tone:`warn`,text:`首次运行时会安装 ${t.length} 个依赖:${t.join(`、`)}(装进这个工具自己的虚拟环境)${e.environment?.requiresPython?` · 需要 Python ${e.environment.requiresPython}`:``}`}}function iE(e){if(e)return e.state===`zero-deps`?{text:`零依赖`,warn:!1}:e.state===`ready`?{text:`环境就绪`,warn:!1}:e.state===`needs-env`?{text:`首次运行时安装依赖`,warn:!1}:e.state===`needs-python`?{text:`缺少可用的 Python`,warn:!0}:{text:`与导出方环境不一致`,warn:!0}}function aE(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function oE(e,t){let{format:n,version:r,exportedAt:i,...a}=e;return{...a,slug:t}}function sE(e){return!Number.isFinite(e)||e<=0?``:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function cE(e){return!Number.isFinite(e)||e<=0?``:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function lE(e,t){if(!e)return 0;let n=0;for(let r of t)n+=e[r]??0;return n}var uE=128e3;function dE(e){let t=[[]],n=0,r=0,i=[0,0],a=e=>{for(;t.length<=e;)t.push([])},o=e=>{let i=t[n];for(;i.length<r;)i.push(` `);for(let t of e)i[r]=t,r+=1},s=e=>e.replace(/^[?>!]/u,``).split(`;`).map(e=>Number.parseInt(e,10)||0),c=(e,o)=>{let c=s(e),l=Math.max(1,c[0]||1);switch(o){case`A`:n=Math.max(0,n-l);break;case`B`:case`e`:n+=l,a(n);break;case`C`:case`a`:r+=l;break;case`D`:r=Math.max(0,r-l);break;case`E`:n+=l,a(n),r=0;break;case`F`:n=Math.max(0,n-l),r=0;break;case`G`:case"`":r=Math.max(0,l-1);break;case`d`:n=Math.max(0,l-1),a(n);break;case`H`:case`f`:n=Math.max(0,l-1),a(n),r=Math.max(0,(c[1]||1)-1);break;case`K`:{let e=t[n];(c[0]??0)===2?t[n]=[]:(c[0]??0)===1?t[n]=[...Array.from({length:Math.min(r+1,e.length)},()=>` `),...e.slice(r+1)]:e.splice(r);break}case`J`:(c[0]??0)===2||(c[0]??0)===3?(t.splice(0,t.length,[]),n=0,r=0):(c[0]??0)===0?t.splice(n+1):(c[0]??0)===1&&(t.splice(0,n),n=0,t[0]=[]);break;case`s`:i=[n,r];break;case`u`:[n,r]=i,a(n);break;case`P`:t[n].splice(r,l);break;case`X`:{let e=t[n];for(let t=r;t<Math.min(e.length,r+l);t+=1)e[t]=` `;break}case`@`:t[n].splice(r,0,...Array.from({length:l},()=>` `))}},l=t=>{for(let n=t;n<e.length;n+=1){if(e[n]===`\x07`)return n+1;if(e[n]===`\x1B`&&e[n+1]===`\\`)return n+2}return e.length};for(let t=0;t<e.length;){let i=e[t];if(i===``||i===``||i===``||i===``){t=l(t+1);continue}if(i===`\x1B`||i===``){let n=e[t+1];if(i===`\x1B`&&(n===`]`||n===`P`||n===`^`||n===`_`)){t=l(t+2);continue}if(i===`\x1B`&&n===`[`||i===``){let n=t+(i===``?1:2),r=n;for(;r<e.length&&!(e.charCodeAt(r)>=64&&e.charCodeAt(r)<=126);)r+=1;r<e.length&&c(e.slice(n,r),e[r]),t=Math.min(e.length,r+1);continue}t+=n===void 0?1:2;continue}if(i===`\r`){t+=1,r=0;continue}if(i===`
|
|
331
|
+
`){t+=1,n+=1,a(n),r=0;continue}if(i===`\b`){t+=1,r=Math.max(0,r-1);continue}if(i===` `){t+=1,o(` `.repeat(8-r%8));continue}let s=e.codePointAt(t)??0;if(s<32||s===127||s>=128&&s<=159){t+=s>65535?2:1;continue}let u=String.fromCodePoint(s);o(u),t+=u.length}return t.map(e=>e.join(``)).join(`
|
|
332
|
+
`).replace(/\n+$/u,``)}function fE(e){return[e.partialOutput??e.output,...(e.toolCalls??[]).map(e=>e.output)].filter(Boolean).join(`
|
|
333
|
+
|
|
334
|
+
`)}var pE=95e3;function mE(e){let t=`归档整棵会话树「${e.title}」?本次将归档 ${e.activeCount} 个会话(1 个根会话和 ${e.activeDescendants} 个活跃子孙)${e.alreadyArchived?`,跳过 ${e.alreadyArchived} 个已归档子孙`:``};恢复根会话时,整棵树会一起恢复。`;return e.pendingDecisions>0?`${t}\n还有 ${e.pendingDecisions} 个未拍板的决策,归档后它们会作废。`:t}function hE(e){return e.activeDescendants>0||e.pendingDecisions>0}var gE={workspaces:[],conversations:[],subagentRuns:[]},_E=e=>e.nativeEvent.isComposing||e.keyCode===229,vE=(e,t,n)=>{let r=e.filter(e=>(e.role===`user`||e.role===`tool`)&&e.delivery),i=r.findIndex(e=>e.id===t);if(i<0||r[i].delivery===`sending`)return e;let a=r.reduce((e,t,n)=>t.delivery===`sending`?n:e,-1),o=Math.max(a+1,Math.min(n,r.length-1));if(o===i)return e;let s=[...r],[c]=s.splice(i,1);s.splice(o,0,c);let l=[...e],u=0;for(let e=0;e<l.length;e+=1)(l[e].role===`user`||l[e].role===`tool`)&&l[e].delivery&&(l[e]=s[u++]);return l},yE=(e,t)=>{for(let n=e.length-1;n>=0;--n)if(e[n].at===t)return n;return-1},bE=(e,t,n)=>{if(t===void 0)return yE(e,n);let r=e.findIndex(e=>e.blockIndex===t);if(r>=0)return r;let i=e.findIndex(e=>e.blockIndex!==void 0);if(i<0)return yE(e,n);let a=t-((e[i].blockIndex??0)-i);return a>=0&&a<e.length?a:-1},xE=(e,t,n)=>{let r=t.at??n,i=[...e],a=bE(i,t.blockIndex,r);return a>=0?i[a]={...i[a],text:i[a].text+t.delta,blockIndex:t.blockIndex??i[a].blockIndex}:i.push({at:r,text:t.delta,blockIndex:t.blockIndex}),i},SE=(e,t)=>{let n=e??[],r=t??[];return r.length>n.length?r:e},CE=e=>{if(typeof e!=`string`||e.length===0)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`}).format(t)},wE=6e4,TE=60*wE,EE=24*TE,DE=7*EE,OE=30*EE,kE=365*EE,AE=(e,t)=>{let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=t-n.getTime();return r<3e4?`now`:r<TE?`${Math.max(1,Math.floor(r/wE))}m ago`:r<EE?`${Math.floor(r/TE)}h ago`:r<DE?`${Math.floor(r/EE)}d ago`:r<OE?`${Math.floor(r/DE)}w ago`:r<kE?`${Math.floor(r/OE)}mo ago`:`${Math.floor(r/kE)}y ago`},jE=(e,t)=>{let n=e.find(e=>e.id===t);if(!n)return[];let r=new Map;for(let t of e){if(t.workspaceId!==n.workspaceId||!t.parentConversationId)continue;let e=r.get(t.parentConversationId);e?e.push(t):r.set(t.parentConversationId,[t])}let i=[],a=new Set,o=e=>{if(!a.has(e.id)){a.add(e.id),i.push(e);for(let t of r.get(e.id)??[])o(t)}};return o(n),i},ME=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`};function NE({workspace:e,x:t,y:n,notify:r,onClose:i}){let a=(0,u.useRef)(null),[o,s]=(0,u.useState)({left:t,top:n});(0,u.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let r=e.getBoundingClientRect();s({left:Math.max(8,Math.min(t,window.innerWidth-r.width-8)),top:Math.max(8,Math.min(n,window.innerHeight-r.height-8))})},[t,n]),(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())},t=e=>{a.current?.contains(e.target)||i()},n={x:window.scrollX,y:window.scrollY,width:window.innerWidth,height:window.innerHeight},r=()=>{(window.scrollX!==n.x||window.scrollY!==n.y)&&i()},o=()=>{(window.innerWidth!==n.width||window.innerHeight!==n.height)&&i()};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`pointerdown`,t,!0),window.addEventListener(`scroll`,r,!0),window.addEventListener(`resize`,o),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`resize`,o)}},[i]);let c=async()=>{let t=await ju(e.path);i(),t?r(`已复制工作区路径:${e.path}`,`info`):r(`复制失败:浏览器拒绝了剪贴板写入,可以手动选中路径复制`,`error`)};return(0,F.jsxs)(`div`,{ref:a,className:`ctx-menu`,role:`menu`,"data-ctx-menu":`1`,"data-workspace-id":e.id,style:{left:o.left,top:o.top},onContextMenu:e=>e.preventDefault(),onPointerDown:e=>e.stopPropagation(),children:[(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item`,"data-copy-workspace-path":e.id,onClick:()=>void c(),children:`复制工作区路径`}),(0,F.jsx)(`div`,{className:`ctx-menu-hint`,"aria-hidden":`true`,children:e.path})]})}function PE({conversation:e,x:t,y:n,notify:r,onRename:i,onClose:a,sendCommand:o,orchestrated:s,childCount:c}){let l=(0,u.useRef)(null),[d,f]=(0,u.useState)({left:t,top:n});(0,u.useLayoutEffect)(()=>{let e=l.current;if(!e)return;let r=e.getBoundingClientRect();f({left:Math.max(8,Math.min(t,window.innerWidth-r.width-8)),top:Math.max(8,Math.min(n,window.innerHeight-r.height-8))})},[t,n]),(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),a())},t=e=>{l.current?.contains(e.target)||a()},n={x:window.scrollX,y:window.scrollY,width:window.innerWidth,height:window.innerHeight},r=()=>{(window.scrollX!==n.x||window.scrollY!==n.y)&&a()},i=()=>{(window.innerWidth!==n.width||window.innerHeight!==n.height)&&a()};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`pointerdown`,t,!0),window.addEventListener(`scroll`,r,!0),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`resize`,i)}},[a]);let p=async e=>{try{let t=await Ae(`/api/orchestrator/stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`,conversationId:e,mode:`all`})}),n=await t.json();if(!t.ok)throw Error(n.error);r(`已停止会话(含排队消息)`,`info`)}catch(e){r(`停止失败:${ct(e)}`,`error`)}},m=async e=>{try{let t=await Ae(`/api/orchestrator/stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`,conversationId:e,mode:`all`,subtree:!0})}),n=await t.json();if(!t.ok)throw Error(n.error);let i=typeof n.descendantCount==`number`?n.descendantCount:0;r(i>0?`已停止会话及其下属 ${i} 个`:`已停止会话(它没有下属会话)`,`info`)}catch(e){r(`停止子树失败:${ct(e)}`,`error`)}},h=async()=>{let t=await ju(e.id);a(),t?r(`已复制会话 ID:${e.id}`,`info`):r(`复制失败:浏览器拒绝了剪贴板写入`,`error`)};return(0,F.jsxs)(`div`,{ref:l,className:`ctx-menu`,role:`menu`,"data-ctx-menu":`1`,"data-session-id":e.id,style:{left:d.left,top:d.top},onContextMenu:e=>e.preventDefault(),onPointerDown:e=>e.stopPropagation(),children:[(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item`,"data-copy-session-id":e.id,onClick:()=>void h(),children:`复制会话 ID`}),(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item`,"data-ai-rename-session":e.id,onClick:()=>{a(),i()},children:`AI 智能重命名`}),![`running`,`waiting`,`awaiting_background`].includes(e.status)&&(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item`,"data-save-warm-session":e.id,onClick:()=>{a();let t=window.prompt(`保存为当前工作区的预热会话。以后选用时会带上当前对话历史。`,e.title)?.trim();t&&!o({type:`conversation.warm.save`,conversationId:e.id,title:t})&&r(`连接断开,未保存预热会话`,`error`)},children:`保存为预热会话`}),(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item`,"data-stop-turn-session":e.id,onClick:()=>{a(),o({type:`run.stop`,conversationId:e.id})},children:`停止当前回合`}),s&&(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item ctx-menu-item-danger`,"data-stop-session-queue":e.id,onClick:()=>{a(),p(e.id)},children:`停止会话(含排队消息)`}),c>0&&(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item ctx-menu-item-danger`,"data-stop-session-tree":e.id,onClick:()=>{a(),m(e.id)},children:[`停止整棵子树(`,c,` 个下属)`]}),(0,F.jsx)(`div`,{className:`ctx-menu-hint`,"aria-hidden":`true`,children:e.id})]})}var FE={model:`模型`,thinking:`思考`,agent:`智能体`,subagent:`子智能体`},IE=`请从刚才被截断的地方接着写完,不要重复已经写过的内容。`,LE={model:`模型`,thinking:`思考等级`,agent:`智能体`,subagent:`子智能体`},RE={model:`没有可用的模型`,thinking:`Pi 没有给出当前模型的思考等级`,agent:`没有可用的智能体`,subagent:`没有可用的子智能体`},zE={model:`选择模型`,thinking:`选择思考等级`,agent:`选择智能体`,subagent:`选择子智能体`},BE=`图文`,VE=e=>e.imageInput?BE:void 0,HE=e=>e.normalize(`NFKD`).replace(/\p{M}/gu,``).toLowerCase(),UE=(e,t)=>{let n=HE(t.trim());return n?e.filter(e=>HE(`${e.label} ${e.detail??``} ${e.badge??``}`).includes(n)):e};function WE({workspaceId:e,value:t,onChange:n}){let[r,i]=(0,u.useState)([]),[a,o]=(0,u.useState)(``);(0,u.useEffect)(()=>{i([]),o(``)},[e]),(0,u.useEffect)(()=>{let n=!0;return o(``),Ae(`/api/files?workspaceId=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`).then(async e=>{let r=await e.json();if(!e.ok)throw Error(r.error??`HTTP ${e.status}`);if(!n)return;let a=(r.entries??[]).filter(e=>e.kind===`directory`).map(e=>e.path);i(e=>[...new Set([...e,t,...a])].filter(Boolean).sort())}).catch(e=>{n&&o(e instanceof Error?e.message:`子目录读取失败`)}),()=>{n=!1}},[e,t]);let s=[...new Set([...r,t])].filter(Boolean).sort();return(0,F.jsxs)(`div`,{className:`empty-workspace-select`,children:[(0,F.jsx)(`label`,{htmlFor:`empty-session-cwd`,children:`工作目录:`}),(0,F.jsxs)(`select`,{id:`empty-session-cwd`,"data-session-cwd-select":`1`,"aria-label":`会话工作目录(可选)`,value:t,onChange:e=>n(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`工作区根目录`}),s.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]}),a&&(0,F.jsx)(`span`,{role:`status`,children:a})]})}function GE({workspace:e,onClose:t,onCreate:n}){let[r,i]=(0,u.useState)(``),a=(0,u.useRef)(null);return(0,u.useEffect)(()=>{i(``)},[e.id]),(0,u.useEffect)(()=>{let e=a.current;e&&e.focus();let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t]),(0,F.jsx)(`div`,{className:`overlay session-create-overlay`,onClick:t,children:(0,F.jsxs)(`div`,{className:`session-create-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`session-create-title`,tabIndex:-1,ref:a,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=a.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),i.focus()):document.activeElement===i&&(e.preventDefault(),r.focus())},children:[(0,F.jsx)(`h2`,{id:`session-create-title`,children:`新建会话`}),(0,F.jsxs)(`p`,{className:`session-create-workspace`,children:[`工作区:`,e.name,(0,F.jsx)(`small`,{children:e.path})]}),(0,F.jsx)(WE,{workspaceId:e.id,value:r,onChange:i}),(0,F.jsxs)(`div`,{className:`session-create-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`session-create-cancel`,onClick:t,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`session-create-confirm picker-ok`,onClick:()=>n(r),children:`创建会话`})]})]})})}function KE({onClose:e,onCreate:t}){let{connections:n,activeServer:r}=se(),i=(0,u.useRef)(0),[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(!0),[l,d]=(0,u.useState)(),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(``),g=async e=>{let t=++i.current;c(!0),d(void 0);try{let n=await Ae(`/api/fs/dirs${e?`?path=${encodeURIComponent(e)}`:``}`),r=await n.json();if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);if(t!==i.current)return;let a=r;o(a),h(a.path),p(a.suggestedName)}catch(e){d(e instanceof Error?e.message:`目录加载失败`)}finally{c(!1)}};(0,u.useEffect)(()=>{o(void 0),h(``),g()},[r]),(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let _=e=>{e?.preventDefault();let t=m.trim();t&&g(t)};return(0,F.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,F.jsxs)(`div`,{className:`picker workspace-picker`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`h2`,{children:`选择工作区目录`}),(0,F.jsxs)(`label`,{className:`server-settings-scope`,children:[`目标服务器`,(0,F.jsx)(`select`,{"aria-label":`新建工作区的服务器`,value:r,onChange:e=>ge(e.target.value),children:n.filter(e=>e.enabled).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,F.jsxs)(`form`,{className:`picker-path-bar`,onSubmit:_,children:[(0,F.jsx)(`input`,{className:`picker-path-input`,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(_E(e)?e.preventDefault():(e.preventDefault(),_()))},placeholder:`输入或粘贴目录绝对路径(如 D:\\projects 或 ~/code)`}),(0,F.jsx)(`button`,{type:`submit`,className:`picker-go-btn`,disabled:!m.trim()||s,children:`跳转`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-up-btn`,disabled:!a?.parent||s,onClick:()=>a?.parent&&void g(a.parent),title:`返回上一级目录`,children:`上一级`})]}),a?.drives?.length||a?.homeDir?(0,F.jsxs)(`div`,{className:`picker-shortcuts`,children:[(0,F.jsx)(`span`,{className:`picker-shortcuts-label`,children:`快捷位置:`}),a?.homeDir&&(0,F.jsx)(`button`,{type:`button`,className:`picker-shortcut`,onClick:()=>void g(`~`),title:a.homeDir,children:`🏠 主目录`}),a?.drives?.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`picker-shortcut`,onClick:()=>void g(e),children:e},e))]}):null,(0,F.jsxs)(`div`,{className:`picker-list`,children:[s&&(0,F.jsx)(`div`,{className:`picker-status`,children:`加载中…`}),!s&&l&&(0,F.jsxs)(`div`,{className:`picker-error`,children:[l,(0,F.jsx)(`button`,{onClick:()=>void g(a?.path||m),children:`重试`})]}),!s&&!l&&a?.entries.map(e=>(0,F.jsxs)(`button`,{className:`picker-dir`,onClick:()=>void g(e.path),children:[`📁 `,e.name]},e.path)),!s&&!l&&a&&a.entries.length===0&&(0,F.jsx)(`div`,{className:`picker-status`,children:`此目录下没有子目录`}),!s&&!l&&a?.truncated&&(0,F.jsx)(`div`,{className:`picker-status`,children:`目录过多,仅显示前 2000 项`})]}),(0,F.jsxs)(`label`,{className:`picker-name`,children:[`工作区名称`,(0,F.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(_E(e)?e.preventDefault():(e.preventDefault(),f.trim()&&a&&t(f.trim(),a.path)))},placeholder:`工作区名称`})]}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{className:`picker-cancel`,onClick:e,children:`取消`}),(0,F.jsx)(`button`,{className:`picker-ok`,disabled:!f.trim()||s||!!l||!a,onClick:()=>a&&t(f.trim(),a.path),children:`使用这个目录`})]})]})})}var qE={timeout:`扩展提问超时,已取消`,aborted:`运行已停止,扩展提问已取消`,expired:`运行已结束,扩展提问已取消`},JE=10;function YE(e,t,n=!1){if(!t)return`正在从 Pi 读取${e}列表…`;if(t.source!==`pi`)return`读取 Pi ${e}列表失败:${t.error??`未知原因`}`;if(t.configError)return`Pi 拒绝了自己的模型配置,文件里的自定义供应商都没有被提供:${t.configError.split(`
|
|
335
|
+
`).find(e=>e.trim().startsWith(`-`))?.trim()??`详情见设置`}`;if(e===`模型`&&n)return`此会话已包含图片,仅显示支持图文的模型`;if(e===`思考等级`&&!t.levels.length)return`Pi 没有给出当前模型的思考等级`}function XE(e){if(!e)return`正在读取 agent 列表…`;if(e.source!==`directory`)return`读取 agent 列表失败:${e.error??`未知原因`}`;if(e.problems.length)return`${e.problems.length} 个 agent 文件无法使用:${e.problems.map(e=>e.file).join(`、`)}`;if(!e.agents.length)return`${e.directory} 下没有 primary agent`}var ZE=e=>Math.abs(e)<1e3?String(e):`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`;function QE(e){if(e===void 0||!Number.isFinite(e))return``;let t=Math.max(0,e);return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.floor(t/6e4)}分${Math.round(t%6e4/1e3)}秒`}var $E={dispatch:`派发时(子进程还没起来)`,prompt:`派活时(Pi 拒收了任务)`,turn:`生成回答时`,tool:`调用工具时`,settle:`收尾时`};function eD(e){return e.replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/g,``).replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,``).replace(/\u001b[@-_]/g,``).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g,``).split(/\r?\n/).map(e=>e.trim()).filter(Boolean).at(-1)??``}function tD(e,t){let[n,r]=(0,u.useState)(()=>t.get(e));return(0,u.useEffect)(()=>{r(t.get(e));let n,i=i=>{i.detail===e&&n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,r(t.get(e))}))};return window.addEventListener(`super-pi-exec-output`,i),()=>{window.removeEventListener(`super-pi-exec-output`,i),n!==void 0&&cancelAnimationFrame(n)}},[e,t]),n}function nD({task:e,execOutputs:t,expanded:n}){let r=tD(e.id,t),i=e.status===`running`?r?.text||e.output:e.output??r?.text,a=i&&dE(i),o=e.status===`running`?r?.truncated??e.outputTruncated:e.outputTruncated;return(0,F.jsxs)(F.Fragment,{children:[!n&&a&&(0,F.jsx)(`div`,{className:`call-live-preview`,"data-background-preview":e.id,title:`展开调用查看完整输出`,children:eD(a)}),n&&(0,F.jsx)(`pre`,{className:`call-result-body`,"data-background-output":e.id,children:[e.reason,o?`日志仅保留最近一段。`:``,a].filter(Boolean).join(`
|
|
336
|
+
|
|
337
|
+
`)||(e.status===`running`?`等待输出…`:`任务未产生输出。`)})]})}function rD({call:e,index:t,expanded:n,onToggle:r,backgroundOutput:i,runCard:a}){let o=e.args??[];return(0,F.jsxs)(`div`,{className:`call-block call-block-${e.status??`running`}`,"data-call-block":t,"data-call-tool":e.label,"data-call-detail":e.detail??void 0,"data-call-status":e.status??`running`,"data-call-expanded":n?`true`:`false`,"data-call-arg-count":o.length,"data-thinking-at":e.thinkingAt,"data-background-exec":e.backgroundTask?.id,"data-background-status":e.backgroundTask?.status,children:[(0,F.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-call-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`} ${e.label} 调用`,title:n?`折叠这次调用`:`展开这次调用`,onClick:r}),(0,F.jsxs)(`div`,{className:`call-head-row`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:r,children:[(0,F.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`error`?`✕`:e.status===`ok`?`✓`:`·`}),(0,F.jsx)(`span`,{className:`call-label`,title:e.label,children:e.label}),e.detail&&(0,F.jsx)(`span`,{className:`call-detail`,title:e.detail,children:e.detail}),e.durationMs!==void 0&&(0,F.jsx)(`span`,{className:`call-duration`,children:QE(e.durationMs)}),e.backgroundTask&&(0,F.jsxs)(`span`,{className:`call-background-status`,"data-background-status-text":e.backgroundTask.status,children:[`后台任务 · `,MD[e.backgroundTask.status]??`未知状态`,e.backgroundTask.exitCode===void 0?``:` · 退出码:${e.backgroundTask.exitCode}`]}),e.preparing&&(0,F.jsx)(`span`,{className:`call-preparing`,"data-call-preparing":t,children:`生成参数中…`})]}),n&&(0,F.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:r,children:`收起`})]}),!n&&e.live&&(0,F.jsx)(`div`,{className:`call-live-preview`,"data-call-live-preview":t,title:`展开查看完整输出`,children:eD(e.live)}),n&&(0,F.jsx)(`div`,{className:`call-args`,"data-call-args":o.length,children:o.length===0?(0,F.jsx)(`div`,{className:`call-arg call-arg-empty`,"data-call-arg-empty":t,children:`(这次调用没有可显示的参数)`}):o.map(e=>(0,F.jsxs)(`div`,{className:`call-arg`,"data-call-arg":e.key,"data-call-arg-value":e.value,children:[(0,F.jsx)(`span`,{className:`call-arg-key`,children:e.key}),(0,F.jsx)(`span`,{className:`call-arg-value`,title:e.value,children:e.value})]},e.key))}),n&&(e.result||e.live||i)&&(0,F.jsxs)(`div`,{className:`call-result`,"data-call-result":t,"data-call-result-state":e.result?`done`:`running`,children:[(e.result||e.live)&&(0,F.jsxs)(`div`,{className:`call-result-head`,children:[(0,F.jsx)(`span`,{className:`call-result-title`,children:e.result&&!e.live?`执行结果`:e.result?`执行结果 · 完整输出`:`执行中 · 输出预览`}),e.result?(0,F.jsx)(iD,{index:t,text:e.live??e.result.text}):null]}),(e.result||e.live)&&(0,F.jsx)(`pre`,{className:`call-result-body`,"data-call-result-body":t,children:e.live??e.result?.text}),e.result?.truncated&&e.live&&(0,F.jsx)(`div`,{className:`call-result-truncated`,children:`(服务端已截断到末尾 8 KB;上方显示的是执行中累积的完整输出)`}),e.result?.truncated&&!e.live&&(0,F.jsxs)(`div`,{className:`call-result-truncated`,children:[`(输出过长,已保留末尾关键内容`,e.result.droppedLines?`,省略前 ${e.result.droppedLines} 行`:``,`)`]}),i]}),!n&&i,a]})}function iD({index:e,text:t}){let[n,r]=(0,u.useState)(!1);return(0,F.jsx)(`button`,{type:`button`,className:`call-result-copy`,"data-call-result-copy":e,onClick:async()=>{await ju(t)&&(r(!0),window.setTimeout(()=>r(!1),1600))},children:n?`已复制`:`复制`})}function aD({messageId:e,nestedCount:t,liveCall:n,liveAwaitingReader:r,liveExtra:i,preview:a,expanded:o,onToggle:s,children:c}){return(0,F.jsxs)(`section`,{className:`thinking-block`,"data-thinking-block":e,"data-thinking-expanded":o?`true`:`false`,"data-thinking-calls":t,children:[(0,F.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-thinking-fold-edge":e,"aria-expanded":o,"aria-label":`${o?`折叠`:`展开`}这段思考`,title:o?`折叠这段思考`:`展开这段思考`,onClick:s}),(0,F.jsxs)(`button`,{type:`button`,className:`thinking-head`,"data-thinking-head":e,"aria-expanded":o,title:o?`折叠这段思考`:`展开这段思考`,onClick:s,children:[(0,F.jsx)(`span`,{className:`thinking-chevron`,"aria-hidden":`true`,children:o?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`thinking-label`,children:`思考`}),t>0&&(0,F.jsxs)(`span`,{className:`thinking-count`,"data-thinking-count":t,children:[t,` 次工具调用`]}),!o&&n&&(0,F.jsxs)(`span`,{className:`thinking-live${r?` thinking-live-question`:``}`,"data-thinking-live":n,"data-thinking-live-extra":i??0,"data-thinking-awaiting-reader":r?`1`:void 0,children:[(0,F.jsx)(`span`,{className:`thinking-live-glyph`,"aria-hidden":`true`,children:r?`?`:`⚙`}),r?`等你回答`:`正在执行 ${n}`,i?` 等 ${i+1} 个`:``]}),!o&&a&&(0,F.jsx)(`span`,{className:`thinking-preview`,title:a,children:a})]}),o&&(0,F.jsx)(`div`,{className:`thinking-body`,"data-thinking-body":e,children:c})]})}function oD({run:e,name:t,expanded:n,onToggle:r,onStop:i,stopping:a}){let o=e.toolCalls??[],s=n?o:o.slice(-10),c=o.length-s.length,l=e.status===`running`,d=e.partialOutput??e.output??``,f=e.dispatchedBy===`model`,[p,m]=(0,u.useState)(0);(0,u.useEffect)(()=>{if(!l)return;m(Date.now());let e=window.setInterval(()=>m(Date.now()),200);return()=>window.clearInterval(e)},[l,e.startedAt]);let h=Date.parse(e.startedAt),g=l&&p>0&&Number.isFinite(h)?p-h:void 0,_=[...o].reverse().find(e=>e.status===void 0)?.label;return(0,F.jsxs)(`article`,{className:`subagent-card subagent-${e.status}${f?` subagent-by-model`:``}`,"data-subagent-card":e.id,"data-subagent-status":e.status,"data-subagent-agent":e.agentId,"data-subagent-tools":o.length,"data-subagent-dispatched-by":f?`model`:`human`,children:[(0,F.jsxs)(`div`,{className:`subagent-head`,children:[(0,F.jsx)(`span`,{className:`subagent-badge`,children:`子智能体`}),f&&(0,F.jsxs)(`span`,{className:`subagent-source`,"data-subagent-source":`model`,title:`primary 模型自己决定派这个子智能体去干活`,children:[(0,F.jsx)(`span`,{className:`subagent-source-glyph`,"aria-hidden":`true`,children:`⚡`}),`模型自主派发`]}),(0,F.jsx)(`strong`,{className:`subagent-name`,"data-subagent-name":`1`,children:t||e.agentId}),(0,F.jsx)(`span`,{className:`subagent-status`,"data-subagent-status-text":`1`,children:l?`运行中`:e.status===`completed`?`已完成`:e.status===`stopped`?`已停止`:`失败`}),l?g!==void 0&&(0,F.jsxs)(`span`,{className:`subagent-clock`,"data-subagent-elapsed":`1`,"data-subagent-elapsed-ms":g,children:[`已运行 `,QE(g)]}):e.durationMs!==void 0&&(0,F.jsxs)(`span`,{className:`subagent-duration`,"data-subagent-duration":`1`,"data-subagent-duration-ms":e.durationMs,children:[`用时 `,QE(e.durationMs)]}),l&&(0,F.jsx)(`button`,{type:`button`,className:`subagent-stop`,"data-subagent-stop":e.id,disabled:a,onClick:i,children:`停止`})]}),l&&e.activity&&(0,F.jsxs)(`div`,{className:`subagent-activity`,"data-subagent-activity":e.activity.kind,"data-subagent-activity-at":e.activity.at,children:[(0,F.jsx)(`span`,{className:`subagent-activity-dot`,"aria-hidden":`true`}),e.activity.kind===`tool`?`正在调用 ${e.activity.label??`工具`}`:`正在思考…`]}),(0,F.jsxs)(`div`,{className:`subagent-task`,"data-subagent-task":`1`,children:[f&&(0,F.jsx)(`span`,{className:`subagent-task-source`,"data-subagent-model-task":`1`,children:`模型给的任务`}),e.task]}),(0,F.jsxs)(`div`,{className:`subagent-output`,"data-subagent-output":`1`,"data-live-length":d.length,children:[d||(l?`…`:`(没有输出)`),e.outputTruncated&&`(输出已截断)`]}),e.failure&&(0,F.jsxs)(`div`,{className:`subagent-failure`,"data-subagent-failure":`1`,"data-subagent-failure-stage":e.failure.stage,children:[(0,F.jsx)(`span`,{className:`subagent-failure-label`,children:`卡在`}),(0,F.jsx)(`span`,{className:`subagent-failure-stage`,"data-subagent-failure-text":`1`,children:$E[e.failure.stage]}),e.failure.stage===`tool`&&_&&(0,F.jsxs)(`span`,{className:`subagent-failure-tool`,"data-subagent-failure-tool":`1`,children:[`· 正在跑 `,_]}),o.length>0&&(0,F.jsxs)(`span`,{className:`subagent-failure-progress`,children:[`· 死前已尝试 `,o.length,` 次工具调用`]})]}),e.error&&(0,F.jsx)(`div`,{className:`subagent-error`,"data-subagent-error":`1`,title:lt(e.error),children:ct(e.error,`这条子任务没有完成。`)}),o.length>0&&(0,F.jsxs)(`div`,{className:`subagent-tools`,"data-subagent-tool-count":o.length,children:[c>0&&!n&&(0,F.jsxs)(`button`,{type:`button`,className:`subagent-more`,"data-subagent-hidden":c,onClick:r,children:[`… 另有 `,c,` 条工具调用`]}),s.map((e,t)=>(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`subagent-tool${e.status?` subagent-tool-${e.status}`:``}`,"data-subagent-tool":e.label,"data-subagent-tool-detail":e.detail??void 0,"data-subagent-tool-status":e.status??`running`,children:[(0,F.jsx)(`span`,{className:`subagent-tool-glyph`,"aria-hidden":`true`,children:e.status===`error`?`✕`:e.status===`ok`?`✓`:`·`}),(0,F.jsx)(`span`,{className:`subagent-tool-label`,title:e.label,children:e.label}),e.detail&&(0,F.jsx)(`span`,{className:`subagent-tool-detail`,title:e.detail,children:e.detail}),e.durationMs!==void 0&&(0,F.jsx)(`span`,{className:`subagent-tool-duration`,children:QE(e.durationMs)})]}),e.output&&(0,F.jsxs)(`details`,{className:`subagent-tool-log`,children:[(0,F.jsxs)(`summary`,{children:[`命令输出`,e.outputTruncated&&`(尾部)`]}),(0,F.jsx)(`pre`,{className:`call-result-body`,"data-subagent-tool-output":!0,children:e.output})]})]},`${c&&!n?c+t:t}:${e.label}`))]}),e.usage&&(0,F.jsxs)(`div`,{className:`subagent-usage`,"data-subagent-usage":`1`,"data-subagent-turns":e.usage.turns,children:[(0,F.jsxs)(`span`,{children:[e.usage.turns,` 轮`]}),(0,F.jsxs)(`span`,{title:`输入 token`,children:[`↑`,ZE(e.usage.input)]}),(0,F.jsxs)(`span`,{title:`输出 token`,children:[`↓`,ZE(e.usage.output)]}),e.usage.cacheRead>0&&(0,F.jsxs)(`span`,{title:`缓存读取`,children:[`缓存读 `,ZE(e.usage.cacheRead)]}),e.usage.cacheWrite>0&&(0,F.jsxs)(`span`,{title:`缓存写入`,children:[`缓存写 `,ZE(e.usage.cacheWrite)]}),e.usage.cost>0&&(0,F.jsxs)(`span`,{title:`本轮花费`,children:[`$`,e.usage.cost.toFixed(4)]})]}),o.length>10&&(0,F.jsx)(`button`,{type:`button`,className:`subagent-collapse`,"data-subagent-collapse":e.id,"aria-expanded":n,onClick:r,children:n?`收起`:`展开全部 ${o.length} 条`})]})}function sD(e,t=[]){return Array.isArray(t)?t.filter(t=>typeof t?.id==`string`&&(td(e,t.id)||!t.id.startsWith(`skill:`)&&typeof t.name==`string`&&td(e,t.name))):[]}function cD(e){let t=e.deliveryMode===`steer`?`steer`:`queue`;return{type:`message.send`,conversationId:e.conversationId,content:e.content,clientId:e.clientId,...e.images?.length?{images:e.images}:{},...e.attachments?.length?{attachments:e.attachments}:{},...e.inFlight&&t===`steer`?{mode:`steer`}:{}}}function lD({mode:e,onChange:t}){return(0,F.jsxs)(`div`,{className:`composer-delivery-bar`,"data-delivery-mode-bar":`1`,children:[(0,F.jsxs)(`div`,{className:`delivery-mode-group`,role:`radiogroup`,"aria-label":`运行中消息投递模式`,children:[(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`queue`,className:`delivery-mode-btn${e===`queue`?` active`:``}`,"data-delivery-mode":`queue`,title:`等待当前回合与前面排队消息完成后依次回答(默认)`,onClick:()=>t(`queue`),children:`排队`}),(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`steer`,className:`delivery-mode-btn${e===`steer`?` active`:``}`,"data-delivery-mode":`steer`,title:`在当前工具调用完成后的下一回合边界插队回复,不会强行中止正在执行的工具`,onClick:()=>t(`steer`),children:`打断`})]}),(0,F.jsx)(`span`,{className:`delivery-mode-note`,"data-delivery-mode-note":`1`,children:e===`steer`?`将在下一回合边界生效(等当前工具跑完,不强行中止工具)`:`默认排队:等当前回合及前面排队消息完成后回答`})]})}function uD({messages:e,running:t,pendingInterrupts:n=[],onSteer:r,onInterrupt:i,onSend:a,onCancel:o,onCancelMany:s,onEdit:c}){let[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)([]),m=(0,u.useMemo)(()=>e.filter(e=>e.delivery!==`sending`).map(e=>e.id),[e]),h=(0,u.useMemo)(()=>f.filter(e=>m.includes(e)),[f,m]);if(!e.length)return null;let g=e.filter(e=>e.delivery===`sending`).length,_=m.length>0&&h.length===m.length,v=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,F.jsxs)(`section`,{className:`queue-dock`,"data-queue-dock":`1`,"data-interrupt-pending":n.length,"data-queue-count":e.length,"data-queue-sending":g,"aria-label":`排队等待回答的消息`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`queue-dock-head`,"data-queue-collapse":`1`,"aria-expanded":!l,onClick:()=>d(e=>!e),children:[(0,F.jsx)(`span`,{className:`chevron`,children:l?`▸`:`▾`}),(0,F.jsxs)(`strong`,{children:[e.length,` 条等待回答`]}),g>0&&(0,F.jsxs)(`span`,{className:`queue-dock-badge`,"data-queue-badge":`sending`,children:[`已交给 Agent `,g,` 条`]}),l&&(0,F.jsx)(`span`,{className:`queue-dock-preview`,children:dD(e[0])})]}),!l&&s&&(m.length>1||h.length>0)&&(0,F.jsxs)(`div`,{className:`queue-dock-toolbar`,"data-queue-bulk-toolbar":`1`,children:[(0,F.jsx)(`span`,{className:`queue-dock-selected-count`,children:h.length>0?`已选 ${h.length} 条`:`共 ${m.length} 条可多选撤回`}),(0,F.jsxs)(`div`,{className:`queue-dock-toolbar-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`queue-select-all`,"data-waiting-select-all":`1`,onClick:()=>p(_?[]:m),children:_?`取消全选`:`全选`}),(0,F.jsxs)(`button`,{type:`button`,className:`queue-cancel-selected`,"data-waiting-cancel-selected":`1`,disabled:h.length===0,onClick:()=>{h.length!==0&&(s(h),p([]))},children:[`撤回所选 (`,h.length,`)`]})]})]}),!l&&(0,F.jsx)(`ul`,{className:`queue-dock-list`,children:e.map((l,u)=>(0,F.jsx)(pD,{message:l,order:u+1,total:e.length,interrupting:n.includes(l.id),running:t,selectable:!!(s&&l.delivery!==`sending`),selected:h.includes(l.id),onToggleSelect:v,onSteer:r,onInterrupt:i,onSend:a,onCancel:o,onEdit:c},l.id))})]})}function dD(e){return e.content||(e.images?.length?`【图片】(${e.images.length})`:``)}function fD(e){if(e.role!==`tool`)return{label:`后台回传`,state:`completed`};if(!/<task id="[^"]+" state="[^"]+"/.test(e.content))return{label:(e.content.split(`
|
|
338
|
+
`).find(e=>e.trim().length>0)??``).trim().slice(0,60)||`任务指令`,state:`running`};let t=(()=>{let t=/<summary>([\s\S]*?)<\/summary>/.exec(e.content);return t?t[1].trim():`后台回传`})(),n=/<task id="[^"]+" state="([^"]+)"/.exec(e.content);return{label:t,state:n?n[1]:`completed`}}function pD({message:e,order:t,total:n,running:r,interrupting:i=!1,selectable:a=!1,selected:o=!1,onToggleSelect:s,onSteer:c,onInterrupt:l,onSend:d,onCancel:f,onEdit:p}){let[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(e.content),v=e.delivery===`sending`,y=e.source===`session-reminder`,b=e.role===`tool`&&!y,{label:x,state:S}=b?fD(e):{label:dD(e),state:`user`},C=()=>{let t=g.trim();t&&t!==e.content&&p(e.id,t),h(!1)};return(0,F.jsxs)(`li`,{className:`queue-row ${v?`queue-row-sending`:`queue-row-queued`} ${b?`queue-row-bg-result`:``}`,"data-queue-id":e.id,"data-message-delivery":e.delivery,"data-message-role":e.role,"data-bg-result-state":b?S:void 0,"data-waiting-order":t,"data-waiting-total":n,children:[a&&(0,F.jsx)(`input`,{type:`checkbox`,className:`queue-select`,"data-waiting-select":e.id,checked:o,"aria-label":`选择「${x}」`,onChange:()=>s?.(e.id)}),(0,F.jsx)(`span`,{className:`queue-index`,"aria-hidden":`true`,children:t}),y?(0,F.jsxs)(`span`,{className:`queue-reminder`,"data-queue-reminder":!0,children:[(0,F.jsxs)(`span`,{className:`reminder-label`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,F.jsx)(`span`,{className:`queue-text`,title:x,children:x})]}):b?(0,F.jsxs)(`span`,{className:`queue-bg-result`,title:x,children:[(0,F.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:S===`error`?`✕`:`↩`}),(0,F.jsx)(`span`,{className:`bg-result-label`,children:`后台回传`}),(0,F.jsx)(`span`,{className:`bg-result-summary`,children:x})]}):m?(0,F.jsxs)(`div`,{className:`queue-row-edit`,children:[(0,F.jsx)(`textarea`,{value:g,autoFocus:!0,rows:2,"aria-label":`修改这条等待中的消息`,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),_(e.content),h(!1)),t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),C())}}),(0,F.jsx)(`button`,{type:`button`,className:`queue-edit-save`,"data-waiting-save":e.id,onClick:C,children:`保存`}),(0,F.jsx)(`button`,{type:`button`,className:`queue-edit-cancel`,"data-waiting-cancel-edit":e.id,onClick:()=>{_(e.content),h(!1)},children:`取消`})]}):(0,F.jsx)(`span`,{className:`queue-text`,title:x,children:x}),(0,F.jsx)(`span`,{className:`queue-state`,"data-waiting-state":v?`sending`:`queued`,children:v?`已交给 Agent`:t===1?`下一条回答这条`:`等待回答 · 第 ${t} 条`}),v?(0,F.jsx)(`span`,{className:`queue-locked`,"data-waiting-locked":e.id,children:`暂时改不了`}):(0,F.jsxs)(F.Fragment,{children:[r?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`queue-interrupt`,"data-waiting-interrupt":e.id,disabled:i,title:`停止当前任务,立即回答这条消息`,"aria-label":`停止当前任务并回答「${x}」`,onClick:()=>l(e.id),children:i?`◌ 打断中…`:`打断并回答`}),(0,F.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-steer":e.id,title:t===1?`当前工具完成后回答这条消息`:`插到最前:让它成为下一条被回答的消息`,"aria-label":t===1?`当前工具完成后回答「${x}」`:`让「${x}」插到最前`,onClick:()=>c(e.id),children:t===1?`当前工具完成后回答`:`插到最前`})]}):(0,F.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-send":e.id,title:`现在就回答这条消息`,"aria-label":`现在就回答「${x}」`,onClick:()=>d(e.id),children:`现在就回答`}),e.role===`user`&&(0,F.jsx)(`button`,{type:`button`,className:`queue-edit`,"data-waiting-edit":e.id,title:`回答这条之前改字`,"aria-label":`修改「${x}」`,onClick:()=>{_(e.content),h(!0)},children:`改字`}),(0,F.jsx)(`button`,{type:`button`,className:`queue-cancel`,"data-waiting-cancel":e.id,title:`撤回这条消息,它不会被回答`,"aria-label":`撤回「${x}」`,onClick:()=>f(e.id),children:`撤回`})]})]})}function mD(e,t,n){return`${e}:${t}:${n}`}function hD(e){return{picked:Object.fromEntries((e.answers??[]).map(e=>[e.id,e.selected])),note:e.answers?.map(e=>e.note??``).join(`
|
|
339
|
+
`)??``}}function gD({question:e,index:t,expanded:n,draft:r,onDraftChange:i,onToggle:a,onAnswer:o}){return(0,F.jsxs)(`div`,{className:`call-block question-block-${e.status}`,"data-call-block":t,"data-call-tool":`question`,"data-call-detail":`提问`,"data-call-status":e.status===`answered`?`ok`:e.status===`cancelled`?`error`:`running`,"data-call-expanded":n?`true`:`false`,"data-question-block":t,children:[(0,F.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-question-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`}提问`,title:n?`折叠这段提问`:`展开这段提问`,onClick:a}),(0,F.jsxs)(`div`,{className:`call-head-row`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:a,children:[(0,F.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`answered`?`✓`:e.status===`cancelled`?`✕`:`?`}),(0,F.jsx)(`span`,{className:`call-label`,children:`提问`}),(0,F.jsxs)(`span`,{className:`call-detail`,children:[e.items.length,` 个问题`]})]}),n&&(0,F.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:a,children:`收起`})]}),n&&(0,F.jsx)(`div`,{className:`question-body`,"data-question-body":t,children:(0,F.jsx)(_D,{question:e,draft:r,onDraftChange:i,instanceId:`inline`,onAnswer:o})})]})}function _D({question:e,draft:t,onDraftChange:n,instanceId:r,onAnswer:i}){let{picked:a,note:o}=t,s=(e,r,i)=>{let o=(()=>{let t=a,n=t[e]??[];return i?{...t,[e]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}:{...t,[e]:[r]}})();n({...t,picked:o})},c=()=>{i(e.items.map(e=>({id:e.id,selected:a[e.id]??[],...e.extraNote&&o.trim()?{note:o.trim()}:{}})),!1)},l=e.items.some(e=>(a[e.id]??[]).length>0);return(0,F.jsxs)(`div`,{className:`question-block question-${e.status}`,"data-question-status":e.status,children:[e.items.map(i=>(0,F.jsxs)(`div`,{className:`question-item`,children:[(0,F.jsx)(`div`,{className:`question-text`,children:i.header?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`question-header`,children:i.header}),(0,F.jsx)(`span`,{className:`question-sep`,children:` · `}),(0,F.jsx)(Wu,{source:i.question})]}):(0,F.jsx)(Wu,{source:i.question})}),(0,F.jsx)(`div`,{className:`question-options`,"data-question-options":i.id,children:i.options.map(t=>{let n=e.status!==`pending`,o=(n?e.answers?.find(e=>e.id===i.id)?.selected:a[i.id])?.includes(t)??!1;return(0,F.jsxs)(`label`,{className:o?`is-chosen`:``,"data-chosen":n&&o?`1`:void 0,children:[(0,F.jsx)(`input`,{type:i.multiple?`checkbox`:`radio`,name:`q-${r}-${i.id}`,checked:o,disabled:n,onChange:()=>s(i.id,t,i.multiple)}),(0,F.jsx)(Gu,{source:t}),n&&o?(0,F.jsx)(`span`,{className:`question-mark`,"aria-label":`已选择`,children:`✓`}):null]},t)})}),e.status===`pending`&&i.extraNote?(0,F.jsx)(`textarea`,{value:o,placeholder:`补充说明(可选)`,onChange:e=>n({...t,note:e.target.value})}):e.status===`answered`&&(e.answers??[]).some(e=>e.note)?(0,F.jsxs)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:[`补充:`,(e.answers??[]).map(e=>e.note).filter(Boolean).join(`;`)]}):null,e.status===`cancelled`&&(0,F.jsx)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:`已取消,没有作答。`})]},i.id)),e.status===`pending`&&(0,F.jsxs)(`div`,{className:`question-actions`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:c,disabled:!l,children:`提交`}),(0,F.jsx)(`button`,{type:`button`,className:`question-skip`,onClick:()=>i([],!0),children:`跳过`})]})]})}function vD({question:e,pendingCount:t,minimized:n,floatingRight:r,onMinimize:i,onExpand:a,onLocate:o,draft:s,onDraftChange:c,onAnswer:l}){return n?(0,We.createPortal)((0,F.jsxs)(`button`,{type:`button`,className:`question-floating-ball`,style:{"--question-floating-right":r},"data-question-floating-ball":e.key,onClick:a,"aria-label":`展开待回答的问题${t>1?`,还有 ${t-1} 个待处理`:``}`,title:`展开待回答的问题`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`?`}),t>1&&(0,F.jsx)(`small`,{children:t})]}),document.body):(0,We.createPortal)((0,F.jsxs)(`section`,{className:`question-floating-panel`,style:{"--question-floating-right":r},"data-question-floating-panel":e.key,role:`dialog`,"aria-labelledby":`question-floating-title`,children:[(0,F.jsxs)(`header`,{className:`question-floating-head`,children:[(0,F.jsx)(`span`,{className:`question-floating-mark`,"aria-hidden":`true`,children:`?`}),(0,F.jsxs)(`h2`,{id:`question-floating-title`,children:[`需要你回答`,t>1?` · 还有 ${t-1} 个`:``]}),(0,F.jsx)(`button`,{type:`button`,className:`question-floating-minimize`,onClick:o,title:`定位到消息上下文并最小化`,children:`查看上下文`}),(0,F.jsx)(`button`,{type:`button`,className:`question-floating-minimize-icon`,onClick:i,title:`最小化为悬浮球`,"aria-label":`最小化问题`,children:`−`})]}),(0,F.jsx)(`div`,{className:`question-floating-body`,children:(0,F.jsx)(_D,{question:e.value,draft:s,onDraftChange:c,instanceId:`floating`,onAnswer:l})})]}),document.body)}function yD({request:e,onAnswer:t,pending:n}){let[r,i]=(0,u.useState)(e.prefill??``),a=e.method===`input`||e.method===`editor`,o=(0,F.jsx)(`button`,{type:`button`,className:`extui-cancel`,onClick:()=>t({cancelled:!0}),children:`取消提问`});return(0,F.jsxs)(`article`,{className:`extui-card extui-${e.method}`,"data-request-id":e.requestId,"data-method":e.method,children:[(0,F.jsxs)(`div`,{className:`extui-head`,children:[(0,F.jsx)(`span`,{className:`extui-badge`,children:`扩展提问`}),e.timeoutMs!==void 0&&(0,F.jsxs)(`span`,{className:`extui-deadline`,children:[Math.ceil(Math.max(0,e.deadlineAt===void 0?e.timeoutMs:e.deadlineAt-Date.now())/1e3),`s 超时`]})]}),n&&(0,F.jsx)(`p`,{className:`extui-pending`,role:`status`,children:`提交中…`}),(0,F.jsxs)(`fieldset`,{disabled:n,style:{border:0,padding:0,margin:0},children:[(0,F.jsx)(`h3`,{className:`extui-title`,children:e.title||ND[e.method]}),e.method===`confirm`&&(0,F.jsx)(`p`,{className:`extui-body`,children:e.message}),e.method===`select`&&(0,F.jsxs)(`div`,{className:`extui-options`,children:[(e.options??[]).map(e=>(0,F.jsx)(`button`,{type:`button`,className:`extui-option`,onClick:()=>t({value:e}),children:e},e)),(e.options??[]).length===0&&(0,F.jsx)(`p`,{className:`extui-body`,children:`扩展没有提供任何选项`})]}),a&&(0,F.jsxs)(`form`,{className:`extui-form`,onSubmit:e=>{e.preventDefault(),!n&&r.trim()&&t({value:r})},children:[e.method===`input`?(0,F.jsx)(`input`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_E(e)&&e.preventDefault()},placeholder:e.placeholder??``}):(0,F.jsx)(`textarea`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_E(e)&&e.preventDefault()}}),(0,F.jsxs)(`div`,{className:`extui-actions`,children:[(0,F.jsx)(`button`,{type:`submit`,className:`extui-primary`,disabled:!r.trim(),children:`提交`}),o]})]}),!a&&(0,F.jsxs)(`div`,{className:`extui-actions`,children:[e.method===`confirm`&&(0,F.jsx)(`button`,{type:`button`,className:`extui-primary`,onClick:()=>t({confirmed:!0}),children:`确认`}),e.method===`confirm`&&(0,F.jsx)(`button`,{type:`button`,className:`extui-no`,onClick:()=>t({confirmed:!1}),children:`拒绝`}),o]})]})]})}function bD({initial:e,label:t,onCommit:n,onClose:r}){let[i,a]=(0,u.useState)(e),o=(0,u.useRef)(null),s=(0,u.useRef)(!1);(0,u.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]);let c=!i.trim(),l=()=>{s.current=!0,r()},d=()=>{if(c)return;let t=i.trim();(t===e||n(t))&&l()};return(0,F.jsxs)(`div`,{className:`inline-edit`,"data-editing":`1`,children:[(0,F.jsx)(`input`,{ref:o,className:`inline-edit-input`,value:i,"aria-label":t,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){if(_E(e))return;e.preventDefault(),d()}else e.key===`Escape`&&(e.preventDefault(),l())},onBlur:()=>{s.current||r()}}),(0,F.jsx)(`button`,{type:`button`,className:`inline-edit-ok`,title:`确认重命名`,"aria-label":`确认重命名`,disabled:c,onMouseDown:e=>e.preventDefault(),onClick:d,children:`✓`}),(0,F.jsx)(`button`,{type:`button`,className:`inline-edit-cancel`,title:`取消重命名`,"aria-label":`取消重命名`,onMouseDown:e=>e.preventDefault(),onClick:l,children:`✗`})]})}function xD({kind:e,label:t,value:n,detail:r,options:i,disabled:a,note:o,onChoose:s,scope:c,providerOptions:l}){let[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(0),[_,v]=(0,u.useState)(`*`),y=(0,u.useRef)(null),b=(0,u.useRef)(null),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)([]),w=i.find(e=>e.selected),T=UE(l?i.filter(e=>_===`*`||e.key!==SD&&e.key.split(`/`)[0]===_):i,p),E=T.length===0?-1:Math.min(Math.max(h,0),T.length-1),D=E<0?void 0:T[E],O=(e=!1)=>{f(!1),e&&b.current?.focus()},k=()=>{m(``),v(`*`),g(Math.max(i.findIndex(e=>e.selected),0)),f(!0)},A=e=>g(t=>T.length?Math.min(Math.max(t+e,0),T.length-1):0);(0,u.useEffect)(()=>{if(!d)return;let e=e=>{y.current?.contains(e.target)||O()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[d]),(0,u.useEffect)(()=>{if(!d)return;let e=y.current,t=t=>{e?.contains(t.relatedTarget)||O()};return e?.addEventListener(`focusout`,t),()=>e?.removeEventListener(`focusout`,t)},[d]),(0,u.useEffect)(()=>{d&&S.current?.focus()},[d]),(0,u.useEffect)(()=>{d&&E>=0&&C.current[E]?.scrollIntoView({block:`nearest`})},[d,E]),(0,u.useLayoutEffect)(()=>{if(!d)return;let e=x.current;if(!e)return;e.style.setProperty(`--picker-nudge`,`0px`),e.style.setProperty(`--picker-drop`,`0px`);let t=e.getBoundingClientRect(),n=Math.min(window.innerWidth-8-t.right,Math.max(8-t.left,0)),r=Math.min(window.innerHeight-8-t.bottom,Math.max(8-t.top,0));e.style.setProperty(`--picker-nudge`,`${n}px`),e.style.setProperty(`--picker-drop`,`${r}px`)},[d,T.length,i.length]);let j=e=>{if(d){if(e.key===`Escape`)e.preventDefault(),O(!0);else if(e.key===`ArrowDown`)e.preventDefault(),A(1);else if(e.key===`ArrowUp`)e.preventDefault(),A(-1);else if(e.key===`Home`)e.preventDefault(),g(0);else if(e.key===`End`)e.preventDefault(),g(Math.max(T.length-1,0));else if(e.key===`Enter`){if(_E(e))return;e.preventDefault(),D&&(s(D.key),O(!0))}}},ee=`picker-list-${c??e}`,M=t=>`picker-option-${c??e}-${t}`;return(0,F.jsxs)(`div`,{className:`session-picker-item session-picker-${e}`,ref:y,onKeyDown:d?j:void 0,children:[(0,F.jsxs)(`button`,{ref:b,type:`button`,className:`session-picker-trigger`,disabled:a,"aria-haspopup":`listbox`,"aria-expanded":d,title:o??`${FE[e]}:${r?`${t} · ${r}`:t}`,"data-picker-trigger":e,"data-picker-value":n??t,"data-picker-selected":i.some(e=>e.selected),onClick:()=>d?O():k(),children:[(0,F.jsx)(`span`,{className:`session-picker-kind`,children:FE[e]}),(0,F.jsx)(`span`,{className:`session-picker-name`,children:t}),r&&(0,F.jsx)(`span`,{className:`session-picker-detail`,children:r}),(0,F.jsx)(`span`,{className:`session-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),d&&(0,F.jsxs)(`div`,{className:`picker-menu`,ref:x,"data-picker-menu":e,"data-picker-highlight":E,children:[l&&(0,F.jsxs)(`label`,{className:`picker-provider-filter`,children:[(0,F.jsx)(`span`,{children:`Provider`}),(0,F.jsxs)(`select`,{"data-picker-provider":e,"aria-label":`筛选模型 Provider`,value:_,onKeyDown:e=>e.stopPropagation(),onChange:e=>{v(e.target.value),g(0)},children:[(0,F.jsx)(`option`,{value:`*`,children:`全部 Provider`}),l.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),(0,F.jsxs)(`div`,{className:`picker-filter`,children:[(0,F.jsx)(`span`,{className:`picker-filter-icon`,"aria-hidden":`true`,children:`🔍`}),(0,F.jsx)(`input`,{ref:S,className:`picker-filter-input`,"data-picker-filter":e,role:`combobox`,"aria-label":`筛选${LE[e]}选项`,"aria-expanded":`true`,"aria-controls":ee,"aria-autocomplete":`list`,"aria-activedescendant":D?M(E):void 0,value:p,placeholder:`输入以筛选…`,autoComplete:`off`,spellCheck:!1,onChange:e=>{m(e.target.value),g(0)}}),p&&(0,F.jsx)(`button`,{type:`button`,className:`picker-filter-clear`,"data-picker-filter-clear":e,title:`清空筛选`,"aria-label":`清空筛选`,onMouseDown:e=>e.preventDefault(),onClick:()=>{m(``),g(0),S.current?.focus()},children:`✕`})]}),w&&!T.some(e=>e.key===w.key)&&(0,F.jsxs)(`div`,{className:`picker-current`,"data-picker-current":e,"data-picker-current-value":w.key,children:[(0,F.jsx)(`span`,{className:`picker-current-label`,children:`当前`}),(0,F.jsx)(`span`,{className:`picker-current-value`,children:w.label})]}),(0,F.jsxs)(`div`,{className:`picker-list`,role:`listbox`,id:ee,"aria-label":zE[e],children:[T.map((e,t)=>(0,F.jsxs)(`button`,{id:M(t),type:`button`,role:`option`,"aria-selected":e.selected,ref:e=>{C.current[t]=e},className:`picker-option${e.selected?` selected`:``}${t===E&&!e.selected?` preview`:``}`,"data-picker-option":e.key,"data-picker-option-selected":e.selected,"data-picker-highlight":t===E,onClick:()=>{s(e.key),O(!0)},children:[e.color&&(0,F.jsx)(`span`,{className:`picker-option-swatch`,style:{background:e.color},"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`picker-option-name`,children:e.label}),e.badge&&(0,F.jsx)(`span`,{className:`picker-option-badge`,"data-picker-option-badge":e.badge,children:e.badge}),e.detail&&(0,F.jsx)(`span`,{className:`picker-option-detail`,children:e.detail}),e.selected&&(0,F.jsx)(`span`,{className:`picker-option-mark`,"aria-hidden":`true`,children:`✓`})]},e.key)),T.length===0&&(0,F.jsx)(`div`,{className:`picker-empty`,"data-picker-empty":e,children:i.length===0?RE[e]:`没有匹配「${p.trim()}」的${LE[e]}`})]})]})]})}var SD=`__pi_default__`;function CD({workspace:e,catalog:t,agents:n,onSave:r,onRename:i,onRemove:a,onClose:o}){let[s,c]=(0,u.useState)(e.defaultAgentId),[l,d]=(0,u.useState)(e.defaultModel),[f,p]=(0,u.useState)(e.defaultThinkingLevel);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let m=t?.source===`pi`,h=[{key:SD,label:`跟随 Pi 默认`,detail:`不为新会话指定模型`,selected:l===void 0},...(t?.models??[]).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,sE(e.contextWindow)?`${sE(e.contextWindow)} 上下文`:``,cE(e.maxTokens)?`${cE(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:VE(e),selected:l?.provider===e.provider&&l.modelId===e.modelId}))],g=t?.models.find(e=>e.provider===l?.provider&&e.modelId===l?.modelId),_=g?.thinkingLevels??t?.levels??[],v=[{key:SD,label:`跟随 Pi 默认`,detail:`不为新会话指定思考等级`,selected:f===void 0},..._.map(e=>({key:e,label:e,selected:e===f}))],y=e=>{if(e===SD){d(void 0),p(void 0);return}let n=(t?.models??[]).find(t=>t.provider===e.split(`/`)[0]&&t.modelId===e.split(`/`)[1]);if(n){let e=l?.provider!==n.provider||l.modelId!==n.modelId;d({provider:n.provider,modelId:n.modelId,label:n.label}),e&&p(void 0)}},b=e=>p(e===SD?void 0:e),x=[{key:SD,label:`跟随 Pi 默认`,detail:`新会话不使用任何 agent 角色`,selected:s===void 0},...(n?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:s===e.id}))];return(0,F.jsx)(`div`,{className:`overlay`,onClick:o,children:(0,F.jsxs)(`div`,{className:`picker settings-dialog`,"data-settings-dialog":`1`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`h2`,{children:`工作区设置`}),(0,F.jsxs)(`div`,{className:`settings-scope`,children:[e.name,` · 默认值只影响之后新建的会话,已有会话不变`]}),(0,F.jsx)(`div`,{className:`workspace-settings-path`,children:e.path}),(0,F.jsxs)(`div`,{className:`settings-row`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认智能体`}),(0,F.jsx)(xD,{kind:`agent`,scope:`settings-agent`,label:n?.agents.find(e=>e.id===s)?.name??`跟随 Pi 默认`,value:s??SD,detail:s?`${n?.agents.find(e=>e.id===s)?.toolSummary??``}`:void 0,options:x,disabled:!n||n.source===`unavailable`,note:XE(n),onChoose:e=>c(e===SD?void 0:e)})]}),(0,F.jsxs)(`div`,{className:`settings-row`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,F.jsx)(xD,{kind:`model`,scope:`settings-model`,label:l?.label??`跟随 Pi 默认`,value:l?`${l.provider}/${l.modelId}`:SD,detail:l?`${l.provider}/${l.modelId}`:void 0,options:h,providerOptions:[...new Set((t?.models??[]).map(e=>e.provider))],disabled:!m,note:YE(`模型`,t),onChoose:y})]}),(0,F.jsxs)(`div`,{className:`settings-row`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`思考强度`}),(0,F.jsx)(xD,{kind:`thinking`,scope:`settings-thinking`,label:f??`跟随 Pi 默认`,value:f??SD,options:v,disabled:!m,note:YE(`思考等级`,t),onChoose:b})]}),l&&g&&_.length===0&&(0,F.jsx)(`div`,{className:`settings-scope`,children:`Pi 未提供此模型的可选等级,使用模型默认值。`}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-rename`,"data-settings-rename":`1`,onClick:i,children:`重命名工作区`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-settings-cancel":`1`,onClick:o,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-ok`,"data-settings-save":`1`,onClick:()=>r(s,l,f),children:`保存`})]}),(0,F.jsx)(`button`,{type:`button`,className:`workspace-delete`,onClick:a,children:`从列表移除工作区`})]})})}var wD=[{id:`main`,label:`任务`,name:`任务与后台任务`},{id:`projects`,label:`项目`,name:`项目控制面`},{id:`tools`,label:`工具`,name:`工具 tab`},{id:`files`,label:`文件`,name:`文件 tab`},{id:`git`,label:`Git`,name:`Git tab`},{id:`terminal`,label:`终端`,name:`终端 tab`}],TD=`super-pi.right-tabs.v1`;function ED(){let e=e=>wD.some(t=>t.id===e),t={tab:wD[0].id,byConversation:{}};try{let n=JSON.parse(window.sessionStorage.getItem(TD)??`null`);return!n||!e(n.tab)?t:{tab:n.tab,byConversation:Object.fromEntries(Object.entries(n.byConversation??{}).filter(t=>e(t[1])))}}catch{return t}}var DD={waiting:`⋯`,running:``,failed:``,question:`?`,completed:``,unread:`•`,idle:``,awaiting_background:`⚙`,pending_report:`↑`,awaiting_subordinates:`↓`,awaiting_decision:`▲`},OD={idle:`空闲`,running:`讨论中`,awaiting_background:`后台任务进行中`,completed:`讨论已完成`,failed:`讨论未完成`},kD={waiting:`等待 LLM`,running:`进行中`,failed:`出错`,question:`等你回答`,completed:`已完成`,unread:`有未读`,idle:`空闲`,awaiting_background:`等待后台任务`,pending_report:`待汇报`,awaiting_subordinates:`等待下级`,awaiting_decision:`等上面拍板`},AD={idle:`就绪`,waiting:`等待 LLM`,running:`正在生成`,completed:`已完成`,stopped:`已停止`,failed:`运行失败`,awaiting_background:`等待后台任务`},jD=e=>e?.status===`running`||e?.status===`waiting`,MD={running:`运行中`,completed:`已完成`,failed:`失败`,stopped:`已停止`,cancelled:`已取消`,interrupted:`已中断`},ND={select:`请选择一项`,confirm:`请确认`,input:`请输入内容`,editor:`请输入内容`,notify:`扩展通知`,setStatus:`扩展状态`,setWidget:`扩展内容`,setTitle:`扩展标题`,set_editor_text:`扩展输入`};function PD(e,t){return t.some(t=>t.conversationId===e.id)?!0:e.messagesLoaded===!1?e.hasPendingQuestion===!0:e.messages.some(e=>(e.toolCalls??[]).some(e=>e.question?.status===`pending`))}function FD(e,t,n){let r=(t||[]).filter(t=>t.parentConversationId===e.id),i=(t||[]).find(t=>t.id===e.parentConversationId),a=n??``;return dw({conversation:e,parent:i,directChildren:r,isTopLevelUnread:e.updatedAt>a})}function ID(e,t,n,r){let i=FD(e,r,n);return fw({status:e.status,reportingState:i,awaitingQuestion:t,quietWhenRead:!0})}function LD(e,t){return t===`awaiting_decision`||e===`awaiting_decision`?(0,F.jsx)(`span`,{className:`conversation-status-badge badge--warning project-status-awaiting_decision`,"data-session-status":`awaiting_decision`,"data-reporting-badge":`awaiting_decision`,title:kD.awaiting_decision,children:kD.awaiting_decision}):t===`awaiting_subordinates`||e===`awaiting_subordinates`?(0,F.jsx)(`span`,{className:`conversation-status-badge project-status-awaiting_subordinates`,"data-session-status":`awaiting_subordinates`,"data-reporting-badge":`awaiting_subordinates`,title:kD.awaiting_subordinates,children:kD.awaiting_subordinates}):t===`pending_report`||e===`pending_report`?(0,F.jsx)(`span`,{className:`conversation-status-badge project-status-pending_report`,"data-session-status":`pending_report`,"data-reporting-badge":`pending_report`,title:kD.pending_report,children:kD.pending_report}):null}function RD({state:e,label:t=kD[e]}){let n=DD[e];if(e===`idle`)return null;let r=e.replace(/_/g,`-`);return(0,F.jsx)(`i`,{className:`session-state session-state-${e} session-state-${r}`,"data-session-state":e,title:t,"aria-label":t,...e===`awaiting_background`?{style:{color:`var(--accent)`}}:{},children:(0,F.jsx)(`i`,{className:`session-state-mark`,"aria-hidden":`true`,children:n})})}function zD(e,t){return(0,F.jsxs)(F.Fragment,{children:[e.origin===`orchestrator`&&(0,F.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`orchestrator`,title:`编排会话:由上级智能体创建`,"aria-label":`编排会话:由上级智能体创建`,children:`编排`}),t&&(0,F.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`scheduled`,title:`定时任务会话:${t.name}`,"aria-label":`定时任务会话:${t.name}`,children:`定时`})]})}function BD(e,t){let n=[];return e.origin===`orchestrator`&&n.push(`编排会话`),t&&n.push(`定时任务会话:${t.name}`),n.length?`(${n.join(`;`)})`:``}var VD={pending:`未开始`,in_progress:`运行中`,completed:`已完成`},HD={pending:`○`,in_progress:`◐`,completed:`✓`},UD={high:`高`,medium:`中`,low:`低`};function WD(e){let t=e.filter(e=>e.status!==`completed`).length;return e.length?t?`${t} 个未完成 / 共 ${e.length} 个`:`全部完成:${e.length} 个`:`0 个待办任务`}function GD({todo:e,index:t}){let n=e.id??`todo_${t}`;return(0,F.jsxs)(`li`,{className:`todo-item todo-${e.status}`,"data-todo-item":n,"data-todo-status":e.status,title:`状态:${VD[e.status]}`,children:[(0,F.jsx)(`span`,{className:`todo-mark`,"aria-hidden":`true`,children:HD[e.status]}),(0,F.jsx)(`span`,{className:`todo-text`,children:e.content}),(0,F.jsx)(`span`,{className:`todo-status`,"data-todo-status-text":`1`,children:VD[e.status]}),e.priority&&(0,F.jsx)(`span`,{className:`todo-priority`,"data-todo-priority":e.priority,children:UD[e.priority]})]})}function KD(e,t){if(!e)return[];let n=t.filter(t=>t.conversationId===e.id&&t.status===`running`),r=new Set(n.map(e=>e.id));for(let t of e.messages)t.toolCalls?.forEach((i,a)=>{let o=i.backgroundTask;o&&o.status===`running`&&!r.has(o.id)&&(r.add(o.id),n.push({id:o.id,conversationId:e.id,title:i.detail?.trim()||i.label?.trim()||o.id,status:o.status,originMessageId:t.id,originCallRow:a}))});return n}function qD({tasks:e,runs:t,execOutputs:n,onStop:r}){return(0,F.jsx)(`ul`,{className:`bg-list`,"data-bg-task-count":e.length,children:e.map((e,i)=>{let a=e.id||`bg_${i}`,o=e.status?.trim()||``,s=o?MD[o]??(/[\u3400-\u9fff]/.test(o)?o:`未知状态`):`未知状态`;return(0,F.jsx)(JD,{task:e,status:s,run:t?.get(e.id),execOutputs:n,onStop:r},a)})})}function JD({task:e,status:t,run:n,execOutputs:r,onStop:i}){let[a,o]=(0,u.useState)(!1),s=tD(e.id,r),c=n?fE(n):s?.text||e.output,l=c&&dE(c),d=n?n.outputTruncated||n.toolCalls?.some(e=>e.outputTruncated):s?.truncated??e.outputTruncated;return(0,F.jsxs)(`li`,{className:`bg-item${a?` bg-item-expanded`:``}`,"data-bg-task":e.id,"data-bg-task-status":e.status??`unknown`,title:`状态:${t}`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`bg-item-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`展开后台任务详情`,children:[(0,F.jsx)(`span`,{className:`bg-title`,children:e.title?.trim()||e.id||`未命名任务`}),(0,F.jsxs)(`span`,{className:`bg-meta`,children:[e.agentId?.trim()&&(0,F.jsx)(`span`,{className:`bg-agent`,"data-bg-agent":e.agentId,children:e.agentId}),(0,F.jsx)(`span`,{className:`bg-status`,children:t})]})]}),i&&(0,F.jsx)(`button`,{type:`button`,className:`bg-stop-btn`,"data-bg-task-stop":e.id,title:`终止后台任务`,onClick:()=>i(e.id),children:`终止`}),a&&(0,F.jsx)(`pre`,{className:`bg-output`,"data-bg-output":e.id,children:[d?`日志仅保留最近一段。`:``,l].filter(Boolean).join(`
|
|
340
|
+
|
|
341
|
+
`)||`运行中,暂无输出`})]})}var YD=(0,u.lazy)(()=>sf(()=>import(`./GitDiffEditor-FQBfGxOY.js`),__vite__mapDeps([4,1,0,2,5,6,3,7])));function XD({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,gitWorkspaceId:u=l,gitRepositoryOnly:d=!1,workspaceLabel:f,workspaceName:p,gitWorkspaceName:m=p,cwd:h=``,conversationId:g,followedWorktreeId:_,connected:v,files:y,onOpenFile:b,onOpenChanged:x,onOpenGitDiff:S,activeGitDiffUrl:C,onFileReference:w,onFilesMoved:T,onSearchFolder:E,activeTab:D,onSelectTab:O,sendCommand:k,registerTerminalSink:A,terminalShell:j,notify:ee,serverTimeZone:M,onOpenSession:te,side:N,onArrange:ne,pinned:re=!0,sharedGit:ie}){let ae=wD,oe=N===`left`;return(0,F.jsx)(`div`,{className:`right-rail${N?` workbench-panel workbench-panel-`+N:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":oe?`左侧栏`:`右侧栏`,"data-right-rail":oe?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":N,hidden:N&&s?!0:void 0,children:s?!N&&(0,F.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,F.jsxs)(F.Fragment,{children:[N?(0,F.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,F.jsx)(`h2`,{children:gt[D]}),ne&&(0,F.jsx)(Ot,{view:D,side:N,pinned:re,onArrange:ne}),(0,F.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":oe?void 0:`1`,title:oe?`收起左侧栏`:`收起右侧栏`,"aria-label":oe?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,F.jsx)(Tt,{name:`close`})})]}):(0,F.jsxs)(`div`,{className:`right-rail-head`,children:[(0,F.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":ae.length,children:ae.map(e=>(0,F.jsx)(`button`,{type:`button`,role:`tab`,id:`right-tab-${e.id}`,className:`right-tab${e.id===D?` right-tab-active`:``}`,"data-right-tab":e.id,"aria-selected":e.id===D,"aria-controls":`right-panel-${e.id}`,title:e.name,"aria-label":e.name,onClick:()=>O(e.id),children:e.label},e.id))}),(0,F.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":`收起右侧栏`,onClick:c,children:`›`})]}),wD.filter(e=>e.id===D).map(s=>(0,F.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":N?gt[s.id]:void 0,"aria-labelledby":N?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,F.jsxs)(F.Fragment,{children:[(e.length>0||t.length>0)&&(0,F.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,F.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,F.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,F.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,F.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,F.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,F.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,F.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,F.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,F.jsx)(cC,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,F.jsx)(`span`,{"data-todo-summary":`1`,children:WD(e)}),children:e.length>0?(0,F.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,F.jsx)(GD,{todo:e,index:t},e.id??`todo_${t}`))}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,F.jsx)(cC,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,F.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,F.jsx)(qD,{tasks:t,runs:n,execOutputs:r,onStop:e=>k({type:`backgroundTask.stop`,taskId:e})}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,F.jsx)(SC,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:k,notify:ee,serverTimeZone:M})]})]}),s.id===`projects`&&(0,F.jsx)(sw,{workspaceId:l,notify:ee,onOpenSession:te,onOpenFile:b,cwd:h},l),s.id===`tools`&&(0,F.jsx)(ZD,{workspaceId:l},l),s.id===`files`&&(0,F.jsx)(yp,{workspaceId:l,workspaceName:p,cwd:h,files:y,onOpenFile:b,onOpenChanged:x,onReference:w,onMoved:T,onSearchFolder:E}),s.id===`git`&&(0,F.jsx)(Mr,{repositoryOnly:d,workspaceId:u??null,conversationId:g,cwd:u===l?h:``,followedWorktreeId:_,onOpenDiff:e=>S({...e,comparison:m?`${m} · ${e.comparison}`:e.comparison}),activeDiffUrl:C,onOpenConversation:te,sharedGit:ie},JSON.stringify([u,h,g,d])),s.id===`terminal`&&(0,F.jsx)(sC,{workspaceId:l,workspaceLabel:f,cwd:h,conversationId:g,connected:v,sendCommand:k,registerSink:A,terminalShell:j},JSON.stringify([l,g]))]},s.id))]})})}function ZD({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=UT(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await KT(e);t&&o(`移除工具失败:${ct(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${gT(t)})`:`打开${e}`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`rail-section-head`,children:[(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,F.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,F.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,F.jsxs)(`li`,{className:`tool-slot`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-tool-icon":e.id,"data-tool-kind":e.kind,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),"aria-current":r===e.id?`true`:void 0,onClick:()=>WT.toggleTool(e.id),children:[(0,F.jsx)(Jw,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,F.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,F.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${gT(i[e.id])}`,children:_T(i[e.id])}),e.kind===`link`&&(0,F.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>WT.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,F.jsxs)(`li`,{className:`tool-slot`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-mounted-tool-icon":e.id,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),onClick:()=>WT.toggleTool(e.id),children:[(0,F.jsx)(Jw,{className:`tool-icon-glyph`,glyph:Xw(e)}),(0,F.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,F.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${gT(i[e.id])}`,children:_T(i[e.id])}),(0,F.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>void s(e.id),children:`✕`})]},e.id))]}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,F.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>WT.openSettings(),children:`⚙ 工具设置`}),a&&(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function QD({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=UT(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(),[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)(),j=(0,u.useRef)(null),ee=(0,u.useRef)(null),[M,te]=(0,u.useState)(),[N,ne]=(0,u.useState)(),re=(0,u.useRef)(null),[ie,ae]=(0,u.useState)(()=>{let e=PT();return!e||typeof window>`u`?e:IT(e,window.innerWidth,window.innerHeight)}),oe=async()=>{let e=await ju(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
|
|
342
|
+
|
|
343
|
+
工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
|
|
344
|
+
|
|
345
|
+
如需本地计算,声明 script: { path, timeoutMs, parameters }。脚本必须是 Python,参数以 JSON 从 stdin 传入,stdout 必须只输出一个 JSON 对象。在 index.html 中加载 <script src="./super-pi-tool.js"><\/script>,然后调用 SuperPiTool.run(params)、SuperPiTool.get(runId)、SuperPiTool.wait(runId) 或 SuperPiTool.cancel(runId)。这些都是已绑定本工具身份的相对接口;不要调用 /api/exec,不要猜测 toolId,也不要传 shell 命令、任意文件路径或未声明参数。页面必须实际执行一次示例任务并显示运行状态、日志和结构化结果。第三方包写进 environment.requires(必须钉死成 pkg==version),首次运行时会装进这个工具自己的虚拟环境。需要模型能力(摘要、改写、抽取、分类)时调用 SuperPiTool.llm({ prompt, system }),不要自己写模型客户端或保管密钥,并在注册时声明 permissions: { llm: true }——否则服务端会拒绝,导入页面也会提示用户。最后返回注册 id、访问地址、文件清单和验证结果。`);f(e),window.setTimeout(()=>f(!1),1800)};(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let se=(0,u.useMemo)(()=>[...t.map(e=>({id:e.id,name:e.name,glyph:e.glyph})),...n.map(e=>({id:e.id,name:e.name,glyph:Xw(e)}))],[t,n]);(0,u.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),te(void 0);return}if(pT(e.key)||ST(e.target))return;e.preventDefault(),e.stopPropagation();let t=M;if(te(void 0),e.key===`Delete`||e.key===`Backspace`){WT.clearShortcut(t).then(e=>ne(e));return}let n=mT(e);if(!n){ne(`没有认出这个按键,换一个试试。`);return}let i=bT(n);if(!i.ok){ne(i.reason);return}let a=ET(r,n,t);if(a){let e=se.find(e=>e.id===a)?.name;ne(e?`这个组合键已经被「${e}」占用了,换一个键。`:`这个组合键已经被另一个工具占用了,换一个键。`)}else WT.setShortcut(t,n).then(e=>ne(e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[M,r,se]);let ce=e=>{ae(IT(e,window.innerWidth,window.innerHeight))},le=e=>{FT(e)},ue=()=>{ae(void 0),FT(void 0)},de=(0,u.useRef)(!1),fe=n.map(e=>e.slug).filter(e=>typeof e==`string`),pe=e=>{m(void 0),g(void 0),A(void 0),O({tool:e,name:eE({slug:e.slug??`tool`})})},me=async(e,t)=>{m(void 0),g(void 0),A(void 0);let n=tE(t);if(!n.ok)A(n.reason);else try{let t=await Ae(`/api/tools/export?id=${encodeURIComponent(e.id)}`),r=await t.json();if(!t.ok||!r.bundle)throw Error(r.error??`HTTP ${t.status}`);let i=new Blob([JSON.stringify(r.bundle,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n.name,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),g(r.skipped?.length?`已导出「${e.name}」,但有 ${r.skipped.length} 个文件没有包含:${r.skipped.join(`、`)}。`:`已导出「${e.name}」。`)}catch(e){m(`导出失败:${ct(e)}`)}finally{O(void 0)}},he=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;m(void 0),g(void 0),S(void 0);let n=ZT(await t.text(),t.name);n.ok?(v({filename:t.name,bundle:n.bundle,unnamedFormat:n.unnamedFormat}),b(fe.includes(n.bundle.slug)?$T(n.bundle.slug,fe):n.bundle.slug),w(n.bundle.files[0]?.path)):m(n.reason)},ge=()=>{v(void 0),b(``),S(void 0),w(void 0)},P=async()=>{if(!_)return;S(void 0);let e=QT(y);if(!e.ok)S(e.reason);else if(fe.includes(e.slug))S(`本机已经有 slug「${e.slug}」的工具,换一个名字再导入。`);else{E(!0);try{let t=await Ae(`/api/tools`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(oE(_.bundle,e.slug))}),n=await t.json();if(!t.ok||!n.id)throw Error(n.error??`HTTP ${t.status}`);await GT(),g(`已导入「${_.bundle.name}」,它现在出现在工具栏里,所有工作区都能用。`),ge()}catch(e){m(`导入失败:${ct(e)}`)}finally{E(!1)}}};(0,u.useEffect)(()=>{D&&ee.current?.scrollIntoView({block:`center`})},[D]);let _e=()=>{let e=Cn(i);e.ok?t.length>=32?l(`工具最多 32 个,先删掉一个再加。`):(WT.setTools([...t,{id:Dn(`link`,t.map(e=>e.id)),kind:`link`,name:o.trim()||rO(e.url),glyph:`↗`,url:e.url}]),a(``),s(``),l(void 0)):l(e.reason)},ve=ie?{width:`${ie.width}px`,height:`${ie.height}px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 32px)`}:void 0;return(0,We.createPortal)((0,F.jsxs)(`div`,{className:`tool-overlay`,"data-tool-settings-overlay":`1`,onPointerDown:()=>{de.current=!1},onClick:t=>{de.current?de.current=!1:t.target===t.currentTarget&&e()},children:[(0,F.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-settings-title`,"data-tool-settings":`1`,ref:re,style:ve,children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title`,id:`tool-settings-title`,children:`⚙ 工具设置`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-settings-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭工具设置`,onClick:e,children:`✕`})]}),(0,F.jsx)(`div`,{className:`tool-dialog-body`,children:_?(0,F.jsx)(nO,{pending:_,slugDraft:y,slugError:x,preview:C,busy:T,onSlugChange:e=>{b(e),S(void 0)},onPreviewChange:w,onCancel:ge,onConfirm:()=>void P()}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`tool-prompt-card`,children:[(0,F.jsx)(`strong`,{children:`直接描述你要的工具`}),(0,F.jsx)(`p`,{className:`tool-hint`,children:`告诉 Super Pi Agent 你要创建什么,它会使用内置开发技能和 tool_register 完成注册。复制提示词仅作为备用入口。`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-development-prompt":`1`,onClick:()=>void oe(),children:d?`已复制`:`复制备用提示词`})]}),(0,F.jsx)(`div`,{className:`rail-section-head`,children:(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`从预置列表添加`})}),(0,F.jsx)(`div`,{className:`tool-presets`,"data-tool-presets":_n.length,children:_n.map(e=>{let n=t.some(t=>t.kind===e.kind);return(0,F.jsxs)(`div`,{className:`tool-preset`,"data-tool-preset":e.kind,children:[(0,F.jsx)(Jw,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,F.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,F.jsx)(`strong`,{children:e.name}),(0,F.jsx)(`small`,{children:e.blurb})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-add-preset":e.kind,disabled:n,title:n?`${e.name}已经在工具栏里了`:`添加${e.name}`,"aria-label":n?`${e.name}已添加`:`添加${e.name}`,onClick:()=>WT.setTools(On(t,e.kind)),children:n?`已添加`:`添加`})]},e.kind)})}),(0,F.jsx)(`div`,{className:`rail-section-head`,children:(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`添加网址工具`})}),(0,F.jsx)(`p`,{className:`tool-hint`,children:`填一个网址,它会变成一个图标;点开后在弹窗里用按钮在新标签页打开。网址只接受 http / https / mailto。`}),(0,F.jsx)(`input`,{className:`tool-input`,"data-tool-url-input":`1`,value:i,maxLength:2048,placeholder:`https://example.com/工具`,"aria-label":`工具网址`,onChange:e=>{a(e.target.value),l(void 0)}}),(0,F.jsx)(`input`,{className:`tool-input`,"data-tool-url-name":`1`,value:o,maxLength:40,placeholder:`名称(可留空,默认用域名)`,"aria-label":`工具名称(可选)`,onChange:e=>s(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-url-add":`1`,disabled:!i.trim(),onClick:_e,children:`添加网址工具`}),c&&(0,F.jsx)(`p`,{className:`tool-error`,"data-tool-error":`1`,role:`alert`,children:c}),(0,F.jsxs)(`p`,{className:`tool-hint`,"data-tool-scope-note":`1`,children:[`能自定义到哪:从上面挑预置工具,或自己填一个网址。`,(0,F.jsx)(`b`,{children:`没有开放「写一段脚本来执行」这一档`}),`——它在浏览器里等同于任意代码执行,会拿着本应用的权限跑。计算器是手写的算术解析器,不含 eval,也认不出变量名。`]}),(0,F.jsx)(`div`,{className:`rail-section-head`,children:(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`快捷键`})}),(0,F.jsxs)(`p`,{className:`tool-hint`,"data-tool-shortcut-hint":`1`,children:[`给每个工具绑一个组合键,按下就直接打开它,不用先找到右侧栏。`,(0,F.jsx)(`b`,{children:`弹窗打开时快捷键不生效`}),`——模态弹窗期间键盘归它自己,关掉之后再按。`]}),(0,F.jsx)(`div`,{className:`tool-shortcuts`,"data-tool-shortcut-count":se.length,children:se.map(e=>(0,F.jsxs)(`div`,{className:`tool-shortcut-row`,"data-tool-shortcut-row":e.id,children:[(0,F.jsx)(Jw,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,F.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,F.jsx)(`strong`,{children:e.name}),(0,F.jsx)(`small`,{children:r[e.id]?`按 ${gT(r[e.id])} 打开`:`还没有快捷键`})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-shortcut-set`,"data-tool-shortcut-set":e.id,"data-tool-shortcut-capturing":M===e.id?`1`:void 0,"aria-pressed":M===e.id,title:M===e.id?`按下想用的组合键(Esc 取消,Delete 清除)`:`点一下,然后按下想用的组合键`,onClick:()=>{ne(void 0),te(M===e.id?void 0:e.id)},children:M===e.id?`按下组合键…`:r[e.id]?gT(r[e.id]):`未设置`}),r[e.id]&&(0,F.jsx)(`button`,{type:`button`,className:`tool-shortcut-clear`,"data-tool-shortcut-clear":e.id,title:`清除${e.name}的快捷键`,"aria-label":`清除${e.name}的快捷键`,onClick:()=>{WT.clearShortcut(e.id),ne(void 0),te(void 0)},children:`清除`})]},e.id))}),N&&(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-shortcut-error":`1`,children:N}),(0,F.jsx)(`div`,{className:`rail-section-head`,children:(0,F.jsxs)(`h2`,{className:`rail-section-title`,children:[`已安装的全局工具(`,n.length,`)`]})}),n.length===0?(0,F.jsx)(`p`,{className:`tool-hint`,"data-tool-mounted-empty":`1`,children:`还没有注册全局工具。直接告诉 Agent 你想做什么即可开始。`}):(0,F.jsx)(`div`,{className:`tool-presets`,"data-tool-mounted-list":n.length,children:n.map(e=>{let t=iE(e.environmentState);return(0,F.jsxs)(`div`,{className:`tool-share-row`,"data-tool-share-row":e.id,children:[(0,F.jsx)(Jw,{className:`tool-preset-glyph`,glyph:Xw(e)}),(0,F.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,F.jsx)(`strong`,{children:e.name}),(0,F.jsx)(`small`,{"data-tool-env":e.environmentState?.state??`unknown`,children:t?`${t.warn?`⚠ `:``}${t.text}${e.environmentState?.detail?` · ${e.environmentState.detail}`:``}`:`环境未知`}),e.permissions?.llm&&(0,F.jsx)(`small`,{"data-tool-model":`1`,children:`⚠ 会调用模型`})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export":e.id,title:`导出${e.name},得到一个可以发给别人导入的文件`,"aria-label":`导出${e.name}`,onClick:()=>pe(e),children:`导出`})]},e.id)})}),D&&(0,F.jsxs)(`div`,{className:`tool-share-review`,ref:ee,"data-tool-export-name":`1`,children:[(0,F.jsxs)(`h3`,{className:`tool-share-title`,children:[`导出「`,D.tool.name,`」`]}),(0,F.jsxs)(`label`,{className:`tool-hint`,children:[`文件名(发给别人的就是这个文件)`,(0,F.jsx)(`input`,{className:`tool-input`,value:D.name,"aria-label":`导出文件名`,"data-tool-export-input":`1`,onChange:e=>O({...D,name:e.target.value})})]}),k&&(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-export-name-error":`1`,children:k}),(0,F.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export-cancel":`1`,onClick:()=>{O(void 0),A(void 0)},children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-export-confirm":`1`,onClick:()=>void me(D.tool,D.name),children:`导出`})]})]}),h&&(0,F.jsx)(`p`,{className:`tool-hint`,"data-tool-share-notice":`1`,children:h}),p&&(0,F.jsx)(`p`,{className:`tool-error`,"data-tool-share-error":`1`,role:`alert`,children:p}),(0,F.jsx)(`div`,{className:`rail-section-head`,children:(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`从文件导入`})}),(0,F.jsxs)(`p`,{className:`tool-hint`,children:[`收到别人分享的工具文件(`,(0,F.jsx)(`code`,{children:qT}),`)?导入后它出现在工具栏里,所有工作区都能用。`,(0,F.jsx)(`b`,{children:`导入前会先给你看这个包里有什么。`})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-pick":`1`,onClick:()=>j.current?.click(),children:`选择文件…`}),(0,F.jsx)(`input`,{ref:j,type:`file`,accept:`.json,application/json`,style:{display:`none`},"data-tool-import-input":`1`,onChange:e=>void he(e)})]})})]}),(0,F.jsx)(eO,{targetRef:re,onResize:ce,onCommit:le,onDragEnd:()=>{de.current=!0},onReset:ue})]}),document.body)}var $D=18;function eO({targetRef:e,onResize:t,onCommit:n,onDragEnd:r,onReset:i}){let[a,o]=(0,u.useState)(),s=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{let e=t.getBoundingClientRect();o({left:e.right-$D,top:e.bottom-$D})};n();let r=new ResizeObserver(n);return r.observe(t),window.addEventListener(`resize`,n),window.addEventListener(`scroll`,n,!0),()=>{r.disconnect(),window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,n,!0)}},[e]),(0,F.jsx)(`div`,{className:`tool-dialog-grip`,"data-tool-settings-grip":`1`,role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":`调整工具设置弹窗大小:拖动或用方向键,Enter 恢复默认尺寸`,style:a?{left:`${a.left}px`,top:`${a.top}px`}:void 0,onPointerDown:i=>{i.preventDefault(),i.stopPropagation();let a=e.current;if(!a)return;let o=a.getBoundingClientRect(),c=o.left+o.width/2,l=o.top+o.height/2;s.current=void 0;let u=e=>{let n=IT({width:2*(e.clientX-c),height:2*(e.clientY-l)},window.innerWidth,window.innerHeight);s.current=n,t(n)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),s.current&&(n(s.current),r())};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},onDoubleClick:()=>i(),onKeyDown:r=>{if(r.key===`Enter`||r.key===` `){r.preventDefault(),i();return}let a=r.shiftKey?8:24,o=e.current?.getBoundingClientRect(),c=o?.width??OT.width,l=o?.height??OT.height;if(r.key===`ArrowRight`)c+=a;else if(r.key===`ArrowLeft`)c-=a;else if(r.key===`ArrowDown`)l+=a;else if(r.key===`ArrowUp`)l-=a;else return;r.preventDefault();let u=IT({width:c,height:l},window.innerWidth,window.innerHeight);s.current=u,t(u),n(u)},onClick:e=>e.stopPropagation()})}function tO(){let{tools:e,mountedTools:t,openToolId:n,settingsOpen:r,shortcuts:i}=UT(),a=e.find(e=>e.id===n),o=t.find(e=>e.id===n);return(0,u.useEffect)(()=>{let n=n=>{if(!r&&!document.querySelector(`[aria-modal="true"]`)&&!(n.isComposing||n.defaultPrevented)){for(let[r,a]of Object.entries(i))if(CT(a,n)&&(e.some(e=>e.id===r)||t.some(e=>e.id===r))){n.preventDefault(),WT.openTool(r);return}}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[i,e,t,r]),(0,u.useEffect)(()=>{GT();let e=()=>{GT()};return window.addEventListener(`super-pi-tools-updated`,e),window.addEventListener(`super-pi-active-server`,e),()=>{window.removeEventListener(`super-pi-tools-updated`,e),window.removeEventListener(`super-pi-active-server`,e)}},[]),(0,u.useEffect)(()=>{WT.persistTools()},[]),(0,F.jsxs)(F.Fragment,{children:[r&&(0,F.jsx)(QD,{onClose:()=>WT.closeSettings()}),a&&(0,F.jsx)(iO,{tool:a,onClose:()=>WT.closeTool()}),o&&(0,F.jsx)(fO,{tool:o,onClose:()=>WT.closeTool()})]})}function nO({pending:e,slugDraft:t,slugError:n,preview:r,busy:i,onSlugChange:a,onPreviewChange:o,onCancel:s,onConfirm:c}){let l=e.bundle,u=l.files.reduce((e,t)=>e+new TextEncoder().encode(t.content).length,0),d=rE(l),f=nE(l),p=l.files.find(e=>e.path===r)??l.files[0];return(0,F.jsxs)(`div`,{className:`tool-share-review`,"data-tool-import-review":`1`,children:[(0,F.jsx)(`h3`,{className:`tool-share-title`,"data-tool-import-name":`1`,children:l.name}),l.description&&(0,F.jsx)(`p`,{className:`tool-hint`,"data-tool-import-desc":`1`,children:l.description}),e.unnamedFormat&&(0,F.jsx)(`p`,{className:`tool-import-note`,"data-tool-import-unbranded":`1`,children:`这个文件没有 Super Pi 的工具标记,已按内容形状读取——粘出来的 tool_register 参数也认。`}),(0,F.jsxs)(`p`,{className:`tool-hint`,"data-tool-import-files":`1`,children:[l.files.length,` 个文件 · 共 `,aE(u)]}),(0,F.jsx)(`p`,{className:`tool-hint`,"data-tool-import-paths":`1`,children:l.files.map(e=>e.path).join(` · `)}),l.script&&(0,F.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-script":l.script.path,children:[(0,F.jsxs)(`b`,{children:[`⚠ 含 Python 脚本 `,l.script.path]}),(0,F.jsx)(`br`,{}),`导入后运行这个工具时,这段代码会在本机上执行,权限和你自己的 Python 一样(能读你的文件、能联网)。 可以先展开下面的文件列表把它读完。`]}),(0,F.jsxs)(`p`,{className:d.tone===`warn`?`tool-import-warn`:`tool-import-note`,"data-tool-import-env":d.tone,children:[(0,F.jsxs)(`b`,{children:[d.tone===`warn`?`⚠ `:`✓ `,d.text]}),l.environment?.fingerprint?.python&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`br`,{}),`导出方环境:Python `,l.environment.fingerprint.python,` · `,l.environment.fingerprint.platform||`未知平台`,`。版本对不上时会标出来,但不会拦住你运行。`]})]}),f&&(0,F.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-model":`1`,children:[(0,F.jsx)(`b`,{children:`⚠ 这个工具可以调用模型`}),(0,F.jsx)(`br`,{}),f.text,`。模型由 Super Pi 通过 Pi 调用(凭据和模型选择都在 Super Pi 这边),工具只拿到文字。`]}),(0,F.jsxs)(`details`,{className:`tool-import-files`,"data-tool-import-filebox":l.files.length,children:[(0,F.jsxs)(`summary`,{children:[`查看文件(`,l.files.length,`)`]}),(0,F.jsx)(`div`,{className:`tool-share-tabs`,children:l.files.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`tool-share-tab`,"aria-pressed":e.path===p?.path,"data-tool-import-file":e.path,onClick:()=>o(e.path),children:e.path},e.path))}),(0,F.jsx)(`pre`,{className:`tool-import-code`,"data-tool-import-code":p?.path,children:p?.content??``})]}),(0,F.jsxs)(`label`,{className:`tool-hint`,"data-tool-import-slug":`1`,children:[`导入后的 slug(工具的短名字,也是它在磁盘上的目录名)`,(0,F.jsx)(`input`,{className:`tool-input`,value:t,"aria-label":`导入后的 slug`,onChange:e=>a(e.target.value)})]}),n&&(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-import-slug-error":`1`,children:n}),(0,F.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-import-cancel":`1`,onClick:s,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-confirm":`1`,disabled:i,onClick:c,children:i?`导入中…`:`导入`})]})]})}function rO(e){let t=e.replace(/^[./]+/,``).slice(0,30).trim();if(!/^[a-z][a-z0-9+.-]*:/i.test(e))return t||e.slice(0,30);try{return new URL(e,typeof window>`u`?`http://localhost`:window.location.href).hostname||t||e.slice(0,30)}catch{return e.slice(0,30)}}function iO({tool:e,onClose:t}){return(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,We.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay`,"data-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,F.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-dialog-title`,"data-tool-dialog":e.id,children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,F.jsxs)(`h2`,{className:`tool-dialog-title`,id:`tool-dialog-title`,children:[(0,F.jsx)(Jw,{className:`tool-dialog-glyph`,glyph:e.glyph}),e.name]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭${e.name}`,onClick:t,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`tool-dialog-body`,children:[e.kind===`calculator`&&(0,F.jsx)(oO,{}),e.kind===`timestamp`&&(0,F.jsx)(sO,{}),e.kind===`link`&&(0,F.jsx)(cO,{tool:e})]})]})}),document.body)}function aO({image:e,onClose:t}){return(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,We.createPortal)((0,F.jsx)(`div`,{className:`lightbox-overlay`,"data-lightbox-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,F.jsxs)(`div`,{className:`lightbox-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`lightbox-title`,"data-lightbox-dialog":`1`,children:[(0,F.jsxs)(`div`,{className:`lightbox-head`,children:[(0,F.jsx)(`h2`,{className:`lightbox-title`,id:`lightbox-title`,children:e.name||`图片大图`}),(0,F.jsx)(`button`,{type:`button`,className:`lightbox-close`,"data-lightbox-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭大图`,onClick:t,children:`✕`})]}),(0,F.jsx)(`div`,{className:`lightbox-body`,children:(0,F.jsx)(`img`,{src:e.url,alt:e.name||`图片大图`,className:`lightbox-image`})})]})}),document.body)}function oO(){let[e,t]=(0,u.useState)(`12 * (3 + 4)`),n=Hn(e),r=e=>{t(t=>t+e)};return(0,F.jsxs)(`div`,{className:`tool-calc`,"data-tool-calc":`1`,children:[(0,F.jsx)(`input`,{className:`tool-input tool-calc-input`,"data-calc-input":`1`,value:e,maxLength:200,"aria-label":`算式`,spellCheck:!1,autoComplete:`off`,placeholder:`例如 (12 + 8) / 4`,onChange:e=>{t(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()}}),(0,F.jsx)(`div`,{className:`tool-calc-keys`,"data-calc-keys":`1`,children:[[`7`,`7`],[`8`,`8`],[`9`,`9`],[`÷`,`/`],[`(`,`(`],[`)`,`)`],[`4`,`4`],[`5`,`5`],[`6`,`6`],[`×`,`*`],[`^`,`^`],[`%`,`%`],[`1`,`1`],[`2`,`2`],[`3`,`3`],[`-`,`-`],[`←`,`back`],[`C`,`clear`],[`0`,`0`],[`.`,`.`],[`+`,`+`]].map(([e,n])=>(0,F.jsx)(`button`,{type:`button`,className:`tool-calc-key`,"data-calc-key":n,"aria-label":e===`C`?`清空`:e===`←`?`退格`:`输入 ${e}`,onClick:()=>{n===`clear`?t(``):n===`back`?t(e=>e.slice(0,-1)):r(n)},children:e},e))}),n.ok?(0,F.jsx)(`p`,{className:`tool-calc-result`,"data-calc-result":`1`,"data-calc-value":String(n.value),children:Un(n.value)}):(0,F.jsx)(`p`,{className:`tool-calc-error`,"data-calc-error":`1`,role:`alert`,children:n.reason})]})}function sO(){let[e,t]=(0,u.useState)(``),n=Wn(e),r=n.ok?Kn(n.ms):null;return(0,F.jsxs)(`div`,{className:`tool-stamp`,"data-tool-stamp":`1`,children:[(0,F.jsx)(`input`,{className:`tool-input`,"data-stamp-input":`1`,value:e,maxLength:64,spellCheck:!1,"aria-label":`时间戳或日期`,placeholder:`1757000000 或 2026-10-08T09:00:00`,onChange:e=>t(e.target.value)}),r?(0,F.jsxs)(`dl`,{className:`tool-stamp-out`,"data-stamp-result":`1`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`本地时间`}),(0,F.jsx)(`dd`,{"data-stamp-local":`1`,children:r.local})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`ISO(UTC)`}),(0,F.jsx)(`dd`,{"data-stamp-iso":`1`,children:r.iso})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`秒`}),(0,F.jsx)(`dd`,{"data-stamp-seconds":`1`,children:r.seconds})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`毫秒`}),(0,F.jsx)(`dd`,{"data-stamp-ms":`1`,children:r.milliseconds})]})]}):(0,F.jsx)(`p`,{className:`tool-stamp-error`,"data-stamp-error":`1`,role:`alert`,children:n.ok?`这个日期无法显示。`:n.reason})]})}function cO({tool:e}){let[t,n]=(0,u.useState)(!1),r=async()=>{let e=await ju(`请为 Super Pi 开发一个全局右侧栏工具并自动挂载。不要启动独立 HTTP 服务器。通过内置 tool_register 提交完整的 HTML/JS/CSS 文件;工具将被 Super Pi 保存并在所有 workspace 可用。如需计算,注册一个 Python 脚本(不接受 shell 命令),参数经 JSON stdin 传入,stdout 只输出 JSON 结果。在页面里加载 ./super-pi-tool.js,使用 SuperPiTool.run(params)、wait(runId)、get(runId) 和 cancel(runId) 执行、等待、查看和取消任务。它们会自动绑定当前工具;不要调用 /api/exec,也不要猜测 toolId。`);n(e),window.setTimeout(()=>n(!1),1800)};return(0,F.jsxs)(`div`,{className:`tool-link`,"data-tool-link":e.id,children:[(0,F.jsx)(`p`,{className:`tool-hint`,children:`这是旧版外部网页链接;新工具由 Super Pi 统一托管,并可选绑定受控 Python 脚本。`}),(0,F.jsx)(`code`,{className:`tool-link-url`,"data-tool-link-url":e.id,children:e.url}),(0,F.jsxs)(`div`,{className:`tool-link-actions`,children:[(0,F.jsx)(`a`,{className:`tool-link-open`,"data-tool-link-open":e.id,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:e.url,children:`在新标签页打开 ↗`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-copy-prompt":e.id,onClick:()=>void r(),children:t?`已复制`:`复制开发 Prompt`})]}),/^https?:\/\//i.test(e.url??``)&&(0,F.jsx)(`iframe`,{className:`tool-link-frame`,"data-tool-frame":e.id,src:e.url,title:e.name,sandbox:`allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts`,referrerPolicy:`no-referrer`})]})}var lO=`(max-width: 1100px)`,uO=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function dO(e){let t=`super-pi.mounted-tool.owner.`+e;try{let e=window.localStorage.getItem(t);if(e&&/^[0-9a-f]{32}$/.test(e))return e}catch{}let n=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);try{window.localStorage.setItem(t,n)}catch{}return n}function fO({tool:e,onClose:t}){(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let n=(0,u.useMemo)(()=>dO(e.id),[e.id]),r=e.dialogSize??{width:1100,height:780},i={width:`min(${r.width}px, calc(100vw - 32px))`,height:`min(${r.height}px, calc(100dvh - 32px))`};return(0,We.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay`,"data-mounted-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,F.jsxs)(`div`,{className:`tool-dialog mounted-tool-dialog`,style:i,"data-mounted-tool-dialog":e.id,role:`dialog`,"aria-modal":`true`,children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,F.jsxs)(`h2`,{className:`tool-dialog-title`,children:[(0,F.jsx)(Jw,{className:`tool-dialog-glyph`,glyph:Xw(e)}),e.name]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,onClick:t,children:`✕`})]}),(0,F.jsx)(`div`,{className:`tool-dialog-body`,children:(0,F.jsx)(`iframe`,{className:`tool-link-frame`,src:ke(`/tools/${encodeURIComponent(e.id)}/#super-pi-owner=${n}`),title:e.name,sandbox:`allow-forms allow-modals allow-popups allow-scripts`,referrerPolicy:`no-referrer`})})]})}),document.body)}function pO(e,t,n){let r=Math.max(0,Math.round(n)-480),i=uO(520,180,Math.max(180,r-240)),a=uO(Math.round(e),180,i),o=uO(640,240,Math.max(240,r-a));return{sidebar:a,rail:uO(Math.round(t),240,o),sidebarMin:180,sidebarMax:i,railMin:240,railMax:o,sumCap:r}}var mO=`super-pi.rail-widths.v1`,hO=`super-pi.reader-state.v1`,gO=`super-pi.folded-groups.v1`;function _O(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.folded-groups.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t=e=>{let t={};if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t};return{workspaces:t(e.workspaces),archived:t(e.archived)}}catch{return{}}}function vO(e){try{typeof window<`u`&&window.localStorage.setItem(gO,JSON.stringify(e))}catch{}}var yO=e=>{let t=document.querySelector(`[data-workspace-group="${CSS.escape(e)}"]`);return t?[...t.querySelectorAll(`.conversation-row[data-session-root]`)].map(e=>({id:e.dataset.sessionRoot??``,middle:(()=>{let t=e.getBoundingClientRect();return t.top+t.height/2})()})).filter(e=>e.id!==``):[]},bO=6,xO=400,SO=32,CO=48,wO=e=>{e.dataset.programmaticScroll=`true`,window.setTimeout(()=>{delete e.dataset.programmaticScroll},0)};function TO(e,t,n=!1,r=!1){let i=e.scrollHeight-e.clientHeight-e.scrollTop,a=n?!1:r?!0:t.followTail?i<=CO:i<=SO,o,s;if(!a){let t=e.getBoundingClientRect().top,n=[...e.querySelectorAll(`[data-transcript-key]`)].find(e=>e.getBoundingClientRect().bottom>t);o=n?.dataset.transcriptKey,s=n?n.getBoundingClientRect().top-t:void 0}return{followTail:a,scrollTop:e.scrollTop,...o?{anchorKey:o,anchorOffset:s}:{}}}function EO(){try{if(typeof window>`u`)return{conversations:{}};let e=JSON.parse(window.localStorage.getItem(`super-pi.reader-state.v1`)??`null`);if(!e||typeof e!=`object`)return{conversations:{}};let t={};if(e.conversations&&typeof e.conversations==`object`)for(let[n,r]of Object.entries(e.conversations)){let e=r;typeof e.followTail==`boolean`&&(t[n]={followTail:e.followTail,scrollTop:Number.isFinite(e.scrollTop)?Math.max(0,Number(e.scrollTop)):0,...typeof e.anchorKey==`string`?{anchorKey:e.anchorKey}:{},...Number.isFinite(e.anchorOffset)?{anchorOffset:Number(e.anchorOffset)}:{}})}let n={};if(e.readAt&&typeof e.readAt==`object`)for(let[t,r]of Object.entries(e.readAt))typeof r==`string`&&(n[t]=r);return{activeId:typeof e.activeId==`string`?e.activeId:void 0,workspaceId:typeof e.workspaceId==`string`?e.workspaceId:void 0,conversations:t,readAt:n}}catch{return{conversations:{}}}}function DO(e){try{typeof window<`u`&&window.localStorage.setItem(hO,JSON.stringify(e))}catch{}}var OO=`super-pi.session-tabs.v1`;function kO(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function AO(e,t,n){let r=e.touched.has(t),i=e.touched;if(r){let r=new Set(e.touched);r.delete(t),n&&r.add(n),i=r}return{ids:e.ids.flatMap(e=>e===t?n?[n]:[]:[e]),previewId:e.previewId===t?n&&!r?n:void 0:e.previewId,emptied:e.emptied,touched:i}}function jO(){try{if(typeof window>`u`)return{ids:[]};let e=JSON.parse(window.sessionStorage.getItem(`super-pi.session-tabs.v1`)??`null`);if(!e||typeof e!=`object`)return{ids:[]};let t=e,n=Array.isArray(t.ids)?[...new Set(t.ids.filter(e=>typeof e==`string`))]:[],r=Array.isArray(t.touched)?[...new Set(t.touched.filter(e=>typeof e==`string`))]:[],i=typeof t.previewId==`string`&&n.includes(t.previewId)&&!r.includes(t.previewId)?t.previewId:void 0;i&&i!==t.activeId&&(n=n.filter(e=>e!==i));let a=typeof t.activeId==`string`&&n.includes(t.activeId)?t.activeId:void 0,o=typeof t.workspaceLandingId==`string`?t.workspaceLandingId:void 0;return{ids:n,activeId:a,workspaceLandingId:o,previewId:i===a?i:void 0,touched:r,emptied:n.length===0&&(t.emptied===!0||!!i)}}catch{return{ids:[]}}}function MO(e,t,n){try{if(typeof window>`u`)return;let{ids:r,previewId:i,touched:a,emptied:o}=e;window.sessionStorage.setItem(OO,JSON.stringify({ids:r,...t&&r.includes(t)?{activeId:t}:{},...n?{workspaceLandingId:n}:{},...i&&r.includes(i)?{previewId:i}:{},...a.size?{touched:[...a]}:{},...o?{emptied:o}:{}}))}catch{}}function NO(){try{if(typeof window>`u`)return{};let e=window.localStorage.getItem(mO);if(e===null)return{};let t=JSON.parse(e),n=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?Math.round(e):void 0;return{sidebar:n(t.sidebar),rail:n(t.rail)}}catch{return{}}}function PO(e){try{if(typeof window>`u`)return;window.localStorage.setItem(mO,JSON.stringify(e))}catch{}}function FO({side:e,width:t,min:n,max:r,label:i,onWidth:a}){let[o,s]=(0,u.useState)(!1),c=e=>e.shiftKey?64:16;return(0,F.jsx)(`div`,{className:`rail-resizer rail-resizer-${e}${o?` rail-resizer-dragging`:``}`,"data-rail-resizer":e,"data-rail-resizer-dragging":o?`true`:`false`,"data-rail-resizer-width":t,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,"aria-valuenow":t,"aria-valuemin":n,"aria-valuemax":r,tabIndex:0,onMouseDown:i=>{i.preventDefault(),i.currentTarget.focus();let o=i.clientX,c=t;s(!0);let l=document.body,u=l.style.cursor,d=l.style.userSelect;l.style.cursor=`col-resize`,l.style.userSelect=`none`;let f=t=>{let i=e===`left`?t.clientX-o:o-t.clientX;a(uO(c+i,n,r))},p=()=>{l.style.cursor=u,l.style.userSelect=d,s(!1),window.removeEventListener(`mousemove`,f),window.removeEventListener(`mouseup`,p)};window.addEventListener(`mousemove`,f),window.addEventListener(`mouseup`,p)},onKeyDown:i=>{let o=c(i);i.key===`ArrowLeft`?(i.preventDefault(),a(uO(e===`left`?t-o:t+o,n,r))):i.key===`ArrowRight`?(i.preventDefault(),a(uO(e===`left`?t+o:t-o,n,r))):i.key===`Home`?(i.preventDefault(),a(n)):i.key===`End`&&(i.preventDefault(),a(r))}})}var IO=`super-pi.composer-height.v1`,LO=148,RO=.55,zO=()=>Math.max(LO,Math.round((typeof window>`u`?800:window.innerHeight)*RO)),BO=e=>{let t=Number.isFinite(e)?e:LO;return Math.round(Math.min(zO(),Math.max(LO,t)))},VO=()=>{try{let e=window.localStorage.getItem(IO);return e===null?LO:BO(Number(e))}catch{return LO}};function HO({height:e,onHeight:t}){let[n,r]=(0,u.useState)(!1),i=e=>e.shiftKey?64:16,a=zO();return(0,F.jsx)(`div`,{className:`composer-resize${n?` composer-resize-dragging`:``}`,"data-composer-resize":`1`,"data-composer-resize-dragging":n?`true`:`false`,"data-composer-height":e,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整消息编辑区高度`,"aria-valuenow":e,"aria-valuemin":LO,"aria-valuemax":a,tabIndex:0,onMouseDown:n=>{n.preventDefault(),n.currentTarget.focus();let i=n.clientY,a=e;r(!0);let o=document.documentElement,s=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let c=e=>{let t=BO(a+(i-e.clientY));o.style.setProperty(`--composer-height`,`${t}px`)},l=()=>{document.body.style.cursor=``,document.body.style.userSelect=s;let n=Number.parseFloat(o.style.getPropertyValue(`--composer-height`));r(!1),window.removeEventListener(`mousemove`,c),window.removeEventListener(`mouseup`,l),t(Number.isFinite(n)?n:e)};window.addEventListener(`mousemove`,c),window.addEventListener(`mouseup`,l)},onKeyDown:n=>{let r=i(n);n.key===`ArrowUp`?(n.preventDefault(),t(BO(e+r))):n.key===`ArrowDown`?(n.preventDefault(),t(BO(e-r))):n.key===`Home`?(n.preventDefault(),t(LO)):n.key===`End`?(n.preventDefault(),t(a)):n.key===`PageUp`?(n.preventDefault(),t(BO(e+96))):n.key===`PageDown`&&(n.preventDefault(),t(BO(e-96)))}})}function UO(e,t,n){if(!e.length)return;let r=n?e.find(e=>e.workspaceId===n):void 0;if(r)return r;if(!(n&&t.some(e=>e.id===n)))return n?e.find(e=>h(e.workspaceId).server===h(n).server):e[0]}function WO(e,t,n){let r=n&&e?JSON.stringify([e,t,n]):void 0,[i,a]=(0,u.useState)();(0,u.useEffect)(()=>{if(!r||!n||!e)return;let i=new AbortController;return Ae(`/api/files/diff?${new URLSearchParams({workspaceId:e,path:n,...t?{cwd:t}:{}})}`,{signal:i.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{i.signal.aborted||a({scope:r,diff:e,error:``})}).catch(e=>{i.signal.aborted||a({scope:r,diff:null,error:e instanceof Error?e.message:`读取差异失败`})}),()=>i.abort()},[r,e,t,n]);let o=i?.scope===r?i:void 0;return{diff:o?.diff??null,error:o?.error??``,loading:!!r&&!o}}function GO(e){try{let t=`super-pi.browser-notification-events`,n=Date.now(),r=JSON.parse(window.localStorage.getItem(t)??`[]`).filter(e=>Array.isArray(e)&&typeof e[0]==`string`&&typeof e[1]==`number`&&n-e[1]<864e5);return!r.some(([t])=>t===e)&&(window.localStorage.setItem(t,JSON.stringify([...r.slice(-63),[e,n]])),!0)}catch{return!0}}function KO(){let[e,t]=(0,u.useState)(gE),[n,r]=(0,u.useState)(()=>{try{return typeof window<`u`&&window.localStorage.getItem(`super-pi.browser-notifications`)===`enabled`}catch{return!1}}),[i,a]=(0,u.useState)(()=>qr()),o=(0,u.useCallback)(()=>a(qr()),[]),s=(0,u.useRef)(new Map),c=(0,u.useRef)(!1),l=(0,u.useRef)(new Map),d=(0,u.useCallback)(e=>{t(t=>{let n=typeof e==`function`?e(t):e;return vt(n,t)})},[]),[f,p]=(0,u.useState)(()=>Yd().map(e=>{let t=new Date().toISOString();return{id:e.clientId,key:`send:${e.conversationId}:${e.clientId}`,serverId:ce(e.conversationId),retry:!0,command:{...e},apply:n=>Qd(n,e,t),accepted:t=>!!t.conversations.find(t=>t.id===e.conversationId)?.messages.some(t=>t.id===e.clientId)}})),m=(0,u.useRef)(f),g=(0,u.useRef)(null);g.current||=EO();let _=(0,u.useRef)(null);_.current||=jO();let v=_.current,y=f.reduce((e,t)=>t.apply(e),e),[b,x]=(0,u.useState)(v.workspaceLandingId?void 0:v.activeId??g.current.activeId),[C,w]=(0,u.useState)(v.workspaceLandingId??g.current.workspaceId),[T,E]=(0,u.useState)(!1),D=se(),O=T&&D.statuses.get(D.activeServer)?.state===`online`,[k,A]=(0,u.useState)(),[j,ee]=(0,u.useState)(()=>_O().workspaces??{}),[M,N]=(0,u.useState)(()=>({ids:v.ids,previewId:v.previewId,touched:new Set(v.touched??[]),emptied:v.emptied})),ne=M.ids,re=M.previewId,ie=(0,u.useRef)(0),[ae,oe]=(0,u.useState)(),[P,_e]=(0,u.useState)({entries:[],index:-1}),[ve,ye]=(0,u.useState)(),be=(0,u.useRef)(new Set),xe=M.emptied===!0,[Se,Ce]=(0,u.useState)(!1),[we,Te]=(0,u.useState)(!1),[Ee,De]=(0,u.useState)(),Oe=(0,u.useRef)(null),je=(0,u.useRef)(void 0),Me=(0,u.useRef)(g.current.conversations),Ne=(0,u.useRef)(ne);Ne.current=ne;let Fe=(0,u.useRef)(g.current.readAt??{}),[Ie,Le]=(0,u.useState)(0),[Re,ze]=(0,u.useState)(_w),[Ve,He]=(0,u.useState)(()=>Re?[Re]:[]),[Ue,We]=(0,u.useState)(!!Re),[I,Ge]=(0,u.useState)(()=>Re?`group`:`session`),{index:Ke,reload:qe,remember:Je,forget:Ye,activities:Xe,recordActivity:Ze}=Dw(y.workspaces,O),[Qe,$e]=(0,u.useState)(()=>new Set),et=Re?.workspaceId??``,tt=Re?.roomId??``,nt=Ke[et]?.rooms.find(e=>e.id===tt),rt=nt?.title;(0,u.useEffect)(()=>{vw(I===`group`?Re:void 0)},[Re,I]),(0,u.useEffect)(()=>{I===`group`&&Se&&!y.workspaces.some(e=>e.id===et&&!e.closedAt)&&(We(!1),Ge(`session`))},[I,Se,y.workspaces,et]);let it=(0,u.useRef)(null),at=(0,u.useRef)(null),ot=(0,u.useRef)(void 0),st=(0,u.useRef)(!1),ut=(0,u.useRef)(!0),[dt,ft]=(0,u.useState)({followTail:!0,scrollTop:0}),pt=(0,u.useRef)(!1),mt=(0,u.useRef)(new Map),ht=(0,u.useRef)(void 0),gt=(0,u.useRef)([]),_t=(0,u.useRef)(void 0),vt=(0,u.useCallback)((e,t)=>{let n=new Map(t.conversations.map(e=>[e.id,e]));return{...e,conversations:e.conversations.map(e=>{let t=n.get(e.id);if(e.messagesLoaded===!1||!t||t.messagesLoaded===!1||t.status!==`running`)return e;let r=new Map(t.messages.map(e=>[e.id,e]));return{...e,messages:e.messages.map(e=>{let t=r.get(e.id);return!t||!(t.content.length>e.content.length||(t.thinking?.length??0)>(e.thinking?.length??0))?e:{...e,content:t.content,thinking:t.thinking,thinkingActive:t.thinkingActive,thinkingBlocks:SE(t.thinkingBlocks,e.thinkingBlocks)}})}})}},[]),yt=(0,u.useCallback)(()=>{if(_t.current!==void 0&&(cancelAnimationFrame(_t.current),_t.current=void 0),!gt.current.length)return;let e=gt.current;gt.current=[];let t=new Map;for(let n of e){let e=`${n.conversationId}\u0000${n.messageId}`,r=t.get(e)??[];r.push(n),t.set(e,r)}d(e=>({...e,conversations:e.conversations.map(e=>{let n=e.messages.map(n=>{let r=t.get(`${e.id}\u0000${n.id}`);if(!r)return n;let i={...n};for(let e of r){if(e.type===`message.delta`){i.content+=e.delta;continue}if(i.thinkingActive=e.active,!e.delta)continue;let t=e.at??i.content.length,n=xE(i.thinkingBlocks??[],e,t);i={...i,thinking:(i.thinking??``)+e.delta,thinkingBlocks:n}}return i});return n.every((t,n)=>t===e.messages[n])?e:{...e,messages:n}})}))},[]),bt=(0,u.useCallback)(e=>{let t=gt.current,n=t.at(-1);n&&n.type===e.type&&n.conversationId===e.conversationId&&n.messageId===e.messageId&&(e.type!==`message.thinking`||n.type===`message.thinking`&&n.at===e.at&&n.active===e.active&&n.blockIndex===e.blockIndex)?t[t.length-1]={...e,delta:n.delta+e.delta}:t.push(e),_t.current===void 0&&(_t.current=requestAnimationFrame(yt))},[yt]),wt=(0,u.useCallback)(e=>{ht.current=e},[]),[Dt,Ot]=(0,u.useState)(()=>_O().archived??{});(0,u.useEffect)(()=>{vO({workspaces:j,archived:Dt})},[j,Dt]);let[kt,At]=(0,u.useState)(()=>rT());(0,u.useEffect)(()=>{iT(kt)},[kt]);let[jt,Mt]=(0,u.useState)(),Nt=(0,u.useRef)(0),Pt=(0,u.useRef)(``),Ft=(e,t,n,r)=>{let i=(e.target instanceof Element?e.target:void 0)?.closest(`button`);if(i&&!i.classList.contains(`conversation`)||e.button!==0)return;let a=e.clientY,o=e.pointerType===`touch`,s=!1,c,l=[],u,d=!1,f=e=>{let t=l.filter(e=>e.id!==n);if(t.length===0){u=void 0,d=!1;return}let r=0;for(;r<t.length&&t[r].middle<e;)r+=1;r<t.length?(u=t[r].id,d=!1):(u=t[t.length-1].id,d=!0)},p=()=>Mt(e=>e&&e.dropRootId===u&&e.dropAfter===d?e:{workspaceId:t,conversationId:n,dropRootId:u,dropAfter:d}),m=()=>{s||(s=!0,l=yO(t),f(a),document.body.style.userSelect=`none`,p())},h=e=>{if(!s){if(o){c!==void 0&&window.clearTimeout(c),c=void 0;return}if(Math.abs(e.clientY-a)<bO)return;m()}f(e.clientY),p()},g=e=>{if(window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,v),document.removeEventListener(`touchmove`,y),c!==void 0&&window.clearTimeout(c),document.body.style.userSelect=``,s&&e){let e=r.filter(e=>e!==n),i=u===void 0?e.length:d?e.indexOf(u)+1:e.indexOf(u);At(e=>({...e,[t]:tT(r,n,i)})),Nt.current=Date.now(),Pt.current=n}Mt(void 0)},_=()=>g(!0),v=()=>g(!1),y=e=>{s&&e.preventDefault()};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,v),o&&(document.addEventListener(`touchmove`,y,{passive:!1}),c=window.setTimeout(m,xO))},[It,Lt]=(0,u.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage.getItem(`super-pi.user-nickname`)??``}catch{return``}}),Rt=e=>{let t=e.slice(0,24);Lt(t);try{window.localStorage.setItem(`super-pi.user-nickname`,t)}catch{}},zt=It.trim()||`你`,[Bt,Vt]=(0,u.useState)(),[Ht,Ut]=(0,u.useState)([]),[Wt,Gt]=(0,u.useState)([]),[Kt,qt]=(0,u.useState)(),[Jt,Yt]=(0,u.useState)(),[Xt,Zt]=(0,u.useState)([]),[Qt,$t]=(0,u.useState)([]),[en,tn]=(0,u.useState)(),[nn,rn]=(0,u.useState)(),[an,on]=(0,u.useState)(),[sn,cn]=(0,u.useState)(),[ln,un]=(0,u.useState)(),dn=Ur(an),fn=(0,u.useMemo)(()=>Ht.filter(e=>e.request.blocking),[Ht]),[pn,mn]=(0,u.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1100px)`).matches),[hn,gn]=(0,u.useState)(`chat`),[_n,vn]=(0,u.useState)(!1),yn=(0,u.useCallback)(()=>{gn(`chat`),window.matchMedia(`(max-width: 700px)`).matches&&mn(!0)},[]),[bn,xn]=(0,u.useState)(!1),[Sn,Cn]=(0,u.useState)(`workspace`),[wn,Tn]=(0,u.useState)(()=>localStorage.getItem(`super-pi.server-filter`)||`all`),[Dn,On]=(0,u.useState)(g.current.workspaceId),[kn,An]=(0,u.useState)(g.current.workspaceId),[jn,Mn]=(0,u.useState)(!1),Nn=(0,u.useRef)(jn);Nn.current=jn;let[Pn,Fn]=(0,u.useState)(()=>typeof window>`u`?1440:window.innerWidth);(0,u.useEffect)(()=>{let e=()=>Fn(window.innerWidth);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]);let[In,Ln]=(0,u.useState)(St);(0,u.useEffect)(()=>Ct(In),[In]);let[Rn,zn]=(0,u.useState)(NO),Bn=pO(Rn.sidebar??270,Rn.rail??320,Pn>1100?Pn-80:Pn);(0,u.useEffect)(()=>{PO({sidebar:Rn.sidebar??270,rail:Rn.rail??320})},[Rn.sidebar,Rn.rail]);let Vn=e=>zn(t=>({...t,sidebar:e})),Hn=e=>zn(t=>({...t,rail:e})),[Un,Wn]=(0,u.useState)(null);(0,u.useEffect)(()=>{Wn(VO())},[]),(0,u.useEffect)(()=>{Un!==null&&document.documentElement.style.setProperty(`--composer-height`,`${Un}px`)},[Un]);let Gn=e=>{let t=BO(e);Wn(t);try{window.localStorage.setItem(IO,String(t))}catch{}};(0,u.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(lO),t=e=>{e.matches&&mn(!0)};return e.addEventListener(`change`,t),e.matches&&mn(!0),()=>e.removeEventListener(`change`,t)},[]);let Kn=Pn<=1100;(0,u.useEffect)(()=>{if(!Kn||pn)return;let e=e=>{e.key===`Escape`&&(e.defaultPrevented||document.querySelector(`.tool-overlay, .lightbox-overlay, .quick-open-backdrop, .ctx-menu, .overlay, .picker-menu, .content-search-overlay`)||(e.preventDefault(),mn(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Kn,pn]);let[qn,Jn]=(0,u.useState)({}),[Yn,Xn]=(0,u.useState)({}),[Zn,Qn]=(0,u.useState)({}),[$n,er]=(0,u.useState)({}),[tr,nr]=(0,u.useState)(null),[rr,ir]=(0,u.useState)(),[ar,or]=(0,u.useState)(()=>new Set);(0,u.useEffect)(()=>{or(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>{let t=y.conversations.find(t=>t.id===e);return t?jD(t):!1}));return t.size===e.size?e:t})},[y.conversations]);let[sr,cr]=(0,u.useState)(),[lr,ur]=(0,u.useState)(),dr=(0,u.useRef)(new Map),[fr,pr]=(0,u.useState)(()=>{let e=$d(`super-pi.composer-drafts.v1`,{});return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,attachments:sD(t.text,t.attachments)}]))}),mr=(0,u.useRef)(fr),gr=(0,u.useRef)(!1);mr.current=fr,(0,u.useEffect)(()=>{let e=()=>{let e=Object.entries(mr.current).filter(([e,t])=>!e.startsWith(`pending:`)&&(t.text||t.images.length||t.attachments.length)).map(([e,{text:t,images:n,attachments:r}])=>[e,{text:t,images:n,attachments:r,uploading:0}]),t=ef(`super-pi.composer-drafts.v1`,Object.fromEntries(e));!t&&e.length&&!gr.current&&Y(`浏览器无法保存聊天草稿,刷新前请先保留这段内容。`,`warning`),gr.current=!t&&e.length>0},t=window.setTimeout(e,250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[fr]);let _r=(0,u.useRef)(new Set),[vr,yr]=(0,u.useState)([]),[br,xr]=(0,u.useState)([]),[Sr,Cr]=(0,u.useState)(),[wr,Tr]=(0,u.useState)(!1),Er=(0,u.useRef)(null),Dr=(0,u.useRef)(!1),Or=(0,u.useRef)(0),kr=(0,u.useRef)([]),Ar=(0,u.useRef)(void 0),jr=(0,u.useRef)(!1),Mr=(0,u.useRef)(new Set),Nr=(0,u.useRef)(new Set),Pr=(0,u.useRef)(new Map),Fr=(0,u.useRef)(new Map),[Ir,Lr]=(0,u.useState)(()=>Date.now());(0,u.useEffect)(()=>{let e=window.setInterval(()=>Lr(Date.now()),3e4);return()=>window.clearInterval(e)},[]);let Rr=(0,u.useMemo)(()=>y.conversations.filter(e=>!e.archivedAt),[y.conversations]),zr=(0,u.useMemo)(()=>e.conversations.filter(e=>!e.archivedAt),[e.conversations]),Br=(0,u.useMemo)(()=>new Set(y.collapsedConversationIds??[]),[y.collapsedConversationIds]),L=(0,u.useMemo)(()=>{let e=Rr.find(e=>e.id===b);if(e)return e;if(!(xe||jn||te(b??C)))return UO(Rr,y.workspaces,C)},[xe,jn,b,Rr,C,y.workspaces]),Vr=(0,u.useMemo)(()=>L?{workspaceId:L.workspaceId,conversationId:L.id,onImageOpen:Cr}:void 0,[L?.workspaceId,L?.id]),[Hr,Gr]=(0,u.useState)(`queue`),Kr=!!(L&&jD(L));(0,u.useEffect)(()=>{Gr(`queue`)},[L?.id,Kr]);let[Jr,R]=(0,u.useState)([]),Zr=(0,u.useMemo)(()=>lw(L?.parentConversationId,L?.parentConversationId?y.conversations.find(e=>e.id===L.parentConversationId):void 0),[L,y.conversations]),Qr=!!(L&&y.unlockedChildConversationIds?.includes(L.id)),$r=Zr&&!Qr,ei=(0,u.useMemo)(()=>(y.conversations||[]).filter(e=>e.parentConversationId===L?.id),[y.conversations,L?.id]),ti=(0,u.useMemo)(()=>(y.conversations||[]).find(e=>e.id===L?.parentConversationId),[y.conversations,L?.parentConversationId]),ni=(0,u.useMemo)(()=>L?dw({conversation:L,parent:ti,directChildren:ei,isTopLevelUnread:!1}):null,[L,ti,ei]),ri=it.current;if(ri){let e=ri.dataset.messageScrollContainer;e&&L?.id&&e!==L?.id&&ri.querySelector(`[data-transcript-key]`)&&(Me.current[e]=TO(ri,Me.current[e]??{followTail:!0,scrollTop:0}))}ut.current=L?.messagesLoaded!==!1,(0,u.useEffect)(()=>{if(!Se||te(b??C)||(xe||jn)&&!b||b&&zr.some(e=>e.id===b)||b&&m.current.some(e=>e.temporaryId===b))return;let e=UO(Rr,y.workspaces,C);xe&&e||(b&&!e&&I!==`group`&&(ie.current++,Ge(`session`)),x(e?.id),e&&N(t=>t.emptied||t.ids.length===0||t.ids.includes(e.id)?t:{...t,ids:[...t.ids,e.id]}))},[xe,jn,b,zr,Rr,Se,C,y.workspaces,I]),(0,u.useEffect)(()=>{A(void 0)},[b,C]);let ii=(0,u.useMemo)(()=>y.workspaces.find(e=>e.id===C)??(jn||te(C)?void 0:y.workspaces[0]),[y.workspaces,C,jn]),ai=ii&&!Rr.some(e=>e.workspaceId===ii.id)?ii:void 0,oi=ii?.id.startsWith(`pending:`)===!0,[si,ci]=(0,u.useState)(``);(0,u.useEffect)(()=>{ci(``)},[ii?.id]);let li=(0,u.useRef)(C);li.current=C,(0,u.useEffect)(()=>{L&&w(L.workspaceId)},[L?.id]),(0,u.useEffect)(()=>{Ar.current=b},[b]),(0,u.useEffect)(()=>{ot.current=L?.id},[L?.id]);let ui=(0,u.useCallback)(e=>{let t=e.activity.lastReplyAt,n=yw({workspaceId:e.workspaceId,roomId:e.id});!t||t<=(Fe.current[n]??``)||(Fe.current[n]=t,Le(e=>e+1),DO({activeId:Ar.current,workspaceId:li.current,conversations:Me.current,readAt:Fe.current}))},[]);(0,u.useEffect)(()=>{let e=L?.id;if(!e)return;let t=y.conversations.find(t=>t.id===e);if(!t)return;let n=Fe.current[e];Fe.current[e]=t.updatedAt,n!==t.updatedAt&&Le(e=>e+1),DO({activeId:Ar.current,workspaceId:L?.workspaceId??C,conversations:Me.current,readAt:Fe.current})},[L?.id,y.conversations]),(0,u.useEffect)(()=>{let e=L?.workspaceId??C;O&&Se&&e&&!e.startsWith(`pending:`)&&!L?.id.startsWith(`pending:`)&&DO({activeId:L?.id,workspaceId:e,conversations:Me.current,readAt:Fe.current})},[L?.id,L?.workspaceId,O,Se,C]),(0,u.useEffect)(()=>{let e=it.current;if(I!==`session`||!e||!L?.id||L.messagesLoaded===!1)return;let t=L.id;pt.current=!1;let n=Me.current[t]??{followTail:!0,scrollTop:0};Me.current[t]=n,ft(n);let r=requestAnimationFrame(()=>{if(it.current!==e)st.current=!1;else{if(n.followTail)wO(e),e.scrollTop=e.scrollHeight;else{let t=n.anchorKey?e.querySelector(`[data-transcript-key="${CSS.escape(n.anchorKey)}"]`):null;e.scrollTop=t?Math.max(0,e.scrollTop+t.getBoundingClientRect().top-(n.anchorOffset??0)-e.getBoundingClientRect().top):n.scrollTop}st.current=!1}});return()=>cancelAnimationFrame(r)},[L?.id,L?.messagesLoaded,I]),(0,u.useLayoutEffect)(()=>{st.current=!0},[L?.id,L?.messagesLoaded,I]);let di=(0,u.useCallback)((e,t=!1,n=!1)=>{let r=ot.current;if(!r||st.current||!ut.current)return;let i=TO(e,Me.current[r]??{followTail:!0,scrollTop:0},t,n);pt.current=!i.followTail,Me.current[r]=i,ft(i),DO({activeId:r,workspaceId:li.current,conversations:Me.current,readAt:Fe.current})},[]),fi=L?.id??``,pi=fr[fi]??{text:``,images:[],attachments:[],uploading:0},mi=pi.text,hi=pi.images,gi=pi.attachments,_i=Object.keys(pi.pendingSkills??{}).length>0,vi=pi.uploading,yi=(e,t)=>pr(n=>({...n,[e]:t(n[e]??{text:``,images:[],attachments:[],uploading:0})})),bi=(e,t)=>({...e,text:t,attachments:sD(t,e.attachments),pendingSkills:e.pendingSkills&&Object.fromEntries(Object.entries(e.pendingSkills).filter(([e])=>td(t,e)))}),xi=e=>yi(fi,t=>bi(t,e)),Si=(e,t,n,r)=>{let i=En();yi(n,n=>{let r=bi(n,t);return{...r,pendingSkills:{...r.pendingSkills,[e]:i}}});let a=t=>t[n]?.pendingSkills?.[e]===i?n:n.startsWith(`pending:`)?Object.keys(t).find(n=>t[n].pendingSkills?.[e]===i):void 0,o=t=>pr(n=>{let r=a(n);if(!r)return n;let i=n[r],o={...i.pendingSkills};delete o[e];let s=t?[...i.attachments.filter(t=>t.id!==e),t]:i.attachments;return{...n,[r]:{...i,pendingSkills:o,attachments:s}}});Ae(`/api/skills/read?${new URLSearchParams({name:e,workspaceId:r})}`,{signal:AbortSignal.timeout(1e4)}).then(async t=>{if(!t.ok)throw Error(`读取技能失败`);let n=await t.json();if(typeof n.content!=`string`)throw Error(`读取技能失败`);o({kind:`skill`,id:e,name:n.name??e.slice(6),content:n.content})}).catch(()=>{a(mr.current)&&Y(`读取技能失败`,`error`),o()})},Ci=(e,t)=>yi(L?.id??``,n=>({...n,attachments:n.attachments.filter(n=>n.kind!==e||n.id!==t)})),[wi,Ti]=(0,u.useState)({visible:!1,query:``,rect:null}),Ei=JSON.stringify([L?.id,L?.workspaceId,L?.cwd??``]),[Di,Oi]=(0,u.useState)(),ki=(0,u.useRef)(null),[Ai,ji]=(0,u.useState)(),Mi=(0,u.useRef)(void 0),Ni=(0,u.useRef)(``),Pi=!$r&&Di?.scope===Ei?Di:void 0,Fi=e=>{let t=!Dr.current&&!$r&&L?id(e.value,e.selectionStart,e.selectionEnd):void 0,n=JSON.stringify([Ei,t]);return!t||Ni.current===n?(Oi(void 0),!1):(Oi({scope:Ei,token:t,rect:e.getBoundingClientRect()}),Ti({visible:!1,query:``,rect:null}),!0)},Ii=()=>{Ni.current=JSON.stringify([Ei,Pi?.token]),Oi(void 0)};(0,u.useEffect)(()=>{Oi(void 0),Ni.current=``},[Ei]),(0,u.useLayoutEffect)(()=>{let e=Mi.current;Mi.current=void 0,e?.scope===Ei&&e.text===mi&&(at.current?.focus(),at.current?.setSelectionRange(e.caret,e.caret))},[mi,Ei]),(0,u.useEffect)(()=>{let e=()=>{let e=at.current;e&&Oi(t=>t?{...t,rect:e.getBoundingClientRect()}:void 0)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Li=e=>yi(L?.id??``,t=>({...t,images:typeof e==`function`?e(t.images):e})),Ri=ne.length>0?ne:xe?[]:L?[L.id]:[],zi=(0,u.useMemo)(()=>Ri.map(e=>Rr.find(t=>t.id===e)).filter(e=>e!==void 0),[Ri,Rr]),Bi=ai?void 0:zi.filter(e=>e.id!==re).at(-1)?.id,Vi=zi.some(e=>e.id===L?.id);(0,u.useEffect)(()=>{if(!Se)return;let e=new Set(Rr.map(e=>e.id));N(t=>{let n=t.ids.filter(t=>e.has(t)||te(t)),r=t.previewId&&(e.has(t.previewId)||te(t.previewId))?t.previewId:void 0;return n.length===t.ids.length&&r===t.previewId?t:{...t,ids:n,previewId:r}})},[Se,Rr]),(0,u.useEffect)(()=>{!Se||oi||b?.startsWith(`pending:`)||te(b??C)||MO(M,b,b?void 0:ai?.id)},[b,Se,M,oi,ai?.id]);let Hi=(0,u.useCallback)(e=>{e&&N(t=>{if(t.touched.has(e))return t;let n=t.previewId===e?void 0:t.previewId;return{...t,previewId:n,touched:kO(t.touched,e)}})},[]),Ui=(0,u.useCallback)(e=>{ge(ce(e)),Mn(!1),ie.current++,We(!1),x(e);let t=Rr.find(t=>t.id===e)?.workspaceId;t&&w(t),Ge(`session`),N(t=>{let n=t.emptied===!0,r=n?{...t,emptied:!1}:t;if(r.ids.includes(e))return r;let i=!n&&r.ids.length===0&&L?.id&&L.id!==e?[L.id]:[],a=[...r.ids,...i];if(r.touched.has(e))return{...r,ids:[...a,e]};let o=r.previewId?a.indexOf(r.previewId):-1,s=o>=0?a.map((t,n)=>n===o?e:t):[...a,e];return{...r,ids:s,previewId:e}})},[L,Rr]);(0,u.useEffect)(()=>{if(!Se)return;let t=new Map(e.conversations.filter(e=>!e.archivedAt).map(e=>[e.id,{status:e.status,hasPendingQuestion:!!e.hasPendingQuestion,title:e.title,workspaceId:e.workspaceId,parentConversationId:e.parentConversationId}]));if(!c.current){s.current=t,c.current=!0;return}let r=document.visibilityState===`visible`&&document.hasFocus(),a=n&&i===`granted`&&!r;for(let[n,r]of t){let t=s.current.get(n);if(!t||r.parentConversationId||!a)continue;let i=!t.hasPendingQuestion&&r.hasPendingQuestion,o=r.status===`completed`&&t.status!==`completed`&&[`waiting`,`running`,`awaiting_background`].includes(t.status);if(!i&&!o)continue;let c=i?`question`:`completed`;if(GO(`${n}:${c}:${e.conversations.find(e=>e.id===n)?.updatedAt??``}`))try{let e=`${n}:${c}`,t=new Notification(i?`Super Pi · 等你回答`:`Super Pi · Agent 已完成`,{icon:new URL(`/favicon.png`,location.origin).href,body:`${he(r.workspaceId)} · ${i?`「${r.title}」需要你的回答。`:`「${r.title}」已完成。`}`,tag:`super-pi-${c}-${n}`});l.current.set(e,t),t.onclose=()=>{l.current.get(e)===t&&l.current.delete(e)},t.onclick=()=>{t.close(),l.current.delete(e),window.focus(),Ui(n)}}catch(e){console.warn(`[Super Pi] Browser notification could not be shown:`,e instanceof Error?e.message:`unknown error`)}}s.current=t},[e.conversations,Se,n,i,Ui]);let Wi=(0,u.useCallback)(e=>{e&&(Hi(e),Ui(e))},[Hi,Ui]),Gi=e=>{e.startsWith(`pending:`)||ge(ce(e)),Mn(!0),ie.current++,We(!1),L&&Vi&&N(e=>e.ids.length||e.emptied?e:{...e,ids:[L.id]}),w(e),x(void 0),Ge(`session`),xn(!1),yn()},Ki=(0,u.useCallback)((e,t=``)=>{ie.current++;let n={workspaceId:e,roomId:t};t&&He(r=>r.some(n=>n.workspaceId===e&&n.roomId===t)?r:[...r,n]),ze(n),We(!0),w(e),xn(!1),Ge(`group`),yn()},[yn]),qi=(0,u.useCallback)((e,t)=>{Je(e,!0),t&&(ee(t=>t[e.workspaceId]?{...t,[e.workspaceId]:!1}:t),Ki(e.workspaceId,e.id))},[Ki,Je]);(0,u.useEffect)(()=>{let e=new Set;if(!n||i!==`granted`)Xr(e);else{for(let t of Object.values(Ke))for(let n of t.rooms)if(!n.archivedAt)for(let t of n.cloneRequests??[]){if(t.status!==`pending`||t.automatic)continue;let r=`group-clone:${n.id}:${t.id}`;e.add(r),Yr(r,`${he(n.workspaceId)} · ${n.title} · 需要决定是否创建分身`,t.reason,I===`group`&&tt===n.id&&document.visibilityState===`visible`&&document.hasFocus(),()=>Ki(n.workspaceId,n.id))}Xr(e)}},[Ke,I,tt,Ki,n,i]);let Ji=(0,u.useCallback)(e=>{qe(),Ye(e)},[Ye,qe]);async function Yi(e,t){if(!Qe.has(e.id)&&(t!==`delete`||window.confirm(`永久删除群聊「${e.title}」及其聊天记录?删除后无法恢复。`))){$e(t=>new Set(t).add(e.id));try{let n=await ww(xw(e.workspaceId,e.id),{action:t});if(t===`delete`)Ji({workspaceId:e.workspaceId,roomId:e.id});else{if(!n)throw Error(`服务没有确认群聊状态。`);qe(),Je(n),t===`archive`&&Ot(t=>({...t,[e.workspaceId]:!1}))}}catch(e){Y(e instanceof Error?e.message:`群聊操作失败。`,`error`)}finally{$e(t=>new Set([...t].filter(t=>t!==e.id)))}}}let Xi=Ue&&I!==`session`,z=Xi?et:L?.workspaceId??C,Zi=z?.startsWith(`pending:`)?void 0:z,Qi=Zi??(Sn===`repo`?y.workspaces.find(e=>e.id===kn&&(!e.worktreeOf||!y.workspaces.some(t=>t.id===e.worktreeOf)))?.id??y.workspaces.find(e=>(wn===`all`||h(e.id).server===wn)&&(!e.worktreeOf||!y.workspaces.some(t=>t.id===e.worktreeOf)))?.id:void 0),$i=Qi?.startsWith(`pending:`)?void 0:Qi,ea=Xi?``:L?.cwd??``;(0,u.useEffect)(()=>{Zi&&ge(ce(Zi))},[Zi]);let ta=Sn===`repo`&&(!L||Xi),na=JSON.stringify([Zi,ea]),[ra,ia]=(0,u.useState)(),[aa,oa]=(0,u.useState)(50),sa=ra?.scope===na?ra:void 0,ca=!!sa,la=sa?.tabId;(0,u.useEffect)(()=>{ia(e=>e?.scope===na?e:void 0)},[na]);let ua=(0,u.useCallback)(e=>{ia(t=>t?.scope===na?{...t,tabId:e}:t)},[na]),da=dp(Zi,ea,{navigation:ie,showingFile:I===`file`,splitFilePath:la?.startsWith(`file:`)?la.slice(5):void 0}),fa=hr($i,$i===Zi?ea:``,O&&Se),pa=(0,u.useRef)(fa.refresh);pa.current=fa.refresh;let ma=(0,u.useRef)(da.setChangedFor),ha=(0,u.useRef)(da.invalidateTree);ha.current=da.invalidateTree;let ga=(0,u.useRef)(Zi);ga.current=Zi,(0,u.useEffect)(()=>{ma.current=da.setChangedFor},[da.setChangedFor]);let[_a]=(0,u.useState)(ED),[va,ya]=(0,u.useState)(_a.tab),[ba,xa]=(0,u.useState)(_a.byConversation),B=(L?.id?ba[L.id]:void 0)??va;(0,u.useEffect)(()=>{try{window.sessionStorage.setItem(TD,JSON.stringify({tab:va,byConversation:ba}))}catch{}},[va,ba]);let V=(0,u.useCallback)(e=>{ya(e),L?.id&&xa(t=>({...t,[L.id]:e}))},[L?.id]),H=In.order.filter(e=>In.sides[e]===`left`),U=In.order.filter(e=>e!==`sessions`&&In.sides[e]===`right`),W=H.includes(In.leftView)?In.leftView:`sessions`,Sa=U.includes(B)?B:U[0],Ca=In.rightClosed||!Sa,wa=Kn||!In.leftClosed&&W===`sessions`,Ta=(e,t=!1)=>{Kn?e===`sessions`?(yn(),xn(!0)):(V(e),mn(!1),Pn<=700&&gn(`rail`)):In.sides[e]===`left`?Ln(n=>({...n,leftView:e,leftClosed:t&&!n.leftClosed&&W===e})):e!==`sessions`&&(V(e),Ln(n=>({...n,rightClosed:t&&!n.rightClosed&&Sa===e})))},Ea=(e,t)=>{let n=In.sides[e];if(t===`move`){let t=n===`left`?`right`:`left`;Ln(n=>({...n,sides:{...n.sides,[e]:t},...t===`left`?{leftView:e,leftClosed:!1}:{rightClosed:!1}})),t===`right`&&V(e),requestAnimationFrame(()=>{(document.querySelector(`[data-workbench-view="${e}"]`)??document.querySelector(`[data-workbench-panel-menu="${e}"]`))?.focus()})}else Ln(t===`pin`?t=>({...t,unpinned:t.unpinned.includes(e)?t.unpinned.filter(t=>t!==e):[...t.unpinned,e]}):r=>{let i=r.order.filter(e=>r.sides[e]===n&&!r.unpinned.includes(e)),a=i.indexOf(e),o=a>=0?i[a+(t===`up`?-1:1)]:void 0;if(!o||o===`sessions`)return r;let s=r.order.slice(),c=s.indexOf(e),l=s.indexOf(o);return[s[c],s[l]]=[s[l],s[c]],{...r,order:s}})},Da=(e,t)=>{e!==t&&Ln(n=>{if(n.sides[e]!==n.sides[t])return n;let r=n.order.slice(),i=r.indexOf(e),a=r.indexOf(t);return r.splice(i,1),r.splice(a,0,e),{...n,order:r}})},Oa=()=>{Ln(xt()),zn({}),V(`main`)},ka=JSON.stringify([Zi,ea]),[G,Aa]=(0,u.useState)(),K=G?.scope===ka?G:void 0,ja=K?.mode===`path`;(0,u.useEffect)(()=>{Aa(e=>e?.scope===ka?e:void 0)},[ka]);let Ma=(0,u.useCallback)((e,t,n)=>{ie.current++,Aa(r=>r?.mode===e&&r.scope===ka&&r.directory===n?r:{mode:e,scope:ka,initialQuery:t,directory:n}),xn(!1)},[ka]),Na=(0,u.useCallback)(()=>{ie.current++,Aa(void 0)},[]),[Pa,Fa]=(0,u.useState)(),Ia=(0,u.useRef)(0),La=e=>{Ui(e.conversationId),Fa({hit:e,request:ie.current}),Aa(void 0),yn()};(0,u.useEffect)(()=>{if(!Pa||Pa.request===Ia.current||L?.id!==Pa.hit.conversationId||L?.messagesLoaded===!1||I!==`session`||!Vi)return;let{hit:e,request:t}=Pa,n=null,r,i=requestAnimationFrame(()=>{let i=it.current;i&&ie.current===t&&(n=i.querySelector(`[data-transcript-key="${CSS.escape(`m:${e.messageId}`)}"]`),n&&(Ia.current=t,wO(i),i.scrollTop+=n.getBoundingClientRect().top-i.getBoundingClientRect().top-24,di(i,!0),n.dataset.sessionSearchHit=`true`,n.tabIndex=-1,n.focus({preventScroll:!0}),r=setTimeout(()=>{n&&delete n.dataset.sessionSearchHit},2400)))});return()=>{cancelAnimationFrame(i),clearTimeout(r),n&&delete n.dataset.sessionSearchHit}},[L?.id,L?.messagesLoaded,I,di,Vi,Pa]);let[Ra,za]=(0,u.useState)(),[Ba,Va]=(0,u.useState)(),[Ha,Ua]=(0,u.useState)({paths:[]}),Wa=Ha.paths,[Ga,Ka]=(0,u.useState)([]),[qa,Ja]=(0,u.useState)(),Ya=I===`gitDiff`?Ga.find(e=>e.target.url===qa):void 0,Xa=I===`gitDiff`?`diff`:I,Za=Ya?.target.path??Ba,Qa=(0,u.useCallback)(e=>{if(ta&&!e.commitHash)return;ie.current++;let t=document.activeElement instanceof HTMLElement?document.activeElement:void 0;Ka(n=>{let r=n.find(t=>t.target.url===e.url);if(!r){let r={target:e,workspaceId:Zi,reading:{},revision:0,preview:!0,origin:t},i=ca&&I===`gitDiff`?qa:void 0,a=n.find(e=>e.preview&&e.target.url!==i);return a?n.map(e=>e===a?r:e):[...n,r]}if(e.commitHash)return n;let i=r.target.label===e.label?{...r.reading,snapshot:void 0}:{split:r.reading.split};return n.map(n=>n===r?{...n,target:e,reading:i,revision:n.revision+1,origin:t}:n)}),ca?(ua(`git-diff:${e.url}`),I===`gitDiff`&&qa===e.url&&Ge(`session`)):(Ja(e.url),Ge(`gitDiff`)),yn()},[Zi,ta,qa,I,ua,yn,ca]),$a=(0,u.useCallback)(()=>{!Vi&&Bi?Ui(Bi):Ge(`session`)},[Vi,Bi,Ui]);(0,u.useEffect)(()=>{let e=e=>{let t=Ke[e.workspaceId];return!t?.loaded||t.rooms.some(t=>t.id===e.roomId)},t=Ve.filter(e);if(t.length!==Ve.length&&He(t),I!==`group`||!Re?.roomId||e(Re))return;let n=t.filter(e=>e.workspaceId===Re.workspaceId).at(-1);n?Ki(n.workspaceId,n.roomId):$a()},[Ke,Re,Ve,I,Ki,$a]),(0,u.useEffect)(()=>{I===`file`&&!da.active&&$a()},[I,da.active,$a]),(0,u.useEffect)(()=>{I===`diff`&&!Ba&&$a()},[I,Ba,$a]);let eo=(0,u.useRef)(`${Zi??``}:${ea}`);(0,u.useEffect)(()=>{let e=`${Zi??``}:${ea}`;eo.current!==e&&(eo.current=e,Ua({paths:[]}),Va(void 0),Ge(e=>e===`gitDiff`||e===`group`?e:`session`))},[Zi,ea]);let to=(0,u.useCallback)((e,t=!1)=>{ie.current++;let n=ca&&!t;Ua(t=>{if(t.paths.includes(e))return t;let r=n&&I===`diff`&&Ba===t.previewPath;return{paths:t.previewPath&&!r?t.paths.map(n=>n===t.previewPath?e:n):[...t.paths,e],previewPath:e}}),n?(ua(`diff:${e}`),I===`diff`&&Ba===e&&Ge(`session`)):(Va(e),Ge(`diff`)),yn(),ya(`files`)},[Ba,I,ua,yn,ca]),no=I===`diff`?Ba:void 0,ro=la?.startsWith(`diff:`)?la.slice(5):void 0,io=ro&&ro!==no&&Wa.includes(ro)?ro:void 0,ao=WO(Zi,ea,no),oo=WO(Zi,ea,io),[so,co]=(0,u.useState)(`server`),[lo,uo]=(0,u.useState)(`server`),fo=e=>{let t=da.open.find(t=>t.path===e);return t?.dirty?t.content:void 0},po=(0,u.useCallback)(e=>{ie.current++,da.setActivePath(e),Ge(`file`),ya(`files`)},[da.setActivePath]),mo=(0,u.useCallback)(async(e,t,n=!1,r=!1,i=!1,a)=>{let o=++ie.current,s=()=>ie.current===o,c=ca&&!i,l=await da.openFile(e,{preview:!n,activate:!c,isCurrent:s,throwOnError:r,requireText:a!==void 0});if(l&&s())return n&&da.pinFile(l),za(t?{scope:ka,path:l,line:t,column:a,request:o}:void 0),c?(ua(`file:${l}`),I===`file`&&da.activePath===l&&Ge(`session`)):Ge(`file`),yn(),l},[da.openFile,da.pinFile,da.activePath,ka,I,ua,yn,ca]),ho=(0,u.useCallback)((e,t)=>{mo(e,void 0,t)},[mo]),go=L&&!$r?(e,t)=>{let n=mi&&!/\s$/u.test(mi)?`${mi} `:mi,r=ad(n,{start:n.length,end:n.length,query:``},{path:e,kind:t?`directory`:`file`});Mi.current={scope:Ei,...r},Hi(L.id),Ui(L.id),yn(),xi(r.text)}:void 0,_o=(e,t)=>{ie.current+=1,Ua(t=>({paths:t.paths.filter(t=>!bd(t,e)),previewPath:t.previewPath&&!bd(t.previewPath,e)?t.previewPath:void 0})),Ba&&bd(Ba,e)&&Va(void 0),ia(n=>{let r=n?.tabId?.startsWith(`file:`)?n.tabId.slice(5):void 0;return n&&r&&bd(r,e)?{...n,tabId:`file:${t}${r.slice(e.length)}`}:n}),za(n=>n?.scope===ka&&bd(n.path,e)?{...n,path:t+n.path.slice(e.length)}:n)};(0,u.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.altKey||e.isComposing)return;let t=e.key.toLowerCase();e.shiftKey&&t===`f`?(e.preventDefault(),Ma(`content`)):!e.shiftKey&&t===`p`&&(e.preventDefault(),Ma(`path`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Ma]);let vo=(0,u.useMemo)(()=>zi.map(e=>({id:`session:${e.id}`,workspaceId:e.workspaceId,rawId:e.id,kind:`session`,label:e.title,title:e.title,closable:!0,preview:re===e.id,badge:(0,F.jsx)(RD,{state:ID(e,PD(e,fn),Fe.current[e.id],y.conversations)})})),[zi,fn,y.conversations,Ie,re]),yo=(0,u.useMemo)(()=>da.open.map(e=>({id:`file:${e.path}`,workspaceId:da.ownerWorkspaceId,rawId:e.path,kind:`file`,label:e.name,title:e.path,closable:!0,preview:e.preview,badge:e.dirty?(0,F.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[da.ownerWorkspaceId,da.open]),q=(0,u.useMemo)(()=>Wa.map(e=>({id:`diff:${e}`,workspaceId:Zi,rawId:e,kind:`diff`,label:e.split(/[\\/]/).pop()||e,title:`${e}(改动)`,closable:!0,preview:Ha.previewPath===e,icon:(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`±`})})),[Zi,Wa,Ha.previewPath]),bo=(0,u.useMemo)(()=>[...vo,...[...Ve,...I===`group`&&Re&&!tt?[Re]:[]].flatMap(e=>{let t=y.workspaces.find(t=>t.id===e.workspaceId&&!t.closedAt);if(!t)return[];let n=Ke[e.workspaceId]?.rooms.find(t=>t.id===e.roomId),r=e.roomId?n?.title??`群聊`:`新建群聊`,i=n?Tw(n,Xe[n.id]):`idle`,a=n?Ew(n,Xe[n.id],Fe.current[yw(e)]):`idle`,o=a===`completed`?`讨论已完成,有新回复未读`:a===`unread`?`有新回复未读`:OD[i],s=`${r} · ${t.name}${i===`idle`?``:` · ${o}`}`;return[{id:yw(e),workspaceId:e.workspaceId,label:r,title:s,closable:!0,icon:(0,F.jsx)(Tt,{name:`group`}),badge:(0,F.jsx)(RD,{state:a,label:o})}]}),...yo,...q,...Ga.map(({target:e,preview:t,workspaceId:n})=>({id:`git-diff:${e.url}`,workspaceId:n,kind:`diff`,closable:!0,preview:t,label:`${e.path.split(/[\\/]/).pop()||e.path} (${e.label})`,title:`${e.path} · ${e.comparison}`,icon:(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`±`})}))],[vo,yo,q,Ga,Ve,Ke,Xe,Re,tt,I,y.workspaces,Ie]),xo=I===`group`&&Re?yw(Re):I===`file`&&da.activePath?`file:${da.activePath}`:I===`diff`&&Ba?`diff:${Ba}`:Ya?`git-diff:${Ya.target.url}`:Vi&&L?.id?`session:${L.id}`:void 0,So=(0,u.useRef)(!1),Co=(0,u.useRef)(void 0);(0,u.useLayoutEffect)(()=>{let e=So.current;if(So.current=!1,Co.current!==da.restoredActive&&(Co.current=da.restoredActive,!ve&&da.restoredActive&&da.restoredActive===da.activePath&&I!==`file`&&I!==`gitDiff`&&I!==`group`)){Ge(`file`);return}if(!e&&Se&&re&&xo!==`session:${re}`&&Rr.some(e=>e.id===re)&&N(e=>{if(e.previewId!==re)return e;let t=e.ids.filter(e=>e!==re);return{...e,ids:t,previewId:void 0,emptied:t.length===0}}),!e)for(let e of da.open)e.preview&&xo!==`file:${e.path}`&&la!==`file:${e.path}`&&da.discardPreview(e.path);let t=Ha.previewPath;!e&&t&&xo!==`diff:${t}`&&la!==`diff:${t}`&&Ua(e=>e.previewPath===t?{paths:e.paths.filter(e=>e!==t)}:e);let n=e=>{let t=`git-diff:${e.target.url}`;return!e.preview||t===xo||t===la};!e&&Ga.some(e=>!n(e))&&Ka(e=>e.filter(n)),Se&&I===`session`&&L&&L.id===b&&!Vi&&!da.restoringWorkbench&&Bi&&Ui(Bi)},[xo,Se,re,da.open,da.activePath,da.restoredActive,da.discardPreview,Ha.previewPath,I,L?.id,b,Vi,da.restoringWorkbench,Bi,Ui,Rr,ve,la,Ga]);let wo=(0,u.useCallback)(e=>{if(e.startsWith(`group:`)){let t=bw(e);t&&Ki(t.workspaceId,t.roomId)}else if(e.startsWith(`file:`)){let t=e.slice(5);po(t)}else if(e.startsWith(`diff:`)){ie.current++;let t=e.slice(5);Va(t),Ge(`diff`)}else if(e.startsWith(`git-diff:`))ie.current++,Ja(e.slice(9)),Ge(`gitDiff`);else if(e.startsWith(`session:`)){let t=e.slice(8);Ui(t)}},[po,Ui,Ki]),To=bo.find(e=>e.id===xo),Eo=I===`file`?da.active:void 0,Do=(0,u.useMemo)(()=>{if(!Se||!To||To.id.startsWith(`session:pending:`))return;let{id:e,label:t}=To;if(I!==`group`||tt&&rt){if(I===`session`)return e.startsWith(`session:`)?{key:e,tabId:e,title:t}:void 0;if(I===`file`||I===`diff`){if(!Zi||da.restoringWorkbench||I===`file`&&!Eo||I===`diff`&&!Ba)return;let n={workspaceId:Zi,cwd:ea,conversationId:L?.id},r=Eo&&{path:Eo.path,name:Eo.name,text:null,...Eo.assetTicket||/^(?:[a-z]:[\\/]|[\\/])/i.test(Eo.path)?{openLink:!0}:{}};return{key:JSON.stringify([n.workspaceId,n.cwd,e]),tabId:e,title:t,scope:n,file:r}}return{key:e,tabId:e,title:t}}},[Se,To,I,Zi,ea,L?.id,da.restoringWorkbench,Ba,Eo?.path,Eo?.name,Eo?.assetTicket,tt,rt]);(0,u.useEffect)(()=>{!ve&&Do&&(be.current.delete(Do.key),_e(e=>Pp(e,Do)))},[Do,ve]);let Oo=e=>{let t=Rr.filter(t=>t.workspaceId===e.workspaceId&&(t.cwd??``)===e.cwd);return t.find(t=>t.id===e.conversationId)??t[0]},ko=e=>{if(e.key===Do?.key||be.current.has(e.key))return!1;if(e.tabId.startsWith(`session:`))return Rr.some(t=>`session:${t.id}`===e.tabId);let t=bw(e.tabId);if(t)return y.workspaces.some(e=>e.id===t.workspaceId&&!e.closedAt)&&!!Ke[t.workspaceId]?.rooms.some(e=>e.id===t.roomId);if(!e.scope)return bo.some(t=>t.id===e.tabId);let{scope:n}=e;return y.workspaces.some(e=>e.id===n.workspaceId)?n.workspaceId===Zi&&n.cwd===ea||!!Oo(n)||!n.cwd&&!Rr.some(e=>e.workspaceId===n.workspaceId):!1},Ao=Fp(P,P.index+ +!Do,-1,ko),jo=Fp(P,P.index,1,ko),Mo=e=>{let t=e<0?Ao:jo;ve||t<0||ye({index:t,direction:e,ticket:++ie.current,stage:`start`})},No=(0,u.useRef)(Mo);No.current=Mo,(0,u.useEffect)(()=>{let e=e=>{(e.button===3||e.button===4)&&(e.preventDefault(),e.type===`mouseup`&&No.current(e.button===3?-1:1))};for(let t of[`mousedown`,`mouseup`,`auxclick`])window.addEventListener(t,e,!0);return()=>{for(let t of[`mousedown`,`mouseup`,`auxclick`])window.removeEventListener(t,e,!0)}},[]),(0,u.useEffect)(()=>{let e=ve;if(!e)return;if(ie.current!==e.ticket){ye(void 0);return}let t=P.entries[e.index];if(t.key===Do?.key){_e(t=>({...t,index:e.index})),ye(void 0);return}let n=(t=e.ticket)=>{let n=Fp(P,e.index,e.direction,ko);ye(n<0?void 0:{...e,index:n,ticket:t,stage:`start`})};if(!ko(t)){n();return}let r=t.scope;if(r&&(r.workspaceId!==Zi||r.cwd!==ea)){if(e.stage!==`start`){n();return}let t=Oo(r);t?Ui(t.id):Gi(r.workspaceId),ye({...e,stage:`scope`,ticket:ie.current});return}if(e.stage===`opening`||r&&da.restoringWorkbench)return;xn(!1),yn();let i=t.file;if(i&&!da.open.some(e=>e.path===i.path)){let r=mo(i,void 0,!1,!0,!0),a=ie.current;ye({...e,stage:`opening`,ticket:a}),r.then(e=>{!e&&ie.current===a&&ye(void 0)}).catch(e=>{ie.current===a&&(e instanceof zf&&e.status===404?(be.current.add(t.key),n(a)):(Y(ct(e instanceof Error?e.message:void 0,`无法打开导航历史中的文件。`),`error`),ye(void 0)))})}else t.tabId.startsWith(`diff:`)&&!bo.some(e=>e.id===t.tabId)?to(t.tabId.slice(5),!0):wo(t.tabId),ye({...e,stage:`opening`,ticket:ie.current})});let Po=(0,u.useCallback)(e=>{if(e.startsWith(`session:`))Wi(e.slice(8));else if(e.startsWith(`file:`))da.pinFile(e.slice(5));else if(e.startsWith(`diff:`)){let t=e.slice(5);Ua(e=>e.previewPath===t?{paths:e.paths}:e)}else e.startsWith(`git-diff:`)&&Ka(t=>t.map(t=>t.preview&&`git-diff:${t.target.url}`===e?{...t,preview:!1}:t))},[Wi,da.pinFile]),Fo=bo.filter(e=>e.kind===`file`||e.kind===`diff`),Io=ca&&la!==xo?Fo.find(e=>e.id===la):void 0,Lo=e=>{Fo.some(t=>t.id===e)&&(ie.current++,ua(e),e===xo&&$a())},Ro=()=>{if(ca){ie.current++,Io&&Po(Io.id),ia(void 0);return}ie.current++;let e=Fo.find(e=>e.id===xo)??Fo.at(-1);ia({scope:na,tabId:e?.id}),e&&e.id===xo&&(L&&!Vi?Ui(L.id):$a())},zo=(0,u.useCallback)(e=>{let t=Ri.indexOf(e);if(t<0)return;let n=Ri.filter(t=>t!==e);if(N(t=>({...t,ids:t.ids.filter(t=>t!==e),previewId:t.previewId===e?void 0:t.previewId,emptied:n.length===0||t.emptied})),L?.id!==e||I!==`session`)return;ie.current++;let r=n[Math.min(t,n.length-1)];if(r)x(r);else if(da.open.length>0){let e=da.activePath&&da.open.some(e=>e.path===da.activePath)?da.activePath:da.open[0].path;da.setActivePath(e),Ge(`file`)}else Wa.length>0?(Va(Wa[0]),Ge(`diff`)):Ga.length>0?(Ja(Ga[0].target.url),Ge(`gitDiff`)):x(void 0)},[Ri,L,da,Wa,Ga,I]),J=(0,u.useCallback)(e=>{if(e.startsWith(`group:`)){let t=Ve.filter(t=>yw(t)!==e);if(He(t),I===`group`&&xo===e){let e=t.filter(e=>e.workspaceId===et).at(-1);e?Ki(e.workspaceId,e.roomId):$a()}}else if(e.startsWith(`file:`)){let t=e.slice(5);da.closeFile(t),I===`file`&&da.activePath===t&&da.open.length<=1&&ie.current++}else if(e.startsWith(`diff:`)){let t=e.slice(5);Ua(e=>({paths:e.paths.filter(e=>e!==t),previewPath:e.previewPath===t?void 0:e.previewPath})),I===`diff`&&Ba===t&&(ie.current++,Va(void 0),$a())}else if(e.startsWith(`session:`)){let t=e.slice(8);zo(t)}else if(e.startsWith(`git-diff:`)){let t=e.slice(9),n=Ga.findIndex(e=>e.target.url===t);if(n<0)return;let r=Ga.filter(e=>e.target.url!==t);Ka(r);let i=document.activeElement?.getAttribute(`data-diff-tab-close`)===e;if(Ya?.target.url===t){ie.current++;let e=r[Math.max(0,n-1)];Ja(e?.target.url),e||$a()}i&&requestAnimationFrame(()=>{let e=document.querySelector(`.chat-tab-strip [role="tab"][aria-selected="true"]`),t=Ga[n].origin;(e??(t?.getClientRects().length?t:void 0)??document.querySelector(`[data-workspace-welcome-create]:not(:disabled)`))?.focus()})}},[da,zo,Ba,I,Ga,Ya?.target.url,$a,et,Ve,xo,Ki]),Bo=da.active,Vo=JSON.stringify([Zi,ea,Bo?.path]),[Ho,Uo]=(0,u.useState)(),Wo=(0,u.useCallback)(e=>{Uo(t=>e?{scope:Vo,position:e}:t?.scope===Vo?void 0:t)},[Vo]),Go=Ho?.scope===Vo?Ho.position:void 0,Ko=y.workspaces.find(e=>e.id===Zi),qo=y.workspaces.find(e=>e.id===$i),Jo=(e,t)=>{let n=e&&Jf(e.path),r=e&&(e.assetTicket||n?(0,F.jsx)(`span`,{className:`file-editor-path`,title:n??e.path,children:n??e.path}):(0,F.jsx)(ud,{root:ea.split(`/`).at(-1)||Ko?.name||`工作目录`,path:e.path,reveal:(e,t)=>{Ta(`files`),da.locatePath(e,t)}})),i=Ra?.scope===ka&&Ra?.path===e?.path?Ra:void 0,a=e&&(!e.view||e.view===`table`)&&(0,F.jsx)(sp,{file:e,state:da.saves[e.path]?.state??`idle`,message:da.saves[e.path]?.message??``,external:da.external[e.path]===!0,jumpToLine:i,onChange:t=>da.updateBuffer(e.path,t),onSave:()=>void da.save(e.path,!1),onReload:()=>void da.reload(e.path),onOverwrite:()=>void da.save(e.path,!0),workspaceId:Zi,cwd:ea,navigation:e.view?void 0:r,embedded:!!e.view,onPosition:t?Wo:void 0});return(0,F.jsx)(`div`,{className:`chat-file-view`,"data-main-file-view":e?.path,"data-file-view-kind":`editor`,children:e?.view&&Zi?(0,F.jsx)(md,{workspaceId:Zi,cwd:n?``:ea,path:n??e.path,name:e.name,kind:e.view,content:e.content,version:e.etag,source:a||void 0,external:da.external[e.path],navigation:r,assetTicket:e.assetTicket,onReload:()=>void da.reload(e.path),sourceRequest:i?.request},JSON.stringify([Zi,ea,e.path])):a||(0,F.jsx)(`p`,{className:`rail-empty`,"data-main-file-empty":`1`,children:`没有选中的文件。`})})},Yo=e=>ta&&!e.target.commitHash?(0,F.jsx)(`div`,{className:`chat-file-view`,role:`status`,children:(0,F.jsx)(`p`,{className:`rail-empty`,children:`请选择具体 session 以确定工作区,再查看或编辑工作区差异。`})}):(0,F.jsx)(`div`,{className:`chat-file-view chat-git-diff`,"data-main-diff-view":e.target.path,"data-file-view-kind":`diff`,children:(0,F.jsx)(u.Suspense,{fallback:(0,F.jsx)(`p`,{className:`rail-empty`,role:`status`,children:`正在读取差异…`}),children:(0,F.jsx)(YD,{tab:e,dark:Cc!==`github-light`&&Cc!==`solarized-light`},JSON.stringify([e.target.url,e.revision]))})}),Xo=(e,t)=>{let n=t?oo:ao;return(0,F.jsx)(`div`,{className:`chat-file-view`,"data-main-diff-view":e??``,"data-file-view-kind":`diff`,children:(0,F.jsx)(lp,{diff:n.diff,loading:n.loading,error:n.error,bufferContent:fo(e),mode:t?lo:so,onMode:t?uo:co})})},Zo=()=>{let e=Io?.id;if(!e)return null;if(e.startsWith(`file:`))return Jo(da.open.find(t=>`file:${t.path}`===e),!1);if(io)return Xo(io,!0);let t=Ga.find(t=>`git-diff:${t.target.url}`===e);return t?Yo(t):null},Qo=L?.id;(0,u.useEffect)(()=>{Qo&&!Qo.startsWith(`pending:`)&&rs({type:`conversation.select`,conversationId:Qo})},[Qo]);let Y=(e,t=`info`)=>{if(!e)return;let n=++Or.current;Gt(r=>[...r,{key:n,text:e,kind:t}]),kr.current.push(window.setTimeout(()=>Gt(e=>e.filter(e=>e.key!==n)),7e3))},$o=async e=>{if(!e){r(!1);try{window.localStorage.setItem(`super-pi.browser-notifications`,`disabled`)}catch{}}else if(typeof window>`u`||!(`Notification`in window))a(`unsupported`);else if(!window.isSecureContext)a(`insecure`);else try{let e=Notification.permission==="default"?await Notification.requestPermission():Notification.permission;a(e);let t=e===`granted`;r(t);try{window.localStorage.setItem(`super-pi.browser-notifications`,t?`enabled`:`disabled`)}catch{}}catch{a(Notification.permission),r(!1),Y(`请求浏览器通知权限失败,请检查站点权限后重试。`,`error`)}};(0,u.useEffect)(()=>{let e=()=>{for(let e of l.current.values())e.close();l.current.clear()},t=()=>{if(a(qr()),document.visibilityState===`visible`&&document.hasFocus()){e();try{window.localStorage.setItem(`super-pi.browser-notification-focus`,String(Date.now()))}catch{}}},n=t=>{t.key===`super-pi.browser-notification-focus`&&e()};window.addEventListener(`focus`,t);let r=!1,i;return navigator.permissions?.query&&navigator.permissions.query({name:`notifications`}).then(e=>{r||(i=e,e.addEventListener(`change`,t),t())}).catch(()=>{}),window.addEventListener(`storage`,n),document.addEventListener(`visibilitychange`,t),()=>{r=!0,i?.removeEventListener(`change`,t),window.removeEventListener(`focus`,t),window.removeEventListener(`storage`,n),document.removeEventListener(`visibilitychange`,t),e()}},[]),(0,u.useEffect)(()=>{let e=L?.id,t=L?.agentNotice;e&&t&&!Mr.current.has(e)&&(Mr.current.add(e),Y(t,`info`))},[L?.id,L?.agentNotice]);let es=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n<0)return[t,...e];let r=[...e];return r[n]=t,r},ts=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n<0)return[t,...e];let r=[...e];return r[n]=t,r},X=(e,t)=>{if(t.method===`notify`)Y(t.message||t.title,t.notifyType??`info`);else if(t.blocking||t.method===`setStatus`||t.method===`setWidget`||t.method===`setTitle`){let n=e=>e.blocking?e.requestId:e.statusKey??e.widgetKey??``,r=t.method===`setStatus`&&t.statusText===void 0||t.method===`setWidget`&&t.widgetLines===void 0||t.method===`setTitle`&&!t.title;Ut(i=>{let a=i.filter(r=>r.conversationId!==e||r.request.method!==t.method||n(r.request)!==n(t));return r?a:[...a,{conversationId:e,request:t}]})}else t.method===`set_editor_text`&&e===Ar.current&&xi(t.text??``)},ns=(e,t,n)=>{Ut(n=>n.filter(n=>!(n.conversationId===e&&n.request.blocking&&n.request.requestId===t)));let r=qE[n];r&&Y(r,`warning`)};(0,u.useEffect)(()=>{let e=!1;return(()=>{if(e)return;let t=new Pe(Ar.current);je.current=t,t.onopen=()=>{if(!e){E(!0);for(let e of[{type:`stream.configure`,coalesce:!0},{type:`catalog.fetch`,conversationId:Ar.current},...li.current?[{type:`prompt.catalog.fetch`,workspaceId:li.current}]:[],{type:`catalog.fetchAll`},{type:`agent.catalog.fetch`},{type:`subagent.catalog.fetch`}])t.canSend(e)&&t.send(JSON.stringify(e))}},t.onserveropen=e=>{for(let n of m.current)n.retry&&n.command&&n.serverId===e&&t.canSend(n.command)&&t.send(JSON.stringify({...n.command,operationRequestId:n.id}))},t.ondisconnect=t=>{if(e)return;let n=Qw(m.current.filter(e=>e.serverId===t));for(let e of n.failed)e.onFailure?.(`${me(t)} 连接中断`);m.current=m.current.filter(e=>!n.failed.includes(e)),p(m.current),Y(`${me(t)} 连接中断,正在自动重连。`,`warning`)},t.onmessage=({data:t})=>{if(e)return;let n=JSON.parse(t);if(n.type===`group.activity`)Ze(n);else if(n.type!==`message.delta`&&n.type!==`message.thinking`&&yt(),n.type===`message.accepted`){Zd(n.conversationId,n.clientId);for(let e of m.current)e.command?.conversationId===n.conversationId&&e.command?.clientId===n.clientId&&(e.receipt=!0)}else if(n.type===`exec.output`){let e=mt.current.get(n.sessionId),t=e?.raw??e?.text??``,r=n.offset===void 0?void 0:n.offset-n.data.length;if(!n.replace&&e?.offset!==void 0&&n.offset!==void 0&&n.offset<=e.offset)return;let i=e&&(r===void 0||e.offset!==void 0&&e.offset>=r),a=r!==void 0&&e?.offset!==void 0?Math.max(0,e.offset-r):0,o=(n.replace||!i?n.data:t+n.data.slice(a)).slice(-uE),s=dE(o);mt.current.delete(n.sessionId),mt.current.set(n.sessionId,{text:s.slice(-uE),raw:o,offset:n.offset,truncated:n.offset===void 0?n.truncated||o.length>128e3:n.offset>o.length}),mt.current.size>64&&mt.current.delete(mt.current.keys().next().value),window.dispatchEvent(new CustomEvent(`super-pi-exec-output`,{detail:n.sessionId}))}else if(n.type===`run.stopping`)or(e=>{let t=new Set(e);return t.add(n.conversationId),t});else if(n.type!==`exec.exit`){if(n.type.startsWith(`terminal.`))ht.current?.(n);else if(n.type===`conversation.autoRename.result`){let e=dr.current.get(n.conversationId);e&&(dr.current.delete(n.conversationId),n.ok?e.resolve(n.title):e.reject(Error(n.error)))}else if(n.type===`message.thinking`)bt(n);else if(n.type===`state`){yt(),jr.current=!1;let e=Ar.current,t=!!(e&&Nr.current.has(e)),r=!(!e||n.state.conversations.some(t=>t.id===e)),i=t&&r&&e&&Pr.current.has(e)?{...n.state,conversations:[Pr.current.get(e),...n.state.conversations]}:n.state;e&&!r&&(Nr.current.delete(e),Pr.current.delete(e)),m.current=m.current.filter(e=>!e.accepted?.(i)||i.sendReceipts&&e.retry&&!e.receipt?!0:(e.retry&&typeof e.command?.conversationId==`string`&&typeof e.command.clientId==`string`&&Zd(e.command.conversationId,e.command.clientId),!1)),p(m.current),or(e=>{let t=new Set(e);for(let e of[...t]){let n=i.conversations.find(t=>t.id===e);(!n||n.status!==`running`&&n.status!==`waiting`)&&t.delete(e)}return t}),i.extensionUi&&Ut(i.extensionUi),i.stoppingConversationIds&&or(new Set(i.stoppingConversationIds)),d(i),Ce(!0),E(!0);let a=m.current.filter(e=>e.key===`create-workspace`).map(e=>e.temporaryId);w(e=>{if(!e&&Nn.current)return;if(e&&(te(e)||i.workspaces.some(t=>t.id===e)||a.includes(e)))return e;let t=g.current?.workspaceId;return t&&i.workspaces.some(e=>e.id===t)?t:i.workspaces[0]?.id})}else if(n.type===`message.delta`)bt(n);else if(n.type===`queue.withdrawn`){R(e=>[...e.filter(e=>e.conversationId!==n.conversationId).slice(-9),{id:`withdrawn_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,conversationId:n.conversationId,actor:n.actor,withdrawn:n.withdrawn}]);let e=n.withdrawn.slice(0,2).map(e=>`「${e.content.replace(/\s+/g,` `).trim().slice(0,24)}」`).join(`、`),t=n.actor===`agent`?`上级 Agent 已撤回`:`已撤回`;Y(`${t} ${n.withdrawn.length} 条排队消息:${e}${n.withdrawn.length>2?`…`:``}`,`info`)}else if(n.type===`message.revert.result`)Xc(void 0),ir(void 0),n.ok||(console.error(`[Super Pi Error] revert failed:`,n.message),A(n.message));else if(n.type===`operation.result`){let e=m.current.find(e=>e.id===n.requestId),t=e?.retry?e.command:void 0;if(t&&Zd(t.conversationId,t.clientId),m.current=m.current.filter(e=>e.id!==n.requestId),p(m.current),e?.temporaryId){let t=e.temporaryId;if(e.key===`create-workspace`&&n.ok&&n.entityId){let r=n.entityId;d(n=>{if(n.workspaces.some(e=>e.id===r))return n;let i=e.apply(n).workspaces.find(e=>e.id===t);return i?{...n,workspaces:[...n.workspaces,{...i,id:r}]}:n})}else if(n.ok&&n.entityId){let e=n.entityId,r=Fr.current.get(t);if(r&&Pr.current.set(e,{...r,id:e}),Nr.current.add(e),r){let t={...r,id:e};d(n=>n.conversations.some(t=>t.id===e)?n:{...n,conversations:[t,...n.conversations]})}pr(n=>{let r=n[t];if(!r)return n;let i=n[e],a={...n};return a[e]=i?{...i,text:r.text||i.text,images:r.images.length?r.images:i.images,attachments:r.text?r.attachments:i.attachments,pendingSkills:r.text?r.pendingSkills:i.pendingSkills,uploading:r.uploading+i.uploading}:r,delete a[t],a}),Fr.current.delete(t)}x(r=>r===t?n.ok?n.entityId:e.previousActiveId:r),N(e=>AO(e,t,n.ok&&n.entityId?n.entityId:void 0)),w(r=>r===t?n.ok?n.entityId:e.previousWorkspaceId:r),!n.ok&&e.key===`create-workspace`&&li.current===t&&x(t=>t??e.previousActiveId)}if(!n.ok){if(console.error(`[Super Pi Error] operation failed:`,n.message),!e?.receipt){if(e?.onFailure)e.onFailure(n.message);else if(t){let e=t.images??[],r=sD(t.content,t.attachments);yr(i=>[...i,{id:t.clientId,conversationId:t.conversationId,content:t.content,images:e,attachments:r,reason:n.message}]),yi(t.conversationId,n=>n.text||n.images.length||n.attachments.length?n:{...n,text:t.content,images:e,attachments:r})}}let r=n.message??`操作失败`;A(r),e?.onFailure||Y(ct(r),`error`)}}else n.type===`tools.updated`?window.dispatchEvent(new Event(`super-pi-tools-updated`)):n.type===`files.changed`?(ma.current(n.workspaceId,n.changes,n.dropped),n.workspaceId===ga.current&&pa.current()):n.type===`files.invalidated`?(ha.current(n.workspaceId,n.paths),n.workspaceId===ga.current&&pa.current()):n.type===`error`?(console.error(`[Super Pi Error]`,n.message),A(n.message),Y(ct(n.message),`error`),jr.current&&=!1):n.type===`extension.ui`?X(n.conversationId,n.request):n.type===`extension.ui.closed`?ns(n.conversationId,n.requestId,n.reason):n.type===`model.catalog`?(!n.conversationId||n.conversationId===Ar.current)&&qt(n.catalog):n.type===`model.catalog.all`?Yt(n.catalog):n.type===`providers.list`?(Zt(n.providers),$t(n.apis)):n.type===`agent.catalog`?((n.sourceServerId??le())===le()&&tn(n.catalog),(n.sourceServerId??le())===ue()&&cn(n.catalog)):n.type===`prompt.catalog`?Vt(n.catalog):n.type===`subagent.catalog`?((n.sourceServerId??le())===le()&&rn(n.catalog),(n.sourceServerId??le())===ue()&&un(n.catalog)):n.type===`server.version`?on(n.version):n.type===`subagent.event`?d(e=>({...e,subagentRuns:es(e.subagentRuns??[],n.run)})):n.type===`workflow.event`?d(e=>({...e,workflows:ts(e.workflows??[],n.workflow)})):n.type===`message.tools`?d(e=>({...e,conversations:e.conversations.map(e=>e.id===n.conversationId?{...e,messages:e.messages.map(e=>e.id===n.messageId?{...e,toolCalls:n.toolCalls}:e)}:e)})):n.type===`conversation.fork.result`&&(il(e=>e===n.conversationId?void 0:e),Y(n.ok?`已从「${n.title}」分叉出新会话,放在侧边栏最上面;没有切换过去。${n.messagesCopied?`复制了 ${n.messagesCopied} 条消息。`:`原会话还没有消息,只复制了会话本身。`}`:`分叉失败:${ct(n.message)}`,n.ok?`info`:`error`))}}})(),()=>{e=!0,yt();for(let e of kr.current)window.clearTimeout(e);je.current?.close()}},[bt,yt,Ze]);let rs=(0,u.useCallback)(e=>{if(!je.current?.canSend(e))return!1;try{return je.current.send(JSON.stringify(e)),!0}catch(e){return Y(e instanceof Error?e.message:`服务器未连接`,`error`),!1}},[]),is=(0,u.useCallback)(e=>{oe({id:e,ticket:++ie.current});let t=Ar.current;t?.startsWith(`pending:`)||rs({type:`state.subscribe`,...t?{conversationId:t}:{}}),yn()},[rs,yn]);(0,u.useEffect)(()=>{if(!ae)return;if(ae.ticket!==ie.current){oe(void 0);return}let e=zr.find(e=>e.id===ae.id);e&&y.workspaces.some(t=>t.id===e.workspaceId)&&(oe(void 0),Ui(e.id),w(e.workspaceId))},[ae,zr,y.workspaces,Ui]),(0,u.useEffect)(()=>{if(!O)return;let e=L?.id;e?.startsWith(`pending:`)||rs({type:`state.subscribe`,...e?{conversationId:e}:{}})},[L?.id,O,rs]);let as=(e,t,n,r,i,a,o)=>{let s=je.current?.canSend(e)===!0,c=Zw(e);if(m.current.some(e=>e.key===t)||!s&&!c)return!1;if(c&&!Xd(e))return Y(`浏览器无法保存待发消息,正文仍在输入框。`,`error`),!1;let l=En(),u=S(e),d=[...u][0]??e._server??le(),f={id:l,key:t,serverId:d,apply:e=>u.size||le()===d?n(e):e,temporaryId:r,previousActiveId:Ar.current,previousWorkspaceId:li.current,onFailure:i,accepted:a,...o?{expiresAt:Date.now()+o}:{},...c?{retry:!0,command:e}:{}};return m.current=[...m.current,f],p(m.current),s&&je.current.send(JSON.stringify({...e,operationRequestId:l})),!0},os=e=>rs({...e,_server:ue()}),ss=(e,...t)=>as({...e,_server:ue()},...t),cs=(e,t)=>{rs({type:`conversation.childLock`,conversationId:e,unlocked:t})||Y(t?`连接断开,这个子会话没有解锁,请重试`:`连接断开,这个子会话没有上锁,请重试`,`error`)},ls=e=>{if(!e)return;let t=`message_${En()}`;as({type:`message.send`,conversationId:e,content:IE,clientId:t},`continue-truncated:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===e?{...t,warning:void 0}:t)}),void 0,void 0,void 0)};(0,u.useEffect)(()=>{let e=f.flatMap(e=>e.expiresAt?[e.expiresAt]:[]);if(!e.length)return;let t=window.setTimeout(()=>{let e=m.current.filter(e=>e.expiresAt&&e.expiresAt<=Date.now());if(e.length){m.current=m.current.filter(t=>!e.includes(t)),p(m.current);for(let t of e)t.onFailure?.(`打断请求超时,尚未确认是否开始回答;请检查会话状态后重试`)}},Math.max(0,Math.min(...e)-Date.now()));return()=>window.clearTimeout(t)},[f]);let us=(e,t)=>n=>({...n,conversations:n.conversations.map(n=>n.id===e?{...n,...t}:n)}),ds=(e,t)=>n=>({...n,workspaces:n.workspaces.map(n=>n.id===e?{...n,...t}:n)}),fs=L?.id.startsWith(`pending:`)===!0,ps=!!(L&&jD(L)&&(ar.has(L.id)||f.some(e=>e.key===`stop:${L.id}`))),ms=L?.messagesLoaded===!1||f.some(e=>e.key.startsWith(`send:${L?.id}:`)||e.key===`configuration:${L?.id}`||e.temporaryId===L?.id||e.key===`archive:${L?.id}`),hs=(e,t,n,r,i)=>{e&&rs({type:`question.answer`,conversationId:e,messageId:t,callIndex:n,answers:r,cancelled:i})},gs=(e,t)=>er(n=>({...n,[e]:t})),_s=(e,t,n)=>(Hi(e),as({type:`extension.ui.answer`,conversationId:e,requestId:t,...n},`answer:${e}:${t}`,e=>e)),vs=L?.model??Kt?.defaultModel,ys=L?.thinkingLevel??Kt?.defaultThinkingLevel,bs=ys&&Kt?.levels.includes(ys)?ys:void 0,xs=Kt?.source===`pi`,Ss=Kt?.models.find(e=>e.provider===vs?.provider&&e.modelId===vs?.modelId),Cs=!!Ss?.imageInput,ws=(e,t)=>!e||!t?e:{...e,models:e.models.filter(e=>(y.modelFilterRules??[]).every(n=>{try{let r=new RegExp(n.workspacePattern,`i`),i=[t.name,t.path,t.worktreeProjectPath].filter(e=>!!e).some(e=>r.test(e.replaceAll(`\\`,`/`))),a=new RegExp(n.modelPattern,`i`);return!i||a.test(e.label)||a.test(`${e.provider}/${e.modelId}`)}catch{return!0}}))},Ts=!!L?.messages?.some(e=>e.images&&e.images.length>0),Es=ws(Kt,y.workspaces.find(e=>e.id===L?.workspaceId))?.models??[],Ds=Ts?Es.filter(e=>e.imageInput):Es,Os=Ds.map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,sE(e.contextWindow)?`${sE(e.contextWindow)} 上下文`:``,cE(e.maxTokens)?`${cE(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:VE(e),selected:vs?.provider===e.provider&&vs.modelId===e.modelId})),ks=(Kt?.levels??[]).map(e=>({key:e,label:e,selected:e===ys})),As=e=>{if(!L)return;let[t,n]=e.split(`/`);t&&n&&(Hi(L.id),as({type:`conversation.model`,conversationId:L.id,provider:t,modelId:n},`configuration:${L.id}`,us(L.id,{model:Kt?.models.find(e=>e.provider===t&&e.modelId===n)??{provider:t,modelId:n,label:n}})))},js=e=>{L&&(Hi(L.id),as({type:`conversation.thinking`,conversationId:L.id,level:e},`configuration:${L.id}`,us(L.id,{thinkingLevel:e})))},Ms=en?.agents.find(e=>e.id===L?.agentId),Ns=[{key:SD,label:`跟随 Pi 默认`,detail:`不使用任何 agent 角色`,selected:!L?.agentId},...(en?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:L?.agentId===e.id}))],Ps=Ms?.model,Fs=!!(Ps&&L?.model&&L.model.provider===Ps.provider&&L.model.modelId===Ps.modelId);Ms?.thinkingLevel&&(L?.thinkingLevel,Ms.thinkingLevel);let Is=e=>{if(L){let t=en?.agents.find(t=>t.id===e);as({type:`conversation.agent`,conversationId:L.id,agentId:e===SD?null:e},`configuration:${L.id}`,us(L.id,{agentId:t?.id,...t?.model?{model:{...t.model,label:t.model.modelId}}:{},...t?.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}}))}},Ls=fn.filter(e=>e.conversationId===L?.id),Rs=(0,u.useMemo)(()=>{let e=L?.id;return e?(L.messages??[]).flatMap(t=>(t.toolCalls??[]).flatMap((n,r)=>n.question?.status===`pending`?[{key:mD(e,t.id,r),messageId:t.id,index:r,value:n.question}]:[])):[]},[L?.id,L?.messages]),zs=Rs[0],Bs=()=>{let e=zs;e&&(nr(e.key),Ge(`session`),window.setTimeout(()=>{(it.current?.querySelector(`[data-transcript-key="${CSS.escape(`m:${e.messageId}`)}"]`))?.scrollIntoView({block:`center`,behavior:`smooth`})},0))},Vs=Ht.filter(e=>e.conversationId===L?.id).map(e=>e.request),Hs=new Map(Vs.filter(e=>e.method===`setStatus`).map(e=>[e.statusKey??``,e.statusText??``])),Us=new Map(Vs.filter(e=>e.method===`setWidget`).map(e=>[e.widgetKey??``,{lines:e.widgetLines??[],placement:e.widgetPlacement??`aboveEditor`}])),Ws=Vs.find(e=>e.method===`setTitle`)?.title,Gs=(0,u.useMemo)(()=>(y.subagentRuns??[]).filter(e=>e.conversationId===L?.id),[y.subagentRuns,L?.id]),Ks=(0,u.useMemo)(()=>(y.workflows??[]).filter(e=>e.conversationId===L?.id),[y.workflows,L?.id]),qs=(0,u.useMemo)(()=>new Map(Ks.map(e=>[e.id,e])),[Ks]),Js=(0,u.useMemo)(()=>new Map((nn?.agents??[]).map(e=>[e.id,e.name])),[nn]),Ys=(0,u.useMemo)(()=>new Map((L?.messages??[]).map(e=>[e.id,e])),[L?.messages]),Xs=(0,u.useMemo)(()=>new Map(Gs.map(e=>[e.id,e])),[Gs]),Zs=(0,u.useMemo)(()=>{let e=new Map;for(let t of Gs)t.originMessageId!==void 0&&t.originCallRow!==void 0&&e.set(`${t.originMessageId}:${t.originCallRow}`,t);return e},[Gs]),Qs=(0,u.useMemo)(()=>{if(!L||!Vi)return[];let e=rr?.conversationId===L.id?(()=>{let e=L.messages.find(e=>e.id===rr.messageId);if(e)return{index:L.messages.indexOf(e),at:Date.parse(e.createdAt)||0,...rr.kind===`withdraw`?{inclusive:!0}:{inclusive:!1}}})():void 0,t=[];return L.messages.forEach((n,r)=>{e&&(r>e.index||e.inclusive&&r===e.index)||n.delivery||t.push({at:Date.parse(n.createdAt)||0,seq:r,key:`m:${n.id}`})}),Gs.forEach((n,r)=>{n.originMessageId&&n.originCallRow!==void 0&&L?.messages.some(e=>e.id===n.originMessageId&&e.toolCalls?.[n.originCallRow])||e&&(Date.parse(n.startedAt)||0)>e.at||t.push({at:Date.parse(n.startedAt)||0,seq:t.length+r,key:`r:${n.id}`})}),Ks.forEach((n,r)=>{e&&(Date.parse(n.startedAt)||0)>e.at||t.push({at:Date.parse(n.startedAt)||0,seq:t.length+r,key:`w:${n.id}`})}),Wr(t)},[L,Gs,Ks,rr]),$s=(0,u.useMemo)(()=>{for(let e=Qs.length-1;e>=0;--e){let t=Qs[e];if(t.startsWith(`m:`)&&Ys.get(t.slice(2))?.role===`user`)return t.slice(2)}},[Qs,Ys]);(0,u.useEffect)(()=>{let e=it.current;if(!e||!L?.id)return;let t=()=>{!pt.current&&Me.current[L.id]?.followTail&&(wO(e),e.scrollTop=e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of e.children)n.observe(t);return()=>n.disconnect()},[L?.id,L?.messages,Gs,Ks,Vi,Qs,I]);let ec=e=>Jn(t=>({...t,[e]:!t[e]})),tc=(e,t)=>Xn(n=>({...n,[`${e}:${t}`]:!n[`${e}:${t}`]})),nc=(e,t)=>Qn(n=>({...n,[`${e}:${t}`]:n[`${e}:${t}`]!==!1})),[rc,ic]=(0,u.useState)({}),ac=e=>ic(t=>({...t,[e]:t[e]!==!0})),oc=e=>{as({type:`subagent.stop`,runId:e},`stop:${e}`,e=>e)||Y(`连接断开,无法停止子智能体,请重试`,`error`)},sc=e=>{as({type:`workflow.stop`,workflowId:e},`stop:${e}`,e=>e)||Y(`连接断开,无法停止编排,请重试`,`error`)},cc=e=>[...Us].filter(([,t])=>t.placement===e).map(([e,t])=>{let n=t.lines;return(0,F.jsxs)(`div`,{className:`extui-widget`,"data-widget-key":e,"data-widget-lines":n.length,children:[n.slice(0,JE).map((e,t)=>(0,F.jsx)(`div`,{children:e},`${t}:${e}`)),n.length>JE&&(0,F.jsx)(`div`,{children:`… (widget truncated)`})]},e)}),lc=(e,t)=>{let n=`pending:${En()}`,r={id:n,name:e,path:t,updatedAt:new Date().toISOString()};as({type:`workspace.create`,name:e,path:t},`create-workspace`,e=>({...e,workspaces:[...e.workspaces,r]}),n)&&(Gi(n),Te(!1))},[uc,dc]=(0,u.useState)(),fc=(e,t)=>dc(n=>n?.kind===e&&n.id===t?n:{kind:e,id:t}),pc=()=>dc(void 0),mc=(e,t)=>uc?.kind===e&&uc.id===t,hc=(e,t,n)=>!t.startsWith(`pending:`)&&(e===`conversation`&&Hi(t),as(e===`workspace`?{type:`workspace.rename`,workspaceId:t,name:n}:{type:`conversation.rename`,conversationId:t,name:n},`rename:${t}`,e===`workspace`?ds(t,{name:n}):us(t,{title:n}))?(jr.current=!0,pc(),!0):(Y(`连接断开,改名未保存,请重试`,`error`),!1)),gc=async e=>{if(e.startsWith(`pending:`)){Y(`这个会话还在创建中,稍后再试`,`warning`);return}if(dr.current.has(e))return;Y(`正在根据对话内容生成标题…`,`info`);let t=new Promise((t,n)=>{dr.current.set(e,{resolve:t,reject:n}),window.setTimeout(()=>{dr.current.delete(e)&&n(Error(`模型在 ${Math.round(pE/1e3)} 秒内没有返回标题`))},pE)});if(!rs({type:`conversation.autoRename`,conversationId:e}))dr.current.delete(e),Y(`连接断开,无法生成标题`,`error`);else try{let n=await t;hc(`conversation`,e,n),Y(`已重命名为「${n}」`,`info`)}catch(e){Y(`重命名失败:${ct(e)}`,`error`)}},_c=e=>{if(e.id.startsWith(`pending:`))return;let t=y.conversations.filter(t=>t.workspaceId===e.id).length;window.confirm(`从列表移除工作区「${e.name}」?${t?`其中的 ${t} 条会话会保留,`:``}重新添加同一个目录即可恢复,不会删除任何会话。`)&&(yc(void 0),as({type:`workspace.delete`,workspaceId:e.id},`delete:${e.id}`,t=>({...t,workspaces:t.workspaces.filter(t=>t.id!==e.id),conversations:t.conversations.filter(t=>t.workspaceId!==e.id)})))},[vc,yc]=(0,u.useState)(),[bc,xc]=(0,u.useState)(!1),Sc=vc?y.workspaces.find(e=>e.id===vc):void 0,{theme:Cc,setTheme:wc}=Nm(),[Tc,Ec]=(0,u.useState)(!1),[Dc,Oc]=(0,u.useState)();(0,u.useEffect)(()=>{let e=()=>{fe(),de(`entry`),Oc(`servers`),Ec(!0)};return window.addEventListener(`super-pi-open-server-management`,e),()=>window.removeEventListener(`super-pi-open-server-management`,e)},[]);let[kc,Ac]=(0,u.useState)(!1),jc=(e,t,n,r)=>{e.startsWith(`pending:`)||(as({type:`workspace.settings`,workspaceId:e,model:n?{provider:n.provider,modelId:n.modelId}:null,thinkingLevel:r??null,agentId:t??null},`defaults:${e}`,ds(e,{defaultModel:n,defaultThinkingLevel:r,defaultAgentId:t}))?yc(void 0):Y(`连接断开,设置未保存,请重试`,`error`))},Mc=(e,t)=>{let n=D.activeServer;as({type:`workspaces.settings.bulk`,model:e?{provider:e.provider,modelId:e.modelId}:null,thinkingLevel:t??null},`workspace-defaults-bulk`,r=>({...r,workspaces:r.workspaces.map(r=>{if(h(r.id).server!==n||r.closedAt||r.id.startsWith(`pending:`))return r;let i={...r};return e?i.defaultModel=e:delete i.defaultModel,t?i.defaultThinkingLevel=t:delete i.defaultThinkingLevel,i})}))?xc(!1):Y(`连接断开,批量设置未保存,请重试`,`error`)},Nc=(e,t=``)=>{if(e.startsWith(`pending:`))return;if(m.current.some(t=>t.key===`defaults:${e}`)){Y(`工作区设置正在保存,请稍后再新建会话`,`warning`);return}let n=`pending:${En()}`,r={id:n,workspaceId:e,title:`新会话`,status:`idle`,updatedAt:new Date().toISOString(),messages:[],...t?{cwd:t}:{}};Fr.current.set(n,r),as({type:`conversation.create`,workspaceId:e,...t?{cwd:t}:{}},`create-session:${e}:${n}`,e=>({...e,conversations:[r,...e.conversations]}),n)?(ie.current++,w(e),x(n),Ge(`session`),N(e=>({...e,ids:[...e.ids.filter(e=>e!==n),n],touched:kO(e.touched,n)}))):(Fr.current.delete(n),Y(`连接断开,会话未创建,请重试`,`error`))},Pc=e=>{if(e.startsWith(`pending:`))return;let t=y.conversations.find(t=>t.id===e);if(!t||t.archivedAt||t.parentConversationId&&y.conversations.some(e=>e.id===t.parentConversationId))return;let n=jE(y.conversations,e),r=n.filter(e=>!e.archivedAt),i=r.length-1,a=n.length-r.length,o=lE(y.pendingUserDecisionsByConversation,n.map(e=>e.id)),s=mE({title:t.title,activeCount:r.length,activeDescendants:i,alreadyArchived:a,pendingDecisions:o});if(hE({activeDescendants:i,pendingDecisions:o})&&!window.confirm(s))return;let c=new Date().toISOString(),l=new Set(r.map(e=>e.id));as({type:`conversation.archive`,conversationId:e},`archive:${e}`,e=>({...e,conversations:e.conversations.map(e=>l.has(e.id)&&!e.archivedAt?{...e,archivedAt:c}:e)}))},Fc=(e,t)=>as({type:`conversation.collapse`,conversationId:e,collapsed:t},`collapse:${e}`,n=>{let r=new Set(n.collapsedConversationIds??[]);t?r.add(e):r.delete(e);let i={...n};return r.size===0?delete i.collapsedConversationIds:i.collapsedConversationIds=[...r],i}),Ic=e=>{let t=y.conversations.find(t=>t.id===e);if(!t?.archivedAt||(t.parentConversationId?y.conversations.find(e=>e.id===t.parentConversationId):void 0)?.archivedAt)return;let n=new Set(jE(y.conversations,e).filter(e=>e.archivedAt).map(e=>e.id));as({type:`conversation.unarchive`,conversationId:e},`unarchive:${e}`,e=>({...e,conversations:e.conversations.map(e=>{if(!n.has(e.id)||!e.archivedAt)return e;let t={...e};return delete t.archivedAt,t})}))},Lc=async e=>{if(!L){Y(`请先选择或创建会话`,`error`);return}if(!Cs){Y(`当前模型不支持图片输入`,`error`);return}let t=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],n=e.filter(e=>t.includes(e.type)?e.size>5242880?(Y(`图片「${e.name}」超过 5MB 上限`,`error`),!1):!0:(Y(`不支持的文件格式「${e.name}」,仅支持 PNG/JPEG/GIF/WebP`,`error`),!1));if(n.length===0)return;let r=L.id;yi(r,e=>({...e,uploading:e.uploading+n.length}));let i=n.map(e=>({id:En(),conversationId:r,name:e.name,url:URL.createObjectURL(e)}));xr(e=>[...e,...i]);for(let[e,t]of n.entries()){let n=i[e];try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>{let t=r.result,n=t.indexOf(`,`);e(n>=0?t.slice(n+1):t)},r.onerror=n,r.readAsDataURL(t)}),i=await Ae(`/api/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({conversationId:r,name:t.name,mimeType:t.type,data:e})});if(!(i.headers.get(`content-type`)??``).includes(`application/json`)){Y(`服务器未返回 JSON 响应,请刷新或重启服务`,`error`);continue}if(i.ok){let e=await i.json();if(_r.current.has(n.id))continue;xr(e=>e.filter(e=>e.id!==n.id)),URL.revokeObjectURL(n.url),yi(r,t=>({...t,images:[...t.images,{id:e.id,name:e.name,mimeType:e.mimeType,bytes:e.bytes}]}))}else{let e=await i.json().catch(()=>({error:`上传失败`}));Y(ct(e.error,`上传失败(HTTP ${i.status})`),`error`)}}catch(e){Y(`上传失败:${ct(e,`网络或服务暂时不可用`)}`,`error`)}finally{xr(e=>e.map(e=>e.id===n.id?{...e,failed:!0}:e)),yi(r,e=>({...e,uploading:Math.max(0,e.uploading-1)}))}}},Rc=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.type.startsWith(`image/`)){let e=r.getAsFile();e&&n.push(e)}}if(n.length>0){if(!Cs){Y(`当前模型不支持图片输入`,`error`);return}e.preventDefault(),Lc(n)}},Z=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),Tr(!0))},zc=e=>{e.currentTarget.contains(e.relatedTarget)||Tr(!1)},Bc=e=>{Tr(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>e.type.startsWith(`image/`));if(t.length>0){if(e.preventDefault(),!Cs){Y(`当前模型不支持图片输入`,`error`);return}Lc(t)}},Vc=t=>{if(t.preventDefault(),!L)return;if($r){Y(cw,`warning`);return}if(ms){Y(fs?`会话正在创建,请稍候再发送`:L.messagesLoaded===!1?`正在加载会话,请稍候再发送`:`正在保存配置,请稍候再发送`,`info`);return}if(!mi.trim()&&hi.length===0)return;if(hi.length>0&&!Cs){Y(`当前模型不支持图片输入,请移除图片或切换至支持图文的模型`,`error`);return}if(vi>0){Y(`图片正在上传中,请稍候…`,`info`);return}if(_i){Y(`技能正在读取中,请稍候…`,`info`);return}let n=`message_${En()}`,r=L.id,i=mi,a=hi,o=gi;Hi(r),e.stoppingConversationIds||or(e=>{if(!e.has(r))return e;let t=new Set(e);return t.delete(r),t});let s=cD({conversationId:r,content:i,clientId:n,images:a,attachments:o,inFlight:jD(L),deliveryMode:Hr}),c=new Date().toISOString();as(s,`send:${r}:${n}`,e=>Qd(e,s,c),n,e=>{yr(t=>[...t,{id:n,conversationId:r,content:i,images:a,attachments:o,reason:e}]),yi(r,e=>e.text||e.images.length||e.attachments.length?e:{...e,text:i,images:a,attachments:o})},e=>!!e.conversations.find(e=>e.id===r)?.messages.some(e=>e.id===n))&&yi(r,e=>({...e,text:``,images:[],attachments:[],pendingSkills:void 0}))},Hc=(0,u.useMemo)(()=>(L?.messages??[]).filter(e=>(e.role===`user`||e.role===`tool`)&&e.delivery),[L?.messages]),Uc=e=>{as({type:`message.cancel`,conversationId:L?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===L?.id?{...t,messages:t.messages.filter(t=>t.id!==e)}:t)}))||Y(`连接断开,撤回没有生效,请重试`,`error`)},Wc=e=>{if(!L?.id||!e.length)return;let t=new Set(e),n=`queue-many:${L.id}:${e.join(`,`)}`;as({type:`message.cancelMany`,conversationId:L.id,messageIds:e},n,e=>({...e,conversations:e.conversations.map(e=>e.id===L.id?{...e,messages:e.messages.filter(e=>!t.has(e.id))}:e)}),void 0,e=>Y(e??`撤回所选消息失败,请重试`,`error`),t=>{let n=t.conversations.find(e=>e.id===L.id);return!!(n&&e.every(e=>!n.messages.some(t=>t.id===e&&t.delivery)))})||Y(`连接断开,批量撤回没有生效,请重试`,`error`)},Gc=e=>{as({type:`message.steer`,conversationId:L?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===L?.id?{...t,messages:vE(t.messages,e,0)}:t)}),void 0,void 0,t=>t.conversations.find(e=>e.id===L?.id)?.messages.find(t=>t.id===e)?.delivery===`sending`)||Y(`连接断开,插到最前没有生效,请重试`,`error`)},Kc=e=>{let t=L?.id;t&&(je.current?.readyState===WebSocket.OPEN?as({type:`message.interrupt`,conversationId:t,messageId:e},`interrupt:${t}:${e}`,e=>e,void 0,e=>Y(e??`打断失败,请重试`,`error`),n=>{let r=n.conversations.find(e=>e.id===t)?.messages.find(t=>t.id===e);return!(!r||r.delivery)},3e4)||Y(`正在打断,请稍候`,`info`):Y(`连接断开,打断没有生效,请重试`,`error`))},qc=e=>{as({type:`message.sendQueued`,conversationId:L?.id??``,messageId:e},`send-queued:${e}`,e=>e,void 0,void 0,t=>!t.conversations.find(e=>e.id===L?.id)?.messages.find(t=>t.id===e)?.delivery)||Y(`连接断开,发送没有生效,请重试`,`error`)},Jc=(e,t)=>{as({type:`message.edit`,conversationId:L?.id??``,messageId:e,content:t},`edit:${e}`,n=>({...n,conversations:n.conversations.map(n=>n.id===L?.id?{...n,messages:n.messages.map(n=>n.id===e?{...n,content:t}:n)}:n)}))||Y(`连接断开,修改没有生效,请重试`,`error`)},[Yc,Xc]=(0,u.useState)(),Zc=(e,t=!1)=>{if(!L||L.messagesLoaded===!1||Yc)return;let n=L.messages.find(t=>t.id===e);n&&(n&&pr(e=>{let t=e[L.id]??{text:``,images:[],attachments:[],uploading:0};return t.text.trim()||t.images.length||t.attachments.length?e:{...e,[L.id]:{...t,text:n.content,images:n.images??[],attachments:sD(n.content,n.attachments)}}}),ir({conversationId:L.id,messageId:e,kind:t?`withdraw`:`revert`})),rs({type:`message.revert`,conversationId:L.id,messageId:e,withdraw:t})?Xc(e):(ir(void 0),Y(`连接断开,回退未执行,请重试`,`error`))},[Qc,$c]=(0,u.useState)(),el=(0,u.useRef)(void 0),tl=(0,u.useRef)(0),nl=async(e,t)=>{let n=++tl.current,r=await ju(t);n===tl.current&&(clearTimeout(el.current),$c({id:e,kind:r?`copied`:`error`}),r||Y(`复制失败:浏览器拒绝了剪贴板写入,可以手动选中这条消息的文字复制`,`error`),el.current=setTimeout(()=>$c(void 0),2e3))};(0,u.useEffect)(()=>()=>{tl.current+=1,clearTimeout(el.current)},[]);let[rl,il]=(0,u.useState)(),al=e=>{rl||e.startsWith(`pending:`)||(Hi(e),rs({type:`conversation.fork`,conversationId:e})?il(e):Y(`连接断开,分叉没有执行,请重试`,`error`))},ol=new Map;for(let e of y.scheduledTasks??[])e.conversationId&&!ol.has(e.conversationId)&&ol.set(e.conversationId,e);let sl=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-theme-open":`1`,title:`设置`,"aria-haspopup":`dialog`,"aria-expanded":Tc,onClick:()=>{Oc(void 0),fe(),Ec(!0),os({type:`catalog.fetchAll`}),os({type:`providers.fetch`})},children:[(0,F.jsx)(Tt,{name:`settings`}),(0,F.jsx)(`span`,{className:`workbench-action-label`,children:`设置`})]}),(0,F.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-help-open":`1`,title:`使用指南`,"aria-haspopup":`dialog`,"aria-expanded":kc,onClick:()=>Ac(!0),children:[(0,F.jsx)(Tt,{name:`help`}),(0,F.jsx)(`span`,{className:`workbench-action-label`,children:`使用指南`})]})]}),cl=Xi?void 0:L,ll=ie.current,ul={onOpenSession:e=>{ll===ie.current&&is(e)},todos:y.todosByConversation?.[cl?.id??``]??[],tasks:KD(cl,y.backgroundTasks??[]),backgroundRuns:cl?Xs:void 0,execOutputs:mt.current,scheduledTasks:(y.scheduledTasks??[]).filter(e=>e.workspaceId===Zi),scheduledCatalog:ws(Kt,Ko),scheduledAgents:en,notify:Y,serverTimeZone:y.serverTimeZone,workspaceId:Zi,gitWorkspaceId:$i,gitRepositoryOnly:ta,gitWorkspaceName:qo?.name,workspaceLabel:Ko?.path,workspaceName:Ko?.name,conversationId:cl?.id,followedWorktreeId:cl?.followedWorktreeId,cwd:ea,connected:O&&D.statuses.get(D.activeServer)?.state===`online`&&Se&&!cl?.id.startsWith(`pending:`),files:da,onOpenFile:ho,onOpenChanged:to,onOpenGitDiff:Qa,activeGitDiffUrl:Ya?.target.url,onFileReference:go,onFilesMoved:_o,onSearchFolder:e=>Ma(`content`,void 0,[ea,e].filter(Boolean).join(`/`)),onSelectTab:V,sendCommand:rs,registerTerminalSink:wt,terminalShell:y.terminalShell,sharedGit:fa},dl=e=>D.connections.some(t=>t.id===h(e).server)&&(wn===`all`||h(e).server===wn),fl=new Set(y.workspaces.map(e=>e.id)),pl=y.workspaces.filter(e=>dl(e.id)&&(!e.worktreeOf||!fl.has(e.worktreeOf))),ml=pl.flatMap(e=>[e,...y.workspaces.filter(t=>t.worktreeOf===e.id)]),hl=(0,u.useMemo)(()=>{let e=new Map;for(let t of y.workspaces){if(t.closedAt)continue;let n=t.name.trim().toLowerCase();n&&e.set(n,(e.get(n)??0)+1)}return new Set([...e].filter(([,e])=>e>1).map(([e])=>e))},[y.workspaces]),gl=Dn&&ml.some(e=>e.id===Dn)?Dn:C&&ml.some(e=>e.id===C)?C:ml[0]?.id,_l=y.workspaces.find(e=>e.id===C),vl=_l?.worktreeOf&&fl.has(_l.worktreeOf)?_l.worktreeOf:_l?.id,yl=kn&&pl.some(e=>e.id===kn)?kn:vl&&pl.some(e=>e.id===vl)?vl:pl[0]?.id,bl=Date.now()-18e6,xl=ml.filter(e=>e.id===yl||e.worktreeOf===yl),Sl=e=>{let t=y.conversations.some(t=>t.workspaceId===e&&!t.archivedAt&&(Sn===`recent`?Date.parse(t.updatedAt)>=bl:t.status===`running`||t.status===`waiting`)),n=(Ke[e]?.rooms??[]).some(e=>!e.archivedAt&&(Sn===`recent`?Date.parse(e.updatedAt)>=bl:[`running`,`queued`].includes(Tw(e,Xe[e.id]))));return t||n},Cl=pl.flatMap(e=>{let t=ml.filter(t=>t.worktreeOf===e.id&&Sl(t.id));return Sl(e.id)||t.length>0?[e,...t]:[]}),wl=Sn===`all`?ml:Sn===`workspace`?ml.filter(e=>e.id===gl):Sn===`repo`?xl:Cl,Tl=Sn===`all`||Sn===`workspace`||Sn===`repo`,El=(e,t=Sn,n=gl,r=yl)=>{if(!e||!dl(e))return!1;if(t===`all`)return!0;if(t===`workspace`)return e===n;if(t===`repo`)return e===r||ml.some(t=>t.id===e&&t.worktreeOf===r);let i=y.conversations.filter(t=>t.workspaceId===e&&!t.archivedAt).some(e=>t===`recent`?Date.parse(e.updatedAt)>=bl:e.status===`running`||e.status===`waiting`),a=(Ke[e]?.rooms??[]).some(e=>!e.archivedAt&&(t===`recent`?Date.parse(e.updatedAt)>=bl:[`running`,`queued`].includes(Tw(e,Xe[e.id]))));return i||a},Dl=(e,t=gl,n=yl)=>{Cn(e),t&&On(t),n&&An(n);let r=I===`group`&&et&&tt?Ke[et]?.rooms.find(e=>e.id===tt):void 0,i=I===`group`?!!(et&&r&&!r.archivedAt&&El(et,e,t,n)&&(e===`all`||e===`workspace`||e===`repo`||(e===`recent`?Date.parse(r.updatedAt)>=bl:[`running`,`queued`].includes(Tw(r,Xe[r.id]))))):!!(L&&!L.archivedAt&&El(L.workspaceId,e,t,n)&&(e===`all`||e===`workspace`||e===`repo`||(e===`recent`?Date.parse(L.updatedAt)>=bl:L.status===`running`||L.status===`waiting`)));if(So.current=!0,i){e===`workspace`&&w(t);let r=bo.find(e=>e.id===xo)?.workspaceId;(e===`recent`||e===`running`||(e===`workspace`||e===`repo`)&&!El(r,e,t,n))&&Ge(`session`)}else Mn(!0),x(void 0),We(!1),(I===`session`||I===`group`||e===`recent`||e===`running`||(e===`workspace`||e===`repo`)&&!El(bo.find(e=>e.id===xo)?.workspaceId,e,t,n))&&Ge(`session`),w(e===`workspace`?t:void 0)},Ol=e=>{Tn(e),localStorage.setItem(`super-pi.server-filter`,e),e!==`all`&&ge(e);let t=I===`group`?et:L?.workspaceId??C;if(t&&e!==`all`&&h(t).server!==e){So.current=!0,Mn(!0),x(void 0),We(!1);let t=y.workspaces.filter(t=>h(t.id).server===e);if(Sn===`workspace`){let e=t.find(e=>e.id===Dn)?.id??t[0]?.id;On(e),w(e)}else w(void 0),Sn===`repo`&&An(t.find(e=>!e.worktreeOf)?.id);Ge(`session`)}};(0,u.useEffect)(()=>{wn!==`all`&&!D.connections.some(e=>e.id===wn)&&Ol(`all`)},[wn,D.connections]);let kl=bo.filter(e=>{if(!e.workspaceId||!dl(e.workspaceId))return!1;if(Sn===`all`)return!0;if(Sn===`workspace`||Sn===`repo`)return El(e.workspaceId);if(e.id.startsWith(`session:`)){let t=y.conversations.find(t=>t.id===e.rawId);return!!(t&&!t.archivedAt&&El(t.workspaceId)&&(Sn===`recent`?Date.parse(t.updatedAt)>=bl:t.status===`running`||t.status===`waiting`))}if(e.id.startsWith(`group:`)){let t=bw(e.id),n=t?.roomId?Ke[t.workspaceId]?.rooms.find(e=>e.id===t.roomId):void 0;return!!(t&&n&&!n.archivedAt&&El(t.workspaceId)&&(Sn===`recent`?Date.parse(n.updatedAt)>=bl:[`running`,`queued`].includes(Tw(n,Xe[n.id]))))}return!1}),Al=ta?`未选工作区`:fa.status?.detached?`游离 HEAD`:fa.status?.branch,jl=!ta&&fa.status&&new Set([...fa.status.staged,...fa.status.unstaged,...fa.status.untracked].map(e=>e.path)).size,Ml=!ta&&fa.status&&(fa.status.ahead||fa.status.behind)?[fa.status.ahead?`↑`+fa.status.ahead:``,fa.status.behind?`↓`+fa.status.behind:``].filter(Boolean).join(` `):``,Nl=()=>Ln(e=>({...e,rightClosed:!0})),Pl=()=>Ln(e=>({...e,leftClosed:!0})),Fl=Kn?pn:Ca;return(0,F.jsxs)(`main`,{className:`shell workbench-shell${Fl?` shell-rail-collapsed`:``} mobile-panel-${hn}${bn?` mobile-drawer-open`:``}`,"data-rail-collapsed":Fl,"data-workbench-left-closed":!Kn&&In.leftClosed,"data-selected-workspace":C??``,style:{"--sidebar-width":`${Bn.sidebar}px`,"--rail-col":Fl?void 0:`${Bn.rail}px`},children:[!Kn&&(0,F.jsx)(Et,{side:`left`,views:H,unpinned:In.unpinned,active:In.leftClosed?void 0:W,onSelect:e=>Ta(e,!0),onSearch:()=>Ma(`content`),onArrange:Ea,onReorder:Da,onReset:Oa,children:sl}),(0,F.jsxs)(`aside`,{className:`workbench-sessions`,id:`workbench-sessions`,"data-workbench-session-view":wa?`shown`:`hidden`,children:[(0,F.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,F.jsx)(`button`,{className:`workspace-new`,onClick:()=>Te(!0),children:`+ 添加工作区`}),L&&Vi&&kl.length===1&&(0,F.jsx)(`button`,{type:`button`,className:`mobile-close-session`,onClick:()=>{zo(L.id),xn(!1)},children:`关闭当前标签`})]}),(0,F.jsxs)(`div`,{className:`label label-desktop workspace-title-row`,children:[(0,F.jsx)(`span`,{children:`工作区`}),(0,F.jsx)(`button`,{type:`button`,className:`workspace-bulk-settings`,title:`批量设置所有工作区`,"aria-label":`批量设置所有工作区`,onClick:()=>xc(!0),children:`⚙`})]}),(0,F.jsx)(`div`,{className:`label label-phone`,children:`会话`}),bc&&(0,F.jsx)(qw,{workspaces:y.workspaces.filter(e=>h(e.id).server===D.activeServer&&!e.closedAt&&!e.id.startsWith(`pending:`)),catalog:Jt??{source:`unavailable`,models:[],levels:[],fetchedAt:``},onClose:()=>xc(!1),onSave:Mc}),(0,F.jsxs)(`div`,{className:`sidebar-session-filters`,"aria-label":`会话与群聊筛选`,children:[(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`span`,{children:`服务器`}),(0,F.jsxs)(`select`,{"aria-label":`服务器范围`,value:wn,onChange:e=>Ol(e.target.value),children:[(0,F.jsx)(`option`,{value:`all`,children:`全部服务器`}),D.connections.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[e.name,D.statuses.get(e.id)?.state===`offline`?` · 离线`:``]},e.id))]})]}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`span`,{children:`显示`}),(0,F.jsxs)(`select`,{"aria-label":`会话列表筛选方式`,value:Sn,onChange:e=>Dl(e.currentTarget.value),children:[(0,F.jsx)(`option`,{value:`all`,children:`全部`}),(0,F.jsx)(`option`,{value:`workspace`,children:`按工作区`}),(0,F.jsx)(`option`,{value:`repo`,children:`按仓库`}),(0,F.jsx)(`option`,{value:`recent`,children:`近期活跃 · 5 小时`}),(0,F.jsx)(`option`,{value:`running`,children:`正在运行`})]})]}),Sn===`workspace`&&(0,F.jsx)(`select`,{"aria-label":`选择工作区`,value:gl??``,onChange:e=>Dl(`workspace`,e.currentTarget.value,yl),children:(0,F.jsx)(Be,{workspaces:ml})}),Sn===`repo`&&(0,F.jsx)(`select`,{"aria-label":`选择仓库`,value:yl??``,onChange:e=>Dl(`repo`,gl,e.currentTarget.value),children:(0,F.jsx)(Be,{workspaces:pl})})]}),(0,F.jsx)(`nav`,{"aria-label":`工作区、会话与群聊`,children:wl.length===0?(0,F.jsx)(`div`,{className:`sidebar-filter-empty`,children:Sn===`recent`?`近 5 小时没有活跃的会话或群聊`:`当前没有正在运行的会话或群聊`}):wl.map((e,t)=>{let n=Ke[e.id],r=(n?.rooms.filter(e=>!e.archivedAt)??[]).filter(e=>Tl||(Sn===`recent`?Date.parse(e.updatedAt)>=bl:[`running`,`queued`].includes(Tw(e,Xe[e.id])))),i=Tl?n?.rooms.filter(e=>e.archivedAt)??[]:[],a=y.conversations.filter(t=>t.workspaceId===e.id),o=a.filter(e=>!e.archivedAt&&(Tl||(Sn===`recent`?Date.parse(e.updatedAt)>=bl:e.status===`running`||e.status===`waiting`))),s=aT(o,Br,{manualRoots:kt[e.id]}),c=s.filter(e=>e.depth===0).map(e=>e.conversation.id),l=Tl?a.filter(e=>e.archivedAt):[],u=aT(l,new Set),d=Tl?l.length+i.length:0,f=j[e.id]??!1,p=Dt[e.id]??!0,m=hl.has(e.name.trim().toLowerCase()),g=!e.worktreeOf||!fl.has(e.worktreeOf),_=(Sn===`recent`||Sn===`running`)&&g,v=t=>I===`group`&&et===e.id&&tt===t;return(0,F.jsxs)(`section`,{className:`workspace-group${e.worktreeOf&&fl.has(e.worktreeOf)?` workspace-linked-checkout`:``}${_?` workspace-active-repo-root`:``}`,"data-workspace-parent":e.worktreeOf,"data-workspace-group":e.id,"data-sidebar-repo-root":_?e.id:void 0,"data-current-workspace":C===e.id,children:[D.connections.length>1&&(t===0||h(wl[t-1].id).server!==h(e.id).server)&&(0,F.jsxs)(`div`,{className:`workspace-server-label`,children:[he(e.id),D.statuses.get(h(e.id).server)?.state===`offline`?` · 离线`:``]}),(0,F.jsx)(`div`,{className:`workspace-header`,children:mc(`workspace`,e.id)?(0,F.jsx)(bD,{initial:e.name,label:`重命名工作区 ${e.name}`,onCommit:t=>hc(`workspace`,e.id,t),onClose:pc}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`workspace-disclosure`,"data-workspace-fold":e.id,"aria-expanded":!f,"aria-label":`${f?`展开`:`折叠`}工作区 ${e.name}`,onClick:()=>ee(t=>({...t,[e.id]:!t[e.id]})),children:(0,F.jsx)(`span`,{className:`chevron-folder`,"aria-hidden":`true`,children:f?`▸`:`▾`})}),(0,F.jsx)(`button`,{type:`button`,className:`workspace-toggle`,"aria-label":e.name,"aria-describedby":m?`workspace-name-warning-${e.id}`:void 0,title:e.path,onContextMenu:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect();cr({workspace:e,x:t.clientX||n.left+24,y:t.clientY||n.top+n.height})},onClick:()=>{On(e.id);let t=Rr.find(t=>t.workspaceId===e.id)?.id;t?(t!==L?.id||I!==`session`||!Vi)&&Ui(t):Gi(e.id)},children:(0,F.jsxs)(`span`,{children:[(0,F.jsxs)(`span`,{className:`workspace-name-line`,children:[(0,F.jsx)(`strong`,{onDoubleClick:()=>fc(`workspace`,e.id),children:e.name}),m&&(0,F.jsx)(`small`,{id:`workspace-name-warning-${e.id}`,className:`workspace-name-warning`,"data-workspace-name-warning":e.id,title:`请重命名其中一个工作区;名称唯一后提示会自动消失。`,children:`存在同名,易混淆`})]}),(0,F.jsx)(`small`,{children:e.path})]})}),(0,F.jsx)(`button`,{className:`workspace-add`,disabled:e.id.startsWith(`pending:`),title:`在此工作区新建会话`,onClick:t=>{On(e.id),Oe.current=t.currentTarget,De({workspaceId:e.id})},children:`+`}),(0,F.jsx)(`button`,{type:`button`,className:`workspace-group-chat`,"data-open-group-chat":e.id,disabled:e.id.startsWith(`pending:`),title:`新建群聊`,"aria-label":`在 ${e.name} 新建群聊`,onClick:()=>{On(e.id),Ki(e.id)},children:(0,F.jsx)(Tt,{name:`group-add`})}),(0,F.jsx)(`button`,{className:`workspace-settings`,title:`工作区设置(默认智能体 / 模型 / 思考强度)`,"aria-label":`工作区设置 ${e.name}`,onClick:()=>yc(e.id),children:`⚙`})]})}),!f&&r.map(t=>{let n=v(t.id),r=Tw(t,Xe[t.id]),i=Ew(t,Xe[t.id],Fe.current[yw({workspaceId:e.id,roomId:t.id})]),a=i===`completed`?`讨论已完成,有新回复未读`:i===`unread`?`有新回复未读`:OD[r];return(0,F.jsxs)(`div`,{className:`conversation-row group-room-row`,children:[(0,F.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),(0,F.jsxs)(`button`,{type:`button`,className:`conversation group-room-button${n?` selected`:``}`,"data-sidebar-group-chat":t.id,"aria-current":n?`true`:void 0,"aria-label":`打开群聊 ${t.title},${a}`,title:t.title,onClick:()=>{On(e.id),Ki(e.id,t.id)},children:[(0,F.jsx)(`i`,{className:`conversation-mark`,children:(0,F.jsx)(RD,{state:i,label:a})}),(0,F.jsx)(Tt,{name:`group`}),(0,F.jsx)(`span`,{className:`group-room-title`,children:t.title})]}),(0,F.jsx)(`button`,{type:`button`,className:`conversation-archive`,"data-archive-group":t.id,title:`归档群聊`,"aria-label":`归档群聊 ${t.title}`,disabled:Qe.has(t.id),onClick:()=>void Yi(t,`archive`),children:(0,F.jsx)(Tt,{name:`archive`})})]},t.id)}),!f&&n?.failed&&(0,F.jsx)(`button`,{type:`button`,className:`group-rooms-retry`,onClick:qe,children:`重试载入群聊`}),!f&&(s.length?s.map(({conversation:t,depth:n,childCount:r,isLastSibling:i})=>(0,F.jsxs)(`div`,{className:`conversation-row`,style:{"--tree-depth":n},"data-session-root":n===0?t.id:void 0,"data-session-dragging":jt?.conversationId===t.id?`true`:void 0,"data-session-drop":jt?.dropRootId===t.id?jt.dropAfter?`after`:`before`:void 0,onPointerDown:n===0?n=>Ft(n,e.id,t.id,c):void 0,children:[r>0?(0,F.jsxs)(`button`,{type:`button`,className:`conversation-tree-toggle`,"data-tree-toggle":t.id,"aria-expanded":!Br.has(t.id),title:Br.has(t.id)?`展开 ${r} 个子会话`:`折叠 ${r} 个子会话`,"aria-label":Br.has(t.id)?`展开会话 ${t.title} 的 ${r} 个子会话`:`折叠会话 ${t.title} 的 ${r} 个子会话`,onClick:()=>Fc(t.id,!Br.has(t.id)),children:[(0,F.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:Br.has(t.id)?`▸`:`▾`}),(0,F.jsx)(`small`,{children:r})]}):(0,F.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),mc(`conversation`,t.id)?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(bD,{initial:t.title,label:`重命名会话 ${t.title}`,onCommit:e=>hc(`conversation`,t.id,e),onClose:pc}),(0,F.jsx)(`small`,{className:`conversation-time`,children:AE(t.updatedAt,Ir)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{className:`conversation ${!Xi&&L?.id===t.id?`selected`:``}`,"data-conversation":t.id,"aria-current":!Xi&&L?.id===t.id?`true`:void 0,"data-tree-child":n>0?`true`:void 0,"data-tree-last":n>0&&i?`true`:void 0,title:n>0?`${t.title}(由「${o.find(e=>e.id===t.parentConversationId)?.title??`已不存在的会话`}」创建)`:t.title,"aria-label":`打开会话 ${t.title}${BD(t,ol.get(t.id))}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.getBoundingClientRect();ur({conversation:t,x:e.clientX||n.left+24,y:e.clientY||n.top+n.height})},onClick:()=>{t.id===Pt.current&&Date.now()-Nt.current<300||(On(e.id),Ui(t.id),w(e.id),xn(!1))},onDoubleClick:()=>{Wi(t.id)},children:[(0,F.jsx)(`i`,{className:`conversation-mark`,children:(0,F.jsx)(RD,{state:ID(t,PD(t,fn),Fe.current[t.id],y.conversations)})}),(0,F.jsx)(`span`,{"data-conversation-title":t.id,onDoubleClick:e=>{e.stopPropagation(),fc(`conversation`,t.id)},style:{flex:`0 1 auto`,minWidth:`3.5em`},children:t.title}),(0,F.jsx)(`span`,{className:`conversation-title-gap`,"aria-hidden":`true`,style:{marginLeft:`-8px`}}),LD(ID(t,PD(t,fn),Fe.current[t.id],y.conversations),FD(t,y.conversations,Fe.current[t.id])),zD(t,ol.get(t.id)),(0,F.jsx)(`small`,{children:AE(t.updatedAt,Ir)})]}),(0,F.jsx)(`button`,{type:`button`,className:`conversation-fork`,"data-fork-conversation":t.id,"data-fork-state":rl===t.id?`pending`:`idle`,disabled:!!rl,title:`从此会话分叉出一个新会话`,"aria-label":`从会话 ${t.title} 分叉出一个新会话`,onClick:()=>al(t.id),children:`⑂`}),!(t.parentConversationId&&y.conversations.some(e=>e.id===t.parentConversationId))&&(0,F.jsx)(`button`,{className:`conversation-archive`,"data-archive-conversation":t.id,title:`归档整棵会话树`,"aria-label":`归档会话 ${t.title}`,onClick:()=>Pc(t.id),children:`×`})]})]},t.id)):!r.length&&(0,F.jsx)(`div`,{className:`conversation-empty`,children:`暂无会话`})),!f&&d>0&&(0,F.jsxs)(`div`,{className:`archived-group`,"data-archived-count":d,children:[(0,F.jsxs)(`button`,{className:`archived-toggle`,title:p?`展开已归档`:`收起已归档`,"aria-expanded":!p,onClick:()=>Ot(t=>({...t,[e.id]:!p})),children:[(0,F.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:p?`▸`:`▾`}),(0,F.jsxs)(`span`,{className:`archived-label`,children:[`已归档 (`,d,`)`]})]}),!p&&u.map(({conversation:e,depth:t,isLastSibling:n})=>{let r=jE(l,e.id).length-1,i=!!(e.parentConversationId&&y.conversations.some(t=>t.id===e.parentConversationId&&t.archivedAt));return(0,F.jsxs)(`div`,{className:`conversation-archived`,"data-archived-conversation":e.id,"data-archived-at":e.archivedAt,"data-tree-child":t>0?`true`:void 0,"data-tree-last":t>0&&n?`true`:void 0,style:{"--tree-depth":t},children:[(0,F.jsx)(`i`,{className:`conversation-mark`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{"data-archived-title":e.id,children:e.title}),zD(e,ol.get(e.id)),(0,F.jsx)(`small`,{children:ME(e.archivedAt)}),!i&&(0,F.jsx)(`button`,{className:`conversation-restore`,"data-restore-conversation":e.id,title:r?`恢复这个会话和它的 ${r} 个子孙会话`:`恢复为正常会话`,"aria-label":r?`恢复会话 ${e.title} 及其 ${r} 个子孙会话`:`恢复会话 ${e.title}`,onClick:()=>Ic(e.id),children:`↑`})]},e.id)}),!p&&i.map(t=>{let n=v(t.id),r=Qe.has(t.id);return(0,F.jsxs)(`div`,{className:`conversation-row group-room-row group-room-history`,"data-archived-group":t.id,children:[(0,F.jsxs)(`button`,{type:`button`,className:`conversation group-room-button${n?` selected`:``}`,"data-open-archived-group":t.id,"aria-current":n?`true`:void 0,"aria-label":`查看已归档群聊 ${t.title}`,title:t.title,onClick:()=>Ki(e.id,t.id),children:[(0,F.jsx)(Tt,{name:`group`}),(0,F.jsx)(`span`,{className:`group-room-title`,children:t.title})]}),(0,F.jsx)(`button`,{type:`button`,className:`conversation-restore`,"data-restore-group":t.id,title:`恢复群聊`,"aria-label":`恢复群聊 ${t.title}`,disabled:r,onClick:()=>void Yi(t,`restore`),children:`↑`}),(0,F.jsx)(`button`,{type:`button`,className:`conversation-restore`,"data-delete-group":t.id,title:`永久删除群聊`,"aria-label":`永久删除群聊 ${t.title}`,disabled:r,onClick:()=>void Yi(t,`delete`),children:(0,F.jsx)(Tt,{name:`delete`})})]},t.id)})]}),!f&&(()=>{let t=y.warmSessions?.filter(t=>t.workspaceId===e.id)??[];return t.length?(0,F.jsxs)(`details`,{className:`archived-group`,"data-warm-sessions":e.id,children:[(0,F.jsx)(`summary`,{className:`archived-toggle`,children:(0,F.jsxs)(`span`,{className:`archived-label`,children:[`预热会话 (`,t.length,`)`]})}),t.map(e=>(0,F.jsxs)(`div`,{className:`conversation-archived`,"data-warm-session":e.id,children:[(0,F.jsx)(`span`,{title:e.title,children:e.title}),(0,F.jsx)(`button`,{type:`button`,className:`conversation-restore`,"aria-label":`移除预热会话 ${e.title}`,onClick:()=>{window.confirm(`移除预热会话「${e.title}」?`)&&!rs({type:`conversation.warm.delete`,conversationId:e.id})&&Y(`连接断开,未移除预热会话`,`error`)},children:`×`})]},e.id))]}):null})()]},e.id)})}),Kn&&(0,F.jsxs)(`footer`,{className:`workbench-mobile-utilities`,children:[(0,F.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-mobile-workbench-search":!0,"aria-label":`搜索`,title:`搜索`,onClick:()=>Ma(`content`),children:(0,F.jsx)(Tt,{name:`search`})}),sl]})]}),!Kn&&!In.leftClosed&&W!==`sessions`&&(0,F.jsx)(XD,{...ul,side:`left`,activeTab:W,collapsed:!1,onToggle:Pl,pinned:!In.unpinned.includes(W),onArrange:Ea}),(Kn||!In.leftClosed)&&(0,F.jsx)(FO,{side:`left`,width:Bn.sidebar,min:Bn.sidebarMin,max:Bn.sidebarMax,label:`调整左侧栏宽度`,onWidth:Vn}),(0,F.jsx)(`div`,{className:`workbench-main`,children:(0,F.jsxs)(`div`,{className:`workbench-main-panes`,"data-workbench-split":ca,style:{"--split-share":`${aa}%`},children:[(0,F.jsxs)(`section`,{className:`chat`,"data-main-view":Xa,"data-main-view-kind":Xa,children:[kl.length>0&&(0,F.jsx)(`div`,{className:`chat-tab-strip`,"data-chat-tab-strip":`1`,"data-session-count":zi.length,"data-file-count":da.open.length,children:(0,F.jsx)(kp,{tabs:(Io?kl.filter(e=>e.id!==Io.id):kl).map(e=>D.connections.length>1&&e.workspaceId?{...e,label:`${e.label} · ${he(e.workspaceId)}`,title:`${he(e.workspaceId)} · ${e.title??e.label}`}:e),prefix:`workspace-tab`,ariaLabel:`工作区标签页`,activeId:xo,onSelect:wo,onClose:J,onActivate:Po,minWidth:120,maxWidth:320})}),(0,F.jsxs)(`header`,{children:[(0,F.jsx)(`button`,{type:`button`,className:`mobile-drawer-toggle`,"data-mobile-drawer-toggle":`1`,"aria-label":`打开会话列表`,title:`会话列表`,"aria-expanded":bn,onClick:()=>xn(!0),children:`☰`}),(0,F.jsxs)(`div`,{className:`chat-head`,children:[(0,F.jsx)(`h1`,{children:I===`group`?tt?rt??`群聊`:`新建群聊`:L?.title??`准备开始`}),I!==`group`&&Hs.size>0?[...Hs].map(([e,t])=>(0,F.jsx)(`p`,{"data-role":`run-status`,"data-status-key":e,children:`扩展状态:${e?`${e} · `:``}${t}`},e)):null]}),(0,F.jsxs)(`div`,{className:`workbench-history-controls`,role:`group`,"aria-label":`主区导航`,"data-workbench-history":Ao>=0||jo>=0?`available`:`empty`,children:[(0,F.jsx)(`button`,{type:`button`,"data-workbench-history-back":!0,"aria-label":`后退`,className:`workbench-icon-button`,title:Ao<0?`后退`:`后退到 ${P.entries[Ao].title}`,disabled:Ao<0||!!ve,onClick:()=>Mo(-1),children:(0,F.jsx)(Tt,{name:`back`})}),(0,F.jsx)(`button`,{type:`button`,"data-workbench-history-forward":!0,"aria-label":`前进`,className:`workbench-icon-button`,title:jo<0?`前进`:`前进到 ${P.entries[jo].title}`,disabled:jo<0||!!ve,onClick:()=>Mo(1),children:(0,F.jsx)(Tt,{name:`forward`})}),Zi&&(0,F.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-toggle-workbench-split":!0,"aria-pressed":ca,"aria-label":ca?`合并主区`:`拆分主区`,title:ca?`合并主区`:`拆分主区`,onClick:Ro,children:(0,F.jsx)(Tt,{name:`split`})})]}),dn.entry(`workbench-status-button software-update-mobile`),(0,F.jsxs)(`span`,{className:`chat-view chat-view-${Xa}`,"data-main-view-indicator":Xa,"data-main-view-kind":Xa,title:I===`file`?`中间主画面正在显示文件 ${da.active?.path??``}`:Xa===`diff`?`中间主画面正在显示 ${Za??``} 的改动`:`中间主画面正在显示这个会话的消息流`,children:[(0,F.jsx)(`span`,{className:`chat-view-kind`,children:I===`group`?`群聊`:I===`file`?`文件`:Xa===`diff`?`改动`:`会话`}),I===`file`&&da.active&&(0,F.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":da.active.name,children:da.active.name}),Xa===`diff`&&Za&&(0,F.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":Za,children:Za})]}),!Xi&&(0,F.jsx)(`div`,{className:`badge`,"data-workbench-header-status":ni||L?.status===`failed`?`attention`:`routine`,"data-conversation-status":L?.status??`idle`,...ni?{"data-reporting-status":ni}:{},children:ni===`awaiting_decision`?`等上面拍板`:jD(L)?AD[L?.status??`idle`]:ni===`awaiting_subordinates`?`等待下级`:ni===`pending_report`?`待汇报`:AD[L?.status??`idle`]}),(0,F.jsx)(`button`,{type:`button`,className:`mobile-tools-toggle`,"data-mobile-nav":`rail`,onClick:()=>{gn(`rail`),mn(!1)},children:`工具`})]}),k&&(0,F.jsxs)(`div`,{className:`error`,role:`alert`,"data-global-error":!0,children:[(0,F.jsx)(`span`,{title:lt(k),children:ct(k)}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`关闭错误提示`,title:`关闭错误提示`,onClick:()=>A(void 0),children:`×`})]}),!Xi&&L?.error&&(0,F.jsx)(`div`,{className:`error`,"data-role":`conversation-error`,title:lt(L.error),children:ct(L.error)}),L?.warning&&(0,F.jsxs)(`div`,{className:`warning`,role:`status`,"data-role":`conversation-warning`,title:lt(L.warning),children:[(0,F.jsx)(`span`,{children:L.warning}),(0,F.jsx)(`button`,{type:`button`,"data-role":`conversation-warning-continue`,title:`让模型接着把被截断的部分写完`,onClick:()=>ls(L?.id??``),children:`继续写完`})]}),!Xi&&L?.modelNotice&&(0,F.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-model-notice`,children:L.modelNotice}),L?.agentNotice&&(0,F.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-agent-notice`,children:L.agentNotice}),Ws&&(0,F.jsxs)(`div`,{className:`extui-title-note`,children:[`扩展建议标题:`,Ws]}),Wt.length>0&&(0,F.jsx)(`div`,{className:`toasts`,role:`status`,"aria-live":`polite`,"data-toast-count":Wt.length,children:Wt.map(e=>(0,F.jsx)(`div`,{className:`toast toast-${e.kind}`,"data-toast-kind":e.kind,children:e.text},e.key))}),I===`group`?Ko?(0,F.jsx)(Ww,{workspaceId:et,roomId:tt,onEnableNotifications:()=>$o(!0),agents:en?.agents??[],catalog:ws(Kt,Ko),userLabel:zt,archivedAt:nt?.archivedAt,restoring:Qe.has(tt),onRestore:e=>void Yi(e,`restore`),onRoomSeen:Je,onRoomRead:ui,onRoomMissing:Ji,onCreated:qi,onCancelCreate:()=>Re&&J(yw(Re))},Re&&yw(Re)):(0,F.jsx)(`div`,{className:`group-empty`,children:Se?`这个群聊的工作区已不可用。`:`正在加载工作区…`}):I===`file`?Jo(Bo,!0):Ya?Yo(Ya):I===`diff`?Xo(Ba,!1):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`messages`,ref:it,"data-message-scroll-container":L?.id??``,onWheel:e=>{e.deltaY<0&&Me.current[L?.id??``]?.followTail&&(pt.current=!0,di(e.currentTarget,!0))},onScroll:e=>{let t=e.currentTarget;t.dataset.programmaticScroll===`true`?delete t.dataset.programmaticScroll:di(t)},children:[(!L||!Vi)&&(0,F.jsxs)(`div`,{className:`empty`,"data-workspace-welcome":ai?.id,children:[(0,F.jsx)(`div`,{className:`orb`,children:`π`}),(0,F.jsx)(`h2`,{children:ai?.name??`开始一个新会话`}),y.workspaces.length===0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{children:`先创建一个工作区,再开始会话。`}),(0,F.jsx)(`button`,{onClick:()=>Te(!0),children:`+ 新建工作区`})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{children:ai?`暂无活跃会话。你可以创建会话,也可以直接使用资源管理器、Git 和终端。`:y.workspaces.length===1&&ii?`在「${ii.name}」中创建会话,即可向 Super Pi 发送任务。`:`选择工作区即可开始会话,向 Super Pi 发送任务。`}),ai&&(0,F.jsx)(`p`,{className:`workspace-welcome-path`,title:ai.path,children:ai.path}),y.workspaces.length>1&&(0,F.jsxs)(`div`,{className:`empty-workspace-select`,children:[(0,F.jsx)(`label`,{htmlFor:`empty-workspace-choice`,children:`工作区:`}),(0,F.jsxs)(`select`,{id:`empty-workspace-choice`,"aria-label":`选择工作区`,value:ii?.id,onChange:e=>{e.target.value===`__new__`?Te(!0):Gi(e.target.value)},children:[(0,F.jsx)(Be,{workspaces:y.workspaces}),(0,F.jsx)(`option`,{value:`__new__`,children:`+ 新建工作区…`})]})]}),ii&&(0,F.jsxs)(F.Fragment,{children:[!oi&&(0,F.jsx)(WE,{workspaceId:ii.id,value:si,onChange:ci}),(0,F.jsx)(`button`,{"data-workspace-welcome-create":ai?`1`:void 0,disabled:oi||!O,onClick:()=>Nc(ii.id,si),children:oi?`正在创建工作区…`:`新建会话`})]}),(0,F.jsx)(`span`,{className:`empty-secondary-action`,role:`button`,tabIndex:0,onClick:()=>Te(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Te(!0))},children:`+ 新建工作区`})]})]}),L?.messagesLoaded===!1&&(0,F.jsx)(`p`,{role:`status`,"data-conversation-loading":`1`,children:`正在加载会话…`}),Qs.map(e=>{if(e.startsWith(`m:`)){let t=Ys.get(e.slice(2));if(!t)return null;let n=t.id===$s,r=t.role===`user`&&L?.status!==`running`&&L?.status!==`waiting`&&Yc!==t.id,i=r&&n&&!t.id.startsWith(`pending:`),a=r&&!n&&!!t.piEntryId,o=t.content?(0,F.jsx)(Wu,{source:t.content,media:Vr}):(0,F.jsx)(`span`,{className:`typing`,children:`正在思考`});if(t.source===`session-reminder`)return(0,F.jsx)(`article`,{className:`message message-reminder`,"data-transcript-key":e,"data-message-reminder":t.id,children:(0,F.jsxs)(`details`,{children:[(0,F.jsxs)(`summary`,{className:`reminder-header`,children:[(0,F.jsxs)(`span`,{className:`reminder-label`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,F.jsx)(`time`,{dateTime:t.createdAt,children:CE(t.createdAt)})]}),(0,F.jsx)(`div`,{className:`content`,children:o})]})},e);let s=t.toolCalls??[],c=Qc?.id===t.id?Qc.kind:void 0;if(t.role===`user`){let n=t.content||(t.images?.length?`[图片]`:``),r=sD(t.content,t.attachments);return(0,F.jsxs)(`article`,{className:`message user`,"data-transcript-key":e,children:[(0,F.jsxs)(`div`,{className:`message-body`,children:[(0,F.jsxs)(`div`,{className:`bubble`,children:[(0,F.jsxs)(`div`,{className:`meta`,children:[zt,(0,F.jsx)(`time`,{children:CE(t.createdAt)})]}),t.images&&t.images.length>0&&(0,F.jsx)(`div`,{className:`message-images`,"data-message-images":`1`,children:t.images.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`message-image-btn`,"data-message-image-id":e.id,onClick:()=>Cr({url:ke(`/api/upload/${encodeURIComponent(L?.id??``)}/${encodeURIComponent(e.id)}`),name:e.name,bytes:e.bytes}),title:e.name?`查看大图:${e.name}`:`查看大图`,children:(0,F.jsx)(`img`,{src:ke(`/api/upload/${encodeURIComponent(L?.id??``)}/${encodeURIComponent(e.id)}`),alt:e.name||`图片`,className:`message-image-thumb`,loading:`lazy`})},e.id))}),(0,F.jsx)(`div`,{className:`content`,children:o})]}),r.length>0&&(0,F.jsx)(`div`,{className:`message-attachments`,"data-message-attachments":`1`,children:r.map(e=>{let n=`att:${t.id}:${e.kind}:${e.id}`,r=Yn[n]??!1;return(0,F.jsxs)(`div`,{className:`message-attachment`,"data-message-attachment":e.kind,children:[(0,F.jsxs)(`button`,{type:`button`,className:`message-attachment-head`,"data-message-attachment-toggle":e.id,"aria-expanded":r,onClick:()=>Xn(e=>({...e,[n]:!r})),children:[(0,F.jsx)(`span`,{className:`message-attachment-glyph`,"aria-hidden":`true`,children:`▤`}),(0,F.jsx)(`span`,{className:`message-attachment-label`,children:`技能`}),(0,F.jsx)(`span`,{className:`message-attachment-name`,title:e.name,children:e.name}),(0,F.jsx)(`span`,{className:`message-attachment-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`})]}),r&&(0,F.jsx)(`pre`,{className:`message-attachment-body`,"data-message-attachment-body":e.id,children:e.content})]},n)})}),(0,F.jsxs)(`div`,{className:`message-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":c,"aria-label":`复制这条消息:${n}`,onClick:()=>nl(t.id,n),children:c===`copied`?`已复制`:c===`error`?`复制失败`:`复制`}),i&&(0,F.jsx)(`button`,{type:`button`,className:`message-revert`,"data-withdraw-message":t.id,title:`撤回并编辑:删除这条消息并将文字恢复到输入框继续编辑`,onClick:()=>Zc(t.id,!0),children:`撤回`}),a&&(0,F.jsx)(`button`,{type:`button`,className:`message-revert`,"data-revert-message":t.id,title:`回退到这里:删除后续全部内容(Pi 的记录和这里的历史一起清掉,不会新建会话,也不动任何代码文件)`,onClick:()=>Zc(t.id),children:`回退`})]})]}),(0,F.jsx)(`div`,{className:`avatar`,title:zt,children:zt})]},e)}if(t.role===`tool`){let n=/<task id="[^"]+" state="[^"]+"/.test(t.content),r=(()=>{let e=/<summary>([\s\S]*?)<\/summary>/.exec(t.content);return e?e[1].trim():n?`后台回传`:(t.content.split(`
|
|
346
|
+
`).find(e=>e.trim().length>0)??``).trim().slice(0,60)||`任务指令`})(),i=(()=>{let e=/<task id="[^"]+" state="([^"]+)"/.exec(t.content);return e?e[1]:`completed`})(),a=(()=>{let e=/<task_(?:result|error)>\n?([\s\S]*?)\n?<\/(?:task_result|task_error)>/.exec(t.content);return e?e[1]:t.content})(),o=t.backgroundTask,s=o?.output===void 0?a:[o.reason,o.outputTruncated?`日志仅保留最近一段。`:``,o.output||`任务未产生输出。`].filter(Boolean).join(`
|
|
347
|
+
|
|
348
|
+
`),c=(()=>{let e=/<result_file>([\s\S]*?)<\/result_file>/.exec(t.content);return e&&e[1].trim()?e[1].trim():void 0})(),l=(()=>{let e=/<task id="([^"]+)"/.exec(t.content);return e?e[1]:void 0})(),u=!!(l&&Rr.some(e=>e.id===l)),d=`tool:${t.id}`,f=Yn[d]??!1,p=n?`后台回传`:`智能体下发`;return(0,F.jsx)(`article`,{className:`message tool${n?``:` tool-order`}`,"data-transcript-key":e,"data-tool-state":i,"data-tool-kind":n?`delivery`:`order`,children:(0,F.jsxs)(`div`,{className:`message-body`,children:[(0,F.jsxs)(`div`,{className:`bg-result-head`,"data-bg-result-head":t.id,children:[(0,F.jsxs)(`button`,{type:`button`,className:`bg-result-toggle`,"data-bg-result-toggle":t.id,"aria-expanded":f,title:f?`折叠${p}`:`展开${p}`,onClick:()=>Xn(e=>({...e,[d]:!f})),children:[(0,F.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:i===`error`?`✕`:n?`↩`:`↓`}),(0,F.jsx)(`span`,{className:`bg-result-label`,children:o&&(o.status===`cancelled`||o.status===`interrupted`)?MD[o.status]:p}),(0,F.jsx)(`span`,{className:`bg-result-summary`,title:r,children:r}),!f&&(0,F.jsx)(`span`,{className:`bg-result-preview`,"data-bg-result-preview":t.id,title:`展开查看任务输出`,children:o?.reason||eD(s)}),(0,F.jsx)(`span`,{className:`bg-result-chevron`,"aria-hidden":`true`,children:f?`▾`:`▸`})]}),(c||u&&l)&&(0,F.jsxs)(`div`,{className:`bg-result-actions`,"data-bg-result-actions":t.id,children:[c&&(0,F.jsxs)(`button`,{type:`button`,className:`bg-result-action`,"data-result-file-link":c,title:`在主区域打开产物文件:${c}`,onClick:e=>{e.stopPropagation();let t=c.split(/[/\\]/).pop()||c;mo({path:c,name:t,text:!0}).catch(e=>{console.warn(`打开产物文件失败:`,e)})},children:[(0,F.jsx)(`span`,{className:`bg-result-action-glyph`,"aria-hidden":`true`,children:`📄`}),(0,F.jsx)(`span`,{children:`查看产物文件`})]}),u&&l&&(0,F.jsxs)(`button`,{type:`button`,className:`bg-result-action`,"data-result-session-link":l,title:`跳转到子会话:${l}`,onClick:e=>{e.stopPropagation(),Ui(l)},children:[(0,F.jsx)(`span`,{className:`bg-result-action-glyph`,"aria-hidden":`true`,children:`↗`}),(0,F.jsx)(`span`,{children:`跳转到子会话`})]})]})]}),f&&(0,F.jsx)(`div`,{className:`bg-result-body`,"data-bg-result-body":t.id,children:(0,F.jsx)(`pre`,{className:`bg-result-pre`,"data-bg-result-pre":t.id,children:s})})]})},e)}let l=t.thinking?.trim()?t.thinking:``,u=t.thinkingBlocks?.length?t.thinkingBlocks:l?[{at:0,text:l}]:[],d=(e,n)=>{let r=typeof e.at==`number`&&Number.isFinite(e.at)?e.at:n;return Math.max(0,Math.min(r,t.content.length))},p=e=>e.thinkingBlock===void 0?typeof e.thinkingAt!=`number`||!(e.thinkingAt<l.length||t.thinkingActive)?-1:u.findIndex((t,n)=>(e.at??0)>=t.at&&(u[n+1]===void 0||(e.at??0)<u[n+1].at)):e.thinkingBlock??-1,m=e=>s.map((e,t)=>({call:e,index:t})).filter(({call:t})=>p(t)===e),h=[],g=[...u.map((e,t)=>({at:e.at,order:u.slice(0,t).reduce((e,t)=>e+t.text.length,0)*2+1,segment:{blockIndex:t}})),...s.map((e,t)=>({at:d(e,t),order:(e.thinkingAt??0)*2,segment:{call:e,index:t}})).filter(({segment:e})=>`call`in e&&p(e.call)<0)].sort((e,t)=>e.at-t.at||e.order-t.order),_=0;for(let e of g){let n=Math.max(_,Math.min(e.at,t.content.length));n>_&&h.push({text:t.content.slice(_,n)}),h.push(e.segment),_=n}_<t.content.length&&h.push({text:t.content.slice(_)});let v=e=>{let t=Zs.get(e);if(t)return(0,F.jsx)(`div`,{className:`call-anchored-run`,"data-call-anchored-run":t.id,"data-call-anchored-site":e,children:(0,F.jsx)(oD,{run:t,name:Js.get(t.agentId)??``,expanded:!!qn[t.id],onToggle:()=>ec(t.id),onStop:()=>oc(t.id),stopping:f.some(e=>e.key===`stop:${t.id}`)})})},y=e=>e.call.question?(()=>{let n=mD(L?.id??``,t.id,e.index),r=$n[n]??hD(e.call.question);return(0,F.jsx)(`div`,{className:`call-blocks`,"data-call-block-index":e.index,children:(0,F.jsx)(gD,{question:e.call.question,index:e.index,draft:r,onDraftChange:e=>gs(n,e),expanded:`${t.id}:${e.index}`in Zn?!!Zn[`${t.id}:${e.index}`]:!0,onToggle:()=>nc(t.id,e.index),onAnswer:(n,r)=>hs(L?.id??``,t.id,e.index,n,r)})},`c${e.index}`)})():(0,F.jsx)(`div`,{className:`call-blocks`,"data-call-block-index":e.index,children:(0,F.jsx)(rD,{call:e.call,index:e.index,expanded:`${t.id}:${e.index}`in Yn&&!!Yn[`${t.id}:${e.index}`],onToggle:()=>tc(t.id,e.index),backgroundOutput:e.call.backgroundTask&&(0,F.jsx)(nD,{task:e.call.backgroundTask,execOutputs:mt.current,expanded:`${t.id}:${e.index}`in Yn&&!!Yn[`${t.id}:${e.index}`]}),runCard:v(`${t.id}:${e.index}`)})},`c${e.index}`),b=e=>{let n=u[e],r=u.slice(0,e).reduce((e,t)=>e+t.text.length,0),i=0,a=[];for(let{call:t,index:o}of m(e).sort((e,t)=>(e.call.thinkingAt??r)-(t.call.thinkingAt??r)||e.index-t.index)){let e=Math.max(i,Math.min(n.text.length,(t.thinkingAt??r)-r));e>i&&a.push((0,F.jsx)(`div`,{className:`content thinking-text`,children:(0,F.jsx)(Wu,{source:n.text.slice(i,e),media:Vr})},`t${o}`)),a.push(y({call:t,index:o})),i=e}i<n.text.length&&a.push((0,F.jsx)(`div`,{className:`content thinking-text`,children:(0,F.jsx)(Wu,{source:n.text.slice(i),media:Vr})},`tail`));let o=m(e).filter(e=>e.call.status===void 0),s=o.find(e=>e.call.question?.status===`pending`);return(0,F.jsx)(aD,{liveCall:s?`question`:o.at(-1)?.call.label,liveAwaitingReader:!!s,liveExtra:o.length>1?o.length-1:void 0,messageId:`${t.id}:${e}`,nestedCount:m(e).length,preview:n.text.split(`
|
|
349
|
+
`).map(e=>e.trim()).find(Boolean)??``,expanded:rc[`${t.id}:${e}`]===!0,onToggle:()=>ac(`${t.id}:${e}`),children:a},`${t.id}:thinking:${e}`)};return(0,F.jsxs)(`article`,{className:`message assistant`,"data-transcript-key":e,children:[(0,F.jsx)(`div`,{className:`avatar`,children:`π`}),(0,F.jsxs)(`div`,{className:`message-body`,children:[(0,F.jsxs)(`div`,{className:`meta`,children:[t.agentIdentity?.name??`Super Pi`,(0,F.jsx)(`time`,{children:CE(t.createdAt)})]}),h.length===0&&(L?.status===`running`||L?.status===`waiting`)?(0,F.jsx)(`div`,{className:`content`,children:(0,F.jsx)(`span`,{className:`typing`,children:`正在思考`})}):h.map((e,t)=>`blockIndex`in e?b(e.blockIndex):`text`in e?e.text?(0,F.jsx)(`div`,{className:`content`,children:(0,F.jsx)(Wu,{source:e.text,media:Vr})},`t${t}`):null:y(e)),t.content.trim()&&(0,F.jsx)(`div`,{className:`message-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":c,"aria-label":`复制智能体回复`,onClick:()=>void nl(t.id,t.content),children:(0,F.jsx)(`span`,{"aria-live":`polite`,children:c===`copied`?`已复制`:c===`error`?`复制失败`:`复制`})})})]})]},e)}if(e.startsWith(`w:`)){let t=qs.get(e.slice(2));return t?(0,F.jsxs)(`div`,{"data-transcript-key":e,children:[f.some(e=>e.key===`stop:${t.id}`)&&(0,F.jsx)(`span`,{children:`停止中…`}),(0,F.jsx)(Wp,{workflow:t,names:Js,stopping:f.some(e=>e.key===`stop:${t.id}`),onStop:()=>sc(t.id)},e)]},e):null}let t=Xs.get(e.slice(2));return t?(0,F.jsxs)(`div`,{"data-transcript-key":e,children:[f.some(e=>e.key===`stop:${t.id}`)&&(0,F.jsx)(`span`,{children:`停止中…`}),(0,F.jsx)(oD,{run:t,stopping:f.some(e=>e.key===`stop:${t.id}`),name:Js.get(t.agentId)??``,expanded:!!qn[t.id],onToggle:()=>ec(t.id),onStop:()=>oc(t.id)},e)]},e):null})]}),!ai&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(uD,{messages:Hc,pendingInterrupts:f.filter(e=>e.key.startsWith(`interrupt:${L?.id}:`)).map(e=>e.key.slice(`interrupt:${L?.id}:`.length)),running:L?.status===`running`,onSteer:Gc,onInterrupt:Kc,onSend:qc,onCancel:Uc,onCancelMany:Wc,onEdit:Jc}),(0,F.jsxs)(`div`,{className:`stream-tail`,"data-stream-tail":`1`,"data-follow-tail":dt.followTail?`true`:`false`,children:[Un!==null&&(0,F.jsx)(HO,{height:Un,onHeight:Gn}),(0,F.jsx)(`span`,{className:`stream-tail-status`,"data-run-status":L?.status??`idle`,"data-stream-state":O?ps?`stopping`:L&&PD(L,fn)?`question`:L?.status===`waiting`?`waiting`:L?.status===`running`?`streaming`:L?.status===`awaiting_background`||Hc.length?`waiting`:L?.status===`failed`?`failed`:ni===`awaiting_decision`?`awaiting_decision`:ni===`awaiting_subordinates`?`awaiting_subordinates`:ni===`pending_report`?`pending_report`:`ready`:`waiting`,children:O?fs?`正在创建会话…`:ps?`正在停止…`:L&&PD(L,fn)?`等你回答 · Agent 在等你的回复`:L?.messagesLoaded===!1?`正在加载会话…`:L?.status===`waiting`?`等待 LLM 返回`:L?.status===`running`?`Streaming · 正在生成`:L?.status===`awaiting_background`?`等待后台任务 · 任务在后台运行中`:Hc.length?`Waiting · 消息排队中`:L?.status===`failed`?`运行失败`:L?.status===`stopped`?`已停止`:ni===`awaiting_decision`?`等待上级处理例外…`:ni===`awaiting_subordinates`?`等待下级汇报…`:ni===`pending_report`?`已完成,待向父会话汇报`:`就绪`:`连接中 / 等待连接`}),!dt.followTail&&(0,F.jsx)(`button`,{type:`button`,className:`stream-tail-jump`,"data-jump-to-bottom":`1`,onClick:()=>{let e=it.current;e&&(wO(e),e.scrollTop=e.scrollHeight,di(e,!1,!0))},children:`↓ 跳到底部`}),(0,F.jsx)(`span`,{className:`stream-tail-mode`,"data-follow-tail":dt.followTail?`true`:`false`,children:dt.followTail?`贴底`:`自由浏览`})]}),(Ls.length>0||[...Us.values()].some(e=>e.placement===`aboveEditor`))&&(0,F.jsxs)(`div`,{className:`extui`,"data-extui-count":Ls.length,children:[Ls.map(e=>(0,F.jsx)(yD,{request:e.request,pending:f.some(t=>t.key===`answer:${e.conversationId}:${e.request.requestId}`),onAnswer:t=>_s(e.conversationId,e.request.requestId,t)},e.request.requestId)),cc(`aboveEditor`)]}),(0,F.jsxs)(`form`,{onSubmit:Vc,onPaste:Rc,onDragOver:Z,onDragLeave:zc,onDrop:Bc,className:wr?`composer-dropzone-active`:void 0,children:[(0,F.jsxs)(`div`,{className:`composer-input`,"data-composer-input":`1`,children:[(0,F.jsx)(`textarea`,{ref:at,value:mi,onCompositionStart:()=>{Dr.current=!0,Oi(void 0)},onCompositionEnd:e=>{Dr.current=!1,Ni.current=``,Fi(e.currentTarget)},onSelect:e=>{e.currentTarget===document.activeElement&&Fi(e.currentTarget)},"aria-autocomplete":Pi?`list`:void 0,"aria-controls":Pi?`file-mention-menu`:void 0,"aria-activedescendant":Pi?Ai:void 0,onChange:e=>{xi(e.target.value),e.target.value!==mi&&Hi(L?.id??``);let t=e.target.value;if(Ni.current=``,Fi(e.currentTarget))return;let n=e.target.selectionStart??t.length,r=t.slice(0,n),i=r.lastIndexOf(`/`),a=r.slice(i+1),o=i>0?r[i-1]:``;i>=0&&(i===0||/\s/.test(o))&&/^[\w:-]*$/u.test(a)?Ti({visible:!0,query:a,rect:e.currentTarget.getBoundingClientRect()}):Ti({visible:!1,query:``,rect:null})},placeholder:L?Cs?`描述你要完成的任务(支持粘贴/拖放图片)…`:`描述你要完成的任务…`:`先创建会话`,disabled:!L,readOnly:$r,"aria-describedby":$r?`child-session-lock-reason`:void 0,onKeyDown:e=>{if(!(Dr.current||_E(e))&&!(Pi&&ki.current?.handleKey(e))){if(wi.visible){if(e.key===`Escape`){e.preventDefault(),Ti({visible:!1,query:``,rect:null});return}if([`ArrowDown`,`ArrowUp`,`Enter`].includes(e.key)){e.preventDefault();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}}),$r&&(0,F.jsxs)(`div`,{className:`composer-lock`,"data-child-session-lock":`1`,role:`note`,"aria-labelledby":`child-session-lock-title`,children:[(0,F.jsx)(`span`,{className:`composer-lock-glyph`,"data-child-session-lock-glyph":`1`,"aria-hidden":`true`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`30`,height:`30`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,focusable:`false`,children:[(0,F.jsx)(`rect`,{x:`4`,y:`10`,width:`16`,height:`11`,rx:`2.5`}),(0,F.jsx)(`path`,{d:`M8 10V7a4 4 0 0 1 8 0v3`}),(0,F.jsx)(`path`,{d:`M12 14.5v2.5`})]})}),(0,F.jsxs)(`span`,{className:`composer-lock-text`,children:[(0,F.jsx)(`span`,{className:`composer-lock-title`,"data-child-session-lock-title":`1`,id:`child-session-lock-title`,children:`子会话输入框已上锁`}),(0,F.jsx)(`span`,{className:`composer-lock-reason`,"data-child-session-lock-reason":`1`,id:`child-session-lock-reason`,children:`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`})]}),(0,F.jsx)(`button`,{type:`button`,className:`composer-lock-action`,"data-child-session-unlock":`1`,onClick:()=>cs(L?.id??``,!0),children:`临时解锁`})]})]}),Pi&&L?.workspaceId&&(0,F.jsx)(rd,{ref:ki,workspaceId:L.workspaceId,cwd:L.cwd??``,query:Pi.token.query,anchor:Pi.rect,onClose:Ii,onActive:ji,onChoose:e=>{let t=at.current,n=t?.value??mi,r=t?id(n,t.selectionStart,t.selectionEnd):void 0;if(!r||r.start!==Pi.token.start||r.query!==Pi.token.query){Ii();return}let i=ad(n,r,e);Mi.current={scope:Ei,...i},xi(i.text),Oi(void 0)}},Ei),!Pi&&wi.visible&&wi.rect&&(0,F.jsx)(nd,{query:wi.query,anchorRect:wi.rect,workspaceId:L?.workspaceId,promptCatalog:Bt,command:rs,onSelect:e=>{let t=at.current?.selectionStart??mi.length,n=mi.slice(0,t),r=n.lastIndexOf(`/`),i=$u(e,wi.query),a=`${n.slice(0,r)}/${i} ${mi.slice(t)}`;e.id.startsWith(`skill:`)&&L?Si(e.id,a,L.id,L.workspaceId):xi(a),Ti({visible:!1,query:``,rect:null})},onClose:()=>Ti({visible:!1,query:``,rect:null})}),Jr.filter(e=>e.conversationId===L?.id).map(e=>(0,F.jsxs)(`div`,{className:`composer-notice queue-withdrawn-notice`,"data-queue-withdrawn-notice":`1`,role:`status`,children:[(0,F.jsx)(`span`,{className:`composer-notice-mark`,"aria-hidden":`true`,children:`↺`}),(0,F.jsxs)(`div`,{className:`composer-notice-body`,children:[(0,F.jsx)(`p`,{className:`composer-notice-title`,children:e.actor===`agent`?`上级 Agent 已撤回 ${e.withdrawn.length} 条排队消息(不会再被回答)`:`已撤回 ${e.withdrawn.length} 条排队消息(不会再被回答)`}),(0,F.jsx)(`p`,{className:`composer-notice-text`,title:e.withdrawn.map(e=>e.content).join(`
|
|
350
|
+
`),children:e.withdrawn.map(e=>`「${e.content.replace(/\s+/g,` `).trim().slice(0,48)}」`).join(` · `)})]}),(0,F.jsx)(`div`,{className:`composer-notice-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`composer-notice-dismiss`,"data-queue-withdrawn-dismiss":`1`,onClick:()=>R(t=>t.filter(t=>t.id!==e.id)),children:`知道了`})})]},e.id)),vr.filter(e=>e.conversationId===L?.id).map(e=>(0,F.jsxs)(`div`,{className:`composer-notice`,"data-failed-send":e.id,role:`alert`,children:[(0,F.jsx)(`span`,{className:`composer-notice-mark`,"aria-hidden":`true`,children:`!`}),(0,F.jsxs)(`div`,{className:`composer-notice-body`,children:[(0,F.jsx)(`p`,{className:`composer-notice-title`,"data-failed-send-reason":`1`,title:lt(e.reason),children:e.reason?.trim()?ct(e.reason):`服务端没有接受这条消息。`}),(0,F.jsx)(`p`,{className:`composer-notice-text`,title:e.content,children:e.content})]}),(0,F.jsxs)(`div`,{className:`composer-notice-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`composer-notice-action`,"data-failed-send-restore":`1`,disabled:!!(mi||hi.length||gi.length),title:mi||hi.length||gi.length?`输入框里已经有内容,先把这条留在下面`:`放回输入框,改完再发`,onClick:()=>{yi(e.conversationId,t=>({...t,text:e.content,images:e.images,attachments:e.attachments})),yr(t=>t.filter(t=>t.id!==e.id))},children:`放回输入框`}),(0,F.jsx)(`button`,{type:`button`,className:`composer-notice-dismiss`,"data-failed-send-dismiss":`1`,onClick:()=>yr(t=>t.filter(t=>t.id!==e.id)),children:`丢弃`})]})]},e.id)),br.filter(e=>e.conversationId===L?.id).map(e=>(0,F.jsxs)(`div`,{className:`composer-upload-preview${e.failed?` composer-upload-preview-failed`:``}`,"data-upload-preview":e.id,children:[(0,F.jsx)(`img`,{src:e.url,alt:e.name,width:44,height:44,className:`composer-upload-thumb`}),(0,F.jsx)(`span`,{className:`composer-upload-state`,"data-upload-preview-state":e.failed?`failed`:`uploading`,children:e.failed?`上传失败`:`上传中…`}),(0,F.jsx)(`button`,{type:`button`,className:`composer-upload-remove`,"aria-label":`移除 ${e.name}`,title:`移除这张图片`,onClick:()=>{_r.current.add(e.id),URL.revokeObjectURL(e.url),xr(t=>t.filter(t=>t.id!==e.id))},children:`移除`})]},e.id)),(hi.length>0||vi>0||gi.length>0||_i)&&(0,F.jsxs)(`div`,{className:`composer-attachments`,"data-composer-attachments":`1`,children:[hi.map((e,t)=>(0,F.jsxs)(`div`,{className:`composer-attachment-item`,"data-composer-attachment-id":e.id,children:[(0,F.jsx)(`img`,{src:ke(`/api/upload/${encodeURIComponent(L?.id??``)}/${encodeURIComponent(e.id)}`),alt:e.name||`已附图片`,className:`composer-attachment-thumb`,onClick:()=>Cr({url:ke(`/api/upload/${encodeURIComponent(L?.id??``)}/${encodeURIComponent(e.id)}`),name:e.name,bytes:e.bytes}),title:`点击查看大图`}),(0,F.jsx)(`span`,{className:`composer-attachment-name`,title:e.name,children:e.name||`图片`}),(0,F.jsx)(`button`,{type:`button`,className:`composer-attachment-remove`,"data-composer-attachment-remove":e.id,onClick:()=>Li(e=>e.filter((e,n)=>n!==t)),"aria-label":`移除 ${e.name||`图片`}`,title:`移除图片`,children:`✕`})]},e.id)),vi>0&&(0,F.jsx)(`div`,{className:`composer-attachment-item composer-attachment-uploading`,children:(0,F.jsxs)(`span`,{children:[`图片上传中 (`,vi,`)…`]})}),_i&&(0,F.jsx)(`div`,{className:`composer-attachment-item composer-attachment-uploading`,"data-composer-skill-loading":!0,role:`status`,children:`读取技能中…`}),gi.map(e=>(0,F.jsxs)(`div`,{className:`composer-attachment-item composer-attachment-skill`,"data-composer-skill-id":e.id,children:[(0,F.jsx)(`span`,{className:`composer-attachment-glyph`,"aria-hidden":`true`,children:`▤`}),(0,F.jsx)(`span`,{className:`composer-attachment-name`,title:e.name,children:e.name}),(0,F.jsx)(`button`,{type:`button`,className:`composer-attachment-remove`,"data-composer-skill-remove":e.id,onClick:()=>Ci(e.kind,e.id),"aria-label":`移除 ${e.name}`,title:`移除技能`,children:`✕`})]},`${e.kind}:${e.id}`))]}),L&&jD(L)&&(0,F.jsx)(lD,{mode:Hr,onChange:Gr}),(0,F.jsxs)(`div`,{className:`composer`,children:[(0,F.jsxs)(`div`,{className:`session-picker`,id:`composer-session-options`,"data-session-picker":`1`,"data-mobile-expanded":_n,children:[(0,F.jsx)(xD,{kind:`agent`,label:Ms?.name??`跟随 Pi 默认`,value:L?.agentId??SD,options:Ns,disabled:!en||en.source===`unavailable`||ms,note:XE(en),onChoose:Is}),(0,F.jsx)(xD,{kind:`model`,label:vs?.label??(Kt?`Pi 默认`:`读取中…`),value:vs?`${vs.provider}/${vs.modelId}`:void 0,detail:Fs?`来自 ${Ms?.name}`:vs&&Kt?.source===`pi`&&!L?.model?`Pi 默认模型`:vs?`${vs.provider}/${vs.modelId}`:void 0,options:Os,providerOptions:[...new Set(Ds.map(e=>e.provider))],disabled:!xs||ms,note:YE(`模型`,Kt,Ts),onChoose:As}),(0,F.jsx)(xD,{kind:`thinking`,label:bs??(Kt?Kt.levels.length?`Pi 默认`:`无可用等级`:`读取中…`),value:ys,options:ks,disabled:!xs||ms,note:YE(`思考等级`,Kt),onChoose:js})]}),(0,F.jsx)(`button`,{type:`button`,className:`mobile-composer-options`,"aria-controls":`composer-session-options`,"aria-expanded":_n,onClick:()=>vn(e=>!e),children:`会话选项`}),(0,F.jsxs)(`div`,{className:`composer-hints`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`composer-attach-btn`,"data-composer-attach":`1`,onClick:()=>Er.current?.click(),disabled:!L||!Cs||vi>0,title:L?Cs?`添加图片(支持剪贴板粘贴与拖拽)`:`当前模型不支持图片输入`:`请先创建或选择会话`,"aria-label":`添加图片`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`+`}),(0,F.jsx)(`span`,{className:`composer-attach-label`,children:` 图片`})]}),(0,F.jsx)(`input`,{ref:Er,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,style:{display:`none`},onChange:e=>{e.target.files?.length&&(Lc(Array.from(e.target.files)),e.target.value=``)}}),Ts&&(0,F.jsx)(`span`,{"data-image-session-hint":`1`,title:`此会话历史已包含图片,仅显示支持图文的模型`,children:`图文会话`}),(0,F.jsx)(`span`,{children:`Enter 发送 · Shift + Enter 换行`})]}),(0,F.jsxs)(`div`,{className:`composer-actions`,children:[Zr&&!$r&&(0,F.jsx)(`button`,{type:`button`,className:`composer-relock`,"data-child-session-relock":`1`,title:`重新给这个子会话上锁`,onClick:()=>cs(L?.id??``,!1),children:`重新上锁`}),L&&(jD(L)||L.status===`awaiting_background`)&&(0,F.jsx)(`button`,{type:`button`,className:`stop`,"data-stop-run":L.id,disabled:f.some(e=>e.key===`stop:${L.id}`)||ar.has(L.id),onClick:()=>as({type:`run.stop`,conversationId:L.id},`stop:${L.id}`,e=>e),children:f.some(e=>e.key===`stop:${L.id}`)||ar.has(L.id)?`停止中…`:`停止`}),(0,F.jsx)(`button`,{className:`send ${jD(L)?Hr===`steer`?`send-steer`:`send-queued`:``}`,"data-send-mode":jD(L)?Hr===`steer`?`steer`:`queued`:`direct`,disabled:!mi.trim()&&hi.length===0||!L||vi>0||_i||!!Yc||ms||$r,title:L?$r?`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`:fs?`正在创建会话,请稍候再发送`:L.messagesLoaded===!1?`正在加载会话,请稍候再发送`:Yc?`正在撤回:Pi 的历史还没截断完成,撤回结束后即可发送`:!mi.trim()&&hi.length===0?`请输入消息或添加图片后发送`:vi>0?`图片上传中…`:_i?`技能正在读取中,请稍候…`:jD(L)?Hr===`steer`?`当前工具完成后在下一回合边界插队回答(不会强行中止正在执行的工具)`:`这一轮结束后发送(发送后可在上面的排队区取消或插队)`:void 0:`请先创建或选择会话`,children:Yc?`撤回中…`:jD(L)?Hr===`steer`?`打断发送 ↑`:`排队发送 ↑`:`发送 ↑`})]})]})]}),cc(`belowEditor`)]})]})]}),ca&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Mp,{share:aa,onShare:oa}),(0,F.jsx)(Np,{tabs:Fo,selected:Io?.id,onSelect:Lo,onPin:Po,onCloseTab:J,onClose:Ro,children:Zo()})]})]})}),(Kn||!Fl)&&(0,F.jsx)(FO,{side:`right`,width:pn&&Kn?30:Bn.rail,min:Bn.railMin,max:Bn.railMax,label:`调整右侧栏宽度`,onWidth:Hn}),ja&&(0,F.jsx)(Tp,{workspaceId:Zi,cwd:ea,connected:O,initialQuery:K.initialQuery,onOpen:e=>mo(e,void 0,!1,!0),onClose:Na,onMode:Ma},ka),K?.mode===`content`&&(0,F.jsx)(wp,{workspaceId:Zi,cwd:ea,directory:K.directory,initialQuery:K.initialQuery,onOpen:(e,t,n)=>mo(e,t,!1,!0,!1,n),onClose:Na,onMode:Ma},JSON.stringify([ka,K.directory])),K?.mode===`session`&&(0,F.jsx)(kd,{workspaceId:Zi,initialQuery:K.initialQuery,onOpen:La,onClose:Na,onMode:Ma},ka),(0,F.jsx)(tO,{}),bn&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`mobile-drawer-backdrop`,"data-mobile-drawer-backdrop":`1`,"aria-label":`关闭会话列表`,onClick:()=>xn(!1)}),(0,F.jsx)(`button`,{type:`button`,className:`mobile-drawer-close`,"data-mobile-drawer-close":`1`,"aria-label":`关闭会话列表`,title:`关闭`,onClick:()=>xn(!1),children:`×`})]}),hn===`rail`&&(0,F.jsx)(`button`,{type:`button`,className:`mobile-rail-back`,"data-mobile-nav":`chat`,onClick:yn,children:`‹ 返回对话`}),sr&&(0,F.jsx)(NE,{workspace:sr.workspace,x:sr.x,y:sr.y,notify:Y,onClose:()=>cr(void 0)}),lr&&(0,F.jsx)(PE,{conversation:lr.conversation,x:lr.x,y:lr.y,notify:Y,onRename:()=>void gc(lr.conversation.id),onClose:()=>ur(void 0),sendCommand:rs,orchestrated:lr.conversation.origin===`orchestrator`,childCount:Rr.filter(e=>e.parentConversationId===lr.conversation.id).length}),we&&(0,F.jsx)(KE,{onClose:()=>Te(!1),onCreate:lc}),Ee&&(()=>{let e=y.workspaces.find(e=>e.id===Ee.workspaceId);return e?(0,F.jsx)(GE,{workspace:e,onClose:()=>{De(void 0),Oe.current?.focus()},onCreate:e=>{Nc(Ee.workspaceId,e),De(void 0),Oe.current?.focus()}}):null})(),Tc&&(0,F.jsx)(Ym,{initialCategory:Dc,workspaceId:C,theme:Cc,onChooseTheme:e=>wc(e),onClose:()=>{Ec(!1),pe()},agentCatalog:sn,subagentCatalog:ln,modelFilterRules:D.settingsSnapshot?.modelFilterRules??[],pendingSettings:f.some(e=>e.key===`model-rules`||e.key===`agent-directories`||e.key===`default-model`),onSetModelRules:e=>ss({type:`model.rules.set`,rules:e},`model-rules`,t=>({...t,modelFilterRules:e})),defaultModel:D.settingsSnapshot?.defaultModel,modelCatalog:Jt,onSetDefaultModel:e=>ss({type:`settings.defaultModel`,model:e?{provider:e.provider,modelId:e.modelId}:null},`default-model`,t=>{let n={...t};return e?n.defaultModel=e:delete n.defaultModel,n}),providers:Xt,providerApis:Qt,onSetProvider:e=>{os({type:`providers.set`,provider:e})},onRemoveProvider:e=>{os({type:`providers.remove`,providerId:e})},onRepairProviders:()=>{os({type:`providers.repair`}),Y(`正在清理 Pi 不接受的空字段并重新读取模型清单`,`info`)},onToggleProvider:(e,t)=>{os(t?{type:`providers.enable`,providerId:e}:{type:`providers.disable`,providerId:e}),Y(t?`已启用供应商「${e}」,它的模型重新出现在选择器里`:`已停用供应商「${e}」:配置已从 Pi 的文件里拿掉并保存在这里,模型不再出现在选择器里`,`info`)},onRemoveProviderModel:(e,t)=>{os({type:`providers.removeModel`,providerId:e,modelId:t})},customAgentDirs:D.settingsSnapshot?.customAgentDirs??[],onSetCustomAgentDirs:e=>ss({type:`agents.setCustomDirs`,dirs:e},`agent-directories`,t=>({...t,customAgentDirs:e})),onRescanAgents:()=>os({type:`agents.rescan`}),userNickname:It,onSetUserNickname:Rt,terminalShell:D.settingsSnapshot?.terminalShell,onSetTerminalShell:e=>{os({type:`terminal.shell.set`,command:e})},onCheckBrowserNotifications:o,browserNotificationsEnabled:n,browserNotificationPermission:i,onSetBrowserNotifications:$o}),kc&&(0,F.jsx)(Kp,{onClose:()=>Ac(!1)}),Sc&&(0,F.jsx)(CD,{workspace:Sc,onRemove:()=>_c(Sc),catalog:ws(Kt,Sc),agents:en,onClose:()=>yc(void 0),onRename:()=>{let e=Sc.id;yc(void 0),fc(`workspace`,e)},onSave:(e,t,n)=>jc(Sc.id,e,t,n)}),Sr&&(0,F.jsx)(aO,{image:Sr,onClose:()=>Cr(void 0)}),Kn&&!pn&&(0,F.jsx)(`div`,{className:`rail-backdrop`,role:`presentation`,"aria-hidden":`true`,onClick:()=>mn(!0)}),Kn?(0,F.jsx)(XD,{...ul,activeTab:B,collapsed:pn,onToggle:()=>mn(e=>!e)}):(0,F.jsxs)(F.Fragment,{children:[Sa&&(0,F.jsx)(XD,{...ul,side:`right`,activeTab:Sa,collapsed:Ca,onToggle:Nl,pinned:!In.unpinned.includes(Sa),onArrange:Ea}),(0,F.jsx)(Et,{side:`right`,views:U,unpinned:In.unpinned,previous:Sa,active:Ca?void 0:Sa,onSelect:e=>Ta(e,!0),onArrange:Ea,onReorder:Da,onReset:Oa})]}),dn.panel,I!==`group`&&zs&&L&&(()=>{let e=zs.key,t=zs.value,n=$n[e]??hD(t);return(0,F.jsx)(vD,{question:{key:e,messageId:zs.messageId,index:zs.index,value:t},pendingCount:Rs.length,minimized:tr===e,floatingRight:Kn?`12px`:pn?`24px`:`calc(var(--rail-width, 320px) + 24px)`,onMinimize:()=>nr(e),onExpand:()=>nr(null),onLocate:Bs,draft:n,onDraftChange:t=>gs(e,t),onAnswer:(e,t)=>hs(L.id,zs.messageId,zs.index,e,t)})})(),(0,F.jsxs)(`footer`,{className:`workbench-status`,"data-workbench-status":`1`,"aria-label":`工作台状态`,children:[(0,F.jsxs)(`div`,{className:`workbench-status-group`,children:[(0,F.jsxs)(`details`,{className:`workbench-menu workbench-connection-details`,children:[(0,F.jsxs)(`summary`,{className:`workbench-connection`,"data-workbench-connection":O?`online`:`offline`,title:`连接详情`,children:[(0,F.jsx)(`i`,{"aria-hidden":`true`}),` `,(0,F.jsx)(`span`,{children:O?`已连接`:`正在连接`}),(0,F.jsx)(`code`,{children:me(D.activeServer)})]}),(0,F.jsxs)(`div`,{className:`workbench-menu-items workbench-server-details`,children:[(0,F.jsxs)(`span`,{children:[`服务器 `,(0,F.jsx)(`code`,{children:me(D.activeServer)})]}),(0,F.jsxs)(`span`,{children:[`连接地址 `,(0,F.jsx)(`code`,{children:D.connections.find(e=>e.id===D.activeServer)?.url})]}),Ko&&(0,F.jsxs)(`span`,{title:Ko.path,children:[`工作目录 `,(0,F.jsx)(`code`,{children:[Ko.path,ea].filter(Boolean).join(`/`)})]}),an?.runningVersion&&(0,F.jsxs)(`span`,{children:[`运行版本 `,(0,F.jsx)(`code`,{children:an.runningVersion})]})]})]}),Al&&O&&(0,F.jsxs)(`button`,{type:`button`,className:`workbench-status-button workbench-branch`,"data-workbench-branch":Al,title:`Git · ${ea||Ko?.name||``}`,onClick:()=>Ta(`git`),children:[(0,F.jsx)(Tt,{name:`git`}),(0,F.jsx)(`code`,{children:Al}),Ml&&(0,F.jsx)(`code`,{children:Ml}),!!jl&&(0,F.jsxs)(`span`,{className:`workbench-changes`,"data-workbench-changes":jl,children:[jl,` 个改动`]})]}),Ko&&(0,F.jsxs)(`span`,{className:`workbench-status-scope`,title:[Ko.path,ea].filter(Boolean).join(`/`),children:[(0,F.jsx)(Tt,{name:`files`}),(0,F.jsxs)(`span`,{children:[Ko.name,ea?` / `+ea:``]})]})]}),(0,F.jsxs)(`div`,{className:`workbench-status-group workbench-status-context`,children:[I===`session`&&L&&vs&&(0,F.jsx)(`span`,{title:vs.provider+`/`+vs.modelId,children:Ss?.label??vs.modelId}),I===`file`&&Bo&&(Go?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`workbench-editor-cursor`,"data-workbench-editor-position":`1`,children:[`第 `,Go.line,` 行,第 `,Go.column,` 列`]}),(0,F.jsx)(`span`,{"data-file-highlight-status":Go.highlight,children:Go.language})]}):(0,F.jsx)(`span`,{title:Bo.path,children:Bo.name})),Xa===`diff`&&Za&&(0,F.jsx)(`span`,{title:Za,children:Za}),dn.entry(`workbench-status-button software-update-desktop`),(0,F.jsxs)(`span`,{className:`workbench-version`,"data-super-pi-version":(dn.status??an)?.runningVersion??``,title:`Super Pi 运行版本`,children:[`v`,(dn.status??an)?.runningVersion??`…`]})]})]})]})}Mm(jm()),(0,d.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(u.StrictMode,{children:(0,F.jsx)(KO,{})}));export{nr as a,Ie as c,$n as i,r as l,Pf as n,lt as o,sf as r,ct as s,jf as t};
|