dsh-more-details 0.3.16 → 0.3.17

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 CHANGED
@@ -28,7 +28,7 @@ Click **Add to DSH** to attach a reference to your main draft. Send it with a qu
28
28
  ## Features
29
29
 
30
30
  - **Explore a selection.** More details automatically sends the selected text and source context to the real DeepSeek website. Customize the instruction in **Prompt**.
31
- - **Start or continue a chat.** Open a blank chat with **New Chat**, or use **History** to reopen a discussion and follow up.
31
+ - **Start or continue a chat.** Use sidebar **New Chat** for a blank discussion and **Continue chat** to restore the collapsed panel without resending. Use **History** to reopen earlier discussions.
32
32
  - **Bring the discussion back.** **Add to DSH** places a reference card in your current main draft. Preview it, send it with your question, or click it to reopen the web chat.
33
33
  - **Read saved text on demand.** The main model can retrieve the captured discussion through `read_webchat_reference`, including after a restart.
34
34
  - **Keep your setup.** Restore a valid web login, website language, and panel size. Drag to resize, expand, or collapse; plugin controls follow DSH’s English or Chinese setting.
@@ -38,7 +38,7 @@ Click **Add to DSH** to attach a reference to your main draft. Send it with a qu
38
38
 
39
39
  Supported versions: **DSH Desktop 0.2.0-rc.2, 0.2.1-alpha.4, 0.2.1-rc.1, 0.2.1-rc.2, and 0.2.1-rc.3**. Installation checks and historical Desktop acceptance are separate; see the [version-specific results](docs/open-source/validation.md). Windows and Linux have not completed maintainer feature acceptance. **Web Chat requires Desktop.** In browser-hosted DSH, New Chat is hidden and More details explains why it is disabled; Add to chat, API side chat, and saved-reference preview/reading remain available.
40
40
 
41
- 1. In **Plugins → Add plugin**, install **`dsh-more-details@0.3.16`** from npm, or use [Discover](docs/guide.md#discover). [Git and release archives](docs/guide.md#git-and-release-archives) remain available. Disable the original AHGGG plugin if installed to avoid duplicate selection menus.
41
+ 1. In **Plugins → Add plugin**, install **`dsh-more-details@0.3.17`** from npm, or use [Discover](docs/guide.md#discover). [Git and release archives](docs/guide.md#git-and-release-archives) remain available. Disable the original AHGGG plugin if installed to avoid duplicate selection menus.
42
42
  2. Fully quit and reopen DSH. Click **New Chat** and sign in inside the panel. This website login is separate from your DSH model configuration.
43
43
  3. Select text in a completed message and click **More details**. Use **Prompt** to save your preferred instruction; the bundled default is in Chinese.
44
44
  4. Continue in the panel, reopen a discussion from **History**, or choose **New** for a fresh chat.
package/README.zh.md CHANGED
@@ -28,7 +28,7 @@
28
28
  ## 功能
29
29
 
30
30
  - **围绕选文展开讨论**:「更多详情」将选文和来源背景自动发送到 DeepSeek 官网;在 **提示词** 中修改默认指令。
31
- - **新建或接续聊天**:侧栏 **新建 Chat** 打开空白聊天,**历史** 可重开已有讨论并继续追问。
31
+ - **新建或接续聊天**:侧栏 **新建 Chat** 打开空白聊天,**继续聊天** 恢复收起的小窗且不重复发送,**历史** 可重开此前的讨论。
32
32
  - **把讨论带回主会话**:**添加到 DSH** 将引用卡放入当前主草稿;支持预览、随问题发送,以及点击重开原网页聊天。
33
33
  - **按需读取正文**:主模型通过 `read_webchat_reference` 读取已保存的讨论正文,重启后仍可使用。
34
34
  - **保留使用习惯**:恢复有效网页登录态、官网语言和小窗尺寸。支持拖拽缩放、放大与收起;插件控件跟随 DSH 中英文设置。
@@ -38,7 +38,7 @@
38
38
 
39
39
  支持版本:**DSH Desktop 0.2.0-rc.2、0.2.1-alpha.4、0.2.1-rc.1、0.2.1-rc.2 和 0.2.1-rc.3**。安装检查与历史桌面验收分开记录,逐版本范围见[验收记录](docs/open-source/validation.md)。Windows、Linux 尚未完成维护者功能验收。**网页讨论需要 Desktop。** 普通浏览器中的 DSH 会隐藏「新建 Chat」,将「更多详情」置灰并说明原因;添加到聊天、API 侧聊和已有引用的预览、读取仍可使用。
40
40
 
41
- 1. 在 **插件 → 添加插件** 中通过 npm 安装 **`dsh-more-details@0.3.16`**,也可使用[「发现」市场](docs/guide.zh.md#发现市场)。[Git 和 Release 安装包](docs/guide.zh.md#git-与-release-安装包)继续保留。若已安装原 AHGGG 插件,请停用它,避免重复划词菜单。
41
+ 1. 在 **插件 → 添加插件** 中通过 npm 安装 **`dsh-more-details@0.3.17`**,也可使用[「发现」市场](docs/guide.zh.md#发现市场)。[Git 和 Release 安装包](docs/guide.zh.md#git-与-release-安装包)继续保留。若已安装原 AHGGG 插件,请停用它,避免重复划词菜单。
42
42
  2. 完整退出并重开 DSH。点击 **新建 Chat**,在小窗内登录官网。网页登录与 DSH 模型账号配置分开。
43
43
  3. 在已完成的消息中划词,点击 **更多详情**。可在 **提示词** 中保存自定义指令,内置默认值为「告诉我更多相关信息」。
44
44
  4. 在小窗继续追问,用 **历史** 重开讨论,或用 **新建** 打开空白聊天。
package/docs/guide.md CHANGED
@@ -4,12 +4,13 @@
4
4
 
5
5
  ## Supported environments
6
6
 
7
- Current version: **0.3.16**, declaring **DSH 0.2.0-rc.2, 0.2.1-alpha.4, 0.2.1-rc.1, 0.2.1-rc.2, and 0.2.1-rc.3**. Web Chat needs the official Desktop browser guest. In an ordinary browser, the plugin hides New Chat and disables More details with an explanation. Add to chat, API side chat, saved-reference previews, and on-demand snapshot reading remain available; reopening the website inside the plugin is Desktop-only. Windows/Linux full feature acceptance is still unverified.
7
+ Current version: **0.3.17**, declaring **DSH 0.2.0-rc.2, 0.2.1-alpha.4, 0.2.1-rc.1, 0.2.1-rc.2, and 0.2.1-rc.3**. Web Chat needs the official Desktop browser guest. In an ordinary browser, the plugin hides New Chat and disables More details with an explanation. Add to chat, API side chat, saved-reference previews, and on-demand snapshot reading remain available; reopening the website inside the plugin is Desktop-only. Windows/Linux full feature acceptance is still unverified.
8
8
 
9
9
  Validation is recorded by release rather than implied for every update:
10
10
 
11
11
  | Plugin release | Verified scope |
12
12
  | --- | --- |
13
+ | 0.3.17 | 349 tests and isolated macOS rc.3 acceptance passed: sidebar New Chat / Continue chat, an unobstructed main send control, restoration of the same webpage and unsent draft without duplicate sending, reference capture, and history reopening. Installation preserved all 110 protected files. Automatic selection sending, main-model reference-tool reading, and full restart recovery were not rerun. |
13
14
  | 0.3.16 | Five-version installation/imports, 345 tests, and isolated rc.3 Desktop automatic sending, reference reading, restart recovery, and follow-up passed. Real npm migration from tgz and Git preserved data; removing the old archive did not block installation. The npm-installed rc.3 Desktop read the saved snapshot before opening the website, then reopened the original discussion without signing in. |
14
15
  | 0.3.14 | Compatibility declarations and development dependencies updated for DSH 0.2.1-rc.2 while retaining both older versions. All three dependency environments passed typechecking and 340 tests, with clean-profile installation and imports. The independent 0.2.1-rc.2 Desktop passed automatic sending, reference reading, and full restart/history/follow-up recovery. Older hosts passed final-package cold startup, historical-reference reading, and signed-in reopening; their complete workflows were not repeated. |
15
16
  | 0.3.13 | 340 tests against each supported DSH version; native-market Git installation, Host loading, and process-restart checks in a fresh isolated alpha.4 profile. This distribution update adds the publisher-maintained index, complete CSS assets, and non-JIT Zod Mini validation without changing saved data or the wire contract. It did not repeat Desktop interaction or model-send acceptance. |
@@ -22,15 +23,15 @@ See [version compatibility](open-source/compatibility.md), [validation records](
22
23
 
23
24
  ### npm (recommended)
24
25
 
25
- In **Plugins → Add plugin**, enter `dsh-more-details@0.3.16`. DSH installs the precompiled package from npm and checks host compatibility. Use the same profile when upgrading; changing the package source does not require removing plugin data.
26
+ In **Plugins → Add plugin**, enter `dsh-more-details@0.3.17`. DSH installs the precompiled package from npm and checks host compatibility. Use the same profile when upgrading; changing the package source does not require removing plugin data.
26
27
 
27
28
  For the Desktop CLI, use the **CLI bundled with your Desktop installation**. Fully quit the test/target DSH instance before a CLI installation, then reopen it. This macOS example assumes `~/Applications`; adjust the executable path for your installation:
28
29
 
29
30
  ```sh
30
- "$HOME/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add dsh-more-details@0.3.16
31
+ "$HOME/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add dsh-more-details@0.3.17
31
32
  ```
32
33
 
33
- For browser-hosted DSH, use its own CLI and profile, for example `dsh plugin --profile web add dsh-more-details@0.3.16`. Do not use a separately installed CLI to manage the Desktop profile, or run bare `pnpm add` in an arbitrary directory. Future upgrades use the same command with the desired compatible version. If a registry mirror has not synchronized a newly released version, add `--registry=https://registry.npmjs.org` to that installation command; this does not change global registry settings.
34
+ For browser-hosted DSH, use its own CLI and profile, for example `dsh plugin --profile web add dsh-more-details@0.3.17`. Do not use a separately installed CLI to manage the Desktop profile, or run bare `pnpm add` in an arbitrary directory. Future upgrades use the same command with the desired compatible version. If a registry mirror has not synchronized a newly released version, add `--registry=https://registry.npmjs.org` to that installation command; this does not change global registry settings.
34
35
 
35
36
  ### Discover
36
37
 
@@ -45,14 +46,14 @@ New versions use an exact npm version; older entries retain their pinned Git com
45
46
  ### Git and release archives
46
47
 
47
48
  - **Git:** use the full public commit associated with the desired release: `git+https://github.com/RZRZ-Q/dsh-more-details.git#<full-commit>`. Enter it in **Add plugin** or pass it to the bundled `dsh plugin --profile desktop add` command. Built runtime files are committed.
48
- - **Archive:** download `dsh-more-details-0.3.16.tgz` from the [release](https://github.com/RZRZ-Q/dsh-more-details/releases/tag/v0.3.16) and install via **Add plugin**. The source archive and `SHA256SUMS` are provided separately.
49
+ - **Archive:** download `dsh-more-details-0.3.17.tgz` from the [release](https://github.com/RZRZ-Q/dsh-more-details/releases/tag/v0.3.17) and install via **Add plugin**. The source archive and `SHA256SUMS` are provided separately.
49
50
 
50
51
  A local archive can remain a `file:` dependency of the profile. Keep the archive at its recorded path while that dependency exists; moving or deleting it can block other package operations in the same profile. Prefer npm for installations that should not depend on local archive storage.
51
52
 
52
53
  ### Migrate an existing tgz or Git installation
53
54
 
54
55
  1. Back up the target profile and fully quit that DSH instance before CLI changes. Keep the same profile, plugin name, credentials, attachments, and browser data.
55
- 2. Install `dsh-more-details@0.3.16` through the matching DSH installer/CLI. This replaces the package source; do not uninstall the plugin and delete its data first.
56
+ 2. Install `dsh-more-details@0.3.17` through the matching DSH installer/CLI. This replaces the package source; do not uninstall the plugin and delete its data first.
56
57
  3. Reopen DSH and check the version, custom prompt, history, existing references, and remembered website sign-in. Website sessions can expire independently.
57
58
  4. Remove the old archive only after the profile's dependency for this plugin no longer points to it and another plugin/package operation succeeds.
58
59
 
@@ -66,6 +67,7 @@ After installation, disable a duplicate AHGGG plugin and fully quit/reopen DSH s
66
67
  2. Select text in a completed main-conversation message, click **More details**, and wait for the web reply.
67
68
  3. Edit the instruction through **Prompt** in the panel or **Settings → General settings → More details**. The bundled default prompt is in Chinese, meaning “Tell me more about this.” You can save your own instruction or restore the default. Upgrades preserve saved custom values; switching the interface language does not translate prompt text.
68
69
  4. Use **New** for a blank web chat or **History** to reopen a discussion. Reopening history does not resend the previous question.
70
+ 5. Collapse the panel to return to the main composer. **Continue chat** appears in the left sidebar and restores the same webpage without creating a chat or sending a message. **New Chat** remains a separate action. The collapsed panel no longer leaves a button over the bottom-right send control; a compact sidebar shows the actions as icons with tooltips.
69
71
 
70
72
  Further selections from the same DSH conversation can continue its active web discussion. Switching the source conversation, starting a blank chat, or manually reopening history makes the next **More details** request start a separate discussion.
71
73
 
package/docs/guide.zh.md CHANGED
@@ -4,12 +4,13 @@
4
4
 
5
5
  ## 支持环境
6
6
 
7
- 当前版本 **0.3.16**,支持 **DSH 0.2.0-rc.2、0.2.1-alpha.4、0.2.1-rc.1、0.2.1-rc.2 和 0.2.1-rc.3**。网页讨论需要官方 Desktop browser guest。普通浏览器中隐藏「新建 Chat」,「更多详情」置灰并说明原因;添加到聊天、API 侧聊、已有引用预览和按需读取仍保留,插件内重开官网仅 Desktop 可用。Windows/Linux 全功能尚未完成验收。
7
+ 当前版本 **0.3.17**,支持 **DSH 0.2.0-rc.2、0.2.1-alpha.4、0.2.1-rc.1、0.2.1-rc.2 和 0.2.1-rc.3**。网页讨论需要官方 Desktop browser guest。普通浏览器中隐藏「新建 Chat」,「更多详情」置灰并说明原因;添加到聊天、API 侧聊、已有引用预览和按需读取仍保留,插件内重开官网仅 Desktop 可用。Windows/Linux 全功能尚未完成验收。
8
8
 
9
9
  各版本的验证范围分别记录,不将旧版验收结果视为每次更新都重新执行:
10
10
 
11
11
  | 插件版本 | 已验证范围 |
12
12
  | --- | --- |
13
+ | 0.3.17 | 349 项回归及独立 macOS rc.3 实机验收通过:侧栏新建 / 继续聊天、主发送键无遮挡、恢复同一网页和未发送草稿且不重复发送、引用采集与历史重开。安装阶段 110 个受保护文件全部保留。本轮未重跑划词自动发送、主模型引用工具读取或完整重启恢复。 |
13
14
  | 0.3.16 | 五版安装导入、345 项回归及独立 rc.3 桌面的自动发送、引用回读、重启恢复和续聊通过。真实 tgz/Git → npm 迁移保留数据,移走旧归档后安装操作仍成功;npm 安装后的 rc.3 冷启动先实际读取本地快照,再免登录重开原讨论。 |
14
15
  | 0.3.14 | 更新 DSH 0.2.1-rc.2 的兼容声明和开发依赖,同时保留两版旧宿主支持。三套依赖均通过 typecheck 和 340 项测试,三版全新 profile 的安装与入口导入通过。独立新版 Desktop 通过自动发送、引用回读、完整重启及历史续聊;旧版本轮补验最终包冷启动、旧引用回读与免登录重开,未重复全部流程。 |
15
16
  | 0.3.13 | 在两套支持的 DSH 依赖下各通过 340 项测试,并在全新隔离的 alpha.4 profile 通过原生市场 Git 安装、Host 加载和进程冷重开检查。本次分发更新新增作者索引、补齐 CSS 资产并改用非 JIT 的 Zod Mini 校验,不修改保存数据或传输契约;未重跑桌面交互和模型发送验收。 |
@@ -22,15 +23,15 @@
22
23
 
23
24
  ### npm(推荐)
24
25
 
25
- 在 **插件 → 添加插件** 中输入 `dsh-more-details@0.3.16`。DSH 从 npm 安装预编译包并检查宿主兼容性。升级时继续使用原 profile,更换包来源不需要删除插件数据。
26
+ 在 **插件 → 添加插件** 中输入 `dsh-more-details@0.3.17`。DSH 从 npm 安装预编译包并检查宿主兼容性。升级时继续使用原 profile,更换包来源不需要删除插件数据。
26
27
 
27
28
  Desktop CLI 必须使用**对应桌面安装自带的 CLI**。通过 CLI 安装前完整退出目标 DSH 实例,安装后重开。下面的 macOS 示例假设应用位于 `~/Applications`,请按实际安装位置调整:
28
29
 
29
30
  ```sh
30
- "$HOME/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add dsh-more-details@0.3.16
31
+ "$HOME/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add dsh-more-details@0.3.17
31
32
  ```
32
33
 
33
- 浏览器宿主使用自己的 CLI 和 profile,例如 `dsh plugin --profile web add dsh-more-details@0.3.16`。不要使用另外安装的 CLI 管理 Desktop profile,也不要在任意目录直接执行 `pnpm add`。后续升级沿用同一命令,将版本号替换为需要的兼容版本。如果镜像尚未同步新发布版本,可在该次安装命令后加 `--registry=https://registry.npmjs.org`,无需修改全局 registry。
34
+ 浏览器宿主使用自己的 CLI 和 profile,例如 `dsh plugin --profile web add dsh-more-details@0.3.17`。不要使用另外安装的 CLI 管理 Desktop profile,也不要在任意目录直接执行 `pnpm add`。后续升级沿用同一命令,将版本号替换为需要的兼容版本。如果镜像尚未同步新发布版本,可在该次安装命令后加 `--registry=https://registry.npmjs.org`,无需修改全局 registry。
34
35
 
35
36
  ### 发现市场
36
37
 
@@ -45,14 +46,14 @@ DSH 0.2.1-alpha.4、0.2.1-rc.1、0.2.1-rc.2 和 0.2.1-rc.3 支持作者维护的
45
46
  ### Git 与 Release 安装包
46
47
 
47
48
  - **Git**:使用目标 Release 对应的完整公开 commit:`git+https://github.com/RZRZ-Q/dsh-more-details.git#<full-commit>`。在「添加插件」中输入,或交给自带的 `dsh plugin --profile desktop add` 命令。仓库已提交构建运行产物。
48
- - **归档**:从[发布页](https://github.com/RZRZ-Q/dsh-more-details/releases/tag/v0.3.16)下载 `dsh-more-details-0.3.16.tgz`,通过「添加插件」安装;源码包和 `SHA256SUMS` 单独提供。
49
+ - **归档**:从[发布页](https://github.com/RZRZ-Q/dsh-more-details/releases/tag/v0.3.17)下载 `dsh-more-details-0.3.17.tgz`,通过「添加插件」安装;源码包和 `SHA256SUMS` 单独提供。
49
50
 
50
51
  本地归档可能作为 profile 的 `file:` 依赖保留。只要依赖仍指向该文件,就应保留它及其记录路径;移动或删除可能阻塞同一 profile 的其他包操作。希望摆脱本地归档依赖的安装优先使用 npm。
51
52
 
52
53
  ### 从已有 tgz 或 Git 安装迁移
53
54
 
54
55
  1. 备份目标 profile;执行 CLI 更改前完整退出该 DSH 实例。保持同一 profile、插件名称、凭据、附件和浏览器数据。
55
- 2. 通过对应 DSH 安装器/CLI 安装 `dsh-more-details@0.3.16`,替换包来源;不需要先卸载插件并删除其数据。
56
+ 2. 通过对应 DSH 安装器/CLI 安装 `dsh-more-details@0.3.17`,替换包来源;不需要先卸载插件并删除其数据。
56
57
  3. 重开 DSH,检查版本、自定义 prompt、历史、原引用及已记住的网页登录。官网会话本身仍可能独立到期。
57
58
  4. 确认该插件的 profile 依赖不再指向旧归档,且另一项插件/包操作成功后,再删除旧归档。
58
59
 
@@ -66,6 +67,7 @@ DSH 0.2.1-alpha.4、0.2.1-rc.1、0.2.1-rc.2 和 0.2.1-rc.3 支持作者维护的
66
67
  2. 在主会话一条已完成的消息中划词,点击 **更多详情**,等待网页回复。
67
68
  3. 在小窗顶部 **提示词** 或 **设置 → 通用设置 → 更多详情** 修改指令。默认 prompt 为“告诉我更多相关信息”,可保存自定义内容或恢复默认;升级保留已保存的自定义值,切换界面语言不会翻译 prompt 文字。
68
69
  4. 用顶部 **新建** 打开空白网页聊天,用 **历史** 重开讨论。重开历史不会再次发送旧问题。
70
+ 5. 收起小窗后回到主输入框,左侧栏会显示 **继续聊天**,点击恢复同一网页,不新建、不发送消息。**新建 Chat** 保持独立操作。收起后不再在右下角留下遮挡发送键的按钮;侧栏折叠时,这两个入口显示为带提示文字的图标。
69
71
 
70
72
  同一 DSH 主会话中的后续划词可接续当前活动网页讨论;切换来源会话、新建空白聊天或手动重开历史后,下次 **更多详情** 另建讨论。
71
73
 
@@ -1,5 +1,11 @@
1
1
  # DSH 版本兼容
2
2
 
3
+ ## 0.3.17:收起入口移至侧栏
4
+
5
+ 兼容范围保持 `0.2.0-rc.2 || 0.2.1-alpha.4 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3`。本版通过既有 `sidebar.footer.action` 插槽提供“继续聊天”,保留独立“新建 Chat”,移除右下角悬浮恢复按钮;Host、RPC 与保存数据格式未改。
6
+
7
+ 2026-10-26,独立 macOS arm64 官方 rc.3 payload / Direct 测试壳通过升级、发送键无遮挡、同一网页和草稿恢复、不重复发送及历史重开。工程检查通过 32 文件 / 349 项测试和 23 项身份校验测试。其他宿主及完整重启、划词自动发送、模型引用回读沿用此前分版本记录,没有计作本轮重新验收;详见[验收范围](validation.md)。
8
+
3
9
  ## 0.3.16:rc.3 兼容与 npm 分发
4
10
 
5
11
  This release adds exact `0.2.1-rc.3` metadata while retaining all four earlier hosts. Package/import checks pass for all five versions; the official rc.3 installer and real Host reference reads pass without an exemption. The isolated rc.3 Desktop passed automatic sending, real model snapshot reading, full restart recovery, and follow-up. Real tgz/Git-to-registry migration passed with 0.3.16-rc.1; the final runtime is byte-identical. The npm-installed rc.3 Desktop also passed cold-start model reading before opening the website and signed-in history reopening. See [current validation](validation.md).
@@ -1,5 +1,47 @@
1
1
  # Release notes / 发布说明
2
2
 
3
+ ## v0.3.17 · Keep the send button clear
4
+
5
+ The collapsed Web Chat button could cover DSH's main send control. It now lives in the **left sidebar** as **Continue chat**, alongside the separate **New Chat** action. Continue chat restores the existing webpage and unsent draft without creating a conversation or sending again. The expanded panel keeps its bottom-right position.
6
+
7
+ Install or upgrade with **`dsh-more-details@0.3.17`** in **Plugins → Add plugin**, or use the CLI bundled with your DSH Desktop:
8
+
9
+ ```sh
10
+ dsh plugin --profile desktop add dsh-more-details@0.3.17 --registry=https://registry.npmjs.org
11
+ ```
12
+
13
+ Keep your existing profile and data; fully quit DSH before CLI installation and reopen afterward. This is a complete plugin package. Supported DSH versions remain **0.2.0-rc.2, 0.2.1-alpha.4, 0.2.1-rc.1, 0.2.1-rc.2, and 0.2.1-rc.3**. Host services, RPC, and saved-data formats are unchanged.
14
+
15
+ ### Validation
16
+
17
+ - **349 tests in 32 files**, **23 identity-guard tests**, peer, type, lint, build, and package checks passed.
18
+ - Isolated macOS arm64 DSH 0.2.1-rc.3 upgraded from 0.3.16 with all **110 protected files unchanged**; all **147 installed package files** matched the tested archive.
19
+ - Manual collapse, Add to DSH, collapse from History, and a half-width window restored the same URL, original question/reply pair, and unsent web draft without duplicate sends. New Chat and history reopening also passed.
20
+ - The main send control remained clear in normal and half-width windows. Clicking it sent a multiline draft with a web reference and received the expected reply.
21
+
22
+ Bilingual labels and compact sidebar icons are covered by automated tests; real UI acceptance used Chinese. Selection-triggered automatic sending, main-model `read_webchat_reference`, and full restart recovery were not rerun for this patch. Existing DSH installations and desktop spaces were untouched. See [validation](https://github.com/RZRZ-Q/dsh-more-details/blob/v0.3.17/docs/open-source/validation.md) for scope and prior results.
23
+
24
+ ### Assets
25
+
26
+ - `dsh-more-details-0.3.17.tgz` — complete installable plugin.
27
+ - `dsh-more-details-0.3.17-source.tar.gz` — public source and built runtime.
28
+ - `SHA256SUMS` — archive checksums.
29
+
30
+ <details>
31
+ <summary>简体中文</summary>
32
+
33
+ ### v0.3.17 · 避免 Chat 按钮遮挡发送键
34
+
35
+ 收起后的 Chat 悬浮按钮可能挡住 DSH 主输入框的发送键。本版将恢复入口移到**左侧栏“继续聊天”**,并保留独立的**“新建 Chat”**。继续聊天恢复原网页和未发送草稿,不新建、不重复发送;展开后仍是右下角小窗。
36
+
37
+ 通过 **插件 → 添加插件** 安装 **`dsh-more-details@0.3.17`**,或使用上方 CLI 命令。沿用现有 profile 和数据,CLI 安装前完整退出,安装后重开。分发的是完整插件包,五版 DSH 兼容范围、Host、RPC 和保存数据格式不变。
38
+
39
+ 工程检查通过 **32 文件 / 349 项测试**及 **23 项身份校验测试**。独立 macOS arm64 DSH rc.3 从 0.3.16 升级后,110 个受保护文件全部一致,147 个已安装包文件与验收包逐字节一致。手动收起、添加到 DSH 自动收起、历史页收起和半宽窗口均能恢复同一网页、原一问一答及未发送草稿,没有重复发送。常规与半宽窗口发送区域无遮挡;实际发送带引用的多行主草稿并收到预期回复。
40
+
41
+ 中英文案和紧凑侧栏图标由自动回归覆盖,实机为中文。本轮未重跑划词自动发送、主模型引用工具读取和完整重启恢复,既往结果仍分版本保留。未操作日常 DSH 或切换桌面。附件提供安装包、公开源码包和校验值,不含私人会话、凭据或备份。
42
+
43
+ </details>
44
+
3
45
  ## v0.3.16 · npm distribution, Web host controls, and DSH rc.3
4
46
 
5
47
  Install or upgrade through **Plugins → Add plugin** with **`dsh-more-details@0.3.16`**, or use the matching DSH CLI:
@@ -1,5 +1,24 @@
1
1
  # 验收范围与自行测试
2
2
 
3
+ ## 0.3.17:侧栏恢复入口与发送区域验收
4
+
5
+ 2026-10-26,在 macOS arm64 独立环境中,将插件从 0.3.16 升级到 0.3.17。使用官方 DSH `0.2.1-rc.3` payload 与既有 Direct 测试壳;应用、profile 和浏览器数据均与日常 DSH 隔离,未操作当前 DSH 或切换桌面。本版将收起后的恢复按钮移入左侧栏,保留独立的“新建 Chat”和“继续聊天”。
6
+
7
+ | 检查 | 本轮结果 |
8
+ | --- | --- |
9
+ | 工程检查 | `npm run check` 通过:32 文件 / 349 项测试、23 项身份校验测试,以及 peer、typecheck、lint、构建和包结构检查。 |
10
+ | 安装与数据保留 | 0.3.16 → 0.3.17 安装成功;安装后的 147 个分发文件与验收包逐字节一致,110 个安装前受保护文件全部保持一致。 |
11
+ | 新建与网页回复 | 左侧“新建 Chat”打开空白官网聊天;发送一次测试请求并收到回复。新建操作保留未发送草稿的保护逻辑;清空测试草稿后可打开空白聊天。 |
12
+ | 手动收起与继续 | 在网页输入框保留未发送草稿后,收起并点击左侧“继续聊天”:恢复同一 URL、原一问一答及网页草稿,没有新建会话或重复发送。 |
13
+ | 添加到 DSH 后恢复 | 捕获两条网页消息并添加引用,小窗自动收起;“继续聊天”恢复同一 URL、原一问一答及网页草稿。 |
14
+ | 历史页与窄窗口 | 从历史页收起后继续会返回当前网页;半宽窗口下收起与继续同样保留 URL、原一问一答和未发送草稿。另行新建空白聊天后,从历史重开原 URL,仍只有原一问一答。 |
15
+ | 主会话发送键 | 常规与半宽窗口的发送区域均无悬浮恢复按钮;主会话保留多行、带引用的草稿,侧栏收起时实际点击发送并收到预期回复。 |
16
+ | 语言与侧栏图标 | 自动回归覆盖中英标签和紧凑侧栏图标。实机使用中文;该测试壳折叠侧栏时整栏隐藏,因此不将图标覆盖写作实机验收。 |
17
+
18
+ 本轮只改插件客户端入口及发布材料,Host、RPC 和保存数据格式不变,五版兼容范围保持不变。本轮未重跑划词自动发送、主模型 `read_webchat_reference` 或完整重启恢复;这些流程的既往结果仍列在对应版本下。Windows/Linux 未增加实机验收。原始截图、网页地址、聊天正文及数据核对记录仅保留在本地忽略目录。
19
+
20
+ English summary: on an isolated macOS arm64 DSH 0.2.1-rc.3 Desktop, installation preserved all 110 protected files, and all 147 installed package files matched the tested archive. Sidebar New Chat opened a blank discussion and received a real reply. Manual collapse, Add to DSH, collapse from History, and a half-width window all restored the same URL, one question/reply pair, and unsent website draft without creating or sending again. The main send control remained unobstructed; clicking it sent a multiline draft with a reference and received the expected reply. Engineering checks passed 349 tests and 23 identity tests. Automatic selection sending, main-model reference-tool reading, and full restart recovery were not rerun in this patch.
21
+
3
22
  ## 0.3.16:rc.3 核心流程与 npm 迁移验收
4
23
 
5
24
  2026-10-25。保留四个旧宿主,增加 DSH `0.2.1-rc.3` 的精确声明和开发依赖;修复普通 Web 宿主先显示入口、点击才报错的问题,新增 npm 分发。rc.3 桌面核心流程与真实模型回读已通过;随后用公开 registry 中的 `0.3.16-rc.1` 完成 tgz/Git 迁移验收。正式 `0.3.16` 的 130 个运行文件与该候选包逐字节一致,只调整版本和发布材料。
@@ -7,7 +7,7 @@ import { createWebChatReferenceSource } from './parent-composer/webchat-referenc
7
7
  import webChatReferenceCss from './parent-composer/webchat-reference.css';
8
8
  import { WebChatController } from './webchat/controller.js';
9
9
  import { DeepSeekGuest, webChatBrowserBridge } from './webchat/guest.js';
10
- import { WebChatPanel, WebChatLauncher } from './webchat/WebChatPanel.js';
10
+ import { WebChatPanel, WebChatLauncher, WebChatRestore } from './webchat/WebChatPanel.js';
11
11
  import webChatCss from './webchat/webchat.css';
12
12
  import { mountMoreDetailsSettings } from './dsh/MoreDetailsSettings.js';
13
13
  import { SideChatController } from './side-chat-controller.js';
@@ -72,6 +72,9 @@ export async function apply(ctx) {
72
72
  cleanups.push(clientCtx.slots.inject('sidebar.footer.action', () => clientCtx.slots.register({
73
73
  name: 'sidebar.footer.action', id: 'dsh-more-details-new-chat', order: 10,
74
74
  }, ({ wide }) => createElement(WebChatLauncher, { controller: details, locale: ctx.locale, wide }))));
75
+ cleanups.push(clientCtx.slots.inject('sidebar.footer.action', () => clientCtx.slots.register({
76
+ name: 'sidebar.footer.action', id: 'dsh-more-details-continue-chat', order: 11,
77
+ }, ({ wide }) => createElement(WebChatRestore, { controller: details, locale: ctx.locale, wide }))));
75
78
  }
76
79
  const controller = new SideChatController(mounted.remote, sessions);
77
80
  cleanups.push(() => controller.dispose());
@@ -23,4 +23,10 @@ export declare function WebChatLauncher({ controller, locale, wide }: {
23
23
  readonly locale: DshLocale;
24
24
  readonly wide: boolean;
25
25
  }): import("react/jsx-runtime").JSX.Element;
26
+ /** 恢复入口随侧栏正常排版;只重新显示已挂载的网页,不导航或重发。 */
27
+ export declare function WebChatRestore({ controller, locale, wide }: {
28
+ readonly controller: Pick<WebChatController, 'getSnapshot' | 'subscribe' | 'show'>;
29
+ readonly locale: DshLocale;
30
+ readonly wide: boolean;
31
+ }): import("react/jsx-runtime").JSX.Element | null;
26
32
  export {};
@@ -50,9 +50,9 @@ export function WebChatPanel({ controller, guest, form, locale }) {
50
50
  const guestLabel = text('DeepSeek 网页聊天', 'DeepSeek web chat');
51
51
  useEffect(() => { guest.setAccessibleLabel(guestLabel); }, [guest, guestLabel]);
52
52
  useEffect(() => {
53
- if (state.busy)
53
+ if (state.busy || state.visible)
54
54
  setView('chat');
55
- }, [state.busy]);
55
+ }, [state.busy, state.visible]);
56
56
  useEffect(() => () => {
57
57
  removeDragEndListeners.current?.();
58
58
  drag.current = null;
@@ -139,18 +139,26 @@ export function WebChatPanel({ controller, guest, form, locale }) {
139
139
  };
140
140
  const resizeEvents = { onPointerMove: moveResize, onPointerUp: endResize,
141
141
  onPointerCancel: endResize, onLostPointerCapture: endResize };
142
- return (_jsxs(_Fragment, { children: [_jsxs("aside", { ref: panel, className: "dsh-webchat-panel", "data-side-chat-panel": "", "aria-label": "DeepSeek Chat", "data-resizing": resizing || undefined, "aria-busy": state.busy || undefined, style: { display: state.visible ? 'flex' : 'none',
143
- width: expanded ? 'var(--webchat-max-width)' : layout.width,
144
- height: expanded ? 'var(--webchat-max-height)' : layout.height }, children: [!expanded && _jsxs(_Fragment, { children: [_jsx("div", { className: "dsh-webchat-resize-edge dsh-webchat-resize-top", "aria-hidden": "true", onPointerDown: event => startResize(event, 'height'), ...resizeEvents }), _jsx("div", { className: "dsh-webchat-resize-edge dsh-webchat-resize-left", "aria-hidden": "true", onPointerDown: event => startResize(event, 'width'), ...resizeEvents }), _jsx("button", { type: "button", className: "dsh-webchat-resize-corner", disabled: !layoutWritable, "aria-label": text('调整聊天窗口大小', 'Resize chat window'), title: text('拖动或用方向键调整大小', 'Drag or use arrow keys to resize'), onPointerDown: event => startResize(event, 'both'), onKeyDown: resizeWithKeyboard, ...resizeEvents, children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: _jsx("path", { d: "M2 9V2h7M2 2l8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }) }) })] }), _jsxs("header", { className: "dsh-webchat-header", children: [_jsx("button", { type: "button", className: "dsh-webchat-title", onClick: showChat, "aria-label": text('返回 DeepSeek 网页聊天', 'Return to DeepSeek web chat'), children: "DeepSeek Chat" }), _jsxs("nav", { className: "dsh-webchat-actions", "aria-label": text('网页聊天操作', 'Web chat actions'), children: [_jsx("button", { type: "button", disabled: state.busy, onClick: newChat, children: text('新建', 'New') }), _jsx("button", { type: "button", disabled: state.busy, "aria-pressed": view === 'history', onClick: () => { setView(view === 'history' ? 'chat' : 'history'); }, children: text('历史', 'History') }), _jsx("button", { type: "button", disabled: state.busy, "aria-pressed": view === 'settings', onClick: () => { setView(view === 'settings' ? 'chat' : 'settings'); }, children: text('提示词', 'Prompt') }), _jsx("button", { type: "button", disabled: !layoutWritable, "aria-label": expanded ? text('还原聊天窗口大小', 'Restore chat window size') : text('放大聊天窗口', 'Expand chat window'), onClick: toggleExpanded, children: expanded ? text('还原', 'Restore') : text('放大', 'Expand') }), _jsx("button", { type: "button", "aria-label": text('收起 DeepSeek Chat', 'Collapse DeepSeek Chat'), onClick: () => { controller.hide(); }, children: text('收起', 'Collapse') })] })] }), (layoutAvailability !== null || layoutSave !== null) && _jsxs("div", { className: "dsh-webchat-notice", children: [layoutAvailability !== null && _jsx("p", { role: preferences.status === 'loading' ? 'status' : 'alert', children: layoutAvailability }), layoutSave === 'saving' && _jsx("p", { role: "status", children: text('正在保存窗口大小…', 'Saving window size…') }), typeof layoutSave === 'object' && layoutSave !== null && _jsx("p", { role: "alert", children: renderWebChatMessage(layoutSave.error, text) })] }), _jsxs("div", { className: "dsh-webchat-reference-action", children: [_jsx("span", { title: state.referenceTarget?.title, children: state.referenceTarget === undefined ? text('请先打开 DSH 主会话', 'Open a DSH conversation first')
145
- : text(`添加到:${state.referenceTarget.title || '当前主会话'}`, `Add to: ${state.referenceTarget.title || 'Current conversation'}`) }), _jsx("button", { type: "button", disabled: state.busy || state.pending !== undefined
146
- || state.currentUrl === undefined || state.referenceTarget === undefined, onClick: () => { void controller.addToDsh(); }, children: text('添加到 DSH', 'Add to DSH') })] }), loginMessage && _jsx("div", { className: "dsh-webchat-notice", children: _jsx("p", { role: "status", children: renderWebChatMessage(loginMessage, text) }) }), (state.message !== undefined || state.pending !== undefined) && (_jsxs("div", { className: "dsh-webchat-notice", children: [state.message !== undefined && _jsx("p", { role: "status", children: renderWebChatMessage(state.message, text) }), state.pending !== undefined && (_jsxs("div", { className: "dsh-webchat-notice-actions", children: [state.pending.reason === 'login-required' && (_jsx("button", { type: "button", disabled: state.busy, onClick: () => { setView('chat'); void controller.resume(); }, children: text('登录后继续', 'Continue after signing in') })), _jsx("button", { type: "button", disabled: state.busy, onClick: () => { controller.cancelPending(); }, children: text('取消待办', 'Cancel pending action') })] }))] })), _jsxs("div", { className: "dsh-webchat-content", children: [_jsx("div", { ref: container, className: "dsh-webchat-guest", "aria-label": text('DeepSeek 网页', 'DeepSeek website'), style: { display: view === 'chat' ? 'flex' : 'none' } }), _jsxs("section", { className: "dsh-webchat-history dsh-webchat-page", "aria-label": text('网页聊天历史', 'Web chat history'), style: { display: view === 'history' ? 'block' : 'none' }, children: [_jsx("h3", { children: text('最近打开的聊天', 'Recently opened chats') }), _jsx("p", { className: "dsh-webchat-description", children: text('点击继续网页聊天。完整聊天记录仍保存在 DeepSeek 账号中。', 'Open a chat to continue. Full conversations remain saved in your DeepSeek account.') }), state.history.length === 0
147
- ? _jsx("p", { className: "dsh-webchat-empty", children: text('还没有网页聊天历史。', 'No web chat history yet.') })
148
- : _jsx("ul", { className: "dsh-webchat-history-list", children: state.history.map(item => (_jsx("li", { children: _jsxs("button", { type: "button", disabled: state.busy, "aria-current": state.currentUrl === item.url ? 'page' : undefined, onClick: () => { setView('chat'); void controller.openHistory(item.url); }, children: [_jsx("span", { className: "dsh-webchat-history-title", children: item.title || 'DeepSeek Chat' }), _jsx("time", { dateTime: new Date(item.updatedAt).toISOString(), children: new Date(item.updatedAt).toLocaleString(text('zh-CN', 'en-US'), {
149
- month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit',
150
- }) })] }) }, item.url))) })] }), _jsx("section", { className: "dsh-webchat-page", "aria-label": text('更多详情提示词设置', 'More details prompt settings'), style: { display: view === 'settings' ? 'block' : 'none' }, children: _jsx(MoreDetailsSettings, { locale: locale, usePromptSettings: usePromptSettings, savePrompt: prompt => form.set('defaultPrompt', prompt), resetPrompt: () => form.unset('defaultPrompt') }) })] })] }), state.hasOpened && !state.visible && (_jsx("button", { type: "button", className: "dsh-webchat-restore", "data-side-chat-panel": "", onClick: showChat, "aria-label": text('展开 DeepSeek Chat', 'Open DeepSeek Chat'), children: "DeepSeek Chat" }))] }));
142
+ return (_jsx(_Fragment, { children: _jsxs("aside", { ref: panel, className: "dsh-webchat-panel", "data-side-chat-panel": "", "aria-label": "DeepSeek Chat", "data-resizing": resizing || undefined, "aria-busy": state.busy || undefined, style: { display: state.visible ? 'flex' : 'none',
143
+ width: expanded ? 'var(--webchat-max-width)' : layout.width,
144
+ height: expanded ? 'var(--webchat-max-height)' : layout.height }, children: [!expanded && _jsxs(_Fragment, { children: [_jsx("div", { className: "dsh-webchat-resize-edge dsh-webchat-resize-top", "aria-hidden": "true", onPointerDown: event => startResize(event, 'height'), ...resizeEvents }), _jsx("div", { className: "dsh-webchat-resize-edge dsh-webchat-resize-left", "aria-hidden": "true", onPointerDown: event => startResize(event, 'width'), ...resizeEvents }), _jsx("button", { type: "button", className: "dsh-webchat-resize-corner", disabled: !layoutWritable, "aria-label": text('调整聊天窗口大小', 'Resize chat window'), title: text('拖动或用方向键调整大小', 'Drag or use arrow keys to resize'), onPointerDown: event => startResize(event, 'both'), onKeyDown: resizeWithKeyboard, ...resizeEvents, children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: _jsx("path", { d: "M2 9V2h7M2 2l8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }) }) })] }), _jsxs("header", { className: "dsh-webchat-header", children: [_jsx("button", { type: "button", className: "dsh-webchat-title", onClick: showChat, "aria-label": text('返回 DeepSeek 网页聊天', 'Return to DeepSeek web chat'), children: "DeepSeek Chat" }), _jsxs("nav", { className: "dsh-webchat-actions", "aria-label": text('网页聊天操作', 'Web chat actions'), children: [_jsx("button", { type: "button", disabled: state.busy, onClick: newChat, children: text('新建', 'New') }), _jsx("button", { type: "button", disabled: state.busy, "aria-pressed": view === 'history', onClick: () => { setView(view === 'history' ? 'chat' : 'history'); }, children: text('历史', 'History') }), _jsx("button", { type: "button", disabled: state.busy, "aria-pressed": view === 'settings', onClick: () => { setView(view === 'settings' ? 'chat' : 'settings'); }, children: text('提示词', 'Prompt') }), _jsx("button", { type: "button", disabled: !layoutWritable, "aria-label": expanded ? text('还原聊天窗口大小', 'Restore chat window size') : text('放大聊天窗口', 'Expand chat window'), onClick: toggleExpanded, children: expanded ? text('还原', 'Restore') : text('放大', 'Expand') }), _jsx("button", { type: "button", "aria-label": text('收起 DeepSeek Chat', 'Collapse DeepSeek Chat'), onClick: () => { controller.hide(); }, children: text('收起', 'Collapse') })] })] }), (layoutAvailability !== null || layoutSave !== null) && _jsxs("div", { className: "dsh-webchat-notice", children: [layoutAvailability !== null && _jsx("p", { role: preferences.status === 'loading' ? 'status' : 'alert', children: layoutAvailability }), layoutSave === 'saving' && _jsx("p", { role: "status", children: text('正在保存窗口大小…', 'Saving window size…') }), typeof layoutSave === 'object' && layoutSave !== null && _jsx("p", { role: "alert", children: renderWebChatMessage(layoutSave.error, text) })] }), _jsxs("div", { className: "dsh-webchat-reference-action", children: [_jsx("span", { title: state.referenceTarget?.title, children: state.referenceTarget === undefined ? text('请先打开 DSH 主会话', 'Open a DSH conversation first')
145
+ : text(`添加到:${state.referenceTarget.title || '当前主会话'}`, `Add to: ${state.referenceTarget.title || 'Current conversation'}`) }), _jsx("button", { type: "button", disabled: state.busy || state.pending !== undefined
146
+ || state.currentUrl === undefined || state.referenceTarget === undefined, onClick: () => { void controller.addToDsh(); }, children: text('添加到 DSH', 'Add to DSH') })] }), loginMessage && _jsx("div", { className: "dsh-webchat-notice", children: _jsx("p", { role: "status", children: renderWebChatMessage(loginMessage, text) }) }), (state.message !== undefined || state.pending !== undefined) && (_jsxs("div", { className: "dsh-webchat-notice", children: [state.message !== undefined && _jsx("p", { role: "status", children: renderWebChatMessage(state.message, text) }), state.pending !== undefined && (_jsxs("div", { className: "dsh-webchat-notice-actions", children: [state.pending.reason === 'login-required' && (_jsx("button", { type: "button", disabled: state.busy, onClick: () => { setView('chat'); void controller.resume(); }, children: text('登录后继续', 'Continue after signing in') })), _jsx("button", { type: "button", disabled: state.busy, onClick: () => { controller.cancelPending(); }, children: text('取消待办', 'Cancel pending action') })] }))] })), _jsxs("div", { className: "dsh-webchat-content", children: [_jsx("div", { ref: container, className: "dsh-webchat-guest", "aria-label": text('DeepSeek 网页', 'DeepSeek website'), style: { display: view === 'chat' ? 'flex' : 'none' } }), _jsxs("section", { className: "dsh-webchat-history dsh-webchat-page", "aria-label": text('网页聊天历史', 'Web chat history'), style: { display: view === 'history' ? 'block' : 'none' }, children: [_jsx("h3", { children: text('最近打开的聊天', 'Recently opened chats') }), _jsx("p", { className: "dsh-webchat-description", children: text('点击继续网页聊天。完整聊天记录仍保存在 DeepSeek 账号中。', 'Open a chat to continue. Full conversations remain saved in your DeepSeek account.') }), state.history.length === 0
147
+ ? _jsx("p", { className: "dsh-webchat-empty", children: text('还没有网页聊天历史。', 'No web chat history yet.') })
148
+ : _jsx("ul", { className: "dsh-webchat-history-list", children: state.history.map(item => (_jsx("li", { children: _jsxs("button", { type: "button", disabled: state.busy, "aria-current": state.currentUrl === item.url ? 'page' : undefined, onClick: () => { setView('chat'); void controller.openHistory(item.url); }, children: [_jsx("span", { className: "dsh-webchat-history-title", children: item.title || 'DeepSeek Chat' }), _jsx("time", { dateTime: new Date(item.updatedAt).toISOString(), children: new Date(item.updatedAt).toLocaleString(text('zh-CN', 'en-US'), {
149
+ month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit',
150
+ }) })] }) }, item.url))) })] }), _jsx("section", { className: "dsh-webchat-page", "aria-label": text('更多详情提示词设置', 'More details prompt settings'), style: { display: view === 'settings' ? 'block' : 'none' }, children: _jsx(MoreDetailsSettings, { locale: locale, usePromptSettings: usePromptSettings, savePrompt: prompt => form.set('defaultPrompt', prompt), resetPrompt: () => form.unset('defaultPrompt') }) })] })] }) }));
151
151
  }
152
152
  /** 侧栏入口单独订阅语言,切换时不重新创建聊天控制器。 */
153
153
  export function WebChatLauncher({ controller, locale, wide }) {
154
154
  const { text } = useDshLocale(locale);
155
155
  return _jsx("button", { type: "button", className: "dsh-webchat-launcher", title: text('新建 DeepSeek 网页聊天', 'New DeepSeek web chat'), "aria-label": text('新建 Chat', 'New Chat'), onClick: () => { void controller.newChat(); }, children: wide ? text('+ 新建 Chat', '+ New Chat') : '+' });
156
156
  }
157
+ /** 恢复入口随侧栏正常排版;只重新显示已挂载的网页,不导航或重发。 */
158
+ export function WebChatRestore({ controller, locale, wide }) {
159
+ const { text } = useDshLocale(locale);
160
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
161
+ if (!state.hasOpened || state.visible)
162
+ return null;
163
+ return _jsx("button", { type: "button", className: "dsh-webchat-launcher", title: text('继续当前 DeepSeek 网页聊天', 'Continue the current DeepSeek web chat'), "aria-label": text('继续聊天', 'Continue chat'), onClick: () => { controller.show(); }, children: wide ? text('继续聊天', 'Continue chat') : _jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "M13.5 7.5a5.5 5.5 0 0 1-5.5 5.5H3l-1.5 1V7.5A5.5 5.5 0 0 1 7 2h1a5.5 5.5 0 0 1 5.5 5.5Z", fill: "none", stroke: "currentColor", strokeWidth: "1.25" }) }) });
164
+ }
@@ -12,8 +12,7 @@
12
12
  }
13
13
  .dsh-webchat-launcher:hover { background: var(--dsw-alias-bg-layer-3, #f1f2f5); }
14
14
 
15
- .dsh-webchat-panel,
16
- .dsh-webchat-restore {
15
+ .dsh-webchat-panel {
17
16
  --webchat-bg: var(--dsw-alias-bg-layer-2, #fff);
18
17
  --webchat-text: var(--dsw-alias-label-primary, #19191d);
19
18
  --webchat-muted: var(--dsw-alias-label-tertiary, #62636a);
@@ -82,8 +81,7 @@
82
81
  border-bottom: 1px solid var(--webchat-border);
83
82
  }
84
83
 
85
- .dsh-webchat-panel button,
86
- .dsh-webchat-restore {
84
+ .dsh-webchat-panel button {
87
85
  color: inherit;
88
86
  font: inherit;
89
87
  cursor: pointer;
@@ -112,8 +110,7 @@
112
110
  color: var(--webchat-accent);
113
111
  }
114
112
  .dsh-webchat-panel button:disabled { opacity: .5; cursor: not-allowed; }
115
- .dsh-webchat-panel button:focus-visible,
116
- .dsh-webchat-restore:focus-visible {
113
+ .dsh-webchat-panel button:focus-visible {
117
114
  outline: 2px solid var(--webchat-accent);
118
115
  outline-offset: 2px;
119
116
  }
@@ -175,7 +172,6 @@
175
172
  }
176
173
  .dsh-webchat-history-title { max-width: 100%; overflow-wrap: anywhere; line-height: 1.5; }
177
174
  .dsh-webchat-history-list time { color: var(--webchat-muted); font-size: 12px; }
178
- .dsh-webchat-restore { padding: 12px 18px; border-radius: 999px; }
179
175
 
180
176
  @media (max-width: 560px) {
181
177
  .dsh-webchat-panel {
@@ -185,5 +181,4 @@
185
181
  bottom: 8px;
186
182
  }
187
183
  .dsh-webchat-header { flex-wrap: wrap; }
188
- .dsh-webchat-restore { right: 12px; bottom: 12px; }
189
184
  }
package/lib/client.js CHANGED
@@ -1173,7 +1173,7 @@ window.__ModuleLoader__.load({id:`dsh-more-details`,factory:e=>{var t={exports:{
1173
1173
  .dsh-more-details-settings button:disabled, .dsh-more-details-settings textarea:disabled { opacity: .55; cursor: not-allowed; }
1174
1174
  .dsh-more-details-settings :is(button, textarea):focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #1473e6); outline-offset: 2px; }
1175
1175
  .dsh-more-details-settings [role=alert] { color: var(--dsw-alias-state-error-primary, #b42318); }
1176
- `}),/* @__PURE__ */ (0,i.jsx)(`h3`,{id:`${c}-title`,children:o(`更多详情`,`More details`)}),/* @__PURE__ */ (0,i.jsx)(`p`,{id:`${c}-description`,children:o(`在官方 DSH 桌面端划词后点击“更多详情”,会在右下角 DeepSeek 网页聊天中自动发送以下提示词;选文和来源背景会自动附加。`,`In the official DSH desktop app, select text and choose More details to send this prompt in the bottom-right DeepSeek Web Chat. The selection and source context are included automatically.`)}),/* @__PURE__ */ (0,i.jsx)(`label`,{htmlFor:c,children:o(`默认提示词`,`Default prompt`)}),/* @__PURE__ */ (0,i.jsx)(`textarea`,{id:c,rows:5,value:g,disabled:!v||f,"aria-describedby":`${c}-description${b?` ${c}-validation`:``}`,onChange:e=>{d(e.currentTarget.value),h(null)}}),b&&/* @__PURE__ */ (0,i.jsx)(`p`,{id:`${c}-validation`,children:o(`请输入非空的提示词。`,`Enter a prompt that is not blank.`)}),x!==null&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:x}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-settings-actions`,children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`submit`,disabled:!v||f||!y||b,children:f?o(`正在保存…`,`Saving…`):o(`保存`,`Save`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:!v||f,onClick:()=>{C(!0)},children:o(`恢复默认`,`Restore default`)})]}),m!==null&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:m.kind===`rejected`||m.kind===`failed`?`alert`:`status`,children:S})]})}function pt(e){let t=e.configForms.get(`more-details`);return e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`more-details-prompt`,order:90,inject:()=>({locale:e.locale,hooks:{promptSettings:t},savePrompt:e=>t.set(`defaultPrompt`,e),resetPrompt:()=>t.unset(`defaultPrompt`)})},ft))}let mt={width:520,height:650,expanded:!1};function ht({controller:e,guest:t,form:n,locale:a}){let{text:o}=N(a),s=(0,r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),c=(0,r.useSyncExternalStore)(t.subscribeLogin,t.getLoginMessage,t.getLoginMessage),[l,u]=(0,r.useState)(`chat`),[d,f]=(0,r.useState)(mt),p=(0,r.useRef)(d),m=(0,r.useRef)(null),h=(0,r.useRef)(0),[g,_]=(0,r.useState)(null),{expanded:v}=d,[y,b]=(0,r.useState)(!1),x=(0,r.useRef)(null),S=(0,r.useRef)(null),C=(0,r.useRef)(null),w=(0,r.useRef)(null),T=(0,r.useCallback)(e=>n.subscribe(e),[n]),E=(0,r.useCallback)(()=>n.getSnapshot(),[n]),D=(0,r.useSyncExternalStore)(T,E,E),O=e=>e((0,r.useSyncExternalStore)(T,E,E)),k=!(`mode`in D)||D.mode===`host`,A=D.status===`ready`&&k&&D.writable,j=D.status===`loading`?o(`正在读取上次的窗口大小…`,`Loading the previous window size…`):D.status!==`ready`||!k?o(`无法读取或保存窗口大小,请确认本机“更多详情”配置可用。`,`Cannot load or save the window size. Check that local More details settings are available.`):D.writable?null:o(`当前 DSH 配置只读,无法保存窗口大小。`,`DSH settings are read-only; the window size cannot be saved.`);(0,r.useEffect)(()=>{D.status===`ready`&&D.value!==void 0&&m.current!==n&&(m.current=n,p.current=D.value.webChatLayout,f(D.value.webChatLayout))},[n,D]),(0,r.useEffect)(()=>{w.current!==null&&t.attach(w.current)},[t]);let M=o(`DeepSeek 网页聊天`,`DeepSeek web chat`);(0,r.useEffect)(()=>{t.setAccessibleLabel(M)},[t,M]),(0,r.useEffect)(()=>{s.busy&&u(`chat`)},[s.busy]),(0,r.useEffect)(()=>()=>{C.current?.(),S.current=null},[]);let P=()=>{u(`chat`),e.show()},F=()=>{u(`chat`),e.newChat()},I=async e=>{let t=++h.current;_(`saving`);try{let r=await n.set(`webChatLayout`,e);if(t!==h.current)return;_(r?null:{error:{zh:`窗口大小未保存:配置可能已变化或不允许写入,请重新调整后重试。`,en:`Window size was not saved: settings changed or are not writable. Resize again to retry.`}})}catch(e){if(t!==h.current)return;let n=e instanceof Error?e.message:String(e);_({error:{zh:`窗口大小未保存:${n}`,en:`Window size was not saved: ${n}`}})}},ee=(e,t)=>{let n=window.innerWidth<=560,r=window.innerWidth-(n?16:40),i=window.innerHeight-(n?48:64),a={...p.current,width:Math.min(r,Math.max(360,e)),height:Math.min(i,Math.max(360,t))};return p.current=a,f(a),a},L=(e,t)=>{if(!A||e.button!==0||x.current===null)return;e.preventDefault();let n=x.current.getBoundingClientRect();e.currentTarget.setPointerCapture(e.pointerId),S.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,width:n.width,height:n.height,axis:t},C.current?.();let r=e=>{S.current?.pointerId===e.pointerId&&R()};window.addEventListener(`pointerup`,r,!0),window.addEventListener(`pointercancel`,r,!0),C.current=()=>{window.removeEventListener(`pointerup`,r,!0),window.removeEventListener(`pointercancel`,r,!0),C.current=null},b(!0)},te=e=>{let t=S.current;t!==null&&t.pointerId===e.pointerId&&ee(t.width+(t.axis===`height`?0:t.x-e.clientX),t.height+(t.axis===`width`?0:t.y-e.clientY))},R=()=>{S.current!==null&&(S.current=null,C.current?.(),b(!1),I(p.current))},ne=e=>{let t=x.current?.getBoundingClientRect();A&&t!==void 0&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),I(ee(t.width+(e.key===`ArrowLeft`?24:e.key===`ArrowRight`?-24:0),t.height+(e.key===`ArrowUp`?24:e.key===`ArrowDown`?-24:0))))},re=()=>{let e={...p.current,expanded:!p.current.expanded};p.current=e,f(e),I(e)},ie={onPointerMove:te,onPointerUp:R,onPointerCancel:R,onLostPointerCapture:R};return/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[/* @__PURE__ */ (0,i.jsxs)(`aside`,{ref:x,className:`dsh-webchat-panel`,"data-side-chat-panel":``,"aria-label":`DeepSeek Chat`,"data-resizing":y||void 0,"aria-busy":s.busy||void 0,style:{display:s.visible?`flex`:`none`,width:v?`var(--webchat-max-width)`:d.width,height:v?`var(--webchat-max-height)`:d.height},children:[!v&&/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-webchat-resize-edge dsh-webchat-resize-top`,"aria-hidden":`true`,onPointerDown:e=>L(e,`height`),...ie}),/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-webchat-resize-edge dsh-webchat-resize-left`,"aria-hidden":`true`,onPointerDown:e=>L(e,`width`),...ie}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-resize-corner`,disabled:!A,"aria-label":o(`调整聊天窗口大小`,`Resize chat window`),title:o(`拖动或用方向键调整大小`,`Drag or use arrow keys to resize`),onPointerDown:e=>L(e,`both`),onKeyDown:ne,...ie,children:/* @__PURE__ */ (0,i.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M2 9V2h7M2 2l8 8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})})]}),/* @__PURE__ */ (0,i.jsxs)(`header`,{className:`dsh-webchat-header`,children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-title`,onClick:P,"aria-label":o(`返回 DeepSeek 网页聊天`,`Return to DeepSeek web chat`),children:`DeepSeek Chat`}),/* @__PURE__ */ (0,i.jsxs)(`nav`,{className:`dsh-webchat-actions`,"aria-label":o(`网页聊天操作`,`Web chat actions`),children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,onClick:F,children:o(`新建`,`New`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,"aria-pressed":l===`history`,onClick:()=>{u(l===`history`?`chat`:`history`)},children:o(`历史`,`History`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,"aria-pressed":l===`settings`,onClick:()=>{u(l===`settings`?`chat`:`settings`)},children:o(`提示词`,`Prompt`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:!A,"aria-label":v?o(`还原聊天窗口大小`,`Restore chat window size`):o(`放大聊天窗口`,`Expand chat window`),onClick:re,children:v?o(`还原`,`Restore`):o(`放大`,`Expand`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,"aria-label":o(`收起 DeepSeek Chat`,`Collapse DeepSeek Chat`),onClick:()=>{e.hide()},children:o(`收起`,`Collapse`)})]})]}),(j!==null||g!==null)&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-notice`,children:[j!==null&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:D.status===`loading`?`status`:`alert`,children:j}),g===`saving`&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:o(`正在保存窗口大小…`,`Saving window size…`)}),typeof g==`object`&&!!g&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`alert`,children:qe(g.error,o)})]}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-reference-action`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{title:s.referenceTarget?.title,children:s.referenceTarget===void 0?o(`请先打开 DSH 主会话`,`Open a DSH conversation first`):o(`添加到:${s.referenceTarget.title||`当前主会话`}`,`Add to: ${s.referenceTarget.title||`Current conversation`}`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy||s.pending!==void 0||s.currentUrl===void 0||s.referenceTarget===void 0,onClick:()=>{e.addToDsh()},children:o(`添加到 DSH`,`Add to DSH`)})]}),c&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-webchat-notice`,children:/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:qe(c,o)})}),(s.message!==void 0||s.pending!==void 0)&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-notice`,children:[s.message!==void 0&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:qe(s.message,o)}),s.pending!==void 0&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-notice-actions`,children:[s.pending.reason===`login-required`&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,onClick:()=>{u(`chat`),e.resume()},children:o(`登录后继续`,`Continue after signing in`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,onClick:()=>{e.cancelPending()},children:o(`取消待办`,`Cancel pending action`)})]})]}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-content`,children:[/* @__PURE__ */ (0,i.jsx)(`div`,{ref:w,className:`dsh-webchat-guest`,"aria-label":o(`DeepSeek 网页`,`DeepSeek website`),style:{display:l===`chat`?`flex`:`none`}}),/* @__PURE__ */ (0,i.jsxs)(`section`,{className:`dsh-webchat-history dsh-webchat-page`,"aria-label":o(`网页聊天历史`,`Web chat history`),style:{display:l===`history`?`block`:`none`},children:[/* @__PURE__ */ (0,i.jsx)(`h3`,{children:o(`最近打开的聊天`,`Recently opened chats`)}),/* @__PURE__ */ (0,i.jsx)(`p`,{className:`dsh-webchat-description`,children:o(`点击继续网页聊天。完整聊天记录仍保存在 DeepSeek 账号中。`,`Open a chat to continue. Full conversations remain saved in your DeepSeek account.`)}),s.history.length===0?/* @__PURE__ */ (0,i.jsx)(`p`,{className:`dsh-webchat-empty`,children:o(`还没有网页聊天历史。`,`No web chat history yet.`)}):/* @__PURE__ */ (0,i.jsx)(`ul`,{className:`dsh-webchat-history-list`,children:s.history.map(t=>/* @__PURE__ */ (0,i.jsx)(`li`,{children:/* @__PURE__ */ (0,i.jsxs)(`button`,{type:`button`,disabled:s.busy,"aria-current":s.currentUrl===t.url?`page`:void 0,onClick:()=>{u(`chat`),e.openHistory(t.url)},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-webchat-history-title`,children:t.title||`DeepSeek Chat`}),/* @__PURE__ */ (0,i.jsx)(`time`,{dateTime:new Date(t.updatedAt).toISOString(),children:new Date(t.updatedAt).toLocaleString(o(`zh-CN`,`en-US`),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]})},t.url))})]}),/* @__PURE__ */ (0,i.jsx)(`section`,{className:`dsh-webchat-page`,"aria-label":o(`更多详情提示词设置`,`More details prompt settings`),style:{display:l===`settings`?`block`:`none`},children:/* @__PURE__ */ (0,i.jsx)(ft,{locale:a,usePromptSettings:O,savePrompt:e=>n.set(`defaultPrompt`,e),resetPrompt:()=>n.unset(`defaultPrompt`)})})]})]}),s.hasOpened&&!s.visible&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-restore`,"data-side-chat-panel":``,onClick:P,"aria-label":o(`展开 DeepSeek Chat`,`Open DeepSeek Chat`),children:`DeepSeek Chat`})]})}function gt({controller:e,locale:t,wide:n}){let{text:r}=N(t);return/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-launcher`,title:r(`新建 DeepSeek 网页聊天`,`New DeepSeek web chat`),"aria-label":r(`新建 Chat`,`New Chat`),onClick:()=>{e.newChat()},children:n?r(`+ 新建 Chat`,`+ New Chat`):`+`})}var _t=`.dsh-webchat-launcher {
1176
+ `}),/* @__PURE__ */ (0,i.jsx)(`h3`,{id:`${c}-title`,children:o(`更多详情`,`More details`)}),/* @__PURE__ */ (0,i.jsx)(`p`,{id:`${c}-description`,children:o(`在官方 DSH 桌面端划词后点击“更多详情”,会在右下角 DeepSeek 网页聊天中自动发送以下提示词;选文和来源背景会自动附加。`,`In the official DSH desktop app, select text and choose More details to send this prompt in the bottom-right DeepSeek Web Chat. The selection and source context are included automatically.`)}),/* @__PURE__ */ (0,i.jsx)(`label`,{htmlFor:c,children:o(`默认提示词`,`Default prompt`)}),/* @__PURE__ */ (0,i.jsx)(`textarea`,{id:c,rows:5,value:g,disabled:!v||f,"aria-describedby":`${c}-description${b?` ${c}-validation`:``}`,onChange:e=>{d(e.currentTarget.value),h(null)}}),b&&/* @__PURE__ */ (0,i.jsx)(`p`,{id:`${c}-validation`,children:o(`请输入非空的提示词。`,`Enter a prompt that is not blank.`)}),x!==null&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:x}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-settings-actions`,children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`submit`,disabled:!v||f||!y||b,children:f?o(`正在保存…`,`Saving…`):o(`保存`,`Save`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:!v||f,onClick:()=>{C(!0)},children:o(`恢复默认`,`Restore default`)})]}),m!==null&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:m.kind===`rejected`||m.kind===`failed`?`alert`:`status`,children:S})]})}function pt(e){let t=e.configForms.get(`more-details`);return e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`more-details-prompt`,order:90,inject:()=>({locale:e.locale,hooks:{promptSettings:t},savePrompt:e=>t.set(`defaultPrompt`,e),resetPrompt:()=>t.unset(`defaultPrompt`)})},ft))}let mt={width:520,height:650,expanded:!1};function ht({controller:e,guest:t,form:n,locale:a}){let{text:o}=N(a),s=(0,r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),c=(0,r.useSyncExternalStore)(t.subscribeLogin,t.getLoginMessage,t.getLoginMessage),[l,u]=(0,r.useState)(`chat`),[d,f]=(0,r.useState)(mt),p=(0,r.useRef)(d),m=(0,r.useRef)(null),h=(0,r.useRef)(0),[g,_]=(0,r.useState)(null),{expanded:v}=d,[y,b]=(0,r.useState)(!1),x=(0,r.useRef)(null),S=(0,r.useRef)(null),C=(0,r.useRef)(null),w=(0,r.useRef)(null),T=(0,r.useCallback)(e=>n.subscribe(e),[n]),E=(0,r.useCallback)(()=>n.getSnapshot(),[n]),D=(0,r.useSyncExternalStore)(T,E,E),O=e=>e((0,r.useSyncExternalStore)(T,E,E)),k=!(`mode`in D)||D.mode===`host`,A=D.status===`ready`&&k&&D.writable,j=D.status===`loading`?o(`正在读取上次的窗口大小…`,`Loading the previous window size…`):D.status!==`ready`||!k?o(`无法读取或保存窗口大小,请确认本机“更多详情”配置可用。`,`Cannot load or save the window size. Check that local More details settings are available.`):D.writable?null:o(`当前 DSH 配置只读,无法保存窗口大小。`,`DSH settings are read-only; the window size cannot be saved.`);(0,r.useEffect)(()=>{D.status===`ready`&&D.value!==void 0&&m.current!==n&&(m.current=n,p.current=D.value.webChatLayout,f(D.value.webChatLayout))},[n,D]),(0,r.useEffect)(()=>{w.current!==null&&t.attach(w.current)},[t]);let M=o(`DeepSeek 网页聊天`,`DeepSeek web chat`);(0,r.useEffect)(()=>{t.setAccessibleLabel(M)},[t,M]),(0,r.useEffect)(()=>{(s.busy||s.visible)&&u(`chat`)},[s.busy,s.visible]),(0,r.useEffect)(()=>()=>{C.current?.(),S.current=null},[]);let P=()=>{u(`chat`),e.show()},F=()=>{u(`chat`),e.newChat()},I=async e=>{let t=++h.current;_(`saving`);try{let r=await n.set(`webChatLayout`,e);if(t!==h.current)return;_(r?null:{error:{zh:`窗口大小未保存:配置可能已变化或不允许写入,请重新调整后重试。`,en:`Window size was not saved: settings changed or are not writable. Resize again to retry.`}})}catch(e){if(t!==h.current)return;let n=e instanceof Error?e.message:String(e);_({error:{zh:`窗口大小未保存:${n}`,en:`Window size was not saved: ${n}`}})}},ee=(e,t)=>{let n=window.innerWidth<=560,r=window.innerWidth-(n?16:40),i=window.innerHeight-(n?48:64),a={...p.current,width:Math.min(r,Math.max(360,e)),height:Math.min(i,Math.max(360,t))};return p.current=a,f(a),a},L=(e,t)=>{if(!A||e.button!==0||x.current===null)return;e.preventDefault();let n=x.current.getBoundingClientRect();e.currentTarget.setPointerCapture(e.pointerId),S.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,width:n.width,height:n.height,axis:t},C.current?.();let r=e=>{S.current?.pointerId===e.pointerId&&R()};window.addEventListener(`pointerup`,r,!0),window.addEventListener(`pointercancel`,r,!0),C.current=()=>{window.removeEventListener(`pointerup`,r,!0),window.removeEventListener(`pointercancel`,r,!0),C.current=null},b(!0)},te=e=>{let t=S.current;t!==null&&t.pointerId===e.pointerId&&ee(t.width+(t.axis===`height`?0:t.x-e.clientX),t.height+(t.axis===`width`?0:t.y-e.clientY))},R=()=>{S.current!==null&&(S.current=null,C.current?.(),b(!1),I(p.current))},ne=e=>{let t=x.current?.getBoundingClientRect();A&&t!==void 0&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),I(ee(t.width+(e.key===`ArrowLeft`?24:e.key===`ArrowRight`?-24:0),t.height+(e.key===`ArrowUp`?24:e.key===`ArrowDown`?-24:0))))},re=()=>{let e={...p.current,expanded:!p.current.expanded};p.current=e,f(e),I(e)},ie={onPointerMove:te,onPointerUp:R,onPointerCancel:R,onLostPointerCapture:R};return/* @__PURE__ */ (0,i.jsx)(i.Fragment,{children:/* @__PURE__ */ (0,i.jsxs)(`aside`,{ref:x,className:`dsh-webchat-panel`,"data-side-chat-panel":``,"aria-label":`DeepSeek Chat`,"data-resizing":y||void 0,"aria-busy":s.busy||void 0,style:{display:s.visible?`flex`:`none`,width:v?`var(--webchat-max-width)`:d.width,height:v?`var(--webchat-max-height)`:d.height},children:[!v&&/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-webchat-resize-edge dsh-webchat-resize-top`,"aria-hidden":`true`,onPointerDown:e=>L(e,`height`),...ie}),/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-webchat-resize-edge dsh-webchat-resize-left`,"aria-hidden":`true`,onPointerDown:e=>L(e,`width`),...ie}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-resize-corner`,disabled:!A,"aria-label":o(`调整聊天窗口大小`,`Resize chat window`),title:o(`拖动或用方向键调整大小`,`Drag or use arrow keys to resize`),onPointerDown:e=>L(e,`both`),onKeyDown:ne,...ie,children:/* @__PURE__ */ (0,i.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M2 9V2h7M2 2l8 8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})})]}),/* @__PURE__ */ (0,i.jsxs)(`header`,{className:`dsh-webchat-header`,children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-title`,onClick:P,"aria-label":o(`返回 DeepSeek 网页聊天`,`Return to DeepSeek web chat`),children:`DeepSeek Chat`}),/* @__PURE__ */ (0,i.jsxs)(`nav`,{className:`dsh-webchat-actions`,"aria-label":o(`网页聊天操作`,`Web chat actions`),children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,onClick:F,children:o(`新建`,`New`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,"aria-pressed":l===`history`,onClick:()=>{u(l===`history`?`chat`:`history`)},children:o(`历史`,`History`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,"aria-pressed":l===`settings`,onClick:()=>{u(l===`settings`?`chat`:`settings`)},children:o(`提示词`,`Prompt`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:!A,"aria-label":v?o(`还原聊天窗口大小`,`Restore chat window size`):o(`放大聊天窗口`,`Expand chat window`),onClick:re,children:v?o(`还原`,`Restore`):o(`放大`,`Expand`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,"aria-label":o(`收起 DeepSeek Chat`,`Collapse DeepSeek Chat`),onClick:()=>{e.hide()},children:o(`收起`,`Collapse`)})]})]}),(j!==null||g!==null)&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-notice`,children:[j!==null&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:D.status===`loading`?`status`:`alert`,children:j}),g===`saving`&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:o(`正在保存窗口大小…`,`Saving window size…`)}),typeof g==`object`&&!!g&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`alert`,children:qe(g.error,o)})]}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-reference-action`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{title:s.referenceTarget?.title,children:s.referenceTarget===void 0?o(`请先打开 DSH 主会话`,`Open a DSH conversation first`):o(`添加到:${s.referenceTarget.title||`当前主会话`}`,`Add to: ${s.referenceTarget.title||`Current conversation`}`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy||s.pending!==void 0||s.currentUrl===void 0||s.referenceTarget===void 0,onClick:()=>{e.addToDsh()},children:o(`添加到 DSH`,`Add to DSH`)})]}),c&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-webchat-notice`,children:/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:qe(c,o)})}),(s.message!==void 0||s.pending!==void 0)&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-notice`,children:[s.message!==void 0&&/* @__PURE__ */ (0,i.jsx)(`p`,{role:`status`,children:qe(s.message,o)}),s.pending!==void 0&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-notice-actions`,children:[s.pending.reason===`login-required`&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,onClick:()=>{u(`chat`),e.resume()},children:o(`登录后继续`,`Continue after signing in`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:s.busy,onClick:()=>{e.cancelPending()},children:o(`取消待办`,`Cancel pending action`)})]})]}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-webchat-content`,children:[/* @__PURE__ */ (0,i.jsx)(`div`,{ref:w,className:`dsh-webchat-guest`,"aria-label":o(`DeepSeek 网页`,`DeepSeek website`),style:{display:l===`chat`?`flex`:`none`}}),/* @__PURE__ */ (0,i.jsxs)(`section`,{className:`dsh-webchat-history dsh-webchat-page`,"aria-label":o(`网页聊天历史`,`Web chat history`),style:{display:l===`history`?`block`:`none`},children:[/* @__PURE__ */ (0,i.jsx)(`h3`,{children:o(`最近打开的聊天`,`Recently opened chats`)}),/* @__PURE__ */ (0,i.jsx)(`p`,{className:`dsh-webchat-description`,children:o(`点击继续网页聊天。完整聊天记录仍保存在 DeepSeek 账号中。`,`Open a chat to continue. Full conversations remain saved in your DeepSeek account.`)}),s.history.length===0?/* @__PURE__ */ (0,i.jsx)(`p`,{className:`dsh-webchat-empty`,children:o(`还没有网页聊天历史。`,`No web chat history yet.`)}):/* @__PURE__ */ (0,i.jsx)(`ul`,{className:`dsh-webchat-history-list`,children:s.history.map(t=>/* @__PURE__ */ (0,i.jsx)(`li`,{children:/* @__PURE__ */ (0,i.jsxs)(`button`,{type:`button`,disabled:s.busy,"aria-current":s.currentUrl===t.url?`page`:void 0,onClick:()=>{u(`chat`),e.openHistory(t.url)},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-webchat-history-title`,children:t.title||`DeepSeek Chat`}),/* @__PURE__ */ (0,i.jsx)(`time`,{dateTime:new Date(t.updatedAt).toISOString(),children:new Date(t.updatedAt).toLocaleString(o(`zh-CN`,`en-US`),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]})},t.url))})]}),/* @__PURE__ */ (0,i.jsx)(`section`,{className:`dsh-webchat-page`,"aria-label":o(`更多详情提示词设置`,`More details prompt settings`),style:{display:l===`settings`?`block`:`none`},children:/* @__PURE__ */ (0,i.jsx)(ft,{locale:a,usePromptSettings:O,savePrompt:e=>n.set(`defaultPrompt`,e),resetPrompt:()=>n.unset(`defaultPrompt`)})})]})]})})}function gt({controller:e,locale:t,wide:n}){let{text:r}=N(t);return/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-launcher`,title:r(`新建 DeepSeek 网页聊天`,`New DeepSeek web chat`),"aria-label":r(`新建 Chat`,`New Chat`),onClick:()=>{e.newChat()},children:n?r(`+ 新建 Chat`,`+ New Chat`):`+`})}function _t({controller:e,locale:t,wide:n}){let{text:a}=N(t),o=(0,r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot);return!o.hasOpened||o.visible?null:/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-webchat-launcher`,title:a(`继续当前 DeepSeek 网页聊天`,`Continue the current DeepSeek web chat`),"aria-label":a(`继续聊天`,`Continue chat`),onClick:()=>{e.show()},children:n?a(`继续聊天`,`Continue chat`):/* @__PURE__ */ (0,i.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M13.5 7.5a5.5 5.5 0 0 1-5.5 5.5H3l-1.5 1V7.5A5.5 5.5 0 0 1 7 2h1a5.5 5.5 0 0 1 5.5 5.5Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`})})})}var vt=`.dsh-webchat-launcher {
1177
1177
  box-sizing: border-box;
1178
1178
  width: 100%;
1179
1179
  padding: 9px 12px;
@@ -1187,8 +1187,7 @@ window.__ModuleLoader__.load({id:`dsh-more-details`,factory:e=>{var t={exports:{
1187
1187
  }
1188
1188
  .dsh-webchat-launcher:hover { background: var(--dsw-alias-bg-layer-3, #f1f2f5); }
1189
1189
 
1190
- .dsh-webchat-panel,
1191
- .dsh-webchat-restore {
1190
+ .dsh-webchat-panel {
1192
1191
  --webchat-bg: var(--dsw-alias-bg-layer-2, #fff);
1193
1192
  --webchat-text: var(--dsw-alias-label-primary, #19191d);
1194
1193
  --webchat-muted: var(--dsw-alias-label-tertiary, #62636a);
@@ -1257,8 +1256,7 @@ window.__ModuleLoader__.load({id:`dsh-more-details`,factory:e=>{var t={exports:{
1257
1256
  border-bottom: 1px solid var(--webchat-border);
1258
1257
  }
1259
1258
 
1260
- .dsh-webchat-panel button,
1261
- .dsh-webchat-restore {
1259
+ .dsh-webchat-panel button {
1262
1260
  color: inherit;
1263
1261
  font: inherit;
1264
1262
  cursor: pointer;
@@ -1287,8 +1285,7 @@ window.__ModuleLoader__.load({id:`dsh-more-details`,factory:e=>{var t={exports:{
1287
1285
  color: var(--webchat-accent);
1288
1286
  }
1289
1287
  .dsh-webchat-panel button:disabled { opacity: .5; cursor: not-allowed; }
1290
- .dsh-webchat-panel button:focus-visible,
1291
- .dsh-webchat-restore:focus-visible {
1288
+ .dsh-webchat-panel button:focus-visible {
1292
1289
  outline: 2px solid var(--webchat-accent);
1293
1290
  outline-offset: 2px;
1294
1291
  }
@@ -1350,7 +1347,6 @@ window.__ModuleLoader__.load({id:`dsh-more-details`,factory:e=>{var t={exports:{
1350
1347
  }
1351
1348
  .dsh-webchat-history-title { max-width: 100%; overflow-wrap: anywhere; line-height: 1.5; }
1352
1349
  .dsh-webchat-history-list time { color: var(--webchat-muted); font-size: 12px; }
1353
- .dsh-webchat-restore { padding: 12px 18px; border-radius: 999px; }
1354
1350
 
1355
1351
  @media (max-width: 560px) {
1356
1352
  .dsh-webchat-panel {
@@ -1360,35 +1356,34 @@ window.__ModuleLoader__.load({id:`dsh-more-details`,factory:e=>{var t={exports:{
1360
1356
  bottom: 8px;
1361
1357
  }
1362
1358
  .dsh-webchat-header { flex-wrap: wrap; }
1363
- .dsh-webchat-restore { right: 12px; bottom: 12px; }
1364
1359
  }
1365
- `,vt=class{value;label;listeners=/* @__PURE__ */ new Set;disposed=!1;constructor(e,t){this.value=e,this.label=t}getSnapshot=()=>this.value;subscribe=e=>this.disposed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(e){if(!this.disposed){this.value=e;for(let e of this.listeners)try{e()}catch(e){console.error(`[${this.label}] subscriber threw`,e)}}}dispose(){this.disposed=!0,this.listeners.clear()}};let yt=16384;function bt(e){return new TextEncoder().encode(e).byteLength}function xt(e){return bt(e)<=yt}function St(e,t=240){let n=[...e];if(n.length<=t)return e;let r=Math.ceil(t*.65),i=t-r;return`${n.slice(0,r).join(``)}…${n.slice(-i).join(``)}`}var B=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`SelectionValidationError`}};function Ct(e){return e.replace(/\r\n?/gu,`
1360
+ `,yt=class{value;label;listeners=/* @__PURE__ */ new Set;disposed=!1;constructor(e,t){this.value=e,this.label=t}getSnapshot=()=>this.value;subscribe=e=>this.disposed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(e){if(!this.disposed){this.value=e;for(let e of this.listeners)try{e()}catch(e){console.error(`[${this.label}] subscriber threw`,e)}}}dispose(){this.disposed=!0,this.listeners.clear()}};let bt=16384;function xt(e){return new TextEncoder().encode(e).byteLength}function St(e){return xt(e)<=bt}function Ct(e,t=240){let n=[...e];if(n.length<=t)return e;let r=Math.ceil(t*.65),i=t-r;return`${n.slice(0,r).join(``)}…${n.slice(-i).join(``)}`}var B=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`SelectionValidationError`}};function wt(e){return e.replace(/\r\n?/gu,`
1366
1361
  `).replace(/\n(?:[\t ]*\n){3,}/gu,`
1367
1362
 
1368
1363
 
1369
- `).trim()}function wt(e){let t=e.fragments[0];if(t===void 0)throw new B(`selection_empty`,`Select some conversation text first.`);if(e.fragments.length!==1)throw new B(`selection_crosses_unsupported_nodes`,`Select text inside one completed message.`);let n=Ct(e.rawText);if(n.length===0)throw new B(`selection_empty`,`The selection contains only whitespace.`);if(bt(n)>16384)throw new B(`selection_too_large`,`The selected text is too large.`);if(!t.modelVisible||!t.settled)throw new B(`context_unavailable`,`Wait for this message to finish before opening Side Chat.`);if(!Number.isSafeInteger(t.seq)||t.seq<0)throw new B(`selection_stale`,`The selected message is no longer available.`);return Object.freeze({parentSessionId:e.parentSessionId,fragments:Object.freeze([{...t}]),text:n,atSeq:t.seq,rect:Object.freeze({...e.rect})})}function Tt(e,t){if(t!==e.parentSessionId)throw new B(`selection_stale`,`The parent conversation changed after selection.`)}let Et=Object.freeze({phase:`closed`,draft:``,messages:[]}),V=e=>({ok:!0,value:e}),H=e=>({ok:!1,error:e});function U(e,t=`invalid_request`,n=!1){return{code:t,message:e,recoverable:n}}var Dt=class{remote;sessions;observable=new vt(Et,`dsh-more-details`);generation=0;modelGeneration=0;requestSequence=0;disposed=!1;releaseParent;creating;closing;running;cancelling=!1;pendingRequest;constructor(e,t){this.remote=e,this.sessions=t}getSnapshot=()=>this.observable.getSnapshot();subscribe=e=>this.observable.subscribe(e);openDraft(e={}){if(this.disposed)return H(U(`Side Chat has been disposed.`));if(this.getSnapshot().phase!==`closed`)return H(U(`Close the current Side Chat first.`,`side_chat_already_open`));let t=e.parentSessionId??this.sessions.currentSessionId();if(t===void 0)return H(U(`Start the main conversation first.`,`parent_session_missing`));try{e.selection!==void 0&&Tt(e.selection,t),this.releaseParent=this.sessions.retainParent(t)}catch(e){return H(U(e instanceof Error?e.message:`The parent conversation is unavailable.`,`selection_stale`))}return++this.generation,this.observable.publish({phase:`draft`,parentSessionId:t,selection:e.selection,modelSelection:this.sessions.moreDetailsModelPreference(),draft:e.draft??``,messages:[]}),V(void 0)}setDraft(e){let t=this.getSnapshot();return![`draft`,`error`,`ready`].includes(t.phase)||t.messages.length>0||t.error?.operation===`close`?H(U(`The draft is not editable right now.`)):(this.observable.publish({...t,draft:e}),V(void 0))}clearSelection(){let e=this.getSnapshot();return e.chatId!==void 0||![`draft`,`error`].includes(e.phase)?H(U(`The selected context is already captured.`)):(this.observable.publish({...e,selection:void 0}),V(void 0))}initializeModel(e){let t=this.getSnapshot();return t.chatId!==void 0||![`draft`,`error`].includes(t.phase)?H(U(`The model cannot be initialized now.`)):(this.observable.publish({...t,modelSelection:{...e}}),V({...e}))}async selectModel(e){let t=this.getSnapshot();if(this.cancelling||![`draft`,`error`,`ready`,`running`].includes(t.phase)||t.error?.operation===`close`)return H(U(`The model cannot be changed while Side Chat is opening, stopping, or closing.`));if(t.chatId===void 0){let t=this.initializeModel(e);return t.ok&&this.sessions.rememberSideChatModelPreference(t.value),t}let n=this.generation,r=++this.modelGeneration,i=await this.invoke(()=>this.remote.selectModel({chatId:t.chatId,...e}));return i.ok?(n===this.generation&&r===this.modelGeneration&&(this.observable.publish({...this.getSnapshot(),modelSelection:i.value.selected}),this.sessions.rememberSideChatModelPreference(i.value.selected)),V(i.value.selected)):i}async sendFirst(e){let t=this.getSnapshot(),n=e.trim();if(n.length===0||t.parentSessionId===void 0||t.messages.length>0||![`draft`,`error`,`ready`].includes(t.phase)||t.error?.operation===`close`)return H(U(`Enter a question in an open Side Chat draft.`));if(t.chatId===void 0){if(t.selection!==void 0&&!this.sessions.selectionIsCurrent(t.selection))return this.fail(U(`Select the passage again before sending.`,`selection_stale`),`create`);let e=t.selection?.atSeq??this.sessions.lastCompletedSeq(t.parentSessionId);if(e===void 0)return this.fail(U(`Wait for a completed parent turn.`,`parent_session_not_ready`,!0),`create`);let r=this.generation;this.observable.publish({...t,phase:`creating`,draft:n,error:void 0});let i=this.invoke(()=>this.remote.create({parentSessionId:t.parentSessionId,atSeq:e,selectedText:t.selection?.text,modelSelection:t.modelSelection}));this.creating=i;let a=await i;if(this.creating===i&&(this.creating=void 0),r!==this.generation)return H(U(`The Side Chat was closed.`));if(!a.ok)return this.fail(a.error,`create`);this.observable.publish({...this.getSnapshot(),phase:`ready`,chatId:a.value.chatId,boundarySeq:a.value.boundarySeq,modelSelection:a.value.modelSelection,error:void 0}),this.sessions.rememberSideChatModelPreference(a.value.modelSelection)}return await this.send(n)}async send(e){let t=this.getSnapshot(),n=e.trim();if(n.length===0||t.chatId===void 0||this.running!==void 0||this.cancelling||![`ready`,`error`].includes(t.phase)||t.error?.operation===`close`)return H(U(`Wait for the current reply or stop it before sending.`));let r=this.pendingRequest?.chatId===t.chatId&&this.pendingRequest.text===n?this.pendingRequest:{chatId:t.chatId,requestId:`${t.chatId}:${++this.requestSequence}`,text:n};this.pendingRequest=r;let i;try{i=this.remote.stream(r)}catch(e){return this.fail(U(String(e),`transport_error`,!0),`prompt`)}let a={stream:i,generation:this.generation,request:r,cancelled:!1};return this.running=a,this.observable.publish({...t,phase:t.messages.length===0?`creating`:`running`,error:void 0}),await new Promise(e=>{a.done=this.consume(a,e)})}async cancel(){let e=this.getSnapshot().chatId;if(e===void 0||this.running===void 0)return V(void 0);this.cancelling=!0;let t=this.running;t.cancelled=!0,this.disposeStream(t.stream);try{let n=await this.invoke(()=>this.remote.cancel({chatId:e}));return await t.done,n.ok?V(void 0):n}finally{this.cancelling=!1}}async retry(){let e=this.getSnapshot();return e.error?.operation===`close`?await this.close():e.messages.length===0?await this.sendFirst(e.draft):this.pendingRequest===void 0?H(U(`An admitted question is never replayed automatically. Send a follow-up to continue.`)):await this.send(this.pendingRequest.text)}async close(){if(this.closing!==void 0)return await this.closing;if(this.getSnapshot().phase===`closed`)return V(void 0);let e=this.closeCurrent();this.closing=e;try{return await e}finally{this.closing===e&&(this.closing=void 0)}}async dispose(){if(!this.disposed){this.disposed=!0;try{let e=await this.close();e.ok||this.sessions.notify({kind:`warning`,text:e.error.message})}finally{this.running!==void 0&&this.disposeStream(this.running.stream),this.releaseParent?.(),this.releaseParent=void 0,this.observable.dispose()}}}async consume(e,t){let n=!1,r=!1,i=()=>e.generation===this.generation&&this.running===e,a=`${e.request.requestId}:assistant`;try{for await(let o of e.stream){if(!i())break;let s=this.getSnapshot();if(o.type===`started`){if(n||o.requestId!==e.request.requestId)throw Error(`Invalid Side Chat admission response.`);n=!0,this.pendingRequest=void 0,this.observable.publish({...s,phase:`running`,draft:``,messages:[...s.messages,{id:`${e.request.requestId}:user`,role:`user`,text:e.request.text,status:`complete`,selectedText:s.messages.length===0?s.selection?.text:void 0},{id:a,role:`assistant`,text:``,reasoning:``,status:`streaming`}],error:void 0}),t(V(void 0))}else if(o.type===`content`){if(!n)throw Error(`Side Chat content arrived before admission.`);this.observable.publish({...s,messages:s.messages.map(e=>e.id===a?{...e,text:o.text,reasoning:o.reasoning}:e)})}else if(o.type===`finished`){if(!n)throw Error(`Side Chat ended before admission.`);r=!0,this.observable.publish({...s,phase:`ready`,messages:s.messages.map(e=>e.id===a?{...e,status:o.status}:e)});break}else{r=!0;let e={...o.error,recoverable:!n&&o.error.recoverable};this.streamFailure(e,a),t(H(e));break}}if(i()&&!r&&!e.cancelled)throw Error(`The Side Chat connection ended before the reply completed.`)}catch(r){if(i()&&!e.cancelled){let e=U(r instanceof Error?r.message:String(r),`transport_error`,!n);this.streamFailure(e,a),t(H(e))}}finally{if(i()&&e.cancelled){this.pendingRequest=void 0;let e=this.getSnapshot();this.observable.publish({...e,phase:`ready`,error:void 0,messages:e.messages.map(e=>e.id===a?{...e,status:`stopped`}:e)})}this.disposeStream(e.stream),this.running===e&&(this.running=void 0),t(H(U(`The Side Chat was closed.`)))}}streamFailure(e,t){let n=this.getSnapshot();this.observable.publish({...n,phase:n.messages.length===0?`error`:`ready`,messages:n.messages.map(e=>e.id===t?{...e,status:`error`}:e),error:{...e,operation:`prompt`}})}async closeCurrent(){let e=this.getSnapshot(),t=this.creating;++this.generation,this.running!==void 0&&this.disposeStream(this.running.stream),this.running=void 0,this.observable.publish({...e,phase:`closing`,error:void 0});let n=e.chatId;if(t!==void 0){let e=await t;e.ok&&(n=e.value.chatId)}if(n!==void 0){let e=await this.invoke(()=>this.remote.close({chatId:n}));if(!e.ok&&e.error.code!==`side_chat_not_found`)return this.observable.publish({...this.getSnapshot(),phase:`error`,chatId:n,error:{...e.error,operation:`close`}}),e}return this.pendingRequest=void 0,this.releaseParent?.(),this.releaseParent=void 0,this.observable.publish(Et),V(void 0)}fail(e,t){return this.observable.publish({...this.getSnapshot(),phase:`error`,error:{...e,operation:t}}),H(e)}disposeStream(e){try{e.dispose()}catch{}}async invoke(e){try{return await e()}catch(e){return H(U(e instanceof Error?e.message:String(e),`transport_error`,!0))}}},Ot;/* @__NO_SIDE_EFFECTS__ */
1370
- function W(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var kt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(Ot=globalThis).__zod_globalConfig??(Ot.__zod_globalConfig={});let At=globalThis.__zod_globalConfig;function jt(e){return e&&Object.assign(At,e),At}function Mt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Nt(e,t){return typeof t==`bigint`?t.toString():t}function Pt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ft(e){return e==null}function It(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}let Lt=/* @__PURE__*/ Symbol(`evaluating`);function G(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Lt)return r===void 0&&(r=Lt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}let Rt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function zt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Bt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ht(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function K(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ut(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Wt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Gt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Kt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function qt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Jt(e){return typeof e==`string`?e:e?.message}function Yt(e,t,n){let r=e.message?e.message:Jt(e.inst?._zod.def?.error?.(e))??Jt(t?.error?.(e))??Jt(n.customError?.(e))??Jt(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Xt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Zt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let Qt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Nt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$t=/* @__PURE__ */ W(`$ZodError`,Qt),en=/* @__PURE__ */ W(`$ZodError`,Qt,{Parent:Error}),tn=/* @__PURE__*/ (e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new kt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Yt(e,a,jt())));throw Rt(t,i?.callee),t}return o.value})(en),nn=/* @__PURE__*/ (e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Yt(e,a,jt())));throw Rt(t,i?.callee),t}return o.value})(en),rn=/* @__PURE__*/ (e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new kt;return a.issues.length?{success:!1,error:new(e??$t)(a.issues.map(e=>Yt(e,i,jt())))}:{success:!0,data:a.value}})(en),an=/* @__PURE__*/ (e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Yt(e,i,jt())))}:{success:!0,data:a.value}})(en),on=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},sn=/^-?\d+$/,cn=/^-?\d+(?:\.\d+)?$/,ln=/^(?:true|false)$/i,un=/*@__PURE__*/ W(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),dn={number:`number`,bigint:`bigint`,object:`date`},fn=/*@__PURE__*/ W(`$ZodCheckGreaterThan`,(e,t)=>{un.init(e,t);let n=dn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pn=/*@__PURE__*/ W(`$ZodCheckNumberFormat`,(e,t)=>{un.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Wt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=sn)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/ W(`$ZodCheckMaxLength`,(e,t)=>{var n;un.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Xt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hn=/*@__PURE__*/ W(`$ZodCheckMinLength`,(e,t)=>{var n;un.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Xt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gn=/*@__PURE__*/ W(`$ZodCheckStringFormat`,(e,t)=>{var n,r;un.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_n=/*@__PURE__*/ W(`$ZodCheckRegex`,(e,t)=>{gn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vn={major:4,minor:4,patch:3},q=/*@__PURE__*/ W(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=vn;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Gt(e),i;for(let a of t){if(a._zod.def.when){if(Kt(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new kt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Gt(e,t))});else{if(e.issues.length===t)continue;r||=Gt(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Gt(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new kt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new kt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}G(e,`~standard`,()=>({validate:t=>{try{let n=rn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return an(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),yn=/*@__PURE__*/ W(`$ZodString`,(e,t)=>{q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??on(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),bn=/*@__PURE__*/ W(`$ZodNumber`,(e,t)=>{q.init(e,t),e._zod.pattern=e._zod.bag.pattern??cn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),xn=/*@__PURE__*/ W(`$ZodNumberFormat`,(e,t)=>{pn.init(e,t),bn.init(e,t)}),Sn=/*@__PURE__*/ W(`$ZodBoolean`,(e,t)=>{q.init(e,t),e._zod.pattern=ln,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Cn=/*@__PURE__*/ W(`$ZodNever`,(e,t)=>{q.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function wn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...qt(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Tn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Ut(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function En(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>wn(e,n,i,t,u,d))):wn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let Dn=/*@__PURE__*/ W(`$ZodObject`,(e,t)=>{if(q.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Pt(()=>Tn(t));G(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=zt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>wn(n,t,e,s,r,i))):wn(a,t,e,s,r,i)}return i?En(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}});function On(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Gt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Yt(e,r,jt())))}),t)}let kn=/*@__PURE__*/ W(`$ZodUnion`,(e,t)=>{q.init(e,t),G(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),G(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),G(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),G(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>It(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>On(t,r,e,i)):On(o,r,e,i)}}),An=/*@__PURE__*/ W(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,kn.init(e,t);let n=e._zod.parse;G(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=Pt(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!zt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),jn=/*@__PURE__*/ W(`$ZodEnum`,(e,t)=>{q.init(e,t);let n=Mt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Bt.has(typeof e)).map(e=>typeof e==`string`?Vt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Mn=/*@__PURE__*/ W(`$ZodLiteral`,(e,t)=>{if(q.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Vt(e):e?Vt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}});function Nn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let Pn=/*@__PURE__*/ W(`$ZodOptional`,(e,t)=>{q.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,G(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),G(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${It(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Nn(e,r)):Nn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Fn=/*@__PURE__*/ W(`$ZodNullable`,(e,t)=>{q.init(e,t),G(e._zod,`optin`,()=>t.innerType._zod.optin),G(e._zod,`optout`,()=>t.innerType._zod.optout),G(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${It(e.source)}|null)$`):void 0}),G(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),In=/*@__PURE__*/ W(`$ZodCustom`,(e,t)=>{un.init(e,t),q.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ln(t,n,r,e));Ln(i,n,r,e)}});function Ln(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Zt(e))}}// @__NO_SIDE_EFFECTS__
1371
- function Rn(e,t){return new e({type:`string`,...K(t)})}// @__NO_SIDE_EFFECTS__
1372
- function zn(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...K(t)})}// @__NO_SIDE_EFFECTS__
1373
- function Bn(e,t){return new e({type:`boolean`,...K(t)})}// @__NO_SIDE_EFFECTS__
1374
- function Vn(e,t){return new e({type:`never`,...K(t)})}// @__NO_SIDE_EFFECTS__
1375
- function Hn(e,t){return new fn({check:`greater_than`,...K(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
1376
- function Un(e){return/* @__PURE__ */ Hn(0,e)}// @__NO_SIDE_EFFECTS__
1377
- function Wn(e,t){return new mn({check:`max_length`,...K(t),maximum:e})}// @__NO_SIDE_EFFECTS__
1378
- function Gn(e,t){return new hn({check:`min_length`,...K(t),minimum:e})}// @__NO_SIDE_EFFECTS__
1379
- function Kn(e,t){return new _n({check:`string_format`,format:`regex`,...K(t),pattern:e})}// @__NO_SIDE_EFFECTS__
1380
- function qn(e,t,n){let r=K(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
1381
- function Jn(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...K(n)})}let J=/*@__PURE__*/ W(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);q.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>tn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>rn(e,t,n),e.parseAsync=async(t,n)=>nn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>an(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Ht(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Yn=/*@__PURE__*/ W(`ZodMiniString`,(e,t)=>{yn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1382
- function Y(e){return/* @__PURE__ */ Rn(Yn,e)}let Xn=/*@__PURE__*/ W(`ZodMiniNumber`,(e,t)=>{bn.init(e,t),J.init(e,t)}),Zn=/*@__PURE__*/ W(`ZodMiniNumberFormat`,(e,t)=>{xn.init(e,t),Xn.init(e,t)});// @__NO_SIDE_EFFECTS__
1383
- function Qn(e){return/* @__PURE__ */ zn(Zn,e)}let $n=/*@__PURE__*/ W(`ZodMiniBoolean`,(e,t)=>{Sn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1384
- function er(e){return/* @__PURE__ */ Bn($n,e)}let tr=/*@__PURE__*/ W(`ZodMiniNever`,(e,t)=>{Cn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1385
- function nr(e){return/* @__PURE__ */ Vn(tr,e)}let rr=/*@__PURE__*/ W(`ZodMiniObject`,(e,t)=>{Dn.init(e,t),J.init(e,t),G(e,`shape`,()=>t.shape)});// @__NO_SIDE_EFFECTS__
1386
- function X(e,t){return new rr({type:`object`,shape:e,catchall:/* @__PURE__ */ nr(),...K(t)})}let ir=/*@__PURE__*/ W(`ZodMiniDiscriminatedUnion`,(e,t)=>{An.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1387
- function ar(e,t,n){return new ir({type:`union`,options:t,discriminator:e,...K(n)})}let or=/*@__PURE__*/ W(`ZodMiniEnum`,(e,t)=>{jn.init(e,t),J.init(e,t),e.options=Object.values(t.entries)});// @__NO_SIDE_EFFECTS__
1388
- function sr(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new or({type:`enum`,entries:n,...K(t)})}let cr=/*@__PURE__*/ W(`ZodMiniLiteral`,(e,t)=>{Mn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1389
- function Z(e,t){return new cr({type:`literal`,values:Array.isArray(e)?e:[e],...K(t)})}let lr=/*@__PURE__*/ W(`ZodMiniOptional`,(e,t)=>{Pn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1390
- function ur(e){return new lr({type:`optional`,innerType:e})}let dr=/*@__PURE__*/ W(`ZodMiniNullable`,(e,t)=>{Fn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1391
- function fr(e){return new dr({type:`nullable`,innerType:e})}let pr=/*@__PURE__*/ W(`ZodMiniCustom`,(e,t)=>{In.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1392
- function mr(e,t){return/* @__PURE__ */ qn(pr,e??(()=>!0),t)}// @__NO_SIDE_EFFECTS__
1393
- function hr(e,t={}){return/* @__PURE__ */ Jn(pr,e,t)}let gr=[`selection_empty`,`selection_outside_conversation`,`selection_not_model_visible`,`selection_too_large`,`selection_stale`,`selection_crosses_unsupported_nodes`,`parent_session_missing`,`parent_session_not_ready`,`context_unavailable`,`context_too_large`,`side_chat_already_open`,`side_chat_not_found`,`side_chat_prompt_failed`,`side_chat_model_failed`,`side_chat_interrupt_failed`,`side_chat_destroy_failed`,`transport_error`,`invalid_request`,`internal_error`],Q=(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Gn(1),/* @__PURE__ */ Wn(512)),_r=/* @__PURE__ */ X({provider:Q,model:Q,reasoningEffort:/* @__PURE__ */ ur(Q)}),vr=/* @__PURE__ */ X({code:/* @__PURE__ */ sr(gr),message:/* @__PURE__ */ Y(),recoverable:/* @__PURE__ */ er()}),yr=/* @__PURE__ */ X({parentSessionId:Q,atSeq:(/* @__PURE__ */ Qn()).check(/* @__PURE__ */ Un()),selectedText:/* @__PURE__ */ ur((/* @__PURE__ */ Y()).check(/* @__PURE__ */ Wn(16384))),modelSelection:/* @__PURE__ */ ur(_r)}),br=/* @__PURE__ */ X({parentSessionId:Q,atSeq:(/* @__PURE__ */ Qn()).check(/* @__PURE__ */ Un()),selectedText:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ hr(e=>/\S/u.test(e),`Select some conversation text first.`),/* @__PURE__ */ hr(e=>new TextEncoder().encode(e).length<=yt,`The selected text is too large.`))}),xr=/* @__PURE__ */ X({chatId:Q}),Sr=/* @__PURE__ */ X({chatId:Q,provider:Q,model:Q,reasoningEffort:/* @__PURE__ */ ur(Q)}),Cr=/* @__PURE__ */ X({chatId:Q,requestId:Q,text:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Gn(1),/* @__PURE__ */ Wn(65536))});function wr(e){return/* @__PURE__ */ ar(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:e}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:vr})])}let Tr=wr(/* @__PURE__ */ X({parentSessionId:Q,chatId:Q,boundarySeq:(/* @__PURE__ */ Qn()).check(/* @__PURE__ */ Un()),modelSelection:_r})),Er=wr(/* @__PURE__ */ X({prompt:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Gn(1))})),Dr=wr(/* @__PURE__ */ X({selected:_r})),Or=wr(/* @__PURE__ */ X({closed:/* @__PURE__ */ Z(!0)})),kr=wr(/* @__PURE__ */ X({cancelled:/* @__PURE__ */ Z(!0)})),Ar=/* @__PURE__ */ ar(`type`,[/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`started`),requestId:Q,modelSelection:_r}),/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`content`),text:/* @__PURE__ */ Y(),reasoning:/* @__PURE__ */ Y()}),/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`finished`),status:/* @__PURE__ */ sr([`complete`,`stopped`])}),/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`error`),error:vr})]),jr=/* @__PURE__ */ mr(ve,`网页讨论快照格式无效。`),Mr=/* @__PURE__ */ mr(ye,`网页讨论引用格式无效。`),Nr=/* @__PURE__ */ X({sessionId:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Gn(1)),capture:jr}),Pr=/* @__PURE__ */ X({sessionId:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Gn(1)),referenceId:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Kn(/^sha256:[a-f0-9]{64}$/u))}),Fr=/* @__PURE__ */ ar(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:/* @__PURE__ */ X({reference:Mr})}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:vr})]),Ir=/* @__PURE__ */ ar(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:/* @__PURE__ */ X({reference:Mr,capture:jr})}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:vr})]);function Lr(e){return/* @__PURE__ */ mr(t=>e.safeParse(t).success,`网页登录数据格式无效。`)}function Rr(e){return Lr(/* @__PURE__ */ ar(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:e}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:vr})]))}let zr=/* @__PURE__ */ mr(rt,`网页登录数据格式无效。`),Br=Lr(/* @__PURE__ */ X({})),Vr=Lr(/* @__PURE__ */ X({state:zr})),Hr=Rr(/* @__PURE__ */ X({state:/* @__PURE__ */ fr(zr)})),Ur=Rr(/* @__PURE__ */ X({saved:/* @__PURE__ */ Z(!0)})),Wr=Rr(/* @__PURE__ */ X({cleared:/* @__PURE__ */ Z(!0)}));function $(e,t,n,r,i,a={}){return{id:`dsh-more-details#moreDetails/${e}`,service:`moreDetails`,namespace:`moreDetails`,method:e,implementation:e,invocation:{kind:`direct`},...a.stream?{mode:`stream`}:{},...a.cancellation?{cancellation:{parameter:`signal`}}:{},parameters:[{name:`request`,wire:`request`,source:`json`,codec:{mode:`strict`,typeSymbol:`dsh-more-details/remote#${t}`,create:()=>r}}],result:{mode:`strict`,typeSymbol:`dsh-more-details/remote#${n}`,create:()=>i},sourceLocation:{file:`src/index.ts`,line:1,column:1}}}let Gr={package:`dsh-more-details`,descriptors:[$(`saveWebChatReference`,`SaveWebChatReferenceRequest`,`SaveWebChatReferenceResult`,Nr,Fr,{cancellation:!0}),$(`readWebChatReference`,`ReadWebChatReferenceRequest`,`ReadWebChatReferenceResult`,Pr,Ir,{cancellation:!0}),$(`readWebChatLogin`,`WebChatLoginRequest`,`ReadWebChatLoginResult`,Br,Hr),$(`saveWebChatLogin`,`SaveWebChatLoginRequest`,`SaveWebChatLoginResult`,Vr,Ur),$(`clearWebChatLogin`,`WebChatLoginRequest`,`ClearWebChatLoginResult`,Br,Wr),$(`prepareDetails`,`PrepareDetailsRequest`,`PrepareDetailsResult`,br,Er,{cancellation:!0}),$(`create`,`CreateSideChatRequest`,`CreateResult`,yr,Tr,{cancellation:!0}),$(`selectModel`,`SelectSideChatModelRequest`,`SelectModelResult`,Sr,Dr,{cancellation:!0}),$(`stream`,`SendSideChatRequest`,`SideChatStreamEvent`,Cr,Ar,{stream:!0,cancellation:!0}),$(`cancel`,`ChatRequest`,`CancelResult`,xr,kr),$(`close`,`ChatRequest`,`CloseResult`,xr,Or)]};function Kr(e){let t=e.code,n=t===`bad-request`||t===`gateway/bad-request`;return{code:n?`invalid_request`:`transport_error`,message:e.message||`The Side Chat RPC failed.`,recoverable:!n}}async function qr(e){let t=await e;return t.ok?t.value:{ok:!1,error:Kr(t.error)}}async function Jr(e,t){try{let t=await e;if(t.ok&&t.value.ok)return t.value.value}catch{}throw Error(t)}async function Yr(e){let t=await e.remote.$mount(Gr),n=e.get(`remote.moreDetails`);return{prepareDetails:e=>qr(n.prepareDetails(e)),saveWebChatReference:e=>qr(n.saveWebChatReference(e)),loginStore:{read:async()=>(await Jr(n.readWebChatLogin({}),`无法读取已保存的网页登录状态。`)).state,save:async e=>{await Jr(n.saveWebChatLogin({state:e}),`无法保存网页登录状态。`)},clear:async()=>{await Jr(n.clearWebChatLogin({}),`无法清除已保存的网页登录状态。`)}},remote:{create:e=>qr(n.create(e)),selectModel:e=>qr(n.selectModel(e)),stream:e=>n.stream(e),cancel:e=>qr(n.cancel(e)),close:e=>qr(n.close(e))},dispose:t}}let Xr={en:{selectModel:`Select model`,menu:`Model and reasoning effort`,model:`Model`,effort:`Effort`,providerDefault:`Default`,loading:`Refreshing model list…`,reload:`Reload`,emptyModels:`No models available.`,emptyEfforts:`This model provides no reasoning effort levels.`,nextReply:`Changes apply to the next reply and future Side Chats.`,aria:(e,t)=>t===void 0?`Select model, current ${e}`:`Select model, current ${e}, reasoning effort ${t}`,operationFailed:e=>`Model operation failed: ${e}`,groupFailed:(e,t)=>`${e} failed to load: ${t}`},"zh-CN":{selectModel:`选择模型`,menu:`模型与推理等级`,model:`模型`,effort:`推理等级`,providerDefault:`Default`,loading:`正在刷新模型列表…`,reload:`重新加载`,emptyModels:`没有可用的模型。`,emptyEfforts:`当前模型未提供推理等级。`,nextReply:`修改将用于下一次回复及之后新开的侧边对话。`,aria:(e,t)=>t===void 0?`选择模型,当前 ${e}`:`选择模型,当前 ${e},推理等级 ${t}`,operationFailed:e=>`模型操作失败:${e}`,groupFailed:(e,t)=>`${e} 加载失败:${t}`}};function Zr(e,t,n){return e?.provider===t&&e.model===n}function Qr(e,t){return e.provider===t.provider&&e.model===t.model&&e.reasoningEffort===t.reasoningEffort}function $r(e,t,n){let r=t.find(t=>Zr(e,t.group.id,t.model.id));if(r===void 0)return n;let i=r.model.reasoning;return i===void 0?{provider:e.provider,model:e.model}:e.reasoningEffort===void 0||i.efforts.some(t=>t.id===e.reasoningEffort)?e:{provider:e.provider,model:e.model,...i.defaultEffort===void 0?{}:{reasoningEffort:i.defaultEffort}}}function ei({directory:e,selection:t,locked:n,running:o=!1,validateInitialSelection:s=!0,locale:c=`en`,onInitialize:l,onSelect:u}){let d=Xr[c],f=(0,r.useSyncExternalStore)(t=>e.store.subscribe(t),()=>e.store.getSnapshot(),()=>e.store.getSnapshot()),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(`root`),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),x=(0,r.useRef)(null),S=(0,r.useRef)(null),C=(0,r.useRef)([]),w=(0,r.useRef)(!1),T=(0,r.useRef)(0),E=(0,r.useRef)(0),D=(0,r.useRef)(!1),O=(0,r.useId)(),k=(0,r.useMemo)(()=>f.groups.flatMap(e=>e.models.map(t=>({group:e,model:t}))),[f.groups]),A=t??f.current??void 0,j=k.find(e=>Zr(A,e.group.id,e.model.id)),M=j?.model.reasoning,N=A?.reasoningEffort??M?.defaultEffort,P=M===void 0?void 0:N===void 0?d.providerDefault:M.efforts.find(e=>e.id===N)?.name??N,F=(0,r.useMemo)(()=>M===void 0?[]:[...M.defaultEffort===void 0?[{key:`provider-default`,effort:void 0,label:d.providerDefault}]:[],...M.efforts.map(e=>({key:`effort:${e.id}`,effort:e.id,label:e.name,...e.description===void 0?{}:{description:e.description}}))],[d.providerDefault,M]),I=j?.model.name??A?.model??d.selectModel,ee=P===void 0?I:`${I} · ${P}`,L=()=>{e.load().catch(()=>void 0)};(0,r.useEffect)(()=>(w.current=!1,L(),()=>{++T.current}),[e]),(0,r.useEffect)(()=>{n&&m(!1)},[n]),(0,r.useEffect)(()=>{if(w.current||n)return;if(t!==void 0&&!s){w.current=!0;return}if(f.current===null)return;let e={provider:f.current.provider,model:f.current.model,...f.current.reasoningEffort===void 0?{}:{reasoningEffort:f.current.reasoningEffort}};if(t===void 0){w.current=!0,l(e,{remember:!1});return}if(f.status!==`ready`||f.error!==null||f.failures.length>0)return;w.current=!0;let r=$r(t,k,e);Qr(t,r)||l(r,{remember:!0})},[k,n,l,t,f.current,f.status,f.error,f.failures,s]),(0,r.useEffect)(()=>{if(!p)return;let e=e=>{x.current?.contains(e.target)||m(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[p]);let te=()=>{g(`root`),m(!0),L()},R=(e=!1)=>{m(!1),g(`root`),e&&queueMicrotask(()=>{S.current?.focus()})},ne=e=>{let t=C.current.filter(e=>e!==null);if(t.length===0)return;let n=t.findIndex(e=>e===document.activeElement);t[(Math.max(n,0)+e+t.length)%t.length]?.focus()},re=e=>{e.key===`Escape`&&p?(e.preventDefault(),e.stopPropagation(),h===`root`?R(!0):g(`root`)):!p||e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),ne(e.key===`ArrowDown`?1:-1))},ie=e=>{e.relatedTarget instanceof Node&&x.current?.contains(e.relatedTarget)||R()},ae=async e=>{if(n||D.current)return;let t=++T.current;D.current=!0,v(!0);try{let n=await u(e);if(t!==T.current)return;if(!n.ok)throw Error(n.error.message);R(!0)}catch(e){if(t!==T.current)return;b({seq:++E.current,text:d.operationFailed(e instanceof Error?e.message:`Could not select the model.`)})}finally{D.current=!1,t===T.current&&v(!1)}},oe=(e,t)=>{Zr(A,e.id,t.id)?R(!0):ae({provider:e.id,model:t.id,...t.reasoning?.defaultEffort===void 0?{}:{reasoningEffort:t.reasoning.defaultEffort}})},se=e=>{A!==void 0&&ae({provider:A.provider,model:A.model,...e===void 0?{}:{reasoningEffort:e}})};C.current=[];let ce=0,le=()=>{let e=ce++;return t=>{C.current[e]=t}};return/* @__PURE__ */ (0,i.jsxs)(`div`,{ref:x,className:`dsh-more-details-model-root`,"data-side-chat-model-select":``,onKeyDown:re,onBlur:ie,children:[/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:S,type:`button`,className:`dsh-more-details-model-trigger`,"aria-label":d.aria(I,P),"aria-haspopup":`menu`,"aria-expanded":p,"aria-controls":p?`${O}-menu`:void 0,title:ee,disabled:n,onClick:()=>{p?R():te()},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-trigger-label`,children:I}),P!==void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-trigger-effort`,children:P}),/* @__PURE__ */ (0,i.jsx)(a.IconChevronDownOutlineRegular,{className:`dsh-more-details-model-chevron${p?` dsh-more-details-model-chevron-open`:``}`})]}),p&&/* @__PURE__ */ (0,i.jsxs)(`div`,{id:`${O}-menu`,className:`dsh-more-details-model-menu`,role:`menu`,"aria-label":d.menu,"aria-busy":f.status===`loading`||_,children:[o&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-status`,children:d.nextReply}),h===`root`&&/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitem`,className:`dsh-more-details-model-cell`,onClick:()=>{g(`model`)},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-label`,children:d.model}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-value`,children:I}),/* @__PURE__ */ (0,i.jsx)(a.IconChevronRightOutlineRegular,{className:`dsh-more-details-model-cell-chevron`})]}),M!==void 0&&/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitem`,className:`dsh-more-details-model-cell`,onClick:()=>{g(`effort`)},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-label`,children:d.effort}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-value`,children:P}),/* @__PURE__ */ (0,i.jsx)(a.IconChevronRightOutlineRegular,{className:`dsh-more-details-model-cell-chevron`})]})]}),h===`model`&&/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[f.status===`loading`&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-status`,children:d.loading}),f.error!==null&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-model-error`,role:`alert`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{children:d.operationFailed(f.error)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-model-retry`,onClick:L,children:d.reload})]}),f.failures.map(e=>/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-model-warning`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{children:d.groupFailed(e.name,e.message)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-model-retry`,onClick:L,children:d.reload})]},e.id)),/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-groups scrollable`,children:f.groups.map(e=>{let t=`${O}-${e.id}`;return/* @__PURE__ */ (0,i.jsxs)(`section`,{role:`group`,"aria-labelledby":t,className:`dsh-more-details-model-group`,children:[/* @__PURE__ */ (0,i.jsx)(`div`,{id:t,className:`dsh-more-details-model-group-title`,children:e.name}),e.models.map(t=>{let r=Zr(A,e.id,t.id);return/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitemradio`,"aria-checked":r,className:`dsh-more-details-model-option${r?` dsh-more-details-model-selected`:``}`,title:t.name,disabled:n||_,onClick:()=>{oe(e,t)},children:[/* @__PURE__ */ (0,i.jsxs)(`span`,{className:`dsh-more-details-model-option-copy`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-name`,children:t.name}),t.description!==void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-description`,children:t.description})]}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-check`,children:r?/* @__PURE__ */ (0,i.jsx)(a.IconCheckOutlineRegular,{}):null})]},t.id)})]},e.id)})}),f.status===`ready`&&k.length===0&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-empty`,children:d.emptyModels})]}),h===`effort`&&(F.length===0?/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-empty`,children:d.emptyEfforts}):F.map(e=>{let t=N===e.effort;return/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitemradio`,"aria-checked":t,className:`dsh-more-details-model-option${t?` dsh-more-details-model-selected`:``}`,disabled:n||_,onClick:()=>{se(e.effort)},children:[/* @__PURE__ */ (0,i.jsxs)(`span`,{className:`dsh-more-details-model-option-copy`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-name`,children:e.label}),e.description!==void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-description`,children:e.description})]}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-check`,children:t?/* @__PURE__ */ (0,i.jsx)(a.IconCheckOutlineRegular,{}):null})]},e.key)}))]}),y!==null&&/* @__PURE__ */ (0,i.jsx)(a.Toast,{text:y.text,icon:/* @__PURE__ */ (0,i.jsx)(a.IconWarningOutlineRegular,{}),anchor:x.current?.closest(`[data-composer-card]`)??null,onDone:()=>{b(null)}},y.seq)]})}function ti(){return/* @__PURE__ */ (0,i.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z`,fill:`currentColor`})})}function ni({children:e}){return/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-body`,children:e})}function ri({error:e,messages:t,onRetry:n}){return/* @__PURE__ */ (0,i.jsxs)(`section`,{className:`dsh-more-details-error`,role:`alert`,children:[/* @__PURE__ */ (0,i.jsx)(`strong`,{children:e.operation===`close`?t.closeError:t.genericError}),/* @__PURE__ */ (0,i.jsx)(`p`,{children:e.message}),e.recoverable&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onClick:n,children:t.retry})]})}function ii(){return/* @__PURE__ */ (0,i.jsxs)(`svg`,{className:`dsh-more-details-add-to-conversation-icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M4.25 4.5h11.5v8.25H9l-3.5 2.75v-2.75H4.25z`}),/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M10 6.5v4M8 8.5h4`})]})}function ai({phase:e,messages:t,addToConversationDisabled:n=!1,onAddToConversation:r,onFocusParent:a,onClose:o}){return/* @__PURE__ */ (0,i.jsxs)(`header`,{className:`dsh-more-details-header`,children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-heading`,onClick:a,children:/* @__PURE__ */ (0,i.jsx)(`strong`,{children:t.title})}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-header-actions`,children:[r!==void 0&&/* @__PURE__ */ (0,i.jsxs)(`button`,{type:`button`,className:`dsh-more-details-add-to-conversation`,disabled:n,onClick:r,children:[/* @__PURE__ */ (0,i.jsx)(ii,{}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:t.addToConversation})]}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-close`,"aria-label":t.close,disabled:e===`closing`,onClick:o,children:`×`})]})]})}function oi(e){let t=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=t.current;if(e===null)return;e.style.height=`auto`;let n=Number.parseFloat(getComputedStyle(e).maxHeight),r=Number.isFinite(n)?Math.min(e.scrollHeight,n):e.scrollHeight;e.style.height=`${String(r)}px`,e.style.overflowY=Number.isFinite(n)&&e.scrollHeight>n?`auto`:`hidden`},[e]),t}function si({state:e,locale:t=`en`,embeddedConversation:n,modelControl:a,onDraftChange:o,onFirstSend:s,onClose:c,onRetry:l,onFocusParent:u,onAddToConversation:d,addToConversationDisabled:f,onRemoveSelection:p}){let m=F[t],[h,g]=(0,r.useState)(!1),_=oi(e.draft),v=async t=>{if(t.preventDefault(),!(h||[`creating`,`running`,`closing`].includes(e.phase))){g(!0);try{await s(e.draft)}finally{g(!1)}}};return/* @__PURE__ */ (0,i.jsxs)(`aside`,{className:`dsh-more-details-panel`,"data-side-chat-panel":``,"aria-label":m.title,"aria-busy":[`creating`,`closing`].includes(e.phase)||void 0,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),c())},children:[/* @__PURE__ */ (0,i.jsx)(ai,{phase:e.phase,messages:m,...d===void 0?{}:{onAddToConversation:d},...f===void 0?{}:{addToConversationDisabled:f},onFocusParent:u,onClose:()=>{c()}}),e.error!==void 0&&/* @__PURE__ */ (0,i.jsx)(ri,{error:e.error,messages:m,onRetry:()=>{l()}}),e.messages.length>0&&n!==void 0?/* @__PURE__ */ (0,i.jsx)(ni,{children:n}):/* @__PURE__ */ (0,i.jsxs)(`form`,{className:`dsh-more-details-draft`,"data-composer-card":``,onSubmit:e=>{v(e)},children:[e.selection!==void 0&&/* @__PURE__ */ (0,i.jsx)(I,{selections:[e.selection],messages:m,...p===void 0?{}:{onRemove:p}}),/* @__PURE__ */ (0,i.jsx)(`label`,{htmlFor:`dsh-more-details-draft-input`,children:m.placeholder}),/* @__PURE__ */ (0,i.jsx)(`textarea`,{id:`dsh-more-details-draft-input`,ref:_,autoFocus:!0,rows:1,value:e.draft,disabled:[`creating`,`running`,`closing`].includes(e.phase),placeholder:m.placeholder,onChange:e=>{o(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-draft-actions`,children:[a,/* @__PURE__ */ (0,i.jsx)(`button`,{type:`submit`,className:`dsh-more-details-send-button`,"aria-label":m.send,disabled:h||[`creating`,`running`,`closing`].includes(e.phase)||e.draft.trim().length===0,children:/* @__PURE__ */ (0,i.jsx)(ti,{})})]})]}),/* @__PURE__ */ (0,i.jsxs)(`footer`,{className:`dsh-more-details-footer`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.temporary}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.referenceOnly}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.cannotReopen}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.readOnly})]}),/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-announcer`,"aria-live":`polite`,children:e.phase===`running`?`Side Chat running`:`Side Chat ${e.phase}`})]})}function ci(e){return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[data-chat-anchor-key]`)??null}function li(e,t){let n=e.parentElement;return n===null||!t.contains(n)||n.closest(`[data-selection-exclude],[data-side-chat-panel],[aria-hidden="true"],[hidden],[inert],script,style,button,textarea,input,[role="button"]`)!==null}function ui(e,t){let n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=r.nextNode();for(;i!==null;){let a=i;!li(a,t)&&ci(a)===e&&n.push(a),i=r.nextNode()}return n}function di(e,t){if(!e.intersectsNode(t))return;let n=e.startContainer===t?e.startOffset:0,r=e.endContainer===t?e.endOffset:t.data.length;if(n>0&&/[\uDC00-\uDFFF]/u.test(t.data[n]??``)&&/[\uD800-\uDBFF]/u.test(t.data[n-1]??``)&&--n,r>0&&r<t.data.length&&/[\uD800-\uDBFF]/u.test(t.data[r-1]??``)&&/[\uDC00-\uDFFF]/u.test(t.data[r]??``)&&(r+=1),!(r<=n))return{start:n,end:r,text:t.data.slice(n,r)}}async function fi(e){let t=e.selection?.rangeCount===1?e.selection.getRangeAt(0):void 0;if(t===void 0||t.collapsed)throw new B(`selection_empty`,`Select some conversation text first.`);if(!e.conversationRoot.contains(t.startContainer)||!e.conversationRoot.contains(t.endContainer))throw new B(`selection_outside_conversation`,`The selection must stay inside the current conversation.`);let n=ci(t.startContainer),r=ci(t.endContainer);if(n===null||r===null||n!==r)throw new B(`selection_crosses_unsupported_nodes`,`Select a passage inside one message.`);let i=e.resolver.resolve(n);if(i===void 0)throw new B(`selection_stale`,`The selected message is no longer in the Session snapshot.`);let a=ui(n,e.conversationRoot),o=[],s,c,l=0;for(let e of a){let n=di(t,e);n!==void 0&&(s??=l+n.start,c=l+n.end,o.push(n.text)),l+=e.data.length}if(s===void 0||c===void 0)throw new B(`selection_not_model_visible`,`The selection contains no supported visible text.`);let u=t.getBoundingClientRect();return await wt({parentSessionId:e.parentSessionId,fragments:[{...i,startOffset:s,endOffset:c,text:o.join(``)}],rawText:o.join(``),rect:{x:u.x,y:u.y,width:u.width,height:u.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}})}function pi(e,t){return[...e.querySelectorAll(`[data-chat-anchor-key]`)].find(e=>e.dataset.chatAnchorKey===t)}function mi(e,t){let n=pi(e,t.nodeKey);if(n===void 0)return;let r=ui(n,e),i=r.map(e=>e.data).join(``);if(!Number.isSafeInteger(t.startOffset)||!Number.isSafeInteger(t.endOffset)||t.startOffset<0||t.endOffset<=t.startOffset||t.endOffset>i.length||i.slice(t.startOffset,t.endOffset)!==t.text)return;let a=[],o=0;for(let e of r){let n=o+e.data.length,r=Math.max(t.startOffset,o)-o,i=Math.min(t.endOffset,n)-o;if(i>r){let t=document.createRange();t.setStart(e,r),t.setEnd(e,i),a.push(t)}if(o=n,o>=t.endOffset)break}return a.length===0?void 0:a}function hi(e){let t=[];for(let n of e.selection.fragments){let r=mi(e.conversationRoot,n);if(r===void 0)return;t.push(...r)}let n=t[0],r=t.at(-1);if(n===void 0||r===void 0)return;let i=document.createRange();return i.setStart(n.startContainer,n.startOffset),i.setEnd(r.endContainer,r.endOffset),{ranges:t,browserRange:i}}function gi(e){return[...document.querySelectorAll(`[data-conversation-session]`)].find(t=>t.dataset.conversationSession===e&&t.closest(`[data-side-chat-panel], [hidden], [aria-hidden="true"]`)===null)}function _i(e){return gi(e)?.querySelector(`[data-chat-flow]`)??void 0}function vi(e){window.requestAnimationFrame(()=>{let t=gi(e)?.querySelector(`[data-composer-seat] textarea, [data-composer-seat] [role="textbox"], [data-composer-seat] [contenteditable="true"]`);t!=null&&(t.focus(),t instanceof HTMLTextAreaElement&&t.setSelectionRange(t.value.length,t.value.length))})}let yi=`dsh-more-details-annotations`,bi=`dsh-more-details-active-annotation`;function xi(e,t,n){return Math.min(Math.max(t,e),Math.max(t,n))}function Si(e){let t=Number.isFinite(e.left)?e.left:e.x,n=Number.isFinite(e.top)?e.top:e.y,r=Number.isFinite(e.right)?e.right:t+e.width,i=Number.isFinite(e.bottom)?e.bottom:n+e.height;return[t,n,r,i].every(Number.isFinite)?{left:t,top:n,right:r,bottom:i}:void 0}function Ci(e){let t=[];for(let n of e){let e=typeof n.getClientRects==`function`?[...n.getClientRects()]:[],r=e.length>0?e:typeof n.getBoundingClientRect==`function`?[n.getBoundingClientRect()]:[];for(let e of r){let n=Si(e);n!==void 0&&(n.right>n.left||n.bottom>n.top)&&t.push(n)}}if(t.length!==0)return{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top)),right:Math.max(...t.map(e=>e.right)),bottom:Math.max(...t.map(e=>e.bottom))}}function wi(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function Ti(e){let t={left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},n=e.startContainer,r=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(`[data-conversation-scroll]`);if(r==null)return t;let i=Si(r.getBoundingClientRect());i!==void 0&&i.right>i.left&&i.bottom>i.top&&(t={left:Math.max(t.left,i.left),top:Math.max(t.top,i.top),right:Math.min(t.right,i.right),bottom:Math.min(t.bottom,i.bottom)});let a=r.querySelector(`[data-composer-seat]`),o=a===null?void 0:Si(a.getBoundingClientRect());return o!==void 0&&o.right>o.left&&o.bottom>o.top&&o.bottom>t.top&&o.top<t.bottom&&(t={...t,bottom:Math.min(t.bottom,o.top)}),t}function Ei(e,t){return e.right>t.left&&e.bottom>t.top&&e.left<t.right&&e.top<t.bottom}function Di(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!==void 0&&r.annotationIndex===e.annotationIndex&&r.left===e.left&&r.top===e.top})}function Oi(){typeof CSS<`u`&&CSS.highlights!==void 0&&(CSS.highlights.delete(yi),CSS.highlights.delete(bi))}function ki(e,t){if(typeof CSS>`u`||CSS.highlights===void 0||typeof Highlight>`u`)return;if(CSS.highlights.set(yi,new Highlight(...e)),t.length===0){CSS.highlights.delete(bi);return}let n=new Highlight(...t);n.priority=1,CSS.highlights.set(bi,n)}function Ai(e){let t=window.getSelection();t!==null&&(t.removeAllRanges(),t.addRange(e))}function ji({annotations:e,activeAnnotationIndex:t,onEdit:n}){let a=(0,r.useRef)(/* @__PURE__ */ new Map),[o,s]=(0,r.useState)([]);return(0,r.useEffect)(()=>{if(e.length===0){a.current.clear(),s(e=>e.length===0?e:[]),Oi();return}let n,r=null,i,o=()=>{n=void 0;let o=e[0]?.selection.parentSessionId,c=o===void 0?null:_i(o)??null;c!==r&&(i?.disconnect(),r=c,c!==null&&i?.observe(c));let l=/* @__PURE__ */ new Map,u=[],d=[],f=[];if(c!==null)for(let n of e){if(n.selection.parentSessionId!==o)continue;let e=hi({selection:n.selection,conversationRoot:c});if(e===void 0)continue;d.push(...e.ranges),n.annotationIndex===t&&f.push(...e.ranges);let r=Ci(e.ranges),i=Ti(e.browserRange);if(r===void 0||!Ei(r,i))continue;let a=wi(r);l.set(n.annotationIndex,{browserRange:e.browserRange,rect:a}),u.push({annotationIndex:n.annotationIndex,left:xi(r.right+3,i.left+4,i.right-26),top:xi(r.top-12,i.top+4,i.bottom-26)})}a.current=l,s(e=>Di(e,u)?e:u),ki(d,f)},c=()=>{n===void 0&&(n=window.requestAnimationFrame(o))};i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(c),o();let l=new MutationObserver(c);return l.observe(document.body,{childList:!0,characterData:!0,subtree:!0}),document.addEventListener(`scroll`,c,!0),window.addEventListener(`resize`,c),()=>{n!==void 0&&window.cancelAnimationFrame(n),l?.disconnect(),i?.disconnect(),document.removeEventListener(`scroll`,c,!0),window.removeEventListener(`resize`,c),Oi()}},[t,e]),o.map(r=>{let o=e.find(e=>e.annotationIndex===r.annotationIndex);if(o===void 0)return null;let s={left:r.left,top:r.top},c=o.annotationIndex+1,l=c>99?`99+`:String(c);return/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-annotation-marker`,style:s,"data-active":o.annotationIndex===t||void 0,"data-large":c>99||void 0,"aria-label":`Edit annotation ${String(c)}`,title:`Edit annotation ${String(c)}`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:()=>{let e=a.current.get(o.annotationIndex);e!==void 0&&(Ai(e.browserRange),n(o,{...o.selection,rect:e.rect}),window.requestAnimationFrame(()=>{Ai(e.browserRange)}))},children:l},`${o.selection.parentSessionId}:${o.selection.fragments[0]?.nodeKey??``}:${String(o.annotationIndex)}`)})}function Mi(e,t,n){return Math.min(Math.max(t,e),Math.max(t,n))}function Ni(e,t,n,r={width:e.viewportWidth,height:e.viewportHeight}){let i=Math.max(0,t.width),a=Math.max(0,t.height),o=r.offsetLeft??0,s=r.offsetTop??0,c=o+r.width,l=s+r.height,u=Mi(e.x+e.width/2-i/2,o+8,c-i-8),d=n?12:8,f=n?64:8,p=e.y+e.height+d,m=e.y-a-f,h=p+a<=l-8,g=m>=s+8,_;return _=h?p:g||e.y-f-s-8>=l-8-e.y-e.height-d?m:p,{left:u,top:Mi(_,s+8,l-a-8)}}function Pi({text:e,selection:t,touchInteraction:n=!1,askDisabledReason:a,moreDetailsDisabledReason:o,annotationNumber:s=1,annotationEditor:c,onAddToChat:l,onMoreDetails:u,onAskInSideChat:d,onAnnotationEditorChange:f,onRemoveAnnotation:p,onDismiss:m}){let[h,g]=(0,r.useState)(c!==void 0),[_,v]=(0,r.useState)(c?.initialComment??``),[y,b]=(0,r.useState)(()=>({width:0,height:0})),[x,S]=(0,r.useState)(()=>({width:t.rect.viewportWidth,height:t.rect.viewportHeight,offsetLeft:0,offsetTop:0})),C=(0,r.useRef)(null),w=(0,r.useRef)(null),T=(0,r.useRef)(null),E=Ni(t.rect,y,n,x),D={left:E.left,top:E.top},O=x.offsetLeft,k=x.offsetTop,A=O+x.width,j=k+x.height,M=Math.max(0,Math.min(420,x.width-16)),N=t.rect.y-118,P=t.rect.y+t.rect.height+12,F={left:Mi(t.rect.x+t.rect.width+28,O+8,A-M-8),top:Mi(N>=k+8?N:P,k+8,j-118-8),width:M},I={left:Mi(t.rect.x+t.rect.width+3,O+4,A-22-4),top:Mi(t.rect.y-12,k+4,j-22-4)},ee=s>99?`99+`:String(s),L=e=>{e.preventDefault()};(0,r.useLayoutEffect)(()=>{let e=window.visualViewport,n=()=>{let n={width:e?.width??window.innerWidth??t.rect.viewportWidth,height:e?.height??window.innerHeight??t.rect.viewportHeight,offsetLeft:e?.offsetLeft??0,offsetTop:e?.offsetTop??0};S(e=>e.width===n.width&&e.height===n.height&&e.offsetLeft===n.offsetLeft&&e.offsetTop===n.offsetTop?e:n);let r=w.current;if(r===null)return;let i=r.getBoundingClientRect(),a={width:i.width,height:i.height};b(e=>e.width===a.width&&e.height===a.height?e:a)};n();let r=w.current,i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return r!==null&&i?.observe(r),window.addEventListener(`resize`,n),e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n),()=>{i?.disconnect(),window.removeEventListener(`resize`,n),e?.removeEventListener(`resize`,n),e?.removeEventListener(`scroll`,n)}},[h,t,n]),(0,r.useEffect)(()=>{h&&C.current?.focus()},[h]);let te=()=>{g(!1),v(``),f?.(!1),m()},R=()=>{let e=_.trim();l(t,e.length===0?void 0:e),f?.(!1),m()},ne=e=>{e.preventDefault(),R()},re=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),te()):e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),R())},ie=()=>{g(!0),f?.(!0)},ae=()=>{u(t),m()},oe=()=>{d(t),m()},se=(e,t)=>{n&&e.pointerType===`touch`&&!e.currentTarget.disabled&&(e.preventDefault(),T.current={target:e.currentTarget,timeStamp:e.timeStamp},t())},ce=(e,t)=>{let n=T.current;T.current=null;let r=n===null?1/0:e.timeStamp-n.timeStamp;e.detail!==0&&n?.target===e.currentTarget&&r>=0&&r<1e3?e.preventDefault():t()};return h?/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[c===void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-selection-marker`,"aria-hidden":`true`,"data-large":s>99||void 0,style:I,children:ee}),/* @__PURE__ */ (0,i.jsxs)(`form`,{className:`dsh-more-details-selection-comment`,role:`dialog`,"aria-label":c?.dialogLabel??e(`添加批注`,`Add annotation comment`),style:F,onSubmit:ne,onMouseDown:e=>{e.stopPropagation()},onKeyUp:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,i.jsx)(`textarea`,{ref:C,value:_,rows:2,"aria-label":e(`批注内容(可选)`,`Optional annotation comment`),placeholder:e(`添加批注(可选)…`,`Add an optional comment…`),onChange:e=>{v(e.currentTarget.value)},onKeyDown:re}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-selection-comment-actions`,children:[c!==void 0&&p!==void 0&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onClick:p,children:e(`移除`,`Remove`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onClick:te,children:e(`取消`,`Cancel`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`submit`,className:`dsh-more-details-selection-comment-save`,children:e(`保存`,`Save`)})]})]})]}):/* @__PURE__ */ (0,i.jsxs)(`div`,{ref:w,className:`dsh-more-details-selection-actions`,role:`toolbar`,"aria-label":e(`所选会话文字操作`,`Selected conversation text actions`),"data-touch":n||void 0,style:D,onMouseDown:L,onPointerDown:e=>{n&&e.pointerType===`touch`&&e.preventDefault()},onKeyDown:e=>{e.key===`Escape`&&m()},children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{se(e,ie)},onClick:e=>{ce(e,ie)},children:e(`添加到聊天`,`Add to chat`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:o!==void 0,title:o,onPointerDown:e=>{se(e,ae)},onClick:e=>{ce(e,ae)},children:e(`更多详情`,`More details`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:a!==void 0,title:a,onPointerDown:e=>{se(e,oe)},onClick:e=>{ce(e,oe)},children:e(`在侧边对话中提问`,`Ask in side chat`)})]})}function Fi(){return/* @__PURE__ */ (0,i.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})})}let Ii={code:{copyLabel:`Copy`,copiedLabel:`Copied`},footnotes:`Footnotes`};function Li({text:e,running:t}){let[n,o]=(0,r.useState)(!1),s=e.trimEnd().split(`
1394
- `);return/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-reasoning`,"data-variant":`think`,"data-state":t?`running`:`ok`,children:/* @__PURE__ */ (0,i.jsx)(a.DisclosureRow,{rowClassName:`dsh-more-details-reasoning-row`,leadingClassName:`dsh-more-details-reasoning-leading`,titleClassName:`dsh-more-details-reasoning-title`,chevronClassName:`dsh-more-details-reasoning-chevron`,icon:/* @__PURE__ */ (0,i.jsx)(a.IconThinkOutlineRegular,{size:14}),title:`Think`,open:n,expandable:!0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},collapsedContent:/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-reasoning-summary`,children:t?s.at(-1):s[0]}),children:/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-reasoning-body`,children:e})})})}function Ri({message:e,locale:t}){let n=/* @__PURE__ */ (0,i.jsxs)(`article`,{className:`dsh-more-details-message`,"data-role":e.role,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-message-role`,children:e.role===`user`?`You`:`Assistant`}),e.role===`user`?/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-message-text`,children:e.text}):/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[e.reasoning&&/* @__PURE__ */ (0,i.jsx)(Li,{text:e.reasoning,running:e.status===`streaming`}),/* @__PURE__ */ (0,i.jsx)(a.MarkdownText,{text:e.text,streaming:e.status===`streaming`,labels:Ii}),e.status===`streaming`&&e.text===``&&!e.reasoning&&/* @__PURE__ */ (0,i.jsx)(`span`,{children:`Thinking…`}),e.status===`stopped`&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-message-note`,children:`Stopped`}),e.status===`error`&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-message-note`,children:`Reply failed`})]})]});return e.selectedText===void 0?n:/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-annotated-user-message`,children:[/* @__PURE__ */ (0,i.jsx)(I,{selections:[{text:e.selectedText}],messages:F[t]}),n]})}function zi({state:e,controller:t,modelControl:n,locale:a=`en`}){let[o,s]=(0,r.useState)(``),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(),m=(0,r.useRef)(!1),h=(0,r.useRef)(!1),g=(0,r.useRef)(0),_=(0,r.useRef)(!0),v=(0,r.useRef)(null),y=oi(o),b=e.phase===`running`,x=b||u,S=[`ready`,`running`].includes(e.phase);(0,r.useEffect)(()=>{let e=v.current;e!==null&&_.current&&(e.scrollTop=e.scrollHeight)},[e.messages]);let C=async e=>{if(e.preventDefault(),o.trim().length===0||!S||b||m.current||h.current)return;let n=g.current;m.current=!0,l(!0),p(void 0);try{let e=await t.send(o);e.ok&&n===g.current?s(``):!e.ok&&t.getSnapshot().error?.message!==e.error.message&&p(e.error.message)}catch{p(`The message could not be sent. Your draft has been kept.`)}finally{m.current=!1,l(!1)}},w=async()=>{if(!h.current){h.current=!0,d(!0),p(void 0);try{let e=await t.cancel();e.ok||p(e.error.message)}catch{p(`The request could not be stopped. Try closing Side Chat.`)}finally{h.current=!1,d(!1)}}};return/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-conversation`,children:[/* @__PURE__ */ (0,i.jsxs)(`div`,{ref:v,className:`dsh-more-details-transcript`,"aria-live":`polite`,onScroll:e=>{let t=e.currentTarget;_.current=t.scrollHeight-t.scrollTop-t.clientHeight<48},children:[e.messages.map(e=>/* @__PURE__ */ (0,i.jsx)(Ri,{message:e,locale:a},e.id)),f!==void 0&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-turn-notice`,role:`alert`,children:f})]}),/* @__PURE__ */ (0,i.jsxs)(`form`,{className:`dsh-more-details-composer`,"data-composer-card":``,onSubmit:e=>{C(e)},children:[/* @__PURE__ */ (0,i.jsx)(`textarea`,{ref:y,rows:1,value:o,disabled:!S,placeholder:`Reply in Side Chat`,onChange:e=>{++g.current,s(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-composer-actions`,children:[n,/* @__PURE__ */ (0,i.jsx)(`button`,{type:x?`button`:`submit`,className:x?`dsh-more-details-stop-button`:`dsh-more-details-send-button`,"aria-label":x?`Stop generating`:`Send`,"aria-busy":u||c||void 0,disabled:!S||(x?u:c||o.trim().length===0),onClick:e=>{x&&(e.preventDefault(),w())},children:x?/* @__PURE__ */ (0,i.jsx)(Fi,{}):/* @__PURE__ */ (0,i.jsx)(ti,{})})]})]})]})}function Bi(){try{return typeof window>`u`?void 0:window.sessionStorage}catch{return}}function Vi(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function Hi(e){return e.occurrences.some(e=>e.source===`dsh-more-details-selection`||e.source===`dsh-more-details-conversation`||e.source===`dsh-more-details-webchat`)}function Ui(e,t){if(!Array.isArray(t)||t.length===0)return!1;let n=0;return t.every(t=>{if(typeof t!=`object`||!t)return!1;let r=t;return!Number.isSafeInteger(r.offset)||!Number.isSafeInteger(r.length)||r.offset<n||r.length<0||r.offset+r.length>e.length||typeof r.source!=`string`||typeof r.ref!=`string`||typeof r.label!=`string`||typeof r.clipboardText!=`string`||e.slice(r.offset,r.offset+r.length)!==r.clipboardText||r.appearance!==void 0&&![`session`,`file`,`folder`].includes(r.appearance)?!1:(n=r.offset+r.length,!0)})}var Wi=class{storage;persistentStorage;observedInputs=/* @__PURE__ */ new WeakSet;restoringWebInputs=/* @__PURE__ */ new WeakSet;reconciling=!1;constructor(e=Bi(),t=Vi()){this.storage=e,this.persistentStorage=t}reconcile(e,t){if(this.reconciling||this.restoringWebInputs.has(t)||this.storage===void 0&&this.persistentStorage===void 0)return;this.reconciling=!0;let n=`dsh-more-details:composer-references:`+encodeURIComponent(e),r=`dsh-more-details:webchat-composer-references:`+encodeURIComponent(e);try{let i=t.state.getSnapshot();if(Hi(i)){this.observedInputs.add(t);let e=JSON.stringify({version:1,draft:i.draft,occurrences:i.occurrences});i.occurrences.some(e=>e.source===`dsh-more-details-webchat`)?(this.persistentStorage?.setItem(r,e),this.storage?.removeItem(n)):(this.storage?.setItem(n,e),this.persistentStorage?.removeItem(r));return}if(this.observedInputs.has(t)){this.storage?.removeItem(n),this.persistentStorage?.removeItem(r);return}let a=this.persistentStorage?.getItem(r),o=a==null?this.storage:this.persistentStorage,s=a==null?n:r,c=a??this.storage?.getItem(n);if(c==null)return;let l=JSON.parse(c);if(l===null||l.version!==1||typeof l.draft!=`string`||!Ui(l.draft,l.occurrences)){o?.removeItem(s);return}if(i.draft===``)return;if(i.draft!==l.draft||i.occurrences.length!==0){o?.removeItem(s);return}if(i.phase!==void 0&&i.phase!==`plain`)return;if(l.occurrences.some(e=>e.source===`dsh-more-details-webchat`))return this.restoringWebInputs.add(t),this.restoreWebDraft(t,l).then(n=>{this.restoringWebInputs.delete(t),n&&(this.observedInputs.add(t),this.reconcile(e,t))});this.restore(t,l)&&this.observedInputs.add(t)}catch{}finally{this.reconciling=!1}}async restoreWebDraft(e,t){let n,r=!1,i=t=>new Promise((n,r)=>{try{s(e,t,n)||n(void 0)}catch(e){r(e)}});try{for(let r of[...t.occurrences].reverse()){let a=e.state.getSnapshot();if(a.draft!==t.draft)return!1;let o=await i(()=>e.insertReference({source:r.source,ref:r.ref,label:r.label,clipboardText:r.clipboardText,...r.appearance===void 0?{}:{appearance:r.appearance}},{start:r.offset,end:r.offset+r.length,draftRev:a.draftRev}));if(o===void 0)return!1;let s=t.draft[r.offset+r.length]!==` `,c=s?t.draft.slice(0,r.offset+r.length)+` `+t.draft.slice(r.offset+r.length):t.draft;if(o.draft!==c||d(a,o,r.source,r.ref)===void 0)return!1;if(n=o,s){let a=await i(()=>e.replaceText(``,{start:r.offset+1,end:r.offset+2,draftRev:o.draftRev}));if(a===void 0||a.draft!==t.draft)return!1;n=a}}return r=!0,!0}catch{return e.notify?.(`error`,`网页引用恢复未完成;原草稿仍在,请检查引用后重试。`),!1}finally{let a=e.state.getSnapshot();if(!r&&n===a){let n=a.draft.length-a.occurrences.reduce((e,t)=>e+t.length-1,0);try{await i(()=>e.replaceText(t.draft,{start:0,end:n,draftRev:a.draftRev}))}catch{e.notify?.(`error`,`网页引用恢复被输入框中止;请保留当前草稿并检查引用。`)}}}}restore(e,t){let n,r=!1;try{for(let r of[...t.occurrences].reverse()){let i=e.state.getSnapshot();if(i.draft!==t.draft||!e.insertReference({source:r.source,ref:r.ref,label:r.label,clipboardText:r.clipboardText,...r.appearance===void 0?{}:{appearance:r.appearance}},{start:r.offset,end:r.offset+r.length,draftRev:i.draftRev}))return!1;let a=e.state.getSnapshot(),o=t.draft[r.offset+r.length]!==` `,s=o?t.draft.slice(0,r.offset+r.length)+` `+t.draft.slice(r.offset+r.length):t.draft;if(a.draft!==s)return!1;if(n=a,o){if(!e.replaceText(``,{start:r.offset+1,end:r.offset+2,draftRev:a.draftRev}))return!1;let i=e.state.getSnapshot();if(i.draft!==t.draft)return!1;n=i}}return r=!0,!0}finally{let i=e.state.getSnapshot();if(!r&&n===i){let n=i.draft.length-i.occurrences.reduce((e,t)=>e+t.length-1,0);e.replaceText(t.draft,{start:0,end:n,draftRev:i.draftRev})}}}};let Gi=`dsh-more-details:model-preference:v1`;function Ki(){if(typeof window<`u`)try{return window.localStorage}catch{return}}function qi(e){if(typeof e!=`object`||!e)return;let t=e;if(typeof t.provider==`string`&&t.provider!==``&&typeof t.model==`string`&&t.model!==``&&(t.reasoningEffort===void 0||typeof t.reasoningEffort==`string`&&t.reasoningEffort!==``))return{provider:t.provider,model:t.model,...t.reasoningEffort===void 0?{}:{reasoningEffort:t.reasoningEffort}}}var Ji=class{storage;constructor(e=Ki()){this.storage=e}get(){if(this.storage!==void 0)try{let e=this.storage.getItem(Gi);if(e===null)return;let t=JSON.parse(e);return t.version===1?qi(t.selection):void 0}catch{return}}set(e){if(this.storage===void 0)return;let t={version:1,selection:{...e}};try{this.storage.setItem(Gi,JSON.stringify(t))}catch{}}};let Yi={turnEnds:/* @__PURE__ */ new Map,chatNodes:{get:()=>void 0}};var Xi=class{chat;source;snapshot=Yi;constructor(e){this.chat=e}subscribe=e=>this.chat.subscribe(e);getSnapshot=()=>{let e=this.chat.getSnapshot();return e!==this.source&&(this.source=e,this.snapshot=e===void 0?Yi:{turnEnds:e.legacy.turnEnds,chatNodes:e.nodes}),this.snapshot}};function Zi(e){return e}function Qi(e){return e.kind===`turn`?e.turn.status===`closed`:e.kind===`step`&&e.turn.status===`closed`&&e.step.status===`closed`}var $i=class{ctx;faces=/* @__PURE__ */ new WeakMap;parentInputs=/* @__PURE__ */ new WeakMap;annotationPersistence=new Wi;modelPreferences=new Ji;constructor(e){this.ctx=e}subscribeList=e=>this.ctx.sessions.list.subscribe(e);subscribeConversationInput=e=>{let t,n=()=>{},r=()=>{let r=this.currentParentInput();r!==t&&(n(),t=r,n=t?.state.subscribe(e)??(()=>{}))};r();let i=this.ctx.sessions.list.subscribe(()=>{r(),e()});return()=>{i(),n()}};currentConversationInputSnapshot=()=>this.currentParentInput()?.state.getSnapshot();currentSessionId(){let e=Object.entries(this.ctx.sessions.list.getSnapshot().byId).find(([,e])=>(e.retainedBy.mainView??0)>0)?.[0];return e===void 0?void 0:P(e)}lastCompletedSeq(e){let t=this.face(e)?.getSnapshot(),n;for(let e of t?.turnEnds.values()??[])(n===void 0||e>n)&&(n=e);return n}selectionIsCurrent(e){let t=this.face(e.parentSessionId)?.getSnapshot();return t!==void 0&&e.fragments.every(e=>{let n=t.chatNodes.get(e.nodeKey);return n!==void 0&&n.visibility===`visible`&&n.kind===e.nodeKind&&n.anchorSeq===e.seq&&Qi(n.location)})}addSelectionToConversation(e,t){if(this.currentSessionId()!==e.parentSessionId)return!1;let n=this.currentParentInput();return n===void 0||!w(n,e,t)?!1:(this.annotationPersistence.reconcile(e.parentSessionId,n),!0)}addSideChatToConversation(e,t){let n=this.ctx.sessions.scope(Zi(e)),r=n===void 0?void 0:this.parentInput(n);return r===void 0||!ue(r,t)?!1:(this.annotationPersistence.reconcile(e,r),!0)}addWebChatToConversation(e,t){let n=this.ctx.sessions.scope(Zi(e)),r=n===void 0?void 0:this.parentInput(n);return r!==void 0&&De(r,t,()=>{this.annotationPersistence.reconcile(e,r)})}focusConversationInput(e){if(this.currentSessionId()!==e)return;let t=this.ctx.sessions.scope(Zi(e));t!==void 0&&this.parentInput(t)?.focus?.()}removeConversationAnnotation(e){let t=this.currentSessionId(),n=this.currentParentInput();return t===void 0||n===void 0||!E(n,e)?!1:(this.annotationPersistence.reconcile(t,n),!0)}updateConversationAnnotation(e,t){let n=this.currentSessionId(),r=this.currentParentInput();return n===void 0||r===void 0||!D(r,e,t)?!1:(this.annotationPersistence.reconcile(n,r),!0)}reconcileConversationAnnotationPersistence(){let e=this.currentSessionId(),t=this.currentParentInput();e!==void 0&&t!==void 0&&this.annotationPersistence.reconcile(e,t)}nextConversationAnnotationNumber(){let e=this.currentConversationInputSnapshot();return e===void 0?1:x(e).length+1}removeConversationAnnotations(e=this.currentSessionId()){let t=e===void 0?void 0:this.ctx.sessions.scope(Zi(e)),n=t===void 0?void 0:this.parentInput(t);return e===void 0||n===void 0||!T(n)?!1:(this.annotationPersistence.reconcile(e,n),!0)}retainParent(e){let t=this.ctx.sessions.retain(Zi(e),{source:`moreDetails`}),n=!0;return t.ready.catch(()=>{n&&this.notify({kind:`warning`,text:`The parent conversation could not be loaded.`})}),()=>{n=!1,t.release()}}async openSession(e){this.ctx.uiWorkspace.openSession(Zi(e))}notify(e){console[e.kind===`warning`?`warn`:`info`](`[dsh-more-details] ${e.text}`),this.currentParentInput()?.notify?.(e.kind===`warning`?`error`:`info`,e.text)}face(e){let t=this.ctx.sessions.binding(Zi(e))?.session;if(t===void 0)return;let n=this.faces.get(t);if(n!==void 0)return n;let r=this.ctx.uiConversation.binding(t.sessionId);r.activate(`chat`);let i=new Xi(r.target(`chat`));return this.faces.set(t,i),i}title(e){return this.ctx.sessions.list.getSnapshot().byId[Zi(e)]?.displayTitle}modelDirectory(e){try{return this.ctx.modelDirectories.directoryFor(Zi(e))}catch{return}}moreDetailsModelPreference(){return this.modelPreferences.get()}rememberSideChatModelPreference(e){this.modelPreferences.set(e)}currentParentInput(){let e=this.currentSessionId(),t=e===void 0?void 0:this.ctx.sessions.scope(Zi(e));return t===void 0?void 0:this.parentInput(t)}parentInput(e){let t=this.ctx.conversation.input.for(e);if(t===void 0)return;let n=this.parentInputs.get(t);if(n!==void 0)return n;let r={state:t.state,setDraft:e=>{t.setDraft(e)},notify:(e,n)=>t.notify?.(e,n),focus:()=>t.focus(),insertReference:(e,n)=>t.insertReference(e,n),replaceText:(t,n)=>e.bail(e,`slash/input-insert-text`,{text:t,span:n})===!0};return this.parentInputs.set(t,r),r}};function ea(e,t){let n=e.chatNodes.get(t);if(n===void 0||n.visibility!==`visible`)return;let r=n.kind===`user`||n.kind===`steering`?`user`:n.kind===`assistant-step`?`assistant`:n.kind===`context`?`context`:void 0,i=n.location.kind===`turn`||n.location.kind===`step`?n.location.turn.turn:void 0;if(r!==void 0&&i!==void 0)return{nodeKey:n.key,nodeKind:n.kind,turnKey:`turn:${String(i)}`,seq:n.anchorSeq,source:r,modelVisible:!0,settled:Qi(n.location)}}function ta(e){if(e instanceof KeyboardEvent&&e.key===`Escape`)return!1;let t=e.target;return!(t instanceof Element&&t.closest(`[data-side-chat-panel], .dsh-more-details-selection-actions, .dsh-more-details-selection-comment, .dsh-more-details-annotation-marker`)!==null)}function na({controller:e,sessions:t,details:n,webChatAvailable:a=!0,locale:o}){let{active:s,text:c}=N(o),l=(0,r.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot),u=(0,r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),d=(0,r.useSyncExternalStore)(t.subscribeList,()=>t.currentSessionId(),()=>t.currentSessionId()),f=(0,r.useSyncExternalStore)(t.subscribeConversationInput,t.currentConversationInputSnapshot,t.currentConversationInputSnapshot),p=(0,r.useMemo)(()=>f===void 0?[]:S(f),[f]),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(null),v=(0,r.useRef)(0),y=(0,r.useRef)(void 0),b=(0,r.useRef)(null),x=(0,r.useRef)(!1),C=(0,r.useRef)(!1),w=(0,r.useRef)(0),T=(0,r.useCallback)(async e=>{let n=++v.current,r=t.currentSessionId(),i=r===void 0?void 0:t.face(r),a=r===void 0?void 0:_i(r),o=window.getSelection();if(r===void 0||i===void 0||a===void 0||o===null||o.isCollapsed){n===v.current&&h(null);return}let s=i.getSnapshot();try{let i=await fi({selection:o,conversationRoot:a,parentSessionId:r,resolver:{resolve(e){let t=e.dataset.chatAnchorKey;return t===void 0?void 0:ea(s,t)}}});n===v.current&&t.currentSessionId()===r&&h({value:i,touch:e})}catch{n===v.current&&h(null)}},[t]),E=(0,r.useCallback)(()=>{y.current!==void 0&&(window.clearTimeout(y.current),y.current=void 0)},[]),D=(0,r.useCallback)(()=>{E();let e=++v.current;y.current=window.setTimeout(()=>{y.current=void 0,!(e!==v.current||x.current)&&T(!0)},300)},[E,T]);(0,r.useEffect)(()=>{let e=()=>{E(),b.current=null,x.current=!1,++v.current,h(null),_(null)},t=()=>Date.now()<w.current,n=n=>{ta(n)&&(n.pointerType===`touch`&&t()||(n.pointerType!==`touch`&&(w.current=0),C.current=n.pointerType===`touch`,C.current&&e()))},r=n=>{ta(n)&&!t()&&(C.current=!0,e())},i=e=>{ta(e)&&!t()&&(C.current=!0,D())},a=e=>{C.current||t()?b.current=null:ta(e)?(E(),b.current={x:e.clientX,y:e.clientY},x.current=!1,++v.current,h(null),_(null)):b.current=null},o=e=>{let n=b.current;b.current=null,ta(e)&&!t()&&(C.current?D():(n===null||Math.abs(e.clientX-n.x)>2||Math.abs(e.clientY-n.y)>2||e.detail>1||e.shiftKey)&&T(!1))},s=()=>{if(x.current)return;if(C.current){D();return}let e=window.getSelection();(e===null||e.isCollapsed)&&(E(),++v.current,h(null))},c=e=>{C.current=!1,E(),e.key===`Escape`?(++v.current,x.current=!1,h(null),_(null)):ta(e)&&T(!1)};return document.addEventListener(`pointerdown`,n),document.addEventListener(`touchstart`,r,{passive:!0}),document.addEventListener(`touchend`,i,{passive:!0}),document.addEventListener(`mousedown`,a),document.addEventListener(`mouseup`,o),document.addEventListener(`selectionchange`,s),document.addEventListener(`keyup`,c),()=>{E(),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`touchstart`,r),document.removeEventListener(`touchend`,i),document.removeEventListener(`mousedown`,a),document.removeEventListener(`mouseup`,o),document.removeEventListener(`selectionchange`,s),document.removeEventListener(`keyup`,c)}},[E,T,e,D]),(0,r.useEffect)(()=>{E(),++v.current,x.current=!1,h(null),_(null)},[E,d]),(0,r.useEffect)(()=>{f!==void 0&&t.reconcileConversationAnnotationPersistence()},[f,t]),(0,r.useEffect)(()=>{g!==null&&(p.some(e=>e.annotationIndex===g.annotationIndex)||(x.current=!1,_(null)))},[p,g]);let O=(0,r.useCallback)(()=>{E(),C.current&&(w.current=Date.now()+750),C.current=!1,x.current=!1,++v.current,h(null)},[E]),k=u.phase===`closed`?void 0:c(`请先关闭当前侧边对话,再新建另一个。`,`Close the current Side Chat before starting another one.`),A=s.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`,j=u.parentSessionId===void 0?void 0:t.modelDirectory?.(u.parentSessionId),M=u.parentSessionId===void 0||u.chatId===void 0||u.phase!==`ready`||!u.messages.some(e=>e.role===`assistant`&&e.text.trim().length>0),P=()=>{let e=u.parentSessionId,n=u.chatId;if(e===void 0||n===void 0||u.phase!==`ready`){t.notify({kind:`warning`,text:`The Side Chat conversation is not ready to add yet.`});return}let r=t.title(e),i=R({conversationId:n,title:[A===`zh-CN`?`侧边对话`:`Side Chat`,r].filter(Boolean).join(` · `),messages:u.messages});if(i.conversation.length===0)t.notify({kind:`warning`,text:`The Side Chat does not have any conversation history to add yet.`});else try{if(!t.addSideChatToConversation(e,i)){t.notify({kind:`warning`,text:`Could not add the Side Chat to the main conversation.`});return}t.openSession(e).then(()=>vi(e),()=>{t.notify({kind:`warning`,text:`The Side Chat was added, but its parent conversation could not be opened.`})})}catch{t.notify({kind:`warning`,text:`Could not add the Side Chat to the main conversation.`})}},F=j===void 0?void 0:/* @__PURE__ */ (0,i.jsx)(ei,{directory:j,selection:u.modelSelection,locked:[`creating`,`closing`].includes(u.phase)||u.error?.operation===`close`,running:u.phase===`running`,validateInitialSelection:u.chatId===void 0,locale:A,onInitialize:(t,n)=>{n.remember?e.selectModel(t):e.initializeModel(t)},onSelect:t=>e.selectModel(t)},`${u.parentSessionId}:${u.chatId??`draft`}`);return/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-overlay`,children:[/* @__PURE__ */ (0,i.jsx)(ji,{annotations:p,...g===null?{}:{activeAnnotationIndex:g.annotationIndex},onEdit:(e,t)=>{x.current=!0,E(),++v.current,h(null),_({...e,selection:t})}}),m!==null&&/* @__PURE__ */ (0,i.jsx)(Pi,{text:c,selection:m.value,touchInteraction:m.touch,annotationNumber:t.nextConversationAnnotationNumber(),...k===void 0?{}:{askDisabledReason:k},...a?l.busy||l.pending!==void 0?{moreDetailsDisabledReason:l.busy?c(`正在处理更多详情请求`,`A More details request is in progress.`):c(`请先处理小窗中的待发送请求`,`Handle the pending request in the Web Chat window first.`)}:{}:{moreDetailsDisabledReason:c(Ke.zh,Ke.en)},onAddToChat:(e,n)=>{try{t.addSelectionToConversation(e,n)?vi(e.parentSessionId):t.notify({kind:`warning`,text:c(`无法将所选内容添加到当前聊天。`,`Could not add the selection to the current chat.`)})}catch{t.notify({kind:`warning`,text:c(`无法将所选内容添加到当前聊天。`,`Could not add the selection to the current chat.`)})}O()},onAnnotationEditorChange:e=>{x.current=e,e&&C.current&&(w.current=Date.now()+750)},onMoreDetails:e=>{n.start(e),O()},onAskInSideChat:n=>{let r=e.openDraft({selection:n});r.ok||t.notify({kind:`warning`,text:r.error.message}),O()},onDismiss:O}),g!==null&&/* @__PURE__ */ (0,i.jsx)(Pi,{text:c,selection:g.selection,annotationNumber:g.annotationIndex+1,annotationEditor:{...g.comment===void 0?{}:{initialComment:g.comment},dialogLabel:c(`编辑批注`,`Edit annotation comment`)},onAddToChat:(e,n)=>{try{t.updateConversationAnnotation(g.annotationIndex,n)||t.notify({kind:`warning`,text:`Could not update the annotation.`})}catch{t.notify({kind:`warning`,text:`Could not update the annotation.`})}x.current=!1,_(null)},onAnnotationEditorChange:e=>{x.current=e},onRemoveAnnotation:()=>{try{t.removeConversationAnnotation(g.annotationIndex)||t.notify({kind:`warning`,text:`Could not remove the annotation.`})}catch{t.notify({kind:`warning`,text:`Could not remove the annotation.`})}x.current=!1,_(null)},onMoreDetails:()=>{},onAskInSideChat:()=>{},onDismiss:()=>{x.current=!1,_(null)}},`annotation:${String(g.annotationIndex)}`),u.phase!==`closed`&&/* @__PURE__ */ (0,i.jsx)(si,{state:u,locale:A,embeddedConversation:/* @__PURE__ */ (0,i.jsx)(zi,{state:u,controller:e,locale:A,modelControl:F},u.chatId),modelControl:F,onDraftChange:t=>{e.setDraft(t)},onFirstSend:t=>e.sendFirst(t),onClose:()=>e.close(),onRetry:()=>e.retry(),onFocusParent:()=>{u.parentSessionId!==void 0&&t.openSession(u.parentSessionId)},onAddToConversation:P,addToConversationDisabled:M,...u.chatId===void 0?{onRemoveSelection:()=>{e.clearSelection()}}:{}})]})}let ra=[`configForms`,`workspaces`,`conversation`,`inputTriggers`,`locale`,`modelDirectories`,`remote`,`sessions`,`slots`,`uiConversation`,`uiWorkspace`];async function ia(e){let t=[],n=!1,i,a=()=>(n=!0,i??=(async()=>{for(let e of t.splice(0).reverse())try{await e()}catch(e){console.warn(`[dsh-more-details] Cleanup failed`,e)}})(),i);e.effect(()=>a,`dsh-more-details.clientLifecycle`);try{let i=document.createElement(`style`);i.textContent=o+_t+Re,i.dataset.plugin=`dsh-more-details`,i.dataset.dshSideChat=`styles`,document.head.append(i),t.push(()=>{i.remove()});let a=e,s=await Yr(a);if(n){await s.dispose();return}t.push(s.dispose),t.push(a.inputTriggers.registerSource(k)),t.push(a.inputTriggers.registerSource(de));let c=new $i(a);t.push(pt(e));let l=ct()!==void 0,u=new dt(s.loginStore);t.push(()=>u.dispose());let d=new $e(u,s.prepareDetails,c,window.localStorage,s.saveWebChatReference,(t,n)=>e.locale.resolveText({zh:t,en:n})),f=l?e=>{d.openHistory(e.url)}:void 0;if(t.push(a.inputTriggers.registerSource(Oe(f,e.locale))),t.push(Le(a,e=>{c.removeConversationAnnotations(e)},f)),u.observe(e=>d.observePage({url:e.url,title:e.title})),t.push(()=>d.dispose()),l){let n=e.configForms.get(`more-details`);t.push(a.slots.inject(`shell.overlay`,()=>a.slots.register({name:`shell.overlay`,id:`dsh-more-details-webchat`,order:91},()=>(0,r.createElement)(ht,{controller:d,guest:u,form:n,locale:e.locale})))),t.push(a.slots.inject(`sidebar.footer.action`,()=>a.slots.register({name:`sidebar.footer.action`,id:`dsh-more-details-new-chat`,order:10},({wide:t})=>(0,r.createElement)(gt,{controller:d,locale:e.locale,wide:t}))))}let p=new Dt(s.remote,c);t.push(()=>p.dispose()),t.push(a.slots.inject(`shell.overlay`,()=>a.slots.register({name:`shell.overlay`,id:`dsh-more-details`,order:90},()=>(0,r.createElement)(na,{controller:p,sessions:c,details:d,webChatAvailable:l,locale:e.locale}))))}catch(e){throw await a(),e}}return n.SelectionActions=Pi,n.SelectionValidationError=B,n.SideChatController=Dt,n.SideChatPanel=si,n.apply=ia,n.assertSelectionCurrent=Tt,n.buildSideChatPrompt=j,n.captureDomConversationSelection=fi,n.finalizeConversationSelection=wt,n.inject=ra,n.name=`more-details-client`,n.normalizeSelectedText=Ct,n.restoreDomConversationSelection=hi,n.selectionFitsLimit=xt,n.summarizeSelection=St,n.utf8ByteLength=bt,t.exports}});
1364
+ `).trim()}function Tt(e){let t=e.fragments[0];if(t===void 0)throw new B(`selection_empty`,`Select some conversation text first.`);if(e.fragments.length!==1)throw new B(`selection_crosses_unsupported_nodes`,`Select text inside one completed message.`);let n=wt(e.rawText);if(n.length===0)throw new B(`selection_empty`,`The selection contains only whitespace.`);if(xt(n)>16384)throw new B(`selection_too_large`,`The selected text is too large.`);if(!t.modelVisible||!t.settled)throw new B(`context_unavailable`,`Wait for this message to finish before opening Side Chat.`);if(!Number.isSafeInteger(t.seq)||t.seq<0)throw new B(`selection_stale`,`The selected message is no longer available.`);return Object.freeze({parentSessionId:e.parentSessionId,fragments:Object.freeze([{...t}]),text:n,atSeq:t.seq,rect:Object.freeze({...e.rect})})}function Et(e,t){if(t!==e.parentSessionId)throw new B(`selection_stale`,`The parent conversation changed after selection.`)}let Dt=Object.freeze({phase:`closed`,draft:``,messages:[]}),V=e=>({ok:!0,value:e}),H=e=>({ok:!1,error:e});function U(e,t=`invalid_request`,n=!1){return{code:t,message:e,recoverable:n}}var Ot=class{remote;sessions;observable=new yt(Dt,`dsh-more-details`);generation=0;modelGeneration=0;requestSequence=0;disposed=!1;releaseParent;creating;closing;running;cancelling=!1;pendingRequest;constructor(e,t){this.remote=e,this.sessions=t}getSnapshot=()=>this.observable.getSnapshot();subscribe=e=>this.observable.subscribe(e);openDraft(e={}){if(this.disposed)return H(U(`Side Chat has been disposed.`));if(this.getSnapshot().phase!==`closed`)return H(U(`Close the current Side Chat first.`,`side_chat_already_open`));let t=e.parentSessionId??this.sessions.currentSessionId();if(t===void 0)return H(U(`Start the main conversation first.`,`parent_session_missing`));try{e.selection!==void 0&&Et(e.selection,t),this.releaseParent=this.sessions.retainParent(t)}catch(e){return H(U(e instanceof Error?e.message:`The parent conversation is unavailable.`,`selection_stale`))}return++this.generation,this.observable.publish({phase:`draft`,parentSessionId:t,selection:e.selection,modelSelection:this.sessions.moreDetailsModelPreference(),draft:e.draft??``,messages:[]}),V(void 0)}setDraft(e){let t=this.getSnapshot();return![`draft`,`error`,`ready`].includes(t.phase)||t.messages.length>0||t.error?.operation===`close`?H(U(`The draft is not editable right now.`)):(this.observable.publish({...t,draft:e}),V(void 0))}clearSelection(){let e=this.getSnapshot();return e.chatId!==void 0||![`draft`,`error`].includes(e.phase)?H(U(`The selected context is already captured.`)):(this.observable.publish({...e,selection:void 0}),V(void 0))}initializeModel(e){let t=this.getSnapshot();return t.chatId!==void 0||![`draft`,`error`].includes(t.phase)?H(U(`The model cannot be initialized now.`)):(this.observable.publish({...t,modelSelection:{...e}}),V({...e}))}async selectModel(e){let t=this.getSnapshot();if(this.cancelling||![`draft`,`error`,`ready`,`running`].includes(t.phase)||t.error?.operation===`close`)return H(U(`The model cannot be changed while Side Chat is opening, stopping, or closing.`));if(t.chatId===void 0){let t=this.initializeModel(e);return t.ok&&this.sessions.rememberSideChatModelPreference(t.value),t}let n=this.generation,r=++this.modelGeneration,i=await this.invoke(()=>this.remote.selectModel({chatId:t.chatId,...e}));return i.ok?(n===this.generation&&r===this.modelGeneration&&(this.observable.publish({...this.getSnapshot(),modelSelection:i.value.selected}),this.sessions.rememberSideChatModelPreference(i.value.selected)),V(i.value.selected)):i}async sendFirst(e){let t=this.getSnapshot(),n=e.trim();if(n.length===0||t.parentSessionId===void 0||t.messages.length>0||![`draft`,`error`,`ready`].includes(t.phase)||t.error?.operation===`close`)return H(U(`Enter a question in an open Side Chat draft.`));if(t.chatId===void 0){if(t.selection!==void 0&&!this.sessions.selectionIsCurrent(t.selection))return this.fail(U(`Select the passage again before sending.`,`selection_stale`),`create`);let e=t.selection?.atSeq??this.sessions.lastCompletedSeq(t.parentSessionId);if(e===void 0)return this.fail(U(`Wait for a completed parent turn.`,`parent_session_not_ready`,!0),`create`);let r=this.generation;this.observable.publish({...t,phase:`creating`,draft:n,error:void 0});let i=this.invoke(()=>this.remote.create({parentSessionId:t.parentSessionId,atSeq:e,selectedText:t.selection?.text,modelSelection:t.modelSelection}));this.creating=i;let a=await i;if(this.creating===i&&(this.creating=void 0),r!==this.generation)return H(U(`The Side Chat was closed.`));if(!a.ok)return this.fail(a.error,`create`);this.observable.publish({...this.getSnapshot(),phase:`ready`,chatId:a.value.chatId,boundarySeq:a.value.boundarySeq,modelSelection:a.value.modelSelection,error:void 0}),this.sessions.rememberSideChatModelPreference(a.value.modelSelection)}return await this.send(n)}async send(e){let t=this.getSnapshot(),n=e.trim();if(n.length===0||t.chatId===void 0||this.running!==void 0||this.cancelling||![`ready`,`error`].includes(t.phase)||t.error?.operation===`close`)return H(U(`Wait for the current reply or stop it before sending.`));let r=this.pendingRequest?.chatId===t.chatId&&this.pendingRequest.text===n?this.pendingRequest:{chatId:t.chatId,requestId:`${t.chatId}:${++this.requestSequence}`,text:n};this.pendingRequest=r;let i;try{i=this.remote.stream(r)}catch(e){return this.fail(U(String(e),`transport_error`,!0),`prompt`)}let a={stream:i,generation:this.generation,request:r,cancelled:!1};return this.running=a,this.observable.publish({...t,phase:t.messages.length===0?`creating`:`running`,error:void 0}),await new Promise(e=>{a.done=this.consume(a,e)})}async cancel(){let e=this.getSnapshot().chatId;if(e===void 0||this.running===void 0)return V(void 0);this.cancelling=!0;let t=this.running;t.cancelled=!0,this.disposeStream(t.stream);try{let n=await this.invoke(()=>this.remote.cancel({chatId:e}));return await t.done,n.ok?V(void 0):n}finally{this.cancelling=!1}}async retry(){let e=this.getSnapshot();return e.error?.operation===`close`?await this.close():e.messages.length===0?await this.sendFirst(e.draft):this.pendingRequest===void 0?H(U(`An admitted question is never replayed automatically. Send a follow-up to continue.`)):await this.send(this.pendingRequest.text)}async close(){if(this.closing!==void 0)return await this.closing;if(this.getSnapshot().phase===`closed`)return V(void 0);let e=this.closeCurrent();this.closing=e;try{return await e}finally{this.closing===e&&(this.closing=void 0)}}async dispose(){if(!this.disposed){this.disposed=!0;try{let e=await this.close();e.ok||this.sessions.notify({kind:`warning`,text:e.error.message})}finally{this.running!==void 0&&this.disposeStream(this.running.stream),this.releaseParent?.(),this.releaseParent=void 0,this.observable.dispose()}}}async consume(e,t){let n=!1,r=!1,i=()=>e.generation===this.generation&&this.running===e,a=`${e.request.requestId}:assistant`;try{for await(let o of e.stream){if(!i())break;let s=this.getSnapshot();if(o.type===`started`){if(n||o.requestId!==e.request.requestId)throw Error(`Invalid Side Chat admission response.`);n=!0,this.pendingRequest=void 0,this.observable.publish({...s,phase:`running`,draft:``,messages:[...s.messages,{id:`${e.request.requestId}:user`,role:`user`,text:e.request.text,status:`complete`,selectedText:s.messages.length===0?s.selection?.text:void 0},{id:a,role:`assistant`,text:``,reasoning:``,status:`streaming`}],error:void 0}),t(V(void 0))}else if(o.type===`content`){if(!n)throw Error(`Side Chat content arrived before admission.`);this.observable.publish({...s,messages:s.messages.map(e=>e.id===a?{...e,text:o.text,reasoning:o.reasoning}:e)})}else if(o.type===`finished`){if(!n)throw Error(`Side Chat ended before admission.`);r=!0,this.observable.publish({...s,phase:`ready`,messages:s.messages.map(e=>e.id===a?{...e,status:o.status}:e)});break}else{r=!0;let e={...o.error,recoverable:!n&&o.error.recoverable};this.streamFailure(e,a),t(H(e));break}}if(i()&&!r&&!e.cancelled)throw Error(`The Side Chat connection ended before the reply completed.`)}catch(r){if(i()&&!e.cancelled){let e=U(r instanceof Error?r.message:String(r),`transport_error`,!n);this.streamFailure(e,a),t(H(e))}}finally{if(i()&&e.cancelled){this.pendingRequest=void 0;let e=this.getSnapshot();this.observable.publish({...e,phase:`ready`,error:void 0,messages:e.messages.map(e=>e.id===a?{...e,status:`stopped`}:e)})}this.disposeStream(e.stream),this.running===e&&(this.running=void 0),t(H(U(`The Side Chat was closed.`)))}}streamFailure(e,t){let n=this.getSnapshot();this.observable.publish({...n,phase:n.messages.length===0?`error`:`ready`,messages:n.messages.map(e=>e.id===t?{...e,status:`error`}:e),error:{...e,operation:`prompt`}})}async closeCurrent(){let e=this.getSnapshot(),t=this.creating;++this.generation,this.running!==void 0&&this.disposeStream(this.running.stream),this.running=void 0,this.observable.publish({...e,phase:`closing`,error:void 0});let n=e.chatId;if(t!==void 0){let e=await t;e.ok&&(n=e.value.chatId)}if(n!==void 0){let e=await this.invoke(()=>this.remote.close({chatId:n}));if(!e.ok&&e.error.code!==`side_chat_not_found`)return this.observable.publish({...this.getSnapshot(),phase:`error`,chatId:n,error:{...e.error,operation:`close`}}),e}return this.pendingRequest=void 0,this.releaseParent?.(),this.releaseParent=void 0,this.observable.publish(Dt),V(void 0)}fail(e,t){return this.observable.publish({...this.getSnapshot(),phase:`error`,error:{...e,operation:t}}),H(e)}disposeStream(e){try{e.dispose()}catch{}}async invoke(e){try{return await e()}catch(e){return H(U(e instanceof Error?e.message:String(e),`transport_error`,!0))}}},kt;/* @__NO_SIDE_EFFECTS__ */
1365
+ function W(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var At=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(kt=globalThis).__zod_globalConfig??(kt.__zod_globalConfig={});let jt=globalThis.__zod_globalConfig;function Mt(e){return e&&Object.assign(jt,e),jt}function Nt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Pt(e,t){return typeof t==`bigint`?t.toString():t}function Ft(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function It(e){return e==null}function Lt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}let Rt=/* @__PURE__*/ Symbol(`evaluating`);function G(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Rt)return r===void 0&&(r=Rt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}let zt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Bt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Vt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ut(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function K(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Wt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Gt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Kt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function qt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Jt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Yt(e){return typeof e==`string`?e:e?.message}function Xt(e,t,n){let r=e.message?e.message:Yt(e.inst?._zod.def?.error?.(e))??Yt(t?.error?.(e))??Yt(n.customError?.(e))??Yt(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Zt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Qt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let $t=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Pt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},en=/* @__PURE__ */ W(`$ZodError`,$t),tn=/* @__PURE__ */ W(`$ZodError`,$t,{Parent:Error}),nn=/* @__PURE__*/ (e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new At;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Xt(e,a,Mt())));throw zt(t,i?.callee),t}return o.value})(tn),rn=/* @__PURE__*/ (e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Xt(e,a,Mt())));throw zt(t,i?.callee),t}return o.value})(tn),an=/* @__PURE__*/ (e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new At;return a.issues.length?{success:!1,error:new(e??en)(a.issues.map(e=>Xt(e,i,Mt())))}:{success:!0,data:a.value}})(tn),on=/* @__PURE__*/ (e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Xt(e,i,Mt())))}:{success:!0,data:a.value}})(tn),sn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},cn=/^-?\d+$/,ln=/^-?\d+(?:\.\d+)?$/,un=/^(?:true|false)$/i,dn=/*@__PURE__*/ W(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fn={number:`number`,bigint:`bigint`,object:`date`},pn=/*@__PURE__*/ W(`$ZodCheckGreaterThan`,(e,t)=>{dn.init(e,t);let n=fn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/ W(`$ZodCheckNumberFormat`,(e,t)=>{dn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Gt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=cn)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),hn=/*@__PURE__*/ W(`$ZodCheckMaxLength`,(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!It(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Zt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gn=/*@__PURE__*/ W(`$ZodCheckMinLength`,(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!It(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Zt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_n=/*@__PURE__*/ W(`$ZodCheckStringFormat`,(e,t)=>{var n,r;dn.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),vn=/*@__PURE__*/ W(`$ZodCheckRegex`,(e,t)=>{_n.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),yn={major:4,minor:4,patch:3},q=/*@__PURE__*/ W(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yn;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Kt(e),i;for(let a of t){if(a._zod.def.when){if(qt(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new At;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Kt(e,t))});else{if(e.issues.length===t)continue;r||=Kt(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Kt(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new At;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new At;return o.then(e=>t(e,r,a))}return t(o,r,a)}}G(e,`~standard`,()=>({validate:t=>{try{let n=an(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return on(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),bn=/*@__PURE__*/ W(`$ZodString`,(e,t)=>{q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??sn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),xn=/*@__PURE__*/ W(`$ZodNumber`,(e,t)=>{q.init(e,t),e._zod.pattern=e._zod.bag.pattern??ln,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Sn=/*@__PURE__*/ W(`$ZodNumberFormat`,(e,t)=>{mn.init(e,t),xn.init(e,t)}),Cn=/*@__PURE__*/ W(`$ZodBoolean`,(e,t)=>{q.init(e,t),e._zod.pattern=un,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),wn=/*@__PURE__*/ W(`$ZodNever`,(e,t)=>{q.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Tn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Jt(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function En(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Wt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Dn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Tn(e,n,i,t,u,d))):Tn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let On=/*@__PURE__*/ W(`$ZodObject`,(e,t)=>{if(q.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Ft(()=>En(t));G(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Bt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Tn(n,t,e,s,r,i))):Tn(a,t,e,s,r,i)}return i?Dn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}});function kn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Kt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Xt(e,r,Mt())))}),t)}let An=/*@__PURE__*/ W(`$ZodUnion`,(e,t)=>{q.init(e,t),G(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),G(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),G(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),G(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Lt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>kn(t,r,e,i)):kn(o,r,e,i)}}),jn=/*@__PURE__*/ W(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,An.init(e,t);let n=e._zod.parse;G(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=Ft(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Bt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Mn=/*@__PURE__*/ W(`$ZodEnum`,(e,t)=>{q.init(e,t);let n=Nt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Vt.has(typeof e)).map(e=>typeof e==`string`?Ht(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Nn=/*@__PURE__*/ W(`$ZodLiteral`,(e,t)=>{if(q.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ht(e):e?Ht(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}});function Pn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let Fn=/*@__PURE__*/ W(`$ZodOptional`,(e,t)=>{q.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,G(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),G(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Lt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Pn(e,r)):Pn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),In=/*@__PURE__*/ W(`$ZodNullable`,(e,t)=>{q.init(e,t),G(e._zod,`optin`,()=>t.innerType._zod.optin),G(e._zod,`optout`,()=>t.innerType._zod.optout),G(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Lt(e.source)}|null)$`):void 0}),G(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ln=/*@__PURE__*/ W(`$ZodCustom`,(e,t)=>{dn.init(e,t),q.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Rn(t,n,r,e));Rn(i,n,r,e)}});function Rn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Qt(e))}}// @__NO_SIDE_EFFECTS__
1366
+ function zn(e,t){return new e({type:`string`,...K(t)})}// @__NO_SIDE_EFFECTS__
1367
+ function Bn(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...K(t)})}// @__NO_SIDE_EFFECTS__
1368
+ function Vn(e,t){return new e({type:`boolean`,...K(t)})}// @__NO_SIDE_EFFECTS__
1369
+ function Hn(e,t){return new e({type:`never`,...K(t)})}// @__NO_SIDE_EFFECTS__
1370
+ function Un(e,t){return new pn({check:`greater_than`,...K(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
1371
+ function Wn(e){return/* @__PURE__ */ Un(0,e)}// @__NO_SIDE_EFFECTS__
1372
+ function Gn(e,t){return new hn({check:`max_length`,...K(t),maximum:e})}// @__NO_SIDE_EFFECTS__
1373
+ function Kn(e,t){return new gn({check:`min_length`,...K(t),minimum:e})}// @__NO_SIDE_EFFECTS__
1374
+ function qn(e,t){return new vn({check:`string_format`,format:`regex`,...K(t),pattern:e})}// @__NO_SIDE_EFFECTS__
1375
+ function Jn(e,t,n){let r=K(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
1376
+ function Yn(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...K(n)})}let J=/*@__PURE__*/ W(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);q.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>nn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>an(e,t,n),e.parseAsync=async(t,n)=>rn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>on(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Ut(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Xn=/*@__PURE__*/ W(`ZodMiniString`,(e,t)=>{bn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1377
+ function Y(e){return/* @__PURE__ */ zn(Xn,e)}let Zn=/*@__PURE__*/ W(`ZodMiniNumber`,(e,t)=>{xn.init(e,t),J.init(e,t)}),Qn=/*@__PURE__*/ W(`ZodMiniNumberFormat`,(e,t)=>{Sn.init(e,t),Zn.init(e,t)});// @__NO_SIDE_EFFECTS__
1378
+ function $n(e){return/* @__PURE__ */ Bn(Qn,e)}let er=/*@__PURE__*/ W(`ZodMiniBoolean`,(e,t)=>{Cn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1379
+ function tr(e){return/* @__PURE__ */ Vn(er,e)}let nr=/*@__PURE__*/ W(`ZodMiniNever`,(e,t)=>{wn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1380
+ function rr(e){return/* @__PURE__ */ Hn(nr,e)}let ir=/*@__PURE__*/ W(`ZodMiniObject`,(e,t)=>{On.init(e,t),J.init(e,t),G(e,`shape`,()=>t.shape)});// @__NO_SIDE_EFFECTS__
1381
+ function X(e,t){return new ir({type:`object`,shape:e,catchall:/* @__PURE__ */ rr(),...K(t)})}let ar=/*@__PURE__*/ W(`ZodMiniDiscriminatedUnion`,(e,t)=>{jn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1382
+ function or(e,t,n){return new ar({type:`union`,options:t,discriminator:e,...K(n)})}let sr=/*@__PURE__*/ W(`ZodMiniEnum`,(e,t)=>{Mn.init(e,t),J.init(e,t),e.options=Object.values(t.entries)});// @__NO_SIDE_EFFECTS__
1383
+ function cr(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new sr({type:`enum`,entries:n,...K(t)})}let lr=/*@__PURE__*/ W(`ZodMiniLiteral`,(e,t)=>{Nn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1384
+ function Z(e,t){return new lr({type:`literal`,values:Array.isArray(e)?e:[e],...K(t)})}let ur=/*@__PURE__*/ W(`ZodMiniOptional`,(e,t)=>{Fn.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1385
+ function dr(e){return new ur({type:`optional`,innerType:e})}let fr=/*@__PURE__*/ W(`ZodMiniNullable`,(e,t)=>{In.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1386
+ function pr(e){return new fr({type:`nullable`,innerType:e})}let mr=/*@__PURE__*/ W(`ZodMiniCustom`,(e,t)=>{Ln.init(e,t),J.init(e,t)});// @__NO_SIDE_EFFECTS__
1387
+ function hr(e,t){return/* @__PURE__ */ Jn(mr,e??(()=>!0),t)}// @__NO_SIDE_EFFECTS__
1388
+ function gr(e,t={}){return/* @__PURE__ */ Yn(mr,e,t)}let _r=[`selection_empty`,`selection_outside_conversation`,`selection_not_model_visible`,`selection_too_large`,`selection_stale`,`selection_crosses_unsupported_nodes`,`parent_session_missing`,`parent_session_not_ready`,`context_unavailable`,`context_too_large`,`side_chat_already_open`,`side_chat_not_found`,`side_chat_prompt_failed`,`side_chat_model_failed`,`side_chat_interrupt_failed`,`side_chat_destroy_failed`,`transport_error`,`invalid_request`,`internal_error`],Q=(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Kn(1),/* @__PURE__ */ Gn(512)),vr=/* @__PURE__ */ X({provider:Q,model:Q,reasoningEffort:/* @__PURE__ */ dr(Q)}),yr=/* @__PURE__ */ X({code:/* @__PURE__ */ cr(_r),message:/* @__PURE__ */ Y(),recoverable:/* @__PURE__ */ tr()}),br=/* @__PURE__ */ X({parentSessionId:Q,atSeq:(/* @__PURE__ */ $n()).check(/* @__PURE__ */ Wn()),selectedText:/* @__PURE__ */ dr((/* @__PURE__ */ Y()).check(/* @__PURE__ */ Gn(16384))),modelSelection:/* @__PURE__ */ dr(vr)}),xr=/* @__PURE__ */ X({parentSessionId:Q,atSeq:(/* @__PURE__ */ $n()).check(/* @__PURE__ */ Wn()),selectedText:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ gr(e=>/\S/u.test(e),`Select some conversation text first.`),/* @__PURE__ */ gr(e=>new TextEncoder().encode(e).length<=bt,`The selected text is too large.`))}),Sr=/* @__PURE__ */ X({chatId:Q}),Cr=/* @__PURE__ */ X({chatId:Q,provider:Q,model:Q,reasoningEffort:/* @__PURE__ */ dr(Q)}),wr=/* @__PURE__ */ X({chatId:Q,requestId:Q,text:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Kn(1),/* @__PURE__ */ Gn(65536))});function Tr(e){return/* @__PURE__ */ or(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:e}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:yr})])}let Er=Tr(/* @__PURE__ */ X({parentSessionId:Q,chatId:Q,boundarySeq:(/* @__PURE__ */ $n()).check(/* @__PURE__ */ Wn()),modelSelection:vr})),Dr=Tr(/* @__PURE__ */ X({prompt:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Kn(1))})),Or=Tr(/* @__PURE__ */ X({selected:vr})),kr=Tr(/* @__PURE__ */ X({closed:/* @__PURE__ */ Z(!0)})),Ar=Tr(/* @__PURE__ */ X({cancelled:/* @__PURE__ */ Z(!0)})),jr=/* @__PURE__ */ or(`type`,[/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`started`),requestId:Q,modelSelection:vr}),/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`content`),text:/* @__PURE__ */ Y(),reasoning:/* @__PURE__ */ Y()}),/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`finished`),status:/* @__PURE__ */ cr([`complete`,`stopped`])}),/* @__PURE__ */ X({type:/* @__PURE__ */ Z(`error`),error:yr})]),Mr=/* @__PURE__ */ hr(ve,`网页讨论快照格式无效。`),Nr=/* @__PURE__ */ hr(ye,`网页讨论引用格式无效。`),Pr=/* @__PURE__ */ X({sessionId:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Kn(1)),capture:Mr}),Fr=/* @__PURE__ */ X({sessionId:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ Kn(1)),referenceId:(/* @__PURE__ */ Y()).check(/* @__PURE__ */ qn(/^sha256:[a-f0-9]{64}$/u))}),Ir=/* @__PURE__ */ or(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:/* @__PURE__ */ X({reference:Nr})}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:yr})]),Lr=/* @__PURE__ */ or(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:/* @__PURE__ */ X({reference:Nr,capture:Mr})}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:yr})]);function Rr(e){return/* @__PURE__ */ hr(t=>e.safeParse(t).success,`网页登录数据格式无效。`)}function zr(e){return Rr(/* @__PURE__ */ or(`ok`,[/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!0),value:e}),/* @__PURE__ */ X({ok:/* @__PURE__ */ Z(!1),error:yr})]))}let Br=/* @__PURE__ */ hr(rt,`网页登录数据格式无效。`),Vr=Rr(/* @__PURE__ */ X({})),Hr=Rr(/* @__PURE__ */ X({state:Br})),Ur=zr(/* @__PURE__ */ X({state:/* @__PURE__ */ pr(Br)})),Wr=zr(/* @__PURE__ */ X({saved:/* @__PURE__ */ Z(!0)})),Gr=zr(/* @__PURE__ */ X({cleared:/* @__PURE__ */ Z(!0)}));function $(e,t,n,r,i,a={}){return{id:`dsh-more-details#moreDetails/${e}`,service:`moreDetails`,namespace:`moreDetails`,method:e,implementation:e,invocation:{kind:`direct`},...a.stream?{mode:`stream`}:{},...a.cancellation?{cancellation:{parameter:`signal`}}:{},parameters:[{name:`request`,wire:`request`,source:`json`,codec:{mode:`strict`,typeSymbol:`dsh-more-details/remote#${t}`,create:()=>r}}],result:{mode:`strict`,typeSymbol:`dsh-more-details/remote#${n}`,create:()=>i},sourceLocation:{file:`src/index.ts`,line:1,column:1}}}let Kr={package:`dsh-more-details`,descriptors:[$(`saveWebChatReference`,`SaveWebChatReferenceRequest`,`SaveWebChatReferenceResult`,Pr,Ir,{cancellation:!0}),$(`readWebChatReference`,`ReadWebChatReferenceRequest`,`ReadWebChatReferenceResult`,Fr,Lr,{cancellation:!0}),$(`readWebChatLogin`,`WebChatLoginRequest`,`ReadWebChatLoginResult`,Vr,Ur),$(`saveWebChatLogin`,`SaveWebChatLoginRequest`,`SaveWebChatLoginResult`,Hr,Wr),$(`clearWebChatLogin`,`WebChatLoginRequest`,`ClearWebChatLoginResult`,Vr,Gr),$(`prepareDetails`,`PrepareDetailsRequest`,`PrepareDetailsResult`,xr,Dr,{cancellation:!0}),$(`create`,`CreateSideChatRequest`,`CreateResult`,br,Er,{cancellation:!0}),$(`selectModel`,`SelectSideChatModelRequest`,`SelectModelResult`,Cr,Or,{cancellation:!0}),$(`stream`,`SendSideChatRequest`,`SideChatStreamEvent`,wr,jr,{stream:!0,cancellation:!0}),$(`cancel`,`ChatRequest`,`CancelResult`,Sr,Ar),$(`close`,`ChatRequest`,`CloseResult`,Sr,kr)]};function qr(e){let t=e.code,n=t===`bad-request`||t===`gateway/bad-request`;return{code:n?`invalid_request`:`transport_error`,message:e.message||`The Side Chat RPC failed.`,recoverable:!n}}async function Jr(e){let t=await e;return t.ok?t.value:{ok:!1,error:qr(t.error)}}async function Yr(e,t){try{let t=await e;if(t.ok&&t.value.ok)return t.value.value}catch{}throw Error(t)}async function Xr(e){let t=await e.remote.$mount(Kr),n=e.get(`remote.moreDetails`);return{prepareDetails:e=>Jr(n.prepareDetails(e)),saveWebChatReference:e=>Jr(n.saveWebChatReference(e)),loginStore:{read:async()=>(await Yr(n.readWebChatLogin({}),`无法读取已保存的网页登录状态。`)).state,save:async e=>{await Yr(n.saveWebChatLogin({state:e}),`无法保存网页登录状态。`)},clear:async()=>{await Yr(n.clearWebChatLogin({}),`无法清除已保存的网页登录状态。`)}},remote:{create:e=>Jr(n.create(e)),selectModel:e=>Jr(n.selectModel(e)),stream:e=>n.stream(e),cancel:e=>Jr(n.cancel(e)),close:e=>Jr(n.close(e))},dispose:t}}let Zr={en:{selectModel:`Select model`,menu:`Model and reasoning effort`,model:`Model`,effort:`Effort`,providerDefault:`Default`,loading:`Refreshing model list…`,reload:`Reload`,emptyModels:`No models available.`,emptyEfforts:`This model provides no reasoning effort levels.`,nextReply:`Changes apply to the next reply and future Side Chats.`,aria:(e,t)=>t===void 0?`Select model, current ${e}`:`Select model, current ${e}, reasoning effort ${t}`,operationFailed:e=>`Model operation failed: ${e}`,groupFailed:(e,t)=>`${e} failed to load: ${t}`},"zh-CN":{selectModel:`选择模型`,menu:`模型与推理等级`,model:`模型`,effort:`推理等级`,providerDefault:`Default`,loading:`正在刷新模型列表…`,reload:`重新加载`,emptyModels:`没有可用的模型。`,emptyEfforts:`当前模型未提供推理等级。`,nextReply:`修改将用于下一次回复及之后新开的侧边对话。`,aria:(e,t)=>t===void 0?`选择模型,当前 ${e}`:`选择模型,当前 ${e},推理等级 ${t}`,operationFailed:e=>`模型操作失败:${e}`,groupFailed:(e,t)=>`${e} 加载失败:${t}`}};function Qr(e,t,n){return e?.provider===t&&e.model===n}function $r(e,t){return e.provider===t.provider&&e.model===t.model&&e.reasoningEffort===t.reasoningEffort}function ei(e,t,n){let r=t.find(t=>Qr(e,t.group.id,t.model.id));if(r===void 0)return n;let i=r.model.reasoning;return i===void 0?{provider:e.provider,model:e.model}:e.reasoningEffort===void 0||i.efforts.some(t=>t.id===e.reasoningEffort)?e:{provider:e.provider,model:e.model,...i.defaultEffort===void 0?{}:{reasoningEffort:i.defaultEffort}}}function ti({directory:e,selection:t,locked:n,running:o=!1,validateInitialSelection:s=!0,locale:c=`en`,onInitialize:l,onSelect:u}){let d=Zr[c],f=(0,r.useSyncExternalStore)(t=>e.store.subscribe(t),()=>e.store.getSnapshot(),()=>e.store.getSnapshot()),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(`root`),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),x=(0,r.useRef)(null),S=(0,r.useRef)(null),C=(0,r.useRef)([]),w=(0,r.useRef)(!1),T=(0,r.useRef)(0),E=(0,r.useRef)(0),D=(0,r.useRef)(!1),O=(0,r.useId)(),k=(0,r.useMemo)(()=>f.groups.flatMap(e=>e.models.map(t=>({group:e,model:t}))),[f.groups]),A=t??f.current??void 0,j=k.find(e=>Qr(A,e.group.id,e.model.id)),M=j?.model.reasoning,N=A?.reasoningEffort??M?.defaultEffort,P=M===void 0?void 0:N===void 0?d.providerDefault:M.efforts.find(e=>e.id===N)?.name??N,F=(0,r.useMemo)(()=>M===void 0?[]:[...M.defaultEffort===void 0?[{key:`provider-default`,effort:void 0,label:d.providerDefault}]:[],...M.efforts.map(e=>({key:`effort:${e.id}`,effort:e.id,label:e.name,...e.description===void 0?{}:{description:e.description}}))],[d.providerDefault,M]),I=j?.model.name??A?.model??d.selectModel,ee=P===void 0?I:`${I} · ${P}`,L=()=>{e.load().catch(()=>void 0)};(0,r.useEffect)(()=>(w.current=!1,L(),()=>{++T.current}),[e]),(0,r.useEffect)(()=>{n&&m(!1)},[n]),(0,r.useEffect)(()=>{if(w.current||n)return;if(t!==void 0&&!s){w.current=!0;return}if(f.current===null)return;let e={provider:f.current.provider,model:f.current.model,...f.current.reasoningEffort===void 0?{}:{reasoningEffort:f.current.reasoningEffort}};if(t===void 0){w.current=!0,l(e,{remember:!1});return}if(f.status!==`ready`||f.error!==null||f.failures.length>0)return;w.current=!0;let r=ei(t,k,e);$r(t,r)||l(r,{remember:!0})},[k,n,l,t,f.current,f.status,f.error,f.failures,s]),(0,r.useEffect)(()=>{if(!p)return;let e=e=>{x.current?.contains(e.target)||m(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[p]);let te=()=>{g(`root`),m(!0),L()},R=(e=!1)=>{m(!1),g(`root`),e&&queueMicrotask(()=>{S.current?.focus()})},ne=e=>{let t=C.current.filter(e=>e!==null);if(t.length===0)return;let n=t.findIndex(e=>e===document.activeElement);t[(Math.max(n,0)+e+t.length)%t.length]?.focus()},re=e=>{e.key===`Escape`&&p?(e.preventDefault(),e.stopPropagation(),h===`root`?R(!0):g(`root`)):!p||e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),ne(e.key===`ArrowDown`?1:-1))},ie=e=>{e.relatedTarget instanceof Node&&x.current?.contains(e.relatedTarget)||R()},ae=async e=>{if(n||D.current)return;let t=++T.current;D.current=!0,v(!0);try{let n=await u(e);if(t!==T.current)return;if(!n.ok)throw Error(n.error.message);R(!0)}catch(e){if(t!==T.current)return;b({seq:++E.current,text:d.operationFailed(e instanceof Error?e.message:`Could not select the model.`)})}finally{D.current=!1,t===T.current&&v(!1)}},oe=(e,t)=>{Qr(A,e.id,t.id)?R(!0):ae({provider:e.id,model:t.id,...t.reasoning?.defaultEffort===void 0?{}:{reasoningEffort:t.reasoning.defaultEffort}})},se=e=>{A!==void 0&&ae({provider:A.provider,model:A.model,...e===void 0?{}:{reasoningEffort:e}})};C.current=[];let ce=0,le=()=>{let e=ce++;return t=>{C.current[e]=t}};return/* @__PURE__ */ (0,i.jsxs)(`div`,{ref:x,className:`dsh-more-details-model-root`,"data-side-chat-model-select":``,onKeyDown:re,onBlur:ie,children:[/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:S,type:`button`,className:`dsh-more-details-model-trigger`,"aria-label":d.aria(I,P),"aria-haspopup":`menu`,"aria-expanded":p,"aria-controls":p?`${O}-menu`:void 0,title:ee,disabled:n,onClick:()=>{p?R():te()},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-trigger-label`,children:I}),P!==void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-trigger-effort`,children:P}),/* @__PURE__ */ (0,i.jsx)(a.IconChevronDownOutlineRegular,{className:`dsh-more-details-model-chevron${p?` dsh-more-details-model-chevron-open`:``}`})]}),p&&/* @__PURE__ */ (0,i.jsxs)(`div`,{id:`${O}-menu`,className:`dsh-more-details-model-menu`,role:`menu`,"aria-label":d.menu,"aria-busy":f.status===`loading`||_,children:[o&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-status`,children:d.nextReply}),h===`root`&&/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitem`,className:`dsh-more-details-model-cell`,onClick:()=>{g(`model`)},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-label`,children:d.model}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-value`,children:I}),/* @__PURE__ */ (0,i.jsx)(a.IconChevronRightOutlineRegular,{className:`dsh-more-details-model-cell-chevron`})]}),M!==void 0&&/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitem`,className:`dsh-more-details-model-cell`,onClick:()=>{g(`effort`)},children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-label`,children:d.effort}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-cell-value`,children:P}),/* @__PURE__ */ (0,i.jsx)(a.IconChevronRightOutlineRegular,{className:`dsh-more-details-model-cell-chevron`})]})]}),h===`model`&&/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[f.status===`loading`&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-status`,children:d.loading}),f.error!==null&&/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-model-error`,role:`alert`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{children:d.operationFailed(f.error)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-model-retry`,onClick:L,children:d.reload})]}),f.failures.map(e=>/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-model-warning`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{children:d.groupFailed(e.name,e.message)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-model-retry`,onClick:L,children:d.reload})]},e.id)),/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-groups scrollable`,children:f.groups.map(e=>{let t=`${O}-${e.id}`;return/* @__PURE__ */ (0,i.jsxs)(`section`,{role:`group`,"aria-labelledby":t,className:`dsh-more-details-model-group`,children:[/* @__PURE__ */ (0,i.jsx)(`div`,{id:t,className:`dsh-more-details-model-group-title`,children:e.name}),e.models.map(t=>{let r=Qr(A,e.id,t.id);return/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitemradio`,"aria-checked":r,className:`dsh-more-details-model-option${r?` dsh-more-details-model-selected`:``}`,title:t.name,disabled:n||_,onClick:()=>{oe(e,t)},children:[/* @__PURE__ */ (0,i.jsxs)(`span`,{className:`dsh-more-details-model-option-copy`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-name`,children:t.name}),t.description!==void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-description`,children:t.description})]}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-check`,children:r?/* @__PURE__ */ (0,i.jsx)(a.IconCheckOutlineRegular,{}):null})]},t.id)})]},e.id)})}),f.status===`ready`&&k.length===0&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-empty`,children:d.emptyModels})]}),h===`effort`&&(F.length===0?/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-model-empty`,children:d.emptyEfforts}):F.map(e=>{let t=N===e.effort;return/* @__PURE__ */ (0,i.jsxs)(`button`,{ref:le(),type:`button`,role:`menuitemradio`,"aria-checked":t,className:`dsh-more-details-model-option${t?` dsh-more-details-model-selected`:``}`,disabled:n||_,onClick:()=>{se(e.effort)},children:[/* @__PURE__ */ (0,i.jsxs)(`span`,{className:`dsh-more-details-model-option-copy`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-name`,children:e.label}),e.description!==void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-description`,children:e.description})]}),/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-model-check`,children:t?/* @__PURE__ */ (0,i.jsx)(a.IconCheckOutlineRegular,{}):null})]},e.key)}))]}),y!==null&&/* @__PURE__ */ (0,i.jsx)(a.Toast,{text:y.text,icon:/* @__PURE__ */ (0,i.jsx)(a.IconWarningOutlineRegular,{}),anchor:x.current?.closest(`[data-composer-card]`)??null,onDone:()=>{b(null)}},y.seq)]})}function ni(){return/* @__PURE__ */ (0,i.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z`,fill:`currentColor`})})}function ri({children:e}){return/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-body`,children:e})}function ii({error:e,messages:t,onRetry:n}){return/* @__PURE__ */ (0,i.jsxs)(`section`,{className:`dsh-more-details-error`,role:`alert`,children:[/* @__PURE__ */ (0,i.jsx)(`strong`,{children:e.operation===`close`?t.closeError:t.genericError}),/* @__PURE__ */ (0,i.jsx)(`p`,{children:e.message}),e.recoverable&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onClick:n,children:t.retry})]})}function ai(){return/* @__PURE__ */ (0,i.jsxs)(`svg`,{className:`dsh-more-details-add-to-conversation-icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M4.25 4.5h11.5v8.25H9l-3.5 2.75v-2.75H4.25z`}),/* @__PURE__ */ (0,i.jsx)(`path`,{d:`M10 6.5v4M8 8.5h4`})]})}function oi({phase:e,messages:t,addToConversationDisabled:n=!1,onAddToConversation:r,onFocusParent:a,onClose:o}){return/* @__PURE__ */ (0,i.jsxs)(`header`,{className:`dsh-more-details-header`,children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-heading`,onClick:a,children:/* @__PURE__ */ (0,i.jsx)(`strong`,{children:t.title})}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-header-actions`,children:[r!==void 0&&/* @__PURE__ */ (0,i.jsxs)(`button`,{type:`button`,className:`dsh-more-details-add-to-conversation`,disabled:n,onClick:r,children:[/* @__PURE__ */ (0,i.jsx)(ai,{}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:t.addToConversation})]}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-close`,"aria-label":t.close,disabled:e===`closing`,onClick:o,children:`×`})]})]})}function si(e){let t=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=t.current;if(e===null)return;e.style.height=`auto`;let n=Number.parseFloat(getComputedStyle(e).maxHeight),r=Number.isFinite(n)?Math.min(e.scrollHeight,n):e.scrollHeight;e.style.height=`${String(r)}px`,e.style.overflowY=Number.isFinite(n)&&e.scrollHeight>n?`auto`:`hidden`},[e]),t}function ci({state:e,locale:t=`en`,embeddedConversation:n,modelControl:a,onDraftChange:o,onFirstSend:s,onClose:c,onRetry:l,onFocusParent:u,onAddToConversation:d,addToConversationDisabled:f,onRemoveSelection:p}){let m=F[t],[h,g]=(0,r.useState)(!1),_=si(e.draft),v=async t=>{if(t.preventDefault(),!(h||[`creating`,`running`,`closing`].includes(e.phase))){g(!0);try{await s(e.draft)}finally{g(!1)}}};return/* @__PURE__ */ (0,i.jsxs)(`aside`,{className:`dsh-more-details-panel`,"data-side-chat-panel":``,"aria-label":m.title,"aria-busy":[`creating`,`closing`].includes(e.phase)||void 0,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),c())},children:[/* @__PURE__ */ (0,i.jsx)(oi,{phase:e.phase,messages:m,...d===void 0?{}:{onAddToConversation:d},...f===void 0?{}:{addToConversationDisabled:f},onFocusParent:u,onClose:()=>{c()}}),e.error!==void 0&&/* @__PURE__ */ (0,i.jsx)(ii,{error:e.error,messages:m,onRetry:()=>{l()}}),e.messages.length>0&&n!==void 0?/* @__PURE__ */ (0,i.jsx)(ri,{children:n}):/* @__PURE__ */ (0,i.jsxs)(`form`,{className:`dsh-more-details-draft`,"data-composer-card":``,onSubmit:e=>{v(e)},children:[e.selection!==void 0&&/* @__PURE__ */ (0,i.jsx)(I,{selections:[e.selection],messages:m,...p===void 0?{}:{onRemove:p}}),/* @__PURE__ */ (0,i.jsx)(`label`,{htmlFor:`dsh-more-details-draft-input`,children:m.placeholder}),/* @__PURE__ */ (0,i.jsx)(`textarea`,{id:`dsh-more-details-draft-input`,ref:_,autoFocus:!0,rows:1,value:e.draft,disabled:[`creating`,`running`,`closing`].includes(e.phase),placeholder:m.placeholder,onChange:e=>{o(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-draft-actions`,children:[a,/* @__PURE__ */ (0,i.jsx)(`button`,{type:`submit`,className:`dsh-more-details-send-button`,"aria-label":m.send,disabled:h||[`creating`,`running`,`closing`].includes(e.phase)||e.draft.trim().length===0,children:/* @__PURE__ */ (0,i.jsx)(ni,{})})]})]}),/* @__PURE__ */ (0,i.jsxs)(`footer`,{className:`dsh-more-details-footer`,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.temporary}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.referenceOnly}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.cannotReopen}),/* @__PURE__ */ (0,i.jsx)(`span`,{children:m.readOnly})]}),/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-announcer`,"aria-live":`polite`,children:e.phase===`running`?`Side Chat running`:`Side Chat ${e.phase}`})]})}function li(e){return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[data-chat-anchor-key]`)??null}function ui(e,t){let n=e.parentElement;return n===null||!t.contains(n)||n.closest(`[data-selection-exclude],[data-side-chat-panel],[aria-hidden="true"],[hidden],[inert],script,style,button,textarea,input,[role="button"]`)!==null}function di(e,t){let n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=r.nextNode();for(;i!==null;){let a=i;!ui(a,t)&&li(a)===e&&n.push(a),i=r.nextNode()}return n}function fi(e,t){if(!e.intersectsNode(t))return;let n=e.startContainer===t?e.startOffset:0,r=e.endContainer===t?e.endOffset:t.data.length;if(n>0&&/[\uDC00-\uDFFF]/u.test(t.data[n]??``)&&/[\uD800-\uDBFF]/u.test(t.data[n-1]??``)&&--n,r>0&&r<t.data.length&&/[\uD800-\uDBFF]/u.test(t.data[r-1]??``)&&/[\uDC00-\uDFFF]/u.test(t.data[r]??``)&&(r+=1),!(r<=n))return{start:n,end:r,text:t.data.slice(n,r)}}async function pi(e){let t=e.selection?.rangeCount===1?e.selection.getRangeAt(0):void 0;if(t===void 0||t.collapsed)throw new B(`selection_empty`,`Select some conversation text first.`);if(!e.conversationRoot.contains(t.startContainer)||!e.conversationRoot.contains(t.endContainer))throw new B(`selection_outside_conversation`,`The selection must stay inside the current conversation.`);let n=li(t.startContainer),r=li(t.endContainer);if(n===null||r===null||n!==r)throw new B(`selection_crosses_unsupported_nodes`,`Select a passage inside one message.`);let i=e.resolver.resolve(n);if(i===void 0)throw new B(`selection_stale`,`The selected message is no longer in the Session snapshot.`);let a=di(n,e.conversationRoot),o=[],s,c,l=0;for(let e of a){let n=fi(t,e);n!==void 0&&(s??=l+n.start,c=l+n.end,o.push(n.text)),l+=e.data.length}if(s===void 0||c===void 0)throw new B(`selection_not_model_visible`,`The selection contains no supported visible text.`);let u=t.getBoundingClientRect();return await Tt({parentSessionId:e.parentSessionId,fragments:[{...i,startOffset:s,endOffset:c,text:o.join(``)}],rawText:o.join(``),rect:{x:u.x,y:u.y,width:u.width,height:u.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}})}function mi(e,t){return[...e.querySelectorAll(`[data-chat-anchor-key]`)].find(e=>e.dataset.chatAnchorKey===t)}function hi(e,t){let n=mi(e,t.nodeKey);if(n===void 0)return;let r=di(n,e),i=r.map(e=>e.data).join(``);if(!Number.isSafeInteger(t.startOffset)||!Number.isSafeInteger(t.endOffset)||t.startOffset<0||t.endOffset<=t.startOffset||t.endOffset>i.length||i.slice(t.startOffset,t.endOffset)!==t.text)return;let a=[],o=0;for(let e of r){let n=o+e.data.length,r=Math.max(t.startOffset,o)-o,i=Math.min(t.endOffset,n)-o;if(i>r){let t=document.createRange();t.setStart(e,r),t.setEnd(e,i),a.push(t)}if(o=n,o>=t.endOffset)break}return a.length===0?void 0:a}function gi(e){let t=[];for(let n of e.selection.fragments){let r=hi(e.conversationRoot,n);if(r===void 0)return;t.push(...r)}let n=t[0],r=t.at(-1);if(n===void 0||r===void 0)return;let i=document.createRange();return i.setStart(n.startContainer,n.startOffset),i.setEnd(r.endContainer,r.endOffset),{ranges:t,browserRange:i}}function _i(e){return[...document.querySelectorAll(`[data-conversation-session]`)].find(t=>t.dataset.conversationSession===e&&t.closest(`[data-side-chat-panel], [hidden], [aria-hidden="true"]`)===null)}function vi(e){return _i(e)?.querySelector(`[data-chat-flow]`)??void 0}function yi(e){window.requestAnimationFrame(()=>{let t=_i(e)?.querySelector(`[data-composer-seat] textarea, [data-composer-seat] [role="textbox"], [data-composer-seat] [contenteditable="true"]`);t!=null&&(t.focus(),t instanceof HTMLTextAreaElement&&t.setSelectionRange(t.value.length,t.value.length))})}let bi=`dsh-more-details-annotations`,xi=`dsh-more-details-active-annotation`;function Si(e,t,n){return Math.min(Math.max(t,e),Math.max(t,n))}function Ci(e){let t=Number.isFinite(e.left)?e.left:e.x,n=Number.isFinite(e.top)?e.top:e.y,r=Number.isFinite(e.right)?e.right:t+e.width,i=Number.isFinite(e.bottom)?e.bottom:n+e.height;return[t,n,r,i].every(Number.isFinite)?{left:t,top:n,right:r,bottom:i}:void 0}function wi(e){let t=[];for(let n of e){let e=typeof n.getClientRects==`function`?[...n.getClientRects()]:[],r=e.length>0?e:typeof n.getBoundingClientRect==`function`?[n.getBoundingClientRect()]:[];for(let e of r){let n=Ci(e);n!==void 0&&(n.right>n.left||n.bottom>n.top)&&t.push(n)}}if(t.length!==0)return{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top)),right:Math.max(...t.map(e=>e.right)),bottom:Math.max(...t.map(e=>e.bottom))}}function Ti(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function Ei(e){let t={left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},n=e.startContainer,r=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(`[data-conversation-scroll]`);if(r==null)return t;let i=Ci(r.getBoundingClientRect());i!==void 0&&i.right>i.left&&i.bottom>i.top&&(t={left:Math.max(t.left,i.left),top:Math.max(t.top,i.top),right:Math.min(t.right,i.right),bottom:Math.min(t.bottom,i.bottom)});let a=r.querySelector(`[data-composer-seat]`),o=a===null?void 0:Ci(a.getBoundingClientRect());return o!==void 0&&o.right>o.left&&o.bottom>o.top&&o.bottom>t.top&&o.top<t.bottom&&(t={...t,bottom:Math.min(t.bottom,o.top)}),t}function Di(e,t){return e.right>t.left&&e.bottom>t.top&&e.left<t.right&&e.top<t.bottom}function Oi(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!==void 0&&r.annotationIndex===e.annotationIndex&&r.left===e.left&&r.top===e.top})}function ki(){typeof CSS<`u`&&CSS.highlights!==void 0&&(CSS.highlights.delete(bi),CSS.highlights.delete(xi))}function Ai(e,t){if(typeof CSS>`u`||CSS.highlights===void 0||typeof Highlight>`u`)return;if(CSS.highlights.set(bi,new Highlight(...e)),t.length===0){CSS.highlights.delete(xi);return}let n=new Highlight(...t);n.priority=1,CSS.highlights.set(xi,n)}function ji(e){let t=window.getSelection();t!==null&&(t.removeAllRanges(),t.addRange(e))}function Mi({annotations:e,activeAnnotationIndex:t,onEdit:n}){let a=(0,r.useRef)(/* @__PURE__ */ new Map),[o,s]=(0,r.useState)([]);return(0,r.useEffect)(()=>{if(e.length===0){a.current.clear(),s(e=>e.length===0?e:[]),ki();return}let n,r=null,i,o=()=>{n=void 0;let o=e[0]?.selection.parentSessionId,c=o===void 0?null:vi(o)??null;c!==r&&(i?.disconnect(),r=c,c!==null&&i?.observe(c));let l=/* @__PURE__ */ new Map,u=[],d=[],f=[];if(c!==null)for(let n of e){if(n.selection.parentSessionId!==o)continue;let e=gi({selection:n.selection,conversationRoot:c});if(e===void 0)continue;d.push(...e.ranges),n.annotationIndex===t&&f.push(...e.ranges);let r=wi(e.ranges),i=Ei(e.browserRange);if(r===void 0||!Di(r,i))continue;let a=Ti(r);l.set(n.annotationIndex,{browserRange:e.browserRange,rect:a}),u.push({annotationIndex:n.annotationIndex,left:Si(r.right+3,i.left+4,i.right-26),top:Si(r.top-12,i.top+4,i.bottom-26)})}a.current=l,s(e=>Oi(e,u)?e:u),Ai(d,f)},c=()=>{n===void 0&&(n=window.requestAnimationFrame(o))};i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(c),o();let l=new MutationObserver(c);return l.observe(document.body,{childList:!0,characterData:!0,subtree:!0}),document.addEventListener(`scroll`,c,!0),window.addEventListener(`resize`,c),()=>{n!==void 0&&window.cancelAnimationFrame(n),l?.disconnect(),i?.disconnect(),document.removeEventListener(`scroll`,c,!0),window.removeEventListener(`resize`,c),ki()}},[t,e]),o.map(r=>{let o=e.find(e=>e.annotationIndex===r.annotationIndex);if(o===void 0)return null;let s={left:r.left,top:r.top},c=o.annotationIndex+1,l=c>99?`99+`:String(c);return/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,className:`dsh-more-details-annotation-marker`,style:s,"data-active":o.annotationIndex===t||void 0,"data-large":c>99||void 0,"aria-label":`Edit annotation ${String(c)}`,title:`Edit annotation ${String(c)}`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:()=>{let e=a.current.get(o.annotationIndex);e!==void 0&&(ji(e.browserRange),n(o,{...o.selection,rect:e.rect}),window.requestAnimationFrame(()=>{ji(e.browserRange)}))},children:l},`${o.selection.parentSessionId}:${o.selection.fragments[0]?.nodeKey??``}:${String(o.annotationIndex)}`)})}function Ni(e,t,n){return Math.min(Math.max(t,e),Math.max(t,n))}function Pi(e,t,n,r={width:e.viewportWidth,height:e.viewportHeight}){let i=Math.max(0,t.width),a=Math.max(0,t.height),o=r.offsetLeft??0,s=r.offsetTop??0,c=o+r.width,l=s+r.height,u=Ni(e.x+e.width/2-i/2,o+8,c-i-8),d=n?12:8,f=n?64:8,p=e.y+e.height+d,m=e.y-a-f,h=p+a<=l-8,g=m>=s+8,_;return _=h?p:g||e.y-f-s-8>=l-8-e.y-e.height-d?m:p,{left:u,top:Ni(_,s+8,l-a-8)}}function Fi({text:e,selection:t,touchInteraction:n=!1,askDisabledReason:a,moreDetailsDisabledReason:o,annotationNumber:s=1,annotationEditor:c,onAddToChat:l,onMoreDetails:u,onAskInSideChat:d,onAnnotationEditorChange:f,onRemoveAnnotation:p,onDismiss:m}){let[h,g]=(0,r.useState)(c!==void 0),[_,v]=(0,r.useState)(c?.initialComment??``),[y,b]=(0,r.useState)(()=>({width:0,height:0})),[x,S]=(0,r.useState)(()=>({width:t.rect.viewportWidth,height:t.rect.viewportHeight,offsetLeft:0,offsetTop:0})),C=(0,r.useRef)(null),w=(0,r.useRef)(null),T=(0,r.useRef)(null),E=Pi(t.rect,y,n,x),D={left:E.left,top:E.top},O=x.offsetLeft,k=x.offsetTop,A=O+x.width,j=k+x.height,M=Math.max(0,Math.min(420,x.width-16)),N=t.rect.y-118,P=t.rect.y+t.rect.height+12,F={left:Ni(t.rect.x+t.rect.width+28,O+8,A-M-8),top:Ni(N>=k+8?N:P,k+8,j-118-8),width:M},I={left:Ni(t.rect.x+t.rect.width+3,O+4,A-22-4),top:Ni(t.rect.y-12,k+4,j-22-4)},ee=s>99?`99+`:String(s),L=e=>{e.preventDefault()};(0,r.useLayoutEffect)(()=>{let e=window.visualViewport,n=()=>{let n={width:e?.width??window.innerWidth??t.rect.viewportWidth,height:e?.height??window.innerHeight??t.rect.viewportHeight,offsetLeft:e?.offsetLeft??0,offsetTop:e?.offsetTop??0};S(e=>e.width===n.width&&e.height===n.height&&e.offsetLeft===n.offsetLeft&&e.offsetTop===n.offsetTop?e:n);let r=w.current;if(r===null)return;let i=r.getBoundingClientRect(),a={width:i.width,height:i.height};b(e=>e.width===a.width&&e.height===a.height?e:a)};n();let r=w.current,i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return r!==null&&i?.observe(r),window.addEventListener(`resize`,n),e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n),()=>{i?.disconnect(),window.removeEventListener(`resize`,n),e?.removeEventListener(`resize`,n),e?.removeEventListener(`scroll`,n)}},[h,t,n]),(0,r.useEffect)(()=>{h&&C.current?.focus()},[h]);let te=()=>{g(!1),v(``),f?.(!1),m()},R=()=>{let e=_.trim();l(t,e.length===0?void 0:e),f?.(!1),m()},ne=e=>{e.preventDefault(),R()},re=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),te()):e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),R())},ie=()=>{g(!0),f?.(!0)},ae=()=>{u(t),m()},oe=()=>{d(t),m()},se=(e,t)=>{n&&e.pointerType===`touch`&&!e.currentTarget.disabled&&(e.preventDefault(),T.current={target:e.currentTarget,timeStamp:e.timeStamp},t())},ce=(e,t)=>{let n=T.current;T.current=null;let r=n===null?1/0:e.timeStamp-n.timeStamp;e.detail!==0&&n?.target===e.currentTarget&&r>=0&&r<1e3?e.preventDefault():t()};return h?/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[c===void 0&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-selection-marker`,"aria-hidden":`true`,"data-large":s>99||void 0,style:I,children:ee}),/* @__PURE__ */ (0,i.jsxs)(`form`,{className:`dsh-more-details-selection-comment`,role:`dialog`,"aria-label":c?.dialogLabel??e(`添加批注`,`Add annotation comment`),style:F,onSubmit:ne,onMouseDown:e=>{e.stopPropagation()},onKeyUp:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,i.jsx)(`textarea`,{ref:C,value:_,rows:2,"aria-label":e(`批注内容(可选)`,`Optional annotation comment`),placeholder:e(`添加批注(可选)…`,`Add an optional comment…`),onChange:e=>{v(e.currentTarget.value)},onKeyDown:re}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-selection-comment-actions`,children:[c!==void 0&&p!==void 0&&/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onClick:p,children:e(`移除`,`Remove`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onClick:te,children:e(`取消`,`Cancel`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`submit`,className:`dsh-more-details-selection-comment-save`,children:e(`保存`,`Save`)})]})]})]}):/* @__PURE__ */ (0,i.jsxs)(`div`,{ref:w,className:`dsh-more-details-selection-actions`,role:`toolbar`,"aria-label":e(`所选会话文字操作`,`Selected conversation text actions`),"data-touch":n||void 0,style:D,onMouseDown:L,onPointerDown:e=>{n&&e.pointerType===`touch`&&e.preventDefault()},onKeyDown:e=>{e.key===`Escape`&&m()},children:[/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{se(e,ie)},onClick:e=>{ce(e,ie)},children:e(`添加到聊天`,`Add to chat`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:o!==void 0,title:o,onPointerDown:e=>{se(e,ae)},onClick:e=>{ce(e,ae)},children:e(`更多详情`,`More details`)}),/* @__PURE__ */ (0,i.jsx)(`button`,{type:`button`,disabled:a!==void 0,title:a,onPointerDown:e=>{se(e,oe)},onClick:e=>{ce(e,oe)},children:e(`在侧边对话中提问`,`Ask in side chat`)})]})}function Ii(){return/* @__PURE__ */ (0,i.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,i.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})})}let Li={code:{copyLabel:`Copy`,copiedLabel:`Copied`},footnotes:`Footnotes`};function Ri({text:e,running:t}){let[n,o]=(0,r.useState)(!1),s=e.trimEnd().split(`
1389
+ `);return/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-reasoning`,"data-variant":`think`,"data-state":t?`running`:`ok`,children:/* @__PURE__ */ (0,i.jsx)(a.DisclosureRow,{rowClassName:`dsh-more-details-reasoning-row`,leadingClassName:`dsh-more-details-reasoning-leading`,titleClassName:`dsh-more-details-reasoning-title`,chevronClassName:`dsh-more-details-reasoning-chevron`,icon:/* @__PURE__ */ (0,i.jsx)(a.IconThinkOutlineRegular,{size:14}),title:`Think`,open:n,expandable:!0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},collapsedContent:/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-reasoning-summary`,children:t?s.at(-1):s[0]}),children:/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-reasoning-body`,children:e})})})}function zi({message:e,locale:t}){let n=/* @__PURE__ */ (0,i.jsxs)(`article`,{className:`dsh-more-details-message`,"data-role":e.role,children:[/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-message-role`,children:e.role===`user`?`You`:`Assistant`}),e.role===`user`?/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-message-text`,children:e.text}):/* @__PURE__ */ (0,i.jsxs)(i.Fragment,{children:[e.reasoning&&/* @__PURE__ */ (0,i.jsx)(Ri,{text:e.reasoning,running:e.status===`streaming`}),/* @__PURE__ */ (0,i.jsx)(a.MarkdownText,{text:e.text,streaming:e.status===`streaming`,labels:Li}),e.status===`streaming`&&e.text===``&&!e.reasoning&&/* @__PURE__ */ (0,i.jsx)(`span`,{children:`Thinking…`}),e.status===`stopped`&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-message-note`,children:`Stopped`}),e.status===`error`&&/* @__PURE__ */ (0,i.jsx)(`span`,{className:`dsh-more-details-message-note`,children:`Reply failed`})]})]});return e.selectedText===void 0?n:/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-annotated-user-message`,children:[/* @__PURE__ */ (0,i.jsx)(I,{selections:[{text:e.selectedText}],messages:F[t]}),n]})}function Bi({state:e,controller:t,modelControl:n,locale:a=`en`}){let[o,s]=(0,r.useState)(``),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(),m=(0,r.useRef)(!1),h=(0,r.useRef)(!1),g=(0,r.useRef)(0),_=(0,r.useRef)(!0),v=(0,r.useRef)(null),y=si(o),b=e.phase===`running`,x=b||u,S=[`ready`,`running`].includes(e.phase);(0,r.useEffect)(()=>{let e=v.current;e!==null&&_.current&&(e.scrollTop=e.scrollHeight)},[e.messages]);let C=async e=>{if(e.preventDefault(),o.trim().length===0||!S||b||m.current||h.current)return;let n=g.current;m.current=!0,l(!0),p(void 0);try{let e=await t.send(o);e.ok&&n===g.current?s(``):!e.ok&&t.getSnapshot().error?.message!==e.error.message&&p(e.error.message)}catch{p(`The message could not be sent. Your draft has been kept.`)}finally{m.current=!1,l(!1)}},w=async()=>{if(!h.current){h.current=!0,d(!0),p(void 0);try{let e=await t.cancel();e.ok||p(e.error.message)}catch{p(`The request could not be stopped. Try closing Side Chat.`)}finally{h.current=!1,d(!1)}}};return/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-conversation`,children:[/* @__PURE__ */ (0,i.jsxs)(`div`,{ref:v,className:`dsh-more-details-transcript`,"aria-live":`polite`,onScroll:e=>{let t=e.currentTarget;_.current=t.scrollHeight-t.scrollTop-t.clientHeight<48},children:[e.messages.map(e=>/* @__PURE__ */ (0,i.jsx)(zi,{message:e,locale:a},e.id)),f!==void 0&&/* @__PURE__ */ (0,i.jsx)(`div`,{className:`dsh-more-details-turn-notice`,role:`alert`,children:f})]}),/* @__PURE__ */ (0,i.jsxs)(`form`,{className:`dsh-more-details-composer`,"data-composer-card":``,onSubmit:e=>{C(e)},children:[/* @__PURE__ */ (0,i.jsx)(`textarea`,{ref:y,rows:1,value:o,disabled:!S,placeholder:`Reply in Side Chat`,onChange:e=>{++g.current,s(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-composer-actions`,children:[n,/* @__PURE__ */ (0,i.jsx)(`button`,{type:x?`button`:`submit`,className:x?`dsh-more-details-stop-button`:`dsh-more-details-send-button`,"aria-label":x?`Stop generating`:`Send`,"aria-busy":u||c||void 0,disabled:!S||(x?u:c||o.trim().length===0),onClick:e=>{x&&(e.preventDefault(),w())},children:x?/* @__PURE__ */ (0,i.jsx)(Ii,{}):/* @__PURE__ */ (0,i.jsx)(ni,{})})]})]})]})}function Vi(){try{return typeof window>`u`?void 0:window.sessionStorage}catch{return}}function Hi(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function Ui(e){return e.occurrences.some(e=>e.source===`dsh-more-details-selection`||e.source===`dsh-more-details-conversation`||e.source===`dsh-more-details-webchat`)}function Wi(e,t){if(!Array.isArray(t)||t.length===0)return!1;let n=0;return t.every(t=>{if(typeof t!=`object`||!t)return!1;let r=t;return!Number.isSafeInteger(r.offset)||!Number.isSafeInteger(r.length)||r.offset<n||r.length<0||r.offset+r.length>e.length||typeof r.source!=`string`||typeof r.ref!=`string`||typeof r.label!=`string`||typeof r.clipboardText!=`string`||e.slice(r.offset,r.offset+r.length)!==r.clipboardText||r.appearance!==void 0&&![`session`,`file`,`folder`].includes(r.appearance)?!1:(n=r.offset+r.length,!0)})}var Gi=class{storage;persistentStorage;observedInputs=/* @__PURE__ */ new WeakSet;restoringWebInputs=/* @__PURE__ */ new WeakSet;reconciling=!1;constructor(e=Vi(),t=Hi()){this.storage=e,this.persistentStorage=t}reconcile(e,t){if(this.reconciling||this.restoringWebInputs.has(t)||this.storage===void 0&&this.persistentStorage===void 0)return;this.reconciling=!0;let n=`dsh-more-details:composer-references:`+encodeURIComponent(e),r=`dsh-more-details:webchat-composer-references:`+encodeURIComponent(e);try{let i=t.state.getSnapshot();if(Ui(i)){this.observedInputs.add(t);let e=JSON.stringify({version:1,draft:i.draft,occurrences:i.occurrences});i.occurrences.some(e=>e.source===`dsh-more-details-webchat`)?(this.persistentStorage?.setItem(r,e),this.storage?.removeItem(n)):(this.storage?.setItem(n,e),this.persistentStorage?.removeItem(r));return}if(this.observedInputs.has(t)){this.storage?.removeItem(n),this.persistentStorage?.removeItem(r);return}let a=this.persistentStorage?.getItem(r),o=a==null?this.storage:this.persistentStorage,s=a==null?n:r,c=a??this.storage?.getItem(n);if(c==null)return;let l=JSON.parse(c);if(l===null||l.version!==1||typeof l.draft!=`string`||!Wi(l.draft,l.occurrences)){o?.removeItem(s);return}if(i.draft===``)return;if(i.draft!==l.draft||i.occurrences.length!==0){o?.removeItem(s);return}if(i.phase!==void 0&&i.phase!==`plain`)return;if(l.occurrences.some(e=>e.source===`dsh-more-details-webchat`))return this.restoringWebInputs.add(t),this.restoreWebDraft(t,l).then(n=>{this.restoringWebInputs.delete(t),n&&(this.observedInputs.add(t),this.reconcile(e,t))});this.restore(t,l)&&this.observedInputs.add(t)}catch{}finally{this.reconciling=!1}}async restoreWebDraft(e,t){let n,r=!1,i=t=>new Promise((n,r)=>{try{s(e,t,n)||n(void 0)}catch(e){r(e)}});try{for(let r of[...t.occurrences].reverse()){let a=e.state.getSnapshot();if(a.draft!==t.draft)return!1;let o=await i(()=>e.insertReference({source:r.source,ref:r.ref,label:r.label,clipboardText:r.clipboardText,...r.appearance===void 0?{}:{appearance:r.appearance}},{start:r.offset,end:r.offset+r.length,draftRev:a.draftRev}));if(o===void 0)return!1;let s=t.draft[r.offset+r.length]!==` `,c=s?t.draft.slice(0,r.offset+r.length)+` `+t.draft.slice(r.offset+r.length):t.draft;if(o.draft!==c||d(a,o,r.source,r.ref)===void 0)return!1;if(n=o,s){let a=await i(()=>e.replaceText(``,{start:r.offset+1,end:r.offset+2,draftRev:o.draftRev}));if(a===void 0||a.draft!==t.draft)return!1;n=a}}return r=!0,!0}catch{return e.notify?.(`error`,`网页引用恢复未完成;原草稿仍在,请检查引用后重试。`),!1}finally{let a=e.state.getSnapshot();if(!r&&n===a){let n=a.draft.length-a.occurrences.reduce((e,t)=>e+t.length-1,0);try{await i(()=>e.replaceText(t.draft,{start:0,end:n,draftRev:a.draftRev}))}catch{e.notify?.(`error`,`网页引用恢复被输入框中止;请保留当前草稿并检查引用。`)}}}}restore(e,t){let n,r=!1;try{for(let r of[...t.occurrences].reverse()){let i=e.state.getSnapshot();if(i.draft!==t.draft||!e.insertReference({source:r.source,ref:r.ref,label:r.label,clipboardText:r.clipboardText,...r.appearance===void 0?{}:{appearance:r.appearance}},{start:r.offset,end:r.offset+r.length,draftRev:i.draftRev}))return!1;let a=e.state.getSnapshot(),o=t.draft[r.offset+r.length]!==` `,s=o?t.draft.slice(0,r.offset+r.length)+` `+t.draft.slice(r.offset+r.length):t.draft;if(a.draft!==s)return!1;if(n=a,o){if(!e.replaceText(``,{start:r.offset+1,end:r.offset+2,draftRev:a.draftRev}))return!1;let i=e.state.getSnapshot();if(i.draft!==t.draft)return!1;n=i}}return r=!0,!0}finally{let i=e.state.getSnapshot();if(!r&&n===i){let n=i.draft.length-i.occurrences.reduce((e,t)=>e+t.length-1,0);e.replaceText(t.draft,{start:0,end:n,draftRev:i.draftRev})}}}};let Ki=`dsh-more-details:model-preference:v1`;function qi(){if(typeof window<`u`)try{return window.localStorage}catch{return}}function Ji(e){if(typeof e!=`object`||!e)return;let t=e;if(typeof t.provider==`string`&&t.provider!==``&&typeof t.model==`string`&&t.model!==``&&(t.reasoningEffort===void 0||typeof t.reasoningEffort==`string`&&t.reasoningEffort!==``))return{provider:t.provider,model:t.model,...t.reasoningEffort===void 0?{}:{reasoningEffort:t.reasoningEffort}}}var Yi=class{storage;constructor(e=qi()){this.storage=e}get(){if(this.storage!==void 0)try{let e=this.storage.getItem(Ki);if(e===null)return;let t=JSON.parse(e);return t.version===1?Ji(t.selection):void 0}catch{return}}set(e){if(this.storage===void 0)return;let t={version:1,selection:{...e}};try{this.storage.setItem(Ki,JSON.stringify(t))}catch{}}};let Xi={turnEnds:/* @__PURE__ */ new Map,chatNodes:{get:()=>void 0}};var Zi=class{chat;source;snapshot=Xi;constructor(e){this.chat=e}subscribe=e=>this.chat.subscribe(e);getSnapshot=()=>{let e=this.chat.getSnapshot();return e!==this.source&&(this.source=e,this.snapshot=e===void 0?Xi:{turnEnds:e.legacy.turnEnds,chatNodes:e.nodes}),this.snapshot}};function Qi(e){return e}function $i(e){return e.kind===`turn`?e.turn.status===`closed`:e.kind===`step`&&e.turn.status===`closed`&&e.step.status===`closed`}var ea=class{ctx;faces=/* @__PURE__ */ new WeakMap;parentInputs=/* @__PURE__ */ new WeakMap;annotationPersistence=new Gi;modelPreferences=new Yi;constructor(e){this.ctx=e}subscribeList=e=>this.ctx.sessions.list.subscribe(e);subscribeConversationInput=e=>{let t,n=()=>{},r=()=>{let r=this.currentParentInput();r!==t&&(n(),t=r,n=t?.state.subscribe(e)??(()=>{}))};r();let i=this.ctx.sessions.list.subscribe(()=>{r(),e()});return()=>{i(),n()}};currentConversationInputSnapshot=()=>this.currentParentInput()?.state.getSnapshot();currentSessionId(){let e=Object.entries(this.ctx.sessions.list.getSnapshot().byId).find(([,e])=>(e.retainedBy.mainView??0)>0)?.[0];return e===void 0?void 0:P(e)}lastCompletedSeq(e){let t=this.face(e)?.getSnapshot(),n;for(let e of t?.turnEnds.values()??[])(n===void 0||e>n)&&(n=e);return n}selectionIsCurrent(e){let t=this.face(e.parentSessionId)?.getSnapshot();return t!==void 0&&e.fragments.every(e=>{let n=t.chatNodes.get(e.nodeKey);return n!==void 0&&n.visibility===`visible`&&n.kind===e.nodeKind&&n.anchorSeq===e.seq&&$i(n.location)})}addSelectionToConversation(e,t){if(this.currentSessionId()!==e.parentSessionId)return!1;let n=this.currentParentInput();return n===void 0||!w(n,e,t)?!1:(this.annotationPersistence.reconcile(e.parentSessionId,n),!0)}addSideChatToConversation(e,t){let n=this.ctx.sessions.scope(Qi(e)),r=n===void 0?void 0:this.parentInput(n);return r===void 0||!ue(r,t)?!1:(this.annotationPersistence.reconcile(e,r),!0)}addWebChatToConversation(e,t){let n=this.ctx.sessions.scope(Qi(e)),r=n===void 0?void 0:this.parentInput(n);return r!==void 0&&De(r,t,()=>{this.annotationPersistence.reconcile(e,r)})}focusConversationInput(e){if(this.currentSessionId()!==e)return;let t=this.ctx.sessions.scope(Qi(e));t!==void 0&&this.parentInput(t)?.focus?.()}removeConversationAnnotation(e){let t=this.currentSessionId(),n=this.currentParentInput();return t===void 0||n===void 0||!E(n,e)?!1:(this.annotationPersistence.reconcile(t,n),!0)}updateConversationAnnotation(e,t){let n=this.currentSessionId(),r=this.currentParentInput();return n===void 0||r===void 0||!D(r,e,t)?!1:(this.annotationPersistence.reconcile(n,r),!0)}reconcileConversationAnnotationPersistence(){let e=this.currentSessionId(),t=this.currentParentInput();e!==void 0&&t!==void 0&&this.annotationPersistence.reconcile(e,t)}nextConversationAnnotationNumber(){let e=this.currentConversationInputSnapshot();return e===void 0?1:x(e).length+1}removeConversationAnnotations(e=this.currentSessionId()){let t=e===void 0?void 0:this.ctx.sessions.scope(Qi(e)),n=t===void 0?void 0:this.parentInput(t);return e===void 0||n===void 0||!T(n)?!1:(this.annotationPersistence.reconcile(e,n),!0)}retainParent(e){let t=this.ctx.sessions.retain(Qi(e),{source:`moreDetails`}),n=!0;return t.ready.catch(()=>{n&&this.notify({kind:`warning`,text:`The parent conversation could not be loaded.`})}),()=>{n=!1,t.release()}}async openSession(e){this.ctx.uiWorkspace.openSession(Qi(e))}notify(e){console[e.kind===`warning`?`warn`:`info`](`[dsh-more-details] ${e.text}`),this.currentParentInput()?.notify?.(e.kind===`warning`?`error`:`info`,e.text)}face(e){let t=this.ctx.sessions.binding(Qi(e))?.session;if(t===void 0)return;let n=this.faces.get(t);if(n!==void 0)return n;let r=this.ctx.uiConversation.binding(t.sessionId);r.activate(`chat`);let i=new Zi(r.target(`chat`));return this.faces.set(t,i),i}title(e){return this.ctx.sessions.list.getSnapshot().byId[Qi(e)]?.displayTitle}modelDirectory(e){try{return this.ctx.modelDirectories.directoryFor(Qi(e))}catch{return}}moreDetailsModelPreference(){return this.modelPreferences.get()}rememberSideChatModelPreference(e){this.modelPreferences.set(e)}currentParentInput(){let e=this.currentSessionId(),t=e===void 0?void 0:this.ctx.sessions.scope(Qi(e));return t===void 0?void 0:this.parentInput(t)}parentInput(e){let t=this.ctx.conversation.input.for(e);if(t===void 0)return;let n=this.parentInputs.get(t);if(n!==void 0)return n;let r={state:t.state,setDraft:e=>{t.setDraft(e)},notify:(e,n)=>t.notify?.(e,n),focus:()=>t.focus(),insertReference:(e,n)=>t.insertReference(e,n),replaceText:(t,n)=>e.bail(e,`slash/input-insert-text`,{text:t,span:n})===!0};return this.parentInputs.set(t,r),r}};function ta(e,t){let n=e.chatNodes.get(t);if(n===void 0||n.visibility!==`visible`)return;let r=n.kind===`user`||n.kind===`steering`?`user`:n.kind===`assistant-step`?`assistant`:n.kind===`context`?`context`:void 0,i=n.location.kind===`turn`||n.location.kind===`step`?n.location.turn.turn:void 0;if(r!==void 0&&i!==void 0)return{nodeKey:n.key,nodeKind:n.kind,turnKey:`turn:${String(i)}`,seq:n.anchorSeq,source:r,modelVisible:!0,settled:$i(n.location)}}function na(e){if(e instanceof KeyboardEvent&&e.key===`Escape`)return!1;let t=e.target;return!(t instanceof Element&&t.closest(`[data-side-chat-panel], .dsh-more-details-selection-actions, .dsh-more-details-selection-comment, .dsh-more-details-annotation-marker`)!==null)}function ra({controller:e,sessions:t,details:n,webChatAvailable:a=!0,locale:o}){let{active:s,text:c}=N(o),l=(0,r.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot),u=(0,r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),d=(0,r.useSyncExternalStore)(t.subscribeList,()=>t.currentSessionId(),()=>t.currentSessionId()),f=(0,r.useSyncExternalStore)(t.subscribeConversationInput,t.currentConversationInputSnapshot,t.currentConversationInputSnapshot),p=(0,r.useMemo)(()=>f===void 0?[]:S(f),[f]),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(null),v=(0,r.useRef)(0),y=(0,r.useRef)(void 0),b=(0,r.useRef)(null),x=(0,r.useRef)(!1),C=(0,r.useRef)(!1),w=(0,r.useRef)(0),T=(0,r.useCallback)(async e=>{let n=++v.current,r=t.currentSessionId(),i=r===void 0?void 0:t.face(r),a=r===void 0?void 0:vi(r),o=window.getSelection();if(r===void 0||i===void 0||a===void 0||o===null||o.isCollapsed){n===v.current&&h(null);return}let s=i.getSnapshot();try{let i=await pi({selection:o,conversationRoot:a,parentSessionId:r,resolver:{resolve(e){let t=e.dataset.chatAnchorKey;return t===void 0?void 0:ta(s,t)}}});n===v.current&&t.currentSessionId()===r&&h({value:i,touch:e})}catch{n===v.current&&h(null)}},[t]),E=(0,r.useCallback)(()=>{y.current!==void 0&&(window.clearTimeout(y.current),y.current=void 0)},[]),D=(0,r.useCallback)(()=>{E();let e=++v.current;y.current=window.setTimeout(()=>{y.current=void 0,!(e!==v.current||x.current)&&T(!0)},300)},[E,T]);(0,r.useEffect)(()=>{let e=()=>{E(),b.current=null,x.current=!1,++v.current,h(null),_(null)},t=()=>Date.now()<w.current,n=n=>{na(n)&&(n.pointerType===`touch`&&t()||(n.pointerType!==`touch`&&(w.current=0),C.current=n.pointerType===`touch`,C.current&&e()))},r=n=>{na(n)&&!t()&&(C.current=!0,e())},i=e=>{na(e)&&!t()&&(C.current=!0,D())},a=e=>{C.current||t()?b.current=null:na(e)?(E(),b.current={x:e.clientX,y:e.clientY},x.current=!1,++v.current,h(null),_(null)):b.current=null},o=e=>{let n=b.current;b.current=null,na(e)&&!t()&&(C.current?D():(n===null||Math.abs(e.clientX-n.x)>2||Math.abs(e.clientY-n.y)>2||e.detail>1||e.shiftKey)&&T(!1))},s=()=>{if(x.current)return;if(C.current){D();return}let e=window.getSelection();(e===null||e.isCollapsed)&&(E(),++v.current,h(null))},c=e=>{C.current=!1,E(),e.key===`Escape`?(++v.current,x.current=!1,h(null),_(null)):na(e)&&T(!1)};return document.addEventListener(`pointerdown`,n),document.addEventListener(`touchstart`,r,{passive:!0}),document.addEventListener(`touchend`,i,{passive:!0}),document.addEventListener(`mousedown`,a),document.addEventListener(`mouseup`,o),document.addEventListener(`selectionchange`,s),document.addEventListener(`keyup`,c),()=>{E(),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`touchstart`,r),document.removeEventListener(`touchend`,i),document.removeEventListener(`mousedown`,a),document.removeEventListener(`mouseup`,o),document.removeEventListener(`selectionchange`,s),document.removeEventListener(`keyup`,c)}},[E,T,e,D]),(0,r.useEffect)(()=>{E(),++v.current,x.current=!1,h(null),_(null)},[E,d]),(0,r.useEffect)(()=>{f!==void 0&&t.reconcileConversationAnnotationPersistence()},[f,t]),(0,r.useEffect)(()=>{g!==null&&(p.some(e=>e.annotationIndex===g.annotationIndex)||(x.current=!1,_(null)))},[p,g]);let O=(0,r.useCallback)(()=>{E(),C.current&&(w.current=Date.now()+750),C.current=!1,x.current=!1,++v.current,h(null)},[E]),k=u.phase===`closed`?void 0:c(`请先关闭当前侧边对话,再新建另一个。`,`Close the current Side Chat before starting another one.`),A=s.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`,j=u.parentSessionId===void 0?void 0:t.modelDirectory?.(u.parentSessionId),M=u.parentSessionId===void 0||u.chatId===void 0||u.phase!==`ready`||!u.messages.some(e=>e.role===`assistant`&&e.text.trim().length>0),P=()=>{let e=u.parentSessionId,n=u.chatId;if(e===void 0||n===void 0||u.phase!==`ready`){t.notify({kind:`warning`,text:`The Side Chat conversation is not ready to add yet.`});return}let r=t.title(e),i=R({conversationId:n,title:[A===`zh-CN`?`侧边对话`:`Side Chat`,r].filter(Boolean).join(` · `),messages:u.messages});if(i.conversation.length===0)t.notify({kind:`warning`,text:`The Side Chat does not have any conversation history to add yet.`});else try{if(!t.addSideChatToConversation(e,i)){t.notify({kind:`warning`,text:`Could not add the Side Chat to the main conversation.`});return}t.openSession(e).then(()=>yi(e),()=>{t.notify({kind:`warning`,text:`The Side Chat was added, but its parent conversation could not be opened.`})})}catch{t.notify({kind:`warning`,text:`Could not add the Side Chat to the main conversation.`})}},F=j===void 0?void 0:/* @__PURE__ */ (0,i.jsx)(ti,{directory:j,selection:u.modelSelection,locked:[`creating`,`closing`].includes(u.phase)||u.error?.operation===`close`,running:u.phase===`running`,validateInitialSelection:u.chatId===void 0,locale:A,onInitialize:(t,n)=>{n.remember?e.selectModel(t):e.initializeModel(t)},onSelect:t=>e.selectModel(t)},`${u.parentSessionId}:${u.chatId??`draft`}`);return/* @__PURE__ */ (0,i.jsxs)(`div`,{className:`dsh-more-details-overlay`,children:[/* @__PURE__ */ (0,i.jsx)(Mi,{annotations:p,...g===null?{}:{activeAnnotationIndex:g.annotationIndex},onEdit:(e,t)=>{x.current=!0,E(),++v.current,h(null),_({...e,selection:t})}}),m!==null&&/* @__PURE__ */ (0,i.jsx)(Fi,{text:c,selection:m.value,touchInteraction:m.touch,annotationNumber:t.nextConversationAnnotationNumber(),...k===void 0?{}:{askDisabledReason:k},...a?l.busy||l.pending!==void 0?{moreDetailsDisabledReason:l.busy?c(`正在处理更多详情请求`,`A More details request is in progress.`):c(`请先处理小窗中的待发送请求`,`Handle the pending request in the Web Chat window first.`)}:{}:{moreDetailsDisabledReason:c(Ke.zh,Ke.en)},onAddToChat:(e,n)=>{try{t.addSelectionToConversation(e,n)?yi(e.parentSessionId):t.notify({kind:`warning`,text:c(`无法将所选内容添加到当前聊天。`,`Could not add the selection to the current chat.`)})}catch{t.notify({kind:`warning`,text:c(`无法将所选内容添加到当前聊天。`,`Could not add the selection to the current chat.`)})}O()},onAnnotationEditorChange:e=>{x.current=e,e&&C.current&&(w.current=Date.now()+750)},onMoreDetails:e=>{n.start(e),O()},onAskInSideChat:n=>{let r=e.openDraft({selection:n});r.ok||t.notify({kind:`warning`,text:r.error.message}),O()},onDismiss:O}),g!==null&&/* @__PURE__ */ (0,i.jsx)(Fi,{text:c,selection:g.selection,annotationNumber:g.annotationIndex+1,annotationEditor:{...g.comment===void 0?{}:{initialComment:g.comment},dialogLabel:c(`编辑批注`,`Edit annotation comment`)},onAddToChat:(e,n)=>{try{t.updateConversationAnnotation(g.annotationIndex,n)||t.notify({kind:`warning`,text:`Could not update the annotation.`})}catch{t.notify({kind:`warning`,text:`Could not update the annotation.`})}x.current=!1,_(null)},onAnnotationEditorChange:e=>{x.current=e},onRemoveAnnotation:()=>{try{t.removeConversationAnnotation(g.annotationIndex)||t.notify({kind:`warning`,text:`Could not remove the annotation.`})}catch{t.notify({kind:`warning`,text:`Could not remove the annotation.`})}x.current=!1,_(null)},onMoreDetails:()=>{},onAskInSideChat:()=>{},onDismiss:()=>{x.current=!1,_(null)}},`annotation:${String(g.annotationIndex)}`),u.phase!==`closed`&&/* @__PURE__ */ (0,i.jsx)(ci,{state:u,locale:A,embeddedConversation:/* @__PURE__ */ (0,i.jsx)(Bi,{state:u,controller:e,locale:A,modelControl:F},u.chatId),modelControl:F,onDraftChange:t=>{e.setDraft(t)},onFirstSend:t=>e.sendFirst(t),onClose:()=>e.close(),onRetry:()=>e.retry(),onFocusParent:()=>{u.parentSessionId!==void 0&&t.openSession(u.parentSessionId)},onAddToConversation:P,addToConversationDisabled:M,...u.chatId===void 0?{onRemoveSelection:()=>{e.clearSelection()}}:{}})]})}let ia=[`configForms`,`workspaces`,`conversation`,`inputTriggers`,`locale`,`modelDirectories`,`remote`,`sessions`,`slots`,`uiConversation`,`uiWorkspace`];async function aa(e){let t=[],n=!1,i,a=()=>(n=!0,i??=(async()=>{for(let e of t.splice(0).reverse())try{await e()}catch(e){console.warn(`[dsh-more-details] Cleanup failed`,e)}})(),i);e.effect(()=>a,`dsh-more-details.clientLifecycle`);try{let i=document.createElement(`style`);i.textContent=o+vt+Re,i.dataset.plugin=`dsh-more-details`,i.dataset.dshSideChat=`styles`,document.head.append(i),t.push(()=>{i.remove()});let a=e,s=await Xr(a);if(n){await s.dispose();return}t.push(s.dispose),t.push(a.inputTriggers.registerSource(k)),t.push(a.inputTriggers.registerSource(de));let c=new ea(a);t.push(pt(e));let l=ct()!==void 0,u=new dt(s.loginStore);t.push(()=>u.dispose());let d=new $e(u,s.prepareDetails,c,window.localStorage,s.saveWebChatReference,(t,n)=>e.locale.resolveText({zh:t,en:n})),f=l?e=>{d.openHistory(e.url)}:void 0;if(t.push(a.inputTriggers.registerSource(Oe(f,e.locale))),t.push(Le(a,e=>{c.removeConversationAnnotations(e)},f)),u.observe(e=>d.observePage({url:e.url,title:e.title})),t.push(()=>d.dispose()),l){let n=e.configForms.get(`more-details`);t.push(a.slots.inject(`shell.overlay`,()=>a.slots.register({name:`shell.overlay`,id:`dsh-more-details-webchat`,order:91},()=>(0,r.createElement)(ht,{controller:d,guest:u,form:n,locale:e.locale})))),t.push(a.slots.inject(`sidebar.footer.action`,()=>a.slots.register({name:`sidebar.footer.action`,id:`dsh-more-details-new-chat`,order:10},({wide:t})=>(0,r.createElement)(gt,{controller:d,locale:e.locale,wide:t})))),t.push(a.slots.inject(`sidebar.footer.action`,()=>a.slots.register({name:`sidebar.footer.action`,id:`dsh-more-details-continue-chat`,order:11},({wide:t})=>(0,r.createElement)(_t,{controller:d,locale:e.locale,wide:t}))))}let p=new Ot(s.remote,c);t.push(()=>p.dispose()),t.push(a.slots.inject(`shell.overlay`,()=>a.slots.register({name:`shell.overlay`,id:`dsh-more-details`,order:90},()=>(0,r.createElement)(ra,{controller:p,sessions:c,details:d,webChatAvailable:l,locale:e.locale}))))}catch(e){throw await a(),e}}return n.SelectionActions=Fi,n.SelectionValidationError=B,n.SideChatController=Ot,n.SideChatPanel=ci,n.apply=aa,n.assertSelectionCurrent=Et,n.buildSideChatPrompt=j,n.captureDomConversationSelection=pi,n.finalizeConversationSelection=Tt,n.inject=ia,n.name=`more-details-client`,n.normalizeSelectedText=wt,n.restoreDomConversationSelection=gi,n.selectionFitsLimit=St,n.summarizeSelection=Ct,n.utf8ByteLength=xt,t.exports}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-more-details",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "Select text for an independent DeepSeek web discussion, then bring it back to DSH with reference cards and on-demand text snapshots.",
5
5
  "keywords": [
6
6
  "deepseek-harness",