From aeab1e3ff8576ab1f52777f67beb200823171b83 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Mon, 2 Nov 2026 13:19:26 +0800
Subject: [PATCH 01/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=8F=92?=
=?UTF-8?q?=E4=BB=B6=E6=8E=A7=E5=88=B6=E9=9D=A2=E5=88=A4=E9=94=99=E5=A4=B1?=
=?UTF-8?q?=E8=B4=A5=E6=97=B6=E5=9B=9E=E8=90=BD=E5=88=B0=20HTTP=20?=
=?UTF-8?q?=E7=8A=B6=E6=80=81=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
ZCode 活动套餐通道用 HTTP 200 + application/json 返回
`{"code":1005,"msg":"exceed quota limit"}`。网关把这类 2xx 交给插件判定,
但原实现一旦 RPC 失败就直接返回错误,整份请求中断;而默认实现又会把
200 当成成功流交给 Anthropic 翻译层,最终只剩 `response.failed`、
`output` 为空。
修复:
- `ProviderAdapter` 为异步判错钩子补上说明,内置家仍转调同步版;
- `RpcAdapter` 问插件失败时回落到 HTTP 状态码判定,避免控制面超时
误罚账号;
- 补两条回归测试:200 + application/json 必须判错误,200 +
text/event-stream 仍判成功。
验证:
- `cargo check -p agent2api-server` 通过;
- `cargo test -p agent2api-server plugin_host::tests` 13 passed。
注:上游 beta 的 `provider_loop/tests.rs` 与 `api/pipeline.rs` 测试代码
存在既有编译错误(`send_with_retry` 参数、`RequestQuery` 字段不齐),
本次仅本地临时补齐以运行测试,未纳入提交。
---
.../server/src/server/core/plugin_host/rpc.rs | 25 ++++--
.../src/server/core/plugin_host/tests.rs | 77 +++++++++++++++++++
.../src/server/core/providers/adapter.rs | 6 ++
3 files changed, 101 insertions(+), 7 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
index 1cdcc766d..de90ab1a6 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
@@ -417,24 +417,35 @@ impl ProviderAdapter for RpcAdapter {
})
}
+ /// 上游响应是否「其实是错误」(HTTP 200 但正文是业务失败)。
+ ///
+ /// ── 为什么这一位必须问插件 ──────────────────────────────────
+ /// 这条判据是 provider 知识:ZCode 的活动套餐通道用 HTTP 200 +
+ /// `application/json` 返回 `{"code":1005,"msg":"exceed quota limit"}`,
+ /// 智谱清言用 200 + `-1001 剩余积分不足`。网关自己只看得到状态码与头,
+ /// 不知道哪家的 2xx 其实是失败。默认实现(`!(200..300).contains`)在
+ /// 这里会把它们当成功,直接交给 SSE 翻译层 —— 结果是 `output` 为空的
+ /// 一次「成功」响应,账号也不会进冷却。
+ ///
+ /// ── 插件问不到时为什么回落到默认 ────────────────────────────
+ /// RPC 失败说明插件挂了;此时按 HTTP 状态码判成功至少与内置家同一口径,
+ /// 不会因为一次控制面超时把所有 2xx 响应都当成错误而误罚账号。
fn is_error_response_async<'a>(
&'a self,
status: u16,
headers: &'a HeaderMap,
) -> std::pin::Pin> + Send + 'a>> {
Box::pin(async move {
- if !(200..300).contains(&status) {
- return Ok(true);
- }
+ let default = !(200..300).contains(&status);
let mut params = self.base();
params.insert("status".into(), Value::from(status));
params.insert("headers".into(), headers_json(headers));
+ // 控制面问不到时回落到 HTTP 状态码:一次 RPC 超时不该把所有 2xx
+ // 响应都判成错误,从而误罚账号。
let value = self.control(
proto::methods::gateway::IS_ERROR_RESPONSE, Value::Object(params),
- ).await?;
- value.as_bool().ok_or_else(|| GatewayError::with_status(
- 502, "插件返回的响应类型判定不是布尔值",
- ))
+ ).await;
+ Ok(value.ok().and_then(|value| value.as_bool()).unwrap_or(default))
})
}
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
index e9275b5e1..2916caea6 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
@@ -249,6 +249,83 @@ async fn classify_error_goes_through_rpc() {
host.shutdown().await;
}
+#[tokio::test(flavor = "multi_thread")]
+async fn is_error_response_goes_through_rpc() {
+ let Some((host, providers)) = boot().await else {
+ eprintln!("跳过:插件二进制不存在");
+ return;
+ };
+ let demo = providers.iter().find(|p| p.id.0 == "demo").expect("demo 存在");
+ let adapter = RpcAdapter::new(
+ "demo".into(),
+ crate::server::core::providers::ProviderKind::WorkBuddy,
+ host.clone(),
+ demo.clone(),
+ );
+
+ // 普通 200 + SSE 是成功流,不能因为走了 RPC 就被误判成错误。
+ let mut sse = axum::http::HeaderMap::new();
+ sse.insert(
+ axum::http::header::CONTENT_TYPE,
+ "text/event-stream".parse().expect("合法头值"),
+ );
+ assert!(
+ !adapter.is_error_response_async(200, &sse).await.expect("RPC 判定失败"),
+ "200 + text/event-stream 应当判成功"
+ );
+
+ // 非 2xx 无论插件怎么答都应当是错误(默认口径不能被 RPC 覆盖掉)。
+ assert!(
+ adapter.is_error_response_async(429, &sse).await.expect("RPC 判定失败"),
+ "429 应当判错误"
+ );
+
+ host.shutdown().await;
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn plugin_200_json_is_an_error_response() {
+ let Some((host, providers)) = boot().await else {
+ eprintln!("跳过:插件二进制不存在");
+ return;
+ };
+ // 用 chatglm:插件侧对「200 + application/json」有明确判据(与 zcode
+ // 同一口径)。这条测试钉的是网关有没有把这一位问出去 —— 没接 RPC 时
+ // 默认实现会把它当成功,正好复现 testwhy0out 的 0 输出。
+ let chatglm = providers
+ .iter()
+ .find(|p| p.id.0 == "chatglm")
+ .expect("chatglm 存在");
+ let adapter = RpcAdapter::new(
+ "chatglm".into(),
+ crate::server::core::providers::ProviderKind::WorkBuddy,
+ host.clone(),
+ chatglm.clone(),
+ );
+
+ let mut json = axum::http::HeaderMap::new();
+ json.insert(
+ axum::http::header::CONTENT_TYPE,
+ "application/json; charset=utf-8".parse().expect("合法头值"),
+ );
+ assert!(
+ adapter.is_error_response_async(200, &json).await.expect("RPC 判定失败"),
+ "200 + application/json 必须判成错误,否则业务错误会被当成空回答"
+ );
+
+ let mut sse = axum::http::HeaderMap::new();
+ sse.insert(
+ axum::http::header::CONTENT_TYPE,
+ "text/event-stream".parse().expect("合法头值"),
+ );
+ assert!(
+ !adapter.is_error_response_async(200, &sse).await.expect("RPC 判定失败"),
+ "200 + text/event-stream 仍然应当判成功"
+ );
+
+ host.shutdown().await;
+}
+
#[tokio::test(flavor = "multi_thread")]
async fn reasoning_patch_goes_through_rpc() {
let Some((host, providers)) = boot().await else {
diff --git a/desktop-tauri/src-tauri/server/src/server/core/providers/adapter.rs b/desktop-tauri/src-tauri/server/src/server/core/providers/adapter.rs
index ba504b295..0644af052 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/providers/adapter.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/providers/adapter.rs
@@ -634,6 +634,12 @@ pub trait ProviderAdapter: Send + Sync {
!(200..300).contains(&status)
}
+ /// [`Self::is_error_response`] 的异步形态。
+ ///
+ /// ── 为什么这一位需要异步 ────────────────────────────────────
+ /// 插件家的判据在子进程里(协议方法 `is_error_response`),而 trait 的
+ /// 同步签名没法 await 一次 RPC;转发循环本身就在 async 上下文里,所以
+ /// 把这一位做成异步钩子,默认转调同步版。内置家逐字不变。
fn is_error_response_async<'a>(
&'a self,
status: u16,
From 0535a6c1b01f951c45491303d567911bcdc79d9a Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Mon, 2 Nov 2026 20:29:14 +0800
Subject: [PATCH 02/23] fix(responses): preserve prompt_cache_key in chat
conversion
---
.../server/src/server/core/protocol/responses.rs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/protocol/responses.rs b/desktop-tauri/src-tauri/server/src/server/core/protocol/responses.rs
index 6952ed170..e1a1650f5 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/protocol/responses.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/protocol/responses.rs
@@ -69,7 +69,15 @@ pub fn chat_from_responses(body: &Value) -> Result {
if let Some(value) = body.get("max_output_tokens").filter(|value| is_truthy(value)) {
out.insert("max_completion_tokens".to_string(), value.clone());
}
- for key in ["temperature", "top_p", "service_tier", "parallel_tool_calls", "user", "metadata"] {
+ for key in [
+ "temperature",
+ "top_p",
+ "service_tier",
+ "parallel_tool_calls",
+ "user",
+ "metadata",
+ "prompt_cache_key",
+ ] {
if let Some(value) = body.get(key) {
if !value.is_null() {
out.insert(key.to_string(), value.clone());
From 747f4c2901e29ad5a39db0c6127cd3b11af764dd Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Mon, 2 Nov 2026 23:58:41 +0800
Subject: [PATCH 03/23] feat: add private plugin source with author metadata
---
desktop-tauri/i18n/i18n-src/en/common.json | 1 +
desktop-tauri/i18n/i18n-src/ja/common.json | 1 +
desktop-tauri/i18n/i18n-src/ko/common.json | 1 +
desktop-tauri/i18n/i18n-src/pt-BR/common.json | 1 +
.../i18n/i18n-src/zh-Hant/common.json | 1 +
.../mobile/src/pages/plugins/PluginCards.tsx | 7 +-
.../src/server/core/plugin_host/catalog.rs | 11 ++-
.../src/server/core/plugin_host/update.rs | 95 ++++++++++++++-----
.../ui-islands/src/islands/plugins-cards.tsx | 10 +-
desktop-tauri/ui-shared/plugins.ts | 4 +
10 files changed, 99 insertions(+), 33 deletions(-)
diff --git a/desktop-tauri/i18n/i18n-src/en/common.json b/desktop-tauri/i18n/i18n-src/en/common.json
index 0ff98fbf6..c087f1270 100644
--- a/desktop-tauri/i18n/i18n-src/en/common.json
+++ b/desktop-tauri/i18n/i18n-src/en/common.json
@@ -80,6 +80,7 @@
"余额优先": "",
"作为 system 消息注入给助手": "Injected to the assistant as a system message",
"作者尚未提供插件介绍。": "The author has not provided a plugin description.",
+ "作者:{author}": "",
"例如:家里、公司": "e.g. Home, Office",
"侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "The sidebar layout module did not load (ui/sidebar-layout.js must be included before app.js).",
"侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "No menus are shown in the sidebar. Turn on the ones you need under Settings → Display → Sidebar menus.",
diff --git a/desktop-tauri/i18n/i18n-src/ja/common.json b/desktop-tauri/i18n/i18n-src/ja/common.json
index c0b001440..fa8cbffbf 100644
--- a/desktop-tauri/i18n/i18n-src/ja/common.json
+++ b/desktop-tauri/i18n/i18n-src/ja/common.json
@@ -80,6 +80,7 @@
"余额优先": "",
"作为 system 消息注入给助手": "system メッセージとしてアシスタントに注入",
"作者尚未提供插件介绍。": "作者によるプラグインの説明はまだありません。",
+ "作者:{author}": "",
"例如:家里、公司": "例:自宅、会社",
"侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "サイドバーのレイアウトモジュールが読み込まれていません(ui/sidebar-layout.js を app.js より前に読み込む必要があります)。",
"侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "サイドバーにメニューが表示されていません。「設定 → 表示 → サイドバーのメニュー」で必要な項目をオンにしてください。",
diff --git a/desktop-tauri/i18n/i18n-src/ko/common.json b/desktop-tauri/i18n/i18n-src/ko/common.json
index cb270d98d..c69203045 100644
--- a/desktop-tauri/i18n/i18n-src/ko/common.json
+++ b/desktop-tauri/i18n/i18n-src/ko/common.json
@@ -80,6 +80,7 @@
"余额优先": "",
"作为 system 消息注入给助手": "system 메시지로 어시스턴트에 주입",
"作者尚未提供插件介绍。": "작성자가 플러그인 설명을 제공하지 않았습니다.",
+ "作者:{author}": "",
"例如:家里、公司": "예: 집, 회사",
"侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "사이드바 레이아웃 모듈이 로드되지 않았습니다(ui/sidebar-layout.js는 app.js보다 먼저 포함되어야 합니다).",
"侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "사이드바에 표시되는 메뉴가 없습니다. 설정 → 표시 → 사이드바 메뉴에서 필요한 항목을 켜세요.",
diff --git a/desktop-tauri/i18n/i18n-src/pt-BR/common.json b/desktop-tauri/i18n/i18n-src/pt-BR/common.json
index 7458352e3..61e33b293 100644
--- a/desktop-tauri/i18n/i18n-src/pt-BR/common.json
+++ b/desktop-tauri/i18n/i18n-src/pt-BR/common.json
@@ -80,6 +80,7 @@
"余额优先": "",
"作为 system 消息注入给助手": "Injetado no assistente como mensagem system",
"作者尚未提供插件介绍。": "O autor ainda não forneceu uma descrição do plugin.",
+ "作者:{author}": "",
"例如:家里、公司": "ex.: Casa, Escritório",
"侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "O módulo de layout da barra lateral não foi carregado (ui/sidebar-layout.js deve vir antes de app.js).",
"侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "Nenhum menu aparece na barra lateral. Ative os que precisar em Configurações → Exibição → Menus da barra lateral.",
diff --git a/desktop-tauri/i18n/i18n-src/zh-Hant/common.json b/desktop-tauri/i18n/i18n-src/zh-Hant/common.json
index 89e9c060e..f4c3bb577 100644
--- a/desktop-tauri/i18n/i18n-src/zh-Hant/common.json
+++ b/desktop-tauri/i18n/i18n-src/zh-Hant/common.json
@@ -80,6 +80,7 @@
"余额优先": "",
"作为 system 消息注入给助手": "",
"作者尚未提供插件介绍。": "作者尚未提供插件介紹。",
+ "作者:{author}": "",
"例如:家里、公司": "",
"侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "",
"侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "",
diff --git a/desktop-tauri/mobile/src/pages/plugins/PluginCards.tsx b/desktop-tauri/mobile/src/pages/plugins/PluginCards.tsx
index 3ba67b168..0fbbc2ec4 100644
--- a/desktop-tauri/mobile/src/pages/plugins/PluginCards.tsx
+++ b/desktop-tauri/mobile/src/pages/plugins/PluginCards.tsx
@@ -18,12 +18,13 @@ function PluginProgress({ operation }: { operation?: PluginOperation }) {
>
}
-function Head({ name, version, icon }: { name: string; version?: string | null; icon?: string | null }) {
+function Head({ name, version, icon, author }: { name: string; version?: string | null; icon?: string | null; author?: string | null }) {
return
{icon ?
: name.slice(0, 1)}
{t(name)}
{version ? `v${version}` : t('暂未发布')}
+ {author ?
{t('作者:{author}', { author })}
: null}
}
@@ -37,7 +38,7 @@ export function StorePluginCard({ item, target, busy, operation, onInstall }: {
}) {
const asset = item.platforms?.find(platform => platform.target === target)
return } className='m-card m-card-pad'>
-
+
{t(item.description)}
{item.official ? {t('官方')} : null}
{item.reason ? {pluginErrorMessage(item.reason)}
: null}
@@ -63,7 +64,7 @@ export function PluginCard({ pack, target, busy, update, operation, onEnabled, o
const required = pack.updateRequired === true
const locked = busy || operation?.active === true
return } className='m-card m-card-pad'>
-
+
{pack.enabled ? t('已启用') : t('已停用')}
{pack.signed ? t('已签名') : t('未签名')}
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/catalog.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/catalog.rs
index 9c7d79961..4cc60b145 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/catalog.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/catalog.rs
@@ -154,7 +154,7 @@ async fn fetch_catalog(channels: crate::server::config::UpdateChannels) -> Resul
let current = super::host_target();
let mut plugins = Vec::new();
for entry in entries {
- let detail = update::read_detail(&entry.manifest).await;
+ let detail = update::read_detail_in(entry.index_url.as_deref(), &entry.manifest).await;
let repo = if entry.repo.is_empty() {
detail
.as_ref()
@@ -172,15 +172,20 @@ async fn fetch_catalog(channels: crate::server::config::UpdateChannels) -> Resul
.cloned()
.unwrap_or_else(|| Value::Null);
let icon = if icon.is_null() {
- json!(update::read_store_icon(&entry.icon).await)
+ json!(update::read_store_icon_in(entry.index_url.as_deref(), &entry.icon).await)
} else {
icon
};
+ let author = entry.author.clone().unwrap_or_else(|| {
+ if entry.official { "Agent2API".to_string() } else { "第三方".to_string() }
+ });
let installed = packs.iter().find(|pack| pack.id == entry.id);
let mut value = json!({
"id": entry.id, "name": entry.name, "description": entry.description,
"official": entry.official, "homepage": detail.as_ref().map(|detail| &detail.homepage),
- "protocol": detail.as_ref().map(|detail| detail.protocol), "icon": icon,
+ "author": author, "publisher": author,
+ "protocol": detail.as_ref().map(|detail| detail.protocol),
+ "icon": icon,
"requireSigned": entry.require_signed || detail.as_ref().is_some_and(|detail| detail.require_signed),
"version": Value::Null, "page": Value::Null, "notes": "", "prerelease": false,
"platforms": [], "error": false, "reason": Value::Null,
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
index 40db6e715..ae65bc30e 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
@@ -13,6 +13,8 @@ use crate::server::core::update::client::{
use crate::server::core::update::{compare_versions, is_prerelease_version, source};
pub const INDEX_REPO: &str = "Agent2plugin/Agent2plugin";
+pub const CUSTOM_INDEX_URL: &str =
+ "https://raw.githubusercontent.com/SsuJojo/Agent2Providers/main/.agent2api/index.json";
pub const FALLBACK_REPO: &str = "Agent2Builder/agent2api-providers-releases";
const GITHUB_API: &str = "https://api.github.com";
const QUERY_TIMEOUT_MS: u64 = 30_000;
@@ -38,6 +40,8 @@ pub struct IndexEntry {
pub description: String,
pub official: bool,
pub require_signed: bool,
+ pub author: Option
,
+ pub index_url: Option,
pub manifest: String,
pub icon: String,
pub repo: String,
@@ -143,22 +147,9 @@ async fn fetch(url: &str) -> Result {
Ok(response)
}
-pub async fn read_index_result() -> Result, String> {
- let url = format!("https://raw.githubusercontent.com/{INDEX_REPO}/main/index.json");
- let response = fetch_json(&url, &github_headers(), QUERY_TIMEOUT_MS, |value| {
- value.get("plugins").and_then(Value::as_array).is_some()
- })
- .await
- .map_err(|error| describe_error(&error.message, 0))?;
- if !response.status.is_success() {
- return Err(format!(
- "读取插件索引失败:HTTP {}",
- response.status.as_u16()
- ));
- }
- let require_signed = !response.official;
- let document = response.value;
- let items = document
+async fn parse_index(value: Value, official: bool, index_url: Option<&str>) -> Result, String> {
+ let require_signed = !official;
+ let items = value
.get("plugins")
.and_then(Value::as_array)
.ok_or_else(|| "插件索引缺少 plugins 数组".to_string())?;
@@ -174,12 +165,26 @@ pub async fn read_index_result() -> Result, String> {
return None;
}
let name = text(item, "name");
+ let author = item
+ .get("author")
+ .and_then(Value::as_str)
+ .filter(|value| !value.trim().is_empty())
+ .map(str::to_string);
Some(IndexEntry {
name: if name.is_empty() { id.clone() } else { name },
id,
description: text(item, "description"),
- official: item.get("official").and_then(Value::as_bool) == Some(true),
+ official: official && item.get("official").and_then(Value::as_bool) == Some(true),
require_signed,
+ author: author.or_else(|| {
+ (!official).then(|| {
+ index_url
+ .and_then(|url| url::Url::parse(url).ok())
+ .and_then(|url| url.path().split('/').nth(1).map(str::to_string))
+ .unwrap_or_else(|| "第三方".to_string())
+ })
+ }),
+ index_url: index_url.map(str::to_string),
manifest: text(item, "manifest"),
icon: text(item, "icon"),
repo: item
@@ -191,11 +196,43 @@ pub async fn read_index_result() -> Result, String> {
.collect())
}
+async fn read_custom_index_result() -> Option> {
+ let response = fetch_json(CUSTOM_INDEX_URL, &github_headers(), QUERY_TIMEOUT_MS, |value| {
+ value.get("plugins").and_then(Value::as_array).is_some()
+ })
+ .await
+ .ok()?;
+ if !response.status.is_success() {
+ return None;
+ }
+ parse_index(response.value, false, Some(CUSTOM_INDEX_URL)).await.ok()
+}
+
+pub async fn read_index_result() -> Result, String> {
+ let url = format!("https://raw.githubusercontent.com/{INDEX_REPO}/main/index.json");
+ let response = fetch_json(&url, &github_headers(), QUERY_TIMEOUT_MS, |value| {
+ value.get("plugins").and_then(Value::as_array).is_some()
+ })
+ .await
+ .map_err(|error| describe_error(&error.message, 0))?;
+ if !response.status.is_success() {
+ return Err(format!(
+ "读取插件索引失败:HTTP {}",
+ response.status.as_u16()
+ ));
+ }
+ let mut entries = parse_index(response.value, response.official, Some(&url)).await?;
+ if let Some(custom) = read_custom_index_result().await {
+ entries.extend(custom);
+ }
+ Ok(entries)
+}
+
pub async fn read_index() -> Vec {
read_index_result().await.unwrap_or_default()
}
-fn index_path(path: &str) -> Option {
+fn index_path(base_url: Option<&str>, path: &str) -> Option {
if path.is_empty()
|| path.starts_with('/')
|| path.contains('\\')
@@ -204,14 +241,22 @@ fn index_path(path: &str) -> Option {
{
return None;
}
- Some(format!(
- "https://raw.githubusercontent.com/{INDEX_REPO}/main/{path}"
- ))
+ Some(match base_url {
+ Some(base) => {
+ let base = base.trim_end_matches('/');
+ format!("{base}/{path}")
+ }
+ None => format!("https://raw.githubusercontent.com/{INDEX_REPO}/main/{path}"),
+ })
}
pub async fn read_detail(path: &str) -> Option {
+ read_detail_in(None, path).await
+}
+
+pub async fn read_detail_in(base_url: Option<&str>, path: &str) -> Option {
let response = fetch_json(
- &index_path(path)?,
+ &index_path(base_url, path)?,
&github_headers(),
QUERY_TIMEOUT_MS,
|value| value.is_object() && value.get("release").is_some_and(Value::is_object),
@@ -243,7 +288,11 @@ pub async fn read_detail(path: &str) -> Option {
}
pub async fn read_store_icon(path: &str) -> Option {
- let response = fetch(&index_path(path)?).await.ok()?;
+ read_store_icon_in(None, path).await
+}
+
+pub async fn read_store_icon_in(base_url: Option<&str>, path: &str) -> Option {
+ let response = fetch(&index_path(base_url, path)?).await.ok()?;
if !response.status().is_success() || response.content_length().unwrap_or(0) > 2 * 1024 * 1024 {
return None;
}
diff --git a/desktop-tauri/ui-islands/src/islands/plugins-cards.tsx b/desktop-tauri/ui-islands/src/islands/plugins-cards.tsx
index 254eba515..37494b7cb 100644
--- a/desktop-tauri/ui-islands/src/islands/plugins-cards.tsx
+++ b/desktop-tauri/ui-islands/src/islands/plugins-cards.tsx
@@ -8,8 +8,8 @@ function Card({ children, installed }: { children: React.ReactNode; installed?:
return } className={'flex flex-col ' + (installed ? 'border-success/40' : '')}>{children}
}
-function CardHead({ id, name, version, icon, children }: {
- id: string; name: string; version?: string | null; icon?: string | null; children?: React.ReactNode
+function CardHead({ id, name, version, icon, author, children }: {
+ id: string; name: string; version?: string | null; icon?: string | null; author?: string | null; children?: React.ReactNode
}) {
const title = pluginName(id, name)
return
@@ -21,6 +21,7 @@ function CardHead({ id, name, version, icon, children }: {
{title}{version ?
v{version} : null}
{children}
+ {author ?
{t('作者:{author}', { author })}
: null}
}
@@ -53,7 +54,7 @@ export function StorePluginCard({ item, target, operation, disabled, onInstall,
const platform = item.platforms.find(platform => platform.target === target)
const installable = Boolean(item.version && platform && !item.error)
return
-
+
{item.official ? {t('官方')} : null}
{item.prerelease ? {t('beta 版')} : null}
{!item.version ? {t('暂未发布')} : null}
@@ -90,7 +91,8 @@ export function InstalledPluginCard({ pack, store, host, update, operation, disa
const blocked = update?.error === true && !required
const packHost = pack.host === undefined ? host : pack.host
return
-
+
{pack.enabled ? t('已启用') : t('已停用')}
{pack.signed ? t('已签名') : t('未签名')}
{pack.version.includes('-') ? {t('beta 版')} : null}
diff --git a/desktop-tauri/ui-shared/plugins.ts b/desktop-tauri/ui-shared/plugins.ts
index 29843d8d3..d2d0d62c8 100644
--- a/desktop-tauri/ui-shared/plugins.ts
+++ b/desktop-tauri/ui-shared/plugins.ts
@@ -21,6 +21,8 @@ export type PackSummary = {
entryPresent: boolean
protocol: number
homepage?: string | null
+ author?: string | null
+ publisher?: string | null
icon?: string | null
providers: PackProvider[]
host?: HostState
@@ -47,6 +49,8 @@ export type StorePlugin = {
name: string
description: string
official: boolean
+ author?: string | null
+ publisher?: string | null
version: string | null
page: string | null
notes?: string | null
From 3128e6425a6f5c04dbc60cf82c1b098b9fc3bd48 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 01:41:11 +0800
Subject: [PATCH 04/23] fix: resolve custom plugin asset urls
---
.../src-tauri/server/src/server/core/plugin_host/update.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
index ae65bc30e..fe727e5c8 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
@@ -221,7 +221,9 @@ pub async fn read_index_result() -> Result, String> {
response.status.as_u16()
));
}
- let mut entries = parse_index(response.value, response.official, Some(&url)).await?;
+ let base_url = url.rsplit_once('/').map(|(base, _)| format!("{base}/"));
+ let mut entries =
+ parse_index(response.value, response.official, base_url.as_deref()).await?;
if let Some(custom) = read_custom_index_result().await {
entries.extend(custom);
}
From 02a9f1d6b244aa00c2d9a2f94a05896f6d49920c Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 08:36:47 +0800
Subject: [PATCH 05/23] fix(plugins): support run template in plugin tag and
trust ssujojo key
---
.../server/src/server/api/pipeline.rs | 4 ++
.../src/server/core/plugin_host/install.rs | 15 +++--
.../src/server/core/plugin_host/update.rs | 62 +++++++++++++++++--
.../core/upstream/provider_loop/tests.rs | 3 +-
4 files changed, 75 insertions(+), 9 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs b/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs
index 47b72ff24..6bb4d9ccf 100644
--- a/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs
+++ b/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs
@@ -1209,6 +1209,10 @@ mod tests {
limit: Some(5),
model: None,
provider: None,
+ client: None,
+ api_key: None,
+ production_only: false,
+ completed_only: false,
status: None,
start: None,
end: None,
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/install.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/install.rs
index a829528fd..fdeff278a 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/install.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/install.rs
@@ -68,10 +68,17 @@ pub use super::pack_view::{list_packs, resolve_ui_file, PackProviderSummary, Pac
/// `official-2026`:2026-10 生成,私钥只存在发布方与插件仓库的 GitHub
/// Actions secret(`AGENT2API_PLUGIN_KEY`)里,CI 打包后自动签名。
/// 轮换时把新公钥加进来、等插件包全部重签后再删旧的。
-pub const OFFICIAL_PUBKEYS: &[(&str, &str)] = &[(
- "official-2026",
- "7cdac378ff9bf23b72ae1b686f19859b3c802c26eed13c699f7df39f027352d6",
-)];
+pub const OFFICIAL_PUBKEYS: &[(&str, &str)] = &[
+ (
+ "official-2026",
+ "7cdac378ff9bf23b72ae1b686f19859b3c802c26eed13c699f7df39f027352d6",
+ ),
+ // SsuJojo 私人插件源(Agent2Providers fork)的签名公钥。
+ (
+ "ssujojo-2026",
+ "1ef33e85fbecbe0a35ea7d040f68e9f315e67cac264d51187034398938e50847",
+ ),
+];
/// 验签结果。
///
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
index fe727e5c8..45a3fe634 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
@@ -205,7 +205,12 @@ async fn read_custom_index_result() -> Option> {
if !response.status.is_success() {
return None;
}
- parse_index(response.value, false, Some(CUSTOM_INDEX_URL)).await.ok()
+ let index_url = CUSTOM_INDEX_URL
+ .rsplit_once('/')
+ .map(|(base, _)| format!("{base}/"));
+ parse_index(response.value, false, index_url.as_deref())
+ .await
+ .ok()
}
pub async fn read_index_result() -> Result, String> {
@@ -328,9 +333,35 @@ fn valid_repo(repo: &str) -> bool {
fn release_version(release: &Value, template: &str) -> Option {
let tag = text(release, "tag_name");
- let (prefix, suffix) = template.split_once("{version}")?;
- let version = tag.strip_prefix(prefix)?.strip_suffix(suffix)?;
- compare_versions(version, version)?;
+ let version_at = template.find("{version}")?;
+ let Some(run_at) = template.find("{run}") else {
+ let prefix = &template[..version_at];
+ let suffix = &template[version_at + "{version}".len()..];
+ let version = tag.strip_prefix(prefix)?.strip_suffix(suffix)?;
+ return compare_versions(version, version).map(|_| version.to_string());
+ };
+ let (prefix, middle, tail, run_first) = if run_at < version_at {
+ let middle = &template[run_at + "{run}".len()..version_at];
+ let tail = &template[version_at + "{version}".len()..];
+ (&template[..run_at], middle, tail, true)
+ } else {
+ let middle = &template[version_at + "{version}".len()..run_at];
+ let tail = &template[run_at + "{run}".len()..];
+ (&template[..version_at], middle, tail, false)
+ };
+ let rest = tag.strip_prefix(prefix)?.strip_suffix(tail)?;
+ let (left, right) = rest.split_once(middle)?;
+ let (version, run) = if run_first {
+ (right, left)
+ } else {
+ (left, right)
+ };
+ if compare_versions(version, version).is_none() {
+ return None;
+ }
+ if run.is_empty() || !run.bytes().all(|byte| byte.is_ascii_digit()) {
+ return None;
+ }
Some(version.to_string())
}
@@ -719,4 +750,27 @@ mod tests {
.expect("应当挑到 Linux 包");
assert_eq!(asset.version, "1.2.3");
}
+
+ #[test]
+ fn parses_fork_run_tag_template() {
+ let release = json!({
+ "tag_name": "v0.2.1-fork.17",
+ "assets": [
+ { "name": "ssujojo-providers-0.2.1-x86_64-pc-windows-msvc.zip",
+ "browser_download_url": "https://example.com/a.zip", "size": 100 }
+ ]
+ });
+ let detail = PluginDetail {
+ protocol: 1,
+ repo: "SsuJojo/Agent2Providers".to_string(),
+ tag_template: "v{version}-fork.{run}".to_string(),
+ asset_template: "{id}-{version}-{target}.zip".to_string(),
+ homepage: String::new(),
+ require_signed: true,
+ };
+ let assets = pick_release_assets(&release, "ssujojo-providers", Some(&detail))
+ .expect("应当解析 fork run tag");
+ assert_eq!(assets.version, "0.2.1");
+ assert_eq!(assets.platforms.len(), 1);
+ }
}
diff --git a/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop/tests.rs b/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop/tests.rs
index fc9cd5e6b..57d39e9e3 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop/tests.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop/tests.rs
@@ -332,8 +332,9 @@ async fn a_real_413_response_is_sent_once_and_handed_back() {
&transport,
&mut budget,
Some(&capture),
- &RequestTelemetry::new(),
+ &std::sync::Arc::new(RequestTelemetry::new()),
false,
+ None,
)
.await;
task.abort();
From 8eb8c964bd3623c6ae1b100c3100bb0a86b35766 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 08:46:02 +0800
Subject: [PATCH 06/23] fix(plugins): prioritize custom provider pack over
legacy official pack
---
.../server/src/server/core/plugin_host/ownership.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/ownership.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/ownership.rs
index df5f067a0..5cb11901b 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/ownership.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/ownership.rs
@@ -30,7 +30,10 @@ pub(super) fn category(dir: &Path) -> ProviderCategory {
pub(super) fn owners(registry: &PackRegistry) -> BTreeMap {
let mut owners = BTreeMap::new();
- for pack in registry.packs.iter().filter(|pack| pack.enabled) {
+ // 自定义提供商插件优先于官方兜底包接管同名提供商,确保本地修复生效。
+ let mut sorted_packs: Vec<&InstalledPack> = registry.packs.iter().filter(|pack| pack.enabled).collect();
+ sorted_packs.sort_by_key(|pack| pack.id == LEGACY_PACK_ID);
+ for pack in sorted_packs {
for provider in declared_ids(pack).into_iter().filter(|id| {
!reserved(id) && !crate::server::core::providers::availability::is_suspended(id)
}) {
From be9b6a671c4d8680d54117a1caa0f22b52acdee0 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 11:28:42 +0800
Subject: [PATCH 07/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A429=20?=
=?UTF-8?q?=E5=90=8E=E5=8F=8D=E5=A4=8D=E5=91=BD=E4=B8=AD=E5=90=8C=E4=B8=80?=
=?UTF-8?q?=E8=B4=A6=E5=8F=B7=E3=80=81=E4=B8=8D=E6=8D=A2=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## 问题
普通转发请求遇到 429 时未进入错误分类,上游错误被当成正常流透传,
`attempts=1、error=null、stickyHit=true`,即使队列里还有可用账号也一直
重试同一个仍在冷却的账号。
## 根因
插件 SDK 默认 `is_error_response()` 恒返回 false,网关 `RpcAdapter` 把
插件答复当作唯一门禁,因此非 2xx 也可能被判成「不是错误」,
`classify / 冷却 / 换号` 链路从未执行。
## 修改
- `RpcAdapter::is_error_response_async`:非 2xx 一律按错误处理;插件只允许
把 2xx 额外判为错误,不能把非 2xx 降级为成功。
- 空响应体 429 兜底为短期限流:优先采用有效 `Retry-After`(秒数或 RFC 2822),
缺失时落现有限流默认时长;客户端错误回带 `Retry-After`。
- 选路保留既有「冷却优先于会话粘性」语义,新增契约测试钉住该行为。
- 请求明细的 `notice` 区分未换号原因:禁止换号 / 无候选账号 / 换号预算耗尽。
- 显式关闭失败换号、指定账号测试、其他状态码处理保持既有语义。
## 验证
- `local_failure::` 8 passed;`routing::tests::` 12 passed;`plugin_host::` 29 passed。
- 全量 `--lib` 285 passed / 1 failed,失败项为既有无关的
`codearts_daily_pool_envelope_cools_to_the_boundary_instead_of_ten_minutes`
(CodeArts 已迁插件、`adapter_for` 现返回占位符),本次改动未触碰该家。
- 未做真实上游验证。
---
.../server/src/server/core/plugin_host/rpc.rs | 22 +-
.../server/src/server/core/routing.rs | 50 ++++
.../src/server/core/upstream/provider_loop.rs | 231 +++++++++++++++++-
3 files changed, 289 insertions(+), 14 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
index de90ab1a6..92048200f 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
@@ -417,7 +417,7 @@ impl ProviderAdapter for RpcAdapter {
})
}
- /// 上游响应是否「其实是错误」(HTTP 200 但正文是业务失败)。
+ /// 上游响应是否「其实是错误」(HTTP 200 但正文是业务失败;非 2xx 一律是错误)。
///
/// ── 为什么这一位必须问插件 ──────────────────────────────────
/// 这条判据是 provider 知识:ZCode 的活动套餐通道用 HTTP 200 +
@@ -427,21 +427,29 @@ impl ProviderAdapter for RpcAdapter {
/// 这里会把它们当成功,直接交给 SSE 翻译层 —— 结果是 `output` 为空的
/// 一次「成功」响应,账号也不会进冷却。
///
- /// ── 插件问不到时为什么回落到默认 ────────────────────────────
- /// RPC 失败说明插件挂了;此时按 HTTP 状态码判成功至少与内置家同一口径,
- /// 不会因为一次控制面超时把所有 2xx 响应都当成错误而误罚账号。
+ /// ── 插件问不到时为什么 2xx 回落为成功 ────────────────────────
+ /// 非 2xx 在进入这条判据之前已经按错误处理(HTTP 状态码本身即证据,插件
+ /// 对状态码的「不是错误」答复不能覆盖,否则未覆写的家会把 429 当正常流透传);
+ /// 2xx 时 RPC 失败说明插件挂了,保持成功至少与内置家同一口径,不会因为一次
+ /// 控制面超时把所有 2xx 响应都当成错误而误罚账号。
fn is_error_response_async<'a>(
&'a self,
status: u16,
headers: &'a HeaderMap,
) -> std::pin::Pin> + Send + 'a>> {
Box::pin(async move {
- let default = !(200..300).contains(&status);
+ // 非 2xx 一律按错误处理:插件对 HTTP 状态码的「不是错误」回答不能
+ // 覆盖这个事实(SDK 默认 `is_error_response` 返回 false,未覆写的家
+ // 会把 429 当正常流透传,错误永远进不了分类 / 冷却 / 换号)。
+ if !(200..300).contains(&status) {
+ return Ok(true);
+ }
+ let default = false;
let mut params = self.base();
params.insert("status".into(), Value::from(status));
params.insert("headers".into(), headers_json(headers));
- // 控制面问不到时回落到 HTTP 状态码:一次 RPC 超时不该把所有 2xx
- // 响应都判成错误,从而误罚账号。
+ // 2xx 时插件可以把它「升级」成错误(HTTP 200 + JSON 业务失败);
+ // 控制面问不到则保持成功,一次 RPC 超时不该把所有 2xx 都误罚。
let value = self.control(
proto::methods::gateway::IS_ERROR_RESPONSE, Value::Object(params),
).await;
diff --git a/desktop-tauri/src-tauri/server/src/server/core/routing.rs b/desktop-tauri/src-tauri/server/src/server/core/routing.rs
index c4a887799..88c132065 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/routing.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/routing.rs
@@ -871,6 +871,21 @@ mod tests {
json!({ "id": id, "provider": provider, "priority": priority })
}
+ fn limited_account(
+ id: &str,
+ provider: &str,
+ priority: i64,
+ model: &str,
+ reset_at: i64,
+ ) -> Value {
+ json!({
+ "id": id,
+ "provider": provider,
+ "priority": priority,
+ "rateLimits": { model: { "resetAt": reset_at } },
+ })
+ }
+
fn ordered_ids(accounts: &[Value], meta: &PlanMeta<'_>) -> Vec {
provider_order(accounts.to_vec(), meta)
.iter()
@@ -1022,6 +1037,41 @@ mod tests {
assert_eq!(plan.ordered[2].id, "a2");
}
+ /// 冷却优先于会话粘性:粘住的账号仍在冷却时不能置顶,必须让位给可用候选。
+ ///
+ /// 粘性只在「收集阶段后仍留在 `ordered`」的账号里生效 —— 被限额冷却的账号
+ /// 在收集阶段就进了 `blocked`,粘性无法把一个不可用的账号捞回队首。
+ /// 这条用例把「粘性命中 + 该账号正在冷却」钉成契约,防止有人把置顶挪到收集前。
+ #[test]
+ fn cooldown_blocks_sticky_promotion() {
+ let empty_numbers: HashMap = HashMap::new();
+ let empty_ids: std::collections::HashSet = std::collections::HashSet::new();
+ let counts: HashMap = HashMap::new();
+ let now = 1_700_000_000_000i64;
+ let keys = CooldownKeys::new("test-model");
+ // a2 粘性命中,但它正在冷却;a1/a3 可用。
+ let accounts = vec![
+ account("a1", "A", 100),
+ limited_account("a2", "A", 110, "test-model", now + 60_000),
+ account("a3", "A", 120),
+ ];
+ let meta = PlanMeta {
+ strategy: RouteStrategy::Order,
+ sunk: &empty_numbers,
+ resting: &empty_numbers,
+ open: &empty_ids,
+ limiter_blocked: &empty_ids,
+ cursor: None,
+ provider_cursors: None,
+ sticky_account: Some("a2"),
+ };
+ let plan = plan_route(&accounts, &keys, &counts, &[], now, &meta);
+ let order: Vec<&str> = plan.ordered.iter().map(|entry| entry.id.as_str()).collect();
+ assert_eq!(order, vec!["a1", "a3"], "冷却中的粘性账号必须被剔除,而不是置顶");
+ assert!(!plan.sticky_hit, "粘性不能对已被滤除的冷却账号宣称为命中");
+ assert!(plan.blocked.iter().any(|entry| entry.id == "a2" && entry.state == "cooldown"));
+ }
+
/// 家内轮询下也一样:命中项置顶后,家内顺序的**其余部分**照常环绕。
#[test]
fn sticky_pinning_survives_under_the_provider_strategy() {
diff --git a/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop.rs b/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop.rs
index 0899ede72..28fc8dedc 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/upstream/provider_loop.rs
@@ -100,6 +100,7 @@ use crate::server::logging;
use super::payload::{send_body, ProviderContext, SendBody};
use super::request::{read_upstream_error, send_chat_request, TransportRequest};
use super::usage::LogPhase;
+use super::usage::RequestTelemetry;
use super::{
account_display, account_label, cancellation, connections::ConnectionGuard, describe_proxy,
format_reset_text, refusal, reset_hint, rotate, ForwardOutcome, InFlightGuard, RouteTarget,
@@ -193,6 +194,7 @@ fn take_switch(switches_left: &mut usize, total: usize) -> bool {
#[allow(clippy::too_many_arguments)]
fn defer_to_next_account(
service: &UpstreamService,
+ telemetry: &RequestTelemetry,
provider_ids: &[&str],
cooldown_keys: &rotate::CooldownKeys<'_>,
tried_ids: &mut Vec,
@@ -214,9 +216,21 @@ fn defer_to_next_account(
let Some(next) =
rotate::pick_next_account(service, provider_ids, cooldown_keys, tried_ids, pinned)
else {
+ note_deferral_notice(
+ telemetry,
+ if tried_ids
+ .last()
+ .is_some_and(|last| !rotate::allows_route_skip(service, last))
+ {
+ "未换号(该账号已关闭失败换号)"
+ } else {
+ "未换号(无可用候选账号)"
+ },
+ );
return false;
};
if !take_switch(switches_left, switch_total) {
+ note_deferral_notice(telemetry, "未换号(换号预算已耗尽)");
return false;
}
let next_home = {
@@ -250,6 +264,14 @@ fn defer_to_next_account(
true
}
+/// 顺延判定收尾但**没有换号**时,把「为什么停在这里」写进本轮尝试明细的 `notice`。
+///
+/// 三档原因共用同一出口(原样返回本次错误),但排障时用户要能分清「明确禁止换号 /
+/// 队列里没有候选 / 换号预算耗尽」;尝试明细的 `notice` 不参与转发判定,只补可观测性。
+fn note_deferral_notice(telemetry: &RequestTelemetry, tag: &str) {
+ telemetry.note_attempt_notice(tag);
+}
+
/// 瞬时 HTTP 状态码:适配器没声明专属重试时,按全局重试设置原样重发再看一眼。
///
/// 只收 408(请求超时)与 5xx(网关 / 服务器错误)—— 都是上游或链路自己的
@@ -333,6 +355,42 @@ fn transport_retry_advice(error: &super::request::UpstreamRequestError, remainin
})
}
+/// 上游 `Retry-After` 头 → 绝对恢复时刻(毫秒);两种合法形态都认:
+/// delay-seconds(整数秒)与 HTTP-date(RFC 2822)。无法识别返回 None(调用方落默认冷却)。
+fn retry_after_reset_at(retry_after: Option<&str>, now_ms: i64) -> Option {
+ let text = retry_after?.trim();
+ if let Ok(seconds) = text.parse::() {
+ return (seconds > 0)
+ .then(|| now_ms.saturating_add(seconds.saturating_mul(1000)));
+ }
+ chrono::DateTime::parse_from_rfc2822(text)
+ .ok()
+ .map(|date| date.timestamp_millis())
+ .filter(|reset_at| *reset_at > now_ms)
+}
+
+/// 空响应体的 429 兜底:HTTP 状态码足以证明是限流,但插件分类器拿不到文案证据
+/// 时可能把它降级成 Fatal —— 那样既不冷却也不换号。这里只把「429 + 空文案 +
+/// 无证据分类」按短期限流归类,其余形态一律原样保留。
+fn empty_body_429_class(
+ class: UpstreamErrorClass,
+ status: u16,
+ body_message: &str,
+ upstream_code: Option,
+ retry_after: Option<&str>,
+ now_ms: i64,
+) -> UpstreamErrorClass {
+ if status == 429 && body_message.is_empty() && matches!(class, UpstreamErrorClass::Fatal { .. }) {
+ return UpstreamErrorClass::QuotaLimited {
+ reset_at: retry_after_reset_at(retry_after, now_ms),
+ message: "上游返回 429: 请求频率受限,请稍后重试".to_string(),
+ upstream_code,
+ status,
+ };
+ }
+ class
+}
+
/// 兜底退避建议:**非限额**的上游错误,在换账号之前先在同一账号上重发。
///
/// ── 为什么需要这一档 ────────────────────────────────────────
@@ -758,6 +816,7 @@ async fn attempt_queue(
// (`take_switch` 已写过那行终端日志),本次错误原样
// 返回:与「没有下一个可用账号」同一个出口。
if !take_switch(&mut switches_left, switch_total) {
+ note_deferral_notice(ctx.telemetry, "未换号(换号预算已耗尽)");
return Err(error);
}
logging::console_line(
@@ -772,7 +831,20 @@ async fn attempt_queue(
);
continue 'accounts;
}
- None => return Err(error),
+ None => {
+ note_deferral_notice(
+ ctx.telemetry,
+ if tried_ids
+ .last()
+ .is_some_and(|last| !rotate::allows_route_skip(service, last))
+ {
+ "未换号(该账号已关闭失败换号)"
+ } else {
+ "未换号(无可用候选账号)"
+ },
+ );
+ return Err(error);
+ }
}
}
}
@@ -884,6 +956,7 @@ async fn attempt_queue(
// (`take_switch` 已写过那行终端日志),本次错误原样
// 返回:与「没有下一个可用账号」同一个出口。
if !take_switch(&mut switches_left, switch_total) {
+ note_deferral_notice(ctx.telemetry, "未换号(换号预算已耗尽)");
return Err(error);
}
// 顺延这件事本身由请求日志的尝试链回答(本轮明细已经
@@ -900,7 +973,20 @@ async fn attempt_queue(
);
continue 'accounts;
}
- None => return Err(error),
+ None => {
+ note_deferral_notice(
+ ctx.telemetry,
+ if tried_ids
+ .last()
+ .is_some_and(|last| !rotate::allows_route_skip(service, last))
+ {
+ "未换号(该账号已关闭失败换号)"
+ } else {
+ "未换号(无可用候选账号)"
+ },
+ );
+ return Err(error);
+ }
}
}
}
@@ -1112,6 +1198,7 @@ async fn attempt_queue(
}
if defer_to_next_account(
service,
+ ctx.telemetry,
provider_ids,
&cooldown_keys,
&mut tried_ids,
@@ -1500,6 +1587,10 @@ async fn attempt_queue(
let from_label =
account_label(target.account.as_ref(), &account_id, &session);
if !rotate::allows_route_skip(service, &account_id) {
+ note_deferral_notice(
+ ctx.telemetry,
+ "未换号(该账号已关闭失败换号)",
+ );
rotate::report_limit_event(
"warn",
&format!("账号「{from_label}」对模型 {limit_label} 已限额,已关闭失败换号"),
@@ -1567,6 +1658,10 @@ async fn attempt_queue(
continue 'accounts;
}
None => {
+ note_deferral_notice(
+ ctx.telemetry,
+ "未换号(无可用候选账号)",
+ );
// 所有候选都在冷却 / 禁用里 —— 把**最早的恢复时刻**
// 带进文案:客户端(Claude Code / Codex 等会读这条
// 文案的)才能做合法的退避等待,而不是立刻重试再撞
@@ -1670,6 +1765,7 @@ async fn attempt_queue(
// 失败」共用同一条路,判据不该有两份。
if defer_to_next_account(
service,
+ ctx.telemetry,
provider_ids,
&cooldown_keys,
&mut tried_ids,
@@ -2859,6 +2955,13 @@ async fn send_with_retry(
return Ok(super::images::ImageResponse::Live(response));
}
let status = response.status().as_u16();
+ // Retry-After 要在读 body **之前**取(`read_upstream_error` 会吃掉响应):
+ // 空响应体的 429 没有可解析文案,但上游可能用这个头给出精确冷却时长。
+ let retry_after = response
+ .headers()
+ .get(reqwest::header::RETRY_AFTER)
+ .and_then(|value| value.to_str().ok())
+ .map(str::to_string);
// 错误响应体的读取同样受「非流式响应超时」管(对应 OmniProxy
// readBodyWithStallGuard 的用法之一):上游接了错误响应却迟迟不吐完
// 出错体时,不能让「读错误」把请求挂住 —— 读不出来就当上游没给细节,
@@ -2874,7 +2977,26 @@ async fn send_with_retry(
}
};
let body = detail.to_value();
- let class = adapter.classify_error_async(status, &body).await;
+ let mut class = adapter.classify_error_async(status, &body).await;
+ class = empty_body_429_class(
+ class,
+ status,
+ &detail.message,
+ detail.code,
+ retry_after.as_deref(),
+ logging::now_ms(),
+ );
+ // 分类器没给出恢复时刻时,优先相信上游的 Retry-After(秒数或 HTTP 日期);
+ // 都没有时 mark_account_limited 自己会落 10 分钟兜底冷却。
+ if let UpstreamErrorClass::QuotaLimited { reset_at: slot, .. } = &mut class {
+ if slot.is_none() {
+ if let Some(reset_at) =
+ retry_after_reset_at(retry_after.as_deref(), logging::now_ms())
+ {
+ *slot = Some(reset_at);
+ }
+ }
+ }
let decision = adapter
.retry_decision_async(status, &body, budget.used(), budget.total)
.await;
@@ -2937,9 +3059,13 @@ async fn send_with_retry(
);
// 文案由适配器给出(含 provider 提示),编排层原样组装成网关错误
let error = match &class {
- UpstreamErrorClass::QuotaLimited { status, message, upstream_code, .. } => {
- GatewayError::with_status(*status as i32, message.clone())
- .with_optional_code(*upstream_code)
+ UpstreamErrorClass::QuotaLimited { status, message, upstream_code, reset_at, .. } => {
+ let error = GatewayError::with_status(*status as i32, message.clone())
+ .with_optional_code(*upstream_code);
+ match (*reset_at).map(|reset_at| (reset_at - logging::now_ms()) / 1000) {
+ Some(seconds) if seconds > 0 => error.with_retry_after_seconds(seconds as u64),
+ _ => error,
+ }
}
// 内容拦截与 Fatal 的客户端形态相同(状态码 + 上游原文 + 上游码):
// 区别只在**编排动作**(前者不罚账号、先换提示词补救),不在文案。
@@ -3044,4 +3170,95 @@ mod local_failure {
assert_eq!(502, error.status_code);
assert_eq!(None, error.retry_after_secs, "内容型不该带 Retry-After");
}
-}
\ No newline at end of file
+
+ #[test]
+ fn retry_after_seconds_become_an_absolute_reset_moment() {
+ let now = 1_700_000_000_000i64;
+ // delay-seconds:30 秒后的绝对毫秒时刻
+ assert_eq!(
+ super::retry_after_reset_at(Some("30"), now),
+ Some(now + 30_000),
+ "整数字段应解释为相对秒数"
+ );
+ // 0 / 负数不作为恢复时刻 —— 让调用方落默认冷却
+ assert_eq!(super::retry_after_reset_at(Some("0"), now), None);
+ assert_eq!(super::retry_after_reset_at(Some("-5"), now), None);
+ // 畸形值不 panic,只返回 None
+ assert_eq!(super::retry_after_reset_at(Some("later"), now), None);
+ // HTTP-date(RFC 2822)同样被接受
+ assert_eq!(
+ super::retry_after_reset_at(Some("Wed, 01 Jan 2031 00:00:30 GMT"), now),
+ Some(1_924_992_030_000),
+ );
+ // 缺失头返回 None
+ assert_eq!(super::retry_after_reset_at(None, now), None);
+ }
+
+ #[test]
+ fn a_past_rfc2822_date_is_not_a_future_reset() {
+ let now = 1_700_000_000_000i64;
+ // 2000 年的日期远早于 now —— 不能把它当冷却恢复时刻
+ assert_eq!(
+ super::retry_after_reset_at(Some("Sat, 01 Jan 2000 00:00:00 GMT"), now),
+ None,
+ );
+ }
+
+ #[test]
+ fn an_empty_body_429_is_treated_as_short_quota_cooldown() {
+ use super::UpstreamErrorClass;
+
+ let now = 1_700_000_000_000i64;
+ let fatal = UpstreamErrorClass::Fatal {
+ status: 429,
+ message: String::new(),
+ upstream_code: None,
+ };
+ // 不带 Retry-After:reset_at 为 None,由 mark_account_limited 落默认冷却
+ let class = super::empty_body_429_class(fatal.clone(), 429, "", None, None, now);
+ assert!(
+ matches!(class, UpstreamErrorClass::QuotaLimited { status: 429, reset_at: None, .. }),
+ "空 body 429 必须归类为限额,才能触发冷却与换号,得到 {class:?}"
+ );
+ // 带 Retry-After:恢复时刻优先取上游给的秒数
+ let class = super::empty_body_429_class(fatal, 429, "", None, Some("30"), now);
+ match class {
+ UpstreamErrorClass::QuotaLimited { reset_at: Some(reset_at), status, .. } => {
+ assert_eq!(status, 429);
+ assert_eq!(reset_at, now + 30_000);
+ }
+ other => panic!("带 Retry-After 的空 429 应有精确恢复时刻,得到 {other:?}"),
+ }
+ }
+
+ #[test]
+ fn an_empty_body_429_does_not_overwrite_an_evidence_backed_class() {
+ use super::UpstreamErrorClass;
+
+ let now = 1_700_000_000_000i64;
+ // 插件已经给出有证据的限额分类:即使 body 为空也不能降级兜底折腾它
+ let quota = UpstreamErrorClass::QuotaLimited {
+ reset_at: Some(now + 3600_000),
+ message: "上游返回 429: quota exceeded".to_string(),
+ upstream_code: Some(429),
+ status: 429,
+ };
+ let class = super::empty_body_429_class(quota.clone(), 429, "", Some(429), None, now);
+ assert!(matches!(class, UpstreamErrorClass::QuotaLimited { .. }), "{class:?}");
+ // 失败但携带正文的 429 不是「空 body」,保持原来分类,不改写成限额
+ let fatal_with_text = UpstreamErrorClass::Fatal {
+ status: 429,
+ message: "上游返回 429: not rate limited after all".to_string(),
+ upstream_code: None,
+ };
+ let class = super::empty_body_429_class(
+ fatal_with_text.clone(),
+ 429,
+ "not rate limited after all",
+ None,
+ None,
+ now,
+ );
+ assert!(matches!(class, UpstreamErrorClass::Fatal { status: 429, .. }), "{class:?}");
+ }
+}
From 0b922c1886f28f2b2cb51cb1f0186f81e7a59ada Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 11:34:36 +0800
Subject: [PATCH 08/23] feat(plugins): support beta release line via alt tag
templates
---
.../server/core/plugin_host/compatibility.rs | 1 +
.../src/server/core/plugin_host/update.rs | 58 +++++++++++++++++--
2 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/compatibility.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/compatibility.rs
index 340b04082..fe117b702 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/compatibility.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/compatibility.rs
@@ -90,6 +90,7 @@ async fn find_asset(id: &str) -> Result {
protocol: agent2api_provider_protocol::PROTOCOL_VERSION,
repo: update::FALLBACK_REPO.to_string(),
tag_template: if id == "agent2api-web-providers" { "web-v{version}" } else { "v{version}" }.to_string(),
+ alt_tag_templates: Vec::new(),
asset_template: "{id}-{version}-{target}.zip".to_string(),
homepage: String::new(),
require_signed: true,
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
index 45a3fe634..054d48fb2 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/update.rs
@@ -52,6 +52,8 @@ pub struct PluginDetail {
pub protocol: u32,
pub repo: String,
pub tag_template: String,
+ /// 备用 tag 模板(如 beta 线的 `v{version}-fork-beta.{run}`)。
+ pub alt_tag_templates: Vec,
pub asset_template: String,
pub homepage: String,
pub require_signed: bool,
@@ -285,6 +287,18 @@ pub async fn read_detail_in(base_url: Option<&str>, path: &str) -> Option,
) -> Option {
- let tag = detail
- .map(|detail| detail.tag_template.as_str())
- .unwrap_or("v{version}");
- let version = release_version(release, tag)?;
+ let templates = detail
+ .map(|detail| {
+ let mut templates = vec![detail.tag_template.clone()];
+ templates.extend(detail.alt_tag_templates.iter().cloned());
+ templates
+ })
+ .unwrap_or_else(|| vec!["v{version}".to_string()]);
+ let mut version = None;
+ for template in &templates {
+ if let Some(parsed) = release_version(release, template) {
+ version = Some(parsed);
+ break;
+ }
+ }
+ let version = version?;
let template = detail
.map(|detail| detail.asset_template.as_str())
.unwrap_or("{id}-{version}-{target}.zip")
@@ -764,6 +789,7 @@ mod tests {
protocol: 1,
repo: "SsuJojo/Agent2Providers".to_string(),
tag_template: "v{version}-fork.{run}".to_string(),
+ alt_tag_templates: Vec::new(),
asset_template: "{id}-{version}-{target}.zip".to_string(),
homepage: String::new(),
require_signed: true,
@@ -773,4 +799,28 @@ mod tests {
assert_eq!(assets.version, "0.2.1");
assert_eq!(assets.platforms.len(), 1);
}
+
+ #[test]
+ fn parses_fork_beta_run_tag_template() {
+ let release = json!({
+ "tag_name": "v3.3.0-beta.6-fork-beta.3",
+ "assets": [
+ { "name": "ssujojo-providers-3.3.0-beta.6-x86_64-pc-windows-msvc.zip",
+ "browser_download_url": "https://example.com/beta.zip", "size": 100 }
+ ]
+ });
+ let detail = PluginDetail {
+ protocol: 1,
+ repo: "SsuJojo/Agent2Providers".to_string(),
+ tag_template: "v{version}-fork.{run}".to_string(),
+ alt_tag_templates: vec!["v{version}-fork-beta.{run}".to_string()],
+ asset_template: "{id}-{version}-{target}.zip".to_string(),
+ homepage: String::new(),
+ require_signed: true,
+ };
+ let assets = pick_release_assets(&release, "ssujojo-providers", Some(&detail))
+ .expect("应当解析 fork-beta run tag");
+ assert_eq!(assets.version, "3.3.0-beta.6");
+ assert_eq!(assets.platforms.len(), 1);
+ }
}
From 6e9e13afdcecedd2f37f1bc2d2eceb248042f575 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 11:43:28 +0800
Subject: [PATCH 09/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AAutoClaw?=
=?UTF-8?q?=E3=80=8C=E5=85=8D=E8=B4=B9=E9=A2=9D=E5=BA=A6=E7=94=A8=E5=AE=8C?=
=?UTF-8?q?=E3=80=8D403=20=E6=8C=89=E9=99=90=E6=B5=81=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
AutoClaw 上游把「GLM-5.3 免费额度已用完,开通连续包月会员继续使用」
包成 HTTP 403 + code 810000。插件 classify 只按状态码走:403 不在
401 / 429 / 内容拦截那张表里,落进 Fatal 原样透传 —— 账号不冷却、
不换号,客户端每轮都撞同一面墙(近 72h 生产库 403×75 全部
attempts=1、无 retries、无冷却)。
- `RpcAdapter::classify_error_async`:插件分类结果之后,对 AutoClaw
两地(autoclaw / autoclaw-intl)的 403 + code 810000(或正文含
「免费额度已用完」)做网关侧兜底覆盖 → QuotaLimited。
- reset_at:上游不给恢复时刻,免费额度按天重置,取下一个北京时间
(UTC+8)零点 —— 与 CodeArts 福利日池、degrade 的零点口径同源。
- 其它 403(含 pay-view 810001)与非 AutoClaw 家不受影响。
- 新增 2 条单测:403+810000 → QuotaLimited 且恢复时刻落北京零点;
810001 对照组仍是 Fatal。
- `plugin_host::` 31 passed(29 既有 + 2 新增)。
- 全量 `--lib` 287 passed / 1 failed,失败项仍为既有无关的
`codearts_daily_pool_envelope_...`(插件化后 adapter_for 返回
占位符所致,与本改动无关,c3806db 验证记录里已注明)。
---
.../server/src/server/core/plugin_host/rpc.rs | 65 +++++++++++++++++++
.../src/server/core/plugin_host/tests.rs | 52 +++++++++++++++
2 files changed, 117 insertions(+)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
index 92048200f..5e265ab7e 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
@@ -487,6 +487,7 @@ impl ProviderAdapter for RpcAdapter {
match serde_json::from_value::(value) {
Ok(class) => {
let class = upstream_error_class(class);
+ let class = autoclaw_quota_fallback(self.id, status, class, error_body);
if strict::applies(self.id) {
strict::sdk_class(self.id, status, class, error_body)
} else { class }
@@ -1448,6 +1449,70 @@ fn upstream_error_class(class: proto::ErrorClass) -> UpstreamErrorClass {
}
}
+/// AutoClaw 系「免费额度用完」的网关侧兜底分类。
+///
+/// ── 为什么在网关侧补一刀 ────────────────────────────────────
+/// 上游把「GLM-5.3 免费额度已用完」包成 403 + `code 810000`,插件侧的
+/// `classify` 只按状态码走:403 不在 401 / 429 / 内容拦截那几张表里,
+/// 落进 `Fatal` 原样透传 ⇒ 账号不冷却、不换号,客户端每轮都撞同一面墙。
+/// 这份知识不该依赖插件更新才能生效 —— 它是「403+810000 就是额度耗尽」
+/// 这一条纯判据,留在网关侧做兜底覆盖最稳。
+///
+/// ── 判据 ────────────────────────────────────────────────────
+/// 只认 AutoClaw 两地(`autoclaw` / `autoclaw-intl`)+ HTTP 403 +
+/// 业务码 810000(或正文含「免费额度已用完」)。其它家的 403 不动。
+///
+/// ── reset_at ────────────────────────────────────────────────
+/// 上游不给恢复时刻;免费额度按天重置(上游的日口径都是北京时间零点),
+ /// 取下一个北京零点,与 CodeArts 福利日池的冷却口径同一来源。
+pub(super) fn autoclaw_quota_fallback(
+ provider_id: &str,
+ status: u16,
+ class: UpstreamErrorClass,
+ error_body: &Value,
+) -> UpstreamErrorClass {
+ use crate::server::core::account_store::is_autoclaw_family;
+
+ if status != 403 || matches!(class, UpstreamErrorClass::QuotaLimited { .. }) {
+ return class;
+ }
+ if !is_autoclaw_family(provider_id) {
+ return class;
+ }
+ let code = error_body.get("code").and_then(Value::as_i64);
+ let message = error_body.get("message").and_then(Value::as_str).unwrap_or("");
+ if code != Some(810000) && !message.contains("免费额度已用完") {
+ return class;
+ }
+ let now_ms = crate::server::logging::now_ms();
+ UpstreamErrorClass::QuotaLimited {
+ reset_at: Some(next_beijing_midnight_ms(now_ms)),
+ message: class_message(&class, status, message),
+ upstream_code: code,
+ status,
+ }
+}
+
+/// 从分类结果里取出已有文案(Fatal/其它档的 message 已含 `上游返回 {status}:`)。
+fn class_message(class: &UpstreamErrorClass, status: u16, raw: &str) -> String {
+ match class {
+ UpstreamErrorClass::Fatal { message, .. }
+ | UpstreamErrorClass::ContentBlocked { message, .. } if !message.is_empty() => message.clone(),
+ _ => format!("上游返回 {status}: {raw}"),
+ }
+}
+
+/// `now` 之后最近的北京时间(UTC+8)零点(毫秒时间戳)。
+///
+/// 算法与 `degrade::next_midnight_cst_ms` 一致:平移 +8h 取整天边界再加一天。
+fn next_beijing_midnight_ms(now_ms: i64) -> i64 {
+ const CST_OFFSET_MS: i64 = 8 * 3600 * 1000;
+ const DAY_MS: i64 = 86_400_000;
+ let shifted = now_ms + CST_OFFSET_MS;
+ let start_of_today = shifted.div_euclid(DAY_MS) * DAY_MS;
+ start_of_today + DAY_MS - CST_OFFSET_MS
+}
+
impl RpcAdapter {
/// 把登录回调产出的账号落库。
///
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
index 2916caea6..aa420c388 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
@@ -174,6 +174,58 @@ async fn host_starts_and_lists_providers() {
host.shutdown().await;
}
+// ── AutoClaw「免费额度用完」403 的网关侧兜底分类 ─────────────────────────
+//
+// 上游把「GLM-5.3 免费额度已用完」包成 403 + code 810000,插件 classify 落
+// Fatal 原样透传 ⇒ 账号不冷却、不换号(生产库里 403 连续 75 次无冷却)。
+// 网关侧兜底把它升成 QuotaLimited 并冷却到下一个北京零点 —— 这里直接钉
+// 分类函数,不依赖插件二进制。
+
+/// 403 + 810000 → QuotaLimited,恢复时刻落在下一个北京零点。
+#[test]
+fn autoclaw_free_quota_403_is_classified_as_quota_limited() {
+ use chrono::Timelike;
+
+ let body = serde_json::json!({
+ "code": 810000,
+ "message": "GLM-5.3 免费额度已用完,开通连续包月会员继续使用",
+ });
+ let fatal = UpstreamErrorClass::Fatal {
+ status: 403,
+ message: "上游返回 403: GLM-5.3 免费额度已用完,开通连续包月会员继续使用".into(),
+ upstream_code: Some(810000),
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", 403, fatal, &body);
+ let UpstreamErrorClass::QuotaLimited { reset_at: Some(reset), status, upstream_code, .. } = &class else {
+ panic!("403+810000 应当被兜底成 QuotaLimited,实际 {class:?}");
+ };
+ assert_eq!(*status, 403);
+ assert_eq!(*upstream_code, Some(810000));
+ // 恢复时刻必须是北京零点:与 degrade 的 UTC+8 零点同一口径(按天重置)。
+ let at = crate::server::core::beijing::date_time_of_ms(*reset).expect("合法时间戳");
+ assert!(
+ at.hour() == 0 && at.minute() == 0 && at.second() == 0,
+ "恢复时刻必须是北京零点,实际 {}",
+ at.format("%Y-%m-%d %H:%M:%S")
+ );
+}
+
+/// 对照组:其它 403(如 pay-view 810001)不受兜底影响,仍是 Fatal。
+#[test]
+fn other_autoclaw_403_stays_fatal() {
+ let body = serde_json::json!({ "code": 810001, "message": "pay-view" });
+ let fatal = UpstreamErrorClass::Fatal {
+ status: 403,
+ message: "上游返回 403: pay-view".into(),
+ upstream_code: Some(810001),
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", 403, fatal, &body);
+ assert!(
+ matches!(class, UpstreamErrorClass::Fatal { .. }),
+ "非 810000 的 403 不该被兜底,实际 {class:?}"
+ );
+}
+
#[tokio::test(flavor = "multi_thread")]
async fn build_chat_request_goes_through_rpc() {
let Some((host, providers)) = boot().await else {
From b83823a3bccb6c6aeaefc427c745c4616c34b95b Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 14:24:40 +0800
Subject: [PATCH 10/23] =?UTF-8?q?chore(ui):=20=E9=87=8D=E5=BB=BA=E3=80=8C?=
=?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=9D=A5=E6=BA=90=E4=BD=9C=E8=80=85=E5=B1=95?=
=?UTF-8?q?=E7=A4=BA=E3=80=8D=E5=AF=B9=E5=BA=94=E7=9A=84=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E4=BA=A7=E7=89=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
747f4c2(feat: add private plugin source with author metadata)加了
作者展示源码与 i18n 词条,但没重建入库产物 —— beta 的
frontend-artifacts 闸从此红着。按 CI 同款三步构建重建:
ui-islands / mobile / i18n,产物与源码重新逐字节对齐。
验证:本地重建后 `git status --porcelain -- desktop-tauri/ui` 为空
(与 CI 判据一致)。
---
desktop-tauri/ui/i18n/zh-Hant/common.js | 2 +-
desktop-tauri/ui/islands/ui.js | 2 +-
desktop-tauri/ui/m/mobile.js | 2 +-
desktop-tauri/ui/sw.js | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/desktop-tauri/ui/i18n/zh-Hant/common.js b/desktop-tauri/ui/i18n/zh-Hant/common.js
index c3b02ccda..b17256455 100644
--- a/desktop-tauri/ui/i18n/zh-Hant/common.js
+++ b/desktop-tauri/ui/i18n/zh-Hant/common.js
@@ -1,2 +1,2 @@
/* Agent2API 词典构建产物:zh-Hant/common —— 由 desktop-tauri/i18n/build.mjs 生成,请勿手改;源头是 i18n-src/*.json */
-window.wbI18nDict = window.wbI18nDict || {}; Object.assign(window.wbI18nDict, { "无可用账号:{reason}": "無可用帳號:{reason}", "AI 助手": "AI 助手", "API Key 用量详情": "API Key 用量詳情", "API Key 统计": "API Key 統計", "API Key(可选)": "API Key(選填)", "API 凭证": "API 憑證", "API 方法提交给插件的账号规范化入口;不会用该密钥发起 OAuth 登录。": "API 方式會提交至外掛的帳號正規化入口;不會用此金鑰發起 OAuth 登入。", "Agent": "Agent", "Agent 接管": "Agent 接管", "Agent2API · 多提供商本地网关": "Agent2API · 多提供商本地閘道器", "Agent2API 官方提供商": "Agent2API 官方提供商", "Linux (amd64)": "Linux (amd64)", "Linux (arm64)": "Linux (arm64)", "OAuth 登录": "OAuth 登入", "QQ 群号": "QQ 群號", "Token 用量": "Token 用量", "Windows (ARM64)": "Windows (ARM64)", "Windows (x64)": "Windows (x64)", "macOS (Apple Silicon)": "macOS (Apple Silicon)", "macOS (Intel)": "macOS (Intel)", "{count} 家": "{count} 家", "{count} 家提供商 · 安装于 {time}": "{count} 家供應商 · 安裝於 {time}", "{key} 需要 true / false / null": "{key} 需要 true / false / null", "{key} 需要数字": "{key} 需要數字", "{label}(API)": "{label}(API)", "{label}(OAuth)": "{label}(OAuth)", "{n} 个启用": "{n} 個啟用", "{n} 个已限流": "{n} 個已限流", "{n} 个请求正在转发中,点开「请求日志」查看": "{n} 個請求正在轉發中,點開「請求日誌」檢視", "{n} 个账号 · {usable} 可用": "{n} 個帳號 · {usable} 可用", "{n} 个账号可用": "{n} 個帳號可用", "{n} 个账号启用": "{n} 個帳號啟用", "{n} 条失败请求未读,点开「请求日志」查看": "{n} 條失敗請求未讀,點開「請求日誌」檢視", "{n} 条错误日志未读,点开「日志」查看": "{n} 條錯誤日誌未讀,點開「日誌」檢視", "{n} 项 · {shown} 显示": "{n} 項 · {shown} 顯示", "{size} · 下载后可直接安装,无需跳转浏览器": "{size} · 下載後可直接安裝,無需跳轉瀏覽器", "{size} · 点击下载后可直接安装,无需跳转浏览器": "{size} · 點擊下載後可直接安裝,無需跳轉瀏覽器", "{total} 个菜单 · 显示 {shown} · 隐藏 {hidden} · {groups} 个分组": "{total} 個選單 · 顯示 {shown} · 隱藏 {hidden} · {groups} 個分組", "· 不会改动任何配置": "· 不會改動任何配置", "· 每次执行前列改动清单,等你确认": "· 每次執行前列改動清單,等你確認", "—": "—", "“本机”指运行网关的机器,不是打开面板的电脑。远程浏览器也可以发起,但网关本机可能需要安装客户端并已登录;是否可用由网关返回结果决定。": "「本機」指執行閘道的機器,不是開啟面板的電腦。遠端瀏覽器也可以發起,但閘道本機可能需要安裝用戶端並已登入;是否可用由閘道回傳結果決定。", "★ 下一单走它": "★ 下一單走它", "✅ GitHub 令牌已保存(加密存储,界面不再显示)": "✅ GitHub 權杖已儲存(加密儲存,介面不再顯示)", "✅ Token 已刷新": "✅ Token 已重新整理", "✅ 已将账号优先级调整到全局第一位": "✅ 已將帳號優先順序調整到全域第一位", "✅ 已清除界面保存的 GitHub 令牌(环境变量若配置过则继续生效)": "✅ 已清除介面儲存的 GitHub 權杖(環境變數若有設定則繼續生效)", "「{name}」匹配到多个账号:{list},请用完整账号名重试": "「{name}」匹配到多個帳號:{list},請用完整帳號名重試", "「工具全不勾选 → 不注入系统提示词」:想当纯聊天用时,不必再去关上面的开关。": "「工具全不勾選 → 不注入系統提示詞」:想當純聊天用時,不必再去關上面的開關。", "「设置」是固定项,含它的分组不能整组隐藏;可以单独隐藏组内其它菜单": "「設定」是固定項,含它的分組不能整組隱藏;可以單獨隱藏組內其它選單", "上一页": "上一頁", "下一页": "下一頁", "下拉刷新": "下拉重新整理", "下次自动重试:{time}": "下次自動重試:{time}", "下载与当前平台对应的插件包(zip),点右上角「安装插件包」选中它即可。": "下載與目前平台對應的外掛套件(zip),點右上角「安裝外掛套件」選取它即可。", "下载任务已交给网关,关闭手机不影响安装": "下載任務已交給閘道器,關閉手機不影響安裝", "下载进度": "下載進度", "不填写(可选)": "不填寫(選填)", "不限模型": "不限模型", "与电脑端一致:每 {n} 分钟": "與電腦端一致:每 {n} 分鐘", "为 Agent2API 扩展网页提供商,支持智谱清言的模型调用、访客与登录账号、凭证续期、模型目录、积分查询、签到和任务领取。": "為 Agent2API 擴充網頁提供商,支援智譜清言的模型呼叫、訪客與登入帳號、憑證續期、模型清單、積分查詢、簽到和任務領取。", "为网关扩展多家 AI 提供商,支持账号登录与导入、模型调用、凭证续期、模型目录、余额查询和签到。具体能力以各提供商的支持情况为准。": "為閘道擴充多家 AI 供應商,支援帳號登入與匯入、模型呼叫、憑證續期、模型清單、餘額查詢和簽到。具體能力以各供應商的支援情況為準。", "主导航": "主導航", "仅在该 API 方法需要额外密钥时填写": "僅在此 API 方式需要額外金鑰時填寫", "仅影响插件更新通道,与主程序独立。": "僅影響外掛更新通道,與主程式獨立。", "仅影响插件更新通道,与主程序独立。开启后可安装 beta 版;已使用 beta 时保持该通道,关闭后只看正式版且不会降级。": "僅影響插件更新通道,與主程式獨立。開啟後可安裝 beta 版;已使用 beta 時保持該通道,關閉後只看正式版且不會降級。", "从文件安装…": "從檔案安裝…", "从网关本机客户端导入": "從閘道本機用戶端匯入", "代价": "代價", "代理:池": "代理:池", "令牌已生效,但写入磁盘失败(重启后会丢失)": "權杖已生效,但寫入磁碟失敗(重新啟動後會遺失)", "以下设置属于所连接网关,不是手机本地设置。": "以下設定屬於所連接閘道,不是手機本機設定。", "会恢复默认的分组、顺序与显隐设置。你自建的分组会被删除(组内菜单不会丢)。": "會恢復預設的分組、順序與顯隱設定。你自建的分組會被刪除(組內選單不會丟)。", "会话内": "會話內", "会话已过期。重新登录后会自动回到手机端。": "會話已過期。重新登入後會自動回到手機端。", "会话粘性": "會話粘性", "低于限制器的阈值,转发时跳过该账号": "低於限制器的閾值,轉發時跳過該帳號", "余额不足或 Token 周期用量到顶,被限制器拦下,自动恢复后回来": "餘額不足或 Token 週期用量到頂,被限制器攔下,自動恢復後回來", "余额优先": "餘額優先", "作为 system 消息注入给助手": "作為 system 訊息注入給助手", "作者尚未提供插件介绍。": "作者尚未提供插件介紹。", "例如:家里、公司": "例如:家裡、公司", "侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "側邊欄佈局模組未載入(ui/sidebar-layout.js 應在 app.js 之前引入)。", "侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "側邊欄沒有顯示任何選單。到「設定 → 顯示 → 側邊欄選單」裡開啟需要的項。", "侧边栏菜单": "側邊欄選單", "保存失败:{error}": "儲存失敗:{error}", "保存对话模型失败:{message}": "儲存對話模型失敗:{message}", "保存并继续": "儲存並繼續", "候选队列": "候選佇列", "停止": "停止", "停用": "停用", "先添加一台网关": "先新增一臺閘道器", "先选择插件声明的账号登录方式,再填写必需字段。OAuth 由共享登录桥负责等待、取消和错误;API 凭证通过账号规范化入口添加。": "先選擇外掛宣告的帳號登入方式,再填寫必填欄位。OAuth 由共用登入橋接負責等待、取消和錯誤;API 憑證透過帳號正規化入口新增。", "免鉴权调用": "免鑑權呼叫", "全不选": "全不選", "全局队列位次(转发按策略在此序上再排)": "全域佇列位次(轉發按策略在此序上再排)", "全部 API Key": "全部 API Key", "全部客户端": "全部客戶端", "共 {n} 条记录": "共 {n} 條記錄", "共享登录桥不可用,请重新打开面板": "共用登入橋接無法使用,請重新開啟面板", "关": "關", "关闭菜单": "關閉選單", "冷却": "冷卻", "凭证 JSON 含有不允许的字段:{key}": "憑證 JSON 含有不允許的欄位:{key}", "凭证 JSON 嵌套过深,请只粘贴该插件要求的凭证对象": "憑證 JSON 巢狀層級過深,請只貼上此外掛要求的憑證物件", "凭证 JSON 必须是非空对象,不能是数组或字符串": "憑證 JSON 必須是非空物件,不能是陣列或字串", "凭证 JSON 格式不正确,请检查括号和引号": "憑證 JSON 格式不正確,請檢查括號和引號", "凭证 JSON(必填)": "憑證 JSON(必填)", "凭证只在提交时发送到网关;备注名和代理请使用下面的字段,解析错误不会回显凭证内容。": "憑證只在提交時傳送至閘道;備註名稱和代理請使用下方欄位,解析錯誤不會顯示憑證內容。", "分布来自保留的日报来源明细;无法恢复的历史不反推客户端或模型。": "分佈來自保留的日報來源明細;無法恢復的歷史不反推客戶端或模型。", "分组名": "分組名", "分组名,例如「常用」": "分組名,例如「常用」", "切换菜单": "切換選單", "列表 = 模型管理页里所有已启用的模型。助手走本地网关发起对话,消耗所选账号的额度。": "列表 = 模型管理頁裡所有已啟用的模型。助手走本地閘道器發起對話,消耗所選帳號的額度。", "创建并进入": "建立並進入", "创建管理员账号": "建立管理員帳號", "删除 {n} 条": "刪除 {n} 條", "删除分组": "刪除分組", "删除分组「{name}」?组内 {n} 个菜单会移到「{target}」,不会丢。": "刪除分組「{name}」?組內 {n} 個選單會移到「{target}」,不會丟。", "删除空分组「{name}」?": "刪除空分組「{name}」?", "删除这个分组(组内菜单移到第一组)": "刪除這個分組(組內選單移到第一組)", "刷新插件仓库": "重新整理外掛倉庫", "加入插件 beta 版": "加入插件 beta 版", "加载中": "載入中", "加载助手设置失败:{message}": "載入助手設定失敗:{message}", "加载失败:{error}": "載入失敗:{error}", "加载更早的记录": "載入更早的記錄", "助手": "助手", "助手自己用哪个模型生成回复": "助手自己用哪個模型生成回覆", "助手设置读取失败,工具可能已过时。": "助手設定讀取失敗,工具可能已過時。", "助手走本地网关,消耗所选账号的额度": "助手走本地閘道器,消耗所選帳號的額度", "勾选即注入该工具;不勾选 = 助手看不到它": "勾選即注入該工具;不勾選 = 助手看不到它", "十几 MB": "十幾 MB", "升级会重新下载并校验插件包(约 {size}),装完立即生效,账号数据不受影响。": "升級會重新下載並校驗外掛包(約 {size}),裝完立即生效,帳號資料不受影響。", "协议版本": "協定版本", "单签": "單籤", "占比": "佔比", "卸载": "卸載", "卸载中…": "解除安裝中…", "卸载插件包": "解除安裝外掛套件", "历史明细不完整,输入、输出与缓存读数无法恢复": "歷史明細不完整,輸入、輸出與快取讀數無法恢復", "历史未记录 Key": "歷史未記錄 Key", "去下载": "去下載", "去登录": "去登入", "参数不完整(需要 account / enabled)": "引數不完整(需要 account / enabled)", "参数不完整(需要 account / position)": "引數不完整(需要 account / position)", "参数不完整(需要 provider / id / alias)": "引數不完整(需要 provider / id / alias)", "参数不完整(需要 provider / id / capabilities)": "引數不完整(需要 provider / id / capabilities)", "参数不完整(需要 provider / id / enabled)": "引數不完整(需要 provider / id / enabled)", "参数不完整(需要 provider / position)": "引數不完整(需要 provider / position)", "发现新版本 {latest}(当前 {current}),点开「设置 - 软件更新」可查看更新日志并下载": "發現新版本 {latest}(當前 {current}),點開「設定 - 軟體更新」可檢視更新日誌並下載", "发现新版本 {version}": "發現新版本 {version}", "发现未安装的官方插件时自动下载并安装,仅接受当前平台且通过官方签名校验的包;开启期间卸载的官方插件也会重新安装。": "發現未安裝的官方插件時自動下載並安裝,僅接受目前平台且通過官方簽章驗證的套件;開啟期間解除安裝的官方插件也會重新安裝。", "发送": "傳送", "取消日期筛选": "取消日期篩選", "只改映射名,不动上游模型 ID;映射立即生效(新对话即可用)。": "只改對映名,不動上游模型 ID;對映立即生效(新對話即可用)。", "只注入工具定义": "只注入工具定義", "只统计已结束的生产请求;失败请求仍计入请求数,Token 用量沿用现有成功请求口径。": "只統計已結束的生產請求;失敗請求仍計入請求數,Token 用量沿用現有成功請求口徑。", "只读": "只讀", "只读工具": "只讀工具", "可以点击「刷新」读取插件仓库,或从本地 zip 安装插件。": "可以點擊「重新整理」讀取插件倉庫,或從本機 zip 安裝插件。", "可安装插件": "可安裝外掛", "可更新到 v{version}": "可更新至 v{version}", "可用": "可用", "可选,留空使用账号昵称": "選填,留空使用帳號暱稱", "各家提供商的转发、账号、签到与余额实现。装好之后这些提供商才会出现在「添加提供商」里。": "各家提供商的轉發、帳號、簽到與餘額實現。裝好之後這些提供商才會出現在「新增提供商」裡。", "各家提供商的转发与账号实现都在插件包里,不随本软件发布。装好插件后,模型转发、添加账号、签到与余额查询才会生效。": "各家供應商的轉發與帳號實作都在外掛套件裡,不隨本軟體發布。裝好外掛後,模型轉發、新增帳號、簽到與餘額查詢才會生效。", "后台只读取状态,不会自动弹出验证码;验证结果一次性使用,短时间内过期。": "背景只讀取狀態,不會自動彈出驗證碼;驗證結果僅能使用一次,短時間內失效。", "含固定项「设置」,不可整组隐藏(可以单独隐藏组内其它菜单)": "含固定項「設定」,不可整組隱藏(可以單獨隱藏組內其它選單)", "启用后重新参与转发": "啟用後重新參與轉發", "启用插件 {name}": "啟用外掛 {name}", "四种组合的实际效果": "四種組合的實際效果", "回复由 {model} 生成 · 走本地网关": "回覆由 {model} 生成 · 走本地閘道器", "固定": "固定", "在 GitHub 上创建令牌(无需勾选任何权限)": "在 GitHub 上建立權杖(無需勾選任何權限)", "在全局队列里上移一位": "在全域佇列裡上移一位", "在全局队列里下移一位": "在全域佇列裡下移一位", "在网关下载并安装": "在閘道器下載並安裝", "填写账号登录所需信息并发起授权;等待、取消与失败原因由共享登录桥处理,设备码和操作指引会显示在上方。": "填寫帳號登入所需資訊並發起授權;等待、取消與失敗原因由共用登入橋接處理,裝置碼和操作指引會顯示在上方。", "备注名(可选)": "備註名(可選)", "复制失败,请手动选择复制": "複製失敗,請手動選擇複製", "复制订阅链接": "複製訂閱連結", "大小": "大小", "失败 · {status}": "失敗 · {status}", "失败退避": "失敗退避", "奖励 {bonus}": "獎勵 {bonus}", "套餐 {plan}": "套餐 {plan}", "套餐池人机验证": "套餐池人機驗證", "套餐池请求需要验证,请主动开始验证后重试请求": "套餐池請求需要驗證,請主動開始驗證後重試請求", "安装": "安裝", "安装 Agent2API 官方提供商": "安裝 Agent2API 官方提供商", "安装 {name}": "安裝 {name}", "安装、更新与启停均作用在这台网关上。插件平台由网关决定,与手机系统无关。": "安裝、更新與啟停均作用在這臺網關上。外掛平臺由閘道器決定,與手機系統無關。", "安装与更新插件时访问 GitHub 用。与「设置 → 更新 → 更新设置」里的同一项互通,填一次即可。不填也能用,只是匿名请求限额较低(60 次/小时)。": "安裝與更新外掛時存取 GitHub 用。與「設定 → 更新 → 更新設定」中的同一項互通,填一次即可。不填也能用,只是匿名請求上限較低(60 次/小時)。", "安装包已就绪,点「安装」即可完成更新": "安裝包已就緒,點「安裝」即可完成更新", "安装插件包": "安裝外掛套件", "安装时间": "安裝時間", "官方": "官方", "官方签名:包内容与发布者签的完全一致,未被改过": "官方簽章:包內容與發佈者簽的完全一致,未被改過", "定时": "定時", "定时任务": "定時任務", "定时检查在网关执行,关闭手机后仍然生效。": "定時檢查在閘道器執行,關閉手機後仍然生效。", "实际注入": "實際注入", "客户端分布": "客戶端分佈", "客户端统计": "客戶端統計", "宿主": "宿主", "宿主错误": "宿主錯誤", "对话模型": "對話模型", "对话模型已切换": "對話模型已切換", "将修改 {model} 的 {n} 项能力:": "將修改 {model} 的 {n} 項能力:", "将修改 {n} 个模型的启停状态:": "將修改 {n} 個模型的啟停狀態:", "将修改 {n} 个账号的启用状态(其中禁用 {k} 个):": "將修改 {n} 個帳號的啟用狀態(其中停用 {k} 個):", "将对 {model} 发起一次真实请求:": "將對 {model} 發起一次真實請求:", "将执行 {label}。": "將執行 {label}。", "将把「{provider}」整组移到第 {position} 顺位:": "將把「{provider}」整組移到第 {position} 順位:", "将把账号「{account}」移到第 {position} 顺位:": "將把帳號「{account}」移到第 {position} 順位:", "将改动 {n} 条映射({parts}):": "將改動 {n} 條對映({parts}):", "尚未检查更新": "尚未檢查更新", "尚未登录": "尚未登入", "已下载,待安装": "已下載,待安裝", "已修改 {n} 个模型": "已修改 {n} 個模型", "已修改 {n} 个账号": "已修改 {n} 個帳號", "已修改 {n} 项能力": "已修改 {n} 項能力", "已停止这次回答。": "已停止這次回答。", "已全部取消勾选": "已全部取消勾選", "已关闭自动检查": "已關閉自動檢查", "已删除分组「{name}」": "已刪除分組「{name}」", "已加载": "已載入", "已加载 {n} 家": "已載入 {n} 家", "已勾选 {n} / {total}": "已勾選 {n} / {total}", "已勾选「{label}」": "已勾選「{label}」", "已勾选工具": "已勾選工具", "已取消「{label}」": "已取消「{label}」", "已启动安装器": "已啟動安裝器", "已填写(粘贴新令牌可覆盖)": "已填寫(貼上新權杖可覆蓋)", "已复制{label}": "已複製{label}", "已复制:{text}": "已複製:{text}", "已安装插件": "已安裝外掛", "已完成 {percent}%": "已完成 {percent}%", "已开启自动检查": "已開啟自動檢查", "已恢复推荐勾选": "已恢復推薦勾選", "已恢复默认分组:概览 / 转发链路 / 诊断 / 系统": "已恢復預設分組:概覽 / 轉發鏈路 / 診斷 / 系統", "已改动 {n} 条映射": "已改動 {n} 條對映", "已新建分组「{name}」,点组头的 + 把菜单移进来": "已新建分組「{name}」,點組頭的 + 把選單移進來", "已是最新版本": "已是最新版本", "已注入 {n} / {total} 个工具 · 系统提示词:{state}": "已注入 {n} / {total} 個工具 · 系統提示詞:{state}", "已添加 {n} 台": "已新增 {n} 臺", "已添加的服务器": "已新增的伺服器", "已登录": "已登入", "已离线 · 显示的是缓存内容": "已離線 · 顯示的是快取內容", "已移到第 {n} 顺位": "已移到第 {n} 順位", "已签名": "已簽章", "已试过": "已試過", "并发上限 {n}": "併發上限 {n}", "并发已满,等一个在途回落再参与": "併發已滿,等一個在途回落再參與", "并发满": "併發滿", "开": "開", "开关和选项即时保存;输入项请点击对应的「保存」按钮。": "開關和選項即時儲存;輸入項請點擊對應的「儲存」按鈕。", "开启期间卸载的官方插件也会重新安装。": "開啟期間解除安裝的官方插件也會重新安裝。", "开始验证": "開始驗證", "当前": "當前", "当前一个工具都没勾选,助手只能纯聊天。去「设置 → AI 助手 → 工具」里勾上需要的工具。": "當前一個工具都沒勾選,助手只能純聊天。去「設定 → AI 助手 → 工具」裡勾上需要的工具。", "当前平台": "目前平台", "当前平台暂无包": "目前平台尚無套件", "当前模型请求免人机验证": "目前模型請求免人機驗證", "当前版本 {current},最低可用版本 {minimum}。": "目前版本 {current},最低可用版本 {minimum}。", "当前版本 {version}": "當前版本 {version}", "当前网关": "當前閘道器", "当前网关平台暂无插件包": "當前閘道器平臺暫無外掛包", "当前网关要求插件版本不低于 v{version},补齐前暂不加载。": "目前閘道要求插件版本不低於 v{version},補齊前暫不載入。", "当前:已关闭(助手不收到任何系统提示词,工具定义照发)": "當前:已關閉(助手不收到任何系統提示詞,工具定義照發)", "当前:已开启 · 使用内置默认提示词(还没自定义)": "當前:已開啟 · 使用內建預設提示詞(還沒自定義)", "当前:已开启 · 自定义内容 {n} 字": "當前:已開啟 · 自定義內容 {n} 字", "影响转发": "影響轉發", "待确认": "待確認", "总剩余 {total}": "總剩餘 {total}", "恢复上游原值": "恢復上游原值", "恢复推荐": "恢復推薦", "恢复默认侧边栏": "恢復預設側邊欄", "成功 / 失败": "成功 / 失敗", "成功领取": "成功領取", "我会在动手前把改动列给你确认。": "我會在動手前把改動列給你確認。", "所有菜单都已在这一组": "所有選單都已在這一組", "手动凭证 JSON": "手動憑證 JSON", "手动凭证 JSON(兼容入口)": "手動憑證 JSON(相容入口)", "手机端打开": "手機端開啟", "打开账号设置": "開啟帳號設定", "执行": "執行", "把菜单移入 {name}": "把選單移入 {name}", "把菜单移入「{name}」": "把選單移入「{name}」", "报表": "報表", "拖动分组 {name}": "拖動分組 {name}", "拖动左侧 ⠿ 调整顺序(菜单可以跨组拖);拨开关控制显隐;点分组名可重命名;组头的 + 把别的菜单移进来;眼睛按钮隐藏整组。改动即时生效并记住,左侧侧边栏就是结果。键盘也能排序:把手聚焦后按 Alt+↑ / ↓。": "拖動左側 ⠿ 調整順序(選單可以跨組拖);撥開關控制顯隱;點分組名可重新命名;組頭的 + 把別的選單移進來;眼睛按鈕隱藏整組。改動即時生效並記住,左側側邊欄就是結果。鍵盤也能排序:把手聚焦後按 Alt+↑ / ↓。", "拖动菜单 {name}": "拖動選單 {name}", "拖动调整分组顺序(Alt+↑ / ↓ 也可)": "拖動調整分組順序(Alt+↑ / ↓ 也可)", "拖动调整队列顺序": "拖動調整佇列順序", "拖动调整顺序,可跨组(Alt+↑ / ↓ 也可)": "拖動調整順序,可跨組(Alt+↑ / ↓ 也可)", "按 API Key 筛选": "按 API Key 篩選", "按 Token": "按 Token", "按天请求趋势": "按天請求趨勢", "按客户端筛选": "按客戶端篩選", "按模型展开队列": "按模型展開佇列", "按访问网关的 API Key 统计生产请求,不包含助手对话和模型测试。停用、删除 Key 不会删除历史用量;密钥值不会进入报表。历史没有记录身份的请求单列,不能追溯到某把 Key。": "按存取閘道器的 API Key 統計生產請求,不包含助手對話和模型測試。停用、刪除 Key 不會刪除歷史用量;金鑰值不會進入報表。歷史沒有記錄身份的請求單列,不能追溯到某把 Key。", "按请求 User-Agent 识别的客户端类型统计,不代表设备或用户数。“其它”表示有 User-Agent 但未匹配已知类型;“未记录客户端”表示旧数据或请求未带 User-Agent。": "按請求 User-Agent 識別的客戶端型別統計,不代表裝置或使用者數。“其它”表示有 User-Agent 但未匹配已知型別;“未記錄客戶端”表示舊資料或請求未帶 User-Agent。", "按请求数": "按請求數", "按请求的模型展开 —— 与转发选路同一份排序,下一个请求会走 ★ 那位": "按請求的模型展開 —— 與轉發選路同一份排序,下一個請求會走 ★ 那位", "按间隔检查插件版本,在对应卡片显示更新;关闭后仍可手动检查。自动更新或自动下载开启时也使用此间隔。": "按間隔檢查插件版本,在對應卡片顯示更新;關閉後仍可手動檢查。自動更新或自動下載開啟時也使用此間隔。", "按需安装插件,为 AI 路由网关扩展提供商能力。插件独立于主程序更新,下载完成后自动校验并安装。": "按需安裝插件,為 AI 路由閘道擴充供應商能力。插件獨立於主程式更新,下載完成後自動驗證並安裝。", "排序已保存,但列表刷新失败:{message}": "排序已儲存,但清單重新整理失敗:{message}", "排序未保存:{message}": "排序未儲存:{message}", "排序设置迁移失败:{message}": "排序設定移轉失敗:{message}", "排第 1 的接走所有请求,直到它不能答(限流 / 故障 / 额度尽)才轮到下一位 —— 就是「从上往下」的现状行为。": "排第 1 的接走所有請求,直到它不能答(限流 / 故障 / 額度盡)才輪到下一位 —— 就是「從上往下」的現狀行為。", "接口文档": "介面文件", "控制主侧边栏显示哪些菜单、按什么顺序、怎么分组。隐藏只影响导航显示,不会撤销页面访问权限;被隐藏的页面仍可通过地址直接打开。": "控制主側邊欄顯示哪些選單、按什麼順序、怎麼分組。隱藏隻影響導航顯示,不會撤銷頁面存取許可權;被隱藏的頁面仍可通過地址直接開啟。", "提供商启停": "提供商啟停", "提供商增强": "提供商增強", "提示词": "提示詞", "提示词开关": "提示詞開關", "插件": "外掛", "插件仓库": "外掛倉庫", "插件仓库还没有发布任何版本。可以点「刷新」重试,或用「从文件安装…」选中本地 zip。": "外掛倉庫還沒有釋出任何版本。可以點「重新整理」重試,或用「從檔案安裝…」選中本地 zip。", "插件包与主程序分开安装、分开升级。卸载插件后账号数据仍然保留,重新装回即可继续使用;仅该包提供的转发与添加账号需要插件,本体订阅不受影响。": "外掛套件與主程式分開安裝、分開升級。解除安裝後帳號資料仍保留,重新安裝即可繼續使用;僅該套件提供的轉發與新增帳號需要外掛,本體訂閱不受影響。", "插件包与主程序分开安装、分开升级。卸载插件后账号数据仍然保留,重新装回即可继续使用;但转发与添加账号需要插件在位。": "外掛套件與主程式分開安裝、分開升級。解除安裝外掛後帳號資料仍然保留,重新裝回即可繼續使用;但轉發與新增帳號需要外掛在位。", "插件包大小不能超过 {n} MiB": "外掛套件大小不能超過 {n} MiB", "插件包已卸载": "外掛套件已解除安裝", "插件包已安装": "外掛套件已安裝", "插件包已安装到 v{version}": "插件套件已安裝至 v{version}", "插件包已更新到 v{version}": "外掛包已更新到 v{version}", "插件包的可执行文件不在磁盘上(可能被手工删除或移动),请重新安装。": "外掛套件的執行檔不在磁碟上(可能被手動刪除或移動),請重新安裝。", "插件只声明了短信登录,但没有下发可用的动态表单;此界面不会猜测短信接口": "外掛只宣告了簡訊登入,卻未提供可用的動態表單;此介面不會猜測簡訊 API", "插件文件缺失,请在电脑端重新安装插件包": "外掛檔案缺失,請在電腦端重新安裝外掛包", "插件文件缺失,请重新安装插件包": "外掛檔案缺失,請重新安裝外掛包", "插件未实现 auth.methods(501),且没有可用的旧版登录声明;仅保留需要插件确认的手动凭证 JSON 入口": "外掛未實作 auth.methods(501),且沒有可用的舊版登入宣告;僅保留需要外掛確認的手動憑證 JSON 入口", "插件未实现 auth.methods(501);以下入口仅依据旧版登录声明显示": "外掛未實作 auth.methods(501);以下入口僅依據舊版登入宣告顯示", "插件没有声明可用的账号登录方式,请查看账号登录帮助或联系插件作者": "外掛未宣告可用的帳號登入方式,請查看帳號登入說明或聯絡外掛作者", "插件状态已变更,但账号列表同步失败。请回到账号页点击「刷新」重试。": "外掛狀態已變更,但帳號清單同步失敗。請回到帳號頁點擊「重新整理」重試。", "插件登录指引": "外掛登入指引", "插件登录方式包含重复的输入字段": "外掛的登入方式包含重複的輸入欄位", "插件登录选择字段包含无效或重复的选项": "外掛的登入選擇欄位包含無效或重複的選項", "插件登录选择字段缺少选项列表": "外掛的登入選擇欄位缺少選項清單", "插件目录": "外掛目錄", "插件设置": "外掛設定", "插件设置已保存": "插件設定已儲存", "插件返回了无效的登录字段,请更新插件或联系作者": "外掛回傳了無效的登入欄位,請更新外掛或聯絡作者", "插件返回了无效的登录方式,请更新插件或联系作者": "外掛回傳了無效的登入方式,請更新外掛或聯絡作者", "插件页面": "外掛頁面", "搜索…": "搜尋…", "改动立即生效;禁用后指向它的请求会落到下一个候选。": "改動立即生效;停用後指向它的請求會落到下一個候選。", "改动类工具": "改動類工具", "改成": "改成", "文件缺失": "檔案缺失", "文档": "文件", "新": "新", "新分组名": "新分組名", "新增 {n} 条": "新增 {n} 條", "新对话": "新對話", "新建分组": "新建分組", "无凭证": "無憑證", "无法解密": "無法解密", "无法读取登录方式": "無法讀取登入方式", "日志": "日誌", "旧版本保存的正文可能已截断,无法恢复缺失内容": "舊版本儲存的正文可能已截斷,無法恢復缺失內容", "旧版浏览器登录暂不接收备注名和登录代理,请添加后在账号设置中调整。": "舊版瀏覽器登入暫不接受備註名稱和登入代理,請新增後在帳號設定中調整。", "旧版登录方式": "舊版登入方式", "映射名": "對映名", "显示 {name}": "顯示 {name}", "显示分组 {name}": "顯示分組 {name}", "显示这一组": "顯示這一組", "智能": "智慧", "暂不可用": "暫不可用", "暂无可安装的插件": "暫無可安裝的插件", "暂时查不到插件仓库({reason})。可以点「刷新」重试,或用「从文件安装…」选中本地 zip。": "暫時查不到外掛倉庫({reason})。可以點「重新整理」重試,或用「從檔案安裝…」選中本地 zip。", "暂未发布": "尚未發布", "更多": "更多", "更新到 v{version}": "更新至 v{version}", "更新前无法继续调用模型;账号、配置和历史记录不会被删除。": "更新前無法繼續呼叫模型;帳號、設定和歷史記錄不會被刪除。", "最大化": "最大化", "最小化": "最小化", "最早 {time} 恢复": "最早 {time} 恢復", "最近调用": "最近呼叫", "有": "有", "有插件包的协议版本与当前网关不一致({versions}),请下载对应版本的插件包。": "有外掛套件的協定版本與目前閘道不一致({versions}),請下載對應版本的外掛套件。", "有新版本,重启后生效": "有新版本,重啟後生效", "有新版本:v{current} → v{latest}": "有新版本:v{current} → v{latest}", "有更新": "有更新", "服务器": "伺服器", "未加载": "未載入", "未同步": "未同步", "未就绪": "未就緒", "未登录": "未登入", "未知工具「{name}」:它在设置里可能刚被取消勾选,或这一版助手还不认识它。": "未知工具「{name}」:它在設定裡可能剛被取消勾選,或這一版助手還不認識它。", "未签名": "未簽章", "未签名包不会自动覆盖;点击「补齐插件」将安装官方签名包。": "未簽章套件不會自動覆寫;點擊「補齊插件」將安裝官方簽章套件。", "未签名:可以正常使用,但无法证明这个包出自官方;升级时同样只做格式校验": "未簽章:可以正常使用,但無法證明這個包出自官方;升級時同樣只做格式校驗", "未记录": "未記錄", "未记录客户端": "未記錄客戶端", "未运行": "未執行", "未选择服务器": "未選擇伺服器", "本周期消耗达到限制器上限,转发时跳过": "本週期消耗達到限制器上限,轉發時跳過", "本地网关监听状态": "本地閘道器監聽狀態", "来自环境变量": "來自環境變數", "来自环境变量 GITHUB_TOKEN": "來自環境變數 GITHUB_TOKEN", "松开刷新": "鬆開重新整理", "查余额": "查餘額", "查看全部": "檢視全部", "查看参数": "檢視引數", "查看发布说明": "查看發佈說明", "查看发布页面": "查看發布頁面", "查看提供商插件": "查看供應商外掛", "查看更新日志": "查看更新日誌", "查看结果": "檢視結果", "查询该账号的余额": "查詢該帳號的餘額", "标题总结设置": "標題總結設定", "桌面桥不可用(本页需要在 Agent2API 客户端里打开)": "桌面橋不可用(本頁需要在 Agent2API 客戶端裡開啟)", "检查更新失败": "檢查更新失敗", "检测到更新后自动下载、校验并安装已启用的官方签名插件。": "偵測到更新後自動下載、驗證並安裝已啟用的官方簽章插件。", "检测到更新后自动下载、校验并安装已启用的官方签名插件。关闭此项不影响最低版本补齐;未签名或第三方插件仍需手动更新。": "偵測到更新後自動下載、驗證並安裝已啟用的官方簽章插件。關閉此項不影響最低版本補齊;未簽章或第三方插件仍需手動更新。", "检测到更新后自动下载、校验并安装已启用的官方签名插件。未签名或第三方插件仍需手动更新。": "偵測到更新後自動下載、驗證並安裝已啟用的官方簽章插件。未簽章或第三方插件仍需手動更新。", "模型分布": "模型分佈", "模型管理": "模型管理", "次熔断": "次熔斷", "正在下载…": "正在下載…", "正在完成人机验证…": "正在完成人機驗證…", "正在应用…": "正在應用…", "正在校验包内容…": "正在驗證套件內容…", "正在检查…": "正在檢查…", "正在自动补齐官方插件,不受日常更新开关和通道限制。": "正在自動補齊官方插件,不受日常更新開關和通道限制。", "正在补齐插件…": "正在補齊插件…", "正在识别二维码…": "正在識別二維碼…", "正在读取、校验并安装插件包…": "正在讀取、驗證並安裝插件套件…", "正在读取插件列表…": "正在讀取插件清單…", "正在读取插件登录方式…": "正在讀取外掛登入方式…", "正在读取文件…": "正在讀取檔案…", "正在连接…": "正在連線…", "正在验证…": "正在驗證…", "此 OAuth 方法未声明备注名字段,账号名由插件获取;添加后可在账号设置中修改。": "此 OAuth 方式未宣告備註名稱欄位,帳號名稱由外掛取得;新增後可在帳號設定中修改。", "此方式可能需要手动提交授权回调。完成官方登录后,按共享登录桥的提示粘贴完整回调地址;不要把回调地址当作 API Key 或 Token。": "此方式可能需要手動提交授權回呼。完成官方登入後,依共用登入橋接的提示貼上完整回呼網址;不要將回呼網址當作 API Key 或 Token。", "此旧版登录声明无法安全映射到动态表单,请联系插件作者": "此舊版登入宣告無法安全對應到動態表單,請聯絡外掛作者", "此登录方式需要由共享登录桥发起": "此登入方式需要由共用登入橋接發起", "每台服务器的登录状态各自独立保存,切换后不用重新登录。地址改掉后需要重新登录。": "每臺伺服器的登入狀態各自獨立儲存,切換後不用重新登入。地址改掉後需要重新登入。", "每条请求轮换到下一个可用账号;新会话交给最近最闲的那位。适合想把手里的号雨露均沾。": "每條請求輪換到下一個可用帳號;新會話交給最近最閒的那位。適合想把手裡的號雨露均霑。", "每轮": "每輪", "没有可恢复的维度明细": "沒有可恢復的維度明細", "没有可更新的版本": "沒有可更新的版本", "没有已启用的模型": "沒有已啟用的模型", "没有找到提供商「{provider}」的账号": "沒有找到提供商「{provider}」的帳號", "没有找到账号「{name}」": "沒有找到帳號「{name}」", "没有说明": "沒有說明", "没有近期套餐池请求,不生成验证码令牌": "沒有近期套餐池請求,不產生驗證碼權杖", "没给账号名": "沒給帳號名", "注入系统提示词": "注入系統提示詞", "活动": "活動", "浅色": "淺色", "消耗该账号额度": "消耗該帳號額度", "消耗额度": "消耗額度", "深色": "深色", "添加": "新增", "添加失败": "新增失敗", "添加服务器": "新增伺服器", "清空 = 回到内置默认(与「恢复默认」等价)。": "清空 = 回到內建預設(與「恢復預設」等價)。", "清除失败:{error}": "清除失敗:{error}", "点「编辑」弹窗改内容;开关关掉就整段不发。": "點「編輯」彈窗改內容;開關關掉就整段不發。", "点击重命名": "點擊重新命名", "熔断": "熔斷", "熔断时长(秒)": "熔斷時長(秒)", "版本 {version} · 从 GitHub 直接下载安装包": "版本 {version} · 從 GitHub 直接下載安裝包", "版本 {version} · 从网关下载安装包": "版本 {version} · 從閘道器下載安裝包", "版本 {version} · 更新包需从 Release 页面获取": "版本 {version} · 更新包需從 Release 頁面獲取", "环境变量 Key": "環境變數 Key", "用一句话让我查或改本机的模型转发配置。": "用一句話讓我查或改本機的模型轉發配置。", "用量占比最低的先用;没有读数的账号按队列位次排在有读数的后面。适合「谁空谁上」。": "用量佔比最低的先用;沒有讀數的帳號按佇列位次排在有讀數的後面。適合「誰空誰上」。", "用量详情": "用量詳情", "电脑端已关闭「软件版本检查」,此处只做手动检查": "電腦端已關閉「軟體版本檢查」,此處只做手動檢查", "登录指引 / 设备码授权": "登入指引 / 裝置碼授權", "登录方式说明": "登入方式說明", "登录桥未确认账号添加完成": "登入橋接未確認帳號新增完成", "登录面板": "登入面板", "监听 127.0.0.1": "監聽 127.0.0.1", "直接说要改什么 / 查什么…(Enter 发送,Shift+Enter 换行)": "直接說要改什麼 / 查什麼…(Enter 傳送,Shift+Enter 換行)", "确定删除账号「{name}」?{note}": "確定刪除帳號「{name}」?{note}", "确定卸载「{name}」吗?卸载后这个包里的提供商将无法转发,也无法添加账号。账号数据本身不会被删除,重新安装后可以继续使用。": "確定解除安裝「{name}」嗎?解除安裝後這個套件裡的供應商將無法轉發,也無法新增帳號。帳號資料本身不會被刪除,重新安裝後可以繼續使用。", "确定卸载「{name}」吗?对应提供商将停止转发,账号数据仍然保留,重新安装后恢复。": "確定解除安裝「{name}」嗎?對應提供商將停止轉發,帳號資料仍然保留,重新安裝後恢復。", "确认后立即生效": "確認後立即生效", "禁用会把账号移出转发队列;若这条线路没有别的可用账号,请求会直接失败。": "停用會把帳號移出轉發佇列;若這條線路沒有別的可用帳號,請求會直接失敗。", "禁用后不参与转发,余额仍可查": "停用後不參與轉發,餘額仍可查", "移入「{name}」": "移入「{name}」", "稍后": "稍後", "空分组 · 点组头的 + 把菜单移进来": "空分組 · 點組頭的 + 把選單移進來", "立即升级": "立即升級", "第 {current} / {total} 页": "第 {current} / {total} 頁", "等待窗口": "等待視窗", "等待账号登录完成…": "等待帳號登入完成…", "等这一轮跑完…": "等這一輪跑完…", "签到中心": "簽到中心", "管理所连接网关的插件,不在手机上安装提供商插件": "管理所連線閘道器的外掛,不在手機上安裝提供商外掛", "粘贴 GitHub 令牌(ghp_… / github_pat_…)": "貼上 GitHub 權杖(ghp_… / github_pat_…)", "粘贴插件要求的 JSON 对象,不要包含 provider、name、proxy 或登录流程控制字段": "貼上外掛要求的 JSON 物件,不要包含 provider、name、proxy 或登入流程控制欄位", "系统提示词 + 工具定义": "系統提示詞 + 工具定義", "系统提示词已保存": "系統提示詞已儲存", "系统提示词已关闭": "系統提示詞已關閉", "系统提示词已开启": "系統提示詞已開啟", "统计排序": "統計排序", "缓存读取": "快取讀取", "编辑服务器": "編輯伺服器", "编辑系统提示词": "編輯系統提示詞", "网关 Key": "閘道器 Key", "网关插件": "閘道器外掛", "网关正在下载…": "閘道器正在下載…", "网关正在安装…": "閘道器正在安裝…", "网关正在校验…": "閘道器正在校驗…", "网关没有返回有效的登录方式列表,无法确认该插件的登录能力": "閘道沒有回傳有效的登入方式清單,無法確認此外掛的登入能力", "网关运行中": "閘道器執行中", "网络不可达": "網路不可達", "网络代理": "網路代理", "网页提供商": "網頁提供商", "网页登录(旧版声明)": "網頁登入(舊版宣告)", "能力位决定下游看到的声明(能不能贴图、能塞多少上下文),不改上游的真实行为。": "能力位決定下游看到的宣告(能不能貼圖、能塞多少上下文),不改上游的真實行為。", "自动": "自動", "自动下载官方插件": "自動下載官方插件", "自动匹配平台": "自動匹配平臺", "自动安装": "自動安裝", "自动更新插件": "自動更新插件", "自动检查插件更新": "自動檢查插件更新", "至少要保留一个分组": "至少要保留一個分組", "补签": "補籤", "补齐插件": "補齊插件", "订阅里的节点会自动同步进下方代理池,账号即可引用。": "訂閱裡的節點會自動同步進下方代理池,帳號即可引用。", "订阅里的节点会被内核起成本地监听器,镜像到下方代理池(账号按 id 引用,与本页其它出口同一用法)。": "訂閱裡的節點會被核心起成本地監聽器,映象到下方代理池(帳號按 id 引用,與本頁其它出口同一用法)。", "订阅链接必须是 http:// 或 https:// 开头": "訂閱連結必須是 http:// 或 https:// 開頭", "设备授权码:{code}": "裝置授權碼:{code}", "设备码授权时,请按网关给出的指引在官方页面确认设备授权码。没有授权地址不等于失败,可能需要在网关本机客户端完成操作;请以共享登录桥返回的状态为准。": "裝置碼授權時,請依閘道提供的指引在官方頁面確認裝置授權碼。沒有授權網址不等於失敗,可能需要在閘道本機用戶端完成操作;請以共用登入橋接回傳的狀態為準。", "设置": "設定", "设置不可隐藏(隐藏了只能清缓存找回来)": "設定不可隱藏(隱藏了只能清快取找回來)", "设置已生效,但写入磁盘失败(重启后会恢复原设置)": "設定已生效,但寫入磁碟失敗(重新啟動後會恢復原設定)", "诊断": "診斷", "诊断信息": "診斷資訊", "该提供商已不在运行时目录中,请返回列表重新选择": "此供應商已不在執行時清單中,請返回清單重新選擇", "该登录方式没有可选项,无法提交;请更新插件或联系作者": "此登入方式沒有可選項,無法提交;請更新外掛或聯絡作者", "请允许安装未知来源应用后重试": "請允許安裝未知來源應用後重試", "请先粘贴 GitHub 令牌": "請先貼上 GitHub 權杖", "请先选择有效的 OAuth 登录方式": "請先選擇有效的 OAuth 登入方式", "请在 Release 页面下载后通过 TestFlight 或 App Store 安装": "請在 Release 頁面下載後通過 TestFlight 或 App Store 安裝", "请填一个分组名": "請填一個分組名", "请填写订阅名称": "請填寫訂閱名稱", "请填写非空的凭证 JSON 对象,且不超过 256 KiB": "請填寫非空的憑證 JSON 物件,且不超過 256 KiB", "请求失败": "請求失敗", "请求失败:{message}": "請求失敗:{message}", "请求数": "請求數", "请求日志": "請求日誌", "请确认": "請確認", "请稍候": "請稍候", "请选择 {label} 的有效选项": "請選擇 {label} 的有效選項", "读取插件仓库失败": "讀取外掛倉庫失敗", "读取插件状态失败:{error}": "讀取外掛狀態失敗:{error}", "读取文件失败": "讀取檔案失敗", "读取消耗排序失败:{message}": "讀取消耗排序失敗:{message}", "读取设置失败:{error}": "讀取設定失敗:{error}", "账号 / 登录出网代理": "帳號 / 登入對外連線代理", "账号不在当前队列里": "帳號不在當前佇列裡", "账号列表响应异常": "帳號清單回應異常", "账号已删除": "帳號已刪除", "账号已在全局队列第一位": "帳號已在全域佇列第一位", "账号排序接口不可用,请确认网关与界面已更新": "帳號排序 API 無法使用,請確認閘道器與介面已更新", "账号登录帮助(account login)": "帳號登入說明(account login)", "账号登录方式": "帳號登入方式", "趋势统计指标": "趨勢統計指標", "趋势统计维度": "趨勢統計維度", "跟随系统": "跟隨系統", "路由策略": "路由策略", "转发失败的账号休息一会儿再回来(连续失败翻倍,上限 1 小时)": "轉發失敗的帳號休息一會兒再回來(連續失敗翻倍,上限 1 小時)", "转发能力": "轉發能力", "轮流均摊": "輪流均攤", "软件版本检查设置不可用": "軟體版本檢查設定不可用", "输入 / 输出": "輸入 / 輸出", "输入这台网关的管理员账号与密码。": "輸入這臺網關的管理員帳號與密碼。", "运行日志": "執行日誌", "运行正常 · {url}": "執行正常 · {url}", "运行状态": "執行狀態", "返回": "返回", "还有额度时被 429 的账号排到队尾,轮一圈才回来 —— 负载摊开而不是每次回到第 1 个": "還有額度時被 429 的帳號排到隊尾,輪一圈才回來 —— 負載攤開而不是每次回到第 1 個", "还没有安装任何提供商插件包": "尚未安裝任何供應商外掛套件", "还没有签到记录": "還沒有簽到記錄", "还没有订阅:粘贴订阅链接,或从图片识别二维码导入。": "還沒有訂閱:貼上訂閱連結,或從圖片識別二維碼匯入。", "还没有选择对话模型:先在下方选一个(或去「设置 → AI 助手」里选)。": "還沒有選擇對話模型:先在下方選一個(或去「設定 → AI 助手」裡選)。", "这一版没有提供 Android 安装包": "這一版沒有提供 Android 安裝包", "这一项已隐藏": "這一項已隱藏", "这一项正在显示": "這一項正在顯示", "这个包提供的提供商(可单独停用某一家)": "這個套件提供的供應商(可單獨停用某一家)", "这个模型下没有可用账号": "這個模型下沒有可用帳號", "这个面板没有管理员,用一把已启用的 API Key 访问(在桌面端「网关 Key」页创建)。": "這個面板沒有管理員,用一把已啟用的 API Key 存取(在桌面版「閘道器 Key」頁建立)。", "这会真实发起上游请求并消耗额度": "這會真實發起上游請求並消耗額度", "这台网关没有管理员,用一把已启用的 API Key 访问(在桌面端「网关 Key」页创建)。": "這臺網關沒有管理員,用一把已啟用的 API Key 存取(在桌面版「閘道器 Key」頁建立)。", "这台网关还没有安装插件": "這臺網關還沒有安裝外掛", "这台网关还没有管理员。设置一个账号密码,之后用它登录。": "這臺網關還沒有管理員。設定一個帳號密碼,之後用它登入。", "这是旧插件的手动兼容入口,不代表支持任意凭证或登录方式。请仅粘贴该插件明确接受的凭证 JSON;网关会交给 account.normalize 校验,不会自动推断 Token、Cookie 或 OAuth。": "這是舊外掛的手動相容入口,不代表支援任意憑證或登入方式。請僅貼上此外掛明確接受的憑證 JSON;閘道會交給 account.normalize 驗證,不會自動推斷 Token、Cookie 或 OAuth。", "这是真实的上游请求,与生产走同一条链路(会记账,报表排除)。": "這是真實的上游請求,與生產走同一條鏈路(會記賬,報表排除)。", "这段文本作为 system 消息排在对话最前面。工具的定义与当前配置概览由网关自动附加,不用写在这里。": "這段文本作為 system 訊息排在對話最前面。工具的定義與當前配置概覽由閘道器自動附加,不用寫在這裡。", "连不上插件仓库,请检查网络或代理后重试": "連不上外掛倉庫,請檢查網路或代理後重試", "连接 {n}": "連線 {n}", "连接并保存": "連線並儲存", "连续失败到阈值后熔断一段时间;到点放行试一次,连续成功才算恢复": "連續失敗到閾值後熔斷一段時間;到點放行試一次,連續成功才算恢復", "连续失败阈值": "連續失敗閾值", "连续崩溃": "連續當機", "连通 · {ms}ms": "連通 · {ms}ms", "选择对话模型…": "選擇對話模型…", "选择模型…": "選擇模型…", "选择要安装的平台。装好之后这些提供商才会出现在「添加提供商」里。": "選擇要安裝的平臺。裝好之後這些提供商才會出現在「新增提供商」裡。", "都不注入": "都不注入", "都不注入(助手退化为纯聊天)": "都不注入(助手退化為純聊天)", "重启更新": "重啟更新", "重新读取登录方式": "重新讀取登入方式", "队列是一次性整表提交(后端按新顺序重编优先级),移动会连带调整其它组的相对次序。": "佇列是一次性整表提交(後端按新順序重編優先順序),移動會連帶調整其它組的相對次序。", "队列是一次性整表提交;位置越靠前,路由时越先被选中。": "佇列是一次性整表提交;位置越靠前,路由時越先被選中。", "限流 · {n} 个模型": "限流 · {n} 個模型", "限流垫底": "限流墊底", "隐藏 {name}": "隱藏 {name}", "隐藏分组 {name}": "隱藏分組 {name}", "隐藏这一组": "隱藏這一組", "需要强制更新": "需要強制更新", "需要网关 API Key": "需要閘道器 API Key", "需要网关本机环境": "需要閘道本機環境", "需要补齐插件": "需要補齊插件", "顺序优先": "順序優先", "首页": "首頁", "高危": "高危", "默认跟随软件的正式版和 beta 关注选择;单独设置只影响日常更新,最低版本补齐按当前软件版本选择配套包。": "預設跟隨軟體的正式版和 beta 關注選擇;單獨設定只影響日常更新,最低版本補齊按目前軟體版本選擇配套套件。", "默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。": "預設跟隨軟體的自動檢查和間隔。關閉後暫停日常自動更新和下載,但仍會補齊已安裝官方插件的最低版本。", "({n} 个整组隐藏)": "({n} 個整組隱藏)", "(不会影响客户端登录态)": "(不會影響客戶端登入態)", "(仅显示前 20 条,共 {n} 条)": "(僅顯示前 20 條,共 {n} 條)", "(可选)": "(選填)", "(未指定)": "(未指定)", "(请下载与该平台对应的插件包)": "(請下載與該平台對應的外掛套件)", "(默认问候)": "(預設問候)" });
+window.wbI18nDict = window.wbI18nDict || {}; Object.assign(window.wbI18nDict, { "无可用账号:{reason}": "無可用帳號:{reason}", "AI 助手": "AI 助手", "API Key 用量详情": "API Key 用量詳情", "API Key 统计": "API Key 統計", "API Key(可选)": "API Key(選填)", "API 凭证": "API 憑證", "API 方法提交给插件的账号规范化入口;不会用该密钥发起 OAuth 登录。": "API 方式會提交至外掛的帳號正規化入口;不會用此金鑰發起 OAuth 登入。", "Agent": "Agent", "Agent 接管": "Agent 接管", "Agent2API · 多提供商本地网关": "Agent2API · 多提供商本地閘道器", "Agent2API 官方提供商": "Agent2API 官方提供商", "Linux (amd64)": "Linux (amd64)", "Linux (arm64)": "Linux (arm64)", "OAuth 登录": "OAuth 登入", "QQ 群号": "QQ 群號", "Token 用量": "Token 用量", "Windows (ARM64)": "Windows (ARM64)", "Windows (x64)": "Windows (x64)", "macOS (Apple Silicon)": "macOS (Apple Silicon)", "macOS (Intel)": "macOS (Intel)", "{count} 家": "{count} 家", "{count} 家提供商 · 安装于 {time}": "{count} 家供應商 · 安裝於 {time}", "{key} 需要 true / false / null": "{key} 需要 true / false / null", "{key} 需要数字": "{key} 需要數字", "{label}(API)": "{label}(API)", "{label}(OAuth)": "{label}(OAuth)", "{n} 个启用": "{n} 個啟用", "{n} 个已限流": "{n} 個已限流", "{n} 个请求正在转发中,点开「请求日志」查看": "{n} 個請求正在轉發中,點開「請求日誌」檢視", "{n} 个账号 · {usable} 可用": "{n} 個帳號 · {usable} 可用", "{n} 个账号可用": "{n} 個帳號可用", "{n} 个账号启用": "{n} 個帳號啟用", "{n} 条失败请求未读,点开「请求日志」查看": "{n} 條失敗請求未讀,點開「請求日誌」檢視", "{n} 条错误日志未读,点开「日志」查看": "{n} 條錯誤日誌未讀,點開「日誌」檢視", "{n} 项 · {shown} 显示": "{n} 項 · {shown} 顯示", "{size} · 下载后可直接安装,无需跳转浏览器": "{size} · 下載後可直接安裝,無需跳轉瀏覽器", "{size} · 点击下载后可直接安装,无需跳转浏览器": "{size} · 點擊下載後可直接安裝,無需跳轉瀏覽器", "{total} 个菜单 · 显示 {shown} · 隐藏 {hidden} · {groups} 个分组": "{total} 個選單 · 顯示 {shown} · 隱藏 {hidden} · {groups} 個分組", "· 不会改动任何配置": "· 不會改動任何配置", "· 每次执行前列改动清单,等你确认": "· 每次執行前列改動清單,等你確認", "—": "—", "“本机”指运行网关的机器,不是打开面板的电脑。远程浏览器也可以发起,但网关本机可能需要安装客户端并已登录;是否可用由网关返回结果决定。": "「本機」指執行閘道的機器,不是開啟面板的電腦。遠端瀏覽器也可以發起,但閘道本機可能需要安裝用戶端並已登入;是否可用由閘道回傳結果決定。", "★ 下一单走它": "★ 下一單走它", "✅ GitHub 令牌已保存(加密存储,界面不再显示)": "✅ GitHub 權杖已儲存(加密儲存,介面不再顯示)", "✅ Token 已刷新": "✅ Token 已重新整理", "✅ 已将账号优先级调整到全局第一位": "✅ 已將帳號優先順序調整到全域第一位", "✅ 已清除界面保存的 GitHub 令牌(环境变量若配置过则继续生效)": "✅ 已清除介面儲存的 GitHub 權杖(環境變數若有設定則繼續生效)", "「{name}」匹配到多个账号:{list},请用完整账号名重试": "「{name}」匹配到多個帳號:{list},請用完整帳號名重試", "「工具全不勾选 → 不注入系统提示词」:想当纯聊天用时,不必再去关上面的开关。": "「工具全不勾選 → 不注入系統提示詞」:想當純聊天用時,不必再去關上面的開關。", "「设置」是固定项,含它的分组不能整组隐藏;可以单独隐藏组内其它菜单": "「設定」是固定項,含它的分組不能整組隱藏;可以單獨隱藏組內其它選單", "上一页": "上一頁", "下一页": "下一頁", "下拉刷新": "下拉重新整理", "下次自动重试:{time}": "下次自動重試:{time}", "下载与当前平台对应的插件包(zip),点右上角「安装插件包」选中它即可。": "下載與目前平台對應的外掛套件(zip),點右上角「安裝外掛套件」選取它即可。", "下载任务已交给网关,关闭手机不影响安装": "下載任務已交給閘道器,關閉手機不影響安裝", "下载进度": "下載進度", "不填写(可选)": "不填寫(選填)", "不限模型": "不限模型", "与电脑端一致:每 {n} 分钟": "與電腦端一致:每 {n} 分鐘", "为 Agent2API 扩展网页提供商,支持智谱清言的模型调用、访客与登录账号、凭证续期、模型目录、积分查询、签到和任务领取。": "為 Agent2API 擴充網頁提供商,支援智譜清言的模型呼叫、訪客與登入帳號、憑證續期、模型清單、積分查詢、簽到和任務領取。", "为网关扩展多家 AI 提供商,支持账号登录与导入、模型调用、凭证续期、模型目录、余额查询和签到。具体能力以各提供商的支持情况为准。": "為閘道擴充多家 AI 供應商,支援帳號登入與匯入、模型呼叫、憑證續期、模型清單、餘額查詢和簽到。具體能力以各供應商的支援情況為準。", "主导航": "主導航", "仅在该 API 方法需要额外密钥时填写": "僅在此 API 方式需要額外金鑰時填寫", "仅影响插件更新通道,与主程序独立。": "僅影響外掛更新通道,與主程式獨立。", "仅影响插件更新通道,与主程序独立。开启后可安装 beta 版;已使用 beta 时保持该通道,关闭后只看正式版且不会降级。": "僅影響插件更新通道,與主程式獨立。開啟後可安裝 beta 版;已使用 beta 時保持該通道,關閉後只看正式版且不會降級。", "从文件安装…": "從檔案安裝…", "从网关本机客户端导入": "從閘道本機用戶端匯入", "代价": "代價", "代理:池": "代理:池", "令牌已生效,但写入磁盘失败(重启后会丢失)": "權杖已生效,但寫入磁碟失敗(重新啟動後會遺失)", "以下设置属于所连接网关,不是手机本地设置。": "以下設定屬於所連接閘道,不是手機本機設定。", "会恢复默认的分组、顺序与显隐设置。你自建的分组会被删除(组内菜单不会丢)。": "會恢復預設的分組、順序與顯隱設定。你自建的分組會被刪除(組內選單不會丟)。", "会话内": "會話內", "会话已过期。重新登录后会自动回到手机端。": "會話已過期。重新登入後會自動回到手機端。", "会话粘性": "會話粘性", "低于限制器的阈值,转发时跳过该账号": "低於限制器的閾值,轉發時跳過該帳號", "余额不足或 Token 周期用量到顶,被限制器拦下,自动恢复后回来": "餘額不足或 Token 週期用量到頂,被限制器攔下,自動恢復後回來", "余额优先": "餘額優先", "作为 system 消息注入给助手": "作為 system 訊息注入給助手", "作者尚未提供插件介绍。": "作者尚未提供插件介紹。", "作者:{author}": "作者:{author}", "例如:家里、公司": "例如:家裡、公司", "侧边栏布局模块未加载(ui/sidebar-layout.js 应在 app.js 之前引入)。": "側邊欄佈局模組未載入(ui/sidebar-layout.js 應在 app.js 之前引入)。", "侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。": "側邊欄沒有顯示任何選單。到「設定 → 顯示 → 側邊欄選單」裡開啟需要的項。", "侧边栏菜单": "側邊欄選單", "保存失败:{error}": "儲存失敗:{error}", "保存对话模型失败:{message}": "儲存對話模型失敗:{message}", "保存并继续": "儲存並繼續", "候选队列": "候選佇列", "停止": "停止", "停用": "停用", "先添加一台网关": "先新增一臺閘道器", "先选择插件声明的账号登录方式,再填写必需字段。OAuth 由共享登录桥负责等待、取消和错误;API 凭证通过账号规范化入口添加。": "先選擇外掛宣告的帳號登入方式,再填寫必填欄位。OAuth 由共用登入橋接負責等待、取消和錯誤;API 憑證透過帳號正規化入口新增。", "免鉴权调用": "免鑑權呼叫", "全不选": "全不選", "全局队列位次(转发按策略在此序上再排)": "全域佇列位次(轉發按策略在此序上再排)", "全部 API Key": "全部 API Key", "全部客户端": "全部客戶端", "共 {n} 条记录": "共 {n} 條記錄", "共享登录桥不可用,请重新打开面板": "共用登入橋接無法使用,請重新開啟面板", "关": "關", "关闭菜单": "關閉選單", "冷却": "冷卻", "凭证 JSON 含有不允许的字段:{key}": "憑證 JSON 含有不允許的欄位:{key}", "凭证 JSON 嵌套过深,请只粘贴该插件要求的凭证对象": "憑證 JSON 巢狀層級過深,請只貼上此外掛要求的憑證物件", "凭证 JSON 必须是非空对象,不能是数组或字符串": "憑證 JSON 必須是非空物件,不能是陣列或字串", "凭证 JSON 格式不正确,请检查括号和引号": "憑證 JSON 格式不正確,請檢查括號和引號", "凭证 JSON(必填)": "憑證 JSON(必填)", "凭证只在提交时发送到网关;备注名和代理请使用下面的字段,解析错误不会回显凭证内容。": "憑證只在提交時傳送至閘道;備註名稱和代理請使用下方欄位,解析錯誤不會顯示憑證內容。", "分布来自保留的日报来源明细;无法恢复的历史不反推客户端或模型。": "分佈來自保留的日報來源明細;無法恢復的歷史不反推客戶端或模型。", "分组名": "分組名", "分组名,例如「常用」": "分組名,例如「常用」", "切换菜单": "切換選單", "列表 = 模型管理页里所有已启用的模型。助手走本地网关发起对话,消耗所选账号的额度。": "列表 = 模型管理頁裡所有已啟用的模型。助手走本地閘道器發起對話,消耗所選帳號的額度。", "创建并进入": "建立並進入", "创建管理员账号": "建立管理員帳號", "删除 {n} 条": "刪除 {n} 條", "删除分组": "刪除分組", "删除分组「{name}」?组内 {n} 个菜单会移到「{target}」,不会丢。": "刪除分組「{name}」?組內 {n} 個選單會移到「{target}」,不會丟。", "删除空分组「{name}」?": "刪除空分組「{name}」?", "删除这个分组(组内菜单移到第一组)": "刪除這個分組(組內選單移到第一組)", "刷新插件仓库": "重新整理外掛倉庫", "加入插件 beta 版": "加入插件 beta 版", "加载中": "載入中", "加载助手设置失败:{message}": "載入助手設定失敗:{message}", "加载失败:{error}": "載入失敗:{error}", "加载更早的记录": "載入更早的記錄", "助手": "助手", "助手自己用哪个模型生成回复": "助手自己用哪個模型生成回覆", "助手设置读取失败,工具可能已过时。": "助手設定讀取失敗,工具可能已過時。", "助手走本地网关,消耗所选账号的额度": "助手走本地閘道器,消耗所選帳號的額度", "勾选即注入该工具;不勾选 = 助手看不到它": "勾選即注入該工具;不勾選 = 助手看不到它", "十几 MB": "十幾 MB", "升级会重新下载并校验插件包(约 {size}),装完立即生效,账号数据不受影响。": "升級會重新下載並校驗外掛包(約 {size}),裝完立即生效,帳號資料不受影響。", "协议版本": "協定版本", "单签": "單籤", "占比": "佔比", "卸载": "卸載", "卸载中…": "解除安裝中…", "卸载插件包": "解除安裝外掛套件", "历史明细不完整,输入、输出与缓存读数无法恢复": "歷史明細不完整,輸入、輸出與快取讀數無法恢復", "历史未记录 Key": "歷史未記錄 Key", "去下载": "去下載", "去登录": "去登入", "参数不完整(需要 account / enabled)": "引數不完整(需要 account / enabled)", "参数不完整(需要 account / position)": "引數不完整(需要 account / position)", "参数不完整(需要 provider / id / alias)": "引數不完整(需要 provider / id / alias)", "参数不完整(需要 provider / id / capabilities)": "引數不完整(需要 provider / id / capabilities)", "参数不完整(需要 provider / id / enabled)": "引數不完整(需要 provider / id / enabled)", "参数不完整(需要 provider / position)": "引數不完整(需要 provider / position)", "发现新版本 {latest}(当前 {current}),点开「设置 - 软件更新」可查看更新日志并下载": "發現新版本 {latest}(當前 {current}),點開「設定 - 軟體更新」可檢視更新日誌並下載", "发现新版本 {version}": "發現新版本 {version}", "发现未安装的官方插件时自动下载并安装,仅接受当前平台且通过官方签名校验的包;开启期间卸载的官方插件也会重新安装。": "發現未安裝的官方插件時自動下載並安裝,僅接受目前平台且通過官方簽章驗證的套件;開啟期間解除安裝的官方插件也會重新安裝。", "发送": "傳送", "取消日期筛选": "取消日期篩選", "只改映射名,不动上游模型 ID;映射立即生效(新对话即可用)。": "只改對映名,不動上游模型 ID;對映立即生效(新對話即可用)。", "只注入工具定义": "只注入工具定義", "只统计已结束的生产请求;失败请求仍计入请求数,Token 用量沿用现有成功请求口径。": "只統計已結束的生產請求;失敗請求仍計入請求數,Token 用量沿用現有成功請求口徑。", "只读": "只讀", "只读工具": "只讀工具", "可以点击「刷新」读取插件仓库,或从本地 zip 安装插件。": "可以點擊「重新整理」讀取插件倉庫,或從本機 zip 安裝插件。", "可安装插件": "可安裝外掛", "可更新到 v{version}": "可更新至 v{version}", "可用": "可用", "可选,留空使用账号昵称": "選填,留空使用帳號暱稱", "各家提供商的转发、账号、签到与余额实现。装好之后这些提供商才会出现在「添加提供商」里。": "各家提供商的轉發、帳號、簽到與餘額實現。裝好之後這些提供商才會出現在「新增提供商」裡。", "各家提供商的转发与账号实现都在插件包里,不随本软件发布。装好插件后,模型转发、添加账号、签到与余额查询才会生效。": "各家供應商的轉發與帳號實作都在外掛套件裡,不隨本軟體發布。裝好外掛後,模型轉發、新增帳號、簽到與餘額查詢才會生效。", "后台只读取状态,不会自动弹出验证码;验证结果一次性使用,短时间内过期。": "背景只讀取狀態,不會自動彈出驗證碼;驗證結果僅能使用一次,短時間內失效。", "含固定项「设置」,不可整组隐藏(可以单独隐藏组内其它菜单)": "含固定項「設定」,不可整組隱藏(可以單獨隱藏組內其它選單)", "启用后重新参与转发": "啟用後重新參與轉發", "启用插件 {name}": "啟用外掛 {name}", "四种组合的实际效果": "四種組合的實際效果", "回复由 {model} 生成 · 走本地网关": "回覆由 {model} 生成 · 走本地閘道器", "固定": "固定", "在 GitHub 上创建令牌(无需勾选任何权限)": "在 GitHub 上建立權杖(無需勾選任何權限)", "在全局队列里上移一位": "在全域佇列裡上移一位", "在全局队列里下移一位": "在全域佇列裡下移一位", "在网关下载并安装": "在閘道器下載並安裝", "填写账号登录所需信息并发起授权;等待、取消与失败原因由共享登录桥处理,设备码和操作指引会显示在上方。": "填寫帳號登入所需資訊並發起授權;等待、取消與失敗原因由共用登入橋接處理,裝置碼和操作指引會顯示在上方。", "备注名(可选)": "備註名(可選)", "复制失败,请手动选择复制": "複製失敗,請手動選擇複製", "复制订阅链接": "複製訂閱連結", "大小": "大小", "失败 · {status}": "失敗 · {status}", "失败退避": "失敗退避", "奖励 {bonus}": "獎勵 {bonus}", "套餐 {plan}": "套餐 {plan}", "套餐池人机验证": "套餐池人機驗證", "套餐池请求需要验证,请主动开始验证后重试请求": "套餐池請求需要驗證,請主動開始驗證後重試請求", "安装": "安裝", "安装 Agent2API 官方提供商": "安裝 Agent2API 官方提供商", "安装 {name}": "安裝 {name}", "安装、更新与启停均作用在这台网关上。插件平台由网关决定,与手机系统无关。": "安裝、更新與啟停均作用在這臺網關上。外掛平臺由閘道器決定,與手機系統無關。", "安装与更新插件时访问 GitHub 用。与「设置 → 更新 → 更新设置」里的同一项互通,填一次即可。不填也能用,只是匿名请求限额较低(60 次/小时)。": "安裝與更新外掛時存取 GitHub 用。與「設定 → 更新 → 更新設定」中的同一項互通,填一次即可。不填也能用,只是匿名請求上限較低(60 次/小時)。", "安装包已就绪,点「安装」即可完成更新": "安裝包已就緒,點「安裝」即可完成更新", "安装插件包": "安裝外掛套件", "安装时间": "安裝時間", "官方": "官方", "官方签名:包内容与发布者签的完全一致,未被改过": "官方簽章:包內容與發佈者簽的完全一致,未被改過", "定时": "定時", "定时任务": "定時任務", "定时检查在网关执行,关闭手机后仍然生效。": "定時檢查在閘道器執行,關閉手機後仍然生效。", "实际注入": "實際注入", "客户端分布": "客戶端分佈", "客户端统计": "客戶端統計", "宿主": "宿主", "宿主错误": "宿主錯誤", "对话模型": "對話模型", "对话模型已切换": "對話模型已切換", "将修改 {model} 的 {n} 项能力:": "將修改 {model} 的 {n} 項能力:", "将修改 {n} 个模型的启停状态:": "將修改 {n} 個模型的啟停狀態:", "将修改 {n} 个账号的启用状态(其中禁用 {k} 个):": "將修改 {n} 個帳號的啟用狀態(其中停用 {k} 個):", "将对 {model} 发起一次真实请求:": "將對 {model} 發起一次真實請求:", "将执行 {label}。": "將執行 {label}。", "将把「{provider}」整组移到第 {position} 顺位:": "將把「{provider}」整組移到第 {position} 順位:", "将把账号「{account}」移到第 {position} 顺位:": "將把帳號「{account}」移到第 {position} 順位:", "将改动 {n} 条映射({parts}):": "將改動 {n} 條對映({parts}):", "尚未检查更新": "尚未檢查更新", "尚未登录": "尚未登入", "已下载,待安装": "已下載,待安裝", "已修改 {n} 个模型": "已修改 {n} 個模型", "已修改 {n} 个账号": "已修改 {n} 個帳號", "已修改 {n} 项能力": "已修改 {n} 項能力", "已停止这次回答。": "已停止這次回答。", "已全部取消勾选": "已全部取消勾選", "已关闭自动检查": "已關閉自動檢查", "已删除分组「{name}」": "已刪除分組「{name}」", "已加载": "已載入", "已加载 {n} 家": "已載入 {n} 家", "已勾选 {n} / {total}": "已勾選 {n} / {total}", "已勾选「{label}」": "已勾選「{label}」", "已勾选工具": "已勾選工具", "已取消「{label}」": "已取消「{label}」", "已启动安装器": "已啟動安裝器", "已填写(粘贴新令牌可覆盖)": "已填寫(貼上新權杖可覆蓋)", "已复制{label}": "已複製{label}", "已复制:{text}": "已複製:{text}", "已安装插件": "已安裝外掛", "已完成 {percent}%": "已完成 {percent}%", "已开启自动检查": "已開啟自動檢查", "已恢复推荐勾选": "已恢復推薦勾選", "已恢复默认分组:概览 / 转发链路 / 诊断 / 系统": "已恢復預設分組:概覽 / 轉發鏈路 / 診斷 / 系統", "已改动 {n} 条映射": "已改動 {n} 條對映", "已新建分组「{name}」,点组头的 + 把菜单移进来": "已新建分組「{name}」,點組頭的 + 把選單移進來", "已是最新版本": "已是最新版本", "已注入 {n} / {total} 个工具 · 系统提示词:{state}": "已注入 {n} / {total} 個工具 · 系統提示詞:{state}", "已添加 {n} 台": "已新增 {n} 臺", "已添加的服务器": "已新增的伺服器", "已登录": "已登入", "已离线 · 显示的是缓存内容": "已離線 · 顯示的是快取內容", "已移到第 {n} 顺位": "已移到第 {n} 順位", "已签名": "已簽章", "已试过": "已試過", "并发上限 {n}": "併發上限 {n}", "并发已满,等一个在途回落再参与": "併發已滿,等一個在途回落再參與", "并发满": "併發滿", "开": "開", "开关和选项即时保存;输入项请点击对应的「保存」按钮。": "開關和選項即時儲存;輸入項請點擊對應的「儲存」按鈕。", "开启期间卸载的官方插件也会重新安装。": "開啟期間解除安裝的官方插件也會重新安裝。", "开始验证": "開始驗證", "当前": "當前", "当前一个工具都没勾选,助手只能纯聊天。去「设置 → AI 助手 → 工具」里勾上需要的工具。": "當前一個工具都沒勾選,助手只能純聊天。去「設定 → AI 助手 → 工具」裡勾上需要的工具。", "当前平台": "目前平台", "当前平台暂无包": "目前平台尚無套件", "当前模型请求免人机验证": "目前模型請求免人機驗證", "当前版本 {current},最低可用版本 {minimum}。": "目前版本 {current},最低可用版本 {minimum}。", "当前版本 {version}": "當前版本 {version}", "当前网关": "當前閘道器", "当前网关平台暂无插件包": "當前閘道器平臺暫無外掛包", "当前网关要求插件版本不低于 v{version},补齐前暂不加载。": "目前閘道要求插件版本不低於 v{version},補齊前暫不載入。", "当前:已关闭(助手不收到任何系统提示词,工具定义照发)": "當前:已關閉(助手不收到任何系統提示詞,工具定義照發)", "当前:已开启 · 使用内置默认提示词(还没自定义)": "當前:已開啟 · 使用內建預設提示詞(還沒自定義)", "当前:已开启 · 自定义内容 {n} 字": "當前:已開啟 · 自定義內容 {n} 字", "影响转发": "影響轉發", "待确认": "待確認", "总剩余 {total}": "總剩餘 {total}", "恢复上游原值": "恢復上游原值", "恢复推荐": "恢復推薦", "恢复默认侧边栏": "恢復預設側邊欄", "成功 / 失败": "成功 / 失敗", "成功领取": "成功領取", "我会在动手前把改动列给你确认。": "我會在動手前把改動列給你確認。", "所有菜单都已在这一组": "所有選單都已在這一組", "手动凭证 JSON": "手動憑證 JSON", "手动凭证 JSON(兼容入口)": "手動憑證 JSON(相容入口)", "手机端打开": "手機端開啟", "打开账号设置": "開啟帳號設定", "执行": "執行", "把菜单移入 {name}": "把選單移入 {name}", "把菜单移入「{name}」": "把選單移入「{name}」", "报表": "報表", "拖动分组 {name}": "拖動分組 {name}", "拖动左侧 ⠿ 调整顺序(菜单可以跨组拖);拨开关控制显隐;点分组名可重命名;组头的 + 把别的菜单移进来;眼睛按钮隐藏整组。改动即时生效并记住,左侧侧边栏就是结果。键盘也能排序:把手聚焦后按 Alt+↑ / ↓。": "拖動左側 ⠿ 調整順序(選單可以跨組拖);撥開關控制顯隱;點分組名可重新命名;組頭的 + 把別的選單移進來;眼睛按鈕隱藏整組。改動即時生效並記住,左側側邊欄就是結果。鍵盤也能排序:把手聚焦後按 Alt+↑ / ↓。", "拖动菜单 {name}": "拖動選單 {name}", "拖动调整分组顺序(Alt+↑ / ↓ 也可)": "拖動調整分組順序(Alt+↑ / ↓ 也可)", "拖动调整队列顺序": "拖動調整佇列順序", "拖动调整顺序,可跨组(Alt+↑ / ↓ 也可)": "拖動調整順序,可跨組(Alt+↑ / ↓ 也可)", "按 API Key 筛选": "按 API Key 篩選", "按 Token": "按 Token", "按天请求趋势": "按天請求趨勢", "按客户端筛选": "按客戶端篩選", "按模型展开队列": "按模型展開佇列", "按访问网关的 API Key 统计生产请求,不包含助手对话和模型测试。停用、删除 Key 不会删除历史用量;密钥值不会进入报表。历史没有记录身份的请求单列,不能追溯到某把 Key。": "按存取閘道器的 API Key 統計生產請求,不包含助手對話和模型測試。停用、刪除 Key 不會刪除歷史用量;金鑰值不會進入報表。歷史沒有記錄身份的請求單列,不能追溯到某把 Key。", "按请求 User-Agent 识别的客户端类型统计,不代表设备或用户数。“其它”表示有 User-Agent 但未匹配已知类型;“未记录客户端”表示旧数据或请求未带 User-Agent。": "按請求 User-Agent 識別的客戶端型別統計,不代表裝置或使用者數。“其它”表示有 User-Agent 但未匹配已知型別;“未記錄客戶端”表示舊資料或請求未帶 User-Agent。", "按请求数": "按請求數", "按请求的模型展开 —— 与转发选路同一份排序,下一个请求会走 ★ 那位": "按請求的模型展開 —— 與轉發選路同一份排序,下一個請求會走 ★ 那位", "按间隔检查插件版本,在对应卡片显示更新;关闭后仍可手动检查。自动更新或自动下载开启时也使用此间隔。": "按間隔檢查插件版本,在對應卡片顯示更新;關閉後仍可手動檢查。自動更新或自動下載開啟時也使用此間隔。", "按需安装插件,为 AI 路由网关扩展提供商能力。插件独立于主程序更新,下载完成后自动校验并安装。": "按需安裝插件,為 AI 路由閘道擴充供應商能力。插件獨立於主程式更新,下載完成後自動驗證並安裝。", "排序已保存,但列表刷新失败:{message}": "排序已儲存,但清單重新整理失敗:{message}", "排序未保存:{message}": "排序未儲存:{message}", "排序设置迁移失败:{message}": "排序設定移轉失敗:{message}", "排第 1 的接走所有请求,直到它不能答(限流 / 故障 / 额度尽)才轮到下一位 —— 就是「从上往下」的现状行为。": "排第 1 的接走所有請求,直到它不能答(限流 / 故障 / 額度盡)才輪到下一位 —— 就是「從上往下」的現狀行為。", "接口文档": "介面文件", "控制主侧边栏显示哪些菜单、按什么顺序、怎么分组。隐藏只影响导航显示,不会撤销页面访问权限;被隐藏的页面仍可通过地址直接打开。": "控制主側邊欄顯示哪些選單、按什麼順序、怎麼分組。隱藏隻影響導航顯示,不會撤銷頁面存取許可權;被隱藏的頁面仍可通過地址直接開啟。", "提供商启停": "提供商啟停", "提供商增强": "提供商增強", "提示词": "提示詞", "提示词开关": "提示詞開關", "插件": "外掛", "插件仓库": "外掛倉庫", "插件仓库还没有发布任何版本。可以点「刷新」重试,或用「从文件安装…」选中本地 zip。": "外掛倉庫還沒有釋出任何版本。可以點「重新整理」重試,或用「從檔案安裝…」選中本地 zip。", "插件包与主程序分开安装、分开升级。卸载插件后账号数据仍然保留,重新装回即可继续使用;仅该包提供的转发与添加账号需要插件,本体订阅不受影响。": "外掛套件與主程式分開安裝、分開升級。解除安裝後帳號資料仍保留,重新安裝即可繼續使用;僅該套件提供的轉發與新增帳號需要外掛,本體訂閱不受影響。", "插件包与主程序分开安装、分开升级。卸载插件后账号数据仍然保留,重新装回即可继续使用;但转发与添加账号需要插件在位。": "外掛套件與主程式分開安裝、分開升級。解除安裝外掛後帳號資料仍然保留,重新裝回即可繼續使用;但轉發與新增帳號需要外掛在位。", "插件包大小不能超过 {n} MiB": "外掛套件大小不能超過 {n} MiB", "插件包已卸载": "外掛套件已解除安裝", "插件包已安装": "外掛套件已安裝", "插件包已安装到 v{version}": "插件套件已安裝至 v{version}", "插件包已更新到 v{version}": "外掛包已更新到 v{version}", "插件包的可执行文件不在磁盘上(可能被手工删除或移动),请重新安装。": "外掛套件的執行檔不在磁碟上(可能被手動刪除或移動),請重新安裝。", "插件只声明了短信登录,但没有下发可用的动态表单;此界面不会猜测短信接口": "外掛只宣告了簡訊登入,卻未提供可用的動態表單;此介面不會猜測簡訊 API", "插件文件缺失,请在电脑端重新安装插件包": "外掛檔案缺失,請在電腦端重新安裝外掛包", "插件文件缺失,请重新安装插件包": "外掛檔案缺失,請重新安裝外掛包", "插件未实现 auth.methods(501),且没有可用的旧版登录声明;仅保留需要插件确认的手动凭证 JSON 入口": "外掛未實作 auth.methods(501),且沒有可用的舊版登入宣告;僅保留需要外掛確認的手動憑證 JSON 入口", "插件未实现 auth.methods(501);以下入口仅依据旧版登录声明显示": "外掛未實作 auth.methods(501);以下入口僅依據舊版登入宣告顯示", "插件没有声明可用的账号登录方式,请查看账号登录帮助或联系插件作者": "外掛未宣告可用的帳號登入方式,請查看帳號登入說明或聯絡外掛作者", "插件状态已变更,但账号列表同步失败。请回到账号页点击「刷新」重试。": "外掛狀態已變更,但帳號清單同步失敗。請回到帳號頁點擊「重新整理」重試。", "插件登录指引": "外掛登入指引", "插件登录方式包含重复的输入字段": "外掛的登入方式包含重複的輸入欄位", "插件登录选择字段包含无效或重复的选项": "外掛的登入選擇欄位包含無效或重複的選項", "插件登录选择字段缺少选项列表": "外掛的登入選擇欄位缺少選項清單", "插件目录": "外掛目錄", "插件设置": "外掛設定", "插件设置已保存": "插件設定已儲存", "插件返回了无效的登录字段,请更新插件或联系作者": "外掛回傳了無效的登入欄位,請更新外掛或聯絡作者", "插件返回了无效的登录方式,请更新插件或联系作者": "外掛回傳了無效的登入方式,請更新外掛或聯絡作者", "插件页面": "外掛頁面", "搜索…": "搜尋…", "改动立即生效;禁用后指向它的请求会落到下一个候选。": "改動立即生效;停用後指向它的請求會落到下一個候選。", "改动类工具": "改動類工具", "改成": "改成", "文件缺失": "檔案缺失", "文档": "文件", "新": "新", "新分组名": "新分組名", "新增 {n} 条": "新增 {n} 條", "新对话": "新對話", "新建分组": "新建分組", "无凭证": "無憑證", "无法解密": "無法解密", "无法读取登录方式": "無法讀取登入方式", "日志": "日誌", "旧版本保存的正文可能已截断,无法恢复缺失内容": "舊版本儲存的正文可能已截斷,無法恢復缺失內容", "旧版浏览器登录暂不接收备注名和登录代理,请添加后在账号设置中调整。": "舊版瀏覽器登入暫不接受備註名稱和登入代理,請新增後在帳號設定中調整。", "旧版登录方式": "舊版登入方式", "映射名": "對映名", "显示 {name}": "顯示 {name}", "显示分组 {name}": "顯示分組 {name}", "显示这一组": "顯示這一組", "智能": "智慧", "暂不可用": "暫不可用", "暂无可安装的插件": "暫無可安裝的插件", "暂时查不到插件仓库({reason})。可以点「刷新」重试,或用「从文件安装…」选中本地 zip。": "暫時查不到外掛倉庫({reason})。可以點「重新整理」重試,或用「從檔案安裝…」選中本地 zip。", "暂未发布": "尚未發布", "更多": "更多", "更新到 v{version}": "更新至 v{version}", "更新前无法继续调用模型;账号、配置和历史记录不会被删除。": "更新前無法繼續呼叫模型;帳號、設定和歷史記錄不會被刪除。", "最大化": "最大化", "最小化": "最小化", "最早 {time} 恢复": "最早 {time} 恢復", "最近调用": "最近呼叫", "有": "有", "有插件包的协议版本与当前网关不一致({versions}),请下载对应版本的插件包。": "有外掛套件的協定版本與目前閘道不一致({versions}),請下載對應版本的外掛套件。", "有新版本,重启后生效": "有新版本,重啟後生效", "有新版本:v{current} → v{latest}": "有新版本:v{current} → v{latest}", "有更新": "有更新", "服务器": "伺服器", "未加载": "未載入", "未同步": "未同步", "未就绪": "未就緒", "未登录": "未登入", "未知工具「{name}」:它在设置里可能刚被取消勾选,或这一版助手还不认识它。": "未知工具「{name}」:它在設定裡可能剛被取消勾選,或這一版助手還不認識它。", "未签名": "未簽章", "未签名包不会自动覆盖;点击「补齐插件」将安装官方签名包。": "未簽章套件不會自動覆寫;點擊「補齊插件」將安裝官方簽章套件。", "未签名:可以正常使用,但无法证明这个包出自官方;升级时同样只做格式校验": "未簽章:可以正常使用,但無法證明這個包出自官方;升級時同樣只做格式校驗", "未记录": "未記錄", "未记录客户端": "未記錄客戶端", "未运行": "未執行", "未选择服务器": "未選擇伺服器", "本周期消耗达到限制器上限,转发时跳过": "本週期消耗達到限制器上限,轉發時跳過", "本地网关监听状态": "本地閘道器監聽狀態", "来自环境变量": "來自環境變數", "来自环境变量 GITHUB_TOKEN": "來自環境變數 GITHUB_TOKEN", "松开刷新": "鬆開重新整理", "查余额": "查餘額", "查看全部": "檢視全部", "查看参数": "檢視引數", "查看发布说明": "查看發佈說明", "查看发布页面": "查看發布頁面", "查看提供商插件": "查看供應商外掛", "查看更新日志": "查看更新日誌", "查看结果": "檢視結果", "查询该账号的余额": "查詢該帳號的餘額", "标题总结设置": "標題總結設定", "桌面桥不可用(本页需要在 Agent2API 客户端里打开)": "桌面橋不可用(本頁需要在 Agent2API 客戶端裡開啟)", "检查更新失败": "檢查更新失敗", "检测到更新后自动下载、校验并安装已启用的官方签名插件。": "偵測到更新後自動下載、驗證並安裝已啟用的官方簽章插件。", "检测到更新后自动下载、校验并安装已启用的官方签名插件。关闭此项不影响最低版本补齐;未签名或第三方插件仍需手动更新。": "偵測到更新後自動下載、驗證並安裝已啟用的官方簽章插件。關閉此項不影響最低版本補齊;未簽章或第三方插件仍需手動更新。", "检测到更新后自动下载、校验并安装已启用的官方签名插件。未签名或第三方插件仍需手动更新。": "偵測到更新後自動下載、驗證並安裝已啟用的官方簽章插件。未簽章或第三方插件仍需手動更新。", "模型分布": "模型分佈", "模型管理": "模型管理", "次熔断": "次熔斷", "正在下载…": "正在下載…", "正在完成人机验证…": "正在完成人機驗證…", "正在应用…": "正在應用…", "正在校验包内容…": "正在驗證套件內容…", "正在检查…": "正在檢查…", "正在自动补齐官方插件,不受日常更新开关和通道限制。": "正在自動補齊官方插件,不受日常更新開關和通道限制。", "正在补齐插件…": "正在補齊插件…", "正在识别二维码…": "正在識別二維碼…", "正在读取、校验并安装插件包…": "正在讀取、驗證並安裝插件套件…", "正在读取插件列表…": "正在讀取插件清單…", "正在读取插件登录方式…": "正在讀取外掛登入方式…", "正在读取文件…": "正在讀取檔案…", "正在连接…": "正在連線…", "正在验证…": "正在驗證…", "此 OAuth 方法未声明备注名字段,账号名由插件获取;添加后可在账号设置中修改。": "此 OAuth 方式未宣告備註名稱欄位,帳號名稱由外掛取得;新增後可在帳號設定中修改。", "此方式可能需要手动提交授权回调。完成官方登录后,按共享登录桥的提示粘贴完整回调地址;不要把回调地址当作 API Key 或 Token。": "此方式可能需要手動提交授權回呼。完成官方登入後,依共用登入橋接的提示貼上完整回呼網址;不要將回呼網址當作 API Key 或 Token。", "此旧版登录声明无法安全映射到动态表单,请联系插件作者": "此舊版登入宣告無法安全對應到動態表單,請聯絡外掛作者", "此登录方式需要由共享登录桥发起": "此登入方式需要由共用登入橋接發起", "每台服务器的登录状态各自独立保存,切换后不用重新登录。地址改掉后需要重新登录。": "每臺伺服器的登入狀態各自獨立儲存,切換後不用重新登入。地址改掉後需要重新登入。", "每条请求轮换到下一个可用账号;新会话交给最近最闲的那位。适合想把手里的号雨露均沾。": "每條請求輪換到下一個可用帳號;新會話交給最近最閒的那位。適合想把手裡的號雨露均霑。", "每轮": "每輪", "没有可恢复的维度明细": "沒有可恢復的維度明細", "没有可更新的版本": "沒有可更新的版本", "没有已启用的模型": "沒有已啟用的模型", "没有找到提供商「{provider}」的账号": "沒有找到提供商「{provider}」的帳號", "没有找到账号「{name}」": "沒有找到帳號「{name}」", "没有说明": "沒有說明", "没有近期套餐池请求,不生成验证码令牌": "沒有近期套餐池請求,不產生驗證碼權杖", "没给账号名": "沒給帳號名", "注入系统提示词": "注入系統提示詞", "活动": "活動", "浅色": "淺色", "消耗该账号额度": "消耗該帳號額度", "消耗额度": "消耗額度", "深色": "深色", "添加": "新增", "添加失败": "新增失敗", "添加服务器": "新增伺服器", "清空 = 回到内置默认(与「恢复默认」等价)。": "清空 = 回到內建預設(與「恢復預設」等價)。", "清除失败:{error}": "清除失敗:{error}", "点「编辑」弹窗改内容;开关关掉就整段不发。": "點「編輯」彈窗改內容;開關關掉就整段不發。", "点击重命名": "點擊重新命名", "熔断": "熔斷", "熔断时长(秒)": "熔斷時長(秒)", "版本 {version} · 从 GitHub 直接下载安装包": "版本 {version} · 從 GitHub 直接下載安裝包", "版本 {version} · 从网关下载安装包": "版本 {version} · 從閘道器下載安裝包", "版本 {version} · 更新包需从 Release 页面获取": "版本 {version} · 更新包需從 Release 頁面獲取", "环境变量 Key": "環境變數 Key", "用一句话让我查或改本机的模型转发配置。": "用一句話讓我查或改本機的模型轉發配置。", "用量占比最低的先用;没有读数的账号按队列位次排在有读数的后面。适合「谁空谁上」。": "用量佔比最低的先用;沒有讀數的帳號按佇列位次排在有讀數的後面。適合「誰空誰上」。", "用量详情": "用量詳情", "电脑端已关闭「软件版本检查」,此处只做手动检查": "電腦端已關閉「軟體版本檢查」,此處只做手動檢查", "登录指引 / 设备码授权": "登入指引 / 裝置碼授權", "登录方式说明": "登入方式說明", "登录桥未确认账号添加完成": "登入橋接未確認帳號新增完成", "登录面板": "登入面板", "监听 127.0.0.1": "監聽 127.0.0.1", "直接说要改什么 / 查什么…(Enter 发送,Shift+Enter 换行)": "直接說要改什麼 / 查什麼…(Enter 傳送,Shift+Enter 換行)", "确定删除账号「{name}」?{note}": "確定刪除帳號「{name}」?{note}", "确定卸载「{name}」吗?卸载后这个包里的提供商将无法转发,也无法添加账号。账号数据本身不会被删除,重新安装后可以继续使用。": "確定解除安裝「{name}」嗎?解除安裝後這個套件裡的供應商將無法轉發,也無法新增帳號。帳號資料本身不會被刪除,重新安裝後可以繼續使用。", "确定卸载「{name}」吗?对应提供商将停止转发,账号数据仍然保留,重新安装后恢复。": "確定解除安裝「{name}」嗎?對應提供商將停止轉發,帳號資料仍然保留,重新安裝後恢復。", "确认后立即生效": "確認後立即生效", "禁用会把账号移出转发队列;若这条线路没有别的可用账号,请求会直接失败。": "停用會把帳號移出轉發佇列;若這條線路沒有別的可用帳號,請求會直接失敗。", "禁用后不参与转发,余额仍可查": "停用後不參與轉發,餘額仍可查", "移入「{name}」": "移入「{name}」", "稍后": "稍後", "空分组 · 点组头的 + 把菜单移进来": "空分組 · 點組頭的 + 把選單移進來", "立即升级": "立即升級", "第 {current} / {total} 页": "第 {current} / {total} 頁", "等待窗口": "等待視窗", "等待账号登录完成…": "等待帳號登入完成…", "等这一轮跑完…": "等這一輪跑完…", "签到中心": "簽到中心", "管理所连接网关的插件,不在手机上安装提供商插件": "管理所連線閘道器的外掛,不在手機上安裝提供商外掛", "粘贴 GitHub 令牌(ghp_… / github_pat_…)": "貼上 GitHub 權杖(ghp_… / github_pat_…)", "粘贴插件要求的 JSON 对象,不要包含 provider、name、proxy 或登录流程控制字段": "貼上外掛要求的 JSON 物件,不要包含 provider、name、proxy 或登入流程控制欄位", "系统提示词 + 工具定义": "系統提示詞 + 工具定義", "系统提示词已保存": "系統提示詞已儲存", "系统提示词已关闭": "系統提示詞已關閉", "系统提示词已开启": "系統提示詞已開啟", "统计排序": "統計排序", "缓存读取": "快取讀取", "编辑服务器": "編輯伺服器", "编辑系统提示词": "編輯系統提示詞", "网关 Key": "閘道器 Key", "网关插件": "閘道器外掛", "网关正在下载…": "閘道器正在下載…", "网关正在安装…": "閘道器正在安裝…", "网关正在校验…": "閘道器正在校驗…", "网关没有返回有效的登录方式列表,无法确认该插件的登录能力": "閘道沒有回傳有效的登入方式清單,無法確認此外掛的登入能力", "网关运行中": "閘道器執行中", "网络不可达": "網路不可達", "网络代理": "網路代理", "网页提供商": "網頁提供商", "网页登录(旧版声明)": "網頁登入(舊版宣告)", "能力位决定下游看到的声明(能不能贴图、能塞多少上下文),不改上游的真实行为。": "能力位決定下游看到的宣告(能不能貼圖、能塞多少上下文),不改上游的真實行為。", "自动": "自動", "自动下载官方插件": "自動下載官方插件", "自动匹配平台": "自動匹配平臺", "自动安装": "自動安裝", "自动更新插件": "自動更新插件", "自动检查插件更新": "自動檢查插件更新", "至少要保留一个分组": "至少要保留一個分組", "补签": "補籤", "补齐插件": "補齊插件", "订阅里的节点会自动同步进下方代理池,账号即可引用。": "訂閱裡的節點會自動同步進下方代理池,帳號即可引用。", "订阅里的节点会被内核起成本地监听器,镜像到下方代理池(账号按 id 引用,与本页其它出口同一用法)。": "訂閱裡的節點會被核心起成本地監聽器,映象到下方代理池(帳號按 id 引用,與本頁其它出口同一用法)。", "订阅链接必须是 http:// 或 https:// 开头": "訂閱連結必須是 http:// 或 https:// 開頭", "设备授权码:{code}": "裝置授權碼:{code}", "设备码授权时,请按网关给出的指引在官方页面确认设备授权码。没有授权地址不等于失败,可能需要在网关本机客户端完成操作;请以共享登录桥返回的状态为准。": "裝置碼授權時,請依閘道提供的指引在官方頁面確認裝置授權碼。沒有授權網址不等於失敗,可能需要在閘道本機用戶端完成操作;請以共用登入橋接回傳的狀態為準。", "设置": "設定", "设置不可隐藏(隐藏了只能清缓存找回来)": "設定不可隱藏(隱藏了只能清快取找回來)", "设置已生效,但写入磁盘失败(重启后会恢复原设置)": "設定已生效,但寫入磁碟失敗(重新啟動後會恢復原設定)", "诊断": "診斷", "诊断信息": "診斷資訊", "该提供商已不在运行时目录中,请返回列表重新选择": "此供應商已不在執行時清單中,請返回清單重新選擇", "该登录方式没有可选项,无法提交;请更新插件或联系作者": "此登入方式沒有可選項,無法提交;請更新外掛或聯絡作者", "请允许安装未知来源应用后重试": "請允許安裝未知來源應用後重試", "请先粘贴 GitHub 令牌": "請先貼上 GitHub 權杖", "请先选择有效的 OAuth 登录方式": "請先選擇有效的 OAuth 登入方式", "请在 Release 页面下载后通过 TestFlight 或 App Store 安装": "請在 Release 頁面下載後通過 TestFlight 或 App Store 安裝", "请填一个分组名": "請填一個分組名", "请填写订阅名称": "請填寫訂閱名稱", "请填写非空的凭证 JSON 对象,且不超过 256 KiB": "請填寫非空的憑證 JSON 物件,且不超過 256 KiB", "请求失败": "請求失敗", "请求失败:{message}": "請求失敗:{message}", "请求数": "請求數", "请求日志": "請求日誌", "请确认": "請確認", "请稍候": "請稍候", "请选择 {label} 的有效选项": "請選擇 {label} 的有效選項", "读取插件仓库失败": "讀取外掛倉庫失敗", "读取插件状态失败:{error}": "讀取外掛狀態失敗:{error}", "读取文件失败": "讀取檔案失敗", "读取消耗排序失败:{message}": "讀取消耗排序失敗:{message}", "读取设置失败:{error}": "讀取設定失敗:{error}", "账号 / 登录出网代理": "帳號 / 登入對外連線代理", "账号不在当前队列里": "帳號不在當前佇列裡", "账号列表响应异常": "帳號清單回應異常", "账号已删除": "帳號已刪除", "账号已在全局队列第一位": "帳號已在全域佇列第一位", "账号排序接口不可用,请确认网关与界面已更新": "帳號排序 API 無法使用,請確認閘道器與介面已更新", "账号登录帮助(account login)": "帳號登入說明(account login)", "账号登录方式": "帳號登入方式", "趋势统计指标": "趨勢統計指標", "趋势统计维度": "趨勢統計維度", "跟随系统": "跟隨系統", "路由策略": "路由策略", "转发失败的账号休息一会儿再回来(连续失败翻倍,上限 1 小时)": "轉發失敗的帳號休息一會兒再回來(連續失敗翻倍,上限 1 小時)", "转发能力": "轉發能力", "轮流均摊": "輪流均攤", "软件版本检查设置不可用": "軟體版本檢查設定不可用", "输入 / 输出": "輸入 / 輸出", "输入这台网关的管理员账号与密码。": "輸入這臺網關的管理員帳號與密碼。", "运行日志": "執行日誌", "运行正常 · {url}": "執行正常 · {url}", "运行状态": "執行狀態", "返回": "返回", "还有额度时被 429 的账号排到队尾,轮一圈才回来 —— 负载摊开而不是每次回到第 1 个": "還有額度時被 429 的帳號排到隊尾,輪一圈才回來 —— 負載攤開而不是每次回到第 1 個", "还没有安装任何提供商插件包": "尚未安裝任何供應商外掛套件", "还没有签到记录": "還沒有簽到記錄", "还没有订阅:粘贴订阅链接,或从图片识别二维码导入。": "還沒有訂閱:貼上訂閱連結,或從圖片識別二維碼匯入。", "还没有选择对话模型:先在下方选一个(或去「设置 → AI 助手」里选)。": "還沒有選擇對話模型:先在下方選一個(或去「設定 → AI 助手」裡選)。", "这一版没有提供 Android 安装包": "這一版沒有提供 Android 安裝包", "这一项已隐藏": "這一項已隱藏", "这一项正在显示": "這一項正在顯示", "这个包提供的提供商(可单独停用某一家)": "這個套件提供的供應商(可單獨停用某一家)", "这个模型下没有可用账号": "這個模型下沒有可用帳號", "这个面板没有管理员,用一把已启用的 API Key 访问(在桌面端「网关 Key」页创建)。": "這個面板沒有管理員,用一把已啟用的 API Key 存取(在桌面版「閘道器 Key」頁建立)。", "这会真实发起上游请求并消耗额度": "這會真實發起上游請求並消耗額度", "这台网关没有管理员,用一把已启用的 API Key 访问(在桌面端「网关 Key」页创建)。": "這臺網關沒有管理員,用一把已啟用的 API Key 存取(在桌面版「閘道器 Key」頁建立)。", "这台网关还没有安装插件": "這臺網關還沒有安裝外掛", "这台网关还没有管理员。设置一个账号密码,之后用它登录。": "這臺網關還沒有管理員。設定一個帳號密碼,之後用它登入。", "这是旧插件的手动兼容入口,不代表支持任意凭证或登录方式。请仅粘贴该插件明确接受的凭证 JSON;网关会交给 account.normalize 校验,不会自动推断 Token、Cookie 或 OAuth。": "這是舊外掛的手動相容入口,不代表支援任意憑證或登入方式。請僅貼上此外掛明確接受的憑證 JSON;閘道會交給 account.normalize 驗證,不會自動推斷 Token、Cookie 或 OAuth。", "这是真实的上游请求,与生产走同一条链路(会记账,报表排除)。": "這是真實的上游請求,與生產走同一條鏈路(會記賬,報表排除)。", "这段文本作为 system 消息排在对话最前面。工具的定义与当前配置概览由网关自动附加,不用写在这里。": "這段文本作為 system 訊息排在對話最前面。工具的定義與當前配置概覽由閘道器自動附加,不用寫在這裡。", "连不上插件仓库,请检查网络或代理后重试": "連不上外掛倉庫,請檢查網路或代理後重試", "连接 {n}": "連線 {n}", "连接并保存": "連線並儲存", "连续失败到阈值后熔断一段时间;到点放行试一次,连续成功才算恢复": "連續失敗到閾值後熔斷一段時間;到點放行試一次,連續成功才算恢復", "连续失败阈值": "連續失敗閾值", "连续崩溃": "連續當機", "连通 · {ms}ms": "連通 · {ms}ms", "选择对话模型…": "選擇對話模型…", "选择模型…": "選擇模型…", "选择要安装的平台。装好之后这些提供商才会出现在「添加提供商」里。": "選擇要安裝的平臺。裝好之後這些提供商才會出現在「新增提供商」裡。", "都不注入": "都不注入", "都不注入(助手退化为纯聊天)": "都不注入(助手退化為純聊天)", "重启更新": "重啟更新", "重新读取登录方式": "重新讀取登入方式", "队列是一次性整表提交(后端按新顺序重编优先级),移动会连带调整其它组的相对次序。": "佇列是一次性整表提交(後端按新順序重編優先順序),移動會連帶調整其它組的相對次序。", "队列是一次性整表提交;位置越靠前,路由时越先被选中。": "佇列是一次性整表提交;位置越靠前,路由時越先被選中。", "限流 · {n} 个模型": "限流 · {n} 個模型", "限流垫底": "限流墊底", "隐藏 {name}": "隱藏 {name}", "隐藏分组 {name}": "隱藏分組 {name}", "隐藏这一组": "隱藏這一組", "需要强制更新": "需要強制更新", "需要网关 API Key": "需要閘道器 API Key", "需要网关本机环境": "需要閘道本機環境", "需要补齐插件": "需要補齊插件", "顺序优先": "順序優先", "首页": "首頁", "高危": "高危", "默认跟随软件的正式版和 beta 关注选择;单独设置只影响日常更新,最低版本补齐按当前软件版本选择配套包。": "預設跟隨軟體的正式版和 beta 關注選擇;單獨設定只影響日常更新,最低版本補齊按目前軟體版本選擇配套套件。", "默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。": "預設跟隨軟體的自動檢查和間隔。關閉後暫停日常自動更新和下載,但仍會補齊已安裝官方插件的最低版本。", "({n} 个整组隐藏)": "({n} 個整組隱藏)", "(不会影响客户端登录态)": "(不會影響客戶端登入態)", "(仅显示前 20 条,共 {n} 条)": "(僅顯示前 20 條,共 {n} 條)", "(可选)": "(選填)", "(未指定)": "(未指定)", "(请下载与该平台对应的插件包)": "(請下載與該平台對應的外掛套件)", "(默认问候)": "(預設問候)" });
diff --git a/desktop-tauri/ui/islands/ui.js b/desktop-tauri/ui/islands/ui.js
index ecc5c5c9c..2804943e1 100644
--- a/desktop-tauri/ui/islands/ui.js
+++ b/desktop-tauri/ui/islands/ui.js
@@ -95,7 +95,7 @@ Path("edited.png").write_bytes(base64.b64decode(edited.data[0].b64_json))`,error
`)}function c1e(e,t){if(!e.length&&!t.length)return a("当前不限制:这把 Key 可以用全部提供商与全部对外模型");const n=[];return e.length&&n.push(a("提供商:{names}",{names:e.map(jP).join(a("、"))})),t.length&&n.push(a("模型:{names}",{names:t.join(a("、"))})),e.length||n.push(a("(模型候选需先选提供商;不选则沿用当前这几项,保存后仍按模型白名单生效)")),n.join(" ")}function bq(e){return Array.isArray(e)?e.map(t=>String(t)):[]}function yq(e,t){const n=new Map(t.map(i=>[i.value.toLowerCase(),i.value])),r=new Set;return e.forEach(i=>{const o=n.get(String(i).toLowerCase());o&&r.add(o)}),t.filter(i=>r.has(i.value)).map(i=>i.value)}function u1e({target:e,providers:t,modelsByProvider:n,onClose:r,onSaved:i}){const o=e?.id??null,c=!!o,[d,f]=v.useState(e?.name??""),[h,p]=v.useState(""),[g,x]=v.useState(""),[y,j]=v.useState(!1),w=v.useRef(!1),[S,N]=v.useState(()=>bq(e?.allowedProviders)),[A,E]=v.useState(()=>bq(e?.allowedModels)),O=v.useMemo(()=>t.map(L=>({value:String(L.id),label:a(String(L.label??L.id))})),[t]),R=v.useMemo(()=>yq(S,O),[S,O]),T=v.useMemo(()=>i1e(n,R,A),[n,R,A]),P=v.useMemo(()=>yq(A,T),[A,T]),M=T.length?a("没有匹配的选项"):R.length?a("这几家当前没有可用模型(账号未登录或清单为空)"):a("请先在上面选择可用提供商");function _(){w.current=!1,j(!1)}async function I(){if(!w.current){w.current=!0,j(!0),x(a("保存中…"));try{const L=ko().workbuddyDesktop;if(!L)throw new Error(a("后端桥不可用"));if(o){const G=await L.updateKey(o,{allowedProviders:R,allowedModels:P});_(),i(G),r(),jb(a("✅ 可用范围已保存"));return}const D=h.trim();if(D&&D.length<8){x(a("Key 至少需要 8 个字符"));return}const z=await L.createKey({name:d.trim(),key:D||void 0,allowedProviders:R,allowedModels:P});_(),i(z,z?.created?.id),r(),jb(a("✅ Key 已创建,记得复制给客户端"))}catch(L){x(a("保存失败:{reason}",{reason:bP(L)}))}finally{_()}}}return s.jsx(St,{open:!0,onOpenChange:(L,D)=>{if(!L){if(w.current){D.cancel();return}r()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:c?a("可用范围 · {name}",{name:e?.name||a("未命名")}):a("新建 API Key")})}),s.jsxs(Ct,{children:[s.jsxs(Ln,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[s.jsx(Ie,{htmlFor:"key-name",className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("名称")}),s.jsx(Be,{id:"key-name",type:"text",maxLength:60,placeholder:a("例如 Cursor / 公司电脑"),autoComplete:"off",value:d,disabled:c,onChange:L=>f(L.currentTarget.value)})]}),!c&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[s.jsx(Ie,{htmlFor:"key-value",className:"text-[12.5px] whitespace-nowrap text-subtle",children:"Key"}),s.jsx(Be,{id:"key-value",type:"text",placeholder:a("留空自动生成;手填至少 8 个字符"),autoComplete:"off",spellCheck:!1,value:h,onChange:L=>p(L.currentTarget.value),onKeyDown:L=>{L.key==="Enter"&&I()}})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[s.jsx(Ie,{className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("可用提供商")}),s.jsx(Ff,{value:R,onValueChange:N,options:O,placeholder:a("留空 = 不限制"),searchPlaceholder:a("搜索提供商…"),"aria-label":a("可用提供商"),className:"flex-auto min-w-[180px] max-w-[260px]"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[s.jsx(Ie,{className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("可用模型")}),s.jsx(Ff,{value:P,onValueChange:E,options:T,placeholder:a("留空 = 不限制"),emptyHint:M,searchPlaceholder:a("搜索模型…"),"aria-label":a("可用模型"),className:"flex-auto min-w-[180px] max-w-[260px]"})]}),s.jsx("p",{children:a("留空表示不限制;同时设置时请求需同时满足两个条件(模型在白名单内且路由到允许的提供商)。 「可用模型」的候选跟着上面勾选的提供商走:没勾提供商时它是空的(还没有约束范围), 勾了几家就列出这几家能收的全部对外名。")}),s.jsx("p",{id:"key-restrict-summary",children:c1e(R,P)})]}),s.jsx("div",{className:"min-h-[18px] text-[11.5px] text-muted-foreground",children:g})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:r,disabled:y,children:a("取消")}),s.jsx(B,{variant:"default",disabled:y,onClick:()=>{I()},children:a(c?"保存范围":"创建")})]})]})})}let $S=null;async function d1e(){await $S?.load()}function f1e(){$S?.render()}function h1e(){const[e,t]=v.useState(null),[n,r]=v.useState(()=>new Set),[i,o]=v.useState(()=>new Set),[c,d]=v.useState(null),[,f]=v.useState(0),h=v.useRef(new Set),p=v.useRef(!1),g=v.useCallback(I=>{t(I)},[]),x=v.useCallback(I=>{I&&Array.isArray(I.keys)&&g(I)},[g]),y=v.useCallback(async()=>{if(!p.current){p.current=!0;try{const I=ko().workbuddyDesktop;if(!I)throw new Error(a("后端桥不可用"));g(await I.getKeys()??null)}catch(I){jb(a("读取 Key 列表失败:{reason}",{reason:bP(I)}),"err")}finally{p.current=!1}}},[g]);async function j(I,L,D){if(!h.current.has(I)){h.current.add(I),o(new Set(h.current));try{x(await L()),D&&jb(D)}catch(z){jb(a("操作失败:{reason}",{reason:bP(z)}),"err")}finally{h.current.delete(I),o(new Set(h.current))}}}function w(I){r(L=>{const D=new Set(L);return D.has(I)?D.delete(I):D.add(I),D})}async function S(I){const L=ko().workbuddyDesktop,D=ko().wbConfirm?.ask;if(!L||!D)return;const z=e1e(I.name||I.masked||I.id);await D({title:a("删除网关 Key"),html:a("确定删除 Key「{name}」?使用它的客户端会立刻无法访问。",{name:z}),okText:a("删除"),okClass:"danger"})&&j(I.id,()=>L.deleteKey(I.id),a("Key 已删除"))}function N(I,L){const D=ko().workbuddyDesktop;D&&j(I.id,()=>D.updateKey(I.id,{enabled:L}),a(L?"Key 已启用":"Key 已停用"))}v.useLayoutEffect(()=>($S={load:y,render:()=>f(I=>I+1)},wP=()=>f(I=>I+1),n1e(),f(I=>I+1),()=>{$S=null,wP=null}),[y]),v.useEffect(()=>{ko().wbApp?.currentPage==="keys"&&y()},[y]),v.useEffect(()=>{ko().wbApp?.renderTopbarStatus?.()},[e]);const A=r1e(e),E=qx(A.length,"keys"),O=E.paged?E.slice(A):A,R=vq(),T=e?.usableKeyCount??A.filter(I=>I.enabled).length,P=T>0,M=P?a("已启用鉴权 · {n} 把 Key 生效",{n:T}):a("没有可用的 API Key,请先在「网关 Key」页创建并启用");function _(I,L,D){switch(I){case"name":return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mid",children:s.jsx("span",{className:"t",children:L.name||a("未命名")})}),s.jsx("div",{className:"mname",title:l1e(L),children:o1e(L)})]});case"key":{const z=n.has(L.id);return s.jsxs("div",{className:"keycell",children:[s.jsx("code",{className:"kv",children:z?L.key:L.masked}),s.jsx(B,{size:"sm",variant:"ghost",onClick:()=>w(L.id),children:a(z?"隐藏":"显示")}),s.jsx(B,{size:"sm",variant:"ghost","data-copy":L.key,title:a("复制 Key"),children:a("复制")})]})}case"time":return s.jsx("span",{className:"muted",children:L.createdAt?ko().wbApp?.formatTime?.(L.createdAt):"—"});case"state":return s.jsx(cn,{checked:L.enabled===!0,disabled:D,"aria-label":a("启用「{name}」",{name:L.name||a("未命名")}),onCheckedChange:z=>N(L,z)});case"act":return s.jsxs("div",{className:"row-actions",children:[s.jsx(B,{size:"sm",variant:"ghost",disabled:D,onClick:()=>d({key:L}),children:a("可用范围")}),s.jsx(B,{size:"sm",variant:"destructive",disabled:D,onClick:()=>{S(L)},children:a("删除")})]});default:return null}}return s.jsxs(tt,{render:s.jsx("section",{}),className:"panel",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsx("h2",{children:a("API Key 列表")}),s.jsx(ye,{id:"keys-status",variant:P?"success":"warning","data-tone":P?"ok":"warn",children:M}),s.jsx("div",{className:"head-actions",children:s.jsx(B,{variant:"default",onClick:()=>d({key:null}),children:a("+ 新建 Key")})})]}),s.jsx("div",{className:"models-table-wrap",children:s.jsxs(ea,{container:!1,className:"models-table keys-table",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"k-name","data-col":"name"}),s.jsx("col",{className:"k-key","data-col":"key"}),s.jsx("col",{className:"k-time","data-col":"time"}),s.jsx("col",{className:"k-state","data-col":"state"}),s.jsx("col",{className:"k-act","data-col":"act"})]}),s.jsx(Ta,{children:s.jsxs(en,{children:[s.jsx(ft,{"data-col":"name",children:a("名称")}),s.jsx(ft,{"data-col":"key",children:"Key"}),s.jsx(ft,{"data-col":"time",children:a("创建时间")}),s.jsx(ft,{"data-col":"state",children:a("启用")}),s.jsx(ft,{className:"r","data-col":"act",children:a("操作")})]})}),s.jsx(ga,{children:O.length?O.map(I=>{const L=i.has(I.id);return s.jsx(en,{className:I.enabled?"":"off","data-id":I.id,children:R.map(D=>s.jsx(Xe,{className:`${t1e[D.key]??""} ta-${D.align}`,children:_(D.key,I,L)},D.key))},I.id)}):s.jsx(en,{children:s.jsx(Xe,{colSpan:R.length,className:"empty",children:a(e?"没有可用的 API Key,请先在「网关 Key」页创建并启用":"加载中…")})})})]})}),s.jsx(fd,{leading:s.jsxs("span",{children:[a("客户端请求需带 "),s.jsx("code",{children:"Authorization: Bearer "}),a(" 或 "),s.jsx("code",{children:"x-api-key: "}),a(";修改后立即生效。模型测试、助手和日活保活必须选择 Key,受限 Key 不能访问管理接口。每把 Key 可单独限制"),s.jsx("b",{children:a("可用提供商")}),a("与"),s.jsx("b",{children:a("可用模型")}),a("(行内「可用范围」):留空 = 不限制,两个都设时 按交集生效 —— 被限制的模型对这把 Key 表现为「不存在」(拉 /v1/models 也看不到它), 提供它的家不在可用列表里时请求同样被拒。")]}),total:A.length,range:E.paged?{start:E.rangeStart,end:E.rangeEnd}:null,page:E.page,pageCount:E.pageCount,size:E.size,onSizeChange:E.setSize,onPageChange:E.goto}),c?s.jsx(u1e,{target:c.key,providers:s1e(e),modelsByProvider:a1e(e),onClose:()=>d(null),onSaved:(I,L)=>{L&&r(D=>new Set(D).add(L)),x(I)}}):null]})}let wq=!1;function jq(){if(wq)return;const e=document.querySelector(gq);e&&(wq=!0,e.replaceChildren(),wn.createRoot(e).render(s.jsx(h1e,{})))}document.querySelector(gq)?jq():document.addEventListener("DOMContentLoaded",jq,{once:!0}),window.wbKeysPanel={load:d1e,render:f1e,visibleColumns:vq};const p1e="login-app";function m1e(){const[e,t]=v.useState("idle"),n=v.useRef(null);return v.useEffect(()=>{const r=n.current;if(!r)return;const i=()=>t(r.getAttribute("state")||"idle"),o=new MutationObserver(i);return o.observe(r,{attributes:!0,attributeFilter:["state"]}),i(),()=>o.disconnect()},[]),v.createElement("panel-captcha",{id:"captcha",ref:n},s.jsx(nve,{state:e,className:"mx-auto mt-5",onClick:()=>{n.current?.start?.()},children:a(e==="verifying"?"验证中…":e==="verified"?"验证成功":e==="error"?"验证失败,请重试":"我不是机器人")}))}function g1e(){return s.jsxs(tt,{className:"w-[min(400px,100%)] p-[36px_34px_30px] shadow-3",children:[s.jsxs("div",{className:"mb-[26px] flex flex-col items-center gap-3 text-center",children:[s.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"Agent2API",className:"size-[52px] rounded-[12px] shadow-[0_6px_18px_rgba(0,122,255,0.35)]",children:[s.jsx("rect",{width:"24",height:"24",rx:"5.4",fill:"#007AFF"}),s.jsxs("g",{fill:"none",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M5.23 9.24h10.71"}),s.jsx("path",{d:"M15.94 6.72 18.77 9.24 15.94 11.76"}),s.jsx("path",{d:"M18.77 14.76H8.06"}),s.jsx("path",{d:"M8.06 12.24 5.23 14.76 8.06 17.28"})]})]}),s.jsxs("div",{children:[s.jsx("h1",{className:"m-0 text-[21px] font-bold tracking-[0.2px]",children:"Agent2API"}),s.jsx("div",{className:"text-[12.5px] text-muted-foreground",children:a("OpenAI 兼容网关 · 管理面板")})]})]}),s.jsx("div",{id:"mode-tip",className:"mb-[18px] text-center text-[13px] text-muted-foreground"}),s.jsxs("form",{id:"form",autoComplete:"on",children:[s.jsx(Ie,{htmlFor:"username",className:"mt-3.5 mb-[5px] text-[12.5px]",children:a("账号")}),s.jsx(Be,{id:"username",autoComplete:"username",placeholder:a("管理员账号")}),s.jsx(Ie,{htmlFor:"password",className:"mt-3.5 mb-[5px] text-[12.5px]",children:a("密码")}),s.jsx(Be,{id:"password",type:"password",autoComplete:"new-password",placeholder:a("至少 8 位")}),s.jsx(m1e,{}),s.jsx(B,{id:"submit",type:"submit",size:"lg",className:"w-full",children:a("继续")}),s.jsx("div",{id:"error",className:"mt-3 min-h-5 text-center text-[13px] whitespace-pre-wrap text-destructive"})]}),s.jsx("div",{className:"mt-[22px] text-center text-[12px] text-muted-foreground",children:a("登录后可在「网关 Key」页为 API 客户端创建密钥")})]})}function v1e(){const e=document.getElementById(p1e);e&&br.flushSync(()=>{wn.createRoot(e).render(s.jsx(g1e,{}))})}v1e();function x1e(e){const t=new URLSearchParams;for(const[n,r]of Object.entries(e))r!==void 0&&r!==""&&t.set(n,typeof r=="boolean"?r?"1":"0":String(r));return t.toString()}function b1e(e){return Array.isArray(e?.groups)?e.groups:(e?.entries||[]).map((t,n)=>({id:t.id??n,firstTs:t.ts??0,lastTs:t.ts??0,count:1,entry:t,entries:[t]}))}function ss(e,t){const n=e.data?.[t];return typeof n=="string"||typeof n=="number"?String(n):""}function Sq(e,t){switch(e){case"debug":return t("调试");case"warn":return t("警告");case"error":return t("错误");default:return t("信息")}}function BS(e,t){switch(e){case"server":return t("服务");case"auth":return t("登录");case"account":return t("账号");case"model":return t("模型");case"upstream":return t("上游");case"config":return t("配置");case"checkin":return t("自动签到");case"maintenance":return t("凭证自动维护");case"update":return t("软件版本检查");case"desensitize":return t("脱敏");case"plugin":return t("插件");default:return e||"—"}}function SP(e,t){return ss(e,"providerLabel")||ss(e,"provider")||ss(e,"component")||BS(e.category,t)}function FS(e,t){const n=ss(e,"summary")||(e.message||"").replace(/^(?:\[[^\]]+\]\s*)+/,"");switch(n){case"计费接口请求":return t("计费接口请求");case"上游接口请求":return t("上游接口请求");case"出站参数归一":return t("出站参数归一");case"补充系统消息":return t("补充系统消息");case"余额查询完成":return t("余额查询完成");case"余额查询未配置":return t("余额查询未配置");case"余额查询失败":return t("余额查询失败");default:return n||"—"}}function y1e(e){const t=[ss(e,"accountName")||ss(e,"account"),ss(e,"model")],n=ss(e,"from"),r=ss(e,"to");(n||r)&&t.push([n,r].filter(Boolean).join(" → "));const i=ss(e,"status");i&&t.push(`HTTP ${i}`);const o=ss(e,"detail");return o&&e.level!=="debug"&&t.push(o),t.filter(Boolean).join(" · ")}function bh(e,t=!1){if(!e)return"—";const n=new Date(e),r=c=>String(c).padStart(2,"0"),i=`${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`;if(t)return i;const o=`${r(n.getMonth()+1)}-${r(n.getDate())}`;return n.getFullYear()===new Date().getFullYear()?`${o} ${i}`:`${n.getFullYear()}-${o} ${i}`}function kq(e){if(e.firstTs===e.lastTs)return bh(e.lastTs);const t=new Date(e.firstTs).toDateString()===new Date(e.lastTs).toDateString();return`${bh(e.firstTs)}–${bh(e.lastTs,t)}`}function w1e(e){return e.map(t=>JSON.stringify(t)).join(`
`)}const Nq="workbuddy-desktop-logs-filters",Cq="workbuddy-desktop-logs-range",Aq="workbuddy-desktop-logs-custom-range",Eq="workbuddy-desktop-logs-view",Tq="workbuddy-desktop-logs-aggregate",Oq={enabled:!0,ms:1e3},Rq=[{value:"today",label:a("今天")},{value:"yesterday",label:a("昨天")},{value:"7",label:a("7 天")},{value:"30",label:a("30 天")},{value:"month",label:a("本月")},{value:"all",label:a("全部")},{value:"custom",label:a("自定义")}],j1e=[{value:"important",label:a("重要事件")},{value:"all",label:a("全部事件")},{value:"debug",label:a("调试详情")}],kP=[{value:"",label:a("全部级别")},{value:"info",label:a("info 及以上")},{value:"warn",label:a("warn 及以上")},{value:"error",label:a("仅 error")}];function Ya(){return window}function Xm(e,t){Ya().wbApp?.toast?.(e,t)}function NP(e){return e instanceof Error?e.message:String(e)}function Pq(){const e=Ya().wbFilterMemory?.load(Nq,{level:"",category:"",keyword:""});let t="important",n="all",r=!0;try{const i=localStorage.getItem(Eq);(i==="all"||i==="debug")&&(t=i);const o=localStorage.getItem(Cq);Rq.some(c=>c.value===o)&&(n=o),r=localStorage.getItem(Tq)!=="0"}catch{}return{view:t,range:n,aggregate:r,dates:xb(Aq),level:kP.some(i=>i.value===e?.level)?e.level:"",category:e?.category||"",keyword:e?.keyword||""}}function Iq(e){IS(Aq,e.dates),Ya().wbFilterMemory?.save(Nq,{level:e.level,category:e.category,keyword:e.keyword.trim()});try{localStorage.setItem(Eq,e.view),localStorage.setItem(Cq,e.range),localStorage.setItem(Tq,e.aggregate?"1":"0")}catch{}}function S1e(e){const t=Number(e?.interval);return!e||!Number.isFinite(t)||t<=0||!["seconds","minutes"].includes(e.unit||"")?Oq:{enabled:e.enabled!==!1,ms:t*(e.unit==="minutes"?6e4:1e3)}}function Sb(e,t={}){return x1e({view:e.view,level:e.view==="debug"?void 0:e.level,category:e.category,keyword:e.keyword.trim(),...QK(e.range,e.dates),...t})}function k1e({groups:e,empty:t,loading:n,listRef:r,onScroll:i,onDetail:o}){return s.jsxs("div",{className:"log-list event-log-list",id:"log-list",ref:r,onScroll:i,"aria-busy":n,children:[s.jsxs("div",{className:"event-log-head","aria-hidden":"true",children:[s.jsx("span",{children:a("时间")}),s.jsx("span",{children:a("级别")}),s.jsx("span",{children:a("来源")}),s.jsx("span",{children:a("事件摘要")}),s.jsx("span",{children:a("次数")}),s.jsx("span",{})]}),e.length?e.map(c=>{const d=c.entry,f=y1e(d);return s.jsxs("div",{className:`event-log-row ${d.level||"info"}`,children:[s.jsxs("time",{className:"event-log-time",dateTime:d.ts?new Date(d.ts).toISOString():void 0,title:kq(c),children:[bh(c.lastTs),c.count>1?s.jsxs("span",{children:[bh(c.firstTs,!0),"–",bh(c.lastTs,!0)]}):null]}),s.jsx("span",{className:`event-log-level ${d.level||"info"}`,children:Sq(d.level,a)}),s.jsx("span",{className:"event-log-source",title:SP(d,a),children:SP(d,a)}),s.jsxs("div",{className:"event-log-message",children:[s.jsx("span",{className:"event-log-summary",title:FS(d,a),children:FS(d,a)}),f?s.jsx("span",{className:"event-log-context",title:f,children:f}):null]}),s.jsx("span",{className:c.count>1?"event-log-count repeated":"event-log-count",title:a("原始记录 {n} 条",{n:c.count}),children:c.count>1?`×${c.count}`:"—"}),s.jsx(B,{variant:"ghost",size:"xs",onClick:()=>o(c),"aria-label":a("查看日志详情:{message}",{message:FS(d,a)}),children:a("详情")})]},c.id)}):s.jsx(zt,{className:"log-empty",children:t})]})}function N1e(e){return[[a("级别"),Sq(e.level,a)],[a("分类"),BS(e.category,a)],[a("来源"),SP(e,a)],[a("提供商"),ss(e,"provider")],[a("账号"),ss(e,"accountName")||ss(e,"account")],[a("模型"),ss(e,"model")],[a("操作"),ss(e,"action")],[a("关联标识"),ss(e,"callId")],[a("状态码"),ss(e,"status")],[a("耗时"),ss(e,"durationMs")?`${ss(e,"durationMs")} ms`:""]].filter(t=>!!t[1])}function C1e({group:e,onClose:t}){const[n,r]=v.useState("detail");if(v.useEffect(()=>r("detail"),[e?.id]),!e)return null;const i=e.entry,o=async()=>{const c=w1e(e.entries);try{const d=Ya().copyToClipboard;if(d){if(!await d(c))throw new Error}else await navigator.clipboard.writeText(c);Xm(a("已复制 {n} 条日志",{n:e.count}),"ok")}catch{Xm(a("复制失败"),"err")}};return s.jsx(St,{open:!0,onOpenChange:c=>{c||t()},children:s.jsxs(kt,{className:"w-[min(860px,calc(100vw-48px))]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("日志详情")})}),s.jsxs(Ct,{children:[s.jsx(bT,{children:FS(i,a)}),s.jsxs("div",{className:"event-log-detail-meta",children:[kq(e)," · ",a("原始记录 {n} 条",{n:e.count})]}),s.jsxs("div",{className:"event-log-detail-tabs",children:[s.jsx(B,{variant:n==="detail"?"secondary":"ghost",size:"sm",onClick:()=>r("detail"),children:a("事件详情")}),s.jsx(B,{variant:n==="raw"?"secondary":"ghost",size:"sm",onClick:()=>r("raw"),children:a("原始记录")})]}),n==="detail"?s.jsxs(s.Fragment,{children:[s.jsx("dl",{className:"event-log-detail-grid",children:N1e(i).map(([c,d])=>s.jsxs("div",{children:[s.jsx("dt",{children:c}),s.jsx("dd",{children:d})]},c))}),ss(i,"detail")?s.jsxs("div",{className:"event-log-detail-block",children:[s.jsx("h3",{children:a("详细信息")}),s.jsx("pre",{children:ss(i,"detail")})]}):null,s.jsxs("div",{className:"event-log-detail-block",children:[s.jsx("h3",{children:a("原始消息")}),s.jsx("pre",{children:i.message||"—"})]}),i.data?s.jsxs("div",{className:"event-log-detail-block",children:[s.jsx("h3",{children:a("附加数据")}),s.jsx("pre",{children:JSON.stringify(i.data,null,2)})]}):null,e.count>1?s.jsxs("div",{className:"event-log-detail-block",children:[s.jsx("h3",{children:a("发生时间")}),s.jsx("div",{className:"event-log-occurrences",children:e.entries.map((c,d)=>s.jsx("span",{children:bh(c.ts)},c.id??d))})]}):null]}):s.jsx("div",{className:"event-log-detail-block",children:s.jsx("pre",{children:e.entries.map(c=>JSON.stringify(c,null,2)).join(`
-`)})})]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"outline",onClick:()=>{o()},children:a("复制原始记录")}),s.jsx("div",{className:"spacer"}),s.jsx(B,{variant:"ghost",onClick:t,children:a("关闭")})]})]})})}let Nd=null,US=null,Mq=null,CP=Oq;function _q(e){Mq=e,Ya().wbApp?.updateLogsBadge?.(e)}function Dq(e){CP=S1e(e),Nd?.applyAutoConfig(CP)}function A1e(){const[e,t]=v.useState({entries:[],groups:[],total:0,matched:0,grouped:0}),[n,r]=v.useState(!1),[i,o]=v.useState(Pq),[c,d]=v.useState(1),[f,h]=v.useState(()=>Number(W0("logs",rh))),[p,g]=v.useState(CP),[x,y]=v.useState(!1),[j,w]=v.useState(!1),[S,N]=v.useState(0),[A,E]=v.useState(null),[O,R]=v.useState(!1),[T,P]=v.useState(""),[M,_]=v.useState(null),I=v.useRef(null),L=v.useRef({filters:i,page:c,size:f,data:e,paused:x,detail:A});L.current={filters:i,page:c,size:f,data:e,paused:x,detail:A};const D=v.useRef(void 0),z=v.useRef(0),G=v.useRef(!1),X=v.useRef(!1),Y=v.useRef(!1),F=v.useRef(!1),K=v.useRef(!1),U=v.useRef(void 0),q=v.useRef(null),W=v.useCallback(async()=>{if(!Y.current)try{const ae=await Ya().workbuddyDesktop?.getScheduledTasks();Array.isArray(ae?.tasks)&&(Y.current=!0,Dq(ae.tasks.find(_e=>_e.id==="logsAutoRefresh")||null))}catch{}},[]),ne=v.useCallback(async(ae={})=>{if(W(),!F.current&&Ya().wbFilterMemory&&(F.current=!0,!K.current)){const Re=Pq();L.current.filters=Re,o(Re)}const _e=L.current;(ae.resetPage||ae.latest)&&(_e.page=1,d(1),D.current=void 0),ae.latest&&(_e.paused=!1,y(!1),w(!1),I.current&&(I.current.scrollTop=0));const de=++z.current,Se=_e.page,ve=_e.size,xe=_e.filters;ae.silent||R(!0);try{const Re=Ya().workbuddyDesktop;if(!Re)throw new Error(a("后端桥不可用"));const we=!ae.latest&&!ae.resetPage&&(Se>1||_e.paused||_e.detail!==null||(I.current?.scrollTop||0)>20),[ge,De]=await Promise.all([Re.getLogs(Sb(xe,{aggregate:xe.aggregate,offset:(Se-1)*ve,limit:ve,untilId:we?D.current:void 0})),Re.getLogStats()]);if(de!==z.current)return;if(!ge)throw new Error(a("读取日志失败"));const Ge=Number(ge.grouped??ge.matched??ge.entries?.length)||0,Ot=Math.max(1,Math.ceil(Ge/ve));if(Se>Ot){L.current.page=Ot,d(Ot),await ne(ae);return}const sn=L.current.paused||L.current.detail!==null||(I.current?.scrollTop||0)>20;if(ae.silent&&!we&&sn&&D.current!==void 0){const $t=await Re.getLogs(Sb(L.current.filters,{sinceId:D.current,limit:1}));de===z.current&&N(Number($t?.matched)||0);return}if(q.current=ae.resetPage||ae.latest||!ae.silent?0:I.current?.scrollTop||0,L.current.data=ge,t(ge),r(!0),P(""),(!we||D.current===void 0)&&(D.current=Number(ge.lastId??De?.lastId)||0,N(0)),_q(De),xe.category&&ge.categories&&!Object.hasOwn(ge.categories,xe.category)){const $t={...L.current.filters,category:""};L.current.filters=$t,o($t),Iq($t),await ne({resetPage:!0})}}catch(Re){de===z.current&&P(NP(Re))}finally{de===z.current&&R(!1)}},[W]),ie=v.useCallback(async()=>{if(!(G.current||X.current||U.current!==void 0)){G.current=!0;try{const ae=L.current;if((ae.paused||ae.detail!==null||ae.page>1||(I.current?.scrollTop||0)>20)&&D.current!==void 0){const de=Ya().workbuddyDesktop;if(!de)return;const Se=D.current,ve=ae.filters,[xe,Re]=await Promise.all([de.getLogs(Sb(ve,{sinceId:Se,limit:1})),de.getLogStats()]);if(ve!==L.current.filters||Se!==D.current)return;Re?.lastId!==void 0&&Re.lastId{K.current=!0;const de={...L.current.filters,...ae};L.current.filters=de,o(de),U.current!==void 0&&window.clearTimeout(U.current),++z.current,R(!0);const Se=()=>{U.current=void 0,Iq(de),N(0),ne({resetPage:!0})};_e?U.current=window.setTimeout(Se,300):Se()},[ne]);v.useEffect(()=>{if(Nd={load:ne,render:ae=>{ae&&(L.current.data=ae,t(ae),r(!0))},showCategory:async ae=>{V({category:ae,view:"important"}),Ya().wbApp?.showPage?.("logs",{persist:!0})},applyAutoConfig:ae=>{Y.current=!0,g(ae)}},US!==null){const ae=US;US=null,Nd.showCategory(ae)}else ne({silent:!0});return()=>{Nd=null,++z.current,U.current!==void 0&&window.clearTimeout(U.current)}},[V,ne]),v.useEffect(()=>{if(!p.enabled)return;const ae=window.setInterval(()=>{!document.hidden&&Ya().wbApp?.currentPage==="logs"&&ie()},p.ms);return()=>window.clearInterval(ae)},[p,ie]),v.useLayoutEffect(()=>{q.current!==null&&(I.current&&(I.current.scrollTop=q.current),q.current=null)});const H=b1e(e),Q=Number(e.grouped??e.matched??H.length)||0,J=Number(e.matched)||0,oe=Math.max(1,Math.ceil(Q/f)),ee=a("{n} 条",{n:J});v.useEffect(()=>{Ya().wbApp?.renderTopbarStatus?.()},[ee]);function se(ae){L.current.page=Math.max(1,Math.min(ae,oe)),d(L.current.page),w(!1),I.current&&(I.current.scrollTop=0),ne()}function le(ae){const _e=Number(ae),de=(L.current.page-1)*L.current.size;L.current.size=_e,L.current.page=Math.floor(de/_e)+1,h(_e),d(L.current.page),X0("logs",_e),ne()}async function te(ae,_e){if(!X.current){X.current=!0,_(ae);try{await _e()}catch(de){Xm(a("操作失败:{error}",{error:NP(de)}),"err")}finally{X.current=!1,_(null)}}}async function re(){if(X.current||O||T||!J)return;const ae=Sb(L.current.filters,{untilId:D.current});await Ya().wbConfirm?.ask?.({title:a("清空运行日志"),html:a("确定清空当前筛选出的 {count} 条日志?清空后无法恢复。",{count:J}),okText:a("清空"),okClass:"danger"})&&await te("clear",async()=>{const de=Ya().workbuddyDesktop;if(!de)throw new Error(a("后端桥不可用"));await de.clearLogs(ae),await ne({resetPage:!0}),Xm(a("运行日志已清空"),"ok")})}async function he(){await te("export",async()=>{const ae=Ya().workbuddyDesktop;if(!ae)throw new Error(a("后端桥不可用"));const _e=await ae.exportLogs(Sb(L.current.filters,{untilId:D.current}));if(!(!_e||_e.canceled)){if(_e.count===0){Xm(a("暂无日志可导出"),"err");return}Xm(a("✅ 已导出 {count} 条日志到 {file}",{count:String(_e.count),file:String(_e.file)}),"ok")}})}const pe=x||j||c>1||A!==null,Ne=kP.find(ae=>ae.value===i.level)?.label||a("全部级别"),me=e.byLevel||{},ce=!n&&!T?a("正在加载日志…"):Number(e.total)?a("没有符合筛选条件的日志"):a("暂无日志");return s.jsxs(tt,{render:s.jsx("section",{}),className:"panel",id:"logs-panel-events",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsx("h2",{children:a("系统事件")}),s.jsx(ye,{id:"logs-badge",variant:"outline","data-tone":"",children:n?ee:"—"}),s.jsxs("div",{className:"head-actions",children:[s.jsx(B,{variant:"ghost",disabled:M!==null,onClick:()=>{const ae=!L.current.paused;L.current.paused=ae,y(ae),!ae&&!j&&c===1&&!A&&ne({latest:!0})},children:a(x?"恢复刷新":"暂停刷新")}),s.jsx(B,{id:"btn-logs-export",variant:"outline",disabled:M!==null||O||!!T,onClick:()=>{he()},children:a(M==="export"?"导出中…":"导出当前筛选")}),s.jsx(B,{id:"btn-logs-clear",variant:"destructive",disabled:M!==null||O||!!T||!J,onClick:()=>{re()},children:a(M==="clear"?"清空中…":"清空当前筛选")})]})]}),s.jsxs(Ft,{className:"panel-body",children:[s.jsxs("div",{className:"event-log-toolbar",children:[s.jsx(dn,{options:j1e,value:i.view,onValueChange:ae=>V({view:ae}),"aria-label":a("日志视图")}),s.jsx("span",{className:"event-log-status",children:pe?a("阅读模式,列表保持不动"):p.enabled?a("自动刷新"):a("自动刷新已关闭")}),s.jsxs(Ie,{className:"event-log-aggregate",children:[s.jsx(cn,{checked:i.aggregate,onCheckedChange:ae=>V({aggregate:ae}),"aria-label":a("折叠重复日志")}),a("折叠重复日志")]})]}),s.jsxs("div",{className:"log-filters",children:[s.jsx(dn,{options:Rq,value:i.range,onValueChange:ae=>V({range:ae}),"aria-label":a("事件日志时间范围"),className:"shrink-0"}),i.range==="custom"?s.jsx(pP,{dates:i.dates,onChange:ae=>V({dates:ae}),onClear:()=>V({range:"all"})}):null,i.view!=="debug"?s.jsxs(ht,{value:i.level,onValueChange:ae=>V({level:String(ae??"")}),children:[s.jsx(mt,{className:"min-w-[120px]","aria-label":a("按最低级别筛选"),children:s.jsx(pt,{children:Ne})}),s.jsx(gt,{children:kP.map(ae=>s.jsx(qe,{value:ae.value,children:ae.label},ae.value))})]}):null,s.jsxs(ht,{value:i.category,onValueChange:ae=>V({category:String(ae??"")}),children:[s.jsx(mt,{className:"min-w-[120px]","aria-label":a("按分类筛选"),children:s.jsx(pt,{children:i.category?BS(i.category,a):a("全部分类")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("全部分类")}),Object.keys(e.categories||{}).map(ae=>s.jsx(qe,{value:ae,children:BS(ae,a)},ae))]})]}),s.jsxs(uo,{className:"w-auto flex-auto",children:[s.jsx(ho,{type:"search",placeholder:a("搜索消息、提供商或账号…"),"aria-label":a("搜索消息、提供商或账号"),autoComplete:"off",value:i.keyword,onChange:ae=>V({keyword:ae.currentTarget.value},!0)}),s.jsx(fo,{"aria-hidden":"true",children:"⌕"})]})]}),s.jsxs("div",{className:"event-log-overview",children:[s.jsx("span",{children:a("显示 {groups} 组 · 原始记录 {entries} 条",{groups:Q,entries:J})}),s.jsx("span",{className:"event-log-errors",children:a("错误 {n}",{n:me.error||0})}),s.jsx("span",{className:"event-log-warnings",children:a("警告 {n}",{n:me.warn||0})}),i.view!=="important"?s.jsx("span",{children:a("调试 {n}",{n:me.debug||0})}):null]}),i.view==="debug"&&!e.debugEnabled?s.jsx("div",{className:"event-log-note",children:a("调试采集未开启,仅显示已保留的记录。可在设置中开启调试模式。")}):null,T?s.jsxs("div",{className:"event-log-error",role:"status",children:[T,s.jsx(B,{variant:"ghost",size:"xs",onClick:()=>{ne()},children:a("重试")})]}):null,S>0||pe&&!x?s.jsxs("div",{className:"event-log-new",role:"status",children:[s.jsx("span",{children:S?a("有 {n} 条新日志",{n:S}):a("阅读模式,列表保持不动")}),s.jsx(B,{variant:"outline",size:"sm",disabled:O,onClick:()=>{ne({latest:!0})},children:a("查看最新")})]}):null,s.jsx(k1e,{groups:H,empty:ce,loading:O,listRef:I,onScroll:()=>w((I.current?.scrollTop||0)>20),onDetail:ae=>{L.current.detail=ae,E(ae)}})]}),s.jsx(fd,{total:Q,page:c,pageCount:oe,size:f,sizes:rh,disabled:O||M!==null,range:{start:H.length?(c-1)*f+1:0,end:(c-1)*f+H.length},leading:s.jsx("span",{className:"event-log-footer-note",children:a("分页按折叠后的组数计算")}),onSizeChange:le,onPageChange:se}),s.jsx(C1e,{group:A,onClose:()=>{L.current.detail=null,E(null)}})]})}async function E1e(e={}){await Nd?.load(e)}function T1e(e){Nd?.render(e)}function O1e(){return Mq}async function R1e(e){if(!Nd){US=e;return}await Nd.showCategory(e)}function Lq(){const e=document.querySelector('.page[data-page="logs"]');e&&(e.replaceChildren(),wn.createRoot(e).render(s.jsx(A1e,{})))}document.querySelector('.page[data-page="logs"]')?Lq():document.addEventListener("DOMContentLoaded",Lq,{once:!0}),window.wbLogsPanel={load:E1e,render:T1e,lastStats:O1e,applyAutoRefresh:Dq,showCategory:R1e};const No="__custom__",P1e=["off","none","minimal","low","medium","high","xhigh","max"];function kb(e,t){const n=zq(t);if(n.length)return n;const r=e?.reasoningLevels;return Array.isArray(r)&&r.length?r.filter(i=>typeof i=="string"):[...P1e]}function zq(e){const t=e?.reasoningLevels;return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.trim()!==""):[]}function I1e(e,t){const n=t.map(zq).filter(c=>c.length>0);if(!n.length||n.length!==t.length)return kb(e);const[r,...i]=n,o=r.filter(c=>i.every(d=>d.includes(c)));return o.length?o:kb(e)}function $q(e,t,n){return`${String(e??"").trim().toLowerCase()}${String(t??"").trim().toLowerCase()}${String(n??"").trim().toLowerCase()}`}function M1e(e){const t=new Map;for(const n of Array.isArray(e)?e:[]){const r=typeof n?.reasoning=="string"?n.reasoning.trim():"";r&&t.set($q(n.alias,n.target,n.provider),r)}return(n,r,i)=>t.get($q(n,r,i))||""}function Zn(){return window}function Cd(e){return e instanceof Error?e.message:String(e)}function Ia(e,t){Zn().wbApp?.toast?.(e,t)}function AP(e){const t=Zn().wbApp?.esc;return t?t(e):String(e??"").replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n]||n)}function _1e(e){const t=Zn().formatTime??Zn().wbApp?.formatTime;return String(t?.(e)??"")}const Bq=e=>String(e??"").trim().toLowerCase(),Ad=(e,t)=>Bq(e)===Bq(t),Fq=8,Uq="workbuddy-desktop-models-filters",EP=["all","enabled","disabled","mapped"],D1e={all:a("全部"),enabled:a("已启用"),disabled:a("已禁用"),mapped:a("有映射")},L1e=EP.map(e=>({value:e,label:D1e[e]})),TP=["default","rate-asc","rate-desc"],z1e={default:a("默认"),"rate-asc":a("倍率升序"),"rate-desc":a("倍率降序")},$1e=TP.map(e=>({value:e,label:z1e[e]})),OP=["all","visible","hidden","undeclared"],B1e={all:a("全部"),visible:a("可见"),hidden:a("不展示"),undeclared:a("未声明")},F1e=OP.map(e=>({value:e,label:B1e[e]}));function Hq(e){const t=typeof e.visibility=="string"?e.visibility.trim().toLowerCase():"";return t==="hidden"?"hidden":t==="shown"||t==="visible"?"visible":"undeclared"}const RP=[{key:"check",label:a("选择"),align:"center"},{key:"model",label:a("上游模型")},{key:"rate",label:a("倍率")},{key:"visibility",label:a("可见性")},{key:"source",label:a("来源")},{key:"budget",label:a("上下文 / 输出")},{key:"caps",label:a("能力")},{key:"alias",label:a("模型映射")},{key:"act",label:a("操作"),align:"right"}],Vq=new Set(["rate","source","visibility"]),PP={models:[],mappings:[]},Kq={provider:"all",state:"all",search:"",sort:"default",visibility:"visible"};function qq(){const e=Zn().wbFilterMemory;if(!e)return{...Kq};const t=e.load(Uq,{...Kq});return{provider:String(t.provider||"all"),state:EP.includes(t.state)?t.state:"all",search:String(t.search||""),sort:TP.includes(t.sort)?t.sort:"default",visibility:OP.includes(t.visibility)?t.visibility:"visible"}}const Nb=qq();let Gq=!!Zn().wbFilterMemory,Cb=!1,Er={provider:Nb.provider,stateFilter:Nb.state,visibilityFilter:Nb.visibility,search:Nb.search,sort:Nb.sort,data:null,expanded:new Set,pending:new Set,mapping:null,customModel:null,capability:null};const IP=new Set;function Ab(){return Er}function U1e(e){return IP.add(e),()=>{IP.delete(e)}}function $s(e){const t={...Er,...e},n=HS(t),r=HS(Er)!==n;Er=n===t.provider?t:{...t,provider:n},V1e(),r&&KS();for(const i of IP)i()}function Eb(e){Zn().wbFilterMemory?.save(Uq,e)}function Yq(){if(Gq||Cb||!Zn().wbFilterMemory)return;Gq=!0;const e=qq();(e.provider!==Er.provider||e.state!==Er.stateFilter||e.search!==Er.search||e.sort!==Er.sort||e.visibility!==Er.visibilityFilter)&&$s({provider:e.provider,stateFilter:e.state,search:e.search,sort:e.sort,visibilityFilter:e.visibility})}function HS(e){const t=e.provider;return t==="all"||t===Ra||gd().some(n=>n.id===t)||e.data?.providers?.some(n=>n.provider===t)||Array.isArray(e.data?.models)&&e.data.models.some(n=>(n.provider||"")===t)||!e.data||!MP()?t:"all"}function Qm(){return HS(Er)}function MP(){return!!Zn().wbProviders}function Zm(){return Qm()===Ra}function Wq(){return Zm()||ts(Qm())}let Tb=null;function _P(e){const t=vd(e);return(!Tb||Tb.id!==e||Tb.record!==t)&&(Tb={id:e,record:t,view:yR(e)||PP}),Tb.view}let Ob=null;function H1e(){const e=pV();if(Ob&&Ob.directory===e)return Ob.view;const t=[],n=[];for(const r of gd()){const i=_P(String(r.id||""));t.push(...i.models||[]),n.push(...i.mappings||[])}return Ob={directory:e,view:t.length||n.length?{models:t,mappings:n}:PP},Ob.view}function DP(){const e=Qm();return e===Ra?H1e():ts(e)?_P(e):Er.data||PP}function Rb(){const e=DP();return Array.isArray(e.models)?e.models:[]}function Xq(){const e=DP();return Array.isArray(e.mappings)?e.mappings:[]}let Qq=(e,t,n)=>"";function V1e(){Qq=M1e(Xq())}function VS(){const e=new Map;for(const n of Er.data?.providers||[])n.provider&&e.set(n.provider,{label:n.providerLabel||n.provider,n:0});const t=Array.isArray(Er.data?.models)?Er.data.models:[];for(const n of t){const r=n.provider||"";if(!r)continue;const i=e.get(r)||{label:n.providerLabel||r,n:0};i.n++,e.set(r,i)}return e}function K1e(){const e=new Map;for(const t of gd()){const n=String(t.id||"");if(!n)continue;const r=_P(n);e.set(n,{label:String(t.name||n),n:(r.models||[]).length})}return e}function q1e(){return[...VS().keys()]}function G1e(e){const t=Er.data?.providers?.find(i=>i.provider===e);if(t)return Number(t.refreshedAt)||0;const r=(Array.isArray(Er.data?.models)?Er.data.models:[]).find(i=>i.provider===e);return Number(r?.refreshedAt)||0}function LP(){const e=new Map;for(const t of Rb()){const n=t.provider||"";n&&!e.has(n)&&e.set(n,a(t.providerLabel||n))}return[...e].map(([t,n])=>({id:t,label:n}))}function Zq(e){return e?Rb().filter(t=>(t.provider||"")===e).sort((t,n)=>+(t.enabled===!1)-+(n.enabled===!1)).map(t=>({id:t.id,label:t.name&&t.name!==t.id?a("{id}({name})",{id:t.id,name:t.name}):t.id,off:t.enabled===!1})):[]}function Y1e(){const e=[],t=Zn().wbProviders?.all?.();if(Array.isArray(t))for(const n of t){const r=String(n?.id||"");r&&e.push({id:r,label:a(String(n?.label||r))})}for(const n of gd()){const r=String(n.id||"");r&&e.push({id:r,label:String(n.name||r)})}return e.length?e:LP()}let Pb=null,zP=null;function Jq(){const e=Pb?Pb.apply(RP):RP;return Wq()?e.filter(t=>!Vq.has(t.key)):e}function KS(){Zn().wbColSettings?.syncStaticHead("models",zP,Wq()?Vq:null)}function W1e(){if(Pb)return;Pb=Zn().wbColSettings?.register({id:"models",label:a("模型管理表"),columns:RP,mount:()=>document.querySelector('.page[data-page="gateway"] .panel-head .head-actions'),buttonPlacement:"last",onChange:()=>{KS(),yh()}})||null,Pb&&yh()}let qS=0,$P=!1;async function GS({force:e=!1}={}){if($P&&!e)return;const t=++qS;$P=!0,Yq();try{const n=await Zn().workbuddyDesktop?.getModelManage();if(t!==qS)return;$s({data:n&&Array.isArray(n.models)?n:null})}catch(n){if(t!==qS)return;yh(),Ia(a("读取模型清单失败:{message}",{message:Cd(n)}),"err")}finally{t===qS&&($P=!1)}}async function e8(){try{await Zn().wbProviders?.refreshCustom?.()}catch{}await GS({force:!0})}function yh(){$s({})}function wh(e){const t=e;if(t&&Array.isArray(t.models)){$s({data:t});return}yh()}async function YS(e,t,n,r){if(ts(e))return gV(e,t,n,r);const i=Zn().workbuddyDesktop;if(!i)throw new Error(a("后端桥不可用"));return i.addModelMapping(t,n,e,r.reasoning,r.enabled)}async function X1e(e,t,n){if(ts(e))return vV(e,t,n);const r=Zn().workbuddyDesktop;if(!r)throw new Error(a("后端桥不可用"));return r.removeModelMapping(t,n,e)}async function Q1e(e,t){if(ts(e))return xV(e,t);const n=Zn().workbuddyDesktop;if(!n)throw new Error(a("后端桥不可用"));return n.addCustomModel(e,t)}async function t8(e,t){if(ts(e))return yV(e,t);const n=Zn().workbuddyDesktop;if(!n)throw new Error(a("后端桥不可用"));return n.removeCustomModel(e,t)}async function Z1e(e,t,n){if(ts(e))return bV(e,t,n);const r=Zn().workbuddyDesktop;if(!r)throw new Error(a("后端桥不可用"));return r.setModelCapabilities(e,t,n)}async function BP(e,t,n){if(!Er.pending.has(e)){$s({pending:new Set(Er.pending).add(e)});try{wh(await t()),n&&Ia(n)}catch(r){Ia(a("操作失败:{message}",{message:Cd(r)}),"err")}finally{const r=new Set(Er.pending);r.delete(e),$s({pending:r})}}}function Ib(e){return Jm(e).some(t=>t.enabled!==!1)}function Jm(e){const t=e.provider||"",n=Xq().filter(d=>Ad(d.target,e.id)&&(!d.provider||Ad(d.provider,t))),r=new Map;for(const d of n){const f=String(d.alias).toLowerCase();(!r.has(f)||d.provider)&&r.set(f,d)}const i=String(e.id).toLowerCase(),o=r.get(i);r.delete(i);const c=[{alias:e.id,target:e.id,provider:t,enabled:e.enabled!==!1&&o?.enabled!==!1,isDefault:!0}];return c.push(...r.values()),c}const jh=e=>`${e.provider||""}:${e.id}`,FP=(e,t,n)=>`${e}:${t}:${n||""}`;function J1e(e){$s({expanded:new Set(Er.expanded).add(e)})}function eCe(e){const t=new Set(Er.expanded);t.delete(e),$s({expanded:t})}function n8(e){const t=EP.includes(e)?e:"all";t!==Er.stateFilter&&(Cb=!0,$s({stateFilter:t}),Eb({state:t}))}function r8(e){const t=TP.includes(e)?e:"default";t!==Er.sort&&(Cb=!0,$s({sort:t}),Eb({sort:t}))}function s8(e){const t=OP.includes(e)?e:"visible";t!==Er.visibilityFilter&&(Cb=!0,$s({visibilityFilter:t}),Eb({visibility:t}))}function a8(e){Cb=!0,$s({search:e}),Eb({search:e})}function Mb(e){$s({provider:String(e??"").trim()||"all"}),Eb({provider:Er.provider}),KS()}async function tCe(e){const t=Zn().wbCustomProvidersUi;if(!t?.remove){Ia(a("删除入口未就绪,请重试或重启应用"),"err");return}await t.remove(e)&&await GS({force:!0})}function nCe(){Zn().wbAccountAddForms?.openNewCustomForm?.()}function i8(e){$s({mapping:e})}function rCe(){$s({mapping:null})}function sCe(){const e=Qm(),t=ts(e);$s({customModel:{provider:t||e!=="all"&&e!==Ra?e:"",locked:t}})}function aCe(){$s({customModel:null})}function o8(e,t){$s({capability:{provider:e,id:t}})}function iCe(){$s({capability:null})}function l8(e,t){return Rb().find(n=>(n.provider||"")===e&&Ad(n.id,t))||null}function UP(e){if(ts(e)){const t=vd(e)?.name;return typeof t=="string"&&t||e}return a(Zn().wbProviders?.labelOf?.(e)||e)}function c8(){const e=Qm(),t=ts(e),n=t?vd(e)?.name||e:a("内置提供商");Zn().wbModelsFetchModal?.open({providerId:e===Ra?"":e,custom:t,name:n,onDone:()=>yh(),onRefreshed:()=>{GS({force:!0})}})}window.wbModelsPanel={render:yh,load:GS,refreshAll:e8,refreshModels:c8,visibleColumns:Jq,selectProvider:Mb,builtinProviders:q1e,providerRefreshedAt:G1e};function HP(e,t,n){return Qq(e,t,n)}function oCe(e){zP=e}function lCe(){const e=zP;if(!e)return;const t=r=>Object.keys(r).some(i=>i.startsWith("__reactFiber$")||i.startsWith("__reactInternalInstance$"));for(const r of[...e.children])r.tagName==="TBODY"?r.id!=="models"&&r.remove():r.tagName==="TR"&&!t(r)&&r.remove();const n=e.querySelector("tbody#models");if(n)for(const r of[...n.children])t(r)||r.remove()}const cCe=e=>[{value:"inherit",label:e},{value:"on",label:a("支持")},{value:"off",label:a("不支持")}];function uCe(e){const t=bR(e);return a(t==="on"?"支持":t==="off"?"不支持":"未声明")}function u8(e,t,n,r,i=""){const o=t!=null,c=ib.includes(e)?ob(t):uCe(t);return n?r?a("已填写:对下游声明 {value}",{value:c}):a("已覆盖:对下游声明 {value}",{value:c}):r?a("未填写(下游按未声明处理)"):o?i==="modelsdev"?a("models.dev 补齐:对下游声明 {value}",{value:c}):a("继承上游:{value}",{value:c}):a("上游未声明(下游会按不支持处理)")}function dCe(e,t,n){return n?$m.filter(r=>{const i=e[r];return i!=null}):t}function fCe(e,t){const n={};for(const r of $m){const i=t.includes(r),o=e[r];ib.includes(r)?n[r]=i&&typeof o=="number"?String(o):"":n[r]=i?o===!0?"on":"off":"inherit"}return n}function hCe({context:e,onClose:t}){const n=ts(e.provider),r=l8(e.provider,e.id),i=fV(r),o=sS(r),c=dCe(o,xR(r?.capOverrides),n),[d,f]=v.useState(()=>fCe(o,c)),[h,p]=v.useState(""),[g,x]=v.useState(!1);if(!r)return s.jsx(St,{open:!0,onOpenChange:R=>{R||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("模型能力")})}),s.jsx(Ct,{children:s.jsx("p",{className:"text-sm leading-[1.7] text-subtle",children:a("这一行已不在当前清单里(模型被移除、或目录刷新后上游不再提供它)。关闭后刷新列表再试。")})}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const y=r.id,j=r.providerLabel||UP(e.provider),w=a(n?"未声明":"继承上游"),S=a(n?"清除":"恢复继承");function N(R){const T=o[R];return A(R)?"":n?a("未填写"):typeof T=="number"?a("继承上游 {value}",{value:ob(T)}):a("上游未声明")}function A(R){return c.includes(R)}function E(R,T){f(P=>({...P,[R]:T}))}async function O(){if(!g){for(const R of ib){const T=d[R].trim();if(T&&vR(R,T)===null){p(a("{label}要填 1 ~ 1 亿之间的整数(留空 = {inherit})",{label:Bm[R],inherit:w}));return}}x(!0),p(a("保存中…"));try{wh(await Z1e(e.provider,e.id,a0e(d))),t(),Ia(a("✅ 已保存 {id} 的能力位({provider})",{id:y,provider:j}))}catch(R){p(a("保存失败:{message}",{message:Cd(R)})),x(!1)}}}return s.jsx(St,{open:!0,onOpenChange:(R,T)=>{if(!R){if(g){T.cancel();return}t()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("模型能力")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 font-mono text-[12px] text-subtle",children:[s.jsx("b",{className:"text-primary-fg",children:r.id}),a("({provider})",{provider:j})]}),ib.map(R=>s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-[7px]",children:[s.jsx(Ie,{htmlFor:`cap-${R}`,children:Bm[R]}),A(R)?s.jsx(B,{variant:"ghost",size:"2xs",disabled:g,title:a(n?"清除这一项(回到未声明)":"清除覆盖,回到上游声明值"),onClick:()=>E(R,""),children:S}):null]}),s.jsx(Be,{id:`cap-${R}`,inputMode:"numeric",autoComplete:"off",spellCheck:!1,placeholder:N(R),disabled:g,value:d[R],onChange:T=>E(R,T.currentTarget.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),O())}}),s.jsx("p",{className:"text-xs leading-[1.6] text-subtle",children:u8(R,o[R]??null,A(R),n,Fm(r,R))})]},R)),cV.map(R=>s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{children:Bm[R]}),s.jsx(dn,{options:cCe(w),value:d[R],"aria-label":Bm[R],className:"self-start",onValueChange:T=>E(R,String(T))}),s.jsx("p",{className:"text-xs leading-[1.6] text-subtle",children:u8(R,o[R]??null,A(R),n,Fm(r,R))})]},R)),i?s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 text-xs leading-[1.7] text-subtle",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{children:a("可配思考档位")}),s.jsx("span",{className:"font-mono text-[12px] text-primary-fg",children:i.levels.join(" / ")}),i.defaultLevel?s.jsxs("span",{children:[a("(默认 "),s.jsx("span",{className:"font-mono text-[12px] text-primary-fg",children:i.defaultLevel}),a(")")]}):null]}),s.jsx("div",{className:"mt-1",children:a("这是模型自己能配的档位(来自上游目录),只读;要改某一档请到映射弹窗里选。")})]}):null,s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("这几项是给"),s.jsx("b",{children:a("下游客户端")}),a("看的能力声明("),s.jsx("code",{children:"/v1/models"}),a(" 里的 "),s.jsx("code",{children:"max_input_tokens"})," / ",s.jsx("code",{children:"supports_*"}),a(" 与 "),s.jsx("code",{children:"input_modalities"}),a("),下游按它们决定发不发图片、按多大的窗口堆历史。"),s.jsx("b",{children:a("不影响网关的转发与路由")}),a("。上游清单给的值不准时,在这里改;"),a(n?"这家的清单是你自己登记的,不填的项下游按未声明处理。":"「恢复继承」会把这一项交还给上游清单的值。")]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:h})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:g,onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:g,onClick:()=>{O()},children:a("保存")})]})]})})}function d8(e){if(e.transport||!e.result||e.result.error)return!1;const t=Number(e.result.status)||0;return t>=200&&t<300}function VP(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"—":t<1e3?`${Math.round(t)} ms`:`${(t/1e3).toFixed(t<1e4?2:1)} s`}const pCe={chat_completions:"Chat Completions",responses:"Responses",anthropic:"Anthropic Messages"},mCe=[{test:e=>e===429,hint:a("该账号对这个模型正在限额冷却,等一会儿自己会好;也可以先测别的账号。")},{test:e=>e===401||e===403,hint:a("上游拒绝了这条登录态:重新登录一次,或把这条账号删掉。")},{test:e=>e===404,hint:a("上游不认识这个模型名:先点「获取模型」刷新清单,或核对默认绑定指向的上游模型。")},{test:e=>e===504,hint:a("上游没在预算内给完回答。可以只勾一个账号再测一次,看是普遍慢还是某一个账号慢。")},{test:e=>e>=500,hint:a("多半是上游自己的问题,过一会儿再试。同一个错误出现在所有账号上时,先查模型目录与映射。")}];function gCe({slot:e,model:t,now:n,expanded:r,onToggle:i}){const o=(p,g)=>s.jsxs("div",{className:"flex items-center gap-2.5 border-b border-hairline px-3 py-2",children:[p,s.jsx("b",{className:"min-w-0 truncate text-[12.5px] text-foreground",title:e.label,children:e.label}),e.position?s.jsxs("span",{className:"flex-none text-xs text-subtle",children:["#",e.position]}):null,s.jsx("span",{className:"ml-auto flex-none font-mono text-[11.5px] tabular-nums text-subtle",children:g})]});if(e.state==="running")return s.jsxs("div",{className:"flex items-center gap-2.5 rounded-md border border-border bg-surface-2 px-3 py-2.5 text-xs text-subtle",children:[s.jsx(Ls,{className:"flex-none"}),s.jsxs("span",{className:"min-w-0 truncate",children:[a("账号 "),s.jsx("b",{className:"text-foreground",children:e.label}),a(" 已发出,等待上游首帧…")]}),s.jsx("span",{className:"ml-auto flex-none font-mono tabular-nums",children:a("已等待 {seconds}s",{seconds:((n-e.startedAt)/1e3).toFixed(1)})})]});const c=e.result;if(!d8(e)){const p=Number(c?.status)||0,g=mCe.find(x=>x.test(p))?.hint??(e.transport?a("确认桌面端还在运行,再重试一次。"):"");return s.jsxs("div",{className:"rounded-md border border-border bg-surface-2",children:[o(s.jsx(ye,{shape:"tag",variant:"destructive",className:"flex-none",children:p||a("失败")}),a("用时 {time}",{time:VP(c?.duration_ms)})),s.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2.5",children:[s.jsxs("div",{className:"text-[12.5px] leading-[1.7]",children:[e.transport?s.jsxs(s.Fragment,{children:[s.jsx("b",{className:"text-destructive",children:a("本机网关没有返回结论")}),a(":"),e.transport]}):s.jsxs(s.Fragment,{children:[s.jsx("b",{className:"text-destructive",children:a("测试未通过")}),a(":"),c?.error||a("上游没有给出可读的错误说明")]}),Number(c?.attempts)>1?a("(中间共尝试 {n} 次)",{n:Number(c?.attempts)}):""]}),g?s.jsx("p",{className:"text-xs leading-[1.65] text-subtle",children:g}):null]})]})}const d=String(c?.reply??""),f=String(c?.reasoning??""),h=[c?.upstream_model&&c.upstream_model!==t?a("上游 {model}",{model:c.upstream_model}):"",c?.upstream_reasoning?a("思考等级 {level}",{level:c.upstream_reasoning}):"",c?.protocol&&c.protocol!=="chat_completions"?pCe[c.protocol]||c.protocol:"",c?.proxy?a("节点 {proxy}",{proxy:c.proxy}):"",c?.apiKeyName?`API Key: ${c.apiKeyName}`:"",Number(c?.attempts)>1?a("尝试 {n} 次",{n:Number(c?.attempts)}):""].filter(Boolean).join(" · ");return s.jsxs("div",{className:"rounded-md border border-border bg-surface-2",children:[o(s.jsx(ye,{shape:"tag",variant:"success",className:"flex-none",children:Number(c?.status)||200}),a("用时 {time} · 首字 {ttfb}",{time:VP(c?.duration_ms),ttfb:VP(c?.ttfb_ms)})),s.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11.5px] text-subtle",children:[s.jsx("span",{className:"flex-none",children:a("回复")}),h?s.jsx("span",{className:"min-w-0 truncate",title:h,children:h}):null,s.jsx(B,{variant:"ghost",size:"2xs",className:"ml-auto flex-none","data-copy":d,children:a("复制")})]}),s.jsx("div",{className:"max-h-[220px] overflow-y-auto whitespace-pre-wrap rounded-sm border border-border bg-surface px-3 py-2 text-[12.5px] leading-[1.7]",children:d||s.jsx("span",{className:"text-subtle",children:a("(上游这一次返回了空正文)")})}),f?s.jsxs("div",{className:"overflow-hidden rounded-sm border border-border",children:[s.jsxs(B,{variant:"ghost",size:"xs",className:"w-full","aria-expanded":r,onClick:i,children:[s.jsx("span",{className:"truncate",children:a("思考过程({n} 字)",{n:f.length})}),s.jsx("span",{"aria-hidden":"true",className:"ml-auto text-[10px]",children:r?"▴":"▾"})]}),r?s.jsx("div",{className:"border-t border-hairline bg-surface px-2.5 py-2",children:s.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11.5px] leading-[1.65] text-subtle",children:f})}):null]}):null]})]})}function eg(){return window}const vCe="你好",f8=4e3,xCe=[{value:"chat_completions",label:"OpenAI - Chat Completions"},{value:"responses",label:"OpenAI - Responses"},{value:"anthropic",label:"Anthropic - Messages"}],bCe="direct",yCe={remote:a("远程目录"),builtin:a("内置清单"),manual:a("手动登记")};function h8(){return eg().wbApp?.getState?.()?.accounts?.accounts||[]}function p8(e){return h8().filter(t=>(t.provider||JT)===e&&t.available!==!1&&t.enabled!==!1).sort(_0)}function m8(e){const t=String(e.email||"").trim();return t&&Oa(e.provider).emailAsName?t:go(e)||t||a("未命名账号")}function wCe(){const e=globalThis.crypto?.randomUUID?.();if(e)return e;const t=n=>Array.from({length:n},()=>Math.floor(Math.random()*16).toString(16)).join("");return`${t(8)}-${t(4)}-4${t(3)}-a${t(3)}-${t(12)}`}function jCe(e,t){return t.kind==="image"?a("图片生成模型请通过 /v1/images/generations 调用,暂不支持对话测试"):p8(e).length?"":a("该提供商没有可用账号(要在账号页启用一个、且凭证完整),一行都发不出去")}function g8({children:e,plain:t=!1}){return s.jsxs("p",{className:t?"flex items-center gap-2 text-xs leading-[1.6] text-subtle":"flex gap-2 rounded-md border border-border bg-surface-2 px-3 py-2.5 text-xs leading-[1.65] text-subtle",children:[s.jsx("span",{"aria-hidden":"true",className:t?"size-4 flex-none rounded-full border border-border-strong text-center text-[10px] leading-[14px]":"mt-px size-4 flex-none rounded-full border border-border-strong text-center text-[10px] leading-[14px]",children:"i"}),s.jsx("span",{children:e})]})}function SCe(e){const[t,n]=v.useState(()=>Date.now());return v.useEffect(()=>{if(!e)return;n(Date.now());const r=window.setInterval(()=>n(Date.now()),400);return()=>window.clearInterval(r)},[e]),t}function kCe({target:e,onClose:t}){const n=e.provider,r=l8(n,e.id),i=p8(n),o=uO(h8()),[c,d]=v.useState(""),[f,h]=v.useState(vCe),[p,g]=v.useState("chat_completions"),[x,y]=v.useState(""),[j,w]=v.useState(null),[S,N]=v.useState(""),[A,E]=v.useState(""),[O,R]=v.useState(!0),T=QR(async()=>{const de=eg().workbuddyDesktop?.getModelApiKeys;if(!de)throw new Error(a("当前环境不支持读取 API Key"));return de()}),{value:P,ready:M,select:_}=v0e("model-test",ub),I=T.keys.find(de=>de.id===P),L=!!(I&&gK(I,e.id,n)),D=v.useRef(I);D.current=I;const[z,G]=v.useState(()=>{const de=i.find(Se=>!Px(Se,e.id))||i[0];return de?[de.id]:[]}),[X,Y]=v.useState([]),[F,K]=v.useState(()=>new Set),U=v.useRef(0),q=v.useRef([]);q.current=X;const W=X.some(de=>de.state==="running"),ne=SCe(W);v.useEffect(()=>{let de=!0;return(async()=>{try{const Se=eg().workbuddyDesktop?.getProxyPool;if(typeof Se!="function")throw new Error(a("当前环境不支持代理池"));const ve=await Se();if(!de)return;if(!ve||typeof ve!="object"||!Array.isArray(ve.items))throw new Error(a("代理池响应异常"));w(ve.items),N("")}catch(Se){if(!de)return;w([]),N(Cd(Se))}})(),()=>{de=!1}},[]);const ie=v.useCallback((de=!1)=>{const Se=q.current.filter(ve=>ve.state==="running");U.current+=1;for(const ve of Se)eg().workbuddyDesktop?.terminateStatsRequest?.(ve.testId)?.catch(()=>{});Y([]),Se.length&&!de&&Ia(a("已中止在途测试({n} 个账号)",{n:Se.length}))},[]);v.useEffect(()=>()=>{ie(!0)},[ie]);async function V(de,Se){const ve={provider:n,model:e.id,account_id:de.accountId,prompt:f.trim(),system_prompt:c.trim(),reasoning:A,stream:O,protocol:p,...x?{proxy:x}:{},test_id:de.testId},xe=Re=>{U.current===Se&&Y(we=>we.map(ge=>ge.testId===de.testId?{...ge,...Re}:ge))};try{const Re=D.current;if(!Re)throw new Error(a("请先选择一把 API Key"));const we=await eg().workbuddyDesktop?.testModel(ve,Re.key);if(!we){xe({state:"done",transport:a("桥接调用返回空(本机网关没有响应这次测试)")});return}xe({state:"done",result:we})}catch(Re){xe({state:"done",transport:Cd(Re)})}}function H(){if(!M||!T.ready||!I){Ia(a("请先选择一把 API Key"),"err");return}if(!L){Ia(a("所选 API Key 无权调用此模型或提供商"),"err");return}const de=i.filter(Re=>z.includes(Re.id));if(!de.length){Ia(a("至少选一个测试账号"),"err");return}const Se=U.current+1;U.current=Se;const ve=Date.now(),xe=de.map(Re=>({accountId:Re.id,label:m8(Re),position:o.get(Re.id)?.position||0,testId:wCe(),startedAt:ve,state:"running"}));K(new Set),Y(xe);for(const Re of xe)V(Re,Se)}function Q(){W?ie():Y([])}const J=s.jsx("span",{className:"ml-2 font-mono text-[12px] font-normal text-subtle",children:e.id});if(!r)return s.jsx(St,{open:!0,onOpenChange:de=>{de||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("测试模型")})}),s.jsx(Ct,{children:s.jsx("p",{className:"text-sm leading-[1.7] text-subtle",children:a("这一行已不在当前清单里(模型被移除、或目录刷新后上游不再提供它)。关闭后刷新列表再试。")})}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const oe=Jm(r).find(de=>de.isDefault)?.enabled===!1,ee=HP(r.id,r.id,n),se=Jm(r).filter(de=>!de.isDefault).map(de=>de.alias),le=kb(Ab().data,r).filter(de=>de!=="off"&&de!=="none"),te=oe?a("跟随映射(该行未启用,本次不注入)"):ee?a("跟随映射(当前 {level})",{level:ee}):a("跟随映射(未绑定等级)"),re=[a("以模型本名直发"),se.length?a("另有 {n} 条别名映射({aliases}),别名不参与本次",{n:se.length,aliases:se.join(a("、"))}):"",oe?a("该行当前未启用:测试照常按本名直发(「先测通、再决定要不要启用」正是这颗按钮的用法),但本行的思考等级绑定不参与本次,生产路由也要等绑定打开后才会放行"):ee?a("映射上绑定的思考等级是 {level},「跟随映射」按它注入",{level:ee}):a("映射上未绑定思考等级,「跟随映射」等于这次不注入")].filter(Boolean).join(a(";"))+a("。"),he=eg().wbProviders?.PROTOCOL_OPTIONS||xCe,pe=he.find(de=>de.value===p)?.label||p,Ne=[{value:"",label:a("跟随账号配置")},{value:bCe,label:a("直连(不使用代理)")},...(j??[]).map(de=>({value:`${tl}${de.id}`,label:dm(de),disabled:de.enabled===!1}))];j===null?Ne.push({value:"__hint_pool__",label:a("正在读取代理列表…"),disabled:!0}):j.length||Ne.push({value:"__hint_pool__",label:a(S?"代理列表读取失败":"还没有代理(去「网络代理」页添加)"),disabled:!0});const me=Ne.find(de=>de.value===x)?.label||a("跟随账号配置"),ce=i.map(de=>({value:de.id,label:`#${o.get(de.id)?.position||0} ${m8(de)}`+(Px(de,e.id)?a(" · 限额中"):"")}));function ae(de){const Se=`think-${de.testId}`;return s.jsx(gCe,{slot:de,model:e.id,now:ne,expanded:F.has(Se),onToggle:()=>K(ve=>{const xe=new Set(ve);return xe.has(Se)?xe.delete(Se):xe.add(Se),xe})},de.testId)}function _e(){if(W){const Se=X.length-X.filter(ve=>ve.state==="running").length;return s.jsxs(s.Fragment,{children:[X.length>1?s.jsxs("p",{className:"text-xs text-subtle",children:[a("正在测 "),s.jsx("b",{className:"text-foreground",children:X.length}),a(" 个账号"),Se?s.jsxs(s.Fragment,{children:[a(",已完成 "),s.jsx("b",{className:"text-foreground",children:Se})]}):null,a("。")]}):null,X.map(ve=>ae(ve))]})}const de=X.filter(d8).length;return s.jsxs(s.Fragment,{children:[X.length>1?s.jsxs("p",{className:"text-xs text-subtle",children:[s.jsx("b",{className:de?"text-success":"text-foreground",children:de}),a(" 成功 ·"),s.jsxs("b",{className:X.length-de?"text-destructive":"text-foreground",children:[" ",X.length-de]}),a(" 失败")]}):null,X.map(Se=>ae(Se)),de===0?s.jsxs(g8,{children:[a("两边原因不一样时各自处理。如果"),s.jsx("b",{className:"text-foreground",children:a("同一条错误出现在所有账号上")}),a(",通常就不是账号问题了:先确认这个模型还在上游目录里(「获取模型」刷一次),再看默认绑定指向的上游模型对不对。")]}):null]})}return s.jsx(St,{open:!0,onOpenChange:de=>{de||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsxs(jt,{children:[a("测试模型"),J]})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-inset px-3 py-2.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px] font-semibold text-primary-fg",title:r.id,children:r.id}),s.jsx(ye,{shape:"tag",variant:"brand",children:UP(n)}),s.jsx(ye,{shape:"tag",variant:"outline",children:ts(n)?a("自定义家"):yCe[r.source]||a("来源未知")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("本次测试的发送口径")}),children:"?"}),s.jsx(Ml,{children:re})]})]}),s.jsx(ZR,{...T,value:P,onChange:_,id:"model-test-api-key",disabled:!M,rememberSelection:!0,onRefresh:()=>{T.refresh().catch(()=>{})},t:a}),I&&!L?s.jsx("p",{role:"status",className:"text-xs text-destructive",children:a("所选 API Key 无权调用此模型或提供商")}):null,s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-system",children:a("系统提示词")}),s.jsx(Ea,{id:"model-test-system",rows:2,maxLength:f8,placeholder:a("留空则不携带;设置页的提示词模式照常生效"),value:c,onChange:de=>d(de.currentTarget.value)})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-prompt",children:a("用户提示词")}),s.jsx(Ea,{id:"model-test-prompt",rows:2,maxLength:f8,placeholder:a("留空用默认问候「你好」"),value:f,onChange:de=>h(de.currentTarget.value)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-protocol",children:a("对话协议")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("对话协议的说明")}),children:"?"}),s.jsx(Ml,{children:a("按所选网关对话协议组装请求并校验响应转换(Chat Completions / Responses / Anthropic Messages)。")})]})]}),s.jsxs(ht,{value:p,onValueChange:de=>g(String(de)),children:[s.jsx(mt,{id:"model-test-protocol",className:"w-full",children:s.jsx(pt,{className:"min-w-0 truncate",children:pe})}),s.jsx(gt,{children:he.map(de=>s.jsx(qe,{value:de.value,children:de.label},de.value))})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-proxy",children:a("测试节点")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("测试节点的说明")}),children:"?"}),s.jsx(Ml,{children:a("仅本次测试临时生效,不修改账号保存的代理配置。可选「网络代理」页里的节点或强制直连。")})]})]}),s.jsxs(ht,{value:x,onValueChange:de=>y(String(de)),children:[s.jsx(mt,{id:"model-test-proxy",className:"w-full",children:s.jsx(pt,{className:"min-w-0 truncate",children:me})}),s.jsx(gt,{children:Ne.map(de=>s.jsx(qe,{value:de.value,disabled:de.disabled,children:de.label},de.value))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-reasoning",children:a("思考等级")}),s.jsxs(ht,{value:A,onValueChange:de=>E(String(de)),children:[s.jsx(mt,{id:"model-test-reasoning",className:"w-full",children:s.jsx(pt,{children:A?a("{level}(本次指定)",{level:A}):te})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:te}),le.map(de=>s.jsx(qe,{value:de,children:a("{level}(本次指定)",{level:de})},de))]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-stream",children:a("流式请求")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("流式请求的说明")}),children:"?"}),s.jsx(Ml,{children:a("默认开,与真实请求一致:可同时验证 SSE 链路与首字延迟。")})]})]}),s.jsx(cn,{id:"model-test-stream",checked:O,onCheckedChange:de=>R(!!de)})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ie,{htmlFor:"model-test-accounts",children:a("测试账号")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("测试账号的说明")}),children:"?"}),s.jsx(Ml,{children:a("勾几个就并行测几次;默认选队列里最靠前的一个。")})]}),s.jsx(B,{variant:"ghost",size:"xs",className:"ml-auto",disabled:!i.length||z.length===i.length,onClick:()=>G(i.map(de=>de.id)),children:a("全选({n})",{n:i.length})})]}),s.jsx(Ff,{id:"model-test-accounts",value:z,onValueChange:G,options:ce,placeholder:a("选一个账号(至少一个)"),searchPlaceholder:a("搜索账号…"),emptyHint:a("这家没有可用账号(要在账号页启用一个、且凭证完整)")})]}),s.jsx(g8,{plain:!0,children:a("真实链路 · 消耗少量额度 · 日志带「测试」标记,不计报表")})]}),s.jsxs(Pt,{className:"justify-end",children:[s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")}),s.jsx(B,{variant:"default",disabled:!z.length||!i.length||!M||!T.ready||!L,onClick:H,children:a("开始测试")})]}),s.jsx(St,{open:X.length>0,onOpenChange:de=>{de||Q()},children:s.jsxs(kt,{overlayForceRender:!0,className:"w-[min(680px,calc(100vw-48px))]",children:[s.jsx(Nt,{children:s.jsxs(jt,{children:[a(W?"测试中…":"测试结果"),J]})}),s.jsx(Ct,{children:_e()}),s.jsx(Pt,{className:"justify-end",children:W?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-xs text-subtle",children:a("关闭即中止")}),s.jsx(B,{variant:"outline",onClick:()=>ie(),children:a("中止测试")}),s.jsx(B,{variant:"default",disabled:!0,children:a("测试中…")})]}):s.jsxs(s.Fragment,{children:[s.jsx(B,{variant:"outline",onClick:Q,children:a("关闭")}),s.jsx(B,{variant:"default",onClick:H,children:a("再测一次")})]})})]})})]})})}const v8=[{value:"enable",label:a("启用")},{value:"disable",label:a("禁用")},{value:"reasoning",label:a("设置思考等级")},{value:"delete",label:a("删除")}];function x8(e){return e.source==="manual"||ts(e.provider)}function NCe(e){return(e.name&&e.name!==e.id?a("{name}({id})",{name:e.name,id:e.id}):e.id)||e.id}function CCe({models:e,onClose:t,onDone:n}){const[r,i]=v.useState("enable"),o=I1e(Ab().data,e),[c,d]=v.useState(()=>({select:o[0]||"",custom:""})),[f,h]=v.useState(!1),[p,g]=v.useState(""),x=c.select===No?c.custom.trim():c.select,y=e.filter(x8).length,j=v8.find(N=>N.value===r)?.label||a("操作");async function w(N){return Promise.resolve(Zn().wbConfirm?.ask?.({title:a("删除选中的模型"),html:a("确定删除选中的 {count} 个模型登记?删除后 /v1/models 不再广告它们、请求也会被拒。",{count:N})+(e.length>N?"
"+a("另有 {n} 个非手动登记的模型将被跳过。",{n:e.length-N}):""),okText:a("删除"),okClass:"danger"})??!1)}async function S(){if(f)return;if(!e.length){Ia(a("没有选中的模型"),"err");return}if(r==="reasoning"&&c.select===No&&!x){g(s.jsx("span",{className:"text-destructive",children:a("请填写自定义思考等级,或改选候选档 / 「清除」")}));return}if(r==="delete"){if(y===0){g(s.jsx("span",{className:"text-destructive",children:a("选中的模型都不是手动登记,无法删除(开关映射才是它们的手段)")}));return}if(!await w(y))return}h(!0),g("");let N=0,A=0,E=0,O="";for(const R of e){const T=R.provider||"";try{if(r==="delete"){if(!x8(R)){A+=1;continue}wh(await t8(T,R.id))}else if(r==="enable"||r==="disable"){const P=r==="enable";for(const M of Jm(R))wh(await YS(T,M.alias,R.id,{enabled:P}))}else for(const P of Jm(R))wh(await YS(T,P.alias,R.id,{reasoning:x}));N+=1}catch(P){E+=1,O||(O=Cd(P)),g(s.jsx("span",{className:"text-destructive",children:a("失败 {n} 个 · 首个失败:{error}",{n:E,error:O})}))}}E===0?(Ia(A?a("✅ 批量{action}完成:共 {n} 个模型(跳过不可删除的 {skipped} 个)",{action:j,n:N,skipped:A}):a("✅ 批量{action}完成:共 {n} 个模型",{action:j,n:N})),n()):(Ia(a("批量{action}完成:成功 {ok} 个,失败 {failed} 个",{action:j,ok:N,failed:E}),"err"),g(s.jsxs("span",{className:"text-destructive",children:[a("成功 {ok} 个,失败 {failed} 个",{ok:N,failed:E}),A?a(",跳过 {n} 个",{n:A}):"",O?a(";首个失败:{error}",{error:O}):""]}))),h(!1)}return s.jsx(St,{open:!0,onOpenChange:N=>{N||f||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("批量操作 · 已选 {n} 个模型",{n:e.length})})}),s.jsxs(Ct,{children:[s.jsxs(Ln,{children:[s.jsx("h3",{children:a("将作用于以下模型")}),s.jsx("p",{style:{maxHeight:84,overflowY:"auto"},children:e.map(NCe).join(a("、"))})]}),s.jsxs(Ln,{children:[s.jsx("h3",{children:a("操作")}),s.jsx(bx,{value:r,onValueChange:N=>i(N),className:"flex-row flex-wrap items-center gap-5","aria-label":a("批量动作"),children:v8.map(N=>s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:N.value}),N.label]},N.value))}),r==="reasoning"?s.jsxs("div",{className:"mt-2.5",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"batch-model-reasoning",children:a("思考等级")}),s.jsxs(ht,{value:c.select,onValueChange:N=>d(A=>({...A,select:String(N)})),children:[s.jsx(mt,{id:"batch-model-reasoning",className:"min-w-[220px]",children:s.jsx(pt,{children:c.select===No?a("自定义等级…"):c.select||a("清除(不覆盖)")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("清除(不覆盖)")}),o.map(N=>s.jsx(qe,{value:N,children:N},N)),s.jsx(qe,{value:No,children:a("自定义等级…")})]})]})]}),c.select===No?s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2",children:[s.jsx(Tt,{htmlFor:"batch-model-reasoning-custom",children:a("自定义等级")}),s.jsx(Be,{id:"batch-model-reasoning-custom",maxLength:32,value:c.custom,onChange:N=>d(A=>({...A,custom:N.currentTarget.value}))})]}):null,s.jsxs("p",{className:"detail mt-1.5",children:[a("设置 / 清除会应用到选中模型的"),s.jsx("b",{children:a("全部映射")}),a("(默认绑定与别名 chips);「清除」= 不给这些映射指定等级(选「不覆盖」的口径与映射弹窗一致)")]})]}):null,r==="delete"?s.jsx("p",{className:"detail mt-2",children:y===0?a("选中的都不是手动登记的模型,删除不可用(上游目录带回来的行由清单决定存在性)"):a("可删除 {n} 个(手动登记 / 自定义家);",{n:y})+(e.length>y?a("其余 {n} 个会被跳过。",{n:e.length-y}):"")}):null]}),s.jsx("div",{className:"detail",style:{minHeight:18},children:p})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:f,onClick:t,children:a("关闭")}),s.jsx(B,{variant:r==="delete"?"destructive":"default",disabled:f,onClick:()=>{S()},children:f?a("执行中…"):a("执行{action}",{action:j})})]})]})})}function ACe(e){const t=/^上游返回\s+([1-5]\d{2})[::] ?/.exec(e);return t?{status:t[1],body:e.slice(t[0].length),upstream:!0}:{status:/^HTTP\s+([1-5]\d{2})(?:\b|$)/i.exec(e)?.[1],body:e,upstream:!1}}function ECe({message:e}){const{status:t,body:n,upstream:r}=ACe(e),i=new TextEncoder().encode(n).length,o=t?a("{status}:模型获取失败",{status:t}):a("模型获取失败"),c=a(r?"上游原始响应":"错误详情");return s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[s.jsxs(It,{variant:"destructive",className:"flex items-center gap-2 rounded-none border-0 bg-transparent p-0",children:[s.jsx("span",{"aria-hidden":"true",className:"size-[7px] shrink-0 rounded-full bg-current"}),s.jsx(om,{className:"text-[13px]",children:o})]}),s.jsxs("div",{className:"min-w-0 overflow-hidden rounded-sm border border-border bg-surface-2",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-hairline py-[7px] pl-3 pr-2.5",children:[s.jsx("span",{className:"text-[11.5px] font-semibold text-subtle",children:c}),s.jsx("span",{className:"font-mono text-[10.5px] text-muted-foreground",children:a("{n} 字节",{n:i})}),s.jsx(B,{variant:"outline",size:"xs",className:"ml-auto h-[22px] text-[11px]","data-copy":n,disabled:!n,children:a("复制")})]}),s.jsx("pre",{role:"region","aria-label":c,tabIndex:0,className:"m-0 max-h-[210px] overflow-auto whitespace-pre-wrap px-3 py-[11px] font-mono text-[11.5px] leading-[1.7] text-subtle [overflow-wrap:anywhere] focus-visible:outline-none focus-visible:shadow-focus",children:n||(r?a("(上游这一次返回了空正文)"):"—")})]})]})}const b8={intl:"fm-table-intl",custom:"fm-table-custom"},y8={intl:"fetch-models",custom:"fetch-models-custom"},TCe=["provider","source","state","count","note","updated","op"],OCe=["pick","model","state"],RCe={provider:"w-[13%]",source:"w-[21%]",state:"w-[9%]",count:"w-[6%]",note:"w-[20%]",updated:"w-[16%]",op:"w-[15%]"},PCe={pick:"w-[8%]",model:"w-[74%]",state:"w-[18%]"},ICe={pick:"",provider:a("提供商"),source:a("模型来源"),state:a("状态"),count:a("模型数"),note:a("说明"),updated:a("更新日期"),model:a("上游模型"),op:a("操作")},MCe={refreshed:{variant:"brand",label:a("已刷新")},failed:{variant:"destructive",label:a("失败")},skipped:{variant:"outline",label:a("跳过")}};function _Ce(e){return e.trim().toLowerCase()}function _b(e){return s.jsx("span",{className:"font-mono text-[11.5px] tabular-nums text-muted-foreground",children:e})}function KP(e){return s.jsx("div",{className:"truncate font-mono text-[12px] font-semibold",children:a(e)})}function DCe({custom:e,status:t,rows:n,upstream:r,managed:i,picked:o,keyword:c,busy:d,busyRow:f,onPick:h,onFetchRow:p,sourceCell:g,refreshedAt:x,formatTime:y}){v.useEffect(()=>{window.wbTableColumns?.repaint?.(e?y8.custom:y8.intl)},[e]);const j=e?OCe:TCe,w=c.trim().toLowerCase(),S=r.filter(T=>!w||T.toLowerCase().includes(w));function N(T){return s.jsx(en,{children:s.jsx(Xe,{colSpan:j.length,className:"py-[26px] text-center text-muted-foreground",children:T})})}function A(T,P,M){if(M||T.target?.closest('[data-slot="checkbox"], input[type="checkbox"]'))return;const I=window.getSelection();I&&!I.isCollapsed&&T.currentTarget.contains(I.anchorNode)||h(P,!o.has(P))}function E(){return t==="idle"?N(a("点右侧「获取模型」从上游拉取这家的模型清单")):t==="loading"?N(a("正在获取…")):S.length?S.map(T=>{const P=i.has(_Ce(T));return s.jsxs(en,{className:P?"opacity-50":"cursor-pointer",onClick:M=>A(M,T,P),children:[s.jsx(Xe,{children:s.jsx(Wr,{checked:o.has(T),disabled:P,"aria-label":T,onCheckedChange:M=>h(T,!!M)})}),s.jsx(Xe,{children:KP(T)}),s.jsx(Xe,{children:P?s.jsx(ye,{variant:"brand",title:a("这个模型已经在这家的清单里,不重复导入"),children:a("已添加")}):s.jsx(ye,{variant:"outline",title:a("勾上它,导入后即进入这家的清单"),children:a("未添加")})})]},T)}):N(r.length?a("没有匹配「{keyword}」的模型",{keyword:w}):a("上游没有返回任何模型"))}function O(T){const P=d&&f===T.provider;return s.jsx(B,{variant:"outline",size:"sm",className:"w-full",disabled:d,title:a("只刷新这一家的模型清单"),onClick:()=>p(T),children:P?a("获取中…"):T.item?a("重新获取"):a("获取")})}function R(){return t==="loading"?N(a("正在获取…")):n.length?n.map(T=>{const P=T.item;if(!P){const D=y(x(T.provider));return s.jsxs(en,{children:[s.jsx(Xe,{children:KP(T.label)}),s.jsx(Xe,{children:g(T.provider)}),s.jsx(Xe,{children:s.jsx(ye,{variant:"outline",children:a("待获取")})}),s.jsx(Xe,{children:_b("—")}),s.jsx(Xe,{children:_b("—")}),s.jsx(Xe,{children:_b(D||"—")}),s.jsx(Xe,{children:O(T)})]},T.provider)}const M=MCe[String(P.status)]??{variant:"outline",label:String(P.status||a("未知"))},_=Number(P.count),I=P.status==="refreshed"?a("远程目录已更新,「来源」列会显示为「远程」"):P.message||(P.fixed?a("这家用固定模型清单,无可刷新"):a("本次没有取到新内容")),L=y(Number(P.refreshedAt)||0);return s.jsxs(en,{children:[s.jsx(Xe,{children:KP(T.label)}),s.jsx(Xe,{children:g(T.provider,P.accountId)}),s.jsx(Xe,{children:s.jsx(ye,{variant:M.variant,children:M.label})}),s.jsx(Xe,{children:_b(_?a("{n} 个",{n:_}):"—")}),s.jsx(Xe,{children:s.jsx("span",{className:"text-[11.5px] leading-[1.5] text-muted-foreground [overflow-wrap:anywhere]",children:a(I)})}),s.jsx(Xe,{children:_b(L||"—")}),s.jsx(Xe,{children:O(T)})]},T.provider)}):N(a("还没有可刷新的提供商:先在账号页添加一个账号"))}return s.jsxs(ea,{id:e?b8.custom:b8.intl,className:"table-fixed",containerClassName:"max-h-[min(48vh,460px)]",children:[s.jsx("colgroup",{children:j.map(T=>s.jsx("col",{"data-col":T,className:e?PCe[T]:RCe[T]},T))}),s.jsx(Ta,{children:s.jsx(en,{children:j.map(T=>s.jsx(ft,{"data-col":T,children:ICe[T]},T))})}),s.jsx(ga,{className:"[&_tr:last-child>td]:border-b-0",children:e?E():R()})]})}function Wa(){return window}const w8=new Set(["cline-free","cline-pass"]),j8="workbuddy-desktop-fetch-model-source";function WS(e){return String(e??"").trim().toLowerCase()}function qP(e,t){Wa().wbApp?.toast?.(e,t)}function GP(e){return e instanceof Error?e.message:String(e)}function LCe(e){const t=Wa().formatTime??Wa().wbApp?.formatTime;return String(t?.(e)??"")}function S8(){return Wa().wbApp?.getState?.()?.accounts?.accounts||[]}function zCe(e){const n=(Wa().wbProviders?.customList?.()||[]).find(r=>r.id===e)?.models;return new Set((Array.isArray(n)?n:[]).map(r=>WS(r?.id)).filter(Boolean))}function k8(e){if(e?.nameCustom===!0&&e?.name)return e.name;const t=String(e?.email||"").trim();return Wa().wbAccountsModel?.providerFeatures?.(e?.provider)?.emailAsName&&t?t:String(e?.nickname||e?.name||t||e?.id||"").trim()||a("未命名账号")}function $Ce(e){if(w8.has(e))return[];const t=Wa().wbAccountsModel?.byPriorityOrder,n=S8().filter(r=>(r?.provider||"workbuddy")===e&&r?.available!==!1&&r?.enabled!==!1);return t?n.sort(t):n}function BCe(){const e=new Set(Wa().wbModelsPanel?.builtinProviders?.()||[]);for(const t of S8())t?.available===!1||t?.enabled===!1||e.add(t?.provider||"workbuddy");return[...e]}function FCe(){const e=new Set(BCe());return(Wa().wbProviders?.all?.()||[]).filter(t=>e.has(t?.id??""))}function UCe(){try{const e=JSON.parse(localStorage.getItem(j8)||"{}");if(!e||typeof e!="object")return{};const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&r&&(t[n]=r);return t}catch{return{}}}function HCe(e){Wa().wbFilterMemory?.save?.(j8,e)}function VCe({options:e,onClose:t}){const n=e.providerId,r=!!e.custom,i=e.name||n,{onDone:o,onRefreshed:c}=e,[d,f]=v.useState("idle"),[h,p]=v.useState(""),[g,x]=v.useState(""),[y,j]=v.useState(null),[w,S]=v.useState(""),N=y!==null,A=d==="error",[E,O]=v.useState(!1),[R,T]=v.useState([]),[P,M]=v.useState(()=>new Set),[_,I]=v.useState(()=>new Set),[L,D]=v.useState([]),[z,G]=v.useState(""),[X,Y]=v.useState(UCe),F=r?[]:FCe(),K=r?[]:q(),U=r?E?a("已选 {picked} 个 · 上游共 {upstream} 个 · 清单已有 {managed} 个",{picked:_.size,upstream:R.length,managed:P.size}):a("尚未获取"):W(K);function q(){const he=new Map(L.map(me=>[String(me.provider||""),me])),pe=F.map(me=>{const ce=String(me.id||"");return{provider:ce,label:String(me.label||ce),item:he.get(ce)}}),Ne=new Set(pe.map(me=>me.provider));for(const me of L){const ce=String(me.provider||"");Ne.has(ce)||pe.push({provider:ce,label:String(me.providerLabel||ce),item:me})}return pe}function W(he){if(d==="loading")return a("正在刷新…");if(d==="error")return"";const pe=he.map(ce=>ce.item).filter(ce=>!!ce);if(!pe.length)return E?a("刷新完成,但没有得到任何结果"):he.length?a("共 {n} 家 · 点「获取模型」开始",{n:he.length}):a("0 家");const Ne=pe.filter(ce=>ce.status==="refreshed").length,me=pe.filter(ce=>ce.status==="failed").length;return me?a("{total} 家 · 成功 {done} · 失败 {failed}",{total:he.length,done:Ne,failed:me}):a("{total} 家 · 成功 {done}",{total:he.length,done:Ne})}function ne(he,pe){const Ne=$Ce(he);if(!Ne.length)return{list:Ne,selected:""};const me=String(X[he]||""),ce=String(pe||""),ae=_e=>Ne.some(de=>String(de.id)===_e);return{list:Ne,selected:ae(me)?me:ae(ce)?ce:String(Ne[0].id)}}function ie(he){const pe={};for(const[Ne,me]of Object.entries(X))me&&(pe[Ne]=me);for(const Ne of he){const{selected:me}=ne(Ne.provider,Ne.reported);me&&(pe[Ne.provider]=me)}return pe}const V=K.map(he=>({provider:he.provider,reported:he.item?.accountId}));function H(he,pe){Y(Ne=>({...Ne,[he]:pe})),HCe({[he]:pe})}async function Q(){if(!N){j("load"),x(""),p(""),f("loading");try{if(r){const me=await Wa().wbProviders?.customRequest?.("POST","/api/custom-providers/fetch-models",{providerId:n}),ce=new Set,ae=(Array.isArray(me?.models)?me.models:[]).map(de=>String(de??"").trim()).filter(de=>{const Se=WS(de);return!de||ce.has(Se)?!1:(ce.add(Se),!0)}),_e=zCe(n);T(ae),M(_e),I(new Set(ae.filter(de=>!_e.has(WS(de))))),O(!0),f("ready");return}const he=Wa().workbuddyDesktop?.refreshModels;if(!he)throw new Error(a("模型目录刷新不可用,请重新打开面板"));const pe=F.map(me=>me.id).filter(me=>!!me),Ne=await he({accounts:ie(V),providers:pe});if(!Array.isArray(Ne?.results)||Ne.results.some(me=>!me||typeof me.provider!="string"||!["refreshed","failed","skipped"].includes(me.status||""))||pe.some(me=>Ne.results.filter(ce=>ce.provider===me).length!==1))throw new Error(a("网关未返回逐家模型目录刷新结果"));D(Ne.results),O(!0),f("ready"),Number(Ne?.refreshed)>0&&c?.()}catch(he){p(GP(he)),f("error")}finally{j(null)}}}async function J(he){if(!(N||!he.provider)){j("row"),S(he.provider),x("");try{const pe=Wa().workbuddyDesktop?.refreshModels;if(!pe)throw new Error(a("模型目录刷新不可用,请重新打开面板"));const Ne=await pe({accounts:ie([{provider:he.provider,reported:he.item?.accountId}]),providers:[he.provider]}),me=Array.isArray(Ne?.results)?Ne.results.filter(ae=>ae?.provider===he.provider):[];if(me.length!==1||!["refreshed","failed","skipped"].includes(me[0].status||""))throw new Error(a("网关未返回逐家模型目录刷新结果"));const ce=me[0];D(ae=>oe(ae,[ce])),O(!0),f("ready"),Number(Ne?.refreshed)>0&&c?.()}catch(pe){const Ne=GP(pe);D(me=>oe(me,[{provider:he.provider,providerLabel:he.label,status:"failed",message:Ne}])),O(!0),f("ready"),x(Ne),qP(a("获取失败:{message}",{message:Ne}),"err")}finally{j(null),S("")}}}function oe(he,pe){const Ne=new Map(pe.map(ae=>[String(ae.provider||""),ae])),me=he.map(ae=>Ne.get(String(ae.provider||""))??ae),ce=new Set(me.map(ae=>String(ae.provider||"")));for(const ae of pe)ce.has(String(ae.provider||""))||me.push(ae);return me}async function ee(){if(!r||N||!_.size)return;const he=[..._];j("import"),x("");try{const pe=Number(await Wa().wbModelsCustom?.addModels?.(n,he))||0;qP(a("✅ 已导入 {added} 个模型({skipped} 个已存在,跳过)",{added:pe,skipped:he.length-pe})),j(null),t(),o?.()}catch(pe){const Ne=GP(pe);qP(a("导入失败:{message}",{message:Ne}),"err"),x(Ne),j(null)}}function se(){N||t()}function le(){const he=new Set(_);for(const pe of R)P.has(WS(pe))||he.add(pe);I(he)}function te(he,pe){const{list:Ne,selected:me}=ne(he,pe);if(!Ne.length){const ae=w8.has(he)?a("这家的模型清单是全局的,不跟账号走"):a("这家还没有可用账号,刷新会使用默认登录态");return s.jsx("span",{className:"text-[11.5px] text-muted-foreground",title:ae,children:"—"})}const ce=Ne.find(ae=>String(ae.id)===me);return s.jsxs(ht,{value:me,onValueChange:ae=>H(he,String(ae)),children:[s.jsx(mt,{className:"w-full",title:a("用哪个账号去拉这家的模型清单"),"aria-label":a("模型来源"),children:s.jsx(pt,{children:ce?k8(ce):"—"})}),s.jsx(gt,{children:Ne.map(ae=>s.jsx(qe,{value:String(ae.id),children:k8(ae)},String(ae.id)))})]})}function re(he,pe){I(Ne=>{const me=new Set(Ne);return pe?me.add(he):me.delete(he),me})}return s.jsx(St,{open:!0,onOpenChange:(he,pe)=>{if(!he){if(N){pe.cancel();return}t()}},children:s.jsxs(kt,{className:A?"w-[min(640px,calc(100vw-48px))]":r?"w-[min(607px,calc(100vw-48px))]":"w-[min(1012px,calc(100vw-48px))]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("获取模型 — {name}",{name:i})})}),s.jsx(Ct,{children:A?s.jsx(ECe,{message:h}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[s.jsx("span",{className:"text-[11.5px] text-muted-foreground",children:U}),r&&s.jsxs(uo,{className:"w-[240px] flex-none",children:[s.jsx(ho,{type:"search",placeholder:a("搜索模型 ID…"),autoComplete:"off",value:z,onChange:he=>G(he.currentTarget.value)}),s.jsx(fo,{"aria-hidden":"true",children:"⌕"})]}),s.jsx("div",{className:"mr-auto"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(B,{variant:"ghost",size:"sm",onClick:le,children:a("全选未添加")}),s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>I(new Set),children:a("清空")})]}),s.jsx(B,{variant:"outline",size:"sm",title:a("刷新全部家(逐家打上游)"),disabled:N,onClick:()=>{Q()},children:a(y==="load"?"获取中…":E?"重新获取":"获取模型")})]}),s.jsx(DCe,{custom:r,status:d,rows:K,upstream:R,managed:P,picked:_,keyword:z,busy:N,busyRow:w,onPick:re,onFetchRow:he=>{J(he)},sourceCell:te,formatTime:LCe,refreshedAt:he=>Number(Wa().wbModelsPanel?.providerRefreshedAt?.(he))||0})]})}),s.jsxs(Pt,{children:[!A&&g&&s.jsx("span",{className:"min-w-0 text-[11.5px] text-muted-foreground [overflow-wrap:anywhere]",children:g}),s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:se,disabled:N,children:a(A?"关闭":r?"取消":"完成")}),A?s.jsx(B,{variant:"default",disabled:N,onClick:()=>{Q()},children:a("重试")}):r&&s.jsx(B,{variant:"default",disabled:!_.size||N,onClick:()=>{ee()},children:y==="import"?a("导入中…"):_.size?a("导入选中的 {n} 个模型",{n:_.size}):a("导入")})]})]})})}let Db=null,tg=null;function N8(){Db&&(Db.unmount(),Db=null),tg&&(tg.remove(),tg=null)}function KCe(e){!e||e.custom&&!e.providerId||(N8(),tg=document.createElement("div"),document.body.append(tg),Db=wn.createRoot(tg),Db.render(s.jsx(VCe,{options:e,onClose:N8})))}window.wbModelsFetchModal={open:KCe};const Qc=(e,t)=>t?`${e} ta-${t}`:e;function C8(e,t){const n=(t||"").trim();if(n)return Rb().find(r=>Ad(r.provider,e)&&Ad(r.id,n))}const qCe="[.pv-row:hover_&_[data-slot=nav-item-count]]:invisible";function GCe(e){const t=/x\s*([\d.]+)/i.exec(String(e||""));return t?`${t[1]}x`:String(e||"")}function A8(e){const t=/x\s*([\d.]+)/i.exec(String(e||""));if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?n:null}const YCe={workbuddy:250,"workbuddy-intl":295,raccoon:60,catpaw:85,autoclaw:250,"autoclaw-intl":295,qoder:330,"qoder-intl":350,"cline-free":200,"cline-pass":200,codearts:210,loomy:155,kuku:15,accio:320,"accio-intl":335,trae:170,zcode:285};function WCe(e){const t=YCe[e];if(t!==void 0)return t;let n=0;for(let r=0;r>>0;return n%360}function XCe(e){const t=String(e||"").trim();if(!t)return"?";const n=t.match(/[A-Za-z]/);return(n?n[0]:t[t.length-1]).toUpperCase()}const QCe=e=>({"--av-h":String(WCe(e))}),YP=s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"13.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"13.5",y:"13.5",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.5"})]})});function ZCe(e){return ts(e)?qbe(e):qc[e==="workbuddy-intl"?"workbuddy":e]||""}function ng(e,t,n){const r=n?"":ZCe(e),i=e==="all"||e===Ra;return s.jsx("span",{className:Te("pv-ico",i&&"mute",r&&"img"),style:r?void 0:QCe(e),"aria-hidden":"true",children:r?s.jsx("img",{src:r,alt:""}):n??XCe(t)})}const JCe={supportsToolCall:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),supportsImages:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2.5"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),supportsVideo:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M10 8.5l6 3.5-6 3.5z"})]})}),supportsReasoning:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),s.jsx("path",{d:"M9 18h6M10 22h4"})]})})};function eAe(e,t,n,r,i){if(r==="enabled"&&!Ib(e)||r==="disabled"&&Ib(e)||r==="mapped"&&!(e.aliases||[]).length)return!1;const o=Hq(e);return i==="visible"&&o==="hidden"||i==="hidden"&&o!=="hidden"||i==="undeclared"&&o!=="undeclared"||n!=="all"&&n!==Ra&&(e.provider||"")!==n?!1:t?[e.id,e.name,...e.aliases||[]].join(" ").toLowerCase().includes(t):!0}function tAe(){const e=v.useSyncExternalStore(U1e,Ab),t=HS(e),n=ts(t)||t===Ra,[r,i]=v.useState(null),[o,c]=v.useState(!1),[d,f]=v.useState(new Set),[h,p]=v.useState(!1),g=n&&!Zm()&&MP()&&!vd(t);v.useEffect(()=>{W1e(),KS(),Yq(),Zn().wbApp?.currentPage==="gateway"&&e8().then(()=>Zn().wbProviders?.refreshCustom?.()).then(()=>{yh()})},[]),v.useEffect(()=>{lCe()});const x=DP(),y=Array.isArray(x.models)?x.models:[],j=y.filter(H=>t==="all"||t===Ra||(H.provider||"")===t),w=e.search.trim().toLowerCase(),S=y.filter(H=>eAe(H,w,t,e.stateFilter,e.visibilityFilter)),N=e.sort,A=Jq(),E=A.length,O=t==="all"?a("全部"):t===Ra?a("自定义 · 全部"):n?String(vd(t)?.name||t):VS().get(t)?.label||UP(t),R=j.filter(Ib).length,T=j.filter(H=>(H.aliases||[]).length>0).length,P=qx(S.length,"models"),M=y.filter(H=>d.has(jh(H))),_=(H,Q)=>{const J=new Set(d);Q?J.add(H):J.delete(H),f(J)},I=S.map(jh),L=I.length>0&&I.every(H=>d.has(H)),D=I.some(H=>d.has(H)),z=s.jsx(Wr,{checked:L,indeterminate:!L&&D,disabled:!I.length,"aria-label":a("全选当前筛选结果"),title:a("全选当前筛选出的模型(跨分页);再点取消"),onCheckedChange:H=>{const Q=new Set(d);for(const J of I)H===!0?Q.add(J):Q.delete(J);f(Q)}});function G(){const H=VS(),Q=gd(),J=K1e(),oe=[...H.values()].reduce((te,re)=>te+re.n,0),ee=a("全部({n} 家)",{n:H.size}),se=[...J.values()].reduce((te,re)=>te+re.n,0),le=a("全部({n} 家)",{n:[...J.values()].filter(te=>te.n>0).length});return s.jsxs(cm,{className:"prov-rail",id:"prov-rail","aria-label":a("按提供商选择"),children:[s.jsxs(Bc,{className:"rail-scroll",children:[s.jsx("div",{className:"rail-label",children:a("内置提供商")}),s.jsx(Ri,{active:t==="all","data-provider":"all",title:ee,count:oe,icon:ng("all","",YP),className:"shadow-none",onClick:()=>Mb("all"),children:ee}),[...H].map(([te,re])=>s.jsx(Ri,{active:t===te,"data-provider":te,title:re.n?re.label:a("{provider}:模型清单为空,等待获取",{provider:re.label}),count:re.n,icon:ng(te,re.label),className:"shadow-none",trailing:re.n===0?s.jsx(ye,{variant:"outline",children:a("待获取")}):void 0,onClick:()=>Mb(te),children:re.label},te)),s.jsx("div",{className:"rail-label",children:a("自定义提供商")}),Q.length?[...se>0?[s.jsx(Ri,{active:Zm(),"data-provider":Ra,title:le,count:se,icon:ng(Ra,"",YP),className:"shadow-none",onClick:()=>Mb(Ra),children:le},Ra)]:[],...Q.map(te=>{const re=String(te.id||""),he=String(te.name||re);return s.jsxs("div",{className:"pv-row",children:[s.jsx(Ri,{active:t===re,"data-provider":re,title:he,count:J.get(re)?.n??0,icon:ng(re,he),className:Te("shadow-none",qCe),onClick:()=>Mb(re),children:he}),s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"pv-del","aria-label":a("删除自定义提供商"),title:a("删除这个自定义提供商(连同名下账号)"),onClick:()=>{tCe(re)},children:"×"})]},re)})]:s.jsx(zt,{className:"rail-empty",children:a("还没有自定义提供商")})]}),s.jsx("div",{className:"rail-foot",children:s.jsx(Ri,{variant:"add",id:"rail-add-custom",title:a("新建一个自定义提供商(同时创建它的第一个账号)"),onClick:()=>nCe(),children:a("+ 新建自定义提供商")})})]})}function X(H,Q,J,oe){const ee=HP(H,Q,J);return s.jsx(B,{variant:ee?"secondary":"dashed",size:"2xs",disabled:oe,className:"font-mono font-bold shadow-none",title:ee?a("思考等级 {level}(点击修改)",{level:ee}):a("设置思考等级(当前未绑定)"),onClick:()=>i8({alias:H,target:Q,provider:J}),children:ee||a("+等级")})}function Y(H){const Q=H.provider||"",J=Jm(H),[oe,...ee]=J;async function se(te){await Zn().wbConfirm?.ask?.({title:a("删除映射"),html:a("确定删除映射「{alias} → {target}」?",{alias:AP(te),target:AP(H.id)}),okText:a("删除"),okClass:"danger"})&&BP(FP(te,H.id,Q),()=>X1e(Q,te,H.id),a("映射已删除"))}const le=te=>{const re=te.alias,he=te.enabled!==!1,pe=e.pending.has(FP(re,H.id,Q));return s.jsxs("span",{className:Te("alias",!he&&"map-off"),children:[s.jsx(cn,{size:"sm",checked:he,disabled:pe,title:a(he?"映射已启用,点击关闭":"映射已关闭,点击启用"),"aria-label":a("{action}映射 {alias}",{action:a(he?"关闭":"启用"),alias:re}),onCheckedChange:Ne=>{BP(FP(re,H.id,Q),()=>YS(Q,re,H.id,{enabled:Ne}),a(Ne?"映射已启用":"映射已关闭"))}}),s.jsx("span",{className:"t","data-copy":re,title:a("点击复制:{name}",{name:re}),children:re}),te.isDefault?s.jsx("span",{className:"binding-default",children:a("默认")}):null,X(re,H.id,Q,pe),te.isDefault?null:s.jsx(B,{variant:"ghost",size:"icon-2xs",className:"text-[12px] leading-none",disabled:pe,title:a("删除映射 {alias}",{alias:re}),onClick:()=>{se(re)},children:"×"})]},`${re}${te.isDefault?"d":"m"}`)};return s.jsxs("div",{className:"aliases",children:[s.jsxs("div",{className:"alias-row",children:[oe?le(oe):null,s.jsx(B,{variant:"dashed",size:"xs",onClick:()=>i8({target:H.id,provider:Q}),children:a("+ 映射")})]}),ee.map(le)]})}function F(H){if(H.source==="manual")return s.jsxs("span",{className:"src manual",title:a("手动登记的上游模型;移除它会直接删掉这条登记"),children:[s.jsx("i",{"aria-hidden":"true"}),a("手动")]});if(!H.source&&ts(H.provider))return s.jsxs("span",{className:"src manual",title:a("用户登记的自定义模型;整份清单只属于这一家"),children:[s.jsx("i",{"aria-hidden":"true"}),a("自定义")]});if(H.source!=="remote"&&H.source!=="builtin")return s.jsx("span",{className:"rate",children:"—"});const Q=H.source==="remote",J=_1e(Number(H.refreshedAt)||0),oe=Q?J?a("来自上游目录接口,清单拉取于 {at};刷新失败时保留上一份成功结果",{at:J}):a("来自上游目录接口;刷新失败时保留上一份成功结果"):a("上游目录尚未拉到,用的是内置静态清单;点「刷新模型清单」可重试");return s.jsxs("span",{className:Te("src",Q?"remote":"builtin"),title:oe,children:[s.jsx("i",{"aria-hidden":"true"}),a(Q?"远程":"内置")]})}function K(H){const Q=Hq(H);return Q==="hidden"?s.jsxs("span",{className:"src hidden-visibility",title:a("上游能列出这个模型,但官方客户端不展示它;本仓已默认关闭它的默认绑定(点这一行的开关可以手动打开)"),children:[s.jsx("i",{"aria-hidden":"true"}),a("不展示")]}):Q==="visible"?s.jsxs("span",{className:"src shown-visibility",title:a("官方客户端会展示这个模型"),children:[s.jsx("i",{"aria-hidden":"true"}),a("可见")]}):Q==="undeclared"?s.jsx("span",{className:"rate",title:a("这家有可见性判据,但这一条上游没有表态 —— 按可见处理"),children:"—"}):s.jsx("span",{className:"rate",title:a("这家提供商没有可见性判据(目前只有 Antigravity / Qoder / 小浣熊 / CodeArts 有)"),children:"—"})}function U(H){const Q=sS(H),J=xR(H.capOverrides),oe=typeof Q.maxInputTokens=="number"?Q.maxInputTokens:null,ee=typeof Q.maxOutputTokens=="number"?Q.maxOutputTokens:null,se=a("上下文窗口 {input} / 最大输出 Token {output} —— 点击修改模型能力",{input:ob(oe),output:ob(ee)})+q(H);return s.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"caps-open",title:se,onClick:()=>o8(H.provider||"",H.id),children:[s.jsxs("span",{className:Te("cap-num",oe===null&&"unset",Fm(H,"maxInputTokens")==="modelsdev"&&"filled"),children:[dV(oe),J.includes("maxInputTokens")?s.jsx("i",{className:"cap-mark",title:a("已覆盖上游值")}):null]}),s.jsx("span",{className:"cap-sep",children:"/"}),s.jsxs("span",{className:Te("cap-num",ee===null&&"unset",Fm(H,"maxOutputTokens")==="modelsdev"&&"filled"),children:[dV(ee),J.includes("maxOutputTokens")?s.jsx("i",{className:"cap-mark",title:a("已覆盖上游值")}):null]})]})}function q(H){const Q=["maxInputTokens","maxOutputTokens"].filter(J=>Fm(H,J)==="modelsdev").map(J=>Bm[J]);return Q.length?a(";其中 {keys} 由 models.dev 补齐",{keys:Q.join(a("、"))}):""}function W(H){const Q=sS(H),J=xR(H.capOverrides);return s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"caps-open caps-badges",title:a("对下游声明的能力(工具调用 / 图片识别 / 视频识别 / 支持思考)—— 点击修改"),onClick:()=>o8(H.provider||"",H.id),children:cV.map(oe=>{const ee=Q[oe]??null,se=bR(ee),le=J.includes(oe),te=Fm(H,oe);return s.jsxs("span",{className:Te("cap-dot",se,te==="modelsdev"&&"filled",le&&"marked"),title:r0e(oe,ee,le,te),children:[JCe[oe],le?s.jsx("i",{className:"cap-mark"}):null]},oe)})})}function ne(H,Q,J){async function oe(){await Zn().wbConfirm?.ask?.({title:a("移除自定义模型"),html:a("确定移除自定义模型「{id}」?这条登记会被直接移除,之后 /v1/models 不再广告它、请求它也会被拒。",{id:AP(Q.id)}),okText:a("移除"),okClass:"danger"})&&BP(jh(Q),()=>t8(Q.provider||"",Q.id),ts(Q.provider||"")?a("模型已移除"):a("自定义模型已移除"))}switch(H.key){case"check":return s.jsx(Xe,{className:Qc("cell-check",H.align),children:s.jsx(Wr,{checked:d.has(jh(Q)),title:a("勾选后可批量操作"),"aria-label":a("勾选后可批量操作"),onCheckedChange:ee=>_(jh(Q),ee===!0)})});case"model":return s.jsxs(Xe,{className:Qc("cell-model",H.align),children:[s.jsxs("div",{className:"mid",children:[s.jsx("span",{className:"t","data-copy":Q.id,title:a("点击复制:{name}",{name:Q.id}),children:Q.id}),Q.kind==="image"?s.jsx("span",{className:"binding-default",title:"POST /v1/images/generations",children:a("图片生成")}):null,Q.supports_image_editing?s.jsx("span",{className:"binding-default",title:"POST /v1/images/edits",children:a("图片编辑")}):null,Q.upstreamStatus==="undeployed"?s.jsx(ye,{variant:"warning",shape:"tag",title:a("上游目录列出了这个模型,但推理端尚未识别;保留在清单中,后续探测成功后自动清除标记"),children:a("上游未部署")}):null]}),Q.name&&Q.name!==Q.id?s.jsx("div",{className:"mname",children:Q.name}):null]});case"rate":return s.jsx(Xe,{className:Qc("cell-rate",H.align),children:s.jsx("span",{className:"rate",children:Q.credits?GCe(Q.credits):"—"})});case"source":return s.jsx(Xe,{className:Qc("cell-source",H.align),children:F(Q)});case"visibility":return s.jsx(Xe,{className:Qc("cell-visibility",H.align),children:K(Q)});case"budget":return s.jsx(Xe,{className:Qc("cell-budget",H.align),children:U(Q)});case"caps":return s.jsx(Xe,{className:Qc("cell-caps",H.align),children:W(Q)});case"alias":return s.jsx(Xe,{className:Qc("cell-alias",H.align),children:Y(Q)});case"act":{const ee=jCe(Q.provider||"",Q),se=Q.source==="manual"||ts(Q.provider||"");return s.jsx(Xe,{className:Qc("cell-act r",H.align),children:s.jsxs("div",{className:"row-actions",children:[s.jsx(B,{variant:"ghost",size:"sm",disabled:!!ee,title:ee||a("以这个上游模型发一次最小请求,走真实转发链路"),onClick:()=>i({provider:Q.provider||"",id:Q.id}),children:a("测试")}),se?s.jsx(B,{variant:"ghost",size:"sm",className:"text-destructive",disabled:J,onClick:()=>{oe()},children:a("移除")}):null]})})}default:return null}}function ie(H){const Q=e.pending.has(jh(H)),J=d.has(jh(H));return s.jsx(en,{className:Te(J&&"sel"),children:A.map(oe=>s.jsx(v.Fragment,{children:ne(oe,H,Q)},oe.key))},`${H.provider||""}${H.id}`)}function V(){if(!j.length){const se=n?MP()?Zm()?a("自定义提供商还没有模型:先在左栏选一家,点「添加模型」登记,或「获取上游模型」从上游拉取"):a(g?"该提供商已不存在(可能已被删除),请刷新列表":"这家还没有模型:点「添加模型」登记,或「获取上游模型」从上游拉取"):a("加载中…"):e.data?VS().size?a("模型清单为空:已有可用账号,请点「获取模型」拉取目录"):a("暂无模型(请先添加账号)"):a("加载中…");return s.jsx(en,{children:s.jsx(Xe,{colSpan:E,className:"empty",children:se})})}if(!S.length)return s.jsx(en,{children:s.jsx(Xe,{colSpan:E,className:"empty",children:w?a("没有匹配「{keyword}」的模型",{keyword:w}):a("没有匹配当前筛选的模型")})});const H=t==="all"||Zm(),Q=H&&!w&&e.stateFilter==="all"&&!P.paged,J=new Map;for(const se of S){const le=se.provider||"";J.has(le)||J.set(le,{label:se.providerLabel||le||a("未知"),items:[]}),J.get(le)?.items.push(se)}const oe=[];let ee=0;for(const[se,le]of J){le.items.sort((ce,ae)=>{const _e=+!Ib(ce)-+!Ib(ae);if(_e!==0||N==="default")return _e;const de=A8(ce.credits),Se=A8(ae.credits);return de===null||Se===null?de===Se?0:de===null?1:-1:N==="rate-asc"?de-Se:Se-de});const te=e.expanded.has(se)||!Q,re=te?le.items:le.items.slice(0,Fq),he=le.items.length-re.length,pe=P.paged?Math.max(0,P.rangeStart-1-ee):0,Ne=P.paged?Math.min(re.length,P.rangeEnd-ee):re.length,me=pe0?a("(续)"):"",a("{n} 个模型",{n:le.items.length})]})},`group:${se}`));for(const ce of me)oe.push(ie(ce));ee+=re.length,he>0?oe.push(s.jsx(en,{className:"tr-more",children:s.jsx(Xe,{colSpan:E,children:s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>J1e(se),children:a("展开其余 {n} 个模型 ▾",{n:he})})})},`more:${se}`)):te&&Q&&le.items.length>Fq&&oe.push(s.jsx(en,{className:"tr-more",children:s.jsx(Xe,{colSpan:E,children:s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>eCe(se),children:a("收起 ▴")})})},`collapse:${se}`))}return oe}return s.jsxs(s.Fragment,{children:[s.jsx(tt,{render:s.jsx("section",{}),className:"panel",children:s.jsxs("div",{className:"mm",children:[G(),s.jsxs("div",{className:"mm-main",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsxs("div",{className:"mm-titlebar",children:[s.jsxs("div",{className:"mm-title",children:[t==="all"||t===Ra?ng(t,"",YP):ng(t,O),s.jsx("h2",{children:O}),s.jsxs("span",{className:"mm-meta",children:[s.jsx("b",{children:j.length}),a(" 个模型 · 已启用 "),s.jsx("b",{children:R}),a(" · 有映射 "),s.jsx("b",{children:T})]})]}),s.jsxs("div",{className:"head-actions",children:[s.jsx(B,{id:"btn-refresh-models",title:ts(t)?a("从这一家的上游拉一份模型清单,勾选要哪些再导入(已添加的不会重复导入)"):a("刷新模型管理页里各提供商的远程模型目录,逐家结果列在弹窗里"),onClick:()=>c8(),children:a("获取模型")}),s.jsx(B,{id:"btn-add-custom-model",variant:"outline",size:"sm",onClick:()=>sCe(),children:a("+ 添加模型")}),s.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"mm-filter-open hidden max-[767px]:inline-flex",onClick:()=>p(!0),"aria-label":a("打开筛选"),children:[a("筛选"),(()=>{const H=(e.stateFilter!=="all"?1:0)+(e.visibilityFilter!=="all"?1:0)+(e.sort!=="default"?1:0)+(String(e.search||"").trim()?1:0);return H>0?s.jsx(ye,{variant:"brand",shape:"tag",className:"mm-filter-badge",children:H}):null})()]})]})]}),s.jsxs(w0,{open:h,onOpenChange:p,title:a("筛选"),inlineClassName:"mm-filters",bodyClassName:"model-filter-body",actions:s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{n8("all"),s8("all"),r8("default"),a8("")},children:a("清空")}),children:[s.jsx(dn,{options:L1e,value:e.stateFilter,onValueChange:n8,"aria-label":a("按状态筛选"),className:"shrink-0"}),s.jsx(dn,{options:F1e,value:e.visibilityFilter,onValueChange:s8,"aria-label":a("按可见性筛选"),className:"shrink-0"}),s.jsx(dn,{options:$1e,value:e.sort,onValueChange:r8,"aria-label":a("按倍率排序"),className:"shrink-0"}),s.jsxs(uo,{className:"w-full min-[768px]:w-[240px] flex-none min-[768px]:flex-none",id:"models-search",children:[s.jsx(ho,{type:"search",placeholder:a("搜索模型 ID / 名称 / 映射名…"),"aria-label":a("搜索模型"),autoComplete:"off",value:e.search,onChange:H=>a8(H.currentTarget.value)}),s.jsx(fo,{"aria-hidden":"true",children:"⌕"})]}),M.length>0?s.jsxs(ye,{variant:"brand",className:"batch-chip",children:[a("已选 "),s.jsx("b",{children:M.length}),a(" 个"),s.jsx(B,{id:"btn-batch-models",variant:"outline",size:"xs",title:a("对选中的 {n} 个模型执行批量操作",{n:M.length}),onClick:()=>c(!0),children:a("批量操作")})]}):null]})]}),s.jsx("div",{className:"models-table-wrap",children:s.jsxs(ea,{container:!1,className:"models-table",ref:H=>oCe(H),children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"c-check","data-col":"check"}),s.jsx("col",{className:"c-model","data-col":"model"}),s.jsx("col",{className:"c-rate","data-col":"rate"}),s.jsx("col",{className:"c-visibility","data-col":"visibility"}),s.jsx("col",{className:"c-source","data-col":"source"}),s.jsx("col",{className:"c-budget","data-col":"budget"}),s.jsx("col",{className:"c-caps","data-col":"caps"}),s.jsx("col",{className:"c-alias","data-col":"alias"}),s.jsx("col",{className:"c-act","data-col":"act"})]}),s.jsx(Ta,{children:s.jsxs(en,{children:[s.jsx(ft,{"data-col":"check",children:z}),s.jsx(ft,{"data-col":"model",children:a("上游模型")}),s.jsx(ft,{"data-col":"rate",children:a("倍率")}),s.jsx(ft,{"data-col":"visibility",title:a("这个模型在官方客户端里是否会被展列;不展示的那些默认已关闭(含默认绑定)"),children:a("可见性")}),s.jsx(ft,{"data-col":"source",children:a("来源")}),s.jsxs(ft,{"data-col":"budget",children:[a("上下文 / 输出"),s.jsx("span",{className:"th-help","aria-hidden":"true",title:a("数字带虚线底 = 由 models.dev 补齐;右上角小点 = 你手动覆盖过;— = 未声明。点任意一格可改。"),children:s.jsx("svg",{viewBox:"0 0 24 24",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]})})})]}),s.jsxs(ft,{"data-col":"caps",children:[a("能力"),s.jsx("span",{className:"th-help","aria-hidden":"true",title:a("圆点带内侧描边 = 由 models.dev 补齐;右上角小点 = 你手动覆盖过;虚线圈 = 未声明。悬停某一枚可看逐项出处。"),children:s.jsx("svg",{viewBox:"0 0 24 24",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]})})})]}),s.jsxs(ft,{"data-col":"alias",children:[a("模型映射"),s.jsx("span",{className:"th-help","aria-hidden":"true",title:a("每条映射 = 对外名 → 上游模型;原始 ID 与别名有独立开关,默认绑定永远存在(没有映射时是合成的那条)。"),children:s.jsx("svg",{viewBox:"0 0 24 24",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]})})})]}),s.jsx(ft,{className:"r","data-col":"act",children:a("操作")})]})}),s.jsx(ga,{id:"models",children:V()})]})}),s.jsx(fd,{className:"models-panel-foot",leading:Zm()?s.jsxs(s.Fragment,{children:[a("这里是"),s.jsx("b",{children:a("全部自定义提供商")}),a("的模型合集:每家的清单互相独立,别名也只在自己那家内生效;要改名称 / 协议 / Base URL,到账号页该家账号的「设置」→ 提供商一栏。")]}):n?s.jsxs(s.Fragment,{children:[a("自定义提供商的清单"),s.jsx("b",{children:a("只属于这一家")}),a(":这里的模型不会出现在其他家,别名也只在这一家内生效。改名称 / 协议 / Base URL 在账号页该家账号的「设置」→ 提供商一栏;整家不要了,鼠标移到左栏这家上点 × 删除(连同名下账号)。")]}):void 0,total:S.length,range:P.paged?{start:P.rangeStart,end:P.rangeEnd}:null,page:P.page,pageCount:P.pageCount,size:P.size,onSizeChange:P.setSize,onPageChange:P.goto})]})]})}),e.mapping?s.jsx(rAe,{context:e.mapping,onClose:rCe}):null,e.customModel?s.jsx(sAe,{initial:e.customModel,onClose:aCe}):null,e.capability?s.jsx(hCe,{context:e.capability,onClose:iCe}):null,r?s.jsx(kCe,{target:r,onClose:()=>i(null)}):null,o?s.jsx(CCe,{models:M,onClose:()=>c(!1),onDone:()=>{f(new Set),c(!1)}}):null]})}const nAe=a("绑定在「对外名 → 上游模型」这一条映射上的思考等级(列表照抄 OmniProxy 的手动绑定),选「不覆盖」表示不给这条映射指定等级。它会跟着这条映射注入转发,由承载的那家翻译成自己的档位字段(CatPaw 归并成 low/high/max,Qoder 按模型声明的档位归一)。以下几种情况故意不注入:① off / none(关闭思考)—— 本项目没有安全的表达方式;② 表外的自定义等级(各家能力范围不同,无法判断上游收不收);③ 客户端请求体里已经自己指定了档位(那是更明确的意图,绑定不覆盖);④ 这家上游不认识档位字段(如 WorkBuddy / 小浣熊 / AutoClaw / Cline)。注入与跳过都会写进详细日志。");function E8(e,t,n){const r=Zq(e),i=(t||"").trim(),o=r.find(c=>c.id.toLowerCase()===i.toLowerCase());return o?o.id:i||r[0]?.id||""}function rAe({context:e,onClose:t}){const n=!!e.alias,[r,i]=v.useState(()=>e.provider||LP()[0]?.id||""),[o,c]=v.useState(e.alias||""),[d,f]=v.useState(()=>E8(r,e.target)),[h,p]=v.useState(""),[g,x]=v.useState(!1),[y,j]=v.useState(()=>{const _=kb(Ab().data,C8(r,d)),I=n?HP(e.alias,e.target,e.provider):"";return I&&_.includes(I)?{select:I,custom:""}:{select:I?No:"",custom:I}}),w=kb(Ab().data,C8(r,d)),S=(()=>{const _=LP();for(const I of[e.provider,r])I&&!_.some(L=>L.id===I)&&_.push({id:I,label:a(Zn().wbProviders?.labelOf?.(I)||I)});return _})(),N=(()=>{const _=Zq(r),I=(d||"").trim();return I&&!_.some(L=>L.id.toLowerCase()===I.toLowerCase())&&_.unshift({id:I,label:a("{name}(不在该家当前清单里)",{name:I}),off:!0}),_})(),A=S.find(_=>_.id===r)?.label||r||a("(全局)"),E=y.select&&y.select!==No&&!w.includes(y.select)?{select:No,custom:y.custom||y.select}:y,O=E.select===No?E.custom.trim():E.select,R=E.select===No;function T(_){i(_),f(E8(_,d))}async function P(){if(g)return;const _=n?e.alias||"":o.trim(),I=d;if(!_){p(a("请填写对外映射名"));return}if(!I){p(a("该提供商当前没有可选的上游模型"));return}if(!r){p(a("请选择提供商"));return}if(!n&&Ad(_,I)&&Rb().some(L=>Ad(L.id,I)&&Ad(L.provider,r))){p(a("原始 ID 已作为默认绑定,请直接使用该绑定的开关或等级按钮"));return}x(!0),p(a("保存中…"));try{wh(await YS(r,_,I,{reasoning:O})),x(!1),t();const L=O?a(" · 思考等级 {level}",{level:O}):"",D=a(Zn().wbProviders?.labelOf?.(r)||r);Ia(n?a("✅ 已更新 {name} 的思考等级",{name:_}):a("✅ 已添加映射 {name} → {target}({label}){suffix}",{name:_,target:I,label:D,suffix:L}))}catch(L){p(a("保存失败:{message}",{message:Cd(L)})),x(!1)}}const M=_=>{_.key==="Enter"&&(_.preventDefault(),P())};return s.jsx(St,{open:!0,onOpenChange:(_,I)=>{if(!_){if(g){I.cancel();return}t()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a(n?"设置思考等级":"添加模型映射")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"mapping-provider",children:a("提供商")}),s.jsxs(ht,{value:r,disabled:!0,onValueChange:_=>T(String(_)),children:[s.jsx(mt,{id:"mapping-provider",className:"w-full",children:s.jsx(pt,{children:S.find(_=>_.id===r)?.label||r})}),s.jsx(gt,{children:S.map(_=>s.jsx(qe,{value:_.id,children:_.label},_.id))})]})]}),s.jsxs("div",{className:"grid grid-cols-[1fr_24px_1fr] items-end gap-2.5",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"mapping-alias",children:a("对外映射名(下游请求时用)")}),s.jsx(Be,{id:"mapping-alias",maxLength:128,placeholder:a("例如 gpt-4o"),autoComplete:"off",autoFocus:!n,value:o,disabled:n,onChange:_=>c(_.currentTarget.value),onKeyDown:M})]}),s.jsx("div",{className:"pb-2 text-center text-muted-foreground",children:"→"}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"mapping-upstream",children:a("转发到上游模型")}),s.jsxs(ht,{value:d,disabled:!0,onValueChange:_=>f(String(_)),children:[s.jsx(mt,{id:"mapping-upstream",className:"w-full",children:s.jsx(pt,{children:N.find(_=>_.id===d)?.label||d})}),s.jsx(gt,{children:N.map(_=>s.jsxs(qe,{value:_.id,children:[_.label,_.off?a("(已禁用)"):""]},_.id))})]})]})]}),s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 font-mono text-[12px] text-subtle",children:[a("下游请求 "),s.jsx("b",{className:"text-primary-fg",children:o.trim()||a("<对外名>")}),a(" → 转发")," ",s.jsx("b",{className:"text-primary-fg",children:d||a("<上游模型>")}),a("({label})",{label:A}),O?s.jsxs(s.Fragment,{children:[a(" · 思考等级 "),s.jsx("b",{className:"text-primary-fg",children:O})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-[7px]",children:[s.jsx(Ie,{htmlFor:"mapping-reasoning",children:a("思考等级")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("思考等级的注入规则")}),children:"?"}),s.jsx(Ml,{children:nAe})]})]}),s.jsxs(ht,{value:E.select,onValueChange:_=>{const I=String(_);j(L=>({...L,select:I}))},children:[s.jsx(mt,{id:"mapping-reasoning",className:"w-full",autoFocus:n,children:s.jsx(pt,{children:E.select===No?a("自定义等级…"):E.select||a("不覆盖")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("不覆盖")}),w.map(_=>s.jsx(qe,{value:_,children:_},_)),s.jsx(qe,{value:No,children:a("自定义等级…")})]})]}),R?s.jsx(Be,{id:"mapping-reasoning-custom",maxLength:32,autoFocus:!0,placeholder:a("自定义等级(例如 custom-high)"),autoComplete:"off",disabled:g,value:E.custom,onChange:_=>j(I=>({...I,custom:_.currentTarget.value})),onKeyDown:M}):null]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("对外名可自由命名,允许与上游模型 ID 同名(同名时该上游的原生路由优先,映射作兜底); 支持字母、数字与 "),s.jsx("code",{children:"- _ . / :"}),a("。同一对外名可在多个提供商各添加一条: 下游用同一个名字请求,网关按账号优先级主备切换,失败自动落到下一个提供商。")]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:h})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:g,onClick:()=>{P()},children:a(n?"保存等级":"保存映射")})]})]})})}function sAe({initial:e,onClose:t}){const[n,r]=v.useState(e.provider),[i,o]=v.useState(""),[c,d]=v.useState(""),[f,h]=v.useState(!1),p=(()=>{const w=Y1e();return n&&!w.some(S=>S.id===n)&&w.push({id:n,label:a(Zn().wbProviders?.labelOf?.(n)||n)}),w})(),g=p.some(w=>w.id===n)?n:p[0]?.id||"",x=p.find(w=>w.id===g)?.label||g||a("(未选)");async function y(){if(f)return;const w=i.trim();if(!g){d(a("请选择提供商"));return}if(!w){d(a("请填写上游模型 ID"));return}h(!0),d(a("保存中…"));try{const S=await Q1e(g,w);wh(S),h(!1),t();const N=p.find(A=>A.id===g)?.label||g;if(ts(Qm()))Ia(a("✅ 已登记模型 {name}({label})",{name:w,label:N}));else{const A=S;Array.isArray(A?.models)&&A.models.some(O=>O.id===w&&(O.provider||"")===g)?Ia(a("✅ 已登记自定义模型 {name}({label})",{name:w,label:N})):Ia(a("✅ 已登记 {name}({label}),但该提供商还没有可用账号,这一行要加上账号后才会显示",{name:w,label:N}),"err")}}catch(S){d(a("保存失败:{message}",{message:Cd(S)})),h(!1)}}const j=w=>{w.key==="Enter"&&(w.preventDefault(),y())};return s.jsx(St,{open:!0,onOpenChange:(w,S)=>{if(!w){if(f){S.cancel();return}t()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("添加自定义模型")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"custom-model-provider",children:a("提供商")}),s.jsxs(ht,{value:g,disabled:e.locked,onValueChange:w=>r(String(w)),children:[s.jsx(mt,{id:"custom-model-provider",className:"w-full",children:s.jsx(pt,{children:x})}),s.jsx(gt,{children:p.map(w=>s.jsx(qe,{value:w.id,children:w.label},w.id))})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"custom-model-id",children:a("上游模型 ID")}),s.jsx(Be,{id:"custom-model-id",maxLength:128,placeholder:a("例如 gpt-5.5-preview"),autoComplete:"off",spellCheck:!1,autoFocus:!0,value:i,onChange:w=>o(w.currentTarget.value),onKeyDown:j})]}),s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 font-mono text-[12px] text-subtle",children:[a("在 "),s.jsx("b",{className:"text-primary-fg",children:x}),a(" 上登记上游模型")," ",s.jsx("b",{className:"text-primary-fg",children:i.trim()||a("<上游模型 ID>")}),a("(登记后即可用这个名字请求)")]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("填上游真正认识的那个模型 ID(不是给下游用的名字)。登记后它会进入该家的模型清单: 表格里出现这一行、"),s.jsx("code",{children:"/v1/models"}),a(" 会广告它、请求它也会被转发到这家。 支持字母、数字与 "),s.jsx("code",{children:"- _ . / :"}),a("。")]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("「来源」列会标成"),s.jsx("b",{children:a("手动")}),a(",与远程目录 / 内置清单区分开。删除自定义模型是"),s.jsx("b",{children:a("直接移除")}),a("这条登记(不像内置模型那样只是隐藏),因为它的存在完全由这次登记决定。")]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:c})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:f,onClick:()=>{y()},children:a("保存")})]})]})})}const T8='.page[data-page="gateway"]';let WP=null;function O8(){if(WP)return;const e=document.querySelector(T8);e&&(e.replaceChildren(),WP=wn.createRoot(e),WP.render(s.jsx(tAe,{})))}document.querySelector(T8)?O8():document.addEventListener("DOMContentLoaded",O8,{once:!0});function R8({children:e,installed:t}){return s.jsx(tt,{render:s.jsx("article",{}),className:"flex flex-col "+(t?"border-success/40":""),children:e})}function P8({id:e,name:t,version:n,icon:r,children:i}){const o=yb(e,t);return s.jsxs("div",{className:"flex gap-3 px-4 pt-4",children:[s.jsx("div",{className:"grid size-11 shrink-0 place-items-center overflow-hidden rounded-xl bg-primary-soft text-[19px] font-bold text-primary-fg",children:r?s.jsx("img",{src:r,alt:"",className:"size-full object-cover"}):o.slice(0,1)}),s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-1.5",children:[s.jsxs("h3",{className:"flex flex-wrap items-center gap-2 text-[14px] font-semibold leading-snug",children:[o,n?s.jsxs("span",{className:"text-[11.5px] font-normal tabular-nums text-muted-foreground",children:["v",n]}):null]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:i})]})]})}function I8({operation:e}){const t=e.stage==="downloading"?a("正在下载…"):e.stage==="verifying"?a("正在校验包内容…"):a("正在安装…"),n=e.stage==="downloading";return s.jsxs("div",{className:"px-4 pb-4 pt-3","aria-live":"polite",children:[s.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2 text-[11.5px]",children:[s.jsx("span",{className:"text-subtle",children:e.required?`${a("正在补齐插件…")} · ${t}`:t}),s.jsx("span",{className:"tabular-nums text-muted-foreground",children:n?e.total>0?`${MS(e.received)||"0 B"} / ${MS(e.total)} · ${Math.round(e.percent||0)}%`:MS(e.received)||"0 B":a("请稍候")})]}),s.jsx(nm,{value:n?e.percent:null,"aria-label":t})]})}function aAe({item:e,target:t,operation:n,disabled:r,onInstall:i,onNotes:o}){const c=e.platforms.find(f=>f.target===t),d=!!(e.version&&c&&!e.error);return s.jsxs(R8,{children:[s.jsxs(P8,{id:e.id,name:e.name,version:e.version,icon:e.icon,children:[e.official?s.jsx(ye,{variant:"brand",children:a("官方")}):null,e.prerelease?s.jsx(ye,{variant:"warning",children:a("beta 版")}):null,e.version?null:s.jsx(ye,{variant:"outline",children:a("暂未发布")})]}),s.jsx("p",{className:"px-4 pt-2.5 text-[12px] leading-relaxed text-subtle",children:sq(e.id,e.description)}),s.jsxs("div",{className:"flex flex-wrap gap-3 px-4 pt-3 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:DNe(t)}),s.jsx("span",{children:MS(c?.size||0)||a("当前平台暂无包")})]}),e.error?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(e.reason)}):null,n?.error?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(n.error)}):null,n?.active?s.jsx(I8,{operation:n}):s.jsxs("div",{className:"mt-auto flex gap-2 px-4 pb-4 pt-3.5",children:[s.jsx(B,{size:"sm",disabled:r||!d,onClick:i,children:a("下载并安装")}),e.version?s.jsx(B,{variant:"outline",size:"sm",onClick:o,children:a("查看更新日志")}):null]})]})}function iAe({pack:e,store:t,host:n,update:r,operation:i,disabled:o,onEnabled:c,onSettings:d,onRemove:f,onUpdate:h,onNotes:p}){const g=e.updateRequired===!0,x=r?.error===!0&&!g,y=e.host===void 0?n:e.host;return s.jsxs(R8,{installed:!0,children:[s.jsxs(P8,{id:e.id,name:t?.name||e.name,version:e.version,icon:e.icon||t?.icon,children:[s.jsx(ye,{variant:e.enabled?"default":"secondary",children:e.enabled?a("已启用"):a("已停用")}),s.jsx(ye,{variant:e.signed?"success":"warning",children:e.signed?a("已签名"):a("未签名")}),e.version.includes("-")?s.jsx(ye,{variant:"warning",children:a("beta 版")}):null,g?s.jsx(ye,{variant:"destructive",children:a("需要补齐插件")}):r?.available?s.jsx(ye,{variant:"brand",children:a("有更新")}):null,e.entryPresent?null:s.jsx(ye,{variant:"destructive",children:a("文件缺失")})]}),s.jsx("p",{className:"px-4 pt-2.5 text-[12px] leading-relaxed text-subtle",children:sq(e.id,t?.description||e.description)}),s.jsx("p",{className:"px-4 pt-2 text-[11px] text-muted-foreground",children:a("{count} 家提供商 · 安装于 {time}",{count:String(e.providers.length),time:rq(e.installedAt)})}),s.jsxs("div",{className:"flex flex-wrap gap-3 px-4 pt-3 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:y?.running?a("运行中"):a("未运行")}),s.jsxs("span",{children:[a("已加载")," ",a("{count} 家",{count:String(e.providers.filter(j=>j.loaded).length)})]})]}),g?s.jsxs("div",{className:"mx-4 mt-3 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px]","aria-live":"polite",children:[s.jsx("p",{className:"font-medium text-destructive",children:a("当前网关要求插件版本不低于 v{version},补齐前暂不加载。",{version:e.requiredVersion||""})}),s.jsx("p",{className:"mt-1 text-subtle",children:e.signed?a("正在自动补齐官方插件,不受日常更新开关和通道限制。"):a("未签名包不会自动覆盖;点击「补齐插件」将安装官方签名包。")}),r?.reason?s.jsx("p",{className:"mt-1 "+(r.error?"text-destructive":"text-subtle"),children:Wl(r.reason)}):null,r?.retryAt&&r.retryAt>Date.now()?s.jsx("p",{className:"mt-1 text-subtle",children:a("下次自动重试:{time}",{time:rq(r.retryAt)})}):null]}):null,e.entryPresent?null:s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:a("插件包的可执行文件不在磁盘上(可能被手工删除或移动),请重新安装。")}),r?.available&&!g?s.jsxs("div",{className:"mx-4 mt-3 flex flex-wrap items-center justify-between gap-2 border-t border-hairline pt-3",children:[s.jsx("span",{className:"text-[12px] font-medium text-primary-fg",children:a("可更新到 v{version}",{version:r.latest||""})}),s.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-subtle",children:[a("更新日志"),s.jsx(B,{variant:"outline",size:"xs",onClick:p,children:a("查看")})]})]}):null,r?.error&&!g?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(r.reason)}):null,i?.error?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(i.error)}):null,y?.lastError?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:y.lastError}):null,i?.hostError?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-warning",children:i.hostError}):null,i?.active?s.jsx(I8,{operation:i}):s.jsxs("div",{className:"mt-auto flex flex-wrap items-center gap-2 px-4 pb-4 pt-3.5",children:[s.jsxs(Ie,{className:"flex items-center gap-1.5 text-[12px] text-subtle",children:[a("启用"),s.jsx(cn,{checked:e.enabled,disabled:o,onCheckedChange:j=>c(j===!0)})]}),s.jsx(B,{variant:"outline",size:"sm",onClick:d,"aria-haspopup":"dialog",children:a("设置")}),s.jsx(B,{variant:"outline",size:"sm",disabled:o,onClick:f,children:a("卸载")}),s.jsx("span",{className:"flex-1"}),g?s.jsx(B,{size:"sm",disabled:o||r?.repairing===!0,onClick:h,children:r?.repairing?a("正在补齐插件…"):a("补齐插件")}):r?.available?s.jsx(B,{size:"sm",disabled:o||x,onClick:h,children:a("更新到 v{version}",{version:r.latest||""})}):s.jsx("span",{className:"text-[11px] "+(r?.error?"text-destructive":"text-muted-foreground"),children:r?.checked?Wl(r.reason)||a("已是最新"):a("尚未检查更新")})]})]})}function hn(){return window}function Ss(e,t){hn().wbApp?.toast?.(e,t)}function ks(e){return nq(e,a,"update")}function M8(e){const t=String(e||"").trim();return/^https?:\/\//i.test(t)?t:""}async function Lb(e){const t=M8(e);if(!t){Ss(a("链接地址不受支持"),"err");return}try{await hn().workbuddyDesktop?.openReleasePage(t)}catch(n){Ss(a("打开链接失败:{error}",{error:ks(n)}),"err")}}const oAe=[{no:"1127656296",nearlyFull:!0},{no:"1130894674",nearlyFull:!0},{no:"1108276647",nearlyFull:!1}],lAe=[{id:"telegram",url:"https://t.me/+9gM8YPvgRL02NGRl"}];function XP(e){return hn().wbMarkdown?.render?.(e)||""}function zb(e){const n=e.target?.closest?.("[data-external]");n&&(e.preventDefault(),Lb(n.dataset.external||""))}async function _8(){try{const e=await hn().workbuddyDesktop?.getUpdateStatus?.();e&&(e.checked!==!1||e.channelChanged)&&hn().wbApp?.updateUpdateBadge?.(e)}catch(e){console.warn("读取版本检查结果失败:",ks(e))}}const XS="__proxy_other__",D8={proxyChoice:null,proxyLoaded:!1,pool:null,poolError:""};async function L8(){const e=hn().workbuddyDesktop,t={...D8};if(!e?.getUpdateProxy)return t;try{const n=await e.getUpdateProxy();if(!n||!Object.prototype.hasOwnProperty.call(n,"proxy"))throw new Error("更新线路响应异常");t.proxyChoice=n.proxy??null,t.proxyLoaded=!0}catch{}try{if(typeof e.getProxyPool!="function")throw new Error("桥未提供代理池方法");const r=(await e.getProxyPool())?.items;if(!Array.isArray(r))throw new Error("代理池响应异常");t.pool=r,JU(r)}catch(n){t.pool=[],t.poolError=ks(n)}return t}async function cAe(e){if(e===XS)return null;const t=hn().workbuddyDesktop;if(!t?.setUpdateProxy)return null;const n=e===""?null:{source:"pool",proxyId:e.slice(tl.length)};try{const r=await t.setUpdateProxy({proxy:n}),i=r?.proxy??null,o=r?.saved!==!1;return o?Ss(i?a("✅ 更新出网已切换为 {label}",{label:i.label||a("指定代理")}):a("✅ 更新出网已切换为直连")):Ss(a("出网线路已切换,但写入磁盘失败(重启后会恢复原线路)"),"err"),{choice:i,saved:o}}catch(r){return Ss(a("保存失败:{error}",{error:ks(r)}),"err"),null}}function uAe(e){const t=e.proxyChoice,n=t?.config?.source||t?.source,r=t?.label||a(n==="custom"?"自定义代理":"已设置"),i=Array.isArray(e.pool)?e.pool:[],o=!!t?.error;let c="";n==="pool"&&t?.config?.proxyId?c=`${tl}${t.config.proxyId}`:t&&(c=XS);const d=[{value:"",label:a("直连")}];for(const f of i)d.push({value:`${tl}${f.id}`,label:dm(f),disabled:f.enabled===!1});if(e.pool===null?d.push({value:"__hint_pool__",label:a("正在读取代理列表…"),disabled:!0}):i.length||d.push({value:"__hint_pool__",label:e.poolError?a("代理列表读取失败"):a("还没有代理(去「网络代理」页添加)"),disabled:!0}),c===XS){const f=n==="clash"?a("Clash 出口:"):n==="custom"?a("自定义:"):"";d.push({value:XS,label:`${f}${r}${o?a("(不可用)"):""}`})}else n==="pool"&&!i.some(f=>`${tl}${f.id}`===c)&&d.push({value:c,label:`${r}${o?a("(不可用)"):""}`});return{current:c,items:d,selected:d.find(f=>f.value===c),broken:o,title:o?a("当前线路不可用:{error};请重新选择代理或切回直连",{error:String(t?.error||"")}):a("检查更新与下载安装包使用所选线路;未选择代理时先直连,失败后尝试 Clash Verge 混合端口;指定代理不可用时不会自动改走直连。")}}function dAe({value:e,onClose:t}){const n=e?.notes?.trim()||"",r=n?XP(n):"";return s.jsx(St,{open:e!==null,onOpenChange:i=>{i||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("更新日志")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]",children:[s.jsx("strong",{children:e?.name}),s.jsxs("span",{className:"text-subtle",children:["v",e?.version]}),e?.prerelease?s.jsx(ye,{variant:"warning",children:a("beta 版")}):null]}),s.jsx("div",{className:"max-h-[46vh] overflow-y-auto overscroll-contain pr-1.5",onClick:zb,children:r?s.jsx(Qo,{className:"md-body",html:r}):n?s.jsx("div",{className:"whitespace-pre-wrap text-[12.5px] leading-relaxed text-subtle",children:n}):s.jsx("p",{className:"text-[12px] text-muted-foreground",children:a("这个版本没有填写发布说明。")})})]}),e?.page?s.jsx(Pt,{children:s.jsx(B,{variant:"outline",size:"sm",onClick:()=>{Lb(e.page||"")},children:a("查看发布页面")})}):null]})})}function fAe({pack:e,name:t,disabled:n,onClose:r,onEnabled:i,onProvider:o}){const[c,d]=v.useState(""),f=v.useId(),h=c.trim().toLocaleLowerCase(),p=e.providers.filter(g=>!h||`${g.label} ${g.id}`.toLocaleLowerCase().includes(h));return s.jsx(St,{open:!0,onOpenChange:g=>{g||r()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsxs(jt,{className:"min-w-0 break-words",children:[yb(e.id,t||e.name)," · ",a("设置")]})}),s.jsxs(Ct,{className:"min-h-0 gap-3.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[12px] text-muted-foreground",children:[s.jsxs("span",{className:"tabular-nums",children:["v",e.version]}),s.jsx(ye,{variant:"outline",children:a("{count} 家",{count:e.providers.length})})]}),s.jsxs(Ie,{htmlFor:`${f}-enabled`,className:"text-[12px] text-subtle",children:[a("启用"),s.jsx(cn,{id:`${f}-enabled`,checked:e.enabled,disabled:n,onCheckedChange:g=>i(g===!0)})]})]}),s.jsx(bT,{className:"text-[12px] leading-relaxed text-subtle",children:a("这个包提供的提供商(可单独停用某一家)")}),e.enabled?null:s.jsx(ye,{variant:"secondary",className:"self-start",children:a("已停用")}),e.providers.length?s.jsxs(s.Fragment,{children:[s.jsx(Be,{type:"search",value:c,placeholder:a("搜索提供商"),"aria-label":a("搜索提供商"),onChange:g=>d(g.currentTarget.value)}),s.jsx("div",{className:"max-h-[46vh] min-h-0 overflow-y-auto overscroll-contain rounded-md border border-hairline",children:p.length?s.jsx("div",{className:"grid grid-cols-1 gap-2 p-2 min-[640px]:grid-cols-2",children:p.map(g=>s.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-md border border-hairline bg-surface-2 px-3 py-2.5",children:[s.jsxs(Ie,{htmlFor:`${f}-${g.id}`,className:"min-w-0 flex-1 flex-col items-start gap-0.5",children:[s.jsx("span",{className:"text-[12.5px] font-medium break-words text-foreground",children:a(g.label)}),s.jsx("code",{className:"max-w-full text-[11px] break-all text-muted-foreground",children:g.id}),g.enabled&&!g.loaded?s.jsx(ye,{variant:"secondary",className:"mt-1",children:a("未加载")}):null]}),s.jsx(cn,{id:`${f}-${g.id}`,checked:g.enabled,disabled:n||!e.enabled,onCheckedChange:x=>o(g,x===!0)})]},g.id))}):s.jsx("p",{className:"px-3 py-5 text-center text-[12px] text-subtle",children:a("没有匹配「{keyword}」的提供商",{keyword:c.trim()})})})]}):null]}),s.jsx(Pt,{className:"justify-end",children:s.jsx(B,{variant:"outline",size:"sm",onClick:r,children:a("关闭")})})]})})}function hAe(){const[e,t]=v.useState(null),[n,r]=v.useState(""),[i,o]=v.useState(!1),[c,d]=v.useState(""),f=[{value:"auto",label:a("自动(官方优先)")},{value:"official",label:a("仅官方源")},{value:"accelerated",label:a("加速源优先")}];v.useEffect(()=>{let p=!0;return hn().workbuddyDesktop?.getGithubAccess().then(g=>{if(p){if(!g)throw new Error(a("读取设置失败:{error}",{error:a("请求失败")}));t(g),r(g.mirrorUrl)}}).catch(g=>{p&&d(ks(g))}),()=>{p=!1}},[]);async function h(p){if(!i){o(!0),d("");try{const g=await hn().workbuddyDesktop?.setGithubAccess(p);if(!g)throw new Error(a("请求失败"));t(g),r(g.mirrorUrl),Ss(g.saved===!1?a("设置已生效,但写入磁盘失败(重启后会恢复原设置)"):a("GitHub 访问设置已保存"),g.saved===!1?"err":"ok")}catch(g){d(ks(g))}finally{o(!1)}}}return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("GitHub 访问方式")}),s.jsxs(ht,{value:e?.mode||"auto",disabled:i||!e,onValueChange:p=>{h({mode:p})},children:[s.jsx(mt,{className:"w-full","aria-label":a("GitHub 访问方式"),children:s.jsx(pt,{children:f.find(p=>p.value===e?.mode)?.label||f[0].label})}),s.jsx(gt,{children:f.map(p=>s.jsx(qe,{value:p.value,children:p.label},p.value))})]}),s.jsx("p",{className:"text-[12px] text-subtle",children:e?.mode==="official"?a("只访问 GitHub 官方源,仍使用所选出网代理。"):e?.mode==="accelerated"?a("优先使用加速源,访问失败后回退官方源;不会绕过 GitHub 限流冷却。"):a("优先访问官方源,连接失败后尝试加速源;短期记住成功的源,定期恢复官方优先。")}),s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:a("GitHub 加速前缀")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Be,{value:n,disabled:i||!e||e.mode==="official",autoComplete:"off",spellCheck:!1,className:"min-w-0 flex-1","aria-label":a("GitHub 加速前缀"),placeholder:"https://gh-proxy.com/",onChange:p=>r(p.currentTarget.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h({mirrorUrl:n}))}}),s.jsx(B,{size:"sm",variant:"outline",disabled:i||!e||e.mode==="official"||n===e.mirrorUrl,onClick:()=>{h({mirrorUrl:n})},children:a("保存")})]}),s.jsx("p",{className:"text-[12px] text-subtle",children:a("填写支持 Raw、Release 和 GitHub API 的 HTTPS 加速站前缀,留空恢复默认。")}),s.jsx("p",{className:"text-[12px] text-subtle",children:a("软件更新与插件共用此设置;GitHub 令牌仅发送给官方 API。镜像安装包需要官方校验值,镜像插件包需要官方签名。")}),c?s.jsx(It,{variant:"destructive",role:"alert",className:"text-[12px] text-destructive",children:c}):null]})}function pAe(e){return e?e.error?{badge:s.jsx(ye,{shape:"tag",variant:"destructive",title:e.error,children:a("无法解密")}),hint:a("重新粘贴保存一次即可自愈")}:e.filled&&e.origin==="stored"?{badge:s.jsx(ye,{shape:"tag",variant:"success",children:a("已填写")}),hint:a("已加密存储在本地,不显示具体值;粘贴新令牌可覆盖")}:e.filled?{badge:s.jsx(ye,{shape:"tag",variant:"secondary",children:a("环境变量")}),hint:a("已配置 GITHUB_TOKEN 环境变量,界面保存的令牌优先于它")}:{badge:s.jsx(ye,{shape:"tag",variant:"outline",children:a("未填写")}),hint:a("填写后检查限额 60 → 5000 次/小时(创建令牌无需勾选任何权限)")}:{badge:s.jsx(ye,{shape:"tag",variant:"outline",children:a("读取中")}),hint:""}}function z8({plugin:e=!1,pane:t}){const[n,r]=v.useState(D8),[i,o]=v.useState(null),[c,d]=v.useState(""),[f,h]=v.useState(!1),[p,g]=v.useState(!1),x=v.useRef(0),y=uAe(n);v.useEffect(()=>{let A=!0;const E=x.current;return L8().then(O=>{A&&E===x.current&&r(O)}),hn().workbuddyDesktop?.getUpdateToken().then(O=>{A&&o(O??null)}).catch(O=>Ss(a("读取设置失败:{error}",{error:ks(O)}),"err")),()=>{A=!1}},[]);async function j(A){if(!p){x.current+=1,g(!0);try{const E=await cAe(A);if(E){r(R=>({...R,proxyChoice:E.choice}));const O=await L8();r(R=>({...O,proxyChoice:O.proxyLoaded?O.proxyChoice:E.choice,pool:O.poolError?R.pool:O.pool}))}}finally{g(!1)}}}async function w(A=!1){if(f)return;const E=c.trim();if(!(!A&&!E)){h(!0);try{const O=await hn().workbuddyDesktop?.setUpdateToken({token:A?null:E});if(!O)throw new Error(a("请求失败"));o(O),d(""),O.saved===!1?Ss(a("令牌已生效,但写入磁盘失败(重启后会丢失)"),"err"):Ss(a(A?"✅ 已清除界面保存的 GitHub 令牌(环境变量若配置过则继续生效)":"✅ GitHub 令牌已保存(加密存储,界面不再显示)"))}catch(O){Ss(a("保存失败:{error}",{error:ks(O)}),"err")}finally{h(!1)}}}const S=pAe(i),N=!!i?.error||i?.origin==="stored";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{hidden:t!=="network",children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("网络")}),e?s.jsx("p",{children:a("与软件更新共用出网代理和 GitHub 凭证,修改任意一处都会同步生效。")}):null]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsx(hAe,{}),s.jsx("div",{className:"h-px bg-hairline"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("出网代理")}),s.jsx("div",{className:"mt-1.5",children:s.jsxs(ht,{value:y.current,disabled:p,onValueChange:A=>{j(String(A))},children:[s.jsx(mt,{className:Te("w-full",y.broken&&"border-destructive-bd"),title:y.title,"aria-label":a("更新出网代理"),children:s.jsx(pt,{className:"min-w-0 truncate",children:y.selected?.label||a("直连")})}),s.jsx(gt,{children:y.items.map(A=>s.jsx(qe,{value:A.value,disabled:A.disabled,children:A.label},A.value))})]})})]})]})]}),s.jsxs("div",{hidden:t!=="token",children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("GitHub 令牌")}),e?s.jsx("p",{children:a("与软件更新共用出网代理和 GitHub 凭证,修改任意一处都会同步生效。")}):null]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[S.badge,s.jsx("span",{className:"text-[12px] text-subtle",children:S.hint})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Be,{type:"password",className:"min-w-0 flex-1",autoComplete:"new-password",spellCheck:!1,"aria-label":a("GitHub 令牌"),placeholder:i?.filled&&i.origin!=="env"?a("已填写(粘贴新令牌可覆盖)"):a("粘贴 GitHub 令牌(ghp_… / github_pat_…)"),value:c,onChange:A=>d(A.currentTarget.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),w())}}),s.jsx(B,{size:"sm",disabled:f||!c.trim(),onClick:()=>{w()},children:a("保存")}),N?s.jsx(B,{variant:"outline",size:"sm",disabled:f,onClick:()=>{w(!0)},children:a("清除")}):null]}),s.jsx("div",{children:s.jsx(B,{variant:"outline",size:"sm",title:a("在默认浏览器中打开 GitHub 的令牌创建页(备注已预设,无需勾选任何权限,直接点 Generate token)"),onClick:()=>{Lb("https://github.com/settings/tokens/new?description="+encodeURIComponent("Agent2API 更新检查"))},children:a("打开 GitHub 令牌页面")})})]})]})]})}function mAe({open:e,onClose:t,onChanged:n}){const[r,i]=v.useState(null),[o,c]=v.useState(""),[d,f]=v.useState(!1),[h,p]=v.useState("check"),g=v.useRef(null),x=[["check",a("检查计划")],["channel",a("更新通道")],["install",a("自动安装")],["network",a("网络")],["token",a("GitHub 令牌")]],y=[{value:"follow",label:a("跟随软件")},{value:"custom",label:a("单独设置")}];v.useEffect(()=>{if(!e)return;let N=!0;return p("check"),i(null),Xc("GET","/api/plugins/settings").then(A=>{N&&(i(A),c(String(A.interval)))}).catch(A=>mi(a("读取设置失败:{error}",{error:String(A)}),"err")),()=>{N=!1}},[e]);async function j(N){if(d||!r)return;const A={...r,...N};if(N.channelMode!=="follow"&&!A.stable&&!A.beta){mi(a("至少需要关注正式版或 beta 版中的一个通道"),"err");return}f(!0);try{const E=await Xc("PATCH","/api/plugins/settings",N);i(E),c(String(E.interval)),mi(E.saved===!1?a("设置已生效,但写入磁盘失败(重启后会恢复原设置)"):a("插件设置已保存"),E.saved===!1?"err":"ok"),("beta"in N||"stable"in N||"channelMode"in N)&&await n()}catch(E){mi(a("保存失败:{error}",{error:E instanceof Error?E.message:String(E)}),"err")}finally{f(!1)}}async function w(){const N=Number(o);if(!Number.isInteger(N)||N<1||N>1440){mi(a("检查间隔必须是 {min} ~ {max} 分钟",{min:1,max:1440}),"err");return}await j({interval:N})}const S=r?.stable&&r.beta?a("正式版与 beta 版"):r?.beta?a("仅 beta 版"):a("仅正式版");return s.jsx(St,{open:e,onOpenChange:N=>{N||t()},children:s.jsxs(kt,{className:"settings-dlg",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("插件设置")})}),s.jsxs(Ct,{className:"settings-dlg-body",children:[s.jsx(cm,{className:"prov-rail settings-dlg-rail","aria-label":a("插件设置"),children:s.jsxs(Bc,{className:"rail-scroll",render:s.jsx("nav",{}),children:[s.jsx("div",{className:"rail-label",children:a("插件设置")}),x.map(([N,A])=>s.jsx(Ri,{active:h===N,title:A,onClick:()=>{p(N),g.current&&(g.current.scrollTop=0)},children:A},N))]})}),s.jsxs("div",{className:"settings-dlg-main",ref:g,children:[h==="check"?s.jsxs("div",{children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("检查计划")}),s.jsx("p",{children:a("默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。")})]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs(ht,{value:r?.checkMode||"follow",disabled:d||!r,onValueChange:N=>{j({checkMode:N})},children:[s.jsx(mt,{className:"w-full","aria-label":a("检查计划"),children:s.jsx(pt,{children:y.find(N=>N.value===(r?.checkMode||"follow"))?.label})}),s.jsx(gt,{children:y.map(N=>s.jsx(qe,{value:N.value,children:N.label},N.value))})]}),r?.checkMode==="custom"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[13px] text-foreground",children:a("自动检查更新")}),s.jsx(cn,{checked:r.autoCheck,disabled:d,onCheckedChange:N=>{j({autoCheck:N===!0})},"aria-label":a("自动检查插件更新")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Be,{type:"number",min:1,max:1440,step:1,className:"w-[110px]",disabled:d||!r.autoCheck,value:o,onChange:N=>c(N.currentTarget.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),w())},"aria-label":a("检查间隔(分钟)")}),s.jsx("span",{className:"text-[12px] text-subtle",children:a("分钟({min} ~ {max})",{min:1,max:1440})}),s.jsx(B,{variant:"outline",size:"sm",disabled:d||!r.autoCheck||Number(o)===r.interval,onClick:()=>{w()},children:a("保存")})]})]}):s.jsx("p",{className:"text-[12px] text-subtle",children:r?r.autoCheck?a("当前:自动检查开启,每 {n} 分钟",{n:r.interval}):a("当前:自动检查关闭"):a("读取中")})]})]}):null,h==="channel"?s.jsxs("div",{children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("更新通道")}),s.jsx("p",{children:a("默认跟随软件的正式版和 beta 关注选择;单独设置只影响日常更新,最低版本补齐按当前软件版本选择配套包。")})]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs(ht,{value:r?.channelMode||"follow",disabled:d||!r,onValueChange:N=>{j({channelMode:N})},children:[s.jsx(mt,{className:"w-full","aria-label":a("更新通道"),children:s.jsx(pt,{children:y.find(N=>N.value===(r?.channelMode||"follow"))?.label})}),s.jsx(gt,{children:y.map(N=>s.jsx(qe,{value:N.value,children:N.label},N.value))})]}),r?.channelMode==="custom"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[13px] text-foreground",children:a("关注正式版更新")}),s.jsx(cn,{checked:r.stable,disabled:d,"aria-label":a("关注正式版更新"),onCheckedChange:N=>{j({stable:N===!0})}})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[13px] text-foreground",children:a("关注 beta 版更新")}),s.jsx(cn,{checked:r.beta,disabled:d,"aria-label":a("关注 beta 版更新"),onCheckedChange:N=>{j({beta:N===!0})}})]})]}):s.jsx("p",{className:"text-[12px] text-subtle",children:r?a("当前关注:{channels}",{channels:S}):a("读取中")})]})]}):null,h==="install"?s.jsxs("div",{children:[s.jsx("div",{className:"settings-dlg-pane-head",children:s.jsx("h3",{children:a("自动安装")})}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("自动更新插件")}),s.jsx(cn,{checked:r?.autoUpdate===!0,disabled:d||!r,onCheckedChange:N=>{j({autoUpdate:N===!0})},"aria-label":a("自动更新插件")})]}),s.jsx("p",{className:"mt-1.5 text-[12px] text-subtle",children:a("检测到更新后自动下载、校验并安装已启用的官方签名插件。关闭此项不影响最低版本补齐;未签名或第三方插件仍需手动更新。")})]}),s.jsx("div",{className:"h-px bg-hairline"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("自动下载官方插件")}),s.jsx(cn,{checked:r?.autoInstallOfficial===!0,disabled:d||!r,onCheckedChange:N=>{j({autoInstallOfficial:N===!0})},"aria-label":a("自动下载官方插件")})]}),s.jsx("p",{className:"mt-1.5 text-[12px] text-subtle",children:a("发现未安装的官方插件时自动下载并安装,仅接受当前平台且通过官方签名校验的包;开启期间卸载的官方插件也会重新安装。")})]}),s.jsx("p",{className:"text-[12px] text-subtle",children:a("默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。")})]})]}):null,e?s.jsx(z8,{plugin:!0,pane:h==="network"||h==="token"?h:null}):null]})]}),s.jsxs(Pt,{className:"settings-dlg-footer",children:[s.jsx("p",{className:"mr-auto text-[12px] text-subtle",children:a("开关和选项即时保存;输入项请点击对应的「保存」按钮。")}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})})}const QP=1024*1024,$8=24*QP,gAe=96*QP;function vAe(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?Math.min(e,gAe):$8}function QS(e){return a("插件包大小不能超过 {n} MiB",{n:e/QP})}async function xAe(e,t){if(e.size>t)throw new Error(QS(t));const n=await LNe(e);if(n.length>Math.ceil(t/3)*4)throw new Error(QS(t));return n}function bAe(){const[e,t]=v.useState(null),[n,r]=v.useState($8),[i,o]=v.useState(""),[c,d]=v.useState(""),[f,h]=v.useState(""),[p,g]=v.useState(!1),[x,y]=v.useState(null),[j,w]=v.useState(null),[S,N]=v.useState(null),A=v.useRef(null),E=v.useRef(new Set),O=v.useRef(""),R=v.useRef(!0),T=v.useRef(null),P=v.useCallback(async ee=>{const se=bb().wbApp,[le]=await Promise.all([se?.refresh?.(),se?.refreshPluginPages?.(ee)]);R.current&&d(le===!0?"":a("插件状态已变更,但账号列表同步失败。请回到账号页点击「刷新」重试。"))},[]),M=v.useCallback(async()=>{if(T.current)return T.current;const ee=(async()=>{try{const se=await Xc("GET","/api/plugins");if(!R.current)return;const le=JSON.stringify({packs:se.packs.map(re=>({id:re.id,version:re.version,enabled:re.enabled,providers:re.providers})),running:se.host?.running}),te=!!(O.current&&O.current!==le);O.current=le,r(vAe(se.maxPackBytes)),t(se),o(""),bb().wbApp?.refreshPluginPages?.(se),te&&await P(se);for(const re of se.operations||[]){if(re.active)continue;const he=`${re.id}:${re.updatedAt}`;E.current.has(he)||(E.current.add(he),!(Date.now()-re.updatedAt>3e4)&&(re.error?mi(re.error,"err"):re.hostError?mi(re.hostError,"err"):re.done&&mi(a("插件包已安装到 v{version}",{version:re.version}),"ok")))}}catch(se){R.current&&o(Wl(se))}})();T.current=ee;try{await ee}finally{T.current=null}},[P]);v.useEffect(()=>{R.current=!0,M();const ee=window.setInterval(()=>{const se=bb().wbApp?.currentPage;!document.hidden&&(!se||se==="plugins")&&M()},1500);return()=>{R.current=!1,window.clearInterval(ee)}},[M]),v.useEffect(()=>(ZS=M,()=>{ZS===M&&(ZS=null)}),[M]);async function _(ee,se){if(!f){h(ee);try{await se()}catch(le){mi(le instanceof Error?le.message:String(le),"err")}finally{R.current&&h("")}}}async function I(){await _("check",async()=>{const ee=await Xc("GET","/api/plugins/update");await M(),ee.error&&mi(ee.reason||a("检查更新失败"),"err")})}async function L(){await _("refresh",async()=>{const ee=await Xc("GET","/api/plugins/release");await M(),ee.error&&mi(ee.reason||a("检查更新失败"),"err")})}async function D(ee){t(se=>se&&{...se,...ee}),await P(ee),ee.hostError&&mi(ee.hostError,"err"),await M()}async function z(ee,se,le){await _(ee,async()=>{await D(await Xc("POST",se,le))})}async function G(ee,se){await _(`start:${ee}`,async()=>{const le=await Xc("POST",se?"/api/plugins/update":"/api/plugins/install-from-release",{id:ee,target:e?.target});t(te=>te&&{...te,operations:[...(te.operations||[]).filter(re=>re.id!==ee),le.operation]})})}function X(){A.current&&(A.current.value="",A.current.click())}async function Y(ee){const se=ee.currentTarget.files?.[0];if(se){if(se.size>n){mi(QS(n),"err");return}await _("file",async()=>{const le=await xAe(se,n);await D(await Xc("POST","/api/plugins/install",{packB64:le})),mi(a("插件包已安装"),"ok")})}}const F=e?.packs||[],K=e?.host,U=e?.catalog,q=U?.plugins||[],W=new Set(F.map(ee=>ee.id)),ne=q.filter(ee=>!W.has(ee.id)),ie=e?.operations||[],V=ie.some(ee=>ee.active),H=e?.target||"",Q=!!f,J=F.find(ee=>ee.id===x),oe=ie.find(ee=>ee.id===x);return v.useEffect(()=>{x&&e&&!J&&y(null)},[e,J,x]),s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"panel",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsxs("div",{children:[s.jsx("h2",{children:a("插件")}),s.jsx("p",{className:"muted",children:a("按需安装插件,为 AI 路由网关扩展提供商能力。插件独立于主程序更新,下载完成后自动校验并安装。")})]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[s.jsx(ye,{variant:K?.running?"success":"outline",children:K?.running?a("运行中"):F.length?a("未运行"):a("未安装")}),s.jsx(B,{variant:"outline",size:"sm",disabled:Q,onClick:()=>{L()},children:a(f==="refresh"?"刷新中…":"刷新")}),s.jsx(B,{variant:"outline",size:"sm",disabled:Q,onClick:()=>{I()},children:f==="check"||U?.checking?a("检查中…"):a("检查更新")}),s.jsx(B,{variant:"outline",size:"sm",onClick:()=>g(!0),children:a("插件设置")}),s.jsx(B,{variant:"outline",size:"sm",disabled:Q||V,onClick:X,children:a("从文件安装…")})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx(Be,{ref:A,type:"file",accept:".zip,application/zip",className:"hidden",onChange:ee=>{Y(ee)}}),s.jsx("p",{className:"mb-3 text-[12px] text-subtle",children:QS(n)}),i||c?s.jsx("p",{className:"mb-3 text-[12px] text-destructive",children:i||c}):null,f==="file"?s.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[s.jsx("span",{className:"text-[12px] text-subtle",children:a("正在读取、校验并安装插件包…")}),s.jsx(nm,{value:null})]}):null,s.jsxs("div",{className:"grid grid-cols-1 items-start gap-3.5 min-[900px]:grid-cols-2",children:[ne.map(ee=>s.jsx(aAe,{item:ee,target:H,operation:ie.find(se=>se.id===ee.id),disabled:Q,onInstall:()=>{G(ee.id,!1)},onNotes:()=>N({name:yb(ee.id,ee.name),version:ee.version||"",notes:ee.notes,page:ee.page,prerelease:ee.prerelease})},ee.id)),F.map(ee=>{const se=e?.updates?.find(te=>te.id===ee.id),le=ie.find(te=>te.id===ee.id);return s.jsx(iAe,{pack:ee,store:q.find(te=>te.id===ee.id),host:K||null,update:se,operation:le,disabled:Q||le?.active===!0,onEnabled:te=>{z(`enable:${ee.id}`,"/api/plugins/enable",{id:ee.id,enabled:te})},onSettings:()=>y(ee.id),onRemove:()=>w(ee),onUpdate:()=>{G(ee.id,!0)},onNotes:()=>N({name:yb(ee.id,ee.name),version:se?.latest||"",notes:se?.notes,page:se?.page,prerelease:se?.prerelease})},ee.id)})]}),!ne.length&&!F.length?s.jsxs("div",{className:"rounded-lg border border-border bg-surface px-4 py-5",children:[s.jsx("p",{className:"text-[13px] font-medium",children:!e||U?.checking?a("正在读取插件列表…"):a("暂无可安装的插件")}),s.jsx("p",{className:"mt-2 text-[12px] text-subtle",children:Wl(U?.reason)||a("可以点击「刷新」读取插件仓库,或从本地 zip 安装插件。")})]}):null,e?s.jsxs(Ll,{className:"mt-3 rounded-md border border-hairline bg-surface-2",children:[s.jsxs(zl,{render:s.jsx(B,{variant:"ghost"}),className:"group/diagnostics flex h-auto w-full justify-start gap-2 rounded-md px-3 py-3 text-[12px] text-subtle",children:[s.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5 transition-transform duration-150 group-aria-expanded/diagnostics:rotate-90 motion-reduce:transition-none",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"m9 5 7 7-7 7"})}),a("诊断信息")]}),s.jsx($l,{children:s.jsxs("div",{className:"flex flex-col gap-1 px-3 pb-3 text-[12px] text-subtle",children:[s.jsxs("span",{children:[a("插件目录")," ",s.jsx("code",{className:"break-all",children:e.pluginsDir})]}),s.jsxs("span",{children:[a("当前平台")," ",s.jsx("code",{children:e.target})]}),s.jsxs("span",{children:[a("协议版本")," ",e.protocol]}),U?.reason?s.jsx("span",{className:"text-destructive",children:Wl(U.reason)}):null,K?.lastError?s.jsx("span",{className:"text-destructive",children:K.lastError}):null]})})]}):null]}),s.jsx(Zo,{className:"panel-foot",children:a("插件包与主程序分开安装、分开升级。卸载插件后账号数据仍然保留,重新装回即可继续使用;仅该包提供的转发与添加账号需要插件,本体订阅不受影响。")})]}),s.jsx(mAe,{open:p,onClose:()=>g(!1),onChanged:I}),J?s.jsx(fAe,{pack:J,name:q.find(ee=>ee.id===J.id)?.name,disabled:Q||oe?.active===!0,onClose:()=>y(null),onEnabled:ee=>{z(`enable:${J.id}`,"/api/plugins/enable",{id:J.id,enabled:ee})},onProvider:(ee,se)=>{z(`provider:${ee.id}`,"/api/plugins/provider",{id:J.id,provider:ee.id,enabled:se})}},J.id):null,s.jsx(dAe,{value:S,onClose:()=>N(null)}),s.jsx(St,{open:j!==null,onOpenChange:ee=>{ee||w(null)},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("卸载插件包")})}),s.jsx(Ct,{children:s.jsx("p",{className:"text-[13px]",children:a("确定卸载「{name}」吗?卸载后这个包里的提供商将无法转发,也无法添加账号。账号数据本身不会被删除,重新安装后可以继续使用。",{name:j?yb(j.id,j.name):""})})}),s.jsxs(Pt,{children:[s.jsx("span",{className:"flex-1"}),s.jsx(B,{variant:"outline",onClick:()=>w(null),children:a("取消")}),s.jsx(B,{variant:"destructive",disabled:Q,onClick:()=>{const ee=j;w(null),ee&&z(`remove:${ee.id}`,"/api/plugins/uninstall",{id:ee.id})},children:a("卸载")})]})]})})]})}const B8='.page[data-page="plugins"]';let F8=!1,ZS=null;function U8(){if(F8)return;const e=document.querySelector(B8);e&&(F8=!0,e.replaceChildren(),wn.createRoot(e).render(s.jsx(bAe,{})))}document.querySelector(B8)?U8():document.addEventListener("DOMContentLoaded",U8,{once:!0}),window.wbPluginsPage={async load(){await ZS?.()}};function ZP(e,t){return[...new Set(e.usedByServices||[])].filter(n=>n==="update").map(()=>t("软件 / 插件更新"))}function Ma(){return window}function Xr(e,t){Ma().wbApp?.toast?.(e,t)}function ol(e){return e instanceof Error?e.message:String(e)}function yAe(e){return Ma().wbApp?.formatTime?.(e)||""}function JP(e){const t=Number(e);return!Number.isFinite(t)||t<0?"":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function $b(e){return e.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]||t)}function rg(e){return String(e?.name||e?.id||"")}let Ur={data:null,loading:!1,syncing:!1,error:"",testing:null,pending:new Set,batchBusy:!1,batchProgress:null,selected:new Set};const eI=new Set;function wAe(e){return eI.add(e),()=>{eI.delete(e)}}function jAe(){return Ur}function as(e){Ur={...Ur,...e},eI.forEach(t=>t())}function tI(){return Ur.data?.items??[]}function H8(e){return Ur.selected.has(e)}function SAe(e,t){const n=new Set(Ur.selected);t?n.add(e):n.delete(e),as({selected:n})}function kAe(e,t){const n=new Set(Ur.selected);for(const r of e)t?n.add(r):n.delete(r);as({selected:n})}function NAe(){as({selected:new Set})}function Ed(e){if(!e||typeof e!="object"||!Array.isArray(e.items))return;const t=new Set(e.items.map(r=>r.id)),n=new Set([...Ur.selected].filter(r=>t.has(r)));as({data:{...Ur.data,...e},error:"",selected:n}),JU(e.items)}async function nI(e=!1){const t=Ma().workbuddyDesktop;if(typeof t?.getProxyPool!="function"){as({error:a("当前环境不支持代理池(桥接方法缺失)")});return}e||as({loading:!0});try{const n=await t.getProxyPool();if(!n||!Array.isArray(n.items))throw new Error(a("代理列表响应异常"));Ed(n)}catch(n){as({error:ol(n)}),e||Xr(a("代理列表加载失败:{reason}",{reason:ol(n)}),"err")}finally{as({loading:!1})}}async function CAe(){const e=Ma().workbuddyDesktop;if(typeof e?.syncClashToProxyPool!="function"){Xr(a("当前环境不支持同步(桥接方法缺失)"),"err");return}if(!(Ur.syncing||Ur.batchBusy||Ur.testing||Ur.pending.size)){as({syncing:!0});try{const t=await e.syncClashToProxyPool();if(!t||!Array.isArray(t.items))throw new Error(a("代理列表响应异常"));Ed(t),t.syncError?Xr(a("没能同步:{reason}",{reason:t.syncError}),"err"):Xr(t.changes?a("✅ 已同步 Clash Verge 出口({n} 项变更)",{n:t.changes}):a("已是最新,没有需要同步的变更"),"ok")}catch(t){Xr(a("同步失败:{reason}",{reason:ol(t)}),"err")}finally{as({syncing:!1})}}}async function AAe(e){const t=Ma().workbuddyDesktop;if(typeof t?.testProxyPoolItem!="function"){Xr(a("当前环境不支持代理测试(桥接方法缺失)"),"err");return}if(!Ur.testing){as({testing:e.id});try{const n=await t.testProxyPoolItem(e.id);if(n?.items&&Ed({items:n.items}),n?.success){const r=JP(n.durationMs);Xr(a("✅ 「{name}」出口可用{ip}{took}",{name:rg(e),ip:n.ip?a(" 出口 IP {ip}",{ip:n.ip}):"",took:r?` ${r}`:""}))}else Xr(a("❌ 「{name}」{error}",{name:rg(e),error:n?.error||a("连接失败")}),"err");n?.saveError&&Xr(a("测试结果没能记下:{reason}",{reason:n.saveError}),"err")}catch(n){Xr(a("测试失败:{reason}",{reason:ol(n)}),"err")}finally{as({testing:null})}}}async function EAe(e,t){const n=Ma().workbuddyDesktop;if(typeof n?.setProxyPoolItemEnabled!="function"){Xr(a("当前环境不支持启停(桥接方法缺失)"),"err");return}const r=new Set(Ur.pending);r.add(e.id),as({pending:r});try{const i=await n.setProxyPoolItemEnabled({id:e.id,enabled:t});Ed(i);const o=rg(e);Xr(t?a("已启用「{name}」",{name:o}):a("已禁用「{name}」",{name:o}))}catch(i){Xr(a("保存失败:{reason}",{reason:ol(i)}),"err")}finally{const i=new Set(Ur.pending);i.delete(e.id),as({pending:i})}}async function TAe(e){if(e.source==="clash"){Xr(a("只读:在 Clash Verge 里改"),"err");return}const t=Ma().workbuddyDesktop;if(typeof t?.removeProxyPoolItem!="function")return;const n=e.usedBy||[],r=n.length?`${a("有 {n} 个账号正在使用它({names})—— 删除后这些账号会回退直连。",{n:n.length,names:n.map(f=>$b(String(f.name||f.id||""))).join(a("、"))})}
`:"",i=ZP(e,a),o=i.length?`${a("此代理用于{services};删除后这些线路将不可用,不会自动回退直连。",{services:i.map($b).join(a("、"))})}
`:"";if(!await Ma().wbConfirm?.ask?.({title:a("删除代理"),html:a("确定删除「{name}」?{used}",{name:$b(rg(e)),used:r+o}),okText:a("删除"),okClass:"danger"}))return;const d=new Set(Ur.pending);d.add(e.id),as({pending:d});try{const f=await t.removeProxyPoolItem(e.id);Ed(f),Xr(a("已删除「{name}」",{name:rg(e)}))}catch(f){Xr(a("删除失败:{reason}",{reason:ol(f)}),"err")}finally{const f=new Set(Ur.pending);f.delete(e.id),as({pending:f})}}async function OAe(){const e=Ma().workbuddyDesktop;if(typeof e?.testProxyPoolItem!="function"){Xr(a("当前环境不支持代理测试(桥接方法缺失)"),"err");return}if(Ur.batchBusy||Ur.testing)return;const t=tI().filter(c=>Ur.selected.has(c.id));if(!t.length)return;as({batchBusy:!0,batchProgress:{done:0,total:t.length}});let n=0,r=0,i="";for(const[c,d]of t.entries()){as({testing:d.id,batchProgress:{done:c,total:t.length}});try{const f=await e.testProxyPoolItem(d.id);f?.items&&Ed({items:f.items}),f?.success?n+=1:r+=1,f?.saveError&&!i&&(i=f.saveError)}catch{r+=1}}as({testing:null,batchBusy:!1,batchProgress:null});const o=r?a("批量测试完成:{ok} 个可用、{failed} 个失败(共 {total} 个)",{ok:n,failed:r,total:t.length}):a("批量测试完成:{ok} 个可用(共 {total} 个)",{ok:n,total:t.length});Xr(r?o:`✅ ${o}`,r?"err":"ok"),i&&Xr(a("部分测试结果没能记下:{reason}",{reason:i}),"err")}async function RAe(){const e=Ma().workbuddyDesktop;if(typeof e?.removeProxyPoolItem!="function"||Ur.batchBusy||Ur.testing)return;const t=tI().filter(S=>Ur.selected.has(S.id)),n=t.filter(S=>S.source!=="clash"),r=t.length-n.length;if(!n.length){r&&Xr(a("选中的 {n} 条都来自 Clash Verge 同步,不能删除(请到 Clash Verge 里删)",{n:r}),"err");return}const i=n.slice(0,8).map(S=>$b(rg(S))).join(a("、")),o=n.length>8?a("{names} 等 {n} 条",{names:i,n:n.length}):i,c=n.filter(S=>(S.usedBy||[]).length).length,d=c?`${a("其中 {n} 条正被账号使用 —— 删除后那些账号会回退直连。",{n:c})}
`:"",f=[...new Set(n.flatMap(S=>ZP(S,a)))],h=f.length?`${a("选中的代理用于{services};删除后这些线路将不可用,不会自动回退直连。",{services:f.map($b).join(a("、"))})}
`:"",p=r?`${a("另有 {n} 条来自 Clash Verge 同步,将跳过(请到 Clash Verge 里删)。",{n:r})}
`:"";if(!await Ma().wbConfirm?.ask?.({title:a("批量删除代理"),html:`${a("确定删除选中的 {n} 个代理?",{n:n.length})}${o}
${d}${h}${p}`,okText:a("删除"),okClass:"danger"}))return;as({batchBusy:!0,batchProgress:{done:0,total:n.length}});let x=0,y=0,j="";for(const[S,N]of n.entries()){as({batchProgress:{done:S,total:n.length}});try{const A=await e.removeProxyPoolItem(N.id);Ed(A),x+=1}catch(A){y+=1,j||(j=ol(A))}}as({batchBusy:!1,batchProgress:null});const w=[a("已删除 {n} 个代理",{n:x})];r&&w.push(a("跳过 {n} 个(Clash 同步)",{n:r})),y&&w.push(a("失败 {n} 个({reason})",{n:y,reason:j})),Xr(y?w.join(a(",")):`✅ ${w.join(a(","))}`,y?"err":"ok")}async function PAe(e,t){const n=Ma().workbuddyDesktop,r=e?{...t,id:e.id}:t,i=e?await n?.updateProxyPoolItem?.(r):await n?.createProxyPoolItem?.(r);if(!i||!Array.isArray(i.items))throw new Error(a("代理列表响应异常"));return Ed(i),i}async function IAe(){const e=Ma().workbuddyDesktop;if(typeof e?.getProxySettings!="function")throw new Error(a("当前环境不支持代理设置(桥接方法缺失)"));const t=await e.getProxySettings();if(!t||typeof t!="object")throw new Error(a("代理设置响应异常"));return t}async function MAe(e){const t=Ma().workbuddyDesktop;if(typeof t?.saveProxySettings!="function")throw new Error(a("当前环境不支持代理设置(桥接方法缺失)"));const n=await t.saveProxySettings(e);if(!n||typeof n!="object")throw new Error(a("代理设置响应异常"));return n}const V8="https://proxylane.dev/zh-cn/isp-proxies?utm_source=agent2api&utm_medium=partnership&utm_campaign=agent2api_202610&utm_content=client";function K8({children:e}){return s.jsx("a",{className:"font-semibold text-primary-fg no-underline hover:underline",href:V8,"data-external":V8,onClick:zb,children:e})}function _Ae({item:e,onClose:t}){const n=e!==null,[r,i]=v.useState(e?.name||""),[o,c]=v.useState(e?.protocol==="socks5"?"socks5":"http"),[d,f]=v.useState(e?.host||""),[h,p]=v.useState(e?.port?String(e.port):""),[g,x]=v.useState(e?.username||""),[y,j]=v.useState(e?.password||""),[w,S]=v.useState(e?e.enabled:!0),[N,A]=v.useState(!!(e?.username||e?.password)),[E,O]=v.useState(!1),[R,T]=v.useState(!1),[P,M]=v.useState(null);function _(){const D=r.trim();if(!D)return{error:a("请填写代理名称")};const z=d.trim();if(!z)return{error:a("请填写代理主机地址")};const G=Number(h);return!Number.isInteger(G)||G<1||G>65535?{error:a("代理端口必须是 1-65535 的整数")}:{payload:{name:D,source:"manual",protocol:o,host:z,port:G,username:N?g.trim():"",password:N?y:"",enabled:w}}}async function I(){if(R)return;const D=_();if("error"in D){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",D.error]}));return}const z=D.payload,G={source:"custom",protocol:z.protocol,host:z.host,port:z.port,username:z.username,password:z.password};T(!0),M(a("正在连接上游…"));try{const X=await Ma().workbuddyDesktop?.testProxy?.({proxy:G});if(X?.success){const Y=JP(X.durationMs);M(s.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),X.ip?a(" 出口 IP {ip}",{ip:X.ip}):"",Y?` ${Y}`:""]}))}else M(s.jsxs("span",{className:"text-destructive",children:["❌ ",X?.error||a("连接失败")]}))}catch(X){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",ol(X)]}))}finally{T(!1)}}async function L(){if(E)return;const D=_();if("error"in D){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",D.error]}));return}O(!0),M(null);try{await PAe(e,D.payload),Xr(n?a("已保存「{name}」",{name:r.trim()}):a("已新增「{name}」",{name:r.trim()})),t()}catch(z){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",ol(z)]})),O(!1)}}return s.jsx(St,{open:!0,onOpenChange:D=>{!D&&!E&&t()},children:s.jsxs(kt,{className:"max-w-[560px]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a(n?"编辑代理":"新增代理")})}),s.jsxs(Ct,{className:"flex flex-col gap-3.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-name",children:a("名称")}),s.jsx(Be,{id:"proxy-name",maxLength:60,autoComplete:"off",spellCheck:!1,placeholder:a("例如:香港 HTTP 出口"),value:r,onChange:D=>i(D.currentTarget.value)})]}),s.jsxs("div",{className:"flex flex-row items-end gap-2.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-protocol",children:a("协议")}),s.jsxs(ht,{value:o,onValueChange:D=>c(D),children:[s.jsx(mt,{id:"proxy-protocol",className:"min-w-[110px]",children:s.jsx(pt,{children:o==="socks5"?"SOCKS5":"HTTP"})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"http",children:"HTTP"}),s.jsx(qe,{value:"socks5",children:"SOCKS5"})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-host",children:a("主机")}),s.jsx(Be,{id:"proxy-host",placeholder:"127.0.0.1",autoComplete:"off",spellCheck:!1,value:d,onChange:D=>f(D.currentTarget.value)})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-port",children:a("端口")}),s.jsx(Be,{id:"proxy-port",type:"number",min:1,max:65535,className:"max-w-[110px]",placeholder:"7890",value:h,onChange:D=>p(D.currentTarget.value)})]})]}),s.jsx("p",{className:"text-xs leading-[1.8] text-subtle",children:a("地址由网关所在设备访问;本机代理需运行在该设备上。")}),s.jsxs(Ie,{className:"flex cursor-pointer items-center gap-2 text-xs font-normal",children:[s.jsx(Wr,{checked:N,onCheckedChange:D=>A(D===!0)}),a("需要用户名和密码(可选)")]}),N?s.jsxs("div",{className:"flex flex-row items-end gap-2.5",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-user",children:a("用户名")}),s.jsx(Be,{id:"proxy-user",placeholder:a("可选"),autoComplete:"off",value:g,onChange:D=>x(D.currentTarget.value)})]}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-pass",children:a("密码")}),s.jsx(Be,{id:"proxy-pass",type:"password",placeholder:a("可选"),autoComplete:"new-password",value:y,onChange:D=>j(D.currentTarget.value)})]})]}):null,s.jsxs("div",{className:"flex flex-row items-center gap-2.5",children:[s.jsx(cn,{checked:w,onCheckedChange:S,"aria-label":a("启用这条代理")}),s.jsx("span",{className:"text-[12.5px]",children:a("启用(禁用的条目不会被账号使用,被引用时账号回退直连;仍可测试)")})]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("需要干净的出口?"),s.jsx(K8,{children:"ProxyLane"}),a(" AI 账号专用静态住宅 IP:Scamalytics 低欺诈评分,不限流量,首单 75 折(AGENT2API25)")," ",s.jsx(K8,{children:a("去获取")})]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:P})]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"outline",disabled:R||E,onClick:()=>{I()},children:a(R?"测试中…":"测试出口")}),s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:E,onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:E,onClick:()=>{L()},children:a(E?"保存中…":"保存")})]})]})})}function DAe({onClose:e}){const[t,n]=v.useState(!0),[r,i]=v.useState(!1),[o,c]=v.useState(""),[d,f]=v.useState(""),[h,p]=v.useState("");v.useEffect(()=>{let x=!0;return IAe().then(y=>{if(x){if(!y)throw new Error(a("代理设置响应异常"));c(y.testUrl||""),f(y.defaults?.testUrl||"")}}).catch(y=>{x&&p(ol(y))}).finally(()=>{x&&n(!1)}),()=>{x=!1}},[]);async function g(){if(r||t)return;const x=o.trim();if(x&&!/^https?:\/\//i.test(x)){p(a("测试网址要以 http:// 或 https:// 开头"));return}i(!0),p("");try{await MAe({testUrl:x}),Xr(a("✅ 连通性测试设置已保存")),e()}catch(y){p(ol(y))}finally{i(!1)}}return s.jsx(St,{open:!0,onOpenChange:x=>{!x&&!r&&e()},children:s.jsxs(kt,{className:"max-w-[500px]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("连通性测试设置")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-settings-url",children:a("测试目标网址")}),s.jsx(Be,{id:"proxy-settings-url",value:o,placeholder:d,autoComplete:"off",spellCheck:!1,disabled:t||r,className:"font-mono text-xs",onChange:x=>c(x.currentTarget.value)})]}),s.jsx("p",{className:"text-xs leading-[1.8] text-subtle",children:a("通过代理访问该网址,检查是否能收到 HTTP 响应。留空沿用网关默认值。")}),t?s.jsx("p",{className:"text-xs text-subtle",children:a("加载中…")}):null,h?s.jsxs("p",{className:"text-xs text-destructive",children:["❌ ",h]}):null]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"ghost",className:"mr-auto",disabled:t||r,onClick:()=>{c(""),p("")},children:a("恢复默认")}),s.jsx(B,{variant:"outline",disabled:r,onClick:e,children:a("取消")}),s.jsx(B,{disabled:t||r,onClick:()=>{g()},children:a(r?"保存中…":"保存设置")})]})]})})}const rI=[{key:"pick",label:a("选择"),align:"center"},{key:"name",label:a("代理名称")},{key:"addr",label:a("地址")},{key:"usage",label:a("使用情况")},{key:"state",label:a("启用"),align:"center"},{key:"test",label:a("最近检测")},{key:"act",label:a("操作"),align:"right"}],LAe={pick:"p-pick",name:"",addr:"p-addr",usage:"p-usage",state:"p-state",test:"p-test",act:"p-act"},q8="proxies";function sI(){return window}let JS=null,G8=null;function Y8(){return JS?JS.apply([...rI]):rI.map(e=>({...e,align:e.align??"left"}))}function zAe(){sI().wbTableColumns?.repaint?.(q8)}function $Ae(e){if(G8=e,JS)return!0;const t=sI().wbColSettings;return t?.register?(JS=t.register({id:q8,label:a("代理池表"),columns:rI.map(n=>({key:n.key,label:n.label,align:n.align??"left"})),mount:()=>document.querySelector('.page[data-page="proxies"] .panel-head .head-actions'),buttonPlacement:"last",onChange:()=>G8?.()}),!0):!1}function BAe(){sI().wbColSettings?.close?.()}const W8="agent2api:proxy-subscription-retired:v1";function FAe(e=""){try{return localStorage.getItem(`${W8}:${e}`)!=="acknowledged"}catch{return!0}}function UAe(e=""){try{localStorage.setItem(`${W8}:${e}`,"acknowledged")}catch{}}function HAe({open:e,onClose:t,t:n,scope:r=""}){const[i,o]=v.useState(!1),c=v.useId();v.useEffect(()=>{e&&o(!1)},[e]);function d(){i&&UAe(r),t()}return s.jsx(St,{open:e,disablePointerDismissal:!0,onOpenChange:f=>{f||t()},children:s.jsxs(kt,{className:"max-w-[540px]",children:[s.jsxs(Ct,{className:"gap-0 px-7 pt-7 pb-6 max-sm:px-5",children:[s.jsx("div",{className:"mb-5 grid size-11 place-items-center rounded-md border border-primary-bd bg-primary-soft text-primary",children:s.jsxs("svg",{width:"23",height:"23",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 11v5m0-9h.01",strokeLinecap:"round"})]})}),s.jsx("span",{className:"text-[11px] tracking-wide text-muted-foreground",children:n("功能调整通知")}),s.jsx(jt,{className:"mt-1.5 text-[22px] font-semibold leading-snug max-sm:text-xl",children:n("代理订阅功能已下线")}),s.jsx(bT,{className:"mt-3 text-xs leading-[1.9] text-subtle",children:n("为降低维护成本、资源占用及合规风险,Agent2API 已停止提供代理订阅与内置代理内核相关功能。")}),s.jsxs("div",{className:"mt-5 divide-y divide-border overflow-hidden rounded-md border border-border bg-surface-2",children:[s.jsx(X8,{retained:!1,title:n("不再提供"),children:n("订阅导入与更新、订阅节点管理,以及代理内核的下载、安装和运行。")}),s.jsx(X8,{retained:!0,title:n("手动代理与 Clash Verge 同步仍然保留"),children:n("已有手动配置和 Clash Verge 端点引用不受影响。仍可添加 HTTP / SOCKS5 地址、同步 Clash Verge 端点并测试连通性;Clash Verge 由你自行安装和运行。")})]}),s.jsxs("div",{className:"mt-5 text-xs leading-[1.85]",children:[s.jsx("strong",{className:"font-semibold",children:n("之前使用订阅节点?")}),s.jsx("p",{className:"mt-1.5 text-muted-foreground",children:n("请填写已有代理服务的 HTTP / SOCKS5 地址,或自行运行 Clash Verge 后同步端点,并重新为相关账号和服务线路选择代理。")})]})]}),s.jsxs(Pt,{className:"justify-between px-7 max-sm:px-5",children:[s.jsxs(Ie,{htmlFor:c,className:"inline-flex cursor-pointer items-center gap-2 text-xs font-normal text-subtle",children:[s.jsx(Wr,{id:c,checked:i,onCheckedChange:f=>o(f===!0)}),n("不再提醒")]}),s.jsx(B,{onClick:d,children:n("我知道了")})]})]})})}function X8({retained:e,title:t,children:n}){return s.jsxs("div",{className:"flex items-start gap-3 p-4",children:[s.jsx("span",{className:`mt-0.5 grid size-[22px] shrink-0 place-items-center rounded-full ${e?"bg-success-soft text-success":"bg-border text-subtle"}`,children:s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:s.jsx("path",{d:e?"m5 12 4 4L19 6":"m6 6 12 12M6 18 18 6"})})}),s.jsxs("div",{children:[s.jsx("strong",{className:"text-xs font-semibold",children:t}),s.jsx("p",{className:"mt-1 text-xs leading-[1.85] text-subtle",children:n})]})]})}let Q8=0;const aI=new Set;function Z8(){FAe()&&(Q8+=1,aI.forEach(e=>e()))}function VAe(){const e=v.useSyncExternalStore(wAe,jAe),t=v.useSyncExternalStore(K=>(aI.add(K),()=>{aI.delete(K)}),()=>Q8),[n,r]=v.useState(!1),[i,o]=v.useState(null),[c,d]=v.useState(!1),[f,h]=v.useState(!1),[p,g]=v.useState(""),[x,y]=v.useState("all"),[j,w]=v.useState("all"),[S,N]=v.useState(0),[,A]=v.useReducer(K=>K+1,0),E=tI(),O=e.data!==null,R=e.selected.size,T=e.batchProgress,P=e.syncing||e.batchBusy||e.testing!==null||e.pending.size>0,M=Y8(),_=p.trim().toLowerCase(),I=E.filter(K=>(x==="all"||(K.resolved?.protocol||K.protocol)===x)&&(j==="all"||Bb(K)===j)&&(!_||[K.name,GT(K),K.host,K.protocol,K.port].join(" ").toLowerCase().includes(_))),L=I.map(K=>K.id),D=L.length>0&&L.every(K=>e.selected.has(K)),z=L.some(K=>e.selected.has(K))&&!D,G=qx(I.length,"proxies"),X=G.paged?G.slice(I):I;v.useEffect(()=>{t>0&&r(!0)},[t]),v.useEffect(()=>{G.goto(1)},[_,x,j]),v.useLayoutEffect(()=>{if(!$Ae(()=>A())){const K=window.setTimeout(()=>N(U=>U+1),50);return()=>window.clearTimeout(K)}A()},[S]),v.useLayoutEffect(()=>{zAe()}),v.useEffect(()=>()=>{BAe()},[]);function Y(){g(""),y("all"),w("all")}function F(K,U){switch(K){case"pick":return s.jsx(Wr,{checked:H8(U.id),disabled:P,"aria-label":a("勾选「{name}」",{name:U.name||a("未命名")}),onCheckedChange:q=>SAe(U.id,q)});case"name":return s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("b",{children:U.name||a("未命名")}),s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-subtle",children:[s.jsx(ye,{variant:"outline",shape:"tag",className:"font-mono text-[10px]",children:(U.resolved?.protocol||U.protocol||"http").toUpperCase()}),U.source==="clash"?s.jsx(ye,{variant:"secondary",shape:"tag",className:"text-[10px]",children:"Clash Verge"}):null,U.enabled===!1?a("已禁用"):null]})]});case"addr":{const q=GT(U);return s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-xs leading-[1.5] text-text-2",title:U.resolveError||q,children:q||a("地址不完整")}),q?s.jsx(B,{variant:"ghost",size:"icon-xs",className:"copy-btn shrink-0","data-copy":q,title:a("复制地址"),children:"⧉"}):null]})}case"usage":{const q=ZP(U,a);return s.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-subtle",children:[U.usedBy?.length?s.jsx("span",{title:U.usedBy.map(W=>W.name||W.id).join(a("、")),children:a("{n} 个账号在用",{n:U.usedBy.length})}):null,q.map(W=>s.jsx("span",{children:W},W)),!U.usedBy?.length&&!q.length?a("暂未使用"):null]})}case"state":return s.jsx(cn,{checked:U.enabled!==!1,disabled:P||U.source==="clash"&&U.sourceEnabled===!1,title:U.source==="clash"?U.sourceEnabled===!1?a("这条在 Clash Verge 里是停用的,本页启用不生效 —— 到 Clash Verge 里打开它"):a("禁用后本端不再用它(引用它的账号回退直连);端口在 Clash Verge 侧,不受影响"):void 0,"aria-label":a("启用「{name}」",{name:U.name||a("未命名")}),onCheckedChange:q=>{EAe(U,q)}});case"test":{if(e.testing===U.id)return s.jsx("span",{className:"text-subtle",children:a("测试中…")});const q=U.lastTest;return q?.at?s.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 text-xs leading-[1.5]",children:[s.jsxs("span",{className:q.success?"text-success":"text-destructive",children:[q.success?a("✅ 连接成功"):a("❌ 连接失败")," ",JP(q.durationMs)]}),s.jsx("span",{className:"truncate text-[10px] text-subtle",title:q.error||void 0,children:q.success?q.ip||"":q.error||a("连接失败")}),s.jsx("span",{className:"text-[10px] text-subtle",children:yAe(q.at)})]}):s.jsx("span",{className:"text-subtle",children:a("未检测")})}case"act":return s.jsxs("div",{className:"row-actions",children:[s.jsx(B,{size:"sm",variant:"ghost",disabled:P,onClick:()=>{AAe(U)},children:a("测试")}),U.source==="clash"?s.jsx("span",{className:"text-[10px] text-subtle",title:a("名字与端口在 Clash Verge 里改;启用可在本页关闭"),children:a("只读:在 Clash Verge 里改")}):s.jsxs(s.Fragment,{children:[s.jsx(B,{size:"sm",variant:"ghost",disabled:P,onClick:()=>o({item:U}),children:a("编辑")}),s.jsx(B,{size:"sm",variant:"ghost",className:"text-destructive",disabled:P,onClick:()=>{TAe(U)},children:a("删除")})]})]});default:return null}}return s.jsxs(s.Fragment,{children:[s.jsxs(tt,{render:s.jsx("section",{}),className:"panel",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsx("h2",{children:a("代理列表")}),s.jsx(ye,{variant:"secondary",shape:"tag",children:E.length}),s.jsx("span",{className:"panel-sub",children:O?a("已启用 {n} 个",{n:E.filter(K=>K.enabled!==!1).length}):a("加载中…")}),s.jsxs("div",{className:"head-actions",children:[s.jsx(B,{disabled:P,onClick:()=>o({item:null}),children:a("+ 新增代理")}),s.jsx(B,{variant:"ghost",className:"hidden max-[767px]:inline-flex",onClick:()=>h(!0),children:a("筛选")}),s.jsx(B,{variant:"outline",disabled:P,onClick:()=>{CAe()},children:e.syncing?a("同步中…"):a("同步 Clash Verge")}),s.jsx(B,{variant:"outline",disabled:P,onClick:()=>d(!0),children:a("测试设置")}),s.jsx(B,{variant:"outline",disabled:e.loading||P,onClick:()=>{nI()},children:e.loading?a("刷新中…"):a("刷新")})]})]}),R?s.jsxs("div",{className:"batch-bar active",children:[s.jsxs("span",{className:"batch-count",children:[a("已选")," ",s.jsx("b",{children:R})," ",a("个")]}),s.jsxs("div",{className:"batch-actions",children:[s.jsx(B,{variant:"outline",disabled:P,onClick:()=>{OAe()},children:T?a("测试中 {done}/{total}",{done:T.done,total:T.total}):a("批量测试")}),s.jsx(B,{variant:"destructive",disabled:P,onClick:()=>{RAe()},children:a("批量删除")}),s.jsx(B,{variant:"outline",disabled:P,onClick:NAe,children:a("取消选择")})]})]}):s.jsxs(w0,{open:f,onOpenChange:h,title:a("筛选"),inlineClassName:"flex flex-wrap items-center gap-2.5 border-b border-border px-4 py-3",bodyClassName:"proxy-filter-body",actions:s.jsx(B,{variant:"ghost",size:"sm",onClick:Y,children:a("清空")}),children:[s.jsxs(uo,{className:"w-[clamp(150px,22vw,240px)]",children:[s.jsx(ho,{type:"search",value:p,"aria-label":a("搜索代理"),placeholder:a("搜索名称 / 地址 / 端口"),onChange:K=>g(K.currentTarget.value)}),s.jsx(fo,{align:"inline-start","aria-hidden":"true",children:s.jsx(qAe,{})})]}),s.jsxs(ht,{value:x,onValueChange:K=>y(K||"all"),children:[s.jsx(mt,{className:"w-[120px]","aria-label":a("按协议筛选"),children:s.jsx(pt,{children:x==="all"?a("全部协议"):x.toUpperCase()})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"all",children:a("全部协议")}),s.jsx(qe,{value:"http",children:"HTTP"}),s.jsx(qe,{value:"socks5",children:"SOCKS5"})]})]}),s.jsx(dn,{className:"ml-auto",options:KAe(E),value:j,onValueChange:w,"aria-label":a("按状态筛选")})]}),s.jsx("div",{className:"models-table-wrap",children:s.jsxs(ea,{container:!1,className:"models-table proxies-table",children:[s.jsx("colgroup",{children:M.map(K=>s.jsx("col",{"data-col":K.key,className:LAe[K.key]||void 0},K.key))}),s.jsx(Ta,{children:s.jsx(en,{children:M.map(K=>s.jsx(ft,{"data-col":K.key,className:`ta-${K.align}`,children:K.key==="pick"?s.jsx(Wr,{checked:D,indeterminate:z,disabled:!L.length||P,"aria-label":a("全选当前筛选出的出口"),onCheckedChange:U=>kAe(L,U)}):K.label},K.key))})}),s.jsx(ga,{children:X.length?X.map(K=>s.jsx(en,{"data-id":K.id,className:Te(K.enabled===!1&&"off",H8(K.id)&&"bg-primary-soft"),children:M.map(U=>s.jsx(Xe,{className:`ta-${U.align}`,children:F(U.key,K)},U.key))},K.id)):s.jsx(en,{children:s.jsx(Xe,{colSpan:M.length,className:"empty",children:O?E.length?s.jsxs("div",{className:"flex flex-col items-center gap-3 py-5",children:[s.jsx("span",{children:a("没有匹配当前筛选的出口")}),s.jsx(B,{variant:"outline",size:"sm",onClick:Y,children:a("清空筛选")})]}):s.jsxs("div",{className:"flex flex-col items-center gap-3 py-8",children:[s.jsx("b",{className:"text-sm text-foreground",children:a("还没有保存的代理")}),s.jsx("p",{className:"text-xs text-subtle",children:a("添加手动 HTTP / SOCKS5 地址,或同步 Clash Verge 的端点,供账号与服务线路使用。")}),s.jsx(B,{onClick:()=>o({item:null}),children:a("添加第一个代理")})]}):e.error||a("加载中…")})})})]})}),s.jsx(fd,{leading:e.error?s.jsx("span",{className:"text-destructive",children:a("读取失败:{reason}",{reason:e.error})}):void 0,total:I.length,page:G.page,pageCount:G.pageCount,size:G.size,onSizeChange:G.setSize,onPageChange:G.goto,range:G.paged?{start:G.rangeStart,end:G.rangeEnd}:null})]}),i?s.jsx(_Ae,{item:i.item,onClose:()=>o(null)}):null,c?s.jsx(DAe,{onClose:()=>d(!1)}):null,s.jsx(HAe,{open:n,onClose:()=>r(!1),t:a})]})}function Bb(e){return e.enabled===!1?"off":e.lastTest?.at?e.lastTest.success?"ok":"fail":"none"}function KAe(e){return[{value:"all",label:a("全部"),count:e.length},{value:"ok",label:a("可用"),count:e.filter(t=>Bb(t)==="ok").length},{value:"fail",label:a("失败"),count:e.filter(t=>Bb(t)==="fail").length},{value:"none",label:a("未检测"),count:e.filter(t=>Bb(t)==="none").length},{value:"off",label:a("已禁用"),count:e.filter(t=>Bb(t)==="off").length}]}function qAe(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]})}window.wbProxiesPanel={load:()=>nI(),activate:Z8,visibleColumns:()=>Y8().map(e=>({key:e.key}))};const J8='.page[data-page="proxies"]';function eG(){const e=document.querySelector(J8);!e||e.dataset.mounted==="1"||(e.dataset.mounted="1",e.replaceChildren(),wn.createRoot(e).render(s.jsx(VAe,{})),Ma().wbApp?.currentPage==="proxies"&&(Z8(),nI()))}document.querySelector(J8)?eG():document.addEventListener("DOMContentLoaded",eG,{once:!0});const ek=YK,iI="7",tk="custom",tG="workbuddy-desktop-report-range",nG="workbuddy-desktop-report-custom-range",rG={today:a("今天"),yesterday:a("昨天"),7:a("近 7 天"),30:a("近 30 天"),month:a("本月"),all:a("全部"),custom:a("自定义区间")},GAe={today:a("今天"),yesterday:a("昨天"),7:a("7 天"),30:a("30 天"),month:a("本月"),all:a("全部"),custom:a("自定义")};function YAe(){try{const e=localStorage.getItem(tG);return e!==null&&ek.includes(e)?e:iI}catch{return iI}}function WAe(){return xb(nG)}function XAe(e){IS(nG,e)}const QAe=[[0,a("一")],[2,a("三")],[4,a("五")]];function oI(){return window.wbUnits||{}}function Bs(e){const t=oI();return t.formatInt?t.formatInt(e):(Number(e)||0).toLocaleString("zh-CN")}function Ns(e){const t=oI();return t.formatTokens?t.formatTokens(e):String(Number(e)||0)}function sG(e,t){const n=oI();return n.formatAxis?n.formatAxis(e,t):String(e)}function Ql(e){return`${((Number(e)||0)*100).toFixed(1)}%`}function nk(e){return Math.round(e*10)/10}function lI(e){return[...e].reduce((t,n)=>t+(/[\u2e80-\u9fff]/.test(n)?9.7:5.4),0)}function rk(e){const[t,n,r]=String(e||"").split("-").map(Number);return new Date(t||1970,(n||1)-1,r||1)}const ZAe=[a("日"),a("一"),a("二"),a("三"),a("四"),a("五"),a("六")];function sk(e){const t=rk(e);return a("{m}月{d}日 周{wd}",{m:t.getMonth()+1,d:t.getDate(),wd:ZAe[t.getDay()]})}function aG(e){const t=String(e||"").slice(11,13);return t?`${t}:00`:"—"}const JAe=[1,1.5,2,2.5,3,4,5,6,8,10];function eEe(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e)),n=e/t;return(JAe.find(i=>i>=n-1e-9)??10)*t}function tEe(e){return eEe(e/4)*4}function nEe(e,t,n){const r=e||{},i=r.topModel,o=Number(r.requests)||0,c=Number(r.successful)||0,d=o?`${(c/o*100).toFixed(1)}%`:"—",f=[{key:"tokens",label:a("总 Token"),value:Ns(r.tokens),sub:a("输入 + 输出"),mono:!1},{key:"successful",label:a("成功请求数"),value:Bs(c),sub:a("成功率 {rate}",{rate:d}),mono:!1},{key:"requests",label:a("总请求数"),value:Bs(o),sub:rG[t]||"",mono:!1},{key:"activeDays",label:a("活跃天数"),value:Bs(r.activeDays),sub:a("区间共 {n} 天",{n}),mono:!1},{key:"streak",label:a("当前连续天数"),value:Bs(r.streak),sub:a("含今天在内往前数"),mono:!1}];return f.push(i?{key:"topModel",label:a("Top 模型"),value:String(i.model??""),sub:a("{tokens} tokens · 占 {pct}",{tokens:Ns(i.tokens),pct:Ql(i.percentage)}),mono:!0}:{key:"topModel",label:a("Top 模型"),value:"—",sub:a("所选范围内还没有模型用量"),mono:!1}),f}function iG(e){if(!Array.isArray(e))return null;const t=e.map(i=>({id:String(i?.id??"").trim(),label:String(i?.label??"").trim(),tokens:Number(i?.totalTokens??i?.tokens)||0})).filter(i=>i.tokens>0);if(!t.length)return[];const n=t.reduce((i,o)=>i+o.tokens,0),r=i=>n?i/n*100:0;return[...t].sort((i,o)=>o.tokens-i.tokens).map((i,o)=>{const c=r(i.tokens),d=Ns(i.tokens),f=i.label||i.id||a("未知"),h=i.id?a("{name}({id})",{name:f,id:i.id}):f;return{key:`${o}-${i.id||f}`,id:i.id,name:f,full:h,tip:a("{name}:{tokens} tokens · 占 {pct}%",{name:h,tokens:d,pct:c.toFixed(1)}),tokensText:d,percentText:`${c.toFixed(1)}%`,barWidth:`${c.toFixed(1)}%`}})}function oG(e){return`${Ns(e.reduce((t,n)=>t+(Number(n?.totalTokens??n?.tokens)||0),0))} tokens`}const sg=["#f73b00","#f7bb07","#4aaa4d","#1872cb","#3444a3","#13c2c2","#722ed1","#eb2f96","#a0d911","#34d399","#d946ef","#ff85c0","#b37feb","#9d174d","#ffa39e","#69b1ff"],cI="#9aa0a6";function lG(e){return(Array.isArray(e)?e:[]).map(t=>({name:String(t?.label??t?.model??t?.id??"").trim(),tokens:Number(t?.totalTokens??t?.tokens)||0,requests:Number(t?.requests)||0})).filter(t=>Number.isFinite(t.tokens)&&t.tokens>0).sort((t,n)=>n.tokens-t.tokens)}function cG(e){const t=new Map;for(const n of lG(e))!n.name||t.has(n.name)||t.set(n.name,sg[t.size%sg.length]);return t}function uG(e,t){const n=lG(e);if(!n.length)return null;const r=n.reduce((c,d)=>c+d.tokens,0);if(!r)return null;const i=cG(e);return{size:220,data:n.map((c,d)=>{const f=c.name||t,h=c.tokens/r;return{key:`${d}-${f}`,name:f,fill:i.get(f)??sg[d%sg.length],tokens:c.tokens,requests:c.requests,percentage:h,tip:a("{name} · {tokens} tokens · {n} 次请求 · {pct}",{name:f,tokens:Ns(c.tokens),n:Bs(c.requests),pct:Ql(h)})}}),totalText:Ns(r)}}const rEe=[1,1.25,1.5,2,2.5,3,4,5,6,8,10];function sEe(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e)),n=e/t;let r=1;for(const i of rEe)i<=n+1e-9&&(r=i);return r*t}function aEe(e){const t=Number(e)||0;if(t<=0)return[0,1,2,3,1/0];const n=Math.max(1,sEe(t/4));return[0,n,n*2,n*3,1/0]}function iEe(e,t){if(e===0)return"0";const n=t[e-1],r=t[e];return Number.isFinite(r)?n===0?`≤${Ns(r)}`:`${Ns(n)}–${Ns(r)}`:`>${Ns(n)}`}function dG(e){const t=Array.isArray(e)?e:[];return aEe(t.reduce((n,r)=>Math.max(n,Number(r?.tokens)||0),0))}function oEe(e,t){const n=Array.isArray(e)?e:[];if(!n.length)return null;const r=(rk(n[0].date).getDay()+6)%7,i=new Array(r).fill(null).concat(n),o=Math.ceil(i.length/7),c=3,d=20,f=t-d,h=Math.floor((f-c*(o-1))/o),p=Math.max(7,Math.min(26,h)),g=p+3,x=p+c,y=d+o*x-c,j=Math.max(0,Math.round((t-y)/2)),w=g+7*x-c+2,S=Math.max(y,Math.round(t)),N=dG(n),A=M=>N.findIndex(_=>Number(M)<=_),E=[];for(let M=0;M({key:_,x:j+d-6,y:nk(g+M*x+p/2),text:_})),R=[];let T=-1,P=-9;for(let M=0;M({level:t,text:iEe(t,e)}))}function cEe(e){const t=e||{};return[["last10m",a("近 10 分钟")],["last1h",a("近 1 小时")],["last24h",a("近 24 小时")],["last7d",a("近 7 天")]].map(([r,i])=>{const o=t[r]||{},c=Number(o.inputTokens)||0;return{key:r,label:i,value:c?Ql(o.rate):"—",sub:a("命中 {hit} / 输入 {input}",{hit:Ns(o.hitTokens),input:Ns(c)})}})}function fG(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{var n=e.children,r=e.width,i=e.height,o=e.viewBox,c=e.className,d=e.style,f=e.title,h=e.desc,p=mEe(e,pEe),g=o||{width:r,height:i,x:0,y:0},x=cr("recharts-surface",c);return v.createElement("svg",dI({},Co(p),{className:x,width:r,height:i,style:d,viewBox:"".concat(g.x," ").concat(g.y," ").concat(g.width," ").concat(g.height),ref:t}),v.createElement("title",null,f),v.createElement("desc",null,h),n)}),vEe=["children","className"];function fI(){return fI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,i=xEe(e,vEe),o=cr("recharts-layer",r);return v.createElement("g",fI({className:o},Co(i),{ref:t}),n)});function hI(e){return e==="__proto__"}const yEe=Object.prototype.hasOwnProperty;function ag(e,t){return yEe.call(e,t)}const wEe=/\.|(\[(?:[^[\]]*|(["'])(?:(?!\2)[^\\]|\\.)*?\2)\])/;function gG(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e===""||e.startsWith(".")||e.endsWith(".")?!1:wEe.test(e);default:return!1}}function ak(e){var t;return typeof e=="string"||typeof e=="symbol"?e:Object.is(e==null||(t=e.valueOf)===null||t===void 0?void 0:t.call(e),-0)?"-0":String(e)}function pI(e){return typeof e=="symbol"||e instanceof Symbol}function vG(e){if(typeof e=="string")return e;if(Array.isArray(e)){let n="";for(let r=0;r0&&(n+=","),n+=vG(e[r]);return n}if(pI(e))return e.toString();const t=e+"";return t==="0"&&Object.is(Number(e),-0)?"-0":t}function jEe(e){return e==null?"":vG(e)}function mI(e){if(Array.isArray(e))return e.map(ak);if(typeof e=="symbol")return[e];e=jEe(e);const t=[],n=e.length;if(n===0)return t;let r=0,i="",o="",c=!1,d=!1;const f=/^-?\d+(?:\.\d+)?$/;for(e.charCodeAt(0)===46&&t.push("");r1&&arguments[1]!==void 0?arguments[1]:kEe,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function xa(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var d=n[c-1];return typeof d=="string"?i+d+o:d!==void 0?i+Zc(d)+o:i+o},"")}var ra=e=>e===0?0:e>0?1:-1,Jl=e=>typeof e=="number"&&e!=+e,kh=e=>typeof e=="string"&&e.length>1&&e.indexOf("%")===e.length-1,ot=e=>(typeof e=="number"||e instanceof Number)&&!Jl(e),ec=e=>ot(e)||typeof e=="string",NEe=0,Fb=e=>{var t=++NEe;return"".concat(e||"").concat(t)},_a=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!ot(t)&&typeof t!="string")return r;var o;if(kh(t)){if(n==null)return r;var c=t.indexOf("%");o=n*parseFloat(t.slice(0,c))/100}else o=+t;return Jl(o)&&(o=r),i&&n!=null&&o>n&&(o=n),o},xG=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):Zl(r,t))===n)}var Hr=e=>e===null||typeof e>"u",gI=e=>Hr(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function gi(e){return e!=null}function Nh(){}function vI(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function yG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tc(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,o=e.parentViewBox,c=vI(t),d=c.x,f=c.y,h=c.height,p=c.upperWidth,g=c.lowerWidth,x=d,y=d+(p-g)/2,j=(x+y)/2,w=(p+g)/2,S=x+p/2,N=h>=0?1:-1,A=N*i,E=N>0?"end":"start",O=N>0?"start":"end",R=p>=0?1:-1,T=R*i,P=R>0?"end":"start",M=R>0?"start":"end",_=o;if(n==="top"){var I={x:x+p/2,y:f-A,horizontalAnchor:"middle",verticalAnchor:E};return _&&(I.height=Math.max(f-_.y,0),I.width=p),I}if(n==="bottom"){var L={x:y+g/2,y:f+h+A,horizontalAnchor:"middle",verticalAnchor:O};return _&&(L.height=Math.max(_.y+_.height-(f+h),0),L.width=g),L}if(n==="left"){var D={x:j-T,y:f+h/2,horizontalAnchor:P,verticalAnchor:"middle"};return _&&(D.width=Math.max(D.x-_.x,0),D.height=h),D}if(n==="right"){var z={x:j+w+T,y:f+h/2,horizontalAnchor:M,verticalAnchor:"middle"};return _&&(z.width=Math.max(_.x+_.width-z.x,0),z.height=h),z}var G=_?{width:w,height:h}:{};return n==="insideLeft"?tc({x:j+T,y:f+h/2,horizontalAnchor:M,verticalAnchor:"middle"},G):n==="insideRight"?tc({x:j+w-T,y:f+h/2,horizontalAnchor:P,verticalAnchor:"middle"},G):n==="insideTop"?tc({x:x+p/2,y:f+A,horizontalAnchor:"middle",verticalAnchor:O},G):n==="insideBottom"?tc({x:y+g/2,y:f+h-A,horizontalAnchor:"middle",verticalAnchor:E},G):n==="insideTopLeft"?tc({x:x+T,y:f+A,horizontalAnchor:M,verticalAnchor:O},G):n==="insideTopRight"?tc({x:x+p-T,y:f+A,horizontalAnchor:P,verticalAnchor:O},G):n==="insideBottomLeft"?tc({x:y+T,y:f+h-A,horizontalAnchor:M,verticalAnchor:E},G):n==="insideBottomRight"?tc({x:y+g-T,y:f+h-A,horizontalAnchor:P,verticalAnchor:E},G):n&&typeof n=="object"&&(ot(n.x)||kh(n.x))&&(ot(n.y)||kh(n.y))?tc({x:d+_a(n.x,w),y:f+_a(n.y,h),horizontalAnchor:"end",verticalAnchor:"end"},G):tc({x:S,y:f+h/2,horizontalAnchor:"middle",verticalAnchor:"middle"},G)},OEe=["top","left","right","bottom"];function REe(e){return e==null?!1:typeof e=="object"?!0:OEe.includes(e)}var PEe=v.createContext(null);function os(e){return function(){return e}}const xI=Math.PI,bI=2*xI,Ch=1e-6,IEe=bI-Ch;function wG(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return wG;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;iCh)if(!(Math.abs(g*f-h*p)>Ch)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let y=r-c,j=i-d,w=f*f+h*h,S=y*y+j*j,N=Math.sqrt(w),A=Math.sqrt(x),E=o*Math.tan((xI-Math.acos((w+x-S)/(2*N*A)))/2),O=E/A,R=E/N;Math.abs(O-1)>Ch&&this._append`L${t+O*p},${n+O*g}`,this._append`A${o},${o},0,0,${+(g*y>p*j)},${this._x1=t+R*f},${this._y1=n+R*h}`}}arc(t,n,r,i,o,c){if(t=+t,n=+n,r=+r,c=!!c,r<0)throw new Error(`negative radius: ${r}`);let d=r*Math.cos(i),f=r*Math.sin(i),h=t+d,p=n+f,g=1^c,x=c?i-o:o-i;this._x1===null?this._append`M${h},${p}`:(Math.abs(this._x1-h)>Ch||Math.abs(this._y1-p)>Ch)&&this._append`L${h},${p}`,r&&(x<0&&(x=x%bI+bI),x>IEe?this._append`A${r},${r},0,1,${g},${t-d},${n-f}A${r},${r},0,1,${g},${this._x1=h},${this._y1=p}`:x>Ch&&this._append`A${r},${r},0,${+(x>=xI)},${g},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function jG(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new _Ee(t)}function yI(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function SG(e){this._context=e}SG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ik(e){return new SG(e)}function kG(e){return e[0]}function NG(e){return e[1]}function CG(e,t){var n=os(!0),r=null,i=ik,o=null,c=jG(d);e=typeof e=="function"?e:e===void 0?kG:os(e),t=typeof t=="function"?t:t===void 0?NG:os(t);function d(f){var h,p=(f=yI(f)).length,g,x=!1,y;for(r==null&&(o=i(y=c())),h=0;h<=p;++h)!(h=y;--j)d.point(E[j],O[j]);d.lineEnd(),d.areaEnd()}N&&(E[x]=+e(S,x,g),O[x]=+t(S,x,g),d.point(r?+r(S,x,g):E[x],n?+n(S,x,g):O[x]))}if(A)return d=null,A+""||null}function p(){return CG().defined(i).curve(c).context(o)}return h.x=function(g){return arguments.length?(e=typeof g=="function"?g:os(+g),r=null,h):e},h.x0=function(g){return arguments.length?(e=typeof g=="function"?g:os(+g),h):e},h.x1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:os(+g),h):r},h.y=function(g){return arguments.length?(t=typeof g=="function"?g:os(+g),n=null,h):t},h.y0=function(g){return arguments.length?(t=typeof g=="function"?g:os(+g),h):t},h.y1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:os(+g),h):n},h.lineX0=h.lineY0=function(){return p().x(e).y(t)},h.lineY1=function(){return p().x(e).y(n)},h.lineX1=function(){return p().x(r).y(t)},h.defined=function(g){return arguments.length?(i=typeof g=="function"?g:os(!!g),h):i},h.curve=function(g){return arguments.length?(c=g,o!=null&&(d=c(o)),h):c},h.context=function(g){return arguments.length?(g==null?o=d=null:d=c(o=g),h):o},h}class AG{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function DEe(e){return new AG(e,!0)}function LEe(e){return new AG(e,!1)}function lk(){}function ck(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function EG(e){this._context=e}EG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ck(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ck(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function zEe(e){return new EG(e)}function TG(e){this._context=e}TG.prototype={areaStart:lk,areaEnd:lk,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:ck(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function $Ee(e){return new TG(e)}function OG(e){this._context=e}OG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:ck(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function BEe(e){return new OG(e)}function RG(e){this._context=e}RG.prototype={areaStart:lk,areaEnd:lk,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function FEe(e){return new RG(e)}function PG(e){return e<0?-1:1}function IG(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),c=(n-e._y1)/(i||r<0&&-0),d=(o*i+c*r)/(r+i);return(PG(o)+PG(c))*Math.min(Math.abs(o),Math.abs(c),.5*Math.abs(d))||0}function MG(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function wI(e,t,n){var r=e._x0,i=e._y0,o=e._x1,c=e._y1,d=(o-r)/3;e._context.bezierCurveTo(r+d,i+d*t,o-d,c-d*n,o,c)}function uk(e){this._context=e}uk.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:wI(this,this._t0,MG(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,wI(this,MG(this,n=IG(this,e,t)),n);break;default:wI(this,this._t0,n=IG(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function _G(e){this._context=new DG(e)}(_G.prototype=Object.create(uk.prototype)).point=function(e,t){uk.prototype.point.call(this,t,e)};function DG(e){this._context=e}DG.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};function UEe(e){return new uk(e)}function HEe(e){return new _G(e)}function LG(e){this._context=e}LG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=zG(e),i=zG(t),o=0,c=1;c=0;--t)i[t]=(c[t]-i[t+1])/o[t];for(o[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function KEe(e){return new dk(e,.5)}function qEe(e){return new dk(e,0)}function GEe(e){return new dk(e,1)}function Ah(e,t){if((c=e.length)>1)for(var n=1,r,i,o=e[t[0]],c,d=o.length;n=0;)n[t]=t;return n}function YEe(e,t){return e[t]}function WEe(e){const t=[];return t.key=e,t}function XEe(){var e=os([]),t=jI,n=Ah,r=YEe;function i(o){var c=Array.from(e.apply(this,arguments),WEe),d,f=c.length,h=-1,p;for(const g of o)for(d=0,++h;d0){for(var n,r,i=0,o=e[0].length,c;i0){for(var n=0,r=e[t[0]],i,o=r.length;n0)||!((o=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,o,c;r"radius"in e&&"startAngle"in e&&"endAngle"in e,SI=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(v.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{uI(i)&&typeof n[i]=="function"&&(r[i]=(o=>n[i](n,o)))}),r},eTe=(e,t,n)=>r=>(e(t,n,r),null),fk=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var o=e[i];uI(i)&&typeof o=="function"&&(r||(r={}),r[i]=eTe(o,t,n))}),r};function BG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tTe(e){for(var t=1;t(c[d]===void 0&&r[d]!==void 0&&(c[d]=r[d]),c),n);return o}function aTe(e,t){const n=new Map;for(let r=0;r=0}function kI(e){return e!=null&&typeof e!="function"&&oTe(e.length)}function lTe(e){return function(t){return Zl(t,e)}}function UG(e){return e==null||typeof e!="object"&&typeof e!="function"}function Eh(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const HG="[object RegExp]",NI="[object String]",CI="[object Number]",AI="[object Boolean]",VG="[object Arguments]",KG="[object Symbol]",qG="[object Date]",GG="[object Map]",YG="[object Set]",WG="[object Array]",cTe="[object Function]",XG="[object ArrayBuffer]",hk="[object Object]",uTe="[object Error]",QG="[object DataView]",ZG="[object Uint8Array]",JG="[object Uint8ClampedArray]",e7="[object Uint16Array]",t7="[object Uint32Array]",dTe="[object BigUint64Array]",n7="[object Int8Array]",r7="[object Int16Array]",s7="[object Int32Array]",fTe="[object BigInt64Array]",a7="[object Float32Array]",i7="[object Float64Array]";function Ub(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function o7(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function l7(e,t,n){return typeof n!="function"?l7(e,t,()=>{}):EI(e,t,function r(i,o,c,d,f,h){const p=n(i,o,c,d,f,h);return p!==void 0?!!p:EI(i,o,r,h,!1)},new Map,!0)}function EI(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case"object":return hTe(e,t,n,r,i);case"function":return Object.keys(t).length>0?EI(e,Object.assign({},t),n,r,i):Ub(e,t);default:return o7(e)&&i?typeof t=="string"?t==="":!0:Ub(e,t)}}function hTe(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return c7(e,t,n,r);if(t instanceof Map)return pTe(e,t,n,r);if(t instanceof Set)return mTe(e,t,n,r);const o=Object.keys(t);if(e==null)return i&&o.length===0;if(i)UG(e)&&(e=Object(e));else{if(Eh(t)==="[object Error]")return Eh(e)==="[object Error]"&&e.name===t.name&&e.message===t.message;const c=Eh(e);if(c!=="[object Object]"&&c!=="[object Arguments]")return!1}if(o.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let c=0;c{})}function TI(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}const d7=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof global=="object"&&global||(function(){return this})();function OI(e){return typeof d7.Buffer<"u"&&d7.Buffer.isBuffer(e)}function gTe(e){return OI(e)}function vTe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function xTe(e){return vTe(e)}function bTe(e,t){return ig(e,void 0,e,new Map)}function ig(e,t,n,r,i){if(UG(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){const c=new Array(e.length);r.set(e,c);for(let d=0;d{c.set(f,ig(d,f,n,r))}),c}if(e instanceof Set){const c=new Set;return r.set(e,c),e.forEach(d=>{c.add(ig(d,void 0,n,r))}),c}if(gTe(e))return e.subarray();if(xTe(e)){const c=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,c);for(let d=0;du7(t,e)}const jTe=/^(?:0|[1-9]\d*)$/;function h7(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&ee,yr=()=>{var e=v.useContext(RI);return e?e.store.dispatch:TTe},pk=()=>{},OTe=()=>pk,RTe=(e,t)=>e===t;function lt(e){var t=v.useContext(RI),n=v.useMemo(()=>t?r=>{if(r!=null)return e(r)}:pk,[t,e]);return j5.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:OTe,t?t.store.getState:pk,t?t.store.getState:pk,n,RTe)}function PTe(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function ITe(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var m7=e=>Array.isArray(e)?e:[e];function MTe(e){const t=Array.isArray(e[0])?e[0]:e;return ITe(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function _Te(e,t){const n=[],{length:r}=e;for(let i=0;itypeof WeakRef>"u"?DTe:WeakRef,g7=LTe(),zTe=0,v7=1;function mk(){return{s:zTe,v:void 0,o:null,p:null}}function $Te(e){return e instanceof g7?e.deref():e}function x7(e,t={}){let n=mk();const{resultEqualityCheck:r}=t;let i,o=0;function c(){let d=n;const{length:f}=arguments;for(let g=0,x=f;g{n=mk(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}function BTe(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,c=0,d,f={},h=i.pop();typeof h=="object"&&(f=h,h=i.pop()),PTe(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const p={...n,...f},{memoize:g,memoizeOptions:x=[],argsMemoize:y=x7,argsMemoizeOptions:j=[]}=p,w=m7(x),S=m7(j),N=MTe(i),A=g(function(){return o++,h.apply(null,arguments)},...w),E=y(function(){c++;const R=_Te(N,arguments);return d=A.apply(null,R),d},...S);return Object.assign(E,{resultFunc:h,memoizedResultFunc:A,dependencies:N,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>d,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:g,argsMemoize:y})};return Object.assign(r,{withTypes:()=>r}),r}var Ae=BTe(x7);function FTe(e,t=1){const n=[],r=Math.floor(t),i=(o,c)=>{for(let d=0;d{if(e!==t){const r=b7(e),i=b7(t);if(r===i&&r===0){if(et)return n==="desc"?-1:1}return n==="desc"?i-r:r-i}return 0},VTe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,KTe=/^\w*$/;function qTe(e,t){return Array.isArray(e)?!1:typeof e=="number"||typeof e=="boolean"||e==null||pI(e)?!0:typeof e=="string"&&(KTe.test(e)||!VTe.test(e))||t!=null}function GTe(e,t,n,r){if(e==null)return[];n=n,Array.isArray(e)||(e=kI(e)?Array.from(e):UTe(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(d=>String(d));const i=(d,f)=>{let h=d,p=0;for(;p0&&p===f.length?h:void 0},o=(d,f)=>{if(d==null)return f;if(f!=null)return typeof d=="object"&&"key"in d?ag(f,d.key)?f[d.key]:i(f,d.path):typeof d=="function"?d(f):Array.isArray(d)?i(f,d):f[d]},c=t.map(d=>(Array.isArray(d)&&d.length===1&&(d=d[0]),d==null||typeof d=="function"||Array.isArray(d)||qTe(d)?d:{key:d,path:mI(d)}));return e.map(d=>({original:d,criteria:c.map(f=>o(f,d))})).slice().sort((d,f)=>{for(let h=0;hd.original)}function gk(e,...t){const n=t.length;return n>1&&PI(e,t[0],t[1])?t=[]:n>2&&PI(t[0],t[1],t[2])&&(t=[t[0]]),GTe(e,FTe(t),["asc"])}var y7=e=>e.legend.settings,YTe=e=>e.legend.size,WTe=e=>e.legend.payload;Ae([WTe,y7],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?gk(r,n):r});function XTe(e,t){return eOe(e)||JTe(e,t)||ZTe(e,t)||QTe()}function QTe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
+`)})})]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"outline",onClick:()=>{o()},children:a("复制原始记录")}),s.jsx("div",{className:"spacer"}),s.jsx(B,{variant:"ghost",onClick:t,children:a("关闭")})]})]})})}let Nd=null,US=null,Mq=null,CP=Oq;function _q(e){Mq=e,Ya().wbApp?.updateLogsBadge?.(e)}function Dq(e){CP=S1e(e),Nd?.applyAutoConfig(CP)}function A1e(){const[e,t]=v.useState({entries:[],groups:[],total:0,matched:0,grouped:0}),[n,r]=v.useState(!1),[i,o]=v.useState(Pq),[c,d]=v.useState(1),[f,h]=v.useState(()=>Number(W0("logs",rh))),[p,g]=v.useState(CP),[x,y]=v.useState(!1),[j,w]=v.useState(!1),[S,N]=v.useState(0),[A,E]=v.useState(null),[O,R]=v.useState(!1),[T,P]=v.useState(""),[M,_]=v.useState(null),I=v.useRef(null),L=v.useRef({filters:i,page:c,size:f,data:e,paused:x,detail:A});L.current={filters:i,page:c,size:f,data:e,paused:x,detail:A};const D=v.useRef(void 0),z=v.useRef(0),G=v.useRef(!1),X=v.useRef(!1),Y=v.useRef(!1),F=v.useRef(!1),K=v.useRef(!1),U=v.useRef(void 0),q=v.useRef(null),W=v.useCallback(async()=>{if(!Y.current)try{const ae=await Ya().workbuddyDesktop?.getScheduledTasks();Array.isArray(ae?.tasks)&&(Y.current=!0,Dq(ae.tasks.find(_e=>_e.id==="logsAutoRefresh")||null))}catch{}},[]),ne=v.useCallback(async(ae={})=>{if(W(),!F.current&&Ya().wbFilterMemory&&(F.current=!0,!K.current)){const Re=Pq();L.current.filters=Re,o(Re)}const _e=L.current;(ae.resetPage||ae.latest)&&(_e.page=1,d(1),D.current=void 0),ae.latest&&(_e.paused=!1,y(!1),w(!1),I.current&&(I.current.scrollTop=0));const de=++z.current,Se=_e.page,ve=_e.size,xe=_e.filters;ae.silent||R(!0);try{const Re=Ya().workbuddyDesktop;if(!Re)throw new Error(a("后端桥不可用"));const we=!ae.latest&&!ae.resetPage&&(Se>1||_e.paused||_e.detail!==null||(I.current?.scrollTop||0)>20),[ge,De]=await Promise.all([Re.getLogs(Sb(xe,{aggregate:xe.aggregate,offset:(Se-1)*ve,limit:ve,untilId:we?D.current:void 0})),Re.getLogStats()]);if(de!==z.current)return;if(!ge)throw new Error(a("读取日志失败"));const Ge=Number(ge.grouped??ge.matched??ge.entries?.length)||0,Ot=Math.max(1,Math.ceil(Ge/ve));if(Se>Ot){L.current.page=Ot,d(Ot),await ne(ae);return}const sn=L.current.paused||L.current.detail!==null||(I.current?.scrollTop||0)>20;if(ae.silent&&!we&&sn&&D.current!==void 0){const $t=await Re.getLogs(Sb(L.current.filters,{sinceId:D.current,limit:1}));de===z.current&&N(Number($t?.matched)||0);return}if(q.current=ae.resetPage||ae.latest||!ae.silent?0:I.current?.scrollTop||0,L.current.data=ge,t(ge),r(!0),P(""),(!we||D.current===void 0)&&(D.current=Number(ge.lastId??De?.lastId)||0,N(0)),_q(De),xe.category&&ge.categories&&!Object.hasOwn(ge.categories,xe.category)){const $t={...L.current.filters,category:""};L.current.filters=$t,o($t),Iq($t),await ne({resetPage:!0})}}catch(Re){de===z.current&&P(NP(Re))}finally{de===z.current&&R(!1)}},[W]),ie=v.useCallback(async()=>{if(!(G.current||X.current||U.current!==void 0)){G.current=!0;try{const ae=L.current;if((ae.paused||ae.detail!==null||ae.page>1||(I.current?.scrollTop||0)>20)&&D.current!==void 0){const de=Ya().workbuddyDesktop;if(!de)return;const Se=D.current,ve=ae.filters,[xe,Re]=await Promise.all([de.getLogs(Sb(ve,{sinceId:Se,limit:1})),de.getLogStats()]);if(ve!==L.current.filters||Se!==D.current)return;Re?.lastId!==void 0&&Re.lastId{K.current=!0;const de={...L.current.filters,...ae};L.current.filters=de,o(de),U.current!==void 0&&window.clearTimeout(U.current),++z.current,R(!0);const Se=()=>{U.current=void 0,Iq(de),N(0),ne({resetPage:!0})};_e?U.current=window.setTimeout(Se,300):Se()},[ne]);v.useEffect(()=>{if(Nd={load:ne,render:ae=>{ae&&(L.current.data=ae,t(ae),r(!0))},showCategory:async ae=>{V({category:ae,view:"important"}),Ya().wbApp?.showPage?.("logs",{persist:!0})},applyAutoConfig:ae=>{Y.current=!0,g(ae)}},US!==null){const ae=US;US=null,Nd.showCategory(ae)}else ne({silent:!0});return()=>{Nd=null,++z.current,U.current!==void 0&&window.clearTimeout(U.current)}},[V,ne]),v.useEffect(()=>{if(!p.enabled)return;const ae=window.setInterval(()=>{!document.hidden&&Ya().wbApp?.currentPage==="logs"&&ie()},p.ms);return()=>window.clearInterval(ae)},[p,ie]),v.useLayoutEffect(()=>{q.current!==null&&(I.current&&(I.current.scrollTop=q.current),q.current=null)});const H=b1e(e),Q=Number(e.grouped??e.matched??H.length)||0,J=Number(e.matched)||0,oe=Math.max(1,Math.ceil(Q/f)),ee=a("{n} 条",{n:J});v.useEffect(()=>{Ya().wbApp?.renderTopbarStatus?.()},[ee]);function se(ae){L.current.page=Math.max(1,Math.min(ae,oe)),d(L.current.page),w(!1),I.current&&(I.current.scrollTop=0),ne()}function le(ae){const _e=Number(ae),de=(L.current.page-1)*L.current.size;L.current.size=_e,L.current.page=Math.floor(de/_e)+1,h(_e),d(L.current.page),X0("logs",_e),ne()}async function te(ae,_e){if(!X.current){X.current=!0,_(ae);try{await _e()}catch(de){Xm(a("操作失败:{error}",{error:NP(de)}),"err")}finally{X.current=!1,_(null)}}}async function re(){if(X.current||O||T||!J)return;const ae=Sb(L.current.filters,{untilId:D.current});await Ya().wbConfirm?.ask?.({title:a("清空运行日志"),html:a("确定清空当前筛选出的 {count} 条日志?清空后无法恢复。",{count:J}),okText:a("清空"),okClass:"danger"})&&await te("clear",async()=>{const de=Ya().workbuddyDesktop;if(!de)throw new Error(a("后端桥不可用"));await de.clearLogs(ae),await ne({resetPage:!0}),Xm(a("运行日志已清空"),"ok")})}async function he(){await te("export",async()=>{const ae=Ya().workbuddyDesktop;if(!ae)throw new Error(a("后端桥不可用"));const _e=await ae.exportLogs(Sb(L.current.filters,{untilId:D.current}));if(!(!_e||_e.canceled)){if(_e.count===0){Xm(a("暂无日志可导出"),"err");return}Xm(a("✅ 已导出 {count} 条日志到 {file}",{count:String(_e.count),file:String(_e.file)}),"ok")}})}const pe=x||j||c>1||A!==null,Ne=kP.find(ae=>ae.value===i.level)?.label||a("全部级别"),me=e.byLevel||{},ce=!n&&!T?a("正在加载日志…"):Number(e.total)?a("没有符合筛选条件的日志"):a("暂无日志");return s.jsxs(tt,{render:s.jsx("section",{}),className:"panel",id:"logs-panel-events",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsx("h2",{children:a("系统事件")}),s.jsx(ye,{id:"logs-badge",variant:"outline","data-tone":"",children:n?ee:"—"}),s.jsxs("div",{className:"head-actions",children:[s.jsx(B,{variant:"ghost",disabled:M!==null,onClick:()=>{const ae=!L.current.paused;L.current.paused=ae,y(ae),!ae&&!j&&c===1&&!A&&ne({latest:!0})},children:a(x?"恢复刷新":"暂停刷新")}),s.jsx(B,{id:"btn-logs-export",variant:"outline",disabled:M!==null||O||!!T,onClick:()=>{he()},children:a(M==="export"?"导出中…":"导出当前筛选")}),s.jsx(B,{id:"btn-logs-clear",variant:"destructive",disabled:M!==null||O||!!T||!J,onClick:()=>{re()},children:a(M==="clear"?"清空中…":"清空当前筛选")})]})]}),s.jsxs(Ft,{className:"panel-body",children:[s.jsxs("div",{className:"event-log-toolbar",children:[s.jsx(dn,{options:j1e,value:i.view,onValueChange:ae=>V({view:ae}),"aria-label":a("日志视图")}),s.jsx("span",{className:"event-log-status",children:pe?a("阅读模式,列表保持不动"):p.enabled?a("自动刷新"):a("自动刷新已关闭")}),s.jsxs(Ie,{className:"event-log-aggregate",children:[s.jsx(cn,{checked:i.aggregate,onCheckedChange:ae=>V({aggregate:ae}),"aria-label":a("折叠重复日志")}),a("折叠重复日志")]})]}),s.jsxs("div",{className:"log-filters",children:[s.jsx(dn,{options:Rq,value:i.range,onValueChange:ae=>V({range:ae}),"aria-label":a("事件日志时间范围"),className:"shrink-0"}),i.range==="custom"?s.jsx(pP,{dates:i.dates,onChange:ae=>V({dates:ae}),onClear:()=>V({range:"all"})}):null,i.view!=="debug"?s.jsxs(ht,{value:i.level,onValueChange:ae=>V({level:String(ae??"")}),children:[s.jsx(mt,{className:"min-w-[120px]","aria-label":a("按最低级别筛选"),children:s.jsx(pt,{children:Ne})}),s.jsx(gt,{children:kP.map(ae=>s.jsx(qe,{value:ae.value,children:ae.label},ae.value))})]}):null,s.jsxs(ht,{value:i.category,onValueChange:ae=>V({category:String(ae??"")}),children:[s.jsx(mt,{className:"min-w-[120px]","aria-label":a("按分类筛选"),children:s.jsx(pt,{children:i.category?BS(i.category,a):a("全部分类")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("全部分类")}),Object.keys(e.categories||{}).map(ae=>s.jsx(qe,{value:ae,children:BS(ae,a)},ae))]})]}),s.jsxs(uo,{className:"w-auto flex-auto",children:[s.jsx(ho,{type:"search",placeholder:a("搜索消息、提供商或账号…"),"aria-label":a("搜索消息、提供商或账号"),autoComplete:"off",value:i.keyword,onChange:ae=>V({keyword:ae.currentTarget.value},!0)}),s.jsx(fo,{"aria-hidden":"true",children:"⌕"})]})]}),s.jsxs("div",{className:"event-log-overview",children:[s.jsx("span",{children:a("显示 {groups} 组 · 原始记录 {entries} 条",{groups:Q,entries:J})}),s.jsx("span",{className:"event-log-errors",children:a("错误 {n}",{n:me.error||0})}),s.jsx("span",{className:"event-log-warnings",children:a("警告 {n}",{n:me.warn||0})}),i.view!=="important"?s.jsx("span",{children:a("调试 {n}",{n:me.debug||0})}):null]}),i.view==="debug"&&!e.debugEnabled?s.jsx("div",{className:"event-log-note",children:a("调试采集未开启,仅显示已保留的记录。可在设置中开启调试模式。")}):null,T?s.jsxs("div",{className:"event-log-error",role:"status",children:[T,s.jsx(B,{variant:"ghost",size:"xs",onClick:()=>{ne()},children:a("重试")})]}):null,S>0||pe&&!x?s.jsxs("div",{className:"event-log-new",role:"status",children:[s.jsx("span",{children:S?a("有 {n} 条新日志",{n:S}):a("阅读模式,列表保持不动")}),s.jsx(B,{variant:"outline",size:"sm",disabled:O,onClick:()=>{ne({latest:!0})},children:a("查看最新")})]}):null,s.jsx(k1e,{groups:H,empty:ce,loading:O,listRef:I,onScroll:()=>w((I.current?.scrollTop||0)>20),onDetail:ae=>{L.current.detail=ae,E(ae)}})]}),s.jsx(fd,{total:Q,page:c,pageCount:oe,size:f,sizes:rh,disabled:O||M!==null,range:{start:H.length?(c-1)*f+1:0,end:(c-1)*f+H.length},leading:s.jsx("span",{className:"event-log-footer-note",children:a("分页按折叠后的组数计算")}),onSizeChange:le,onPageChange:se}),s.jsx(C1e,{group:A,onClose:()=>{L.current.detail=null,E(null)}})]})}async function E1e(e={}){await Nd?.load(e)}function T1e(e){Nd?.render(e)}function O1e(){return Mq}async function R1e(e){if(!Nd){US=e;return}await Nd.showCategory(e)}function Lq(){const e=document.querySelector('.page[data-page="logs"]');e&&(e.replaceChildren(),wn.createRoot(e).render(s.jsx(A1e,{})))}document.querySelector('.page[data-page="logs"]')?Lq():document.addEventListener("DOMContentLoaded",Lq,{once:!0}),window.wbLogsPanel={load:E1e,render:T1e,lastStats:O1e,applyAutoRefresh:Dq,showCategory:R1e};const No="__custom__",P1e=["off","none","minimal","low","medium","high","xhigh","max"];function kb(e,t){const n=zq(t);if(n.length)return n;const r=e?.reasoningLevels;return Array.isArray(r)&&r.length?r.filter(i=>typeof i=="string"):[...P1e]}function zq(e){const t=e?.reasoningLevels;return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.trim()!==""):[]}function I1e(e,t){const n=t.map(zq).filter(c=>c.length>0);if(!n.length||n.length!==t.length)return kb(e);const[r,...i]=n,o=r.filter(c=>i.every(d=>d.includes(c)));return o.length?o:kb(e)}function $q(e,t,n){return`${String(e??"").trim().toLowerCase()}${String(t??"").trim().toLowerCase()}${String(n??"").trim().toLowerCase()}`}function M1e(e){const t=new Map;for(const n of Array.isArray(e)?e:[]){const r=typeof n?.reasoning=="string"?n.reasoning.trim():"";r&&t.set($q(n.alias,n.target,n.provider),r)}return(n,r,i)=>t.get($q(n,r,i))||""}function Zn(){return window}function Cd(e){return e instanceof Error?e.message:String(e)}function Ia(e,t){Zn().wbApp?.toast?.(e,t)}function AP(e){const t=Zn().wbApp?.esc;return t?t(e):String(e??"").replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n]||n)}function _1e(e){const t=Zn().formatTime??Zn().wbApp?.formatTime;return String(t?.(e)??"")}const Bq=e=>String(e??"").trim().toLowerCase(),Ad=(e,t)=>Bq(e)===Bq(t),Fq=8,Uq="workbuddy-desktop-models-filters",EP=["all","enabled","disabled","mapped"],D1e={all:a("全部"),enabled:a("已启用"),disabled:a("已禁用"),mapped:a("有映射")},L1e=EP.map(e=>({value:e,label:D1e[e]})),TP=["default","rate-asc","rate-desc"],z1e={default:a("默认"),"rate-asc":a("倍率升序"),"rate-desc":a("倍率降序")},$1e=TP.map(e=>({value:e,label:z1e[e]})),OP=["all","visible","hidden","undeclared"],B1e={all:a("全部"),visible:a("可见"),hidden:a("不展示"),undeclared:a("未声明")},F1e=OP.map(e=>({value:e,label:B1e[e]}));function Hq(e){const t=typeof e.visibility=="string"?e.visibility.trim().toLowerCase():"";return t==="hidden"?"hidden":t==="shown"||t==="visible"?"visible":"undeclared"}const RP=[{key:"check",label:a("选择"),align:"center"},{key:"model",label:a("上游模型")},{key:"rate",label:a("倍率")},{key:"visibility",label:a("可见性")},{key:"source",label:a("来源")},{key:"budget",label:a("上下文 / 输出")},{key:"caps",label:a("能力")},{key:"alias",label:a("模型映射")},{key:"act",label:a("操作"),align:"right"}],Vq=new Set(["rate","source","visibility"]),PP={models:[],mappings:[]},Kq={provider:"all",state:"all",search:"",sort:"default",visibility:"visible"};function qq(){const e=Zn().wbFilterMemory;if(!e)return{...Kq};const t=e.load(Uq,{...Kq});return{provider:String(t.provider||"all"),state:EP.includes(t.state)?t.state:"all",search:String(t.search||""),sort:TP.includes(t.sort)?t.sort:"default",visibility:OP.includes(t.visibility)?t.visibility:"visible"}}const Nb=qq();let Gq=!!Zn().wbFilterMemory,Cb=!1,Er={provider:Nb.provider,stateFilter:Nb.state,visibilityFilter:Nb.visibility,search:Nb.search,sort:Nb.sort,data:null,expanded:new Set,pending:new Set,mapping:null,customModel:null,capability:null};const IP=new Set;function Ab(){return Er}function U1e(e){return IP.add(e),()=>{IP.delete(e)}}function $s(e){const t={...Er,...e},n=HS(t),r=HS(Er)!==n;Er=n===t.provider?t:{...t,provider:n},V1e(),r&&KS();for(const i of IP)i()}function Eb(e){Zn().wbFilterMemory?.save(Uq,e)}function Yq(){if(Gq||Cb||!Zn().wbFilterMemory)return;Gq=!0;const e=qq();(e.provider!==Er.provider||e.state!==Er.stateFilter||e.search!==Er.search||e.sort!==Er.sort||e.visibility!==Er.visibilityFilter)&&$s({provider:e.provider,stateFilter:e.state,search:e.search,sort:e.sort,visibilityFilter:e.visibility})}function HS(e){const t=e.provider;return t==="all"||t===Ra||gd().some(n=>n.id===t)||e.data?.providers?.some(n=>n.provider===t)||Array.isArray(e.data?.models)&&e.data.models.some(n=>(n.provider||"")===t)||!e.data||!MP()?t:"all"}function Qm(){return HS(Er)}function MP(){return!!Zn().wbProviders}function Zm(){return Qm()===Ra}function Wq(){return Zm()||ts(Qm())}let Tb=null;function _P(e){const t=vd(e);return(!Tb||Tb.id!==e||Tb.record!==t)&&(Tb={id:e,record:t,view:yR(e)||PP}),Tb.view}let Ob=null;function H1e(){const e=pV();if(Ob&&Ob.directory===e)return Ob.view;const t=[],n=[];for(const r of gd()){const i=_P(String(r.id||""));t.push(...i.models||[]),n.push(...i.mappings||[])}return Ob={directory:e,view:t.length||n.length?{models:t,mappings:n}:PP},Ob.view}function DP(){const e=Qm();return e===Ra?H1e():ts(e)?_P(e):Er.data||PP}function Rb(){const e=DP();return Array.isArray(e.models)?e.models:[]}function Xq(){const e=DP();return Array.isArray(e.mappings)?e.mappings:[]}let Qq=(e,t,n)=>"";function V1e(){Qq=M1e(Xq())}function VS(){const e=new Map;for(const n of Er.data?.providers||[])n.provider&&e.set(n.provider,{label:n.providerLabel||n.provider,n:0});const t=Array.isArray(Er.data?.models)?Er.data.models:[];for(const n of t){const r=n.provider||"";if(!r)continue;const i=e.get(r)||{label:n.providerLabel||r,n:0};i.n++,e.set(r,i)}return e}function K1e(){const e=new Map;for(const t of gd()){const n=String(t.id||"");if(!n)continue;const r=_P(n);e.set(n,{label:String(t.name||n),n:(r.models||[]).length})}return e}function q1e(){return[...VS().keys()]}function G1e(e){const t=Er.data?.providers?.find(i=>i.provider===e);if(t)return Number(t.refreshedAt)||0;const r=(Array.isArray(Er.data?.models)?Er.data.models:[]).find(i=>i.provider===e);return Number(r?.refreshedAt)||0}function LP(){const e=new Map;for(const t of Rb()){const n=t.provider||"";n&&!e.has(n)&&e.set(n,a(t.providerLabel||n))}return[...e].map(([t,n])=>({id:t,label:n}))}function Zq(e){return e?Rb().filter(t=>(t.provider||"")===e).sort((t,n)=>+(t.enabled===!1)-+(n.enabled===!1)).map(t=>({id:t.id,label:t.name&&t.name!==t.id?a("{id}({name})",{id:t.id,name:t.name}):t.id,off:t.enabled===!1})):[]}function Y1e(){const e=[],t=Zn().wbProviders?.all?.();if(Array.isArray(t))for(const n of t){const r=String(n?.id||"");r&&e.push({id:r,label:a(String(n?.label||r))})}for(const n of gd()){const r=String(n.id||"");r&&e.push({id:r,label:String(n.name||r)})}return e.length?e:LP()}let Pb=null,zP=null;function Jq(){const e=Pb?Pb.apply(RP):RP;return Wq()?e.filter(t=>!Vq.has(t.key)):e}function KS(){Zn().wbColSettings?.syncStaticHead("models",zP,Wq()?Vq:null)}function W1e(){if(Pb)return;Pb=Zn().wbColSettings?.register({id:"models",label:a("模型管理表"),columns:RP,mount:()=>document.querySelector('.page[data-page="gateway"] .panel-head .head-actions'),buttonPlacement:"last",onChange:()=>{KS(),yh()}})||null,Pb&&yh()}let qS=0,$P=!1;async function GS({force:e=!1}={}){if($P&&!e)return;const t=++qS;$P=!0,Yq();try{const n=await Zn().workbuddyDesktop?.getModelManage();if(t!==qS)return;$s({data:n&&Array.isArray(n.models)?n:null})}catch(n){if(t!==qS)return;yh(),Ia(a("读取模型清单失败:{message}",{message:Cd(n)}),"err")}finally{t===qS&&($P=!1)}}async function e8(){try{await Zn().wbProviders?.refreshCustom?.()}catch{}await GS({force:!0})}function yh(){$s({})}function wh(e){const t=e;if(t&&Array.isArray(t.models)){$s({data:t});return}yh()}async function YS(e,t,n,r){if(ts(e))return gV(e,t,n,r);const i=Zn().workbuddyDesktop;if(!i)throw new Error(a("后端桥不可用"));return i.addModelMapping(t,n,e,r.reasoning,r.enabled)}async function X1e(e,t,n){if(ts(e))return vV(e,t,n);const r=Zn().workbuddyDesktop;if(!r)throw new Error(a("后端桥不可用"));return r.removeModelMapping(t,n,e)}async function Q1e(e,t){if(ts(e))return xV(e,t);const n=Zn().workbuddyDesktop;if(!n)throw new Error(a("后端桥不可用"));return n.addCustomModel(e,t)}async function t8(e,t){if(ts(e))return yV(e,t);const n=Zn().workbuddyDesktop;if(!n)throw new Error(a("后端桥不可用"));return n.removeCustomModel(e,t)}async function Z1e(e,t,n){if(ts(e))return bV(e,t,n);const r=Zn().workbuddyDesktop;if(!r)throw new Error(a("后端桥不可用"));return r.setModelCapabilities(e,t,n)}async function BP(e,t,n){if(!Er.pending.has(e)){$s({pending:new Set(Er.pending).add(e)});try{wh(await t()),n&&Ia(n)}catch(r){Ia(a("操作失败:{message}",{message:Cd(r)}),"err")}finally{const r=new Set(Er.pending);r.delete(e),$s({pending:r})}}}function Ib(e){return Jm(e).some(t=>t.enabled!==!1)}function Jm(e){const t=e.provider||"",n=Xq().filter(d=>Ad(d.target,e.id)&&(!d.provider||Ad(d.provider,t))),r=new Map;for(const d of n){const f=String(d.alias).toLowerCase();(!r.has(f)||d.provider)&&r.set(f,d)}const i=String(e.id).toLowerCase(),o=r.get(i);r.delete(i);const c=[{alias:e.id,target:e.id,provider:t,enabled:e.enabled!==!1&&o?.enabled!==!1,isDefault:!0}];return c.push(...r.values()),c}const jh=e=>`${e.provider||""}:${e.id}`,FP=(e,t,n)=>`${e}:${t}:${n||""}`;function J1e(e){$s({expanded:new Set(Er.expanded).add(e)})}function eCe(e){const t=new Set(Er.expanded);t.delete(e),$s({expanded:t})}function n8(e){const t=EP.includes(e)?e:"all";t!==Er.stateFilter&&(Cb=!0,$s({stateFilter:t}),Eb({state:t}))}function r8(e){const t=TP.includes(e)?e:"default";t!==Er.sort&&(Cb=!0,$s({sort:t}),Eb({sort:t}))}function s8(e){const t=OP.includes(e)?e:"visible";t!==Er.visibilityFilter&&(Cb=!0,$s({visibilityFilter:t}),Eb({visibility:t}))}function a8(e){Cb=!0,$s({search:e}),Eb({search:e})}function Mb(e){$s({provider:String(e??"").trim()||"all"}),Eb({provider:Er.provider}),KS()}async function tCe(e){const t=Zn().wbCustomProvidersUi;if(!t?.remove){Ia(a("删除入口未就绪,请重试或重启应用"),"err");return}await t.remove(e)&&await GS({force:!0})}function nCe(){Zn().wbAccountAddForms?.openNewCustomForm?.()}function i8(e){$s({mapping:e})}function rCe(){$s({mapping:null})}function sCe(){const e=Qm(),t=ts(e);$s({customModel:{provider:t||e!=="all"&&e!==Ra?e:"",locked:t}})}function aCe(){$s({customModel:null})}function o8(e,t){$s({capability:{provider:e,id:t}})}function iCe(){$s({capability:null})}function l8(e,t){return Rb().find(n=>(n.provider||"")===e&&Ad(n.id,t))||null}function UP(e){if(ts(e)){const t=vd(e)?.name;return typeof t=="string"&&t||e}return a(Zn().wbProviders?.labelOf?.(e)||e)}function c8(){const e=Qm(),t=ts(e),n=t?vd(e)?.name||e:a("内置提供商");Zn().wbModelsFetchModal?.open({providerId:e===Ra?"":e,custom:t,name:n,onDone:()=>yh(),onRefreshed:()=>{GS({force:!0})}})}window.wbModelsPanel={render:yh,load:GS,refreshAll:e8,refreshModels:c8,visibleColumns:Jq,selectProvider:Mb,builtinProviders:q1e,providerRefreshedAt:G1e};function HP(e,t,n){return Qq(e,t,n)}function oCe(e){zP=e}function lCe(){const e=zP;if(!e)return;const t=r=>Object.keys(r).some(i=>i.startsWith("__reactFiber$")||i.startsWith("__reactInternalInstance$"));for(const r of[...e.children])r.tagName==="TBODY"?r.id!=="models"&&r.remove():r.tagName==="TR"&&!t(r)&&r.remove();const n=e.querySelector("tbody#models");if(n)for(const r of[...n.children])t(r)||r.remove()}const cCe=e=>[{value:"inherit",label:e},{value:"on",label:a("支持")},{value:"off",label:a("不支持")}];function uCe(e){const t=bR(e);return a(t==="on"?"支持":t==="off"?"不支持":"未声明")}function u8(e,t,n,r,i=""){const o=t!=null,c=ib.includes(e)?ob(t):uCe(t);return n?r?a("已填写:对下游声明 {value}",{value:c}):a("已覆盖:对下游声明 {value}",{value:c}):r?a("未填写(下游按未声明处理)"):o?i==="modelsdev"?a("models.dev 补齐:对下游声明 {value}",{value:c}):a("继承上游:{value}",{value:c}):a("上游未声明(下游会按不支持处理)")}function dCe(e,t,n){return n?$m.filter(r=>{const i=e[r];return i!=null}):t}function fCe(e,t){const n={};for(const r of $m){const i=t.includes(r),o=e[r];ib.includes(r)?n[r]=i&&typeof o=="number"?String(o):"":n[r]=i?o===!0?"on":"off":"inherit"}return n}function hCe({context:e,onClose:t}){const n=ts(e.provider),r=l8(e.provider,e.id),i=fV(r),o=sS(r),c=dCe(o,xR(r?.capOverrides),n),[d,f]=v.useState(()=>fCe(o,c)),[h,p]=v.useState(""),[g,x]=v.useState(!1);if(!r)return s.jsx(St,{open:!0,onOpenChange:R=>{R||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("模型能力")})}),s.jsx(Ct,{children:s.jsx("p",{className:"text-sm leading-[1.7] text-subtle",children:a("这一行已不在当前清单里(模型被移除、或目录刷新后上游不再提供它)。关闭后刷新列表再试。")})}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const y=r.id,j=r.providerLabel||UP(e.provider),w=a(n?"未声明":"继承上游"),S=a(n?"清除":"恢复继承");function N(R){const T=o[R];return A(R)?"":n?a("未填写"):typeof T=="number"?a("继承上游 {value}",{value:ob(T)}):a("上游未声明")}function A(R){return c.includes(R)}function E(R,T){f(P=>({...P,[R]:T}))}async function O(){if(!g){for(const R of ib){const T=d[R].trim();if(T&&vR(R,T)===null){p(a("{label}要填 1 ~ 1 亿之间的整数(留空 = {inherit})",{label:Bm[R],inherit:w}));return}}x(!0),p(a("保存中…"));try{wh(await Z1e(e.provider,e.id,a0e(d))),t(),Ia(a("✅ 已保存 {id} 的能力位({provider})",{id:y,provider:j}))}catch(R){p(a("保存失败:{message}",{message:Cd(R)})),x(!1)}}}return s.jsx(St,{open:!0,onOpenChange:(R,T)=>{if(!R){if(g){T.cancel();return}t()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("模型能力")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 font-mono text-[12px] text-subtle",children:[s.jsx("b",{className:"text-primary-fg",children:r.id}),a("({provider})",{provider:j})]}),ib.map(R=>s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-[7px]",children:[s.jsx(Ie,{htmlFor:`cap-${R}`,children:Bm[R]}),A(R)?s.jsx(B,{variant:"ghost",size:"2xs",disabled:g,title:a(n?"清除这一项(回到未声明)":"清除覆盖,回到上游声明值"),onClick:()=>E(R,""),children:S}):null]}),s.jsx(Be,{id:`cap-${R}`,inputMode:"numeric",autoComplete:"off",spellCheck:!1,placeholder:N(R),disabled:g,value:d[R],onChange:T=>E(R,T.currentTarget.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),O())}}),s.jsx("p",{className:"text-xs leading-[1.6] text-subtle",children:u8(R,o[R]??null,A(R),n,Fm(r,R))})]},R)),cV.map(R=>s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{children:Bm[R]}),s.jsx(dn,{options:cCe(w),value:d[R],"aria-label":Bm[R],className:"self-start",onValueChange:T=>E(R,String(T))}),s.jsx("p",{className:"text-xs leading-[1.6] text-subtle",children:u8(R,o[R]??null,A(R),n,Fm(r,R))})]},R)),i?s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 text-xs leading-[1.7] text-subtle",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{children:a("可配思考档位")}),s.jsx("span",{className:"font-mono text-[12px] text-primary-fg",children:i.levels.join(" / ")}),i.defaultLevel?s.jsxs("span",{children:[a("(默认 "),s.jsx("span",{className:"font-mono text-[12px] text-primary-fg",children:i.defaultLevel}),a(")")]}):null]}),s.jsx("div",{className:"mt-1",children:a("这是模型自己能配的档位(来自上游目录),只读;要改某一档请到映射弹窗里选。")})]}):null,s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("这几项是给"),s.jsx("b",{children:a("下游客户端")}),a("看的能力声明("),s.jsx("code",{children:"/v1/models"}),a(" 里的 "),s.jsx("code",{children:"max_input_tokens"})," / ",s.jsx("code",{children:"supports_*"}),a(" 与 "),s.jsx("code",{children:"input_modalities"}),a("),下游按它们决定发不发图片、按多大的窗口堆历史。"),s.jsx("b",{children:a("不影响网关的转发与路由")}),a("。上游清单给的值不准时,在这里改;"),a(n?"这家的清单是你自己登记的,不填的项下游按未声明处理。":"「恢复继承」会把这一项交还给上游清单的值。")]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:h})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:g,onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:g,onClick:()=>{O()},children:a("保存")})]})]})})}function d8(e){if(e.transport||!e.result||e.result.error)return!1;const t=Number(e.result.status)||0;return t>=200&&t<300}function VP(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"—":t<1e3?`${Math.round(t)} ms`:`${(t/1e3).toFixed(t<1e4?2:1)} s`}const pCe={chat_completions:"Chat Completions",responses:"Responses",anthropic:"Anthropic Messages"},mCe=[{test:e=>e===429,hint:a("该账号对这个模型正在限额冷却,等一会儿自己会好;也可以先测别的账号。")},{test:e=>e===401||e===403,hint:a("上游拒绝了这条登录态:重新登录一次,或把这条账号删掉。")},{test:e=>e===404,hint:a("上游不认识这个模型名:先点「获取模型」刷新清单,或核对默认绑定指向的上游模型。")},{test:e=>e===504,hint:a("上游没在预算内给完回答。可以只勾一个账号再测一次,看是普遍慢还是某一个账号慢。")},{test:e=>e>=500,hint:a("多半是上游自己的问题,过一会儿再试。同一个错误出现在所有账号上时,先查模型目录与映射。")}];function gCe({slot:e,model:t,now:n,expanded:r,onToggle:i}){const o=(p,g)=>s.jsxs("div",{className:"flex items-center gap-2.5 border-b border-hairline px-3 py-2",children:[p,s.jsx("b",{className:"min-w-0 truncate text-[12.5px] text-foreground",title:e.label,children:e.label}),e.position?s.jsxs("span",{className:"flex-none text-xs text-subtle",children:["#",e.position]}):null,s.jsx("span",{className:"ml-auto flex-none font-mono text-[11.5px] tabular-nums text-subtle",children:g})]});if(e.state==="running")return s.jsxs("div",{className:"flex items-center gap-2.5 rounded-md border border-border bg-surface-2 px-3 py-2.5 text-xs text-subtle",children:[s.jsx(Ls,{className:"flex-none"}),s.jsxs("span",{className:"min-w-0 truncate",children:[a("账号 "),s.jsx("b",{className:"text-foreground",children:e.label}),a(" 已发出,等待上游首帧…")]}),s.jsx("span",{className:"ml-auto flex-none font-mono tabular-nums",children:a("已等待 {seconds}s",{seconds:((n-e.startedAt)/1e3).toFixed(1)})})]});const c=e.result;if(!d8(e)){const p=Number(c?.status)||0,g=mCe.find(x=>x.test(p))?.hint??(e.transport?a("确认桌面端还在运行,再重试一次。"):"");return s.jsxs("div",{className:"rounded-md border border-border bg-surface-2",children:[o(s.jsx(ye,{shape:"tag",variant:"destructive",className:"flex-none",children:p||a("失败")}),a("用时 {time}",{time:VP(c?.duration_ms)})),s.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2.5",children:[s.jsxs("div",{className:"text-[12.5px] leading-[1.7]",children:[e.transport?s.jsxs(s.Fragment,{children:[s.jsx("b",{className:"text-destructive",children:a("本机网关没有返回结论")}),a(":"),e.transport]}):s.jsxs(s.Fragment,{children:[s.jsx("b",{className:"text-destructive",children:a("测试未通过")}),a(":"),c?.error||a("上游没有给出可读的错误说明")]}),Number(c?.attempts)>1?a("(中间共尝试 {n} 次)",{n:Number(c?.attempts)}):""]}),g?s.jsx("p",{className:"text-xs leading-[1.65] text-subtle",children:g}):null]})]})}const d=String(c?.reply??""),f=String(c?.reasoning??""),h=[c?.upstream_model&&c.upstream_model!==t?a("上游 {model}",{model:c.upstream_model}):"",c?.upstream_reasoning?a("思考等级 {level}",{level:c.upstream_reasoning}):"",c?.protocol&&c.protocol!=="chat_completions"?pCe[c.protocol]||c.protocol:"",c?.proxy?a("节点 {proxy}",{proxy:c.proxy}):"",c?.apiKeyName?`API Key: ${c.apiKeyName}`:"",Number(c?.attempts)>1?a("尝试 {n} 次",{n:Number(c?.attempts)}):""].filter(Boolean).join(" · ");return s.jsxs("div",{className:"rounded-md border border-border bg-surface-2",children:[o(s.jsx(ye,{shape:"tag",variant:"success",className:"flex-none",children:Number(c?.status)||200}),a("用时 {time} · 首字 {ttfb}",{time:VP(c?.duration_ms),ttfb:VP(c?.ttfb_ms)})),s.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11.5px] text-subtle",children:[s.jsx("span",{className:"flex-none",children:a("回复")}),h?s.jsx("span",{className:"min-w-0 truncate",title:h,children:h}):null,s.jsx(B,{variant:"ghost",size:"2xs",className:"ml-auto flex-none","data-copy":d,children:a("复制")})]}),s.jsx("div",{className:"max-h-[220px] overflow-y-auto whitespace-pre-wrap rounded-sm border border-border bg-surface px-3 py-2 text-[12.5px] leading-[1.7]",children:d||s.jsx("span",{className:"text-subtle",children:a("(上游这一次返回了空正文)")})}),f?s.jsxs("div",{className:"overflow-hidden rounded-sm border border-border",children:[s.jsxs(B,{variant:"ghost",size:"xs",className:"w-full","aria-expanded":r,onClick:i,children:[s.jsx("span",{className:"truncate",children:a("思考过程({n} 字)",{n:f.length})}),s.jsx("span",{"aria-hidden":"true",className:"ml-auto text-[10px]",children:r?"▴":"▾"})]}),r?s.jsx("div",{className:"border-t border-hairline bg-surface px-2.5 py-2",children:s.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11.5px] leading-[1.65] text-subtle",children:f})}):null]}):null]})]})}function eg(){return window}const vCe="你好",f8=4e3,xCe=[{value:"chat_completions",label:"OpenAI - Chat Completions"},{value:"responses",label:"OpenAI - Responses"},{value:"anthropic",label:"Anthropic - Messages"}],bCe="direct",yCe={remote:a("远程目录"),builtin:a("内置清单"),manual:a("手动登记")};function h8(){return eg().wbApp?.getState?.()?.accounts?.accounts||[]}function p8(e){return h8().filter(t=>(t.provider||JT)===e&&t.available!==!1&&t.enabled!==!1).sort(_0)}function m8(e){const t=String(e.email||"").trim();return t&&Oa(e.provider).emailAsName?t:go(e)||t||a("未命名账号")}function wCe(){const e=globalThis.crypto?.randomUUID?.();if(e)return e;const t=n=>Array.from({length:n},()=>Math.floor(Math.random()*16).toString(16)).join("");return`${t(8)}-${t(4)}-4${t(3)}-a${t(3)}-${t(12)}`}function jCe(e,t){return t.kind==="image"?a("图片生成模型请通过 /v1/images/generations 调用,暂不支持对话测试"):p8(e).length?"":a("该提供商没有可用账号(要在账号页启用一个、且凭证完整),一行都发不出去")}function g8({children:e,plain:t=!1}){return s.jsxs("p",{className:t?"flex items-center gap-2 text-xs leading-[1.6] text-subtle":"flex gap-2 rounded-md border border-border bg-surface-2 px-3 py-2.5 text-xs leading-[1.65] text-subtle",children:[s.jsx("span",{"aria-hidden":"true",className:t?"size-4 flex-none rounded-full border border-border-strong text-center text-[10px] leading-[14px]":"mt-px size-4 flex-none rounded-full border border-border-strong text-center text-[10px] leading-[14px]",children:"i"}),s.jsx("span",{children:e})]})}function SCe(e){const[t,n]=v.useState(()=>Date.now());return v.useEffect(()=>{if(!e)return;n(Date.now());const r=window.setInterval(()=>n(Date.now()),400);return()=>window.clearInterval(r)},[e]),t}function kCe({target:e,onClose:t}){const n=e.provider,r=l8(n,e.id),i=p8(n),o=uO(h8()),[c,d]=v.useState(""),[f,h]=v.useState(vCe),[p,g]=v.useState("chat_completions"),[x,y]=v.useState(""),[j,w]=v.useState(null),[S,N]=v.useState(""),[A,E]=v.useState(""),[O,R]=v.useState(!0),T=QR(async()=>{const de=eg().workbuddyDesktop?.getModelApiKeys;if(!de)throw new Error(a("当前环境不支持读取 API Key"));return de()}),{value:P,ready:M,select:_}=v0e("model-test",ub),I=T.keys.find(de=>de.id===P),L=!!(I&&gK(I,e.id,n)),D=v.useRef(I);D.current=I;const[z,G]=v.useState(()=>{const de=i.find(Se=>!Px(Se,e.id))||i[0];return de?[de.id]:[]}),[X,Y]=v.useState([]),[F,K]=v.useState(()=>new Set),U=v.useRef(0),q=v.useRef([]);q.current=X;const W=X.some(de=>de.state==="running"),ne=SCe(W);v.useEffect(()=>{let de=!0;return(async()=>{try{const Se=eg().workbuddyDesktop?.getProxyPool;if(typeof Se!="function")throw new Error(a("当前环境不支持代理池"));const ve=await Se();if(!de)return;if(!ve||typeof ve!="object"||!Array.isArray(ve.items))throw new Error(a("代理池响应异常"));w(ve.items),N("")}catch(Se){if(!de)return;w([]),N(Cd(Se))}})(),()=>{de=!1}},[]);const ie=v.useCallback((de=!1)=>{const Se=q.current.filter(ve=>ve.state==="running");U.current+=1;for(const ve of Se)eg().workbuddyDesktop?.terminateStatsRequest?.(ve.testId)?.catch(()=>{});Y([]),Se.length&&!de&&Ia(a("已中止在途测试({n} 个账号)",{n:Se.length}))},[]);v.useEffect(()=>()=>{ie(!0)},[ie]);async function V(de,Se){const ve={provider:n,model:e.id,account_id:de.accountId,prompt:f.trim(),system_prompt:c.trim(),reasoning:A,stream:O,protocol:p,...x?{proxy:x}:{},test_id:de.testId},xe=Re=>{U.current===Se&&Y(we=>we.map(ge=>ge.testId===de.testId?{...ge,...Re}:ge))};try{const Re=D.current;if(!Re)throw new Error(a("请先选择一把 API Key"));const we=await eg().workbuddyDesktop?.testModel(ve,Re.key);if(!we){xe({state:"done",transport:a("桥接调用返回空(本机网关没有响应这次测试)")});return}xe({state:"done",result:we})}catch(Re){xe({state:"done",transport:Cd(Re)})}}function H(){if(!M||!T.ready||!I){Ia(a("请先选择一把 API Key"),"err");return}if(!L){Ia(a("所选 API Key 无权调用此模型或提供商"),"err");return}const de=i.filter(Re=>z.includes(Re.id));if(!de.length){Ia(a("至少选一个测试账号"),"err");return}const Se=U.current+1;U.current=Se;const ve=Date.now(),xe=de.map(Re=>({accountId:Re.id,label:m8(Re),position:o.get(Re.id)?.position||0,testId:wCe(),startedAt:ve,state:"running"}));K(new Set),Y(xe);for(const Re of xe)V(Re,Se)}function Q(){W?ie():Y([])}const J=s.jsx("span",{className:"ml-2 font-mono text-[12px] font-normal text-subtle",children:e.id});if(!r)return s.jsx(St,{open:!0,onOpenChange:de=>{de||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("测试模型")})}),s.jsx(Ct,{children:s.jsx("p",{className:"text-sm leading-[1.7] text-subtle",children:a("这一行已不在当前清单里(模型被移除、或目录刷新后上游不再提供它)。关闭后刷新列表再试。")})}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const oe=Jm(r).find(de=>de.isDefault)?.enabled===!1,ee=HP(r.id,r.id,n),se=Jm(r).filter(de=>!de.isDefault).map(de=>de.alias),le=kb(Ab().data,r).filter(de=>de!=="off"&&de!=="none"),te=oe?a("跟随映射(该行未启用,本次不注入)"):ee?a("跟随映射(当前 {level})",{level:ee}):a("跟随映射(未绑定等级)"),re=[a("以模型本名直发"),se.length?a("另有 {n} 条别名映射({aliases}),别名不参与本次",{n:se.length,aliases:se.join(a("、"))}):"",oe?a("该行当前未启用:测试照常按本名直发(「先测通、再决定要不要启用」正是这颗按钮的用法),但本行的思考等级绑定不参与本次,生产路由也要等绑定打开后才会放行"):ee?a("映射上绑定的思考等级是 {level},「跟随映射」按它注入",{level:ee}):a("映射上未绑定思考等级,「跟随映射」等于这次不注入")].filter(Boolean).join(a(";"))+a("。"),he=eg().wbProviders?.PROTOCOL_OPTIONS||xCe,pe=he.find(de=>de.value===p)?.label||p,Ne=[{value:"",label:a("跟随账号配置")},{value:bCe,label:a("直连(不使用代理)")},...(j??[]).map(de=>({value:`${tl}${de.id}`,label:dm(de),disabled:de.enabled===!1}))];j===null?Ne.push({value:"__hint_pool__",label:a("正在读取代理列表…"),disabled:!0}):j.length||Ne.push({value:"__hint_pool__",label:a(S?"代理列表读取失败":"还没有代理(去「网络代理」页添加)"),disabled:!0});const me=Ne.find(de=>de.value===x)?.label||a("跟随账号配置"),ce=i.map(de=>({value:de.id,label:`#${o.get(de.id)?.position||0} ${m8(de)}`+(Px(de,e.id)?a(" · 限额中"):"")}));function ae(de){const Se=`think-${de.testId}`;return s.jsx(gCe,{slot:de,model:e.id,now:ne,expanded:F.has(Se),onToggle:()=>K(ve=>{const xe=new Set(ve);return xe.has(Se)?xe.delete(Se):xe.add(Se),xe})},de.testId)}function _e(){if(W){const Se=X.length-X.filter(ve=>ve.state==="running").length;return s.jsxs(s.Fragment,{children:[X.length>1?s.jsxs("p",{className:"text-xs text-subtle",children:[a("正在测 "),s.jsx("b",{className:"text-foreground",children:X.length}),a(" 个账号"),Se?s.jsxs(s.Fragment,{children:[a(",已完成 "),s.jsx("b",{className:"text-foreground",children:Se})]}):null,a("。")]}):null,X.map(ve=>ae(ve))]})}const de=X.filter(d8).length;return s.jsxs(s.Fragment,{children:[X.length>1?s.jsxs("p",{className:"text-xs text-subtle",children:[s.jsx("b",{className:de?"text-success":"text-foreground",children:de}),a(" 成功 ·"),s.jsxs("b",{className:X.length-de?"text-destructive":"text-foreground",children:[" ",X.length-de]}),a(" 失败")]}):null,X.map(Se=>ae(Se)),de===0?s.jsxs(g8,{children:[a("两边原因不一样时各自处理。如果"),s.jsx("b",{className:"text-foreground",children:a("同一条错误出现在所有账号上")}),a(",通常就不是账号问题了:先确认这个模型还在上游目录里(「获取模型」刷一次),再看默认绑定指向的上游模型对不对。")]}):null]})}return s.jsx(St,{open:!0,onOpenChange:de=>{de||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsxs(jt,{children:[a("测试模型"),J]})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-inset px-3 py-2.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px] font-semibold text-primary-fg",title:r.id,children:r.id}),s.jsx(ye,{shape:"tag",variant:"brand",children:UP(n)}),s.jsx(ye,{shape:"tag",variant:"outline",children:ts(n)?a("自定义家"):yCe[r.source]||a("来源未知")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("本次测试的发送口径")}),children:"?"}),s.jsx(Ml,{children:re})]})]}),s.jsx(ZR,{...T,value:P,onChange:_,id:"model-test-api-key",disabled:!M,rememberSelection:!0,onRefresh:()=>{T.refresh().catch(()=>{})},t:a}),I&&!L?s.jsx("p",{role:"status",className:"text-xs text-destructive",children:a("所选 API Key 无权调用此模型或提供商")}):null,s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-system",children:a("系统提示词")}),s.jsx(Ea,{id:"model-test-system",rows:2,maxLength:f8,placeholder:a("留空则不携带;设置页的提示词模式照常生效"),value:c,onChange:de=>d(de.currentTarget.value)})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-prompt",children:a("用户提示词")}),s.jsx(Ea,{id:"model-test-prompt",rows:2,maxLength:f8,placeholder:a("留空用默认问候「你好」"),value:f,onChange:de=>h(de.currentTarget.value)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-protocol",children:a("对话协议")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("对话协议的说明")}),children:"?"}),s.jsx(Ml,{children:a("按所选网关对话协议组装请求并校验响应转换(Chat Completions / Responses / Anthropic Messages)。")})]})]}),s.jsxs(ht,{value:p,onValueChange:de=>g(String(de)),children:[s.jsx(mt,{id:"model-test-protocol",className:"w-full",children:s.jsx(pt,{className:"min-w-0 truncate",children:pe})}),s.jsx(gt,{children:he.map(de=>s.jsx(qe,{value:de.value,children:de.label},de.value))})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-proxy",children:a("测试节点")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("测试节点的说明")}),children:"?"}),s.jsx(Ml,{children:a("仅本次测试临时生效,不修改账号保存的代理配置。可选「网络代理」页里的节点或强制直连。")})]})]}),s.jsxs(ht,{value:x,onValueChange:de=>y(String(de)),children:[s.jsx(mt,{id:"model-test-proxy",className:"w-full",children:s.jsx(pt,{className:"min-w-0 truncate",children:me})}),s.jsx(gt,{children:Ne.map(de=>s.jsx(qe,{value:de.value,disabled:de.disabled,children:de.label},de.value))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-reasoning",children:a("思考等级")}),s.jsxs(ht,{value:A,onValueChange:de=>E(String(de)),children:[s.jsx(mt,{id:"model-test-reasoning",className:"w-full",children:s.jsx(pt,{children:A?a("{level}(本次指定)",{level:A}):te})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:te}),le.map(de=>s.jsx(qe,{value:de,children:a("{level}(本次指定)",{level:de})},de))]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"model-test-stream",children:a("流式请求")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("流式请求的说明")}),children:"?"}),s.jsx(Ml,{children:a("默认开,与真实请求一致:可同时验证 SSE 链路与首字延迟。")})]})]}),s.jsx(cn,{id:"model-test-stream",checked:O,onCheckedChange:de=>R(!!de)})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ie,{htmlFor:"model-test-accounts",children:a("测试账号")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("测试账号的说明")}),children:"?"}),s.jsx(Ml,{children:a("勾几个就并行测几次;默认选队列里最靠前的一个。")})]}),s.jsx(B,{variant:"ghost",size:"xs",className:"ml-auto",disabled:!i.length||z.length===i.length,onClick:()=>G(i.map(de=>de.id)),children:a("全选({n})",{n:i.length})})]}),s.jsx(Ff,{id:"model-test-accounts",value:z,onValueChange:G,options:ce,placeholder:a("选一个账号(至少一个)"),searchPlaceholder:a("搜索账号…"),emptyHint:a("这家没有可用账号(要在账号页启用一个、且凭证完整)")})]}),s.jsx(g8,{plain:!0,children:a("真实链路 · 消耗少量额度 · 日志带「测试」标记,不计报表")})]}),s.jsxs(Pt,{className:"justify-end",children:[s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")}),s.jsx(B,{variant:"default",disabled:!z.length||!i.length||!M||!T.ready||!L,onClick:H,children:a("开始测试")})]}),s.jsx(St,{open:X.length>0,onOpenChange:de=>{de||Q()},children:s.jsxs(kt,{overlayForceRender:!0,className:"w-[min(680px,calc(100vw-48px))]",children:[s.jsx(Nt,{children:s.jsxs(jt,{children:[a(W?"测试中…":"测试结果"),J]})}),s.jsx(Ct,{children:_e()}),s.jsx(Pt,{className:"justify-end",children:W?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-xs text-subtle",children:a("关闭即中止")}),s.jsx(B,{variant:"outline",onClick:()=>ie(),children:a("中止测试")}),s.jsx(B,{variant:"default",disabled:!0,children:a("测试中…")})]}):s.jsxs(s.Fragment,{children:[s.jsx(B,{variant:"outline",onClick:Q,children:a("关闭")}),s.jsx(B,{variant:"default",onClick:H,children:a("再测一次")})]})})]})})]})})}const v8=[{value:"enable",label:a("启用")},{value:"disable",label:a("禁用")},{value:"reasoning",label:a("设置思考等级")},{value:"delete",label:a("删除")}];function x8(e){return e.source==="manual"||ts(e.provider)}function NCe(e){return(e.name&&e.name!==e.id?a("{name}({id})",{name:e.name,id:e.id}):e.id)||e.id}function CCe({models:e,onClose:t,onDone:n}){const[r,i]=v.useState("enable"),o=I1e(Ab().data,e),[c,d]=v.useState(()=>({select:o[0]||"",custom:""})),[f,h]=v.useState(!1),[p,g]=v.useState(""),x=c.select===No?c.custom.trim():c.select,y=e.filter(x8).length,j=v8.find(N=>N.value===r)?.label||a("操作");async function w(N){return Promise.resolve(Zn().wbConfirm?.ask?.({title:a("删除选中的模型"),html:a("确定删除选中的 {count} 个模型登记?删除后 /v1/models 不再广告它们、请求也会被拒。",{count:N})+(e.length>N?"
"+a("另有 {n} 个非手动登记的模型将被跳过。",{n:e.length-N}):""),okText:a("删除"),okClass:"danger"})??!1)}async function S(){if(f)return;if(!e.length){Ia(a("没有选中的模型"),"err");return}if(r==="reasoning"&&c.select===No&&!x){g(s.jsx("span",{className:"text-destructive",children:a("请填写自定义思考等级,或改选候选档 / 「清除」")}));return}if(r==="delete"){if(y===0){g(s.jsx("span",{className:"text-destructive",children:a("选中的模型都不是手动登记,无法删除(开关映射才是它们的手段)")}));return}if(!await w(y))return}h(!0),g("");let N=0,A=0,E=0,O="";for(const R of e){const T=R.provider||"";try{if(r==="delete"){if(!x8(R)){A+=1;continue}wh(await t8(T,R.id))}else if(r==="enable"||r==="disable"){const P=r==="enable";for(const M of Jm(R))wh(await YS(T,M.alias,R.id,{enabled:P}))}else for(const P of Jm(R))wh(await YS(T,P.alias,R.id,{reasoning:x}));N+=1}catch(P){E+=1,O||(O=Cd(P)),g(s.jsx("span",{className:"text-destructive",children:a("失败 {n} 个 · 首个失败:{error}",{n:E,error:O})}))}}E===0?(Ia(A?a("✅ 批量{action}完成:共 {n} 个模型(跳过不可删除的 {skipped} 个)",{action:j,n:N,skipped:A}):a("✅ 批量{action}完成:共 {n} 个模型",{action:j,n:N})),n()):(Ia(a("批量{action}完成:成功 {ok} 个,失败 {failed} 个",{action:j,ok:N,failed:E}),"err"),g(s.jsxs("span",{className:"text-destructive",children:[a("成功 {ok} 个,失败 {failed} 个",{ok:N,failed:E}),A?a(",跳过 {n} 个",{n:A}):"",O?a(";首个失败:{error}",{error:O}):""]}))),h(!1)}return s.jsx(St,{open:!0,onOpenChange:N=>{N||f||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("批量操作 · 已选 {n} 个模型",{n:e.length})})}),s.jsxs(Ct,{children:[s.jsxs(Ln,{children:[s.jsx("h3",{children:a("将作用于以下模型")}),s.jsx("p",{style:{maxHeight:84,overflowY:"auto"},children:e.map(NCe).join(a("、"))})]}),s.jsxs(Ln,{children:[s.jsx("h3",{children:a("操作")}),s.jsx(bx,{value:r,onValueChange:N=>i(N),className:"flex-row flex-wrap items-center gap-5","aria-label":a("批量动作"),children:v8.map(N=>s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:N.value}),N.label]},N.value))}),r==="reasoning"?s.jsxs("div",{className:"mt-2.5",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"batch-model-reasoning",children:a("思考等级")}),s.jsxs(ht,{value:c.select,onValueChange:N=>d(A=>({...A,select:String(N)})),children:[s.jsx(mt,{id:"batch-model-reasoning",className:"min-w-[220px]",children:s.jsx(pt,{children:c.select===No?a("自定义等级…"):c.select||a("清除(不覆盖)")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("清除(不覆盖)")}),o.map(N=>s.jsx(qe,{value:N,children:N},N)),s.jsx(qe,{value:No,children:a("自定义等级…")})]})]})]}),c.select===No?s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2",children:[s.jsx(Tt,{htmlFor:"batch-model-reasoning-custom",children:a("自定义等级")}),s.jsx(Be,{id:"batch-model-reasoning-custom",maxLength:32,value:c.custom,onChange:N=>d(A=>({...A,custom:N.currentTarget.value}))})]}):null,s.jsxs("p",{className:"detail mt-1.5",children:[a("设置 / 清除会应用到选中模型的"),s.jsx("b",{children:a("全部映射")}),a("(默认绑定与别名 chips);「清除」= 不给这些映射指定等级(选「不覆盖」的口径与映射弹窗一致)")]})]}):null,r==="delete"?s.jsx("p",{className:"detail mt-2",children:y===0?a("选中的都不是手动登记的模型,删除不可用(上游目录带回来的行由清单决定存在性)"):a("可删除 {n} 个(手动登记 / 自定义家);",{n:y})+(e.length>y?a("其余 {n} 个会被跳过。",{n:e.length-y}):"")}):null]}),s.jsx("div",{className:"detail",style:{minHeight:18},children:p})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:f,onClick:t,children:a("关闭")}),s.jsx(B,{variant:r==="delete"?"destructive":"default",disabled:f,onClick:()=>{S()},children:f?a("执行中…"):a("执行{action}",{action:j})})]})]})})}function ACe(e){const t=/^上游返回\s+([1-5]\d{2})[::] ?/.exec(e);return t?{status:t[1],body:e.slice(t[0].length),upstream:!0}:{status:/^HTTP\s+([1-5]\d{2})(?:\b|$)/i.exec(e)?.[1],body:e,upstream:!1}}function ECe({message:e}){const{status:t,body:n,upstream:r}=ACe(e),i=new TextEncoder().encode(n).length,o=t?a("{status}:模型获取失败",{status:t}):a("模型获取失败"),c=a(r?"上游原始响应":"错误详情");return s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[s.jsxs(It,{variant:"destructive",className:"flex items-center gap-2 rounded-none border-0 bg-transparent p-0",children:[s.jsx("span",{"aria-hidden":"true",className:"size-[7px] shrink-0 rounded-full bg-current"}),s.jsx(om,{className:"text-[13px]",children:o})]}),s.jsxs("div",{className:"min-w-0 overflow-hidden rounded-sm border border-border bg-surface-2",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-hairline py-[7px] pl-3 pr-2.5",children:[s.jsx("span",{className:"text-[11.5px] font-semibold text-subtle",children:c}),s.jsx("span",{className:"font-mono text-[10.5px] text-muted-foreground",children:a("{n} 字节",{n:i})}),s.jsx(B,{variant:"outline",size:"xs",className:"ml-auto h-[22px] text-[11px]","data-copy":n,disabled:!n,children:a("复制")})]}),s.jsx("pre",{role:"region","aria-label":c,tabIndex:0,className:"m-0 max-h-[210px] overflow-auto whitespace-pre-wrap px-3 py-[11px] font-mono text-[11.5px] leading-[1.7] text-subtle [overflow-wrap:anywhere] focus-visible:outline-none focus-visible:shadow-focus",children:n||(r?a("(上游这一次返回了空正文)"):"—")})]})]})}const b8={intl:"fm-table-intl",custom:"fm-table-custom"},y8={intl:"fetch-models",custom:"fetch-models-custom"},TCe=["provider","source","state","count","note","updated","op"],OCe=["pick","model","state"],RCe={provider:"w-[13%]",source:"w-[21%]",state:"w-[9%]",count:"w-[6%]",note:"w-[20%]",updated:"w-[16%]",op:"w-[15%]"},PCe={pick:"w-[8%]",model:"w-[74%]",state:"w-[18%]"},ICe={pick:"",provider:a("提供商"),source:a("模型来源"),state:a("状态"),count:a("模型数"),note:a("说明"),updated:a("更新日期"),model:a("上游模型"),op:a("操作")},MCe={refreshed:{variant:"brand",label:a("已刷新")},failed:{variant:"destructive",label:a("失败")},skipped:{variant:"outline",label:a("跳过")}};function _Ce(e){return e.trim().toLowerCase()}function _b(e){return s.jsx("span",{className:"font-mono text-[11.5px] tabular-nums text-muted-foreground",children:e})}function KP(e){return s.jsx("div",{className:"truncate font-mono text-[12px] font-semibold",children:a(e)})}function DCe({custom:e,status:t,rows:n,upstream:r,managed:i,picked:o,keyword:c,busy:d,busyRow:f,onPick:h,onFetchRow:p,sourceCell:g,refreshedAt:x,formatTime:y}){v.useEffect(()=>{window.wbTableColumns?.repaint?.(e?y8.custom:y8.intl)},[e]);const j=e?OCe:TCe,w=c.trim().toLowerCase(),S=r.filter(T=>!w||T.toLowerCase().includes(w));function N(T){return s.jsx(en,{children:s.jsx(Xe,{colSpan:j.length,className:"py-[26px] text-center text-muted-foreground",children:T})})}function A(T,P,M){if(M||T.target?.closest('[data-slot="checkbox"], input[type="checkbox"]'))return;const I=window.getSelection();I&&!I.isCollapsed&&T.currentTarget.contains(I.anchorNode)||h(P,!o.has(P))}function E(){return t==="idle"?N(a("点右侧「获取模型」从上游拉取这家的模型清单")):t==="loading"?N(a("正在获取…")):S.length?S.map(T=>{const P=i.has(_Ce(T));return s.jsxs(en,{className:P?"opacity-50":"cursor-pointer",onClick:M=>A(M,T,P),children:[s.jsx(Xe,{children:s.jsx(Wr,{checked:o.has(T),disabled:P,"aria-label":T,onCheckedChange:M=>h(T,!!M)})}),s.jsx(Xe,{children:KP(T)}),s.jsx(Xe,{children:P?s.jsx(ye,{variant:"brand",title:a("这个模型已经在这家的清单里,不重复导入"),children:a("已添加")}):s.jsx(ye,{variant:"outline",title:a("勾上它,导入后即进入这家的清单"),children:a("未添加")})})]},T)}):N(r.length?a("没有匹配「{keyword}」的模型",{keyword:w}):a("上游没有返回任何模型"))}function O(T){const P=d&&f===T.provider;return s.jsx(B,{variant:"outline",size:"sm",className:"w-full",disabled:d,title:a("只刷新这一家的模型清单"),onClick:()=>p(T),children:P?a("获取中…"):T.item?a("重新获取"):a("获取")})}function R(){return t==="loading"?N(a("正在获取…")):n.length?n.map(T=>{const P=T.item;if(!P){const D=y(x(T.provider));return s.jsxs(en,{children:[s.jsx(Xe,{children:KP(T.label)}),s.jsx(Xe,{children:g(T.provider)}),s.jsx(Xe,{children:s.jsx(ye,{variant:"outline",children:a("待获取")})}),s.jsx(Xe,{children:_b("—")}),s.jsx(Xe,{children:_b("—")}),s.jsx(Xe,{children:_b(D||"—")}),s.jsx(Xe,{children:O(T)})]},T.provider)}const M=MCe[String(P.status)]??{variant:"outline",label:String(P.status||a("未知"))},_=Number(P.count),I=P.status==="refreshed"?a("远程目录已更新,「来源」列会显示为「远程」"):P.message||(P.fixed?a("这家用固定模型清单,无可刷新"):a("本次没有取到新内容")),L=y(Number(P.refreshedAt)||0);return s.jsxs(en,{children:[s.jsx(Xe,{children:KP(T.label)}),s.jsx(Xe,{children:g(T.provider,P.accountId)}),s.jsx(Xe,{children:s.jsx(ye,{variant:M.variant,children:M.label})}),s.jsx(Xe,{children:_b(_?a("{n} 个",{n:_}):"—")}),s.jsx(Xe,{children:s.jsx("span",{className:"text-[11.5px] leading-[1.5] text-muted-foreground [overflow-wrap:anywhere]",children:a(I)})}),s.jsx(Xe,{children:_b(L||"—")}),s.jsx(Xe,{children:O(T)})]},T.provider)}):N(a("还没有可刷新的提供商:先在账号页添加一个账号"))}return s.jsxs(ea,{id:e?b8.custom:b8.intl,className:"table-fixed",containerClassName:"max-h-[min(48vh,460px)]",children:[s.jsx("colgroup",{children:j.map(T=>s.jsx("col",{"data-col":T,className:e?PCe[T]:RCe[T]},T))}),s.jsx(Ta,{children:s.jsx(en,{children:j.map(T=>s.jsx(ft,{"data-col":T,children:ICe[T]},T))})}),s.jsx(ga,{className:"[&_tr:last-child>td]:border-b-0",children:e?E():R()})]})}function Wa(){return window}const w8=new Set(["cline-free","cline-pass"]),j8="workbuddy-desktop-fetch-model-source";function WS(e){return String(e??"").trim().toLowerCase()}function qP(e,t){Wa().wbApp?.toast?.(e,t)}function GP(e){return e instanceof Error?e.message:String(e)}function LCe(e){const t=Wa().formatTime??Wa().wbApp?.formatTime;return String(t?.(e)??"")}function S8(){return Wa().wbApp?.getState?.()?.accounts?.accounts||[]}function zCe(e){const n=(Wa().wbProviders?.customList?.()||[]).find(r=>r.id===e)?.models;return new Set((Array.isArray(n)?n:[]).map(r=>WS(r?.id)).filter(Boolean))}function k8(e){if(e?.nameCustom===!0&&e?.name)return e.name;const t=String(e?.email||"").trim();return Wa().wbAccountsModel?.providerFeatures?.(e?.provider)?.emailAsName&&t?t:String(e?.nickname||e?.name||t||e?.id||"").trim()||a("未命名账号")}function $Ce(e){if(w8.has(e))return[];const t=Wa().wbAccountsModel?.byPriorityOrder,n=S8().filter(r=>(r?.provider||"workbuddy")===e&&r?.available!==!1&&r?.enabled!==!1);return t?n.sort(t):n}function BCe(){const e=new Set(Wa().wbModelsPanel?.builtinProviders?.()||[]);for(const t of S8())t?.available===!1||t?.enabled===!1||e.add(t?.provider||"workbuddy");return[...e]}function FCe(){const e=new Set(BCe());return(Wa().wbProviders?.all?.()||[]).filter(t=>e.has(t?.id??""))}function UCe(){try{const e=JSON.parse(localStorage.getItem(j8)||"{}");if(!e||typeof e!="object")return{};const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&r&&(t[n]=r);return t}catch{return{}}}function HCe(e){Wa().wbFilterMemory?.save?.(j8,e)}function VCe({options:e,onClose:t}){const n=e.providerId,r=!!e.custom,i=e.name||n,{onDone:o,onRefreshed:c}=e,[d,f]=v.useState("idle"),[h,p]=v.useState(""),[g,x]=v.useState(""),[y,j]=v.useState(null),[w,S]=v.useState(""),N=y!==null,A=d==="error",[E,O]=v.useState(!1),[R,T]=v.useState([]),[P,M]=v.useState(()=>new Set),[_,I]=v.useState(()=>new Set),[L,D]=v.useState([]),[z,G]=v.useState(""),[X,Y]=v.useState(UCe),F=r?[]:FCe(),K=r?[]:q(),U=r?E?a("已选 {picked} 个 · 上游共 {upstream} 个 · 清单已有 {managed} 个",{picked:_.size,upstream:R.length,managed:P.size}):a("尚未获取"):W(K);function q(){const he=new Map(L.map(me=>[String(me.provider||""),me])),pe=F.map(me=>{const ce=String(me.id||"");return{provider:ce,label:String(me.label||ce),item:he.get(ce)}}),Ne=new Set(pe.map(me=>me.provider));for(const me of L){const ce=String(me.provider||"");Ne.has(ce)||pe.push({provider:ce,label:String(me.providerLabel||ce),item:me})}return pe}function W(he){if(d==="loading")return a("正在刷新…");if(d==="error")return"";const pe=he.map(ce=>ce.item).filter(ce=>!!ce);if(!pe.length)return E?a("刷新完成,但没有得到任何结果"):he.length?a("共 {n} 家 · 点「获取模型」开始",{n:he.length}):a("0 家");const Ne=pe.filter(ce=>ce.status==="refreshed").length,me=pe.filter(ce=>ce.status==="failed").length;return me?a("{total} 家 · 成功 {done} · 失败 {failed}",{total:he.length,done:Ne,failed:me}):a("{total} 家 · 成功 {done}",{total:he.length,done:Ne})}function ne(he,pe){const Ne=$Ce(he);if(!Ne.length)return{list:Ne,selected:""};const me=String(X[he]||""),ce=String(pe||""),ae=_e=>Ne.some(de=>String(de.id)===_e);return{list:Ne,selected:ae(me)?me:ae(ce)?ce:String(Ne[0].id)}}function ie(he){const pe={};for(const[Ne,me]of Object.entries(X))me&&(pe[Ne]=me);for(const Ne of he){const{selected:me}=ne(Ne.provider,Ne.reported);me&&(pe[Ne.provider]=me)}return pe}const V=K.map(he=>({provider:he.provider,reported:he.item?.accountId}));function H(he,pe){Y(Ne=>({...Ne,[he]:pe})),HCe({[he]:pe})}async function Q(){if(!N){j("load"),x(""),p(""),f("loading");try{if(r){const me=await Wa().wbProviders?.customRequest?.("POST","/api/custom-providers/fetch-models",{providerId:n}),ce=new Set,ae=(Array.isArray(me?.models)?me.models:[]).map(de=>String(de??"").trim()).filter(de=>{const Se=WS(de);return!de||ce.has(Se)?!1:(ce.add(Se),!0)}),_e=zCe(n);T(ae),M(_e),I(new Set(ae.filter(de=>!_e.has(WS(de))))),O(!0),f("ready");return}const he=Wa().workbuddyDesktop?.refreshModels;if(!he)throw new Error(a("模型目录刷新不可用,请重新打开面板"));const pe=F.map(me=>me.id).filter(me=>!!me),Ne=await he({accounts:ie(V),providers:pe});if(!Array.isArray(Ne?.results)||Ne.results.some(me=>!me||typeof me.provider!="string"||!["refreshed","failed","skipped"].includes(me.status||""))||pe.some(me=>Ne.results.filter(ce=>ce.provider===me).length!==1))throw new Error(a("网关未返回逐家模型目录刷新结果"));D(Ne.results),O(!0),f("ready"),Number(Ne?.refreshed)>0&&c?.()}catch(he){p(GP(he)),f("error")}finally{j(null)}}}async function J(he){if(!(N||!he.provider)){j("row"),S(he.provider),x("");try{const pe=Wa().workbuddyDesktop?.refreshModels;if(!pe)throw new Error(a("模型目录刷新不可用,请重新打开面板"));const Ne=await pe({accounts:ie([{provider:he.provider,reported:he.item?.accountId}]),providers:[he.provider]}),me=Array.isArray(Ne?.results)?Ne.results.filter(ae=>ae?.provider===he.provider):[];if(me.length!==1||!["refreshed","failed","skipped"].includes(me[0].status||""))throw new Error(a("网关未返回逐家模型目录刷新结果"));const ce=me[0];D(ae=>oe(ae,[ce])),O(!0),f("ready"),Number(Ne?.refreshed)>0&&c?.()}catch(pe){const Ne=GP(pe);D(me=>oe(me,[{provider:he.provider,providerLabel:he.label,status:"failed",message:Ne}])),O(!0),f("ready"),x(Ne),qP(a("获取失败:{message}",{message:Ne}),"err")}finally{j(null),S("")}}}function oe(he,pe){const Ne=new Map(pe.map(ae=>[String(ae.provider||""),ae])),me=he.map(ae=>Ne.get(String(ae.provider||""))??ae),ce=new Set(me.map(ae=>String(ae.provider||"")));for(const ae of pe)ce.has(String(ae.provider||""))||me.push(ae);return me}async function ee(){if(!r||N||!_.size)return;const he=[..._];j("import"),x("");try{const pe=Number(await Wa().wbModelsCustom?.addModels?.(n,he))||0;qP(a("✅ 已导入 {added} 个模型({skipped} 个已存在,跳过)",{added:pe,skipped:he.length-pe})),j(null),t(),o?.()}catch(pe){const Ne=GP(pe);qP(a("导入失败:{message}",{message:Ne}),"err"),x(Ne),j(null)}}function se(){N||t()}function le(){const he=new Set(_);for(const pe of R)P.has(WS(pe))||he.add(pe);I(he)}function te(he,pe){const{list:Ne,selected:me}=ne(he,pe);if(!Ne.length){const ae=w8.has(he)?a("这家的模型清单是全局的,不跟账号走"):a("这家还没有可用账号,刷新会使用默认登录态");return s.jsx("span",{className:"text-[11.5px] text-muted-foreground",title:ae,children:"—"})}const ce=Ne.find(ae=>String(ae.id)===me);return s.jsxs(ht,{value:me,onValueChange:ae=>H(he,String(ae)),children:[s.jsx(mt,{className:"w-full",title:a("用哪个账号去拉这家的模型清单"),"aria-label":a("模型来源"),children:s.jsx(pt,{children:ce?k8(ce):"—"})}),s.jsx(gt,{children:Ne.map(ae=>s.jsx(qe,{value:String(ae.id),children:k8(ae)},String(ae.id)))})]})}function re(he,pe){I(Ne=>{const me=new Set(Ne);return pe?me.add(he):me.delete(he),me})}return s.jsx(St,{open:!0,onOpenChange:(he,pe)=>{if(!he){if(N){pe.cancel();return}t()}},children:s.jsxs(kt,{className:A?"w-[min(640px,calc(100vw-48px))]":r?"w-[min(607px,calc(100vw-48px))]":"w-[min(1012px,calc(100vw-48px))]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("获取模型 — {name}",{name:i})})}),s.jsx(Ct,{children:A?s.jsx(ECe,{message:h}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[s.jsx("span",{className:"text-[11.5px] text-muted-foreground",children:U}),r&&s.jsxs(uo,{className:"w-[240px] flex-none",children:[s.jsx(ho,{type:"search",placeholder:a("搜索模型 ID…"),autoComplete:"off",value:z,onChange:he=>G(he.currentTarget.value)}),s.jsx(fo,{"aria-hidden":"true",children:"⌕"})]}),s.jsx("div",{className:"mr-auto"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(B,{variant:"ghost",size:"sm",onClick:le,children:a("全选未添加")}),s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>I(new Set),children:a("清空")})]}),s.jsx(B,{variant:"outline",size:"sm",title:a("刷新全部家(逐家打上游)"),disabled:N,onClick:()=>{Q()},children:a(y==="load"?"获取中…":E?"重新获取":"获取模型")})]}),s.jsx(DCe,{custom:r,status:d,rows:K,upstream:R,managed:P,picked:_,keyword:z,busy:N,busyRow:w,onPick:re,onFetchRow:he=>{J(he)},sourceCell:te,formatTime:LCe,refreshedAt:he=>Number(Wa().wbModelsPanel?.providerRefreshedAt?.(he))||0})]})}),s.jsxs(Pt,{children:[!A&&g&&s.jsx("span",{className:"min-w-0 text-[11.5px] text-muted-foreground [overflow-wrap:anywhere]",children:g}),s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:se,disabled:N,children:a(A?"关闭":r?"取消":"完成")}),A?s.jsx(B,{variant:"default",disabled:N,onClick:()=>{Q()},children:a("重试")}):r&&s.jsx(B,{variant:"default",disabled:!_.size||N,onClick:()=>{ee()},children:y==="import"?a("导入中…"):_.size?a("导入选中的 {n} 个模型",{n:_.size}):a("导入")})]})]})})}let Db=null,tg=null;function N8(){Db&&(Db.unmount(),Db=null),tg&&(tg.remove(),tg=null)}function KCe(e){!e||e.custom&&!e.providerId||(N8(),tg=document.createElement("div"),document.body.append(tg),Db=wn.createRoot(tg),Db.render(s.jsx(VCe,{options:e,onClose:N8})))}window.wbModelsFetchModal={open:KCe};const Qc=(e,t)=>t?`${e} ta-${t}`:e;function C8(e,t){const n=(t||"").trim();if(n)return Rb().find(r=>Ad(r.provider,e)&&Ad(r.id,n))}const qCe="[.pv-row:hover_&_[data-slot=nav-item-count]]:invisible";function GCe(e){const t=/x\s*([\d.]+)/i.exec(String(e||""));return t?`${t[1]}x`:String(e||"")}function A8(e){const t=/x\s*([\d.]+)/i.exec(String(e||""));if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?n:null}const YCe={workbuddy:250,"workbuddy-intl":295,raccoon:60,catpaw:85,autoclaw:250,"autoclaw-intl":295,qoder:330,"qoder-intl":350,"cline-free":200,"cline-pass":200,codearts:210,loomy:155,kuku:15,accio:320,"accio-intl":335,trae:170,zcode:285};function WCe(e){const t=YCe[e];if(t!==void 0)return t;let n=0;for(let r=0;r>>0;return n%360}function XCe(e){const t=String(e||"").trim();if(!t)return"?";const n=t.match(/[A-Za-z]/);return(n?n[0]:t[t.length-1]).toUpperCase()}const QCe=e=>({"--av-h":String(WCe(e))}),YP=s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"13.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"13.5",y:"13.5",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.5"})]})});function ZCe(e){return ts(e)?qbe(e):qc[e==="workbuddy-intl"?"workbuddy":e]||""}function ng(e,t,n){const r=n?"":ZCe(e),i=e==="all"||e===Ra;return s.jsx("span",{className:Te("pv-ico",i&&"mute",r&&"img"),style:r?void 0:QCe(e),"aria-hidden":"true",children:r?s.jsx("img",{src:r,alt:""}):n??XCe(t)})}const JCe={supportsToolCall:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),supportsImages:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2.5"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),supportsVideo:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M10 8.5l6 3.5-6 3.5z"})]})}),supportsReasoning:s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),s.jsx("path",{d:"M9 18h6M10 22h4"})]})})};function eAe(e,t,n,r,i){if(r==="enabled"&&!Ib(e)||r==="disabled"&&Ib(e)||r==="mapped"&&!(e.aliases||[]).length)return!1;const o=Hq(e);return i==="visible"&&o==="hidden"||i==="hidden"&&o!=="hidden"||i==="undeclared"&&o!=="undeclared"||n!=="all"&&n!==Ra&&(e.provider||"")!==n?!1:t?[e.id,e.name,...e.aliases||[]].join(" ").toLowerCase().includes(t):!0}function tAe(){const e=v.useSyncExternalStore(U1e,Ab),t=HS(e),n=ts(t)||t===Ra,[r,i]=v.useState(null),[o,c]=v.useState(!1),[d,f]=v.useState(new Set),[h,p]=v.useState(!1),g=n&&!Zm()&&MP()&&!vd(t);v.useEffect(()=>{W1e(),KS(),Yq(),Zn().wbApp?.currentPage==="gateway"&&e8().then(()=>Zn().wbProviders?.refreshCustom?.()).then(()=>{yh()})},[]),v.useEffect(()=>{lCe()});const x=DP(),y=Array.isArray(x.models)?x.models:[],j=y.filter(H=>t==="all"||t===Ra||(H.provider||"")===t),w=e.search.trim().toLowerCase(),S=y.filter(H=>eAe(H,w,t,e.stateFilter,e.visibilityFilter)),N=e.sort,A=Jq(),E=A.length,O=t==="all"?a("全部"):t===Ra?a("自定义 · 全部"):n?String(vd(t)?.name||t):VS().get(t)?.label||UP(t),R=j.filter(Ib).length,T=j.filter(H=>(H.aliases||[]).length>0).length,P=qx(S.length,"models"),M=y.filter(H=>d.has(jh(H))),_=(H,Q)=>{const J=new Set(d);Q?J.add(H):J.delete(H),f(J)},I=S.map(jh),L=I.length>0&&I.every(H=>d.has(H)),D=I.some(H=>d.has(H)),z=s.jsx(Wr,{checked:L,indeterminate:!L&&D,disabled:!I.length,"aria-label":a("全选当前筛选结果"),title:a("全选当前筛选出的模型(跨分页);再点取消"),onCheckedChange:H=>{const Q=new Set(d);for(const J of I)H===!0?Q.add(J):Q.delete(J);f(Q)}});function G(){const H=VS(),Q=gd(),J=K1e(),oe=[...H.values()].reduce((te,re)=>te+re.n,0),ee=a("全部({n} 家)",{n:H.size}),se=[...J.values()].reduce((te,re)=>te+re.n,0),le=a("全部({n} 家)",{n:[...J.values()].filter(te=>te.n>0).length});return s.jsxs(cm,{className:"prov-rail",id:"prov-rail","aria-label":a("按提供商选择"),children:[s.jsxs(Bc,{className:"rail-scroll",children:[s.jsx("div",{className:"rail-label",children:a("内置提供商")}),s.jsx(Ri,{active:t==="all","data-provider":"all",title:ee,count:oe,icon:ng("all","",YP),className:"shadow-none",onClick:()=>Mb("all"),children:ee}),[...H].map(([te,re])=>s.jsx(Ri,{active:t===te,"data-provider":te,title:re.n?re.label:a("{provider}:模型清单为空,等待获取",{provider:re.label}),count:re.n,icon:ng(te,re.label),className:"shadow-none",trailing:re.n===0?s.jsx(ye,{variant:"outline",children:a("待获取")}):void 0,onClick:()=>Mb(te),children:re.label},te)),s.jsx("div",{className:"rail-label",children:a("自定义提供商")}),Q.length?[...se>0?[s.jsx(Ri,{active:Zm(),"data-provider":Ra,title:le,count:se,icon:ng(Ra,"",YP),className:"shadow-none",onClick:()=>Mb(Ra),children:le},Ra)]:[],...Q.map(te=>{const re=String(te.id||""),he=String(te.name||re);return s.jsxs("div",{className:"pv-row",children:[s.jsx(Ri,{active:t===re,"data-provider":re,title:he,count:J.get(re)?.n??0,icon:ng(re,he),className:Te("shadow-none",qCe),onClick:()=>Mb(re),children:he}),s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"pv-del","aria-label":a("删除自定义提供商"),title:a("删除这个自定义提供商(连同名下账号)"),onClick:()=>{tCe(re)},children:"×"})]},re)})]:s.jsx(zt,{className:"rail-empty",children:a("还没有自定义提供商")})]}),s.jsx("div",{className:"rail-foot",children:s.jsx(Ri,{variant:"add",id:"rail-add-custom",title:a("新建一个自定义提供商(同时创建它的第一个账号)"),onClick:()=>nCe(),children:a("+ 新建自定义提供商")})})]})}function X(H,Q,J,oe){const ee=HP(H,Q,J);return s.jsx(B,{variant:ee?"secondary":"dashed",size:"2xs",disabled:oe,className:"font-mono font-bold shadow-none",title:ee?a("思考等级 {level}(点击修改)",{level:ee}):a("设置思考等级(当前未绑定)"),onClick:()=>i8({alias:H,target:Q,provider:J}),children:ee||a("+等级")})}function Y(H){const Q=H.provider||"",J=Jm(H),[oe,...ee]=J;async function se(te){await Zn().wbConfirm?.ask?.({title:a("删除映射"),html:a("确定删除映射「{alias} → {target}」?",{alias:AP(te),target:AP(H.id)}),okText:a("删除"),okClass:"danger"})&&BP(FP(te,H.id,Q),()=>X1e(Q,te,H.id),a("映射已删除"))}const le=te=>{const re=te.alias,he=te.enabled!==!1,pe=e.pending.has(FP(re,H.id,Q));return s.jsxs("span",{className:Te("alias",!he&&"map-off"),children:[s.jsx(cn,{size:"sm",checked:he,disabled:pe,title:a(he?"映射已启用,点击关闭":"映射已关闭,点击启用"),"aria-label":a("{action}映射 {alias}",{action:a(he?"关闭":"启用"),alias:re}),onCheckedChange:Ne=>{BP(FP(re,H.id,Q),()=>YS(Q,re,H.id,{enabled:Ne}),a(Ne?"映射已启用":"映射已关闭"))}}),s.jsx("span",{className:"t","data-copy":re,title:a("点击复制:{name}",{name:re}),children:re}),te.isDefault?s.jsx("span",{className:"binding-default",children:a("默认")}):null,X(re,H.id,Q,pe),te.isDefault?null:s.jsx(B,{variant:"ghost",size:"icon-2xs",className:"text-[12px] leading-none",disabled:pe,title:a("删除映射 {alias}",{alias:re}),onClick:()=>{se(re)},children:"×"})]},`${re}${te.isDefault?"d":"m"}`)};return s.jsxs("div",{className:"aliases",children:[s.jsxs("div",{className:"alias-row",children:[oe?le(oe):null,s.jsx(B,{variant:"dashed",size:"xs",onClick:()=>i8({target:H.id,provider:Q}),children:a("+ 映射")})]}),ee.map(le)]})}function F(H){if(H.source==="manual")return s.jsxs("span",{className:"src manual",title:a("手动登记的上游模型;移除它会直接删掉这条登记"),children:[s.jsx("i",{"aria-hidden":"true"}),a("手动")]});if(!H.source&&ts(H.provider))return s.jsxs("span",{className:"src manual",title:a("用户登记的自定义模型;整份清单只属于这一家"),children:[s.jsx("i",{"aria-hidden":"true"}),a("自定义")]});if(H.source!=="remote"&&H.source!=="builtin")return s.jsx("span",{className:"rate",children:"—"});const Q=H.source==="remote",J=_1e(Number(H.refreshedAt)||0),oe=Q?J?a("来自上游目录接口,清单拉取于 {at};刷新失败时保留上一份成功结果",{at:J}):a("来自上游目录接口;刷新失败时保留上一份成功结果"):a("上游目录尚未拉到,用的是内置静态清单;点「刷新模型清单」可重试");return s.jsxs("span",{className:Te("src",Q?"remote":"builtin"),title:oe,children:[s.jsx("i",{"aria-hidden":"true"}),a(Q?"远程":"内置")]})}function K(H){const Q=Hq(H);return Q==="hidden"?s.jsxs("span",{className:"src hidden-visibility",title:a("上游能列出这个模型,但官方客户端不展示它;本仓已默认关闭它的默认绑定(点这一行的开关可以手动打开)"),children:[s.jsx("i",{"aria-hidden":"true"}),a("不展示")]}):Q==="visible"?s.jsxs("span",{className:"src shown-visibility",title:a("官方客户端会展示这个模型"),children:[s.jsx("i",{"aria-hidden":"true"}),a("可见")]}):Q==="undeclared"?s.jsx("span",{className:"rate",title:a("这家有可见性判据,但这一条上游没有表态 —— 按可见处理"),children:"—"}):s.jsx("span",{className:"rate",title:a("这家提供商没有可见性判据(目前只有 Antigravity / Qoder / 小浣熊 / CodeArts 有)"),children:"—"})}function U(H){const Q=sS(H),J=xR(H.capOverrides),oe=typeof Q.maxInputTokens=="number"?Q.maxInputTokens:null,ee=typeof Q.maxOutputTokens=="number"?Q.maxOutputTokens:null,se=a("上下文窗口 {input} / 最大输出 Token {output} —— 点击修改模型能力",{input:ob(oe),output:ob(ee)})+q(H);return s.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"caps-open",title:se,onClick:()=>o8(H.provider||"",H.id),children:[s.jsxs("span",{className:Te("cap-num",oe===null&&"unset",Fm(H,"maxInputTokens")==="modelsdev"&&"filled"),children:[dV(oe),J.includes("maxInputTokens")?s.jsx("i",{className:"cap-mark",title:a("已覆盖上游值")}):null]}),s.jsx("span",{className:"cap-sep",children:"/"}),s.jsxs("span",{className:Te("cap-num",ee===null&&"unset",Fm(H,"maxOutputTokens")==="modelsdev"&&"filled"),children:[dV(ee),J.includes("maxOutputTokens")?s.jsx("i",{className:"cap-mark",title:a("已覆盖上游值")}):null]})]})}function q(H){const Q=["maxInputTokens","maxOutputTokens"].filter(J=>Fm(H,J)==="modelsdev").map(J=>Bm[J]);return Q.length?a(";其中 {keys} 由 models.dev 补齐",{keys:Q.join(a("、"))}):""}function W(H){const Q=sS(H),J=xR(H.capOverrides);return s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"caps-open caps-badges",title:a("对下游声明的能力(工具调用 / 图片识别 / 视频识别 / 支持思考)—— 点击修改"),onClick:()=>o8(H.provider||"",H.id),children:cV.map(oe=>{const ee=Q[oe]??null,se=bR(ee),le=J.includes(oe),te=Fm(H,oe);return s.jsxs("span",{className:Te("cap-dot",se,te==="modelsdev"&&"filled",le&&"marked"),title:r0e(oe,ee,le,te),children:[JCe[oe],le?s.jsx("i",{className:"cap-mark"}):null]},oe)})})}function ne(H,Q,J){async function oe(){await Zn().wbConfirm?.ask?.({title:a("移除自定义模型"),html:a("确定移除自定义模型「{id}」?这条登记会被直接移除,之后 /v1/models 不再广告它、请求它也会被拒。",{id:AP(Q.id)}),okText:a("移除"),okClass:"danger"})&&BP(jh(Q),()=>t8(Q.provider||"",Q.id),ts(Q.provider||"")?a("模型已移除"):a("自定义模型已移除"))}switch(H.key){case"check":return s.jsx(Xe,{className:Qc("cell-check",H.align),children:s.jsx(Wr,{checked:d.has(jh(Q)),title:a("勾选后可批量操作"),"aria-label":a("勾选后可批量操作"),onCheckedChange:ee=>_(jh(Q),ee===!0)})});case"model":return s.jsxs(Xe,{className:Qc("cell-model",H.align),children:[s.jsxs("div",{className:"mid",children:[s.jsx("span",{className:"t","data-copy":Q.id,title:a("点击复制:{name}",{name:Q.id}),children:Q.id}),Q.kind==="image"?s.jsx("span",{className:"binding-default",title:"POST /v1/images/generations",children:a("图片生成")}):null,Q.supports_image_editing?s.jsx("span",{className:"binding-default",title:"POST /v1/images/edits",children:a("图片编辑")}):null,Q.upstreamStatus==="undeployed"?s.jsx(ye,{variant:"warning",shape:"tag",title:a("上游目录列出了这个模型,但推理端尚未识别;保留在清单中,后续探测成功后自动清除标记"),children:a("上游未部署")}):null]}),Q.name&&Q.name!==Q.id?s.jsx("div",{className:"mname",children:Q.name}):null]});case"rate":return s.jsx(Xe,{className:Qc("cell-rate",H.align),children:s.jsx("span",{className:"rate",children:Q.credits?GCe(Q.credits):"—"})});case"source":return s.jsx(Xe,{className:Qc("cell-source",H.align),children:F(Q)});case"visibility":return s.jsx(Xe,{className:Qc("cell-visibility",H.align),children:K(Q)});case"budget":return s.jsx(Xe,{className:Qc("cell-budget",H.align),children:U(Q)});case"caps":return s.jsx(Xe,{className:Qc("cell-caps",H.align),children:W(Q)});case"alias":return s.jsx(Xe,{className:Qc("cell-alias",H.align),children:Y(Q)});case"act":{const ee=jCe(Q.provider||"",Q),se=Q.source==="manual"||ts(Q.provider||"");return s.jsx(Xe,{className:Qc("cell-act r",H.align),children:s.jsxs("div",{className:"row-actions",children:[s.jsx(B,{variant:"ghost",size:"sm",disabled:!!ee,title:ee||a("以这个上游模型发一次最小请求,走真实转发链路"),onClick:()=>i({provider:Q.provider||"",id:Q.id}),children:a("测试")}),se?s.jsx(B,{variant:"ghost",size:"sm",className:"text-destructive",disabled:J,onClick:()=>{oe()},children:a("移除")}):null]})})}default:return null}}function ie(H){const Q=e.pending.has(jh(H)),J=d.has(jh(H));return s.jsx(en,{className:Te(J&&"sel"),children:A.map(oe=>s.jsx(v.Fragment,{children:ne(oe,H,Q)},oe.key))},`${H.provider||""}${H.id}`)}function V(){if(!j.length){const se=n?MP()?Zm()?a("自定义提供商还没有模型:先在左栏选一家,点「添加模型」登记,或「获取上游模型」从上游拉取"):a(g?"该提供商已不存在(可能已被删除),请刷新列表":"这家还没有模型:点「添加模型」登记,或「获取上游模型」从上游拉取"):a("加载中…"):e.data?VS().size?a("模型清单为空:已有可用账号,请点「获取模型」拉取目录"):a("暂无模型(请先添加账号)"):a("加载中…");return s.jsx(en,{children:s.jsx(Xe,{colSpan:E,className:"empty",children:se})})}if(!S.length)return s.jsx(en,{children:s.jsx(Xe,{colSpan:E,className:"empty",children:w?a("没有匹配「{keyword}」的模型",{keyword:w}):a("没有匹配当前筛选的模型")})});const H=t==="all"||Zm(),Q=H&&!w&&e.stateFilter==="all"&&!P.paged,J=new Map;for(const se of S){const le=se.provider||"";J.has(le)||J.set(le,{label:se.providerLabel||le||a("未知"),items:[]}),J.get(le)?.items.push(se)}const oe=[];let ee=0;for(const[se,le]of J){le.items.sort((ce,ae)=>{const _e=+!Ib(ce)-+!Ib(ae);if(_e!==0||N==="default")return _e;const de=A8(ce.credits),Se=A8(ae.credits);return de===null||Se===null?de===Se?0:de===null?1:-1:N==="rate-asc"?de-Se:Se-de});const te=e.expanded.has(se)||!Q,re=te?le.items:le.items.slice(0,Fq),he=le.items.length-re.length,pe=P.paged?Math.max(0,P.rangeStart-1-ee):0,Ne=P.paged?Math.min(re.length,P.rangeEnd-ee):re.length,me=pe0?a("(续)"):"",a("{n} 个模型",{n:le.items.length})]})},`group:${se}`));for(const ce of me)oe.push(ie(ce));ee+=re.length,he>0?oe.push(s.jsx(en,{className:"tr-more",children:s.jsx(Xe,{colSpan:E,children:s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>J1e(se),children:a("展开其余 {n} 个模型 ▾",{n:he})})})},`more:${se}`)):te&&Q&&le.items.length>Fq&&oe.push(s.jsx(en,{className:"tr-more",children:s.jsx(Xe,{colSpan:E,children:s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>eCe(se),children:a("收起 ▴")})})},`collapse:${se}`))}return oe}return s.jsxs(s.Fragment,{children:[s.jsx(tt,{render:s.jsx("section",{}),className:"panel",children:s.jsxs("div",{className:"mm",children:[G(),s.jsxs("div",{className:"mm-main",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsxs("div",{className:"mm-titlebar",children:[s.jsxs("div",{className:"mm-title",children:[t==="all"||t===Ra?ng(t,"",YP):ng(t,O),s.jsx("h2",{children:O}),s.jsxs("span",{className:"mm-meta",children:[s.jsx("b",{children:j.length}),a(" 个模型 · 已启用 "),s.jsx("b",{children:R}),a(" · 有映射 "),s.jsx("b",{children:T})]})]}),s.jsxs("div",{className:"head-actions",children:[s.jsx(B,{id:"btn-refresh-models",title:ts(t)?a("从这一家的上游拉一份模型清单,勾选要哪些再导入(已添加的不会重复导入)"):a("刷新模型管理页里各提供商的远程模型目录,逐家结果列在弹窗里"),onClick:()=>c8(),children:a("获取模型")}),s.jsx(B,{id:"btn-add-custom-model",variant:"outline",size:"sm",onClick:()=>sCe(),children:a("+ 添加模型")}),s.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"mm-filter-open hidden max-[767px]:inline-flex",onClick:()=>p(!0),"aria-label":a("打开筛选"),children:[a("筛选"),(()=>{const H=(e.stateFilter!=="all"?1:0)+(e.visibilityFilter!=="all"?1:0)+(e.sort!=="default"?1:0)+(String(e.search||"").trim()?1:0);return H>0?s.jsx(ye,{variant:"brand",shape:"tag",className:"mm-filter-badge",children:H}):null})()]})]})]}),s.jsxs(w0,{open:h,onOpenChange:p,title:a("筛选"),inlineClassName:"mm-filters",bodyClassName:"model-filter-body",actions:s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{n8("all"),s8("all"),r8("default"),a8("")},children:a("清空")}),children:[s.jsx(dn,{options:L1e,value:e.stateFilter,onValueChange:n8,"aria-label":a("按状态筛选"),className:"shrink-0"}),s.jsx(dn,{options:F1e,value:e.visibilityFilter,onValueChange:s8,"aria-label":a("按可见性筛选"),className:"shrink-0"}),s.jsx(dn,{options:$1e,value:e.sort,onValueChange:r8,"aria-label":a("按倍率排序"),className:"shrink-0"}),s.jsxs(uo,{className:"w-full min-[768px]:w-[240px] flex-none min-[768px]:flex-none",id:"models-search",children:[s.jsx(ho,{type:"search",placeholder:a("搜索模型 ID / 名称 / 映射名…"),"aria-label":a("搜索模型"),autoComplete:"off",value:e.search,onChange:H=>a8(H.currentTarget.value)}),s.jsx(fo,{"aria-hidden":"true",children:"⌕"})]}),M.length>0?s.jsxs(ye,{variant:"brand",className:"batch-chip",children:[a("已选 "),s.jsx("b",{children:M.length}),a(" 个"),s.jsx(B,{id:"btn-batch-models",variant:"outline",size:"xs",title:a("对选中的 {n} 个模型执行批量操作",{n:M.length}),onClick:()=>c(!0),children:a("批量操作")})]}):null]})]}),s.jsx("div",{className:"models-table-wrap",children:s.jsxs(ea,{container:!1,className:"models-table",ref:H=>oCe(H),children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"c-check","data-col":"check"}),s.jsx("col",{className:"c-model","data-col":"model"}),s.jsx("col",{className:"c-rate","data-col":"rate"}),s.jsx("col",{className:"c-visibility","data-col":"visibility"}),s.jsx("col",{className:"c-source","data-col":"source"}),s.jsx("col",{className:"c-budget","data-col":"budget"}),s.jsx("col",{className:"c-caps","data-col":"caps"}),s.jsx("col",{className:"c-alias","data-col":"alias"}),s.jsx("col",{className:"c-act","data-col":"act"})]}),s.jsx(Ta,{children:s.jsxs(en,{children:[s.jsx(ft,{"data-col":"check",children:z}),s.jsx(ft,{"data-col":"model",children:a("上游模型")}),s.jsx(ft,{"data-col":"rate",children:a("倍率")}),s.jsx(ft,{"data-col":"visibility",title:a("这个模型在官方客户端里是否会被展列;不展示的那些默认已关闭(含默认绑定)"),children:a("可见性")}),s.jsx(ft,{"data-col":"source",children:a("来源")}),s.jsxs(ft,{"data-col":"budget",children:[a("上下文 / 输出"),s.jsx("span",{className:"th-help","aria-hidden":"true",title:a("数字带虚线底 = 由 models.dev 补齐;右上角小点 = 你手动覆盖过;— = 未声明。点任意一格可改。"),children:s.jsx("svg",{viewBox:"0 0 24 24",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]})})})]}),s.jsxs(ft,{"data-col":"caps",children:[a("能力"),s.jsx("span",{className:"th-help","aria-hidden":"true",title:a("圆点带内侧描边 = 由 models.dev 补齐;右上角小点 = 你手动覆盖过;虚线圈 = 未声明。悬停某一枚可看逐项出处。"),children:s.jsx("svg",{viewBox:"0 0 24 24",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]})})})]}),s.jsxs(ft,{"data-col":"alias",children:[a("模型映射"),s.jsx("span",{className:"th-help","aria-hidden":"true",title:a("每条映射 = 对外名 → 上游模型;原始 ID 与别名有独立开关,默认绑定永远存在(没有映射时是合成的那条)。"),children:s.jsx("svg",{viewBox:"0 0 24 24",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]})})})]}),s.jsx(ft,{className:"r","data-col":"act",children:a("操作")})]})}),s.jsx(ga,{id:"models",children:V()})]})}),s.jsx(fd,{className:"models-panel-foot",leading:Zm()?s.jsxs(s.Fragment,{children:[a("这里是"),s.jsx("b",{children:a("全部自定义提供商")}),a("的模型合集:每家的清单互相独立,别名也只在自己那家内生效;要改名称 / 协议 / Base URL,到账号页该家账号的「设置」→ 提供商一栏。")]}):n?s.jsxs(s.Fragment,{children:[a("自定义提供商的清单"),s.jsx("b",{children:a("只属于这一家")}),a(":这里的模型不会出现在其他家,别名也只在这一家内生效。改名称 / 协议 / Base URL 在账号页该家账号的「设置」→ 提供商一栏;整家不要了,鼠标移到左栏这家上点 × 删除(连同名下账号)。")]}):void 0,total:S.length,range:P.paged?{start:P.rangeStart,end:P.rangeEnd}:null,page:P.page,pageCount:P.pageCount,size:P.size,onSizeChange:P.setSize,onPageChange:P.goto})]})]})}),e.mapping?s.jsx(rAe,{context:e.mapping,onClose:rCe}):null,e.customModel?s.jsx(sAe,{initial:e.customModel,onClose:aCe}):null,e.capability?s.jsx(hCe,{context:e.capability,onClose:iCe}):null,r?s.jsx(kCe,{target:r,onClose:()=>i(null)}):null,o?s.jsx(CCe,{models:M,onClose:()=>c(!1),onDone:()=>{f(new Set),c(!1)}}):null]})}const nAe=a("绑定在「对外名 → 上游模型」这一条映射上的思考等级(列表照抄 OmniProxy 的手动绑定),选「不覆盖」表示不给这条映射指定等级。它会跟着这条映射注入转发,由承载的那家翻译成自己的档位字段(CatPaw 归并成 low/high/max,Qoder 按模型声明的档位归一)。以下几种情况故意不注入:① off / none(关闭思考)—— 本项目没有安全的表达方式;② 表外的自定义等级(各家能力范围不同,无法判断上游收不收);③ 客户端请求体里已经自己指定了档位(那是更明确的意图,绑定不覆盖);④ 这家上游不认识档位字段(如 WorkBuddy / 小浣熊 / AutoClaw / Cline)。注入与跳过都会写进详细日志。");function E8(e,t,n){const r=Zq(e),i=(t||"").trim(),o=r.find(c=>c.id.toLowerCase()===i.toLowerCase());return o?o.id:i||r[0]?.id||""}function rAe({context:e,onClose:t}){const n=!!e.alias,[r,i]=v.useState(()=>e.provider||LP()[0]?.id||""),[o,c]=v.useState(e.alias||""),[d,f]=v.useState(()=>E8(r,e.target)),[h,p]=v.useState(""),[g,x]=v.useState(!1),[y,j]=v.useState(()=>{const _=kb(Ab().data,C8(r,d)),I=n?HP(e.alias,e.target,e.provider):"";return I&&_.includes(I)?{select:I,custom:""}:{select:I?No:"",custom:I}}),w=kb(Ab().data,C8(r,d)),S=(()=>{const _=LP();for(const I of[e.provider,r])I&&!_.some(L=>L.id===I)&&_.push({id:I,label:a(Zn().wbProviders?.labelOf?.(I)||I)});return _})(),N=(()=>{const _=Zq(r),I=(d||"").trim();return I&&!_.some(L=>L.id.toLowerCase()===I.toLowerCase())&&_.unshift({id:I,label:a("{name}(不在该家当前清单里)",{name:I}),off:!0}),_})(),A=S.find(_=>_.id===r)?.label||r||a("(全局)"),E=y.select&&y.select!==No&&!w.includes(y.select)?{select:No,custom:y.custom||y.select}:y,O=E.select===No?E.custom.trim():E.select,R=E.select===No;function T(_){i(_),f(E8(_,d))}async function P(){if(g)return;const _=n?e.alias||"":o.trim(),I=d;if(!_){p(a("请填写对外映射名"));return}if(!I){p(a("该提供商当前没有可选的上游模型"));return}if(!r){p(a("请选择提供商"));return}if(!n&&Ad(_,I)&&Rb().some(L=>Ad(L.id,I)&&Ad(L.provider,r))){p(a("原始 ID 已作为默认绑定,请直接使用该绑定的开关或等级按钮"));return}x(!0),p(a("保存中…"));try{wh(await YS(r,_,I,{reasoning:O})),x(!1),t();const L=O?a(" · 思考等级 {level}",{level:O}):"",D=a(Zn().wbProviders?.labelOf?.(r)||r);Ia(n?a("✅ 已更新 {name} 的思考等级",{name:_}):a("✅ 已添加映射 {name} → {target}({label}){suffix}",{name:_,target:I,label:D,suffix:L}))}catch(L){p(a("保存失败:{message}",{message:Cd(L)})),x(!1)}}const M=_=>{_.key==="Enter"&&(_.preventDefault(),P())};return s.jsx(St,{open:!0,onOpenChange:(_,I)=>{if(!_){if(g){I.cancel();return}t()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a(n?"设置思考等级":"添加模型映射")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"mapping-provider",children:a("提供商")}),s.jsxs(ht,{value:r,disabled:!0,onValueChange:_=>T(String(_)),children:[s.jsx(mt,{id:"mapping-provider",className:"w-full",children:s.jsx(pt,{children:S.find(_=>_.id===r)?.label||r})}),s.jsx(gt,{children:S.map(_=>s.jsx(qe,{value:_.id,children:_.label},_.id))})]})]}),s.jsxs("div",{className:"grid grid-cols-[1fr_24px_1fr] items-end gap-2.5",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"mapping-alias",children:a("对外映射名(下游请求时用)")}),s.jsx(Be,{id:"mapping-alias",maxLength:128,placeholder:a("例如 gpt-4o"),autoComplete:"off",autoFocus:!n,value:o,disabled:n,onChange:_=>c(_.currentTarget.value),onKeyDown:M})]}),s.jsx("div",{className:"pb-2 text-center text-muted-foreground",children:"→"}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"mapping-upstream",children:a("转发到上游模型")}),s.jsxs(ht,{value:d,disabled:!0,onValueChange:_=>f(String(_)),children:[s.jsx(mt,{id:"mapping-upstream",className:"w-full",children:s.jsx(pt,{children:N.find(_=>_.id===d)?.label||d})}),s.jsx(gt,{children:N.map(_=>s.jsxs(qe,{value:_.id,children:[_.label,_.off?a("(已禁用)"):""]},_.id))})]})]})]}),s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 font-mono text-[12px] text-subtle",children:[a("下游请求 "),s.jsx("b",{className:"text-primary-fg",children:o.trim()||a("<对外名>")}),a(" → 转发")," ",s.jsx("b",{className:"text-primary-fg",children:d||a("<上游模型>")}),a("({label})",{label:A}),O?s.jsxs(s.Fragment,{children:[a(" · 思考等级 "),s.jsx("b",{className:"text-primary-fg",children:O})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-[7px]",children:[s.jsx(Ie,{htmlFor:"mapping-reasoning",children:a("思考等级")}),s.jsxs(Il,{children:[s.jsx(Bf,{render:s.jsx("span",{className:"tip-q",tabIndex:0,"aria-label":a("思考等级的注入规则")}),children:"?"}),s.jsx(Ml,{children:nAe})]})]}),s.jsxs(ht,{value:E.select,onValueChange:_=>{const I=String(_);j(L=>({...L,select:I}))},children:[s.jsx(mt,{id:"mapping-reasoning",className:"w-full",autoFocus:n,children:s.jsx(pt,{children:E.select===No?a("自定义等级…"):E.select||a("不覆盖")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("不覆盖")}),w.map(_=>s.jsx(qe,{value:_,children:_},_)),s.jsx(qe,{value:No,children:a("自定义等级…")})]})]}),R?s.jsx(Be,{id:"mapping-reasoning-custom",maxLength:32,autoFocus:!0,placeholder:a("自定义等级(例如 custom-high)"),autoComplete:"off",disabled:g,value:E.custom,onChange:_=>j(I=>({...I,custom:_.currentTarget.value})),onKeyDown:M}):null]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("对外名可自由命名,允许与上游模型 ID 同名(同名时该上游的原生路由优先,映射作兜底); 支持字母、数字与 "),s.jsx("code",{children:"- _ . / :"}),a("。同一对外名可在多个提供商各添加一条: 下游用同一个名字请求,网关按账号优先级主备切换,失败自动落到下一个提供商。")]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:h})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:g,onClick:()=>{P()},children:a(n?"保存等级":"保存映射")})]})]})})}function sAe({initial:e,onClose:t}){const[n,r]=v.useState(e.provider),[i,o]=v.useState(""),[c,d]=v.useState(""),[f,h]=v.useState(!1),p=(()=>{const w=Y1e();return n&&!w.some(S=>S.id===n)&&w.push({id:n,label:a(Zn().wbProviders?.labelOf?.(n)||n)}),w})(),g=p.some(w=>w.id===n)?n:p[0]?.id||"",x=p.find(w=>w.id===g)?.label||g||a("(未选)");async function y(){if(f)return;const w=i.trim();if(!g){d(a("请选择提供商"));return}if(!w){d(a("请填写上游模型 ID"));return}h(!0),d(a("保存中…"));try{const S=await Q1e(g,w);wh(S),h(!1),t();const N=p.find(A=>A.id===g)?.label||g;if(ts(Qm()))Ia(a("✅ 已登记模型 {name}({label})",{name:w,label:N}));else{const A=S;Array.isArray(A?.models)&&A.models.some(O=>O.id===w&&(O.provider||"")===g)?Ia(a("✅ 已登记自定义模型 {name}({label})",{name:w,label:N})):Ia(a("✅ 已登记 {name}({label}),但该提供商还没有可用账号,这一行要加上账号后才会显示",{name:w,label:N}),"err")}}catch(S){d(a("保存失败:{message}",{message:Cd(S)})),h(!1)}}const j=w=>{w.key==="Enter"&&(w.preventDefault(),y())};return s.jsx(St,{open:!0,onOpenChange:(w,S)=>{if(!w){if(f){S.cancel();return}t()}},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("添加自定义模型")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"custom-model-provider",children:a("提供商")}),s.jsxs(ht,{value:g,disabled:e.locked,onValueChange:w=>r(String(w)),children:[s.jsx(mt,{id:"custom-model-provider",className:"w-full",children:s.jsx(pt,{children:x})}),s.jsx(gt,{children:p.map(w=>s.jsx(qe,{value:w.id,children:w.label},w.id))})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"custom-model-id",children:a("上游模型 ID")}),s.jsx(Be,{id:"custom-model-id",maxLength:128,placeholder:a("例如 gpt-5.5-preview"),autoComplete:"off",spellCheck:!1,autoFocus:!0,value:i,onChange:w=>o(w.currentTarget.value),onKeyDown:j})]}),s.jsxs("div",{className:"rounded-md border border-border bg-surface-inset px-3 py-2.5 font-mono text-[12px] text-subtle",children:[a("在 "),s.jsx("b",{className:"text-primary-fg",children:x}),a(" 上登记上游模型")," ",s.jsx("b",{className:"text-primary-fg",children:i.trim()||a("<上游模型 ID>")}),a("(登记后即可用这个名字请求)")]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("填上游真正认识的那个模型 ID(不是给下游用的名字)。登记后它会进入该家的模型清单: 表格里出现这一行、"),s.jsx("code",{children:"/v1/models"}),a(" 会广告它、请求它也会被转发到这家。 支持字母、数字与 "),s.jsx("code",{children:"- _ . / :"}),a("。")]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("「来源」列会标成"),s.jsx("b",{children:a("手动")}),a(",与远程目录 / 内置清单区分开。删除自定义模型是"),s.jsx("b",{children:a("直接移除")}),a("这条登记(不像内置模型那样只是隐藏),因为它的存在完全由这次登记决定。")]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:c})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:f,onClick:()=>{y()},children:a("保存")})]})]})})}const T8='.page[data-page="gateway"]';let WP=null;function O8(){if(WP)return;const e=document.querySelector(T8);e&&(e.replaceChildren(),WP=wn.createRoot(e),WP.render(s.jsx(tAe,{})))}document.querySelector(T8)?O8():document.addEventListener("DOMContentLoaded",O8,{once:!0});function R8({children:e,installed:t}){return s.jsx(tt,{render:s.jsx("article",{}),className:"flex flex-col "+(t?"border-success/40":""),children:e})}function P8({id:e,name:t,version:n,icon:r,author:i,children:o}){const c=yb(e,t);return s.jsxs("div",{className:"flex gap-3 px-4 pt-4",children:[s.jsx("div",{className:"grid size-11 shrink-0 place-items-center overflow-hidden rounded-xl bg-primary-soft text-[19px] font-bold text-primary-fg",children:r?s.jsx("img",{src:r,alt:"",className:"size-full object-cover"}):c.slice(0,1)}),s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-1.5",children:[s.jsxs("h3",{className:"flex flex-wrap items-center gap-2 text-[14px] font-semibold leading-snug",children:[c,n?s.jsxs("span",{className:"text-[11.5px] font-normal tabular-nums text-muted-foreground",children:["v",n]}):null]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:o}),i?s.jsx("div",{className:"text-[11px] text-muted-foreground",children:a("作者:{author}",{author:i})}):null]})]})}function I8({operation:e}){const t=e.stage==="downloading"?a("正在下载…"):e.stage==="verifying"?a("正在校验包内容…"):a("正在安装…"),n=e.stage==="downloading";return s.jsxs("div",{className:"px-4 pb-4 pt-3","aria-live":"polite",children:[s.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2 text-[11.5px]",children:[s.jsx("span",{className:"text-subtle",children:e.required?`${a("正在补齐插件…")} · ${t}`:t}),s.jsx("span",{className:"tabular-nums text-muted-foreground",children:n?e.total>0?`${MS(e.received)||"0 B"} / ${MS(e.total)} · ${Math.round(e.percent||0)}%`:MS(e.received)||"0 B":a("请稍候")})]}),s.jsx(nm,{value:n?e.percent:null,"aria-label":t})]})}function aAe({item:e,target:t,operation:n,disabled:r,onInstall:i,onNotes:o}){const c=e.platforms.find(f=>f.target===t),d=!!(e.version&&c&&!e.error);return s.jsxs(R8,{children:[s.jsxs(P8,{id:e.id,name:e.name,version:e.version,icon:e.icon,author:e.author||e.publisher,children:[e.official?s.jsx(ye,{variant:"brand",children:a("官方")}):null,e.prerelease?s.jsx(ye,{variant:"warning",children:a("beta 版")}):null,e.version?null:s.jsx(ye,{variant:"outline",children:a("暂未发布")})]}),s.jsx("p",{className:"px-4 pt-2.5 text-[12px] leading-relaxed text-subtle",children:sq(e.id,e.description)}),s.jsxs("div",{className:"flex flex-wrap gap-3 px-4 pt-3 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:DNe(t)}),s.jsx("span",{children:MS(c?.size||0)||a("当前平台暂无包")})]}),e.error?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(e.reason)}):null,n?.error?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(n.error)}):null,n?.active?s.jsx(I8,{operation:n}):s.jsxs("div",{className:"mt-auto flex gap-2 px-4 pb-4 pt-3.5",children:[s.jsx(B,{size:"sm",disabled:r||!d,onClick:i,children:a("下载并安装")}),e.version?s.jsx(B,{variant:"outline",size:"sm",onClick:o,children:a("查看更新日志")}):null]})]})}function iAe({pack:e,store:t,host:n,update:r,operation:i,disabled:o,onEnabled:c,onSettings:d,onRemove:f,onUpdate:h,onNotes:p}){const g=e.updateRequired===!0,x=r?.error===!0&&!g,y=e.host===void 0?n:e.host;return s.jsxs(R8,{installed:!0,children:[s.jsxs(P8,{id:e.id,name:t?.name||e.name,version:e.version,icon:e.icon||t?.icon,author:t?.author||t?.publisher||e.author||e.publisher,children:[s.jsx(ye,{variant:e.enabled?"default":"secondary",children:e.enabled?a("已启用"):a("已停用")}),s.jsx(ye,{variant:e.signed?"success":"warning",children:e.signed?a("已签名"):a("未签名")}),e.version.includes("-")?s.jsx(ye,{variant:"warning",children:a("beta 版")}):null,g?s.jsx(ye,{variant:"destructive",children:a("需要补齐插件")}):r?.available?s.jsx(ye,{variant:"brand",children:a("有更新")}):null,e.entryPresent?null:s.jsx(ye,{variant:"destructive",children:a("文件缺失")})]}),s.jsx("p",{className:"px-4 pt-2.5 text-[12px] leading-relaxed text-subtle",children:sq(e.id,t?.description||e.description)}),s.jsx("p",{className:"px-4 pt-2 text-[11px] text-muted-foreground",children:a("{count} 家提供商 · 安装于 {time}",{count:String(e.providers.length),time:rq(e.installedAt)})}),s.jsxs("div",{className:"flex flex-wrap gap-3 px-4 pt-3 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:y?.running?a("运行中"):a("未运行")}),s.jsxs("span",{children:[a("已加载")," ",a("{count} 家",{count:String(e.providers.filter(j=>j.loaded).length)})]})]}),g?s.jsxs("div",{className:"mx-4 mt-3 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px]","aria-live":"polite",children:[s.jsx("p",{className:"font-medium text-destructive",children:a("当前网关要求插件版本不低于 v{version},补齐前暂不加载。",{version:e.requiredVersion||""})}),s.jsx("p",{className:"mt-1 text-subtle",children:e.signed?a("正在自动补齐官方插件,不受日常更新开关和通道限制。"):a("未签名包不会自动覆盖;点击「补齐插件」将安装官方签名包。")}),r?.reason?s.jsx("p",{className:"mt-1 "+(r.error?"text-destructive":"text-subtle"),children:Wl(r.reason)}):null,r?.retryAt&&r.retryAt>Date.now()?s.jsx("p",{className:"mt-1 text-subtle",children:a("下次自动重试:{time}",{time:rq(r.retryAt)})}):null]}):null,e.entryPresent?null:s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:a("插件包的可执行文件不在磁盘上(可能被手工删除或移动),请重新安装。")}),r?.available&&!g?s.jsxs("div",{className:"mx-4 mt-3 flex flex-wrap items-center justify-between gap-2 border-t border-hairline pt-3",children:[s.jsx("span",{className:"text-[12px] font-medium text-primary-fg",children:a("可更新到 v{version}",{version:r.latest||""})}),s.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-subtle",children:[a("更新日志"),s.jsx(B,{variant:"outline",size:"xs",onClick:p,children:a("查看")})]})]}):null,r?.error&&!g?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(r.reason)}):null,i?.error?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:Wl(i.error)}):null,y?.lastError?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-destructive",children:y.lastError}):null,i?.hostError?s.jsx("p",{className:"px-4 pt-2 text-[12px] text-warning",children:i.hostError}):null,i?.active?s.jsx(I8,{operation:i}):s.jsxs("div",{className:"mt-auto flex flex-wrap items-center gap-2 px-4 pb-4 pt-3.5",children:[s.jsxs(Ie,{className:"flex items-center gap-1.5 text-[12px] text-subtle",children:[a("启用"),s.jsx(cn,{checked:e.enabled,disabled:o,onCheckedChange:j=>c(j===!0)})]}),s.jsx(B,{variant:"outline",size:"sm",onClick:d,"aria-haspopup":"dialog",children:a("设置")}),s.jsx(B,{variant:"outline",size:"sm",disabled:o,onClick:f,children:a("卸载")}),s.jsx("span",{className:"flex-1"}),g?s.jsx(B,{size:"sm",disabled:o||r?.repairing===!0,onClick:h,children:r?.repairing?a("正在补齐插件…"):a("补齐插件")}):r?.available?s.jsx(B,{size:"sm",disabled:o||x,onClick:h,children:a("更新到 v{version}",{version:r.latest||""})}):s.jsx("span",{className:"text-[11px] "+(r?.error?"text-destructive":"text-muted-foreground"),children:r?.checked?Wl(r.reason)||a("已是最新"):a("尚未检查更新")})]})]})}function hn(){return window}function Ss(e,t){hn().wbApp?.toast?.(e,t)}function ks(e){return nq(e,a,"update")}function M8(e){const t=String(e||"").trim();return/^https?:\/\//i.test(t)?t:""}async function Lb(e){const t=M8(e);if(!t){Ss(a("链接地址不受支持"),"err");return}try{await hn().workbuddyDesktop?.openReleasePage(t)}catch(n){Ss(a("打开链接失败:{error}",{error:ks(n)}),"err")}}const oAe=[{no:"1127656296",nearlyFull:!0},{no:"1130894674",nearlyFull:!0},{no:"1108276647",nearlyFull:!1}],lAe=[{id:"telegram",url:"https://t.me/+9gM8YPvgRL02NGRl"}];function XP(e){return hn().wbMarkdown?.render?.(e)||""}function zb(e){const n=e.target?.closest?.("[data-external]");n&&(e.preventDefault(),Lb(n.dataset.external||""))}async function _8(){try{const e=await hn().workbuddyDesktop?.getUpdateStatus?.();e&&(e.checked!==!1||e.channelChanged)&&hn().wbApp?.updateUpdateBadge?.(e)}catch(e){console.warn("读取版本检查结果失败:",ks(e))}}const XS="__proxy_other__",D8={proxyChoice:null,proxyLoaded:!1,pool:null,poolError:""};async function L8(){const e=hn().workbuddyDesktop,t={...D8};if(!e?.getUpdateProxy)return t;try{const n=await e.getUpdateProxy();if(!n||!Object.prototype.hasOwnProperty.call(n,"proxy"))throw new Error("更新线路响应异常");t.proxyChoice=n.proxy??null,t.proxyLoaded=!0}catch{}try{if(typeof e.getProxyPool!="function")throw new Error("桥未提供代理池方法");const r=(await e.getProxyPool())?.items;if(!Array.isArray(r))throw new Error("代理池响应异常");t.pool=r,JU(r)}catch(n){t.pool=[],t.poolError=ks(n)}return t}async function cAe(e){if(e===XS)return null;const t=hn().workbuddyDesktop;if(!t?.setUpdateProxy)return null;const n=e===""?null:{source:"pool",proxyId:e.slice(tl.length)};try{const r=await t.setUpdateProxy({proxy:n}),i=r?.proxy??null,o=r?.saved!==!1;return o?Ss(i?a("✅ 更新出网已切换为 {label}",{label:i.label||a("指定代理")}):a("✅ 更新出网已切换为直连")):Ss(a("出网线路已切换,但写入磁盘失败(重启后会恢复原线路)"),"err"),{choice:i,saved:o}}catch(r){return Ss(a("保存失败:{error}",{error:ks(r)}),"err"),null}}function uAe(e){const t=e.proxyChoice,n=t?.config?.source||t?.source,r=t?.label||a(n==="custom"?"自定义代理":"已设置"),i=Array.isArray(e.pool)?e.pool:[],o=!!t?.error;let c="";n==="pool"&&t?.config?.proxyId?c=`${tl}${t.config.proxyId}`:t&&(c=XS);const d=[{value:"",label:a("直连")}];for(const f of i)d.push({value:`${tl}${f.id}`,label:dm(f),disabled:f.enabled===!1});if(e.pool===null?d.push({value:"__hint_pool__",label:a("正在读取代理列表…"),disabled:!0}):i.length||d.push({value:"__hint_pool__",label:e.poolError?a("代理列表读取失败"):a("还没有代理(去「网络代理」页添加)"),disabled:!0}),c===XS){const f=n==="clash"?a("Clash 出口:"):n==="custom"?a("自定义:"):"";d.push({value:XS,label:`${f}${r}${o?a("(不可用)"):""}`})}else n==="pool"&&!i.some(f=>`${tl}${f.id}`===c)&&d.push({value:c,label:`${r}${o?a("(不可用)"):""}`});return{current:c,items:d,selected:d.find(f=>f.value===c),broken:o,title:o?a("当前线路不可用:{error};请重新选择代理或切回直连",{error:String(t?.error||"")}):a("检查更新与下载安装包使用所选线路;未选择代理时先直连,失败后尝试 Clash Verge 混合端口;指定代理不可用时不会自动改走直连。")}}function dAe({value:e,onClose:t}){const n=e?.notes?.trim()||"",r=n?XP(n):"";return s.jsx(St,{open:e!==null,onOpenChange:i=>{i||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("更新日志")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]",children:[s.jsx("strong",{children:e?.name}),s.jsxs("span",{className:"text-subtle",children:["v",e?.version]}),e?.prerelease?s.jsx(ye,{variant:"warning",children:a("beta 版")}):null]}),s.jsx("div",{className:"max-h-[46vh] overflow-y-auto overscroll-contain pr-1.5",onClick:zb,children:r?s.jsx(Qo,{className:"md-body",html:r}):n?s.jsx("div",{className:"whitespace-pre-wrap text-[12.5px] leading-relaxed text-subtle",children:n}):s.jsx("p",{className:"text-[12px] text-muted-foreground",children:a("这个版本没有填写发布说明。")})})]}),e?.page?s.jsx(Pt,{children:s.jsx(B,{variant:"outline",size:"sm",onClick:()=>{Lb(e.page||"")},children:a("查看发布页面")})}):null]})})}function fAe({pack:e,name:t,disabled:n,onClose:r,onEnabled:i,onProvider:o}){const[c,d]=v.useState(""),f=v.useId(),h=c.trim().toLocaleLowerCase(),p=e.providers.filter(g=>!h||`${g.label} ${g.id}`.toLocaleLowerCase().includes(h));return s.jsx(St,{open:!0,onOpenChange:g=>{g||r()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsxs(jt,{className:"min-w-0 break-words",children:[yb(e.id,t||e.name)," · ",a("设置")]})}),s.jsxs(Ct,{className:"min-h-0 gap-3.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[12px] text-muted-foreground",children:[s.jsxs("span",{className:"tabular-nums",children:["v",e.version]}),s.jsx(ye,{variant:"outline",children:a("{count} 家",{count:e.providers.length})})]}),s.jsxs(Ie,{htmlFor:`${f}-enabled`,className:"text-[12px] text-subtle",children:[a("启用"),s.jsx(cn,{id:`${f}-enabled`,checked:e.enabled,disabled:n,onCheckedChange:g=>i(g===!0)})]})]}),s.jsx(bT,{className:"text-[12px] leading-relaxed text-subtle",children:a("这个包提供的提供商(可单独停用某一家)")}),e.enabled?null:s.jsx(ye,{variant:"secondary",className:"self-start",children:a("已停用")}),e.providers.length?s.jsxs(s.Fragment,{children:[s.jsx(Be,{type:"search",value:c,placeholder:a("搜索提供商"),"aria-label":a("搜索提供商"),onChange:g=>d(g.currentTarget.value)}),s.jsx("div",{className:"max-h-[46vh] min-h-0 overflow-y-auto overscroll-contain rounded-md border border-hairline",children:p.length?s.jsx("div",{className:"grid grid-cols-1 gap-2 p-2 min-[640px]:grid-cols-2",children:p.map(g=>s.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-md border border-hairline bg-surface-2 px-3 py-2.5",children:[s.jsxs(Ie,{htmlFor:`${f}-${g.id}`,className:"min-w-0 flex-1 flex-col items-start gap-0.5",children:[s.jsx("span",{className:"text-[12.5px] font-medium break-words text-foreground",children:a(g.label)}),s.jsx("code",{className:"max-w-full text-[11px] break-all text-muted-foreground",children:g.id}),g.enabled&&!g.loaded?s.jsx(ye,{variant:"secondary",className:"mt-1",children:a("未加载")}):null]}),s.jsx(cn,{id:`${f}-${g.id}`,checked:g.enabled,disabled:n||!e.enabled,onCheckedChange:x=>o(g,x===!0)})]},g.id))}):s.jsx("p",{className:"px-3 py-5 text-center text-[12px] text-subtle",children:a("没有匹配「{keyword}」的提供商",{keyword:c.trim()})})})]}):null]}),s.jsx(Pt,{className:"justify-end",children:s.jsx(B,{variant:"outline",size:"sm",onClick:r,children:a("关闭")})})]})})}function hAe(){const[e,t]=v.useState(null),[n,r]=v.useState(""),[i,o]=v.useState(!1),[c,d]=v.useState(""),f=[{value:"auto",label:a("自动(官方优先)")},{value:"official",label:a("仅官方源")},{value:"accelerated",label:a("加速源优先")}];v.useEffect(()=>{let p=!0;return hn().workbuddyDesktop?.getGithubAccess().then(g=>{if(p){if(!g)throw new Error(a("读取设置失败:{error}",{error:a("请求失败")}));t(g),r(g.mirrorUrl)}}).catch(g=>{p&&d(ks(g))}),()=>{p=!1}},[]);async function h(p){if(!i){o(!0),d("");try{const g=await hn().workbuddyDesktop?.setGithubAccess(p);if(!g)throw new Error(a("请求失败"));t(g),r(g.mirrorUrl),Ss(g.saved===!1?a("设置已生效,但写入磁盘失败(重启后会恢复原设置)"):a("GitHub 访问设置已保存"),g.saved===!1?"err":"ok")}catch(g){d(ks(g))}finally{o(!1)}}}return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("GitHub 访问方式")}),s.jsxs(ht,{value:e?.mode||"auto",disabled:i||!e,onValueChange:p=>{h({mode:p})},children:[s.jsx(mt,{className:"w-full","aria-label":a("GitHub 访问方式"),children:s.jsx(pt,{children:f.find(p=>p.value===e?.mode)?.label||f[0].label})}),s.jsx(gt,{children:f.map(p=>s.jsx(qe,{value:p.value,children:p.label},p.value))})]}),s.jsx("p",{className:"text-[12px] text-subtle",children:e?.mode==="official"?a("只访问 GitHub 官方源,仍使用所选出网代理。"):e?.mode==="accelerated"?a("优先使用加速源,访问失败后回退官方源;不会绕过 GitHub 限流冷却。"):a("优先访问官方源,连接失败后尝试加速源;短期记住成功的源,定期恢复官方优先。")}),s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:a("GitHub 加速前缀")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Be,{value:n,disabled:i||!e||e.mode==="official",autoComplete:"off",spellCheck:!1,className:"min-w-0 flex-1","aria-label":a("GitHub 加速前缀"),placeholder:"https://gh-proxy.com/",onChange:p=>r(p.currentTarget.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h({mirrorUrl:n}))}}),s.jsx(B,{size:"sm",variant:"outline",disabled:i||!e||e.mode==="official"||n===e.mirrorUrl,onClick:()=>{h({mirrorUrl:n})},children:a("保存")})]}),s.jsx("p",{className:"text-[12px] text-subtle",children:a("填写支持 Raw、Release 和 GitHub API 的 HTTPS 加速站前缀,留空恢复默认。")}),s.jsx("p",{className:"text-[12px] text-subtle",children:a("软件更新与插件共用此设置;GitHub 令牌仅发送给官方 API。镜像安装包需要官方校验值,镜像插件包需要官方签名。")}),c?s.jsx(It,{variant:"destructive",role:"alert",className:"text-[12px] text-destructive",children:c}):null]})}function pAe(e){return e?e.error?{badge:s.jsx(ye,{shape:"tag",variant:"destructive",title:e.error,children:a("无法解密")}),hint:a("重新粘贴保存一次即可自愈")}:e.filled&&e.origin==="stored"?{badge:s.jsx(ye,{shape:"tag",variant:"success",children:a("已填写")}),hint:a("已加密存储在本地,不显示具体值;粘贴新令牌可覆盖")}:e.filled?{badge:s.jsx(ye,{shape:"tag",variant:"secondary",children:a("环境变量")}),hint:a("已配置 GITHUB_TOKEN 环境变量,界面保存的令牌优先于它")}:{badge:s.jsx(ye,{shape:"tag",variant:"outline",children:a("未填写")}),hint:a("填写后检查限额 60 → 5000 次/小时(创建令牌无需勾选任何权限)")}:{badge:s.jsx(ye,{shape:"tag",variant:"outline",children:a("读取中")}),hint:""}}function z8({plugin:e=!1,pane:t}){const[n,r]=v.useState(D8),[i,o]=v.useState(null),[c,d]=v.useState(""),[f,h]=v.useState(!1),[p,g]=v.useState(!1),x=v.useRef(0),y=uAe(n);v.useEffect(()=>{let A=!0;const E=x.current;return L8().then(O=>{A&&E===x.current&&r(O)}),hn().workbuddyDesktop?.getUpdateToken().then(O=>{A&&o(O??null)}).catch(O=>Ss(a("读取设置失败:{error}",{error:ks(O)}),"err")),()=>{A=!1}},[]);async function j(A){if(!p){x.current+=1,g(!0);try{const E=await cAe(A);if(E){r(R=>({...R,proxyChoice:E.choice}));const O=await L8();r(R=>({...O,proxyChoice:O.proxyLoaded?O.proxyChoice:E.choice,pool:O.poolError?R.pool:O.pool}))}}finally{g(!1)}}}async function w(A=!1){if(f)return;const E=c.trim();if(!(!A&&!E)){h(!0);try{const O=await hn().workbuddyDesktop?.setUpdateToken({token:A?null:E});if(!O)throw new Error(a("请求失败"));o(O),d(""),O.saved===!1?Ss(a("令牌已生效,但写入磁盘失败(重启后会丢失)"),"err"):Ss(a(A?"✅ 已清除界面保存的 GitHub 令牌(环境变量若配置过则继续生效)":"✅ GitHub 令牌已保存(加密存储,界面不再显示)"))}catch(O){Ss(a("保存失败:{error}",{error:ks(O)}),"err")}finally{h(!1)}}}const S=pAe(i),N=!!i?.error||i?.origin==="stored";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{hidden:t!=="network",children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("网络")}),e?s.jsx("p",{children:a("与软件更新共用出网代理和 GitHub 凭证,修改任意一处都会同步生效。")}):null]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsx(hAe,{}),s.jsx("div",{className:"h-px bg-hairline"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("出网代理")}),s.jsx("div",{className:"mt-1.5",children:s.jsxs(ht,{value:y.current,disabled:p,onValueChange:A=>{j(String(A))},children:[s.jsx(mt,{className:Te("w-full",y.broken&&"border-destructive-bd"),title:y.title,"aria-label":a("更新出网代理"),children:s.jsx(pt,{className:"min-w-0 truncate",children:y.selected?.label||a("直连")})}),s.jsx(gt,{children:y.items.map(A=>s.jsx(qe,{value:A.value,disabled:A.disabled,children:A.label},A.value))})]})})]})]})]}),s.jsxs("div",{hidden:t!=="token",children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("GitHub 令牌")}),e?s.jsx("p",{children:a("与软件更新共用出网代理和 GitHub 凭证,修改任意一处都会同步生效。")}):null]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[S.badge,s.jsx("span",{className:"text-[12px] text-subtle",children:S.hint})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Be,{type:"password",className:"min-w-0 flex-1",autoComplete:"new-password",spellCheck:!1,"aria-label":a("GitHub 令牌"),placeholder:i?.filled&&i.origin!=="env"?a("已填写(粘贴新令牌可覆盖)"):a("粘贴 GitHub 令牌(ghp_… / github_pat_…)"),value:c,onChange:A=>d(A.currentTarget.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),w())}}),s.jsx(B,{size:"sm",disabled:f||!c.trim(),onClick:()=>{w()},children:a("保存")}),N?s.jsx(B,{variant:"outline",size:"sm",disabled:f,onClick:()=>{w(!0)},children:a("清除")}):null]}),s.jsx("div",{children:s.jsx(B,{variant:"outline",size:"sm",title:a("在默认浏览器中打开 GitHub 的令牌创建页(备注已预设,无需勾选任何权限,直接点 Generate token)"),onClick:()=>{Lb("https://github.com/settings/tokens/new?description="+encodeURIComponent("Agent2API 更新检查"))},children:a("打开 GitHub 令牌页面")})})]})]})]})}function mAe({open:e,onClose:t,onChanged:n}){const[r,i]=v.useState(null),[o,c]=v.useState(""),[d,f]=v.useState(!1),[h,p]=v.useState("check"),g=v.useRef(null),x=[["check",a("检查计划")],["channel",a("更新通道")],["install",a("自动安装")],["network",a("网络")],["token",a("GitHub 令牌")]],y=[{value:"follow",label:a("跟随软件")},{value:"custom",label:a("单独设置")}];v.useEffect(()=>{if(!e)return;let N=!0;return p("check"),i(null),Xc("GET","/api/plugins/settings").then(A=>{N&&(i(A),c(String(A.interval)))}).catch(A=>mi(a("读取设置失败:{error}",{error:String(A)}),"err")),()=>{N=!1}},[e]);async function j(N){if(d||!r)return;const A={...r,...N};if(N.channelMode!=="follow"&&!A.stable&&!A.beta){mi(a("至少需要关注正式版或 beta 版中的一个通道"),"err");return}f(!0);try{const E=await Xc("PATCH","/api/plugins/settings",N);i(E),c(String(E.interval)),mi(E.saved===!1?a("设置已生效,但写入磁盘失败(重启后会恢复原设置)"):a("插件设置已保存"),E.saved===!1?"err":"ok"),("beta"in N||"stable"in N||"channelMode"in N)&&await n()}catch(E){mi(a("保存失败:{error}",{error:E instanceof Error?E.message:String(E)}),"err")}finally{f(!1)}}async function w(){const N=Number(o);if(!Number.isInteger(N)||N<1||N>1440){mi(a("检查间隔必须是 {min} ~ {max} 分钟",{min:1,max:1440}),"err");return}await j({interval:N})}const S=r?.stable&&r.beta?a("正式版与 beta 版"):r?.beta?a("仅 beta 版"):a("仅正式版");return s.jsx(St,{open:e,onOpenChange:N=>{N||t()},children:s.jsxs(kt,{className:"settings-dlg",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("插件设置")})}),s.jsxs(Ct,{className:"settings-dlg-body",children:[s.jsx(cm,{className:"prov-rail settings-dlg-rail","aria-label":a("插件设置"),children:s.jsxs(Bc,{className:"rail-scroll",render:s.jsx("nav",{}),children:[s.jsx("div",{className:"rail-label",children:a("插件设置")}),x.map(([N,A])=>s.jsx(Ri,{active:h===N,title:A,onClick:()=>{p(N),g.current&&(g.current.scrollTop=0)},children:A},N))]})}),s.jsxs("div",{className:"settings-dlg-main",ref:g,children:[h==="check"?s.jsxs("div",{children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("检查计划")}),s.jsx("p",{children:a("默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。")})]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs(ht,{value:r?.checkMode||"follow",disabled:d||!r,onValueChange:N=>{j({checkMode:N})},children:[s.jsx(mt,{className:"w-full","aria-label":a("检查计划"),children:s.jsx(pt,{children:y.find(N=>N.value===(r?.checkMode||"follow"))?.label})}),s.jsx(gt,{children:y.map(N=>s.jsx(qe,{value:N.value,children:N.label},N.value))})]}),r?.checkMode==="custom"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[13px] text-foreground",children:a("自动检查更新")}),s.jsx(cn,{checked:r.autoCheck,disabled:d,onCheckedChange:N=>{j({autoCheck:N===!0})},"aria-label":a("自动检查插件更新")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Be,{type:"number",min:1,max:1440,step:1,className:"w-[110px]",disabled:d||!r.autoCheck,value:o,onChange:N=>c(N.currentTarget.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),w())},"aria-label":a("检查间隔(分钟)")}),s.jsx("span",{className:"text-[12px] text-subtle",children:a("分钟({min} ~ {max})",{min:1,max:1440})}),s.jsx(B,{variant:"outline",size:"sm",disabled:d||!r.autoCheck||Number(o)===r.interval,onClick:()=>{w()},children:a("保存")})]})]}):s.jsx("p",{className:"text-[12px] text-subtle",children:r?r.autoCheck?a("当前:自动检查开启,每 {n} 分钟",{n:r.interval}):a("当前:自动检查关闭"):a("读取中")})]})]}):null,h==="channel"?s.jsxs("div",{children:[s.jsxs("div",{className:"settings-dlg-pane-head",children:[s.jsx("h3",{children:a("更新通道")}),s.jsx("p",{children:a("默认跟随软件的正式版和 beta 关注选择;单独设置只影响日常更新,最低版本补齐按当前软件版本选择配套包。")})]}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs(ht,{value:r?.channelMode||"follow",disabled:d||!r,onValueChange:N=>{j({channelMode:N})},children:[s.jsx(mt,{className:"w-full","aria-label":a("更新通道"),children:s.jsx(pt,{children:y.find(N=>N.value===(r?.channelMode||"follow"))?.label})}),s.jsx(gt,{children:y.map(N=>s.jsx(qe,{value:N.value,children:N.label},N.value))})]}),r?.channelMode==="custom"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[13px] text-foreground",children:a("关注正式版更新")}),s.jsx(cn,{checked:r.stable,disabled:d,"aria-label":a("关注正式版更新"),onCheckedChange:N=>{j({stable:N===!0})}})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[13px] text-foreground",children:a("关注 beta 版更新")}),s.jsx(cn,{checked:r.beta,disabled:d,"aria-label":a("关注 beta 版更新"),onCheckedChange:N=>{j({beta:N===!0})}})]})]}):s.jsx("p",{className:"text-[12px] text-subtle",children:r?a("当前关注:{channels}",{channels:S}):a("读取中")})]})]}):null,h==="install"?s.jsxs("div",{children:[s.jsx("div",{className:"settings-dlg-pane-head",children:s.jsx("h3",{children:a("自动安装")})}),s.jsxs("div",{className:"settings-dlg-fields",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("自动更新插件")}),s.jsx(cn,{checked:r?.autoUpdate===!0,disabled:d||!r,onCheckedChange:N=>{j({autoUpdate:N===!0})},"aria-label":a("自动更新插件")})]}),s.jsx("p",{className:"mt-1.5 text-[12px] text-subtle",children:a("检测到更新后自动下载、校验并安装已启用的官方签名插件。关闭此项不影响最低版本补齐;未签名或第三方插件仍需手动更新。")})]}),s.jsx("div",{className:"h-px bg-hairline"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:a("自动下载官方插件")}),s.jsx(cn,{checked:r?.autoInstallOfficial===!0,disabled:d||!r,onCheckedChange:N=>{j({autoInstallOfficial:N===!0})},"aria-label":a("自动下载官方插件")})]}),s.jsx("p",{className:"mt-1.5 text-[12px] text-subtle",children:a("发现未安装的官方插件时自动下载并安装,仅接受当前平台且通过官方签名校验的包;开启期间卸载的官方插件也会重新安装。")})]}),s.jsx("p",{className:"text-[12px] text-subtle",children:a("默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。")})]})]}):null,e?s.jsx(z8,{plugin:!0,pane:h==="network"||h==="token"?h:null}):null]})]}),s.jsxs(Pt,{className:"settings-dlg-footer",children:[s.jsx("p",{className:"mr-auto text-[12px] text-subtle",children:a("开关和选项即时保存;输入项请点击对应的「保存」按钮。")}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})})}const QP=1024*1024,$8=24*QP,gAe=96*QP;function vAe(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?Math.min(e,gAe):$8}function QS(e){return a("插件包大小不能超过 {n} MiB",{n:e/QP})}async function xAe(e,t){if(e.size>t)throw new Error(QS(t));const n=await LNe(e);if(n.length>Math.ceil(t/3)*4)throw new Error(QS(t));return n}function bAe(){const[e,t]=v.useState(null),[n,r]=v.useState($8),[i,o]=v.useState(""),[c,d]=v.useState(""),[f,h]=v.useState(""),[p,g]=v.useState(!1),[x,y]=v.useState(null),[j,w]=v.useState(null),[S,N]=v.useState(null),A=v.useRef(null),E=v.useRef(new Set),O=v.useRef(""),R=v.useRef(!0),T=v.useRef(null),P=v.useCallback(async ee=>{const se=bb().wbApp,[le]=await Promise.all([se?.refresh?.(),se?.refreshPluginPages?.(ee)]);R.current&&d(le===!0?"":a("插件状态已变更,但账号列表同步失败。请回到账号页点击「刷新」重试。"))},[]),M=v.useCallback(async()=>{if(T.current)return T.current;const ee=(async()=>{try{const se=await Xc("GET","/api/plugins");if(!R.current)return;const le=JSON.stringify({packs:se.packs.map(re=>({id:re.id,version:re.version,enabled:re.enabled,providers:re.providers})),running:se.host?.running}),te=!!(O.current&&O.current!==le);O.current=le,r(vAe(se.maxPackBytes)),t(se),o(""),bb().wbApp?.refreshPluginPages?.(se),te&&await P(se);for(const re of se.operations||[]){if(re.active)continue;const he=`${re.id}:${re.updatedAt}`;E.current.has(he)||(E.current.add(he),!(Date.now()-re.updatedAt>3e4)&&(re.error?mi(re.error,"err"):re.hostError?mi(re.hostError,"err"):re.done&&mi(a("插件包已安装到 v{version}",{version:re.version}),"ok")))}}catch(se){R.current&&o(Wl(se))}})();T.current=ee;try{await ee}finally{T.current=null}},[P]);v.useEffect(()=>{R.current=!0,M();const ee=window.setInterval(()=>{const se=bb().wbApp?.currentPage;!document.hidden&&(!se||se==="plugins")&&M()},1500);return()=>{R.current=!1,window.clearInterval(ee)}},[M]),v.useEffect(()=>(ZS=M,()=>{ZS===M&&(ZS=null)}),[M]);async function _(ee,se){if(!f){h(ee);try{await se()}catch(le){mi(le instanceof Error?le.message:String(le),"err")}finally{R.current&&h("")}}}async function I(){await _("check",async()=>{const ee=await Xc("GET","/api/plugins/update");await M(),ee.error&&mi(ee.reason||a("检查更新失败"),"err")})}async function L(){await _("refresh",async()=>{const ee=await Xc("GET","/api/plugins/release");await M(),ee.error&&mi(ee.reason||a("检查更新失败"),"err")})}async function D(ee){t(se=>se&&{...se,...ee}),await P(ee),ee.hostError&&mi(ee.hostError,"err"),await M()}async function z(ee,se,le){await _(ee,async()=>{await D(await Xc("POST",se,le))})}async function G(ee,se){await _(`start:${ee}`,async()=>{const le=await Xc("POST",se?"/api/plugins/update":"/api/plugins/install-from-release",{id:ee,target:e?.target});t(te=>te&&{...te,operations:[...(te.operations||[]).filter(re=>re.id!==ee),le.operation]})})}function X(){A.current&&(A.current.value="",A.current.click())}async function Y(ee){const se=ee.currentTarget.files?.[0];if(se){if(se.size>n){mi(QS(n),"err");return}await _("file",async()=>{const le=await xAe(se,n);await D(await Xc("POST","/api/plugins/install",{packB64:le})),mi(a("插件包已安装"),"ok")})}}const F=e?.packs||[],K=e?.host,U=e?.catalog,q=U?.plugins||[],W=new Set(F.map(ee=>ee.id)),ne=q.filter(ee=>!W.has(ee.id)),ie=e?.operations||[],V=ie.some(ee=>ee.active),H=e?.target||"",Q=!!f,J=F.find(ee=>ee.id===x),oe=ie.find(ee=>ee.id===x);return v.useEffect(()=>{x&&e&&!J&&y(null)},[e,J,x]),s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"panel",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsxs("div",{children:[s.jsx("h2",{children:a("插件")}),s.jsx("p",{className:"muted",children:a("按需安装插件,为 AI 路由网关扩展提供商能力。插件独立于主程序更新,下载完成后自动校验并安装。")})]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[s.jsx(ye,{variant:K?.running?"success":"outline",children:K?.running?a("运行中"):F.length?a("未运行"):a("未安装")}),s.jsx(B,{variant:"outline",size:"sm",disabled:Q,onClick:()=>{L()},children:a(f==="refresh"?"刷新中…":"刷新")}),s.jsx(B,{variant:"outline",size:"sm",disabled:Q,onClick:()=>{I()},children:f==="check"||U?.checking?a("检查中…"):a("检查更新")}),s.jsx(B,{variant:"outline",size:"sm",onClick:()=>g(!0),children:a("插件设置")}),s.jsx(B,{variant:"outline",size:"sm",disabled:Q||V,onClick:X,children:a("从文件安装…")})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx(Be,{ref:A,type:"file",accept:".zip,application/zip",className:"hidden",onChange:ee=>{Y(ee)}}),s.jsx("p",{className:"mb-3 text-[12px] text-subtle",children:QS(n)}),i||c?s.jsx("p",{className:"mb-3 text-[12px] text-destructive",children:i||c}):null,f==="file"?s.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[s.jsx("span",{className:"text-[12px] text-subtle",children:a("正在读取、校验并安装插件包…")}),s.jsx(nm,{value:null})]}):null,s.jsxs("div",{className:"grid grid-cols-1 items-start gap-3.5 min-[900px]:grid-cols-2",children:[ne.map(ee=>s.jsx(aAe,{item:ee,target:H,operation:ie.find(se=>se.id===ee.id),disabled:Q,onInstall:()=>{G(ee.id,!1)},onNotes:()=>N({name:yb(ee.id,ee.name),version:ee.version||"",notes:ee.notes,page:ee.page,prerelease:ee.prerelease})},ee.id)),F.map(ee=>{const se=e?.updates?.find(te=>te.id===ee.id),le=ie.find(te=>te.id===ee.id);return s.jsx(iAe,{pack:ee,store:q.find(te=>te.id===ee.id),host:K||null,update:se,operation:le,disabled:Q||le?.active===!0,onEnabled:te=>{z(`enable:${ee.id}`,"/api/plugins/enable",{id:ee.id,enabled:te})},onSettings:()=>y(ee.id),onRemove:()=>w(ee),onUpdate:()=>{G(ee.id,!0)},onNotes:()=>N({name:yb(ee.id,ee.name),version:se?.latest||"",notes:se?.notes,page:se?.page,prerelease:se?.prerelease})},ee.id)})]}),!ne.length&&!F.length?s.jsxs("div",{className:"rounded-lg border border-border bg-surface px-4 py-5",children:[s.jsx("p",{className:"text-[13px] font-medium",children:!e||U?.checking?a("正在读取插件列表…"):a("暂无可安装的插件")}),s.jsx("p",{className:"mt-2 text-[12px] text-subtle",children:Wl(U?.reason)||a("可以点击「刷新」读取插件仓库,或从本地 zip 安装插件。")})]}):null,e?s.jsxs(Ll,{className:"mt-3 rounded-md border border-hairline bg-surface-2",children:[s.jsxs(zl,{render:s.jsx(B,{variant:"ghost"}),className:"group/diagnostics flex h-auto w-full justify-start gap-2 rounded-md px-3 py-3 text-[12px] text-subtle",children:[s.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5 transition-transform duration-150 group-aria-expanded/diagnostics:rotate-90 motion-reduce:transition-none",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"m9 5 7 7-7 7"})}),a("诊断信息")]}),s.jsx($l,{children:s.jsxs("div",{className:"flex flex-col gap-1 px-3 pb-3 text-[12px] text-subtle",children:[s.jsxs("span",{children:[a("插件目录")," ",s.jsx("code",{className:"break-all",children:e.pluginsDir})]}),s.jsxs("span",{children:[a("当前平台")," ",s.jsx("code",{children:e.target})]}),s.jsxs("span",{children:[a("协议版本")," ",e.protocol]}),U?.reason?s.jsx("span",{className:"text-destructive",children:Wl(U.reason)}):null,K?.lastError?s.jsx("span",{className:"text-destructive",children:K.lastError}):null]})})]}):null]}),s.jsx(Zo,{className:"panel-foot",children:a("插件包与主程序分开安装、分开升级。卸载插件后账号数据仍然保留,重新装回即可继续使用;仅该包提供的转发与添加账号需要插件,本体订阅不受影响。")})]}),s.jsx(mAe,{open:p,onClose:()=>g(!1),onChanged:I}),J?s.jsx(fAe,{pack:J,name:q.find(ee=>ee.id===J.id)?.name,disabled:Q||oe?.active===!0,onClose:()=>y(null),onEnabled:ee=>{z(`enable:${J.id}`,"/api/plugins/enable",{id:J.id,enabled:ee})},onProvider:(ee,se)=>{z(`provider:${ee.id}`,"/api/plugins/provider",{id:J.id,provider:ee.id,enabled:se})}},J.id):null,s.jsx(dAe,{value:S,onClose:()=>N(null)}),s.jsx(St,{open:j!==null,onOpenChange:ee=>{ee||w(null)},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("卸载插件包")})}),s.jsx(Ct,{children:s.jsx("p",{className:"text-[13px]",children:a("确定卸载「{name}」吗?卸载后这个包里的提供商将无法转发,也无法添加账号。账号数据本身不会被删除,重新安装后可以继续使用。",{name:j?yb(j.id,j.name):""})})}),s.jsxs(Pt,{children:[s.jsx("span",{className:"flex-1"}),s.jsx(B,{variant:"outline",onClick:()=>w(null),children:a("取消")}),s.jsx(B,{variant:"destructive",disabled:Q,onClick:()=>{const ee=j;w(null),ee&&z(`remove:${ee.id}`,"/api/plugins/uninstall",{id:ee.id})},children:a("卸载")})]})]})})]})}const B8='.page[data-page="plugins"]';let F8=!1,ZS=null;function U8(){if(F8)return;const e=document.querySelector(B8);e&&(F8=!0,e.replaceChildren(),wn.createRoot(e).render(s.jsx(bAe,{})))}document.querySelector(B8)?U8():document.addEventListener("DOMContentLoaded",U8,{once:!0}),window.wbPluginsPage={async load(){await ZS?.()}};function ZP(e,t){return[...new Set(e.usedByServices||[])].filter(n=>n==="update").map(()=>t("软件 / 插件更新"))}function Ma(){return window}function Xr(e,t){Ma().wbApp?.toast?.(e,t)}function ol(e){return e instanceof Error?e.message:String(e)}function yAe(e){return Ma().wbApp?.formatTime?.(e)||""}function JP(e){const t=Number(e);return!Number.isFinite(t)||t<0?"":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function $b(e){return e.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]||t)}function rg(e){return String(e?.name||e?.id||"")}let Ur={data:null,loading:!1,syncing:!1,error:"",testing:null,pending:new Set,batchBusy:!1,batchProgress:null,selected:new Set};const eI=new Set;function wAe(e){return eI.add(e),()=>{eI.delete(e)}}function jAe(){return Ur}function as(e){Ur={...Ur,...e},eI.forEach(t=>t())}function tI(){return Ur.data?.items??[]}function H8(e){return Ur.selected.has(e)}function SAe(e,t){const n=new Set(Ur.selected);t?n.add(e):n.delete(e),as({selected:n})}function kAe(e,t){const n=new Set(Ur.selected);for(const r of e)t?n.add(r):n.delete(r);as({selected:n})}function NAe(){as({selected:new Set})}function Ed(e){if(!e||typeof e!="object"||!Array.isArray(e.items))return;const t=new Set(e.items.map(r=>r.id)),n=new Set([...Ur.selected].filter(r=>t.has(r)));as({data:{...Ur.data,...e},error:"",selected:n}),JU(e.items)}async function nI(e=!1){const t=Ma().workbuddyDesktop;if(typeof t?.getProxyPool!="function"){as({error:a("当前环境不支持代理池(桥接方法缺失)")});return}e||as({loading:!0});try{const n=await t.getProxyPool();if(!n||!Array.isArray(n.items))throw new Error(a("代理列表响应异常"));Ed(n)}catch(n){as({error:ol(n)}),e||Xr(a("代理列表加载失败:{reason}",{reason:ol(n)}),"err")}finally{as({loading:!1})}}async function CAe(){const e=Ma().workbuddyDesktop;if(typeof e?.syncClashToProxyPool!="function"){Xr(a("当前环境不支持同步(桥接方法缺失)"),"err");return}if(!(Ur.syncing||Ur.batchBusy||Ur.testing||Ur.pending.size)){as({syncing:!0});try{const t=await e.syncClashToProxyPool();if(!t||!Array.isArray(t.items))throw new Error(a("代理列表响应异常"));Ed(t),t.syncError?Xr(a("没能同步:{reason}",{reason:t.syncError}),"err"):Xr(t.changes?a("✅ 已同步 Clash Verge 出口({n} 项变更)",{n:t.changes}):a("已是最新,没有需要同步的变更"),"ok")}catch(t){Xr(a("同步失败:{reason}",{reason:ol(t)}),"err")}finally{as({syncing:!1})}}}async function AAe(e){const t=Ma().workbuddyDesktop;if(typeof t?.testProxyPoolItem!="function"){Xr(a("当前环境不支持代理测试(桥接方法缺失)"),"err");return}if(!Ur.testing){as({testing:e.id});try{const n=await t.testProxyPoolItem(e.id);if(n?.items&&Ed({items:n.items}),n?.success){const r=JP(n.durationMs);Xr(a("✅ 「{name}」出口可用{ip}{took}",{name:rg(e),ip:n.ip?a(" 出口 IP {ip}",{ip:n.ip}):"",took:r?` ${r}`:""}))}else Xr(a("❌ 「{name}」{error}",{name:rg(e),error:n?.error||a("连接失败")}),"err");n?.saveError&&Xr(a("测试结果没能记下:{reason}",{reason:n.saveError}),"err")}catch(n){Xr(a("测试失败:{reason}",{reason:ol(n)}),"err")}finally{as({testing:null})}}}async function EAe(e,t){const n=Ma().workbuddyDesktop;if(typeof n?.setProxyPoolItemEnabled!="function"){Xr(a("当前环境不支持启停(桥接方法缺失)"),"err");return}const r=new Set(Ur.pending);r.add(e.id),as({pending:r});try{const i=await n.setProxyPoolItemEnabled({id:e.id,enabled:t});Ed(i);const o=rg(e);Xr(t?a("已启用「{name}」",{name:o}):a("已禁用「{name}」",{name:o}))}catch(i){Xr(a("保存失败:{reason}",{reason:ol(i)}),"err")}finally{const i=new Set(Ur.pending);i.delete(e.id),as({pending:i})}}async function TAe(e){if(e.source==="clash"){Xr(a("只读:在 Clash Verge 里改"),"err");return}const t=Ma().workbuddyDesktop;if(typeof t?.removeProxyPoolItem!="function")return;const n=e.usedBy||[],r=n.length?`${a("有 {n} 个账号正在使用它({names})—— 删除后这些账号会回退直连。",{n:n.length,names:n.map(f=>$b(String(f.name||f.id||""))).join(a("、"))})}
`:"",i=ZP(e,a),o=i.length?`${a("此代理用于{services};删除后这些线路将不可用,不会自动回退直连。",{services:i.map($b).join(a("、"))})}
`:"";if(!await Ma().wbConfirm?.ask?.({title:a("删除代理"),html:a("确定删除「{name}」?{used}",{name:$b(rg(e)),used:r+o}),okText:a("删除"),okClass:"danger"}))return;const d=new Set(Ur.pending);d.add(e.id),as({pending:d});try{const f=await t.removeProxyPoolItem(e.id);Ed(f),Xr(a("已删除「{name}」",{name:rg(e)}))}catch(f){Xr(a("删除失败:{reason}",{reason:ol(f)}),"err")}finally{const f=new Set(Ur.pending);f.delete(e.id),as({pending:f})}}async function OAe(){const e=Ma().workbuddyDesktop;if(typeof e?.testProxyPoolItem!="function"){Xr(a("当前环境不支持代理测试(桥接方法缺失)"),"err");return}if(Ur.batchBusy||Ur.testing)return;const t=tI().filter(c=>Ur.selected.has(c.id));if(!t.length)return;as({batchBusy:!0,batchProgress:{done:0,total:t.length}});let n=0,r=0,i="";for(const[c,d]of t.entries()){as({testing:d.id,batchProgress:{done:c,total:t.length}});try{const f=await e.testProxyPoolItem(d.id);f?.items&&Ed({items:f.items}),f?.success?n+=1:r+=1,f?.saveError&&!i&&(i=f.saveError)}catch{r+=1}}as({testing:null,batchBusy:!1,batchProgress:null});const o=r?a("批量测试完成:{ok} 个可用、{failed} 个失败(共 {total} 个)",{ok:n,failed:r,total:t.length}):a("批量测试完成:{ok} 个可用(共 {total} 个)",{ok:n,total:t.length});Xr(r?o:`✅ ${o}`,r?"err":"ok"),i&&Xr(a("部分测试结果没能记下:{reason}",{reason:i}),"err")}async function RAe(){const e=Ma().workbuddyDesktop;if(typeof e?.removeProxyPoolItem!="function"||Ur.batchBusy||Ur.testing)return;const t=tI().filter(S=>Ur.selected.has(S.id)),n=t.filter(S=>S.source!=="clash"),r=t.length-n.length;if(!n.length){r&&Xr(a("选中的 {n} 条都来自 Clash Verge 同步,不能删除(请到 Clash Verge 里删)",{n:r}),"err");return}const i=n.slice(0,8).map(S=>$b(rg(S))).join(a("、")),o=n.length>8?a("{names} 等 {n} 条",{names:i,n:n.length}):i,c=n.filter(S=>(S.usedBy||[]).length).length,d=c?`${a("其中 {n} 条正被账号使用 —— 删除后那些账号会回退直连。",{n:c})}
`:"",f=[...new Set(n.flatMap(S=>ZP(S,a)))],h=f.length?`${a("选中的代理用于{services};删除后这些线路将不可用,不会自动回退直连。",{services:f.map($b).join(a("、"))})}
`:"",p=r?`${a("另有 {n} 条来自 Clash Verge 同步,将跳过(请到 Clash Verge 里删)。",{n:r})}
`:"";if(!await Ma().wbConfirm?.ask?.({title:a("批量删除代理"),html:`${a("确定删除选中的 {n} 个代理?",{n:n.length})}${o}
${d}${h}${p}`,okText:a("删除"),okClass:"danger"}))return;as({batchBusy:!0,batchProgress:{done:0,total:n.length}});let x=0,y=0,j="";for(const[S,N]of n.entries()){as({batchProgress:{done:S,total:n.length}});try{const A=await e.removeProxyPoolItem(N.id);Ed(A),x+=1}catch(A){y+=1,j||(j=ol(A))}}as({batchBusy:!1,batchProgress:null});const w=[a("已删除 {n} 个代理",{n:x})];r&&w.push(a("跳过 {n} 个(Clash 同步)",{n:r})),y&&w.push(a("失败 {n} 个({reason})",{n:y,reason:j})),Xr(y?w.join(a(",")):`✅ ${w.join(a(","))}`,y?"err":"ok")}async function PAe(e,t){const n=Ma().workbuddyDesktop,r=e?{...t,id:e.id}:t,i=e?await n?.updateProxyPoolItem?.(r):await n?.createProxyPoolItem?.(r);if(!i||!Array.isArray(i.items))throw new Error(a("代理列表响应异常"));return Ed(i),i}async function IAe(){const e=Ma().workbuddyDesktop;if(typeof e?.getProxySettings!="function")throw new Error(a("当前环境不支持代理设置(桥接方法缺失)"));const t=await e.getProxySettings();if(!t||typeof t!="object")throw new Error(a("代理设置响应异常"));return t}async function MAe(e){const t=Ma().workbuddyDesktop;if(typeof t?.saveProxySettings!="function")throw new Error(a("当前环境不支持代理设置(桥接方法缺失)"));const n=await t.saveProxySettings(e);if(!n||typeof n!="object")throw new Error(a("代理设置响应异常"));return n}const V8="https://proxylane.dev/zh-cn/isp-proxies?utm_source=agent2api&utm_medium=partnership&utm_campaign=agent2api_202610&utm_content=client";function K8({children:e}){return s.jsx("a",{className:"font-semibold text-primary-fg no-underline hover:underline",href:V8,"data-external":V8,onClick:zb,children:e})}function _Ae({item:e,onClose:t}){const n=e!==null,[r,i]=v.useState(e?.name||""),[o,c]=v.useState(e?.protocol==="socks5"?"socks5":"http"),[d,f]=v.useState(e?.host||""),[h,p]=v.useState(e?.port?String(e.port):""),[g,x]=v.useState(e?.username||""),[y,j]=v.useState(e?.password||""),[w,S]=v.useState(e?e.enabled:!0),[N,A]=v.useState(!!(e?.username||e?.password)),[E,O]=v.useState(!1),[R,T]=v.useState(!1),[P,M]=v.useState(null);function _(){const D=r.trim();if(!D)return{error:a("请填写代理名称")};const z=d.trim();if(!z)return{error:a("请填写代理主机地址")};const G=Number(h);return!Number.isInteger(G)||G<1||G>65535?{error:a("代理端口必须是 1-65535 的整数")}:{payload:{name:D,source:"manual",protocol:o,host:z,port:G,username:N?g.trim():"",password:N?y:"",enabled:w}}}async function I(){if(R)return;const D=_();if("error"in D){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",D.error]}));return}const z=D.payload,G={source:"custom",protocol:z.protocol,host:z.host,port:z.port,username:z.username,password:z.password};T(!0),M(a("正在连接上游…"));try{const X=await Ma().workbuddyDesktop?.testProxy?.({proxy:G});if(X?.success){const Y=JP(X.durationMs);M(s.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),X.ip?a(" 出口 IP {ip}",{ip:X.ip}):"",Y?` ${Y}`:""]}))}else M(s.jsxs("span",{className:"text-destructive",children:["❌ ",X?.error||a("连接失败")]}))}catch(X){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",ol(X)]}))}finally{T(!1)}}async function L(){if(E)return;const D=_();if("error"in D){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",D.error]}));return}O(!0),M(null);try{await PAe(e,D.payload),Xr(n?a("已保存「{name}」",{name:r.trim()}):a("已新增「{name}」",{name:r.trim()})),t()}catch(z){M(s.jsxs("span",{className:"text-destructive",children:["❌ ",ol(z)]})),O(!1)}}return s.jsx(St,{open:!0,onOpenChange:D=>{!D&&!E&&t()},children:s.jsxs(kt,{className:"max-w-[560px]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a(n?"编辑代理":"新增代理")})}),s.jsxs(Ct,{className:"flex flex-col gap-3.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-name",children:a("名称")}),s.jsx(Be,{id:"proxy-name",maxLength:60,autoComplete:"off",spellCheck:!1,placeholder:a("例如:香港 HTTP 出口"),value:r,onChange:D=>i(D.currentTarget.value)})]}),s.jsxs("div",{className:"flex flex-row items-end gap-2.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-protocol",children:a("协议")}),s.jsxs(ht,{value:o,onValueChange:D=>c(D),children:[s.jsx(mt,{id:"proxy-protocol",className:"min-w-[110px]",children:s.jsx(pt,{children:o==="socks5"?"SOCKS5":"HTTP"})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"http",children:"HTTP"}),s.jsx(qe,{value:"socks5",children:"SOCKS5"})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-host",children:a("主机")}),s.jsx(Be,{id:"proxy-host",placeholder:"127.0.0.1",autoComplete:"off",spellCheck:!1,value:d,onChange:D=>f(D.currentTarget.value)})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-port",children:a("端口")}),s.jsx(Be,{id:"proxy-port",type:"number",min:1,max:65535,className:"max-w-[110px]",placeholder:"7890",value:h,onChange:D=>p(D.currentTarget.value)})]})]}),s.jsx("p",{className:"text-xs leading-[1.8] text-subtle",children:a("地址由网关所在设备访问;本机代理需运行在该设备上。")}),s.jsxs(Ie,{className:"flex cursor-pointer items-center gap-2 text-xs font-normal",children:[s.jsx(Wr,{checked:N,onCheckedChange:D=>A(D===!0)}),a("需要用户名和密码(可选)")]}),N?s.jsxs("div",{className:"flex flex-row items-end gap-2.5",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-user",children:a("用户名")}),s.jsx(Be,{id:"proxy-user",placeholder:a("可选"),autoComplete:"off",value:g,onChange:D=>x(D.currentTarget.value)})]}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-pass",children:a("密码")}),s.jsx(Be,{id:"proxy-pass",type:"password",placeholder:a("可选"),autoComplete:"new-password",value:y,onChange:D=>j(D.currentTarget.value)})]})]}):null,s.jsxs("div",{className:"flex flex-row items-center gap-2.5",children:[s.jsx(cn,{checked:w,onCheckedChange:S,"aria-label":a("启用这条代理")}),s.jsx("span",{className:"text-[12.5px]",children:a("启用(禁用的条目不会被账号使用,被引用时账号回退直连;仍可测试)")})]}),s.jsxs("p",{className:"text-xs leading-[1.65] text-subtle",children:[a("需要干净的出口?"),s.jsx(K8,{children:"ProxyLane"}),a(" AI 账号专用静态住宅 IP:Scamalytics 低欺诈评分,不限流量,首单 75 折(AGENT2API25)")," ",s.jsx(K8,{children:a("去获取")})]}),s.jsx("div",{className:"min-h-[18px] text-xs text-subtle",children:P})]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"outline",disabled:R||E,onClick:()=>{I()},children:a(R?"测试中…":"测试出口")}),s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:E,onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:E,onClick:()=>{L()},children:a(E?"保存中…":"保存")})]})]})})}function DAe({onClose:e}){const[t,n]=v.useState(!0),[r,i]=v.useState(!1),[o,c]=v.useState(""),[d,f]=v.useState(""),[h,p]=v.useState("");v.useEffect(()=>{let x=!0;return IAe().then(y=>{if(x){if(!y)throw new Error(a("代理设置响应异常"));c(y.testUrl||""),f(y.defaults?.testUrl||"")}}).catch(y=>{x&&p(ol(y))}).finally(()=>{x&&n(!1)}),()=>{x=!1}},[]);async function g(){if(r||t)return;const x=o.trim();if(x&&!/^https?:\/\//i.test(x)){p(a("测试网址要以 http:// 或 https:// 开头"));return}i(!0),p("");try{await MAe({testUrl:x}),Xr(a("✅ 连通性测试设置已保存")),e()}catch(y){p(ol(y))}finally{i(!1)}}return s.jsx(St,{open:!0,onOpenChange:x=>{!x&&!r&&e()},children:s.jsxs(kt,{className:"max-w-[500px]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("连通性测试设置")})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Ie,{htmlFor:"proxy-settings-url",children:a("测试目标网址")}),s.jsx(Be,{id:"proxy-settings-url",value:o,placeholder:d,autoComplete:"off",spellCheck:!1,disabled:t||r,className:"font-mono text-xs",onChange:x=>c(x.currentTarget.value)})]}),s.jsx("p",{className:"text-xs leading-[1.8] text-subtle",children:a("通过代理访问该网址,检查是否能收到 HTTP 响应。留空沿用网关默认值。")}),t?s.jsx("p",{className:"text-xs text-subtle",children:a("加载中…")}):null,h?s.jsxs("p",{className:"text-xs text-destructive",children:["❌ ",h]}):null]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"ghost",className:"mr-auto",disabled:t||r,onClick:()=>{c(""),p("")},children:a("恢复默认")}),s.jsx(B,{variant:"outline",disabled:r,onClick:e,children:a("取消")}),s.jsx(B,{disabled:t||r,onClick:()=>{g()},children:a(r?"保存中…":"保存设置")})]})]})})}const rI=[{key:"pick",label:a("选择"),align:"center"},{key:"name",label:a("代理名称")},{key:"addr",label:a("地址")},{key:"usage",label:a("使用情况")},{key:"state",label:a("启用"),align:"center"},{key:"test",label:a("最近检测")},{key:"act",label:a("操作"),align:"right"}],LAe={pick:"p-pick",name:"",addr:"p-addr",usage:"p-usage",state:"p-state",test:"p-test",act:"p-act"},q8="proxies";function sI(){return window}let JS=null,G8=null;function Y8(){return JS?JS.apply([...rI]):rI.map(e=>({...e,align:e.align??"left"}))}function zAe(){sI().wbTableColumns?.repaint?.(q8)}function $Ae(e){if(G8=e,JS)return!0;const t=sI().wbColSettings;return t?.register?(JS=t.register({id:q8,label:a("代理池表"),columns:rI.map(n=>({key:n.key,label:n.label,align:n.align??"left"})),mount:()=>document.querySelector('.page[data-page="proxies"] .panel-head .head-actions'),buttonPlacement:"last",onChange:()=>G8?.()}),!0):!1}function BAe(){sI().wbColSettings?.close?.()}const W8="agent2api:proxy-subscription-retired:v1";function FAe(e=""){try{return localStorage.getItem(`${W8}:${e}`)!=="acknowledged"}catch{return!0}}function UAe(e=""){try{localStorage.setItem(`${W8}:${e}`,"acknowledged")}catch{}}function HAe({open:e,onClose:t,t:n,scope:r=""}){const[i,o]=v.useState(!1),c=v.useId();v.useEffect(()=>{e&&o(!1)},[e]);function d(){i&&UAe(r),t()}return s.jsx(St,{open:e,disablePointerDismissal:!0,onOpenChange:f=>{f||t()},children:s.jsxs(kt,{className:"max-w-[540px]",children:[s.jsxs(Ct,{className:"gap-0 px-7 pt-7 pb-6 max-sm:px-5",children:[s.jsx("div",{className:"mb-5 grid size-11 place-items-center rounded-md border border-primary-bd bg-primary-soft text-primary",children:s.jsxs("svg",{width:"23",height:"23",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 11v5m0-9h.01",strokeLinecap:"round"})]})}),s.jsx("span",{className:"text-[11px] tracking-wide text-muted-foreground",children:n("功能调整通知")}),s.jsx(jt,{className:"mt-1.5 text-[22px] font-semibold leading-snug max-sm:text-xl",children:n("代理订阅功能已下线")}),s.jsx(bT,{className:"mt-3 text-xs leading-[1.9] text-subtle",children:n("为降低维护成本、资源占用及合规风险,Agent2API 已停止提供代理订阅与内置代理内核相关功能。")}),s.jsxs("div",{className:"mt-5 divide-y divide-border overflow-hidden rounded-md border border-border bg-surface-2",children:[s.jsx(X8,{retained:!1,title:n("不再提供"),children:n("订阅导入与更新、订阅节点管理,以及代理内核的下载、安装和运行。")}),s.jsx(X8,{retained:!0,title:n("手动代理与 Clash Verge 同步仍然保留"),children:n("已有手动配置和 Clash Verge 端点引用不受影响。仍可添加 HTTP / SOCKS5 地址、同步 Clash Verge 端点并测试连通性;Clash Verge 由你自行安装和运行。")})]}),s.jsxs("div",{className:"mt-5 text-xs leading-[1.85]",children:[s.jsx("strong",{className:"font-semibold",children:n("之前使用订阅节点?")}),s.jsx("p",{className:"mt-1.5 text-muted-foreground",children:n("请填写已有代理服务的 HTTP / SOCKS5 地址,或自行运行 Clash Verge 后同步端点,并重新为相关账号和服务线路选择代理。")})]})]}),s.jsxs(Pt,{className:"justify-between px-7 max-sm:px-5",children:[s.jsxs(Ie,{htmlFor:c,className:"inline-flex cursor-pointer items-center gap-2 text-xs font-normal text-subtle",children:[s.jsx(Wr,{id:c,checked:i,onCheckedChange:f=>o(f===!0)}),n("不再提醒")]}),s.jsx(B,{onClick:d,children:n("我知道了")})]})]})})}function X8({retained:e,title:t,children:n}){return s.jsxs("div",{className:"flex items-start gap-3 p-4",children:[s.jsx("span",{className:`mt-0.5 grid size-[22px] shrink-0 place-items-center rounded-full ${e?"bg-success-soft text-success":"bg-border text-subtle"}`,children:s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:s.jsx("path",{d:e?"m5 12 4 4L19 6":"m6 6 12 12M6 18 18 6"})})}),s.jsxs("div",{children:[s.jsx("strong",{className:"text-xs font-semibold",children:t}),s.jsx("p",{className:"mt-1 text-xs leading-[1.85] text-subtle",children:n})]})]})}let Q8=0;const aI=new Set;function Z8(){FAe()&&(Q8+=1,aI.forEach(e=>e()))}function VAe(){const e=v.useSyncExternalStore(wAe,jAe),t=v.useSyncExternalStore(K=>(aI.add(K),()=>{aI.delete(K)}),()=>Q8),[n,r]=v.useState(!1),[i,o]=v.useState(null),[c,d]=v.useState(!1),[f,h]=v.useState(!1),[p,g]=v.useState(""),[x,y]=v.useState("all"),[j,w]=v.useState("all"),[S,N]=v.useState(0),[,A]=v.useReducer(K=>K+1,0),E=tI(),O=e.data!==null,R=e.selected.size,T=e.batchProgress,P=e.syncing||e.batchBusy||e.testing!==null||e.pending.size>0,M=Y8(),_=p.trim().toLowerCase(),I=E.filter(K=>(x==="all"||(K.resolved?.protocol||K.protocol)===x)&&(j==="all"||Bb(K)===j)&&(!_||[K.name,GT(K),K.host,K.protocol,K.port].join(" ").toLowerCase().includes(_))),L=I.map(K=>K.id),D=L.length>0&&L.every(K=>e.selected.has(K)),z=L.some(K=>e.selected.has(K))&&!D,G=qx(I.length,"proxies"),X=G.paged?G.slice(I):I;v.useEffect(()=>{t>0&&r(!0)},[t]),v.useEffect(()=>{G.goto(1)},[_,x,j]),v.useLayoutEffect(()=>{if(!$Ae(()=>A())){const K=window.setTimeout(()=>N(U=>U+1),50);return()=>window.clearTimeout(K)}A()},[S]),v.useLayoutEffect(()=>{zAe()}),v.useEffect(()=>()=>{BAe()},[]);function Y(){g(""),y("all"),w("all")}function F(K,U){switch(K){case"pick":return s.jsx(Wr,{checked:H8(U.id),disabled:P,"aria-label":a("勾选「{name}」",{name:U.name||a("未命名")}),onCheckedChange:q=>SAe(U.id,q)});case"name":return s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("b",{children:U.name||a("未命名")}),s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-subtle",children:[s.jsx(ye,{variant:"outline",shape:"tag",className:"font-mono text-[10px]",children:(U.resolved?.protocol||U.protocol||"http").toUpperCase()}),U.source==="clash"?s.jsx(ye,{variant:"secondary",shape:"tag",className:"text-[10px]",children:"Clash Verge"}):null,U.enabled===!1?a("已禁用"):null]})]});case"addr":{const q=GT(U);return s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-xs leading-[1.5] text-text-2",title:U.resolveError||q,children:q||a("地址不完整")}),q?s.jsx(B,{variant:"ghost",size:"icon-xs",className:"copy-btn shrink-0","data-copy":q,title:a("复制地址"),children:"⧉"}):null]})}case"usage":{const q=ZP(U,a);return s.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-subtle",children:[U.usedBy?.length?s.jsx("span",{title:U.usedBy.map(W=>W.name||W.id).join(a("、")),children:a("{n} 个账号在用",{n:U.usedBy.length})}):null,q.map(W=>s.jsx("span",{children:W},W)),!U.usedBy?.length&&!q.length?a("暂未使用"):null]})}case"state":return s.jsx(cn,{checked:U.enabled!==!1,disabled:P||U.source==="clash"&&U.sourceEnabled===!1,title:U.source==="clash"?U.sourceEnabled===!1?a("这条在 Clash Verge 里是停用的,本页启用不生效 —— 到 Clash Verge 里打开它"):a("禁用后本端不再用它(引用它的账号回退直连);端口在 Clash Verge 侧,不受影响"):void 0,"aria-label":a("启用「{name}」",{name:U.name||a("未命名")}),onCheckedChange:q=>{EAe(U,q)}});case"test":{if(e.testing===U.id)return s.jsx("span",{className:"text-subtle",children:a("测试中…")});const q=U.lastTest;return q?.at?s.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 text-xs leading-[1.5]",children:[s.jsxs("span",{className:q.success?"text-success":"text-destructive",children:[q.success?a("✅ 连接成功"):a("❌ 连接失败")," ",JP(q.durationMs)]}),s.jsx("span",{className:"truncate text-[10px] text-subtle",title:q.error||void 0,children:q.success?q.ip||"":q.error||a("连接失败")}),s.jsx("span",{className:"text-[10px] text-subtle",children:yAe(q.at)})]}):s.jsx("span",{className:"text-subtle",children:a("未检测")})}case"act":return s.jsxs("div",{className:"row-actions",children:[s.jsx(B,{size:"sm",variant:"ghost",disabled:P,onClick:()=>{AAe(U)},children:a("测试")}),U.source==="clash"?s.jsx("span",{className:"text-[10px] text-subtle",title:a("名字与端口在 Clash Verge 里改;启用可在本页关闭"),children:a("只读:在 Clash Verge 里改")}):s.jsxs(s.Fragment,{children:[s.jsx(B,{size:"sm",variant:"ghost",disabled:P,onClick:()=>o({item:U}),children:a("编辑")}),s.jsx(B,{size:"sm",variant:"ghost",className:"text-destructive",disabled:P,onClick:()=>{TAe(U)},children:a("删除")})]})]});default:return null}}return s.jsxs(s.Fragment,{children:[s.jsxs(tt,{render:s.jsx("section",{}),className:"panel",children:[s.jsxs(fn,{className:"panel-head",children:[s.jsx("h2",{children:a("代理列表")}),s.jsx(ye,{variant:"secondary",shape:"tag",children:E.length}),s.jsx("span",{className:"panel-sub",children:O?a("已启用 {n} 个",{n:E.filter(K=>K.enabled!==!1).length}):a("加载中…")}),s.jsxs("div",{className:"head-actions",children:[s.jsx(B,{disabled:P,onClick:()=>o({item:null}),children:a("+ 新增代理")}),s.jsx(B,{variant:"ghost",className:"hidden max-[767px]:inline-flex",onClick:()=>h(!0),children:a("筛选")}),s.jsx(B,{variant:"outline",disabled:P,onClick:()=>{CAe()},children:e.syncing?a("同步中…"):a("同步 Clash Verge")}),s.jsx(B,{variant:"outline",disabled:P,onClick:()=>d(!0),children:a("测试设置")}),s.jsx(B,{variant:"outline",disabled:e.loading||P,onClick:()=>{nI()},children:e.loading?a("刷新中…"):a("刷新")})]})]}),R?s.jsxs("div",{className:"batch-bar active",children:[s.jsxs("span",{className:"batch-count",children:[a("已选")," ",s.jsx("b",{children:R})," ",a("个")]}),s.jsxs("div",{className:"batch-actions",children:[s.jsx(B,{variant:"outline",disabled:P,onClick:()=>{OAe()},children:T?a("测试中 {done}/{total}",{done:T.done,total:T.total}):a("批量测试")}),s.jsx(B,{variant:"destructive",disabled:P,onClick:()=>{RAe()},children:a("批量删除")}),s.jsx(B,{variant:"outline",disabled:P,onClick:NAe,children:a("取消选择")})]})]}):s.jsxs(w0,{open:f,onOpenChange:h,title:a("筛选"),inlineClassName:"flex flex-wrap items-center gap-2.5 border-b border-border px-4 py-3",bodyClassName:"proxy-filter-body",actions:s.jsx(B,{variant:"ghost",size:"sm",onClick:Y,children:a("清空")}),children:[s.jsxs(uo,{className:"w-[clamp(150px,22vw,240px)]",children:[s.jsx(ho,{type:"search",value:p,"aria-label":a("搜索代理"),placeholder:a("搜索名称 / 地址 / 端口"),onChange:K=>g(K.currentTarget.value)}),s.jsx(fo,{align:"inline-start","aria-hidden":"true",children:s.jsx(qAe,{})})]}),s.jsxs(ht,{value:x,onValueChange:K=>y(K||"all"),children:[s.jsx(mt,{className:"w-[120px]","aria-label":a("按协议筛选"),children:s.jsx(pt,{children:x==="all"?a("全部协议"):x.toUpperCase()})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"all",children:a("全部协议")}),s.jsx(qe,{value:"http",children:"HTTP"}),s.jsx(qe,{value:"socks5",children:"SOCKS5"})]})]}),s.jsx(dn,{className:"ml-auto",options:KAe(E),value:j,onValueChange:w,"aria-label":a("按状态筛选")})]}),s.jsx("div",{className:"models-table-wrap",children:s.jsxs(ea,{container:!1,className:"models-table proxies-table",children:[s.jsx("colgroup",{children:M.map(K=>s.jsx("col",{"data-col":K.key,className:LAe[K.key]||void 0},K.key))}),s.jsx(Ta,{children:s.jsx(en,{children:M.map(K=>s.jsx(ft,{"data-col":K.key,className:`ta-${K.align}`,children:K.key==="pick"?s.jsx(Wr,{checked:D,indeterminate:z,disabled:!L.length||P,"aria-label":a("全选当前筛选出的出口"),onCheckedChange:U=>kAe(L,U)}):K.label},K.key))})}),s.jsx(ga,{children:X.length?X.map(K=>s.jsx(en,{"data-id":K.id,className:Te(K.enabled===!1&&"off",H8(K.id)&&"bg-primary-soft"),children:M.map(U=>s.jsx(Xe,{className:`ta-${U.align}`,children:F(U.key,K)},U.key))},K.id)):s.jsx(en,{children:s.jsx(Xe,{colSpan:M.length,className:"empty",children:O?E.length?s.jsxs("div",{className:"flex flex-col items-center gap-3 py-5",children:[s.jsx("span",{children:a("没有匹配当前筛选的出口")}),s.jsx(B,{variant:"outline",size:"sm",onClick:Y,children:a("清空筛选")})]}):s.jsxs("div",{className:"flex flex-col items-center gap-3 py-8",children:[s.jsx("b",{className:"text-sm text-foreground",children:a("还没有保存的代理")}),s.jsx("p",{className:"text-xs text-subtle",children:a("添加手动 HTTP / SOCKS5 地址,或同步 Clash Verge 的端点,供账号与服务线路使用。")}),s.jsx(B,{onClick:()=>o({item:null}),children:a("添加第一个代理")})]}):e.error||a("加载中…")})})})]})}),s.jsx(fd,{leading:e.error?s.jsx("span",{className:"text-destructive",children:a("读取失败:{reason}",{reason:e.error})}):void 0,total:I.length,page:G.page,pageCount:G.pageCount,size:G.size,onSizeChange:G.setSize,onPageChange:G.goto,range:G.paged?{start:G.rangeStart,end:G.rangeEnd}:null})]}),i?s.jsx(_Ae,{item:i.item,onClose:()=>o(null)}):null,c?s.jsx(DAe,{onClose:()=>d(!1)}):null,s.jsx(HAe,{open:n,onClose:()=>r(!1),t:a})]})}function Bb(e){return e.enabled===!1?"off":e.lastTest?.at?e.lastTest.success?"ok":"fail":"none"}function KAe(e){return[{value:"all",label:a("全部"),count:e.length},{value:"ok",label:a("可用"),count:e.filter(t=>Bb(t)==="ok").length},{value:"fail",label:a("失败"),count:e.filter(t=>Bb(t)==="fail").length},{value:"none",label:a("未检测"),count:e.filter(t=>Bb(t)==="none").length},{value:"off",label:a("已禁用"),count:e.filter(t=>Bb(t)==="off").length}]}function qAe(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]})}window.wbProxiesPanel={load:()=>nI(),activate:Z8,visibleColumns:()=>Y8().map(e=>({key:e.key}))};const J8='.page[data-page="proxies"]';function eG(){const e=document.querySelector(J8);!e||e.dataset.mounted==="1"||(e.dataset.mounted="1",e.replaceChildren(),wn.createRoot(e).render(s.jsx(VAe,{})),Ma().wbApp?.currentPage==="proxies"&&(Z8(),nI()))}document.querySelector(J8)?eG():document.addEventListener("DOMContentLoaded",eG,{once:!0});const ek=YK,iI="7",tk="custom",tG="workbuddy-desktop-report-range",nG="workbuddy-desktop-report-custom-range",rG={today:a("今天"),yesterday:a("昨天"),7:a("近 7 天"),30:a("近 30 天"),month:a("本月"),all:a("全部"),custom:a("自定义区间")},GAe={today:a("今天"),yesterday:a("昨天"),7:a("7 天"),30:a("30 天"),month:a("本月"),all:a("全部"),custom:a("自定义")};function YAe(){try{const e=localStorage.getItem(tG);return e!==null&&ek.includes(e)?e:iI}catch{return iI}}function WAe(){return xb(nG)}function XAe(e){IS(nG,e)}const QAe=[[0,a("一")],[2,a("三")],[4,a("五")]];function oI(){return window.wbUnits||{}}function Bs(e){const t=oI();return t.formatInt?t.formatInt(e):(Number(e)||0).toLocaleString("zh-CN")}function Ns(e){const t=oI();return t.formatTokens?t.formatTokens(e):String(Number(e)||0)}function sG(e,t){const n=oI();return n.formatAxis?n.formatAxis(e,t):String(e)}function Ql(e){return`${((Number(e)||0)*100).toFixed(1)}%`}function nk(e){return Math.round(e*10)/10}function lI(e){return[...e].reduce((t,n)=>t+(/[\u2e80-\u9fff]/.test(n)?9.7:5.4),0)}function rk(e){const[t,n,r]=String(e||"").split("-").map(Number);return new Date(t||1970,(n||1)-1,r||1)}const ZAe=[a("日"),a("一"),a("二"),a("三"),a("四"),a("五"),a("六")];function sk(e){const t=rk(e);return a("{m}月{d}日 周{wd}",{m:t.getMonth()+1,d:t.getDate(),wd:ZAe[t.getDay()]})}function aG(e){const t=String(e||"").slice(11,13);return t?`${t}:00`:"—"}const JAe=[1,1.5,2,2.5,3,4,5,6,8,10];function eEe(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e)),n=e/t;return(JAe.find(i=>i>=n-1e-9)??10)*t}function tEe(e){return eEe(e/4)*4}function nEe(e,t,n){const r=e||{},i=r.topModel,o=Number(r.requests)||0,c=Number(r.successful)||0,d=o?`${(c/o*100).toFixed(1)}%`:"—",f=[{key:"tokens",label:a("总 Token"),value:Ns(r.tokens),sub:a("输入 + 输出"),mono:!1},{key:"successful",label:a("成功请求数"),value:Bs(c),sub:a("成功率 {rate}",{rate:d}),mono:!1},{key:"requests",label:a("总请求数"),value:Bs(o),sub:rG[t]||"",mono:!1},{key:"activeDays",label:a("活跃天数"),value:Bs(r.activeDays),sub:a("区间共 {n} 天",{n}),mono:!1},{key:"streak",label:a("当前连续天数"),value:Bs(r.streak),sub:a("含今天在内往前数"),mono:!1}];return f.push(i?{key:"topModel",label:a("Top 模型"),value:String(i.model??""),sub:a("{tokens} tokens · 占 {pct}",{tokens:Ns(i.tokens),pct:Ql(i.percentage)}),mono:!0}:{key:"topModel",label:a("Top 模型"),value:"—",sub:a("所选范围内还没有模型用量"),mono:!1}),f}function iG(e){if(!Array.isArray(e))return null;const t=e.map(i=>({id:String(i?.id??"").trim(),label:String(i?.label??"").trim(),tokens:Number(i?.totalTokens??i?.tokens)||0})).filter(i=>i.tokens>0);if(!t.length)return[];const n=t.reduce((i,o)=>i+o.tokens,0),r=i=>n?i/n*100:0;return[...t].sort((i,o)=>o.tokens-i.tokens).map((i,o)=>{const c=r(i.tokens),d=Ns(i.tokens),f=i.label||i.id||a("未知"),h=i.id?a("{name}({id})",{name:f,id:i.id}):f;return{key:`${o}-${i.id||f}`,id:i.id,name:f,full:h,tip:a("{name}:{tokens} tokens · 占 {pct}%",{name:h,tokens:d,pct:c.toFixed(1)}),tokensText:d,percentText:`${c.toFixed(1)}%`,barWidth:`${c.toFixed(1)}%`}})}function oG(e){return`${Ns(e.reduce((t,n)=>t+(Number(n?.totalTokens??n?.tokens)||0),0))} tokens`}const sg=["#f73b00","#f7bb07","#4aaa4d","#1872cb","#3444a3","#13c2c2","#722ed1","#eb2f96","#a0d911","#34d399","#d946ef","#ff85c0","#b37feb","#9d174d","#ffa39e","#69b1ff"],cI="#9aa0a6";function lG(e){return(Array.isArray(e)?e:[]).map(t=>({name:String(t?.label??t?.model??t?.id??"").trim(),tokens:Number(t?.totalTokens??t?.tokens)||0,requests:Number(t?.requests)||0})).filter(t=>Number.isFinite(t.tokens)&&t.tokens>0).sort((t,n)=>n.tokens-t.tokens)}function cG(e){const t=new Map;for(const n of lG(e))!n.name||t.has(n.name)||t.set(n.name,sg[t.size%sg.length]);return t}function uG(e,t){const n=lG(e);if(!n.length)return null;const r=n.reduce((c,d)=>c+d.tokens,0);if(!r)return null;const i=cG(e);return{size:220,data:n.map((c,d)=>{const f=c.name||t,h=c.tokens/r;return{key:`${d}-${f}`,name:f,fill:i.get(f)??sg[d%sg.length],tokens:c.tokens,requests:c.requests,percentage:h,tip:a("{name} · {tokens} tokens · {n} 次请求 · {pct}",{name:f,tokens:Ns(c.tokens),n:Bs(c.requests),pct:Ql(h)})}}),totalText:Ns(r)}}const rEe=[1,1.25,1.5,2,2.5,3,4,5,6,8,10];function sEe(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e)),n=e/t;let r=1;for(const i of rEe)i<=n+1e-9&&(r=i);return r*t}function aEe(e){const t=Number(e)||0;if(t<=0)return[0,1,2,3,1/0];const n=Math.max(1,sEe(t/4));return[0,n,n*2,n*3,1/0]}function iEe(e,t){if(e===0)return"0";const n=t[e-1],r=t[e];return Number.isFinite(r)?n===0?`≤${Ns(r)}`:`${Ns(n)}–${Ns(r)}`:`>${Ns(n)}`}function dG(e){const t=Array.isArray(e)?e:[];return aEe(t.reduce((n,r)=>Math.max(n,Number(r?.tokens)||0),0))}function oEe(e,t){const n=Array.isArray(e)?e:[];if(!n.length)return null;const r=(rk(n[0].date).getDay()+6)%7,i=new Array(r).fill(null).concat(n),o=Math.ceil(i.length/7),c=3,d=20,f=t-d,h=Math.floor((f-c*(o-1))/o),p=Math.max(7,Math.min(26,h)),g=p+3,x=p+c,y=d+o*x-c,j=Math.max(0,Math.round((t-y)/2)),w=g+7*x-c+2,S=Math.max(y,Math.round(t)),N=dG(n),A=M=>N.findIndex(_=>Number(M)<=_),E=[];for(let M=0;M({key:_,x:j+d-6,y:nk(g+M*x+p/2),text:_})),R=[];let T=-1,P=-9;for(let M=0;M({level:t,text:iEe(t,e)}))}function cEe(e){const t=e||{};return[["last10m",a("近 10 分钟")],["last1h",a("近 1 小时")],["last24h",a("近 24 小时")],["last7d",a("近 7 天")]].map(([r,i])=>{const o=t[r]||{},c=Number(o.inputTokens)||0;return{key:r,label:i,value:c?Ql(o.rate):"—",sub:a("命中 {hit} / 输入 {input}",{hit:Ns(o.hitTokens),input:Ns(c)})}})}function fG(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{var n=e.children,r=e.width,i=e.height,o=e.viewBox,c=e.className,d=e.style,f=e.title,h=e.desc,p=mEe(e,pEe),g=o||{width:r,height:i,x:0,y:0},x=cr("recharts-surface",c);return v.createElement("svg",dI({},Co(p),{className:x,width:r,height:i,style:d,viewBox:"".concat(g.x," ").concat(g.y," ").concat(g.width," ").concat(g.height),ref:t}),v.createElement("title",null,f),v.createElement("desc",null,h),n)}),vEe=["children","className"];function fI(){return fI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,i=xEe(e,vEe),o=cr("recharts-layer",r);return v.createElement("g",fI({className:o},Co(i),{ref:t}),n)});function hI(e){return e==="__proto__"}const yEe=Object.prototype.hasOwnProperty;function ag(e,t){return yEe.call(e,t)}const wEe=/\.|(\[(?:[^[\]]*|(["'])(?:(?!\2)[^\\]|\\.)*?\2)\])/;function gG(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e===""||e.startsWith(".")||e.endsWith(".")?!1:wEe.test(e);default:return!1}}function ak(e){var t;return typeof e=="string"||typeof e=="symbol"?e:Object.is(e==null||(t=e.valueOf)===null||t===void 0?void 0:t.call(e),-0)?"-0":String(e)}function pI(e){return typeof e=="symbol"||e instanceof Symbol}function vG(e){if(typeof e=="string")return e;if(Array.isArray(e)){let n="";for(let r=0;r0&&(n+=","),n+=vG(e[r]);return n}if(pI(e))return e.toString();const t=e+"";return t==="0"&&Object.is(Number(e),-0)?"-0":t}function jEe(e){return e==null?"":vG(e)}function mI(e){if(Array.isArray(e))return e.map(ak);if(typeof e=="symbol")return[e];e=jEe(e);const t=[],n=e.length;if(n===0)return t;let r=0,i="",o="",c=!1,d=!1;const f=/^-?\d+(?:\.\d+)?$/;for(e.charCodeAt(0)===46&&t.push("");r1&&arguments[1]!==void 0?arguments[1]:kEe,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function xa(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var d=n[c-1];return typeof d=="string"?i+d+o:d!==void 0?i+Zc(d)+o:i+o},"")}var ra=e=>e===0?0:e>0?1:-1,Jl=e=>typeof e=="number"&&e!=+e,kh=e=>typeof e=="string"&&e.length>1&&e.indexOf("%")===e.length-1,ot=e=>(typeof e=="number"||e instanceof Number)&&!Jl(e),ec=e=>ot(e)||typeof e=="string",NEe=0,Fb=e=>{var t=++NEe;return"".concat(e||"").concat(t)},_a=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!ot(t)&&typeof t!="string")return r;var o;if(kh(t)){if(n==null)return r;var c=t.indexOf("%");o=n*parseFloat(t.slice(0,c))/100}else o=+t;return Jl(o)&&(o=r),i&&n!=null&&o>n&&(o=n),o},xG=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):Zl(r,t))===n)}var Hr=e=>e===null||typeof e>"u",gI=e=>Hr(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function gi(e){return e!=null}function Nh(){}function vI(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function yG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tc(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,o=e.parentViewBox,c=vI(t),d=c.x,f=c.y,h=c.height,p=c.upperWidth,g=c.lowerWidth,x=d,y=d+(p-g)/2,j=(x+y)/2,w=(p+g)/2,S=x+p/2,N=h>=0?1:-1,A=N*i,E=N>0?"end":"start",O=N>0?"start":"end",R=p>=0?1:-1,T=R*i,P=R>0?"end":"start",M=R>0?"start":"end",_=o;if(n==="top"){var I={x:x+p/2,y:f-A,horizontalAnchor:"middle",verticalAnchor:E};return _&&(I.height=Math.max(f-_.y,0),I.width=p),I}if(n==="bottom"){var L={x:y+g/2,y:f+h+A,horizontalAnchor:"middle",verticalAnchor:O};return _&&(L.height=Math.max(_.y+_.height-(f+h),0),L.width=g),L}if(n==="left"){var D={x:j-T,y:f+h/2,horizontalAnchor:P,verticalAnchor:"middle"};return _&&(D.width=Math.max(D.x-_.x,0),D.height=h),D}if(n==="right"){var z={x:j+w+T,y:f+h/2,horizontalAnchor:M,verticalAnchor:"middle"};return _&&(z.width=Math.max(_.x+_.width-z.x,0),z.height=h),z}var G=_?{width:w,height:h}:{};return n==="insideLeft"?tc({x:j+T,y:f+h/2,horizontalAnchor:M,verticalAnchor:"middle"},G):n==="insideRight"?tc({x:j+w-T,y:f+h/2,horizontalAnchor:P,verticalAnchor:"middle"},G):n==="insideTop"?tc({x:x+p/2,y:f+A,horizontalAnchor:"middle",verticalAnchor:O},G):n==="insideBottom"?tc({x:y+g/2,y:f+h-A,horizontalAnchor:"middle",verticalAnchor:E},G):n==="insideTopLeft"?tc({x:x+T,y:f+A,horizontalAnchor:M,verticalAnchor:O},G):n==="insideTopRight"?tc({x:x+p-T,y:f+A,horizontalAnchor:P,verticalAnchor:O},G):n==="insideBottomLeft"?tc({x:y+T,y:f+h-A,horizontalAnchor:M,verticalAnchor:E},G):n==="insideBottomRight"?tc({x:y+g-T,y:f+h-A,horizontalAnchor:P,verticalAnchor:E},G):n&&typeof n=="object"&&(ot(n.x)||kh(n.x))&&(ot(n.y)||kh(n.y))?tc({x:d+_a(n.x,w),y:f+_a(n.y,h),horizontalAnchor:"end",verticalAnchor:"end"},G):tc({x:S,y:f+h/2,horizontalAnchor:"middle",verticalAnchor:"middle"},G)},OEe=["top","left","right","bottom"];function REe(e){return e==null?!1:typeof e=="object"?!0:OEe.includes(e)}var PEe=v.createContext(null);function os(e){return function(){return e}}const xI=Math.PI,bI=2*xI,Ch=1e-6,IEe=bI-Ch;function wG(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return wG;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;iCh)if(!(Math.abs(g*f-h*p)>Ch)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let y=r-c,j=i-d,w=f*f+h*h,S=y*y+j*j,N=Math.sqrt(w),A=Math.sqrt(x),E=o*Math.tan((xI-Math.acos((w+x-S)/(2*N*A)))/2),O=E/A,R=E/N;Math.abs(O-1)>Ch&&this._append`L${t+O*p},${n+O*g}`,this._append`A${o},${o},0,0,${+(g*y>p*j)},${this._x1=t+R*f},${this._y1=n+R*h}`}}arc(t,n,r,i,o,c){if(t=+t,n=+n,r=+r,c=!!c,r<0)throw new Error(`negative radius: ${r}`);let d=r*Math.cos(i),f=r*Math.sin(i),h=t+d,p=n+f,g=1^c,x=c?i-o:o-i;this._x1===null?this._append`M${h},${p}`:(Math.abs(this._x1-h)>Ch||Math.abs(this._y1-p)>Ch)&&this._append`L${h},${p}`,r&&(x<0&&(x=x%bI+bI),x>IEe?this._append`A${r},${r},0,1,${g},${t-d},${n-f}A${r},${r},0,1,${g},${this._x1=h},${this._y1=p}`:x>Ch&&this._append`A${r},${r},0,${+(x>=xI)},${g},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function jG(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new _Ee(t)}function yI(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function SG(e){this._context=e}SG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ik(e){return new SG(e)}function kG(e){return e[0]}function NG(e){return e[1]}function CG(e,t){var n=os(!0),r=null,i=ik,o=null,c=jG(d);e=typeof e=="function"?e:e===void 0?kG:os(e),t=typeof t=="function"?t:t===void 0?NG:os(t);function d(f){var h,p=(f=yI(f)).length,g,x=!1,y;for(r==null&&(o=i(y=c())),h=0;h<=p;++h)!(h=y;--j)d.point(E[j],O[j]);d.lineEnd(),d.areaEnd()}N&&(E[x]=+e(S,x,g),O[x]=+t(S,x,g),d.point(r?+r(S,x,g):E[x],n?+n(S,x,g):O[x]))}if(A)return d=null,A+""||null}function p(){return CG().defined(i).curve(c).context(o)}return h.x=function(g){return arguments.length?(e=typeof g=="function"?g:os(+g),r=null,h):e},h.x0=function(g){return arguments.length?(e=typeof g=="function"?g:os(+g),h):e},h.x1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:os(+g),h):r},h.y=function(g){return arguments.length?(t=typeof g=="function"?g:os(+g),n=null,h):t},h.y0=function(g){return arguments.length?(t=typeof g=="function"?g:os(+g),h):t},h.y1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:os(+g),h):n},h.lineX0=h.lineY0=function(){return p().x(e).y(t)},h.lineY1=function(){return p().x(e).y(n)},h.lineX1=function(){return p().x(r).y(t)},h.defined=function(g){return arguments.length?(i=typeof g=="function"?g:os(!!g),h):i},h.curve=function(g){return arguments.length?(c=g,o!=null&&(d=c(o)),h):c},h.context=function(g){return arguments.length?(g==null?o=d=null:d=c(o=g),h):o},h}class AG{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function DEe(e){return new AG(e,!0)}function LEe(e){return new AG(e,!1)}function lk(){}function ck(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function EG(e){this._context=e}EG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ck(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ck(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function zEe(e){return new EG(e)}function TG(e){this._context=e}TG.prototype={areaStart:lk,areaEnd:lk,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:ck(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function $Ee(e){return new TG(e)}function OG(e){this._context=e}OG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:ck(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function BEe(e){return new OG(e)}function RG(e){this._context=e}RG.prototype={areaStart:lk,areaEnd:lk,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function FEe(e){return new RG(e)}function PG(e){return e<0?-1:1}function IG(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),c=(n-e._y1)/(i||r<0&&-0),d=(o*i+c*r)/(r+i);return(PG(o)+PG(c))*Math.min(Math.abs(o),Math.abs(c),.5*Math.abs(d))||0}function MG(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function wI(e,t,n){var r=e._x0,i=e._y0,o=e._x1,c=e._y1,d=(o-r)/3;e._context.bezierCurveTo(r+d,i+d*t,o-d,c-d*n,o,c)}function uk(e){this._context=e}uk.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:wI(this,this._t0,MG(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,wI(this,MG(this,n=IG(this,e,t)),n);break;default:wI(this,this._t0,n=IG(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function _G(e){this._context=new DG(e)}(_G.prototype=Object.create(uk.prototype)).point=function(e,t){uk.prototype.point.call(this,t,e)};function DG(e){this._context=e}DG.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};function UEe(e){return new uk(e)}function HEe(e){return new _G(e)}function LG(e){this._context=e}LG.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=zG(e),i=zG(t),o=0,c=1;c=0;--t)i[t]=(c[t]-i[t+1])/o[t];for(o[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function KEe(e){return new dk(e,.5)}function qEe(e){return new dk(e,0)}function GEe(e){return new dk(e,1)}function Ah(e,t){if((c=e.length)>1)for(var n=1,r,i,o=e[t[0]],c,d=o.length;n=0;)n[t]=t;return n}function YEe(e,t){return e[t]}function WEe(e){const t=[];return t.key=e,t}function XEe(){var e=os([]),t=jI,n=Ah,r=YEe;function i(o){var c=Array.from(e.apply(this,arguments),WEe),d,f=c.length,h=-1,p;for(const g of o)for(d=0,++h;d0){for(var n,r,i=0,o=e[0].length,c;i0){for(var n=0,r=e[t[0]],i,o=r.length;n0)||!((o=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,o,c;r"radius"in e&&"startAngle"in e&&"endAngle"in e,SI=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(v.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{uI(i)&&typeof n[i]=="function"&&(r[i]=(o=>n[i](n,o)))}),r},eTe=(e,t,n)=>r=>(e(t,n,r),null),fk=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var o=e[i];uI(i)&&typeof o=="function"&&(r||(r={}),r[i]=eTe(o,t,n))}),r};function BG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tTe(e){for(var t=1;t(c[d]===void 0&&r[d]!==void 0&&(c[d]=r[d]),c),n);return o}function aTe(e,t){const n=new Map;for(let r=0;r=0}function kI(e){return e!=null&&typeof e!="function"&&oTe(e.length)}function lTe(e){return function(t){return Zl(t,e)}}function UG(e){return e==null||typeof e!="object"&&typeof e!="function"}function Eh(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const HG="[object RegExp]",NI="[object String]",CI="[object Number]",AI="[object Boolean]",VG="[object Arguments]",KG="[object Symbol]",qG="[object Date]",GG="[object Map]",YG="[object Set]",WG="[object Array]",cTe="[object Function]",XG="[object ArrayBuffer]",hk="[object Object]",uTe="[object Error]",QG="[object DataView]",ZG="[object Uint8Array]",JG="[object Uint8ClampedArray]",e7="[object Uint16Array]",t7="[object Uint32Array]",dTe="[object BigUint64Array]",n7="[object Int8Array]",r7="[object Int16Array]",s7="[object Int32Array]",fTe="[object BigInt64Array]",a7="[object Float32Array]",i7="[object Float64Array]";function Ub(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function o7(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function l7(e,t,n){return typeof n!="function"?l7(e,t,()=>{}):EI(e,t,function r(i,o,c,d,f,h){const p=n(i,o,c,d,f,h);return p!==void 0?!!p:EI(i,o,r,h,!1)},new Map,!0)}function EI(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case"object":return hTe(e,t,n,r,i);case"function":return Object.keys(t).length>0?EI(e,Object.assign({},t),n,r,i):Ub(e,t);default:return o7(e)&&i?typeof t=="string"?t==="":!0:Ub(e,t)}}function hTe(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return c7(e,t,n,r);if(t instanceof Map)return pTe(e,t,n,r);if(t instanceof Set)return mTe(e,t,n,r);const o=Object.keys(t);if(e==null)return i&&o.length===0;if(i)UG(e)&&(e=Object(e));else{if(Eh(t)==="[object Error]")return Eh(e)==="[object Error]"&&e.name===t.name&&e.message===t.message;const c=Eh(e);if(c!=="[object Object]"&&c!=="[object Arguments]")return!1}if(o.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let c=0;c{})}function TI(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}const d7=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof global=="object"&&global||(function(){return this})();function OI(e){return typeof d7.Buffer<"u"&&d7.Buffer.isBuffer(e)}function gTe(e){return OI(e)}function vTe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function xTe(e){return vTe(e)}function bTe(e,t){return ig(e,void 0,e,new Map)}function ig(e,t,n,r,i){if(UG(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){const c=new Array(e.length);r.set(e,c);for(let d=0;d{c.set(f,ig(d,f,n,r))}),c}if(e instanceof Set){const c=new Set;return r.set(e,c),e.forEach(d=>{c.add(ig(d,void 0,n,r))}),c}if(gTe(e))return e.subarray();if(xTe(e)){const c=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,c);for(let d=0;du7(t,e)}const jTe=/^(?:0|[1-9]\d*)$/;function h7(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&ee,yr=()=>{var e=v.useContext(RI);return e?e.store.dispatch:TTe},pk=()=>{},OTe=()=>pk,RTe=(e,t)=>e===t;function lt(e){var t=v.useContext(RI),n=v.useMemo(()=>t?r=>{if(r!=null)return e(r)}:pk,[t,e]);return j5.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:OTe,t?t.store.getState:pk,t?t.store.getState:pk,n,RTe)}function PTe(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function ITe(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var m7=e=>Array.isArray(e)?e:[e];function MTe(e){const t=Array.isArray(e[0])?e[0]:e;return ITe(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function _Te(e,t){const n=[],{length:r}=e;for(let i=0;itypeof WeakRef>"u"?DTe:WeakRef,g7=LTe(),zTe=0,v7=1;function mk(){return{s:zTe,v:void 0,o:null,p:null}}function $Te(e){return e instanceof g7?e.deref():e}function x7(e,t={}){let n=mk();const{resultEqualityCheck:r}=t;let i,o=0;function c(){let d=n;const{length:f}=arguments;for(let g=0,x=f;g{n=mk(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}function BTe(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,c=0,d,f={},h=i.pop();typeof h=="object"&&(f=h,h=i.pop()),PTe(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const p={...n,...f},{memoize:g,memoizeOptions:x=[],argsMemoize:y=x7,argsMemoizeOptions:j=[]}=p,w=m7(x),S=m7(j),N=MTe(i),A=g(function(){return o++,h.apply(null,arguments)},...w),E=y(function(){c++;const R=_Te(N,arguments);return d=A.apply(null,R),d},...S);return Object.assign(E,{resultFunc:h,memoizedResultFunc:A,dependencies:N,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>d,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:g,argsMemoize:y})};return Object.assign(r,{withTypes:()=>r}),r}var Ae=BTe(x7);function FTe(e,t=1){const n=[],r=Math.floor(t),i=(o,c)=>{for(let d=0;d{if(e!==t){const r=b7(e),i=b7(t);if(r===i&&r===0){if(et)return n==="desc"?-1:1}return n==="desc"?i-r:r-i}return 0},VTe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,KTe=/^\w*$/;function qTe(e,t){return Array.isArray(e)?!1:typeof e=="number"||typeof e=="boolean"||e==null||pI(e)?!0:typeof e=="string"&&(KTe.test(e)||!VTe.test(e))||t!=null}function GTe(e,t,n,r){if(e==null)return[];n=n,Array.isArray(e)||(e=kI(e)?Array.from(e):UTe(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(d=>String(d));const i=(d,f)=>{let h=d,p=0;for(;p0&&p===f.length?h:void 0},o=(d,f)=>{if(d==null)return f;if(f!=null)return typeof d=="object"&&"key"in d?ag(f,d.key)?f[d.key]:i(f,d.path):typeof d=="function"?d(f):Array.isArray(d)?i(f,d):f[d]},c=t.map(d=>(Array.isArray(d)&&d.length===1&&(d=d[0]),d==null||typeof d=="function"||Array.isArray(d)||qTe(d)?d:{key:d,path:mI(d)}));return e.map(d=>({original:d,criteria:c.map(f=>o(f,d))})).slice().sort((d,f)=>{for(let h=0;hd.original)}function gk(e,...t){const n=t.length;return n>1&&PI(e,t[0],t[1])?t=[]:n>2&&PI(t[0],t[1],t[2])&&(t=[t[0]]),GTe(e,FTe(t),["asc"])}var y7=e=>e.legend.settings,YTe=e=>e.legend.size,WTe=e=>e.legend.payload;Ae([WTe,y7],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?gk(r,n):r});function XTe(e,t){return eOe(e)||JTe(e,t)||ZTe(e,t)||QTe()}function QTe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ZTe(e,t){if(e){if(typeof e=="string")return w7(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w7(e,t):void 0}}function w7(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);nvk||Math.abs(e.left-t.left)>vk||Math.abs(e.top-t.top)>vk||Math.abs(e.width-t.width)>vk}function S7(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function tOe(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=v.useState({height:0,left:0,top:0,width:0}),n=XTe(t,2),r=n[0],i=n[1],o=v.useRef(null),c=v.useRef(r);c.current=r;var d=v.useCallback(f=>{if(o.current!=null&&(o.current.disconnect(),o.current=null),f!=null){var h=S7(f);if(j7(h,c.current)&&i(h),typeof ResizeObserver<"u"){var p=new ResizeObserver(()=>{var g=S7(f);j7(g,c.current)&&i(g)});p.observe(f),o.current=p}}},[...e]);return v.useEffect(()=>()=>{var f;(f=o.current)===null||f===void 0||f.disconnect()},[]),[r,d]}function ya(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var nOe=typeof Symbol=="function"&&Symbol.observable||"@@observable",k7=nOe,II=()=>Math.random().toString(36).substring(7).split("").join("."),rOe={INIT:`@@redux/INIT${II()}`,REPLACE:`@@redux/REPLACE${II()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${II()}`},xk=rOe;function MI(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function N7(e,t,n){if(typeof e!="function")throw new Error(ya(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ya(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ya(1));return n(N7)(e,t)}let r=e,i=t,o=new Map,c=o,d=0,f=!1;function h(){c===o&&(c=new Map,o.forEach((S,N)=>{c.set(N,S)}))}function p(){if(f)throw new Error(ya(3));return i}function g(S){if(typeof S!="function")throw new Error(ya(4));if(f)throw new Error(ya(5));let N=!0;h();const A=d++;return c.set(A,S),function(){if(N){if(f)throw new Error(ya(6));N=!1,h(),c.delete(A),o=null}}}function x(S){if(!MI(S))throw new Error(ya(7));if(typeof S.type>"u")throw new Error(ya(8));if(typeof S.type!="string")throw new Error(ya(17));if(f)throw new Error(ya(9));try{f=!0,i=r(i,S)}finally{f=!1}return(o=c).forEach(A=>{A()}),S}function y(S){if(typeof S!="function")throw new Error(ya(10));r=S,x({type:xk.REPLACE})}function j(){const S=g;return{subscribe(N){if(typeof N!="object"||N===null)throw new Error(ya(11));function A(){const O=N;O.next&&O.next(p())}return A(),{unsubscribe:S(A)}},[k7](){return this}}}return x({type:xk.INIT}),{dispatch:x,subscribe:g,getState:p,replaceReducer:y,[k7]:j}}function sOe(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:xk.INIT})>"u")throw new Error(ya(12));if(typeof n(void 0,{type:xk.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ya(13))})}function C7(e){const t=Object.keys(e),n={};for(let o=0;o"u")throw d&&d.type,new Error(ya(14));h[g]=j,f=f||j!==y}return f=f||r.length!==Object.keys(c).length,f?h:c}}function bk(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function aOe(...e){return t=>(n,r)=>{const i=t(n,r);let o=()=>{throw new Error(ya(15))};const c={getState:i.getState,dispatch:(f,...h)=>o(f,...h)},d=e.map(f=>f(c));return o=bk(...d)(i.dispatch),{...i,dispatch:o}}}function A7(e){return MI(e)&&"type"in e&&typeof e.type=="string"}var E7=Symbol.for("immer-nothing"),T7=Symbol.for("immer-draftable"),Da=Symbol.for("immer-state");function ll(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ui=Object,lg=Ui.getPrototypeOf,yk="constructor",wk="prototype",_I="configurable",jk="enumerable",Sk="writable",Hb="value",Jc=e=>!!e&&!!e[Da];function Ao(e){return e?R7(e)||Ck(e)||!!e[T7]||!!e[yk]?.[T7]||Ak(e)||Kb(e):!1}var iOe=Ui[wk][yk].toString(),O7=new WeakMap;function R7(e){if(!e||!zI(e))return!1;const t=lg(e);if(t===null||t===Ui[wk])return!0;const n=Ui.hasOwnProperty.call(t,yk)&&t[yk];if(n===Object)return!0;if(!cg(n))return!1;let r=O7.get(n);return r===void 0&&(r=Function.toString.call(n),O7.set(n,r)),r===iOe}function kk(e,t,n=!0){Vb(e)===0?(n?Reflect.ownKeys(e):Ui.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Vb(e){const t=e[Da];return t?t.type_:Ck(e)?1:Ak(e)?2:Kb(e)?3:0}var DI=(e,t,n=Vb(e))=>n===2?e.has(t):Ui[wk].hasOwnProperty.call(e,t),LI=(e,t,n=Vb(e))=>n===2?e.get(t):e[t],Nk=(e,t,n,r=Vb(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function oOe(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ck=Array.isArray,Ak=e=>e instanceof Map,Kb=e=>e instanceof Set,zI=e=>typeof e=="object",cg=e=>typeof e=="function",$I=e=>typeof e=="boolean";function lOe(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var eu=e=>e.copy_||e.base_,BI=e=>e.modified_?e.copy_:e.base_;function FI(e,t){if(Ak(e))return new Map(e);if(Kb(e))return new Set(e);if(Ck(e))return Array[wk].slice.call(e);const n=R7(e);if(t===!0||t==="class_only"&&!n){const r=Ui.getOwnPropertyDescriptors(e);delete r[Da];let i=Reflect.ownKeys(r);for(let o=0;o1&&Ui.defineProperties(e,{set:Ek,add:Ek,clear:Ek,delete:Ek}),Ui.freeze(e),t&&kk(e,(n,r)=>{UI(r,!0)},!1)),e}function cOe(){ll(2)}var Ek={[Hb]:cOe};function Tk(e){return e===null||!zI(e)?!0:Ui.isFrozen(e)}var Ok="MapSet",HI="Patches",P7="ArrayMethods",I7={};function Th(e){const t=I7[e];return t||ll(0,e),t}var M7=e=>!!I7[e],qb,_7=()=>qb,uOe=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:M7(Ok)?Th(Ok):void 0,arrayMethodsPlugin_:M7(P7)?Th(P7):void 0});function D7(e,t){t&&(e.patchPlugin_=Th(HI),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function VI(e){KI(e),e.drafts_.forEach(dOe),e.drafts_=null}function KI(e){e===qb&&(qb=e.parent_)}var L7=e=>qb=uOe(qb,e);function dOe(e){const t=e[Da];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function z7(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[Da].modified_&&(VI(t),ll(4)),Ao(e)&&(e=$7(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[Da].base_,e,t)}else e=$7(t,n);return fOe(t,e,!0),VI(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==E7?e:void 0}function $7(e,t){if(Tk(t))return t;const n=t[Da];if(!n)return Pk(t,e.handledSet_,e);if(!Rk(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);U7(n,e)}return n.copy_}function fOe(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&UI(t,n)}function B7(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Rk=(e,t)=>e.scope_===t,hOe=[];function F7(e,t,n,r){const i=eu(e),o=e.type_;if(r!==void 0&&LI(i,r,o)===t){Nk(i,r,n,o);return}if(!e.draftLocations_){const d=e.draftLocations_=new Map;kk(i,(f,h)=>{if(Jc(h)){const p=d.get(h)||[];p.push(f),d.set(h,p)}})}const c=e.draftLocations_.get(t)??hOe;for(const d of c)Nk(i,d,n,o)}function pOe(e,t,n){e.callbacks_.push(function(i){const o=t;if(!o||!Rk(o,i))return;i.mapSetPlugin_?.fixSetContents(o);const c=BI(o);F7(e,o.draft_??o,c,n),U7(o,i)})}function U7(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}B7(e)}}function mOe(e,t,n){const{scope_:r}=e;if(Jc(n)){const i=n[Da];Rk(i,r)&&i.callbacks_.push(function(){Mk(e);const c=BI(i);F7(e,n,c,t)})}else Ao(n)&&e.callbacks_.push(function(){const o=eu(e);e.type_===3?o.has(n)&&Pk(n,r.handledSet_,r):LI(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Pk(LI(e.copy_,t,e.type_),r.handledSet_,r)})}function Pk(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Jc(e)||t.has(e)||!Ao(e)||Tk(e)||(t.add(e),kk(e,(r,i)=>{if(Jc(i)){const o=i[Da];if(Rk(o,n)){const c=BI(o);Nk(e,r,c,e.type_),B7(o)}}else Ao(i)&&Pk(i,t,n)})),e}function gOe(e,t){const n=Ck(e),r={type_:n?1:0,scope_:t?t.scope_:_7(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,o=Ik;n&&(i=[r],o=Gb);const{revoke:c,proxy:d}=Proxy.revocable(i,o);return r.draft_=d,r.revoke_=c,[d,r]}var Ik={get(e,t){if(t===Da)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=eu(e);if(!DI(i,t,e.type_))return xOe(e,i,t);const o=i[t];if(e.finalized_||!Ao(o)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&lOe(t))return o;if(o===qI(e.base_,t)||vOe(e,t,o)){Mk(e);const c=e.type_===1?+t:t,d=YI(e.scope_,o,e,c);return e.copy_[c]=d}return o},has(e,t){return t in eu(e)},ownKeys(e){return Reflect.ownKeys(eu(e))},set(e,t,n){const r=H7(eu(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=qI(eu(e),t),o=i?.[Da];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.delete(t),!0;if(oOe(n,i)&&(n!==void 0||DI(e.base_,t,e.type_)))return!0;Mk(e),GI(e)}return e.copy_[t]===n&&(n!==void 0||DI(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),mOe(e,t,n)),!0},deleteProperty(e,t){return Mk(e),qI(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),GI(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=eu(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Sk]:!0,[_I]:e.type_!==1||t!=="length",[jk]:r[jk],[Hb]:n[t]}},defineProperty(){ll(11)},getPrototypeOf(e){return lg(e.base_)},setPrototypeOf(){ll(12)}},Gb={};for(let e in Ik){let t=Ik[e];Gb[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Gb.deleteProperty=function(e,t){return Gb.set.call(this,e,t,void 0)},Gb.set=function(e,t,n){return Ik.set.call(this,e[0],t,n,e[0])};function qI(e,t){const n=e[Da];return(n?eu(n):e)[t]}function vOe(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||!Ao(n)||n[Da]?!1:e.baseRefs_.has(n)}function xOe(e,t,n){const r=H7(t,n);return r?Hb in r?r[Hb]:r.get?.call(e.draft_):void 0}function H7(e,t){if(!(t in e))return;let n=lg(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=lg(n)}}function GI(e){e.modified_||(e.modified_=!0,e.parent_&&GI(e.parent_))}function Mk(e){e.copy_||(e.assigned_=new Map,e.copy_=FI(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var bOe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(cg(t)&&!cg(n)){const o=n;n=t;const c=this;return function(f=o,...h){return c.produce(f,p=>n.call(this,p,...h))}}cg(n)||ll(6),r!==void 0&&!cg(r)&&ll(7);let i;if(Ao(t)){const o=L7(this),c=YI(o,t,void 0);let d=!0;try{i=n(c),d=!1}finally{d?VI(o):KI(o)}return D7(o,r),z7(i,o)}else if(!t||!zI(t)){if(i=n(t),i===void 0&&(i=t),i===E7&&(i=void 0),this.autoFreeze_&&UI(i,!0),r){const o=[],c=[];Th(HI).generateReplacementPatches_(t,i,{patches_:o,inversePatches_:c}),r(o,c)}return i}else ll(1,t)},this.produceWithPatches=(t,n)=>{if(cg(t))return(c,...d)=>this.produceWithPatches(c,f=>t(f,...d));let r,i;return[this.produce(t,n,(c,d)=>{r=c,i=d}),r,i]},$I(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),$I(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),$I(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ao(e)||ll(8),Jc(e)&&(e=Eo(e));const t=L7(this),n=YI(t,e,void 0);return n[Da].isManual_=!0,KI(t),n}finishDraft(e,t){const n=e&&e[Da];(!n||!n.isManual_)&&ll(9);const{scope_:r}=n;return D7(r,t),z7(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Th(HI).applyPatches_;return Jc(e)?r(e,t):this.produce(e,i=>r(i,t))}};function YI(e,t,n,r){const[i,o]=Ak(t)?Th(Ok).proxyMap_(t,n):Kb(t)?Th(Ok).proxySet_(t,n):gOe(t,n);return(n?.scope_??_7()).drafts_.push(i),o.callbacks_=n?.callbacks_??[],o.key_=r,n&&r!==void 0?pOe(n,o,r):o.callbacks_.push(function(f){f.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:h}=f;o.modified_&&h&&h.generatePatches_(o,[],f)}),i}function Eo(e){return Jc(e)||ll(10,e),V7(e)}function V7(e){if(!Ao(e)||Tk(e))return e;const t=e[Da];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=FI(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=FI(e,!0);const i=n;return Kb(n)&&(n=new Set),kk(i,(o,c)=>{Nk(n,o,V7(c))},r),t&&(t.finalized_=!1),n}var yOe=globalThis.Iterator;yOe?.from;var wOe=new bOe,K7=wOe.produce,Wn=e=>e;function q7(e){return({dispatch:n,getState:r})=>i=>o=>typeof o=="function"?o(n,r,e):i(o)}var jOe=q7(),SOe=q7;const kOe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?bk:bk.apply(null,arguments)};function Hi(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(vi(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>A7(r)&&r.type===e,n}var G7=class cj extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,cj.prototype)}static get[Symbol.species](){return cj}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new cj(...t[0].concat(this)):new cj(...t.concat(this))}};function Y7(e){return Ao(e)?K7(e,()=>{}):e}function _k(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function NOe(e){return typeof e=="boolean"}const COe=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=t??{};let c=new G7;return n&&(NOe(n)?c.push(jOe):c.push(SOe(n.extraArgument))),c},W7="RTK_autoBatch",_r=()=>e=>({payload:e,meta:{[W7]:!0}}),X7=e=>t=>{setTimeout(t,e)},AOe=(e,t)=>n=>{let r=!1,i,o;const c=()=>{r||(r=!0,cancelAnimationFrame(i),clearTimeout(o),n())};i=e(c),o=setTimeout(c,t)},Q7=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,o=!1,c=!1;const d=new Set,f=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?AOe(window.requestAnimationFrame,100):X7(10):e.type==="callback"?e.queueNotification:X7(e.timeout),h=()=>{c=!1,o&&(o=!1,d.forEach(p=>p()))};return Object.assign({},r,{subscribe(p){const g=()=>i&&p(),x=r.subscribe(g);return d.add(p),()=>{x(),d.delete(p)}},dispatch(p){try{return i=!p?.meta?.[W7],o=!i,o&&(c||(c=!0,f(h))),r.dispatch(p)}finally{i=!0}}})},EOe=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new G7(e);return r&&i.push(Q7(typeof r=="object"?r:void 0)),i};function TOe(e){const t=COe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:o=void 0,enhancers:c=void 0}=e||{};let d;if(typeof n=="function")d=n;else if(MI(n))d=C7(n);else throw new Error(vi(1));let f;typeof r=="function"?f=r(t):f=t();let h=bk;i&&(h=kOe({trace:!1,...typeof i=="object"&&i}));const p=aOe(...f),g=EOe(p);let x=typeof c=="function"?c(g):g();const y=h(...x);return N7(d,o,y)}function Z7(e){const t={},n=[];let r;const i={addCase(o,c){const d=typeof o=="string"?o:o.type;if(!d)throw new Error(vi(28));if(d in t)throw new Error(vi(29));return t[d]=c,i},addAsyncThunk(o,c){return c.pending&&(t[o.pending.type]=c.pending),c.rejected&&(t[o.rejected.type]=c.rejected),c.fulfilled&&(t[o.fulfilled.type]=c.fulfilled),c.settled&&n.push({matcher:o.settled,reducer:c.settled}),i},addMatcher(o,c){return n.push({matcher:o,reducer:c}),i},addDefaultCase(o){return r=o,i}};return e(i),[t,n,r]}function OOe(e){return typeof e=="function"}function ROe(e,t){let[n,r,i]=Z7(t),o;if(OOe(e))o=()=>Y7(e());else{const d=Y7(e);o=()=>d}function c(d=o(),f){let h=[n[f.type],...r.filter(({matcher:p})=>p(f)).map(({reducer:p})=>p)];return h.filter(p=>!!p).length===0&&(h=[i]),h.reduce((p,g)=>{if(g)if(Jc(p)){const x=g(p,f);return x===void 0?p:x}else{if(Ao(p))return K7(p,x=>g(x,f));{const x=g(p,f);if(x===void 0){if(p===null)return p;throw new Error(vi(9))}return x}}return p},d)}return c.getInitialState=o,c}let POe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",IOe=(e=21)=>{let t="",n=e;for(;n--;)t+=POe[Math.random()*64|0];return t};const MOe=Symbol.for("rtk-slice-createasyncthunk");function _Oe(e,t){return`${e}/${t}`}function DOe({creators:e}={}){const t=e?.asyncThunk?.[MOe];return function(r){const{name:i,reducerPath:o=i}=r;if(!i)throw new Error(vi(11));const c=(typeof r.reducers=="function"?r.reducers(zOe()):r.reducers)||{},d=Object.keys(c),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},h={addCase(E,O){const R=typeof E=="string"?E:E.type;if(!R)throw new Error(vi(12));if(R in f.sliceCaseReducersByType)throw new Error(vi(13));return f.sliceCaseReducersByType[R]=O,h},addMatcher(E,O){return f.sliceMatchers.push({matcher:E,reducer:O}),h},exposeAction(E,O){return f.actionCreators[E]=O,h},exposeCaseReducer(E,O){return f.sliceCaseReducersByName[E]=O,h}};d.forEach(E=>{const O=c[E],R={reducerName:E,type:_Oe(i,E),createNotation:typeof r.reducers=="function"};BOe(O)?UOe(R,O,h,t):$Oe(R,O,h)});function p(){const[E={},O=[],R=void 0]=typeof r.extraReducers=="function"?Z7(r.extraReducers):[r.extraReducers],T={...E,...f.sliceCaseReducersByType};return ROe(r.initialState,P=>{for(let M in T)P.addCase(M,T[M]);for(let M of f.sliceMatchers)P.addMatcher(M.matcher,M.reducer);for(let M of O)P.addMatcher(M.matcher,M.reducer);R&&P.addDefaultCase(R)})}const g=E=>E,x=new Map,y=new WeakMap;let j;function w(E,O){return j||(j=p()),j(E,O)}function S(){return j||(j=p()),j.getInitialState()}function N(E,O=!1){function R(P){let M=P[E];return typeof M>"u"&&O&&(M=_k(y,R,S)),M}function T(P=g){return _k(_k(x,O,()=>new WeakMap),P,()=>{const M={};for(const[_,I]of Object.entries(r.selectors??{}))M[_]=LOe(I,P,()=>_k(y,P,S),O);return M})}return{reducerPath:E,getSelectors:T,get selectors(){return T(R)},selectSlice:R}}const A={name:i,reducer:w,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:S,...N(o),injectInto(E,{reducerPath:O,...R}={}){const T=O??o;return E.inject({reducerPath:T,reducer:w},R),{...A,...N(T,!0)}}};return A}}function LOe(e,t,n,r){function i(o,...c){let d=t(o);return typeof d>"u"&&r&&(d=n()),e(d,...c)}return i.unwrapped=e,i}const La=DOe();function zOe(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function $Oe({type:e,reducerName:t,createNotation:n},r,i){let o,c;if("reducer"in r){if(n&&!FOe(r))throw new Error(vi(17));o=r.reducer,c=r.prepare}else o=r;i.addCase(e,o).exposeCaseReducer(t,o).exposeAction(t,c?Hi(e,c):Hi(e))}function BOe(e){return e._reducerDefinitionType==="asyncThunk"}function FOe(e){return e._reducerDefinitionType==="reducerWithPrepare"}function UOe({type:e,reducerName:t},n,r,i){if(!i)throw new Error(vi(18));const{payloadCreator:o,fulfilled:c,pending:d,rejected:f,settled:h,options:p}=n,g=i(e,o,p);r.exposeAction(t,g),c&&r.addCase(g.fulfilled,c),d&&r.addCase(g.pending,d),f&&r.addCase(g.rejected,f),h&&r.addMatcher(g.settled,h),r.exposeCaseReducer(t,{fulfilled:c||Dk,pending:d||Dk,rejected:f||Dk,settled:h||Dk})}function Dk(){}const HOe="task",J7="listener",e9="completed",WI="cancelled",VOe=`task-${WI}`,KOe=`task-${e9}`,XI=`${J7}-${WI}`,qOe=`${J7}-${e9}`;var Lk=class{constructor(e){on(this,"code");on(this,"name","TaskAbortError");on(this,"message");this.code=e,this.message=`${HOe} ${WI} (reason: ${e})`}};const QI=(e,t)=>{if(typeof e!="function")throw new TypeError(vi(32))},zk=()=>{},t9=(e,t=zk)=>(e.catch(t),e),n9=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Oh=e=>{if(e.aborted)throw new Lk(e.reason)};function r9(e,t){let n=zk;return new Promise((r,i)=>{const o=()=>i(new Lk(e.reason));if(e.aborted){o();return}n=n9(e,o),t.finally(()=>n()).then(r,i)}).finally(()=>{n=zk})}const GOe=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof Lk?"cancelled":"rejected",error:n}}finally{t?.()}},$k=e=>t=>t9(r9(e,t).then(n=>(Oh(e),n))),s9=e=>{const t=$k(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:ug}=Object,a9={},Bk="listenerMiddleware",YOe=(e,t)=>{const n=r=>n9(e,()=>r.abort(e.reason));return(r,i)=>{QI(r);const o=new AbortController;n(o);const c=GOe(async()=>{Oh(e),Oh(o.signal);const d=await r({pause:$k(o.signal),delay:s9(o.signal),signal:o.signal});return Oh(o.signal),d},()=>o.abort(KOe));return i?.autoJoin&&t.push(c.catch(zk)),{result:$k(e)(c),cancel(){o.abort(VOe)}}}},WOe=(e,t)=>{const n=async(r,i)=>{Oh(t);let o=()=>{};const c=[new Promise((d,f)=>{let h=e({predicate:r,effect:(p,g)=>{g.unsubscribe(),d([p,g.getState(),g.getOriginalState()])}});o=()=>{h(),f()}})];i!=null&&c.push(new Promise(d=>setTimeout(d,i,null)));try{const d=await r9(t,Promise.race(c));return Oh(t),d}finally{o()}};return((r,i)=>t9(n(r,i)))},i9=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:o}=e;if(t)i=Hi(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(vi(21));return QI(o),{predicate:i,type:t,effect:o}},o9=ug(e=>{const{type:t,predicate:n,effect:r}=i9(e);return{id:IOe(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(vi(22))}}},{withTypes:()=>o9}),l9=(e,t)=>{const{type:n,effect:r,predicate:i}=i9(t);return Array.from(e.values()).find(o=>(typeof n=="string"?o.type===n:o.predicate===i)&&o.effect===r)},ZI=e=>{e.pending.forEach(t=>{t.abort(XI)})},XOe=(e,t)=>()=>{for(const n of t.keys())ZI(n);e.clear()},c9=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},u9=ug(Hi(`${Bk}/add`),{withTypes:()=>u9}),QOe=Hi(`${Bk}/removeAll`),d9=ug(Hi(`${Bk}/remove`),{withTypes:()=>d9}),ZOe=(...e)=>{console.error(`${Bk}/error`,...e)},Yb=(e={})=>{const t=new Map,n=new Map,r=y=>{const j=n.get(y)??0;n.set(y,j+1)},i=y=>{const j=n.get(y)??1;j===1?n.delete(y):n.set(y,j-1)},{extra:o,onError:c=ZOe}=e;QI(c);const d=y=>(y.unsubscribe=()=>t.delete(y.id),t.set(y.id,y),j=>{y.unsubscribe(),j?.cancelActive&&ZI(y)}),f=(y=>{const j=l9(t,y)??o9(y);return d(j)});ug(f,{withTypes:()=>f});const h=y=>{const j=l9(t,y);return j&&(j.unsubscribe(),y.cancelActive&&ZI(j)),!!j};ug(h,{withTypes:()=>h});const p=async(y,j,w,S)=>{const N=new AbortController,A=WOe(f,N.signal),E=[];try{y.pending.add(N),r(y),await Promise.resolve(y.effect(j,ug({},w,{getOriginalState:S,condition:(O,R)=>A(O,R).then(Boolean),take:A,delay:s9(N.signal),pause:$k(N.signal),extra:o,signal:N.signal,fork:YOe(N.signal,E),unsubscribe:y.unsubscribe,subscribe:()=>{t.set(y.id,y)},cancelActiveListeners:()=>{y.pending.forEach((O,R,T)=>{O!==N&&(O.abort(XI),T.delete(O))})},cancel:()=>{N.abort(XI),y.pending.delete(N)},throwIfCancelled:()=>{Oh(N.signal)}})))}catch(O){O instanceof Lk||c9(c,O,{raisedBy:"effect"})}finally{await Promise.all(E),N.abort(qOe),i(y),y.pending.delete(N)}},g=XOe(t,n);return{middleware:y=>j=>w=>{if(!A7(w))return j(w);if(u9.match(w))return f(w.payload);if(QOe.match(w)){g();return}if(d9.match(w))return h(w.payload);let S=y.getState();const N=()=>{if(S===a9)throw new Error(vi(23));return S};let A;try{if(A=j(w),t.size>0){const E=y.getState(),O=Array.from(t.values());for(const R of O){let T=!1;try{T=R.predicate(w,E,S)}catch(P){T=!1,c9(c,P,{raisedBy:"predicate"})}T&&p(R,w,y,N)}}}finally{S=a9}return A},startListening:f,stopListening:h,clearListeners:g}};function vi(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var JOe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},f9=La({name:"chartLayout",initialState:JOe,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,i,o;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(o=t.payload.left)!==null&&o!==void 0?o:0},setScale(e,t){e.scale=t.payload}}}),Fk=f9.actions,eRe=Fk.setMargin,tRe=Fk.setLayout,nRe=Fk.setChartSize,rRe=Fk.setScale,sRe=f9.reducer;function h9(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function $n(e){return Number.isFinite(e)}function nc(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function p9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function xi(e){for(var t=1;t{if(t&&n){var r=n.width,i=n.height,o=t.align,c=t.verticalAlign,d=t.layout,f=t.position,h=t.offset,p=h===void 0?0:h;if(f!=null){if(REe(f)){if(f==="top"&&ot(e.top))return xi(xi({},e),{},{top:e.top+(i||0)+p});if(f==="bottom"&&ot(e.bottom))return xi(xi({},e),{},{bottom:e.bottom+(i||0)+p});if(f==="left"&&ot(e.left))return xi(xi({},e),{},{left:e.left+(r||0)+p});if(f==="right"&&ot(e.right))return xi(xi({},e),{},{right:e.right+(r||0)+p})}return e}if((d==="vertical"||d==="horizontal"&&c==="middle")&&o!=="center"&&ot(e[o]))return xi(xi({},e),{},{[o]:e[o]+(r||0)});if((d==="horizontal"||d==="vertical"&&o==="center")&&c!=="middle"&&ot(e[c]))return xi(xi({},e),{},{[c]:e[c]+(i||0)})}return e},tu=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",m9=(e,t,n,r)=>{if(r)return e.map(d=>d.coordinate);var i,o,c=e.map(d=>(d.coordinate===t&&(i=!0),d.coordinate===n&&(o=!0),d.coordinate));return i||c.push(t),o||c.push(n),c},g9=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,o=e.range,c=e.scale,d=e.realScaleType,f=e.isCategorical,h=e.categoricalDomain,p=e.tickCount,g=e.ticks,x=e.niceTicks,y=e.axisType;if(!c)return null;var j=d==="scaleBand"&&c.bandwidth?c.bandwidth()/2:2,w=i==="category"&&c.bandwidth?c.bandwidth()/j:0;if(w=y==="angleAxis"&&o&&o.length>=2?ra(o[0]-o[1])*2*w:w,g||x){var S=(g||x||[]).map((N,A)=>{var E=r?r.indexOf(N):N,O=c.map(E);return $n(O)?{coordinate:O+w,value:N,offset:w,index:A}:null}).filter(gi);return S}return f&&h?h.map((N,A)=>{var E=c.map(N);return $n(E)?{coordinate:E+w,value:N,index:A,offset:w}:null}).filter(gi):c.ticks&&p!=null?c.ticks(p).map((N,A)=>{var E=c.map(N);return $n(E)?{coordinate:E+w,value:N,index:A,offset:w}:null}).filter(gi):c.domain().map((N,A)=>{var E=c.map(N);return $n(E)?{coordinate:E+w,value:r?r[N]:N,index:A,offset:w}:null}).filter(gi)},cRe=(e,t)=>{if(!t||t.length!==2||!ot(t[0])||!ot(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!ot(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(h[0]=o,o+=x,h[1]=o):(h[0]=c,c+=x,h[1]=c)}}}},dRe=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(f[0]=o,o+=h,f[1]=o):(f[0]=0,f[1]=0)}}}},fRe={sign:uRe,expand:QEe,none:Ah,silhouette:ZEe,wiggle:JEe,positive:dRe},hRe=(e,t,n)=>{var r,i=(r=fRe[n])!==null&&r!==void 0?r:Ah,o=XEe().keys(t).value((d,f)=>Number(sr(d,f,0))).order(jI).offset(i),c=o(e);return c.forEach((d,f)=>{d.forEach((h,p)=>{var g=sr(e[p],t[f],0);Array.isArray(g)&&g.length===2&&ot(g[0])&&ot(g[1])&&(h[0]=g[0],h[1]=g[1])})}),c};function pRe(e){return e==null?void 0:String(e)}function v9(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,o=e.index,c=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Hr(i[t.dataKey])){var d=bG(n,"value",i[t.dataKey]);if(d)return d.coordinate+r/2}return n!=null&&n[o]?n[o].coordinate+r/2:null}var f=sr(i,Hr(c)?t.dataKey:c),h=t.scale.map(f);return ot(h)?h:null}var x9=e=>{var t=e.axis,n=e.ticks,r=e.offset,i=e.bandSize,o=e.entry,c=e.index;if(t.type==="category")return n[c]?n[c].coordinate+r:null;var d=sr(o,t.dataKey,t.scale.domain()[c]);if(Hr(d))return null;var f=t.scale.map(d);return ot(f)?f-i/2+r:null},mRe=e=>{var t=e.numericAxis,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},gRe=e=>{var t=e.flat(2).filter(ot);return[Math.min(...t),Math.max(...t)]},vRe=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],xRe=(e,t,n)=>{if(!(e==null||Object.keys(e).length===0))return vRe(Object.keys(e).reduce((r,i)=>{var o=e[i];if(!o)return r;var c=o.stackedData,d=c.reduce((f,h)=>{var p=h9(h,t,n),g=gRe(p);return!$n(g[0])||!$n(g[1])?f:[Math.min(f[0],g[0]),Math.max(f[1],g[1])]},[1/0,-1/0]);return[Math.min(d[0],r[0]),Math.max(d[1],r[1])]},[1/0,-1/0]))},b9=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,y9=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,dg=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=gk(t,w=>w.coordinate),o=[],c=0,d=1,f=i.length;dx&&(y=Math.min(j,y));return y===1/0?0:y}return n?void 0:0};function w9(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,o=e.name;return xi(xi({},t),{},{dataKey:n,payload:r,value:i,name:o})}function fg(e,t){if(e!=null)return String(e);if(typeof t=="string")return t}var bRe=(e,t)=>{if(t==="horizontal")return e.relativeX;if(t==="vertical")return e.relativeY},yRe=(e,t)=>t==="centric"?e.angle:e.radius,nu=e=>e.layout.width,ru=e=>e.layout.height,wRe=e=>e.layout.scale,j9=e=>e.layout.margin,Uk=Ae(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Hk=Ae(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),S9="data-recharts-item-index",k9="data-recharts-item-id",Wb=60,JI=30;function N9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Vk(e){for(var t=1;te.brush.height;function CRe(e){var t=Hk(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Wb;return n+i}return n},0)}function ARe(e){var t=Hk(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Wb;return n+i}return n},0)}function ERe(e){var t=Uk(e);return t.reduce((n,r)=>{if(r.orientation==="top"&&!r.mirror&&!r.hide){var i=typeof r.height=="number"?r.height:JI;return n+i}return n},0)}function TRe(e){var t=Uk(e);return t.reduce((n,r)=>{if(r.orientation==="bottom"&&!r.mirror&&!r.hide){var i=typeof r.height=="number"?r.height:JI;return n+i}return n},0)}var Us=Ae([nu,ru,j9,NRe,CRe,ARe,ERe,TRe,y7,YTe],(e,t,n,r,i,o,c,d,f,h)=>{var p={left:(n.left||0)+i,right:(n.right||0)+o},g={top:(n.top||0)+c,bottom:(n.bottom||0)+d},x=Vk(Vk({},g),p),y=x.bottom;x.bottom+=r,x=lRe(x,f,h);var j=e-x.left-x.right,w=t-x.top-x.bottom;return Vk(Vk({brushBottom:y},x),{},{width:Math.max(j,0),height:Math.max(w,0)})}),ORe=Ae(Us,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),eM=Ae(nu,ru,(e,t)=>({x:0,y:0,width:e,height:t})),RRe=v.createContext(null),sa=()=>v.useContext(RRe)!=null,Kk=e=>e.brush,qk=Ae([Kk,Us,j9],(e,t,n)=>({height:e.height,x:ot(e.x)?e.x:t.left,y:ot(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:ot(e.width)?e.width:t.width}));function PRe(e,t,{signal:n,edges:r}={}){let i,o=null;const c=r!=null&&r.includes("leading"),d=r==null||r.includes("trailing"),f=()=>{o!==null&&(e.apply(i,o),i=void 0,o=null)},h=()=>{d&&f(),y()};let p=null;const g=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,h()},t)},x=()=>{p!==null&&(clearTimeout(p),p=null)},y=()=>{x(),i=void 0,o=null},j=()=>{f()},w=function(...S){if(n?.aborted)return;i=this,o=S;const N=p==null;g(),c&&N&&f()};return w.schedule=g,w.cancel=y,w.flush=j,n?.addEventListener("abort",y,{once:!0}),w}function IRe(e,t=0,n={}){typeof n!="object"&&(n={});const{leading:r=!1,trailing:i=!0,maxWait:o}=n,c=Array(2);r&&(c[0]="leading"),i&&(c[1]="trailing");let d,f=null;const h=PRe(function(...x){d=e.apply(this,x),f=null},t,{edges:c}),p=function(...x){return o!=null&&(f===null&&(f=Date.now()),Date.now()-f>=o)?((r||i)&&(d=e.apply(this,x)),f=Date.now(),h.cancel(),h.schedule(),d):(h.apply(this,x),d)},g=()=>(h.flush(),d);return p.cancel=h.cancel,p.flush=g,p}function MRe(e,t=0,n={}){const{leading:r=!0,trailing:i=!0}=n;return IRe(e,t,{leading:r,maxWait:t,trailing:i})}var Gk=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;oi[c++]))}},rc={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},C9=(e,t,n)=>{var r=n.width,i=r===void 0?rc.width:r,o=n.height,c=o===void 0?rc.height:o,d=n.aspect,f=n.maxHeight,h=kh(i)?e:Number(i),p=kh(c)?t:Number(c);return d&&d>0&&(h?p=h/d:p&&(h=p*d),f&&p!=null&&p>f&&(p=f)),{calculatedWidth:h,calculatedHeight:p}},_Re={width:0,height:0,overflow:"visible"},DRe={width:0,overflowX:"visible"},LRe={height:0,overflowY:"visible"},zRe={},$Re=e=>{var t=e.width,n=e.height,r=kh(t),i=kh(n);return r&&i?_Re:r?DRe:i?LRe:zRe};function BRe(e){var t=e.width,n=e.height,r=e.aspect,i=t,o=n;return i===void 0&&o===void 0?(i=rc.width,o=rc.height):i===void 0?i=r&&r>0?void 0:rc.width:o===void 0&&(o=r&&r>0?void 0:rc.height),{width:i,height:o}}var FRe=["aspect","initialDimension","width","height","minWidth","minHeight","maxHeight","children","debounce","id","className","onResize","style"];function Yk(){return Yk=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({width:n,height:r}),[n,r]);return ZRe(i)?v.createElement(O9.Provider,{value:i},t):null}var tM=()=>v.useContext(O9),JRe=v.forwardRef((e,t)=>{var n=e.aspect,r=e.initialDimension,i=r===void 0?rc.initialDimension:r,o=e.width,c=e.height,d=e.minWidth,f=d===void 0?rc.minWidth:d,h=e.minHeight,p=e.maxHeight,g=e.children,x=e.debounce,y=x===void 0?rc.debounce:x,j=e.id,w=e.className,S=e.onResize,N=e.style,A=N===void 0?{}:N,E=XRe(e,FRe),O=v.useRef(null),R=v.useRef();R.current=S,v.useImperativeHandle(t,()=>O.current);var T=v.useState({containerWidth:i.width,containerHeight:i.height}),P=KRe(T,2),M=P[0],_=P[1],I=v.useCallback((Y,F)=>{_(K=>{var U=Math.round(Y),q=Math.round(F);return K.containerWidth===U&&K.containerHeight===q?K:{containerWidth:U,containerHeight:q}})},[]);v.useEffect(()=>{if(O.current==null||typeof ResizeObserver>"u")return Nh;var Y=W=>{var ne,ie=W[0];if(ie!=null){var V=ie.contentRect,H=V.width,Q=V.height;I(H,Q),(ne=R.current)===null||ne===void 0||ne.call(R,H,Q)}};y>0&&(Y=MRe(Y,y,{trailing:!0,leading:!1}));var F=new ResizeObserver(Y),K=O.current.getBoundingClientRect(),U=K.width,q=K.height;return I(U,q),F.observe(O.current),()=>{F.disconnect()}},[I,y]);var L=M.containerWidth,D=M.containerHeight;Gk(!n||n>0,"The aspect(%s) must be greater than zero.",n);var z=C9(L,D,{width:o,height:c,aspect:n,maxHeight:p}),G=z.calculatedWidth,X=z.calculatedHeight;return Gk(L<0||D<0||G!=null&&G>0||X!=null&&X>0,`The width(%s) and height(%s) of chart should be greater than 0,
please check the style of container, or the props width(%s) and height(%s),
diff --git a/desktop-tauri/ui/m/mobile.js b/desktop-tauri/ui/m/mobile.js
index 00bbed110..51b489dab 100644
--- a/desktop-tauri/ui/m/mobile.js
+++ b/desktop-tauri/ui/m/mobile.js
@@ -87,4 +87,4 @@ description: Describe when to use this skill.
`)})]},_.path))]}):s==="skills"?r.jsxs(r.Fragment,{children:[T?r.jsxs(r.Fragment,{children:[r.jsx(pt,{htmlFor:"agent-skill-name",children:c("Skill 目录名")}),r.jsx(yt,{id:"agent-skill-name",placeholder:"my-skill",value:M,disabled:j,onChange:_=>I(_.currentTarget.value)})]}):r.jsx("code",{className:"break-all text-xs",children:V?.path}),V?.description?r.jsx("p",{className:"text-xs text-muted-foreground",children:V.description}):null,r.jsx(Ti,{rows:16,className:"font-mono",value:S,disabled:j||V?.linked,onChange:_=>N(_.currentTarget.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:c("删除只移除 SKILL.md,辅助文件保留在原目录;不会执行其中的脚本。")})]}):r.jsxs(r.Fragment,{children:[r.jsx(pt,{htmlFor:"agent-mcp-name",children:c("MCP 服务名称")}),r.jsx(yt,{id:"agent-mcp-name",value:M,disabled:!T||j,onChange:_=>I(_.currentTarget.value)}),r.jsx(pt,{htmlFor:"agent-mcp-config",children:c("客户端原生 MCP 配置(JSON)")}),r.jsx(Ti,{id:"agent-mcp-config",rows:14,className:"font-mono",value:S,disabled:j,onChange:_=>N(_.currentTarget.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:c("仅修改所选 MCP 条目,保留其它配置和注释;保存不会启动服务。")})]}),b?r.jsx(nn,{variant:"destructive",children:b}):null]}),r.jsxs(Ii,{children:[K&&O?r.jsx(ee,{variant:"outline",className:"mr-auto",disabled:j,onClick:()=>{G(null),x("")},children:c("返回编辑")}):null,r.jsx(ee,{variant:"outline",disabled:j,onClick:H,children:c("取消")}),K?r.jsx(ee,{variant:K.deleting?"destructive":"default",disabled:j,onClick:()=>{me()},children:c("确认")}):r.jsx(ee,{disabled:j||V?.linked||T&&!M.trim(),onClick:W,children:c("预览并保存")})]})]})})]})}const D6=(e,s,a)=>Ce(s,{method:e,body:a});function _6(){const[e,s]=v.useState(null),[a,l]=v.useState(""),[c,d]=v.useState(""),[m,g]=v.useState({}),h=async()=>{try{const x=await f5();s(x.clients||[]),l("")}catch(x){l(x instanceof Error?x.message:String(x))}};Is(h,12e4);const y=ds({onRefresh:h}),b=async x=>{if(x.id){d(x.id);try{const j=await m5(x.id);if(!await qa(r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("p",{children:u("恢复作用在网关所在机器;密钥已隐藏,不会覆盖应用后的外部修改。")}),j.warnings.map((S,N)=>r.jsx("p",{children:S},N)),j.files.map(S=>r.jsxs("div",{children:[r.jsx("code",{className:"break-all",children:S.path}),r.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre text-[11px]",children:S.diff.filter(N=>N.kind!=="same").map(N=>`${N.kind==="added"?"+":"−"} ${N.text}`).join(`
`)})]},S.path))]}),{title:u("撤销上次应用"),confirmText:u("确认恢复")}))return;await p5(x.id,j.token),ce.toast(u("配置已恢复并校验")),await h()}catch(j){ce.toast(j instanceof Error?j.message:String(j),"err")}finally{d("")}}};return r.jsxs("div",{className:"m-page",ref:y.bindRef,children:[r.jsx(fs,{pull:y.pull,refreshing:y.refreshing}),r.jsx(vr,{subtitle:u("改写网关所在机器上的客户端配置"),actions:r.jsx(zs,{name:"refresh",label:u("刷新"),onClick:()=>{h()}})}),r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsx(Ue,{className:"m-card m-card-pad",style:{background:"var(--m-warn-soft)",borderColor:"color-mix(in srgb, var(--m-warn) 24%, transparent)"},children:r.jsxs("div",{style:{fontSize:12.3,lineHeight:1.6,color:"var(--m-text-2)"},children:[u("手机端可查看模型配置、撤销上次应用,并管理提示词、Skill 与 MCP。"),r.jsx("b",{style:{color:"var(--m-text)"},children:u("所有操作作用在网关所在机器。")})]})})}),a?r.jsx(is,{text:a}):null,e?null:r.jsx(_r,{rows:3,height:96}),e&&!e.length?r.jsx("div",{className:"m-section",children:r.jsx(Ue,{className:"m-card",children:r.jsx(on,{text:u("没有检测到可接管的客户端")})})}):null,(e||[]).map(x=>r.jsx("div",{className:"m-section",style:{marginTop:10},children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx(wh,{name:"agent"}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600},children:x.name||x.id}),r.jsx("div",{className:"m-mono",style:{fontSize:11,color:"var(--m-text-3)",marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.resolvedPath||x.configPath||"—"})]}),r.jsx(Mn,{tone:x.viaGateway?"ok":"mute",children:x.viaGateway?u("接入本网关"):u("未接入本网关")})]}),r.jsx(Rr,{className:"mt-3",value:m[x.id||""]||"config",onValueChange:j=>g(E=>({...E,[x.id||""]:j})),"aria-label":u("客户端管理分类"),options:[{value:"config",label:u("模型配置")},{value:"prompt",label:u("提示词")},{value:"skills",label:"Skill"},{value:"mcp",label:"MCP"}]}),m[x.id||""]&&m[x.id||""]!=="config"?r.jsx(M6,{clientId:x.id||"",kind:m[x.id||""],capabilities:x.resources,request:D6,t:u,notify:(j,E)=>ce.toast(j,E?"err":"ok")}):null,r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:11,paddingTop:10,borderTop:"1px solid var(--m-line)",fontSize:11.5,color:"var(--m-text-3)"},children:[r.jsx("span",{children:x.detectionState==="missing"?u("未检测到"):x.detectionState==="uninitialized"?u("尚未初始化"):x.detectionState==="read_error"?u("读取失败"):x.detectionState==="unsupported"?u("仅可读取"):u("客户端原生配置")}),x.readError?r.jsx("span",{style:{color:"var(--m-danger)"},children:x.readError}):null,x.applied?.canUndo?r.jsxs(ee,{size:"touch-sm",variant:"outline",type:"button",className:"m-btn m-sm m-ghost",style:{marginLeft:"auto",height:28,fontSize:11.5,padding:"0 10px"},disabled:c===x.id,onClick:()=>{b(x)},children:[r.jsx(_e,{name:"refresh",style:{width:12,height:12}}),c===x.id?u("还原中…"):u("撤销上次应用")]}):null]})]})},x.id)),r.jsx("div",{className:"m-section",style:{paddingBottom:8},children:r.jsx(Ue,{className:"m-card m-card-pad",style:{fontSize:11.5,color:"var(--m-text-3)",lineHeight:1.7},children:u("接入状态来自客户端配置文件。恢复前显示差异;文件被其他程序修改时拒绝覆盖。")})})]})}function Lw(){const{servers:e,server:s,stack:a}=On(),l=a.length>0,[c,d]=v.useState(null),[m,g]=v.useState(""),[h,y]=v.useState(""),[b,x]=v.useState(!1),[j,E]=v.useState(""),[S,N]=v.useState(null),w=()=>{d("new"),g(""),y(""),E(""),N(null)},R=M=>{const I=e.find(A=>A.id===M);I&&(d(M),g(I.name),y(la(I.base)),E(""),N(null))},T=()=>{d(null),E(""),N(null)},B=async()=>{const M=M1(h);if(!M){E(u("地址格式不对。填「IP 或域名:端口」,可带 http:// 或 https://,例如 192.168.1.23:3065"));return}x(!0),E("");const I=await K1(M);if(x(!1),!I.ok){E(u("连不上这台网关。确认地址与端口正确、网关已启动,且已开启「局域网访问」;用 https 时还要确认证书有效"));return}N({version:I.version}),c==="new"?ce.addServer({name:m,base:M}):c&&ce.updateServer(c,{name:m,base:M}),d(null),N(null),ce.toast(u("已保存")),ce.refresh(!0).then(()=>{ce.get().stack.length>0&&ce.back()})};return r.jsxs("div",{className:"m-page",children:[l?r.jsx(vr,{subtitle:e.length?u("已添加 {n} 台",{n:e.length}):u("先添加一台网关"),actions:r.jsxs(ee,{size:"touch-sm",variant:"default",type:"button",className:"m-btn m-sm",onClick:w,disabled:c==="new",children:[r.jsx(_e,{name:"plus"}),u("添加")]})}):r.jsx(gc,{title:u("服务器"),subtitle:e.length?u("已添加 {n} 台",{n:e.length}):u("先添加一台网关"),actions:r.jsxs(ee,{size:"touch-sm",variant:"default",type:"button",className:"m-btn m-sm",onClick:w,disabled:c==="new",children:[r.jsx(_e,{name:"plus"}),u("添加")]})}),j?r.jsx(is,{text:j}):null,c?r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx("div",{style:{fontSize:13,fontWeight:600},children:u(c==="new"?"添加服务器":"编辑服务器")}),r.jsxs(pt,{style:{display:"block",marginTop:12},children:[r.jsx("span",{style:{fontSize:12,color:"var(--m-text-3)"},children:u("地址")}),r.jsx(yt,{value:h,onChange:M=>y(M.target.value),placeholder:"192.168.1.23:3065 或 https://gw.example.com",inputMode:"url",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,style:{width:"100%",boxSizing:"border-box",marginTop:5,height:44,padding:"0 12px",borderRadius:11,border:"1px solid var(--m-line-strong)",background:"var(--m-surface-2)",color:"var(--m-text)",fontSize:16,fontFamily:"var(--m-mono)"}})]}),r.jsx("div",{style:{fontSize:11.5,color:"var(--m-text-3)",marginTop:6,lineHeight:1.6},children:u("填「IP 或域名:端口」。协议可写 http:// 或 https://,不写默认 http;http 不写端口默认 3065,https 默认 443。地址里的 /m、/v1 会自动去掉。")}),r.jsxs(pt,{style:{display:"block",marginTop:12},children:[r.jsx("span",{style:{fontSize:12,color:"var(--m-text-3)"},children:u("备注名(可选)")}),r.jsx(yt,{value:m,onChange:M=>g(M.target.value),placeholder:u("例如:家里、公司"),style:{width:"100%",boxSizing:"border-box",marginTop:5,height:44,padding:"0 12px",borderRadius:11,border:"1px solid var(--m-line-strong)",background:"var(--m-surface-2)",color:"var(--m-text)",fontSize:16}})]}),r.jsxs("div",{className:"m-btn-row",style:{marginTop:14},children:[r.jsx(ee,{size:"touch",variant:"outline",type:"button",className:"m-btn m-ghost w-full",onClick:T,disabled:b,children:u("取消")}),r.jsx(ee,{size:"touch",variant:"default",type:"button",className:"m-btn w-full",onClick:()=>{B()},disabled:b||!h.trim(),children:u(b?"正在连接…":"连接并保存")})]})]})}):null,r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("已添加的服务器")}),e.length===0?r.jsx(Ue,{className:"m-card m-card-pad",style:{fontSize:12.5,color:"var(--m-text-2)",lineHeight:1.7},children:u("还没有添加服务器。点右上角「添加」,填入网关所在机器的 IP 或域名与端口。")}):r.jsx(Ue,{className:"m-card",children:e.map(M=>{const I=s?.id===M.id;return r.jsxs("div",{className:"m-row",children:[r.jsx("span",{className:"m-logo",style:I?{background:"var(--m-primary-soft)",borderColor:"transparent",color:"var(--m-primary)"}:void 0,children:r.jsx(_e,{name:"server"})}),r.jsxs(ee,{size:"default",variant:"ghost",type:"button",className:"m-grow",onClick:()=>{ce.switchServer(M.id),ce.refresh(!0).then(()=>{ce.get().stack.length>0&&ce.back()})},style:{border:0,background:"none",textAlign:"left",padding:0},children:[r.jsxs("div",{className:"m-t1",style:{display:"flex",alignItems:"center",gap:6},children:[M.name||la(M.base),I?r.jsx(Rn,{variant:"brand",shape:"tag",className:"m-badge m-badge-brand",style:{height:18,fontSize:10.5},children:u("当前")}):null]}),r.jsx("div",{className:"m-t2 m-mono",style:{fontSize:11.5},children:la(M.base)})]}),r.jsx(ee,{size:"icon-touch",variant:"outline",type:"button",className:"m-icon-btn","aria-label":u("编辑"),onClick:()=>R(M.id),style:{width:30,height:30,boxShadow:"none"},children:r.jsx(_e,{name:"edit"})}),r.jsx(ee,{size:"icon-touch",variant:"outline",type:"button",className:"m-icon-btn","aria-label":u("删除"),onClick:()=>{ce.deleteServer(M.id),ce.toast(u("已删除")),ce.refresh(!0)},style:{width:30,height:30,boxShadow:"none",color:"var(--m-danger)"},children:r.jsx(_e,{name:"trash"})})]},M.id)})})]}),r.jsx("div",{className:"m-section",style:{paddingBottom:8},children:r.jsx(Ue,{className:"m-card m-card-pad",style:{fontSize:11.5,color:"var(--m-text-3)",lineHeight:1.7},children:u("每台服务器的登录状态各自独立保存,切换后不用重新登录。地址改掉后需要重新登录。")})})]})}const z6=[{value:"daily",label:"每日签到"},{value:"onboarding",label:"新手福利"},{value:"plans",label:"活动福利"},{value:"growth",label:"成长任务"}];function I6(e){return e.status==="completed"||Number.isFinite(e.current)&&Number.isFinite(e.target)&&Number(e.target)>0&&Number(e.current)>=Number(e.target)}function L6(e,s){if(!e.supported||e.locked||e.status==="claimed")return!1;const a=I6(e);return s==="claim"?a:!e.unforgeable||a}function P6(e){const s=e?.modes;return!Array.isArray(s)||s.length===0?["checkin"]:s.filter(a=>typeof a=="string"&&a)}function Pw(e){const s=new URLSearchParams;for(const[l,c]of Object.entries(e))c!=null&&c!==""&&s.set(l,String(c));const a=s.toString();return a?`?${a}`:""}const Kl=e=>`/api/accounts/${encodeURIComponent(e)}`;function B6(e){return Ce("/api/checkin-center",{signal:e})}function U6(e){return Ce("/api/accounts/checkin",{method:"POST",body:e?{id:e}:{}})}function H6(e,s){return Ce("/api/checkin-activity",{method:"POST",body:{id:e,mode:s}})}function V6(e){return Ce("/api/auto-checkin",{method:"POST",body:{enabled:e}})}function Bw(e){return Ce("/api/checkin-schedules",{method:"POST",body:e})}function q6(e){return Ce(`/api/checkin-schedules/${encodeURIComponent(e)}/delete`,{method:"POST"})}function K6(e){return Ce(`/api/checkin-schedules/${encodeURIComponent(e)}/run`,{method:"POST"})}function Uw(e,s){return Ce("/api/checkin-keepalive",{method:"POST",body:{models:e,apiKeyId:s}})}function Hw(e){return Ce("/api/travel-schedule",{method:"POST",body:e})}function G6(){return Ce("/api/travel-schedule/run",{method:"POST"})}function $6(e,s){return Ce(`/api/checkin-records${Pw(e)}`,{signal:s})}function Y6(e,s=!1){return Ce(`/api/checkin-records${Pw(s?{all:1}:e)}`,{method:"DELETE"})}function F6(e,s=!1){return Ce(`${Kl(e)}/onboarding${s?"?refresh=1":""}`)}function X6(e){return Ce(`${Kl(e)}/onboarding/claim`,{method:"POST"})}function sg(e){return Ce(`${Kl(e)}/growth`)}function Q6(e,s,a){return Ce(`${Kl(e)}/growth/task`,{method:"POST",body:{code:s,mode:a}})}function Z6(e){return Ce(`${Kl(e)}/growth/travel`,{method:"POST"})}function W6(e,s){return Ce(`${Kl(e)}/growth/school`,{method:"POST",body:{lottery:s}})}function J6(){return Ce("/api/qoder-umid")}function eI(){return Ce("/api/qoder-umid/install",{method:"POST"})}function tI(e){if(!e||e.error?.trim())return!1;if(e.outcome!==void 0)return e.outcome==="claimed"||e.outcome==="done";if(e.success===!0||e.alreadyCompleted===!0)return!0;const s=e.msg??"";return!/可能|未能|未见|失败/.test(s)&&/已签到|已领取/.test(s)}function rg(e){if(e.error?.trim())return!1;const s=e.activity?.report?.succeeded===!0||e.activity?.webConversation?.succeeded===!0;return e.mode==="keepalive"?s||e.activity?.pokeSucceeded===!0:tI(e.claim)||s}function Vw(e){if(e.error?.trim()||e.claim?.error?.trim()||rg(e))return!1;const s=e.claim;return s?.outcome!==void 0?s.outcome==="inactive"||s.outcome==="ineligible":/没有可领取的签到活动|未下发每日积分活动|暂未给该账号下发每日积分活动|暂无可领取活动|等待重试/.test(s?.msg??"")}function qw(e){return e.error?.trim()||e.claim?.error?.trim()||e.claim?.msg?.trim()||e.activity?.error?.trim()||""}function ag(e,s=!1){const a=e.results??[];if(s&&a.length===1)return Kw(a[0]);const l=a.filter(g=>!rg(g)&&!Vw(g)),c=e.failedCount??(Array.isArray(e.failed)?e.failed.length:e.failed)??l.length,d=u("签到完成:{success}/{total} 成功,保活 {active},失败 {failed}",{success:Number(e.succeeded)||0,total:Number(e.total)||a.length,active:Number(e.active)||0,failed:c}),m=Array.isArray(e.failed)?e.failed:l.map(qw).filter(Boolean);return{text:m.length>0?`${d}(${m.slice(0,5).join(";")})`:d,tone:c>0?"err":Number(e.succeeded)>0||Number(e.active)>0?"ok":"warn"}}function Kw(e){const s=rg(e);return{text:qw(e)||u(s?"执行完成":"未完成,请查看签到记录"),tone:s?"ok":Vw(e)?"warn":"err"}}function nI(e){switch(e){case"checkin":return u("签到");case"keepalive":return u("保活");case"claim":return u("领取");case"full":return u("保活 + 领取");default:return e}}function Gw(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const s=dj();return Object.entries(e).filter(([,a])=>{const l=Number(a);return Number.isFinite(l)&&l>0&&l<864e13-8*36e5&&dj(l)===s}).map(([a])=>a)}function sI(e){if(e==="all")return;const s=new Date(Date.now()+8*36e5),a=Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())-8*36e5;if(e==="today")return a;if(e==="month")return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),1)-8*36e5;const l=Number(e);return Number.isFinite(l)&&l>0?a-(l-1)*864e5:void 0}function Ud(e,s){return L6(e,s)}function rI({row:e,busy:s,action:a}){const[l,c]=v.useState(null),[d,m]=v.useState([]),g=l?.tasks?.tasks||[],h=async()=>{const x=await a(`growth-query:${e.id}`,()=>sg(e.id));x&&c(x)},y=async x=>{const j=g.filter(S=>Ud(S,x));if(!j.length)return;m([]);const E=await a(`growth-run:${e.id}`,async S=>{const N=[];for(const R of j){S();try{const T=await Q6(e.id,R.code,x);S(),N.push(T)}catch(T){S(),N.push({code:R.code,outcome:"failed",message:T instanceof Error?T.message:String(T)})}m([...N])}const w=await sg(e.id);return S(),c(w),N});if(E){const S=E.filter(N=>N.outcome==="failed"||N.error).length;ce.toast(u("执行完成:{n} 项,{failed} 项失败",{n:E.length,failed:S}),S?"err":"ok")}},b=async x=>{const j=await a(`growth-${x}:${e.id}`,async E=>{const S=x==="travel"?await Z6(e.id):await W6(e.id,x==="lottery");E();const N=await sg(e.id);return E(),c(N),S});j&&ce.toast(j.message||j.error||u("执行完成"),j.outcome==="failed"||j.error?"err":"ok")};return r.jsxs("div",{className:"m-card-pad m-ck-account",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx(Js,{id:e.provider}),r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:e.name||e.id}),l?r.jsx("div",{className:"m-ck-note",children:u("能量 {energy} · 连登 {streak} 天",{energy:l.energy??"—",streak:l.streak??"—"})}):null]}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s,onClick:()=>{h()},children:s===`growth-query:${e.id}`?u("查询中…"):u("查询任务")})]}),l?.tasks?.error?r.jsx("p",{className:"m-ck-error",children:l.tasks.error}):null,l?r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",disabled:!!s||!g.some(x=>Ud(x,"full")),onClick:()=>{y("full")},children:s===`growth-run:${e.id}`?u("执行中…"):u("一键完成")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||!g.some(x=>Ud(x,"claim")),onClick:()=>{y("claim")},children:u("领取奖励")})]}):null,g.map(x=>r.jsxs("div",{className:"m-ck-task",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{children:x.title||x.code}),x.target&&x.target>1?r.jsxs("div",{className:"m-ck-note",children:[x.current||0," / ",x.target]}):null,d.find(j=>j.code===x.code)?.message?r.jsx("div",{className:"m-ck-note",children:d.find(j=>j.code===x.code)?.message}):null]}),r.jsx(Mn,{tone:x.status==="claimed"?"ok":!x.supported||x.unforgeable||x.locked?"mute":"warn",children:x.status==="claimed"?u("已领取"):Ud(x,"claim")?u("可领取"):x.unforgeable?u("需真实操作"):x.supported?x.locked?u("未解锁"):u("待完成"):u("不支持")})]},x.code)),l?r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s,onClick:()=>{b("travel")},children:u("猫猫旅行一趟")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s,onClick:()=>{b("school")},children:u("开学季任务")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s,onClick:()=>{b("lottery")},children:u("开学季 + 抽奖")})]}):r.jsx("p",{className:"m-ck-note",children:u("查询后查看任务清单,仅执行插件标记为支持的任务")})]})}const $w=()=>window.wbAliyunCaptcha;let jc=null;function Yw(){const e=$w();return e?Promise.resolve(e):jc||(jc=new Promise((s,a)=>{const l=document.createElement("script"),c=window.setTimeout(()=>d(new Error(u("验证码组件加载超时,请重试"))),15e3),d=m=>{window.clearTimeout(c),l.onload=null,l.onerror=null;const g=$w();m||!g?(l.remove(),a(m||new Error(u("验证码组件未加载,请重试")))):s(g)};l.src=new URL("aliyun-captcha.js",document.baseURI).href,l.onload=()=>d(),l.onerror=()=>d(new Error(u("验证码组件加载失败,请重试"))),document.head.appendChild(l)}).catch(s=>{throw jc=null,s}),jc)}const Hd=e=>`/api/accounts/${encodeURIComponent(e)}`;function aI(e){return Ce(`${Hd(e)}/zcode-claim/preview`,{method:"POST"})}async function iI(e,s,a,l){const c=oe(),d=()=>{if(a?.aborted||oe()!==c)throw new DOMException("请求已取消","AbortError")};d(),l?.("preparing");const m=await Ce(`${Hd(e)}/zcode-claim/captcha-config`,{method:"POST",signal:a});if(d(),!m||typeof m.enabled!="boolean")throw new Error(u("风控验证配置不完整,请稍后重试"));const g=b=>(d(),l?.("submitting"),Ce(`${Hd(e)}/zcode-claim`,{method:"POST",body:{planId:s,captchaVerifyParam:b,captchaRegion:m.region||""}}));if(!m.enabled)return g("");const h=await Yw();d();const y=await h.solve({...m,region:m.region||"cn"},async b=>{const x=await g(b);return{captchaResult:x.failure!=="captcha",bizResult:!!x.ok,result:x}},a,{protocol:"v3",onPhase:l});return d(),y.result}function Fw(e){return Ce("/api/zcode/captcha",{signal:e})}async function lI(e,s,a){const l=oe(),c=()=>{if(s?.aborted||oe()!==l)throw new DOMException("请求已取消","AbortError")};c(),a?.("preparing");const d=await Ce(`${Hd(e)}/zcode-claim/captcha-config`,{method:"POST",signal:s});c();const m=await Fw(s);if(c(),m.required===!1)return!1;const g=await Yw();c();const h=await g.requestToken(d,s,{onPhase:a});if(c(),a?.("submitting"),(await Ce("/api/zcode/captcha",{method:"POST",body:{tokens:[{param:h.param,region:d.region||""}]}})).accepted!==1)throw new Error(u("验证码令牌未全部入池"));return!0}function oI({accountId:e,disabled:s,onBusy:a}){const[l,c]=v.useState(null),[d,m]=v.useState(""),[g,h]=v.useState(""),y=v.useRef(null),b=v.useRef(!0),x=oe(),j=v.useCallback(async(w=!1)=>{try{const R=await Fw();b.current&&oe()===x&&(c(R),w&&h(""))}catch(R){b.current&&oe()===x&&h(R instanceof Error?R.message:String(R))}},[x]);v.useEffect(()=>(b.current=!0,j(),()=>{b.current=!1,y.current?.abort(),a?.(!1)}),[e,j,a]);async function E(){if(y.current||s)return;const w=new AbortController;y.current=w,h(""),m("preparing"),a?.(!0);try{await lI(e,w.signal,R=>{b.current&&m(R)})}catch(R){b.current&&!w.signal.aborted&&R?.name!=="CaptchaCancelledError"&&h(R instanceof Error?R.message:String(R))}finally{y.current===w&&(y.current=null),b.current&&oe()===x&&(m(""),a?.(!1),j())}}const S=g||l?.error||l?.configError,N=l?.required===!1?u("当前模型请求免人机验证"):Number(l?.ready)>0?u("验证码令牌:{counts}",{counts:`${l?.ready} / ${l?.target||3}`}):l?.needsTokens?u("套餐池请求需要验证,请主动开始验证后重试请求"):u("没有近期套餐池请求,不生成验证码令牌");return r.jsxs("section",{className:"m-ck-account",children:[r.jsx("div",{className:"m-ck-title",children:u("套餐池人机验证")}),r.jsx("p",{className:S?"m-ck-error":"m-ck-note",children:S||(l?N:u("读取中…"))}),r.jsx("p",{className:"m-ck-note",children:u("后台只读取状态,不会自动弹出验证码;验证结果一次性使用,短时间内过期。")}),r.jsxs("div",{className:"m-ck-actions",children:[l?.required!==!1&&Number(l?.startPlanAccounts)>0?r.jsx(ee,{size:"sm",variant:"outline",disabled:s||!!d||!!(l?.error||l?.configError),onClick:()=>{E()},children:u(d?"正在验证…":"开始验证")}):null,d?r.jsx(ee,{size:"sm",variant:"outline",disabled:d==="submitting",onClick:()=>y.current?.abort(),children:u("取消验证")}):null,r.jsx(ee,{size:"sm",variant:"ghost",disabled:s||!!d,onClick:()=>{j(!0)},children:u("刷新")})]})]})}function Vd(e){return e?Ds(e*1e3):""}function Xw(e){const s=e.period==="daily"?u("每日"):e.period==="weekly"?u("每周"):e.period==="monthly"?u("每月"):"";return[e.showName,e.grantUnits?`${dc(e.grantUnits)} ${e.unitType||""}`:"",s].filter(Boolean).join(" · ")}function cI(e){return e==="active"?{label:u("生效中"),tone:"ok"}:e==="pending"?{label:u("待生效"),tone:"warn"}:{label:u(e==="expired"?"已过期":"状态未知"),tone:"mute"}}function uI({entry:e,onClose:s}){const{session:a}=On(),[l,c]=v.useState(null),[d,m]=v.useState(null),[g,h]=v.useState(""),[y,b]=v.useState(""),[x,j]=v.useState(""),[E,S]=v.useState(!0),[N,w]=v.useState(!1),[R,T]=v.useState(""),[B,M]=v.useState(""),[I,A]=v.useState(!1),[L,O]=v.useState([]),z=v.useRef(!0),K=v.useRef(null),G=oe(),U=a?.accounts?.accounts?.find(W=>W.id===e.id)?.claimPlans,X=[...new Set([...Gw(U||e.claimPlans),...L])],q=Array.isArray(d?.usage?.plans)?d.usage.plans:[],Y=X.filter(W=>!q.some(me=>me.planId===W)),$=v.useCallback(async()=>{if(!(!z.current||oe()!==G)){S(!0);try{const W=await aI(e.id);z.current&&oe()===G&&(c(W),h(""))}catch(W){z.current&&oe()===G&&h(W instanceof Error?W.message:String(W))}finally{z.current&&oe()===G&&S(!1)}}},[e.id,G]),V=v.useCallback(async()=>{if(!(!z.current||oe()!==G)){w(!0);try{const W=await fh(e.id);if(!z.current||oe()!==G)return;const me=W.results?.find(k=>k.id===e.id);m(me||null),j(me?.error||(me?"":u("未返回余额数据")))}catch(W){z.current&&oe()===G&&j(W instanceof Error?W.message:String(W))}finally{z.current&&oe()===G&&w(!1)}}},[e.id,G]);v.useEffect(()=>{z.current=!0;const W=new AbortController;return $(),uc(W.signal).then(me=>{if(W.signal.aborted||!z.current||oe()!==G)return;const k=me.results?.find(_=>_.id===e.id);k?(m(k),j(k.error||"")):V()}).catch(()=>{!W.signal.aborted&&z.current&&oe()===G&&V()}),()=>{z.current=!1,W.abort(),K.current?.abort()}},[e.id,G,$,V]);const H=async W=>{if(K.current||I||!z.current||oe()!==G)return;const me=new AbortController;K.current=me,T(W),M("preparing");try{const k=await iI(e.id,W,me.signal,_=>{z.current&&M(_)});if(me.signal.aborted||!z.current||oe()!==G)return;if(k.ok||k.failure==="already_claimed"){b(k.marketingError||"");const _=k.planId||W;O(J=>[...new Set([...J,_])]),ce.toast(k.ok?u("领取成功:{planId}",{planId:_}):k.failureLabel||u("今日已领")),ce.refresh(!0),V(),$()}else ce.toast([k.failureLabel||u("未领取成功"),k.message].filter(Boolean).join(":"),"err")}catch(k){!me.signal.aborted&&z.current&&oe()===G&&k?.name!=="CaptchaCancelledError"&&ce.toast(k instanceof Error?k.message:String(k),"err")}finally{K.current===me&&(K.current=null),z.current&&oe()===G&&(T(""),M(""))}},P=()=>{B!=="submitting"&&K.current?.abort()},re=()=>{B!=="submitting"&&(P(),s())};return r.jsx(xn,{open:!0,modal:!R&&!I,onOpenChange:(W,me)=>{if(!W){if(B==="submitting"||(R||I)&&["outside-press","focus-out"].includes(me.reason)){me.cancel();return}re()}},children:r.jsxs(yn,{showCloseButton:B!=="submitting",children:[r.jsx(bn,{children:r.jsx(vn,{children:u("套餐明细 — {name}",{name:e.name||e.id})})}),r.jsxs(jn,{children:[r.jsx(oI,{accountId:e.id,disabled:!!R,onBusy:A}),r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("div",{className:"m-ck-title m-ck-grow",children:u("可领取的套餐")}),r.jsx(ee,{variant:"outline",size:"sm",disabled:E||!!R,onClick:()=>{$()},children:u("刷新")})]}),g?r.jsx("p",{className:"m-ck-error",children:g}):null,E?r.jsx("p",{className:"m-ck-note",children:u("正在探测可领取的套餐…")}):!g&&!l?.plans?.length?r.jsx("p",{className:"m-ck-note",children:l?.previewError||l?.marketingError?u("部分套餐来源查询失败,暂不能确认是否有可领取套餐"):u("当前没有可领取的套餐")}):null,l?.plans?.map(W=>{const me=W.planId||"",k=X.includes(me)||W.claimed===!0,_=(W.entitlements||[]).map(se=>Number(se.effectiveAt)).filter(se=>Number.isFinite(se)&&se>Date.now()/1e3),J=_.length?Math.min(..._):0;return r.jsxs("div",{className:"m-ck-account",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("div",{className:"m-ck-title m-ck-grow",children:W.name||me}),k?r.jsx(Mn,{tone:"ok",children:u("已领取")}):null]}),J?r.jsx("p",{className:"m-ck-note",children:u("待生效 {time}",{time:Vd(J)})}):null,W.endsAt?r.jsx("p",{className:"m-ck-note",children:u("到期 {time}",{time:Vd(W.endsAt)})}):null,W.entitlements?.map((se,be)=>r.jsx("p",{className:"m-ck-note",children:Xw(se)},be)),W.description?r.jsx("p",{className:"m-ck-note",children:W.description}):null,r.jsx("div",{className:"m-ck-actions",children:r.jsx(ee,{size:"sm",disabled:!!R||I||k||!me,onClick:()=>{H(me)},children:u(R===me?"领取中…":k?"已领取":"领取")})})]},me||W.name)}),l?.previewError||l?.marketingError?r.jsx("p",{className:"m-ck-note",children:u("部分套餐来源查询失败,已保留其他来源的结果:{message}",{message:[l.previewError,l.marketingError].filter(Boolean).join(";")})}):null,y?r.jsx("p",{className:"m-ck-note",children:u("套餐已领取,但营销回执未完成,不会重复领取:{message}",{message:y})}):null,l?.activationError?r.jsx("p",{className:"m-ck-note",children:l.activationError}):null,r.jsx("p",{className:"m-ck-note",children:u("可领取清单合并每日赠送与限时营销活动;按套餐去重,已领取的不重复提交。只有主动领取时才会进行人机验证。")}),r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("div",{className:"m-ck-title m-ck-grow",children:u("我的套餐")}),r.jsx(ee,{variant:"outline",size:"sm",disabled:N||!!R,onClick:()=>{V()},children:u(N?"查询中…":"查询余额")})]}),x?r.jsx("p",{className:"m-ck-error",children:x}):null,q.map(W=>{const me=cI(W.state);return r.jsxs("div",{className:"m-ck-account",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:W.name||W.planId}),r.jsx(Mn,{tone:me.tone,children:me.label})]}),W.pendingUntil?r.jsx("p",{className:"m-ck-note",children:u("待生效 {time}",{time:Vd(W.pendingUntil)})}):null,W.endsAt?r.jsx("p",{className:"m-ck-note",children:u("到期 {time}",{time:Vd(W.endsAt)})}):null,W.entitlements?.map((k,_)=>r.jsx("p",{className:"m-ck-note",children:Xw(k)},_))]},W.planId||W.name)}),q.length?null:r.jsx("p",{className:"m-ck-note",children:u(N?"查询中…":"当前余额读数里没有套餐清单")}),Y.length?r.jsx("p",{className:"m-ck-note",children:u("今天已领取但读数尚未同步:{plans}",{plans:Y.join("、")})}):null]}),r.jsxs(rs,{children:[R?r.jsx(ee,{variant:"outline",disabled:B==="submitting",onClick:P,children:u("取消验证")}):null,r.jsx(ee,{variant:"outline",disabled:B==="submitting",onClick:re,children:u("关闭")})]})]})})}function dI({center:e,section:s,busy:a,action:l}){const[c,d]=v.useState(""),m=e.extras?.plans?.find(g=>g.id===c);return r.jsxs(r.Fragment,{children:[r.jsx("div",{hidden:s!=="onboarding",children:e.extras?.onboarding?.length?r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("新手福利")}),r.jsx(Ue,{className:"m-card",children:e.extras.onboarding.map(g=>r.jsx(fI,{row:g,busy:a,action:l},g.id))})]}):r.jsx(on,{text:u("没有支持新手福利的账号")})}),r.jsx("div",{hidden:s!=="plans",children:e.extras?.plans?.length?r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("活动福利")}),r.jsx(Ue,{className:"m-card",children:e.extras.plans.map(g=>{const h=Gw(g.claimPlans);return r.jsx("div",{className:"m-card-pad m-ck-account",children:r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx(Js,{id:g.provider}),r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:g.name||g.id}),r.jsx("div",{className:"m-ck-note",children:h.length?u("今天已领取 {n} 份",{n:h.length}):u("今天还没有领取")})]}),r.jsx(ee,{variant:"outline",size:"sm",disabled:!!a,onClick:()=>d(g.id),children:u("套餐明细")})]})},g.id)})})]}):r.jsx(on,{text:u("没有可领套餐的账号(ZCode 未添加)。")})}),r.jsx("div",{hidden:s!=="growth",children:e.extras?.growth?.length?r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("成长任务")}),r.jsx(Ue,{className:"m-card",children:e.extras.growth.map(g=>r.jsx(rI,{row:g,busy:a,action:l},g.id))})]}):r.jsx(on,{text:u("没有支持成长任务的账号(需要 WorkBuddy 国内版)。")})}),m?r.jsx(uI,{entry:m,onClose:()=>d("")},m.id):null]})}function Qw(e){return e.settled?{tasks:e.settled.tasks,earned:e.settled.earned??void 0,total:e.settled.total??void 0,unclaimed:0,settled:!0,settledAt:e.settled.at}:null}function fI({row:e,busy:s,action:a}){const[l,c]=v.useState(()=>Qw(e)),[d,m]=v.useState(""),g=l?l.settled===!0:!!e.settled,h=l?.settledAt||e.settled?.at;v.useEffect(()=>{const x=Qw(e);c(j=>x??(j?.settled?null:j))},[e.settled]);const y=async()=>{m("");const x=await a(`onboarding-query:${e.id}`,()=>F6(e.id,!0));x&&c(x)},b=async()=>{const x=await a(`onboarding-claim:${e.id}`,()=>X6(e.id));if(!x)return;c(x);const j=Number(x.failed)||0,E=x.message||u("领取完成:{n} 项,+{points} 积分,{failed} 项失败",{n:Number(x.claimed)||0,points:Number(x.claimedPoints)||0,failed:j});m(j>0?E:""),ce.toast(E,j>0?"err":"ok")};return r.jsxs("div",{className:"m-card-pad m-ck-account",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx(Js,{id:e.provider}),r.jsx("div",{className:"m-ck-title m-ck-grow",children:e.name||e.id}),g?r.jsx(Mn,{tone:"ok",children:u("已领取")}):null]}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{variant:"outline",size:"sm",disabled:!!s,onClick:()=>{y()},children:s===`onboarding-query:${e.id}`?u("查询中…"):u("查询任务")}),r.jsx(ee,{size:"sm",disabled:!!s||g||!l||!l.tasks?.some(x=>!x.done&&!x.blocked),onClick:()=>{b()},children:s===`onboarding-claim:${e.id}`?u("领取中…"):u("领取福利")})]}),g?r.jsxs("p",{className:"m-ck-note",children:[u("一次性福利已结清,无需重复查询"),h?` · ${u("结算于 {time}",{time:Ds(h)})}`:""]}):null,d?r.jsx("p",{className:"m-ck-error",children:d}):null,l?.tasks?.map(x=>r.jsxs("div",{className:"m-ck-task",children:[r.jsxs("span",{className:"m-ck-grow",children:[x.title||x.key,x.points?` · +${x.points}`:""]}),r.jsx(Mn,{tone:x.done?"ok":x.blocked?"mute":"warn",children:x.done?u("已领取"):x.blocked?u("未解锁"):u("待领取")})]},x.key)),!l&&!g?r.jsx("p",{className:"m-ck-note",children:u("点击查询后查看任务,领取操作由网关执行")}):null]})}function mI(){const[e,s]=v.useState(null),[a,l]=v.useState(!1),[c,d]=v.useState(""),m=oe(),g=async()=>{try{const y=await J6();oe()===m&&(s(y),d(""))}catch(y){oe()===m&&d(y instanceof Error?y.message:String(y))}};Is(g,e?.installing?3e3:6e4);const h=async()=>{if(!a){l(!0);try{const y=await eI();if(oe()!==m)return;s(y),await g()}catch(y){oe()===m&&ce.toast(y instanceof Error?y.message:String(y),"err")}finally{l(!1)}}};return r.jsxs("div",{className:"m-card-pad",children:[r.jsxs("p",{className:"m-ck-note",children:[u("网关设备组件"),": ",e?.available?u("已就绪"):e?.installing?u("安装中…"):u("未就绪")]}),e?.installSupported&&!e.available?r.jsx(ee,{variant:"outline",size:"sm",disabled:a||e.installing,onClick:()=>{h()},children:a||e.installing?u("安装中…"):u("在网关安装组件")}):null,c?r.jsx("p",{className:"m-ck-error",children:c}):null]})}function pI({center:e,busy:s,action:a,onRecords:l}){const[c,d]=v.useState("daily"),m=z6.map(j=>({...j,label:u(j.label)})),g=e.daily,h=g?.providers||[],y=Object.keys(e.checkinFeatures||{}).length>0||h.length>0,b=h.some(j=>j.accounts?.length>0),x=async(j,E="checkin")=>{if(E==="checkin"){const N=await a(j||"all",()=>U6(j));if(N){const w=ag(N,!!j);ce.toast(w.text,w.tone)}return}const S=await a(j||"all",()=>H6(j||"",E));if(S){const N=Kw(S);ce.toast(N.text,N.tone)}};return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{children:[r.jsx("div",{className:"m-ck-title",children:u("今日签到 {done} / {total}",{done:g?.todayDone||0,total:g?.todayEligible||0})}),r.jsx("div",{className:"m-ck-note",children:e.auto?.running?u("自动签到执行中…"):e.auto?.enabled?u("自动签到已开启"):u("自动签到已关闭")})]}),r.jsx(ee,{size:"sm",disabled:!!s||e.auto?.running||!b,onClick:()=>{x()},children:u(s==="all"?"签到中…":"全部签到")})]}),r.jsx(ee,{size:"sm",variant:"ghost",onClick:l,children:u("查看签到记录")})]})}),r.jsx("div",{className:"m-section",children:r.jsx(Rr,{options:m,value:c,onValueChange:d,"aria-label":u("签到功能分类"),className:"m-checkin-tabs flex-wrap"})}),c==="daily"&&(!y||!b)?r.jsx("div",{className:"m-section",children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx("p",{className:"m-ck-note",children:u(y?"还没有可签到的账号。账号与插件均保存在所连接的网关上。":"还没有可签到的提供商。请安装或启用所连接网关的提供商插件。")}),r.jsx(ee,{size:"sm",variant:"outline",onClick:()=>ce.push(y?"accounts":"plugins"),children:u(y?"查看账号":"查看插件状态")})]})}):null,c==="daily"?h.filter(j=>j.accounts?.length>0).map(j=>r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u(j.label)}),r.jsxs(Ue,{className:"m-card",children:[j.description?r.jsx("p",{className:"m-ck-note m-card-pad",children:u(j.description)}):null,j.uiHooks?.includes("umid_component")?r.jsx(mI,{}):null,j.accounts.map(E=>r.jsxs("div",{className:"m-card-pad m-ck-account",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx(Js,{id:j.id,label:j.label}),r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:E.name||E.id}),r.jsxs("div",{className:"m-ck-note",children:[E.checkinAt?Ds(E.checkinAt):u("还没签到过"),E.streakDays>0?u(" · 连登 {n} 天",{n:E.streakDays}):""]})]}),r.jsx(Mn,{tone:E.available?E.checkedInToday?"ok":"warn":"bad",children:E.available?E.checkedInToday?u("今日已签"):u("待签"):u("凭证不可用")})]}),r.jsx("div",{className:"m-ck-actions",children:P6(j).map(S=>r.jsx(ee,{variant:"outline",size:"sm",disabled:!!s||e.auto?.running||!E.available||!["checkin","keepalive","claim","full"].includes(S),onClick:()=>{x(E.id,S)},children:s===E.id?u("执行中…"):nI(S)},S))})]},E.id))]})]},j.id)):null,c==="daily"&&g?.outOfScope?.length?r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("不参与每日签到")}),r.jsx(Ue,{className:"m-card",children:g.outOfScope.map(j=>r.jsxs("div",{className:"m-card-pad m-ck-account",children:[r.jsxs("div",{className:"m-ck-title",children:[u(j.label)," ×",j.count]}),r.jsx("div",{className:"m-ck-note",children:u(j.reason)})]},`${j.label}:${j.reason}`))})]}):null,r.jsx(dI,{center:e,section:c,busy:s,action:a}),c==="daily"&&!h.length&&!e.extras?.onboarding?.length&&!e.extras?.plans?.length&&!e.extras?.growth?.length?r.jsx(on,{text:u("安装插件并添加账号后,支持的签到与福利会自动显示")}):null]})}function hI({center:e,busy:s,action:a}){const l=new Set(e.adminPanels||[]);return r.jsxs(r.Fragment,{children:[l.has("daily_keepalive")&&e.keepalive?r.jsx(gI,{center:e,busy:s,action:a}):null,l.has("growth_tasks")&&e.travel?r.jsx(xI,{center:e,busy:s,action:a}):null]})}function gI({center:e,busy:s,action:a}){const[l,c]=v.useState(null),d=yw(()=>Ce("/api/model-access/keys")),m=l??e.keepalive.models.join(`
`),g=async()=>{const h=[...new Set(m.split(/[\n,,、]+/).map(b=>b.trim()).filter(Boolean))];await a("keepalive",()=>Uw(h),u("模型链已保存"))&&c(null)};return r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("保活模型链")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx(bw,{...d,value:e.keepalive.apiKeyId??null,disabled:!!s,onRefresh:()=>{d.refresh().catch(()=>{})},t:u,id:"keepalive-api-key",onChange:h=>{a("keepalive",()=>Uw(e.keepalive.models,h),u("保活 API Key 已保存"))}}),e.keepalive.authError?r.jsx("p",{role:"status",className:"m-ck-error",children:e.keepalive.authError}):null,r.jsx("p",{className:"m-ck-note",children:u("按顺序尝试免费模型,一行一个;清空并保存恢复默认链。")}),r.jsx(Ti,{className:"text-base",rows:4,value:m,disabled:!!s,"aria-label":u("保活模型链"),onChange:h=>c(h.currentTarget.value)}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s,onClick:()=>c(e.keepalive.defaultModels.join(`
-`)),children:u("填入缺省链")}),r.jsx(ee,{size:"sm",disabled:!!s||l===null,onClick:()=>{g()},children:u(s==="keepalive"?"保存中…":"保存")})]})]})]})}function xI({center:e,busy:s,action:a}){const[l,c]=v.useState(null),d=e.travel,m=l??(d.times||[]).join(", "),g=async()=>{const y=m.split(/[,,\s]+/).map(x=>x.trim()).filter(Boolean);if(!y.length||y.length>6||y.some(x=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(x))){ce.toast(u("请填写 1–6 个 HH:MM 时刻,以逗号分隔"),"err");return}await a("travel-save",()=>Hw({times:y}),u("已保存"))&&c(null)},h=async()=>{const y=await a("travel-run",G6);if(!y)return;const b=Number(y.summary?.failed)||0;ce.toast(y.outcome==="skipped"?y.message||u("本轮已跳过"):u("猫猫旅行:{n} 个动作,+{credit} 积分,{failed} 个失败",{n:y.summary?.actions?.length||0,credit:Number(y.summary?.credit)||0,failed:b}),b>0?"err":"ok")};return r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("猫猫旅行定时排程")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:u("自动巡检")}),r.jsx("div",{className:"m-ck-note",children:u("一趟推进一步,与签到排程互相独立")})]}),r.jsx(gn,{checked:d.enabled,disabled:!!s,"aria-label":u("自动巡检"),onCheckedChange:y=>{a("travel-toggle",()=>Hw({enabled:y}),u("已保存"))}})]}),d.available===!1?r.jsx("p",{className:"m-ck-note",children:u("自动巡检已暂停:{reason}",{reason:d.pausedReason||""})}):null,r.jsxs(pt,{className:"m-ck-field",children:[u("每天时刻(北京时间)"),r.jsx(yt,{className:"text-base",value:m,placeholder:"09:00, 21:00",disabled:!!s,onChange:y=>c(y.currentTarget.value)})]}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",disabled:!!s||l===null,onClick:()=>{g()},children:u("保存")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||d.running||d.available===!1,onClick:()=>{h()},children:s==="travel-run"||d.running?u("巡检中…"):u("立即巡检全部")})]}),d.firedToday?.length?r.jsx("p",{className:"m-ck-note",children:u("今天已执行:{times}",{times:d.firedToday.join(" / ")})}):null,d.lastResult?.at?r.jsx("p",{className:"m-ck-note",children:u("上次执行:{time}",{time:Ds(d.lastResult.at)})}):null,d.lastResult?.error?r.jsx("p",{className:"m-ck-error",children:d.lastResult.error}):null,d.lastResult?.actions?.map((y,b)=>r.jsxs("p",{className:"m-ck-note",children:[y.name||y.accountId,": ",y.message||y.outcome]},`${y.accountId}:${b}`))]})]})}const vI="00:10",yI=9;function Ya(e){return/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(e)?Number(e.slice(0,2))*60+Number(e.slice(3)):null}function ig(e){return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Zw(e){const s=Ya(e);return s===null?vI:ig(Math.min(1439,s+yI))}function lg(e,s){return wc(e,s??"")?s:Zw(e)}function wc(e,s){const a=Ya(e),l=Ya(s);return a!==null&&l!==null&&l>=a}function Ww(e,s,a){const l=Ya(e),c=Ya(s),d=Ya(lg(s,a));return l===null||c===null||d===null?e:ig(Math.min(1439,l+d-c))}function og(e,s){return s&&s!==e?`${e}–${s}`:e}function bI(e,s,a){const l=Ya(e),c=Ya(s);if(l===null||c===null)return"";const d=Math.max(c,l+Math.max(1,a));return d<1440?ig(d):""}function jI({center:e,busy:s,action:a}){const[l,c]=v.useState(null),[d,m]=v.useState(null),g=e.auto,h=g?.providerOptions||[],y=g?.schedules||[],b=(j,E)=>{a(`toggle:${j.id}`,()=>Bw({id:j.id,label:j.label,enabled:E,time:j.time,timeEnd:j.timeEnd,providers:j.providers}),u("已保存"))},x=async j=>{const E=await a(`run:${j}`,()=>K6(j));if(E){const S=ag(E);ce.toast(S.text,S.tone)}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-section",style:{marginTop:0},children:[r.jsx(Jt,{title:u("定时签到")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:u("总开关")}),r.jsx("div",{className:"m-ck-note",children:g?.enabled?u("启用的计划在各自区间内随机签到"):u("所有定时签到条目均已暂停")})]}),r.jsx(gn,{checked:g?.enabled===!0,disabled:!!s,"aria-label":u("定时签到总开关"),onCheckedChange:j=>{a("master",()=>V6(j),u("已保存"))}})]}),r.jsx("p",{className:"m-ck-note",children:u("北京时间 · 错过区间会补跑未执行账号,重启保留当天安排;任务在网关执行,关闭手机不影响排程。")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||!h.length,onClick:()=>c("new"),children:u("添加条目")})]})]}),y.map(j=>r.jsx("div",{className:"m-section",children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:j.displayLabel||j.label||j.time}),r.jsx("div",{className:"m-ck-note",children:u("每天 {time}",{time:og(j.time,lg(j.time,j.timeEnd))})})]}),r.jsx(gn,{checked:j.enabled,disabled:!!s,"aria-label":j.displayLabel||j.time,onCheckedChange:E=>b(j,E)})]}),r.jsx("p",{className:"m-ck-note",children:j.providers.map(E=>u(h.find(S=>S.id===E)?.label||E)).join("、")}),(j.providerRows||[]).length?r.jsxs("p",{className:"m-ck-note",children:[j.providerRows.map(E=>{const S=Number(E.accountCount)>0?u("已执行 {n} / {total} 个账号",{n:E.attemptedCount||0,total:E.accountCount||0}):u("没有可执行账号");return`${u(E.label)} ${og(E.time,E.timeEnd)} · ${S}`}).join(" · "),j.retryTime?u(" · 补签在主签到区间结束后执行"):"",Number(j.retryCount)>0?u(" · {n} 个账号等窗口重试",{n:j.retryCount}):"",Number(j.retryExhausted?.length??0)>0?u(" · {n} 个账号今日重试已用完",{n:j.retryExhausted?.length??0}):""]}):null,r.jsxs("p",{className:"m-ck-note",children:[j.nextRunAt?u("下次执行:{time}",{time:Ds(j.nextRunAt)}):u("未安排下次执行"),j.lastResult?.at?u(" · 上次执行:{time}",{time:Ds(j.lastResult.at)}):""]}),j.lastResult?r.jsx("p",{className:"m-ck-note",children:ag(j.lastResult).text}):null,r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||g?.running,onClick:()=>{x(j.id)},children:s===`run:${j.id}`?u("执行中…"):u("立即执行")}),r.jsx(ee,{size:"sm",variant:"ghost",disabled:!!s,onClick:()=>c(j),children:u("编辑")}),r.jsx(ee,{size:"sm",variant:"ghost",disabled:!!s,className:"text-destructive",onClick:()=>m(j),children:u("删除")})]})]})},j.id)),y.length?null:r.jsx(on,{text:u("还没有定时条目,添加一条或到签到中心手动签到")}),r.jsx(hI,{center:e,busy:s,action:a}),l?r.jsx(wI,{entry:l==="new"?null:l,options:h,busy:s,action:a,onClose:()=>c(null)},typeof l=="string"?l:l.id):null,r.jsx(xn,{open:!!d,onOpenChange:(j,E)=>{if(!j){if(s){E.cancel();return}m(null)}},children:r.jsxs(yn,{showCloseButton:!s,children:[r.jsx(bn,{children:r.jsx(vn,{children:u("删除定时签到条目")})}),r.jsx(jn,{children:r.jsx("p",{className:"m-ck-note",children:u("确定删除「{name}」?删除后到点不再执行。",{name:d?.displayLabel||d?.time||""})})}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:!!s,onClick:()=>m(null),children:u("取消")}),r.jsx(ee,{variant:"destructive",disabled:!!s,onClick:async()=>{if(!d)return;await a(`delete:${d.id}`,()=>q6(d.id),u("已删除"))!==void 0&&m(null)},children:u(s?"删除中…":"删除")})]})]})})]})}function wI({entry:e,options:s,busy:a,action:l,onClose:c}){const[d,m]=v.useState(e?.label||""),[g,h]=v.useState(e?.time||"00:01"),[y,b]=v.useState(lg(e?.time||"00:01",e?.timeEnd)),[x,j]=v.useState(e?.providers||s.map(O=>O.id)),[E,S]=v.useState(e?.providerTimes||{}),[N,w]=v.useState(e?.retryTime??"00:10"),[R,T]=v.useState(String(e?.retryGapMinutes??10)),[B,M]=v.useState(String(e?.retryLimit??3)),I=x.filter(O=>!s.some(z=>z.id===O)),A=[...s,...I.map(O=>({id:O,label:O}))],L=async()=>{if(!wc(g,y)||!x.length){ce.toast(u("请填写合法区间,结束不早于开始,并至少选择一家提供商。"),"err");return}const O={};for(const[K,G]of Object.entries(E))G&&(O[K]=G);await l("schedule-save",()=>Bw({...e?{id:e.id}:{},label:d.trim(),time:g,timeEnd:y,enabled:e?e.enabled:!0,providers:x,providerTimes:O,retryTime:N.trim(),retryGapMinutes:Number(R)||0,retryLimit:Number(B)||0}),u("已保存"))&&c()};return r.jsx(xn,{open:!0,onOpenChange:(O,z)=>{if(!O){if(a){z.cancel();return}c()}},children:r.jsxs(yn,{showCloseButton:!a,children:[r.jsx(bn,{children:r.jsx(vn,{children:u(e?"编辑定时条目":"新建定时条目")})}),r.jsxs(jn,{children:[r.jsxs(pt,{className:"m-ck-field",children:[u("名称(可选)"),r.jsx(yt,{className:"text-base",value:d,disabled:!!a,onChange:O=>m(O.currentTarget.value)})]}),r.jsxs(pt,{className:"m-ck-field",children:[u("随机签到开始"),r.jsx(yt,{type:"time",className:"text-base",value:g,disabled:!!a,onChange:O=>{const z=O.currentTarget.value;h(z),wc(z,y)||b(Zw(z))}})]}),r.jsxs(pt,{className:"m-ck-field",children:[u("随机签到结束"),r.jsx(yt,{type:"time",className:"text-base",value:y,disabled:!!a,onChange:O=>b(O.currentTarget.value)})]}),r.jsx("p",{className:"m-ck-note",children:u("每个账号每天在区间内随机执行一次;开始与结束相同则按固定时刻执行。")}),r.jsx("div",{className:"m-ck-title",children:u("各家区间起点")}),r.jsx("p",{className:"m-ck-note",children:u("专属或自定义时间作为区间起点,沿用默认区间长度;每天重新随机,重启不改变当天安排。")}),A.filter(O=>x.includes(O.id)).map(O=>{const z=s.find(G=>G.id===O.id)?.builtinTime||"",K=E[O.id]||"";return r.jsxs(pt,{className:"m-ck-field",children:[u(O.label),z?u("(专属 {time})",{time:z}):"",r.jsx(yt,{type:"time",className:"text-base",value:K||z||g,disabled:!!a,onChange:G=>S(F=>({...F,[O.id]:G.currentTarget.value}))}),r.jsx("span",{className:"m-ck-note font-mono",children:og(K||z||g,Ww(K||z||g,g,y))})]},`time-${O.id}`)}),r.jsx("p",{className:"m-ck-note",children:u("补签在主签到区间结束后执行,只补未签到账号。")}),N&&wc(g,y)?r.jsx("p",{className:"m-ck-note",children:A.filter(O=>x.includes(O.id)).map(O=>{const z=E[O.id]||s.find(F=>F.id===O.id)?.builtinTime||g,K=Ww(z,g,y),G=bI(K,N,Number(R)||0);return`${u(O.label)} · ${u("实际补签")} ${G||"—"}`}).join(" · ")}):null,r.jsxs(pt,{className:"m-ck-field",children:[u("补签时刻(只补今天没签上的账号,清空 = 关闭)"),r.jsx(yt,{type:"time",className:"text-base",value:N,disabled:!!a,onChange:O=>w(O.currentTarget.value)})]}),r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs(pt,{className:"m-ck-grow",children:[u("窗口重试间隔(分钟,0 = 关闭)"),r.jsx(yt,{type:"number",className:"text-base",value:R,disabled:!!a,onChange:O=>T(O.currentTarget.value)})]}),r.jsxs(pt,{className:"m-ck-grow",children:[u("最多重试次数(0 = 关闭)"),r.jsx(yt,{type:"number",className:"text-base",value:B,disabled:!!a,onChange:O=>M(O.currentTarget.value)})]})]}),r.jsx("div",{className:"m-ck-title",children:u("签到范围")}),A.map(O=>r.jsxs(pt,{className:"m-ck-toolbar",children:[r.jsx(lp,{checked:x.includes(O.id),disabled:!!a,onCheckedChange:z=>{j(K=>z?[...new Set([...K,O.id])]:K.filter(G=>G!==O.id))}}),r.jsxs("span",{className:"m-ck-grow m-ck-note",children:[u(O.label),I.includes(O.id)?u("(插件未就绪,保留原配置)"):""]})]},O.id))]}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:!!a,onClick:c,children:u("取消")}),r.jsx(ee,{disabled:!!a||!wc(g,y)||!x.length,onClick:()=>{L()},children:u(a?"保存中…":"保存")})]})]})})}const ua=30;function SI(e){switch(e){case"success":return{label:u("成功领取"),tone:"ok"};case"already":return{label:u("今日已领"),tone:"brand"};case"pending":return{label:u("未领取"),tone:"warn"};case"failed":return{label:u("失败"),tone:"bad"};default:return{label:e||"—",tone:"mute"}}}function EI(e){switch(e){case"schedule":return u("定时");case"startup":return u("补签");case"manual":return u("手动");case"single":return u("单签");case"activity":return u("活动");default:return e||"—"}}function CI({providers:e}){const[s,a]=v.useState("all"),[l,c]=v.useState("all"),[d,m]=v.useState("all"),[g,h]=v.useState(""),[y,b]=v.useState(""),[x,j]=v.useState(0),[E,S]=v.useState(null),[N,w]=v.useState(""),[R,T]=v.useState(!1),[B,M]=v.useState(!1),[I,A]=v.useState(null),L=v.useRef(null),O=oe(),z=[{value:"all",label:u("全部时间")},{value:"today",label:u("今天")},{value:"7",label:u("7 天")},{value:"30",label:u("30 天")},{value:"month",label:u("本月")}],K=[{value:"all",label:u("全部结果")},{value:"success",label:u("成功领取")},{value:"already",label:u("今日已领")},{value:"pending",label:u("未领取")},{value:"failed",label:u("失败")}],G=[{value:"all",label:u("全部提供商")},...e.map(H=>({value:H.id,label:u(H.label)}))],F=v.useCallback(()=>({start:sI(s),outcome:l==="all"?void 0:l,provider:d==="all"?void 0:d,keyword:y||void 0}),[s,l,d,y]),U=v.useCallback(async()=>{L.current?.abort();const H=new AbortController;L.current=H,T(!0);try{const P=await $6({...F(),offset:x,limit:ua},H.signal);if(H.signal.aborted||oe()!==O)return;if(x>0&&x>=P.total){j(Math.max(0,Math.ceil(P.total/ua)-1)*ua);return}S(P),w("")}catch(P){!H.signal.aborted&&oe()===O&&w(P instanceof Error?P.message:String(P))}finally{!H.signal.aborted&&oe()===O&&T(!1)}},[F,x,O]);v.useEffect(()=>(U(),()=>L.current?.abort()),[U]);const X=(H,P)=>{H(P||"all"),j(0)},q=async()=>{if(!(!I||B)){M(!0);try{const H=await Y6(F(),I==="all");if(oe()!==O)return;A(null),ce.toast(u("已删除 {n} 条签到记录",{n:H.removed})),x>0?j(0):await U()}catch(H){oe()===O&&ce.toast(H instanceof Error?H.message:String(H),"err")}finally{M(!1)}}},Y=E?.total||0,$=s!=="all"||l!=="all"||d!=="all"||!!y,V=[{value:s,options:z,label:u("时间范围"),setter:a},{value:l,options:K,label:u("结果"),setter:c},{value:d,options:G,label:u("提供商"),setter:m}];return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-section",style:{marginTop:0},children:[r.jsx(Jt,{title:u("签到记录")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx("div",{className:"m-ck-filters",children:V.map(H=>r.jsxs(Rs,{value:H.value,disabled:B,onValueChange:P=>X(H.setter,P),children:[r.jsx(Os,{className:"h-10 text-sm","aria-label":H.label,children:r.jsx(As,{children:H.options.find(P=>P.value===H.value)?.label||H.value})}),r.jsx(Ms,{children:H.options.map(P=>r.jsx(An,{value:P.value,children:P.label},P.value))})]},H.label))}),r.jsxs("form",{className:"m-ck-toolbar",onSubmit:H=>{H.preventDefault(),b(g.trim()),j(0)},children:[r.jsx(yt,{type:"search",className:"text-base",value:g,placeholder:u("搜索账号 / 说明"),disabled:B,"aria-label":u("搜索账号 / 说明"),onChange:H=>h(H.currentTarget.value)}),r.jsx(ee,{type:"submit",size:"sm",variant:"outline",disabled:B,children:u("搜索")})]}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:R||B,onClick:()=>{U()},children:u("刷新")}),$?r.jsx(ee,{size:"sm",variant:"ghost",className:"text-destructive",disabled:B||!Y,onClick:()=>A("filtered"),children:u("清空筛选结果")}):null,r.jsx(ee,{size:"sm",variant:"ghost",className:"text-destructive",disabled:B,onClick:()=>A("all"),children:u("清空全部")})]}),r.jsx("p",{className:"m-ck-note",children:u("共 {n} 条",{n:Y})})]})]}),N?r.jsx(is,{text:N}):null,!E&&R?r.jsx(on,{text:u("正在读取签到记录…")}):E?.records?.length?null:r.jsx(on,{text:u("这段时间里还没有签到记录")}),E?.records?.map((H,P)=>{const re=SI(H.outcome);return r.jsx("div",{className:"m-section",children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("div",{className:"m-ck-title m-ck-grow",children:H.accountName||H.accountId||"—"}),r.jsx(Mn,{tone:re.tone,children:re.label})]}),r.jsxs("p",{className:"m-ck-note",children:[Ds(H.ts)," · ",e.find(W=>W.id===H.provider)?.label||H.provider||"—"," · ",EI(H.source)]}),r.jsx("p",{className:H.error?"m-ck-error":"m-ck-note",children:H.message||H.error||(H.keptActive?u("保活成功"):"—")}),H.reason?r.jsx("p",{className:"m-ck-note",children:H.reason}):null]})},`${H.ts}:${H.accountId}:${P}`)}),Y>ua?r.jsxs("div",{className:"m-section m-ck-toolbar",children:[r.jsx(ee,{variant:"outline",size:"sm",disabled:R||x===0,onClick:()=>j(H=>Math.max(0,H-ua)),children:u("上一页")}),r.jsxs("span",{className:"m-ck-note",children:[Math.floor(x/ua)+1," / ",Math.ceil(Y/ua)]}),r.jsx(ee,{variant:"outline",size:"sm",disabled:R||x+ua>=Y,onClick:()=>j(H=>H+ua),children:u("下一页")})]}):null,r.jsx(xn,{open:!!I,onOpenChange:(H,P)=>{if(!H){if(B){P.cancel();return}A(null)}},children:r.jsxs(yn,{showCloseButton:!B,children:[r.jsx(bn,{children:r.jsx(vn,{children:u(I==="all"?"清空全部签到记录":"清空筛选结果")})}),r.jsx(jn,{children:r.jsx("p",{className:"m-ck-note",children:I==="all"?u("确定清空全部签到记录?清空后无法恢复。"):u("确定删除当前筛选命中的 {n} 条签到记录?清空后无法恢复。",{n:Y})})}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:B,onClick:()=>A(null),children:u("取消")}),r.jsx(ee,{variant:"destructive",disabled:B,onClick:()=>{q()},children:u(B?"删除中…":"删除")})]})]})})]})}function NI(){const e=ce.get().route.params?.tab,[s,a]=v.useState(e==="records"||e==="schedule"?e:"center"),[l,c]=v.useState(null),[d,m]=v.useState(""),[g,h]=v.useState(""),y=v.useRef(""),b=v.useRef(!0),x=oe();v.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const j=v.useCallback(async()=>{if(!(!b.current||oe()!==x))try{const w=await B6();if(!b.current||oe()!==x)return;c(w),m("")}catch(w){b.current&&oe()===x&&m(w instanceof Error?w.message:String(w))}},[x]),E=async(w,R,T)=>{if(y.current||!b.current||oe()!==x)return;const B=()=>{if(!b.current||oe()!==x)throw new DOMException("请求已取消","AbortError")};y.current=w,h(w);try{const M=await R(B);return B(),await Promise.all([j(),ce.refresh(!0)]),B(),T&&ce.toast(T),M}catch(M){b.current&&oe()===x&&ce.toast(M instanceof Error?M.message:String(M),"err");return}finally{y.current="",b.current&&oe()===x&&h("")}};Is(j,l?.auto?.running||l?.travel?.running||s==="schedule"&&l?.auto?.enabled?3e3:3e4);const S=ds({onRefresh:j}),N=[{value:"center",label:u("签到中心")},{value:"schedule",label:u("定时签到")},{value:"records",label:u("签到记录")}];return r.jsxs("div",{className:"m-page",ref:S.bindRef,children:[r.jsx(fs,{pull:S.pull,refreshing:S.refreshing}),r.jsx(vr,{subtitle:u("页面由手机端提供,签到能力由所连接网关的插件提供")}),r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsx(Rr,{options:N,value:s,onValueChange:a,"aria-label":u("签到中心标签页"),className:"m-checkin-tabs"})}),d?r.jsx(is,{text:d}):null,!l&&s!=="records"?r.jsx(_r,{rows:3,height:92}):null,l&&s==="center"?r.jsx(pI,{center:l,busy:g,action:E,onRecords:()=>a("records")}):null,l&&s==="schedule"?r.jsx(jI,{center:l,busy:g,action:E}):null,s==="records"?r.jsx(CI,{providers:l?.auto?.providerOptions||[]}):null]})}function Ir(e){return Bd(e,u,"plugin")}function TI(e){return Ce("/api/plugins",{signal:e})}function kI(){return Ce("/api/plugins/release")}function RI(){return Ce("/api/plugins/update")}function AI(e,s,a=!1){return Ce(a?"/api/plugins/update":"/api/plugins/install-from-release",{method:"POST",body:{id:e,target:s}})}function OI(e,s){return Ce("/api/plugins/enable",{method:"POST",body:{id:e,enabled:s}})}function MI(e,s,a){return Ce("/api/plugins/provider",{method:"POST",body:{id:e,provider:s,enabled:a}})}function DI(e){return Ce("/api/plugins/uninstall",{method:"POST",body:{id:e}})}function _I(e){return Ce("/api/plugins/settings",{signal:e})}function zI(e){return Ce("/api/plugins/settings",{method:"PATCH",body:e})}function Jw({operation:e}){if(!e)return null;const s=e.stage==="downloading"?u("网关正在下载…"):e.stage==="verifying"?u("网关正在校验…"):u("网关正在安装…");return r.jsxs(r.Fragment,{children:[e.active?r.jsxs("div",{className:"my-3","aria-live":"polite",children:[r.jsxs("p",{className:"m-ck-note",children:[e.required?`${u("正在补齐插件…")} · `:"",s,e.stage==="downloading"&&e.percent!=null?` ${Math.round(e.percent)}%`:""]}),r.jsx(Hu,{value:e.stage==="downloading"?e.percent:null,"aria-label":s})]}):null,e.error?r.jsx("p",{className:"m-ck-error",children:Ir(e.error)}):null,e.hostError?r.jsx("p",{className:"m-ck-error",children:e.hostError}):null]})}function eS({name:e,version:s,icon:a}){return r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-logo",children:a?r.jsx("img",{src:a,alt:""}):e.slice(0,1)}),r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:u(e)}),r.jsx("div",{className:"m-ck-note",children:s?`v${s}`:u("暂未发布")})]})]})}function II({item:e,target:s,busy:a,operation:l,onInstall:c}){const d=e.platforms?.find(m=>m.target===s);return r.jsxs(Ue,{render:r.jsx("article",{}),className:"m-card m-card-pad",children:[r.jsx(eS,{name:e.name||e.id,version:e.version,icon:e.icon}),r.jsx("p",{className:"m-ck-note",children:u(e.description)}),e.official?r.jsx(Mn,{tone:"brand",children:u("官方")}):null,e.reason?r.jsx("p",{className:e.error?"m-ck-error":"m-ck-note",children:Ir(e.reason)}):null,r.jsx(Jw,{operation:l}),l?.active?null:r.jsx("div",{className:"m-ck-actions",children:r.jsx(ee,{size:"sm",disabled:a||!d||!e.version||e.error,onClick:c,children:u("在网关下载并安装")})}),d?null:r.jsx("p",{className:"m-ck-note",children:u("当前网关平台暂无插件包")})]})}function LI({pack:e,target:s,busy:a,update:l,operation:c,onEnabled:d,onProvider:m,onUpdate:g,onRemove:h}){const y=e.updateRequired===!0,b=a||c?.active===!0;return r.jsxs(Ue,{render:r.jsx("article",{}),className:"m-card m-card-pad",children:[r.jsx(eS,{name:e.name||e.id,version:e.version,icon:e.icon}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(Mn,{tone:e.enabled?"ok":"mute",children:e.enabled?u("已启用"):u("已停用")}),r.jsx(Mn,{tone:e.signed?"ok":"warn",children:e.signed?u("已签名"):u("未签名")}),y?r.jsx(Mn,{tone:"warn",children:u("需要补齐插件")}):null,r.jsx(Mn,{tone:e.providers?.some(x=>x.loaded)?"ok":"warn",children:u("已加载 {n} 家",{n:e.providers?.filter(x=>x.loaded).length||0})})]}),e.description?r.jsx("p",{className:"m-ck-note",children:u(e.description)}):null,y?r.jsxs("div",{className:"mt-3 rounded-md border border-destructive/30 px-3 py-2","aria-live":"polite",children:[r.jsx("p",{className:"m-ck-error",children:u("当前网关要求插件版本不低于 v{version},补齐前暂不加载。",{version:e.requiredVersion||""})}),r.jsx("p",{className:"m-ck-note",children:e.signed?u("正在自动补齐官方插件,不受日常更新开关和通道限制。"):u("未签名包不会自动覆盖;点击「补齐插件」将安装官方签名包。")}),l?.reason?r.jsx("p",{className:l.error?"m-ck-error":"m-ck-note",children:Ir(l.reason)}):null,l?.retryAt&&l.retryAt>Date.now()?r.jsx("p",{className:"m-ck-note",children:u("下次自动重试:{time}",{time:new Date(l.retryAt).toLocaleString()})}):null]}):null,e.entryPresent?null:r.jsx("p",{className:"m-ck-error",children:u("插件文件缺失,请重新安装插件包")}),e.host?.lastError?r.jsx("p",{className:"m-ck-error",children:e.host.lastError}):null,l?.reason&&!y?r.jsx("p",{className:l.error?"m-ck-error":"m-ck-note",children:Ir(l.reason)}):null,r.jsx(Jw,{operation:c}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsxs(pt,{className:"m-ck-toolbar m-ck-note",children:[u("启用"),r.jsx(gn,{checked:e.enabled,disabled:b,"aria-label":u("启用插件 {name}",{name:e.name}),onCheckedChange:d})]}),r.jsx(ee,{size:"sm",variant:"outline",disabled:b,onClick:h,children:u("卸载")}),y?r.jsx(ee,{size:"sm",disabled:b||l?.repairing===!0,onClick:g,children:l?.repairing?u("正在补齐插件…"):u("补齐插件")}):l?.available?r.jsx(ee,{size:"sm",disabled:b||l.error||!l.asset||l.asset.target!==s,onClick:g,children:u("更新到 v{version}",{version:l.latest||""})}):null]}),r.jsxs(p1,{className:"mt-3 border-t border-hairline pt-3",children:[r.jsx(h1,{className:"m-ck-title",children:u("提供商启停")}),r.jsx(g1,{keepMounted:!0,children:e.providers?.map(x=>r.jsxs(pt,{className:"m-ck-toolbar py-2",children:[r.jsx(gn,{checked:x.enabled,disabled:b||!e.enabled,"aria-label":u(x.label),onCheckedChange:j=>m(x.id,j)}),r.jsx("span",{className:"m-ck-note m-ck-grow",children:u(x.label)}),x.enabled&&!x.loaded?r.jsx(Mn,{tone:"warn",children:u("未加载")}):null]},x.id))})]})]})}function PI({onClose:e,onChanged:s}){const[a,l]=v.useState(null),[c,d]=v.useState(""),[m,g]=v.useState(""),[h,y]=v.useState(!1),b=oe(),x=[{value:"follow",label:u("跟随软件")},{value:"custom",label:u("单独设置")}];v.useEffect(()=>{const w=new AbortController;return _I(w.signal).then(R=>{w.signal.aborted||(l(R),d(String(R.interval)))}).catch(R=>{w.signal.aborted||g(R instanceof Error?R.message:String(R))}),()=>w.abort()},[]);async function j(w){if(h||!a)return;const R={...a,...w};if(w.channelMode!=="follow"&&!R.stable&&!R.beta){g(u("至少需要关注正式版或 beta 版中的一个通道"));return}y(!0);try{const T=await zI(w);if(oe()!==b)return;l(T),d(String(T.interval)),g(""),ce.toast(T.saved===!1?u("设置已生效,但写入磁盘失败(重启后会恢复原设置)"):u("插件设置已保存"),T.saved===!1?"err":"ok"),("beta"in w||"stable"in w||"channelMode"in w)&&await s()}catch(T){oe()===b&&g(T instanceof Error?T.message:String(T))}finally{y(!1)}}const E=[{key:"autoUpdate",label:u("自动更新插件"),note:u("检测到更新后自动下载、校验并安装已启用的官方签名插件。关闭此项不影响最低版本补齐;未签名或第三方插件仍需手动更新。")},{key:"autoInstallOfficial",label:u("自动下载官方插件"),note:u("开启期间卸载的官方插件也会重新安装。")}],S=()=>{const w=Number(c);if(!Number.isInteger(w)||w<1||w>1440){g(u("检查间隔必须是 {min} ~ {max} 分钟",{min:1,max:1440}));return}j({interval:w})},N=a?.stable&&a.beta?u("正式版与 beta 版"):a?.beta?u("仅 beta 版"):u("仅正式版");return r.jsx(xn,{open:!0,onOpenChange:(w,R)=>{if(!w){if(h){R.cancel();return}e()}},children:r.jsxs(yn,{showCloseButton:!h,children:[r.jsx(bn,{children:r.jsx(vn,{children:u("插件设置")})}),r.jsxs(jn,{children:[r.jsx("p",{className:"m-ck-note",children:u("以下设置属于所连接网关,不是手机本地设置。")}),r.jsx("div",{className:"m-ck-title",children:u("检查计划")}),r.jsxs(Rs,{value:a?.checkMode||"follow",disabled:h||!a,onValueChange:w=>{j({checkMode:w})},children:[r.jsx(Os,{className:"w-full","aria-label":u("检查计划"),children:r.jsx(As,{children:x.find(w=>w.value===(a?.checkMode||"follow"))?.label})}),r.jsx(Ms,{children:x.map(w=>r.jsx(An,{value:w.value,children:w.label},w.value))})]}),a?.checkMode==="custom"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:u("自动检查插件更新")}),r.jsx(gn,{checked:a.autoCheck,disabled:h,"aria-label":u("自动检查插件更新"),onCheckedChange:w=>{j({autoCheck:w===!0})}})]}),r.jsxs(pt,{className:"m-ck-field",children:[u("检查间隔(分钟)"),r.jsx(yt,{type:"number",min:1,max:1440,step:1,className:"text-base",value:c,disabled:h||!a.autoCheck,onChange:w=>d(w.currentTarget.value)})]}),r.jsx(ee,{variant:"outline",disabled:h||!a.autoCheck||Number(c)===a.interval,onClick:S,children:u("保存")})]}):r.jsx("p",{className:"m-ck-note",children:a?a.autoCheck?u("当前:自动检查开启,每 {n} 分钟",{n:a.interval}):u("当前:自动检查关闭"):u("读取中")}),r.jsx("p",{className:"m-ck-note",children:u("默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。")}),r.jsx("div",{className:"m-ck-title",children:u("更新通道")}),r.jsxs(Rs,{value:a?.channelMode||"follow",disabled:h||!a,onValueChange:w=>{j({channelMode:w})},children:[r.jsx(Os,{className:"w-full","aria-label":u("更新通道"),children:r.jsx(As,{children:x.find(w=>w.value===(a?.channelMode||"follow"))?.label})}),r.jsx(Ms,{children:x.map(w=>r.jsx(An,{value:w.value,children:w.label},w.value))})]}),a?.channelMode==="custom"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:u("关注正式版更新")}),r.jsx(gn,{checked:a.stable,disabled:h,"aria-label":u("关注正式版更新"),onCheckedChange:w=>{j({stable:w===!0})}})]}),r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:u("关注 beta 版更新")}),r.jsx(gn,{checked:a.beta,disabled:h,"aria-label":u("关注 beta 版更新"),onCheckedChange:w=>{j({beta:w===!0})}})]})]}):r.jsx("p",{className:"m-ck-note",children:a?u("当前关注:{channels}",{channels:N}):u("读取中")}),r.jsx("p",{className:"m-ck-note",children:u("默认跟随软件的正式版和 beta 关注选择;单独设置只影响日常更新,最低版本补齐按当前软件版本选择配套包。")}),E.map(w=>r.jsxs("div",{children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:w.label}),r.jsx(gn,{checked:a?.[w.key]===!0,disabled:h||!a,"aria-label":w.label,onCheckedChange:R=>{j({[w.key]:R===!0})}})]}),r.jsx("p",{className:"m-ck-note",children:w.note})]},w.key)),m?r.jsx("p",{className:"m-ck-error",children:m}):null,r.jsx(Aw,{})]})]})})}function BI(){const{server:e}=On(),[s,a]=v.useState(null),[l,c]=v.useState(""),[d,m]=v.useState(""),[g,h]=v.useState(!1),[y,b]=v.useState(null),x=v.useRef(!1),j=v.useRef(""),E=v.useRef(new Set),S=oe(),N=v.useCallback(async()=>{try{const z=await TI();if(oe()!==S)return;const K=JSON.stringify({packs:z.packs.map(G=>({id:G.id,version:G.version,enabled:G.enabled,providers:G.providers})),host:z.host});j.current!==K&&(j.current=K,ce.refresh(!0)),a(z),c("");for(const G of z.operations||[]){if(G.active)continue;const F=`${G.id}:${G.updatedAt}`;E.current.has(F)||(E.current.add(F),!(Date.now()-G.updatedAt>3e4)&&(G.error||G.hostError?ce.toast(Ir(G.error||G.hostError),"err"):G.done&&ce.toast(u("插件包已安装到 v{version}",{version:G.version}))))}}catch(z){oe()===S&&c(Ir(z))}},[S]);Is(N,s?.operations?.some(z=>z.active)?1500:1e4);const w=ds({onRefresh:N});async function R(z,K){if(!x.current){x.current=!0,m(z);try{const G=await K();return oe()!==S?void 0:(await N(),G)}catch(G){oe()===S&&ce.toast(Ir(G),"err");return}finally{x.current=!1,oe()===S&&m("")}}}async function T(z,K){return await R(z,async()=>{const F=await K();return oe()!==S||(await ce.refresh(!0),F.hostError&&ce.toast(F.hostError,"err")),F})!==void 0}const B=async()=>{const z=await R("catalog",kI);z?.error&&ce.toast(Ir(z.reason)||u("读取插件仓库失败"),"err")},M=async()=>{const z=await R("check",RI);z?.error&&ce.toast(Ir(z.reason)||u("检查更新失败"),"err")},I=async(z,K)=>{if(!s?.target)return;await R(`install:${z}`,()=>AI(z,s.target,K))&&ce.toast(u("下载任务已交给网关,关闭手机不影响安装"))},A=s?.packs||[],O=(s?.catalog?.plugins||[]).filter(z=>!A.some(K=>K.id===z.id));return r.jsxs("div",{className:"m-page",ref:w.bindRef,children:[r.jsx(fs,{pull:w.pull,refreshing:w.refreshing}),r.jsx(vr,{subtitle:u("管理所连接网关的插件,不在手机上安装提供商插件")}),r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx("div",{className:"m-ck-title",children:e?.name||e?.base||u("当前网关")}),r.jsx("p",{className:"m-ck-note",children:u("安装、更新与启停均作用在这台网关上。插件平台由网关决定,与手机系统无关。")}),s?r.jsx("p",{className:"m-ck-note m-mono",children:s.target}):null,r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:!!d,onClick:()=>{B()},children:u(d==="catalog"?"读取中…":"刷新插件仓库")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!d,onClick:()=>{M()},children:u(d==="check"?"检查中…":"检查更新")}),r.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>h(!0),children:u("插件设置")})]})]})}),l?r.jsx(is,{text:l}):null,s?.host?.lastError?r.jsx(is,{text:s.host.lastError}):null,O.length?r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("可安装插件")}),O.map(z=>r.jsx(II,{item:z,target:s?.target||"",operation:s?.operations?.find(K=>K.id===z.id),busy:!!d,onInstall:()=>{I(z.id,!1)}},z.id))]}):null,r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("已安装插件")}),A.map(z=>r.jsx(LI,{pack:z,busy:!!d,target:s?.target||"",update:s?.updates?.find(K=>K.id===z.id),operation:s?.operations?.find(K=>K.id===z.id),onEnabled:K=>{T(`enable:${z.id}`,()=>OI(z.id,K))},onProvider:(K,G)=>{T(`provider:${K}`,()=>MI(z.id,K,G))},onUpdate:()=>{I(z.id,!0)},onRemove:()=>b(z)},z.id)),A.length?null:r.jsx(Ue,{className:"m-card",children:r.jsx(on,{text:u(s?"这台网关还没有安装插件":"正在读取插件列表…")})})]}),s?.catalog?.reason?r.jsx("div",{className:"m-section",children:r.jsx("p",{className:"m-ck-note",children:Ir(s.catalog.reason)})}):null,s?r.jsx("div",{className:"m-section",children:r.jsxs(p1,{className:"m-card m-card-pad",children:[r.jsx(h1,{className:"m-ck-title",children:u("诊断信息")}),r.jsxs(g1,{keepMounted:!0,children:[r.jsxs("p",{className:"m-ck-note",children:[u("插件目录"),":",r.jsx("span",{className:"m-mono",children:s.pluginsDir})]}),r.jsxs("p",{className:"m-ck-note",children:[u("协议版本"),":",s.protocol]})]})]})}):null,g?r.jsx(PI,{onClose:()=>h(!1),onChanged:N}):null,r.jsx(xn,{open:!!y,onOpenChange:(z,K)=>{if(!z){if(d){K.cancel();return}b(null)}},children:r.jsxs(yn,{showCloseButton:!d,children:[r.jsx(bn,{children:r.jsx(vn,{children:u("卸载插件包")})}),r.jsx(jn,{children:r.jsx("p",{className:"m-ck-note",children:u("确定卸载「{name}」吗?对应提供商将停止转发,账号数据仍然保留,重新安装后恢复。",{name:y?.name||""})})}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:!!d,onClick:()=>b(null),children:u("取消")}),r.jsx(ee,{variant:"destructive",disabled:!!d,onClick:async()=>{y&&await T(`remove:${y.id}`,()=>DI(y.id))&&b(null)},children:u(d?"卸载中…":"卸载")})]})]})})]})}function UI({title:e,onBack:s,actions:a}){return r.jsxs(A1,{className:"m-navbar",children:[r.jsx(ee,{size:"icon-touch",variant:"outline",type:"button",className:"m-icon-btn",onClick:s,"aria-label":u("返回"),children:r.jsx(_e,{name:"back"})}),r.jsx("span",{className:"m-navbar-title",children:e}),r.jsx("span",{className:"m-navbar-slot",children:a})]})}function HI(){const e=On(),[s,a]=v.useState(null),[l,c]=v.useState(""),[d,m]=v.useState(!1);return v.useEffect(()=>{let g=!1;if(a(null),m(!1),e.packaged&&!e.server)return;const h=()=>{Ce(`/api/update/policy${e.packaged?`?current=${encodeURIComponent(zr)}`:""}`).then(b=>{g||(a(b.forceUpdate),c(b.currentVersion))}).catch(()=>{})};h();const y=setInterval(h,6e4);return()=>{g=!0,clearInterval(y)}},[e.serverRevision,e.packaged,e.server]),!s?.required||d&&e.route.screen==="settings"?null:r.jsx(La,{open:!0,onOpenChange:()=>{},children:r.jsxs(Ba,{showCloseButton:!1,children:[r.jsx(zi,{children:r.jsx(Pa,{children:u("需要强制更新")})}),r.jsxs(Ua,{children:[r.jsx(nn,{variant:"warning",children:s.message}),r.jsx("p",{children:u("当前版本 {current},最低可用版本 {minimum}。",{current:l,minimum:s.minimumVersion})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:u("更新前无法继续调用模型;账号、配置和历史记录不会被删除。")})]}),r.jsx(Ii,{children:r.jsx(ee,{onClick:()=>{ce.go("settings"),m(!0)},children:u("立即更新")})})]})})}const VI={home:{title:u("首页"),component:nD,primary:!0},report:{title:u("报表"),component:dD,primary:!0},accounts:{title:u("账号"),component:qD,primary:!0},assistant:{title:u("AI 助手"),component:pz,primary:!0},more:{title:u("更多"),component:hz,primary:!0},models:{title:u("模型管理"),component:gz},keys:{title:u("网关 Key"),component:jz},proxies:{title:u("网络代理"),component:Az},tasks:{title:u("定时任务"),component:Oz},requests:{title:u("请求日志"),component:_z},logs:{title:u("运行日志"),component:Bz},settings:{title:u("设置"),component:m6},docs:{title:u("接口文档"),component:A6},agent:{title:u("Agent 配置"),component:_6},servers:{title:u("服务器"),component:Lw},checkin:{title:u("签到中心"),component:NI},plugins:{title:u("网关插件"),component:BI}};function qI(){const e=On(),s=jh(),a=VI[e.route.screen],l=a.component,c=!!a.primary,d=e.route.screen==="assistant",m=e.packaged&&!e.server;return v.useEffect(()=>{E5(),ce.restoreFromHash(),(!e.packaged||e.server)&&ce.refresh(!0);const g=()=>ce.handlePopState();return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[]),v.useEffect(()=>{if(!e.packaged)return;let g,h=!1;return Promise.resolve().then(()=>GI).then(({App:y})=>{h||y.addListener("backButton",()=>{const b=document.querySelector('[data-slot="sheet-content"][data-open], [data-slot="dialog-content"][data-open]');if(b){b.querySelector('[data-slot="sheet-close"], [data-slot="dialog-close"]')?.click();return}ce.handleHardwareBack()||y.exitApp()}).then(b=>{h?b.remove():g=()=>{b.remove()}})}).catch(()=>{}),()=>{h=!0,g?.()}},[]),v.useEffect(()=>{document.title=m?`${u("服务器")} · Agent2API`:`${a.title} · Agent2API`},[a.title,m]),m?r.jsxs(Kp,{className:"m-app",children:[r.jsx(gj,{}),r.jsx("div",{className:"m-scroll","data-screen":"servers",children:r.jsx(Lw,{},e.serverRevision)}),r.jsx(hj,{})]}):r.jsxs(Kp,{className:"m-app","data-offline":s.offline?"true":void 0,children:[r.jsx(gj,{}),r.jsx(Y5,{}),c?null:r.jsx(UI,{title:a.title,onBack:()=>ce.back()}),r.jsx("div",{className:"m-scroll",style:d?{overflow:"hidden"}:void 0,"data-screen":e.route.screen,children:r.jsx(l,{},e.serverRevision)}),r.jsx(B5,{}),r.jsx(hj,{}),r.jsx(HI,{}),r.jsx(U5,{},e.serverRevision)]})}U1(e=>{ce.setAuthLost(e)}),q5();const tS=document.getElementById("root");tS?Yv.createRoot(tS).render(r.jsx(qI,{})):document.body.innerHTML='手机端挂载失败:页面缺少 #root 容器。
';const KI=Vl("App",{web:()=>Promise.resolve().then(()=>YI).then(e=>new e.AppWeb)}),GI=Object.freeze(Object.defineProperty({__proto__:null,App:KI},Symbol.toStringTag,{value:"Module"}));class $I extends _d{constructor(){super(),this.handleVisibilityChange=()=>{const s={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",s),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}const YI=Object.freeze(Object.defineProperty({__proto__:null,AppWeb:$I},Symbol.toStringTag,{value:"Module"}))})();
+`)),children:u("填入缺省链")}),r.jsx(ee,{size:"sm",disabled:!!s||l===null,onClick:()=>{g()},children:u(s==="keepalive"?"保存中…":"保存")})]})]})]})}function xI({center:e,busy:s,action:a}){const[l,c]=v.useState(null),d=e.travel,m=l??(d.times||[]).join(", "),g=async()=>{const y=m.split(/[,,\s]+/).map(x=>x.trim()).filter(Boolean);if(!y.length||y.length>6||y.some(x=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(x))){ce.toast(u("请填写 1–6 个 HH:MM 时刻,以逗号分隔"),"err");return}await a("travel-save",()=>Hw({times:y}),u("已保存"))&&c(null)},h=async()=>{const y=await a("travel-run",G6);if(!y)return;const b=Number(y.summary?.failed)||0;ce.toast(y.outcome==="skipped"?y.message||u("本轮已跳过"):u("猫猫旅行:{n} 个动作,+{credit} 积分,{failed} 个失败",{n:y.summary?.actions?.length||0,credit:Number(y.summary?.credit)||0,failed:b}),b>0?"err":"ok")};return r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("猫猫旅行定时排程")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:u("自动巡检")}),r.jsx("div",{className:"m-ck-note",children:u("一趟推进一步,与签到排程互相独立")})]}),r.jsx(gn,{checked:d.enabled,disabled:!!s,"aria-label":u("自动巡检"),onCheckedChange:y=>{a("travel-toggle",()=>Hw({enabled:y}),u("已保存"))}})]}),d.available===!1?r.jsx("p",{className:"m-ck-note",children:u("自动巡检已暂停:{reason}",{reason:d.pausedReason||""})}):null,r.jsxs(pt,{className:"m-ck-field",children:[u("每天时刻(北京时间)"),r.jsx(yt,{className:"text-base",value:m,placeholder:"09:00, 21:00",disabled:!!s,onChange:y=>c(y.currentTarget.value)})]}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",disabled:!!s||l===null,onClick:()=>{g()},children:u("保存")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||d.running||d.available===!1,onClick:()=>{h()},children:s==="travel-run"||d.running?u("巡检中…"):u("立即巡检全部")})]}),d.firedToday?.length?r.jsx("p",{className:"m-ck-note",children:u("今天已执行:{times}",{times:d.firedToday.join(" / ")})}):null,d.lastResult?.at?r.jsx("p",{className:"m-ck-note",children:u("上次执行:{time}",{time:Ds(d.lastResult.at)})}):null,d.lastResult?.error?r.jsx("p",{className:"m-ck-error",children:d.lastResult.error}):null,d.lastResult?.actions?.map((y,b)=>r.jsxs("p",{className:"m-ck-note",children:[y.name||y.accountId,": ",y.message||y.outcome]},`${y.accountId}:${b}`))]})]})}const vI="00:10",yI=9;function Ya(e){return/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(e)?Number(e.slice(0,2))*60+Number(e.slice(3)):null}function ig(e){return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Zw(e){const s=Ya(e);return s===null?vI:ig(Math.min(1439,s+yI))}function lg(e,s){return wc(e,s??"")?s:Zw(e)}function wc(e,s){const a=Ya(e),l=Ya(s);return a!==null&&l!==null&&l>=a}function Ww(e,s,a){const l=Ya(e),c=Ya(s),d=Ya(lg(s,a));return l===null||c===null||d===null?e:ig(Math.min(1439,l+d-c))}function og(e,s){return s&&s!==e?`${e}–${s}`:e}function bI(e,s,a){const l=Ya(e),c=Ya(s);if(l===null||c===null)return"";const d=Math.max(c,l+Math.max(1,a));return d<1440?ig(d):""}function jI({center:e,busy:s,action:a}){const[l,c]=v.useState(null),[d,m]=v.useState(null),g=e.auto,h=g?.providerOptions||[],y=g?.schedules||[],b=(j,E)=>{a(`toggle:${j.id}`,()=>Bw({id:j.id,label:j.label,enabled:E,time:j.time,timeEnd:j.timeEnd,providers:j.providers}),u("已保存"))},x=async j=>{const E=await a(`run:${j}`,()=>K6(j));if(E){const S=ag(E);ce.toast(S.text,S.tone)}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-section",style:{marginTop:0},children:[r.jsx(Jt,{title:u("定时签到")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:u("总开关")}),r.jsx("div",{className:"m-ck-note",children:g?.enabled?u("启用的计划在各自区间内随机签到"):u("所有定时签到条目均已暂停")})]}),r.jsx(gn,{checked:g?.enabled===!0,disabled:!!s,"aria-label":u("定时签到总开关"),onCheckedChange:j=>{a("master",()=>V6(j),u("已保存"))}})]}),r.jsx("p",{className:"m-ck-note",children:u("北京时间 · 错过区间会补跑未执行账号,重启保留当天安排;任务在网关执行,关闭手机不影响排程。")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||!h.length,onClick:()=>c("new"),children:u("添加条目")})]})]}),y.map(j=>r.jsx("div",{className:"m-section",children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:j.displayLabel||j.label||j.time}),r.jsx("div",{className:"m-ck-note",children:u("每天 {time}",{time:og(j.time,lg(j.time,j.timeEnd))})})]}),r.jsx(gn,{checked:j.enabled,disabled:!!s,"aria-label":j.displayLabel||j.time,onCheckedChange:E=>b(j,E)})]}),r.jsx("p",{className:"m-ck-note",children:j.providers.map(E=>u(h.find(S=>S.id===E)?.label||E)).join("、")}),(j.providerRows||[]).length?r.jsxs("p",{className:"m-ck-note",children:[j.providerRows.map(E=>{const S=Number(E.accountCount)>0?u("已执行 {n} / {total} 个账号",{n:E.attemptedCount||0,total:E.accountCount||0}):u("没有可执行账号");return`${u(E.label)} ${og(E.time,E.timeEnd)} · ${S}`}).join(" · "),j.retryTime?u(" · 补签在主签到区间结束后执行"):"",Number(j.retryCount)>0?u(" · {n} 个账号等窗口重试",{n:j.retryCount}):"",Number(j.retryExhausted?.length??0)>0?u(" · {n} 个账号今日重试已用完",{n:j.retryExhausted?.length??0}):""]}):null,r.jsxs("p",{className:"m-ck-note",children:[j.nextRunAt?u("下次执行:{time}",{time:Ds(j.nextRunAt)}):u("未安排下次执行"),j.lastResult?.at?u(" · 上次执行:{time}",{time:Ds(j.lastResult.at)}):""]}),j.lastResult?r.jsx("p",{className:"m-ck-note",children:ag(j.lastResult).text}):null,r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:!!s||g?.running,onClick:()=>{x(j.id)},children:s===`run:${j.id}`?u("执行中…"):u("立即执行")}),r.jsx(ee,{size:"sm",variant:"ghost",disabled:!!s,onClick:()=>c(j),children:u("编辑")}),r.jsx(ee,{size:"sm",variant:"ghost",disabled:!!s,className:"text-destructive",onClick:()=>m(j),children:u("删除")})]})]})},j.id)),y.length?null:r.jsx(on,{text:u("还没有定时条目,添加一条或到签到中心手动签到")}),r.jsx(hI,{center:e,busy:s,action:a}),l?r.jsx(wI,{entry:l==="new"?null:l,options:h,busy:s,action:a,onClose:()=>c(null)},typeof l=="string"?l:l.id):null,r.jsx(xn,{open:!!d,onOpenChange:(j,E)=>{if(!j){if(s){E.cancel();return}m(null)}},children:r.jsxs(yn,{showCloseButton:!s,children:[r.jsx(bn,{children:r.jsx(vn,{children:u("删除定时签到条目")})}),r.jsx(jn,{children:r.jsx("p",{className:"m-ck-note",children:u("确定删除「{name}」?删除后到点不再执行。",{name:d?.displayLabel||d?.time||""})})}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:!!s,onClick:()=>m(null),children:u("取消")}),r.jsx(ee,{variant:"destructive",disabled:!!s,onClick:async()=>{if(!d)return;await a(`delete:${d.id}`,()=>q6(d.id),u("已删除"))!==void 0&&m(null)},children:u(s?"删除中…":"删除")})]})]})})]})}function wI({entry:e,options:s,busy:a,action:l,onClose:c}){const[d,m]=v.useState(e?.label||""),[g,h]=v.useState(e?.time||"00:01"),[y,b]=v.useState(lg(e?.time||"00:01",e?.timeEnd)),[x,j]=v.useState(e?.providers||s.map(O=>O.id)),[E,S]=v.useState(e?.providerTimes||{}),[N,w]=v.useState(e?.retryTime??"00:10"),[R,T]=v.useState(String(e?.retryGapMinutes??10)),[B,M]=v.useState(String(e?.retryLimit??3)),I=x.filter(O=>!s.some(z=>z.id===O)),A=[...s,...I.map(O=>({id:O,label:O}))],L=async()=>{if(!wc(g,y)||!x.length){ce.toast(u("请填写合法区间,结束不早于开始,并至少选择一家提供商。"),"err");return}const O={};for(const[K,G]of Object.entries(E))G&&(O[K]=G);await l("schedule-save",()=>Bw({...e?{id:e.id}:{},label:d.trim(),time:g,timeEnd:y,enabled:e?e.enabled:!0,providers:x,providerTimes:O,retryTime:N.trim(),retryGapMinutes:Number(R)||0,retryLimit:Number(B)||0}),u("已保存"))&&c()};return r.jsx(xn,{open:!0,onOpenChange:(O,z)=>{if(!O){if(a){z.cancel();return}c()}},children:r.jsxs(yn,{showCloseButton:!a,children:[r.jsx(bn,{children:r.jsx(vn,{children:u(e?"编辑定时条目":"新建定时条目")})}),r.jsxs(jn,{children:[r.jsxs(pt,{className:"m-ck-field",children:[u("名称(可选)"),r.jsx(yt,{className:"text-base",value:d,disabled:!!a,onChange:O=>m(O.currentTarget.value)})]}),r.jsxs(pt,{className:"m-ck-field",children:[u("随机签到开始"),r.jsx(yt,{type:"time",className:"text-base",value:g,disabled:!!a,onChange:O=>{const z=O.currentTarget.value;h(z),wc(z,y)||b(Zw(z))}})]}),r.jsxs(pt,{className:"m-ck-field",children:[u("随机签到结束"),r.jsx(yt,{type:"time",className:"text-base",value:y,disabled:!!a,onChange:O=>b(O.currentTarget.value)})]}),r.jsx("p",{className:"m-ck-note",children:u("每个账号每天在区间内随机执行一次;开始与结束相同则按固定时刻执行。")}),r.jsx("div",{className:"m-ck-title",children:u("各家区间起点")}),r.jsx("p",{className:"m-ck-note",children:u("专属或自定义时间作为区间起点,沿用默认区间长度;每天重新随机,重启不改变当天安排。")}),A.filter(O=>x.includes(O.id)).map(O=>{const z=s.find(G=>G.id===O.id)?.builtinTime||"",K=E[O.id]||"";return r.jsxs(pt,{className:"m-ck-field",children:[u(O.label),z?u("(专属 {time})",{time:z}):"",r.jsx(yt,{type:"time",className:"text-base",value:K||z||g,disabled:!!a,onChange:G=>S(F=>({...F,[O.id]:G.currentTarget.value}))}),r.jsx("span",{className:"m-ck-note font-mono",children:og(K||z||g,Ww(K||z||g,g,y))})]},`time-${O.id}`)}),r.jsx("p",{className:"m-ck-note",children:u("补签在主签到区间结束后执行,只补未签到账号。")}),N&&wc(g,y)?r.jsx("p",{className:"m-ck-note",children:A.filter(O=>x.includes(O.id)).map(O=>{const z=E[O.id]||s.find(F=>F.id===O.id)?.builtinTime||g,K=Ww(z,g,y),G=bI(K,N,Number(R)||0);return`${u(O.label)} · ${u("实际补签")} ${G||"—"}`}).join(" · ")}):null,r.jsxs(pt,{className:"m-ck-field",children:[u("补签时刻(只补今天没签上的账号,清空 = 关闭)"),r.jsx(yt,{type:"time",className:"text-base",value:N,disabled:!!a,onChange:O=>w(O.currentTarget.value)})]}),r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsxs(pt,{className:"m-ck-grow",children:[u("窗口重试间隔(分钟,0 = 关闭)"),r.jsx(yt,{type:"number",className:"text-base",value:R,disabled:!!a,onChange:O=>T(O.currentTarget.value)})]}),r.jsxs(pt,{className:"m-ck-grow",children:[u("最多重试次数(0 = 关闭)"),r.jsx(yt,{type:"number",className:"text-base",value:B,disabled:!!a,onChange:O=>M(O.currentTarget.value)})]})]}),r.jsx("div",{className:"m-ck-title",children:u("签到范围")}),A.map(O=>r.jsxs(pt,{className:"m-ck-toolbar",children:[r.jsx(lp,{checked:x.includes(O.id),disabled:!!a,onCheckedChange:z=>{j(K=>z?[...new Set([...K,O.id])]:K.filter(G=>G!==O.id))}}),r.jsxs("span",{className:"m-ck-grow m-ck-note",children:[u(O.label),I.includes(O.id)?u("(插件未就绪,保留原配置)"):""]})]},O.id))]}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:!!a,onClick:c,children:u("取消")}),r.jsx(ee,{disabled:!!a||!wc(g,y)||!x.length,onClick:()=>{L()},children:u(a?"保存中…":"保存")})]})]})})}const ua=30;function SI(e){switch(e){case"success":return{label:u("成功领取"),tone:"ok"};case"already":return{label:u("今日已领"),tone:"brand"};case"pending":return{label:u("未领取"),tone:"warn"};case"failed":return{label:u("失败"),tone:"bad"};default:return{label:e||"—",tone:"mute"}}}function EI(e){switch(e){case"schedule":return u("定时");case"startup":return u("补签");case"manual":return u("手动");case"single":return u("单签");case"activity":return u("活动");default:return e||"—"}}function CI({providers:e}){const[s,a]=v.useState("all"),[l,c]=v.useState("all"),[d,m]=v.useState("all"),[g,h]=v.useState(""),[y,b]=v.useState(""),[x,j]=v.useState(0),[E,S]=v.useState(null),[N,w]=v.useState(""),[R,T]=v.useState(!1),[B,M]=v.useState(!1),[I,A]=v.useState(null),L=v.useRef(null),O=oe(),z=[{value:"all",label:u("全部时间")},{value:"today",label:u("今天")},{value:"7",label:u("7 天")},{value:"30",label:u("30 天")},{value:"month",label:u("本月")}],K=[{value:"all",label:u("全部结果")},{value:"success",label:u("成功领取")},{value:"already",label:u("今日已领")},{value:"pending",label:u("未领取")},{value:"failed",label:u("失败")}],G=[{value:"all",label:u("全部提供商")},...e.map(H=>({value:H.id,label:u(H.label)}))],F=v.useCallback(()=>({start:sI(s),outcome:l==="all"?void 0:l,provider:d==="all"?void 0:d,keyword:y||void 0}),[s,l,d,y]),U=v.useCallback(async()=>{L.current?.abort();const H=new AbortController;L.current=H,T(!0);try{const P=await $6({...F(),offset:x,limit:ua},H.signal);if(H.signal.aborted||oe()!==O)return;if(x>0&&x>=P.total){j(Math.max(0,Math.ceil(P.total/ua)-1)*ua);return}S(P),w("")}catch(P){!H.signal.aborted&&oe()===O&&w(P instanceof Error?P.message:String(P))}finally{!H.signal.aborted&&oe()===O&&T(!1)}},[F,x,O]);v.useEffect(()=>(U(),()=>L.current?.abort()),[U]);const X=(H,P)=>{H(P||"all"),j(0)},q=async()=>{if(!(!I||B)){M(!0);try{const H=await Y6(F(),I==="all");if(oe()!==O)return;A(null),ce.toast(u("已删除 {n} 条签到记录",{n:H.removed})),x>0?j(0):await U()}catch(H){oe()===O&&ce.toast(H instanceof Error?H.message:String(H),"err")}finally{M(!1)}}},Y=E?.total||0,$=s!=="all"||l!=="all"||d!=="all"||!!y,V=[{value:s,options:z,label:u("时间范围"),setter:a},{value:l,options:K,label:u("结果"),setter:c},{value:d,options:G,label:u("提供商"),setter:m}];return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-section",style:{marginTop:0},children:[r.jsx(Jt,{title:u("签到记录")}),r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx("div",{className:"m-ck-filters",children:V.map(H=>r.jsxs(Rs,{value:H.value,disabled:B,onValueChange:P=>X(H.setter,P),children:[r.jsx(Os,{className:"h-10 text-sm","aria-label":H.label,children:r.jsx(As,{children:H.options.find(P=>P.value===H.value)?.label||H.value})}),r.jsx(Ms,{children:H.options.map(P=>r.jsx(An,{value:P.value,children:P.label},P.value))})]},H.label))}),r.jsxs("form",{className:"m-ck-toolbar",onSubmit:H=>{H.preventDefault(),b(g.trim()),j(0)},children:[r.jsx(yt,{type:"search",className:"text-base",value:g,placeholder:u("搜索账号 / 说明"),disabled:B,"aria-label":u("搜索账号 / 说明"),onChange:H=>h(H.currentTarget.value)}),r.jsx(ee,{type:"submit",size:"sm",variant:"outline",disabled:B,children:u("搜索")})]}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:R||B,onClick:()=>{U()},children:u("刷新")}),$?r.jsx(ee,{size:"sm",variant:"ghost",className:"text-destructive",disabled:B||!Y,onClick:()=>A("filtered"),children:u("清空筛选结果")}):null,r.jsx(ee,{size:"sm",variant:"ghost",className:"text-destructive",disabled:B,onClick:()=>A("all"),children:u("清空全部")})]}),r.jsx("p",{className:"m-ck-note",children:u("共 {n} 条",{n:Y})})]})]}),N?r.jsx(is,{text:N}):null,!E&&R?r.jsx(on,{text:u("正在读取签到记录…")}):E?.records?.length?null:r.jsx(on,{text:u("这段时间里还没有签到记录")}),E?.records?.map((H,P)=>{const re=SI(H.outcome);return r.jsx("div",{className:"m-section",children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("div",{className:"m-ck-title m-ck-grow",children:H.accountName||H.accountId||"—"}),r.jsx(Mn,{tone:re.tone,children:re.label})]}),r.jsxs("p",{className:"m-ck-note",children:[Ds(H.ts)," · ",e.find(W=>W.id===H.provider)?.label||H.provider||"—"," · ",EI(H.source)]}),r.jsx("p",{className:H.error?"m-ck-error":"m-ck-note",children:H.message||H.error||(H.keptActive?u("保活成功"):"—")}),H.reason?r.jsx("p",{className:"m-ck-note",children:H.reason}):null]})},`${H.ts}:${H.accountId}:${P}`)}),Y>ua?r.jsxs("div",{className:"m-section m-ck-toolbar",children:[r.jsx(ee,{variant:"outline",size:"sm",disabled:R||x===0,onClick:()=>j(H=>Math.max(0,H-ua)),children:u("上一页")}),r.jsxs("span",{className:"m-ck-note",children:[Math.floor(x/ua)+1," / ",Math.ceil(Y/ua)]}),r.jsx(ee,{variant:"outline",size:"sm",disabled:R||x+ua>=Y,onClick:()=>j(H=>H+ua),children:u("下一页")})]}):null,r.jsx(xn,{open:!!I,onOpenChange:(H,P)=>{if(!H){if(B){P.cancel();return}A(null)}},children:r.jsxs(yn,{showCloseButton:!B,children:[r.jsx(bn,{children:r.jsx(vn,{children:u(I==="all"?"清空全部签到记录":"清空筛选结果")})}),r.jsx(jn,{children:r.jsx("p",{className:"m-ck-note",children:I==="all"?u("确定清空全部签到记录?清空后无法恢复。"):u("确定删除当前筛选命中的 {n} 条签到记录?清空后无法恢复。",{n:Y})})}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:B,onClick:()=>A(null),children:u("取消")}),r.jsx(ee,{variant:"destructive",disabled:B,onClick:()=>{q()},children:u(B?"删除中…":"删除")})]})]})})]})}function NI(){const e=ce.get().route.params?.tab,[s,a]=v.useState(e==="records"||e==="schedule"?e:"center"),[l,c]=v.useState(null),[d,m]=v.useState(""),[g,h]=v.useState(""),y=v.useRef(""),b=v.useRef(!0),x=oe();v.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const j=v.useCallback(async()=>{if(!(!b.current||oe()!==x))try{const w=await B6();if(!b.current||oe()!==x)return;c(w),m("")}catch(w){b.current&&oe()===x&&m(w instanceof Error?w.message:String(w))}},[x]),E=async(w,R,T)=>{if(y.current||!b.current||oe()!==x)return;const B=()=>{if(!b.current||oe()!==x)throw new DOMException("请求已取消","AbortError")};y.current=w,h(w);try{const M=await R(B);return B(),await Promise.all([j(),ce.refresh(!0)]),B(),T&&ce.toast(T),M}catch(M){b.current&&oe()===x&&ce.toast(M instanceof Error?M.message:String(M),"err");return}finally{y.current="",b.current&&oe()===x&&h("")}};Is(j,l?.auto?.running||l?.travel?.running||s==="schedule"&&l?.auto?.enabled?3e3:3e4);const S=ds({onRefresh:j}),N=[{value:"center",label:u("签到中心")},{value:"schedule",label:u("定时签到")},{value:"records",label:u("签到记录")}];return r.jsxs("div",{className:"m-page",ref:S.bindRef,children:[r.jsx(fs,{pull:S.pull,refreshing:S.refreshing}),r.jsx(vr,{subtitle:u("页面由手机端提供,签到能力由所连接网关的插件提供")}),r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsx(Rr,{options:N,value:s,onValueChange:a,"aria-label":u("签到中心标签页"),className:"m-checkin-tabs"})}),d?r.jsx(is,{text:d}):null,!l&&s!=="records"?r.jsx(_r,{rows:3,height:92}):null,l&&s==="center"?r.jsx(pI,{center:l,busy:g,action:E,onRecords:()=>a("records")}):null,l&&s==="schedule"?r.jsx(jI,{center:l,busy:g,action:E}):null,s==="records"?r.jsx(CI,{providers:l?.auto?.providerOptions||[]}):null]})}function Ir(e){return Bd(e,u,"plugin")}function TI(e){return Ce("/api/plugins",{signal:e})}function kI(){return Ce("/api/plugins/release")}function RI(){return Ce("/api/plugins/update")}function AI(e,s,a=!1){return Ce(a?"/api/plugins/update":"/api/plugins/install-from-release",{method:"POST",body:{id:e,target:s}})}function OI(e,s){return Ce("/api/plugins/enable",{method:"POST",body:{id:e,enabled:s}})}function MI(e,s,a){return Ce("/api/plugins/provider",{method:"POST",body:{id:e,provider:s,enabled:a}})}function DI(e){return Ce("/api/plugins/uninstall",{method:"POST",body:{id:e}})}function _I(e){return Ce("/api/plugins/settings",{signal:e})}function zI(e){return Ce("/api/plugins/settings",{method:"PATCH",body:e})}function Jw({operation:e}){if(!e)return null;const s=e.stage==="downloading"?u("网关正在下载…"):e.stage==="verifying"?u("网关正在校验…"):u("网关正在安装…");return r.jsxs(r.Fragment,{children:[e.active?r.jsxs("div",{className:"my-3","aria-live":"polite",children:[r.jsxs("p",{className:"m-ck-note",children:[e.required?`${u("正在补齐插件…")} · `:"",s,e.stage==="downloading"&&e.percent!=null?` ${Math.round(e.percent)}%`:""]}),r.jsx(Hu,{value:e.stage==="downloading"?e.percent:null,"aria-label":s})]}):null,e.error?r.jsx("p",{className:"m-ck-error",children:Ir(e.error)}):null,e.hostError?r.jsx("p",{className:"m-ck-error",children:e.hostError}):null]})}function eS({name:e,version:s,icon:a,author:l}){return r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-logo",children:a?r.jsx("img",{src:a,alt:""}):e.slice(0,1)}),r.jsxs("div",{className:"m-ck-grow",children:[r.jsx("div",{className:"m-ck-title",children:u(e)}),r.jsx("div",{className:"m-ck-note",children:s?`v${s}`:u("暂未发布")}),l?r.jsx("div",{className:"m-ck-note",children:u("作者:{author}",{author:l})}):null]})]})}function II({item:e,target:s,busy:a,operation:l,onInstall:c}){const d=e.platforms?.find(m=>m.target===s);return r.jsxs(Ue,{render:r.jsx("article",{}),className:"m-card m-card-pad",children:[r.jsx(eS,{name:e.name||e.id,version:e.version,icon:e.icon,author:e.author||e.publisher}),r.jsx("p",{className:"m-ck-note",children:u(e.description)}),e.official?r.jsx(Mn,{tone:"brand",children:u("官方")}):null,e.reason?r.jsx("p",{className:e.error?"m-ck-error":"m-ck-note",children:Ir(e.reason)}):null,r.jsx(Jw,{operation:l}),l?.active?null:r.jsx("div",{className:"m-ck-actions",children:r.jsx(ee,{size:"sm",disabled:a||!d||!e.version||e.error,onClick:c,children:u("在网关下载并安装")})}),d?null:r.jsx("p",{className:"m-ck-note",children:u("当前网关平台暂无插件包")})]})}function LI({pack:e,target:s,busy:a,update:l,operation:c,onEnabled:d,onProvider:m,onUpdate:g,onRemove:h}){const y=e.updateRequired===!0,b=a||c?.active===!0;return r.jsxs(Ue,{render:r.jsx("article",{}),className:"m-card m-card-pad",children:[r.jsx(eS,{name:e.name||e.id,version:e.version,icon:e.icon,author:e.author||e.publisher}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(Mn,{tone:e.enabled?"ok":"mute",children:e.enabled?u("已启用"):u("已停用")}),r.jsx(Mn,{tone:e.signed?"ok":"warn",children:e.signed?u("已签名"):u("未签名")}),y?r.jsx(Mn,{tone:"warn",children:u("需要补齐插件")}):null,r.jsx(Mn,{tone:e.providers?.some(x=>x.loaded)?"ok":"warn",children:u("已加载 {n} 家",{n:e.providers?.filter(x=>x.loaded).length||0})})]}),e.description?r.jsx("p",{className:"m-ck-note",children:u(e.description)}):null,y?r.jsxs("div",{className:"mt-3 rounded-md border border-destructive/30 px-3 py-2","aria-live":"polite",children:[r.jsx("p",{className:"m-ck-error",children:u("当前网关要求插件版本不低于 v{version},补齐前暂不加载。",{version:e.requiredVersion||""})}),r.jsx("p",{className:"m-ck-note",children:e.signed?u("正在自动补齐官方插件,不受日常更新开关和通道限制。"):u("未签名包不会自动覆盖;点击「补齐插件」将安装官方签名包。")}),l?.reason?r.jsx("p",{className:l.error?"m-ck-error":"m-ck-note",children:Ir(l.reason)}):null,l?.retryAt&&l.retryAt>Date.now()?r.jsx("p",{className:"m-ck-note",children:u("下次自动重试:{time}",{time:new Date(l.retryAt).toLocaleString()})}):null]}):null,e.entryPresent?null:r.jsx("p",{className:"m-ck-error",children:u("插件文件缺失,请重新安装插件包")}),e.host?.lastError?r.jsx("p",{className:"m-ck-error",children:e.host.lastError}):null,l?.reason&&!y?r.jsx("p",{className:l.error?"m-ck-error":"m-ck-note",children:Ir(l.reason)}):null,r.jsx(Jw,{operation:c}),r.jsxs("div",{className:"m-ck-actions",children:[r.jsxs(pt,{className:"m-ck-toolbar m-ck-note",children:[u("启用"),r.jsx(gn,{checked:e.enabled,disabled:b,"aria-label":u("启用插件 {name}",{name:e.name}),onCheckedChange:d})]}),r.jsx(ee,{size:"sm",variant:"outline",disabled:b,onClick:h,children:u("卸载")}),y?r.jsx(ee,{size:"sm",disabled:b||l?.repairing===!0,onClick:g,children:l?.repairing?u("正在补齐插件…"):u("补齐插件")}):l?.available?r.jsx(ee,{size:"sm",disabled:b||l.error||!l.asset||l.asset.target!==s,onClick:g,children:u("更新到 v{version}",{version:l.latest||""})}):null]}),r.jsxs(p1,{className:"mt-3 border-t border-hairline pt-3",children:[r.jsx(h1,{className:"m-ck-title",children:u("提供商启停")}),r.jsx(g1,{keepMounted:!0,children:e.providers?.map(x=>r.jsxs(pt,{className:"m-ck-toolbar py-2",children:[r.jsx(gn,{checked:x.enabled,disabled:b||!e.enabled,"aria-label":u(x.label),onCheckedChange:j=>m(x.id,j)}),r.jsx("span",{className:"m-ck-note m-ck-grow",children:u(x.label)}),x.enabled&&!x.loaded?r.jsx(Mn,{tone:"warn",children:u("未加载")}):null]},x.id))})]})]})}function PI({onClose:e,onChanged:s}){const[a,l]=v.useState(null),[c,d]=v.useState(""),[m,g]=v.useState(""),[h,y]=v.useState(!1),b=oe(),x=[{value:"follow",label:u("跟随软件")},{value:"custom",label:u("单独设置")}];v.useEffect(()=>{const w=new AbortController;return _I(w.signal).then(R=>{w.signal.aborted||(l(R),d(String(R.interval)))}).catch(R=>{w.signal.aborted||g(R instanceof Error?R.message:String(R))}),()=>w.abort()},[]);async function j(w){if(h||!a)return;const R={...a,...w};if(w.channelMode!=="follow"&&!R.stable&&!R.beta){g(u("至少需要关注正式版或 beta 版中的一个通道"));return}y(!0);try{const T=await zI(w);if(oe()!==b)return;l(T),d(String(T.interval)),g(""),ce.toast(T.saved===!1?u("设置已生效,但写入磁盘失败(重启后会恢复原设置)"):u("插件设置已保存"),T.saved===!1?"err":"ok"),("beta"in w||"stable"in w||"channelMode"in w)&&await s()}catch(T){oe()===b&&g(T instanceof Error?T.message:String(T))}finally{y(!1)}}const E=[{key:"autoUpdate",label:u("自动更新插件"),note:u("检测到更新后自动下载、校验并安装已启用的官方签名插件。关闭此项不影响最低版本补齐;未签名或第三方插件仍需手动更新。")},{key:"autoInstallOfficial",label:u("自动下载官方插件"),note:u("开启期间卸载的官方插件也会重新安装。")}],S=()=>{const w=Number(c);if(!Number.isInteger(w)||w<1||w>1440){g(u("检查间隔必须是 {min} ~ {max} 分钟",{min:1,max:1440}));return}j({interval:w})},N=a?.stable&&a.beta?u("正式版与 beta 版"):a?.beta?u("仅 beta 版"):u("仅正式版");return r.jsx(xn,{open:!0,onOpenChange:(w,R)=>{if(!w){if(h){R.cancel();return}e()}},children:r.jsxs(yn,{showCloseButton:!h,children:[r.jsx(bn,{children:r.jsx(vn,{children:u("插件设置")})}),r.jsxs(jn,{children:[r.jsx("p",{className:"m-ck-note",children:u("以下设置属于所连接网关,不是手机本地设置。")}),r.jsx("div",{className:"m-ck-title",children:u("检查计划")}),r.jsxs(Rs,{value:a?.checkMode||"follow",disabled:h||!a,onValueChange:w=>{j({checkMode:w})},children:[r.jsx(Os,{className:"w-full","aria-label":u("检查计划"),children:r.jsx(As,{children:x.find(w=>w.value===(a?.checkMode||"follow"))?.label})}),r.jsx(Ms,{children:x.map(w=>r.jsx(An,{value:w.value,children:w.label},w.value))})]}),a?.checkMode==="custom"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:u("自动检查插件更新")}),r.jsx(gn,{checked:a.autoCheck,disabled:h,"aria-label":u("自动检查插件更新"),onCheckedChange:w=>{j({autoCheck:w===!0})}})]}),r.jsxs(pt,{className:"m-ck-field",children:[u("检查间隔(分钟)"),r.jsx(yt,{type:"number",min:1,max:1440,step:1,className:"text-base",value:c,disabled:h||!a.autoCheck,onChange:w=>d(w.currentTarget.value)})]}),r.jsx(ee,{variant:"outline",disabled:h||!a.autoCheck||Number(c)===a.interval,onClick:S,children:u("保存")})]}):r.jsx("p",{className:"m-ck-note",children:a?a.autoCheck?u("当前:自动检查开启,每 {n} 分钟",{n:a.interval}):u("当前:自动检查关闭"):u("读取中")}),r.jsx("p",{className:"m-ck-note",children:u("默认跟随软件的自动检查和间隔。关闭后暂停日常自动更新和下载,但仍会补齐已安装官方插件的最低版本。")}),r.jsx("div",{className:"m-ck-title",children:u("更新通道")}),r.jsxs(Rs,{value:a?.channelMode||"follow",disabled:h||!a,onValueChange:w=>{j({channelMode:w})},children:[r.jsx(Os,{className:"w-full","aria-label":u("更新通道"),children:r.jsx(As,{children:x.find(w=>w.value===(a?.channelMode||"follow"))?.label})}),r.jsx(Ms,{children:x.map(w=>r.jsx(An,{value:w.value,children:w.label},w.value))})]}),a?.channelMode==="custom"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:u("关注正式版更新")}),r.jsx(gn,{checked:a.stable,disabled:h,"aria-label":u("关注正式版更新"),onCheckedChange:w=>{j({stable:w===!0})}})]}),r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:u("关注 beta 版更新")}),r.jsx(gn,{checked:a.beta,disabled:h,"aria-label":u("关注 beta 版更新"),onCheckedChange:w=>{j({beta:w===!0})}})]})]}):r.jsx("p",{className:"m-ck-note",children:a?u("当前关注:{channels}",{channels:N}):u("读取中")}),r.jsx("p",{className:"m-ck-note",children:u("默认跟随软件的正式版和 beta 关注选择;单独设置只影响日常更新,最低版本补齐按当前软件版本选择配套包。")}),E.map(w=>r.jsxs("div",{children:[r.jsxs("div",{className:"m-ck-toolbar",children:[r.jsx("span",{className:"m-ck-title m-ck-grow",children:w.label}),r.jsx(gn,{checked:a?.[w.key]===!0,disabled:h||!a,"aria-label":w.label,onCheckedChange:R=>{j({[w.key]:R===!0})}})]}),r.jsx("p",{className:"m-ck-note",children:w.note})]},w.key)),m?r.jsx("p",{className:"m-ck-error",children:m}):null,r.jsx(Aw,{})]})]})})}function BI(){const{server:e}=On(),[s,a]=v.useState(null),[l,c]=v.useState(""),[d,m]=v.useState(""),[g,h]=v.useState(!1),[y,b]=v.useState(null),x=v.useRef(!1),j=v.useRef(""),E=v.useRef(new Set),S=oe(),N=v.useCallback(async()=>{try{const z=await TI();if(oe()!==S)return;const K=JSON.stringify({packs:z.packs.map(G=>({id:G.id,version:G.version,enabled:G.enabled,providers:G.providers})),host:z.host});j.current!==K&&(j.current=K,ce.refresh(!0)),a(z),c("");for(const G of z.operations||[]){if(G.active)continue;const F=`${G.id}:${G.updatedAt}`;E.current.has(F)||(E.current.add(F),!(Date.now()-G.updatedAt>3e4)&&(G.error||G.hostError?ce.toast(Ir(G.error||G.hostError),"err"):G.done&&ce.toast(u("插件包已安装到 v{version}",{version:G.version}))))}}catch(z){oe()===S&&c(Ir(z))}},[S]);Is(N,s?.operations?.some(z=>z.active)?1500:1e4);const w=ds({onRefresh:N});async function R(z,K){if(!x.current){x.current=!0,m(z);try{const G=await K();return oe()!==S?void 0:(await N(),G)}catch(G){oe()===S&&ce.toast(Ir(G),"err");return}finally{x.current=!1,oe()===S&&m("")}}}async function T(z,K){return await R(z,async()=>{const F=await K();return oe()!==S||(await ce.refresh(!0),F.hostError&&ce.toast(F.hostError,"err")),F})!==void 0}const B=async()=>{const z=await R("catalog",kI);z?.error&&ce.toast(Ir(z.reason)||u("读取插件仓库失败"),"err")},M=async()=>{const z=await R("check",RI);z?.error&&ce.toast(Ir(z.reason)||u("检查更新失败"),"err")},I=async(z,K)=>{if(!s?.target)return;await R(`install:${z}`,()=>AI(z,s.target,K))&&ce.toast(u("下载任务已交给网关,关闭手机不影响安装"))},A=s?.packs||[],O=(s?.catalog?.plugins||[]).filter(z=>!A.some(K=>K.id===z.id));return r.jsxs("div",{className:"m-page",ref:w.bindRef,children:[r.jsx(fs,{pull:w.pull,refreshing:w.refreshing}),r.jsx(vr,{subtitle:u("管理所连接网关的插件,不在手机上安装提供商插件")}),r.jsx("div",{className:"m-section",style:{marginTop:0},children:r.jsxs(Ue,{className:"m-card m-card-pad",children:[r.jsx("div",{className:"m-ck-title",children:e?.name||e?.base||u("当前网关")}),r.jsx("p",{className:"m-ck-note",children:u("安装、更新与启停均作用在这台网关上。插件平台由网关决定,与手机系统无关。")}),s?r.jsx("p",{className:"m-ck-note m-mono",children:s.target}):null,r.jsxs("div",{className:"m-ck-actions",children:[r.jsx(ee,{size:"sm",variant:"outline",disabled:!!d,onClick:()=>{B()},children:u(d==="catalog"?"读取中…":"刷新插件仓库")}),r.jsx(ee,{size:"sm",variant:"outline",disabled:!!d,onClick:()=>{M()},children:u(d==="check"?"检查中…":"检查更新")}),r.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>h(!0),children:u("插件设置")})]})]})}),l?r.jsx(is,{text:l}):null,s?.host?.lastError?r.jsx(is,{text:s.host.lastError}):null,O.length?r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("可安装插件")}),O.map(z=>r.jsx(II,{item:z,target:s?.target||"",operation:s?.operations?.find(K=>K.id===z.id),busy:!!d,onInstall:()=>{I(z.id,!1)}},z.id))]}):null,r.jsxs("div",{className:"m-section",children:[r.jsx(Jt,{title:u("已安装插件")}),A.map(z=>r.jsx(LI,{pack:z,busy:!!d,target:s?.target||"",update:s?.updates?.find(K=>K.id===z.id),operation:s?.operations?.find(K=>K.id===z.id),onEnabled:K=>{T(`enable:${z.id}`,()=>OI(z.id,K))},onProvider:(K,G)=>{T(`provider:${K}`,()=>MI(z.id,K,G))},onUpdate:()=>{I(z.id,!0)},onRemove:()=>b(z)},z.id)),A.length?null:r.jsx(Ue,{className:"m-card",children:r.jsx(on,{text:u(s?"这台网关还没有安装插件":"正在读取插件列表…")})})]}),s?.catalog?.reason?r.jsx("div",{className:"m-section",children:r.jsx("p",{className:"m-ck-note",children:Ir(s.catalog.reason)})}):null,s?r.jsx("div",{className:"m-section",children:r.jsxs(p1,{className:"m-card m-card-pad",children:[r.jsx(h1,{className:"m-ck-title",children:u("诊断信息")}),r.jsxs(g1,{keepMounted:!0,children:[r.jsxs("p",{className:"m-ck-note",children:[u("插件目录"),":",r.jsx("span",{className:"m-mono",children:s.pluginsDir})]}),r.jsxs("p",{className:"m-ck-note",children:[u("协议版本"),":",s.protocol]})]})]})}):null,g?r.jsx(PI,{onClose:()=>h(!1),onChanged:N}):null,r.jsx(xn,{open:!!y,onOpenChange:(z,K)=>{if(!z){if(d){K.cancel();return}b(null)}},children:r.jsxs(yn,{showCloseButton:!d,children:[r.jsx(bn,{children:r.jsx(vn,{children:u("卸载插件包")})}),r.jsx(jn,{children:r.jsx("p",{className:"m-ck-note",children:u("确定卸载「{name}」吗?对应提供商将停止转发,账号数据仍然保留,重新安装后恢复。",{name:y?.name||""})})}),r.jsxs(rs,{children:[r.jsx(ee,{variant:"outline",disabled:!!d,onClick:()=>b(null),children:u("取消")}),r.jsx(ee,{variant:"destructive",disabled:!!d,onClick:async()=>{y&&await T(`remove:${y.id}`,()=>DI(y.id))&&b(null)},children:u(d?"卸载中…":"卸载")})]})]})})]})}function UI({title:e,onBack:s,actions:a}){return r.jsxs(A1,{className:"m-navbar",children:[r.jsx(ee,{size:"icon-touch",variant:"outline",type:"button",className:"m-icon-btn",onClick:s,"aria-label":u("返回"),children:r.jsx(_e,{name:"back"})}),r.jsx("span",{className:"m-navbar-title",children:e}),r.jsx("span",{className:"m-navbar-slot",children:a})]})}function HI(){const e=On(),[s,a]=v.useState(null),[l,c]=v.useState(""),[d,m]=v.useState(!1);return v.useEffect(()=>{let g=!1;if(a(null),m(!1),e.packaged&&!e.server)return;const h=()=>{Ce(`/api/update/policy${e.packaged?`?current=${encodeURIComponent(zr)}`:""}`).then(b=>{g||(a(b.forceUpdate),c(b.currentVersion))}).catch(()=>{})};h();const y=setInterval(h,6e4);return()=>{g=!0,clearInterval(y)}},[e.serverRevision,e.packaged,e.server]),!s?.required||d&&e.route.screen==="settings"?null:r.jsx(La,{open:!0,onOpenChange:()=>{},children:r.jsxs(Ba,{showCloseButton:!1,children:[r.jsx(zi,{children:r.jsx(Pa,{children:u("需要强制更新")})}),r.jsxs(Ua,{children:[r.jsx(nn,{variant:"warning",children:s.message}),r.jsx("p",{children:u("当前版本 {current},最低可用版本 {minimum}。",{current:l,minimum:s.minimumVersion})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:u("更新前无法继续调用模型;账号、配置和历史记录不会被删除。")})]}),r.jsx(Ii,{children:r.jsx(ee,{onClick:()=>{ce.go("settings"),m(!0)},children:u("立即更新")})})]})})}const VI={home:{title:u("首页"),component:nD,primary:!0},report:{title:u("报表"),component:dD,primary:!0},accounts:{title:u("账号"),component:qD,primary:!0},assistant:{title:u("AI 助手"),component:pz,primary:!0},more:{title:u("更多"),component:hz,primary:!0},models:{title:u("模型管理"),component:gz},keys:{title:u("网关 Key"),component:jz},proxies:{title:u("网络代理"),component:Az},tasks:{title:u("定时任务"),component:Oz},requests:{title:u("请求日志"),component:_z},logs:{title:u("运行日志"),component:Bz},settings:{title:u("设置"),component:m6},docs:{title:u("接口文档"),component:A6},agent:{title:u("Agent 配置"),component:_6},servers:{title:u("服务器"),component:Lw},checkin:{title:u("签到中心"),component:NI},plugins:{title:u("网关插件"),component:BI}};function qI(){const e=On(),s=jh(),a=VI[e.route.screen],l=a.component,c=!!a.primary,d=e.route.screen==="assistant",m=e.packaged&&!e.server;return v.useEffect(()=>{E5(),ce.restoreFromHash(),(!e.packaged||e.server)&&ce.refresh(!0);const g=()=>ce.handlePopState();return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[]),v.useEffect(()=>{if(!e.packaged)return;let g,h=!1;return Promise.resolve().then(()=>GI).then(({App:y})=>{h||y.addListener("backButton",()=>{const b=document.querySelector('[data-slot="sheet-content"][data-open], [data-slot="dialog-content"][data-open]');if(b){b.querySelector('[data-slot="sheet-close"], [data-slot="dialog-close"]')?.click();return}ce.handleHardwareBack()||y.exitApp()}).then(b=>{h?b.remove():g=()=>{b.remove()}})}).catch(()=>{}),()=>{h=!0,g?.()}},[]),v.useEffect(()=>{document.title=m?`${u("服务器")} · Agent2API`:`${a.title} · Agent2API`},[a.title,m]),m?r.jsxs(Kp,{className:"m-app",children:[r.jsx(gj,{}),r.jsx("div",{className:"m-scroll","data-screen":"servers",children:r.jsx(Lw,{},e.serverRevision)}),r.jsx(hj,{})]}):r.jsxs(Kp,{className:"m-app","data-offline":s.offline?"true":void 0,children:[r.jsx(gj,{}),r.jsx(Y5,{}),c?null:r.jsx(UI,{title:a.title,onBack:()=>ce.back()}),r.jsx("div",{className:"m-scroll",style:d?{overflow:"hidden"}:void 0,"data-screen":e.route.screen,children:r.jsx(l,{},e.serverRevision)}),r.jsx(B5,{}),r.jsx(hj,{}),r.jsx(HI,{}),r.jsx(U5,{},e.serverRevision)]})}U1(e=>{ce.setAuthLost(e)}),q5();const tS=document.getElementById("root");tS?Yv.createRoot(tS).render(r.jsx(qI,{})):document.body.innerHTML='手机端挂载失败:页面缺少 #root 容器。
';const KI=Vl("App",{web:()=>Promise.resolve().then(()=>YI).then(e=>new e.AppWeb)}),GI=Object.freeze(Object.defineProperty({__proto__:null,App:KI},Symbol.toStringTag,{value:"Module"}));class $I extends _d{constructor(){super(),this.handleVisibilityChange=()=>{const s={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",s),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}const YI=Object.freeze(Object.defineProperty({__proto__:null,AppWeb:$I},Symbol.toStringTag,{value:"Module"}))})();
diff --git a/desktop-tauri/ui/sw.js b/desktop-tauri/ui/sw.js
index eb8c462e8..570cd7a4c 100644
--- a/desktop-tauri/ui/sw.js
+++ b/desktop-tauri/ui/sw.js
@@ -31,7 +31,7 @@
* 填的表单会被一次自动刷新清掉。页面侧在设置页给「重启以更新」按钮。
*/
-const CACHE = 'agent2api-mobile-fa0e44f4e707'
+const CACHE = 'agent2api-mobile-77eab230ce71'
/** 预缓存的外壳文件(相对 SW 所在目录,即 `ui/` 根) */
const SHELL = [
From 92ab3a17a0ed7ab4ca5b1ceb2904ffb750490587 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 15:09:04 +0800
Subject: [PATCH 11/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AAutoClaw=20?=
=?UTF-8?q?=E9=A2=9D=E5=BA=A6=E8=80=97=E5=B0=BD=E7=9A=84=20402=20/=20406?=
=?UTF-8?q?=EF=BC=88=E7=A9=BA=E5=93=8D=E5=BA=94=E4=BD=93=EF=BC=89=E4=B9=9F?=
=?UTF-8?q?=E6=8C=89=E9=99=90=E6=B5=81=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
issue #6:生产库实测 AutoClaw 家额度耗尽时除 403+810000 外,还会以
402 / 406 + 空响应体的形态出现(近 72h:autoclaw 402 ×45、
autoclaw-intl 406 ×75,全部 attempts=1、无冷却、粘住同一账号反复撞)。
修改:
- `autoclaw_quota_fallback` 状态码集合从 {403} 扩到 {402, 403, 406};
有 body 证据(code 810000 / 「免费额度已用完」)→ 冷却到下一个北京
零点(口径不变)。
- 新增分支:空响应体 + 402/406 + Fatal → QuotaLimited,reset_at 不猜
(None),由上层 provider_loop 优先接上游 Retry-After、缺失时落默认
短期冷却 —— 与 429 空体兜底(PR #5)同一收口。
- 带 body 的 402 / 406(真实计费墙等)不受影响,仍走原分类。
验证:
- 新增 2 条单测:空体 402/406 → QuotaLimited 且 reset_at=None;
带 body 的 402/406 对照组仍是 Fatal。
- `plugin_host::` 34 passed(32 既有 + 2 新增)。
---
.../server/src/server/core/plugin_host/rpc.rs | 36 ++++++++++++-----
.../src/server/core/plugin_host/tests.rs | 39 +++++++++++++++++++
2 files changed, 66 insertions(+), 9 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
index 5e265ab7e..4116a6e6d 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
@@ -1461,6 +1461,9 @@ fn upstream_error_class(class: proto::ErrorClass) -> UpstreamErrorClass {
/// ── 判据 ────────────────────────────────────────────────────
/// 只认 AutoClaw 两地(`autoclaw` / `autoclaw-intl`)+ HTTP 403 +
/// 业务码 810000(或正文含「免费额度已用完」)。其它家的 403 不动。
+/// 另外 402 / 406 + **空响应体**也按额度耗尽兜底:生产库实测 AutoClaw 家
+/// 在额度耗尽时会把同一判据换成这两个状态码,且正文为空拿不到任何证据
+/// (issue #6)—— 状态码即证据,空体 + 这两个码没有「正常业务含义」。
///
/// ── reset_at ────────────────────────────────────────────────
/// 上游不给恢复时刻;免费额度按天重置(上游的日口径都是北京时间零点),
@@ -1473,7 +1476,7 @@ pub(super) fn autoclaw_quota_fallback(
) -> UpstreamErrorClass {
use crate::server::core::account_store::is_autoclaw_family;
- if status != 403 || matches!(class, UpstreamErrorClass::QuotaLimited { .. }) {
+ if matches!(class, UpstreamErrorClass::QuotaLimited { .. }) {
return class;
}
if !is_autoclaw_family(provider_id) {
@@ -1481,16 +1484,31 @@ pub(super) fn autoclaw_quota_fallback(
}
let code = error_body.get("code").and_then(Value::as_i64);
let message = error_body.get("message").and_then(Value::as_str).unwrap_or("");
- if code != Some(810000) && !message.contains("免费额度已用完") {
- return class;
+ if code == Some(810000) || message.contains("免费额度已用完") {
+ let now_ms = crate::server::logging::now_ms();
+ return UpstreamErrorClass::QuotaLimited {
+ reset_at: Some(next_beijing_midnight_ms(now_ms)),
+ message: class_message(&class, status, message),
+ upstream_code: code,
+ status,
+ };
}
- let now_ms = crate::server::logging::now_ms();
- UpstreamErrorClass::QuotaLimited {
- reset_at: Some(next_beijing_midnight_ms(now_ms)),
- message: class_message(&class, status, message),
- upstream_code: code,
- status,
+ // 空响应体的 402 / 406:没有文案证据,但生产库(issue #6)里 AutoClaw
+ // 额度耗尽就是这个形态 —— 状态码即证据。reset_at 不猜:上层
+ // provider_loop 会优先采用上游 Retry-After,没有则落默认短期冷却。
+ if message.is_empty()
+ && code.is_none()
+ && matches!(status, 402 | 406)
+ && matches!(class, UpstreamErrorClass::Fatal { .. })
+ {
+ return UpstreamErrorClass::QuotaLimited {
+ reset_at: None,
+ message: format!("上游返回 {status}: 请求额度受限(上游未返回详情),按限流冷却"),
+ upstream_code: None,
+ status,
+ };
}
+ class
}
/// 从分类结果里取出已有文案(Fatal/其它档的 message 已含 `上游返回 {status}:`)。
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
index aa420c388..3363e930e 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
@@ -226,6 +226,45 @@ fn other_autoclaw_403_stays_fatal() {
);
}
+/// 空响应体的 402 / 406 也按额度耗尽兜底(issue #6):生产库实测 AutoClaw
+/// 额度耗尽会以这两个状态码 + 空正文出现,插件分类器拿不到证据落 Fatal
+/// ⇒ 不冷却不换号。reset_at 留 None:上层接 Retry-After 或默认短期冷却。
+#[test]
+fn autoclaw_empty_body_402_and_406_fall_back_to_quota_limited() {
+ for status in [402u16, 406] {
+ let body = serde_json::json!({}); // 空体
+ let fatal = UpstreamErrorClass::Fatal {
+ status,
+ message: format!("上游返回 {status}: "),
+ upstream_code: None,
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", status, fatal, &body);
+ let UpstreamErrorClass::QuotaLimited { reset_at, status: got, .. } = &class else {
+ panic!("空体 {status} 应当被兜底成 QuotaLimited,实际 {class:?}");
+ };
+ assert_eq!(*got, status);
+ assert!(reset_at.is_none(), "空体兜底不该猜恢复时刻,实际 {reset_at:?}");
+ }
+}
+
+/// 对照组:带业务 body 的 402 / 406(真实计费墙、请求形态问题等)不兜底。
+#[test]
+fn autoclaw_402_406_with_body_stays_fatal() {
+ for status in [402u16, 406] {
+ let body = serde_json::json!({ "message": "余额不足,请充值" });
+ let fatal = UpstreamErrorClass::Fatal {
+ status,
+ message: format!("上游返回 {status}: 余额不足,请充值"),
+ upstream_code: None,
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", status, fatal, &body);
+ assert!(
+ matches!(class, UpstreamErrorClass::Fatal { .. }),
+ "带 body 的 {status} 不该被兜底,实际 {class:?}"
+ );
+ }
+}
+
#[tokio::test(flavor = "multi_thread")]
async fn build_chat_request_goes_through_rpc() {
let Some((host, providers)) = boot().await else {
From ad8472eea267292be9ed8bc9f233812dc08bf59a Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 15:20:51 +0800
Subject: [PATCH 12/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E7=9B=AE=E5=BD=95=E8=BF=81=E7=A7=BB=E4=B8=8D=E5=86=8D?=
=?UTF-8?q?=E6=95=B4=E4=BB=BD=E5=A4=8D=E5=88=B6=20SQLite=20=E5=BA=93?=
=?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E5=90=AF=E5=8A=A8=E6=97=B6=E5=90=83?=
=?UTF-8?q?=E6=8E=89=E6=95=B4=E5=9D=97=E7=A3=81=E7=9B=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## 问题
`config_migration::copy_dir_all` 递归拷贝整个旧配置目录
(`~/.workbuddy-proxy` → `~/.agent2api`),没有按文件类型过滤。这段代码
写于「配置目录只有 config.json / accounts.json / logs.jsonl 这类小文件」
的时代(见模块头),当时整份拷贝的代价可忽略。
统一库落地后 `{config_dir}/agent2api.db` 是 GB 级单文件,还带 `-wal` /
`-shm`。只要旧目录里存在一份库(升级路径上的常见形态),一次启动就会
凭空多出「一整份库」的磁盘占用 —— 用户实测 C 盘被吃满。
## 修改
- `copy_dir_all` 跳过 SQLite 库文件:主库 + 一切 `-` 开头的伴随后缀
(`-wal` / `-shm` / `-journal` / WAL2 的 `-wal2`)。
- 判据按**文件名**而不是体积:体积阈值会随数据增长失效,文件名是
结构化事实(`db::FILE_NAME` + SQLite 固定后缀)。
- 跳过时打一行 `[Config]` 说明,用户能在日志里看到「库没被搬」。
- 用户手工改名的 `agent2api.db.backup` 不跳过:它不是活库,搬走不占
运行期资源,也保留了用户自己留的那份。
## 为什么跳过是安全的
- 旧版程序根本不写 `agent2api.db`(统一库由本程序引入),迁移的语义是
「把旧版的数据搬过来」,库文件不属于旧版数据;
- 若旧目录里真有一份库,它来自更早的本程序运行 —— 那种情况下新目录
通常已存在,迁移在第一次启动就完成了,走不到这条拷贝路径。
## 验证
- 新增 3 条测试:库三件套被排除、普通配置与手工副本不受影响、
端到端 `copy_dir_all` 拷贝后目标目录里没有库文件。
- `config_migration::` 3 passed。
---
.../server/src/server/config_migration.rs | 116 ++++++++++++++++++
1 file changed, 116 insertions(+)
diff --git a/desktop-tauri/src-tauri/server/src/server/config_migration.rs b/desktop-tauri/src-tauri/server/src/server/config_migration.rs
index c51cc2f24..a6a1cf68a 100644
--- a/desktop-tauri/src-tauri/server/src/server/config_migration.rs
+++ b/desktop-tauri/src-tauri/server/src/server/config_migration.rs
@@ -338,6 +338,22 @@ fn sweep_stale_staging(parent: &Path, target_name: &str) {
///
/// `skip` 是暂存目录里的所有权标记文件路径:它只属于本次迁移,源目录里即使
/// 恰好同名也不该把它覆盖/写坏(那会让清理逻辑认不出自己的目录)。
+///
+/// ── 为什么必须排除 SQLite 库 ────────────────────────────────
+/// 这条迁移写于「配置目录只有 config.json / accounts.json / logs.jsonl」的
+/// 时代(见模块头),当时整份拷贝的代价可以忽略。统一库落地后
+/// `{config_dir}/agent2api.db` 是**几 GB 级**的单一文件,并且带着 `-wal` /
+/// `-shm`;无条件递归拷贝会让一次启动凭空多出「一份整库」的磁盘占用,
+/// 在小容量系统盘上直接触顶(用户实测:C 盘被吃满)。
+///
+/// 因此这里跳过库文件三件套与它的临时伴随文件。跳过是**安全**的:
+/// - 旧版程序根本不会写 `agent2api.db`(统一库是本程序引入的),
+/// 迁移的语义是「把旧版的数据搬过来」,库文件不属于旧版数据;
+/// - 若旧目录里真有一份库,它也来自更早的本程序运行 —— 那种情况下
+/// 新目录通常已存在(迁移在第一次启动就完成了),走不到这条拷贝路径。
+///
+/// 判据按文件名匹配而不是按体积:体积阈值会随数据增长失效,而文件名是
+/// 结构化事实(见 `db::FILE_NAME` 与 SQLite 的固定伴随后缀)。
fn copy_dir_all(from: &Path, to: &Path, skip: &Path) -> io::Result<()> {
for entry in std::fs::read_dir(from)? {
let entry = entry?;
@@ -346,6 +362,16 @@ fn copy_dir_all(from: &Path, to: &Path, skip: &Path) -> io::Result<()> {
if destination == skip {
continue;
}
+ if is_sqlite_database_name(&entry.file_name()) {
+ crate::server::logging::console_line(
+ "[Config]",
+ &format!(
+ "迁移跳过数据库文件(统一库由新版本自行建库,不随配置目录搬运): {}",
+ source.display()
+ ),
+ );
+ continue;
+ }
if is_link_like(&entry.metadata()?) {
crate::server::logging::console_line(
"[Config]",
@@ -369,6 +395,32 @@ fn copy_dir_all(from: &Path, to: &Path, skip: &Path) -> io::Result<()> {
Ok(())
}
+/// SQLite 库文件名是否属于「不随配置目录搬运」的那一组。
+///
+/// 覆盖 `agent2api.db` 与 SQLite 为它维护的伴随后缀:
+/// - `-wal`(预写日志)、`-shm`(共享内存索引)—— 运行期必须与主库同进同退;
+/// - `-journal`(回滚日志)—— 非 WAL 模式或崩溃恢复期间出现。
+///
+/// 判据是「主库名 + `-` 开头 + 纯字母数字」,而不是枚举有限几种后缀:
+/// SQLite 的实验特性与不同编译选项会造出 `-wal2` / `-shm2` 这类变体,
+/// 用前缀规则一次覆盖。`agent2api.db.backup` 这种用户手工改名**不**跳过 ——
+/// 它不是活库,搬走既不占运行期资源,也保留了用户自己留的那份。
+fn is_sqlite_database_name(name: &std::ffi::OsStr) -> bool {
+ let name = name.to_string_lossy();
+ let base = crate::server::db::FILE_NAME;
+ if name == base {
+ return true;
+ }
+ match name.strip_prefix(base) {
+ Some(rest) => {
+ rest.starts_with('-')
+ && rest.len() > 1
+ && rest[1..].chars().all(|c| c.is_ascii_alphanumeric())
+ }
+ None => false,
+ }
+}
+
/// 是否是链接类目录项:符号链接,或 Windows 重解析点(junction / mount point)。
///
/// `file_type().is_symlink()` 只覆盖真正的符号链接;Windows 的 junction 在
@@ -405,3 +457,67 @@ fn env_dir_override_set() -> bool {
.unwrap_or(false)
})
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::ffi::OsStr;
+
+ /// 库三件套(主库 + WAL + SHM)都必须被排除,否则迁移会多拷一份整库。
+ #[test]
+ fn sqlite_database_files_are_skipped() {
+ for name in ["agent2api.db", "agent2api.db-wal", "agent2api.db-shm", "agent2api.db-journal"] {
+ assert!(
+ is_sqlite_database_name(OsStr::new(name)),
+ "{name} 必须被迁移跳过(否则会整库复制一份)"
+ );
+ }
+ }
+
+ /// 配置文件与用户手工改名的库副本照常搬运,不受影响。
+ #[test]
+ fn ordinary_config_files_are_not_skipped() {
+ for name in [
+ "config.json",
+ "accounts.json",
+ "logs.jsonl",
+ "agent2api.db.backup",
+ "agent2api.dbx",
+ "my-agent2api.db",
+ ] {
+ assert!(
+ !is_sqlite_database_name(OsStr::new(name)),
+ "{name} 是普通文件,不该被跳过"
+ );
+ }
+ }
+
+ /// 端到端:源目录里放一份假库,迁移后目标目录里不该出现它。
+ #[test]
+ fn copy_dir_all_skips_database_bytes() {
+ let root = std::env::temp_dir().join(format!(
+ "cfg-migrate-test-{}-{:?}",
+ std::process::id(),
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map(|d| d.as_nanos())
+ .unwrap_or(0)
+ ));
+ let from = root.join("from");
+ let to = root.join("to");
+ std::fs::create_dir_all(&from).expect("建源目录");
+ std::fs::create_dir_all(&to).expect("建目标目录");
+ std::fs::write(from.join("config.json"), b"{}").expect("写配置");
+ std::fs::write(from.join("agent2api.db"), vec![0u8; 4096]).expect("写假库");
+ std::fs::write(from.join("agent2api.db-wal"), vec![0u8; 16]).expect("写假 WAL");
+
+ let skip = to.join(".marker");
+ copy_dir_all(&from, &to, &skip).expect("拷贝应当成功");
+
+ assert!(to.join("config.json").is_file(), "配置文件必须搬过去");
+ assert!(!to.join("agent2api.db").exists(), "库文件不该被复制");
+ assert!(!to.join("agent2api.db-wal").exists(), "WAL 不该被复制");
+
+ let _ = std::fs::remove_dir_all(&root);
+ }
+}
From 75964a4be1480abe4d14daa107af2c20274f5521 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 15:23:41 +0800
Subject: [PATCH 13/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=9A=B4?=
=?UTF-8?q?=E9=9C=B2=E6=95=B0=E6=8D=AE=E5=BA=93=E7=A9=BA=E9=97=B2=E9=A1=B5?=
=?UTF-8?q?=E8=AF=BB=E6=95=B0=EF=BC=8C=E8=AF=B4=E6=98=8E=E3=80=8C=E5=BA=93?=
=?UTF-8?q?=E5=BE=88=E5=A4=A7=E4=BD=86=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=A4=9A?=
=?UTF-8?q?=E3=80=8D=E7=9A=84=E6=9D=A5=E6=BA=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## 问题
库开的是 `auto_vacuum=0`:`DELETE` 只把页标成空闲,文件**不会缩小**。
用户实测库里留着 340469 个空闲页(约 1.3GB),而真实数据只有 1.1GB ——
文件 2.5GB,设置页照实显示,用户以为程序在偷偷占盘(C 盘爆满)。
唯一回收路径是请求日志页的「清理」弹窗里手动压缩,但界面上没有任何
「这个库有多少是空洞」的读数,用户没有判断依据。
## 修改
- `RequestStats::free_space()`:读 `PRAGMA page_size / page_count /
freelist_count`(都是 O(1) 头字段,不扫表),给出
`(空闲页数, 总页数, 可回收字节)`。
- `stats()` 增加 `reclaimableBytes` 与 `freePageRatio`(0..1,三位小数)。
- `GET /api/storage` 的 `database` 一并透出这两个字段。
## 为什么不自动 VACUUM
VACUUM 需要**约等于整库大小**的临时空间,且持锁期间会阻塞全部数据库
读写。在只剩少量空间的盘上自动执行,恰好会把「空间紧张」变成「空间耗尽」。
所以这里只把判据交给界面与用户,由用户显式触发既有的「压缩」动作。
## 验证
- `cargo check -p agent2api-server` 通过。
- 全量 `--lib` 293 passed / 1 failed(既有无关项
`codearts_daily_pool_envelope_...`,插件化后 adapter_for 返回占位符所致)。
---
.../server/src/server/api/storage_api.rs | 6 ++++
.../server/src/server/request_stats.rs | 15 ++++++++++
.../src/server/request_stats/maintenance.rs | 28 +++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/desktop-tauri/src-tauri/server/src/server/api/storage_api.rs b/desktop-tauri/src-tauri/server/src/server/api/storage_api.rs
index 817dc2e04..7d6b46b6d 100644
--- a/desktop-tauri/src-tauri/server/src/server/api/storage_api.rs
+++ b/desktop-tauri/src-tauri/server/src/server/api/storage_api.rs
@@ -80,6 +80,12 @@ pub async fn get_storage(State(state): State) -> Response {
"database": {
"file": db_file.to_string_lossy(),
"bytes": if available { request_stats.db_bytes() } else { 0 },
+ // 空洞读数(`stats()` 的 reclaimableBytes / freePageRatio):
+ // `auto_vacuum=0` 时 DELETE 只把页标成空闲,文件不会缩小。
+ // 设置页据此给出「可回收 X MB」与「压缩」建议,而不是让用户
+ // 看到一个解释不了的 2.5GB —— 这是实测里「C 盘爆满」的直接来源。
+ "reclaimableBytes": stats.get("reclaimableBytes").cloned().unwrap_or(json!(0)),
+ "freePageRatio": stats.get("freePageRatio").cloned().unwrap_or(json!(0.0)),
// 条数只在库可用时才可信(不可用时各 store 都回落 0,与「真的没有
// 数据」在数字上无法区分)—— 这个布尔让界面能说「不可用」而不是
// 显示一排看着正常的 0
diff --git a/desktop-tauri/src-tauri/server/src/server/request_stats.rs b/desktop-tauri/src-tauri/server/src/server/request_stats.rs
index f392c6d2a..d5895b00b 100644
--- a/desktop-tauri/src-tauri/server/src/server/request_stats.rs
+++ b/desktop-tauri/src-tauri/server/src/server/request_stats.rs
@@ -755,11 +755,26 @@ impl RequestStats {
let (total, daily_days, first_ts, last_ts, downstream_raw, upstream_raw) =
loaded.unwrap_or((0, 0, None, None, 0, 0));
let file = self.file().to_string_lossy().to_string();
+ // 空闲页读数(见 `free_space` 的说明):`auto_vacuum=0` 下删除行只把页
+ // 标成空闲,文件不会缩小。界面据此能把「库 2.5GB、其中 1.3GB 是空洞」
+ // 说明白,而不是让用户以为程序在偷偷占盘。
+ let (free_pages, total_pages, reclaimable) = self
+ .free_space()
+ .map(|(free, total, bytes)| (free, total, bytes))
+ .unwrap_or((0, 0, 0));
json!({
"total": total,
"dailyDays": daily_days,
"downstreamRaw": downstream_raw,
"upstreamRaw": upstream_raw,
+ // 空闲页:reclaimableBytes 是「压缩一次能还给文件系统多少」,
+ // freePageRatio 是占比(0..1,保留三位小数)。
+ "reclaimableBytes": reclaimable,
+ "freePageRatio": if total_pages == 0 {
+ 0.0
+ } else {
+ ((free_pages as f64 / total_pages as f64) * 1000.0).round() / 1000.0
+ },
"file": file,
// 与 file 同值:明细与聚合同居一个库。保留这个字段是为了不破坏
// 既有读取方(`file` 的语义已经说明它指库文件),但**不要再把两者
diff --git a/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs b/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs
index dcf48a163..0c74b01d2 100644
--- a/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs
+++ b/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs
@@ -84,6 +84,34 @@ impl RequestStats {
file_size(&file) + file_size(&PathBuf::from(format!("{}-wal", file.to_string_lossy())))
}
+ /// 空闲页占比(0.0 ~ 1.0)与可回收字节数;库不可用时返回 `None`。
+ ///
+ /// ── 为什么需要这个读数 ──────────────────────────────────────
+ /// 库开了 `auto_vacuum=0`(见 `db::apply_pragmas`),删除行只把页标成空闲,
+ /// 文件**不会缩小**。用户删掉大量历史正文(或 v13 升级清了整张
+ /// `request_raw`)之后,库里会留下成千上万个空闲页:文件看着还是 2.5GB,
+ /// 实际数据只有 1.1GB。这份「虚胖」在设置页原样显示成占用,用户既看不到
+ /// 原因,也找不到该不该压缩的依据 —— 实测出现过「库里 1.3GB 是空洞,
+ /// 用户以为程序在偷偷占盘」(C 盘爆满)。
+ ///
+ /// 因此把判据暴露出来:只有占比够高(调用方决定阈值)时才值得付一次
+ /// VACUUM 的代价。`PRAGMA freelist_count` 与 `page_count` 都是 O(1) 的
+ /// 头字段读,不扫表,可以放在概览接口里。
+ pub fn free_space(&self) -> Option<(u64, u64, u64)> {
+ let db = self.db.clone()?;
+ db.with(|conn| {
+ let page_size: i64 = conn.query_row("PRAGMA page_size;", [], |row| row.get(0))?;
+ let page_count: i64 = conn.query_row("PRAGMA page_count;", [], |row| row.get(0))?;
+ let free: i64 = conn.query_row("PRAGMA freelist_count;", [], |row| row.get(0))?;
+ Ok::<_, rusqlite::Error>((
+ free.max(0) as u64,
+ page_count.max(0) as u64,
+ (page_size.max(0) as u64) * (free.max(0) as u64),
+ ))
+ })?
+ .ok()
+ }
+
/// 压缩数据库:`checkpoint(TRUNCATE)` → `VACUUM` → 再 `checkpoint(TRUNCATE)`
/// —— 首尾两次 checkpoint 缺一不可(理由见下),中间那次 VACUUM 重建整库
/// 文件回收空闲页。**后台线程**执行,返回启动结果。
From 886bfe1087a4f10b37fa40492ba6e1483ca64f60 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 15:28:25 +0800
Subject: [PATCH 14/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=94=B6?=
=?UTF-8?q?=E7=B4=A7=20AutoClaw=20402/406=20=E5=85=9C=E5=BA=95=E5=88=A4?=
=?UTF-8?q?=E6=8D=AE=EF=BC=88=E5=AE=A1=E6=9F=A5=E5=8F=8D=E9=A6=88=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
独立审查指出的两点:
1. 810000 判据在扩到 402/406 时被顺手放开了状态码限制 —— 原判据只认
403,放开后任何状态码带 810000 都会被当成额度耗尽(例如 500 上游故障
被误冷却)。现在先收窄状态码集合到 {402, 403, 406},其它一律原样返回。
2. 「空响应体」原来只看顶层 message 是否为空、code 是否缺省,会把
`{"error":{"type":"insufficient_quota"}}` 这类**有结构化内容**的正文
误判成空体。新增 `is_blank_error_body`:逐值检查,只含
null / 空串 / 空对象 / 空数组才算空。
顺带:空体兜底分支保留分类器原本解析出的 upstream_code,不再无条件写 None。
验证:新增 3 条对照测试(结构化正文不兜底、402/406 之外的状态码不兜底、
非 AutoClaw 家不受影响);`plugin_host::tests::` 20 passed。
---
.../server/src/server/core/plugin_host/rpc.rs | 72 +++++++++++++++----
.../src/server/core/plugin_host/tests.rs | 63 ++++++++++++++++
2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
index 4116a6e6d..799ee8e63 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
@@ -1459,15 +1459,23 @@ fn upstream_error_class(class: proto::ErrorClass) -> UpstreamErrorClass {
/// 这一条纯判据,留在网关侧做兜底覆盖最稳。
///
/// ── 判据 ────────────────────────────────────────────────────
-/// 只认 AutoClaw 两地(`autoclaw` / `autoclaw-intl`)+ HTTP 403 +
-/// 业务码 810000(或正文含「免费额度已用完」)。其它家的 403 不动。
-/// 另外 402 / 406 + **空响应体**也按额度耗尽兜底:生产库实测 AutoClaw 家
-/// 在额度耗尽时会把同一判据换成这两个状态码,且正文为空拿不到任何证据
-/// (issue #6)—— 状态码即证据,空体 + 这两个码没有「正常业务含义」。
+/// 只认 AutoClaw 两地(`autoclaw` / `autoclaw-intl`),且状态码必须是
+/// **402 / 403 / 406** 之一。其它家的 403、其它状态码一律不动 ——
+/// 判据收得窄,误伤的代价(把一次真实计费墙/上游故障当成限流去冷却)
+/// 远高于漏判(下一轮还会再判一次)。
+///
+/// 分两条:
+/// 1. 有正文证据:业务码 810000 或正文含「免费额度已用完」→ 按天重置,
+/// 冷却到下一个北京零点;
+/// 2. **空响应体**的 402 / 406:生产库实测 AutoClaw 额度耗尽会以这两个
+/// 状态码 + 空正文出现(issue #6),拿不到任何文案证据 ——
+/// 「空体 + 402/406」在 AutoClaw 上没有正常业务含义,状态码即证据。
+/// 恢复时刻不猜,交给上层按 `Retry-After` 或默认短期冷却。
///
/// ── reset_at ────────────────────────────────────────────────
/// 上游不给恢复时刻;免费额度按天重置(上游的日口径都是北京时间零点),
- /// 取下一个北京零点,与 CodeArts 福利日池的冷却口径同一来源。
+/// 取下一个北京零点,与 CodeArts 福利日池的冷却口径同一来源。
+/// 空体兜底那一条是例外(见上):没有「按天」的依据,不做跨天猜测。
pub(super) fn autoclaw_quota_fallback(
provider_id: &str,
status: u16,
@@ -1479,11 +1487,14 @@ pub(super) fn autoclaw_quota_fallback(
if matches!(class, UpstreamErrorClass::QuotaLimited { .. }) {
return class;
}
- if !is_autoclaw_family(provider_id) {
+ // 状态码先收窄:402 / 406 是本次新增,403 是原有判据。
+ // 这一步放在最前面,保证「任何 provider 的其它状态码」都原样返回。
+ if !matches!(status, 402 | 403 | 406) || !is_autoclaw_family(provider_id) {
return class;
}
let code = error_body.get("code").and_then(Value::as_i64);
let message = error_body.get("message").and_then(Value::as_str).unwrap_or("");
+ // ① 有正文证据:业务码 / 文案。
if code == Some(810000) || message.contains("免费额度已用完") {
let now_ms = crate::server::logging::now_ms();
return UpstreamErrorClass::QuotaLimited {
@@ -1493,24 +1504,57 @@ pub(super) fn autoclaw_quota_fallback(
status,
};
}
- // 空响应体的 402 / 406:没有文案证据,但生产库(issue #6)里 AutoClaw
- // 额度耗尽就是这个形态 —— 状态码即证据。reset_at 不猜:上层
- // provider_loop 会优先采用上游 Retry-After,没有则落默认短期冷却。
- if message.is_empty()
- && code.is_none()
- && matches!(status, 402 | 406)
+ // ② 空响应体的 402 / 406(issue #6)。
+ //
+ // 判据必须核验「体确实是空的」,而不是只看顶层 `message` 缺省:
+ // 上游也可能返回 `{"error":{"type":"insufficient_quota"}}` 这类
+ // 没有 `message` / `code` 顶层键的**有内容**正文 —— 那种形态说明
+ // 上游给了结构化说明,应当保持原本的 Fatal 透传,而不是猜成限流。
+ if matches!(status, 402 | 406)
&& matches!(class, UpstreamErrorClass::Fatal { .. })
+ && is_blank_error_body(error_body)
{
return UpstreamErrorClass::QuotaLimited {
reset_at: None,
message: format!("上游返回 {status}: 请求额度受限(上游未返回详情),按限流冷却"),
- upstream_code: None,
+ // 正文没给业务码时保留分类器已有的那个(插件可能从状态行/头部
+ // 解析出过),不要因为走了兜底分支就丢掉。
+ upstream_code: match &class {
+ UpstreamErrorClass::Fatal { upstream_code, .. } => *upstream_code,
+ _ => None,
+ },
status,
};
}
class
}
+/// 错误正文是否是「空白」(没有任何可用信息)。
+///
+/// `UpstreamErrorDetail::to_value()` 对空响应体固定产出
+/// `{"code":null,"message":""}`,所以最常见的形态是「键在、值为空」;
+/// 但插件也可能把一段非 JSON 文本原样塞进 `message`,或有上游返回
+/// `{"error":{...}}` 这类结构。判据因此是**逐值检查**:只含
+/// null / 空串 / 空对象 / 空数组时才算空 —— 出现任何非空内容就判为
+/// 「有正文」,退回原分类。
+fn is_blank_error_body(body: &Value) -> bool {
+ fn blank(value: &Value) -> bool {
+ match value {
+ Value::Null => true,
+ Value::String(text) => text.trim().is_empty(),
+ Value::Array(items) => items.iter().all(blank),
+ Value::Object(map) => map.values().all(blank),
+ Value::Bool(_) | Value::Number(_) => false,
+ }
+ }
+ match body {
+ // 非对象(数组 / 字符串 / 数字)不是错误正文的常规形态;
+ // 只有「什么都读不到」才算空。
+ Value::Object(map) => map.values().all(blank),
+ other => blank(other),
+ }
+}
+
/// 从分类结果里取出已有文案(Fatal/其它档的 message 已含 `上游返回 {status}:`)。
fn class_message(class: &UpstreamErrorClass, status: u16, raw: &str) -> String {
match class {
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
index 3363e930e..f35412446 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
@@ -265,6 +265,69 @@ fn autoclaw_402_406_with_body_stays_fatal() {
}
}
+/// 对照组:正文没有顶层 `message` / `code`,但有结构化内容(如
+/// `{"error":{"type":"insufficient_quota"}}`)—— 不能当成「空体」兜底。
+///
+/// 这是本次修复最容易误伤的一种形态:只看顶层键是否存在会把它判成空体,
+/// 而它其实是上游给了明确说明的正文。
+#[test]
+fn autoclaw_402_406_with_structured_body_stays_fatal() {
+ for status in [402u16, 406] {
+ let body = serde_json::json!({ "error": { "type": "insufficient_quota" } });
+ let fatal = UpstreamErrorClass::Fatal {
+ status,
+ message: format!("上游返回 {status}: insufficient_quota"),
+ upstream_code: None,
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", status, fatal, &body);
+ assert!(
+ matches!(class, UpstreamErrorClass::Fatal { .. }),
+ "带结构化正文的 {status} 不该被当成空体兜底,实际 {class:?}"
+ );
+ }
+}
+
+/// 对照组:状态码不在 {402,403,406} 时,即使正文是 810000 也不兜底。
+///
+/// 810000 这条判据原本只认 403;扩到 402/406 时**不能**顺手放开到所有
+/// 状态码 —— 那会把 500 之类的上游故障也当成额度耗尽去冷却。
+#[test]
+fn autoclaw_810000_outside_the_three_statuses_is_ignored() {
+ let body = serde_json::json!({ "code": 810000, "message": "GLM-5.3 免费额度已用完" });
+ for status in [400u16, 429, 500, 502] {
+ let fatal = UpstreamErrorClass::Fatal {
+ status,
+ message: format!("上游返回 {status}"),
+ upstream_code: Some(810000),
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", status, fatal, &body);
+ assert!(
+ matches!(class, UpstreamErrorClass::Fatal { .. }),
+ "状态码 {status} 不该被 810000 判据覆盖(429 已由上层处理)"
+ );
+ }
+}
+
+/// 对照组:非 AutoClaw 家的 402 / 406 空体不受影响。
+#[test]
+fn other_providers_empty_402_406_stay_fatal() {
+ for provider in ["workbuddy", "raccoon", "trae", "some-custom"] {
+ for status in [402u16, 406] {
+ let body = serde_json::json!({ "code": null, "message": "" });
+ let fatal = UpstreamErrorClass::Fatal {
+ status,
+ message: format!("上游返回 {status}: "),
+ upstream_code: None,
+ };
+ let class = super::rpc::autoclaw_quota_fallback(provider, status, fatal, &body);
+ assert!(
+ matches!(class, UpstreamErrorClass::Fatal { .. }),
+ "{provider} 的 {status} 不该被 AutoClaw 兜底覆盖"
+ );
+ }
+ }
+}
+
#[tokio::test(flavor = "multi_thread")]
async fn build_chat_request_goes_through_rpc() {
let Some((host, providers)) = boot().await else {
From 46b93f9984d7d4ef599db066187f5d56578169ca Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 16:36:29 +0800
Subject: [PATCH 15/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A406=20?=
=?UTF-8?q?=E7=A9=BA=E5=93=8D=E5=BA=94=E4=BD=93=E4=B8=8D=E5=86=8D=E5=BD=93?=
=?UTF-8?q?=E4=BD=9C=E9=A2=9D=E5=BA=A6=E8=80=97=E5=B0=BD=EF=BC=88=E5=AE=A1?=
=?UTF-8?q?=E6=9F=A5=E5=8F=8D=E9=A6=88=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## 问题
上一版把「空响应体 + 402/406」一律兜底成 QuotaLimited。406 这一半是错的:
AutoClaw 的 406 空体是**上游预校验拒收的统一形态**,插件侧实测过三个独立
成因(max_tokens 取小值 / system 首句命中指纹 / 请求形态风控,见
`autoclaw/mod.rs` 的「四道上游闸」与 `prompt.rs` 的 `UPSTREAM_406_HINT`)。
把它当额度耗尽有两个用户可见的坏结果:
- 一次提示词闸门拒收 → 冷却一个**健康**账号并换号;而同一份 body 换谁的
账号都会被拒,等于空转一个冷却窗口、还少一个可用账号;
- 把插件拼好的「该改什么」提示替换成「请求额度受限」,用户失去唯一线索。
## 修改
- 空体兜底收窄到 **402**(Payment Required,语义上就是额度/计费受限)。
406 保持插件给的 Fatal 原样透传,提示文案逐字保留。
- `is_blank_error_body` 增加占位词识别(`is_placeholder_message`):
`上游错误` 与 `上游返回 <数字>: 上游错误` 都算「没有正文」。
修的是审查指出的「两条投递路径结论不一致」——状态码路径拿到的是真空串,
`StreamEvent::Done(Err(provider_http:…))` 路径拿到的是插件渲染过的占位文案,
只判空串会让后者永远不触发兜底。
- 占位词判据按**形状**识别而不是「包含」:`上游错误(余额不足)` 这类仍含
上游信息的文案不算空,避免真实计费墙被误判。
## 测试
- `autoclaw_empty_body_402_falls_back_to_quota_limited`:四种空体形状
(`{}` / `{code:null,message:""}` / `{message:"上游错误"}` /
`{message:"上游返回 402: 上游错误"}`)都兜底。
- `autoclaw_empty_body_406_stays_fatal`:空体与带提示两种文案都保持 Fatal,
且文案逐字不变。
- `autoclaw_402_message_with_content_is_not_treated_as_blank`:含信息量的
402 文案不被当空体。
- `cargo test --lib plugin_host::tests::autoclaw` 7 passed。
---
.../server/src/server/core/plugin_host/rpc.rs | 62 ++++++++++++---
.../src/server/core/plugin_host/tests.rs | 76 ++++++++++++++++---
2 files changed, 118 insertions(+), 20 deletions(-)
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
index 799ee8e63..d2525e406 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/rpc.rs
@@ -1467,10 +1467,21 @@ fn upstream_error_class(class: proto::ErrorClass) -> UpstreamErrorClass {
/// 分两条:
/// 1. 有正文证据:业务码 810000 或正文含「免费额度已用完」→ 按天重置,
/// 冷却到下一个北京零点;
-/// 2. **空响应体**的 402 / 406:生产库实测 AutoClaw 额度耗尽会以这两个
-/// 状态码 + 空正文出现(issue #6),拿不到任何文案证据 ——
-/// 「空体 + 402/406」在 AutoClaw 上没有正常业务含义,状态码即证据。
-/// 恢复时刻不猜,交给上层按 `Retry-After` 或默认短期冷却。
+/// 2. **空响应体的 402**:生产库实测 AutoClaw 额度耗尽会以 402 + 空正文
+/// 出现(issue #6),拿不到任何文案证据。恢复时刻不猜,交给上层按
+/// `Retry-After` 或默认短期冷却。
+///
+/// ── 为什么 406 不在空体兜底里(审查结论)─────────────────────
+/// 406 空响应体在 AutoClaw 上是**上游预校验拒收的统一形态**,实测过三个
+/// 独立成因:`max_tokens` 取小值、system 首句命中指纹、请求形态风控
+/// (见插件侧 `autoclaw/mod.rs` 的「四道上游闸」与 `prompt.rs` 的
+/// `UPSTREAM_406_HINT`,以及本插件 classify 在空体 406 时追加的那句提示)。
+/// 把它一律当额度耗尽会有两个用户可见的坏结果:
+/// - 一次提示词闸门拒收 → 冷却一个**健康**账号并换号,而同一份 body 换
+/// 谁的账号都会被拒,等于空转一个冷却窗口、还少一个可用账号;
+/// - 把插件拼好的「该改什么」提示换成「请求额度受限」,用户失去唯一线索。
+/// 因此 406 保持插件给的 `Fatal` 原样透传;只有 402(Payment Required)这种
+/// 语义上就是「额度/计费受限」的状态码才走空体兜底。
///
/// ── reset_at ────────────────────────────────────────────────
/// 上游不给恢复时刻;免费额度按天重置(上游的日口径都是北京时间零点),
@@ -1504,18 +1515,21 @@ pub(super) fn autoclaw_quota_fallback(
status,
};
}
- // ② 空响应体的 402 / 406(issue #6)。
+ // ② 空响应体的 402(issue #6)。406 不在这里 —— 理由见上面的
+ // 「为什么 406 不在空体兜底里」。
//
// 判据必须核验「体确实是空的」,而不是只看顶层 `message` 缺省:
// 上游也可能返回 `{"error":{"type":"insufficient_quota"}}` 这类
// 没有 `message` / `code` 顶层键的**有内容**正文 —— 那种形态说明
// 上游给了结构化说明,应当保持原本的 Fatal 透传,而不是猜成限流。
- if matches!(status, 402 | 406)
+ if status == 402
&& matches!(class, UpstreamErrorClass::Fatal { .. })
&& is_blank_error_body(error_body)
{
return UpstreamErrorClass::QuotaLimited {
reset_at: None,
+ // 空体兜底不沿用 `class_message`:那时 Fatal 的文案只是插件对空正文
+ // 的占位(「上游返回 402: 上游错误」),对用户没有任何信息量。
message: format!("上游返回 {status}: 请求额度受限(上游未返回详情),按限流冷却"),
// 正文没给业务码时保留分类器已有的那个(插件可能从状态行/头部
// 解析出过),不要因为走了兜底分支就丢掉。
@@ -1535,13 +1549,13 @@ pub(super) fn autoclaw_quota_fallback(
/// `{"code":null,"message":""}`,所以最常见的形态是「键在、值为空」;
/// 但插件也可能把一段非 JSON 文本原样塞进 `message`,或有上游返回
/// `{"error":{...}}` 这类结构。判据因此是**逐值检查**:只含
-/// null / 空串 / 空对象 / 空数组时才算空 —— 出现任何非空内容就判为
-/// 「有正文」,退回原分类。
+/// null / 空串 / 占位词(见 [`is_placeholder_message`])/ 空对象 / 空数组
+/// 时才算空 —— 出现任何非空内容就判为「有正文」,退回原分类。
fn is_blank_error_body(body: &Value) -> bool {
fn blank(value: &Value) -> bool {
match value {
Value::Null => true,
- Value::String(text) => text.trim().is_empty(),
+ Value::String(text) => is_placeholder_message(text),
Value::Array(items) => items.iter().all(blank),
Value::Object(map) => map.values().all(blank),
Value::Bool(_) | Value::Number(_) => false,
@@ -1555,6 +1569,36 @@ fn is_blank_error_body(body: &Value) -> bool {
}
}
+/// 这段文本是不是「什么都没有」的占位文案。
+///
+/// ── 为什么需要它(审查反馈:两条投递路径结论不一致)─────────────
+/// 同一份空响应体会从两条路进来:
+/// - 状态码路径(`finish_stream` 的 `status >= 400`)拿到的是**解出来的
+/// 原始字节**,空体 → 空串;
+/// - `StreamEvent::Done(Err(provider_http:…))` 路径拿到的是插件渲染过的
+/// `WireError.message`,即 `autoclaw::classify` 对空正文的占位
+/// 「上游返回 402: 上游错误」。
+/// 只判空串会让第二条路径永远不触发兜底。占位词的形状是固定的
+/// (`format!("上游返回 {status}: {raw}")` + 上游没给文案时的「上游错误」),
+/// 因此按形状识别:`上游错误` 或 `上游返回 <数字>: 上游错误` 都算空。
+/// 占位之后若还跟着插件提示(406 的 `UPSTREAM_406_HINT`)则**不算空** ——
+/// 那说明上游形态已被识别,应当保留提示、走原分类。
+fn is_placeholder_message(text: &str) -> bool {
+ let text = text.trim();
+ if text.is_empty() || text == "上游错误" {
+ return true;
+ }
+ let Some(rest) = text.strip_prefix("上游返回 ") else {
+ return false;
+ };
+ let Some((status, raw)) = rest.split_once(": ") else {
+ return false;
+ };
+ !status.is_empty()
+ && status.chars().all(|c| c.is_ascii_digit())
+ && raw.trim() == "上游错误"
+}
+
/// 从分类结果里取出已有文案(Fatal/其它档的 message 已含 `上游返回 {status}:`)。
fn class_message(class: &UpstreamErrorClass, status: u16, raw: &str) -> String {
match class {
diff --git a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
index f35412446..74b71268a 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/plugin_host/tests.rs
@@ -226,27 +226,56 @@ fn other_autoclaw_403_stays_fatal() {
);
}
-/// 空响应体的 402 / 406 也按额度耗尽兜底(issue #6):生产库实测 AutoClaw
-/// 额度耗尽会以这两个状态码 + 空正文出现,插件分类器拿不到证据落 Fatal
-/// ⇒ 不冷却不换号。reset_at 留 None:上层接 Retry-After 或默认短期冷却。
+/// 空响应体的 402 按额度耗尽兜底(issue #6):生产库实测 AutoClaw 额度耗尽
+/// 会以 402 + 空正文出现,插件分类器拿不到证据落 Fatal ⇒ 不冷却不换号。
+/// reset_at 留 None:上层接 Retry-After 或默认短期冷却。
+///
+/// 两种「空体」形状都要覆盖:状态码路径给的是空对象,`provider_http` 路径
+/// 给的是插件渲染过的占位文案(见 `is_placeholder_message`)。
#[test]
-fn autoclaw_empty_body_402_and_406_fall_back_to_quota_limited() {
- for status in [402u16, 406] {
- let body = serde_json::json!({}); // 空体
+fn autoclaw_empty_body_402_falls_back_to_quota_limited() {
+ for body in [
+ serde_json::json!({}),
+ serde_json::json!({ "code": null, "message": "" }),
+ serde_json::json!({ "message": "上游错误" }),
+ serde_json::json!({ "message": "上游返回 402: 上游错误" }),
+ ] {
let fatal = UpstreamErrorClass::Fatal {
- status,
- message: format!("上游返回 {status}: "),
+ status: 402,
+ message: "上游返回 402: 上游错误".into(),
upstream_code: None,
};
- let class = super::rpc::autoclaw_quota_fallback("autoclaw", status, fatal, &body);
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", 402, fatal, &body);
let UpstreamErrorClass::QuotaLimited { reset_at, status: got, .. } = &class else {
- panic!("空体 {status} 应当被兜底成 QuotaLimited,实际 {class:?}");
+ panic!("空体 402 应当被兜底成 QuotaLimited,实际 {class:?}(body {body})");
};
- assert_eq!(*got, status);
+ assert_eq!(*got, 402);
assert!(reset_at.is_none(), "空体兜底不该猜恢复时刻,实际 {reset_at:?}");
}
}
+/// 空响应体的 406 **不**兜底(审查结论):406 在 AutoClaw 上是上游预校验
+/// 拒收的统一形态(max_tokens 取小值 / system 首句指纹 / 请求形态风控),
+/// 一律当额度耗尽会冷却健康账号、并吞掉插件拼好的 `UPSTREAM_406_HINT`。
+#[test]
+fn autoclaw_empty_body_406_stays_fatal() {
+ let hint = "上游返回 406: 上游错误;上游拒收(406)且未给出原因,实测过的方向:……";
+ for message in ["上游返回 406: 上游错误", hint] {
+ let fatal = UpstreamErrorClass::Fatal {
+ status: 406,
+ message: message.into(),
+ upstream_code: None,
+ };
+ for body in [serde_json::json!({}), serde_json::json!({ "message": "上游错误" })] {
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", 406, fatal.clone(), &body);
+ let UpstreamErrorClass::Fatal { message: kept, .. } = &class else {
+ panic!("空体 406 不该被兜底,实际 {class:?}");
+ };
+ assert_eq!(kept, message, "406 的原始文案(含提示)必须原样保留");
+ }
+ }
+}
+
/// 对照组:带业务 body 的 402 / 406(真实计费墙、请求形态问题等)不兜底。
#[test]
fn autoclaw_402_406_with_body_stays_fatal() {
@@ -265,6 +294,31 @@ fn autoclaw_402_406_with_body_stays_fatal() {
}
}
+/// 对照组:只有「占位词」才算空体 —— 任何带信息量的正文都要保持 Fatal。
+///
+/// 这一条防的是 `is_placeholder_message` 判得太宽:把「上游错误(余额不足)」
+/// 这类仍含上游信息的文案误判成占位词,会让一次真实计费墙被当成额度过期。
+#[test]
+fn autoclaw_402_message_with_content_is_not_treated_as_blank() {
+ for message in [
+ "上游返回 402: 余额不足,请充值",
+ "上游返回 402: 上游错误(余额不足)",
+ "上游错误:计费账户已欠费",
+ ] {
+ let body = serde_json::json!({ "message": message });
+ let fatal = UpstreamErrorClass::Fatal {
+ status: 402,
+ message: message.into(),
+ upstream_code: None,
+ };
+ let class = super::rpc::autoclaw_quota_fallback("autoclaw", 402, fatal, &body);
+ assert!(
+ matches!(class, UpstreamErrorClass::Fatal { .. }),
+ "{message} 含上游信息,不该当空体兜底,实际 {class:?}"
+ );
+ }
+}
+
/// 对照组:正文没有顶层 `message` / `code`,但有结构化内容(如
/// `{"error":{"type":"insufficient_quota"}}`)—— 不能当成「空体」兜底。
///
From 027a5bd3135414c17e6955ba643d4c7c03336133 Mon Sep 17 00:00:00 2001
From: SsuJo_ <1049731887@qq.com>
Date: Tue, 3 Nov 2026 17:15:27 +0800
Subject: [PATCH 16/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=8A=8A?=
=?UTF-8?q?=E3=80=8C=E7=A3=81=E7=9B=98=E8=A2=AB=E5=90=83=E6=8E=89=E3=80=8D?=
=?UTF-8?q?=E7=9A=84=E4=B8=89=E6=9D=A1=E6=9D=A5=E6=BA=90=E9=83=BD=E5=A0=B5?=
=?UTF-8?q?=E4=B8=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1. 设置页显示库内可回收空洞(reclaimableBytes / freePageRatio):
auto_vacuum=0 下删除只标空闲页、文件不缩小,2.5GB 的库可能有一半是空洞;
界面现在会写「可回收 X(Y%)」,并指路请求日志页的「清理 → 压缩」。
条数与空洞在同一次持锁里读(free_space 收 guard,避免不可重入死锁)。
2. backups/ 增加保留上限:整库恢复的 pre-restore-*.db 与云同步的
cloud-sync-*.json 各只留最近 2 份,超出按 mtime + 名字删最旧。
两者都是整库级留影,此前从不清理,操作越多占盘越多。
3. 请求日志分析脚本退出时删除自己建的 %TEMP% 快照(含异常 / Ctrl-C):
以前一份快照 = 一份整库且从不清理,实测残留过 4.7GB。
SKILL.md 同步写明快照体积与 --no-copy 直连。
---
.agents/skills/request-log-analysis/SKILL.md | 172 +++++
.../skills/request-log-analysis/analyze.py | 641 ++++++++++++++++++
.../src/server/core/cloud_sync/snapshot.rs | 3 +
.../src-tauri/server/src/server/db/backup.rs | 1 +
.../server/src/server/db/backup/retention.rs | 139 ++++
.../server/src/server/db/backup/safety.rs | 9 +
.../server/src/server/request_stats.rs | 14 +-
.../src/server/request_stats/maintenance.rs | 19 +-
.../ui-islands/src/islands/settings-model.ts | 1 +
.../ui-islands/src/islands/settings-page.tsx | 15 +
.../ui-islands/src/islands/settings-state.ts | 19 +-
desktop-tauri/ui/islands/ui.js | 106 +--
12 files changed, 1072 insertions(+), 67 deletions(-)
create mode 100644 .agents/skills/request-log-analysis/SKILL.md
create mode 100644 .agents/skills/request-log-analysis/analyze.py
create mode 100644 desktop-tauri/src-tauri/server/src/server/db/backup/retention.rs
diff --git a/.agents/skills/request-log-analysis/SKILL.md b/.agents/skills/request-log-analysis/SKILL.md
new file mode 100644
index 000000000..82b6c3bfd
--- /dev/null
+++ b/.agents/skills/request-log-analysis/SKILL.md
@@ -0,0 +1,172 @@
+---
+name: request-log-analysis
+description: Agent2API(workbuddy)网关的请求日志自动排障 —— 从统一库 `{config_dir}/agent2api.db`(安装版默认 `%USERPROFILE%\.agent2api`,WAL 热库先快照只读)读 `requests` 明细、`attempt_details` 重试链、`route` 选路快照与 `logs` 应用日志,把最近的转发(中转)请求按「家 + 状态码 + 归一化错误文案」聚类并分桶定责(客户端断开 / 上游故障 / 限额轮换 / 适配缺陷 / 请求体形态被拒…),定位到具体代码落点并给出原因或修改建议。凡是用户提到「分析最近的请求 / 看看请求日志 / 为什么转发失败 / 一直 429 / 408 / 500 parse response failed / 帮我看看中转哪里有问题 / 某家最近不稳 / 基于请求日志写修复」这类诉求,都先按本 Skill 执行 —— 即使对方没提「日志」「排障」这类字眼。
+---
+
+# Agent2API 请求日志排障(中转请求自动分析)
+
+覆盖:定位数据(第 1 节)→ 标准流程(第 2 节)→ 分桶定责与代码落点(第 3 节)→ 伴随脚本(第 4 节)→ 报告(第 5 节)→ 坑(第 6 节)。手头只有 sqlite3 CLI 时用第 7 节的 SQL 速查。
+
+## 0. 三条工作约定
+
+1. **只读**。分析过程绝不写库、不改配置、不动账号;临时快照只落 `%TEMP%`。
+2. **先给结论与建议,等用户点头再改代码**;真要改 providers/ 适配器时,接着按 `provider-adaptation` 执行(那是改代码的规范)。
+3. **每条结论带证据**:错误原文、重试链、能复现的命令/SQL。「上游故障」也要给依据(多账号同挂、时间窗集中)—— 没证据的定责等于猜。
+
+## 1. 数据在哪、长什么样
+
+### 1.1 库的定位(与服务端 `paths::config_dir()` 同序)
+
+| 优先级 | 来源 |
+|---|---|
+| 1 | `--db` 显式指定(传目录会自动拼 `agent2api.db`) |
+| 2 | 环境变量 `AGENT2API_PROXY_HOME`(旧名 `WORKBUDDY_PROXY_HOME` 兼容) |
+| 3 | 默认 `%USERPROFILE%\.agent2api\agent2api.db`(Windows;非 Windows 为 `~/.agent2api`) |
+
+服务器 / Docker 部署是**同一个库文件**,把 `agent2api.db`(连同 `-wal` / `-shm`)拷回本机后用 `--db` 指进来即可。同目录还有 `debug/last-request.json`(最近一次请求落盘)与 `debug/Agent2Providers-src`(插件家源码缓存)。
+
+**网关在跑时库是 WAL 热库 —— 先快照再查**(脚本默认已做:SQLite backup API 拿一致快照,失败则三件套整拷)。
+
+### 1.2 表速查
+
+| 表 | 内容 | 排障用途 |
+|---|---|---|
+| `requests` | 每次转发一条明细(全量记,与调试开关无关) | **主战场** |
+| `logs` | 应用日志(`server` / `upstream` / `model` …) | 载荷改写告警、插件动作、启动事件 |
+| `debug_traffic` | **调试模式开着才有**:上游侧原始报文(头部已脱敏) | 看最终发出去的 body 与上游原始响应 |
+| `request_raw` | **调试模式开着才有**:下游侧正文(客户端原文) | 对照客户端发来的东西 |
+| `request_daily` | 按天聚合 | 趋势对照 |
+| `accounts` | 账号(凭证加密落库,明文不在库里) | 对照 account_id / name |
+| `kv` | 配置(`modelRules` / `customProviders` / `routingStrategy` / `proxyPool` / `apiKeys` …) | 查映射、自定义家、出口 |
+
+「记录全请求」有两层:`requests` 明细**始终全量**;原始报文(`debug_traffic` / `request_raw`)只在面板设置页开**调试模式**期间落库。要分析某次请求的报文,先开调试模式再复现一次。
+
+### 1.3 `requests` 关键列
+
+| 列 | 含义 |
+|---|---|
+| `ts` | 毫秒时间戳 |
+| `model` / `client_model` / `upstream_model` | 请求侧解析名 / 客户端点名的原值 / 实际发给上游的名字(空串 = 一次都没发出去) |
+| `provider` / `account_id` / `account_name` | 实际承载者;空串 = 没选上路就失败(如模型不存在) |
+| `status` | **回给客户端的** HTTP 状态码;`0` = 没发出去就失败 |
+| `error` | 失败摘要,成功为 NULL。注意 `status=200` 且 `error` 非空 = 客户端断开类,不是上游失败 |
+| `attempts` | 尝试次数(含首次),>1 说明走过重试/轮换 |
+| `attempt_details` | 重试链全史:JSON 数组 `[{provider, account, status, error, retries:[{reason, status, delayMs}], notice}]` |
+| `route` | 选路快照 `{strategy, sticky, stickyHit, picked, ordered[≤12], blocked[≤12]}`,每项 `{id, name, provider, state, reason}` —— 「当时为什么这么排」 |
+| `duration_ms` / `first_response_ms` | 总耗时 / 上游首帧耗时(NULL = 一帧都没收到,转发前就失败) |
+| `*_tokens` / `cache_read_tokens` | 用量(失败恒 0) |
+| `client` | 下游客户端归类(`Codex` / `Claude Code` / `deepseek-harness` / `other` …) |
+| `is_test` | 模型管理页「测试」发起的流量,**分析一律默认排除** |
+| `phase` / `phase_started_at` | 在途阶段(非空 = 这行还没跑完) |
+| `sensitive_hits` | 命中的脱敏规则标签 |
+
+**成功口径(与后端 `RequestEntry::is_success` 逐字一致)**:`status BETWEEN 200 AND 299 AND error IS NULL`,其余一律算失败。`error` 里「上游返回 X」的 X 是**上游侧**状态码,与 `status` 列(回给客户端的)可以不同 —— 两个都看。
+
+## 2. 标准分析流程(五步)
+
+```bash
+# 用 DSH 会话时先 load_workspace_dependencies 拿内置 Python;任何 Python 3.8+ 均可
+python .agents/skills/request-log-analysis/analyze.py overview --hours 24
+python .agents/skills/request-log-analysis/analyze.py failures --hours 24 --limit 15
+python .agents/skills/request-log-analysis/analyze.py detail --id <请求id>
+python .agents/skills/request-log-analysis/analyze.py logs --level warn --category upstream
+```
+
+1. **总览**(`overview`):总数、成功率、状态码分布、按家失败率与耗时、重试率、按客户端。先看形状:是个别家失败还是整体掉线;失败集中在哪个客户端。
+2. **失败聚类**(`failures`):按「家 + 状态码 + 归一化文案」分组并自动分桶。错误文案里常带 request_id / 时间戳 / 数字等动态值,**聚类前必须归一化**(脚本已做),否则同一种错误被拆成几十组。
+3. **分桶定责**:对照第 3 节映射表,给每个聚类判定「上游的锅 / 客户端的锅 / 网关适配缺陷 / 配置问题」。
+4. **单条深挖**(`detail`):每个可疑聚类挑 1–2 条代表(最新一条 + 重试链最长的一条),看 `attempt_details`(换了谁、为什么换)与 `route`(为什么排它先上)、邻近 `logs`。要看原始报文再开调试模式复现。
+5. **出报告**(第 5 节骨架):现象 → 证据 → 定责 → 建议;无需改码的明确说无需改码。
+
+## 3. 分桶定责映射(哪类错误 → 查哪里)
+
+| 桶 | 实测典型文案 | 定责 | 建议落点 |
+|---|---|---|---|
+| 客户端断开 | `客户端在响应完成前断开连接`;`响应流未完整下发(客户端中断或服务退出)` | 客户端取消/超时,**不是网关的锅** | 看 `client` 列哪家高频 → 建议调该客户端超时;网关无需改码 |
+| 无账号可转发 | `所有账号均已禁用…`;`所有启用中的账号都被限制器拦下…` | 配置/限制器 | 面板账号页启用、检查限制器规则;无需改码 |
+| 模型/路由不存在 | `模型不存在: luna。完整列表见 GET /v1/models`;`上游返回 400: 模型不存在…`;`model [x] service info not found`;`model [x] is not allowed for user type [y]` | 客户端点名的模型没有映射到可用家;或上游账号档位不承载 | 模型规则/映射(面板「模型规则」,`kv.modelRules`;代码 `core/model_rules/`);该家目录 `core/providers//models.rs`。`user type` 是上游账号档位问题 → 换绑承载家,不是改映射 |
+| 解析/翻译层 | `上游返回 500: parse response failed`;`Parse message failed: unsupported content type …: encrypted_content` | **适配缺陷,最值得改代码**:报文形态超出该家适配层处理范围 | 内置家:`core/providers//` 与 `core/upstream/translate`;插件家去插件仓库(见下) |
+| 请求体形态被上游拒 | `Invalid 'tools': array too long … 253 instead`(上限 128);`prompt is too long: … > … maximum` | 网关发出的 body 超出上游硬限制,未做裁剪 | `core/upstream/payload` 组装处按家裁剪(工具条数/上下文长度);先确认该家适配层是否声明了对应能力 |
+| 限额/轮换 | `上游返回 429: usage exceeds frequency limit … reset at …`;`too many requests(所有候选账号…均已限额或禁用)` | 限额分档与冷却是否生效 | `classify_error` 四档与冷却标记(`provider-adaptation` §2.6);用 `attempt_details` 验证**是否真换了账号** —— 同一账号反复撞墙 = 分档或冷却失效,这才是要修的 |
+| 凭证/权限 | 401 / 402 / 403 及上游对应文案 | TokenExpired 分档、续期失效 | 该家 `adapter.rs` 的 `supports_refresh` 与 `credential_maintenance` |
+| 超时 | `连接中超时(30秒,出口 直连)`;408 / 504 | 网络/上游慢 | 出口与代理(面板 `proxyPool` 设置);一般无需改码 |
+| 上游故障 | `上游返回 500/502/503: …`;`Upstream service temporarily unavailable` | 上游侧 | 无需改码;多账号同挂 = 上游整体故障;某家长期高占比时建议下线或降级 |
+| 其它 | — | 逐条看 | — |
+
+**内置家 vs 插件家**:本仓库 `core/providers/` 下是 `accio / autoclaw / cline / loomy / modelscope / monkeycode / qoder / workbuddy / zcode`(外加 `catalog` / `custom`);`raccoon`、`trae`、`antigravity` 等是**插件家**,实现在插件仓库(`Agent2Providers`),本机最近一次插件源码缓存在 `%USERPROFILE%\.agent2api\debug\Agent2Providers-src` —— 修适配别在本仓库里瞎找。`custom-` 这类 id 是自定义 provider,名字与 base_url 去 `kv.customProviders` 对。
+
+## 4. 伴随脚本 analyze.py
+
+四个子命令:`overview`(总览)/ `failures`(聚类分桶)/ `detail`(单条深挖)/ `logs`(应用日志)。零第三方依赖(Python 3.8+ 标准库)。
+
+- **选项一律放在子命令后面**(脚本如此设计:公共选项只挂子解析器)。
+- 默认先快照再查(`%TEMP%\a2a-logs-*`);`--no-copy` 直连只读;`--db` 指其它库(服务器拷回 / 复用上次的快照目录继续追问)。
+- `--json` 额外输出机器可读结构;`--include-test` 才包含模型测试流量;`--since` / `--until`(`YYYY-MM-DD HH:MM` 本地时间)替代 `--hours`。
+- `detail --body` 会打印报文正文 —— `request_raw` 是用户原文,**报告里不要整段外贴**。
+
+常用组合:
+
+```bash
+python analyze.py failures --hours 72 --limit 20 # 近三天的失败全景
+python analyze.py detail --id --log-window 120 # 深挖 + 前后 2 分钟日志
+python analyze.py detail --id --body # 连原始报文一起看(调试模式需已开)
+python analyze.py logs --level warn --category upstream # 载荷改写类告警(剔除工具声明等)
+```
+
+## 5. 报告骨架
+
+```markdown
+## 中转请求分析报告(YYYY-MM-DD HH:MM,窗口 …)
+### 总览
+总数 / 成功率 / 失败率 / 重试率,1–2 行;失败最集中的家与客户端。
+### 失败聚类与定责
+| # | 条数 | 现象(家+状态码+样例文案) | 桶 | 定责 | 证据 |
+### 结论与建议
+1. 【无需改码】…(依据:上游侧故障/客户端断开/配置项)
+2. 【建议改码】<文件与位置> —— 现象、根因假设、建议做法
+### 复现
+脚本命令与/或 SQL
+```
+
+## 6. 已知坑
+
+1. **WAL 热库**:只拷 `.db` 不拷 `-wal` 会丢最近几分钟的数据;脚本默认 backup API 快照,手工操作请三件套一起拷。
+2. **脚本选项必须放子命令后**:`analyze.py overview --hours 6`,不是 `analyze.py --hours 6 overview`。
+3. **同 id 多行**:重试、去重排队会给同一个 `requests.id` 记多行;按 `ts DESC, row_id DESC` 取最新,统计别拿 id 当唯一键。`debug_traffic` / `request_raw` 的 id 才是主键一对一。
+4. **error 带动态值**:聚类前必须归一化(request_id / 时间戳 / 数字),否则聚不拢;看样例原文别只看归一键(模型名里的数字也会被抹掉,如 `gpt-6-luna` → `gpt-#-luna`)。
+5. **status=200 + error 非空** = 客户端断开类,别当上游失败算进失败率定责。
+6. **调试报文只有调试模式开着才落库**;`request_raw` 是用户原文,外贴注意脱敏。
+7. `is_test=1` 默认排除;`ts` 是毫秒,展示按本地时区换算。
+8. **Windows 控制台默认 GBK**:脚本已强制 UTF-8 输出;自己写 Python 内联 SQL 时记得 `PYTHONIOENCODING=utf-8` 或 `sys.stdout.reconfigure(encoding="utf-8")`,否则中文错误文案全是乱码、聚类也没法做。
+9. **快照 = 一份整库**:库可能到 GB 级(调试模式开着时尤其),快照目录在 `%TEMP%\a2a-logs-*`。
+ 脚本**退出时自动删除**本次自己建的快照目录(含异常 / Ctrl-C);只有 `--db` 指进去复用的旧快照不归本次管,需要手工清理。
+ 系统盘紧张时用 `--no-copy` 直连只读(WAL 热库也能读,只是可能少最后几秒的数据)。
+
+## 7. 手头只有 sqlite3 CLI 时(SQL 速查)
+
+在拷贝出来的快照上(`sqlite3 agent2api.db` 会自动恢复 WAL):
+
+```sql
+-- 按家汇总(成功口径与后端一致)
+SELECT provider, COUNT(*) total,
+ SUM(CASE WHEN status BETWEEN 200 AND 299 AND error IS NULL THEN 1 ELSE 0 END) ok
+FROM requests WHERE ts >= (strftime('%s','now') - 86400) * 1000
+GROUP BY provider ORDER BY total DESC;
+
+-- 失败 Top(粗聚类:substr 代替归一化,动态文案会拆散,尽量用脚本)
+SELECT provider, status, COUNT(*) c, MAX(error) sample
+FROM requests
+WHERE ts >= (strftime('%s','now') - 86400) * 1000
+ AND (status < 200 OR status > 299 OR error IS NOT NULL)
+GROUP BY provider, status, substr(error, 1, 60)
+ORDER BY c DESC;
+
+-- 重试链展开
+SELECT r.ts, r.provider, j.value
+FROM requests r, json_each(r.attempt_details) j
+WHERE r.ts >= (strftime('%s','now') - 86400) * 1000 AND r.status <> 200;
+```
+
+---
+
+产出「原因 + 建议」是本 Skill 的终点;要动手改适配器 / 模型规则时按 `provider-adaptation` 执行,涉及提交与发版按 `release-flow` 执行。
diff --git a/.agents/skills/request-log-analysis/analyze.py b/.agents/skills/request-log-analysis/analyze.py
new file mode 100644
index 000000000..7620d2602
--- /dev/null
+++ b/.agents/skills/request-log-analysis/analyze.py
@@ -0,0 +1,641 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""Agent2API 请求日志分析(skill: request-log-analysis)的伴随脚本。
+
+只读分析统一库 {config_dir}/agent2api.db(安装版 / 服务器部署同一格式):
+
+ overview 总览:成功率 / 状态码分布 / 按家 / 按模型 / 重试率 / 客户端分布
+ failures 失败聚类:按「家 + 状态码 + 归一化错误文案」分组并自动分桶定责
+ detail 单条深挖:明细 + 重试链(attempt_details) + 选路快照(route) +
+ 邻近应用日志 + 调试报文(debug_traffic / request_raw)
+ logs 应用日志(logs 表)
+
+成功口径与后端 `RequestEntry::is_success` 逐字一致:
+status BETWEEN 200 AND 299 AND error IS NULL,其余一律算失败(status=0 =
+没发出去就失败)。error 里「上游返回 X」的 X 是上游侧状态码,status 列是
+回给客户端的状态码,两者可以不同。
+
+零第三方依赖(Python 3.8+ 标准库)。默认先把库快照到临时目录再查
+(SQLite backup API,热库也能拿到一致快照),绝不写原库。
+"""
+
+import argparse
+import json
+import os
+import re
+import shutil
+import sqlite3
+import sys
+import tempfile
+from datetime import datetime
+from pathlib import Path
+
+DB_NAME = "agent2api.db"
+
+# 本次运行创建的临时快照目录:退出时(含异常 / Ctrl-C)由 main 统一删掉。
+# 库是 GB 级的,一份快照就等于整库大小;早期版本把快照留在 %TEMP% 里不清理,
+# 反复分析几次就能把系统盘吃满(实测残留过 4.7GB)。因此这里必须「谁创建、
+# 谁负责删」,而不是把「完事可删」留给用户记着。
+_SNAPSHOT_DIRS = []
+
+# 「客户端断开」类错误的识别片段(status 常为 200,error 非空 —— 不是上游的锅)
+CLIENT_ABORT_MARKERS = (
+ "客户端在响应完成前断开连接",
+ "响应流未完整下发",
+ "客户端中断",
+ "客户端断开",
+)
+
+LOG_LEVELS = {"debug": 10, "info": 20, "warn": 30, "warning": 30, "error": 40}
+
+BUCKET_LABELS = {
+ "client_abort": "客户端断开",
+ "no_account": "无账号可转发",
+ "model_missing": "模型/路由不存在",
+ "parse": "解析/翻译层",
+ "quota": "限额/轮换",
+ "auth": "凭证/权限",
+ "bad_request": "请求体形态被上游拒",
+ "timeout": "超时",
+ "upstream_5xx": "上游故障",
+ "other": "其它",
+}
+
+# Windows 控制台默认 GBK:强制 UTF-8,坏字节替换而不是报错
+if hasattr(sys.stdout, "reconfigure"):
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace")
+ sys.stderr.reconfigure(encoding="utf-8", errors="replace")
+
+
+# ────────────────────────── 基础工具 ──────────────────────────
+
+def fmt_ms(ms):
+ """毫秒时间戳 → 本地时间字符串。"""
+ if ms is None:
+ return "-"
+ return datetime.fromtimestamp(ms / 1000).strftime("%m-%d %H:%M:%S")
+
+
+def dur_str(ms):
+ if ms is None:
+ return "-"
+ if ms >= 60000:
+ return f"{ms / 60000:.1f}m"
+ if ms >= 1000:
+ return f"{ms / 1000:.1f}s"
+ return f"{ms}ms"
+
+
+def parse_local(s, end_of_day=False):
+ d = datetime.strptime(s, "%Y-%m-%d %H:%M")
+ if end_of_day:
+ d = d.replace(minute=59, hour=23)
+ return int(d.timestamp() * 1000)
+
+
+def pct(part, whole):
+ if not whole:
+ return "0%"
+ return f"{part * 100.0 / whole:.1f}%"
+
+
+def percentile(sorted_values, p):
+ if not sorted_values:
+ return None
+ idx = min(len(sorted_values) - 1, max(0, round(p / 100.0 * (len(sorted_values) - 1))))
+ return sorted_values[idx]
+
+
+_HEX_RE = re.compile(r"[0-9a-fA-F]{8,}")
+_TS_RE = re.compile(r"\d{13}")
+_DATE_RE = re.compile(r"\d{4}-\d{1,2}-\d{1,2}[ T]\d{1,2}:\d{2}(:\d{2})?")
+_NUM_RE = re.compile(r"\d+")
+_WS_RE = re.compile(r"\s+")
+
+
+def normalize_error(text, maxlen=150):
+ """错误文案归一化:抹掉 request_id / 时间戳 / 数字等动态值,供聚类。
+
+ 原始文案保留在分组样例里;分组键用归一化后的形态,否则
+ 「usage will reset at 2026-10-22 17:11:47」这类每条都不同的错误
+ 永远聚不到一起。
+ """
+ s = text or ""
+ s = _TS_RE.sub("", s)
+ s = _DATE_RE.sub("", s)
+ s = _HEX_RE.sub("", s)
+ s = _NUM_RE.sub("#", s)
+ s = _WS_RE.sub(" ", s).strip()
+ return s[:maxlen]
+
+
+# ────────────────────────── 分桶定责 ──────────────────────────
+
+def bucket_of(status, error):
+ e = error or ""
+ low = e.lower()
+ if any(m in e for m in CLIENT_ABORT_MARKERS):
+ return "client_abort"
+ if "所有账号均已禁用" in e or "无账号可转发" in e or "无可用账号" in e:
+ return "no_account"
+ if status == 404 or "模型不存在" in e or "is not allowed" in low or "service info not found" in low:
+ return "model_missing"
+ if "parse response failed" in low or "parse message failed" in low or "unsupported content type" in low:
+ return "parse"
+ if status == 429 or "too many requests" in low or "usage exceeds" in low or "频率限制" in e:
+ return "quota"
+ if status in (401, 402, 403):
+ return "auth"
+ if status == 400:
+ return "bad_request"
+ if status in (408, 504) or "超时" in e or "timed out" in low or "timeout" in low:
+ return "timeout"
+ if status >= 500:
+ return "upstream_5xx"
+ return "other"
+
+
+# ────────────────────────── 定位与快照 ──────────────────────────
+
+def resolve_db(explicit):
+ """库路径:--db > AGENT2API_PROXY_HOME > WORKBUDDY_PROXY_HOME > ~/.agent2api。
+
+ 与服务端 paths::config_dir() 的解析顺序一致(环境变量整体覆盖)。
+ """
+ if explicit:
+ p = Path(explicit).expanduser()
+ if p.is_dir():
+ p = p / DB_NAME
+ return p
+ for var in ("AGENT2API_PROXY_HOME", "WORKBUDDY_PROXY_HOME"):
+ val = os.environ.get(var, "").strip()
+ if val:
+ return Path(val) / DB_NAME
+ home = os.environ.get("USERPROFILE") or os.environ.get("HOME") or "."
+ return Path(home) / ".agent2api" / DB_NAME
+
+
+def snapshot_db(db_path):
+ """把库快照到临时目录,返回 (快照路径, 方式说明)。
+
+ 方式一 SQLite backup API:网关在跑(WAL 热库)也能拿到一致快照;
+ 方式二 三件套整拷(db + -wal + -shm),打开副本时自动恢复 WAL。
+ 只拷 .db 不拷 -wal 会丢最近几分钟的数据 —— 这是常见坑。
+ """
+ if not db_path.exists():
+ raise SystemExit(
+ f"找不到库文件:{db_path}\n"
+ f" 可用 --db 显式指定(传目录会自动拼 {DB_NAME});\n"
+ f" 服务器/Docker 部署把 agent2api.db(连同 -wal/-shm)拷回本机后再指进来。"
+ )
+ tmp = Path(tempfile.mkdtemp(prefix="a2a-logs-"))
+ _SNAPSHOT_DIRS.append(tmp)
+ snap = tmp / DB_NAME
+ try:
+ uri = "file:///" + db_path.resolve().as_posix() + "?mode=ro"
+ src = sqlite3.connect(uri, uri=True)
+ try:
+ dst = sqlite3.connect(str(snap))
+ try:
+ src.backup(dst)
+ finally:
+ dst.close()
+ finally:
+ src.close()
+ return snap, "backup-api(热库一致快照)"
+ except Exception:
+ pass
+ copied = []
+ for suffix in ("", "-wal", "-shm"):
+ src = Path(str(db_path) + suffix)
+ if src.exists():
+ shutil.copy2(src, tmp / (DB_NAME + suffix))
+ copied.append(src.name)
+ if not copied:
+ raise SystemExit(f"库文件读取失败且无可拷贝的文件:{db_path}")
+ return snap, "file-copy(" + ", ".join(copied) + ")"
+
+
+def open_db(args):
+ db_path = resolve_db(args.db)
+ if args.no_copy:
+ uri = "file:///" + db_path.resolve().as_posix() + "?mode=ro"
+ conn = sqlite3.connect(uri, uri=True)
+ conn.row_factory = sqlite3.Row
+ return conn, db_path, "直连原库(只读,未快照)"
+ snap, how = snapshot_db(db_path)
+ conn = sqlite3.connect(str(snap))
+ conn.row_factory = sqlite3.Row
+ return conn, snap, f"快照 {how}: {snap}"
+
+
+def window_ms(args):
+ """时间窗:--since/--until 优先,缺省 = 最近 --hours 小时。"""
+ if args.since:
+ start = parse_local(args.since)
+ else:
+ start = None
+ if args.until:
+ end = parse_local(args.until, end_of_day=True)
+ else:
+ end = None
+ now = int(datetime.now().timestamp() * 1000)
+ if start is None and end is None:
+ end, start = now, now - int(args.hours * 3600 * 1000)
+ elif start is None:
+ start = end - int(args.hours * 3600 * 1000)
+ elif end is None:
+ end = now
+ return start, end
+
+
+def test_clause(args):
+ return "" if args.include_test else " AND is_test = 0"
+
+
+# ────────────────────────── overview ──────────────────────────
+
+def cmd_overview(conn, args, start, end):
+ where = "ts >= ? AND ts <= ?" + test_clause(args)
+ params = [start, end]
+ total = conn.execute(f"SELECT COUNT(*) FROM requests WHERE {where}", params).fetchone()[0]
+ ok = conn.execute(
+ f"SELECT COUNT(*) FROM requests WHERE {where} AND status BETWEEN 200 AND 299 AND error IS NULL",
+ params,
+ ).fetchone()[0]
+ fail = conn.execute(
+ f"SELECT COUNT(*) FROM requests WHERE {where} AND (status < 200 OR status > 299 OR error IS NOT NULL)",
+ params,
+ ).fetchone()[0]
+ running = conn.execute(
+ f"SELECT COUNT(*) FROM requests WHERE {where} AND phase <> ''", params
+ ).fetchone()[0]
+ status_rows = conn.execute(
+ f"SELECT status, COUNT(*) c FROM requests WHERE {where} GROUP BY status ORDER BY c DESC",
+ params,
+ ).fetchall()
+
+ data = {
+ "window": [fmt_ms(start), fmt_ms(end)],
+ "total": total, "success": ok, "failed": fail, "running": running,
+ "successRate": pct(ok, total),
+ "status": {str(r["status"]): r["c"] for r in status_rows},
+ }
+ print(f"窗口 {fmt_ms(start)} ~ {fmt_ms(end)} 总数 {total} 成功 {ok} ({pct(ok, total)})"
+ f" 失败 {fail} ({pct(fail, total)}) 在途 {running}"
+ f"{' [含测试流量]' if args.include_test else ' [已排除测试流量]'}")
+ print("状态码:", " ".join(f"{r['status']}×{r['c']}" for r in status_rows) or "无")
+
+ print("\n── 按家(provider)──")
+ print(f"{'provider':22s} {'total':>7s} {'fail':>6s} {'失败率':>7s} {'p50':>8s} {'p95':>8s}")
+ prov_rows = conn.execute(
+ f"SELECT provider, COUNT(*) total, "
+ f"SUM(CASE WHEN status < 200 OR status > 299 OR error IS NOT NULL THEN 1 ELSE 0 END) fail "
+ f"FROM requests WHERE {where} GROUP BY provider ORDER BY total DESC",
+ params,
+ ).fetchall()
+ provider_data = []
+ for r in prov_rows:
+ d = conn.execute(
+ f"SELECT duration_ms FROM requests WHERE {where} AND provider = ? ORDER BY duration_ms",
+ params + [r["provider"]],
+ ).fetchall()
+ durs = sorted(x[0] or 0 for x in d)
+ p50, p95 = percentile(durs, 50), percentile(durs, 95)
+ name = r["provider"] or "(未选路)"
+ print(f"{name:22s} {r['total']:>7d} {r['fail'] or 0:>6d} {pct(r['fail'] or 0, r['total']):>7s}"
+ f" {dur_str(p50):>8s} {dur_str(p95):>8s}")
+ provider_data.append({"provider": r["provider"], "total": r["total"],
+ "failed": r["fail"] or 0, "p50ms": p50, "p95ms": p95})
+ data["providers"] = provider_data
+
+ print("\n── 失败 Top 模型 ──")
+ model_rows = conn.execute(
+ f"SELECT COALESCE(NULLIF(upstream_model, ''), model) m, COUNT(*) c FROM requests "
+ f"WHERE {where} AND (status < 200 OR status > 299 OR error IS NOT NULL) "
+ f"GROUP BY m ORDER BY c DESC LIMIT 8",
+ params,
+ ).fetchall()
+ for r in model_rows:
+ print(f" {r['m'] or '(空)'} × {r['c']}")
+
+ print("\n── 重试 ──")
+ retry = conn.execute(
+ f"SELECT COUNT(*) c, MAX(attempts) mx, AVG(attempts * 1.0) avg FROM requests "
+ f"WHERE {where} AND attempts > 1",
+ params,
+ ).fetchone()
+ print(f"attempts>1 共 {retry['c']} 条({pct(retry['c'], total)}),最多 {retry['mx']} 次,"
+ f"平均 {retry['avg'] or 0:.2f} 次")
+
+ print("\n── 按客户端 ──")
+ client_rows = conn.execute(
+ f"SELECT client, COUNT(*) total, "
+ f"SUM(CASE WHEN status < 200 OR status > 299 OR error IS NOT NULL THEN 1 ELSE 0 END) fail "
+ f"FROM requests WHERE {where} GROUP BY client ORDER BY total DESC",
+ params,
+ ).fetchall()
+ for r in client_rows:
+ name = r["client"] or "(未识别)"
+ print(f" {name:18s} total {r['total']:>6d} fail {r['fail'] or 0:>6d} ({pct(r['fail'] or 0, r['total'])})")
+
+ if args.json:
+ print(json.dumps(data, ensure_ascii=False, indent=2))
+
+
+# ────────────────────────── failures ──────────────────────────
+
+def cmd_failures(conn, args, start, end):
+ where = ("ts >= ? AND ts <= ?" + test_clause(args) +
+ " AND (status < 200 OR status > 299 OR error IS NOT NULL)")
+ params = [start, end]
+ total_all = conn.execute(
+ f"SELECT COUNT(*) FROM requests WHERE ts >= ? AND ts <= ?" + test_clause(args),
+ params,
+ ).fetchone()[0]
+ rows = conn.execute(
+ f"SELECT ts, model, upstream_model, provider, account_name, account_id, status, attempts, "
+ f"error, client FROM requests WHERE {where} ORDER BY ts DESC",
+ params,
+ ).fetchall()
+
+ print(f"失败 {len(rows)} 条 / 总 {total_all} 条({pct(len(rows), total_all)}),窗口 {fmt_ms(start)} ~ {fmt_ms(end)}")
+ if not rows:
+ print("窗口内没有失败请求。")
+ return
+
+ groups = {}
+ for r in rows:
+ key = (r["provider"] or "(未选路)", r["status"], normalize_error(r["error"]))
+ g = groups.setdefault(key, {
+ "count": 0, "first": r["ts"], "last": r["ts"], "accounts": set(),
+ "models": set(), "clients": set(), "sample": r["error"] or "",
+ "bucket": bucket_of(r["status"], r["error"]),
+ })
+ g["count"] += 1
+ g["first"] = min(g["first"], r["ts"])
+ g["last"] = max(g["last"], r["ts"])
+ if r["account_name"]:
+ g["accounts"].add(r["account_name"])
+ g["models"].add(r["upstream_model"] or r["model"])
+ if r["client"]:
+ g["clients"].add(r["client"])
+
+ ordered = sorted(groups.items(), key=lambda kv: -kv[1]["count"])
+ print(f"\n── 失败聚类 Top {args.limit}(键 = 家 + 状态码 + 归一化文案)──")
+ for i, ((provider, status, norm), g) in enumerate(ordered[: args.limit], 1):
+ print(f"\n#{i} {g['count']}条(占失败 {pct(g['count'], len(rows))})"
+ f" [{BUCKET_LABELS[g['bucket']]}] provider={provider} status={status}"
+ f" 账号{len(g['accounts'])}个 模型{sorted(g['models'])}"
+ f" {fmt_ms(g['first'])} ~ {fmt_ms(g['last'])}")
+ if g["clients"]:
+ print(f" 客户端: {sorted(g['clients'])}")
+ sample = (g["sample"] or "").replace("\n", " ")[:220]
+ print(f" 样例: {sample}")
+ print(f" 归一键: {norm}")
+
+ buckets = {}
+ for _, g in groups.items():
+ buckets[g["bucket"]] = buckets.get(g["bucket"], 0) + g["count"]
+ print("\n── 分桶汇总(定责见 SKILL.md 第 3 节映射表)──")
+ for b, c in sorted(buckets.items(), key=lambda kv: -kv[1]):
+ print(f" {BUCKET_LABELS[b]:12s} {c:>6d} ({pct(c, len(rows))})")
+
+ if args.json:
+ data = [{
+ "provider": p, "status": s, "normalized": n, "bucket": g["bucket"],
+ "count": g["count"], "first": g["first"], "last": g["last"],
+ "accounts": sorted(g["accounts"]), "models": sorted(g["models"]),
+ "sample": g["sample"],
+ } for (p, s, n), g in ordered]
+ print(json.dumps(data, ensure_ascii=False, indent=2))
+
+
+# ────────────────────────── detail ──────────────────────────
+
+def print_attempt_details(entry):
+ try:
+ details = json.loads(entry["attempt_details"] or "[]")
+ except (ValueError, TypeError):
+ details = []
+ if not details:
+ print(" attempt_details: (空)")
+ return
+ print(f" 重试链({len(details)} 次尝试):")
+ for i, d in enumerate(details, 1):
+ retries = d.get("retries") or []
+ print(f" [{i}] provider={d.get('provider') or '-'} account={d.get('account') or '-'}"
+ f" status={d.get('status')}")
+ if d.get("error"):
+ print(f" error: {str(d['error'])[:200]}")
+ for rr in retries:
+ print(f" 重试: {rr.get('reason') or ''} status={rr.get('status')}"
+ f" delay={rr.get('delayMs')}ms")
+ if d.get("notice"):
+ print(f" notice: {d['notice']}")
+
+
+def print_route(entry):
+ raw = entry["route"]
+ if not raw:
+ print(" route: (空)")
+ return
+ try:
+ r = json.loads(raw)
+ except (ValueError, TypeError):
+ print(f" route(原文): {str(raw)[:300]}")
+ return
+ head = ", ".join(f"{k}={r[k]}" for k in ("strategy", "sticky", "stickyHit") if k in r)
+ if r.get("picked"):
+ head += f", picked={r['picked']}"
+ print(f" 选路快照: {head or '(无字段)'}")
+ for kind in ("ordered", "blocked"):
+ for e in r.get(kind) or []:
+ print(f" {kind:8s} {e.get('name') or e.get('id')} provider={e.get('provider')}"
+ f" state={e.get('state')} 理由: {e.get('reason') or ''}")
+
+
+def cmd_detail(conn, args, start, end):
+ if args.row_id is not None:
+ entries = conn.execute(
+ "SELECT * FROM requests WHERE row_id = ?", (args.row_id,)
+ ).fetchall()
+ elif args.id:
+ entries = conn.execute(
+ "SELECT * FROM requests WHERE id = ? ORDER BY ts DESC, row_id DESC", (args.id,)
+ ).fetchall()
+ else:
+ raise SystemExit("detail 需要 --id <请求id> 或 --row-id ")
+ if not entries:
+ raise SystemExit("没有找到对应明细(同 id 可有多行,本命令按 id 全部列出)。")
+ print(f"命中 {len(entries)} 行(同 id 多行 = 重试/去重排队产生的重复记账,看最新一行即可)")
+ for entry in entries:
+ ts = entry["ts"]
+ print(f"\nrow_id={entry['row_id']} id={entry['id']}")
+ print(f" 时间 {fmt_ms(ts)}.{ts % 1000:03d} model={entry['model']}"
+ f" client={entry['client'] or '-'}")
+ print(f" provider={entry['provider'] or '(未选路)'} account={entry['account_name'] or '-'}"
+ f" status={entry['status']} attempts={entry['attempts']}"
+ f" phase={entry['phase'] or '-'}")
+ print(f" 耗时 {dur_str(entry['duration_ms'])}"
+ f" 首帧 {dur_str(entry['first_response_ms']) if entry['first_response_ms'] is not None else '-'}"
+ f" tokens prompt={entry['prompt_tokens']} completion={entry['completion_tokens']}"
+ f" total={entry['total_tokens']} cacheRead={entry['cache_read_tokens']}")
+ print(f" 模型: client_model={entry['client_model'] or '-'}"
+ f" upstream_model={entry['upstream_model'] or '-'}"
+ f" reasoning: client={entry['client_reasoning'] or '-'}"
+ f" upstream={entry['upstream_reasoning'] or '-'}")
+ if entry["error"]:
+ print(f" error: {entry['error']}")
+ if entry["sensitive_hits"] and entry["sensitive_hits"] != "[]":
+ print(f" sensitive_hits: {entry['sensitive_hits'][:200]}")
+ print_attempt_details(entry)
+ print_route(entry)
+
+ rid = entries[0]["id"]
+ if rid:
+ ts = entries[0]["ts"]
+ span = args.log_window * 1000
+ logs = conn.execute(
+ "SELECT ts, level, category, message, data FROM logs "
+ "WHERE ts >= ? AND ts <= ? ORDER BY ts LIMIT 40",
+ (ts - span, ts + span),
+ ).fetchall()
+ if logs:
+ print(f"\n── 邻近应用日志(±{args.log_window}s,{len(logs)} 条)──")
+ for l in logs:
+ msg = (l["message"] or "").replace("\n", " ")[:200]
+ print(f" {fmt_ms(l['ts'])} {l['level']:5s} [{l['category']}] {msg}")
+ if args.body and l["data"]:
+ print(f" data: {str(l['data'])[:300]}")
+
+ dt = conn.execute("SELECT * FROM debug_traffic WHERE id = ?", (rid,)).fetchone()
+ if dt:
+ print(f"\n── 调试报文 debug_traffic(上游侧,头部已脱敏)──")
+ print(f" url={dt['url']}")
+ print(f" provider={dt['provider']} status={dt['status']} truncated={dt['truncated']}"
+ f" size={dt['size']}B")
+ if args.body:
+ print(f" request_headers keys: {list((json.loads(dt['request_headers'] or '{}')).keys())}")
+ print(f" request_body 头 1200 字:\n{(dt['request_body'] or '')[:1200]}")
+ if dt["response_body"]:
+ print(f" response_body 头 1200 字:\n{dt['response_body'][:1200]}")
+ else:
+ print("\n debug_traffic 无此 id(调试模式没开 —— 面板设置页打开后复现一次再看)")
+
+ rr = conn.execute("SELECT * FROM request_raw WHERE id = ?", (rid,)).fetchone()
+ if rr:
+ print(f" request_raw(下游侧): req {len(rr['request_body'] or '')}B"
+ f" / resp {len(rr['response_body'] or '')}B")
+ if args.body:
+ print(f" request_body 头 800 字:\n{(rr['request_body'] or '')[:800]}")
+ print(f" response_body 尾 800 字:\n{(rr['response_body'] or '')[-800:]}")
+ else:
+ print(" request_raw 无此 id")
+
+
+# ────────────────────────── logs ──────────────────────────
+
+def cmd_logs(conn, args, start, end):
+ where = "ts >= ? AND ts <= ?"
+ params = [start, end]
+ if args.level:
+ min_lv = LOG_LEVELS.get(args.level.lower(), 20)
+ conds = " OR ".join(
+ f"level = '{lv}'" for lv, v in LOG_LEVELS.items() if v >= min_lv and lv != "warning"
+ )
+ where += f" AND ({conds})"
+ if args.category:
+ where += " AND category = ?"
+ params.append(args.category)
+ rows = conn.execute(
+ f"SELECT ts, level, category, message, data FROM logs WHERE {where} "
+ f"ORDER BY ts DESC LIMIT {args.limit}",
+ params,
+ ).fetchall()
+ print(f"日志 {len(rows)} 条(level≥{args.level or 'info'}"
+ f"{' category=' + args.category if args.category else ''}),窗口 {fmt_ms(start)} ~ {fmt_ms(end)}")
+ for r in rows:
+ msg = (r["message"] or "") if args.full else (r["message"] or "").replace("\n", " ")[:200]
+ print(f"{fmt_ms(r['ts'])} {r['level']:5s} [{r['category']}] {msg}")
+ if args.json:
+ print(json.dumps([dict(r) for r in rows], ensure_ascii=False, indent=2))
+
+
+# ────────────────────────── 入口 ──────────────────────────
+
+def build_parser():
+ # 公共选项只挂在子解析器上 —— 调用形如
+ # analyze.py overview --hours 6 --no-copy
+ # (选项一律放在子命令后面;挂到主解析器上会被子解析器的默认值覆盖,
+ # 出现「前面的 --no-copy 静默失效」这类坑)
+ common = argparse.ArgumentParser(add_help=False)
+ common.add_argument("--db", help="库路径(文件或目录);默认自动定位 %%USERPROFILE%%\\.agent2api")
+ common.add_argument("--hours", type=float, default=24, help="时间窗(小时),默认 24")
+ common.add_argument("--since", help="起始本地时间 YYYY-MM-DD HH:MM")
+ common.add_argument("--until", help="截止本地时间 YYYY-MM-DD HH:MM")
+ common.add_argument("--limit", type=int, default=50, help="条数上限,默认 50")
+ common.add_argument("--json", action="store_true", help="额外输出 JSON")
+ common.add_argument("--include-test", action="store_true", help="包含模型测试流量(is_test=1)")
+ common.add_argument("--no-copy", action="store_true", help="直连原库(只读),不快照")
+
+ p = argparse.ArgumentParser(
+ prog="analyze.py",
+ description="Agent2API 请求日志只读分析(skill: request-log-analysis)",
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ )
+ sub = p.add_subparsers(dest="cmd", required=True)
+ sub.add_parser("overview", parents=[common], help="总览")
+ sub.add_parser("failures", parents=[common], help="失败聚类与分桶")
+ dp = sub.add_parser("detail", parents=[common], help="单条深挖")
+ dp.add_argument("--id", help="请求关联 id(requests.id)")
+ dp.add_argument("--row-id", type=int, help="requests.row_id")
+ dp.add_argument("--body", action="store_true", help="同时打印报文/日志正文(注意含用户内容)")
+ dp.add_argument("--log-window", type=int, default=90, help="邻近日志窗口秒数,默认 90")
+ lp = sub.add_parser("logs", parents=[common], help="应用日志")
+ lp.add_argument("--level", default="info", help="最低级别 debug/info/warn/error")
+ lp.add_argument("--category", help="按分类过滤(server/upstream/model…)")
+ lp.add_argument("--full", action="store_true", help="不截断消息")
+ return p
+
+
+def main():
+ args = build_parser().parse_args()
+ try:
+ # open_db 也可能在建好快照目录之后失败(拷到一半磁盘满 / 库被独占),
+ # 所以它同样要落在 try 里,否则那次失败会留下整库大小的垃圾。
+ conn, used_path, how = open_db(args)
+ try:
+ start, end = window_ms(args)
+ print(f"# 库: {how}")
+ if args.cmd == "overview":
+ cmd_overview(conn, args, start, end)
+ elif args.cmd == "failures":
+ cmd_failures(conn, args, start, end)
+ elif args.cmd == "detail":
+ cmd_detail(conn, args, start, end)
+ elif args.cmd == "logs":
+ cmd_logs(conn, args, start, end)
+ finally:
+ conn.close()
+ finally:
+ cleanup_snapshots()
+
+
+def cleanup_snapshots():
+ """删掉本次运行创建的临时快照目录(尽力而为)。
+
+ 只删 `_SNAPSHOT_DIRS` 里自己 `mkdtemp` 出来的路径 —— 绝不按通配符扫
+ `%TEMP%\\a2a-logs-*`:用户可能正用 `--db` 复用上一次的快照追问,
+ 那种目录不归本次运行管。删不掉(文件仍被占用)只提示路径,不报错。
+ """
+ while _SNAPSHOT_DIRS:
+ path = _SNAPSHOT_DIRS.pop()
+ try:
+ shutil.rmtree(path)
+ except OSError as error:
+ print(f"# 提示:临时快照未能删除({path}):{error}", file=sys.stderr)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/desktop-tauri/src-tauri/server/src/server/core/cloud_sync/snapshot.rs b/desktop-tauri/src-tauri/server/src/server/core/cloud_sync/snapshot.rs
index 034d5a15d..4583c4762 100644
--- a/desktop-tauri/src-tauri/server/src/server/core/cloud_sync/snapshot.rs
+++ b/desktop-tauri/src-tauri/server/src/server/core/cloud_sync/snapshot.rs
@@ -443,6 +443,9 @@ pub(crate) fn safety_backup(snapshot: &Snapshot, config_dir: &std::path::Path) -
let _ = std::fs::remove_file(&tmp);
format!("保存安全备份失败: {error}")
})?;
+ // 与整库恢复的 pre-restore-* 同一套保留上限:自动同步会在每次下载前写一份,
+ // 不清理的话磁盘占用随下载次数线性增长。留 2 份足够覆盖「这次也错了」。
+ crate::server::db::backup::retention::prune_backups(&dir, "cloud-sync-", ".json", 2);
Ok(name)
}
diff --git a/desktop-tauri/src-tauri/server/src/server/db/backup.rs b/desktop-tauri/src-tauri/server/src/server/db/backup.rs
index 4f72b1c6c..3e3f5deb0 100644
--- a/desktop-tauri/src-tauri/server/src/server/db/backup.rs
+++ b/desktop-tauri/src-tauri/server/src/server/db/backup.rs
@@ -25,6 +25,7 @@ use crate::server::logging;
mod archive;
mod keys;
+pub(crate) mod retention;
mod restore;
mod safety;
mod sql_import;
diff --git a/desktop-tauri/src-tauri/server/src/server/db/backup/retention.rs b/desktop-tauri/src-tauri/server/src/server/db/backup/retention.rs
new file mode 100644
index 000000000..b7e4568e1
--- /dev/null
+++ b/desktop-tauri/src-tauri/server/src/server/db/backup/retention.rs
@@ -0,0 +1,139 @@
+//! `{config_dir}/backups/` 的保留上限:同类安全备份只留最近 N 份。
+//!
+//! ── 为什么必须有上限 ────────────────────────────────────────
+//! 这个目录里放的是**整库级**的留影:
+//! - 整库恢复前的 `pre-restore-*.db`(SQLite Backup API 写出的完整库);
+//! - 云同步下载前的 `cloud-sync-*.json`(业务快照)。
+//! 两者都是「用户后悔时的最后一根稻草」,所以不能不留;但**都没有清理**时,
+//! 每做一次恢复 / 每次自动同步下载都会再落一份,磁盘占用随操作次数线性增长 ——
+//! 实测里这被误认为「启动时复制整库把 C 盘吃满」。
+//!
+//! ── 为什么按名字而不是按体积 ────────────────────────────────
+//! 体积阈值会随库增长失效(今天 50MB 算大,明天 500MB 算正常)。文件名里的
+//! 时间戳是结构化事实,排序稳定;同秒内的多份再用文件 mtime 与名字兜底,
+//! 保证「删的一定是最旧的」。
+//!
+//! ── 失败语义 ────────────────────────────────────────────────
+//! 尽力而为:清理失败只打一行警告,绝不让「备份已经写成功了,但删旧的失败」
+//! 反过来把恢复 / 下载判成失败。删不掉的旧备份最坏只是继续占盘。
+
+use std::path::Path;
+
+use crate::server::logging;
+
+/// 只保留最近 `keep` 份匹配 `{prefix}*{suffix}` 的文件,返回删掉的数量。
+///
+/// `keep == 0` 视为「不清理」而不是「全删」:调用方误传 0 时把用户的留影
+/// 全删掉是不可接受的,而「保留 0 份」这个需求本身也不存在。
+pub(crate) fn prune_backups(dir: &Path, prefix: &str, suffix: &str, keep: usize) -> usize {
+ if keep == 0 {
+ return 0;
+ }
+ let Ok(entries) = std::fs::read_dir(dir) else {
+ // 目录不存在 = 还没做过任何备份,正常路径
+ return 0;
+ };
+ let mut found: Vec<(std::time::SystemTime, String, std::path::PathBuf)> = Vec::new();
+ for entry in entries.flatten() {
+ let name = entry.file_name();
+ let Some(name) = name.to_str() else {
+ continue;
+ };
+ if !name.starts_with(prefix) || !name.ends_with(suffix) {
+ continue;
+ }
+ let Ok(file_type) = entry.file_type() else {
+ continue;
+ };
+ if !file_type.is_file() {
+ continue;
+ }
+ // mtime 读不到就退化成「最旧」(UNIX_EPOCH):宁可先删它,也不因为它
+ // 元数据异常而让整个清理停摆。
+ let modified = entry
+ .metadata()
+ .and_then(|meta| meta.modified())
+ .unwrap_or(std::time::UNIX_EPOCH);
+ found.push((modified, name.to_string(), entry.path()));
+ }
+ if found.len() <= keep {
+ return 0;
+ }
+ found.sort_by(|a, b| (a.0, &a.1).cmp(&(b.0, &b.1)));
+ let remove_count = found.len() - keep;
+ let mut removed = 0usize;
+ for (_, _, path) in found.into_iter().take(remove_count) {
+ match std::fs::remove_file(&path) {
+ Ok(()) => removed += 1,
+ Err(error) => logging::console_line(
+ "[Backup]",
+ &format!("⚠️ 清理旧备份失败({}):{error}", path.display()),
+ ),
+ }
+ }
+ if removed > 0 {
+ logging::console_line(
+ "[Backup]",
+ &format!("已清理 {removed} 份旧备份({prefix}*{suffix},保留最近 {keep} 份)"),
+ );
+ }
+ removed
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn temp_dir(label: &str) -> std::path::PathBuf {
+ let dir = std::env::temp_dir().join(format!(
+ "backup-retention-{label}-{}-{:?}",
+ std::process::id(),
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map(|d| d.as_nanos())
+ .unwrap_or(0)
+ ));
+ std::fs::create_dir_all(&dir).expect("建临时目录");
+ dir
+ }
+
+ /// 超过上限时删最旧的,且只动匹配前缀 + 后缀的文件。
+ #[test]
+ fn keeps_newest_and_leaves_other_files_alone() {
+ let dir = temp_dir("keep-newest");
+ for stamp in ["20260101-000000", "20260102-000000", "20260103-000000"] {
+ std::fs::write(dir.join(format!("cloud-sync-{stamp}.json")), b"{}").expect("写备份");
+ }
+ std::fs::write(dir.join("cloud-sync-20260101-000000.json.tmp"), b"{}").expect("写半成品");
+ std::fs::write(dir.join("pre-restore-20260101_000000-abc.db"), b"x").expect("写整库备份");
+ std::fs::write(dir.join("notes.txt"), b"x").expect("写无关文件");
+
+ let removed = prune_backups(&dir, "cloud-sync-", ".json", 2);
+
+ assert_eq!(removed, 1, "三份只该删最旧的一份");
+ assert!(!dir.join("cloud-sync-20260101-000000.json").exists());
+ assert!(dir.join("cloud-sync-20260102-000000.json").exists());
+ assert!(dir.join("cloud-sync-20260103-000000.json").exists());
+ assert!(
+ dir.join("cloud-sync-20260101-000000.json.tmp").exists(),
+ "写入中的临时文件不是备份,不能删"
+ );
+ assert!(dir.join("pre-restore-20260101_000000-abc.db").exists());
+ assert!(dir.join("notes.txt").exists());
+
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+
+ /// 没超上限时一个都不删;`keep = 0` 不当成「全删」。
+ #[test]
+ fn does_nothing_below_limit_or_with_zero_keep() {
+ let dir = temp_dir("below-limit");
+ std::fs::write(dir.join("pre-restore-20260101_000000-abc.db"), b"x").expect("写备份");
+
+ assert_eq!(prune_backups(&dir, "pre-restore-", ".db", 2), 0);
+ assert_eq!(prune_backups(&dir, "pre-restore-", ".db", 0), 0);
+ assert!(dir.join("pre-restore-20260101_000000-abc.db").exists());
+
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+}
diff --git a/desktop-tauri/src-tauri/server/src/server/db/backup/safety.rs b/desktop-tauri/src-tauri/server/src/server/db/backup/safety.rs
index a508facb2..a20e0d5a8 100644
--- a/desktop-tauri/src-tauri/server/src/server/db/backup/safety.rs
+++ b/desktop-tauri/src-tauri/server/src/server/db/backup/safety.rs
@@ -5,6 +5,11 @@ use rusqlite::backup::Backup;
use rusqlite::Connection;
use super::complete_backup;
+use super::retention::prune_backups;
+
+/// 保留最近几份「恢复前安全备份」。整库级留影每份都等于整个库,
+/// 留 2 份足够覆盖「这次恢复错了 + 上一次也错了」的回退链,再多就是纯占盘。
+const KEEP_SAFETY_BACKUPS: usize = 2;
pub(super) fn create(main: &mut Connection, config_dir: &Path) -> Result {
let backup_dir = config_dir.join("backups");
@@ -47,5 +52,9 @@ pub(super) fn create(main: &mut Connection, config_dir: &Path) -> Result Value {
- let loaded = {
+ // 条数与空闲页在**同一次持锁**里读:`free_space` 收 `guard` 而不是自己
+ // 再取一次(那把 `Mutex` 不可重入),两者因此出自同一份库快照。
+ let (loaded, free_space) = {
let guard = self.guard();
- self.with_conn(&guard, |conn| {
+ let loaded = self.with_conn(&guard, |conn| {
let total = sql::count_all(conn)?;
let days = daily::count_daily(conn)?;
let first = sql::min_ts(conn)?;
@@ -750,7 +752,8 @@ impl RequestStats {
let downstream_raw = sql::count_raw(conn)?;
let upstream_raw = sql::count_upstream_raw(conn)?;
Ok((total, days, first, last, downstream_raw, upstream_raw))
- })
+ });
+ (loaded, self.free_space(&guard))
};
let (total, daily_days, first_ts, last_ts, downstream_raw, upstream_raw) =
loaded.unwrap_or((0, 0, None, None, 0, 0));
@@ -758,10 +761,7 @@ impl RequestStats {
// 空闲页读数(见 `free_space` 的说明):`auto_vacuum=0` 下删除行只把页
// 标成空闲,文件不会缩小。界面据此能把「库 2.5GB、其中 1.3GB 是空洞」
// 说明白,而不是让用户以为程序在偷偷占盘。
- let (free_pages, total_pages, reclaimable) = self
- .free_space()
- .map(|(free, total, bytes)| (free, total, bytes))
- .unwrap_or((0, 0, 0));
+ let (free_pages, total_pages, reclaimable) = free_space.unwrap_or((0, 0, 0));
json!({
"total": total,
"dailyDays": daily_days,
diff --git a/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs b/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs
index 0c74b01d2..9c6e56860 100644
--- a/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs
+++ b/desktop-tauri/src-tauri/server/src/server/request_stats/maintenance.rs
@@ -84,7 +84,7 @@ impl RequestStats {
file_size(&file) + file_size(&PathBuf::from(format!("{}-wal", file.to_string_lossy())))
}
- /// 空闲页占比(0.0 ~ 1.0)与可回收字节数;库不可用时返回 `None`。
+ /// 库内空闲页读数:`(空闲页数, 总页数, 可回收字节数)`;库不可用时返回 `None`。
///
/// ── 为什么需要这个读数 ──────────────────────────────────────
/// 库开了 `auto_vacuum=0`(见 `db::apply_pragmas`),删除行只把页标成空闲,
@@ -97,9 +97,17 @@ impl RequestStats {
/// 因此把判据暴露出来:只有占比够高(调用方决定阈值)时才值得付一次
/// VACUUM 的代价。`PRAGMA freelist_count` 与 `page_count` 都是 O(1) 的
/// 头字段读,不扫表,可以放在概览接口里。
- pub fn free_space(&self) -> Option<(u64, u64, u64)> {
- let db = self.db.clone()?;
- db.with(|conn| {
+ ///
+ /// 由调用方传入自己持有的 `guard`(与 `with_conn` 同形):`stats()` 要在
+ /// **同一次持锁**里既读条数又读空洞,保证这一行里的两个数字出自同一份
+ /// 快照。这里若自己去 `guard()` 会二次加锁 —— 那把 `Mutex` 不可重入,
+ /// 在 `stats()` 里调用会当场死锁。三行 PRAGMA 都是读,与记账事务只会
+ /// 排队、不会互相阻塞出问题。
+ pub(super) fn free_space(
+ &self,
+ guard: &std::sync::MutexGuard<'_, ()>,
+ ) -> Option<(u64, u64, u64)> {
+ self.with_conn(guard, |conn| {
let page_size: i64 = conn.query_row("PRAGMA page_size;", [], |row| row.get(0))?;
let page_count: i64 = conn.query_row("PRAGMA page_count;", [], |row| row.get(0))?;
let free: i64 = conn.query_row("PRAGMA freelist_count;", [], |row| row.get(0))?;
@@ -108,8 +116,7 @@ impl RequestStats {
page_count.max(0) as u64,
(page_size.max(0) as u64) * (free.max(0) as u64),
))
- })?
- .ok()
+ })
}
/// 压缩数据库:`checkpoint(TRUNCATE)` → `VACUUM` → 再 `checkpoint(TRUNCATE)`
diff --git a/desktop-tauri/ui-islands/src/islands/settings-model.ts b/desktop-tauri/ui-islands/src/islands/settings-model.ts
index faa6c750d..0e48b351d 100644
--- a/desktop-tauri/ui-islands/src/islands/settings-model.ts
+++ b/desktop-tauri/ui-islands/src/islands/settings-model.ts
@@ -873,6 +873,7 @@ export const NOTES = {
retention: t('保存后立即生效:保留天数和数量上限同时生效,调小任一项会立即清理超出的历史数据,且不可恢复。'),
storageFile: t('配置目录下的 agent2api.db(账号、日志、请求记录、调试报文与设置都在里面)。'),
storageSize: t('数据库主文件与 WAL 文件的总占用,与请求日志清理弹窗采用同一口径;清理后可压缩数据库回收空闲空间。'),
+ storageReclaim: t('这部分是库里已删除但尚未还给磁盘的页(SQLite 默认只标空闲、不缩小文件)。它不是还能读的数据 —— 到「请求日志」页的「清理」里点一次压缩即可回收;压缩期间需要与库文件等大的临时空间。'),
storage: t('数据统一保存在配置目录下的 agent2api.db;如需更换位置,请设置环境变量 AGENT2API_PROXY_HOME 后重启程序。'),
captcha: t('开启后,登录页在浏览器后台自动完成验证(对真人无感),而脚本每次尝试都要先算一道题 —— 暴力破解与抢注的成本显著上升。仅影响面板的登录 / 注册,与 API 客户端的 API Key 无关。桌面端与网页端各自独立:桌面端主要服务本机与局域网,网页端(Docker / 服务端)直接暴露在网络上的登录页风险更高,建议保持开启。'),
panelLogin: t('当前浏览器以管理员身份登录着本面板。「退出登录」会撤销这台设备的登录会话(30 天内的自动续期一并失效),需要重新输入账号密码;其他已登录的设备不受影响。'),
diff --git a/desktop-tauri/ui-islands/src/islands/settings-page.tsx b/desktop-tauri/ui-islands/src/islands/settings-page.tsx
index 944585bd1..bdef1f110 100644
--- a/desktop-tauri/ui-islands/src/islands/settings-page.tsx
+++ b/desktop-tauri/ui-islands/src/islands/settings-page.tsx
@@ -1930,6 +1930,21 @@ function DataPane({ snap }: { snap: SettingsSnapshot }) {
{NOTES.storageSize}
+ {/* 空洞读数:只在确实有可回收空间时出现 —— 0 时多一行「可回收 0 B」
+ 只会让用户以为这里坏了。占比过低(<1%)时压缩也不值得,
+ 与后端「只有占比够高才值得 VACUUM」的口径一致。 */}
+ {counts && storage.reclaimableBytes > 0 && storage.freePageRatio >= 0.01 ? (
+
+
+
+
+ {formatBytes(storage.reclaimableBytes)}
+ {` (${Math.round(storage.freePageRatio * 100)}%)`}
+
+
+
{NOTES.storageReclaim}
+
+ ) : null}
diff --git a/desktop-tauri/ui-islands/src/islands/settings-state.ts b/desktop-tauri/ui-islands/src/islands/settings-state.ts
index 84e52d707..4c9e9a40c 100644
--- a/desktop-tauri/ui-islands/src/islands/settings-state.ts
+++ b/desktop-tauri/ui-islands/src/islands/settings-state.ts
@@ -265,6 +265,16 @@ export type StorageState = {
dailyDays: number | null
downstreamRaw: number | null
upstreamRaw: number | null
+ /**
+ * 库内空闲页占用的字节数(压缩一次能还给文件系统多少)。
+ *
+ * `auto_vacuum=0` 下删除行只把页标成空闲,库文件**不会**缩小 —— 用户会看到
+ * 「库里没多少数据、文件却有几个 GB」。这是实测「C 盘爆满」最容易被误读成
+ * 「程序偷偷占盘」的那一项,所以单独露出来,而不是只给一个总占用。
+ */
+ reclaimableBytes: number
+ /** 空闲页占比(0..1,后端保留三位小数)。0 = 没有可回收空洞。 */
+ freePageRatio: number
}
/** 导入失败明细(只列前 3 条,more 表示还有更多) */
@@ -456,6 +466,8 @@ const INITIAL: SettingsSnapshot = {
dailyDays: null,
downstreamRaw: null,
upstreamRaw: null,
+ reclaimableBytes: 0,
+ freePageRatio: 0,
},
captcha: { available: true, desktop: false, web: false, localPanel: false },
account: { status: 'loading', registered: false, username: '', password: null },
@@ -2562,7 +2574,8 @@ function finiteOrNull(value: unknown): number | null {
/**
* 渲染概况。形状是后端的**单库语义**:
- * `{ configDir, database: { file, bytes, available, accounts, logs, requests, dailyDays, downstreamRaw, upstreamRaw } }`。
+ * `{ configDir, database: { file, bytes, reclaimableBytes, freePageRatio, available,
+ * accounts, logs, requests, dailyDays, downstreamRaw, upstreamRaw } }`。
* 后端起不来(网络 / 桥失败)与库打不开是两件事,但对这一页的结论相同:读不到存储概况就
* 展示「不可用」而不是一排看着正常的 0。
*/
@@ -2588,6 +2601,10 @@ export function renderStorage(data?: unknown): void {
dailyDays: finiteOrNull(record.dailyDays),
downstreamRaw: finiteOrNull(record.downstreamRaw),
upstreamRaw: finiteOrNull(record.upstreamRaw ?? record.debug),
+ // 空洞读数:老后端没有这两个字段时回落 0(= 不显示「可回收」),
+ // 而不是让视图去猜一个 undefined。
+ reclaimableBytes: finiteOrNull(record.reclaimableBytes) ?? 0,
+ freePageRatio: finiteOrNull(record.freePageRatio) ?? 0,
},
})
}
diff --git a/desktop-tauri/ui/islands/ui.js b/desktop-tauri/ui/islands/ui.js
index 2804943e1..d5a42b329 100644
--- a/desktop-tauri/ui/islands/ui.js
+++ b/desktop-tauri/ui/islands/ui.js
@@ -1,23 +1,23 @@
-var xXe=Object.defineProperty;var bXe=(zu,Tl,$u)=>Tl in zu?xXe(zu,Tl,{enumerable:!0,configurable:!0,writable:!0,value:$u}):zu[Tl]=$u;var on=(zu,Tl,$u)=>bXe(zu,typeof Tl!="symbol"?Tl+"":Tl,$u);(function(){"use strict";function zu(e,t){for(var n=0;n
r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Tl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $u={exports:{}},Wv={};var X$;function nle(){if(X$)return Wv;X$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var c=null;if(o!==void 0&&(c=""+o),i.key!==void 0&&(c=""+i.key),"key"in i){o={};for(var d in i)d!=="key"&&(o[d]=i[d])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:c,ref:i!==void 0?i:null,props:o}}return Wv.Fragment=t,Wv.jsx=n,Wv.jsxs=n,Wv}var Q$;function rle(){return Q$||(Q$=1,$u.exports=nle()),$u.exports}var s=rle(),TA={exports:{}},ha={},OA={exports:{}},Zt={};var Z$;function sle(){if(Z$)return Zt;Z$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.for("react.view_transition"),y=Symbol.iterator;function j(V){return V===null||typeof V!="object"?null:(V=y&&V[y]||V["@@iterator"],typeof V=="function"?V:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,N={};function A(V,H,Q){this.props=V,this.context=H,this.refs=N,this.updater=Q||w}A.prototype.isReactComponent={},A.prototype.setState=function(V,H){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,H,"setState")},A.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function E(){}E.prototype=A.prototype;function O(V,H,Q){this.props=V,this.context=H,this.refs=N,this.updater=Q||w}var R=O.prototype=new E;R.constructor=O,S(R,A.prototype),R.isPureReactComponent=!0;var T=Array.isArray;function P(){}var M={H:null,A:null,T:null,S:null},_=Object.prototype.hasOwnProperty;function I(V,H,Q){var J=Q.ref;return{$$typeof:e,type:V,key:H,ref:J!==void 0?J:null,props:Q}}function L(V,H){return I(V.type,H,V.props)}function D(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function z(V){var H={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(Q){return H[Q]})}var G=/\/+/g;function X(V,H){return typeof V=="object"&&V!==null&&V.key!=null?z(""+V.key):H.toString(36)}function Y(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(P,P):(V.status="pending",V.then(function(H){V.status==="pending"&&(V.status="fulfilled",V.value=H)},function(H){V.status==="pending"&&(V.status="rejected",V.reason=H)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function F(V,H,Q,J,oe){var ee=typeof V;(ee==="undefined"||ee==="boolean")&&(V=null);var se=!1;if(V===null)se=!0;else switch(ee){case"bigint":case"string":case"number":se=!0;break;case"object":switch(V.$$typeof){case e:case t:se=!0;break;case p:return se=V._init,F(se(V._payload),H,Q,J,oe)}}if(se)return oe=oe(V),se=J===""?"."+X(V,0):J,T(oe)?(Q="",se!=null&&(Q=se.replace(G,"$&/")+"/"),F(oe,H,Q,"",function(re){return re})):oe!=null&&(D(oe)&&(oe=L(oe,Q+(oe.key==null||V&&V.key===oe.key?"":(""+oe.key).replace(G,"$&/")+"/")+se)),H.push(oe)),1;se=0;var le=J===""?".":J+":";if(T(V))for(var te=0;te"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),TA.exports=ale(),TA.exports}var br=n3(),RA={exports:{}},Xv={},PA={exports:{}},IA={};var r3;function ile(){return r3||(r3=1,(function(e){function t(Y,F){var K=Y.length;Y.push(F);e:for(;0>>1,q=Y[U];if(0>>1;Ui(ie,K))Vi(H,ie)?(Y[U]=H,Y[V]=K,U=V):(Y[U]=ie,Y[ne]=K,U=ne);else if(Vi(H,K))Y[U]=H,Y[V]=K,U=V;else break e}}return F}function i(Y,F){var K=Y.sortIndex-F.sortIndex;return K!==0?K:Y.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var f=[],h=[],p=1,g=null,x=3,y=!1,j=!1,w=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function O(Y){for(var F=n(h);F!==null;){if(F.callback===null)r(h);else if(F.startTime<=Y)r(h),F.sortIndex=F.expirationTime,t(f,F);else break;F=n(h)}}function R(Y){if(w=!1,O(Y),!j)if(n(f)!==null)j=!0,T||(T=!0,D());else{var F=n(h);F!==null&&X(R,F.startTime-Y)}}var T=!1,P=-1,M=5,_=-1;function I(){return S?!0:!(e.unstable_now()-_Y&&I());){var U=g.callback;if(typeof U=="function"){g.callback=null,x=g.priorityLevel;var q=U(g.expirationTime<=Y);if(Y=e.unstable_now(),typeof q=="function"){g.callback=q,O(Y),F=!0;break t}g===n(f)&&r(f),O(Y)}else r(f);g=n(f)}if(g!==null)F=!0;else{var W=n(h);W!==null&&X(R,W.startTime-Y),F=!1}}break e}finally{g=null,x=K,y=!1}F=void 0}}finally{F?D():T=!1}}}var D;if(typeof E=="function")D=function(){E(L)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,G=z.port2;z.port1.onmessage=L,D=function(){G.postMessage(null)}}else D=function(){N(L,0)};function X(Y,F){P=N(function(){Y(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Y){Y.callback=null},e.unstable_forceFrameRate=function(Y){0>Y||125U?(Y.sortIndex=K,t(h,Y),n(f)===null&&Y===n(h)&&(w?(A(P),P=-1):w=!0,X(R,K-U))):(Y.sortIndex=q,t(f,Y),j||y||(j=!0,T||(T=!0,D()))),Y},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(Y){var F=x;return function(){var K=x;x=F;try{return Y.apply(this,arguments)}finally{x=K}}}})(IA)),IA}var s3;function ole(){return s3||(s3=1,PA.exports=ile()),PA.exports}var a3;function lle(){if(a3)return Xv;a3=1;var e=ole(),t=Vp(),n=n3();function r(l){var u="https://react.dev/errors/"+l;if(1pe||(l.current=he[pe],he[pe]=null,pe--)}function ce(l,u){pe++,he[pe]=l.current,l.current=u}var ae=Ne(null),_e=Ne(null),de=Ne(null),Se=Ne(null);function ve(l,u){switch(ce(de,u),ce(_e,l),ce(ae,null),u.nodeType){case 9:case 11:l=(l=u.documentElement)&&(l=l.namespaceURI)?doe(l):0;break;default:if(l=u.tagName,u=u.namespaceURI)u=doe(u),l=foe(u,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}me(ae),ce(ae,l)}function xe(){me(ae),me(_e),me(de)}function Re(l){var u=l.memoizedState;u!==null&&(qv._currentValue=u.memoizedState,ce(Se,l)),u=ae.current;var m=foe(u,l.type);u!==m&&(ce(_e,l),ce(ae,m))}function we(l){_e.current===l&&(me(ae),me(_e)),Se.current===l&&(me(Se),qv._currentValue=re)}var ge,De;function Ge(l){if(ge===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);ge=u&&u[1]||"",De=-1Tl in zu?xXe(zu,Tl,{enumerable:!0,configurable:!0,writable:!0,value:$u}):zu[Tl]=$u;var on=(zu,Tl,$u)=>bXe(zu,typeof Tl!="symbol"?Tl+"":Tl,$u);(function(){"use strict";function zu(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Tl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $u={exports:{}},Wv={};var X$;function nle(){if(X$)return Wv;X$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var c=null;if(o!==void 0&&(c=""+o),i.key!==void 0&&(c=""+i.key),"key"in i){o={};for(var d in i)d!=="key"&&(o[d]=i[d])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:c,ref:i!==void 0?i:null,props:o}}return Wv.Fragment=t,Wv.jsx=n,Wv.jsxs=n,Wv}var Q$;function rle(){return Q$||(Q$=1,$u.exports=nle()),$u.exports}var s=rle(),TA={exports:{}},ha={},OA={exports:{}},Zt={};var Z$;function sle(){if(Z$)return Zt;Z$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.for("react.view_transition"),y=Symbol.iterator;function j(V){return V===null||typeof V!="object"?null:(V=y&&V[y]||V["@@iterator"],typeof V=="function"?V:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,N={};function A(V,H,Q){this.props=V,this.context=H,this.refs=N,this.updater=Q||w}A.prototype.isReactComponent={},A.prototype.setState=function(V,H){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,H,"setState")},A.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function E(){}E.prototype=A.prototype;function O(V,H,Q){this.props=V,this.context=H,this.refs=N,this.updater=Q||w}var R=O.prototype=new E;R.constructor=O,S(R,A.prototype),R.isPureReactComponent=!0;var T=Array.isArray;function P(){}var M={H:null,A:null,T:null,S:null},_=Object.prototype.hasOwnProperty;function I(V,H,Q){var J=Q.ref;return{$$typeof:e,type:V,key:H,ref:J!==void 0?J:null,props:Q}}function L(V,H){return I(V.type,H,V.props)}function D(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function z(V){var H={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(Q){return H[Q]})}var G=/\/+/g;function X(V,H){return typeof V=="object"&&V!==null&&V.key!=null?z(""+V.key):H.toString(36)}function Y(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(P,P):(V.status="pending",V.then(function(H){V.status==="pending"&&(V.status="fulfilled",V.value=H)},function(H){V.status==="pending"&&(V.status="rejected",V.reason=H)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function F(V,H,Q,J,oe){var ee=typeof V;(ee==="undefined"||ee==="boolean")&&(V=null);var se=!1;if(V===null)se=!0;else switch(ee){case"bigint":case"string":case"number":se=!0;break;case"object":switch(V.$$typeof){case e:case t:se=!0;break;case p:return se=V._init,F(se(V._payload),H,Q,J,oe)}}if(se)return oe=oe(V),se=J===""?"."+X(V,0):J,T(oe)?(Q="",se!=null&&(Q=se.replace(G,"$&/")+"/"),F(oe,H,Q,"",function(re){return re})):oe!=null&&(D(oe)&&(oe=L(oe,Q+(oe.key==null||V&&V.key===oe.key?"":(""+oe.key).replace(G,"$&/")+"/")+se)),H.push(oe)),1;se=0;var le=J===""?".":J+":";if(T(V))for(var te=0;te"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),TA.exports=ale(),TA.exports}var br=n3(),RA={exports:{}},Xv={},PA={exports:{}},IA={};var r3;function ile(){return r3||(r3=1,(function(e){function t(Y,F){var K=Y.length;Y.push(F);e:for(;0>>1,q=Y[U];if(0>>1;Ui(ie,K))Vi(H,ie)?(Y[U]=H,Y[V]=K,U=V):(Y[U]=ie,Y[ne]=K,U=ne);else if(Vi(H,K))Y[U]=H,Y[V]=K,U=V;else break e}}return F}function i(Y,F){var K=Y.sortIndex-F.sortIndex;return K!==0?K:Y.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var f=[],h=[],p=1,g=null,x=3,y=!1,j=!1,w=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function O(Y){for(var F=n(h);F!==null;){if(F.callback===null)r(h);else if(F.startTime<=Y)r(h),F.sortIndex=F.expirationTime,t(f,F);else break;F=n(h)}}function R(Y){if(w=!1,O(Y),!j)if(n(f)!==null)j=!0,T||(T=!0,D());else{var F=n(h);F!==null&&X(R,F.startTime-Y)}}var T=!1,P=-1,M=5,_=-1;function I(){return S?!0:!(e.unstable_now()-_Y&&I());){var U=g.callback;if(typeof U=="function"){g.callback=null,x=g.priorityLevel;var q=U(g.expirationTime<=Y);if(Y=e.unstable_now(),typeof q=="function"){g.callback=q,O(Y),F=!0;break t}g===n(f)&&r(f),O(Y)}else r(f);g=n(f)}if(g!==null)F=!0;else{var W=n(h);W!==null&&X(R,W.startTime-Y),F=!1}}break e}finally{g=null,x=K,y=!1}F=void 0}}finally{F?D():T=!1}}}var D;if(typeof E=="function")D=function(){E(L)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,G=z.port2;z.port1.onmessage=L,D=function(){G.postMessage(null)}}else D=function(){N(L,0)};function X(Y,F){P=N(function(){Y(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Y){Y.callback=null},e.unstable_forceFrameRate=function(Y){0>Y||125U?(Y.sortIndex=K,t(h,Y),n(f)===null&&Y===n(h)&&(w?(A(P),P=-1):w=!0,X(R,K-U))):(Y.sortIndex=q,t(f,Y),j||y||(j=!0,T||(T=!0,D()))),Y},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(Y){var F=x;return function(){var K=x;x=F;try{return Y.apply(this,arguments)}finally{x=K}}}})(IA)),IA}var s3;function ole(){return s3||(s3=1,PA.exports=ile()),PA.exports}var a3;function lle(){if(a3)return Xv;a3=1;var e=ole(),t=Kp(),n=n3();function r(l){var u="https://react.dev/errors/"+l;if(1pe||(l.current=he[pe],he[pe]=null,pe--)}function ce(l,u){pe++,he[pe]=l.current,l.current=u}var ae=Ne(null),_e=Ne(null),de=Ne(null),Se=Ne(null);function ve(l,u){switch(ce(de,u),ce(_e,l),ce(ae,null),u.nodeType){case 9:case 11:l=(l=u.documentElement)&&(l=l.namespaceURI)?doe(l):0;break;default:if(l=u.tagName,u=u.namespaceURI)u=doe(u),l=foe(u,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}me(ae),ce(ae,l)}function xe(){me(ae),me(_e),me(de)}function Re(l){var u=l.memoizedState;u!==null&&(qv._currentValue=u.memoizedState,ce(Se,l)),u=ae.current;var m=foe(u,l.type);u!==m&&(ce(_e,l),ce(ae,m))}function we(l){_e.current===l&&(me(ae),me(_e)),Se.current===l&&(me(Se),qv._currentValue=re)}var ge,De;function Ge(l){if(ge===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);ge=u&&u[1]||"",De=-1)":-1k||fe[b]!==Ce[k]){var Pe=`
`+fe[b].replace(" at new "," at ");return l.displayName&&Pe.includes("")&&(Pe=Pe.replace("",l.displayName)),Pe}while(1<=b&&0<=k);break}}}finally{Ot=!1,Error.prepareStackTrace=m}return(m=l?l.displayName||l.name:"")?Ge(m):""}function $t(l,u){switch(l.tag){case 26:case 27:case 5:return Ge(l.type);case 16:return Ge("Lazy");case 13:return l.child!==u&&u!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return sn(l.type,!1);case 11:return sn(l.type.render,!1);case 1:return sn(l.type,!0);case 31:return Ge("Activity");case 30:return Ge("ViewTransition");default:return""}}function Me(l){try{var u="",m=null;do u+=$t(l,m),m=l,l=l.return;while(l);return u}catch(b){return`
Error generating stack: `+b.message+`
-`+b.stack}}var Ht=Object.prototype.hasOwnProperty,an=e.unstable_scheduleCallback,Mt=e.unstable_cancelCallback,_t=e.unstable_shouldYield,Ve=e.unstable_requestPaint,bt=e.unstable_now,Ut=e.unstable_getCurrentPriorityLevel,Yt=e.unstable_ImmediatePriority,yt=e.unstable_UserBlockingPriority,un=e.unstable_NormalPriority,Tn=e.unstable_LowPriority,$r=e.unstable_IdlePriority,Sr=e.log,kr=e.unstable_setDisableYieldValue,ur=null,Fn=null;function Gr(l){if(typeof Sr=="function"&&kr(l),Fn&&typeof Fn.setStrictMode=="function")try{Fn.setStrictMode(ur,l)}catch{}}var yn=Math.clz32?Math.clz32:Ye,Le=Math.log,Ze=Math.LN2;function Ye(l){return l>>>=0,l===0?32:31-(Le(l)/Ze|0)|0}var Kt=256,ln=262144,Gt=4194304;function Rt(l){var u=l&42;if(u!==0)return u;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&-l;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function vr(l,u,m){var b=l.pendingLanes;if(b===0)return 0;var k=0,C=l.suspendedLanes,$=l.pingedLanes;l=l.warmLanes;var Z=b&134217727;return Z!==0?(b=Z&~C,b!==0?k=Rt(b):($&=Z,$!==0?k=Rt($):m||(m=Z&~l,m!==0&&(k=Rt(m))))):(Z=b&~C,Z!==0?k=Rt(Z):$!==0?k=Rt($):m||(m=b&~l,m!==0&&(k=Rt(m)))),k===0?0:u!==0&&u!==k&&(u&C)===0&&(C=k&-k,m=u&-u,C>=m||C===32&&(m&4194048)!==0)?u:k}function Qt(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function gs(l,u){(u&8)!==0&&(u|=u&32);var m=l.entangledLanes;if(m!==0)for(l=l.entanglements,m&=u;0m;m++)u.push(l);return u}function us(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function bl(l,u,m,b,k,C){var $=l.pendingLanes;l.pendingLanes=m,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=m,l.entangledLanes&=m,l.errorRecoveryDisabledLanes&=m,l.shellSuspendCounter=0;var Z=l.entanglements,fe=l.expirationTimes,Ce=l.hiddenUpdates;for(m=$&~m;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hn=!1;if(Wt)try{var Nr={};Object.defineProperty(Nr,"passive",{get:function(){Hn=!0}}),window.addEventListener("test",Nr,Nr),window.removeEventListener("test",Nr,Nr)}catch{Hn=!1}var dr=null,Cr=null,vs=null;function wi(){if(vs)return vs;var l,u=Cr,m=u.length,b,k="value"in dr?dr.value:dr.textContent,C=k.length;for(l=0;l=Nw),hse=" ",pse=!1;function mse(l,u){switch(l){case"keyup":return mYe.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gse(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var pv=!1;function vYe(l,u){switch(l){case"compositionend":return gse(u);case"keypress":return u.which!==32?null:(pse=!0,hse);case"textInput":return l=u.data,l===hse&&pse?null:l;default:return null}}function xYe(l,u){if(pv)return l==="compositionend"||!$L&&mse(l,u)?(l=wi(),vs=Cr=dr=null,pv=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function kse(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Nse(l,u){var m=kse(l);l=0;for(var b;m;){if(m.nodeType===3){if(b=l+m.textContent.length,l<=u&&b>=u)return{node:m,offset:u-l};l=b}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=kse(m)}}function Cse(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?Cse(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Ase(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var u=UL(l.document);u instanceof l.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)l=u.contentWindow;else break;u=UL(l.document)}return u}function HL(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}var CYe=Wt&&"documentMode"in document&&11>=document.documentMode,mv=null,VL=null,Tw=null,KL=!1;function Ese(l,u,m){var b=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;KL||mv==null||mv!==UL(b)||(b=mv,"selectionStart"in b&&HL(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Tw&&Ew(Tw,b)||(Tw=b,b=vA(VL,"onSelect"),0>=$,k-=$,mc=1<<32-yn(u)+k|m<qt?(Is=Bt,Bt=null):Is=Bt.sibling;var Vn=je(ke,Bt,Ee[qt],ze);if(Vn===null){Bt===null&&(Bt=Is);break}l&&Bt&&Vn.alternate===null&&u(ke,Bt),be=C(Vn,be,qt),Dn===null?ct=Vn:Dn.sibling=Vn,Dn=Vn,Bt=Is}if(qt===Ee.length)return m(ke,Bt),Nn&&Tu(ke,qt),ct;if(Bt===null){for(;qtqt?(Is=Bt,Bt=null):Is=Bt.sibling;var Af=je(ke,Bt,Vn.value,ze);if(Af===null){Bt===null&&(Bt=Is);break}l&&Bt&&Af.alternate===null&&u(ke,Bt),be=C(Af,be,qt),Dn===null?ct=Af:Dn.sibling=Af,Dn=Af,Bt=Is}if(Vn.done)return m(ke,Bt),Nn&&Tu(ke,qt),ct;if(Bt===null){for(;!Vn.done;qt++,Vn=Ee.next())Vn=$e(ke,Vn.value,ze),Vn!==null&&(be=C(Vn,be,qt),Dn===null?ct=Vn:Dn.sibling=Vn,Dn=Vn);return Nn&&Tu(ke,qt),ct}for(Bt=b(Bt);!Vn.done;qt++,Vn=Ee.next())Vn=Oe(Bt,ke,qt,Vn.value,ze),Vn!==null&&(l&&(Is=Vn.alternate,Is!==null&&Bt.delete(Is.key===null?qt:Is.key)),be=C(Vn,be,qt),Dn===null?ct=Vn:Dn.sibling=Vn,Dn=Vn);return l&&Bt.forEach(function(vXe){return u(ke,vXe)}),Nn&&Tu(ke,qt),ct}function gn(ke,be,Ee,ze){if(typeof Ee=="object"&&Ee!==null&&Ee.type===L&&Ee.key===null&&Ee.props.ref===void 0&&(Ee=Ee.props.children),typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case _:e:{for(var ct=Ee.key;be!==null;){if(be.key===ct){if(ct=Ee.type,ct===L){if(be.tag===7){m(ke,be.sibling),ze=k(be,Ee.props.children),lf(ze,Ee),ze.return=ke,ke=ze;break e}}else if(be.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===q&&Mp(ct)===be.type){m(ke,be.sibling),ze=k(be,Ee.props),lf(ze,Ee),ze.return=ke,ke=ze;break e}m(ke,be);break}else u(ke,be);be=be.sibling}Ee.type===L?(ze=Ap(Ee.props.children,ke.mode,ze,Ee.key),lf(ze,Ee),ze.return=ke,ke=ze):(ze=jC(Ee.type,Ee.key,Ee.props,null,ke.mode,ze),lf(ze,Ee),ze.return=ke,ke=ze)}return $(ke);case I:e:{for(ct=Ee.key;be!==null;){if(be.key===ct)if(be.tag===4&&be.stateNode.containerInfo===Ee.containerInfo&&be.stateNode.implementation===Ee.implementation){m(ke,be.sibling),ze=k(be,Ee.children||[]),ze.return=ke,ke=ze;break e}else{m(ke,be);break}else u(ke,be);be=be.sibling}ze=ZL(Ee,ke.mode,ze),ze.return=ke,ke=ze}return $(ke);case q:return Ee=Mp(Ee),gn(ke,be,Ee,ze)}if(se(Ee))return et(ke,be,Ee,ze);if(J(Ee)){if(ct=J(Ee),typeof ct!="function")throw Error(r(150));return Ee=ct.call(Ee),At(ke,be,Ee,ze)}if(typeof Ee.then=="function")return gn(ke,be,PC(Ee),ze);if(Ee.$$typeof===X)return gn(ke,be,EC(ke,Ee),ze);IC(ke,Ee)}return typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint"?(Ee=""+Ee,be!==null&&be.tag===6?(m(ke,be.sibling),ze=k(be,Ee),ze.return=ke,ke=ze):(m(ke,be),ze=QL(Ee,ke.mode,ze),ze.return=ke,ke=ze),$(ke)):m(ke,be)}return function(ke,be,Ee,ze){try{_w=0;var ct=gn(ke,be,Ee,ze);return kv=null,ct}catch(Bt){if(Bt===Sv||Bt===OC)throw Bt;var Dn=ji(29,Bt,null,ke.mode);return Dn.lanes=ze,Dn.return=ke,Dn}}}var Dp=Zse(!0),Jse=Zse(!1),cf=!1;function lz(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function cz(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function uf(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function df(l,u,m){var b=l.updateQueue;if(b===null)return null;if(b=b.shared,(er&2)!==0){var k=b.pending;return k===null?u.next=u:(u.next=k.next,k.next=u),b.pending=u,u=wC(l),Dse(l,null,m),u}return yC(l,b,u,m),wC(l)}function Dw(l,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194048)!==0)){var b=u.lanes;b&=l.pendingLanes,m|=b,u.lanes=m,pp(l,m)}}function uz(l,u){var m=l.updateQueue,b=l.alternate;if(b!==null&&(b=b.updateQueue,m===b)){var k=null,C=null;if(m=m.firstBaseUpdate,m!==null){do{var $={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};C===null?k=C=$:C=C.next=$,m=m.next}while(m!==null);C===null?k=C=u:C=C.next=u}else k=C=u;m={baseState:b.baseState,firstBaseUpdate:k,lastBaseUpdate:C,shared:b.shared,callbacks:b.callbacks},l.updateQueue=m;return}l=m.lastBaseUpdate,l===null?m.firstBaseUpdate=u:l.next=u,m.lastBaseUpdate=u}var dz=!1;function Lw(){if(dz){var l=jv;if(l!==null)throw l}}function zw(l,u,m,b){dz=!1;var k=l.updateQueue;cf=!1;var C=k.firstBaseUpdate,$=k.lastBaseUpdate,Z=k.shared.pending;if(Z!==null){k.shared.pending=null;var fe=Z,Ce=fe.next;fe.next=null,$===null?C=Ce:$.next=Ce,$=fe;var Pe=l.alternate;Pe!==null&&(Pe=Pe.updateQueue,Z=Pe.lastBaseUpdate,Z!==$&&(Z===null?Pe.firstBaseUpdate=Ce:Z.next=Ce,Pe.lastBaseUpdate=fe))}if(C!==null){var $e=k.baseState;$=0,Pe=Ce=fe=null,Z=C;do{var je=Z.lane&-536870913,Oe=je!==Z.lane;if(Oe?(_n&je)===je:(b&je)===je){je!==0&&je===Pp&&(dz=!0),Pe!==null&&(Pe=Pe.next={lane:0,tag:Z.tag,payload:Z.payload,callback:null,next:null});e:{var et=l,At=Z;je=u;var gn=m;switch(At.tag){case 1:if(et=At.payload,typeof et=="function"){$e=et.call(gn,$e,je);break e}$e=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=At.payload,je=typeof et=="function"?et.call(gn,$e,je):et,je==null)break e;$e=P({},$e,je);break e;case 2:cf=!0}}je=Z.callback,je!==null&&(l.flags|=64,Oe&&(l.flags|=8192),Oe=k.callbacks,Oe===null?k.callbacks=[je]:Oe.push(je))}else Oe={lane:je,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},Pe===null?(Ce=Pe=Oe,fe=$e):Pe=Pe.next=Oe,$|=je;if(Z=Z.next,Z===null){if(Z=k.shared.pending,Z===null)break;Oe=Z,Z=Oe.next,Oe.next=null,k.lastBaseUpdate=Oe,k.shared.pending=null}}while(!0);Pe===null&&(fe=$e),k.baseState=fe,k.firstBaseUpdate=Ce,k.lastBaseUpdate=Pe,C===null&&(k.shared.lanes=0),xf|=$,l.lanes=$,l.memoizedState=$e}}function eae(l,u){if(typeof l!="function")throw Error(r(191,l));l.call(u)}function tae(l,u){var m=l.callbacks;if(m!==null)for(l.callbacks=null,l=0;lC?C:8;var $=le.T,Z={};Z.types=$!==null?$.types:null,le.T=Z,Rz(l,!1,u,m);try{var fe=k(),Ce=le.S;if(Ce!==null&&Ce(Z,fe),fe!==null&&typeof fe=="object"&&typeof fe.then=="function"){var Pe=LYe(fe,b);Uw(l,u,Pe,so(l))}else Uw(l,u,b,so(l))}catch($e){Uw(l,u,{then:function(){},status:"rejected",reason:$e},so())}finally{te.p=C,$!==null&&Z.types!==null&&($.types=Z.types),le.T=$}}function HYe(){}function Tz(l,u,m,b){if(l.tag!==5)throw Error(r(476));var k=Iae(l).queue;Pae(l,k,u,re,m===null?HYe:function(){return Mae(l),m(b)})}function Iae(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:re,baseState:re,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Iu,lastRenderedState:re},next:null};var m={};return u.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Iu,lastRenderedState:m},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function Mae(l){var u=Iae(l);u.next===null&&(u=l.alternate.memoizedState),Uw(l,u.next.queue,{},so())}function Oz(){return Sa(qv)}function _ae(){return xs().memoizedState}function Dae(){return xs().memoizedState}function VYe(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var m=so();l=uf(m);var b=df(u,l,m);b!==null&&(Ci(b,u,m),Dw(b,u,m)),u={cache:sz()},l.payload=u;return}u=u.return}}function KYe(l,u,m){var b=so();m={lane:b,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},HC(l)?zae(u,m):(m=WL(l,u,m,b),m!==null&&(Ci(m,l,b),$ae(m,u,b)))}function Lae(l,u,m){var b=so();Uw(l,u,m,b)}function Uw(l,u,m,b){var k={lane:b,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null};if(HC(l))zae(u,k);else{var C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=u.lastRenderedReducer,C!==null))try{var $=u.lastRenderedState,Z=C($,m);if(k.hasEagerState=!0,k.eagerState=Z,Ji(Z,$))return yC(l,u,k,0),Ar===null&&bC(),!1}catch{}if(m=WL(l,u,k,b),m!==null)return Ci(m,l,b),$ae(m,u,b),!0}return!1}function Rz(l,u,m,b){if(b={lane:2,revertLane:w$(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},HC(l)){if(u)throw Error(r(479))}else u=WL(l,m,b,2),u!==null&&Ci(u,l,2)}function HC(l){var u=l.alternate;return l===mn||u!==null&&u===mn}function zae(l,u){Nv=DC=!0;var m=l.pending;m===null?u.next=u:(u.next=m.next,m.next=u),l.pending=u}function $ae(l,u,m){if((m&4194048)!==0){var b=u.lanes;b&=l.pendingLanes,m|=b,u.lanes=m,pp(l,m)}}var VC={readContext:Sa,use:$C,useCallback:ds,useContext:ds,useEffect:ds,useImperativeHandle:ds,useLayoutEffect:ds,useInsertionEffect:ds,useMemo:ds,useReducer:ds,useRef:ds,useState:ds,useDebugValue:ds,useDeferredValue:ds,useTransition:ds,useSyncExternalStore:ds,useId:ds,useHostTransitionStatus:ds,useFormState:ds,useActionState:ds,useOptimistic:ds,useMemoCache:ds,useCacheRefresh:ds,useEffectEvent:ds},Bae={readContext:Sa,use:$C,useCallback:function(l,u){return ti().memoizedState=[l,u===void 0?null:u],l},useContext:Sa,useEffect:Sae,useImperativeHandle:function(l,u,m){m=m!=null?m.concat([l]):null,FC(4194308,4,Aae.bind(null,u,l),m)},useLayoutEffect:function(l,u){return FC(4194308,4,l,u)},useInsertionEffect:function(l,u){FC(4,2,l,u)},useMemo:function(l,u){var m=ti();u=u===void 0?null:u;var b=l();if(Lp){Gr(!0);try{l()}finally{Gr(!1)}}return m.memoizedState=[b,u],b},useReducer:function(l,u,m){var b=ti();if(m!==void 0){var k=m(u);if(Lp){Gr(!0);try{m(u)}finally{Gr(!1)}}}else k=u;return b.memoizedState=b.baseState=k,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:k},b.queue=l,l=l.dispatch=KYe.bind(null,mn,l),[b.memoizedState,l]},useRef:function(l){var u=ti();return l={current:l},u.memoizedState=l},useState:function(l){l=kz(l);var u=l.queue,m=Lae.bind(null,mn,u);return u.dispatch=m,[l.memoizedState,m]},useDebugValue:Az,useDeferredValue:function(l,u){var m=ti();return Ez(m,l,u)},useTransition:function(){var l=kz(!1);return l=Pae.bind(null,mn,l.queue,!0,!1),ti().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,m){var b=mn,k=ti();if(Nn){if(m===void 0)throw Error(r(407));m=m()}else{if(m=u(),Ar===null)throw Error(r(349));(_n&127)!==0||oae(b,u,m)}k.memoizedState=m;var C={value:m,getSnapshot:u};return k.queue=C,Sae(cae.bind(null,b,C,l),[l]),b.flags|=2048,Av(9,{destroy:void 0},lae.bind(null,b,C,m,u),null),m},useId:function(){var l=ti(),u=Ar.identifierPrefix;if(Nn){var m=gc,b=mc;m=(b&~(1<<32-yn(b)-1)).toString(32)+m,u="_"+u+"R_"+m,m=LC++,0<\/script>",C=C.removeChild(C.firstChild);break;case"select":C=typeof b.is=="string"?$.createElement("select",{is:b.is}):$.createElement("select"),b.multiple?C.multiple=!0:b.size&&(C.size=b.size);break;default:C=typeof b.is=="string"?$.createElement(k,{is:b.is}):$.createElement(k)}}C[Xs]=u,C[ja]=b;e:for($=u.child;$!==null;){if($.tag===5||$.tag===6)C.appendChild($.stateNode);else if($.tag!==4&&$.tag!==27&&$.child!==null){$.child.return=$,$=$.child;continue}if($===u)break e;for(;$.sibling===null;){if($.return===null||$.return===u)break e;$=$.return}$.sibling.return=$.return,$=$.sibling}u.stateNode=C;e:switch(Aa(C,k,b),k){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&_u(u)}}return Pr(u),u.subtreeFlags&=-33554433,Vz(u,u.type,l===null?null:l.memoizedProps,u.pendingProps,m),null;case 6:if(l&&u.stateNode!=null)l.memoizedProps!==b&&_u(u);else{if(typeof b!="string"&&u.stateNode===null)throw Error(r(166));if(l=de.current,wv(u)){if(l=u.stateNode,m=u.memoizedProps,b=null,k=ua,k!==null)switch(k.tag){case 27:case 5:b=k.memoizedProps}l[Xs]=u,l=!!(l.nodeValue===m||b!==null&&b.suppressHydrationWarning===!0||coe(l.nodeValue,m)),l||af(u,!0)}else l=tj(l).createTextNode(b),l[Xs]=u,u.stateNode=l}return Pr(u),null;case 31:if(m=u.memoizedState,l===null||l.memoizedState!==null){if(b=wv(u),m!==null){if(l===null){if(!b)throw Error(r(318));if(l=u.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(r(557));l[Xs]=u}else Ep(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Pr(u),l=!1}else m=tz(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=m),l=!0;if(!l)return u.flags&256?(eo(u),u):(eo(u),null);if((u.flags&128)!==0)throw Error(r(558))}return Pr(u),null;case 13:if(b=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(k=wv(u),b!==null&&b.dehydrated!==null){if(l===null){if(!k)throw Error(r(318));if(k=u.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[Xs]=u}else Ep(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Pr(u),k=!1}else k=tz(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=k),k=!0;if(!k)return u.flags&256?(eo(u),u):(eo(u),null)}return eo(u),(u.flags&128)!==0?(u.lanes=m,u):(m=b!==null,l=l!==null&&l.memoizedState!==null,m&&(b=u.child,k=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(k=b.alternate.memoizedState.cachePool.pool),C=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(C=b.memoizedState.cachePool.pool),C!==k&&(b.flags|=2048)),m!==l&&m&&(u.child.flags|=8192),XC(u,u.updateQueue),Pr(u),null);case 4:return xe(),l===null&&N$(u.stateNode.containerInfo),u.flags|=67108864,Pr(u),null;case 10:return Ru(u.type),Pr(u),null;case 19:if(mz(u),b=u.memoizedState,b===null)return Pr(u),null;if(k=(u.flags&128)!==0,C=b.rendering,C===null)if(k)Vw(b,!1);else{if(fs!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(C=_C(l),C!==null){for(u.flags|=128,Vw(b,!1),l=C.updateQueue,u.updateQueue=l,XC(u,l),u.subtreeFlags=0,l=m,m=u.child;m!==null;)Lse(m,l),m=m.sibling;return $w(u,Na.current&1|2),Nn&&Tu(u,b.treeForkCount),u.child}l=l.sibling}b.tail!==null&&bt()>lA&&(u.flags|=128,k=!0,Vw(b,!1),u.lanes=4194304)}else{if(!k)if(l=_C(C),l!==null){if(u.flags|=128,k=!0,l=l.updateQueue,u.updateQueue=l,XC(u,l),Vw(b,!0),b.tail===null&&b.tailMode!=="collapsed"&&b.tailMode!=="visible"&&!C.alternate&&!Nn)return Pr(u),null}else 2*bt()-b.renderingStartTime>lA&&m!==536870912&&(u.flags|=128,k=!0,Vw(b,!1),u.lanes=4194304);b.isBackwards?(C.sibling=u.child,u.child=C):(l=b.last,l!==null?l.sibling=C:u.child=C,b.last=C)}if(b.tail!==null){l=b.tail;e:{for(m=l;m!==null;){if(m.alternate!==null){m=!1;break e}m=m.sibling}m=!0}return b.rendering=l,b.tail=l.sibling,b.renderingStartTime=bt(),l.sibling=null,C=Na.current,C=k?C&1|2:C&1,b.tailMode==="visible"||b.tailMode==="collapsed"||!m||Nn?$w(u,C):(m=C,ce(ka,u),ce(Na,m),Ha===null&&(Ha=u)),Nn&&Tu(u,b.treeForkCount),l}return Pr(u),null;case 22:case 23:return eo(u),hz(),b=u.memoizedState!==null,l!==null?l.memoizedState!==null!==b&&(u.flags|=8192):b&&(u.flags|=8192),b?(m&536870912)!==0&&(u.flags&128)===0&&(Pr(u),u.subtreeFlags&6&&(u.flags|=8192)):Pr(u),m=u.updateQueue,m!==null&&XC(u,m.retryQueue),m=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),b=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(b=u.memoizedState.cachePool.pool),b!==m&&(u.flags|=2048),l!==null&&me(Ip),null;case 24:return m=null,l!==null&&(m=l.memoizedState.cache),u.memoizedState.cache!==m&&(u.flags|=2048),Ru(Os),Pr(u),null;case 25:return null;case 30:return u.flags|=33554432,Pr(u),null}throw Error(r(156,u.tag))}function ZYe(l,u){switch(JL(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Ru(Os),xe(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return we(u),null;case 31:if(u.memoizedState!==null){if(eo(u),u.alternate===null)throw Error(r(340));Ep()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 13:if(eo(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(r(340));Ep()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return mz(u),l=u.flags,l&65536?(u.flags=l&-65537|128,l=u.memoizedState,l!==null&&(l.rendering=null,l.tail=null),u.flags|=4,u):null;case 4:return xe(),null;case 10:return Ru(u.type),null;case 22:case 23:return eo(u),hz(),l!==null&&me(Ip),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return Ru(Os),null;case 25:return null;default:return null}}function die(l,u){switch(JL(u),u.tag){case 3:Ru(Os),xe();break;case 26:case 27:case 5:we(u);break;case 4:xe();break;case 31:u.memoizedState!==null&&eo(u);break;case 13:eo(u);break;case 19:mz(u);break;case 10:Ru(u.type);break;case 22:case 23:eo(u),hz(),l!==null&&me(Ip);break;case 24:Ru(Os)}}function Kw(l,u){try{var m=u.updateQueue,b=m!==null?m.lastEffect:null;if(b!==null){var k=b.next;m=k;do{if((m.tag&l)===l){b=void 0;var C=m.create,$=m.inst;b=C(),$.destroy=b}m=m.next}while(m!==k)}}catch(Z){hr(u,u.return,Z)}}function mf(l,u,m){try{var b=u.updateQueue,k=b!==null?b.lastEffect:null;if(k!==null){var C=k.next;b=C;do{if((b.tag&l)===l){var $=b.inst,Z=$.destroy;if(Z!==void 0){$.destroy=void 0,k=u;var fe=m,Ce=Z;try{Ce()}catch(Pe){hr(k,fe,Pe)}}}b=b.next}while(b!==C)}}catch(Pe){hr(u,u.return,Pe)}}function fie(l){var u=l.updateQueue;if(u!==null){var m=l.stateNode;try{tae(u,m)}catch(b){hr(l,l.return,b)}}}function hie(l,u,m){m.props=zp(l.type,l.memoizedProps),m.state=l.memoizedState;try{m.componentWillUnmount()}catch(b){hr(l,u,b)}}function vc(l,u){try{var m=l.ref;if(m!==null){switch(l.tag){case 26:case 27:case 5:var b=l.stateNode;break;case 30:var k=l.stateNode,C=Cu(l.memoizedProps,k);(k.ref===null||k.ref.name!==C)&&(k.ref=yoe(C)),b=k.ref;break;case 7:if(l.stateNode===null){var $=new ao(l);g(l.child,!1,UWe,$,void 0,void 0),l.stateNode=$}b=l.stateNode;break;default:b=l.stateNode}typeof m=="function"?l.refCleanup=m(b):m.current=b}}catch(Z){hr(l,u,Z)}}function Ca(l,u){var m=l.ref,b=l.refCleanup;if(m!==null)if(typeof b=="function")try{b()}catch(k){hr(l,u,k)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof m=="function")try{m(null)}catch(k){hr(l,u,k)}else m.current=null}function QC(l,u){if((l.tag===5||l.tag===27||l.tag===6)&&l.alternate===null&&u!==null)for(var m=0;m title"))),Aa(b,u,m),b[Xs]=l,Ts(b),u=b;break e;case"link":if(C=Loe("link","href",k).get(u+(m.href||""))){for($=0;$gn&&($=gn,gn=At,At=$);var ke=Nse(Z,At),be=Nse(Z,gn);if(ke&&be&&(Oe.rangeCount!==1||Oe.anchorNode!==ke.node||Oe.anchorOffset!==ke.offset||Oe.focusNode!==be.node||Oe.focusOffset!==be.offset)){var Ee=$e.createRange();Ee.setStart(ke.node,ke.offset),Oe.removeAllRanges(),At>gn?(Oe.addRange(Ee),Oe.extend(be.node,be.offset)):(Ee.setEnd(be.node,be.offset),Oe.addRange(Ee))}}}}for($e=[],Oe=Z;Oe=Oe.parentNode;)Oe.nodeType===1&&$e.push({element:Oe,left:Oe.scrollLeft,top:Oe.scrollTop});for(typeof Z.focus=="function"&&Z.focus(),Z=0;Z<$e.length;Z++){var ze=$e[Z];ze.element.scrollLeft=ze.left,ze.element.scrollTop=ze.top}}Gv=!!E$,T$=E$=null}finally{er=C,te.p=k,le.T=b}}l.current=u,es=2}}function m$(){if(es===2){es=0;var l=Al,u=Up,m=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||m){m=le.T,le.T=null;var b=te.p;te.p=2;var k=er;er|=4;try{kie(l,u.alternate,u)}finally{er=k,te.p=b,le.T=m}}es=3}}function g$(){if(es===4||es===3){es=0;var l=Mv;Mv=null,Ve();var u=Al,m=Up,b=Sc,k=$ie,C=(b&335544064)===b?10262:10256;if((m.subtreeFlags&C)!==0||(m.flags&C)!==0?es=5:(es=0,Up=Al=null,Qie(u,u.pendingLanes)),C=u.pendingLanes,C===0&&(bf=null),Dt(b),m=m.stateNode,Fn&&typeof Fn.onCommitFiberRoot=="function")try{Fn.onCommitFiberRoot(ur,m,void 0,(m.current.flags&128)===128)}catch{}if(k!==null){m=le.T,C=te.p,te.p=2,le.T=null;try{for(var $=u.onRecoverableError,Z=0;Zm?32:m,le.T=null,m=d$,d$=null;var C=Al,$=Sc;if(es=0,Up=Al=null,Sc=0,(er&6)!==0)throw Error(r(331));var Z=er;if(er|=4,Die(C.current),Iie(C,C.current,$,m),er=Z,Zw(0,!1),Fn&&typeof Fn.onPostCommitFiberRoot=="function")try{Fn.onPostCommitFiberRoot(ur,C)}catch{}return!0}finally{te.p=k,le.T=b,Qie(l,u)}}function Zie(l,u,m){u=$o(m,u),u=Mz(l.stateNode,u,2),l=df(l,u,2),l!==null&&(us(l,2),kc(l))}function hr(l,u,m){if(l.tag===3)Zie(l,l,m);else for(;u!==null;){if(u.tag===3){Zie(u,l,m);break}else if(u.tag===1){var b=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(bf===null||!bf.has(b))){l=$o(m,l),m=Yae(2),b=df(u,m,2),b!==null&&(Wae(m,b,u,l),us(b,2),kc(b));break}}u=u.return}}function x$(l,u,m){var b=l.pingCache;if(b===null){b=l.pingCache=new nWe;var k=new Set;b.set(u,k)}else k=b.get(u),k===void 0&&(k=new Set,b.set(u,k));k.has(m)||(l$=!0,k.add(m),l=uWe.bind(null,l,u,m),u.then(l,l))}function uWe(l,u,m){var b=l.pingCache;b!==null&&b.delete(u),l.pingedLanes|=l.suspendedLanes&m,l.warmLanes&=~m,Ar===l&&(_n&m)===m&&((fs===4||fs===3&&(_n&62914560)===_n&&300>bt()-oA)&&(er&2)===0?zv(l,0):iA|=m,Iv===_n&&(Iv=0)),kc(l)}function Jie(l,u){u===0&&(u=Or()),l=Cp(l,u),l!==null&&(us(l,u),kc(l))}function dWe(l){var u=l.memoizedState,m=0;u!==null&&(m=u.retryLane),Jie(l,m)}function fWe(l,u){var m=0;switch(l.tag){case 31:case 13:var b=l.stateNode,k=l.memoizedState;k!==null&&(m=k.retryLane);break;case 19:b=l.stateNode;break;case 22:b=l.stateNode._retryCache;break;default:throw Error(r(314))}b!==null&&b.delete(u),Jie(l,m)}function hWe(l,u){return an(l,u)}var Bv=null,Fv=null,b$=!1,mA=!1,y$=!1,wf=0;function kc(l){l!==Fv&&l.next===null&&(Fv===null?Bv=Fv=l:Fv=Fv.next=l),mA=!0,b$||(b$=!0,mWe())}function Zw(l,u){if(!y$&&mA){y$=!0;do for(var m=!1,b=Bv;b!==null;){if(l!==0){var k=b.pendingLanes;if(k===0)var C=0;else{var $=b.suspendedLanes,Z=b.pingedLanes;C=(1<<31-yn(42|l)+1)-1,C&=k&~($&~Z),C=C&201326741?C&201326741|1:C?C|2:0}C!==0&&(m=!0,roe(b,C))}else C=_n,C=vr(b,b===Ar?C:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(C&3)===0||Qt(b,C)||(m=!0,roe(b,C));b=b.next}while(m);y$=!1}}function pWe(){eoe()}function eoe(){mA=b$=!1;var l=0;wf!==0&&CWe()&&(l=wf);for(var u=bt(),m=null,b=Bv;b!==null;){var k=b.next,C=toe(b,u);C===0?(b.next=null,m===null?Bv=k:m.next=k,k===null&&(Fv=m)):(m=b,(l!==0||(C&3)!==0)&&(mA=!0)),b=k}es!==0&&es!==5||Zw(l),wf!==0&&(wf=0)}function toe(l,u){for(var m=l.suspendedLanes,b=l.pingedLanes,k=l.expirationTimes,C=l.pendingLanes&-62914561;0Z)break;var Pe=fe.transferSize,$e=fe.initiatorType;Pe&&uoe($e)&&(fe=fe.responseEnd,$+=Pe*(feyA){At.length=et;break}Ee=new Promise(PWe.bind(Ee)),At.push(Ee)}}}if(0"u"?null:document;function Ioe(l,u,m){var b=Hv;if(b&&typeof u=="string"&&u){var k=ei(u);k='link[rel="'+l+'"][href="'+k+'"]',typeof m=="string"&&(k+='[crossorigin="'+m+'"]'),Poe.has(k)||(Poe.add(k),l={rel:l,crossOrigin:m,href:u},b.querySelector(k)===null&&(u=b.createElement("link"),Aa(u,"link",l),Ts(u),b.head.appendChild(u)))}}function QWe(l){Lu.D(l),Ioe("dns-prefetch",l,null)}function ZWe(l,u){Lu.C(l,u),Ioe("preconnect",l,u)}function JWe(l,u,m){Lu.L(l,u,m);var b=Hv;if(b&&l&&u){var k='link[rel="preload"][as="'+ei(u)+'"]';u==="image"&&m&&m.imageSrcSet?(k+='[imagesrcset="'+ei(m.imageSrcSet)+'"]',typeof m.imageSizes=="string"&&(k+='[imagesizes="'+ei(m.imageSizes)+'"]')):k+='[href="'+ei(l)+'"]';var C=k;switch(u){case"style":C=Vv(l);break;case"script":C=Kv(l)}if(!(Ko.has(C)||(l=P({rel:"preload",href:u==="image"&&m&&m.imageSrcSet?void 0:l,as:u},m),Ko.set(C,l),b.querySelector(k)!==null||u==="style"&&b.querySelector(rj(C))||u==="script"&&b.querySelector(sj(C))))){var $=b.createElement("link");Aa($,"link",l),u==="style"&&($[Qs]=!0,$.onload=$.onerror=function(){pw($)}),Ts($),b.head.appendChild($)}}}function eXe(l,u){Lu.m(l,u);var m=Hv;if(m&&l){var b=u&&typeof u.as=="string"?u.as:"script",k='link[rel="modulepreload"][as="'+ei(b)+'"][href="'+ei(l)+'"]',C=k;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":C=Kv(l)}if(!Ko.has(C)&&(l=P({rel:"modulepreload",href:l},u),Ko.set(C,l),m.querySelector(k)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(m.querySelector(sj(C)))return}b=m.createElement("link"),Aa(b,"link",l),Ts(b),m.head.appendChild(b)}}}function tXe(l,u,m){Lu.S(l,u,m);var b=Hv;if(b&&l){var k=ef(b).hoistableStyles,C=Vv(l);u=u||"default";var $=k.get(C);if(!$){var Z={loading:0,preload:null};if($=b.querySelector(rj(C)))Z.loading=5;else{l=P({rel:"stylesheet",href:l,"data-precedence":u},m),(m=Ko.get(C))&&F$(l,m);var fe=$=b.createElement("link");Ts(fe),Aa(fe,"link",l),fe._p=new Promise(function(Ce,Pe){fe.onload=Ce,fe.onerror=Pe}),fe.addEventListener("load",function(){Z.loading|=1}),fe.addEventListener("error",function(){Z.loading|=2}),Z.loading|=4,xA($,u,b)}$={type:"stylesheet",instance:$,count:1,state:Z},k.set(C,$)}}}function nXe(l,u){Lu.X(l,u);var m=Hv;if(m&&l){var b=ef(m).hoistableScripts,k=Kv(l),C=b.get(k);C||(C=m.querySelector(sj(k)),C||(l=P({src:l,async:!0},u),(u=Ko.get(k))&&U$(l,u),C=m.createElement("script"),Ts(C),Aa(C,"link",l),m.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},b.set(k,C))}}function rXe(l,u){Lu.M(l,u);var m=Hv;if(m&&l){var b=ef(m).hoistableScripts,k=Kv(l),C=b.get(k);C||(C=m.querySelector(sj(k)),C||(l=P({src:l,async:!0,type:"module"},u),(u=Ko.get(k))&&U$(l,u),C=m.createElement("script"),Ts(C),Aa(C,"link",l),m.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},b.set(k,C))}}function Moe(l,u,m,b){var k=(k=de.current)?nj(k):null;if(!k)throw Error(r(446));switch(l){case"meta":case"title":return null;case"style":return typeof m.precedence=="string"&&typeof m.href=="string"?(m=Vv(m.href),u=ef(k).hoistableStyles,b=u.get(m),b||(b={type:"style",instance:null,count:0,state:null},u.set(m,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(m.rel==="stylesheet"&&typeof m.href=="string"&&typeof m.precedence=="string"){l=Vv(m.href);var C=ef(k).hoistableStyles,$=C.get(l);if($||(k=k.ownerDocument||k,$={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},C.set(l,$),(C=k.querySelector(rj(l)))?C._p||($.instance=C,$.state.loading=5):(C=Ko.get(l),C||(C={rel:"preload",as:"style",href:m.href,crossOrigin:m.crossOrigin,integrity:m.integrity,media:m.media,hrefLang:m.hrefLang,referrerPolicy:m.referrerPolicy},Ko.set(l,C)),sXe(k,l,C,$.state))),u&&b===null)throw Error(r(528,""));return $}if(u&&b!==null)throw Error(r(529,""));return null;case"script":return u=m.async,m=m.src,typeof m=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(m=Kv(m),u=ef(k).hoistableScripts,b=u.get(m),b||(b={type:"script",instance:null,count:0,state:null},u.set(m,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,l))}}function Vv(l){return'href="'+ei(l)+'"'}function rj(l){return'link[rel="stylesheet"]['+l+"]"}function _oe(l){return P({},l,{"data-precedence":l.precedence,precedence:null})}function sXe(l,u,m,b){if(u=l.querySelector('link[rel="preload"][as="style"]['+u+"]")){if(u[Qs]!==!0){b.loading=1;return}}else u=l.createElement("link"),u[Qs]=!0,u.onload=u.onerror=pw.bind(null,u),Aa(u,"link",m),Ts(u),l.head.appendChild(u);b.preload=u,u.addEventListener("load",function(){return b.loading|=1}),u.addEventListener("error",function(){return b.loading|=2})}function Kv(l){return'[src="'+ei(l)+'"]'}function sj(l){return"script[async]"+l}function Doe(l,u,m){if(u.count++,u.instance===null)switch(u.type){case"style":var b=l.querySelector('style[data-href~="'+ei(m.href)+'"]');if(b)return u.instance=b,Ts(b),b;var k=P({},m,{"data-href":m.href,"data-precedence":m.precedence,href:null,precedence:null});return b=(l.ownerDocument||l).createElement("style"),Ts(b),Aa(b,"style",k),xA(b,m.precedence,l),u.instance=b;case"stylesheet":k=Vv(m.href);var C=l.querySelector(rj(k));if(C)return u.state.loading|=4,u.instance=C,Ts(C),C;b=_oe(m),(k=Ko.get(k))&&F$(b,k),C=(l.ownerDocument||l).createElement("link"),Ts(C);var $=C;return $._p=new Promise(function(Z,fe){$.onload=Z,$.onerror=fe}),Aa(C,"link",b),u.state.loading|=4,xA(C,m.precedence,l),u.instance=C;case"script":return C=Kv(m.src),(k=l.querySelector(sj(C)))?(u.instance=k,Ts(k),k):(b=m,(k=Ko.get(C))&&(b=P({},m),U$(b,k)),l=l.ownerDocument||l,k=l.createElement("script"),Ts(k),Aa(k,"link",b),l.head.appendChild(k),u.instance=k);case"void":return null;default:throw Error(r(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(b=u.instance,u.state.loading|=4,xA(b,m.precedence,l));return u.instance}function xA(l,u,m){for(var b=m.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=b.length?b[b.length-1]:null,C=k,$=0;$ title"):null)}function aXe(l,u,m){if(m===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;return u.rel==="stylesheet"?(l=u.disabled,typeof u.precedence=="string"&&l==null):!0;case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function zoe(l,u){return l==="img"&&u.src!=null&&u.src!==""&&u.onLoad==null&&u.loading!=="lazy"}function $oe(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Boe(l){return(l.width||100)*(l.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function Foe(l,u){typeof u.decode=="function"&&(l.imgCount++,u.complete||(l.imgBytes+=Boe(u),l.suspenseyImages.push(u)),l=lXe.bind(l),u.decode().then(l,l))}function iXe(l,u,m,b){if(m.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(m.state.loading&4)===0){if(m.instance===null){var k=Vv(b.href),C=u.querySelector(rj(k));if(C){u=C._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(l.count++,l=aj.bind(l),u.then(l,l)),m.state.loading|=4,m.instance=C,Ts(C);return}C=u.ownerDocument||u,b=_oe(b),(k=Ko.get(k))&&F$(b,k),C=C.createElement("link"),Ts(C);var $=C;$._p=new Promise(function(Z,fe){$.onload=Z,$.onerror=fe}),Aa(C,"link",b),m.instance=C}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(m,u),(u=m.state.preload)&&(m.state.loading&3)===0&&(l.count++,m=aj.bind(l),u.addEventListener("load",m),u.addEventListener("error",m))}}var yA=0;function oXe(l,u){return l.stylesheets&&l.count===0&&jA(l,l.stylesheets),0yA?50:800)+u);return l.unsuspend=m,function(){l.unsuspend=null,clearTimeout(b),clearTimeout(k)}}:null}function Uoe(l){if(l.count===0&&(l.imgCount===0||!l.waitingForImages)){if(l.stylesheets)jA(l,l.stylesheets);else if(l.unsuspend){var u=l.unsuspend;l.unsuspend=null,u()}}}function aj(){this.count--,Uoe(this)}function lXe(){this.imgCount--,Uoe(this)}var wA=null;function jA(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,wA=new Map,u.forEach(cXe,l),wA=null,aj.call(l))}function cXe(l,u){if(!(u.state.loading&4)){var m=wA.get(l);if(m)var b=m.get(null);else{m=new Map,wA.set(l,m);for(var k=l.querySelectorAll("link[data-precedence],style[data-precedence]"),C=0;C"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),RA.exports=lle(),RA.exports}var wn=cle();const ule=zu({__proto__:null},[wn]);var v=Vp();const MA=zu({__proto__:null,default:Tl(v)},[v]);function uj(){return typeof window<"u"}function pa(e){return _A(e)?(e.nodeName||"").toLowerCase():"#document"}function tr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Nc(e){var t;return(t=(_A(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _A(e){return uj()?e instanceof Node||e instanceof tr(e).Node:!1}function Cn(e){return uj()?e instanceof Element||e instanceof tr(e).Element:!1}function nr(e){return uj()?e instanceof HTMLElement||e instanceof tr(e).HTMLElement:!1}function Kp(e){return!uj()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tr(e).ShadowRoot}function Qv(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=si(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function dle(e){return/^(table|td|th)$/.test(pa(e))}function dj(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const fle=/transform|translate|scale|rotate|perspective|filter/,hle=/paint|layout|strict|content/,Ef=e=>!!e&&e!=="none";let DA;function LA(e){const t=Cn(e)?si(e):e;return Ef(t.transform)||Ef(t.translate)||Ef(t.scale)||Ef(t.rotate)||Ef(t.perspective)||!zA()&&(Ef(t.backdropFilter)||Ef(t.filter))||fle.test(t.willChange||"")||hle.test(t.contain||"")}function ple(e){let t=Fu(e);for(;nr(t)&&!Bu(t);){if(LA(t))return t;if(dj(t))return null;t=Fu(t)}return null}function zA(){return DA==null&&(DA=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),DA}function Bu(e){return/^(html|body|#document)$/.test(pa(e))}function si(e){return tr(e).getComputedStyle(e)}function fj(e){return Cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fu(e){if(pa(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Kp(e)&&e.host||Nc(e);return Kp(t)?t.host:t}function o3(e){const t=Fu(e);return Bu(t)?(e.ownerDocument||e).body:nr(t)&&Qv(t)?t:o3(t)}function qp(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=o3(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),c=tr(i);if(o){const d=$A(c);return t.concat(c,c.visualViewport||[],Qv(i)?i:[],d&&n?qp(d):[])}else return t.concat(i,qp(i,[],n))}function $A(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const BA={...MA},l3={};function hs(e,t){const n=v.useRef(l3);return n.current===l3&&(n.current=e(t)),n}const FA=BA.useInsertionEffect,mle=FA&&FA!==BA.useLayoutEffect?FA:e=>e();function Fe(e){const t=hs(gle).current;return t.next=e,mle(t.effect),t.trampoline}function gle(){const e={next:void 0,callback:vle,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function vle(){}const Ue=typeof document<"u"?v.useLayoutEffect:()=>{};function UA(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const HA={};function Ai(e,t,n,r,i){if(!n&&!r&&!i&&!e)return hj(t);let o=hj(e);return t&&(o=Zv(o,t)),n&&(o=Zv(o,n)),r&&(o=Zv(o,r)),i&&(o=Zv(o,i)),o}function xle(e){if(e.length===0)return HA;if(e.length===1)return hj(e[0]);let t=hj(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function VA(e){return typeof e=="function"}function u3(e,t){return VA(e)?e(t):e??HA}function wle(e,t){return t?e?(...n)=>{const r=n[0];if(h3(r)){const o=r;pj(o);const c=t(...n);return o.baseUIHandlerPrevented||e?.(...n),c}const i=t(...n);return e?.(...n),i}:d3(t):e}function d3(e){return e&&((...t)=>{const n=t[0];return h3(n)&&pj(n),e(...t)})}function pj(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function f3(e,t){return t?e?t+" "+e:t:e}function h3(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function jle(e,t){return function(r,...i){const o=new URL(e);return o.searchParams.set("code",r.toString()),i.forEach(c=>o.searchParams.append("args[]",c)),`${t} error #${r}; visit ${o} for the full message.`}}const En=jle("https://base-ui.com/production-error","Base UI"),p3=v.createContext(void 0);function m3(e=!1){const t=v.useContext(p3);if(t===void 0&&!e)throw new Error(En(16));return t}function Sle(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:o}=e,c=r&&t!==!1,d=r&&t===!1;return{props:v.useMemo(()=>{const h={onKeyDown(p){n&&t&&p.key!=="Tab"&&p.preventDefault()}};return r||(h.tabIndex=i,!o&&n&&(h.tabIndex=t?i:-1)),(o&&(t||c)||!o&&n)&&(h["aria-disabled"]=n),o&&(!t||d)&&(h.disabled=n),h},[r,n,t,c,d,o,i])}}function vn(e){return e?.ownerDocument||document}function Gp(e,t,{detail:n=0}={}){e.dispatchEvent(new(tr(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function ai(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:o}=e,c=v.useRef(null),d=m3(!0),f=o??d!==void 0,{props:h}=Sle({focusableWhenDisabled:n,disabled:t,composite:f,tabIndex:r,isNativeButton:i}),p=v.useCallback(()=>{const y=c.current;KA(y)&&f&&t&&h.disabled===void 0&&y.disabled&&(y.disabled=!1)},[t,h.disabled,f]);Ue(p,[p]);const g=v.useCallback((y={})=>{const{onClick:j,onMouseDown:w,onKeyUp:S,onKeyDown:N,onPointerDown:A,...E}=y;return Ai({onClick(O){if(t){O.preventDefault();return}j?.(O)},onMouseDown(O){t||w?.(O)},onKeyDown(O){if(t||(pj(O),N?.(O),O.baseUIHandlerPrevented))return;const R=O.target===O.currentTarget,T=O.currentTarget,P=KA(T),M=!i&&kle(T),_=R&&(i?P:!M),I=O.key==="Enter",L=O.key===" ",D=T.getAttribute("role"),z=D?.startsWith("menuitem")||D==="option"||D==="gridcell";if(R&&f&&L){if(O.defaultPrevented&&z)return;O.preventDefault(),(!i||P)&&(O.preventBaseUIHandler(),Gp(T,O));return}if(!_||i||!L&&!I){R&&M&&L&&O.preventDefault();return}O.defaultPrevented||(O.preventDefault(),I&&(O.preventBaseUIHandler(),Gp(T,O)))},onKeyUp(O){if(!t){if(pj(O),S?.(O),O.target===O.currentTarget&&i&&f&&KA(O.currentTarget)&&O.key===" "){O.preventDefault();return}O.baseUIHandlerPrevented||O.target===O.currentTarget&&!i&&!f&&!O.defaultPrevented&&O.key===" "&&(O.preventBaseUIHandler(),Gp(O.currentTarget,O))}},onPointerDown(O){if(t){O.preventDefault();return}A?.(O)}},i?{type:"button"}:{role:"button"},h,E)},[t,h,f,i]),x=Fe(y=>{c.current=y,p()});return{getButtonProps:g,buttonRef:x}}function KA(e){return nr(e)&&e.tagName==="BUTTON"}function kle(e){return nr(e)&&e.tagName==="A"&&!!e.href}function Ei(e,t,n,r){const i=hs(g3).current;return Cle(i,e,t,n,r)&&v3(i,[e,t,n,r]),i.callback}function Nle(e){const t=hs(g3).current;return Ale(t,e)&&v3(t,e),t.callback}function g3(){return{callback:null,cleanup:null,refs:[]}}function Cle(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Ale(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function v3(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function x3(e){if(!v.isValidElement(e))return null;const t=e,n=t.props;return(qA(19)?n?.ref:t.ref)??null}function Pn(){}const Ti=Object.freeze([]),rr=Object.freeze({});function Tle(e,t){const n={};for(const r in e){const i=e[r];if(t?.hasOwnProperty(r)){const o=t[r](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Ole(e,t){return typeof e=="function"?e(t):e}function b3(e,t){return typeof e=="function"?e(t):e}function wt(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Mle(r));const i=Rle(t,n,r);if(n.enabled===!1)return null;const o=n.state??rr;return _le(e,r,i,o)}function Rle(e,t,n){const{className:r,style:i}=e,{state:o=rr,ref:c,props:d,stateAttributesMapping:f,enabled:h=!0}=t,p=h?Ole(r,o):void 0,g=h?b3(i,o):void 0,x=h?Tle(o,f):rr,y=h&&d?Ple(d):void 0,j=h?UA(x,y)??{}:rr;return typeof document<"u"&&(h?Array.isArray(c)?j.ref=Nle([j.ref,x3(n),...c]):j.ref=Ei(j.ref,x3(n),c):Ei(null,null)),h?(p!==void 0&&(j.className=f3(j.className,p)),g!==void 0&&(j.style=UA(j.style,g)),j):rr}function Ple(e){return Array.isArray(e)?xle(e):Ai(void 0,e)}const Ile=Symbol.for("react.lazy");function Mle(e){if(e?.$$typeof!==Ile)return e;const t=v.Children.toArray(e)[0];return v.isValidElement(t)?t:e}function _le(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=Ai(n,t.props);return i.ref=n.ref,v.cloneElement(t,i)}if(e&&typeof e=="string")return Dle(e,n);throw new Error(En(8))}function Dle(e,t){return e==="button"?v.createElement("button",{type:"button",...t,key:t.key}):e==="img"?v.createElement("img",{alt:"",...t,key:t.key}):v.createElement(e,t)}const Lle=v.forwardRef(function(t,n){const{render:r,className:i,disabled:o=!1,focusableWhenDisabled:c=!1,nativeButton:d=!0,style:f,...h}=t,{getButtonProps:p,buttonRef:g}=ai({disabled:o,focusableWhenDisabled:c,native:d});return wt("button",t,{state:{disabled:o},ref:[n,g],props:[h,p]})});function y3(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,S3=w3,Tf=(e,t)=>n=>{var r;if(t?.variants==null)return S3(e,n?.class,n?.className);const{variants:i,defaultVariants:o}=t,c=Object.keys(i).map(h=>{const p=n?.[h],g=o?.[h];if(p===null)return null;const x=j3(p)||j3(g);return i[h][x]}),d=n&&Object.entries(n).reduce((h,p)=>{let[g,x]=p;return x===void 0||(h[g]=x),h},{}),f=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((h,p)=>{let{class:g,className:x,...y}=p;return Object.entries(y).every(j=>{let[w,S]=j;return Array.isArray(S)?S.includes({...o,...d}[w]):{...o,...d}[w]===S})?[...h,g,x]:h},[]);return S3(e,c,f,n?.class,n?.className)},zle=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r({classGroupId:e,validator:t}),k3=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),mj="-",N3=[],Ble="arbitrary..",Fle=e=>{const t=Hle(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return Ule(c);const d=c.split(mj),f=d[0]===""&&d.length>1?1:0;return C3(d,f,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const f=r[c],h=n[c];return f?h?zle(h,f):f:h||N3}return n[c]||N3}}},C3=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],o=n.nextPart.get(i);if(o){const h=C3(e,t+1,o);if(h)return h}const c=n.validators;if(c===null)return;const d=t===0?e.join(mj):e.slice(t).join(mj),f=c.length;for(let h=0;he.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Ble+r:void 0})(),Hle=e=>{const{theme:t,classGroups:n}=e;return Vle(n,t)},Vle=(e,t)=>{const n=k3();for(const r in e){const i=e[r];GA(i,n,r,t)}return n},GA=(e,t,n,r)=>{const i=e.length;for(let o=0;o{if(typeof e=="string"){qle(e,t,n);return}if(typeof e=="function"){Gle(e,t,n,r);return}Yle(e,t,n,r)},qle=(e,t,n)=>{const r=e===""?t:A3(t,e);r.classGroupId=n},Gle=(e,t,n,r)=>{if(Wle(e)){GA(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push($le(n,e))},Yle=(e,t,n,r)=>{const i=Object.entries(e),o=i.length;for(let c=0;c{let n=e;const r=t.split(mj),i=r.length;for(let o=0;o"isThemeGetter"in e&&e.isThemeGetter===!0,Xle=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(o,c)=>{n[o]=c,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(o){let c=n[o];if(c!==void 0)return c;if((c=r[o])!==void 0)return i(o,c),c},set(o,c){o in n?n[o]=c:i(o,c)}}},YA="!",E3=":",Qle=[],T3=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Zle=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const o=[];let c=0,d=0,f=0,h;const p=i.length;for(let w=0;wf?h-f:void 0;return T3(o,y,x,j)};if(t){const i=t+E3,o=r;r=c=>c.startsWith(i)?o(c.slice(i.length)):T3(Qle,!1,c,void 0,!0)}if(n){const i=r;r=o=>n({className:o,parseClassName:i})}return r},Jle=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let o=0;o0&&(i.sort(),r.push(...i),i=[]),r.push(c)):i.push(c)}return i.length>0&&(i.sort(),r.push(...i)),r}},ece=e=>({cache:Xle(e.cacheSize),parseClassName:Zle(e),sortModifiers:Jle(e),postfixLookupClassGroupIds:tce(e),...Fle(e)}),tce=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:c}=t,d=[],f=e.trim().split(nce);let h="";for(let p=f.length-1;p>=0;p-=1){const g=f[p],{isExternal:x,modifiers:y,hasImportantModifier:j,baseClassName:w,maybePostfixModifierPosition:S}=n(g);if(x){h=g+(h.length>0?" "+h:h);continue}let N=!!S,A;if(N){const P=w.substring(0,S);A=r(P);const M=A&&c[A]?r(w):void 0;M&&M!==A&&(A=M,N=!1)}else A=r(w);if(!A){if(!N){h=g+(h.length>0?" "+h:h);continue}if(A=r(w),!A){h=g+(h.length>0?" "+h:h);continue}N=!1}const E=y.length===0?"":y.length===1?y[0]:o(y).join(":"),O=j?E+YA:E,R=O+A;if(d.indexOf(R)>-1)continue;d.push(R);const T=i(A,N);for(let P=0;P0?" "+h:h)}return h},sce=(...e)=>{let t=0,n,r,i="";for(;t{if(typeof e=="string")return e;let t,n="";for(let r=0;r{let n,r,i,o;const c=f=>{const h=t.reduce((p,g)=>g(p),e());return n=ece(h),r=n.cache.get,i=n.cache.set,o=d,d(f)},d=f=>{const h=r(f);if(h)return h;const p=rce(f,n);return i(f,p),p};return o=c,(...f)=>o(sce(...f))},ice=[],Ms=e=>{const t=n=>n[e]||ice;return t.isThemeGetter=!0,t.themeKey=e,t},R3=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,P3=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oce=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lce=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cce=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,uce=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,dce=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,fce=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Uu=e=>oce.test(e),Sn=e=>!!e&&!Number.isNaN(Number(e)),Ol=e=>!!e&&Number.isInteger(Number(e)),WA=e=>e.endsWith("%")&&Sn(e.slice(0,-1)),Cc=e=>lce.test(e),I3=()=>!0,hce=e=>cce.test(e)&&!uce.test(e),XA=()=>!1,pce=e=>dce.test(e),mce=e=>fce.test(e),gce=e=>!ut(e)&&!dt(e),vce=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),xce=e=>Hu(e,$3,XA),ut=e=>R3.test(e),Of=e=>Hu(e,B3,hce),M3=e=>Hu(e,Cce,Sn),bce=e=>Hu(e,U3,I3),yce=e=>Hu(e,F3,XA),_3=e=>Hu(e,L3,XA),wce=e=>Hu(e,z3,mce),gj=e=>Hu(e,H3,pce),dt=e=>P3.test(e),Jv=e=>Rf(e,B3),jce=e=>Rf(e,F3),D3=e=>Rf(e,L3),Sce=e=>Rf(e,$3),kce=e=>Rf(e,z3),vj=e=>Rf(e,H3,!0),Nce=e=>Rf(e,U3,!0),Hu=(e,t,n)=>{const r=R3.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Rf=(e,t,n=!1)=>{const r=P3.exec(e);return r?r[1]?t(r[1]):n:!1},L3=e=>e==="position"||e==="percentage",z3=e=>e==="image"||e==="url",$3=e=>e==="length"||e==="size"||e==="bg-size",B3=e=>e==="length",Cce=e=>e==="number",F3=e=>e==="family-name",U3=e=>e==="number"||e==="weight",H3=e=>e==="shadow",Ace=ace(()=>{const e=Ms("color"),t=Ms("font"),n=Ms("text"),r=Ms("font-weight"),i=Ms("tracking"),o=Ms("leading"),c=Ms("breakpoint"),d=Ms("container"),f=Ms("spacing"),h=Ms("radius"),p=Ms("shadow"),g=Ms("inset-shadow"),x=Ms("text-shadow"),y=Ms("drop-shadow"),j=Ms("blur"),w=Ms("perspective"),S=Ms("aspect"),N=Ms("ease"),A=Ms("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...O(),dt,ut],T=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],M=()=>[dt,ut,f],_=()=>[Uu,"full","auto",...M()],I=()=>[Ol,"none","subgrid",dt,ut],L=()=>["auto",{span:["full",Ol,dt,ut]},Ol,dt,ut],D=()=>[Ol,"auto",dt,ut],z=()=>["auto","min","max","fr",dt,ut],G=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...M()],F=()=>[Uu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...M()],K=()=>[d,Uu,"screen","full","dvw","lvw","svw","min","max","fit",...M()],U=()=>[Uu,"screen","full","lh","dvh","lvh","svh","min","max","fit",...M()],q=()=>[e,dt,ut],W=()=>[...O(),D3,_3,{position:[dt,ut]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ie=()=>["auto","cover","contain",Sce,xce,{size:[dt,ut]}],V=()=>[WA,Jv,Of],H=()=>["","none","full",h,dt,ut],Q=()=>["",Sn,Jv,Of],J=()=>["solid","dashed","dotted","double"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>[Sn,WA,D3,_3],se=()=>["","none",j,dt,ut],le=()=>["none",Sn,dt,ut],te=()=>["none",Sn,dt,ut],re=()=>[Sn,dt,ut],he=()=>[Uu,"full",...M()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Cc],breakpoint:[Cc],color:[I3],container:[Cc],"drop-shadow":[Cc],ease:["in","out","in-out"],font:[gce],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Cc],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Cc],shadow:[Cc],spacing:["px",Sn],text:[Cc],"text-shadow":[Cc],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Uu,ut,dt,S]}],container:["container"],"container-type":[{"@container":["","normal","size",dt,ut]}],"container-named":[vce],columns:[{columns:[Sn,"auto",ut,dt,d]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{"inset-s":_(),start:_()}],end:[{"inset-e":_(),end:_()}],"inset-bs":[{"inset-bs":_()}],"inset-be":[{"inset-be":_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[Ol,"auto",dt,ut]}],basis:[{basis:[Uu,"full","auto",d,...M()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Sn,Uu,"auto","initial","none",ut]}],grow:[{grow:["",Sn,dt,ut]}],shrink:[{shrink:["",Sn,dt,ut]}],order:[{order:[Ol,"first","last","none",dt,ut]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:M()}],"gap-x":[{"gap-x":M()}],"gap-y":[{"gap-y":M()}],"justify-content":[{justify:[...G(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...G()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":G()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:M()}],px:[{px:M()}],py:[{py:M()}],ps:[{ps:M()}],pe:[{pe:M()}],pbs:[{pbs:M()}],pbe:[{pbe:M()}],pt:[{pt:M()}],pr:[{pr:M()}],pb:[{pb:M()}],pl:[{pl:M()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mbs:[{mbs:Y()}],mbe:[{mbe:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":M()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":M()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...K()]}],"min-inline-size":[{"min-inline":["auto",...K()]}],"max-inline-size":[{"max-inline":["none",...K()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[d,"screen",...F()]}],"min-w":[{"min-w":[d,"screen","none",...F()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[c]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh","none",...F()]}],"font-size":[{text:["base",n,Jv,Of]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Nce,bce]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",WA,ut]}],"font-family":[{font:[jce,yce,t]}],"font-features":[{"font-features":[ut]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,dt,ut]}],"line-clamp":[{"line-clamp":[Sn,"none",dt,M3]}],leading:[{leading:["none",o,...M()]}],"list-image":[{"list-image":["none",dt,ut]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",dt,ut]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[Sn,"from-font","auto",dt,Of]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Sn,"auto",dt,ut]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"tab-size":[{tab:[Ol,dt,ut]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",dt,ut]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",dt,ut]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:ie()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ol,dt,ut],radial:["",dt,ut],conic:["",Ol,dt,ut]},kce,wce]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:V()}],"gradient-via-pos":[{via:V()}],"gradient-to-pos":[{to:V()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-bs":[{"border-bs":Q()}],"border-w-be":[{"border-be":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Sn,dt,ut]}],"outline-w":[{outline:["",Sn,Jv,Of]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","inner","none",p,vj,gj]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",g,vj,gj]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Sn,Of]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",x,vj,gj]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Sn,dt,ut]}],"mix-blend":[{"mix-blend":[...oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Sn]}],"mask-image-linear-from-pos":[{"mask-linear-from":ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":ee()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":ee()}],"mask-image-t-to-pos":[{"mask-t-to":ee()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":ee()}],"mask-image-r-to-pos":[{"mask-r-to":ee()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":ee()}],"mask-image-b-to-pos":[{"mask-b-to":ee()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":ee()}],"mask-image-l-to-pos":[{"mask-l-to":ee()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":ee()}],"mask-image-x-to-pos":[{"mask-x-to":ee()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":ee()}],"mask-image-y-to-pos":[{"mask-y-to":ee()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[dt,ut]}],"mask-image-radial-from-pos":[{"mask-radial-from":ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":ee()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[Sn]}],"mask-image-conic-from-pos":[{"mask-conic-from":ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":ee()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:ie()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",dt,ut]}],filter:[{filter:["","none",dt,ut]}],blur:[{blur:se()}],brightness:[{brightness:[Sn,dt,ut]}],contrast:[{contrast:[Sn,dt,ut]}],"drop-shadow":[{"drop-shadow":["","none",y,vj,gj]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Sn,dt,ut]}],"hue-rotate":[{"hue-rotate":[Sn,dt,ut]}],invert:[{invert:["",Sn,dt,ut]}],saturate:[{saturate:[Sn,dt,ut]}],sepia:[{sepia:["",Sn,dt,ut]}],"backdrop-filter":[{"backdrop-filter":["","none",dt,ut]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[Sn,dt,ut]}],"backdrop-contrast":[{"backdrop-contrast":[Sn,dt,ut]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Sn,dt,ut]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Sn,dt,ut]}],"backdrop-invert":[{"backdrop-invert":["",Sn,dt,ut]}],"backdrop-opacity":[{"backdrop-opacity":[Sn,dt,ut]}],"backdrop-saturate":[{"backdrop-saturate":[Sn,dt,ut]}],"backdrop-sepia":[{"backdrop-sepia":["",Sn,dt,ut]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":M()}],"border-spacing-x":[{"border-spacing-x":M()}],"border-spacing-y":[{"border-spacing-y":M()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",dt,ut]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Sn,"initial",dt,ut]}],ease:[{ease:["linear","initial",N,dt,ut]}],delay:[{delay:[Sn,dt,ut]}],animate:[{animate:["none",A,dt,ut]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,dt,ut]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[dt,ut,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":["translate-none"],zoom:[{zoom:[Ol,dt,ut]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",dt,ut]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mbs":[{"scroll-mbs":M()}],"scroll-mbe":[{"scroll-mbe":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pbs":[{"scroll-pbs":M()}],"scroll-pbe":[{"scroll-pbe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",dt,ut]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Sn,Jv,Of,M3]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Te(...e){return Ace(w3(e))}const Ece=Tf(["group/button inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap border [font-family:inherit]","font-medium transition-[background-color,border-color,color,transform,box-shadow] duration-150 ease-out","outline-none select-none active:translate-y-[0.5px] focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45 disabled:shadow-none","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:"border-primary bg-primary font-semibold text-primary-on shadow-glow hover:border-primary-hover hover:bg-primary-hover",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"border-transparent bg-transparent text-subtle shadow-none hover:bg-control-hover hover:text-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive hover:bg-destructive-hover",dashed:"border-dashed border-border-strong bg-transparent text-muted-foreground shadow-none hover:border-primary hover:text-primary-fg",link:"border-transparent bg-transparent text-primary shadow-none underline-offset-4 hover:underline"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]","2xs":"h-4 rounded-pill px-1.5 text-[10px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]",icon:"h-[30px] w-[30px] rounded-md p-0","icon-2xs":"size-4 rounded-pill p-0","icon-xs":"size-6 rounded-sm p-0","icon-sm":"h-[26px] w-[26px] rounded-sm p-0","icon-lg":"size-9 rounded-md p-0",touch:"h-[46px] rounded-md px-4 text-[14px]","touch-sm":"h-[34px] rounded-sm px-3 text-[12.5px]","icon-touch":"size-9 rounded-full p-0"}},defaultVariants:{variant:"default",size:"default"}});function B({className:e,variant:t,size:n,...r}){return s.jsx(Lle,{"data-slot":"button",className:Te(Ece({variant:t,size:n}),e),...r})}const Tce="data-valid",Oce="data-invalid",xj={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},V3={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Rce={disabled:!1,...V3},Rl={valid(e){return e===null?null:e?{[Tce]:""}:{[Oce]:""}}},K3={invalid:void 0,name:void 0,validityData:{state:xj,errors:[],error:"",value:"",initialValue:null},setValidityData:Pn,disabled:void 0,setTouched:Pn,setDirty:Pn,setFilled:Pn,setFocused:Pn,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Rce,registerFieldControl:Pn,validation:{getValidationProps:(e,t=rr)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Pn,getInputControl:()=>null,commit:async()=>{},change:Pn}},QA=v.createContext(K3);function Oi(e=!0){const t=v.useContext(QA);if(t.setValidityData===Pn&&!e)throw new Error(En(28));return t}const q3=v.createContext(void 0);function ZA(e=!1){const t=v.useContext(q3);if(!t&&!e)throw new Error(En(86));return t}const Pce=v.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Pn,validationMode:"onSubmit",submitCountRef:{current:0}});function Ac(){return v.useContext(Pce)}let G3=0;function Ice(e,t="mui"){const[n,r]=v.useState(e),i=e||n;return v.useEffect(()=>{n==null&&(G3+=1,r(`${t}-${G3}`))},[n,t]),i}const Y3=BA.useId;function Yp(e,t){if(Y3!==void 0){const n=Y3();return e??(t?`${t}-${n}`:n)}return Ice(e,t)}function bs(e){return Yp(e,"base-ui")}const W3=v.createContext({controlId:void 0,registerControlId:Pn,resetControlId:Pn,labelId:void 0,setLabelId:Pn,messageIds:[],setMessageIds:Pn,getDescriptionProps:e=>e});function ii(){return v.useContext(W3)}const Mce=function(t){const n=bs(),[r,i]=v.useState(n),[o,c]=v.useState(),[d,f]=v.useState([]),h=r===void 0?n:r,p=hs(()=>new Map),{messageIds:g}=ii(),x=Fe((S,N)=>{const A=p.current;N===void 0?A.delete(S):A.set(S,N),i(E=>{if(A.size===0)return E;let O;for(const R of A.values()){if(R===E)return E;O===void 0&&(O=R)}return O})}),y=Fe(()=>{p.current.size===0&&i(n)}),j=v.useCallback(S=>{const N=S["aria-describedby"]?S["aria-describedby"].split(" "):[];return N.push(...g,...d),{...S,"aria-describedby":Array.from(new Set(N)).join(" ")||void 0}},[g,d]),w=v.useMemo(()=>({controlId:h,registerControlId:x,resetControlId:y,labelId:o,setLabelId:c,messageIds:d,setMessageIds:f,getDescriptionProps:j}),[h,x,y,o,c,d,f,j]);return s.jsx(W3.Provider,{value:w,children:t.children})};function JA(e,t,n,r=!0,i){const[o,c]=v.useState(),d=bs(i?`${i}-label`:void 0),f=e??t??o;return Ue(()=>{const h=e||t||!r?void 0:_ce(n.current,d);o!==h&&c(h)}),f}function _ce(e,t){const n=Dce(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Dce(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const i=e.nextElementSibling;if(i&&i.htmlFor===n)return i}const r=e.labels;return r&&r[0]}function Vu(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:o}=ii(),c=bs(),d=hs(()=>Symbol()),f=v.useRef(!1),h=v.useRef(!1),p=Fe(()=>{!f.current||i===Pn||(f.current=!1,i(d.current,void 0))});return Ue(()=>{if(!n||i===Pn){p();return}let g;if(t!==void 0)h.current=!0,g=t;else if(h.current)g=c;else{o();return}if(g===void 0){p();return}f.current=!0,i(d.current,g)},[t,n,i,o,c,d,p]),Ue(()=>p,[p]),(n?r:void 0)??t??c}function Lce(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:zce,platform:$ce,maxTouchPoints:Bce}=Lce(),bj=zce.toLowerCase(),ex=$ce.toLowerCase(),tx=/^i(os$|p)/.test(ex)||ex==="macintel"&&Bce>1,X3="android",yj=ex===X3||bj.includes(X3),Q3=!tx&&ex.startsWith("mac");ex.startsWith("win");const Fce=Q3||tx,Ec=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none"),Z3=!Ec&&bj.includes("firefox");!Ec&&bj.includes("chrom");const Uce=Fce,eE=/jsdom|happydom/.test(bj);function ys(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function nt(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Kp(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function or(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}const tE="data-base-ui-focusable",J3="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Pf="ArrowLeft",If="ArrowRight",nE="ArrowUp",wj="ArrowDown",rE="data-starting-style",Hce="data-ending-style",Vce={[rE]:""},Kce={[Hce]:""},io={transitionStatus(e){return e==="starting"?Vce:e==="ending"?Kce:null}},qce="data-open",Gce="data-closed",Yce="data-anchor-hidden",eB="data-popup-open",Wce="data-pressed",Xce={[eB]:""},Qce={[eB]:"",[Wce]:""},Zce={[qce]:""},Jce={[Gce]:""},eue={[Yce]:""},jj={open(e){return e?Xce:null}},sE={open(e){return e?Qce:null}},Wp={open(e){return e?Zce:Jce},anchorHidden(e){return e?eue:null}},aE={...Wp,...io},iE="data-trigger-disabled";function Sj(e,t){if(!Cn(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute(iE);for(const[,r]of t.entries())if(nt(r,n))return!r.hasAttribute(iE);return!1}function oE(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function tue(e){return e.matches("html,body")}function kj(e){return nr(e)&&e.matches(J3)}function nue(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${J3}`)!=null}function lE(e){return e?e.getAttribute("role")==="combobox"&&kj(e):!1}function Nj(e){if(!e||eE)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function Cj(e){return e?e.hasAttribute(tE)?e:e.querySelector(`[${tE}]`)||e:null}function Ku(e,t,n=!0){return e.filter(i=>i.parentId===t).flatMap(i=>[...!n||i.context?.open?[i]:[],...Ku(e,i.id,n)])}function tB(e,t){let n=[],r=e.find(i=>i.id===t)?.parentId;for(;r;){const i=e.find(o=>o.id===r);r=i?.parentId,i&&(n=n.concat(i))}return n}function _s(e){e.preventDefault(),e.stopPropagation()}function rue(e){return"nativeEvent"in e}function Aj(e){return e.pointerType===""&&e.isTrusted?!0:yj&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function cE(e){return eE?!1:!yj&&e.width===0&&e.height===0||yj&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function qu(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function sue(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Xp=Math.min,Tc=Math.max,Ej=Math.round,Mf=Math.floor,Oc=e=>({x:e,y:e}),aue={left:"right",right:"left",bottom:"top",top:"bottom"};function nB(e,t,n){return Tc(e,Xp(t,n))}function Gu(e,t){return typeof e=="function"?e(t):e}function oo(e){return e.split("-")[0]}function Rc(e){return e.split("-")[1]}function uE(e){return e==="x"?"y":"x"}function dE(e){return e==="y"?"height":"width"}function lo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fE(e){return uE(lo(e))}function iue(e,t,n){n===void 0&&(n=!1);const r=Rc(e),i=fE(e),o=dE(i);let c=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=Tj(c)),[c,Tj(c)]}function oue(e){const t=Tj(e);return[hE(e),t,hE(t)]}function hE(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const rB=["left","right"],sB=["right","left"],lue=["top","bottom"],cue=["bottom","top"];function uue(e,t,n){switch(e){case"top":case"bottom":return n?t?sB:rB:t?rB:sB;case"left":case"right":return t?lue:cue;default:return[]}}function due(e,t,n,r){const i=Rc(e);let o=uue(oo(e),n==="start",r);return i&&(o=o.map(c=>c+"-"+i),t&&(o=o.concat(o.map(hE)))),o}function Tj(e){const t=oo(e);return aue[t]+e.slice(t.length)}function fue(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function aB(e){return typeof e!="number"?fue(e):{top:e,right:e,bottom:e,left:e}}function nx(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Oj(e,t,n){return Math.floor(e/t)!==n}function Yu(e,t){return t<0||t>=e.length}function Rj(e,t){return Js(e.current,{disabledIndices:t})}function pE(e,t){return Js(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Js(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let o=t;do o+=n?-i:i;while(o>=0&&o<=e.length-1&&Wu(e,o,r));return o}function hue(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:o,cols:c,disabledIndices:d,minIndex:f,maxIndex:h,prevIndex:p,stopEvent:g=!1}){let x=p,y;if(t.key===nE?y="up":t.key===wj&&(y="down"),y){const j=[],w=[];let S=!1,N=0;{let _=null,I=-1;e.forEach((L,D)=>{if(L==null)return;N+=1;const z=L.closest('[role="row"]');z&&(S=!0),(z!==_||I===-1)&&(_=z,I+=1,j[I]=[]),j[I].push(D),w[D]=I})}let A=!1,E=0;if(S)for(const _ of j){const I=_.length;I>E&&(E=I),I!==c&&(A=!0)}const O=A&&N{if(!A||p===-1)return;const I=w[p];if(I==null)return;const L=j[I].indexOf(p),D=_==="up"?-1:1;for(let z=I+D,G=0;G=j.length){if(!r||O)return;if(z=z<0?j.length-1:0,i){const Y=Math.min(L,j[z].length-1),F=j[z][Y]??j[z][0],K=i(t,p,F);z=w[K]??z}}const X=j[z];for(let Y=Math.min(L,X.length-1);Y>=0;Y-=1){const F=X[Y];if(!Wu(e,F,d))return F}}},P=_=>{if(!O||p===-1)return;const I=p%R,L=_==="up"?-R:R,D=h-h%R,z=Mf(h/R)+1;for(let G=p-I+L,X=0;Xh){if(!r)return;G=G<0?D:0}const Y=Math.min(G+R-1,h);for(let F=Math.min(G+I,Y);F>=G;F-=1)if(!Wu(e,F,d))return F}};g&&_s(t);const M=T(y)??P(y);if(M!==void 0)x=M;else if(p===-1)x=y==="up"?h:f;else if(x=Js(e,{startingIndex:p,amount:R,decrement:y==="up",disabledIndices:d}),r){if(y==="up"&&(p-R_?L:L-R,i&&(x=i(t,p,x))}y==="down"&&p+R>h&&(x=Js(e,{startingIndex:p%R-R,amount:R,disabledIndices:d}),i&&(x=i(t,p,x)))}Yu(e,x)&&(x=p)}if(n==="both"){const j=Mf(p/c);t.key===(o?Pf:If)&&(g&&_s(t),p%c!==c-1?(x=Js(e,{startingIndex:p,disabledIndices:d}),r&&Oj(x,c,j)&&(x=Js(e,{startingIndex:p-p%c-1,disabledIndices:d}),i&&(x=i(t,p,x)))):r&&(x=Js(e,{startingIndex:p-p%c-1,disabledIndices:d}),i&&(x=i(t,p,x))),Oj(x,c,j)&&(x=p)),t.key===(o?If:Pf)&&(g&&_s(t),p%c!==0?(x=Js(e,{startingIndex:p,decrement:!0,disabledIndices:d}),r&&Oj(x,c,j)&&(x=Js(e,{startingIndex:p+(c-p%c),decrement:!0,disabledIndices:d}),i&&(x=i(t,p,x)))):r&&(x=Js(e,{startingIndex:p+(c-p%c),decrement:!0,disabledIndices:d}),i&&(x=i(t,p,x))),Oj(x,c,j)&&(x=p));const w=Mf(h/c)===j;Yu(e,x)&&(r&&w?(x=t.key===(o?If:Pf)?h:Js(e,{startingIndex:p-p%c-1,disabledIndices:d}),i&&(x=i(t,p,x))):x=p)}return x}function Wu(e,t,n){if(typeof n=="function"?n(t):n?.includes(t)??!1)return!0;const i=e[t];return i?!Pj(i)||i.matches(":disabled")?!0:!n&&(i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"):!1}function pue(e){return e.visibility==="hidden"||e.visibility==="collapse"}function Pj(e,t=e?si(e):null){return!e||!e.isConnected||!t||pue(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const mue='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function gue(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return Kp(n)?n.host:null}function mE(e){for(const t of Array.from(e.children))if(pa(t)==="summary")return t;return null}function vue(e,t){const n=mE(t);return!!n&&(e===n||nt(n,e))}function iB(e){const t=e?pa(e):"";return e!=null&&e.matches(mue)&&(t!=="summary"||e.parentElement!=null&&pa(e.parentElement)==="details"&&mE(e.parentElement)===e)&&(t!=="details"||mE(e)==null)&&(t!=="input"||e.type!=="hidden")}function oB(e){if(!iB(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=gue(t)){const n=t!==e,r=pa(t)==="slot";if(t.hasAttribute("inert")||n&&pa(t)==="details"&&!t.open&&!vue(e,t)||t.hasAttribute("hidden")||!r&&!xue(t,n))return!1}return!0}function xue(e,t){const n=si(e);return t?n.display!=="none":Pj(e,n)}function lB(e){const t=e.tabIndex;if(t<0){const n=pa(e);if(n==="details"||n==="audio"||n==="video"||nr(e)&&e.isContentEditable)return 0}return t}function gE(e){if(pa(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function bue(e,t){const n=gE(e);if(!n)return!0;const r=t.find(i=>{const o=gE(i);return o?.name===n.name&&o.form===n.form&&o.checked});return r?r===n:t.find(i=>{const o=gE(i);return o?.name===n.name&&o.form===n.form})===n}function cB(e){if(nr(e)&&pa(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return nr(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function uB(e,t){cB(e).forEach(n=>{iB(n)&&t.push(n),uB(n,t)})}function dB(e,t,n){cB(e).forEach(r=>{nr(r)&&r.matches(t)&&n.push(r),dB(r,t,n)})}function vE(e){return oB(e)&&lB(e)>=0}function fB(e){const t=[];return uB(e,t),t.filter(oB)}function rx(e){const t=fB(e);return t.filter(n=>lB(n)>=0&&bue(n,t))}function hB(e,t){const n=rx(e),r=n.length;if(r===0)return;const i=ys(vn(e)),o=n.indexOf(i),c=o===-1?t===1?0:r-1:o+t;return n[c]}function xE(e){return hB(vn(e).body,1)||e}function pB(e){return hB(vn(e).body,-1)||e}function mB(e,t){if(!e)return null;const n=rx(vn(e).body),r=n.length;if(r===0)return null;const i=n.indexOf(e);if(i===-1)return null;const o=(i+t+r)%r;return n[o]}function yue(e){return mB(e,1)}function wue(e){return mB(e,-1)}function Qp(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!nt(n,r)}function jue(e){rx(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function gB(e){const t=[];dB(e,"[data-tabindex]",t),t.forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Sue(e,t){const n=bs(e);return Ue(()=>(t(n),()=>{t(r=>r===n?void 0:r)}),[n,t]),n}function kue(e={}){const{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:o}=e,{controlId:c,setLabelId:d}=ii(),f=Fe(y=>{d(y),i?.(y)}),h=Sue(t,f),p=c??n;function g(y){if(o){o(y,p);return}if(!p)return;const j=vn(y.currentTarget).getElementById(p);nr(j)&&Nue(j)}function x(y){or(y.nativeEvent)?.closest("button,input,select,textarea")||(!y.defaultPrevented&&y.detail>1&&y.preventDefault(),!r&&g(y))}return r?{id:h,htmlFor:p,onMouseDown:x}:{id:h,onClick:x,onPointerDown(y){y.preventDefault()}}}function Nue(e){e.focus({focusVisible:!0})}function Ij(e){v.useEffect(e,Ti)}const sx=0;class oi{constructor(){on(this,"currentId",sx);on(this,"clear",()=>{this.currentId!==sx&&(clearTimeout(this.currentId),this.currentId=sx)});on(this,"disposeEffect",()=>this.clear)}static create(){return new oi}start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=sx,n()},t)}isStarted(){return this.currentId!==sx}}function Ds(){const e=hs(oi.create).current;return Ij(e.disposeEffect),e}function bE(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const yE=Object.keys(xj);function vB(e,t){return e.matches(":disabled")?!1:!t||e.form===t?!0:e.form===null&&!e.hasAttribute("form")}function xB(e,t){let n=null;for(const r of e.keys())if(vB(r,t)){if(!r.validity.valid)return r;n??(n=r)}return n}function bB(e){return{...xj,valid:!e,customError:e}}function wE(e){return e&&e.validationMessage?[e.validationMessage]:[]}function Cue(e){const{elementRef:t,formRef:n}=Ac(),{setValidityData:r,validate:i,validityData:o,validationDebounceTime:c,invalid:d,markedDirtyRef:f,state:h,shouldValidateOnChange:p,validationMode:g,registeredFieldIdRef:x}=e,{controlId:y,getDescriptionProps:j}=ii(),w=Ds(),S=v.useRef(null),N=hs(()=>new Map).current,A=v.useRef(0),E=v.useRef(null),O=v.useCallback((_,I)=>(N.set(_,I),()=>{N.delete(_)}),[N]),R=Fe(()=>{const _=xB(N,t.current);return _&&N.get(_)?.controlRef.current||null}),T=Fe(async(_,I=!1)=>{A.current+=1;const L=A.current;function D(V,H=d){const Q=x.current??y;if(Q==null)return;const J=n.current.fields.get(Q);if(!J)return;const oe=bE(V,H);n.current.fields.set(Q,{...J,validityData:oe})}function z(V,H){const Q=V.valid===!1?H:[];return{value:_,state:V,error:Q[0]??"",errors:Q,initialValue:o.initialValue}}function G(V,H){const Q=V.validity.customError?V.validationMessage:"",J=H.replace(/\r\n?/g,`
+`+b.stack}}var Ht=Object.prototype.hasOwnProperty,an=e.unstable_scheduleCallback,Mt=e.unstable_cancelCallback,_t=e.unstable_shouldYield,Ve=e.unstable_requestPaint,bt=e.unstable_now,Ut=e.unstable_getCurrentPriorityLevel,Yt=e.unstable_ImmediatePriority,yt=e.unstable_UserBlockingPriority,un=e.unstable_NormalPriority,Tn=e.unstable_LowPriority,$r=e.unstable_IdlePriority,Sr=e.log,kr=e.unstable_setDisableYieldValue,ur=null,Fn=null;function Gr(l){if(typeof Sr=="function"&&kr(l),Fn&&typeof Fn.setStrictMode=="function")try{Fn.setStrictMode(ur,l)}catch{}}var yn=Math.clz32?Math.clz32:Ye,Le=Math.log,Ze=Math.LN2;function Ye(l){return l>>>=0,l===0?32:31-(Le(l)/Ze|0)|0}var Kt=256,ln=262144,Gt=4194304;function Rt(l){var u=l&42;if(u!==0)return u;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&-l;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function vr(l,u,m){var b=l.pendingLanes;if(b===0)return 0;var k=0,C=l.suspendedLanes,$=l.pingedLanes;l=l.warmLanes;var Z=b&134217727;return Z!==0?(b=Z&~C,b!==0?k=Rt(b):($&=Z,$!==0?k=Rt($):m||(m=Z&~l,m!==0&&(k=Rt(m))))):(Z=b&~C,Z!==0?k=Rt(Z):$!==0?k=Rt($):m||(m=b&~l,m!==0&&(k=Rt(m)))),k===0?0:u!==0&&u!==k&&(u&C)===0&&(C=k&-k,m=u&-u,C>=m||C===32&&(m&4194048)!==0)?u:k}function Qt(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function gs(l,u){(u&8)!==0&&(u|=u&32);var m=l.entangledLanes;if(m!==0)for(l=l.entanglements,m&=u;0m;m++)u.push(l);return u}function us(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function bl(l,u,m,b,k,C){var $=l.pendingLanes;l.pendingLanes=m,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=m,l.entangledLanes&=m,l.errorRecoveryDisabledLanes&=m,l.shellSuspendCounter=0;var Z=l.entanglements,fe=l.expirationTimes,Ce=l.hiddenUpdates;for(m=$&~m;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hn=!1;if(Wt)try{var Nr={};Object.defineProperty(Nr,"passive",{get:function(){Hn=!0}}),window.addEventListener("test",Nr,Nr),window.removeEventListener("test",Nr,Nr)}catch{Hn=!1}var dr=null,Cr=null,vs=null;function wi(){if(vs)return vs;var l,u=Cr,m=u.length,b,k="value"in dr?dr.value:dr.textContent,C=k.length;for(l=0;l=Cw),hse=" ",pse=!1;function mse(l,u){switch(l){case"keyup":return mYe.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gse(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var pv=!1;function vYe(l,u){switch(l){case"compositionend":return gse(u);case"keypress":return u.which!==32?null:(pse=!0,hse);case"textInput":return l=u.data,l===hse&&pse?null:l;default:return null}}function xYe(l,u){if(pv)return l==="compositionend"||!$L&&mse(l,u)?(l=wi(),vs=Cr=dr=null,pv=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function kse(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Nse(l,u){var m=kse(l);l=0;for(var b;m;){if(m.nodeType===3){if(b=l+m.textContent.length,l<=u&&b>=u)return{node:m,offset:u-l};l=b}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=kse(m)}}function Cse(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?Cse(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Ase(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var u=UL(l.document);u instanceof l.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)l=u.contentWindow;else break;u=UL(l.document)}return u}function HL(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}var CYe=Wt&&"documentMode"in document&&11>=document.documentMode,mv=null,VL=null,Ow=null,KL=!1;function Ese(l,u,m){var b=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;KL||mv==null||mv!==UL(b)||(b=mv,"selectionStart"in b&&HL(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Ow&&Tw(Ow,b)||(Ow=b,b=vA(VL,"onSelect"),0>=$,k-=$,mc=1<<32-yn(u)+k|m<qt?(Is=Bt,Bt=null):Is=Bt.sibling;var Vn=je(ke,Bt,Ee[qt],ze);if(Vn===null){Bt===null&&(Bt=Is);break}l&&Bt&&Vn.alternate===null&&u(ke,Bt),be=C(Vn,be,qt),Dn===null?ct=Vn:Dn.sibling=Vn,Dn=Vn,Bt=Is}if(qt===Ee.length)return m(ke,Bt),Nn&&Tu(ke,qt),ct;if(Bt===null){for(;qtqt?(Is=Bt,Bt=null):Is=Bt.sibling;var Ef=je(ke,Bt,Vn.value,ze);if(Ef===null){Bt===null&&(Bt=Is);break}l&&Bt&&Ef.alternate===null&&u(ke,Bt),be=C(Ef,be,qt),Dn===null?ct=Ef:Dn.sibling=Ef,Dn=Ef,Bt=Is}if(Vn.done)return m(ke,Bt),Nn&&Tu(ke,qt),ct;if(Bt===null){for(;!Vn.done;qt++,Vn=Ee.next())Vn=$e(ke,Vn.value,ze),Vn!==null&&(be=C(Vn,be,qt),Dn===null?ct=Vn:Dn.sibling=Vn,Dn=Vn);return Nn&&Tu(ke,qt),ct}for(Bt=b(Bt);!Vn.done;qt++,Vn=Ee.next())Vn=Oe(Bt,ke,qt,Vn.value,ze),Vn!==null&&(l&&(Is=Vn.alternate,Is!==null&&Bt.delete(Is.key===null?qt:Is.key)),be=C(Vn,be,qt),Dn===null?ct=Vn:Dn.sibling=Vn,Dn=Vn);return l&&Bt.forEach(function(vXe){return u(ke,vXe)}),Nn&&Tu(ke,qt),ct}function gn(ke,be,Ee,ze){if(typeof Ee=="object"&&Ee!==null&&Ee.type===L&&Ee.key===null&&Ee.props.ref===void 0&&(Ee=Ee.props.children),typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case _:e:{for(var ct=Ee.key;be!==null;){if(be.key===ct){if(ct=Ee.type,ct===L){if(be.tag===7){m(ke,be.sibling),ze=k(be,Ee.props.children),cf(ze,Ee),ze.return=ke,ke=ze;break e}}else if(be.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===q&&_p(ct)===be.type){m(ke,be.sibling),ze=k(be,Ee.props),cf(ze,Ee),ze.return=ke,ke=ze;break e}m(ke,be);break}else u(ke,be);be=be.sibling}Ee.type===L?(ze=Ep(Ee.props.children,ke.mode,ze,Ee.key),cf(ze,Ee),ze.return=ke,ke=ze):(ze=jC(Ee.type,Ee.key,Ee.props,null,ke.mode,ze),cf(ze,Ee),ze.return=ke,ke=ze)}return $(ke);case I:e:{for(ct=Ee.key;be!==null;){if(be.key===ct)if(be.tag===4&&be.stateNode.containerInfo===Ee.containerInfo&&be.stateNode.implementation===Ee.implementation){m(ke,be.sibling),ze=k(be,Ee.children||[]),ze.return=ke,ke=ze;break e}else{m(ke,be);break}else u(ke,be);be=be.sibling}ze=ZL(Ee,ke.mode,ze),ze.return=ke,ke=ze}return $(ke);case q:return Ee=_p(Ee),gn(ke,be,Ee,ze)}if(se(Ee))return et(ke,be,Ee,ze);if(J(Ee)){if(ct=J(Ee),typeof ct!="function")throw Error(r(150));return Ee=ct.call(Ee),At(ke,be,Ee,ze)}if(typeof Ee.then=="function")return gn(ke,be,PC(Ee),ze);if(Ee.$$typeof===X)return gn(ke,be,EC(ke,Ee),ze);IC(ke,Ee)}return typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint"?(Ee=""+Ee,be!==null&&be.tag===6?(m(ke,be.sibling),ze=k(be,Ee),ze.return=ke,ke=ze):(m(ke,be),ze=QL(Ee,ke.mode,ze),ze.return=ke,ke=ze),$(ke)):m(ke,be)}return function(ke,be,Ee,ze){try{Dw=0;var ct=gn(ke,be,Ee,ze);return kv=null,ct}catch(Bt){if(Bt===Sv||Bt===OC)throw Bt;var Dn=ji(29,Bt,null,ke.mode);return Dn.lanes=ze,Dn.return=ke,Dn}}}var Lp=Zse(!0),Jse=Zse(!1),uf=!1;function lz(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function cz(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function df(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function ff(l,u,m){var b=l.updateQueue;if(b===null)return null;if(b=b.shared,(er&2)!==0){var k=b.pending;return k===null?u.next=u:(u.next=k.next,k.next=u),b.pending=u,u=wC(l),Dse(l,null,m),u}return yC(l,b,u,m),wC(l)}function Lw(l,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194048)!==0)){var b=u.lanes;b&=l.pendingLanes,m|=b,u.lanes=m,mp(l,m)}}function uz(l,u){var m=l.updateQueue,b=l.alternate;if(b!==null&&(b=b.updateQueue,m===b)){var k=null,C=null;if(m=m.firstBaseUpdate,m!==null){do{var $={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};C===null?k=C=$:C=C.next=$,m=m.next}while(m!==null);C===null?k=C=u:C=C.next=u}else k=C=u;m={baseState:b.baseState,firstBaseUpdate:k,lastBaseUpdate:C,shared:b.shared,callbacks:b.callbacks},l.updateQueue=m;return}l=m.lastBaseUpdate,l===null?m.firstBaseUpdate=u:l.next=u,m.lastBaseUpdate=u}var dz=!1;function zw(){if(dz){var l=jv;if(l!==null)throw l}}function $w(l,u,m,b){dz=!1;var k=l.updateQueue;uf=!1;var C=k.firstBaseUpdate,$=k.lastBaseUpdate,Z=k.shared.pending;if(Z!==null){k.shared.pending=null;var fe=Z,Ce=fe.next;fe.next=null,$===null?C=Ce:$.next=Ce,$=fe;var Pe=l.alternate;Pe!==null&&(Pe=Pe.updateQueue,Z=Pe.lastBaseUpdate,Z!==$&&(Z===null?Pe.firstBaseUpdate=Ce:Z.next=Ce,Pe.lastBaseUpdate=fe))}if(C!==null){var $e=k.baseState;$=0,Pe=Ce=fe=null,Z=C;do{var je=Z.lane&-536870913,Oe=je!==Z.lane;if(Oe?(_n&je)===je:(b&je)===je){je!==0&&je===Ip&&(dz=!0),Pe!==null&&(Pe=Pe.next={lane:0,tag:Z.tag,payload:Z.payload,callback:null,next:null});e:{var et=l,At=Z;je=u;var gn=m;switch(At.tag){case 1:if(et=At.payload,typeof et=="function"){$e=et.call(gn,$e,je);break e}$e=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=At.payload,je=typeof et=="function"?et.call(gn,$e,je):et,je==null)break e;$e=P({},$e,je);break e;case 2:uf=!0}}je=Z.callback,je!==null&&(l.flags|=64,Oe&&(l.flags|=8192),Oe=k.callbacks,Oe===null?k.callbacks=[je]:Oe.push(je))}else Oe={lane:je,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},Pe===null?(Ce=Pe=Oe,fe=$e):Pe=Pe.next=Oe,$|=je;if(Z=Z.next,Z===null){if(Z=k.shared.pending,Z===null)break;Oe=Z,Z=Oe.next,Oe.next=null,k.lastBaseUpdate=Oe,k.shared.pending=null}}while(!0);Pe===null&&(fe=$e),k.baseState=fe,k.firstBaseUpdate=Ce,k.lastBaseUpdate=Pe,C===null&&(k.shared.lanes=0),bf|=$,l.lanes=$,l.memoizedState=$e}}function eae(l,u){if(typeof l!="function")throw Error(r(191,l));l.call(u)}function tae(l,u){var m=l.callbacks;if(m!==null)for(l.callbacks=null,l=0;lC?C:8;var $=le.T,Z={};Z.types=$!==null?$.types:null,le.T=Z,Rz(l,!1,u,m);try{var fe=k(),Ce=le.S;if(Ce!==null&&Ce(Z,fe),fe!==null&&typeof fe=="object"&&typeof fe.then=="function"){var Pe=LYe(fe,b);Hw(l,u,Pe,so(l))}else Hw(l,u,b,so(l))}catch($e){Hw(l,u,{then:function(){},status:"rejected",reason:$e},so())}finally{te.p=C,$!==null&&Z.types!==null&&($.types=Z.types),le.T=$}}function HYe(){}function Tz(l,u,m,b){if(l.tag!==5)throw Error(r(476));var k=Iae(l).queue;Pae(l,k,u,re,m===null?HYe:function(){return Mae(l),m(b)})}function Iae(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:re,baseState:re,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Iu,lastRenderedState:re},next:null};var m={};return u.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Iu,lastRenderedState:m},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function Mae(l){var u=Iae(l);u.next===null&&(u=l.alternate.memoizedState),Hw(l,u.next.queue,{},so())}function Oz(){return Sa(qv)}function _ae(){return xs().memoizedState}function Dae(){return xs().memoizedState}function VYe(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var m=so();l=df(m);var b=ff(u,l,m);b!==null&&(Ci(b,u,m),Lw(b,u,m)),u={cache:sz()},l.payload=u;return}u=u.return}}function KYe(l,u,m){var b=so();m={lane:b,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},HC(l)?zae(u,m):(m=WL(l,u,m,b),m!==null&&(Ci(m,l,b),$ae(m,u,b)))}function Lae(l,u,m){var b=so();Hw(l,u,m,b)}function Hw(l,u,m,b){var k={lane:b,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null};if(HC(l))zae(u,k);else{var C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=u.lastRenderedReducer,C!==null))try{var $=u.lastRenderedState,Z=C($,m);if(k.hasEagerState=!0,k.eagerState=Z,Ji(Z,$))return yC(l,u,k,0),Ar===null&&bC(),!1}catch{}if(m=WL(l,u,k,b),m!==null)return Ci(m,l,b),$ae(m,u,b),!0}return!1}function Rz(l,u,m,b){if(b={lane:2,revertLane:w$(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},HC(l)){if(u)throw Error(r(479))}else u=WL(l,m,b,2),u!==null&&Ci(u,l,2)}function HC(l){var u=l.alternate;return l===mn||u!==null&&u===mn}function zae(l,u){Nv=DC=!0;var m=l.pending;m===null?u.next=u:(u.next=m.next,m.next=u),l.pending=u}function $ae(l,u,m){if((m&4194048)!==0){var b=u.lanes;b&=l.pendingLanes,m|=b,u.lanes=m,mp(l,m)}}var VC={readContext:Sa,use:$C,useCallback:ds,useContext:ds,useEffect:ds,useImperativeHandle:ds,useLayoutEffect:ds,useInsertionEffect:ds,useMemo:ds,useReducer:ds,useRef:ds,useState:ds,useDebugValue:ds,useDeferredValue:ds,useTransition:ds,useSyncExternalStore:ds,useId:ds,useHostTransitionStatus:ds,useFormState:ds,useActionState:ds,useOptimistic:ds,useMemoCache:ds,useCacheRefresh:ds,useEffectEvent:ds},Bae={readContext:Sa,use:$C,useCallback:function(l,u){return ti().memoizedState=[l,u===void 0?null:u],l},useContext:Sa,useEffect:Sae,useImperativeHandle:function(l,u,m){m=m!=null?m.concat([l]):null,FC(4194308,4,Aae.bind(null,u,l),m)},useLayoutEffect:function(l,u){return FC(4194308,4,l,u)},useInsertionEffect:function(l,u){FC(4,2,l,u)},useMemo:function(l,u){var m=ti();u=u===void 0?null:u;var b=l();if(zp){Gr(!0);try{l()}finally{Gr(!1)}}return m.memoizedState=[b,u],b},useReducer:function(l,u,m){var b=ti();if(m!==void 0){var k=m(u);if(zp){Gr(!0);try{m(u)}finally{Gr(!1)}}}else k=u;return b.memoizedState=b.baseState=k,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:k},b.queue=l,l=l.dispatch=KYe.bind(null,mn,l),[b.memoizedState,l]},useRef:function(l){var u=ti();return l={current:l},u.memoizedState=l},useState:function(l){l=kz(l);var u=l.queue,m=Lae.bind(null,mn,u);return u.dispatch=m,[l.memoizedState,m]},useDebugValue:Az,useDeferredValue:function(l,u){var m=ti();return Ez(m,l,u)},useTransition:function(){var l=kz(!1);return l=Pae.bind(null,mn,l.queue,!0,!1),ti().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,m){var b=mn,k=ti();if(Nn){if(m===void 0)throw Error(r(407));m=m()}else{if(m=u(),Ar===null)throw Error(r(349));(_n&127)!==0||oae(b,u,m)}k.memoizedState=m;var C={value:m,getSnapshot:u};return k.queue=C,Sae(cae.bind(null,b,C,l),[l]),b.flags|=2048,Av(9,{destroy:void 0},lae.bind(null,b,C,m,u),null),m},useId:function(){var l=ti(),u=Ar.identifierPrefix;if(Nn){var m=gc,b=mc;m=(b&~(1<<32-yn(b)-1)).toString(32)+m,u="_"+u+"R_"+m,m=LC++,0<\/script>",C=C.removeChild(C.firstChild);break;case"select":C=typeof b.is=="string"?$.createElement("select",{is:b.is}):$.createElement("select"),b.multiple?C.multiple=!0:b.size&&(C.size=b.size);break;default:C=typeof b.is=="string"?$.createElement(k,{is:b.is}):$.createElement(k)}}C[Xs]=u,C[ja]=b;e:for($=u.child;$!==null;){if($.tag===5||$.tag===6)C.appendChild($.stateNode);else if($.tag!==4&&$.tag!==27&&$.child!==null){$.child.return=$,$=$.child;continue}if($===u)break e;for(;$.sibling===null;){if($.return===null||$.return===u)break e;$=$.return}$.sibling.return=$.return,$=$.sibling}u.stateNode=C;e:switch(Aa(C,k,b),k){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&_u(u)}}return Ir(u),u.subtreeFlags&=-33554433,Vz(u,u.type,l===null?null:l.memoizedProps,u.pendingProps,m),null;case 6:if(l&&u.stateNode!=null)l.memoizedProps!==b&&_u(u);else{if(typeof b!="string"&&u.stateNode===null)throw Error(r(166));if(l=de.current,wv(u)){if(l=u.stateNode,m=u.memoizedProps,b=null,k=ua,k!==null)switch(k.tag){case 27:case 5:b=k.memoizedProps}l[Xs]=u,l=!!(l.nodeValue===m||b!==null&&b.suppressHydrationWarning===!0||coe(l.nodeValue,m)),l||of(u,!0)}else l=nj(l).createTextNode(b),l[Xs]=u,u.stateNode=l}return Ir(u),null;case 31:if(m=u.memoizedState,l===null||l.memoizedState!==null){if(b=wv(u),m!==null){if(l===null){if(!b)throw Error(r(318));if(l=u.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(r(557));l[Xs]=u}else Tp(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Ir(u),l=!1}else m=tz(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=m),l=!0;if(!l)return u.flags&256?(eo(u),u):(eo(u),null);if((u.flags&128)!==0)throw Error(r(558))}return Ir(u),null;case 13:if(b=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(k=wv(u),b!==null&&b.dehydrated!==null){if(l===null){if(!k)throw Error(r(318));if(k=u.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[Xs]=u}else Tp(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Ir(u),k=!1}else k=tz(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=k),k=!0;if(!k)return u.flags&256?(eo(u),u):(eo(u),null)}return eo(u),(u.flags&128)!==0?(u.lanes=m,u):(m=b!==null,l=l!==null&&l.memoizedState!==null,m&&(b=u.child,k=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(k=b.alternate.memoizedState.cachePool.pool),C=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(C=b.memoizedState.cachePool.pool),C!==k&&(b.flags|=2048)),m!==l&&m&&(u.child.flags|=8192),XC(u,u.updateQueue),Ir(u),null);case 4:return xe(),l===null&&N$(u.stateNode.containerInfo),u.flags|=67108864,Ir(u),null;case 10:return Ru(u.type),Ir(u),null;case 19:if(mz(u),b=u.memoizedState,b===null)return Ir(u),null;if(k=(u.flags&128)!==0,C=b.rendering,C===null)if(k)Kw(b,!1);else{if(fs!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(C=_C(l),C!==null){for(u.flags|=128,Kw(b,!1),l=C.updateQueue,u.updateQueue=l,XC(u,l),u.subtreeFlags=0,l=m,m=u.child;m!==null;)Lse(m,l),m=m.sibling;return Bw(u,Na.current&1|2),Nn&&Tu(u,b.treeForkCount),u.child}l=l.sibling}b.tail!==null&&bt()>lA&&(u.flags|=128,k=!0,Kw(b,!1),u.lanes=4194304)}else{if(!k)if(l=_C(C),l!==null){if(u.flags|=128,k=!0,l=l.updateQueue,u.updateQueue=l,XC(u,l),Kw(b,!0),b.tail===null&&b.tailMode!=="collapsed"&&b.tailMode!=="visible"&&!C.alternate&&!Nn)return Ir(u),null}else 2*bt()-b.renderingStartTime>lA&&m!==536870912&&(u.flags|=128,k=!0,Kw(b,!1),u.lanes=4194304);b.isBackwards?(C.sibling=u.child,u.child=C):(l=b.last,l!==null?l.sibling=C:u.child=C,b.last=C)}if(b.tail!==null){l=b.tail;e:{for(m=l;m!==null;){if(m.alternate!==null){m=!1;break e}m=m.sibling}m=!0}return b.rendering=l,b.tail=l.sibling,b.renderingStartTime=bt(),l.sibling=null,C=Na.current,C=k?C&1|2:C&1,b.tailMode==="visible"||b.tailMode==="collapsed"||!m||Nn?Bw(u,C):(m=C,ce(ka,u),ce(Na,m),Ha===null&&(Ha=u)),Nn&&Tu(u,b.treeForkCount),l}return Ir(u),null;case 22:case 23:return eo(u),hz(),b=u.memoizedState!==null,l!==null?l.memoizedState!==null!==b&&(u.flags|=8192):b&&(u.flags|=8192),b?(m&536870912)!==0&&(u.flags&128)===0&&(Ir(u),u.subtreeFlags&6&&(u.flags|=8192)):Ir(u),m=u.updateQueue,m!==null&&XC(u,m.retryQueue),m=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),b=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(b=u.memoizedState.cachePool.pool),b!==m&&(u.flags|=2048),l!==null&&me(Mp),null;case 24:return m=null,l!==null&&(m=l.memoizedState.cache),u.memoizedState.cache!==m&&(u.flags|=2048),Ru(Os),Ir(u),null;case 25:return null;case 30:return u.flags|=33554432,Ir(u),null}throw Error(r(156,u.tag))}function ZYe(l,u){switch(JL(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Ru(Os),xe(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return we(u),null;case 31:if(u.memoizedState!==null){if(eo(u),u.alternate===null)throw Error(r(340));Tp()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 13:if(eo(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(r(340));Tp()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return mz(u),l=u.flags,l&65536?(u.flags=l&-65537|128,l=u.memoizedState,l!==null&&(l.rendering=null,l.tail=null),u.flags|=4,u):null;case 4:return xe(),null;case 10:return Ru(u.type),null;case 22:case 23:return eo(u),hz(),l!==null&&me(Mp),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return Ru(Os),null;case 25:return null;default:return null}}function die(l,u){switch(JL(u),u.tag){case 3:Ru(Os),xe();break;case 26:case 27:case 5:we(u);break;case 4:xe();break;case 31:u.memoizedState!==null&&eo(u);break;case 13:eo(u);break;case 19:mz(u);break;case 10:Ru(u.type);break;case 22:case 23:eo(u),hz(),l!==null&&me(Mp);break;case 24:Ru(Os)}}function qw(l,u){try{var m=u.updateQueue,b=m!==null?m.lastEffect:null;if(b!==null){var k=b.next;m=k;do{if((m.tag&l)===l){b=void 0;var C=m.create,$=m.inst;b=C(),$.destroy=b}m=m.next}while(m!==k)}}catch(Z){hr(u,u.return,Z)}}function gf(l,u,m){try{var b=u.updateQueue,k=b!==null?b.lastEffect:null;if(k!==null){var C=k.next;b=C;do{if((b.tag&l)===l){var $=b.inst,Z=$.destroy;if(Z!==void 0){$.destroy=void 0,k=u;var fe=m,Ce=Z;try{Ce()}catch(Pe){hr(k,fe,Pe)}}}b=b.next}while(b!==C)}}catch(Pe){hr(u,u.return,Pe)}}function fie(l){var u=l.updateQueue;if(u!==null){var m=l.stateNode;try{tae(u,m)}catch(b){hr(l,l.return,b)}}}function hie(l,u,m){m.props=$p(l.type,l.memoizedProps),m.state=l.memoizedState;try{m.componentWillUnmount()}catch(b){hr(l,u,b)}}function vc(l,u){try{var m=l.ref;if(m!==null){switch(l.tag){case 26:case 27:case 5:var b=l.stateNode;break;case 30:var k=l.stateNode,C=Cu(l.memoizedProps,k);(k.ref===null||k.ref.name!==C)&&(k.ref=yoe(C)),b=k.ref;break;case 7:if(l.stateNode===null){var $=new ao(l);g(l.child,!1,UWe,$,void 0,void 0),l.stateNode=$}b=l.stateNode;break;default:b=l.stateNode}typeof m=="function"?l.refCleanup=m(b):m.current=b}}catch(Z){hr(l,u,Z)}}function Ca(l,u){var m=l.ref,b=l.refCleanup;if(m!==null)if(typeof b=="function")try{b()}catch(k){hr(l,u,k)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof m=="function")try{m(null)}catch(k){hr(l,u,k)}else m.current=null}function QC(l,u){if((l.tag===5||l.tag===27||l.tag===6)&&l.alternate===null&&u!==null)for(var m=0;m title"))),Aa(b,u,m),b[Xs]=l,Ts(b),u=b;break e;case"link":if(C=Loe("link","href",k).get(u+(m.href||""))){for($=0;$gn&&($=gn,gn=At,At=$);var ke=Nse(Z,At),be=Nse(Z,gn);if(ke&&be&&(Oe.rangeCount!==1||Oe.anchorNode!==ke.node||Oe.anchorOffset!==ke.offset||Oe.focusNode!==be.node||Oe.focusOffset!==be.offset)){var Ee=$e.createRange();Ee.setStart(ke.node,ke.offset),Oe.removeAllRanges(),At>gn?(Oe.addRange(Ee),Oe.extend(be.node,be.offset)):(Ee.setEnd(be.node,be.offset),Oe.addRange(Ee))}}}}for($e=[],Oe=Z;Oe=Oe.parentNode;)Oe.nodeType===1&&$e.push({element:Oe,left:Oe.scrollLeft,top:Oe.scrollTop});for(typeof Z.focus=="function"&&Z.focus(),Z=0;Z<$e.length;Z++){var ze=$e[Z];ze.element.scrollLeft=ze.left,ze.element.scrollTop=ze.top}}Gv=!!E$,T$=E$=null}finally{er=C,te.p=k,le.T=b}}l.current=u,es=2}}function m$(){if(es===2){es=0;var l=Al,u=Hp,m=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||m){m=le.T,le.T=null;var b=te.p;te.p=2;var k=er;er|=4;try{kie(l,u.alternate,u)}finally{er=k,te.p=b,le.T=m}}es=3}}function g$(){if(es===4||es===3){es=0;var l=Mv;Mv=null,Ve();var u=Al,m=Hp,b=Sc,k=$ie,C=(b&335544064)===b?10262:10256;if((m.subtreeFlags&C)!==0||(m.flags&C)!==0?es=5:(es=0,Hp=Al=null,Qie(u,u.pendingLanes)),C=u.pendingLanes,C===0&&(yf=null),Dt(b),m=m.stateNode,Fn&&typeof Fn.onCommitFiberRoot=="function")try{Fn.onCommitFiberRoot(ur,m,void 0,(m.current.flags&128)===128)}catch{}if(k!==null){m=le.T,C=te.p,te.p=2,le.T=null;try{for(var $=u.onRecoverableError,Z=0;Zm?32:m,le.T=null,m=d$,d$=null;var C=Al,$=Sc;if(es=0,Hp=Al=null,Sc=0,(er&6)!==0)throw Error(r(331));var Z=er;if(er|=4,Die(C.current),Iie(C,C.current,$,m),er=Z,Jw(0,!1),Fn&&typeof Fn.onPostCommitFiberRoot=="function")try{Fn.onPostCommitFiberRoot(ur,C)}catch{}return!0}finally{te.p=k,le.T=b,Qie(l,u)}}function Zie(l,u,m){u=$o(m,u),u=Mz(l.stateNode,u,2),l=ff(l,u,2),l!==null&&(us(l,2),kc(l))}function hr(l,u,m){if(l.tag===3)Zie(l,l,m);else for(;u!==null;){if(u.tag===3){Zie(u,l,m);break}else if(u.tag===1){var b=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(yf===null||!yf.has(b))){l=$o(m,l),m=Yae(2),b=ff(u,m,2),b!==null&&(Wae(m,b,u,l),us(b,2),kc(b));break}}u=u.return}}function x$(l,u,m){var b=l.pingCache;if(b===null){b=l.pingCache=new nWe;var k=new Set;b.set(u,k)}else k=b.get(u),k===void 0&&(k=new Set,b.set(u,k));k.has(m)||(l$=!0,k.add(m),l=uWe.bind(null,l,u,m),u.then(l,l))}function uWe(l,u,m){var b=l.pingCache;b!==null&&b.delete(u),l.pingedLanes|=l.suspendedLanes&m,l.warmLanes&=~m,Ar===l&&(_n&m)===m&&((fs===4||fs===3&&(_n&62914560)===_n&&300>bt()-oA)&&(er&2)===0?zv(l,0):iA|=m,Iv===_n&&(Iv=0)),kc(l)}function Jie(l,u){u===0&&(u=Rr()),l=Ap(l,u),l!==null&&(us(l,u),kc(l))}function dWe(l){var u=l.memoizedState,m=0;u!==null&&(m=u.retryLane),Jie(l,m)}function fWe(l,u){var m=0;switch(l.tag){case 31:case 13:var b=l.stateNode,k=l.memoizedState;k!==null&&(m=k.retryLane);break;case 19:b=l.stateNode;break;case 22:b=l.stateNode._retryCache;break;default:throw Error(r(314))}b!==null&&b.delete(u),Jie(l,m)}function hWe(l,u){return an(l,u)}var Bv=null,Fv=null,b$=!1,mA=!1,y$=!1,jf=0;function kc(l){l!==Fv&&l.next===null&&(Fv===null?Bv=Fv=l:Fv=Fv.next=l),mA=!0,b$||(b$=!0,mWe())}function Jw(l,u){if(!y$&&mA){y$=!0;do for(var m=!1,b=Bv;b!==null;){if(l!==0){var k=b.pendingLanes;if(k===0)var C=0;else{var $=b.suspendedLanes,Z=b.pingedLanes;C=(1<<31-yn(42|l)+1)-1,C&=k&~($&~Z),C=C&201326741?C&201326741|1:C?C|2:0}C!==0&&(m=!0,roe(b,C))}else C=_n,C=vr(b,b===Ar?C:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(C&3)===0||Qt(b,C)||(m=!0,roe(b,C));b=b.next}while(m);y$=!1}}function pWe(){eoe()}function eoe(){mA=b$=!1;var l=0;jf!==0&&CWe()&&(l=jf);for(var u=bt(),m=null,b=Bv;b!==null;){var k=b.next,C=toe(b,u);C===0?(b.next=null,m===null?Bv=k:m.next=k,k===null&&(Fv=m)):(m=b,(l!==0||(C&3)!==0)&&(mA=!0)),b=k}es!==0&&es!==5||Jw(l),jf!==0&&(jf=0)}function toe(l,u){for(var m=l.suspendedLanes,b=l.pingedLanes,k=l.expirationTimes,C=l.pendingLanes&-62914561;0Z)break;var Pe=fe.transferSize,$e=fe.initiatorType;Pe&&uoe($e)&&(fe=fe.responseEnd,$+=Pe*(feyA){At.length=et;break}Ee=new Promise(PWe.bind(Ee)),At.push(Ee)}}}if(0"u"?null:document;function Ioe(l,u,m){var b=Hv;if(b&&typeof u=="string"&&u){var k=ei(u);k='link[rel="'+l+'"][href="'+k+'"]',typeof m=="string"&&(k+='[crossorigin="'+m+'"]'),Poe.has(k)||(Poe.add(k),l={rel:l,crossOrigin:m,href:u},b.querySelector(k)===null&&(u=b.createElement("link"),Aa(u,"link",l),Ts(u),b.head.appendChild(u)))}}function QWe(l){Lu.D(l),Ioe("dns-prefetch",l,null)}function ZWe(l,u){Lu.C(l,u),Ioe("preconnect",l,u)}function JWe(l,u,m){Lu.L(l,u,m);var b=Hv;if(b&&l&&u){var k='link[rel="preload"][as="'+ei(u)+'"]';u==="image"&&m&&m.imageSrcSet?(k+='[imagesrcset="'+ei(m.imageSrcSet)+'"]',typeof m.imageSizes=="string"&&(k+='[imagesizes="'+ei(m.imageSizes)+'"]')):k+='[href="'+ei(l)+'"]';var C=k;switch(u){case"style":C=Vv(l);break;case"script":C=Kv(l)}if(!(Ko.has(C)||(l=P({rel:"preload",href:u==="image"&&m&&m.imageSrcSet?void 0:l,as:u},m),Ko.set(C,l),b.querySelector(k)!==null||u==="style"&&b.querySelector(sj(C))||u==="script"&&b.querySelector(aj(C))))){var $=b.createElement("link");Aa($,"link",l),u==="style"&&($[Qs]=!0,$.onload=$.onerror=function(){mw($)}),Ts($),b.head.appendChild($)}}}function eXe(l,u){Lu.m(l,u);var m=Hv;if(m&&l){var b=u&&typeof u.as=="string"?u.as:"script",k='link[rel="modulepreload"][as="'+ei(b)+'"][href="'+ei(l)+'"]',C=k;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":C=Kv(l)}if(!Ko.has(C)&&(l=P({rel:"modulepreload",href:l},u),Ko.set(C,l),m.querySelector(k)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(m.querySelector(aj(C)))return}b=m.createElement("link"),Aa(b,"link",l),Ts(b),m.head.appendChild(b)}}}function tXe(l,u,m){Lu.S(l,u,m);var b=Hv;if(b&&l){var k=tf(b).hoistableStyles,C=Vv(l);u=u||"default";var $=k.get(C);if(!$){var Z={loading:0,preload:null};if($=b.querySelector(sj(C)))Z.loading=5;else{l=P({rel:"stylesheet",href:l,"data-precedence":u},m),(m=Ko.get(C))&&F$(l,m);var fe=$=b.createElement("link");Ts(fe),Aa(fe,"link",l),fe._p=new Promise(function(Ce,Pe){fe.onload=Ce,fe.onerror=Pe}),fe.addEventListener("load",function(){Z.loading|=1}),fe.addEventListener("error",function(){Z.loading|=2}),Z.loading|=4,xA($,u,b)}$={type:"stylesheet",instance:$,count:1,state:Z},k.set(C,$)}}}function nXe(l,u){Lu.X(l,u);var m=Hv;if(m&&l){var b=tf(m).hoistableScripts,k=Kv(l),C=b.get(k);C||(C=m.querySelector(aj(k)),C||(l=P({src:l,async:!0},u),(u=Ko.get(k))&&U$(l,u),C=m.createElement("script"),Ts(C),Aa(C,"link",l),m.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},b.set(k,C))}}function rXe(l,u){Lu.M(l,u);var m=Hv;if(m&&l){var b=tf(m).hoistableScripts,k=Kv(l),C=b.get(k);C||(C=m.querySelector(aj(k)),C||(l=P({src:l,async:!0,type:"module"},u),(u=Ko.get(k))&&U$(l,u),C=m.createElement("script"),Ts(C),Aa(C,"link",l),m.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},b.set(k,C))}}function Moe(l,u,m,b){var k=(k=de.current)?rj(k):null;if(!k)throw Error(r(446));switch(l){case"meta":case"title":return null;case"style":return typeof m.precedence=="string"&&typeof m.href=="string"?(m=Vv(m.href),u=tf(k).hoistableStyles,b=u.get(m),b||(b={type:"style",instance:null,count:0,state:null},u.set(m,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(m.rel==="stylesheet"&&typeof m.href=="string"&&typeof m.precedence=="string"){l=Vv(m.href);var C=tf(k).hoistableStyles,$=C.get(l);if($||(k=k.ownerDocument||k,$={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},C.set(l,$),(C=k.querySelector(sj(l)))?C._p||($.instance=C,$.state.loading=5):(C=Ko.get(l),C||(C={rel:"preload",as:"style",href:m.href,crossOrigin:m.crossOrigin,integrity:m.integrity,media:m.media,hrefLang:m.hrefLang,referrerPolicy:m.referrerPolicy},Ko.set(l,C)),sXe(k,l,C,$.state))),u&&b===null)throw Error(r(528,""));return $}if(u&&b!==null)throw Error(r(529,""));return null;case"script":return u=m.async,m=m.src,typeof m=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(m=Kv(m),u=tf(k).hoistableScripts,b=u.get(m),b||(b={type:"script",instance:null,count:0,state:null},u.set(m,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,l))}}function Vv(l){return'href="'+ei(l)+'"'}function sj(l){return'link[rel="stylesheet"]['+l+"]"}function _oe(l){return P({},l,{"data-precedence":l.precedence,precedence:null})}function sXe(l,u,m,b){if(u=l.querySelector('link[rel="preload"][as="style"]['+u+"]")){if(u[Qs]!==!0){b.loading=1;return}}else u=l.createElement("link"),u[Qs]=!0,u.onload=u.onerror=mw.bind(null,u),Aa(u,"link",m),Ts(u),l.head.appendChild(u);b.preload=u,u.addEventListener("load",function(){return b.loading|=1}),u.addEventListener("error",function(){return b.loading|=2})}function Kv(l){return'[src="'+ei(l)+'"]'}function aj(l){return"script[async]"+l}function Doe(l,u,m){if(u.count++,u.instance===null)switch(u.type){case"style":var b=l.querySelector('style[data-href~="'+ei(m.href)+'"]');if(b)return u.instance=b,Ts(b),b;var k=P({},m,{"data-href":m.href,"data-precedence":m.precedence,href:null,precedence:null});return b=(l.ownerDocument||l).createElement("style"),Ts(b),Aa(b,"style",k),xA(b,m.precedence,l),u.instance=b;case"stylesheet":k=Vv(m.href);var C=l.querySelector(sj(k));if(C)return u.state.loading|=4,u.instance=C,Ts(C),C;b=_oe(m),(k=Ko.get(k))&&F$(b,k),C=(l.ownerDocument||l).createElement("link"),Ts(C);var $=C;return $._p=new Promise(function(Z,fe){$.onload=Z,$.onerror=fe}),Aa(C,"link",b),u.state.loading|=4,xA(C,m.precedence,l),u.instance=C;case"script":return C=Kv(m.src),(k=l.querySelector(aj(C)))?(u.instance=k,Ts(k),k):(b=m,(k=Ko.get(C))&&(b=P({},m),U$(b,k)),l=l.ownerDocument||l,k=l.createElement("script"),Ts(k),Aa(k,"link",b),l.head.appendChild(k),u.instance=k);case"void":return null;default:throw Error(r(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(b=u.instance,u.state.loading|=4,xA(b,m.precedence,l));return u.instance}function xA(l,u,m){for(var b=m.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=b.length?b[b.length-1]:null,C=k,$=0;$ title"):null)}function aXe(l,u,m){if(m===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;return u.rel==="stylesheet"?(l=u.disabled,typeof u.precedence=="string"&&l==null):!0;case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function zoe(l,u){return l==="img"&&u.src!=null&&u.src!==""&&u.onLoad==null&&u.loading!=="lazy"}function $oe(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Boe(l){return(l.width||100)*(l.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function Foe(l,u){typeof u.decode=="function"&&(l.imgCount++,u.complete||(l.imgBytes+=Boe(u),l.suspenseyImages.push(u)),l=lXe.bind(l),u.decode().then(l,l))}function iXe(l,u,m,b){if(m.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(m.state.loading&4)===0){if(m.instance===null){var k=Vv(b.href),C=u.querySelector(sj(k));if(C){u=C._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(l.count++,l=ij.bind(l),u.then(l,l)),m.state.loading|=4,m.instance=C,Ts(C);return}C=u.ownerDocument||u,b=_oe(b),(k=Ko.get(k))&&F$(b,k),C=C.createElement("link"),Ts(C);var $=C;$._p=new Promise(function(Z,fe){$.onload=Z,$.onerror=fe}),Aa(C,"link",b),m.instance=C}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(m,u),(u=m.state.preload)&&(m.state.loading&3)===0&&(l.count++,m=ij.bind(l),u.addEventListener("load",m),u.addEventListener("error",m))}}var yA=0;function oXe(l,u){return l.stylesheets&&l.count===0&&jA(l,l.stylesheets),0yA?50:800)+u);return l.unsuspend=m,function(){l.unsuspend=null,clearTimeout(b),clearTimeout(k)}}:null}function Uoe(l){if(l.count===0&&(l.imgCount===0||!l.waitingForImages)){if(l.stylesheets)jA(l,l.stylesheets);else if(l.unsuspend){var u=l.unsuspend;l.unsuspend=null,u()}}}function ij(){this.count--,Uoe(this)}function lXe(){this.imgCount--,Uoe(this)}var wA=null;function jA(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,wA=new Map,u.forEach(cXe,l),wA=null,ij.call(l))}function cXe(l,u){if(!(u.state.loading&4)){var m=wA.get(l);if(m)var b=m.get(null);else{m=new Map,wA.set(l,m);for(var k=l.querySelectorAll("link[data-precedence],style[data-precedence]"),C=0;C"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),RA.exports=lle(),RA.exports}var wn=cle();const ule=zu({__proto__:null},[wn]);var v=Kp();const MA=zu({__proto__:null,default:Tl(v)},[v]);function dj(){return typeof window<"u"}function pa(e){return _A(e)?(e.nodeName||"").toLowerCase():"#document"}function tr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Nc(e){var t;return(t=(_A(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _A(e){return dj()?e instanceof Node||e instanceof tr(e).Node:!1}function Cn(e){return dj()?e instanceof Element||e instanceof tr(e).Element:!1}function nr(e){return dj()?e instanceof HTMLElement||e instanceof tr(e).HTMLElement:!1}function qp(e){return!dj()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tr(e).ShadowRoot}function Qv(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=si(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function dle(e){return/^(table|td|th)$/.test(pa(e))}function fj(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const fle=/transform|translate|scale|rotate|perspective|filter/,hle=/paint|layout|strict|content/,Tf=e=>!!e&&e!=="none";let DA;function LA(e){const t=Cn(e)?si(e):e;return Tf(t.transform)||Tf(t.translate)||Tf(t.scale)||Tf(t.rotate)||Tf(t.perspective)||!zA()&&(Tf(t.backdropFilter)||Tf(t.filter))||fle.test(t.willChange||"")||hle.test(t.contain||"")}function ple(e){let t=Fu(e);for(;nr(t)&&!Bu(t);){if(LA(t))return t;if(fj(t))return null;t=Fu(t)}return null}function zA(){return DA==null&&(DA=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),DA}function Bu(e){return/^(html|body|#document)$/.test(pa(e))}function si(e){return tr(e).getComputedStyle(e)}function hj(e){return Cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fu(e){if(pa(e)==="html")return e;const t=e.assignedSlot||e.parentNode||qp(e)&&e.host||Nc(e);return qp(t)?t.host:t}function o3(e){const t=Fu(e);return Bu(t)?(e.ownerDocument||e).body:nr(t)&&Qv(t)?t:o3(t)}function Gp(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=o3(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),c=tr(i);if(o){const d=$A(c);return t.concat(c,c.visualViewport||[],Qv(i)?i:[],d&&n?Gp(d):[])}else return t.concat(i,Gp(i,[],n))}function $A(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const BA={...MA},l3={};function hs(e,t){const n=v.useRef(l3);return n.current===l3&&(n.current=e(t)),n}const FA=BA.useInsertionEffect,mle=FA&&FA!==BA.useLayoutEffect?FA:e=>e();function Fe(e){const t=hs(gle).current;return t.next=e,mle(t.effect),t.trampoline}function gle(){const e={next:void 0,callback:vle,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function vle(){}const Ue=typeof document<"u"?v.useLayoutEffect:()=>{};function UA(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const HA={};function Ai(e,t,n,r,i){if(!n&&!r&&!i&&!e)return pj(t);let o=pj(e);return t&&(o=Zv(o,t)),n&&(o=Zv(o,n)),r&&(o=Zv(o,r)),i&&(o=Zv(o,i)),o}function xle(e){if(e.length===0)return HA;if(e.length===1)return pj(e[0]);let t=pj(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function VA(e){return typeof e=="function"}function u3(e,t){return VA(e)?e(t):e??HA}function wle(e,t){return t?e?(...n)=>{const r=n[0];if(h3(r)){const o=r;mj(o);const c=t(...n);return o.baseUIHandlerPrevented||e?.(...n),c}const i=t(...n);return e?.(...n),i}:d3(t):e}function d3(e){return e&&((...t)=>{const n=t[0];return h3(n)&&mj(n),e(...t)})}function mj(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function f3(e,t){return t?e?t+" "+e:t:e}function h3(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function jle(e,t){return function(r,...i){const o=new URL(e);return o.searchParams.set("code",r.toString()),i.forEach(c=>o.searchParams.append("args[]",c)),`${t} error #${r}; visit ${o} for the full message.`}}const En=jle("https://base-ui.com/production-error","Base UI"),p3=v.createContext(void 0);function m3(e=!1){const t=v.useContext(p3);if(t===void 0&&!e)throw new Error(En(16));return t}function Sle(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:o}=e,c=r&&t!==!1,d=r&&t===!1;return{props:v.useMemo(()=>{const h={onKeyDown(p){n&&t&&p.key!=="Tab"&&p.preventDefault()}};return r||(h.tabIndex=i,!o&&n&&(h.tabIndex=t?i:-1)),(o&&(t||c)||!o&&n)&&(h["aria-disabled"]=n),o&&(!t||d)&&(h.disabled=n),h},[r,n,t,c,d,o,i])}}function vn(e){return e?.ownerDocument||document}function Yp(e,t,{detail:n=0}={}){e.dispatchEvent(new(tr(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function ai(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:o}=e,c=v.useRef(null),d=m3(!0),f=o??d!==void 0,{props:h}=Sle({focusableWhenDisabled:n,disabled:t,composite:f,tabIndex:r,isNativeButton:i}),p=v.useCallback(()=>{const y=c.current;KA(y)&&f&&t&&h.disabled===void 0&&y.disabled&&(y.disabled=!1)},[t,h.disabled,f]);Ue(p,[p]);const g=v.useCallback((y={})=>{const{onClick:j,onMouseDown:w,onKeyUp:S,onKeyDown:N,onPointerDown:A,...E}=y;return Ai({onClick(O){if(t){O.preventDefault();return}j?.(O)},onMouseDown(O){t||w?.(O)},onKeyDown(O){if(t||(mj(O),N?.(O),O.baseUIHandlerPrevented))return;const R=O.target===O.currentTarget,T=O.currentTarget,P=KA(T),M=!i&&kle(T),_=R&&(i?P:!M),I=O.key==="Enter",L=O.key===" ",D=T.getAttribute("role"),z=D?.startsWith("menuitem")||D==="option"||D==="gridcell";if(R&&f&&L){if(O.defaultPrevented&&z)return;O.preventDefault(),(!i||P)&&(O.preventBaseUIHandler(),Yp(T,O));return}if(!_||i||!L&&!I){R&&M&&L&&O.preventDefault();return}O.defaultPrevented||(O.preventDefault(),I&&(O.preventBaseUIHandler(),Yp(T,O)))},onKeyUp(O){if(!t){if(mj(O),S?.(O),O.target===O.currentTarget&&i&&f&&KA(O.currentTarget)&&O.key===" "){O.preventDefault();return}O.baseUIHandlerPrevented||O.target===O.currentTarget&&!i&&!f&&!O.defaultPrevented&&O.key===" "&&(O.preventBaseUIHandler(),Yp(O.currentTarget,O))}},onPointerDown(O){if(t){O.preventDefault();return}A?.(O)}},i?{type:"button"}:{role:"button"},h,E)},[t,h,f,i]),x=Fe(y=>{c.current=y,p()});return{getButtonProps:g,buttonRef:x}}function KA(e){return nr(e)&&e.tagName==="BUTTON"}function kle(e){return nr(e)&&e.tagName==="A"&&!!e.href}function Ei(e,t,n,r){const i=hs(g3).current;return Cle(i,e,t,n,r)&&v3(i,[e,t,n,r]),i.callback}function Nle(e){const t=hs(g3).current;return Ale(t,e)&&v3(t,e),t.callback}function g3(){return{callback:null,cleanup:null,refs:[]}}function Cle(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Ale(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function v3(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function x3(e){if(!v.isValidElement(e))return null;const t=e,n=t.props;return(qA(19)?n?.ref:t.ref)??null}function Pn(){}const Ti=Object.freeze([]),rr=Object.freeze({});function Tle(e,t){const n={};for(const r in e){const i=e[r];if(t?.hasOwnProperty(r)){const o=t[r](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Ole(e,t){return typeof e=="function"?e(t):e}function b3(e,t){return typeof e=="function"?e(t):e}function wt(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Mle(r));const i=Rle(t,n,r);if(n.enabled===!1)return null;const o=n.state??rr;return _le(e,r,i,o)}function Rle(e,t,n){const{className:r,style:i}=e,{state:o=rr,ref:c,props:d,stateAttributesMapping:f,enabled:h=!0}=t,p=h?Ole(r,o):void 0,g=h?b3(i,o):void 0,x=h?Tle(o,f):rr,y=h&&d?Ple(d):void 0,j=h?UA(x,y)??{}:rr;return typeof document<"u"&&(h?Array.isArray(c)?j.ref=Nle([j.ref,x3(n),...c]):j.ref=Ei(j.ref,x3(n),c):Ei(null,null)),h?(p!==void 0&&(j.className=f3(j.className,p)),g!==void 0&&(j.style=UA(j.style,g)),j):rr}function Ple(e){return Array.isArray(e)?xle(e):Ai(void 0,e)}const Ile=Symbol.for("react.lazy");function Mle(e){if(e?.$$typeof!==Ile)return e;const t=v.Children.toArray(e)[0];return v.isValidElement(t)?t:e}function _le(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=Ai(n,t.props);return i.ref=n.ref,v.cloneElement(t,i)}if(e&&typeof e=="string")return Dle(e,n);throw new Error(En(8))}function Dle(e,t){return e==="button"?v.createElement("button",{type:"button",...t,key:t.key}):e==="img"?v.createElement("img",{alt:"",...t,key:t.key}):v.createElement(e,t)}const Lle=v.forwardRef(function(t,n){const{render:r,className:i,disabled:o=!1,focusableWhenDisabled:c=!1,nativeButton:d=!0,style:f,...h}=t,{getButtonProps:p,buttonRef:g}=ai({disabled:o,focusableWhenDisabled:c,native:d});return wt("button",t,{state:{disabled:o},ref:[n,g],props:[h,p]})});function y3(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,S3=w3,Of=(e,t)=>n=>{var r;if(t?.variants==null)return S3(e,n?.class,n?.className);const{variants:i,defaultVariants:o}=t,c=Object.keys(i).map(h=>{const p=n?.[h],g=o?.[h];if(p===null)return null;const x=j3(p)||j3(g);return i[h][x]}),d=n&&Object.entries(n).reduce((h,p)=>{let[g,x]=p;return x===void 0||(h[g]=x),h},{}),f=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((h,p)=>{let{class:g,className:x,...y}=p;return Object.entries(y).every(j=>{let[w,S]=j;return Array.isArray(S)?S.includes({...o,...d}[w]):{...o,...d}[w]===S})?[...h,g,x]:h},[]);return S3(e,c,f,n?.class,n?.className)},zle=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r({classGroupId:e,validator:t}),k3=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),gj="-",N3=[],Ble="arbitrary..",Fle=e=>{const t=Hle(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return Ule(c);const d=c.split(gj),f=d[0]===""&&d.length>1?1:0;return C3(d,f,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const f=r[c],h=n[c];return f?h?zle(h,f):f:h||N3}return n[c]||N3}}},C3=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],o=n.nextPart.get(i);if(o){const h=C3(e,t+1,o);if(h)return h}const c=n.validators;if(c===null)return;const d=t===0?e.join(gj):e.slice(t).join(gj),f=c.length;for(let h=0;he.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Ble+r:void 0})(),Hle=e=>{const{theme:t,classGroups:n}=e;return Vle(n,t)},Vle=(e,t)=>{const n=k3();for(const r in e){const i=e[r];GA(i,n,r,t)}return n},GA=(e,t,n,r)=>{const i=e.length;for(let o=0;o{if(typeof e=="string"){qle(e,t,n);return}if(typeof e=="function"){Gle(e,t,n,r);return}Yle(e,t,n,r)},qle=(e,t,n)=>{const r=e===""?t:A3(t,e);r.classGroupId=n},Gle=(e,t,n,r)=>{if(Wle(e)){GA(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push($le(n,e))},Yle=(e,t,n,r)=>{const i=Object.entries(e),o=i.length;for(let c=0;c{let n=e;const r=t.split(gj),i=r.length;for(let o=0;o"isThemeGetter"in e&&e.isThemeGetter===!0,Xle=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(o,c)=>{n[o]=c,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(o){let c=n[o];if(c!==void 0)return c;if((c=r[o])!==void 0)return i(o,c),c},set(o,c){o in n?n[o]=c:i(o,c)}}},YA="!",E3=":",Qle=[],T3=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Zle=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const o=[];let c=0,d=0,f=0,h;const p=i.length;for(let w=0;wf?h-f:void 0;return T3(o,y,x,j)};if(t){const i=t+E3,o=r;r=c=>c.startsWith(i)?o(c.slice(i.length)):T3(Qle,!1,c,void 0,!0)}if(n){const i=r;r=o=>n({className:o,parseClassName:i})}return r},Jle=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let o=0;o0&&(i.sort(),r.push(...i),i=[]),r.push(c)):i.push(c)}return i.length>0&&(i.sort(),r.push(...i)),r}},ece=e=>({cache:Xle(e.cacheSize),parseClassName:Zle(e),sortModifiers:Jle(e),postfixLookupClassGroupIds:tce(e),...Fle(e)}),tce=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:c}=t,d=[],f=e.trim().split(nce);let h="";for(let p=f.length-1;p>=0;p-=1){const g=f[p],{isExternal:x,modifiers:y,hasImportantModifier:j,baseClassName:w,maybePostfixModifierPosition:S}=n(g);if(x){h=g+(h.length>0?" "+h:h);continue}let N=!!S,A;if(N){const P=w.substring(0,S);A=r(P);const M=A&&c[A]?r(w):void 0;M&&M!==A&&(A=M,N=!1)}else A=r(w);if(!A){if(!N){h=g+(h.length>0?" "+h:h);continue}if(A=r(w),!A){h=g+(h.length>0?" "+h:h);continue}N=!1}const E=y.length===0?"":y.length===1?y[0]:o(y).join(":"),O=j?E+YA:E,R=O+A;if(d.indexOf(R)>-1)continue;d.push(R);const T=i(A,N);for(let P=0;P0?" "+h:h)}return h},sce=(...e)=>{let t=0,n,r,i="";for(;t{if(typeof e=="string")return e;let t,n="";for(let r=0;r{let n,r,i,o;const c=f=>{const h=t.reduce((p,g)=>g(p),e());return n=ece(h),r=n.cache.get,i=n.cache.set,o=d,d(f)},d=f=>{const h=r(f);if(h)return h;const p=rce(f,n);return i(f,p),p};return o=c,(...f)=>o(sce(...f))},ice=[],Ms=e=>{const t=n=>n[e]||ice;return t.isThemeGetter=!0,t.themeKey=e,t},R3=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,P3=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oce=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lce=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cce=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,uce=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,dce=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,fce=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Uu=e=>oce.test(e),Sn=e=>!!e&&!Number.isNaN(Number(e)),Ol=e=>!!e&&Number.isInteger(Number(e)),WA=e=>e.endsWith("%")&&Sn(e.slice(0,-1)),Cc=e=>lce.test(e),I3=()=>!0,hce=e=>cce.test(e)&&!uce.test(e),XA=()=>!1,pce=e=>dce.test(e),mce=e=>fce.test(e),gce=e=>!ut(e)&&!dt(e),vce=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),xce=e=>Hu(e,$3,XA),ut=e=>R3.test(e),Rf=e=>Hu(e,B3,hce),M3=e=>Hu(e,Cce,Sn),bce=e=>Hu(e,U3,I3),yce=e=>Hu(e,F3,XA),_3=e=>Hu(e,L3,XA),wce=e=>Hu(e,z3,mce),vj=e=>Hu(e,H3,pce),dt=e=>P3.test(e),Jv=e=>Pf(e,B3),jce=e=>Pf(e,F3),D3=e=>Pf(e,L3),Sce=e=>Pf(e,$3),kce=e=>Pf(e,z3),xj=e=>Pf(e,H3,!0),Nce=e=>Pf(e,U3,!0),Hu=(e,t,n)=>{const r=R3.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Pf=(e,t,n=!1)=>{const r=P3.exec(e);return r?r[1]?t(r[1]):n:!1},L3=e=>e==="position"||e==="percentage",z3=e=>e==="image"||e==="url",$3=e=>e==="length"||e==="size"||e==="bg-size",B3=e=>e==="length",Cce=e=>e==="number",F3=e=>e==="family-name",U3=e=>e==="number"||e==="weight",H3=e=>e==="shadow",Ace=ace(()=>{const e=Ms("color"),t=Ms("font"),n=Ms("text"),r=Ms("font-weight"),i=Ms("tracking"),o=Ms("leading"),c=Ms("breakpoint"),d=Ms("container"),f=Ms("spacing"),h=Ms("radius"),p=Ms("shadow"),g=Ms("inset-shadow"),x=Ms("text-shadow"),y=Ms("drop-shadow"),j=Ms("blur"),w=Ms("perspective"),S=Ms("aspect"),N=Ms("ease"),A=Ms("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...O(),dt,ut],T=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],M=()=>[dt,ut,f],_=()=>[Uu,"full","auto",...M()],I=()=>[Ol,"none","subgrid",dt,ut],L=()=>["auto",{span:["full",Ol,dt,ut]},Ol,dt,ut],D=()=>[Ol,"auto",dt,ut],z=()=>["auto","min","max","fr",dt,ut],G=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...M()],F=()=>[Uu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...M()],K=()=>[d,Uu,"screen","full","dvw","lvw","svw","min","max","fit",...M()],U=()=>[Uu,"screen","full","lh","dvh","lvh","svh","min","max","fit",...M()],q=()=>[e,dt,ut],W=()=>[...O(),D3,_3,{position:[dt,ut]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ie=()=>["auto","cover","contain",Sce,xce,{size:[dt,ut]}],V=()=>[WA,Jv,Rf],H=()=>["","none","full",h,dt,ut],Q=()=>["",Sn,Jv,Rf],J=()=>["solid","dashed","dotted","double"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>[Sn,WA,D3,_3],se=()=>["","none",j,dt,ut],le=()=>["none",Sn,dt,ut],te=()=>["none",Sn,dt,ut],re=()=>[Sn,dt,ut],he=()=>[Uu,"full",...M()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Cc],breakpoint:[Cc],color:[I3],container:[Cc],"drop-shadow":[Cc],ease:["in","out","in-out"],font:[gce],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Cc],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Cc],shadow:[Cc],spacing:["px",Sn],text:[Cc],"text-shadow":[Cc],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Uu,ut,dt,S]}],container:["container"],"container-type":[{"@container":["","normal","size",dt,ut]}],"container-named":[vce],columns:[{columns:[Sn,"auto",ut,dt,d]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{"inset-s":_(),start:_()}],end:[{"inset-e":_(),end:_()}],"inset-bs":[{"inset-bs":_()}],"inset-be":[{"inset-be":_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[Ol,"auto",dt,ut]}],basis:[{basis:[Uu,"full","auto",d,...M()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Sn,Uu,"auto","initial","none",ut]}],grow:[{grow:["",Sn,dt,ut]}],shrink:[{shrink:["",Sn,dt,ut]}],order:[{order:[Ol,"first","last","none",dt,ut]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:M()}],"gap-x":[{"gap-x":M()}],"gap-y":[{"gap-y":M()}],"justify-content":[{justify:[...G(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...G()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":G()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:M()}],px:[{px:M()}],py:[{py:M()}],ps:[{ps:M()}],pe:[{pe:M()}],pbs:[{pbs:M()}],pbe:[{pbe:M()}],pt:[{pt:M()}],pr:[{pr:M()}],pb:[{pb:M()}],pl:[{pl:M()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mbs:[{mbs:Y()}],mbe:[{mbe:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":M()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":M()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...K()]}],"min-inline-size":[{"min-inline":["auto",...K()]}],"max-inline-size":[{"max-inline":["none",...K()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[d,"screen",...F()]}],"min-w":[{"min-w":[d,"screen","none",...F()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[c]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh","none",...F()]}],"font-size":[{text:["base",n,Jv,Rf]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Nce,bce]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",WA,ut]}],"font-family":[{font:[jce,yce,t]}],"font-features":[{"font-features":[ut]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,dt,ut]}],"line-clamp":[{"line-clamp":[Sn,"none",dt,M3]}],leading:[{leading:["none",o,...M()]}],"list-image":[{"list-image":["none",dt,ut]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",dt,ut]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[Sn,"from-font","auto",dt,Rf]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Sn,"auto",dt,ut]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"tab-size":[{tab:[Ol,dt,ut]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",dt,ut]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",dt,ut]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:ie()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ol,dt,ut],radial:["",dt,ut],conic:["",Ol,dt,ut]},kce,wce]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:V()}],"gradient-via-pos":[{via:V()}],"gradient-to-pos":[{to:V()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-bs":[{"border-bs":Q()}],"border-w-be":[{"border-be":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Sn,dt,ut]}],"outline-w":[{outline:["",Sn,Jv,Rf]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","inner","none",p,xj,vj]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",g,xj,vj]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Sn,Rf]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",x,xj,vj]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Sn,dt,ut]}],"mix-blend":[{"mix-blend":[...oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Sn]}],"mask-image-linear-from-pos":[{"mask-linear-from":ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":ee()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":ee()}],"mask-image-t-to-pos":[{"mask-t-to":ee()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":ee()}],"mask-image-r-to-pos":[{"mask-r-to":ee()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":ee()}],"mask-image-b-to-pos":[{"mask-b-to":ee()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":ee()}],"mask-image-l-to-pos":[{"mask-l-to":ee()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":ee()}],"mask-image-x-to-pos":[{"mask-x-to":ee()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":ee()}],"mask-image-y-to-pos":[{"mask-y-to":ee()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[dt,ut]}],"mask-image-radial-from-pos":[{"mask-radial-from":ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":ee()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[Sn]}],"mask-image-conic-from-pos":[{"mask-conic-from":ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":ee()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:ie()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",dt,ut]}],filter:[{filter:["","none",dt,ut]}],blur:[{blur:se()}],brightness:[{brightness:[Sn,dt,ut]}],contrast:[{contrast:[Sn,dt,ut]}],"drop-shadow":[{"drop-shadow":["","none",y,xj,vj]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Sn,dt,ut]}],"hue-rotate":[{"hue-rotate":[Sn,dt,ut]}],invert:[{invert:["",Sn,dt,ut]}],saturate:[{saturate:[Sn,dt,ut]}],sepia:[{sepia:["",Sn,dt,ut]}],"backdrop-filter":[{"backdrop-filter":["","none",dt,ut]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[Sn,dt,ut]}],"backdrop-contrast":[{"backdrop-contrast":[Sn,dt,ut]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Sn,dt,ut]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Sn,dt,ut]}],"backdrop-invert":[{"backdrop-invert":["",Sn,dt,ut]}],"backdrop-opacity":[{"backdrop-opacity":[Sn,dt,ut]}],"backdrop-saturate":[{"backdrop-saturate":[Sn,dt,ut]}],"backdrop-sepia":[{"backdrop-sepia":["",Sn,dt,ut]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":M()}],"border-spacing-x":[{"border-spacing-x":M()}],"border-spacing-y":[{"border-spacing-y":M()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",dt,ut]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Sn,"initial",dt,ut]}],ease:[{ease:["linear","initial",N,dt,ut]}],delay:[{delay:[Sn,dt,ut]}],animate:[{animate:["none",A,dt,ut]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,dt,ut]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[dt,ut,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":["translate-none"],zoom:[{zoom:[Ol,dt,ut]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",dt,ut]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mbs":[{"scroll-mbs":M()}],"scroll-mbe":[{"scroll-mbe":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pbs":[{"scroll-pbs":M()}],"scroll-pbe":[{"scroll-pbe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",dt,ut]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Sn,Jv,Rf,M3]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Te(...e){return Ace(w3(e))}const Ece=Of(["group/button inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap border [font-family:inherit]","font-medium transition-[background-color,border-color,color,transform,box-shadow] duration-150 ease-out","outline-none select-none active:translate-y-[0.5px] focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45 disabled:shadow-none","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:"border-primary bg-primary font-semibold text-primary-on shadow-glow hover:border-primary-hover hover:bg-primary-hover",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"border-transparent bg-transparent text-subtle shadow-none hover:bg-control-hover hover:text-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive hover:bg-destructive-hover",dashed:"border-dashed border-border-strong bg-transparent text-muted-foreground shadow-none hover:border-primary hover:text-primary-fg",link:"border-transparent bg-transparent text-primary shadow-none underline-offset-4 hover:underline"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]","2xs":"h-4 rounded-pill px-1.5 text-[10px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]",icon:"h-[30px] w-[30px] rounded-md p-0","icon-2xs":"size-4 rounded-pill p-0","icon-xs":"size-6 rounded-sm p-0","icon-sm":"h-[26px] w-[26px] rounded-sm p-0","icon-lg":"size-9 rounded-md p-0",touch:"h-[46px] rounded-md px-4 text-[14px]","touch-sm":"h-[34px] rounded-sm px-3 text-[12.5px]","icon-touch":"size-9 rounded-full p-0"}},defaultVariants:{variant:"default",size:"default"}});function B({className:e,variant:t,size:n,...r}){return s.jsx(Lle,{"data-slot":"button",className:Te(Ece({variant:t,size:n}),e),...r})}const Tce="data-valid",Oce="data-invalid",bj={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},V3={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Rce={disabled:!1,...V3},Rl={valid(e){return e===null?null:e?{[Tce]:""}:{[Oce]:""}}},K3={invalid:void 0,name:void 0,validityData:{state:bj,errors:[],error:"",value:"",initialValue:null},setValidityData:Pn,disabled:void 0,setTouched:Pn,setDirty:Pn,setFilled:Pn,setFocused:Pn,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Rce,registerFieldControl:Pn,validation:{getValidationProps:(e,t=rr)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Pn,getInputControl:()=>null,commit:async()=>{},change:Pn}},QA=v.createContext(K3);function Oi(e=!0){const t=v.useContext(QA);if(t.setValidityData===Pn&&!e)throw new Error(En(28));return t}const q3=v.createContext(void 0);function ZA(e=!1){const t=v.useContext(q3);if(!t&&!e)throw new Error(En(86));return t}const Pce=v.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Pn,validationMode:"onSubmit",submitCountRef:{current:0}});function Ac(){return v.useContext(Pce)}let G3=0;function Ice(e,t="mui"){const[n,r]=v.useState(e),i=e||n;return v.useEffect(()=>{n==null&&(G3+=1,r(`${t}-${G3}`))},[n,t]),i}const Y3=BA.useId;function Wp(e,t){if(Y3!==void 0){const n=Y3();return e??(t?`${t}-${n}`:n)}return Ice(e,t)}function bs(e){return Wp(e,"base-ui")}const W3=v.createContext({controlId:void 0,registerControlId:Pn,resetControlId:Pn,labelId:void 0,setLabelId:Pn,messageIds:[],setMessageIds:Pn,getDescriptionProps:e=>e});function ii(){return v.useContext(W3)}const Mce=function(t){const n=bs(),[r,i]=v.useState(n),[o,c]=v.useState(),[d,f]=v.useState([]),h=r===void 0?n:r,p=hs(()=>new Map),{messageIds:g}=ii(),x=Fe((S,N)=>{const A=p.current;N===void 0?A.delete(S):A.set(S,N),i(E=>{if(A.size===0)return E;let O;for(const R of A.values()){if(R===E)return E;O===void 0&&(O=R)}return O})}),y=Fe(()=>{p.current.size===0&&i(n)}),j=v.useCallback(S=>{const N=S["aria-describedby"]?S["aria-describedby"].split(" "):[];return N.push(...g,...d),{...S,"aria-describedby":Array.from(new Set(N)).join(" ")||void 0}},[g,d]),w=v.useMemo(()=>({controlId:h,registerControlId:x,resetControlId:y,labelId:o,setLabelId:c,messageIds:d,setMessageIds:f,getDescriptionProps:j}),[h,x,y,o,c,d,f,j]);return s.jsx(W3.Provider,{value:w,children:t.children})};function JA(e,t,n,r=!0,i){const[o,c]=v.useState(),d=bs(i?`${i}-label`:void 0),f=e??t??o;return Ue(()=>{const h=e||t||!r?void 0:_ce(n.current,d);o!==h&&c(h)}),f}function _ce(e,t){const n=Dce(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Dce(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const i=e.nextElementSibling;if(i&&i.htmlFor===n)return i}const r=e.labels;return r&&r[0]}function Vu(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:o}=ii(),c=bs(),d=hs(()=>Symbol()),f=v.useRef(!1),h=v.useRef(!1),p=Fe(()=>{!f.current||i===Pn||(f.current=!1,i(d.current,void 0))});return Ue(()=>{if(!n||i===Pn){p();return}let g;if(t!==void 0)h.current=!0,g=t;else if(h.current)g=c;else{o();return}if(g===void 0){p();return}f.current=!0,i(d.current,g)},[t,n,i,o,c,d,p]),Ue(()=>p,[p]),(n?r:void 0)??t??c}function Lce(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:zce,platform:$ce,maxTouchPoints:Bce}=Lce(),yj=zce.toLowerCase(),ex=$ce.toLowerCase(),tx=/^i(os$|p)/.test(ex)||ex==="macintel"&&Bce>1,X3="android",wj=ex===X3||yj.includes(X3),Q3=!tx&&ex.startsWith("mac");ex.startsWith("win");const Fce=Q3||tx,Ec=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none"),Z3=!Ec&&yj.includes("firefox");!Ec&&yj.includes("chrom");const Uce=Fce,eE=/jsdom|happydom/.test(yj);function ys(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function nt(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&qp(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function or(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}const tE="data-base-ui-focusable",J3="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",If="ArrowLeft",Mf="ArrowRight",nE="ArrowUp",jj="ArrowDown",rE="data-starting-style",Hce="data-ending-style",Vce={[rE]:""},Kce={[Hce]:""},io={transitionStatus(e){return e==="starting"?Vce:e==="ending"?Kce:null}},qce="data-open",Gce="data-closed",Yce="data-anchor-hidden",eB="data-popup-open",Wce="data-pressed",Xce={[eB]:""},Qce={[eB]:"",[Wce]:""},Zce={[qce]:""},Jce={[Gce]:""},eue={[Yce]:""},Sj={open(e){return e?Xce:null}},sE={open(e){return e?Qce:null}},Xp={open(e){return e?Zce:Jce},anchorHidden(e){return e?eue:null}},aE={...Xp,...io},iE="data-trigger-disabled";function kj(e,t){if(!Cn(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute(iE);for(const[,r]of t.entries())if(nt(r,n))return!r.hasAttribute(iE);return!1}function oE(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function tue(e){return e.matches("html,body")}function Nj(e){return nr(e)&&e.matches(J3)}function nue(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${J3}`)!=null}function lE(e){return e?e.getAttribute("role")==="combobox"&&Nj(e):!1}function Cj(e){if(!e||eE)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function Aj(e){return e?e.hasAttribute(tE)?e:e.querySelector(`[${tE}]`)||e:null}function Ku(e,t,n=!0){return e.filter(i=>i.parentId===t).flatMap(i=>[...!n||i.context?.open?[i]:[],...Ku(e,i.id,n)])}function tB(e,t){let n=[],r=e.find(i=>i.id===t)?.parentId;for(;r;){const i=e.find(o=>o.id===r);r=i?.parentId,i&&(n=n.concat(i))}return n}function _s(e){e.preventDefault(),e.stopPropagation()}function rue(e){return"nativeEvent"in e}function Ej(e){return e.pointerType===""&&e.isTrusted?!0:wj&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function cE(e){return eE?!1:!wj&&e.width===0&&e.height===0||wj&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function qu(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function sue(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Qp=Math.min,Tc=Math.max,Tj=Math.round,_f=Math.floor,Oc=e=>({x:e,y:e}),aue={left:"right",right:"left",bottom:"top",top:"bottom"};function nB(e,t,n){return Tc(e,Qp(t,n))}function Gu(e,t){return typeof e=="function"?e(t):e}function oo(e){return e.split("-")[0]}function Rc(e){return e.split("-")[1]}function uE(e){return e==="x"?"y":"x"}function dE(e){return e==="y"?"height":"width"}function lo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fE(e){return uE(lo(e))}function iue(e,t,n){n===void 0&&(n=!1);const r=Rc(e),i=fE(e),o=dE(i);let c=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=Oj(c)),[c,Oj(c)]}function oue(e){const t=Oj(e);return[hE(e),t,hE(t)]}function hE(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const rB=["left","right"],sB=["right","left"],lue=["top","bottom"],cue=["bottom","top"];function uue(e,t,n){switch(e){case"top":case"bottom":return n?t?sB:rB:t?rB:sB;case"left":case"right":return t?lue:cue;default:return[]}}function due(e,t,n,r){const i=Rc(e);let o=uue(oo(e),n==="start",r);return i&&(o=o.map(c=>c+"-"+i),t&&(o=o.concat(o.map(hE)))),o}function Oj(e){const t=oo(e);return aue[t]+e.slice(t.length)}function fue(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function aB(e){return typeof e!="number"?fue(e):{top:e,right:e,bottom:e,left:e}}function nx(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Rj(e,t,n){return Math.floor(e/t)!==n}function Yu(e,t){return t<0||t>=e.length}function Pj(e,t){return Js(e.current,{disabledIndices:t})}function pE(e,t){return Js(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Js(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let o=t;do o+=n?-i:i;while(o>=0&&o<=e.length-1&&Wu(e,o,r));return o}function hue(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:o,cols:c,disabledIndices:d,minIndex:f,maxIndex:h,prevIndex:p,stopEvent:g=!1}){let x=p,y;if(t.key===nE?y="up":t.key===jj&&(y="down"),y){const j=[],w=[];let S=!1,N=0;{let _=null,I=-1;e.forEach((L,D)=>{if(L==null)return;N+=1;const z=L.closest('[role="row"]');z&&(S=!0),(z!==_||I===-1)&&(_=z,I+=1,j[I]=[]),j[I].push(D),w[D]=I})}let A=!1,E=0;if(S)for(const _ of j){const I=_.length;I>E&&(E=I),I!==c&&(A=!0)}const O=A&&N{if(!A||p===-1)return;const I=w[p];if(I==null)return;const L=j[I].indexOf(p),D=_==="up"?-1:1;for(let z=I+D,G=0;G=j.length){if(!r||O)return;if(z=z<0?j.length-1:0,i){const Y=Math.min(L,j[z].length-1),F=j[z][Y]??j[z][0],K=i(t,p,F);z=w[K]??z}}const X=j[z];for(let Y=Math.min(L,X.length-1);Y>=0;Y-=1){const F=X[Y];if(!Wu(e,F,d))return F}}},P=_=>{if(!O||p===-1)return;const I=p%R,L=_==="up"?-R:R,D=h-h%R,z=_f(h/R)+1;for(let G=p-I+L,X=0;Xh){if(!r)return;G=G<0?D:0}const Y=Math.min(G+R-1,h);for(let F=Math.min(G+I,Y);F>=G;F-=1)if(!Wu(e,F,d))return F}};g&&_s(t);const M=T(y)??P(y);if(M!==void 0)x=M;else if(p===-1)x=y==="up"?h:f;else if(x=Js(e,{startingIndex:p,amount:R,decrement:y==="up",disabledIndices:d}),r){if(y==="up"&&(p-R_?L:L-R,i&&(x=i(t,p,x))}y==="down"&&p+R>h&&(x=Js(e,{startingIndex:p%R-R,amount:R,disabledIndices:d}),i&&(x=i(t,p,x)))}Yu(e,x)&&(x=p)}if(n==="both"){const j=_f(p/c);t.key===(o?If:Mf)&&(g&&_s(t),p%c!==c-1?(x=Js(e,{startingIndex:p,disabledIndices:d}),r&&Rj(x,c,j)&&(x=Js(e,{startingIndex:p-p%c-1,disabledIndices:d}),i&&(x=i(t,p,x)))):r&&(x=Js(e,{startingIndex:p-p%c-1,disabledIndices:d}),i&&(x=i(t,p,x))),Rj(x,c,j)&&(x=p)),t.key===(o?Mf:If)&&(g&&_s(t),p%c!==0?(x=Js(e,{startingIndex:p,decrement:!0,disabledIndices:d}),r&&Rj(x,c,j)&&(x=Js(e,{startingIndex:p+(c-p%c),decrement:!0,disabledIndices:d}),i&&(x=i(t,p,x)))):r&&(x=Js(e,{startingIndex:p+(c-p%c),decrement:!0,disabledIndices:d}),i&&(x=i(t,p,x))),Rj(x,c,j)&&(x=p));const w=_f(h/c)===j;Yu(e,x)&&(r&&w?(x=t.key===(o?Mf:If)?h:Js(e,{startingIndex:p-p%c-1,disabledIndices:d}),i&&(x=i(t,p,x))):x=p)}return x}function Wu(e,t,n){if(typeof n=="function"?n(t):n?.includes(t)??!1)return!0;const i=e[t];return i?!Ij(i)||i.matches(":disabled")?!0:!n&&(i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"):!1}function pue(e){return e.visibility==="hidden"||e.visibility==="collapse"}function Ij(e,t=e?si(e):null){return!e||!e.isConnected||!t||pue(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const mue='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function gue(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return qp(n)?n.host:null}function mE(e){for(const t of Array.from(e.children))if(pa(t)==="summary")return t;return null}function vue(e,t){const n=mE(t);return!!n&&(e===n||nt(n,e))}function iB(e){const t=e?pa(e):"";return e!=null&&e.matches(mue)&&(t!=="summary"||e.parentElement!=null&&pa(e.parentElement)==="details"&&mE(e.parentElement)===e)&&(t!=="details"||mE(e)==null)&&(t!=="input"||e.type!=="hidden")}function oB(e){if(!iB(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=gue(t)){const n=t!==e,r=pa(t)==="slot";if(t.hasAttribute("inert")||n&&pa(t)==="details"&&!t.open&&!vue(e,t)||t.hasAttribute("hidden")||!r&&!xue(t,n))return!1}return!0}function xue(e,t){const n=si(e);return t?n.display!=="none":Ij(e,n)}function lB(e){const t=e.tabIndex;if(t<0){const n=pa(e);if(n==="details"||n==="audio"||n==="video"||nr(e)&&e.isContentEditable)return 0}return t}function gE(e){if(pa(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function bue(e,t){const n=gE(e);if(!n)return!0;const r=t.find(i=>{const o=gE(i);return o?.name===n.name&&o.form===n.form&&o.checked});return r?r===n:t.find(i=>{const o=gE(i);return o?.name===n.name&&o.form===n.form})===n}function cB(e){if(nr(e)&&pa(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return nr(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function uB(e,t){cB(e).forEach(n=>{iB(n)&&t.push(n),uB(n,t)})}function dB(e,t,n){cB(e).forEach(r=>{nr(r)&&r.matches(t)&&n.push(r),dB(r,t,n)})}function vE(e){return oB(e)&&lB(e)>=0}function fB(e){const t=[];return uB(e,t),t.filter(oB)}function rx(e){const t=fB(e);return t.filter(n=>lB(n)>=0&&bue(n,t))}function hB(e,t){const n=rx(e),r=n.length;if(r===0)return;const i=ys(vn(e)),o=n.indexOf(i),c=o===-1?t===1?0:r-1:o+t;return n[c]}function xE(e){return hB(vn(e).body,1)||e}function pB(e){return hB(vn(e).body,-1)||e}function mB(e,t){if(!e)return null;const n=rx(vn(e).body),r=n.length;if(r===0)return null;const i=n.indexOf(e);if(i===-1)return null;const o=(i+t+r)%r;return n[o]}function yue(e){return mB(e,1)}function wue(e){return mB(e,-1)}function Zp(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!nt(n,r)}function jue(e){rx(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function gB(e){const t=[];dB(e,"[data-tabindex]",t),t.forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Sue(e,t){const n=bs(e);return Ue(()=>(t(n),()=>{t(r=>r===n?void 0:r)}),[n,t]),n}function kue(e={}){const{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:o}=e,{controlId:c,setLabelId:d}=ii(),f=Fe(y=>{d(y),i?.(y)}),h=Sue(t,f),p=c??n;function g(y){if(o){o(y,p);return}if(!p)return;const j=vn(y.currentTarget).getElementById(p);nr(j)&&Nue(j)}function x(y){or(y.nativeEvent)?.closest("button,input,select,textarea")||(!y.defaultPrevented&&y.detail>1&&y.preventDefault(),!r&&g(y))}return r?{id:h,htmlFor:p,onMouseDown:x}:{id:h,onClick:x,onPointerDown(y){y.preventDefault()}}}function Nue(e){e.focus({focusVisible:!0})}function Mj(e){v.useEffect(e,Ti)}const sx=0;class oi{constructor(){on(this,"currentId",sx);on(this,"clear",()=>{this.currentId!==sx&&(clearTimeout(this.currentId),this.currentId=sx)});on(this,"disposeEffect",()=>this.clear)}static create(){return new oi}start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=sx,n()},t)}isStarted(){return this.currentId!==sx}}function Ds(){const e=hs(oi.create).current;return Mj(e.disposeEffect),e}function bE(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const yE=Object.keys(bj);function vB(e,t){return e.matches(":disabled")?!1:!t||e.form===t?!0:e.form===null&&!e.hasAttribute("form")}function xB(e,t){let n=null;for(const r of e.keys())if(vB(r,t)){if(!r.validity.valid)return r;n??(n=r)}return n}function bB(e){return{...bj,valid:!e,customError:e}}function wE(e){return e&&e.validationMessage?[e.validationMessage]:[]}function Cue(e){const{elementRef:t,formRef:n}=Ac(),{setValidityData:r,validate:i,validityData:o,validationDebounceTime:c,invalid:d,markedDirtyRef:f,state:h,shouldValidateOnChange:p,validationMode:g,registeredFieldIdRef:x}=e,{controlId:y,getDescriptionProps:j}=ii(),w=Ds(),S=v.useRef(null),N=hs(()=>new Map).current,A=v.useRef(0),E=v.useRef(null),O=v.useCallback((_,I)=>(N.set(_,I),()=>{N.delete(_)}),[N]),R=Fe(()=>{const _=xB(N,t.current);return _&&N.get(_)?.controlRef.current||null}),T=Fe(async(_,I=!1)=>{A.current+=1;const L=A.current;function D(V,H=d){const Q=x.current??y;if(Q==null)return;const J=n.current.fields.get(Q);if(!J)return;const oe=bE(V,H);n.current.fields.set(Q,{...J,validityData:oe})}function z(V,H){const Q=V.valid===!1?H:[];return{value:_,state:V,error:Q[0]??"",errors:Q,initialValue:o.initialValue}}function G(V,H){const Q=V.validity.customError?V.validationMessage:"",J=H.replace(/\r\n?/g,`
`);V.setCustomValidity(J),E.current=[V,J,Q]}function X(){const V=E.current;E.current=null,V&&(!V[0].willValidate||V[0].validationMessage===V[1])&&V[0].setCustomValidity(V[2])}function Y(V,H,Q){const J=z(V,H);D(J,Q),r(J)}function F(V){const H=yE.reduce((J,oe)=>(J[oe]=V.validity[oe],J),{});let Q=!1;for(const J of yE)if(J!=="valid"){if(J==="valueMissing"&&H[J])Q=!0;else if(H[J])return H}return Q&&!f.current&&(H.valid=!0,H.valueMissing=!1),H}function K(){return N.size>0?xB(N,t.current):S.current}let U=K();function q(){return U=K(),U?.willValidate?F(U):bB(!1)}if(I){if(h.valid!==!1||!U)return;if(!U.validity.valueMissing){X();const V=K(),H=V?.validity.customError?wE(V):[];Y(bB(H.length>0),H,!1);return}for(const V of yE)if(V!=="valid"&&V!=="valueMissing"&&V!=="customError"&&U.validity[V])return}w.clear(),X();let W=q(),ne=wE(U);const ie=p();if(ne.length===0||ie){const V=Array.from(n.current.fields.values()).reduce((J,oe)=>(oe.name&&(J[oe.name]=oe.getValue()),J),{}),H=i(_,V);let Q;if(typeof H=="object"&&H!==null&&"then"in H){if(W.valid===!1?Y(W,ne):(g==="onSubmit"||!o.state.customError)&&(W.valid=null,Y(W,ne)),Q=await H,L!==A.current)return;W=q()}else Q=H;ne=Q?[].concat(Q).filter(Boolean):[],ne.length>0?(W.valid=!1,W.customError=!0,U?.willValidate&&G(U,ne.join(`
-`))):ne=wE(U)}Y(W,ne)}),P=Fe((_,I=!1)=>{if(w.clear(),A.current+=1,I)return;const L=p();L&&_!==""&&c?w.start(c,()=>{T(_)}):T(_,!L)}),M=v.useCallback((_,I={})=>Ai(j(I),h.valid===!1&&!h.disabled&&!_?{"aria-invalid":!0}:rr),[j,h.disabled,h.valid]);return v.useMemo(()=>({getValidationProps:M,inputRef:S,registeredInputs:N,registerInput:O,getInputControl:R,commit:T,change:P}),[M,N,O,R,T,P])}function Aue(e){const{change:t,commit:n,invalid:r,markedDirtyRef:i,name:o,setRegisteredFieldName:c,registeredFieldIdRef:d,setValidityData:f,validityData:h}=e,{formRef:p}=Ac(),g=v.useRef(null),x=v.useRef(null),y=v.useRef(!1),j=Fe(()=>{const R=x.current;if(R)return R.getValue?R.getValue():R.value});function w(R){return R.value===void 0?j():R.value}const S=Fe(()=>{const R=x.current;if(i.current=!0,!R){n(h.value);return}n(w(R))});function N(){const R=x.current;!R||!R.id||p.current.fields.set(R.id,{getValue:j,name:o??R.name,controlRef:R.controlRef,validityData:bE(h,r),validate:S})}function A(R=x.current?.id){R&&p.current.fields.delete(R)}function E(R){if(y.current)return;y.current=!0;const T=w(R);f(P=>P.initialValue===T?P:{...P,initialValue:T})}Ue(()=>{const R=x.current;!R||!R.id||(c(o?void 0:R.name),p.current.fields.set(R.id,{getValue:j,name:o??R.name,controlRef:R.controlRef,validityData:bE(h,r),validate:S}))},[p,j,r,o,c,S,h]),Ue(()=>{const R=p.current.fields;return()=>{const T=x.current?.id;T&&R.delete(T)}},[p]);const O=Fe((R,T)=>{if(!T){g.current===R&&(g.current=null,t(void 0,!0),A(),x.current=null,c(void 0),d.current=void 0);return}const P=x.current?.id,M=g.current;M&&M!==R&&t(void 0,!0),g.current=R,x.current=T,o||c(T.name),d.current=T.id,P&&P!==T.id&&A(P),E(T),N()});return[S,O]}const Eue=v.forwardRef(function(t,n){const{errors:r,validationMode:i,submitCountRef:o}=Ac(),{render:c,className:d,validate:f,validationDebounceTime:h=0,validationMode:p=i,name:g,disabled:x=!1,invalid:y,dirty:j,touched:w,actionsRef:S,style:N,...A}=t,E=ZA(!0)?.disabled,O=Fe(f||(()=>null)),R=E||x,[T,P]=v.useState(!1),[M,_]=v.useState(!1),[I,L]=v.useState(!1),[D,z]=v.useState(!1),G=j??M,X=w??T,Y=v.useRef(G),F=v.useRef(void 0),[K,U]=v.useState(),q=g??K;Ue(()=>{j!==void 0&&(Y.current=j)},[j]);const W=Fe(Ne=>{j===void 0&&(Ne&&(Y.current=!0),_(Ne))}),ne=Fe(Ne=>{w===void 0&&P(Ne)}),ie=Fe(()=>p==="onChange"||p==="onSubmit"&&o.current>0),V=q&&Object.hasOwn(r,q)?r[q]:null,H=!!(Array.isArray(V)?V.length:V),Q=y===!0||H,[J,oe]=v.useState({state:xj,error:"",errors:[],value:null,initialValue:null}),ee=!Q&&(R?null:J.state.valid),se=v.useMemo(()=>({disabled:R,touched:X,dirty:G,valid:ee,filled:I,focused:D}),[R,X,G,ee,I,D]),le=Cue({setValidityData:oe,validate:O,validityData:J,validationDebounceTime:h,invalid:Q,markedDirtyRef:Y,state:se,shouldValidateOnChange:ie,validationMode:p,registeredFieldIdRef:F}),[te,re]=Aue({change:le.change,commit:le.commit,invalid:Q,markedDirtyRef:Y,name:g,setRegisteredFieldName:U,registeredFieldIdRef:F,setValidityData:oe,validityData:J});v.useImperativeHandle(S,()=>({validate:te}),[te]);const he=v.useMemo(()=>({invalid:Q,name:q,validityData:J,setValidityData:oe,disabled:R,setTouched:ne,setDirty:W,setFilled:L,setFocused:z,validationMode:p,shouldValidateOnChange:ie,state:se,registerFieldControl:re,validation:le}),[Q,q,J,R,ne,W,L,z,p,ie,se,re,le]),pe=wt("div",t,{ref:n,state:se,props:A,stateAttributesMapping:Rl});return s.jsx(QA.Provider,{value:he,children:pe})}),Tue=v.forwardRef(function(t,n){return s.jsx(Mce,{children:s.jsx(Eue,{...t,ref:n})})}),Oue=v.createContext({disabled:!1});function Mj(){return v.useContext(Oue)}const Rue=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,nativeLabel:d=!0,...f}=t,h=Oi(!1),p=Mj(),{labelId:g}=ii(),x={...h.state,disabled:h.disabled||p.disabled},y=v.useRef(null),j=kue({id:g??c,native:d});return wt("label",t,{ref:[n,y],state:x,props:[j,f],stateAttributesMapping:Rl})}),_j=null;class Pue{constructor(){on(this,"callbacks",[]);on(this,"callbacksCount",0);on(this,"nextId",1);on(this,"startId",1);on(this,"isScheduled",!1);on(this,"tick",t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let i=0;i=this.callbacks.length||this.callbacks[n]!==null&&(this.callbacks[n]=null,this.callbacksCount-=1)}}let Dj=new Pue;class li{constructor(){on(this,"currentId",_j);on(this,"cancel",()=>{this.currentId!==_j&&(Dj.cancel(this.currentId),this.currentId=_j)});on(this,"disposeEffect",()=>this.cancel)}static create(){return new li}static request(t){return Dj.request(t)}static cancel(t){return Dj.cancel(t)}request(t){this.cancel(),this.currentId=Dj.request(()=>{this.currentId=_j,t()})}}function Zp(){const e=hs(li.create).current;return Ij(e.disposeEffect),e}function Pc(e){return e==null?e:"current"in e?e.current:e}let Lj=null;function Iue(e){if(!Lj){const t=[];Lj=t,queueMicrotask(()=>{Lj=null,br.flushSync(()=>{for(const n of t)n()})})}Lj.push(e)}function jE(e,t=!1,n=!1){const r=Zp();return Fe((i,o=null)=>{r.cancel();const c=Pc(e);if(c==null)return;const d=c,f=()=>{if(!n){br.flushSync(i);return}Iue(()=>{o?.aborted||i()})};if(typeof d.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function h(){Promise.all(d.getAnimations().map(p=>p.finished)).then(()=>{o?.aborted||f()},()=>{if(o?.aborted)return;if(d.getAnimations().some(g=>g.pending||g.playState!=="finished")){h();return}f()})}if(t){const p=rE;if(!d.hasAttribute(p)){r.request(h);return}const g=new MutationObserver(()=>{d.hasAttribute(p)||(g.disconnect(),h())});g.observe(d,{attributes:!0,attributeFilter:[p]}),o?.addEventListener("abort",()=>g.disconnect(),{once:!0});return}r.request(h)})}function Va(e){const{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:o}=e,c=Fe(o),d=jE(r,n,i);v.useEffect(()=>{if(!t)return;const f=new AbortController;return d(c,f.signal),()=>{f.abort()}},[t,n,c,d])}function Ic(e,t=!1,n=!1,r=!1){const[i,o]=v.useState(e&&t?"idle":void 0),[c,d]=v.useState(e&&!r);return e&&!c&&(d(!0),o("starting")),!e&&c&&i!=="ending"&&!n&&o("ending"),!e&&!c&&i==="ending"&&o(void 0),Ue(()=>{if(!e&&c&&i!=="ending"&&n){const f=li.request(()=>{o("ending")});return()=>{li.cancel(f)}}},[e,c,i,n]),Ue(()=>{if(!e||t)return;const f=li.request(()=>{o(void 0)});return()=>{li.cancel(f)}},[t,e]),Ue(()=>{if(!e||!t)return;e&&c&&i!=="idle"&&o("starting");const f=li.request(()=>{o("idle")});return()=>{li.cancel(f)}},[t,e,c,i]),{mounted:c,setMounted:d,transitionStatus:i}}const Mue=v.forwardRef(function(t,n){const{render:r,id:i,className:o,style:c,...d}=t,f=bs(i),h=Oi(!1),p=Mj(),{setMessageIds:g}=ii(),x={...h.state,disabled:h.disabled||p.disabled};return Ue(()=>{if(f)return g(j=>j.concat(f)),()=>{g(j=>j.filter(w=>w!==f))}},[f,g]),wt("p",t,{ref:n,state:x,props:[{id:f},d],stateAttributesMapping:Rl})});function qo({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=v.useRef(e!==void 0),[o,c]=v.useState(t),d=i&&e!==void 0?e:o,f=v.useCallback(h=>{i||c(h)},[]);return[d,f]}function Jp(e,t,n,r,i=!0,o){const{registerFieldControl:c}=Oi(),d=hs(()=>Symbol());Ue(()=>{const f=d.current;if(!i){c(f,void 0);return}c(f,{controlRef:e,getValue:r,id:t,name:o,value:n})},[e,i,r,t,o,c,d,n]),Ue(()=>{const f=d.current;return()=>{c(f,void 0)}},[c,d])}function co(e,t){const n=v.useRef(e),r=Fe(t);Ue(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}const Br="none",Mc="trigger-press",ma="trigger-hover",zj="trigger-focus",$j="outside-press",ax="item-press",SE="close-press",ix="input-change",Pl="input-clear",_ue="input-press",Xu="focus-out",em="escape-key",kE="list-navigation",yB="keyboard",wB="pointer",jB="cancel-open",Due="disabled",NE="imperative-action",Lue="window-resize";function at(e,t,n,r){let i=!1,o=!1;const c=r??rr;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){o=!0},get isCanceled(){return i},get isPropagationAllowed(){return o},trigger:n,...c}}function zue(e,t,n){const r=n??rr;return{reason:e,event:t??new Event("base-ui"),...r}}const $ue=v.forwardRef(function(t,n){const{render:r,className:i,id:o,name:c,value:d,disabled:f=!1,onValueChange:h,defaultValue:p,autoFocus:g=!1,style:x,...y}=t,{state:j,name:w,disabled:S,setTouched:N,setDirty:A,validityData:E,setFocused:O,setFilled:R,validationMode:T,validation:P}=Oi(),{clearErrors:M,elementRef:_,submitCountRef:I}=Ac(),L=S||f,D=w??c,z={...j,disabled:L},{labelId:G}=ii(),X=Vu({id:o}),[Y]=qo({controlled:d,default:p,name:"FieldControl",state:"value"}),F=d!==void 0,K=F?Y:void 0,U=K==null?void 0:String(K),q=Fe(()=>P.inputRef.current?.value);Jp(P.inputRef,X,U,q,!L,c),Ue(()=>{const V=U??P.inputRef.current?.value;V!==void 0&&R(V!=="")},[U,P.inputRef,R]),co(U,()=>{U!==void 0&&(M(D),A(U!==(E.initialValue??"")),P.change(U))});const W=v.useRef(null),ne=Ds();return Ue(()=>{g&&W.current===ys(vn(W.current))&&O(!0)},[g,O]),wt("input",t,{ref:[n,W],state:z,props:[{id:X,disabled:L,name:D,ref:P.inputRef,"aria-labelledby":G,autoFocus:g,...F?{value:K}:{defaultValue:p},onChange(V){const H=V.currentTarget.value,Q=at(Br,V.nativeEvent);h?.(H,Q),!F&&(A(H!==(E.initialValue??"")),R(H!==""),!V.nativeEvent.defaultPrevented&&!Q.isCanceled&&(M(D),P.change(H)))},onFocus(){O(!0)},onBlur(V){if(N(!0),O(!1),T==="onBlur"){const H=V.currentTarget.value;P.commit(H),F&&queueMicrotask(()=>{const Q=P.inputRef.current?.value;Q!==void 0&&Q!==H&&Q!==(E.initialValue??"")&&P.commit(Q)})}},onKeyDown(V){if(V.currentTarget.tagName==="INPUT"&&V.key==="Enter"){N(!0);const H=V.currentTarget.value,Q=V.currentTarget.form;if(Q&&Q===_.current&&!V.defaultPrevented){const J=V.currentTarget,oe=I.current;ne.start(0,()=>{I.current===oe&&P.commit(J.value)})}else P.commit(H)}}},y,V=>P.getValidationProps(L,V)],stateAttributesMapping:Rl})}),Bue=v.forwardRef(function(t,n){return s.jsx($ue,{ref:n,...t})});function Be({className:e,type:t,ref:n,...r}){return t==="file"||t==="hidden"?s.jsx("input",{ref:n,type:t,"data-slot":"input",className:Te(e),...r}):s.jsx(Bue,{ref:n,type:t,"data-slot":"input",className:Te("h-[30px] w-full min-w-0 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] text-foreground outline-none max-[767px]:h-10 max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground","file:inline-flex file:border-0 file:bg-transparent file:text-foreground",e),...r})}function Ea({className:e,...t}){return s.jsx("textarea",{"data-slot":"textarea",className:Te("min-h-26 w-full resize-y rounded-md border border-control-border bg-control px-3 py-2.5","font-mono text-[12px] leading-[1.6] text-foreground outline-none max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground",e),...t})}function uo({className:e,...t}){return s.jsx("div",{"data-slot":"input-group",role:"group",className:Te("group/input-group relative flex h-[30px] w-full min-w-0 items-center rounded-md border border-control-border bg-control max-[767px]:h-10","transition-[border-color,box-shadow] duration-150 ease-out","outline-none","has-[[data-slot=input-group-control]:focus-visible]:border-primary","has-[[data-slot=input-group-control]:focus-visible]:shadow-focus","has-[[data-slot=input-group-control]:hover:not(:focus-visible)]:border-control-border-hover","has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>[data-slot=input-group-control]]:pl-1.5","has-[>[data-align=inline-end]]:[&>[data-slot=input-group-control]]:pr-1.5","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-start]]:[&>[data-slot=input-group-control]]:pb-1.5","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col","has-[>[data-align=block-end]]:[&>[data-slot=input-group-control]]:pt-1.5",e),...t})}const Fue=Tf(["flex h-auto cursor-text items-center justify-center gap-1.5 select-none","text-[12px] font-medium text-muted-foreground","group-data-[disabled=true]/input-group:opacity-50"],{variants:{align:{"inline-start":"order-first pl-[9px] has-[>button]:-ml-1","inline-end":"order-last pr-[9px] has-[>button]:-mr-1","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-1.5","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-1.5"}},defaultVariants:{align:"inline-start"}});function fo({className:e,align:t="inline-start",...n}){return s.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Te(Fue({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const Uue=Tf("flex items-center shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-xs px-1.5",sm:"h-8 gap-1.5 rounded-sm px-2.5","icon-xs":"size-6 rounded-xs p-0","icon-sm":"size-8 rounded-sm p-0"}},defaultVariants:{size:"xs"}});function SB({className:e,type:t="button",variant:n="ghost",size:r="xs",...i}){return s.jsx(B,{type:t,"data-size":r,variant:n,className:Te(Uue({size:r}),e),...i})}function ho({className:e,...t}){return s.jsx(Be,{"data-slot":"input-group-control",className:Te("flex-1 rounded-none border-0 bg-transparent shadow-none focus:border-0 focus:shadow-none",e),...t})}function ox(e){return wt(e.defaultTagName??"div",e,e)}const Hue=Tf("inline-flex w-fit shrink-0 items-center justify-center gap-[5px] overflow-hidden whitespace-nowrap border font-semibold",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive",outline:"border-control-border bg-control text-subtle",ghost:"border-transparent bg-transparent text-muted-foreground",link:"border-transparent bg-transparent text-primary underline-offset-4 hover:underline",success:"border-success-bd bg-success-soft text-success",warning:"border-warning-bd bg-warning-soft text-warning",info:"border-info-bd bg-info-soft text-info",brand:"border-primary-bd bg-primary-soft text-primary-fg",cn:"border-cn-bd bg-cn-soft text-cn",intl:"border-intl-bd bg-intl-soft text-intl",sensitive:"border-sensitive-bd bg-sensitive-soft text-sensitive"},shape:{pill:"min-h-[21px] rounded-pill px-[9px] py-px text-[11.5px]",tag:"min-h-[19px] rounded-xs px-2 py-0 text-[11px]"}},defaultVariants:{variant:"default",shape:"pill"}});function ye({className:e,variant:t,shape:n,render:r,...i}){return ox({render:r,defaultTagName:"span",props:Ai({"data-slot":"badge"},i,{className:Te(Hue({variant:t,shape:n}),e)})})}function CE({className:e,...t}){return s.jsx("span",{className:Te("size-1.5 flex-none rounded-full bg-current",e),...t})}const kB=v.createContext(void 0);function NB(){const e=v.useContext(kB);if(e===void 0)throw new Error(En(13));return e}const AE={imageLoadingStatus:()=>null},Vue=v.forwardRef(function(t,n){const{className:r,render:i,style:o,...c}=t,[d,f]=v.useState("idle"),h={imageLoadingStatus:d},p=v.useMemo(()=>({imageLoadingStatus:d,setImageLoadingStatus:f}),[d,f]),g=wt("span",t,{state:h,ref:n,props:c,stateAttributesMapping:AE});return s.jsx(kB.Provider,{value:p,children:g})});function Kue(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},o){const c=v.useState("idle"),d=c[1];return Ue(()=>{if(!o)return Pn;if(!e&&!i)return d("error"),Pn;let f=!0;const h=new window.Image,p=g=>()=>{f&&d(g)};return d("loading"),h.onload=p("loaded"),h.onerror=p("error"),t&&(h.referrerPolicy=t),h.crossOrigin=n??null,r&&(h.sizes=r),i&&(h.srcset=i),e&&(h.src=e),h.complete&&d(h.naturalWidth>0?"loaded":"error"),()=>{f=!1}},[o,e,i,r,n,t,d]),c}const que={...AE,...io},Gue=v.forwardRef(function(t,n){const{className:r,render:i,onLoadingStatusChange:o,keepMounted:c=!1,style:d,sizes:f,srcSet:h,src:p,...g}=t,{setImageLoadingStatus:x}=NB(),[y,j]=Kue(p,t,!c),w=y==="loaded",{mounted:S,transitionStatus:N,setMounted:A}=Ic(w),E=v.useRef(null),O=v.useRef(!0);Ue(()=>{if(!c)return;const L=O.current;O.current=!1;const D=E.current;if(!D)return;if(!D.complete){j("loading");return}const z=D.naturalWidth>0?"loaded":"error";j(z),z==="loaded"&&L&&A(!0)},[c,p,h,f,g.crossOrigin,g.referrerPolicy,i,j,A]);const R=c?{"data-loading":y==="loading"?"":void 0,"data-error":y==="error"?"":void 0,"aria-hidden":y!=="loaded"||void 0,onLoad(){j("loaded")},onError(){j("error")}}:void 0,T=Fe(L=>{o?.(L),x(L)});Ue(()=>{y!=="idle"&&T(y)},[y,T]),Ue(()=>()=>x("idle"),[x]),Va({enabled:!w,open:w,ref:E,onComplete(){w||A(!1)}});const P={imageLoadingStatus:y,transitionStatus:c&&N==="ending"?void 0:N},M=c||S,_={};f!==void 0&&(_.sizes=f),h!==void 0&&(_.srcSet=h),p!==void 0&&(_.src=p);const I=wt("img",t,{state:P,ref:[n,E],props:[R,g,_],stateAttributesMapping:que,enabled:M});return M?I:null}),Yue=v.forwardRef(function(t,n){const{className:r,render:i,delay:o=0,style:c,...d}=t,{imageLoadingStatus:f}=NB(),[h,p]=v.useState(o===0),g=Ds();return v.useEffect(()=>(o>0?g.start(o,()=>p(!0)):p(!0),g.clear),[g,o]),wt("span",t,{state:{imageLoadingStatus:f},ref:n,props:d,stateAttributesMapping:AE,enabled:f!=="loaded"&&(o===0||h)})});function Wue({className:e,...t}){return s.jsx(Vue,{"data-slot":"avatar",className:n=>Te("relative inline-flex size-8 shrink-0 overflow-hidden rounded-full text-foreground",typeof e=="function"?e(n):e),...t})}function Xue({className:e,...t}){return s.jsx(Gue,{"data-slot":"avatar-image",className:n=>Te("absolute inset-0 block size-full object-cover data-loading:invisible data-error:invisible",typeof e=="function"?e(n):e),...t})}function Que({className:e,...t}){return s.jsx(Yue,{"data-slot":"avatar-fallback",className:n=>Te("absolute inset-0 flex items-center justify-center bg-control text-[12px] font-semibold text-subtle",typeof e=="function"?e(n):e),...t})}function ue(e,t){if(typeof window>"u")return e;const n=window.wbI18n;return n?n.t(e,t)??e:e}function Ls({className:e,...t}){return s.jsx("svg",{"data-slot":"spinner",role:"status","aria-label":ue("加载中"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:Te("size-4 animate-spin [animation-duration:0.7s]",e),...t,children:s.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Ie({className:e,...t}){return s.jsx("label",{"data-slot":"label",className:Te("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",e),...t})}const CB={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},_c={...CB,position:"fixed",top:0,left:0},tm={...CB,position:"absolute"},AB=v.createContext(void 0);function Zue(){const e=v.useContext(AB);if(e===void 0)throw new Error(En(63));return e}const Jue="data-checked",ede="data-unchecked",EB={...Rl,checked(e){return e?{[Jue]:""}:{[ede]:""}}},tde=v.forwardRef(function(t,n){const{checked:r,className:i,defaultChecked:o,"aria-labelledby":c,form:d,id:f,inputRef:h,name:p,nativeButton:g=!1,onCheckedChange:x,readOnly:y=!1,required:j=!1,disabled:w=!1,render:S,uncheckedValue:N,value:A,style:E,...O}=t,{clearErrors:R}=Ac(),{state:T,setTouched:P,setDirty:M,validityData:_,setFilled:I,setFocused:L,validationMode:D,disabled:z,name:G,validation:X}=Oi(),{labelId:Y}=ii(),F=z||w,K=G??p,U=v.useRef(null),q=Ei(U,h,X.inputRef),W=v.useRef(null),ne=bs(),ie=Vu({id:f}),V=g?void 0:ie,[H,Q]=qo({controlled:r,default:!!o,name:"Switch",state:"checked"});Jp(W,ne,H,void 0,!F,p),Ue(()=>{I(H)},[H,I]),co(H,()=>{R(K),M(H!==_.initialValue),X.change(H)});const{getButtonProps:J,buttonRef:oe}=ai({disabled:F,native:g}),ee=JA(c,Y,U,!g,V),se={id:g?ie:ne,role:"switch","aria-checked":H,"aria-readonly":y||void 0,"aria-required":j||void 0,"aria-labelledby":ee,onFocus(){F||L(!0)},onBlur(){const he=U.current;!he||F||(P(!0),L(!1),D==="onBlur"&&X.commit(he.checked))},onClick(he){if(y||F)return;he.preventDefault();const pe=U.current;pe&&Gp(pe,he)}},le={...X.getValidationProps(F),checked:H,disabled:F,form:d,id:V,name:K,required:j,style:K?tm:_c,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:q,onChange(he){if(he.nativeEvent.defaultPrevented)return;if(y){he.preventDefault();return}const pe=he.currentTarget.checked,Ne=at(Br,he.nativeEvent);x?.(pe,Ne),!Ne.isCanceled&&Q(pe)},onClick(he){he.stopPropagation()},onFocus(){W.current?.focus()},...A!==void 0?{value:A}:rr},te=v.useMemo(()=>({...T,checked:H,disabled:F,readOnly:y,required:j}),[T,H,F,y,j]),re=wt("span",t,{state:te,ref:[n,W,oe],props:[se,O,J,he=>X.getValidationProps(F,he)],stateAttributesMapping:EB});return s.jsxs(AB.Provider,{value:te,children:[re,!H&&K&&N!==void 0&&s.jsx("input",{type:"hidden",form:d,name:K,value:N,disabled:F}),s.jsx("input",{...le,suppressHydrationWarning:!0})]})}),nde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,d=Zue();return wt("span",t,{state:d,ref:n,stateAttributesMapping:EB,props:c})});function cn({className:e,size:t="default",variant:n="default",...r}){const i=t==="sm";return s.jsx(tde,{"data-slot":"switch",className:Te("relative inline-flex flex-none cursor-pointer items-center rounded-pill border-0 bg-border-strong p-0","transition-colors duration-[180ms] ease-out",n==="success"?"data-checked:bg-success":"data-checked:bg-primary","focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:opacity-50",i?"h-[14px] w-6":t==="touch"?"h-6 w-10":"h-[21px] w-9",e),...r,children:s.jsx(nde,{"data-slot":"switch-thumb",className:Te("block rounded-full bg-primary-on shadow-1","transition-transform duration-[180ms] [transition-timing-function:cubic-bezier(.3,1.4,.6,1)]",i?"size-[10px] translate-x-0.5 data-checked:translate-x-[10px]":t==="touch"?"size-5 translate-x-0.5 data-checked:translate-x-[18px]":"size-[17px] translate-x-0.5 data-checked:translate-x-[17px]")})})}function rde(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const r=t;if(r.type==="submit")return r}}return null}const sde="data-checked",ade="data-unchecked";function TB(e){return{checked(t){return e.indeterminate?{}:t?{[sde]:""}:{[ade]:""}},...Rl}}const ide=v.createContext(void 0);function ode(){return v.useContext(ide)}const OB=v.createContext(void 0);function lde(){const e=v.useContext(OB);if(e===void 0)throw new Error(En(14));return e}const cde="data-parent",ude=v.forwardRef(function(t,n){const{checked:r,className:i,defaultChecked:o=!1,"aria-labelledby":c,disabled:d=!1,form:f,id:h,indeterminate:p=!1,inputRef:g,name:x,onCheckedChange:y,parent:j=!1,readOnly:w=!1,render:S,required:N=!1,uncheckedValue:A,value:E,nativeButton:O=!1,style:R,...T}=t,{clearErrors:P}=Ac(),{disabled:M,name:_,setDirty:I,setFilled:L,setFocused:D,setTouched:z,state:G,validationMode:X,validityData:Y,validation:F}=Oi(),K=Mj(),{labelId:U,registerControlId:q,getDescriptionProps:W}=ii(),ne=ode(),ie=ne?.allValues===void 0?void 0:ne.parent,V=ie!==void 0,H=M||K.disabled||ne?.disabled||d,Q=_??x,J=E??Q,oe=bs(),ee=ne?.registerControlId!==q,se=Vu({id:h||void 0,enabled:ee}),le=O?se:oe;let te={};V&&(j?te=ie.getParentProps():J!==void 0&&(te=ie.getChildProps(J)));const{checked:re=r,indeterminate:he=p,onCheckedChange:pe,...Ne}=te,me=ne?.value,ce=v.useRef(null),{getButtonProps:ae,buttonRef:_e}=ai({disabled:H,native:O}),de=ne?.validation??F,[Se,ve]=qo({controlled:J!==void 0&&me!==void 0&&!j?me.includes(J):re,default:o,name:"Checkbox",state:"checked"}),xe=V?!!re:Se,Re=V&&he||p;Jp(ce,oe,Se,void 0,!ne&&!H,x);const we=ie?.registerChildId,ge=v.useRef(null),De=de.registerInput,Ge=ne?J:void 0,Ot=v.useCallback(Ve=>De(Ve,{controlRef:ce,value:Ge}),[De,Ge]),sn=Ei(g,ge,j?void 0:Ot),$t=JA(c,U,ge,!O,se);Ue(()=>{ge.current&&(ge.current.indeterminate=Re),ne||L(Se)},[Se,Re,ne,L]),co(Se,()=>{ne||(P(Q),I(Se!==Y.initialValue),de.change(Se))});const Me=Ai({checked:Se,disabled:H,form:f,name:j?void 0:Q,id:O?void 0:se,required:N,ref:sn,style:Q?tm:_c,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Ve){if(Ve.nativeEvent.defaultPrevented)return;if(w){Ve.preventDefault();return}const bt=Ve.currentTarget.checked,Ut=at(Br,Ve.nativeEvent);if(y?.(bt,Ut),!Ut.isCanceled&&(pe?.(bt,Ut),!Ut.isCanceled&&(ve(bt),J!==void 0&&ne!==void 0&&!j&&!V))){const Yt=bt?[...ne.value,J]:ne.value.filter(yt=>yt!==J);ne.setValue(Yt,Ut)}},onClick(Ve){Ve.stopPropagation()},onFocus(){ce.current?.focus()}},E!==void 0?{value:(ne?Se&&E:E)||""}:rr,W,Ve=>de.getValidationProps(H,Ve));v.useEffect(()=>{if(!ie||J===void 0)return;const Ve=ie.disabledStatesRef.current;return Ve.set(J,H),()=>{Ve.delete(J)}},[ie,H,J]);const Ht=v.useMemo(()=>({...G,checked:xe,disabled:H,readOnly:w,required:N,indeterminate:Re}),[G,xe,H,w,N,Re]),an=TB(Ht),Mt=wt("span",t,{state:Ht,ref:[_e,ce,n],props:[{id:le,role:"checkbox","aria-checked":Re?"mixed":xe,"aria-readonly":w||void 0,"aria-required":N||void 0,"aria-labelledby":$t,[cde]:j?"":void 0,onFocus(){H||D(!0)},onBlur(){const Ve=ge.current;Ve&&(z(!0),D(!1),X==="onBlur"&&de.commit(ne?me:Ve.checked))},onKeyDown(Ve){if(Ve.key!=="Enter"||(Ve.preventBaseUIHandler(),Ve.defaultPrevented))return;const bt=ge.current?.form??null,Ut=Ve.currentTarget,Yt=Ve.nativeEvent,yt=Ve.preventDefault,un=Yt.preventDefault;let Tn=!1;Ve.preventDefault=()=>{Tn=!0,yt.call(Ve)},Yt.preventDefault=()=>{Tn=!0,un.call(Yt)},un.call(Yt),tr(Ut).queueMicrotask(()=>{Ve.preventDefault=yt,Yt.preventDefault=un,Tn||rde(bt)?.click()})},onClick(Ve){if(w||H)return;Ve.preventDefault();const bt=ge.current;bt&&Gp(bt,Ve)}},T,Ne,ae,W,Ve=>de.getValidationProps(H,Ve)],stateAttributesMapping:an}),_t=Mt.props.id;return Ue(()=>{if(!(!we||j||J===void 0||_t===void 0))return we(J,_t)},[we,j,J,_t]),s.jsxs(OB.Provider,{value:Ht,children:[Mt,!Se&&!ne&&Q&&!j&&A!==void 0&&s.jsx("input",{type:"hidden",form:f,name:Q,value:A,disabled:H}),s.jsx("input",{...Me,suppressHydrationWarning:!0})]})}),dde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,keepMounted:c=!1,...d}=t,f=lde(),h=f.checked||f.indeterminate,{mounted:p,transitionStatus:g,setMounted:x}=Ic(h),y=v.useRef(null),j={...f,transitionStatus:g};Va({batch:!0,enabled:!h,open:h,ref:y,onComplete(){h||x(!1)}});const S={...TB(f),...io},N=c||p,A=wt("span",t,{ref:[n,y],state:j,stateAttributesMapping:S,props:d});return N?A:null});function Wr({className:e,...t}){return s.jsx(ude,{"data-slot":"checkbox",className:Te("group/checkbox relative inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-[3px] border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...t,children:s.jsx(dde,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-primary-foreground data-unchecked:hidden",children:s.jsxs("svg",{viewBox:"0 0 12 12",className:"size-2.5","aria-hidden":"true",children:[s.jsx("path",{d:"M2 6h8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none",className:"hidden group-aria-[checked=indeterminate]/checkbox:block"}),s.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",className:"group-aria-[checked=indeterminate]/checkbox:hidden"})]})})})}function EE(e){return Array.isArray(e)?e.map(t=>EE(t)).join(","):e==null?"":String(e)}const RB=new Map;function fde(e,t){const n=JSON.stringify({locale:EE(e),options:t}),r=RB.get(n);if(r)return r;const i=new Intl.NumberFormat(e,t);return RB.set(n,i),i}function Bj(e,t,n){return e==null?"":fde(t,n).format(e)}function Dc(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function PB(e,t,n){return(e-t)*100/(n-t)}const IB=v.createContext(void 0);function MB(){const e=v.useContext(IB);if(e===void 0)throw new Error(En(51));return e}const hde="data-complete",pde="data-indeterminate",mde="data-progressing",TE={status(e){return e==="progressing"?{[mde]:""}:e==="complete"?{[hde]:""}:e==="indeterminate"?{[pde]:""}:null}},gde=v.forwardRef(function(t,n){const{format:r,getAriaValueText:i,locale:o,max:c=100,min:d=0,value:f,render:h,className:p,children:g,style:x,...y}=t,[j,w]=v.useState();let S="indeterminate",N=null,A=null,E="",O="indeterminate progress";if(f!=null&&Number.isFinite(f)){const _=PB(f,d,c);N=Dc(Number.isNaN(_)?0:_,0,100),A=Dc(f,d,c),S=A===c?"complete":"progressing",E=r?Bj(A,o,r):Bj(N/100,o,{style:"percent"}),O=E}const R=v.useMemo(()=>({status:S}),[S]),T={"aria-labelledby":j,"aria-valuemax":c,"aria-valuemin":d,"aria-valuenow":A??void 0,"aria-valuetext":i?i(E,f):O,role:"progressbar",children:s.jsxs(v.Fragment,{children:[g,s.jsx("span",{role:"presentation",style:_c,children:"x"})]})},P=v.useMemo(()=>({formattedValue:E,percentageValue:N,setLabelId:w,state:R,value:f}),[E,N,w,R,f]),M=wt("div",t,{state:R,ref:n,props:[T,y],stateAttributesMapping:TE});return s.jsx(IB.Provider,{value:P,children:M})}),vde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,{state:d}=MB();return wt("div",t,{state:d,ref:n,props:c,stateAttributesMapping:TE})}),xde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,{percentageValue:d,state:f}=MB(),h=d==null?{}:{insetInlineStart:0,height:"inherit",width:`${d}%`};return wt("div",t,{state:f,ref:n,props:[{style:h},c],stateAttributesMapping:TE})});function nm({className:e,children:t,value:n,...r}){return s.jsxs(gde,{value:n,"data-slot":"progress",className:Te("flex w-full flex-wrap items-center gap-3",e),...r,children:[t,s.jsx(bde,{children:s.jsx(yde,{})})]})}function bde({className:e,...t}){return s.jsx(vde,{"data-slot":"progress-track",className:Te("relative flex h-1.5 w-full items-center overflow-x-hidden overflow-y-hidden rounded-pill bg-surface-3",e),...t})}function yde({className:e,...t}){return s.jsx(xde,{"data-slot":"progress-indicator",className:Te("h-full rounded-[inherit] bg-primary transition-[width] duration-300 ease-out data-[indeterminate]:w-1/3 data-[indeterminate]:animate-pulse",e),...t})}const OE=[];let RE;function wde(){return RE}function jde(e){OE.push(e)}function Fj(e){const t=(n,r)=>{const i=hs(Sde).current;let o;try{RE=i;for(const c of OE)c.before(i);o=e(n,r);for(const c of OE)c.after(i);i.didInitialize=!0}finally{RE=void 0}return o};return t.displayName=e.displayName||e.name,t}function PE(e){return v.forwardRef(Fj(e))}function Sde(){return{didInitialize:!1}}const _B=v.createContext(void 0);function lx(e){const t=v.useContext(_B);if(t===void 0&&!e)throw new Error(En(72));return t}function kde(e,t){return t!=null&&!qu(t)?0:typeof e=="function"?e():e}function _f(e,t,n){const r=kde(e,n);return typeof r=="number"?r:r?.[t]}function DB(e){return typeof e=="function"?e():e}function LB(e,t){return t||e==="click"||e==="mousedown"}function Nde(e){return e?.includes("mouse")&&e!=="mousedown"}const zB=v.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new oi,currentIdRef:{current:null},currentContextRef:{current:null}});function Cde(e,t){e.current=t.current}function Ade(e){const{children:t,delay:n,timeoutMs:r=0}=e,i=v.useRef(n),o=v.useRef(n),c=v.useRef(null),d=v.useRef(null),f=Ds();return Ue(()=>{if(o.current=n,!c.current){i.current=n;return}i.current={open:_f(i.current,"open"),close:_f(n,"close")}},[n,c,i,o]),s.jsx(zB.Provider,{value:v.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:o,currentIdRef:c,timeoutMs:r,currentContextRef:d,timeout:f}),[r,f]),children:t})}function Ede(e,t={open:!1}){const{open:n}=t,r="rootStore"in e?e.rootStore:e,i=r.useState("floatingId"),o=v.useContext(zB),{currentIdRef:c,delayRef:d,timeoutMs:f,initialDelayRef:h,currentContextRef:p,hasProvider:g,timeout:x}=o,[y,j]=v.useState(!1),w=v.useRef(n);return Ue(()=>{w.current=n},[n]),Ue(()=>{function S(){p.current?.setIsInstantPhase(!1),c.current=null,p.current=null,d.current=h.current,x.clear()}if(c.current&&!n&&c.current===i){if(j(!1),f){const N=i;return x.start(f,()=>{r.select("open")||c.current&&c.current!==N||S()}),()=>{(w.current||c.current!==N)&&x.clear()}}S()}},[n,i,c,d,f,h,p,x,r]),Ue(()=>{if(!n)return;const S=p.current,N=c.current;x.clear(),p.current={onOpenChange:r.setOpen,setIsInstantPhase:j},c.current=i,d.current={open:0,close:_f(h.current,"close")},N!==null&&N!==i?(j(!0),S?.setIsInstantPhase(!0),S?.onOpenChange(!1,at(Br))):(j(!1),S?.setIsInstantPhase(!1))},[n,i,r,c,d,h,p,x]),Ue(()=>()=>{if(c.current===i){if(p.current=null,!w.current)return;c.current=null,Cde(d,h),x.clear()}},[p,c,d,i,h,x]),v.useMemo(()=>({activeIdRef:c,hasProvider:g,delayRef:d,isInstantPhase:y}),[c,g,d,y])}function Jt(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Go(...e){return()=>{for(let t=0;t{t.current=t.next}};return t}const Df=v.forwardRef(function(t,n){const[r,i]=v.useState();Ue(()=>{Uce&&Ec&&i("button")},[]);const o={tabIndex:0,role:r};return s.jsx("span",{...t,ref:n,style:_c,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});function cx(e){return`data-base-ui-${e}`}let Uj=0;function Hj(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Uj);function o(){i&&!i()||e?.focus({preventScroll:n})}if(r)return o(),Pn;const c=requestAnimationFrame(o);return Uj=c,()=>{Uj===c&&(cancelAnimationFrame(c),Uj=0)}}const IE={inert:new WeakMap,"aria-hidden":new WeakMap},$B="data-base-ui-inert",ME={inert:new WeakSet,"aria-hidden":new WeakSet};let ux=new WeakMap,_E=0;function Ode(e){return ME[e]}function BB(e){return e?Kp(e)?e.host:BB(e.parentNode):null}const FB=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=BB(n);return e.contains(r)?r:null}).filter(n=>n!=null),UB=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},HB=(e,t,n)=>{const r=[],i=o=>{!o||n.has(o)||Array.from(o.children).forEach(c=>{pa(c)!=="script"&&(t.has(c)?i(c):r.push(c))})};return i(e),r};function Rde(e,t,n,r,{mark:i=!0}){let o=null;r?o="inert":n&&(o="aria-hidden");let c=null,d=null;const f=FB(t,e),h=i?HB(t,UB(f),new Set(f)):[],p=[],g=[];if(o){const x=IE[o],y=Ode(o);d=y,c=x;const j=FB(t,Array.from(t.querySelectorAll("[aria-live]"))),w=f.concat(j);HB(t,UB(w),new Set(w)).forEach(N=>{const A=N.getAttribute(o),E=A!==null&&A!=="false",O=(x.get(N)||0)+1;x.set(N,O),p.push(N),O===1&&E&&y.add(N),E||N.setAttribute(o,o==="inert"?"":"true")})}return i&&h.forEach(x=>{const y=(ux.get(x)||0)+1;ux.set(x,y),g.push(x),y===1&&x.setAttribute($B,"")}),_E+=1,()=>{c&&p.forEach(x=>{const j=(c.get(x)||0)-1;c.set(x,j),j||(!d?.has(x)&&o&&x.removeAttribute(o),d?.delete(x))}),i&&g.forEach(x=>{const y=(ux.get(x)||0)-1;ux.set(x,y),y||x.removeAttribute($B)}),_E-=1,_E||(IE.inert=new WeakMap,IE["aria-hidden"]=new WeakMap,ME.inert=new WeakSet,ME["aria-hidden"]=new WeakSet,ux=new WeakMap)}}function VB(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,o=vn(e[0]).body;return Rde(e,o,n,r,{mark:i})}const Pde=500,Ide={style:{transition:"none"}},DE="data-base-ui-click-trigger",Mde="data-base-ui-swipe-ignore",_de="data-swipe-ignore",Dde=`[${Mde}]`,Lde=`[${_de}]`,KB={fallbackAxisSide:"none"},qB={fallbackAxisSide:"end"},zde={clipPath:"inset(50%)",position:"fixed",top:0,left:0},GB=v.createContext(null),YB=()=>v.useContext(GB),$de=cx("portal");function WB(e={}){const{ref:t,container:n,componentProps:r=rr,elementProps:i}=e,o=Yp(),d=YB()?.portalNode,[f,h]=v.useState(null),[p,g]=v.useState(null),x=Fe(S=>{S!==null&&g(S)}),y=v.useRef(null);Ue(()=>{if(n===null){y.current&&(y.current=null,g(null),h(null));return}const S=(n&&(_A(n)?n:n.current))??d??document.body;if(S==null){y.current&&(y.current=null,g(null),h(null));return}y.current!==S&&(y.current=S,g(null),h(S))},[n,d]);const j=wt("div",r,{ref:[t,x],props:[{id:o,[$de]:""},i]}),w=f&&j?br.createPortal(j,f):null;return{node:p,nodeId:v.isValidElement(j)?j.props.id:void 0,subtree:w}}const Vj=v.forwardRef(function(t,n){const{render:r,className:i,style:o,children:c,container:d,portalOwnerRole:f,...h}=t,{node:p,nodeId:g,subtree:x}=WB({container:d,ref:n,componentProps:t,elementProps:h}),y=v.useRef(null),j=v.useRef(null),w=v.useRef(null),S=v.useRef(null),[N,A]=v.useState(null),E=v.useRef(!1),O=N?.modal,R=N?.open,T=!!N&&!N.modal&&N.open&&!!p;v.useEffect(()=>{if(!p||O)return;function M(_){p&&_.relatedTarget&&Qp(_)&&(_.type==="focusin"?E.current&&(gB(p),E.current=!1):(jue(p),E.current=!0))}return Go(Jt(p,"focusin",M,!0),Jt(p,"focusout",M,!0))},[p,O]),Ue(()=>{!p||R!==!0||!E.current||(gB(p),E.current=!1)},[R,p]);const P=v.useMemo(()=>({beforeOutsideRef:y,afterOutsideRef:j,beforeInsideRef:w,afterInsideRef:S,portalNode:p,setFocusManagerState:A}),[p]);return s.jsxs(v.Fragment,{children:[x,s.jsxs(GB.Provider,{value:P,children:[T&&p&&s.jsx(Df,{"data-type":"outside",ref:y,onFocus:M=>{if(Qp(M,p))w.current?.focus();else{const _=N?N.domReference:null;pB(_)?.focus()}}}),T&&p&&s.jsx("span",{role:f,"aria-owns":g,style:zde}),p&&br.createPortal(c,p),T&&p&&s.jsx(Df,{"data-type":"outside",ref:j,onFocus:M=>{if(Qp(M,p))S.current?.focus();else{const _=N?N.domReference:null;xE(_)?.focus(),N?.closeOnFocusOut&&N?.onOpenChange(!1,at(Xu,M.nativeEvent))}}})]})]})});function XB(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class Bde{constructor(){on(this,"nodesRef",{current:[]});on(this,"events",XB())}addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const QB=v.createContext(null),ZB=v.createContext(null),rm=()=>v.useContext(QB)?.id||null,Lf=e=>{const t=v.useContext(ZB);return e??t};function Fde(e){const t=Yp(),n=Lf(e),r=rm();return Ue(()=>{if(!t)return;const i={id:t,parentId:r};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,r]),t}function Ude(e){const{children:t,id:n}=e,r=rm();return s.jsx(QB.Provider,{value:v.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Hde(e){const{children:t,externalTree:n}=e,r=hs(()=>n??new Bde).current;return s.jsx(ZB.Provider,{value:r,children:t})}function Vde(e,t){const n=tr(or(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const JB=20;let Qu=[];function LE(){Qu=Qu.filter(e=>e.deref()?.isConnected)}function e5(e){LE(),e&&pa(e)!=="body"&&(Qu.push(new WeakRef(e)),Qu.length>JB&&(Qu=Qu.slice(-JB)))}function t5(){return LE(),Qu[Qu.length-1]?.deref()}function Kde(e){return e?vE(e)?e:rx(e)[0]||e:null}function n5(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;const n=fB(e).filter(i=>{const o=i.getAttribute("data-tabindex")||"";return vE(i)||i.hasAttribute("data-tabindex")&&!o.startsWith("-")}),r=e.getAttribute("tabindex");n.length===0?r!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(r!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Kj(e){const{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:o=!0,restoreFocus:c=!1,modal:d=!0,closeOnFocusOut:f=!0,openInteractionType:h="",nextFocusableElement:p,previousFocusableElement:g,beforeContentFocusGuardRef:x,externalTree:y,getInsideElements:j}=e,w="rootStore"in t?t.rootStore:t,S=w.useState("open"),N=w.useState("domReferenceElement"),A=w.useState("floatingElement"),{events:E,dataRef:O}=w.context,R=Fe(()=>O.current.floatingContext?.nodeId),T=i===!1,P=lE(N)&&T,M=Fr(i),_=Fr(o),I=Fr(h),L=Fr(S),D=Lf(y),z=YB(),G=v.useRef(!1),X=v.useRef(!1),Y=v.useRef(!1),F=v.useRef(null),K=v.useRef(""),U=v.useRef(""),q=v.useRef(null),W=v.useRef(null),ne=Ei(q,x,z?.beforeInsideRef),ie=Ei(W,z?.afterInsideRef),V=Ds(),H=Ds(),Q=Zp(),J=z!=null,oe=Cj(A),ee=Fe((te=oe)=>te?rx(te):[]),se=Fe(()=>j?.().filter(te=>te!=null)??[]);v.useEffect(()=>{if(r||!d)return;function te(he){he.key==="Tab"&&nt(oe,ys(vn(oe)))&&ee().length===0&&!P&&_s(he)}const re=vn(oe);return Jt(re,"keydown",te)},[r,oe,d,P,ee]),v.useEffect(()=>{if(r||!S)return;const te=vn(oe);function re(){Y.current=!1}function he(Ne){const me=or(Ne),ce=se(),ae=nt(A,me)||nt(N,me)||nt(z?.portalNode,me)||ce.some(_e=>_e===me||nt(_e,me));Y.current=!ae,U.current=Ne.pointerType||"keyboard",me?.closest(`[${DE}]`)&&(X.current=!0,H.start(0,()=>{X.current=!1}))}function pe(){U.current="keyboard"}return Go(Jt(te,"pointerdown",he,!0),Jt(te,"pointerup",re,!0),Jt(te,"pointercancel",re,!0),Jt(te,"keydown",pe,!0),re)},[r,A,N,oe,S,z,H,se]),v.useEffect(()=>{if(r||!f)return;const te=vn(oe);function re(){X.current=!0,H.start(0,()=>{X.current=!1})}function he(ce){const ae=or(ce);vE(ae)&&(F.current=ae)}function pe(ce){const ae=ce.relatedTarget,_e=ce.currentTarget,de=or(ce);d&&ae==null&&de!=null&&nt(A,de)&&e5(de),queueMicrotask(()=>{const Se=R(),ve=w.context.triggerElements,xe=se(),Re=ae?.hasAttribute(cx("focus-guard"))&&[q.current,W.current,z?.beforeInsideRef.current,z?.afterInsideRef.current,z?.beforeOutsideRef.current,z?.afterOutsideRef.current,Pc(g),Pc(p)].includes(ae),we=!(nt(N,ae)||nt(A,ae)||nt(ae,A)||nt(z?.portalNode,ae)||xe.some(ge=>ge===ae||nt(ge,ae))||ve.hasMatchingElement(ge=>nt(ge,ae))||Re||D&&(Ku(D.nodesRef.current,Se).find(ge=>nt(ge.context?.elements.floating,ae)||nt(ge.context?.elements.domReference,ae))||tB(D.nodesRef.current,Se).find(ge=>[ge.context?.elements.floating,Cj(ge.context?.elements.floating)].includes(ae)||ge.context?.elements.domReference===ae)));if(_e===N&&oe&&n5(oe),c&&_e!==N&&!Pj(de)&&ys(te)===te.body){if(nr(oe)&&(oe.focus(),c==="popup")){Q.request(()=>{oe.focus()});return}const ge=ee(),De=F.current,Ge=(De&&ge.includes(De)?De:null)||ge[ge.length-1]||oe;nr(Ge)&&Ge.focus()}if(O.current.insideReactTree){O.current.insideReactTree=!1;return}(P||!d)&&ae&&we&&!X.current&&(P||ae!==t5())&&(G.current=!0,w.setOpen(!1,at(Xu,ce)))})}function Ne(){Y.current||(O.current.insideReactTree=!0,V.start(0,()=>{O.current.insideReactTree=!1}))}const me=nr(N)?N:null;if(!(!A&&!me))return Go(me&&Jt(me,"focusout",pe),me&&Jt(me,"pointerdown",re),A&&Jt(A,"focusin",he),A&&Jt(A,"focusout",pe),A&&z&&Jt(A,"focusout",Ne,!0))},[r,N,A,oe,d,D,z,w,f,c,ee,P,R,O,V,H,Q,p,g,se]),v.useEffect(()=>{if(r||!A||!S)return;const te=Array.from(z?.portalNode?.querySelectorAll(`[${cx("portal")}]`)||[]),he=(D?tB(D.nodesRef.current,R()):[]).find(_e=>lE(_e.context?.elements.domReference||null))?.context?.elements.domReference,Ne=[...[A,...te,q.current,W.current,z?.beforeOutsideRef.current,z?.afterOutsideRef.current,...se()],he,Pc(g),Pc(p),P?N:null].filter(_e=>_e!=null),me=VB(Ne,{ariaHidden:d||P,mark:!1}),ce=[A,...te].filter(_e=>_e!=null),ae=VB(ce);return()=>{ae(),me()}},[S,r,N,A,d,z,P,D,R,p,g,se]),Ue(()=>{if(!S||r||!nr(oe))return;K.current="",U.current="";const te=vn(oe),re=ys(te);queueMicrotask(()=>{const he=M.current,pe=typeof he=="function"?he(I.current||""):he;if(pe===void 0||pe===!1||nt(oe,re))return;let me=null;const ce=()=>(me==null&&(me=ee(oe)),me[0]||oe);let ae;pe===!0||pe===null?ae=ce():ae=Pc(pe),ae=ae||ce();const _e=nt(oe,ys(te));Hj(ae,{preventScroll:ae===oe,shouldFocus(){if(!L.current)return!1;if(_e)return!0;const de=ys(te);return!(de!==ae&&nt(oe,de))}})})},[r,S,oe,ee,M,I,L]),Ue(()=>{if(r||!oe)return;const te=vn(oe),re=ys(te),he=I.current==null;e5(re);function pe(me){if(me.open||(K.current=Vde(me.nativeEvent,U.current)),me.reason===ma&&me.nativeEvent.type==="mouseleave"&&(G.current=!0),me.reason===$j)if(me.nested)G.current=!1;else if(Aj(me.nativeEvent)||cE(me.nativeEvent))G.current=!1;else{let ce=!1;vn(oe).createElement("div").focus({get preventScroll(){return ce=!0,!1}}),ce?G.current=!1:G.current=!0}}E.on("openchange",pe);function Ne(me){const ce=_.current;let ae=typeof ce=="function"?ce(me):ce;if(ae===void 0||ae===!1)return null;ae===null&&(ae=!0);const _e=N?.isConnected?N:null,de=re?.isConnected&&pa(re)!=="body"?re:null;let Se=he?de||_e:_e||de;return Se||(Se=t5()||null),typeof ae=="boolean"?Se:Pc(ae)||Se||null}return()=>{E.off("openchange",pe);const me=ys(te),ce=se(),ae=nt(A,me)||ce.some(ve=>ve===me||nt(ve,me))||D&&Ku(D.nodesRef.current,R(),!1).some(ve=>nt(ve.context?.elements.floating,me)),_e=_.current,de=K.current,Se=Ne(de);queueMicrotask(()=>{const ve=Kde(Se),xe=typeof _e!="boolean";if(_e&&!G.current&&nr(ve)&&(!(!xe&&ve!==me&&me!==te.body)||ae)){const Re={preventScroll:!0};de==="keyboard"&&(Re.focusVisible=!0),ve.focus(Re)}G.current=!1})}},[r,A,oe,_,I,E,D,N,R,se]),Ue(()=>{if(!Ec||S||!A)return;const te=ys(vn(A));!nr(te)||!kj(te)||nt(A,te)&&te.blur()},[S,A]),Ue(()=>{if(!(r||!z))return z.setFocusManagerState({modal:d,closeOnFocusOut:f,open:S,onOpenChange:w.setOpen,domReference:N}),()=>{z.setFocusManagerState(null)}},[r,z,d,S,w,f,N]),Ue(()=>{if(!(r||!oe))return n5(oe),()=>{queueMicrotask(LE)}},[r,oe]);const le=!r&&(d?!P:!0)&&(J||d);return s.jsxs(v.Fragment,{children:[le&&s.jsx(Df,{"data-type":"inside",ref:ne,onFocus:te=>{if(d){const re=ee();Hj(re[re.length-1])}else z?.portalNode&&(G.current=!1,Qp(te,z.portalNode)?xE(N)?.focus():Pc(g??z.beforeOutsideRef)?.focus())}}),n,le&&s.jsx(Df,{"data-type":"inside",ref:ie,onFocus:te=>{d?Hj(ee()[0]):z?.portalNode&&(f&&(G.current=!0),Qp(te,z.portalNode)?pB(N)?.focus():Pc(p??z.afterOutsideRef)?.focus())}})]})}function dx(e,t={}){const{enabled:n=!0,event:r="click",toggle:i=!0,ignoreMouse:o=!1,stickIfOpen:c=!0,touchOpenDelay:d=0,reason:f=Mc}=t,h="rootStore"in e?e.rootStore:e,p=h.context.dataRef,g=v.useRef(void 0),x=Zp(),y=Ds(),j=v.useMemo(()=>{function w(N,A,E,O){const R=at(f,A,E);N&&O==="touch"&&d>0?y.start(d,()=>{h.setOpen(!0,R)}):h.setOpen(N,R)}function S(N,A,E){const O=p.current.openEvent,R=h.select("domReferenceElement")!==A;return N&&R||!N||!i?!0:O&&c?!E(O.type):!1}return{onPointerDown(N){g.current=qu(N.pointerType,!0)&&cE(N.nativeEvent)?"virtual":N.pointerType},onMouseDown(N){const A=g.current,E=N.nativeEvent,O=h.select("open");if(N.button!==0||r==="click"||qu(A,!0)&&o)return;const R=S(O,N.currentTarget,M=>M==="click"||M==="mousedown"),T=or(E);if(kj(T)){w(R,E,T,A);return}const P=N.currentTarget;x.request(()=>{w(R,E,P,A)})},onClick(N){if(r==="mousedown-only")return;const A=g.current;if(r==="mousedown"&&A){g.current=void 0;return}if(qu(A,!0)&&o)return;const E=h.select("open"),O=S(E,N.currentTarget,R=>R==="click"||R==="mousedown"||R==="keydown"||R==="keyup");w(O,N.nativeEvent,N.currentTarget,A)},onKeyDown(){g.current=void 0}}},[p,r,o,f,h,c,i,x,y,d]);return v.useMemo(()=>n?{reference:j}:rr,[n,j])}function qde(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){const o=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},c=t.axis==="x"||t.axis==="both",d=t.axis==="y"||t.axis==="both",f=["mouseenter","mousemove"].includes(t.dataRef.current.openEvent?.type||"")&&t.pointerType!=="touch";let h=o.width,p=o.height,g=o.x,x=o.y;return n==null&&t.x&&c&&(n=o.x-t.x),r==null&&t.y&&d&&(r=o.y-t.y),g-=n||0,x-=r||0,h=0,p=0,!i||f?(h=t.axis==="y"?o.width:0,p=t.axis==="x"?o.height:0,g=c&&t.x!=null?t.x:g,x=d&&t.y!=null?t.y:x):i&&!f&&(p=t.axis==="x"?o.height:p,h=t.axis==="y"?o.width:h),i=!0,{width:h,height:p,x:g,y:x,top:x,right:g+h,bottom:x+p,left:g}}}}function r5(e){return e!=null&&e.clientX!=null}function Gde(e,t={}){const{enabled:n=!0,axis:r="both"}=t,i="rootStore"in e?e.rootStore:e,o=i.useState("open"),c=i.useState("floatingElement"),d=i.useState("domReferenceElement"),f=i.context.dataRef,h=v.useRef(!1),p=v.useRef(null),[g,x]=v.useState(),[y,j]=v.useState([]),w=Fe(O=>{i.set("positionReference",O)}),S=Fe((O,R,T)=>{h.current||f.current.openEvent&&!r5(f.current.openEvent)||i.set("positionReference",qde(T??d,{x:O,y:R,axis:r,dataRef:f,pointerType:g}))}),N=Fe(O=>{o?p.current||(S(O.clientX,O.clientY,O.currentTarget),j([])):S(O.clientX,O.clientY,O.currentTarget)}),A=qu(g)?c:o;v.useEffect(()=>{if(!n){w(d);return}if(!A)return;function O(){p.current?.(),p.current=null}const R=tr(c);function T(P){const M=or(P);nt(c,M)?O():S(P.clientX,P.clientY)}return!f.current.openEvent||r5(f.current.openEvent)?p.current=Jt(R,"mousemove",T):w(d),O},[A,n,c,f,d,i,S,w,y]),v.useEffect(()=>()=>{i.set("positionReference",null)},[i]),v.useEffect(()=>{n&&!c&&(h.current=!1)},[n,c]),v.useEffect(()=>{!n&&o&&(h.current=!0)},[n,o]);const E=v.useMemo(()=>{function O(R){x(R.pointerType)}return{onPointerDown:O,onPointerEnter:O,onMouseMove:N,onMouseEnter:N}},[N]);return v.useMemo(()=>n?{reference:E,trigger:E}:{},[n,E])}function Yde(){return!1}function Wde(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function fx(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:o="sloppy",referencePress:c=Yde,bubbles:d,externalTree:f}=t,h="rootStore"in e?e.rootStore:e,p=h.useState("open"),g=h.useState("floatingElement"),{dataRef:x,events:y}=h.context,j=Lf(f),w=Fe(typeof i=="function"?i:()=>!1),S=typeof i=="function"?w:i,N=S!==!1,A=Fe(()=>o),{escapeKey:E,outsidePress:O}=Wde(d),R=v.useRef(!1),T=v.useRef(!1),P=v.useRef(!1),M=v.useRef(!1),_=v.useRef(!1),I=v.useRef(""),L=v.useRef(null),D=Ds(),z=Ds(),G=Fe(()=>{z.clear(),x.current.insideReactTree=!1}),X=Fe(V=>{const H=x.current.floatingContext?.nodeId;return(j?Ku(j.nodesRef.current,H):[]).some(J=>J.context?.open&&!J.context.dataRef.current[V])}),Y=Fe(V=>oE(V,h.select("floatingElement"))||oE(V,h.select("domReferenceElement"))),F=Fe(V=>{c()&&h.setOpen(!1,at(Mc,V.nativeEvent))}),K=Fe(V=>{if(!p||!n||!r||V.key!=="Escape"||_.current||!E&&X("__escapeKeyBubbles"))return;const H=rue(V)?V.nativeEvent:V,Q=at(em,H);h.setOpen(!1,Q),Q.isCanceled||V.preventDefault(),!E&&!Q.isPropagationAllowed&&V.stopPropagation()}),U=Fe(()=>{x.current.insideReactTree=!0,z.start(0,G)}),q=Fe(V=>{if(!p||!n||V.button!==0)return;const H=or(V.nativeEvent);nt(h.select("floatingElement"),H)&&(R.current||(R.current=!0,T.current=!1))}),W=Fe(V=>{!p||!n||(V.defaultPrevented||V.nativeEvent.defaultPrevented)&&R.current&&(T.current=!0)});v.useEffect(()=>{function V(H){H.open||(M.current=!1)}return y.on("openchange",V),()=>{y.off("openchange",V)}},[y]),v.useEffect(()=>{if(!p||!n)return p||(M.current=!1),G;x.current.__escapeKeyBubbles=E,x.current.__outsidePressBubbles=O;const V=new oi,H=new oi,Q=vn(g);function J(){V.clear(),_.current=!0}function oe(){V.start(Ec?5:0,()=>{_.current=!1})}function ee(){P.current=!0,H.start(0,()=>{P.current=!1})}function se(){R.current=!1,T.current=!1}function le(){const we=I.current,ge=we==="pen"||!we?"mouse":we,De=A(),Ge=typeof De=="function"?De():De;return typeof Ge=="string"?Ge:Ge[ge]}function te(we){const ge=le();return ge==="intentional"&&we.type!=="click"||ge==="sloppy"&&we.type==="click"}function re(we){const ge=x.current.floatingContext?.nodeId,De=j&&Ku(j.nodesRef.current,ge).some(Ge=>oE(we,Ge.context?.elements.floating));return Y(we)||De}function he(we){if(te(we)){we.type!=="click"&&!Y(we)&&(H.clear(),P.current=!1),G();return}if(x.current.insideReactTree){G();return}const ge=or(we),De=`[${cx("inert")}]`,Ge=Cn(ge)?ge.getRootNode():null,Ot=Array.from((Kp(Ge)?Ge:vn(h.select("floatingElement"))).querySelectorAll(De)),sn=h.context.triggerElements;if(ge&&(sn.hasElement(ge)||sn.hasMatchingElement(Me=>nt(Me,ge))))return;let $t=Cn(ge)?ge:null;for(;$t&&!Bu($t);){const Me=Fu($t);if(Bu(Me)||!Cn(Me))break;$t=Me}if(!(Ot.length&&Cn(ge)&&!tue(ge)&&!nt(ge,h.select("floatingElement"))&&Ot.every(Me=>!nt($t,Me)))){if(nr(ge)&&!("touches"in we)){const Me=Bu(ge),Ht=si(ge),an=/auto|scroll/,Mt=Me||an.test(Ht.overflowX),_t=Me||an.test(Ht.overflowY),Ve=Mt&&ge.clientWidth>0&&ge.scrollWidth>ge.clientWidth,bt=_t&&ge.clientHeight>0&&ge.scrollHeight>ge.clientHeight,Ut=Ht.direction==="rtl",Yt=bt&&(Ut?we.offsetX<=ge.offsetWidth-ge.clientWidth:we.offsetX>ge.clientWidth),yt=Ve&&we.offsetY>ge.clientHeight;if(Yt||yt)return}if(!re(we)){if(le()==="intentional"){if(we.detail!==0&&!Aj(we)&&!M.current)return;if(P.current){H.clear(),P.current=!1;return}}typeof S=="function"&&!S(we)||X("__outsidePressBubbles")||(h.setOpen(!1,at($j,we)),G())}}}function pe(we){le()!=="sloppy"||we.pointerType==="touch"||!h.select("open")||!n||Y(we)||he(we)}function Ne(we){if(le()!=="sloppy"||!h.select("open")||!n||Y(we))return;const ge=we.touches[0];ge&&(L.current={startTime:Date.now(),startX:ge.clientX,startY:ge.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{L.current&&(L.current.dismissOnTouchEnd=!1,L.current.dismissOnMouseDown=!1)}))}function me(we,ge){const De=or(we);if(!De)return;const Ge=Jt(De,we.type,()=>{ge(we),Ge()})}function ce(we){I.current="touch",me(we,Ne)}function ae(we){D.clear(),we.type==="pointerdown"&&(we.button===0&&(M.current=!0),I.current=we.pointerType),!(we.type==="mousedown"&&L.current&&!L.current.dismissOnMouseDown)&&me(we,ge=>{ge.type==="pointerdown"?pe(ge):he(ge)})}function _e(we){if(we.type==="pointercancel"&&(M.current=!1),!R.current)return;const ge=T.current;if(se(),le()==="intentional"){if(we.type==="pointercancel"){ge&&ee();return}if(!re(we)){if(ge){ee();return}typeof S=="function"&&!S(we)||(H.clear(),P.current=!0,G())}}}function de(we){if(le()!=="sloppy"||!L.current||Y(we))return;const ge=we.touches[0];if(!ge)return;const De=Math.abs(ge.clientX-L.current.startX),Ge=Math.abs(ge.clientY-L.current.startY),Ot=Math.sqrt(De*De+Ge*Ge);Ot>5&&(L.current.dismissOnTouchEnd=!0),Ot>10&&(he(we),D.clear(),L.current=null)}function Se(we){me(we,de)}function ve(we){le()!=="sloppy"||!L.current||Y(we)||(L.current.dismissOnTouchEnd&&he(we),D.clear(),L.current=null)}function xe(we){me(we,ve)}const Re=Go(r&&Go(Jt(Q,"keydown",K),Jt(Q,"compositionstart",J),Jt(Q,"compositionend",oe)),N&&Go(Jt(Q,"click",ae,!0),Jt(Q,"pointerdown",ae,!0),Jt(Q,"pointerup",_e,!0),Jt(Q,"pointercancel",_e,!0),Jt(Q,"mousedown",ae,!0),Jt(Q,"mouseup",_e,!0),Jt(Q,"touchstart",ce,{capture:!0,passive:!0}),Jt(Q,"touchmove",Se,{capture:!0,passive:!0}),Jt(Q,"touchend",xe,{capture:!0,passive:!0})));return()=>{Re(),V.clear(),H.clear(),se(),P.current=!1,G()}},[x,g,r,N,S,p,n,E,O,K,G,A,X,Y,j,h,D]);const ne=v.useMemo(()=>({onKeyDown:K,onPointerDown:F,onClick:F}),[K,F]),ie=v.useMemo(()=>({onKeyDown:K,onPointerDown:W,onMouseDown:W,onClickCapture:U,onMouseDownCapture(V){U(),q(V)},onPointerDownCapture(V){U(),q(V)},onMouseUpCapture:U,onTouchEndCapture:U,onTouchMoveCapture:U}),[K,U,q,W]);return v.useMemo(()=>n?{reference:ne,floating:ie,trigger:ne}:{},[n,ne,ie])}function s5(e,t,n){let{reference:r,floating:i}=e;const o=lo(t),c=fE(t),d=dE(c),f=oo(t),h=o==="y",p=r.x+r.width/2-i.width/2,g=r.y+r.height/2-i.height/2,x=r[d]/2-i[d]/2;let y;switch(f){case"top":y={x:p,y:r.y-i.height};break;case"bottom":y={x:p,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:g};break;case"left":y={x:r.x-i.width,y:g};break;default:y={x:r.x,y:r.y}}const j=Rc(t);return j&&(y[c]+=x*(j==="end"?1:-1)*(n&&h?-1:1)),y}async function Xde(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:c,elements:d,strategy:f}=e,{boundary:h="clippingAncestors",rootBoundary:p="viewport",elementContext:g="floating",altBoundary:x=!1,padding:y=0}=Gu(t,e),j=aB(y),S=d[x?g==="floating"?"reference":"floating":g],N=nx(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(S)))==null||n?S:S.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(d.floating)),boundary:h,rootBoundary:p,strategy:f})),A=g==="floating"?{x:r,y:i,width:c.floating.width,height:c.floating.height}:c.reference,E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d.floating)),O=await(o.isElement==null?void 0:o.isElement(E))&&await(o.getScale==null?void 0:o.getScale(E))||{x:1,y:1},R=nx(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:A,offsetParent:E,strategy:f}):A);return{top:(N.top-R.top+j.top)/O.y,bottom:(R.bottom-N.bottom+j.bottom)/O.y,left:(N.left-R.left+j.left)/O.x,right:(R.right-N.right+j.right)/O.x}}const Qde=50,Zde=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:c}=n,d=c.detectOverflow?c:{...c,detectOverflow:Xde},f=await(c.isRTL==null?void 0:c.isRTL(t));let h=await c.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:g}=s5(h,r,f),x=r,y=0;const j={};for(let w=0;wG<=0)){var L,D;const G=(((L=o.flip)==null?void 0:L.index)||0)+1,X=P[G];if(X&&(!(g==="alignment"?A!==lo(X):!1)||I.every(K=>lo(K.placement)===A?K.overflows[0]>0:!0)))return{data:{index:G,overflows:I},reset:{placement:X}};let Y=(D=I.filter(F=>F.overflows[0]<=0).sort((F,K)=>F.overflows[1]-K.overflows[1])[0])==null?void 0:D.placement;if(!Y)switch(y){case"bestFit":{var z;const F=(z=I.filter(K=>{if(T){const U=lo(K.placement);return U===A||U==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(U=>U>0).reduce((U,q)=>U+q,0)]).sort((K,U)=>K[1]-U[1])[0])==null?void 0:z[0];F&&(Y=F);break}case"initialPlacement":Y=d;break}if(i!==Y)return{reset:{placement:Y}}}return{}}}},a5=new Set(["left","top"]);async function efe(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),c=oo(n),d=Rc(n),f=lo(n)==="y",h=a5.has(c)?-1:1,p=o&&f?-1:1,g=Gu(t,e);let{mainAxis:x,crossAxis:y,alignmentAxis:j}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return d&&typeof j=="number"&&(y=d==="end"?j*-1:j),f?{x:y*p,y:x*h}:{x:x*h,y:y*p}}const tfe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:c,middlewareData:d}=t,f=await efe(t,e);return c===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:i+f.x,y:o+f.y,data:{...f,placement:c}}}}},nfe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:o}=t,{mainAxis:c=!0,crossAxis:d=!1,limiter:f={fn:A=>{let{x:E,y:O}=A;return{x:E,y:O}}},...h}=Gu(e,t),p={x:n,y:r},g=await o.detectOverflow(t,h),x=lo(i),y=uE(x);let j=p[y],w=p[x];const S=(A,E)=>nB(E+g[A==="y"?"top":"left"],E,E-g[A==="y"?"bottom":"right"]);c&&(j=S(y,j)),d&&(w=S(x,w));const N=f.fn({...t,[y]:j,[x]:w});return{...N,data:{x:N.x-n,y:N.y-r,enabled:{[y]:c,[x]:d}}}}}},rfe=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:o,placement:c,rects:d,middlewareData:f}=t,{offset:h=0,mainAxis:p=!0,crossAxis:g=!0}=Gu(e,t),x={x:i,y:o},y=lo(c),j=uE(y);let w=x[j],S=x[y];const N=Gu(h,t),A=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(n=N.mainAxis)!=null?n:0,crossAxis:(r=N.crossAxis)!=null?r:0};if(p){const R=j==="y"?"height":"width",T=d.reference[j]-d.floating[R]+A.mainAxis,P=d.reference[j]+d.reference[R]-A.mainAxis;wP&&(w=P)}if(g){var E,O;const R=j==="y"?"width":"height",T=a5.has(oo(c)),P=d.reference[y]-d.floating[R]+(T&&((E=f.offset)==null?void 0:E[y])||0)+(T?0:A.crossAxis),M=d.reference[y]+d.reference[R]+(T?0:((O=f.offset)==null?void 0:O[y])||0)-(T?A.crossAxis:0);SM&&(S=M)}return{[j]:w,[y]:S}}}},sfe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:c=()=>{},...d}=Gu(e,t),f=await i.detectOverflow(t,d),h=oo(n),p=Rc(n),g=lo(n)==="y",{width:x,height:y}=r.floating;let j,w;h==="top"||h==="bottom"?(j=h,w=p===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(w=h,j=p==="end"?"top":"bottom");const S=y-f.top-f.bottom,N=x-f.left-f.right,A=Xp(y-f[j],S),E=Xp(x-f[w],N),O=t.middlewareData.shift,R=!O;let T=A,P=E;O!=null&&O.enabled.x&&(P=N),O!=null&&O.enabled.y&&(T=S),R&&!p&&(g?P=x-2*Tc(f.left,f.right):T=y-2*Tc(f.top,f.bottom)),await c({...t,availableWidth:P,availableHeight:T});const M=await i.getDimensions(o.floating);return x!==M.width||y!==M.height?{reset:{rects:!0}}:{}}}};function i5(e){const t=si(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=nr(e),o=i?e.offsetWidth:n,c=i?e.offsetHeight:r,d=Ej(n)!==o||Ej(r)!==c;return d&&(n=o,r=c),{width:n,height:r,$:d}}function zE(e){return Cn(e)?e:e.contextElement}function sm(e){const t=zE(e);if(!nr(t))return Oc(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=i5(t);let c=(o?Ej(n.width):n.width)/r,d=(o?Ej(n.height):n.height)/i;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const afe=Oc(0);function o5(e){const t=tr(e);return!zA()||!t.visualViewport?afe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ife(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===tr(e)}function zf(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=zE(e);let c=Oc(1);t&&(r?Cn(r)&&(c=sm(r)):c=sm(e));const d=ife(o,n,r)?o5(o):Oc(0);let f=(i.left+d.x)/c.x,h=(i.top+d.y)/c.y,p=i.width/c.x,g=i.height/c.y;if(o&&r){const x=tr(o),y=Cn(r)?tr(r):r;let j=x,w=$A(j);for(;w&&y!==j;){const S=sm(w),N=w.getBoundingClientRect(),A=si(w),E=N.left+(w.clientLeft+parseFloat(A.paddingLeft))*S.x,O=N.top+(w.clientTop+parseFloat(A.paddingTop))*S.y;f*=S.x,h*=S.y,p*=S.x,g*=S.y,f+=E,h+=O,j=tr(w),w=$A(j)}}return nx({width:p,height:g,x:f,y:h})}function qj(e,t){const n=fj(e).scrollLeft;return t?t.left+n:zf(Nc(e)).left+n}function l5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qj(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function ofe(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",c=Nc(r),d=t?dj(t.floating):!1;if(r===c||d&&o)return n;let f={scrollLeft:0,scrollTop:0},h=Oc(1);const p=Oc(0),g=nr(r);if((g||!o)&&((pa(r)!=="body"||Qv(c))&&(f=fj(r)),g)){const y=zf(r);h=sm(r),p.x=y.x+r.clientLeft,p.y=y.y+r.clientTop}const x=c&&!g&&!o?l5(c,f):Oc(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-f.scrollLeft*h.x+p.x+x.x,y:n.y*h.y-f.scrollTop*h.y+p.y+x.y}}function lfe(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function cfe(e){const t=fj(e),n=e.ownerDocument.body,r=Tc(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Tc(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+qj(e);const c=-t.scrollTop;return si(n).direction==="rtl"&&(o+=Tc(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:o,y:c}}const ufe=25;function dfe(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=tr(e),o=Nc(e),c=i.visualViewport;let d=o.clientWidth,f=o.clientHeight,h=0,p=0;if(c){const x=!zA()||t==="fixed";r?x||(h=-c.offsetLeft,p=-c.offsetTop):(d=c.width,f=c.height,x&&(h=c.offsetLeft,p=c.offsetTop))}if(qj(o)<=0){const x=o.ownerDocument,y=x.body,j=getComputedStyle(y),w=x.compatMode==="CSS1Compat"&&parseFloat(j.marginLeft)+parseFloat(j.marginRight)||0,S=Math.abs(o.clientWidth-y.clientWidth-w),N=getComputedStyle(o).scrollbarGutter==="stable both-edges"?S/2:S;N<=ufe&&(d-=N)}return{width:d,height:f,x:h,y:p}}function ffe(e,t){const n=zf(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=sm(e),c=e.clientWidth*o.x,d=e.clientHeight*o.y,f=i*o.x,h=r*o.y;return{width:c,height:d,x:f,y:h}}function c5(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=dfe(e,n,t);else if(t==="document")r=cfe(Nc(e));else if(Cn(t))r=ffe(t,n);else{const i=o5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return nx(r)}function hfe(e,t){const n=t.get(e);if(n)return n;let r=qp(e,[],!1).filter(d=>Cn(d)&&pa(d)!=="body"),i=null;const o=si(e).position==="fixed";let c=o?Fu(e):e;for(;Cn(c)&&!Bu(c);){const d=si(c),f=LA(c),h=i?i.position:o?"fixed":"";!f&&(h==="fixed"||h==="absolute"&&d.position==="static")?r=r.filter(g=>g!==c):i=d,c=Fu(c)}return t.set(e,r),r}function pfe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const c=[...n==="clippingAncestors"?dj(t)?[]:hfe(t,this._c):[].concat(n),r],d=c5(t,c[0],i);let f=d.top,h=d.right,p=d.bottom,g=d.left;for(let x=1;x{d(!1,1e-7)},1e3)}P=!1}try{r=new IntersectionObserver(M,{...T,root:o.ownerDocument})}catch{r=new IntersectionObserver(M,T)}r.observe(e)}const f=tr(e),h=()=>d(n);return f.addEventListener("resize",h),d(!0),()=>{f.removeEventListener("resize",h),c()}}function p5(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:f=!1}=r,h=zE(e),p=i||o?[...h?qp(h):[],...t?qp(t):[]]:[];p.forEach(N=>{i&&N.addEventListener("scroll",n),o&&N.addEventListener("resize",n)});const g=h&&d?bfe(h,n,o):null;let x=-1,y=null;c&&(y=new ResizeObserver(N=>{let[A]=N;A&&A.target===h&&y&&t&&(y.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var E;(E=y)==null||E.observe(t)})),n()}),h&&!f&&y.observe(h),t&&y.observe(t));let j,w=f?zf(e):null;f&&S();function S(){const N=zf(e);w&&!h5(w,N)&&n(),w=N,j=requestAnimationFrame(S)}return n(),()=>{var N;p.forEach(A=>{i&&A.removeEventListener("scroll",n),o&&A.removeEventListener("resize",n)}),g?.(),(N=y)==null||N.disconnect(),y=null,f&&cancelAnimationFrame(j)}}const yfe=tfe,wfe=nfe,jfe=Jde,Sfe=sfe,kfe=rfe,Nfe=(e,t,n)=>{const r=new Map,i=n??{},o={...f5,...i.platform,_c:r};return Zde(e,t,{...i,platform:o})};var Cfe=typeof document<"u",Afe=function(){},Gj=Cfe?v.useLayoutEffect:Afe;function Yj(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Yj(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!Yj(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function m5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function g5(e,t){const n=m5(e);return Math.round(t*n)/n}function BE(e){const t=v.useRef(e);return Gj(()=>{t.current=e}),t}function Efe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:c}={},transform:d=!0,whileElementsMounted:f,open:h}=e,[p,g]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[x,y]=v.useState(r);Yj(x,r)||y(r);const[j,w]=v.useState(null),[S,N]=v.useState(null),A=v.useCallback(K=>{K!==T.current&&(T.current=K,w(K))},[]),E=v.useCallback(K=>{K!==P.current&&(P.current=K,N(K))},[]),O=o||j,R=c||S,T=v.useRef(null),P=v.useRef(null),M=v.useRef(p),_=f!=null,I=BE(f),L=BE(i),D=BE(h),z=v.useCallback(()=>{if(!T.current||!P.current)return;const K={placement:t,strategy:n,middleware:x};L.current&&(K.platform=L.current),Nfe(T.current,P.current,K).then(U=>{const q={...U,isPositioned:D.current!==!1};G.current&&!Yj(M.current,q)&&(M.current=q,br.flushSync(()=>{g(q)}))})},[x,t,n,L,D]);Gj(()=>{h===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,g(K=>({...K,isPositioned:!1})))},[h]);const G=v.useRef(!1);Gj(()=>(G.current=!0,()=>{G.current=!1}),[]),Gj(()=>{if(O&&(T.current=O),R&&(P.current=R),O&&R){if(I.current)return I.current(O,R,z);z()}},[O,R,z,I,_]);const X=v.useMemo(()=>({reference:T,floating:P,setReference:A,setFloating:E}),[A,E]),Y=v.useMemo(()=>({reference:O,floating:R}),[O,R]),F=v.useMemo(()=>{const K={position:n,left:0,top:0};if(!Y.floating)return K;const U=g5(Y.floating,p.x),q=g5(Y.floating,p.y);return d?{...K,transform:"translate("+U+"px, "+q+"px)",...m5(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:q}},[n,d,Y.floating,p.x,p.y]);return v.useMemo(()=>({...p,update:z,refs:X,elements:Y,floatingStyles:F}),[p,z,X,Y,F])}const Tfe=(e,t)=>{const n=yfe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ofe=(e,t)=>{const n=wfe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rfe=(e,t)=>({fn:kfe(e).fn,options:[e,t]}),Pfe=(e,t)=>{const n=jfe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ife=(e,t)=>{const n=Sfe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var FE={exports:{}},UE={};var v5;function Mfe(){if(v5)return UE;v5=1;var e=Vp();function t(g,x){return g===x&&(g!==0||1/g===1/x)||g!==g&&x!==x}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function d(g,x){var y=x(),j=r({inst:{value:y,getSnapshot:x}}),w=j[0].inst,S=j[1];return o(function(){w.value=y,w.getSnapshot=x,f(w)&&S({inst:w})},[g,y,x]),i(function(){return f(w)&&S({inst:w}),g(function(){f(w)&&S({inst:w})})},[g]),c(y),y}function f(g){var x=g.getSnapshot;g=g.value;try{var y=x();return!n(g,y)}catch{return!0}}function h(g,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:d;return UE.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,UE}var x5;function b5(){return x5||(x5=1,FE.exports=Mfe()),FE.exports}var HE=b5(),VE={exports:{}},KE={};var y5;function _fe(){if(y5)return KE;y5=1;var e=Vp(),t=b5();function n(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,d=e.useMemo,f=e.useDebugValue;return KE.useSyncExternalStoreWithSelector=function(h,p,g,x,y){var j=o(null);if(j.current===null){var w={hasValue:!1,value:null};j.current=w}else w=j.current;j=d(function(){function N(T){if(!A){if(A=!0,E=T,T=x(T),y!==void 0&&w.hasValue){var P=w.value;if(y(P,T))return O=P}return O=T}if(P=O,r(E,T))return P;var M=x(T);return y!==void 0&&y(P,M)?(E=T,P):(E=T,O=M)}var A=!1,E,O,R=g===void 0?null:g;return[function(){return N(p())},R===null?void 0:function(){return N(R())}]},[p,g,x,y]);var S=i(h,j[0],j[1]);return c(function(){w.hasValue=!0,w.value=S},[S]),f(S),S},KE}var w5;function Dfe(){return w5||(w5=1,VE.exports=_fe()),VE.exports}var j5=Dfe();const Lfe=qA(19)?$fe:Bfe;function S5(e,t,n,r,i){return Lfe(e,t,n,r,i)}function zfe(e,t,n,r,i){const o=v.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return HE.useSyncExternalStore(e.subscribe,o,o)}jde({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const i of e.syncHooks)n.add(i.store);const r=[];for(const i of n)r.push(i.subscribe(t));return()=>{for(const i of r)i()}}),HE.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function $fe(e,t,n,r,i){const o=wde();if(!o)return zfe(e,t,n,r,i);const c=o.syncIndex;o.syncIndex+=1;let d;return o.didInitialize?(d=o.syncHooks[c],(d.store!==e||d.selector!==t||!Object.is(d.a1,n)||!Object.is(d.a2,r)||!Object.is(d.a3,i))&&(d.store!==e&&(o.didChangeStore=!0),d.store=e,d.selector=t,d.a1=n,d.a2=r,d.a3=i,d.value=t(e.getSnapshot(),n,r,i))):(d={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},o.syncHooks.push(d)),d.value}function Bfe(e,t,n,r,i){return j5.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,r,i))}class Ffe{constructor(t){on(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));on(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}static create(t){return new this(t)}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,r,i){return S5(this,t,n,r,i)}}class $f extends Ffe{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}useSyncedValue(t,n){v.useDebugValue(t);const r=this;Ue(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ue(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);Ue(()=>{n.update(t)},[n,...r])}useControlledProp(t,n){v.useDebugValue(t);const r=this,i=n!==void 0;Ue(()=>{i&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,i])}select(t,n,r,i){const o=this.selectors[t];return o(this.state,n,r,i)}useState(t,n,r,i){return v.useDebugValue(t),S5(this,this.selectors[t],n,r,i)}useContextCallback(t,n){v.useDebugValue(t);const r=Fe(n??Pn);this.context[t]=r}useStateSetter(t){const n=v.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let i=r(this.state);return n(i,i,this),this.subscribe(o=>{const c=r(o);if(!Object.is(i,c)){const d=i;i=c,n(c,d,this)}})}}const Ufe={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};class qE extends $f{constructor(n){const{syncOnly:r,nested:i,onOpenChange:o,triggerElements:c,...d}=n;super({...d,positionReference:d.referenceElement,domReferenceElement:d.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:XB(),nested:i,triggerElements:c},Ufe);on(this,"syncOpenEvent",(n,r)=>{(!n||!this.state.open||r!=null&&sue(r))&&(this.context.dataRef.current.openEvent=n?r:void 0)});on(this,"dispatchOpenChange",(n,r)=>{this.syncOpenEvent(n,r.event);const i={open:n,reason:r.reason,nativeEvent:r.event,nested:this.context.nested,triggerElement:r.trigger};this.context.events.emit("openchange",i)});on(this,"setOpen",(n,r)=>{if(this.syncOnly){this.context.onOpenChange?.(n,r);return}this.dispatchOpenChange(n,r),this.context.onOpenChange?.(n,r)});this.syncOnly=r}}function Hfe(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:o,onOpenChange:c}=e,d=t.useState("open"),f=t.useState("activeTriggerElement"),h=t.useState(n?"popupElement":"positionerElement"),p=t.context.triggerElements,g=c,x=v.useRef(null);r===void 0&&x.current===null&&(x.current=new qE({open:d,transitionStatus:void 0,referenceElement:f,floatingElement:h,triggerElements:p,onOpenChange:g,floatingId:i,syncOnly:!0,nested:o}));const y=r??x.current;return t.useSyncedValue("floatingId",i),Ue(()=>{const j={open:d,floatingId:i,referenceElement:f,floatingElement:h};Cn(f)&&(j.domReferenceElement=f),y.state.positionReference===y.state.referenceElement&&(j.positionReference=f),y.update(j)},[d,i,f,h,y]),y.context.onOpenChange=g,y.context.nested=o,y}const hx={tabIndex:-1,[tE]:""};function k5(e){return t=>t==="touch"?e.current:!0}function GE(e,t=!1){const n=Yp(),r=rm()!=null,i=hs(()=>e(n,r)).current;return Hfe({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function YE({handle:e,store:t}){return Ue(()=>e.attachStore(t),[e,t]),null}function N5(e){const t=e.context.triggerElements.size;e.select("open")&&e.state.triggerCount!==t&&e.set("triggerCount",t)}function Vfe(e,t){const n=v.useRef(null);return Fe(r=>{const i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;const o=i.store;o.context.triggerElements.getById(i.id)===i.element&&(o.context.triggerElements.delete(i.id),N5(o))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),N5(t))})}function WE(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);const o=n?.id??null;let c=e.activeTriggerId,d=e.activeTriggerElement;return(o||t)&&(c=o,d=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:c,activeTriggerElement:d}}function C5(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Kfe(e,t,n,r={}){const i=n.reason,o=i===ma,c=t&&i===zj,d=!t&&(i===Mc||i===em),f=C5(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);const h=()=>{const p=WE(e.state,t,n.trigger,f()),g={...r.extraState,...p};c?g.instantType="focus":d?g.instantType="dismiss":o&&(g.instantType=void 0),e.update(g)};o?br.flushSync(h):h()}function XE(e,t,n,r){const i=n.useState("isMountedByTrigger",e),o=Vfe(e,n),c=Fe(f=>{const h=n.select("open"),p=n.select("activeTriggerId");if(p===e){const g={activeTriggerElement:f,...h?r:null};n.update(g);return}if(p==null&&h){const g={activeTriggerId:e??null,activeTriggerElement:f,...r};n.update(g)}}),d=Fe(f=>{o(f),f&&c(f)});return Ue(()=>(d(t.current),()=>d(null)),[d,t,n,e]),Ue(()=>{if(i){const f={activeTriggerElement:t.current,...r};n.update(f)}},[i,n,t,...Object.values(r)]),{registerTrigger:d,isMountedByThisTrigger:i}}function QE(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,r=v.useRef(null),i=e.useState("open"),o=e.useState("triggerCount"),c=e.useState("activeTriggerId"),d=e.useState("activeTriggerElement");Ue(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0);return}const f=e.context.triggerElements.size,h={};e.state.triggerCount!==f&&(h.triggerCount=f);const p=e.select("activeTriggerId");let g=null;if(p){const x=e.context.triggerElements.getById(p);if(x)r.current=p,x!==e.state.activeTriggerElement&&(h.activeTriggerElement=x);else{for(const[y,j]of e.context.triggerElements.entries())if(j===e.state.activeTriggerElement){h.activeTriggerId=y,h.activeTriggerElement=j,r.current=y;break}h.activeTriggerId===void 0&&(r.current===p?g=p:r.current=null)}}else r.current=null;if(!g&&!p&&f===1){const x=e.context.triggerElements.entries().next();if(!x.done){const[y,j]=x.value;h.activeTriggerId=y,h.activeTriggerElement=j,r.current=y}}(h.triggerCount!==void 0||h.activeTriggerId!==void 0||h.activeTriggerElement!==void 0)&&e.update(h),g&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===g&&!e.context.triggerElements.getById(g)){const x=at(Br);e.setOpen(!1,x),x.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,o,c,d,n])}function ZE(e,t,n,r){const{mounted:i,setMounted:o,transitionStatus:c}=Ic(e,!1,!1,r),d=t.useState("preventUnmountingOnClose"),f=e?!1:d;t.useSyncedValues({mounted:i,transitionStatus:c,preventUnmountingOnClose:f});const h=Fe(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return Va({enabled:i&&!e&&!f,open:e,ref:t.context.popupRef,onComplete(){e||h()}}),{forceUnmount:h,transitionStatus:c}}function JE(e,t){e.useSyncedValues(t),Ue(()=>()=>{e.update({activeTriggerProps:rr,inactiveTriggerProps:rr,popupProps:rr})},[e])}function A5(e,t){Ue(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),Ue(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class Wj{constructor(){this.idMap=new Map}add(t,n){this.idMap.set(t,n)}delete(t){this.idMap.delete(t)}hasElement(t){for(const n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(const n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}}function eT(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new qE({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:rr,inactiveTriggerProps:rr,popupProps:rr}}const px=e=>e.triggerIdProp??e.activeTriggerId,tT=e=>e.openProp??e.open,E5=e=>(e.popupElement?.id??e.floatingId)||void 0;function T5(e,t){return t!==void 0&&tT(e)&&px(e)===t}function qfe(e,t){return T5(e,t)?!0:t!==void 0&&tT(e)&&px(e)==null&&e.triggerCount===1}const nT={open:tT,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:px,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:E5,isTriggerActive:(e,t)=>t!==void 0&&px(e)===t,isOpenedByTrigger:(e,t)=>T5(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&px(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>qfe(e,t)?E5(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function rT(e){const t=v.useCallback(r=>e===void 0?Pn:e.subscribeStore(r),[e]),n=v.useCallback(()=>e===void 0?void 0:e.store,[e]);return HE.useSyncExternalStore(t,n,()=>e?.serverStore)}function O5(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Yp(),o=rm()!=null,c=hs(()=>new qE({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Wj,floatingId:i,syncOnly:!1,nested:o})).current;return Ue(()=>{const d={open:t,floatingId:i};r.reference!==void 0&&(d.referenceElement=r.reference,d.domReferenceElement=Cn(r.reference)?r.reference:null),r.floating!==void 0&&(d.floatingElement=r.floating),c.update(d)},[t,i,r.reference,r.floating,c]),c.context.onOpenChange=n,c.context.nested=o,c}function Gfe(e){return Yfe(e,e.rootContext)}function Yfe(e,t){const{nodeId:n,externalTree:r}=e,i=t.useState("referenceElement"),o=t.useState("floatingElement"),c=t.useState("domReferenceElement"),d=t.useState("open"),f=t.useState("floatingId"),[h,p]=v.useState(null),[g,x]=v.useState(void 0),[y,j]=v.useState(void 0),w=v.useRef(null),S=Lf(r),N=v.useMemo(()=>({reference:i,floating:o,domReference:c}),[i,o,c]),A=Efe({...e,elements:{...N,...h&&{reference:h}}}),E=Cn(g)?g:null,O=y===void 0?t.state.floatingElement:y;t.useSyncedValue("referenceElement",g??null),t.useSyncedValue("domReferenceElement",g===void 0?c:E),t.useSyncedValue("floatingElement",O);const R=v.useCallback(L=>{const D=Cn(L)?{getBoundingClientRect:()=>L.getBoundingClientRect(),getClientRects:()=>L.getClientRects(),contextElement:L}:L;p(D),A.refs.setReference(D)},[A.refs]),T=v.useCallback(L=>{(Cn(L)||L===null)&&(w.current=L,x(L)),(Cn(A.refs.reference.current)||A.refs.reference.current===null||L!==null&&!Cn(L))&&A.refs.setReference(L)},[A.refs,x]),P=v.useCallback(L=>{j(L),A.refs.setFloating(L)},[A.refs]),M=v.useMemo(()=>({...A.refs,setReference:T,setFloating:P,setPositionReference:R,domReference:w}),[A.refs,T,P,R]),_=v.useMemo(()=>({...A.elements,domReference:c}),[A.elements,c]),I=v.useMemo(()=>({...A,dataRef:t.context.dataRef,open:d,onOpenChange:t.setOpen,events:t.context.events,floatingId:f,refs:M,elements:_,nodeId:n,rootStore:t}),[A,M,_,n,t,d,f]);return Ue(()=>{c&&(w.current=c)},[c]),Ue(()=>{t.context.dataRef.current.floatingContext=I;const L=S?.nodesRef.current.find(D=>D.id===n);L&&(L.context=I)}),v.useMemo(()=>({...A,context:I,refs:M,elements:_,rootStore:t}),[A,M,_,I,t])}const sT=Q3&&Ec;function Wfe(e,t={}){const{enabled:n=!0,delay:r}=t,i="rootStore"in e?e.rootStore:e,{events:o,dataRef:c}=i.context,d=v.useRef(!1),f=v.useRef(null),h=v.useRef(!0),p=Ds();v.useEffect(()=>{const x=i.select("domReferenceElement");if(!n)return;const y=tr(x);function j(){const N=i.select("domReferenceElement");!i.select("open")&&nr(N)&&N===ys(vn(N))&&(d.current=!0,f.current=N)}function w(){h.current=!0}function S(){h.current=!1}return Go(Jt(y,"blur",j),sT&&Jt(y,"keydown",w,!0),sT&&Jt(y,"pointerdown",S,!0))},[i,n]),v.useEffect(()=>{if(!n)return;function x(y){if(y.reason===Mc||y.reason===em){const j=i.select("domReferenceElement");Cn(j)&&(f.current=j,d.current=!0)}}return o.on("openchange",x),()=>{o.off("openchange",x)}},[o,n,i]);const g=v.useMemo(()=>{function x(){d.current=!1,f.current=null}return{onMouseLeave(){x()},onFocus(y){const j=y.currentTarget;if(d.current){if(f.current===j)return;x()}const w=or(y.nativeEvent);if(Cn(w)){if(sT&&!y.relatedTarget){if(!h.current&&!kj(w))return}else if(!Nj(w))return}const S=Sj(y.relatedTarget,i.context.triggerElements),{nativeEvent:N,currentTarget:A}=y,E=typeof r=="function"?r():r;if(i.select("open")&&S||E===0||E===void 0){i.setOpen(!0,at(zj,N,A));return}p.start(E,()=>{d.current||i.setOpen(!0,at(zj,N,A))})},onBlur(y){x();const j=y.relatedTarget,w=y.nativeEvent,S=Cn(j)&&j.hasAttribute(cx("focus-guard"))&&j.getAttribute("data-type")==="outside";p.start(0,()=>{const N=i.select("domReferenceElement"),A=ys(vn(N));!j&&A===N||nt(c.current.floatingContext?.refs.floating.current,A)||nt(N,A)||S||Sj(j??A,i.context.triggerElements)||i.setOpen(!1,at(zj,w))})}}},[c,r,i,p]);return v.useMemo(()=>n?{reference:g,trigger:g}:{},[n,g])}class aT{constructor(){on(this,"dispose",()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()});on(this,"disposeEffect",()=>this.dispose);this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new oi,this.restTimeout=new oi,this.handleCloseOptions=void 0}static create(){return new aT}}const Xj=new WeakMap;function Qj(e){if(!e.performedPointerEventsMutation)return;const t=e.pointerEventsScopeElement;t&&Xj.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),Xj.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function R5(e,t){const{scopeElement:n,referenceElement:r,floatingElement:i}=t,o=Xj.get(n);o&&o!==e&&Qj(o),Qj(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Xj.set(n,e),n.style.pointerEvents="none",r.style.pointerEvents="auto",i.style.pointerEvents="auto"}function iT(e){const t=e.context.dataRef.current,n=hs(()=>t.hoverInteractionState??aT.create()).current;return t.hoverInteractionState||(t.hoverInteractionState=n),Ij(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function P5(e,t={}){const{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,o="rootStore"in e?e.rootStore:e,c=o.useState("open"),d=o.useState("floatingElement"),f=o.useState("domReferenceElement"),{dataRef:h}=o.context,p=Lf(),g=rm(),x=iT(o),y=Ds(),j=Fe(()=>LB(h.current.openEvent?.type,x.interactedInside)),w=Fe(()=>Nde(h.current.openEvent?.type)),S=Fe(()=>{Qj(x)});Ue(()=>{c||(x.pointerType=void 0,x.restTimeoutPending=!1,x.interactedInside=!1,S())},[c,x,S]),v.useEffect(()=>S,[S]),Ue(()=>{if(n&&c&&x.handleCloseOptions?.blockPointerEvents&&w()&&Cn(f)&&d){const N=f,A=d,E=vn(d),O=p?.nodesRef.current.find(M=>M.id===g)?.context?.elements.floating;O&&(O.style.pointerEvents="");const R=x.pointerEventsScopeElement!==A?x.pointerEventsScopeElement:null,T=O!==A?O:null,P=x.handleCloseOptions?.getScope?.()??R??T??N.closest("[data-rootownerid]")??E.body;return R5(x,{scopeElement:P,referenceElement:N,floatingElement:A}),()=>{S()}}},[n,c,f,d,x,w,p,g,S]),v.useEffect(()=>{if(!n)return;function N(){return!!(p&&g&&Ku(p.nodesRef.current,g).length>0)}function A(M){const _=_f(r,"close",x.pointerType),I=()=>{o.setOpen(!1,at(ma,M)),p?.events.emit("floating.closed",M)};_?x.openChangeTimeout.start(_,I):(x.openChangeTimeout.clear(),I())}function E(M){const _=or(M);if(!nue(_)){x.interactedInside=!1;return}x.interactedInside=_?.closest("[aria-haspopup]")!=null}function O(){x.openChangeTimeout.clear(),y.clear(),p?.events.off("floating.closed",T),S()}function R(M){if(N()&&p){p.events.on("floating.closed",T);return}if(Sj(M.relatedTarget,o.context.triggerElements))return;const _=h.current.floatingContext?.nodeId??i,I=M.relatedTarget;if(!(p&&_&&Cn(I)&&Ku(p.nodesRef.current,_,!1).some(D=>nt(D.context?.elements.floating,I)))){if(x.handler){x.handler(M);return}S(),w()&&!j()&&A(M)}}function T(M){!p||!g||N()||y.start(0,()=>{p.events.off("floating.closed",T),o.setOpen(!1,at(ma,M)),p.events.emit("floating.closed",M)})}const P=d;return Go(P&&Jt(P,"mouseenter",O),P&&Jt(P,"mouseleave",R),P&&Jt(P,"pointerdown",E,!0),()=>{p?.events.off("floating.closed",T)})},[n,d,o,h,r,i,w,j,S,x,p,g,y])}const Xfe={current:null};function I5(e,t={}){const{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:o=!1,restMs:c=0,move:d=!0,triggerElementRef:f=Xfe,externalTree:h,isActiveTrigger:p=!0,getHandleCloseContext:g,isClosing:x,shouldOpen:y,guardStaleOpen:j=!1}=t,w="rootStore"in e?e.rootStore:e,{dataRef:S,events:N}=w.context,A=Lf(h),E=iT(w),O=v.useRef(!1),R=Fr(i),T=Fr(r),P=Fr(c),M=Fr(n),_=Fr(y),I=Fr(x),L=Fe(()=>LB(S.current.openEvent?.type,E.interactedInside)),D=Fe(()=>_.current?.()!==!1),z=Fe((Y,F,K)=>{const U=w.context.triggerElements;if(U.hasElement(F))return!Y||!nt(Y,F);if(!Cn(K))return!1;const q=K;return U.hasMatchingElement(W=>nt(W,q))&&(!Y||!nt(Y,q))}),G=Fe(()=>{if(!E.handler)return;vn(w.select("domReferenceElement")).removeEventListener("mousemove",E.handler),E.handler=void 0}),X=Fe(()=>{Qj(E)});return p&&(E.handleCloseOptions=i?.__options),v.useEffect(()=>G,[G]),v.useEffect(()=>{if(!n)return;function Y(F){F.open?O.current=!1:(O.current=F.reason===ma,G(),E.openChangeTimeout.clear(),E.restTimeout.clear(),E.blockMouseMove=!0,E.restTimeoutPending=!1)}return N.on("openchange",Y),()=>{N.off("openchange",Y)}},[n,N,E,G]),v.useEffect(()=>{if(!n)return;function Y(ne,ie=!0){const V=_f(T.current,"close",E.pointerType);V?E.openChangeTimeout.start(V,()=>{w.setOpen(!1,at(ma,ne)),A?.events.emit("floating.closed",ne)}):ie&&(E.openChangeTimeout.clear(),w.setOpen(!1,at(ma,ne)),A?.events.emit("floating.closed",ne))}const F=f.current??(p?w.select("domReferenceElement"):null);if(!Cn(F))return;function K(ne){if(E.openChangeTimeout.clear(),E.blockMouseMove=!1,o&&!qu(E.pointerType))return;const ie=DB(P.current),V=_f(T.current,"open",E.pointerType),H=or(ne),Q=ne.currentTarget??null,J=w.select("domReferenceElement");let oe=Q;if(Cn(H)&&!w.context.triggerElements.hasElement(H)){for(const me of w.context.triggerElements.elements())if(nt(me,H)){oe=me;break}}Cn(Q)&&Cn(J)&&!w.context.triggerElements.hasElement(Q)&&nt(Q,J)&&(oe=J);const ee=oe==null?!1:z(J,oe,H),se=w.select("open"),le=I.current?.()??w.select("transitionStatus")==="ending",te=!se&&le&&O.current,re=!ee&&Cn(oe)&&Cn(J)&&nt(J,oe)&&te,he=ie>0&&!V,pe=ee&&(se||te)||re,Ne=!se||ee;if(pe){D()&&w.setOpen(!0,at(ma,ne,oe));return}he||(V?E.openChangeTimeout.start(V,()=>{Ne&&D()&&w.setOpen(!0,at(ma,ne,oe))}):Ne&&D()&&w.setOpen(!0,at(ma,ne,oe)))}function U(ne){if(L()){X();return}G();const ie=w.select("domReferenceElement"),V=vn(ie);E.restTimeout.clear(),E.restTimeoutPending=!1;const H=S.current.floatingContext??g?.();if(Sj(ne.relatedTarget,w.context.triggerElements))return;if(R.current&&H){w.select("open")||E.openChangeTimeout.clear();const J=f.current;E.handler=R.current({...H,tree:A,x:ne.clientX,y:ne.clientY,onClose(){X(),G(),M.current&&!L()&&J===w.select("domReferenceElement")&&Y(ne,!0)}}),V.addEventListener("mousemove",E.handler),E.handler(ne);return}(E.pointerType!=="touch"||!nt(w.select("floatingElement"),ne.relatedTarget))&&Y(ne)}function q(ne){nt(F,ne.relatedTarget)||(E.openChangeTimeout.clear(),E.restTimeout.clear(),E.restTimeoutPending=!1)}const W=j?Jt(F,"mouseout",q):void 0;return d?Go(Jt(F,"mousemove",K,{once:!0}),Jt(F,"mouseenter",K),Jt(F,"mouseleave",U),W):Go(Jt(F,"mouseenter",K),Jt(F,"mouseleave",U),W)},[G,X,S,T,w,n,R,E,p,z,L,o,d,P,f,A,M,g,I,D,j]),v.useMemo(()=>{if(!n)return;function Y(F){E.pointerType=F.pointerType}return{onPointerDown:Y,onPointerEnter:Y,onMouseMove(F){const{nativeEvent:K}=F,U=F.currentTarget,q=w.select("domReferenceElement"),W=w.select("open"),ne=z(q,U,F.target);if(o&&!qu(E.pointerType))return;if(W&&ne&&E.handleCloseOptions?.blockPointerEvents){const H=w.select("floatingElement");if(H){const Q=E.handleCloseOptions?.getScope?.()??U.ownerDocument.body;R5(E,{scopeElement:Q,referenceElement:U,floatingElement:H})}}const ie=DB(P.current);if(W&&!ne||ie===0||!ne&&E.restTimeoutPending&&F.movementX**2+F.movementY**2<2)return;E.restTimeout.clear();function V(){if(E.restTimeoutPending=!1,L())return;const H=w.select("open");!E.blockMouseMove&&(!H||ne)&&D()&&w.setOpen(!0,at(ma,K,U))}E.pointerType==="touch"?br.flushSync(()=>{V()}):ne&&W?V():(E.restTimeoutPending=!0,E.restTimeout.start(ie,V))}}},[n,E,L,z,o,w,P,D])}const Qfe="Escape";function M5(e){return Ec&&e.movementX===0&&e.movementY===0}function Zj(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Jj(e,t){return Zj(t,e===nE||e===wj,e===Pf||e===If)}function oT(e,t,n){return Zj(t,e===wj,n?e===Pf:e===If)||e==="Enter"||e===" "||e===""}function Zfe(e,t,n){return Zj(t,n?e===Pf:e===If,e===wj)}function Jfe(e,t,n,r){const i=n?e===If:e===Pf,o=e===nE;return t==="both"||t==="horizontal"&&r?e===Qfe:Zj(t,i,o)}function _5(e,t){const{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:o=!0,selectedIndex:c=null,allowEscape:d=!1,loopFocus:f=!1,nested:h=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:x="auto",focusItemOnHover:y=!0,openOnArrowKeyDown:j=!0,disabledIndices:w=void 0,orientation:S="vertical",parentOrientation:N,id:A,resetOnPointerLeave:E=!0,externalTree:O,grid:R}=t,T=R!=null,P="rootStore"in e?e.rootStore:e,M=P.useState("open"),_=P.useState("floatingElement"),I=P.useState("domReferenceElement"),L=P.context.dataRef,D=Cj(_),z=lE(I),G=Fr(D),X=rm(),Y=Lf(O),F=v.useRef(x),K=v.useRef(c??-1),U=v.useRef(null),q=v.useRef(!0),W=Fe(xe=>{i(K.current===-1?null:K.current,xe)}),ne=v.useRef(!!_),ie=v.useRef(M),V=v.useRef(!1),H=v.useRef(!1),Q=v.useRef(null),J=Fr(w),oe=Fr(M),ee=Fr(c),se=Fr(E),le=Zp(),te=Zp(),re=Fe(()=>{function xe(De){g?Y?.events.emit("virtualfocus",De):Q.current=Hj(De,{sync:V.current,preventScroll:!0})}const Re=n.current[K.current],we=H.current;Re&&xe(Re),(V.current?De=>De():De=>le.request(De))(()=>{const De=n.current[K.current]||Re;if(!De)return;Re||xe(De),ae&&(we||!q.current)&&De.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Ue(()=>{L.current.orientation=S},[L,S]),Ue(()=>{o&&(M&&_?(K.current=c??-1,F.current&&c!=null&&(H.current=!0,W())):ne.current&&(K.current=-1,W()))},[o,M,_,c,W]),Ue(()=>{if(o){if(!M){V.current=!1;return}if(_)if(r==null){if(V.current=!1,ee.current!=null)return;if(ne.current&&(K.current=-1,re()),(!ie.current||!ne.current)&&F.current&&(U.current!=null||F.current===!0&&U.current==null)){let xe=0;const Re=()=>{n.current[0]==null?(xe<2&&(xe?ge=>te.request(ge):queueMicrotask)(Re),xe+=1):(K.current=U.current==null||oT(U.current,S,p)||h?Rj(n):pE(n),U.current=null,W())};Re()}}else Yu(n.current,r)||(K.current=r,re(),H.current=!1)}},[o,M,_,r,ee,h,n,S,p,W,re,te]),Ue(()=>{if(!o||_||!Y||g||!ne.current)return;const xe=Y.nodesRef.current,Re=xe.find(De=>De.id===X)?.context?.elements.floating,we=ys(vn(I??Re??null)),ge=xe.some(De=>De.context&&nt(De.context.elements.floating,we));Re&&!ge&&q.current&&Re.focus({preventScroll:!0})},[o,_,I,Y,X,g]),Ue(()=>{ie.current=M,ne.current=!!_}),Ue(()=>{M||(U.current=null,F.current=x)},[M,x]);const he=r!=null,pe=Fe(xe=>{if(!oe.current)return;const Re=n.current.indexOf(xe.currentTarget);Re!==-1&&(K.current!==Re||r!==Re)&&(K.current=Re,W(xe))}),Ne=Fe(()=>N??Y?.nodesRef.current.find(xe=>xe.id===X)?.context?.dataRef?.current.orientation),me=Fe(()=>Rj(n,J.current)),ce=Fe(xe=>{if(q.current=!1,V.current=!0,xe.which===229||!oe.current&&xe.currentTarget===G.current)return;if(h&&Jfe(xe.key,S,p,T)){Jj(xe.key,Ne())||_s(xe),P.setOpen(!1,at(kE,xe.nativeEvent)),nr(I)&&(g?Y?.events.emit("virtualfocus",I):I.focus());return}const Re=K.current,we=Rj(n,w),ge=pE(n,w);if(z||(xe.key==="Home"&&(_s(xe),K.current=we,W(xe)),xe.key==="End"&&(_s(xe),K.current=ge,W(xe))),R!=null){const De=R(xe,K.current,n,S,f,p,w,we,ge);if(De!=null&&(K.current=De,W(xe)),S==="both")return}if(Jj(xe.key,S)){if(_s(xe),M&&!g&&ys(xe.currentTarget.ownerDocument)===xe.currentTarget){K.current=oT(xe.key,S,p)?we:ge,W(xe);return}oT(xe.key,S,p)?f?Re>=ge?d&&Re!==n.current.length?K.current=-1:(V.current=!1,K.current=we):K.current=Js(n.current,{startingIndex:Re,disabledIndices:w}):K.current=Math.min(ge,Js(n.current,{startingIndex:Re,disabledIndices:w})):f?Re<=we?d&&Re!==-1?K.current=n.current.length:(V.current=!1,K.current=ge):K.current=Js(n.current,{startingIndex:Re,decrement:!0,disabledIndices:w}):K.current=Math.max(we,Js(n.current,{startingIndex:Re,decrement:!0,disabledIndices:w})),Yu(n.current,K.current)&&(K.current=-1),W(xe)}}),ae=v.useMemo(()=>({onFocus(Re){V.current=!0,pe(Re)},onClick:({currentTarget:Re})=>Re.focus({preventScroll:!0}),onMouseMove(Re){M5(Re)||(V.current=!0,H.current=!1,y&&pe(Re))},onPointerLeave(Re){if(!oe.current||!q.current||Re.pointerType==="touch")return;V.current=!0;const we=Re.relatedTarget;if(!(!y||n.current.includes(we))&&se.current&&(Q.current?.(),Q.current=null,K.current=-1,W(Re),!g)){const ge=G.current,De=ys(vn(ge));ge&&nt(ge,De)&&ge.focus({preventScroll:!0})}}}),[pe,oe,G,y,n,W,se,g]),_e=v.useMemo(()=>g&&M&&he&&{"aria-activedescendant":`${A}-${r}`},[g,M,he,A,r]),de=v.useMemo(()=>({...z?{}:_e,onKeyDown(xe){if(xe.key==="Tab"&&xe.shiftKey&&M&&!g){const Re=or(xe.nativeEvent);if(Re&&!nt(G.current,Re))return;_s(xe),P.setOpen(!1,at(Xu,xe.nativeEvent)),nr(I)&&I.focus();return}ce(xe)},onPointerMove(xe){M5(xe)||(q.current=!0)}}),[_e,ce,G,z,P,M,g,I]),Se=v.useMemo(()=>{function xe(ge){P.setOpen(!0,at(kE,ge.nativeEvent,ge.currentTarget))}function Re(ge){x==="auto"&&Aj(ge.nativeEvent)&&(F.current=!g)}function we(ge){F.current=x,x==="auto"&&cE(ge.nativeEvent)&&(F.current=!0)}return{onKeyDown(ge){const De=P.select("open");q.current=!1;const Ge=ge.key.startsWith("Arrow"),Ot=Zfe(ge.key,Ne(),p),sn=Jj(ge.key,S),$t=(h?Ot:sn)||ge.key==="Enter"||ge.key.trim()==="";if(g&&De)return ce(ge);if(!(!De&&!j&&Ge)){if($t){const Me=Jj(ge.key,Ne());U.current=h&&Me?null:ge.key}if(h){Ot&&(_s(ge),De?(K.current=me(),W(ge)):xe(ge));return}sn&&(ee.current!=null&&(K.current=ee.current),_s(ge),!De&&j?xe(ge):ce(ge),De&&W(ge))}},onFocus(ge){P.select("open")&&!g&&(K.current=-1,W(ge))},onPointerDown:we,onPointerEnter:we,onMouseDown:Re,onClick:Re}},[ce,x,me,h,W,P,j,S,Ne,p,ee,g]),ve=v.useMemo(()=>({..._e,...Se}),[_e,Se]);return v.useMemo(()=>o?{reference:ve,floating:de,item:ae,trigger:Se}:{},[o,ve,de,Se,ae])}function D5(e,t){const{listRef:n,elementsRef:r,activeIndex:i,onMatch:o,disabledIndices:c,onTyping:d,enabled:f=!0,resetMs:h=750,selectedIndex:p=null}=t,g="rootStore"in e?e.rootStore:e,x=g.useState("open"),y=Ds(),j=v.useRef(""),w=v.useRef(p??i??-1),S=v.useRef(null),N=Fe(O=>{function R(G){return r?.current[G]}function T(G){const X=R(G);return X&&!Pj(X)||X?.matches(":disabled")?!1:c==null||!Wu(Ti,G,c)}function P(G,X,Y=0){if(G.length===0)return-1;const F=(Y%G.length+G.length)%G.length,K=X.toLowerCase();for(let U=0;U0&&O.key===" "&&(_s(O),d?.(!0)),j.current.length>0&&j.current[0]!==" "&&P(M,j.current)===-1&&O.key!==" "&&d?.(!1),M==null||O.key.length!==1||O.ctrlKey||O.metaKey||O.altKey)return;x&&O.key!==" "&&(_s(O),d?.(!0));const _=j.current==="";_&&(w.current=p??i??-1),M.every((G,X)=>G&&T(X)?G[0]?.toLowerCase()!==G[1]?.toLowerCase():!0)&&j.current===O.key&&(j.current="",w.current=S.current),j.current+=O.key,y.start(h,()=>{j.current="",w.current=S.current,d?.(!1)});const D=((_?p??i??-1:w.current)??0)+1,z=P(M,j.current,D);z!==-1?(o?.(z),S.current=z):O.key!==" "&&(j.current="",d?.(!1))}),A=Fe(O=>{const R=O.relatedTarget,T=g.select("domReferenceElement"),P=g.select("floatingElement");nt(T,R)||nt(P,R)||(y.clear(),j.current="",w.current=S.current,d?.(!1))});Ue(()=>{!x&&p!==null||(y.clear(),S.current=null,j.current!==""&&(j.current=""))},[x,p,y]);const E=v.useMemo(()=>({onKeyDown:N,onBlur:A}),[N,A]);return v.useMemo(()=>f?{reference:E,floating:E}:{},[f,E])}const L5=.1,ehe=L5*L5,mr=.5;function e0(e,t,n,r,i,o){return r>=t!=o>=t&&e<=(i-n)*(t-r)/(o-r)+n}function t0(e,t,n,r,i,o,c,d,f,h){let p=!1;return e0(e,t,n,r,i,o)&&(p=!p),e0(e,t,i,o,c,d)&&(p=!p),e0(e,t,c,d,f,h)&&(p=!p),e0(e,t,f,h,n,r)&&(p=!p),p}function the(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function n0(e,t,n,r,i,o){const c=Math.min(n,i),d=Math.max(n,i),f=Math.min(r,o),h=Math.max(r,o);return e>=c&&e<=d&&t>=f&&t<=h}function z5(e={}){const{blockPointerEvents:t=!1}=e,n=new oi,r=({x:i,y:o,placement:c,elements:d,onClose:f,nodeId:h,tree:p})=>{const g=c?.split("-")[0];let x=!1,y=null,j=null,w=typeof performance<"u"?performance.now():0;function S(A,E){const O=performance.now(),R=O-w;if(y===null||j===null||R===0)return y=A,j=E,w=O,!1;const T=A-y,P=E-j,M=T*T+P*P,_=R*R*ehe;return y=A,j=E,w=O,M<_}function N(){n.clear(),f()}return function(E){n.clear();const O=d.domReference,R=d.floating;if(!O||!R||g==null||i==null||o==null)return;const{clientX:T,clientY:P}=E,M=or(E),_=E.type==="mouseleave",I=nt(R,M),L=nt(O,M);if(I&&(x=!0,!_))return;if(L&&(x=!1,!_)){x=!0;return}if(_&&Cn(E.relatedTarget)&&nt(R,E.relatedTarget))return;function D(){return!!(p&&Ku(p.nodesRef.current,h).length>0)}function z(){D()||N()}if(D())return;const G=O.getBoundingClientRect(),X=R.getBoundingClientRect(),Y=i>X.right-X.width/2,F=o>X.bottom-X.height/2,K=X.width>G.width,U=X.height>G.height,q=(K?G:X).left,W=(K?G:X).right,ne=(U?G:X).top,ie=(U?G:X).bottom;if(g==="top"&&o>=G.bottom-1||g==="bottom"&&o<=G.top+1||g==="left"&&i>=G.right-1||g==="right"&&i<=G.left+1){z();return}let V=!1;switch(g){case"top":V=n0(T,P,q,G.top+1,W,X.bottom-1);break;case"bottom":V=n0(T,P,q,X.top+1,W,G.bottom-1);break;case"left":V=n0(T,P,X.right-1,ie,G.left+1,ne);break;case"right":V=n0(T,P,G.right-1,ie,X.left+1,ne);break}if(V)return;if(x&&!the(T,P,G)){z();return}if(!_&&S(T,P)){z();return}let H=!1;switch(g){case"top":{const Q=K?mr/2:mr*4,J=K||Y?i+Q:i-Q,oe=K?i-Q:Y?i+Q:i-Q,ee=o+mr+1,se=Y||K?X.bottom-mr:X.top,le=Y?K?X.bottom-mr:X.top:X.bottom-mr;H=t0(T,P,J,ee,oe,ee,X.left,se,X.right,le);break}case"bottom":{const Q=K?mr/2:mr*4,J=K||Y?i+Q:i-Q,oe=K?i-Q:Y?i+Q:i-Q,ee=o-mr,se=Y||K?X.top+mr:X.bottom,le=Y?K?X.top+mr:X.bottom:X.top+mr;H=t0(T,P,J,ee,oe,ee,X.left,se,X.right,le);break}case"left":{const Q=U?mr/2:mr*4,J=U||F?o+Q:o-Q,oe=U?o-Q:F?o+Q:o-Q,ee=i+mr+1,se=F||U?X.right-mr:X.left,le=F?U?X.right-mr:X.left:X.right-mr;H=t0(T,P,se,X.top,le,X.bottom,ee,J,ee,oe);break}case"right":{const Q=U?mr/2:mr*4,J=U||F?o+Q:o-Q,oe=U?o-Q:F?o+Q:o-Q,ee=i-mr,se=F||U?X.left+mr:X.right,le=F?U?X.left+mr:X.right:X.left+mr;H=t0(T,P,ee,J,ee,oe,se,X.top,le,X.bottom);break}}H?x||n.start(40,z):z()}};return r.__options={...e,blockPointerEvents:t},r}const nhe={...nT,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class rhe extends $f{constructor(n,r,i){const o=new Wj;super(she(n,o,r,i),ahe(o),nhe);on(this,"setOpen",(n,r)=>{Kfe(this,n,r,{extraState:{openChangeReason:r.reason}})})}cancelPendingOpen(n){this.state.floatingRootContext.dispatchOpenChange(!1,at(Mc,n))}}function she(e,t,n,r=!1){return{...eT(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function ahe(e){return{popupRef:v.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}const ihe=Fj(function(t){const{disabled:n=!1,defaultOpen:r=!1,open:i,disableHoverablePopup:o=!1,trackCursorAxis:c="none",actionsRef:d,onOpenChange:f,onOpenChangeComplete:h,handle:p,triggerId:g,defaultTriggerId:x=null,children:y}=t,j=GE((L,D)=>new rhe({open:r,openProp:i,activeTriggerId:x,triggerIdProp:g},L,D));j.useControlledProp("openProp",i),j.useControlledProp("triggerIdProp",g),j.useContextCallback("onOpenChange",f),j.useContextCallback("onOpenChangeComplete",h);const w=j.useState("open"),S=!n&&w,N=j.useState("activeTriggerId"),A=j.useState("mounted"),E=j.useState("payload");j.useSyncedValues({trackCursorAxis:c,disableHoverablePopup:o,disabled:n}),QE(j,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:O,transitionStatus:R}=ZE(S,j),T=j.useState("isInstantPhase"),P=j.useState("instantType"),M=j.useState("lastOpenChangeReason"),_=v.useRef(null);Ue(()=>{w&&n&&j.setOpen(!1,at(Due))},[w,n,j]),Ue(()=>{R==="ending"&&M===Br||R!=="ending"&&T?(P!=="delay"&&(_.current=P),j.set("instantType","delay")):_.current!==null&&(j.set("instantType",_.current),_.current=null)},[R,T,M,P,j]),Ue(()=>{S&&N==null&&j.set("payload",void 0)},[j,N,S]),v.useImperativeHandle(d,()=>({unmount:O,close:()=>j.setOpen(!1,at(NE))}),[O,j]);const I=S||A||!n&&c!=="none";return s.jsxs(_B.Provider,{value:j,children:[p&&s.jsx(YE,{handle:p,store:j}),I&&s.jsx(ohe,{store:j,disabled:n,trackCursorAxis:c}),typeof y=="function"?y({payload:E}):y]})});function ohe({store:e,disabled:t,trackCursorAxis:n}){const r=e.useState("floatingRootContext"),i=fx(r,{enabled:!t,referencePress:()=>e.select("closeOnClick")}),o=Gde(r,{enabled:!t&&n!=="none",axis:n==="none"?void 0:n}),c=v.useMemo(()=>Ai(o.reference,i.reference),[o.reference,i.reference]);return JE(e,{activeTriggerProps:c,inactiveTriggerProps:c,popupProps:i.floating??rr}),null}const $5=v.createContext(void 0);function lhe(){return v.useContext($5)}const che=600,B5="data-base-ui-tooltip-trigger";function F5(e){if("composedPath"in e){const n=e.composedPath();for(let r=0;rS.select("transitionStatus")==="ending",shouldOpen(){return!q.current}}),J=Wfe(O,{enabled:!Y}).reference,oe=re=>{const he=q.current,pe=F5(re),Ne=H(pe),me=R.current,ce=me&&pe&&nt(me,pe);if(Ne&&S.select("open")&&S.select("lastOpenChangeReason")===ma){S.setOpen(!1,at(ma,re));return}if(he&&!Ne&&ce&&!F.current&&!S.select("open")&&me&&qu(ne.current)){const ae=()=>{!q.current&&!F.current&&!S.select("open")&&S.setOpen(!0,at(ma,re,me))},_e=ie();_e===0?(W.clear(),ae()):W.start(_e,ae)}},ee=S.useState("triggerProps",M);return wt("button",t,{state:{open:E},ref:[n,P,R],props:[Q,J,M||K!=="none"?ee:void 0,{onMouseOver(re){oe(re.nativeEvent)},onFocus(re){V(F5(re.nativeEvent))&&re.preventBaseUIHandler()},onMouseLeave(){q.current=!1,W.clear(),ne.current=void 0},onPointerEnter(re){ne.current=re.pointerType},onPointerDown(re){ne.current=re.pointerType,S.set("closeOnClick",p),p&&!S.select("open")&&S.cancelPendingOpen(re.nativeEvent)},onClick(re){p&&!S.select("open")&&S.cancelPendingOpen(re.nativeEvent)},id:N,[iE]:Y?"":void 0,[B5]:Y?void 0:""},y],stateAttributesMapping:jj})}),U5=v.createContext(void 0);function fhe(){const e=v.useContext(U5);if(e===void 0)throw new Error(En(70));return e}const H5=v.forwardRef(function(t,n){const{children:r,container:i,className:o,render:c,style:d,...f}=t,{node:h,subtree:p}=WB({container:i,ref:n,componentProps:t,elementProps:f});return!p&&!h?null:s.jsxs(v.Fragment,{children:[p,h&&br.createPortal(r,h)]})}),hhe=v.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t;return lx().useState("mounted")||r?s.jsx(U5.Provider,{value:r,children:s.jsx(H5,{ref:n,...i})}):null}),V5=v.createContext(void 0);function K5(){const e=v.useContext(V5);if(e===void 0)throw new Error(En(71));return e}const phe=v.createContext(void 0);function mx(){return v.useContext(phe)?.direction??"ltr"}const mhe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:c,elements:d,middlewareData:f}=t,{element:h,padding:p=0,offsetParent:g="real"}=Gu(e,t)||{};if(h==null)return{};const x=aB(p),y={x:n,y:r},j=fE(i),w=dE(j),S=await c.getDimensions(h),N=j==="y",A=N?"top":"left",E=N?"bottom":"right",O=N?"clientHeight":"clientWidth",R=o.reference[w]+o.reference[j]-y[j]-o.floating[w],T=y[j]-o.reference[j],P=g==="real"?await c.getOffsetParent?.(h):d.floating;let M=d.floating[O]||o.floating[w];(!M||!await c.isElement?.(P))&&(M=d.floating[O]||o.floating[w]);const _=R/2-T/2,I=M/2-S[w]/2-1,L=Math.min(x[A],I),D=Math.min(x[E],I),z=L,G=M-S[w]-D,X=M/2-S[w]/2+_,Y=nB(z,X,G),F=!f.arrow&&Rc(i)!=null&&X!==Y&&o.reference[w]/2-(X{const{name:n,fn:r}=mhe(e);return{name:n,fn:r,options:[e,t]}},vhe={name:"hide",async fn(e){const{width:t,height:n,x:r,y:i}=e.rects.reference,o=t===0&&n===0&&r===0&&i===0,c=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:c.top-n>=0||c.right-t>=0||c.bottom-n>=0||c.left-t>=0||o}}}},xhe={sideX:"left",sideY:"top"},bhe="--available-width",yhe="--available-height",whe="--anchor-width",jhe="--anchor-height",She="--transform-origin",q5=bhe,G5=yhe;function Y5(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function W5(e,t,n){const{rects:r,placement:i}=e;return{side:Y5(t,oo(i),n),align:Rc(i)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function r0(e){return khe(e,Gfe)}function khe(e,t){const{anchor:n,positionMethod:r="absolute",side:i="bottom",sideOffset:o=0,align:c="center",alignOffset:d=0,collisionBoundary:f,collisionPadding:h=5,sticky:p=!1,arrowPadding:g=5,disableAnchorTracking:x=!1,inline:y,keepMounted:j=!1,floatingRootContext:w,mounted:S,collisionAvoidance:N,shift:A,nodeId:E,adaptiveOrigin:O,lazyFlip:R=!1,externalTree:T}=e,[P,M]=v.useState(null);!S&&P!==null&&M(null);const _=N.side||"flip",I=N.align||"flip",L=N.fallbackAxisSide||"end",D=A?.crossAxis??!1,z=A?.rootBoundary,G=typeof n=="function"?n:void 0,X=Fe(G),Y=G?X:n,F=Fr(n),K=Fr(S),q=mx()==="rtl",W=P||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":q?"left":"right","inline-start":q?"right":"left"}[i],ne=c==="center"?W:`${W}-${c}`;let ie=h;typeof ie=="number"?ie={top:ie,right:ie,bottom:ie,left:ie}:ie&&(ie={top:ie.top||0,right:ie.right||0,bottom:ie.bottom||0,left:ie.left||0});const V=1,H=i==="bottom"?V:0,Q=i==="top"?V:0,J=i==="right"?V:0,oe=i==="left"?V:0,ee={boundary:f==="clipping-ancestors"?"clippingAncestors":f,padding:ie},se=v.useRef(null),le=Fr(o),te=Fr(d),re=typeof o!="function"?o:0,he=typeof d!="function"?d:0,pe=[];y&&pe.push(y),pe.push(Tfe(yt=>{const un=W5(yt,i,q),Tn=typeof le.current=="function"?le.current(un):le.current,$r=typeof te.current=="function"?te.current(un):te.current;return{mainAxis:Tn,crossAxis:$r,alignmentAxis:$r}},[re,he,q,i]));const Ne=I==="none"&&_!=="shift",me=!Ne&&(p||D||_==="shift"),ce=_==="none"?null:Pfe({...ee,padding:{top:ie.top+V+H,right:ie.right+V+oe,bottom:ie.bottom+V+Q,left:ie.left+V+J},mainAxis:!D&&_==="flip",crossAxis:I==="flip"?"alignment":!1,fallbackAxisSideDirection:L}),ae=Ne?null:Ofe({...ee,rootBoundary:z,mainAxis:I!=="none",crossAxis:me,limiter:p||D?void 0:Rfe(yt=>{if(!se.current)return{};const{width:un,height:Tn}=se.current.getBoundingClientRect(),$r=lo(oo(yt.placement)),Sr=$r==="y"?un:Tn,kr=$r==="y"?ie.left+ie.right:ie.top+ie.bottom;return{offset:Sr/2+kr/2}})},[ee,p,D,z,ie,I]);_==="shift"||I==="shift"||c==="center"?pe.push(ae,ce):pe.push(ce,ae),pe.push(Ife({...ee,apply({elements:{floating:yt},availableWidth:un,availableHeight:Tn,rects:$r}){if(!K.current)return;const Sr=yt.style;Sr.setProperty(q5,`${un}px`),Sr.setProperty(G5,`${Tn}px`);const kr=tr(yt).devicePixelRatio||1,{x:ur,y:Fn,width:Gr,height:yn}=$r.reference,Le=(Math.round((ur+Gr)*kr)-Math.round(ur*kr))/kr,Ze=(Math.round((Fn+yn)*kr)-Math.round(Fn*kr))/kr;Sr.setProperty(whe,`${Le}px`),Sr.setProperty(jhe,`${Ze}px`)}}),ghe(yt=>({element:se.current||vn(yt.elements.floating).createElement("div"),padding:se.current?g:0,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(yt){const{elements:{floating:un},middlewareData:Tn,placement:$r,platform:Sr,rects:kr,y:ur}=yt,Fn=oo($r),Gr=Rc($r),yn=lo(Fn)==="y",Le=se.current,Ze=typeof o=="function"?o(W5(yt,i,q)):o;let Ye;if(!Le&&Gr&&Math.abs(yn?Tn.shift?.x||0:Tn.shift?.y||0)<=1)Ye=Gr==="start"===(yn&&Sr.isRTL?.(un)===!0)?"100%":"0%";else{const ln=yn?Tn.arrow?.x||0:Tn.arrow?.y||0,Gt=yn?Le?.clientWidth||0:Le?.clientHeight||0;Ye=`${ln+Gt/2}px`}let Kt=Fn==="top"||Fn==="left"?`calc(100% + ${Ze}px)`:`${-Ze}px`;return me&&yn&&Math.abs(Tn.shift?.y||0)>Ze&&(Kt=`${kr.reference.y+kr.reference.height/2-ur}px`),un.style.setProperty(She,yn?`${Ye} ${Kt}`:`${Kt} ${Ye}`),{}}},vhe,O),Ue(()=>{!S&&w&&w.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[S,w]);const _e=v.useMemo(()=>({ancestorScroll:!x,elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:de,elements:Se,x:ve,y:xe,middlewareData:Re,update:we,placement:ge,context:De,isPositioned:Ge,floatingStyles:Ot}=t({rootContext:w,open:j?S:void 0,placement:ne,middleware:pe,strategy:r,whileElementsMounted:j?void 0:(...yt)=>p5(...yt,_e),nodeId:E,externalTree:T}),{sideX:sn,sideY:$t}=Re.adaptiveOrigin||xhe,Me=Ge?r:"fixed",Ht=v.useMemo(()=>{let yt;return Ge?O?yt={position:Me,[sn]:ve,[$t]:xe}:yt={...Ot,position:Me}:yt={position:Me,top:0,left:0},yt[q5]="100vw",yt[G5]="100vh",Ge||(yt.opacity=0),yt},[O,Me,sn,ve,$t,xe,Ot,Ge]),an=v.useRef(null);Ue(()=>{if(!S)return;const yt=F.current,un=typeof yt=="function"?yt():yt,$r=(X5(un)?un.current:un)||null||null;$r!==an.current&&(de.setPositionReference($r),an.current=$r)},[S,de,Y,F]),v.useEffect(()=>{if(!S)return;const yt=F.current;typeof yt!="function"&&X5(yt)&&yt.current!==an.current&&(de.setPositionReference(yt.current),an.current=yt.current)},[S,de,Y,F]),v.useEffect(()=>{if(j&&S&&Se.reference&&Se.floating)return p5(Se.reference,Se.floating,we,_e)},[j,S,Se,we,_e]);const Mt=oo(ge),_t=Y5(i,Mt,q),Ve=Rc(ge)||"center",bt=!!Re.hide?.referenceHidden;Ue(()=>{R&&S&&Ge&&Mt!==W&&M(Mt)},[R,S,Ge,Mt,W]);const Ut=v.useMemo(()=>({position:"absolute",top:Re.arrow?.y,left:Re.arrow?.x}),[Re.arrow]),Yt=Re.arrow?.centerOffset!==0;return v.useMemo(()=>({positionerStyles:Ht,arrowStyles:Ut,arrowRef:se,arrowUncentered:Yt,side:_t,align:Ve,physicalSide:Mt,anchorHidden:bt,refs:de,context:De,isPositioned:Ge,update:we}),[Ht,Ut,se,Yt,_t,Ve,Mt,bt,de,De,Ge,we])}function X5(e){return e!=null&&"current"in e}function gx(e){return e==="starting"?Ide:rr}function s0(e,t,{styles:n,transitionStatus:r,props:i,refs:o,hidden:c,inert:d=!1}){const f={...n};return d&&(f.pointerEvents="none"),wt("div",e,{state:t,ref:o,props:[{role:"presentation",hidden:c,style:f},gx(r),i],stateAttributesMapping:Wp})}const Nhe=v.forwardRef(function(t,n){const{render:r,className:i,anchor:o,positionMethod:c="absolute",side:d="top",align:f="center",sideOffset:h=0,alignOffset:p=0,collisionBoundary:g="clipping-ancestors",collisionPadding:x=5,arrowPadding:y=5,sticky:j=!1,disableAnchorTracking:w=!1,collisionAvoidance:S=qB,style:N,...A}=t,E=lx(),O=fhe(),R=E.useState("open"),T=E.useState("mounted"),P=E.useState("trackCursorAxis"),M=E.useState("disableHoverablePopup"),_=E.useState("floatingRootContext"),I=E.useState("instantType"),L=E.useState("transitionStatus"),D=E.useState("adaptiveOrigin"),z=r0({anchor:o,positionMethod:c,floatingRootContext:_,mounted:T,side:d,sideOffset:h,align:f,alignOffset:p,collisionBoundary:g,collisionPadding:x,sticky:j,arrowPadding:y,disableAnchorTracking:w,keepMounted:O,collisionAvoidance:S,adaptiveOrigin:D}),G=v.useMemo(()=>({open:R,side:z.side,align:z.align,anchorHidden:z.anchorHidden,instant:P!=="none"?"tracking-cursor":I}),[R,z.side,z.align,z.anchorHidden,P,I]),X=s0(t,G,{styles:z.positionerStyles,transitionStatus:L,props:A,refs:[n,E.useStateSetter("positionerElement")],hidden:!T,inert:!R||P==="both"||M});return s.jsx(V5.Provider,{value:z,children:X})}),Che=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,d=lx(),{side:f,align:h}=K5(),p=d.useState("open"),g=d.useState("instantType"),x=d.useState("transitionStatus"),y=d.useState("popupProps"),j=d.useState("floatingRootContext"),w=d.useState("disabled"),S=d.useState("closeDelay");Va({open:p,ref:d.context.popupRef,onComplete(){p&&d.context.onOpenChangeComplete?.(!0)}}),P5(j,{enabled:!w,closeDelay:S});const N=d.useStateSetter("popupElement");return wt("div",t,{state:{open:p,side:f,align:h,instant:g,transitionStatus:x},ref:[n,d.context.popupRef,N],props:[hx,y,gx(x),c],stateAttributesMapping:aE})}),Ahe=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,d=lx(),{arrowRef:f,side:h,align:p,arrowUncentered:g,arrowStyles:x}=K5(),y=d.useState("open"),j=d.useState("instantType");return wt("div",t,{state:{open:y,side:h,align:p,uncentered:g,instant:j},ref:[n,f],props:[{style:x,"aria-hidden":!0},c],stateAttributesMapping:Wp})}),Ehe=function(t){const{delay:n,closeDelay:r,timeout:i=400}=t,o=v.useMemo(()=>({open:n,close:r}),[n,r]);return s.jsx($5.Provider,{value:n,children:s.jsx(Ade,{delay:o,timeoutMs:i,children:t.children})})};function vx(e){return qA(19)?e:e?"true":void 0}function The(e){const[t,n]=v.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function a0(e){return s.jsx(Ehe,{"data-slot":"tooltip-provider",...e})}function Il(e){return s.jsx(ihe,{"data-slot":"tooltip",...e})}function Bf(e){return s.jsx(dhe,{"data-slot":"tooltip-trigger",...e})}function Ml({className:e,sideOffset:t=8,side:n="top",anchor:r,variant:i="default",children:o,...c}){return s.jsx(hhe,{children:s.jsx(Nhe,{anchor:r,positionMethod:"fixed",collisionPadding:8,sideOffset:t,side:n,className:"z-[90] data-anchor-hidden:hidden",children:s.jsx(Che,{"data-slot":"tooltip-content",className:Te("max-w-[min(320px,calc(100vw-16px))] rounded-md px-2.5 py-2 text-[11.5px] leading-[1.55] shadow-3",i==="plain"?"border border-border bg-raised text-foreground":"bg-primary text-primary-on","break-words outline-none","transition-[opacity,transform] duration-150 ease-out","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95","data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...c,children:o})})})}function Ohe({className:e,...t}){return s.jsx(Ahe,{className:Te("size-2 rotate-45 rounded-[1px] bg-primary","data-[side=top]:-bottom-1 data-[side=bottom]:-top-1",e),...t})}const Q5=v.createContext(void 0);function Zu(e){const t=v.useContext(Q5);if(!e&&t===void 0)throw new Error(En(27));return t}const lT=v.forwardRef(function(t,n){const{render:r,className:i,style:o,forceRender:c=!1,...d}=t,f=Zu(),h=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),x=f.useState("transitionStatus");return wt("div",t,{state:{open:h,transitionStatus:x},ref:[f.context.backdropRef,n],stateAttributesMapping:aE,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},d],enabled:c||!p})}),xx=v.forwardRef(function(t,n){const{render:r,className:i,style:o,disabled:c=!1,nativeButton:d=!0,...f}=t,h=Zu(),p=h.useState("open"),{getButtonProps:g,buttonRef:x}=ai({disabled:c,native:d}),y={disabled:c};function j(w){p&&h.setOpen(!1,at(SE,w.nativeEvent))}return wt("button",t,{state:y,ref:[n,x],props:[{onClick:j},f,g]})}),Rhe=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,...d}=t,f=Zu(),h=bs(c);return f.useSyncedValueWithCleanup("descriptionElementId",h),wt("p",t,{ref:n,props:[{id:h},d]})}),Z5=v.createContext(void 0);function Phe(){const e=v.useContext(Z5);if(e===void 0)throw new Error(En(26));return e}const cT="ArrowUp",uT="ArrowDown",dT="ArrowLeft",fT="ArrowRight",hT="Home",pT="End",i0=new Set([cT,uT,dT,fT,hT,pT]),J5="Shift",Ihe=[J5,"Control","Alt","Meta"];function Mhe(e){return nr(e)&&e.tagName==="INPUT"}function e4(e){return!!(Mhe(e)&&e.selectionStart!=null||nr(e)&&e.tagName==="TEXTAREA")}function t4(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,o=e.scrollTop;const c=e.clientWidthe.scrollLeft+e.clientWidth-h.scrollPaddingRight?i=f+t.offsetWidth+p.scrollMarginRight-e.clientWidth+h.scrollPaddingRight:f-p.scrollMarginLefte.scrollLeft+e.clientWidth-h.scrollPaddingRight&&(i=f+t.offsetWidth+p.scrollMarginRight-e.clientWidth+h.scrollPaddingRight))}if(d&&r!=="horizontal"){const f=n4(e,t,"top"),h=o0(e),p=o0(t);f-p.scrollMarginTope.scrollTop+e.clientHeight-h.scrollPaddingBottom&&(o=f+t.offsetHeight+p.scrollMarginBottom-e.clientHeight+h.scrollPaddingBottom)}e.scrollTo({left:i,top:o,behavior:"auto"})}function n4(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function o0(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const _he="--nested-dialogs",Dhe="data-nested-dialog-open",Lhe={...Wp,...io,nestedDialogOpen(e){return e?{[Dhe]:""}:null}},mT=v.forwardRef(function(t,n){const{render:r,className:i,style:o,finalFocus:c,initialFocus:d,...f}=t,h=Zu(),p=h.useState("descriptionElementId"),g=h.useState("disablePointerDismissal"),x=h.useState("floatingRootContext"),y=h.useState("popupProps"),j=h.useState("modal"),w=h.useState("mounted"),S=h.useState("nested"),N=h.useState("nestedOpenDialogCount"),A=h.useState("open"),E=h.useState("openMethod"),O=h.useState("titleElementId"),R=h.useState("transitionStatus"),T=h.useState("role"),P=x.useState("floatingId");Phe(),Va({open:A,ref:h.context.popupRef,onComplete(){A&&h.context.onOpenChangeComplete?.(!0)}});const M=d===void 0?k5(h.context.popupRef):d,_=N>0,I=h.useStateSetter("popupElement"),D=wt("div",t,{state:{open:A,nested:S,transitionStatus:R,nestedDialogOpen:_},props:[y,{id:P,"aria-labelledby":O,"aria-describedby":p,role:T,...hx,hidden:!w,onKeyDown(z){i0.has(z.key)&&z.stopPropagation()},style:{[_he]:N}},f],ref:[n,h.context.popupRef,I],stateAttributesMapping:Lhe});return s.jsx(Kj,{context:x,openInteractionType:E,disabled:!w,closeOnFocusOut:!g,initialFocus:M,returnFocus:c,modal:j!==!1,restoreFocus:"popup",children:D})}),l0=v.forwardRef(function(t,n){const{cutout:r,...i}=t;let o;if(r){const c=r.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${c.left}px ${c.top}px,${c.left}px ${c.bottom}px,${c.right}px ${c.bottom}px,${c.right}px ${c.top}px,${c.left}px ${c.top}px)`}return s.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),gT=v.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t,o=Zu(),c=o.useState("mounted"),d=o.useState("modal"),f=o.useState("open");return c||r?s.jsx(Z5.Provider,{value:r,children:s.jsxs(Vj,{ref:n,...i,children:[c&&d===!0&&s.jsx(l0,{ref:o.context.internalBackdropRef,inert:vx(!f)}),t.children]})}):null});let r4={},s4={},a4="";function c0(e,t){return Qv(e)?e:t}function i4(e,t,n){return/hidden|clip/.test(e.getComputedStyle(c0(t,n)).overflowY)}function zhe(e){if(typeof document>"u")return!1;const t=vn(e);return tr(t).innerWidth-t.documentElement.clientWidth>0}function $he(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=vn(e),r=n.documentElement,i=n.body,o=c0(r,i),c=o.style.overflowY,d=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",o.style.overflowY="scroll";const f=o.offsetWidth;o.style.overflowY="hidden";const h=o.offsetWidth;return o.style.overflowY=c,r.style.scrollbarGutter=d,f===h}function Bhe(e){const t=vn(e),n=t.documentElement,r=t.body,i=c0(n,r),o={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(i.style,o)}}function Fhe(e){const t=vn(e),n=t.documentElement,r=t.body,i=tr(n);let o=0,c=0,d=!1;const f=li.create();if(Ec&&(i.visualViewport?.scale??1)!==1)return()=>{};function h(){const y=i.getComputedStyle(n),j=i.getComputedStyle(r),N=(y.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,c=n.scrollLeft,r4={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},a4=n.style.scrollBehavior,s4={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const A=n.scrollHeight>n.clientHeight,E=n.scrollWidth>n.clientWidth,O=y.overflowY==="scroll"||j.overflowY==="scroll",R=y.overflowX==="scroll"||j.overflowX==="scroll",T=Math.max(0,i.innerWidth-r.clientWidth),P=Math.max(0,i.innerHeight-r.clientHeight),M=parseFloat(j.marginTop)+parseFloat(j.marginBottom),_=parseFloat(j.marginLeft)+parseFloat(j.marginRight),I=c0(n,r);if(d=$he(e),d){n.style.scrollbarGutter=N,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:N,overflowY:"hidden",overflowX:"hidden"}),(A||O)&&(n.style.overflowY="scroll"),(E||R)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:M||P?`calc(100dvh - ${M+P}px)`:"100dvh",width:_||T?`calc(100vw - ${_+T}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=c,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function p(){Object.assign(n.style,r4),Object.assign(r.style,s4),d||(n.scrollTop=o,n.scrollLeft=c,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=a4)}function g(){p(),f.request(h)}h();const x=Jt(i,"resize",g);return()=>{f.cancel(),p(),typeof i.removeEventListener=="function"&&x()}}class Uhe{constructor(){on(this,"lockCount",0);on(this,"restore",null);on(this,"timeoutLock",oi.create());on(this,"timeoutUnlock",oi.create());on(this,"release",()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)});on(this,"unlock",()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)})}acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}lock(t){if(this.lockCount===0||this.restore!==null)return;const n=vn(t),r=n.documentElement,i=n.body,o=tr(r);if(i4(o,r,i)){const d=new o.MutationObserver(()=>{i4(o,r,i)||(d.disconnect(),this.restore=null,this.lock(t))}),f={attributes:!0};d.observe(r,f),d.observe(i,f),this.restore=()=>d.disconnect();return}const c=tx||!zhe(t);this.restore=c?Bhe(t):Fhe(t)}}const Hhe=new Uhe;function o4(e=!0,t=null){Ue(()=>{if(e)return Hhe.acquire(t)},[e,t])}function Vhe({store:e,parentContext:t,isDrawer:n}){const r=e.useState("open"),i=e.useState("disablePointerDismissal"),o=e.useState("modal"),c=e.useState("popupElement"),d=e.useState("floatingRootContext"),[f,h]=v.useState(0),[p,g]=v.useState(0),x=f===0,y=fx(d,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(j){if(!e.context.outsidePressEnabledRef.current||"button"in j&&j.button!==0)return!1;if("touches"in j){if(j.type==="touchend"){if(j.changedTouches.length!==1||j.touches.length!==0)return!1}else if(j.touches.length!==1)return!1}const w=or(j);if(x&&!i){if(o){const S=e.context.internalBackdropRef.current,N=e.context.backdropRef.current;return S||N?S===w||N===w||nt(w,c)&&!w?.hasAttribute("data-base-ui-portal"):!0}return!0}return!1},escapeKey:x});return o4(r&&o===!0,c),e.useContextCallback("onNestedDialogOpen",(j,w)=>{h(j),g(w)}),Ue(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(f+1,p+(n?1:0)):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,f,p,t]),JE(e,{activeTriggerProps:y.reference,inactiveTriggerProps:y.trigger,popupProps:y.floating,nestedOpenDialogCount:f,nestedOpenDrawerCount:p}),null}const Khe={...nT,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};class qhe extends $f{constructor(n,r,i){const o=new Wj,c=Ghe(n,o,r,i);super(c,Yhe(o),Khe);on(this,"setOpen",(n,r)=>{r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!n&&r.trigger==null&&this.state.activeTriggerId!=null&&(r.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(n,r),!r.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(n,r),this.update(WE(this.state,n,r.trigger)))})}}function Ghe(e,t,n,r=!1){return{...eT(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Yhe(e){return{popupRef:v.createRef(),backdropRef:v.createRef(),internalBackdropRef:v.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function l4(e,t){const{children:n,open:r,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:c,disablePointerDismissal:d=!1,modal:f=!0,actionsRef:h,handle:p,triggerId:g,defaultTriggerId:x=null}=t,y=e==="drawer",j=e==="alert-dialog",w=j?!0:f,S=j||d,N=j?"alertdialog":"dialog",A=Zu(!0),E=A!=null,O={modal:w,disablePointerDismissal:S,nested:E,role:N},R=GE((L,D)=>new qhe({open:i,openProp:r,activeTriggerId:x,triggerIdProp:g,...O},L,D),!0);R.useControlledProp("openProp",r),R.useControlledProp("triggerIdProp",g),R.useSyncedValues(O),R.useContextCallback("onOpenChange",o),R.useContextCallback("onOpenChangeComplete",c);const T=R.useState("open"),P=R.useState("mounted"),M=R.useState("payload");A5(R,T),QE(R);const{forceUnmount:_}=ZE(T,R);v.useImperativeHandle(h,()=>({unmount:_,close:()=>R.setOpen(!1,at(NE))}),[_,R]);const I=T||P;return s.jsxs(Q5.Provider,{value:R,children:[p&&s.jsx(YE,{handle:p,store:R}),I&&s.jsx(Vhe,{store:R,parentContext:A?.context,isDrawer:y}),typeof n=="function"?n({payload:M}):n]})}const c4=Fj(function(t){return l4("dialog",t)}),vT=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,...d}=t,f=Zu(),h=bs(c);return f.useSyncedValueWithCleanup("titleElementId",h),wt("h2",t,{ref:n,props:[{id:h},d]})});function Whe(e){const t=v.useRef(""),n=v.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:v.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i?e(i,i.pointerType):e(i,t.current),t.current=""},[e]),onPointerDown:n}}function xT(e,t){const n=Fe((o,c)=>{(typeof e=="function"?e():e)||t(c||(tx?"touch":""))}),{onClick:r,onPointerDown:i}=Whe(n);return v.useMemo(()=>({onClick:r,onPointerDown:i}),[r,i])}function u4(e){const[t,n]=v.useState(null),r=xT(e,n);return co(e,i=>{i&&!e&&n(null)}),v.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Xhe=PE(function(t,n){const{render:r,className:i,style:o,disabled:c=!1,nativeButton:d=!0,id:f,payload:h,handle:p,...g}=t,x=Zu(!0),j=rT(p)??x;if(!j)throw new Error(En(79));const w=bs(f),S=j.useState("floatingRootContext"),N=j.useState("isOpenedByTrigger",w),A=j.useState("triggerPopupId",w),E=v.useRef(null),{registerTrigger:O,isMountedByThisTrigger:R}=XE(w,E,j,{payload:h}),{getButtonProps:T,buttonRef:P}=ai({disabled:c,native:d}),M=dx(S),_=xT(()=>j.select("open"),D=>{j.set("openMethod",D)}),I={disabled:c,open:N},L=j.useState("triggerProps",R);return wt("button",t,{state:I,ref:[P,n,O,E],props:[M.reference,L,_,{[DE]:"",id:w,"aria-haspopup":"dialog","aria-expanded":N,"aria-controls":A},g,T],stateAttributesMapping:jj})});function St(e){return s.jsx(c4,{"data-slot":"dialog",...e})}function Qhe(e){return s.jsx(Xhe,{"data-slot":"dialog-trigger",...e})}function Zhe(e){return s.jsx(gT,{"data-slot":"dialog-portal",...e})}function Jhe(e){return s.jsx(xx,{"data-slot":"dialog-close",...e})}const jt=e=>s.jsx(vT,{"data-slot":"dialog-title",...e}),bT=e=>s.jsx(Rhe,{"data-slot":"dialog-description",...e});function epe({className:e,...t}){return s.jsx(lT,{"data-slot":"dialog-overlay",className:Te("fixed inset-0 isolate z-30 bg-mask backdrop-blur-[3px]","transition-opacity duration-150","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function kt({className:e,children:t,showCloseButton:n=!0,keepMounted:r=!1,overlayForceRender:i=!1,...o}){return s.jsxs(Zhe,{keepMounted:r,children:[s.jsx(epe,{forceRender:i}),s.jsxs(mT,{"data-slot":"dialog-content",className:Te("fixed top-1/2 left-1/2 z-30 flex max-h-[calc(100vh-48px)] w-[min(620px,calc(100vw-48px))] -translate-x-1/2 -translate-y-1/2 flex-col","overflow-hidden rounded-lg border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.2,.9,.3,1)]","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985] data-open:slide-in-from-bottom-2.5","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...o,children:[t,n&&s.jsxs(xx,{"data-slot":"dialog-close",render:s.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[s.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:s.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),s.jsx("span",{className:"sr-only",children:ue("关闭")})]})]})]})}function Nt({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:Te("flex items-center gap-2.5 border-b border-hairline px-5 py-[15px] pr-10","[&_h2]:flex-1 [&_h2]:text-[14.5px] [&_h2]:font-semibold",e),...t})}function Ct({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-body",className:Te("flex flex-col gap-4 overflow-y-auto px-5 py-[18px]",e),...t})}function Pt({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-footer",className:Te("flex items-center justify-end gap-2 border-t border-hairline bg-surface-2 px-5 py-[13px]",e),...t})}function Ln({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-section",className:Te("flex flex-col gap-2.5 rounded-md border border-border bg-surface-inset p-3.5","[&_h3]:text-[12.5px] [&_h3]:font-semibold","[&_p]:text-xs [&_p]:leading-[1.65] [&_p]:text-subtle",e),...t})}function tpe(e){return l4("alert-dialog",e)}const d4=tpe,npe=gT,f4=e=>s.jsx(vT,{"data-slot":"alert-dialog-title",...e});function rpe({className:e,...t}){return s.jsx(lT,{"data-slot":"alert-dialog-overlay",className:Te("fixed inset-0 isolate z-[38] bg-mask backdrop-blur-[3px]","transition-opacity duration-150","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function h4({className:e,children:t,showCloseButton:n=!1,...r}){return s.jsxs(npe,{children:[s.jsx(rpe,{}),s.jsxs(mT,{"data-slot":"alert-dialog-content",className:Te("fixed top-1/2 left-1/2 z-[38] flex max-h-[calc(100vh-48px)] w-[min(440px,calc(100vw-48px))] -translate-x-1/2 -translate-y-1/2 flex-col","overflow-hidden rounded-lg border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.2,.9,.3,1)]","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985] data-open:slide-in-from-bottom-2.5","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...r,children:[t,n&&s.jsxs(xx,{"data-slot":"alert-dialog-close",render:s.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[s.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:s.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),s.jsx("span",{className:"sr-only",children:ue("关闭")})]})]})]})}function p4({className:e,...t}){return s.jsx("div",{"data-slot":"alert-dialog-header",className:Te("flex items-center gap-2.5 border-b border-hairline px-5 py-[15px]","[&_h2]:flex-1 [&_h2]:text-[14.5px] [&_h2]:font-semibold",e),...t})}function m4({className:e,...t}){return s.jsx("div",{"data-slot":"alert-dialog-body",className:Te("flex flex-col gap-4 overflow-y-auto px-5 py-[18px]",e),...t})}function g4({className:e,...t}){return s.jsx("div",{"data-slot":"alert-dialog-footer",className:Te("flex items-center justify-end gap-2 border-t border-hairline bg-surface-2 px-5 py-[13px]",e),...t})}function spe({className:e,tone:t="danger",...n}){return s.jsx("div",{"data-slot":"alert-dialog-banner","data-tone":t,className:Te("rounded-md border px-3.5 py-3 text-xs leading-[1.65] text-subtle","[&_strong]:font-semibold",t==="danger"?"border-destructive-bd bg-destructive-soft [&_strong]:text-destructive":"border-border bg-surface-inset [&_strong]:text-foreground",e),...n})}function ea({className:e,containerClassName:t,container:n=!0,...r}){const i=s.jsx("table",{"data-slot":"table",className:Te("w-full caption-bottom border-collapse text-[12.5px]",e),...r});return n?s.jsx("div",{"data-slot":"table-container",className:Te("relative w-full overflow-auto",t),children:i}):i}function Ta({className:e,...t}){return s.jsx("thead",{"data-slot":"table-header",className:Te(e),...t})}function ga({className:e,...t}){return s.jsx("tbody",{"data-slot":"table-body",className:Te(e),...t})}function ape({className:e,...t}){return s.jsx("tfoot",{"data-slot":"table-footer",className:Te("border-t border-border bg-surface-2 font-medium",e),...t})}function en({className:e,...t}){return s.jsx("tr",{"data-slot":"table-row",className:Te("transition-colors duration-100 hover:[&>td]:bg-control-hover",e),...t})}function ft({className:e,...t}){return s.jsx("th",{"data-slot":"table-head",className:Te("sticky top-0 z-[2] whitespace-nowrap border-b border-border bg-[var(--ui-table-head-bg)] px-2 py-2","text-left text-[10.5px] font-semibold tracking-[.05em] text-muted-foreground",e),...t})}function Xe({className:e,...t}){return s.jsx("td",{"data-slot":"table-cell",className:Te("border-b border-hairline px-2 py-2 align-middle",e),...t})}function ipe({className:e,...t}){return s.jsx("caption",{"data-slot":"table-caption",className:Te("mt-4 text-xs text-muted-foreground",e),...t})}const ope="data-checked",lpe="data-unchecked",yT={checked(e){return e?{[ope]:""}:{[lpe]:""}},...io,...Rl},wT="data-composite-item-active",v4=v.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function cpe(){return v.useContext(v4)}function jT(e={}){const{guess:t,label:n,metadata:r,textRef:i,index:o}=e,{register:c,unregister:d,subscribeMapChange:f,nextIndexRef:h}=cpe(),p=v.useRef(-1),[g,x]=v.useState(o==null&&t?()=>{if(p.current===-1){const S=h.current;h.current+=1,p.current=S}return p.current}:-1),y=o??g,j=v.useRef(null),w=v.useCallback(S=>{const N=j.current;N&&d(N),j.current=S,S&&c(S,{metadata:r??null,index:o??null,label:n,textRef:i})},[o,c,d,r,n,i]);return Ue(()=>{if(o==null)return f(S=>{const N=j.current?S.get(j.current)?.index:null;N!=null&&x(N)})},[o,f]),{ref:w,index:y}}function upe(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=m3(),{ref:i,index:o}=jT(e),c=n===o,d=v.useRef(null),f=Ei(i,d);return{compositeProps:{tabIndex:c?0:-1,onFocus(){r(o)},onMouseMove(){const p=d.current;if(!t||!p)return;const g=p.hasAttribute("disabled")||p.ariaDisabled==="true";!c&&!g&&p.focus()}},compositeRef:f,index:o}}function x4(e){const{render:t,className:n,style:r,state:i=rr,props:o=Ti,refs:c=Ti,metadata:d,stateAttributesMapping:f,tag:h="div",...p}=e,{compositeProps:g,compositeRef:x}=upe({metadata:d});return wt(h,e,{state:i,ref:[x,...c],props:[g,...o,p],stateAttributesMapping:f})}const b4=v.createContext(void 0);function dpe(){return v.useContext(b4)}function u0(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}const y4=v.createContext(void 0);function fpe(){const e=v.useContext(y4);if(e===void 0)throw new Error(En(52));return e}const w4=v.forwardRef(function(t,n){const{render:r,className:i,disabled:o=!1,readOnly:c=!1,required:d=!1,"aria-labelledby":f,value:h,inputRef:p,nativeButton:g=!1,id:x,style:y,...j}=t,w=dpe(),{disabled:S,readOnly:N,required:A,form:E,checkedValue:O,touched:R=!1,validation:T,name:P,setCheckedValue:M=Pn,setTouched:_=Pn,registerInputRef:I=Pn}=w??{},{setTouched:L,setFilled:D,state:z,disabled:G}=Oi(),X=Mj(),{labelId:Y,getDescriptionProps:F}=ii(),K=G||X.disabled||S||o,U=N||c,q=A||d,W=E,ne=w?O===h:h==="",ie=v.useRef(null),V=v.useRef(null),H=T?.registerInput,Q=v.useCallback(Se=>H?.(Se,{controlRef:ie,value:void 0}),[H]),J=Ei(p,V,I,Q);Ue(()=>{V.current?.checked&&D(!0)},[D]),Ue(()=>{if(V.current){if(K&&ne){I(null);return}I(V.current)}},[ne,K,I]);const oe=bs(),ee=Vu({id:x}),se=g?void 0:ee,le=JA(f,Y,V,!g,se),te={role:"radio","aria-checked":ne,"aria-labelledby":le,[wT]:ne?"":void 0,id:g?ee:oe,onKeyDown(Se){Se.key==="Enter"&&Se.preventDefault()},onClick(Se){if(Se.defaultPrevented||K||U)return;Se.preventDefault();const ve=V.current;ve&&Gp(ve,Se)},onFocus(Se){Se.defaultPrevented||K||U||!R||(V.current?.click(),_(!1))}},{getButtonProps:re,buttonRef:he}=ai({disabled:K,native:g,composite:!1}),pe={type:"radio",ref:J,form:W,id:se,name:P,tabIndex:-1,style:P?tm:_c,"aria-hidden":!0,...h!==void 0?{value:u0(h)}:rr,disabled:K,checked:ne,required:q,readOnly:U,onChange(Se){if(Se.nativeEvent.defaultPrevented||K||U||h===void 0)return;const ve=at(Br,Se.nativeEvent);M(h,ve),!ve.isCanceled&&L(!0)},onClick(Se){Se.stopPropagation()},onFocus(){ie.current?.focus()}},Ne=v.useMemo(()=>({...z,required:q,disabled:K,readOnly:U,checked:ne}),[z,K,U,ne,q]),me=Ne,ce=w!==void 0,ae=[n,ie,he],_e=[te,j,re,F,T?Se=>T.getValidationProps(K,Se):rr],de=wt("span",t,{enabled:!ce,state:Ne,ref:ae,props:_e,stateAttributesMapping:yT});return s.jsxs(y4.Provider,{value:me,children:[ce?s.jsx(x4,{tag:"span",render:r,className:i,style:y,state:Ne,refs:ae,props:_e,stateAttributesMapping:yT}):de,s.jsx("input",{...pe,suppressHydrationWarning:!0})]})}),hpe=v.forwardRef(function(t,n){const{render:r,className:i,style:o,keepMounted:c=!1,...d}=t,f=fpe(),h=f.checked,{mounted:p,transitionStatus:g,setMounted:x}=Ic(h),y={...f,transitionStatus:g},j=v.useRef(null),w=c||p,S=wt("span",t,{ref:[n,j],state:y,props:d,stateAttributesMapping:yT});return Va({batch:!0,enabled:!h,open:h,ref:j,onComplete(){h||x(!1)}}),w?S:null});function ST(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,o=Fe(i),[,c]=v.useState(!1),d=hs(mpe).current,f=hs(ppe).current,h=v.useRef(0),p=v.useRef(!0),g=v.useRef(null),x=v.useRef(null),y=Fe(()=>{p.current||(p.current=!0,c(R=>!R))}),j=Fe((R,T)=>{f.set(R,T),y()}),w=Fe(R=>{f.delete(R),y()}),S=Fe(R=>{const T=new Map;return n.current.length=0,r&&(r.current.length=0),R.forEach(P=>{T.set(P.element,{...P.registration.metadata??{},index:P.index}),n.current[P.index]=P.element,r&&(r.current[P.index]=P.registration.label!==void 0?P.registration.label:P.registration.textRef?.current?.textContent??P.element.textContent)}),h.current=n.current.length,T});function N(R){if(x.current?.disconnect(),x.current=null,typeof MutationObserver!="function"||R.length<2)return;const T=new MutationObserver(M=>{if(!xpe(M))return;let _=null;for(const I of R)if(I.isConnected){if(_&&j4(_,I)>0){T.disconnect(),y();return}_=I}});x.current=T;const P=new Set;for(let M=1;MT.observe(M,{childList:!0}))}const A=Fe(()=>{const[R,T]=gpe(f),P=S(R),M=g.current,_=!M||M.length!==R.length||R.some((I,L)=>{const D=M[L];return I.index!==D.index||I.element!==D.element||I.registration.index!==D.registration.index||I.registration.metadata!==D.registration.metadata});N(T),g.current=R,p.current=!1,_&&(d.forEach(I=>I(P)),o(P))});Ue(()=>(!p.current&&g.current&&S(g.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,S]),Ue(()=>{p.current&&A()}),Ue(()=>()=>{x.current?.disconnect(),p.current=!0},[]);const E=Fe(R=>(d.add(R),()=>{d.delete(R)})),O=v.useMemo(()=>({register:j,unregister:w,subscribeMapChange:E,nextIndexRef:h}),[j,w,E,h]);return s.jsx(v4.Provider,{value:O,children:t})}function ppe(){return new Map}function mpe(){return new Set}function gpe(e){const t=new Set,n=[],r=[];e.forEach((o,c)=>{if(!c.isConnected)return;const d=o.index,f={index:d??-1,element:c,registration:o};d===null?r.push(f):d>=0&&(t.add(d),n.push(f))});let i=0;return r.sort((o,c)=>j4(o.element,c.element)),r.forEach(o=>{for(;t.has(i);)i+=1;o.index=i,n.push(o),i+=1}),t.size>0&&n.sort((o,c)=>o.index-c.index),[n,r.map(o=>o.element)]}function vpe(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function xpe(e){for(const t of e)for(let n=0;n{if(O.current=A.current[L]??null,(d??j)(L),D){const z=A.current[L];t4(S.current,z,o,n)}}),P=Fe(L=>{if(L.size===0)return;if(E.current){const X=A.current,Y=X.indexOf(O.current);if(Y===-1){const F=X[R];!F||Wu(X,R,g)?T(ype(X,g)):O.current=F}else Y!==R&&T(Y);return}E.current=!0;const D=Array.from(L.keys()),z=D.find(X=>X?.hasAttribute(wT))??null,G=z?L.get(z)?.index??-1:-1;if(G!==-1)T(G);else if(Wu(D,R,g)){const X=Js(D,{disabledIndices:g});Yu(D,X)||T(X)}t4(S.current,z,o,n)});Ue(()=>{if(g==null||c!=null||!E.current)return;const L=A.current;if(Wu(L,R,g)){const D=Js(L,{disabledIndices:g});Yu(L,D)||T(D)}},[g,c,R,A,T]);const M=Fe((L,D,z)=>i?i(L,D,z,A):z),_=Fe(L=>{const D=L.key===hT||L.key===pT;if(!i0.has(L.key)||!h&&D||wpe(L,x)||!S.current)return;const G=o==="rtl",X=G?dT:fT,Y=G?fT:dT,F=n==="vertical"?uT:X,K=n==="vertical"?cT:Y,U=or(L.nativeEvent);if(U!=null&&e4(U)&&!S4(U)){const H=U.selectionStart,Q=U.selectionEnd,J=U.value;if(H==null||L.shiftKey||H!==Q||L.key!==K&&H0)return}let q=R;const W=Rj(A,g),ne=pE(A,g);r!=null&&(q=r({disabledIndices:g,elementsRef:A,event:L,highlightedIndex:R,loopFocus:t,maxIndex:ne,minIndex:W,onLoop:M,orientation:n,rtl:G}));const ie=n!=="vertical"&&L.key===X||n!=="horizontal"&&L.key===uT,V=n!=="vertical"&&L.key===Y||n!=="horizontal"&&L.key===cT;h&&(L.key===hT?q=W:L.key===pT&&(q=ne)),q===R&&(ie||V)&&(t&&q===ne&&ie?(q=W,i&&(q=i(L,R,q,A))):t&&q===W&&V?(q=ne,i&&(q=i(L,R,q,A))):q=Js(A.current,{startingIndex:q,decrement:V,disabledIndices:g})),q!==R&&!Yu(A.current,q)&&(p&&L.stopPropagation(),(w||D||ie||V)&&L.preventDefault(),T(q,!0),queueMicrotask(()=>{A.current[q]?.focus()}))});return{props:{ref:N,onFocus(L){const D=S.current,z=or(L.nativeEvent);!D||z==null||!e4(z)||z.setSelectionRange(0,z.value.length)},onKeyDown:_},highlightedIndex:R,onHighlightedIndexChange:T,elementsRef:A,onMapChange:P,relayKeyboardEvent:_}}function ype(e,t){let n=-1;for(let r=0;r({highlightedIndex:_,onHighlightedIndexChange:I,highlightItemOnHover:O,relayKeyboardEvent:z}),[_,I,O,z]);return s.jsx(p3.Provider,{value:X,children:s.jsx(ST,{elementsRef:L,onMapChange:Y=>{w?.(Y),D(Y)},children:G})})}const Spe=[J5],k4=v.forwardRef(function(t,n){const{render:r,className:i,disabled:o,readOnly:c,required:d,onValueChange:f,value:h,defaultValue:p,form:g,name:x,inputRef:y,id:j,style:w,...S}=t,{setTouched:N,setFocused:A,validationMode:E,name:O,disabled:R,state:T,validation:P,setDirty:M,setFilled:_,validityData:I}=Oi(),{labelId:L}=ii(),{clearErrors:D,elementRef:z}=Ac(),G=ZA(!0),X=R||o,Y=O??x,F=bs(j),[K,U]=qo({controlled:h,default:p,name:"RadioGroup",state:"value"}),[q,W]=v.useState(!1),ne=Fe((he,pe)=>{f?.(he,pe),!pe.isCanceled&&U(he)}),ie=P.getInputControl,V=v.useMemo(()=>({get current(){return ie()}}),[ie]),H=v.useRef(null),Q=v.useRef(null);function J(he){let pe;return y&&(typeof y=="function"?pe=y(he):y.current=he),H.current=he,pe}const oe=Fe(he=>{if(!he||he.disabled)return;Q.current||(Q.current=he);const pe=H.current,Ne=he.checked||pe==null||pe.disabled?J(he):void 0;return()=>{Q.current===he&&(Q.current=null),H.current===he?Ne?(Ne(),H.current=null):J(null):Ne?.()}}),ee=Fe(()=>{const he=z.current;if(!he)return K??null;for(const pe of P.registeredInputs.keys())if(pe.checked&&vB(pe,he))return K??null;return null});Jp(V,F,K??null,ee,!X,x),co(K,()=>{D(Y),M(K!==I.initialValue),_(K!=null),P.change(K);const he=Q.current;K==null&&he&&!he.disabled&&J(he)});const se=L??G?.legendId,le={...T,disabled:X??!1,required:d??!1,readOnly:c??!1},te=v.useMemo(()=>({checkedValue:K,disabled:X,form:g,validation:P,name:Y,readOnly:c,registerInputRef:oe,required:d,setCheckedValue:ne,setTouched:W,touched:q}),[K,X,g,P,Y,c,oe,d,ne,W,q]),re={id:j,role:"radiogroup","aria-required":d||void 0,"aria-disabled":X||void 0,"aria-readonly":c||void 0,"aria-labelledby":se,onFocus(){A(!0)},onBlur(he){nt(he.currentTarget,he.relatedTarget)||(N(!0),A(!1),E==="onBlur"&&P.commit(K))},onKeyDownCapture(he){he.key.startsWith("Arrow")&&(W(!0),A(!0))}};return s.jsx(b4.Provider,{value:te,children:s.jsx(jpe,{render:r,className:i,style:w,state:le,props:[re,S,he=>P.getValidationProps(X??!1,he)],refs:[n],stateAttributesMapping:Rl,enableHomeAndEndKeys:!1,modifierKeys:Spe})})});function bx({className:e,...t}){return s.jsx(k4,{"data-slot":"radio-group",className:Te("flex flex-col gap-2",e),...t})}function Lc({className:e,children:t,...n}){return s.jsxs(w4,{"data-slot":"radio-group-item",className:Te("relative inline-flex size-3.5 flex-none cursor-pointer items-center justify-center rounded-full border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...n,children:[t,s.jsx(hpe,{"data-slot":"radio-group-indicator",className:"grid place-content-center data-unchecked:hidden",children:s.jsx("span",{className:"block size-[5px] rounded-full bg-primary-foreground"})})]})}function N4(e){const t=v.useRef(!0);t.current&&(t.current=!1,e())}const C4=v.createContext(void 0),A4=v.createContext(void 0),E4=v.createContext(void 0);function Ju(){const e=v.useContext(C4);if(e===void 0)throw new Error(En(60));return e}function kT(){const e=v.useContext(A4);if(e===void 0)throw new Error(En(101));return e}function T4(){const e=v.useContext(E4);if(e===void 0)throw new Error(En(61));return e}function kpe(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let i=0;iObject.is(e,t);function po(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function O4(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!kpe(e,t,(r,i)=>po(r,i,n)):e!==t}function f0(e,t,n){return e?e.some(r=>r===void 0?!1:po(t,r,n)):!1}function am(e,t,n){return e?e.findIndex(r=>r===void 0?!1:po(r,t,n)):-1}function Npe(e,t){if(t!==d0)return r=>f0(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(i=>Object.is(r,i)))}function yx(e,t,n,r){const i=r&&Array.isArray(t)?e.findIndex(Npe(t,n)):am(e,t,n);return i===-1?null:i}function R4(e,t,n,r,i,o){return f0(r,t,i)?o!=null&&e>o&&f0(r,n[o],i)?o:e:e===o?yx(n,r,i,!0):o}function P4(e,t,n){return e.filter(r=>!po(t,r,n))}function Cpe(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function NT(e){return Cpe(e?.[0])}function h0(e){return NT(e)?e.flatMap(t=>t.items):e}function I4(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(NT(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function ed(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return u0(e)}function Yo(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?u0(e.value):u0(e)}function M4(e,t,n){function r(){return ed(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const o=h0(t);if(e==null||typeof e!="object"){const c=o.find(d=>d.value===e);return c&&c.label!=null?c.label:r()}if("value"in e){const c=o.find(d=>d&&d.value===e.value);if(c&&c.label!=null)return c.label}}return r()}function Ape(e,t,n){return e.reduce((r,i,o)=>(o>0&&r.push(", "),r.push(s.jsx(v.Fragment,{children:M4(i,t,n)},o)),r),[])}const Epe={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Yo(t,r)!==""},hasNullItemLabel:(e,t)=>t?I4(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(i=>po(t,i,n)):po(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},zc=1;function _4(e,t){return Math.max(0,e-t)}function Tpe(e,t){if(t<=0)return 0;const n=Dc(e,0,t),r=n,i=t-n,o=r<=zc,c=i<=zc;return o&&c?r<=i?0:t:o?0:c?t:n}function Ope(e){const{id:t,value:n,defaultValue:r=null,onValueChange:i,open:o,defaultOpen:c=!1,onOpenChange:d,name:f,form:h,autoComplete:p,disabled:g=!1,readOnly:x=!1,required:y=!1,modal:j=!0,actionsRef:w,inputRef:S,onOpenChangeComplete:N,items:A,multiple:E=!1,itemToStringLabel:O,itemToStringValue:R,isItemEqualToValue:T=d0,highlightItemOnHover:P=!0,children:M}=e,{clearErrors:_}=Ac(),{setDirty:I,setTouched:L,setFocused:D,validityData:z,setFilled:G,name:X,disabled:Y,validation:F,validationMode:K}=Oi(),U=Vu({id:t}),q=Y||g,W=X??f,[ne,ie]=qo({controlled:n,default:E?r??Ti:r,name:"Select",state:"value"}),[V,H]=qo({controlled:o,default:c,name:"Select",state:"open"}),Q=v.useRef([]),J=v.useRef([]),oe=v.useRef(null),ee=v.useRef(null),se=v.useRef(0),le=v.useRef(null),te=v.useRef([]),re=v.useRef(!1),he=v.useRef(null),pe=v.useRef(null),Ne=v.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),me=v.useRef(!1),ce=v.useRef(ne),{mounted:ae,setMounted:_e,transitionStatus:de}=Ic(V),{openMethod:Se,triggerProps:ve}=u4(V),xe=hs(()=>new $f({id:U,labelId:void 0,modal:j,multiple:E,itemToStringLabel:O,itemToStringValue:R,isItemEqualToValue:T,value:ne,open:V,mounted:ae,transitionStatus:de,items:A,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:rr,triggerProps:rr,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Pn,setOpen:Pn,handleScrollArrowVisibility:Pn,onOpenChangeComplete:Pn,listRef:Q,popupRef:oe,scrollHandlerRef:ee,scrollArrowsMountedCountRef:se,valueRef:le,valuesRef:te,labelsRef:J,typingRef:re,selectionRef:Ne,firstItemTextRef:he,selectedItemTextRef:pe,alignItemWithTriggerActiveRef:me,initialValueRef:ce},Epe)).current,Re=xe.useState("activeIndex"),we=xe.useState("selectedIndex"),ge=xe.useState("triggerElement"),De=xe.useState("positionerElement"),Ge=The(Se),Ot=Se??Ge,sn=v.useMemo(()=>E?"":Yo(ne,R),[E,ne,R]),$t=v.useMemo(()=>E&&Array.isArray(ne)?ne.map(Le=>Yo(Le,R)):Yo(ne,R),[E,ne,R]),Me=Fr(ge),Ht=Fe(()=>$t);Jp(Me,U,ne,Ht,!q,f);const an=E?Array.isArray(ne)&&ne.length>0:ne!=null&&sn!=="";Ue(()=>{G(an)},[an,G]),Ue(function(){const Ze=yx(te.current,ne,T,E);Ze===null&&(pe.current=null),!V&&xe.set("selectedIndex",Ze)},[E,V,ne,T,xe]),co(ne,()=>{_(W),I(O4(ne,z.initialValue,T)),F.change(ne)});const Mt=Fe((Le,Ze)=>{d?.(Le,Ze),!Ze.isCanceled&&(H(Le),!Le&&(Ze.reason===Xu||Ze.reason===$j)&&(L(!0),D(!1),K==="onBlur"&&F.commit(ne)))}),_t=Fe(()=>{_e(!1),xe.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),N?.(!1)});Va({enabled:!w,open:V,ref:oe,onComplete(){V||_t()}}),v.useImperativeHandle(w,()=>({unmount:_t}),[_t]);const Ve=Fe((Le,Ze)=>{i?.(Le,Ze),!Ze.isCanceled&&ie(Le)}),bt=Fe(Le=>{const Ze=_4(Le.scrollHeight,Le.clientHeight),Ye=Tpe(Le.scrollTop,Ze),Kt=Ye>0,ln=YeS4(Q.current[Le]),onMatch(Le){V?xe.set("activeIndex",Le):Ve(te.current[Le],at(Br))},onTyping(Le){re.current=Le}}),$r=v.useMemo(()=>Ai(Tn.reference,un.reference,yt.reference,Yt.reference,ve),[Yt.reference,Tn.reference,un.reference,yt.reference,ve]),Sr=v.useMemo(()=>Ai(hx,Tn.floating,un.floating,yt.floating),[Tn.floating,un.floating,yt.floating]),kr=un.item??rr;xe.useContextCallback("setValue",Ve),xe.useContextCallback("setOpen",Mt),xe.useContextCallback("handleScrollArrowVisibility",bt),xe.useContextCallback("onOpenChangeComplete",N),N4(()=>{xe.update({popupProps:Sr,triggerProps:$r})}),xe.useSyncedValues({id:U,modal:j,multiple:E,value:ne,open:V,mounted:ae,transitionStatus:de,popupProps:Sr,triggerProps:$r,items:A,itemToStringLabel:O,itemToStringValue:R,isItemEqualToValue:T,openMethod:Ot});const ur=v.useMemo(()=>({disabled:q,readOnly:x,required:y,multiple:E,highlightItemOnHover:P,itemProps:kr}),[q,x,y,E,P,kr]),Fn=Ei(S,F.inputRef),Gr=E?void 0:W,yn=v.useMemo(()=>!E||!Array.isArray(ne)||!W?null:ne.map(Le=>{const Ze=Yo(Le,R);return s.jsx("input",{type:"hidden",form:h,name:W,value:Ze,disabled:q},Ze)}),[E,ne,h,W,R,q]);return s.jsxs(C4.Provider,{value:xe,children:[s.jsx(A4.Provider,{value:ur,children:s.jsx(E4.Provider,{value:Ut,children:M})}),s.jsx("input",{...F.getValidationProps(q,{onFocus(){xe.state.triggerElement?.focus({focusVisible:!0})},onChange(Le){if(Le.nativeEvent.defaultPrevented||q||x)return;const Ze=Le.currentTarget.value,Ye=at(Br,Le.nativeEvent);function Kt(){if(E)return;const ln=Ze.toLowerCase();let Gt=te.current.findIndex(vr=>Yo(vr,R).toLowerCase()===ln||ed(vr,O).toLowerCase()===ln);Gt===-1&&(Gt=te.current.findIndex((vr,Qt)=>{const gs=J.current[Qt];return gs!=null&&gs.toLowerCase()===ln}));const Rt=te.current[Gt];Rt!=null&&Ve(Rt,Ye)}xe.set("forceMount",!0),queueMicrotask(Kt)}}),id:U&&Gr==null?`${U}-hidden-input`:void 0,form:h,name:Gr,autoComplete:p,value:sn,disabled:q,required:y&&!(E&&an),readOnly:x,ref:Fn,style:W?tm:_c,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]})}function D4(e,t){return e??t}const p0=5;function L4(e,t){const n=Rpe(t);return e.clientX>=n.left-p0&&e.clientX<=n.right+p0&&e.clientY>=n.top-p0&&e.clientY<=n.bottom+p0}function Rpe(e){const t=e.getBoundingClientRect(),n=tr(e);if(eE)return t;const r=n.getComputedStyle(e,"::before"),i=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||i.content!=="none"))return t;const c=parseFloat(r.width)||0,d=parseFloat(r.height)||0,f=parseFloat(i.width)||0,h=parseFloat(i.height)||0,p=Math.max(t.width,c,f),g=Math.max(t.height,d,h),x=p-t.width,y=g-t.height;return{left:t.left-x/2,right:t.right+x/2,top:t.top-y/2,bottom:t.bottom+y/2}}const Ppe="data-popup-side",Ipe=400,Mpe={...sE,...Rl,popupSide:e=>e?{[Ppe]:e}:null,value:()=>null},_pe=v.forwardRef(function(t,n){const{render:r,className:i,id:o,disabled:c=!1,nativeButton:d=!0,style:f,...h}=t,{setTouched:p,setFocused:g,validationMode:x,validation:y,state:j,disabled:w}=Oi(),{labelId:S}=ii(),N=Ju(),{readOnly:A,required:E,disabled:O}=kT(),R=w||O||c,T=N.useState("open"),P=N.useState("mounted"),M=N.useState("value"),_=N.useState("triggerProps"),I=N.useState("positionerElement"),L=N.useState("listElement"),D=N.useState("popupSide"),z=N.useState("id"),G=N.useState("labelId"),X=N.useState("hasSelectedValue"),Y=P&&I?D:null,F=o??z,K=D4(S,G);Vu({id:o});const U=Fr(I),q=v.useRef(null),{getButtonProps:W,buttonRef:ne}=ai({disabled:R,native:d}),ie=N.useStateSetter("triggerElement"),V=Ds(),H=Ds(),Q=Ds();v.useEffect(()=>{if(T)return Q.start(Ipe,()=>{N.context.selectionRef.current.allowUnselectedMouseUp=!0,N.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{Q.clear()};N.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},H.clear()},[T,N,H,Q]);const J=Ai(_,{id:F,role:"combobox","aria-expanded":T,"aria-haspopup":"listbox","aria-controls":T?L?.id??Cj(I)?.id:void 0,"aria-labelledby":K,"aria-readonly":A||void 0,"aria-required":E||void 0,tabIndex:R?-1:0,onFocus(se){g(!0),T&&N.context.alignItemWithTriggerActiveRef.current&&N.context.setOpen(!1,at(Br,se.nativeEvent)),V.start(0,()=>{N.set("forceMount",!0)})},onBlur(se){nt(I,se.relatedTarget)||(p(!0),g(!1),x==="onBlur"&&y.commit(M))},onMouseDown(se){if(T)return;const le=vn(se.currentTarget);function te(re){if(!q.current)return;const he=re.target;nt(q.current,he)||nt(U.current,he)||L4(re,q.current)||N.context.setOpen(!1,at(jB,re))}H.start(0,()=>{le.addEventListener("mouseup",te,{once:!0})})}},h,W),oe=y.getValidationProps(R,J);oe.role="combobox";const ee={...j,open:T,disabled:R,value:M,readOnly:A,popupSide:Y,placeholder:!X};return wt("button",t,{ref:[n,q,ne,ie],state:ee,stateAttributesMapping:Mpe,props:oe})}),Dpe={value:()=>null},Lpe=v.forwardRef(function(t,n){const{className:r,render:i,children:o,placeholder:c,style:d,...f}=t,h=Ju(),p=h.useState("value"),g=h.useState("items"),x=h.useState("itemToStringLabel"),y=h.useState("hasSelectedValue"),j=!y&&c!=null&&o==null,w=h.useState("hasNullItemLabel",j),S={value:p,placeholder:!y};let N=null;return typeof o=="function"?N=o(p):o!=null?N=o:j&&!w?N=c:Array.isArray(p)?N=Ape(p,g,x):N=M4(p,g,x),wt("span",t,{state:S,ref:[n,h.context.valueRef],props:[{children:N},f],stateAttributesMapping:Dpe})}),zpe=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,h={open:Ju().useState("open")};return wt("span",t,{state:h,ref:n,props:[{"aria-hidden":!0,children:"▼"},c],stateAttributesMapping:jj})}),$pe=v.forwardRef(function(t,n){const r=Ju(),i=r.useState("mounted"),o=r.useState("forceMount");return i||o?s.jsx(Vj,{ref:n,...t}):null}),z4=v.createContext(void 0);function Bpe(){const e=v.useContext(z4);if(!e)throw new Error(En(59));return e}function m0(e,t){e&&Object.assign(e.style,t)}const Fpe={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Upe=20;function CT(e,t,n,r){const[i,o]=v.useState(!1);Ue(()=>{if(!e||!t||n==null){o(!1);return}const c=vn(n).documentElement.clientWidth,d=n.offsetWidth;o(c>0&&d>0&&d>=c-Upe)},[e,t,n]),o4(e&&(!t||i),r)}const Hpe={position:"fixed"},Vpe=v.forwardRef(function(t,n){const{anchor:r,className:i,render:o,positionMethod:c,side:d,align:f,sideOffset:h,alignOffset:p,collisionBoundary:g="clipping-ancestors",collisionPadding:x,arrowPadding:y,sticky:j,disableAnchorTracking:w,alignItemWithTrigger:S=!0,collisionAvoidance:N=KB,style:A,...E}=t,O=Ju(),R=T4(),T=O.useState("open"),P=O.useState("mounted"),M=O.useState("modal"),_=O.useState("value"),I=O.useState("openMethod"),L=O.useState("positionerElement"),D=O.useState("triggerElement"),z=O.useState("isItemEqualToValue"),G=O.useState("transitionStatus"),X=v.useRef(null),Y=v.useRef(null),[F,K]=v.useState(S),U=P&&F&&I!=="touch";!P&&F!==S&&K(S),v.useImperativeHandle(O.context.alignItemWithTriggerActiveRef,()=>U),CT((U||M)&&T,I==="touch",L,D);const q=r0({anchor:r,floatingRootContext:R,positionMethod:c,mounted:P,side:d,sideOffset:h,align:f,alignOffset:p,arrowPadding:y,collisionBoundary:g,collisionPadding:x,sticky:j,disableAnchorTracking:w??U,collisionAvoidance:N,keepMounted:!0}),W=U?"none":q.side,ne=U?Hpe:q.positionerStyles,ie={open:T,side:W,align:q.align,anchorHidden:q.anchorHidden};Ue(()=>{O.set("popupSide",q.side)},[O,q.side]);const V=O.useStateSetter("positionerElement"),H=s0(t,ie,{styles:ne,transitionStatus:G,props:E,refs:[n,V],hidden:!P,inert:!T}),Q=v.useRef(0),J=Fe(ee=>{if(O.context.valuesRef.current.length===0)return;const se=Q.current;Q.current=ee.size;const le=at(Br);if(se!==0&&!O.state.multiple&&_!==null&&am(O.context.valuesRef.current,_,z)===-1){const re=O.context.initialValueRef.current,pe=re!=null&&am(O.context.valuesRef.current,re,z)!==-1?re:null;O.context.setValue(pe,le),pe===null&&(O.set("selectedIndex",null),O.context.selectedItemTextRef.current=null)}if(se!==0&&O.state.multiple&&Array.isArray(_)){const te=_.filter(re=>am(O.context.valuesRef.current,re,z)!==-1);te.length!==_.length&&(O.context.setValue(te,le),te.length===0&&(O.set("selectedIndex",null),O.context.selectedItemTextRef.current=null))}if(T&&U){O.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const te={height:""};m0(L,te),m0(O.context.popupRef.current,te)}}),oe=v.useMemo(()=>({...q,side:W,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:K,scrollUpArrowRef:X,scrollDownArrowRef:Y}),[q,W,U,K]);return s.jsx(ST,{elementsRef:O.context.listRef,labelsRef:O.context.labelsRef,onMapChange:J,children:s.jsxs(z4.Provider,{value:oe,children:[P&&M&&s.jsx(l0,{inert:vx(!T),cutout:D}),H]})})}),g0="base-ui-disable-scrollbar",$4={className:g0,getElement(e){return s.jsx("style",{nonce:e,href:g0,precedence:"base-ui:low",children:`.${g0}{scrollbar-width:none}.${g0}::-webkit-scrollbar{display:none}`})}},Kpe=v.createContext(void 0);function B4(e){return v.useContext(Kpe)}const qpe=v.createContext(void 0),Gpe={disableStyleElements:!1};function Ype(){return v.useContext(qpe)??Gpe}const F4="--transform-origin",Wpe={...Wp,...io},Xpe=v.forwardRef(function(t,n){const{render:r,className:i,style:o,finalFocus:c,...d}=t,f=Ju(),{multiple:h,readOnly:p,highlightItemOnHover:g}=kT(),x=T4(),{side:y,align:j,alignItemWithTriggerActive:w,isPositioned:S,setControlledAlignItemWithTrigger:N}=Bpe(),A=B4()!=null,E=mx(),{nonce:O,disableStyleElements:R}=Ype(),T=f.useState("id"),P=f.useState("open"),M=f.useState("openMethod"),_=f.useState("mounted"),I=f.useState("popupProps"),L=f.useState("transitionStatus"),D=f.useState("triggerElement"),z=f.useState("positionerElement"),G=f.useState("listElement"),X=v.useRef(!1),Y=v.useRef(!1),F=v.useRef({}),K=Zp(),U=Fe(ie=>{if(!z||!f.context.popupRef.current||!Y.current)return;const V=z.style.top==="0px",H=z.style.bottom==="0px";if(X.current||!w||!V&&!H){f.context.handleScrollArrowVisibility(ie);return}const Q=H4(z),J=wx(z.getBoundingClientRect().height,"y",Q),oe=vn(z),ee=tr(z),se=ee.getComputedStyle(z),le=parseFloat(se.marginTop),te=parseFloat(se.marginBottom),re=U4(ee.getComputedStyle(f.context.popupRef.current)),he=Math.min(oe.documentElement.clientHeight-le-te,re),pe=ie.scrollTop,Ne=v0(ie);let me=null;const ce=Se=>{z.style.height=`${Se}px`},ae=V?Ne-pe:pe,_e=Math.min(J+ae,he);if(ae<=zc){const Se=Dc(ae,0,he-J);Se>0&&ce(J+Se),ie.scrollTop=V?Ne:0,he-(J+Se)<=zc&&(X.current=!0),f.context.handleScrollArrowVisibility(ie);return}if(he-_e>zc)me=V?1/0:0;else if(H&&pezc&&(ie.scrollTop=Se)}de>=he-zc&&(X.current=!0),f.context.handleScrollArrowVisibility(ie)});v.useImperativeHandle(f.context.scrollHandlerRef,()=>U,[U]),Va({open:P,ref:f.context.popupRef,onComplete(){P&&f.context.onOpenChangeComplete(!0)}});const q={open:P,transitionStatus:L,side:y,align:j};Ue(()=>{!z||!f.context.popupRef.current||Object.keys(F.current).length||(F.current={top:z.style.top||"0",left:z.style.left||"0",right:z.style.right,height:z.style.height,bottom:z.style.bottom,minHeight:z.style.minHeight,maxHeight:z.style.maxHeight,marginTop:z.style.marginTop,marginBottom:z.style.marginBottom})},[f,z]),Ue(()=>{P||w||(Y.current=!1,X.current=!1,m0(z,F.current))},[P,w,z]),Ue(()=>{const ie=f.context.popupRef.current;if(!P||!D||!z||!ie||w&&!S||f.state.transitionStatus==="ending")return;if(Y.current=!0,ie.style.removeProperty(F4),!w){K.request(()=>f.context.handleScrollArrowVisibility(G||ie));return}const V=Qpe(ie);try{let H=f.context.selectedItemTextRef.current;H?.isConnected||(H=!f.select("hasSelectedValue")&&f.context.firstItemTextRef.current?.isConnected?f.context.firstItemTextRef.current:null);const Q=f.context.valueRef.current,J=tr(z),oe=J.getComputedStyle(z),ee=J.getComputedStyle(ie),se=vn(D),le=H4(D),te=x0(D.getBoundingClientRect(),le),re=x0(z.getBoundingClientRect(),le),he=te.height,pe=G||ie,Ne=pe.scrollHeight,me=parseFloat(ee.borderBottomWidth),ce=parseFloat(oe.marginTop)||10,ae=parseFloat(oe.marginBottom)||10,_e=parseFloat(oe.minHeight)||100,de=U4(ee),Se=5,ve=5,xe=20,Re=se.documentElement.clientHeight-ce-ae,we=se.documentElement.clientWidth,ge=Re-te.bottom+he;let De,Ge=E==="rtl"?te.right-re.width:te.left,Ot=0;if(H&&Q){const Yt=x0(Q.getBoundingClientRect(),le);De=x0(H.getBoundingClientRect(),le),Ge=re.left+(E==="rtl"?Yt.right-De.right:Yt.left-De.left);const yt=Yt.top-te.top+Yt.height/2;Ot=De.top-re.top+De.height/2-yt}const sn=ge+Ot+ae+me;let $t=Math.min(Re,sn);const Me=Re-ce-ae,Ht=sn-$t,an=we-ve;z.style.left=`${Dc(Ge,Se,an-re.width)}px`,z.style.height=`${$t}px`,z.style.maxHeight="none",z.style.marginTop=`${ce}px`,z.style.marginBottom=`${ae}px`,ie.style.height="100%";const Mt=v0(pe),_t=Ht>=Mt-zc;_t&&($t=Math.min(Re,re.height)-(Ht-Mt));const Ve=te.topRe-xe||Math.ceil($t)+zc=Me?"0":`${Yt}px`,z.style.height=`${$t}px`,pe.scrollTop=v0(pe)}else z.style.bottom="0",pe.scrollTop=Ht;if(De){const Yt=re.top,yt=re.height,un=De.top+De.height/2,Tn=Dc(yt>0?(un-Yt)/yt*100:50,0,100);ie.style.setProperty(F4,`50% ${Tn}%`)}(Ut===Re||$t>=de)&&(X.current=!0),f.context.handleScrollArrowVisibility(pe),g&&f.state.selectedIndex===null&&f.state.activeIndex===null&&f.context.listRef.current[0]!=null&&f.set("activeIndex",0)}finally{V()}},[f,P,z,D,w,N,K,G,g,E,S]),v.useEffect(()=>{if(!w||!z||!P)return;const ie=tr(z);function V(H){f.context.setOpen(!1,at(Lue,H))}return Jt(ie,"resize",V)},[f,w,z,P]);const W={...G?{role:"presentation"}:{role:"listbox","aria-multiselectable":h||void 0,"aria-readonly":p||void 0,id:`${T}-list`},onKeyDown(ie){A&&i0.has(ie.key)&&ie.stopPropagation()},onScroll(ie){G||U(ie.currentTarget)},...w&&{style:G?{height:"100%"}:Fpe},className:!G&&w?$4.className:void 0},ne=wt("div",t,{ref:[n,f.context.popupRef],state:q,stateAttributesMapping:Wpe,props:[I,W,gx(L),d]});return s.jsxs(v.Fragment,{children:[!R&&$4.getElement(O),s.jsx(Kj,{context:x,modal:!1,disabled:!_,openInteractionType:M,returnFocus:c,restoreFocus:!0,children:ne})]})});function U4(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function v0(e){return _4(e.scrollHeight,e.clientHeight)}function H4(e){return f5.getScale(e)}function wx(e,t,n){return e/n[t]}function x0(e,t){return nx({x:wx(e.x,"x",t),y:wx(e.y,"y",t),width:wx(e.width,"x",t),height:wx(e.height,"y",t)})}const V4=[["transform","none"],["scale","1"],["translate","0 0"]];function Qpe(e){const{style:t}=e,n={};for(const[r,i]of V4)n[r]=t.getPropertyValue(r),t.setProperty(r,i,"important");return()=>{for(const[r]of V4){const i=n[r];i?t.setProperty(r,i):t.removeProperty(r)}}}const K4=v.createContext(void 0);function AT(){const e=v.useContext(K4);if(!e)throw new Error(En(57));return e}const Zpe=v.memo(v.forwardRef(function(t,n){const{render:r,className:i,style:o,value:c=null,label:d,disabled:f=!1,nativeButton:h=!1,...p}=t,g=v.useRef(null),x=jT({guess:!0,label:d,textRef:g}),y=Ju(),{itemProps:j,multiple:w,disabled:S,readOnly:N}=kT(),A=S||f,E=y.useState("isActive",x.index),O=y.useState("open"),R=y.useState("isSelected",c),T=y.useState("isSelectedByFocus",x.index),P=y.useState("isItemEqualToValue"),M=x.index,_=v.useRef(null);Ue(()=>{const q=y.context.valuesRef.current;return q[M]=c,()=>{delete q[M]}},[M,c,y]),Ue(()=>{const q=y.state.value,W=y.state.selectedIndex;let ne=W,ie;w&&Array.isArray(q)?(ne=R4(M,c,y.context.valuesRef.current,q,P,W),ie=ne===M,M===W&&!ie&&(y.context.selectedItemTextRef.current=null)):(ie=q!==void 0&&po(c,q,P),ie&&(ne=M)),y.set("selectedIndex",ne),ie&&g.current&&(y.context.selectedItemTextRef.current=g.current)},[M,w,P,y,c]);const I=v.useRef("mouse"),L=v.useRef(!1),{getButtonProps:D,buttonRef:z}=ai({disabled:A,focusableWhenDisabled:!0,native:h,composite:!0}),G={disabled:A,selected:R,highlighted:E};function X(q){if(S||N)return;const W=y.state.value;if(w){const ne=Array.isArray(W)?W:[],ie=R?P4(ne,c,P):[...ne,c];y.context.setValue(ie,at(ax,q))}else y.context.setValue(c,at(ax,q)),y.context.setOpen(!1,at(ax,q))}function Y(){y.context.selectionRef.current.dragY=0}const F={role:"option","aria-selected":R,tabIndex:O&&E?0:-1,onKeyDown(q){y.set("activeIndex",M),q.key===" "&&y.context.typingRef.current&&q.preventDefault()},onClick(q){const W=I.current!=="touch",ne=q.nativeEvent.pointerType,ie=W&&Aj(q.nativeEvent)&&(ne!==void 0||E),V=W&&!ie&&!L.current;L.current=!1,!(A||V)&&X(q.nativeEvent)},onPointerEnter(q){I.current=q.pointerType},onPointerMove(q){if(q.pointerType==="mouse"&&q.buttons===1){const W=y.context.selectionRef.current;W.dragY+=q.movementY,W.dragY**2>=64&&(W.allowUnselectedMouseUp=!0)}},onPointerDown(q){I.current=q.pointerType,L.current=!0,Y()},onMouseUp(){if(Y(),A||I.current==="touch"||L.current)return;const q=!y.context.selectionRef.current.allowSelectedMouseUp&&R,W=!y.context.selectionRef.current.allowUnselectedMouseUp&&!R;q||W||(L.current=!0,_.current?.click(),L.current=!1)}},K=wt("div",t,{ref:[z,n,x.ref,_],state:G,props:[j,F,p,D]}),U=v.useMemo(()=>({selected:R,index:M,textRef:g,selectedByFocus:T}),[R,M,g,T]);return s.jsx(K4.Provider,{value:U,children:K})})),Jpe=v.forwardRef(function(t,n){const{selected:r}=AT();return t.keepMounted||r?s.jsx(eme,{...t,ref:n}):null}),eme=v.memo(v.forwardRef((e,t)=>{const{render:n,className:r,style:i,keepMounted:o,...c}=e,{selected:d}=AT(),f=v.useRef(null),{transitionStatus:h,setMounted:p}=Ic(d),x=wt("span",e,{ref:[t,f],state:{selected:d,transitionStatus:h},props:[{"aria-hidden":!0,children:"✔️"},c],stateAttributesMapping:io});return Va({batch:!0,enabled:!d,open:d,ref:f,onComplete(){d||p(!1)}}),x})),tme=v.memo(v.forwardRef(function(t,n){const{index:r,textRef:i,selectedByFocus:o}=AT(),c=Ju(),{render:d,className:f,style:h,...p}=t,g=v.useCallback(y=>{y&&(r===0&&(c.context.firstItemTextRef.current=y),o&&(c.context.selectedItemTextRef.current=y))},[c,r,o]);return wt("div",t,{ref:[g,n,i],props:p})})),q4=v.createContext(void 0);function nme(){const e=v.useContext(q4);if(e===void 0)throw new Error(En(56));return e}const rme=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,[d,f]=v.useState(),h=v.useMemo(()=>({labelId:d,setLabelId:f}),[d,f]),p=wt("div",t,{ref:n,props:[{role:"group","aria-labelledby":d},c]});return s.jsx(q4.Provider,{value:h,children:p})}),sme=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,...d}=t,{setLabelId:f}=nme(),h=bs(c);return Ue(()=>(f(h),()=>{f(g=>g===h?void 0:g)}),[h,f]),wt("div",t,{ref:n,props:[{id:h,"aria-hidden":!0},d]})}),ame=v.forwardRef(function(t,n){const{className:r,render:i,orientation:o="horizontal",style:c,...d}=t;return wt("div",t,{state:{orientation:o},ref:n,props:[{role:"presentation"},d]})}),ht=Ope,pt=Lpe,ime=rme,ome=sme,lme=ame;function mt({className:e,children:t,...n}){return s.jsxs(_pe,{"data-slot":"select-trigger",className:Te("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","[&>span]:min-w-0 [&>span]:truncate","text-[12.5px] font-normal text-foreground max-[767px]:h-10 max-[767px]:text-base","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",e),...n,children:[t,s.jsx(zpe,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:s.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:s.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}function gt({className:e,sideOffset:t=4,children:n,...r}){return s.jsx($pe,{children:s.jsx(Vpe,{sideOffset:t,alignItemWithTrigger:!1,className:"z-[35]",children:s.jsx(Xpe,{"data-slot":"select-content",className:Te("max-h-[260px] min-w-[var(--anchor-width)] overflow-y-auto overscroll-contain rounded-lg border border-border-strong bg-raised p-[5px] shadow-3","outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0",e),...r,children:n})})})}function qe({className:e,children:t,...n}){return s.jsxs(Zpe,{"data-slot":"select-item",className:Te("flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-[9px] text-[12.5px] leading-[1.4] text-foreground select-none","transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:font-normal data-disabled:text-muted-foreground",e),...n,children:[s.jsx(tme,{className:"min-w-0 flex-1 truncate",children:t}),s.jsx(Jpe,{className:"flex flex-none text-primary",children:s.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:s.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}const cme={left:0,top:0,width:0,height:0,ready:!1};function G4(e,t){const n=v.useRef(null),[r,i]=v.useState(cme),[o,c]=v.useState(!1),d=v.useRef(!1),f=v.useRef(null),h=v.useCallback(()=>{const g=n.current,x=g?.querySelector(t);if(!g||!x||!g.offsetWidth||!g.offsetHeight||!x.getClientRects().length){d.current=!1,c(!1),i(A=>A.ready?{...A,ready:!1}:A);return}const y=g.getBoundingClientRect(),j=x.getBoundingClientRect();if(!y.width||!y.height||!j.width||!j.height)return;const w=y.width/g.offsetWidth,S=y.height/g.offsetHeight,N={left:(j.left-y.left)/w-g.clientLeft+g.scrollLeft,top:(j.top-y.top)/S-g.clientTop+g.scrollTop,width:j.width/w,height:j.height/S,ready:!0};d.current=!0,i(A=>A.ready&&Math.abs(A.left-N.left)<.1&&Math.abs(A.top-N.top)<.1&&Math.abs(A.width-N.width)<.1&&Math.abs(A.height-N.height)<.1?A:N)},[t]),p=v.useCallback(()=>{if(!d.current){h();return}f.current===null&&(f.current=requestAnimationFrame(()=>{f.current=null,h()}))},[h]);return v.useLayoutEffect(()=>{p()}),v.useLayoutEffect(()=>{const g=n.current;if(!g)return;const x=typeof ResizeObserver>"u"?null:new ResizeObserver(p),y=()=>{x?.disconnect(),x?.observe(g),g.querySelectorAll(e).forEach(w=>x?.observe(w))};y();const j=new MutationObserver(w=>{const S=w.filter(N=>!(N.target instanceof Element&&N.target.hasAttribute("data-selection-indicator")));S.length&&(S.some(N=>N.type==="childList")&&y(),p())});return j.observe(g,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["data-active","data-checked","class","hidden","style"]}),window.addEventListener("resize",p),document.fonts?.addEventListener("loadingdone",p),()=>{x?.disconnect(),j.disconnect(),f.current!==null&&cancelAnimationFrame(f.current),f.current=null,window.removeEventListener("resize",p),document.fonts?.removeEventListener("loadingdone",p)}},[e,p]),v.useEffect(()=>{if(!r.ready||o)return;let g=0;const x=requestAnimationFrame(()=>{g=requestAnimationFrame(()=>{d.current&&c(!0)})});return()=>{cancelAnimationFrame(x),cancelAnimationFrame(g)}},[r.ready,o]),{containerRef:n,indicator:{"data-selection-indicator":"","data-ready":r.ready?"true":"false","data-animate":o?"true":"false",style:{transform:`translate3d(${r.left}px, ${r.top}px, 0)`,width:r.width,height:r.height}}}}function dn({options:e,value:t,onValueChange:n,disabled:r=!1,className:i,...o}){const{containerRef:c,indicator:d}=G4('[data-slot="segmented-item"]','[data-slot="segmented-item"][data-checked]');return s.jsxs(k4,{ref:c,"data-slot":"segmented-control",className:Te("relative inline-flex gap-0.5 rounded-md border border-control-border bg-control p-0.5",i),value:t,disabled:r,onValueChange:f=>n(f),...o,children:[s.jsx("span",{"aria-hidden":"true","data-slot":"segmented-thumb",...d}),e.map(f=>s.jsxs(w4,{value:f.value,"data-slot":"segmented-item",disabled:f.disabled,"data-zero":f.count===0?"true":void 0,className:Te("group/seg relative z-[1] inline-flex h-6 items-center gap-[5px] rounded-sm border-0 bg-transparent px-2.5","text-xs font-medium whitespace-nowrap text-subtle select-none","transition-[background-color,color] duration-150 ease-out","hover:bg-nav-hover hover:text-foreground","data-checked:bg-transparent data-checked:text-primary-fg data-checked:hover:bg-transparent","data-disabled:cursor-not-allowed data-disabled:opacity-40","data-[zero=true]:data-unchecked:opacity-45"),children:[f.label,f.count!==void 0&&s.jsx("span",{className:Te("min-w-4 rounded-pill bg-surface-3 px-[5px] text-center text-[10.5px] font-semibold tabular-nums text-muted-foreground","group-data-checked/seg:bg-primary-tint group-data-checked/seg:text-primary-fg"),children:f.count})]},f.value))]})}const ume=v.createContext(void 0);function dme(){return v.useContext(ume)}const fme=v.forwardRef(function(t,n){const{className:r,defaultPressed:i=!1,disabled:o=!1,form:c,onPressedChange:d,pressed:f,render:h,type:p,value:g,nativeButton:x=!0,style:y,...j}=t,w=bs(g||void 0),S=dme(),N=S?.value??[],A=(o||S?.disabled)??!1,[E,O]=qo({controlled:S?w!==void 0&&N.indexOf(w)>-1:f,default:i,name:"Toggle",state:"pressed"}),{getButtonProps:R,buttonRef:T}=ai({disabled:A,native:x}),P={disabled:A,pressed:E},M=[T,n],_=[{"aria-pressed":E,onClick(D){const z=!E,G=at(Br,D.nativeEvent);d?.(z,G),!G.isCanceled&&(w&&S?.setGroupValue?.(w,z,G),!G.isCanceled&&O(z))}},j,R],I=wt("button",t,{enabled:!S,state:P,ref:M,props:_}),L=v.useMemo(()=>({disabled:A,focusableWhenDisabled:!1}),[A]);return S?s.jsx(x4,{tag:"button",render:h,className:r,style:y,metadata:L,state:P,refs:M,props:_}):I}),hme=Tf(["inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border","font-medium transition-[background-color,border-color,color] duration-150 ease-out","outline-none select-none disabled:pointer-events-none disabled:opacity-45","[&_svg]:pointer-events-none [&_svg]:shrink-0","data-pressed:border-primary-bd data-pressed:bg-primary-soft data-pressed:font-semibold data-pressed:text-primary-fg","data-pressed:hover:bg-primary-tint"],{variants:{variant:{default:"border-transparent bg-transparent text-subtle hover:bg-nav-hover hover:text-foreground",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]"}},defaultVariants:{variant:"default",size:"default"}});function pme({className:e,variant:t,size:n,...r}){return s.jsx(fme,{"data-slot":"toggle",className:Te(hme({variant:t,size:n}),e),...r})}function mme(e,t,n,r,i,o,c,d,f,h=2){const p=hue(n.current,{event:e,orientation:r,loopFocus:i,rtl:o,cols:h,disabledIndices:c,minIndex:d,maxIndex:f,prevIndex:t>f?d:t,stopEvent:!0});return Yu(n.current,p)?void 0:p}const Y4=v.createContext(void 0),W4=v.createContext(void 0),X4=v.createContext(void 0),Q4=v.createContext(!1),Z4=v.createContext("");function Wo(){const e=v.useContext(Y4);if(!e)throw new Error(En(22));return e}function b0(){const e=v.useContext(W4);if(!e)throw new Error(En(23));return e}function jx(){const e=v.useContext(X4);if(!e)throw new Error(En(24));return e}function J4(){return v.useContext(Z4)}function gme(){return v.useContext(Q4)}const vme={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?I4(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(i=>po(t,i,n)):po(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight};function eF(e){return e==null?void 0:`${e}-popup`}function xme(e,t){return(n,r)=>n==null?!1:e.contains(n,r,t)}const tF=new Map;function bme(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${EE(e.locale)}|${JSON.stringify(t)}`,r=tF.get(n);if(r)return r;const i=new Intl.Collator(e.locale,t),o={contains(c,d,f){if(!d)return!0;const h=ed(c,f);for(let p=0;p<=h.length-d.length;p+=1)if(i.compare(h.slice(p,p+d.length),d)===0)return!0;return!1},startsWith(c,d,f){if(!d)return!0;const h=ed(c,f);return i.compare(h.slice(0,d.length),d)===0},endsWith(c,d,f){if(!d)return!0;const h=ed(c,f),p=d.length;return h.length>=p&&i.compare(h.slice(h.length-p),d)===0}};return tF.set(n,o),o}const yme=bme;function wme(e,t=!1){const{overflowY:n}=si(e);return n!=="auto"&&n!=="scroll"?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}const nF=Symbol("none"),ET={value:nF,index:-1};function jme(e,t,n){const r=e.get(t);if(r!==void 0||n===d0)return r;for(const[i,o]of e)if(po(i,t,n))return o}function Sme(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:o,defaultInputValue:c,inputValue:d,open:f,defaultOpen:h=!1,selectionMode:p,onItemHighlighted:g,name:x,form:y,disabled:j=!1,readOnly:w=!1,required:S=!1,inputRef:N,grid:A=!1,items:E,filteredItems:O,filter:R,filterQuery:T,openOnInputClick:P=!0,autoHighlight:M=!1,keepHighlight:_=!1,highlightItemOnHover:I=!0,loopFocus:L=!0,itemToStringLabel:D,itemToStringValue:z,isItemEqualToValue:G=d0,virtualized:X=!1,inline:Y=!1,fillInputOnItemPress:F=!0,modal:K=!1,limit:U=-1,autoComplete:q="list",formAutoComplete:W,locale:ne,submitOnItemClick:ie=!1}=e,{clearErrors:V}=Ac(),{setDirty:H,validityData:Q,setFilled:J,name:oe,disabled:ee,setTouched:se,setFocused:le,validationMode:te,validation:re}=Oi(),he=mx(),pe=Vu({id:t}),Ne=yme({locale:ne}),me=Array.isArray(E)?null:E;if(me&&typeof me.label!="function")throw new Error(En(100));const ce=me?me.data:E,ae=me?.value,_e=ae?void 0:ce,de=v.useMemo(()=>{if(!O||!ae)return;const We=h0(O),Je=We.map(ae);let Wt;return{values:Je,findItem(Hn,Nr){if(!Wt){Wt=new Map;for(let dr=0;drme?We=>me.label(We,G,Je=>{const Wt=de?.findItem(Je,G);return Wt!=null?me.itemLabel(Wt):ed(Je,D)}):D,[me,D,de,G]),ve=v.useMemo(()=>me?Object.assign(We=>me.itemLabel(We),{selected:We=>ed(We,Se)}):D,[me,Se,D]);function xe(We){return ed(We,Se)}const[Re,we]=v.useState(!1),[ge,De]=v.useState(null),Ge=v.useRef(ge),Ot=v.useRef([]),sn=v.useRef([]),$t=v.useRef(null),Me=v.useRef(null),Ht=v.useRef(null),an=v.useRef(null),Mt=v.useRef(null),_t=v.useRef(!0),Ve=v.useRef(!1),bt=v.useRef(null),Ut=v.useRef(null),Yt=v.useRef(null),yt=v.useRef(ET),un=v.useRef(null),Tn=v.useRef([]),$r=v.useRef(null),Sr=ee||j,kr=oe??x,ur=p==="multiple",Fn=p==="single",Gr=d!==void 0||c!==void 0,yn=ce!==void 0,Le=O!==void 0;let Ze;M==="always"?Ze="always":Ze=M?"input-change":!1;const[Ye,Kt]=qo({controlled:i,default:ur?r??Ti:r,name:"Combobox",state:"selectedValue"}),ln=v.useMemo(()=>R===null?()=>!0:R!==void 0?R:xme(Ne,ve),[R,Ne,ve]),Gt=hs(()=>Gr?c??"":Fn?xe(Ye):"").current,[Rt,vr]=qo({controlled:d,default:Gt,name:"Combobox",state:"inputValue"}),[Qt,gs]=qo({controlled:f,default:h,name:"Combobox",state:"open"}),_o=NT(ce),Or=!Qt&&ge!==null?ge:String(Rt).trim(),pn=Fn?xe(Ye):"",us=Fn&&!Re&&Or!==""&&pn.length===Or.length&&Ne.contains(pn,Or),bl=us?"":T??Or,hw=yn&&Le&&us&&(!me||me.hasValue(Ye,G)),pp=v.useMemo(()=>ce?h0(ce):Ti,[ce]),Zd=v.useMemo(()=>{if(O&&!hw)return O;if(!ce)return Ti;if(_o){const Je=ce,Wt=[];let Hn=0;for(const Nr of Je){if(U>-1&&Hn>=U)break;const dr=U>-1?U-Hn:1/0,Cr=bl===""?Nr.items.slice(0,dr):[];if(bl!=="")for(const vs of Nr.items){if(Cr.length>=dr)break;ln(vs,bl,ve)&&Cr.push(vs)}if(Cr.length>0){const vs={...Nr,items:Cr};Wt.push(vs),Hn+=Cr.length}}return Wt}if(bl==="")return U>-1?pp.slice(0,U):pp;const We=[];for(const Je of pp){if(U>-1&&We.length>=U)break;ln(Je,bl,ve)&&We.push(Je)}return We},[O,hw,ce,_o,bl,U,ln,ve,pp]),Ws=v.useMemo(()=>{if(de&&Zd===O)return de.values;const We=h0(Zd);return ae?We.map(Je=>ae(Je)):We},[Zd,O,de,ae]),Dt=hs(()=>{let We=null;return Y&&Qt&&yn&&p!=="none"&&(We=yx(Ws,Ye,G,ur)),new $f({id:pe,labelId:void 0,selectedValue:Ye,open:Qt,items:_e,selectionMode:p,name:kr,form:y,disabled:Sr,readOnly:w,required:S,grid:A,virtualized:X,openOnInputClick:P,itemToStringLabel:Se,isItemEqualToValue:G,modal:K,autoHighlight:Ze,submitOnItemClick:ie,hasInputValue:Gr,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:Y,activeIndex:null,selectedIndex:We,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:rr,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:p==="none"},{onOpenChangeComplete:Pn,setOpen:Pn,setInputValue:Pn,setSelectedValue:Pn,setIndices:Pn,handleSelection:Pn,forceMount:Pn,requestSubmit:Pn,listRef:Ot,labelsRef:sn,popupRef:$t,emptyRef:Mt,inputRef:Me,startDismissRef:Ht,endDismissRef:an,keyboardActiveRef:_t,chipsContainerRef:bt,clearRef:Ut,valuesRef:Tn,pointerDownItemRef:$r,selectionEventRef:Yt},vme)}).current,bu=p==="none"?Rt:Ye,oC=v.useMemo(()=>p==="none"?bu:Array.isArray(Ye)?Ye.map(We=>Yo(We,z)):Yo(Ye,z),[bu,z,p,Ye]),yl=Fe(g),Xs=Fe(n),ja=Dt.useState("activeIndex"),Jd=Dt.useState("selectedIndex"),mp=Dt.useState("positionerElement"),lC=Dt.useState("listElement"),gp=Dt.useState("triggerElement"),vp=Dt.useState("inputElement"),xp=Dt.useState("inputGroupElement"),Qs=Dt.useState("inline"),Ua=Dt.useState("inputInsidePopup"),yu=Dt.useState("inputOwnsFormValue"),wu=Fn&&!Ua&&Rt===pn,bp=Fr(gp),{mounted:ef,setMounted:Ts,transitionStatus:pw}=Ic(Qt),{openMethod:cC,triggerProps:mw}=u4(Qt),ju=Fe(()=>oC);Jp(Ua?bp:Me,pe,bu,ju,!Sr,x);const Su=Fe(()=>{ce?sn.current=Ws.map(xe):Dt.set("forceMounted",!0)}),tf=Fe((We,Je,Wt)=>{if(Je===-1){if(yt.current===ET)return;yt.current=ET}else yt.current={value:We,index:Je};yl(We,zue(Wt,void 0,{index:Je}))}),Wi=Fe(We=>{const Je={};We.activeIndex!==void 0&&(Je.activeIndex=We.activeIndex),We.selectedIndex!==void 0&&(Je.selectedIndex=We.selectedIndex),Dt.update(Je);const Wt=We.activeIndex;if(Wt===void 0)return;const Hn=We.type||Br;Wt===null?tf(void 0,-1,Hn):tf(Tn.current[Wt],Wt,Hn)}),Xi=Fe((We,Je)=>{if(e.onInputValueChange?.(We,Je),!Je.isCanceled){if(Ve.current=Je.reason===Pl,Je.reason===ix){Qt&&ge!==null&&De(null);const Wt=Je.event,Hn=Wt.inputType;if(Wt.type==="compositionend"||Hn!=null&&Hn!==""&&Hn!=="insertReplacementText"){const dr=We.trim()!=="";dr&&we(!0),un.current={hasQuery:dr};const Cr=Dt.state.listElement;if(!Dt.state.virtualized&&Cr){const vs=$t.current;for(const wi of qp(Cr.firstElementChild??Cr)){if(!nr(wi)||(vs?!nt(vs,wi):wi.getAttribute("role")==="dialog"))break;if(wme(wi)){wi.scrollTop=0;break}}}dr&&Ze&&Dt.state.activeIndex==null&&(Qt||Qs)&&Dt.set("activeIndex",0)}}else Je.reason===Pl&&We===""&&Dt.state.inputInsidePopup&&(un.current={hasQuery:!1,selection:!0});vr(We)}}),uC=Fe(We=>{const Je=!We&&Ua&&!Qs&&Rt!==""&&(String(Rt).trim()===ge||Rt===pn);!We&&(Je||Rt===""||wu)&&we(!1),De(null),Je&&Xi("",at(Pl))}),An=Fe((We,Je)=>{if(Qt!==We&&(Je.reason===em&&yn&&Ws.length===0&&!Mt.current&&Je.allowPropagation(),e.onOpenChange?.(We,Je),!Je.isCanceled&&(We&&ge!==null&&uC(Je.reason===ix),!We&&Re&&(Fn?(Qs||De(Or),Or===""&&we(!1)):ur&&(Qs||De(Or),Ua&&Wi({activeIndex:null}),(!Ua||Qs)&&Xi("",at(Pl,Je.event,void 0,{isItemPress:Je.reason===ax})))),gs(We),!We&&Ua&&(Je.reason===Xu||Je.reason===$j)&&(se(!0),le(!1),te==="onBlur")))){const Wt=p==="none"?Rt:Ye;re.commit(Wt)}}),yp=Fe((We,Je)=>{if(o?.(We,Je),Je.isCanceled)return;Kt(We),(p==="none"&&$t.current&&F||Fn&&!Dt.state.inputInsidePopup)&&Xi(xe(We),at(Je.reason,Je.event))}),lv=Fe((We,Je)=>{const Wt=or(We),Hn=Yt.current??We;Yt.current=null;const Nr=at(ax,Hn),dr=Wt?.closest("a")?.getAttribute("href");if(dr){dr.startsWith("#")&&An(!1,Nr);return}if(ur){const Cr=Array.isArray(Ye)?Ye:[],vs=f0(Cr,Je,G),wi=vs?P4(Cr,Je,G):[...Cr,Je];if(yp(wi,Nr),Nr.isCanceled||!(Me.current?Me.current.value.trim()!=="":!1))return;if(Dt.state.inputInsidePopup){Xi("",at(Pl,Nr.event,void 0,{isItemPress:!0}));const Zi=un.current;Zi&&!vs&&(Zi.toggledValue=Je)}else An(!1,Nr)}else{if(yp(Je,Nr),Nr.isCanceled)return;An(!1,Nr)}}),cv=Fe(()=>{const We=re.inputRef.current?.form??Dt.state.inputElement?.form;We&&typeof We.requestSubmit=="function"&&We.requestSubmit()}),Qi=Fe(()=>{if(Ts(!1),Xs?.(!1),we(!1),De(null),Wi(p==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),ur&&Me.current&&Me.current.value!==""&&!Ve.current&&Xi("",at(Pl)),Fn)if(Dt.state.inputInsidePopup)Me.current&&Me.current.value!==""&&Xi("",at(Pl));else{const We=xe(Ye);Me.current&&Me.current.value!==We&&Xi(We,at(We===""?Pl:Br))}}),Ja=v.useMemo(()=>Qs&&mp?{current:mp.closest('[role="dialog"]')}:$t,[Qs,mp]);Va({enabled:!e.actionsRef,open:Qt,ref:Ja,onComplete(){Qt||Qi()}}),v.useImperativeHandle(e.actionsRef,()=>({unmount:Qi}),[Qi]),Ue(function(){const Je=Ge.current!==null&&ge===null;if(Ge.current=ge,Qt&&(!Je||!yn)||(Qt||($r.current=null),p==="none"))return;const Wt=yn?Ws:Tn.current;Wi({selectedIndex:yx(Wt,Ye,G,ur)})},[Qt,ge,Ye,p,ur,yn,Ws,G,Wi]),Ue(()=>{ce&&(Tn.current=Ws,Ot.current.length=Ws.length)},[ce,Ws]),Ue(()=>{const We=un.current;if(We){const vs=Qt||Qs||Dt.state.positionerElement?.hidden===!1;if(We.hasQuery)Ze&&vs&&Dt.set("activeIndex",0),un.current=null;else if(String(Rt).trim()===""&&(un.current=null,vs)){const wi=We.selection;Ze==="always"&&!wi&&Dt.state.selectionMode==="none"&&Dt.set("activeIndex",0),queueMicrotask(()=>{if(!Dt.state.open&&!Dt.state.inline||Me.current&&Me.current.value.trim()!=="")return;const Lo=Dt.state.selectedValue,Zi=Dt.state.selectionMode==="multiple";if(Zi&&Array.isArray(Lo)?Lo.length>0:Dt.state.selectionMode!=="none"&&Lo!=null){const ca=yn||Le?Ws:Tn.current,jl=am(ca,We.toggledValue,Dt.state.isItemEqualToValue);Dt.set("activeIndex",jl!==-1?jl:yx(ca,Lo,Dt.state.isItemEqualToValue,Zi))}else wi?Dt.set("activeIndex",null):Ze==="always"&&Dt.set("activeIndex",0)})}}if(!Qt&&!Qs)return;const Wt=yn||Le?Ws:Tn.current,Hn=Dt.state.activeIndex;if(Hn==null){if(Ze==="always"&&Wt.length>0){Dt.set("activeIndex",0);return}tf(void 0,-1,Br);return}if(Hn>=Wt.length){tf(void 0,-1,Br),Dt.set("activeIndex",null);return}const Nr=Wt[Hn],dr=yt.current.value,Cr=dr!==nF&&po(Nr,dr,Dt.state.isItemEqualToValue);(yt.current.index!==Hn||!Cr)&&tf(Nr,Hn,Br)},[ja,Ze,tf,Le,yn,Ws,Qs,Qt,Dt,Rt]),Ue(()=>{if(p==="none"){J(String(Rt)!=="");return}J(ur?Array.isArray(Ye)&&Ye.length>0:Ye!=null)},[J,p,Rt,Ye,ur]),v.useEffect(()=>{yn&&Ze&&Ws.length===0&&Wi({activeIndex:null})},[yn,Ze,Ws.length,Wi]);function dC(){Qt&&Or!==""&&Or!==String(Gt)&&!wu&&we(!0)}function PL(){Qt&&ge!==null&&uC(!1)}let uv=!1;function gw(){!uv&&Rt!==pn&&(uv=!0,Xi(pn,at(Br)))}function IL(){p!=="none"&&(V(kr),H(O4(Ye,Q.initialValue,G)),re.change(Ye),Fn&&!Gr&&!Ua&&gw())}function ei(){Fn&&!Gr&&!Ua&&!Re&&gw()}function vw(){p==="none"&&(V(kr),H(Rt!==Q.initialValue),re.change(Rt))}co(Or,dC),co(Qt,PL),co(Ye,IL),co(pn,ei),co(ce,ei),co(Rt,vw);const wp=O5({open:Qs?!0:Qt,onOpenChange:An,elements:{reference:Ua?gp:vp,floating:mp}}),dv=A?"grid":"listbox",wl=Qt||Qs,xw=wl?"true":"false",jp=v.useMemo(()=>{const We=vp?.tagName==="INPUT",Je=vp==null||We,Wt=Je||wl,Hn=Je?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return Wt&&(Hn.role="combobox",Hn["aria-expanded"]=xw,Hn["aria-haspopup"]=dv,Hn["aria-controls"]=wl?lC?.id:void 0,Hn["aria-autocomplete"]=w?"none":q),{reference:Hn,floating:{role:"presentation"}}},[vp,wl,xw,dv,lC?.id,q,w]),ku=dx(wp,{enabled:!Sr&&P,event:"mousedown-only",toggle:!1,touchOpenDelay:Ua?0:100,reason:_ue}),fv=fx(wp,{enabled:!Sr&&!Qs,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Qs?!0:void 0,outsidePress(We){const Je=or(We);return!nt(gp,Je)&&!nt(Ut.current,Je)&&!nt(bt.current,Je)&&!nt(xp,Je)}}),Nu=_5(wp,{enabled:!Sr,id:pe,listRef:Ot,activeIndex:ja,selectedIndex:Jd,virtual:!0,loopFocus:L,allowEscape:L&&!Ze,focusItemOnOpen:Re||p==="none"&&!Ze?!1:"auto",focusItemOnHover:I,resetOnPointerLeave:!_,orientation:A?"horizontal":void 0,rtl:he==="rtl",disabledIndices:Ti,grid:A?mme:void 0,onNavigate(We,Je){!Je&&!Qt||pw==="ending"||Wi(Je?{activeIndex:We,type:_t.current?yB:wB}:{activeIndex:We})}}),bw=v.useMemo(()=>Ai(Nu.reference,{onKeyDown(We){A&&Dt.state.activeIndex==null&&(We.key==="ArrowLeft"||We.key==="ArrowRight")&&We.preventBaseUIHandler()}},fv.reference,ku.reference,jp.reference),[Nu.reference,fv.reference,ku.reference,jp.reference,A,Dt]),hv=v.useMemo(()=>Ai(hx,fv.floating),[fv.floating]),fC=v.useMemo(()=>Ai(Nu.floating,jp.floating),[Nu.floating,jp.floating]),hC=v.useMemo(()=>{const We=Nu.item;return We?{...We,onFocus:void 0}:rr},[Nu.item]);Dt.useContextCallback("setOpen",An),Dt.useContextCallback("setInputValue",Xi),Dt.useContextCallback("setSelectedValue",yp),Dt.useContextCallback("setIndices",Wi),Dt.useContextCallback("handleSelection",lv),Dt.useContextCallback("forceMount",Su),Dt.useContextCallback("requestSubmit",cv),Dt.useContextCallback("onOpenChangeComplete",n),N4(()=>{Dt.update({inline:Y,popupProps:hv,listProps:fC,inputProps:bw,triggerProps:mw,itemProps:hC})});const Sp={id:pe,selectedValue:Ye,open:Qt,mounted:ef,transitionStatus:pw,items:_e,inline:Y,popupProps:hv,listProps:fC,inputProps:bw,triggerProps:mw,itemProps:hC,openMethod:cC,selectionMode:p,name:kr,form:y,disabled:Sr,readOnly:w,required:S,grid:A,virtualized:X,openOnInputClick:P,itemToStringLabel:Se,modal:K,autoHighlight:Ze,isItemEqualToValue:G,submitOnItemClick:ie,hasInputValue:Gr};Ue(()=>{Dt.update({...Sp,inputOwnsFormValue:p==="none"&&(Y||!Dt.state.inputInsidePopup)})},[Dt,...Object.values(Sp)]);const Do=Ei(N,re.inputRef),yw=v.useMemo(()=>({query:Or,hasItems:yn,filteredItems:Zd,flatFilteredValues:Ws}),[Or,yn,Zd,Ws]),ww=v.useMemo(()=>Array.isArray(bu)?"":Yo(bu,z),[bu,z]),nf=ur&&Array.isArray(Ye)&&Ye.length>0,pc=ur||p==="none"&&yu?void 0:kr,pC=v.useMemo(()=>!ur||!Array.isArray(Ye)||!kr?null:Ye.map(We=>{const Je=Yo(We,z);return s.jsx("input",{type:"hidden",form:y,name:kr,value:Je,disabled:Sr},Je)}),[ur,Ye,y,kr,z,Sr]),jw=s.jsxs(v.Fragment,{children:[e.children,s.jsx("input",{...re.getValidationProps(Sr,{onFocus(){if(Ua){gp?.focus();return}(Me.current||gp)?.focus()},onChange(We){if(We.nativeEvent.defaultPrevented||Sr||w)return;const Je=We.currentTarget.value,Wt=Je.toLowerCase(),Hn=at(Br,We.nativeEvent),Nr=()=>Tn.current.findIndex(Cr=>Yo(Cr,z).toLowerCase()===Wt||xe(Cr).toLowerCase()===Wt);function dr(){if(ur)return;if(p==="none"){Xi(Je,Hn);return}let Cr=Nr();Cr===-1&&(Cr=Tn.current.findIndex((wi,Lo)=>{const Zi=sn.current[Lo];return Zi!=null&&Zi.toLowerCase()===Wt}));const vs=Cr===-1?void 0:Tn.current[Cr];vs!=null&&yp?.(vs,Hn)}Fn&&(Su(),ce&&Nr()===-1&&Dt.set("forceMounted",!0)),queueMicrotask(dr)}}),id:pe&&pc==null?`${pe}-hidden-input`:void 0,form:y,name:pc,autoComplete:W,disabled:Sr,required:S&&!nf,readOnly:w,value:ww,ref:Do,style:pc?tm:_c,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),pC]});return s.jsx(Y4.Provider,{value:Dt,children:s.jsx(W4.Provider,{value:wp,children:s.jsx(Q4.Provider,{value:yn,children:s.jsx(X4.Provider,{value:yw,children:s.jsx(Z4.Provider,{value:Rt,children:jw})})})})})}function kme(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:o,...c}=e;return s.jsx(Sme,{...c,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:o})}const Nme="data-popup-side",Cme="data-list-empty",rF={...sE,...Rl,popupSide:e=>e?{[Nme]:e}:null,listEmpty:e=>e?{[Cme]:""}:null},Ame=v.createContext(void 0);function Eme(){return v.useContext(Ame)}const sF=v.createContext(void 0);function TT(e){const t=v.useContext(sF);if(t===void 0&&!e)throw new Error(En(21));return t}const aF=v.forwardRef(function(t,n){const r=Wo(),{buttonRef:i,getButtonProps:o}=ai({native:!1}),c=Ei(n,i);function d(h){r.context.setOpen(!1,at(SE,h.nativeEvent,h.currentTarget))}const f=o({onClick:d});return s.jsx("span",{ref:c,...f,"aria-label":"Dismiss",tabIndex:void 0,style:tm})});function iF(e){const t=e.useState("mounted"),n=e.useState("popupSide"),r=e.useState("positionerElement");return t&&r?n:null}function y0(){return jx().filteredItems.length===0}function Tme(e){return e==="rtl"?["ArrowRight","ArrowLeft"]:["ArrowLeft","ArrowRight"]}function Ome(e,t){const n=e>=t-1?t-2:e;return n>=0?n:void 0}function oF(e,t,n){const r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}const Rme=v.forwardRef(function(t,n){const{render:r,className:i,disabled:o=!1,id:c,style:d,...f}=t,{state:h,disabled:p,setTouched:g,setFocused:x,validationMode:y,validation:j}=Oi(),{labelId:w}=ii(),S=Eme(),A=!!TT(!0),E=Wo(),O=J4(),R=mx(),T=E.useState("required"),P=E.useState("disabled"),M=E.useState("readOnly"),_=E.useState("name"),I=E.useState("form"),L=E.useState("selectionMode"),D=E.useState("autoHighlight"),z=E.useState("inputProps"),G=E.useState("triggerProps"),X=E.useState("open"),Y=E.useState("mounted"),F=E.useState("selectedValue"),K=E.useState("id"),U=E.useState("inline"),q=E.useState("modal"),W=!!D,ne=iF(E),ie=p||P||o,V=y0(),H=A||U,Q=!H||q,J=bs(c??(H?void 0:K)),oe=A?V3:h,[ee,se]=v.useState(null),le=v.useRef(!1),te=v.useRef(null),re=v.useRef(!1),he=L==="none"&&!A,pe=Fe(ve=>{const xe=A||E.state.inline;xe&&!E.state.hasInputValue&&E.context.setInputValue("",at(Br)),E.update({inputElement:ve,inputInsidePopup:xe,inputOwnsFormValue:he})}),Ne=A?f:j.getValidationProps(ie,f);function me(){E.context.setIndices({activeIndex:null,selectedIndex:null,type:E.context.keyboardActiveRef.current?yB:wB})}function ce(){E.context.keyboardActiveRef.current=!1}const ae={...oe,open:X,disabled:ie,readOnly:M,popupSide:ne,listEmpty:V};function _e(ve){if(!S)return;let xe;const{highlightedChipIndex:Re}=S,we=S.chipsRef.current.length,[ge,De]=Tme(R);return Re!==void 0?(ve.key===ge?(ve.preventDefault(),Re>0?xe=Re-1:xe=void 0):ve.key===De?(ve.preventDefault(),Re0&&(ve.preventDefault(),xe=we>0?we-1:void 0),xe)}const de=wt("input",t,{state:ae,ref:[n,E.context.inputRef,pe],props:[z,G,{value:ee??O,"aria-readonly":M||void 0,"aria-required":T||void 0,"aria-labelledby":w,disabled:ie,readOnly:M,required:L==="none"?T:void 0,form:I,...he&&_&&{name:_},id:J,onFocus(){if(x(!0),!U||!re.current)return;re.current=!1;const ve=te.current;ve==null||!Object.hasOwn(E.context.valuesRef.current,ve)||E.context.setIndices({activeIndex:ve})},onBlur(){g(!0),x(!1);const ve=E.state.activeIndex;if(U&&ve!==null&&D!=="always"&&(te.current=ve,re.current=!0,E.context.setIndices({activeIndex:null})),y==="onBlur"){const xe=L==="none"?O:F;j.commit(xe)}},onCompositionStart(ve){yj||(le.current=!0,se(ve.currentTarget.value))},onCompositionEnd(ve){le.current=!1;const xe=ve.currentTarget.value;se(null),E.context.setInputValue(xe,at(ix,ve.nativeEvent))},onChange(ve){const xe=ve.nativeEvent,Re=xe.inputType,we=!Re||Re==="insertReplacementText",ge=le.current||!we;function De($t){M||ie||!$t||!ge||(E.context.setOpen(!0,at(ix,xe)),W||me())}if(le.current){const $t=ve.currentTarget.value;se($t),$t===""&&!E.state.openOnInputClick&&!E.state.inputInsidePopup&&E.context.setOpen(!1,at(Pl,xe));const Me=$t.trim(),Ht=W&&Me!=="";De(Me),X&&E.state.activeIndex!==null&&!Ht&&me();return}const Ge=at(ix,xe);if(E.context.setInputValue(ve.currentTarget.value,Ge),Ge.isCanceled)return;const Ot=ve.currentTarget.value==="",sn=at(Pl,xe);Ot&&!E.state.inputInsidePopup&&(L==="single"&&E.context.setSelectedValue(null,sn),E.state.openOnInputClick||E.context.setOpen(!1,sn)),De(ve.currentTarget.value.trim()),X&&E.state.activeIndex!==null&&!W&&me()},onKeyDown(ve){if(ve.ctrlKey||ve.shiftKey||ve.altKey||ve.metaKey)return;if(E.context.keyboardActiveRef.current=!0,ie||M){M&&ve.key==="Enter"&&X&&E.state.activeIndex!==null&&_s(ve);return}const xe=ve.currentTarget,Re=xe.scrollWidth-xe.clientWidth,we=R==="rtl";if(ve.key==="Home"){_s(ve);const Ge=Z3&&we?xe.value.length:0;xe.setSelectionRange(Ge,Ge),xe.scrollLeft=0;return}if(ve.key==="End"){_s(ve);const Ge=Z3&&we?0:xe.value.length;xe.setSelectionRange(Ge,Ge),xe.scrollLeft=we?-Re:Re;return}if(!Y&&ve.key==="Escape"){const Ge=L==="multiple"&&Array.isArray(F)?F.length===0:F===null,Ot=at(em,ve.nativeEvent),sn=L==="multiple"?[]:null;E.context.setInputValue("",Ot),E.context.setSelectedValue(sn,Ot),!Ge&&!E.state.inline&&!Ot.isPropagationAllowed&&ve.stopPropagation();return}if(S&&ve.key==="Backspace"&&xe.value===""&&S.highlightedChipIndex===void 0&&Array.isArray(F)&&F.length>0){const Ge=S.chipsRef.current.length,Ot=Ge>0?Ge-1:F.length-1,sn=F.filter(($t,Me)=>Me!==Ot);me(),E.context.setSelectedValue(sn,at(Br,ve.nativeEvent));return}const ge=S?.highlightedChipIndex!==void 0,De=_e(ve);if(S?.setHighlightedChipIndex(De),De!==void 0?S?.chipsRef.current[De]?.focus():ge&&E.context.inputRef.current?.focus(),ve.which!==229&&ve.key==="Enter"&&X){const Ge=E.state.activeIndex,Ot=ve.nativeEvent;if(Ge===null){if(U)return;E.context.setOpen(!1,at(Br,Ot));return}_s(ve),oF(E,Ge,Ot)}},onPointerMove:ce,onPointerDown:ce},Ne],stateAttributesMapping:rF}),Se=A?s.jsx(QA.Provider,{value:K3,children:de}):de;return s.jsxs(v.Fragment,{children:[X&&Q&&s.jsx(aF,{ref:E.context.startDismissRef}),Se]})}),Pme=v.forwardRef(function(t,n){const{render:r,className:i,nativeButton:o=!0,disabled:c=!1,id:d,style:f,...h}=t,{state:p,disabled:g,setTouched:x,setFocused:y,validationMode:j,validation:w}=Oi(),{labelId:S}=ii(),N=Wo(),A=N.useState("selectionMode"),E=N.useState("disabled"),O=N.useState("readOnly"),R=N.useState("required"),T=N.useState("positionerElement"),P=N.useState("listElement"),M=N.useState("popupId"),_=N.useState("triggerProps"),I=N.useState("inputInsidePopup"),L=N.useState("id"),D=N.useState("labelId"),z=N.useState("open"),G=N.useState("selectedValue"),X=N.useState("activeIndex"),Y=N.useState("selectedIndex"),F=N.useState("hasSelectedValue"),K=b0(),U=J4(),q=Ds(),W=g||E||c,ne=y0(),ie=iF(N);Vu({id:I?d:void 0});const V=I?d??L:d,H=D4(S,D);let Q;z&&I?Q=M??eF(L):z&&(Q=P?.id);const J=v.useRef("");function oe(Ne){J.current=Ne.pointerType}const{reference:ee}=D5(K,{enabled:!z&&!O&&!E&&A==="single",listRef:N.context.labelsRef,activeIndex:X,selectedIndex:Y,onMatch(Ne){const me=N.context.valuesRef.current[Ne];me!==void 0&&N.context.setSelectedValue(me,at(Br))}}),{reference:se}=dx(K,{enabled:!E,event:"mousedown"}),{buttonRef:le,getButtonProps:te}=ai({native:o,disabled:W}),re={...p,readOnly:O,open:z,disabled:W,popupSide:ie,listEmpty:ne,placeholder:A==="none"?!1:!F},he=Fe(Ne=>{N.set("triggerElement",Ne)});return wt("button",t,{ref:[n,le,he],state:re,props:[_,se,ee,{id:V,tabIndex:I?0:-1,role:I?"combobox":void 0,"aria-expanded":z,"aria-haspopup":I?"dialog":"listbox","aria-controls":Q,"aria-required":I&&R||void 0,"aria-readonly":I&&O||void 0,"aria-labelledby":H,onPointerDown:oe,onPointerEnter:oe,onFocus(){y(!0),!W&&q.start(0,N.context.forceMount)},onBlur(Ne){if(!nt(T,Ne.relatedTarget)&&(x(!0),y(!1),j==="onBlur")){const me=A==="none"?U:G;w.commit(me)}},onMouseDown(Ne){if(W||(I||K.set("domReferenceElement",Ne.currentTarget),N.context.forceMount(),J.current!=="touch"&&(N.context.inputRef.current?.focus(),I||Ne.preventDefault()),z))return;const me=vn(Ne.currentTarget);function ce(ae){const _e=N.state.triggerElement;if(!_e)return;const de=or(ae),Se=N.state.positionerElement,ve=N.state.listElement;nt(_e,de)||nt(Se,de)||nt(ve,de)||L4(ae,_e)||N.context.setOpen(!1,at(jB,ae))}I&&me.addEventListener("mouseup",ce,{once:!0})},onKeyDown(Ne){(Ne.key==="ArrowDown"||Ne.key==="ArrowUp")&&(_s(Ne),N.context.setOpen(!0,at(kE,Ne.nativeEvent)),N.context.inputRef.current?.focus())}},w.getValidationProps(W,h),te],stateAttributesMapping:rF})}),Ime=v.createContext(null);function Mme(){return v.useContext(Ime)}function _me(e){const{children:t}=e,{filteredItems:n}=jx(),r=Mme(),i=r?r.items:n;return s.jsx(v.Fragment,{children:i.map(t)})}const Dme=v.forwardRef(function(t,n){var r;const{render:i,className:o,style:c,children:d,...f}=t,h=Wo(),p=b0(),g=!!TT(!0),{filteredItems:x,hasItems:y}=jx(),j=h.useState("selectionMode"),w=h.useState("grid"),S=h.useState("readOnly"),N=h.useState("listProps"),A=h.useState("virtualized"),E=h.useState("forceMounted"),O=j==="multiple",R=x.length===0,T=Fe(z=>{h.set("positionerElement",z)}),P=Fe(z=>{h.set("listElement",z)}),M=v.useMemo(()=>typeof d=="function"?r||(r=s.jsx(_me,{children:d})):d,[d]),_={empty:R},I=p.useState("floatingId"),L=wt("div",t,{state:_,ref:[n,P,g?null:T],props:[N,{children:M,tabIndex:-1,id:I,role:w?"grid":"listbox","aria-multiselectable":O?"true":void 0,"aria-readonly":!w&&S?!0:void 0,onKeyDown(z){if(!(h.state.disabled||h.state.readOnly)&&z.key==="Enter"){const G=h.state.activeIndex;if(G==null)return;_s(z),oF(h,G,z.nativeEvent)}},onKeyDownCapture(){h.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){h.context.keyboardActiveRef.current=!1}},f]});if(A)return L;const D=y&&!E?void 0:h.context.labelsRef;return s.jsx(ST,{elementsRef:h.context.listRef,labelsRef:D,children:L})}),Lme="",zme=200;function $me(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const r=t.currentNode;r.nodeValue!==""&&(n=r)}return n}function Bme(){const e=Ds(),t=v.useRef(null);return v.useEffect(()=>{if(tx)return;const n=t.current;if(n==null)return;const r=$me(n);if(r==null)return;const i=r.data,o=`${i}${Lme}`;return r.nodeValue=o,e.start(zme,()=>{r.nodeValue===o&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===o&&(r.nodeValue=i)}},[t,e]),t}const lF=v.createContext(void 0);function Fme(){const e=v.useContext(lF);if(e===void 0)throw new Error(En(20));return e}const Ume=v.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t,o=Wo(),c=o.useState("mounted"),d=o.useState("forceMounted");return c||r||d?s.jsx(lF.Provider,{value:r,children:s.jsx(Vj,{ref:n,...i})}):null}),Hme=v.forwardRef(function(t,n){const{render:r,className:i,anchor:o,positionMethod:c,side:d,align:f,sideOffset:h,alignOffset:p,collisionBoundary:g="clipping-ancestors",collisionPadding:x,arrowPadding:y,sticky:j,disableAnchorTracking:w=!1,collisionAvoidance:S=KB,style:N,...A}=t,E=Wo(),O=b0(),R=Fme(),T=E.useState("modal"),P=E.useState("open"),M=E.useState("mounted"),_=E.useState("openMethod"),I=E.useState("positionerElement"),L=E.useState("triggerElement"),D=E.useState("inputElement"),z=E.useState("inputGroupElement"),G=E.useState("inputInsidePopup"),X=E.useState("transitionStatus"),Y=y0(),K=r0({anchor:o??(G?L:z??D),floatingRootContext:O,positionMethod:c,mounted:M,side:d,sideOffset:h,align:f,alignOffset:p,arrowPadding:y,collisionBoundary:g,collisionPadding:x,sticky:j,disableAnchorTracking:w,keepMounted:R,collisionAvoidance:S,lazyFlip:!0});CT(P&&T,_==="touch",I,L);const U={open:P,side:K.side,align:K.align,anchorHidden:K.anchorHidden,empty:Y};Ue(()=>{E.set("popupSide",K.side)},[E,K.side]);const q=Fe(ne=>{E.set("positionerElement",ne)}),W=s0(t,U,{styles:K.positionerStyles,transitionStatus:X,props:A,refs:[n,q],hidden:!M,inert:!P});return s.jsxs(sF.Provider,{value:K,children:[M&&T&&s.jsx(l0,{inert:vx(!P),cutout:z??D??L}),W]})}),Vme={...Wp,...io},Kme=v.forwardRef(function(t,n){const{render:r,className:i,style:o,initialFocus:c,finalFocus:d,...f}=t,h=Wo(),p=TT(),g=b0(),x=h.useState("mounted"),y=h.useState("open"),j=h.useState("openMethod"),w=h.useState("popupProps"),S=h.useState("transitionStatus"),N=h.useState("inputInsidePopup"),A=h.useState("inputElement"),E=h.useState("modal"),O=h.useState("id"),R=y0(),T=f.id??(N?eF(O):void 0);Ue(()=>(h.set("popupId",h.context.popupRef.current?.id||T),()=>{h.set("popupId",void 0)}),[h,T]),Va({open:y,ref:h.context.popupRef,onComplete(){y&&h.context.onOpenChangeComplete(!0)}});const P={open:y,side:p.side,align:p.align,anchorHidden:p.anchorHidden,transitionStatus:S,empty:R},M=wt("div",t,{state:P,ref:[n,h.context.popupRef],props:[w,{id:T,role:N?"dialog":"presentation",onFocus(z){const G=or(z.nativeEvent);j!=="touch"&&(nt(h.state.listElement,G)||G===z.currentTarget)&&h.context.inputRef.current?.focus()}},gx(S),f],stateAttributesMapping:Vme}),I=c===void 0?N?z=>z==="touch"?h.context.popupRef.current:A:!1:c;let L;d!=null?L=d:L=N?void 0:!1;const D=!N||E;return s.jsx(Kj,{context:g,disabled:!x,modal:D,openInteractionType:j,initialFocus:I,returnFocus:L,getInsideElements:()=>[h.context.startDismissRef.current,h.context.endDismissRef.current],children:s.jsxs(v.Fragment,{children:[M,D&&s.jsx(aF,{ref:h.context.endDismissRef})]})})}),qme=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t;return wt("span",t,{ref:n,props:[{"aria-hidden":!0,children:"▼"},c]})}),cF=v.createContext(void 0);function uF(){const e=v.useContext(cF);if(!e)throw new Error(En(19));return e}const Gme=v.createContext(!1);function Yme(){return v.useContext(Gme)}function dF(e){const{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:o,className:c,style:d,value:f=null,index:h,disabled:p=!1,nativeButton:g=!1,...x}=t,y=v.useRef(null),j=jT({guess:!0,index:h,textRef:y}),w=Wo(),S=Yme(),N=gme(),A=w.useState("selectionMode"),E=w.useState("disabled"),O=w.useState("readOnly"),R=w.useState("isItemEqualToValue"),T=E||p,P=A!=="none",M=h??i??j.index,_=M!==-1,I=w.useState("id"),L=w.useState("isActive",M),D=w.useState("isSelected",f),z=w.useState("itemProps"),G=v.useRef(null),X=I!=null&&_?`${I}-${M}`:void 0,Y=D&&P;Ue(()=>{if(!(_&&(r||h!=null)))return;const H=w.context.listRef.current;return H[M]=G.current,()=>{delete H[M]}},[_,r,M,h,w]),Ue(()=>{if(!_||N)return;const V=w.context.valuesRef.current;return V[M]=f,()=>{delete V[M]}},[_,N,M,f,w]),Ue(()=>{if(!_||N)return;const V=w.state.selectedValue;let H=w.state.selectedIndex;w.state.selectionMode==="multiple"&&Array.isArray(V)?H=R4(M,f,w.context.valuesRef.current,V,R,H):po(f,V,R)&&(H=M),w.set("selectedIndex",H)},[_,N,w,M,f,R]);const{getButtonProps:F,buttonRef:K}=ai({disabled:T,focusableWhenDisabled:!0,native:g,composite:!0}),U={disabled:T,selected:Y,highlighted:L};function q(V){function H(){w.context.handleSelection(V,f)}w.state.submitOnItemClick?(br.flushSync(H),w.context.requestSubmit()):H()}const W={id:X,role:S?"gridcell":"option","aria-selected":P?Y:void 0,tabIndex:void 0,onPointerDownCapture(V){V.isPrimary&&(w.context.pointerDownItemRef.current=V.currentTarget),V.preventDefault()},onMouseDown(V){V.preventDefault()},onClick(V){T||O||q(V.nativeEvent)},onMouseUp(V){const H=w.context.pointerDownItemRef.current===V.currentTarget;w.context.pointerDownItemRef.current=null,!(T||O||V.button!==0||H||!L)&&q(V.nativeEvent)}},ne=wt("div",t,{ref:[K,n,j.ref,G],state:U,props:[z,W,x,F]}),ie=v.useMemo(()=>({selected:Y,textRef:y}),[Y,y]);return s.jsx(cF.Provider,{value:ie,children:ne})}function Wme(e){const{componentProps:t,forwardedRef:n}=e,i=Wo().useState("isItemEqualToValue"),{flatFilteredValues:o}=jx(),c=t.value??null,d=am(o,c,i);return s.jsx(dF,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:d})}const Xme=v.memo(v.forwardRef(function(t,n){const i=Wo().useState("virtualized");return i&&t.index==null?s.jsx(Wme,{componentProps:t,forwardedRef:n}):s.jsx(dF,{componentProps:t,forwardedRef:n,virtualized:i,indexFromFilter:void 0})})),Qme=v.forwardRef(function(t,n){const{selected:r}=uF();return t.keepMounted||r?s.jsx(Zme,{...t,ref:n}):null}),Zme=v.memo(v.forwardRef((e,t)=>{const{render:n,className:r,style:i,keepMounted:o,...c}=e,{selected:d}=uF(),f=v.useRef(null),{transitionStatus:h,setMounted:p}=Ic(d),x=wt("span",e,{ref:[t,f],state:{selected:d,transitionStatus:h},props:[{"aria-hidden":!0,children:"✔️"},c],stateAttributesMapping:io});return Va({batch:!0,enabled:!d,open:d,ref:f,onComplete(){d||p(!1)}}),x})),Jme=v.forwardRef(function(t,n){const{render:r,className:i,style:o,children:c,...d}=t,{filteredItems:f}=jx(),h=Wo(),p=Bme(),g=f.length===0?c:null;return wt("div",t,{ref:[n,h.context.emptyRef,p],props:[{children:g,role:"status","aria-live":"polite","aria-atomic":!0},d]})}),ege="、";function Ff({value:e,onValueChange:t,options:n,placeholder:r="",emptyHint:i=ue("没有匹配的选项"),searchPlaceholder:o=ue("搜索…"),disabled:c=!1,className:d,id:f,title:h,...p}){const g=v.useMemo(()=>n.filter(y=>e.includes(y.value)),[n,e]),x=g.length?g.map(y=>y.label).join(ege):r;return s.jsxs(kme,{items:n,multiple:!0,value:g,onValueChange:y=>t(y.map(j=>j.value)),isItemEqualToValue:(y,j)=>y?.value===j?.value,disabled:c,children:[s.jsxs(Pme,{"data-slot":"multi-select-trigger",id:f,title:h,"aria-label":p["aria-label"],className:Te("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] font-normal text-foreground","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",d),children:[s.jsx("span",{"data-slot":"multi-select-value",className:"min-w-0 flex-1 truncate text-left data-[placeholder]:text-muted-foreground","data-placeholder":g.length?void 0:"",title:x,children:x}),s.jsx(qme,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:s.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:s.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),s.jsx(Ume,{children:s.jsx(Hme,{sideOffset:4,className:"z-[35]",children:s.jsxs(Kme,{"data-slot":"multi-select-content",className:Te("flex max-h-[280px] w-[max(var(--anchor-width),220px)] flex-col overflow-hidden","rounded-lg border border-border-strong bg-raised shadow-3 outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0"),children:[s.jsxs("div",{className:"flex flex-none items-center gap-1.5 border-b border-hairline px-2.5 py-1.5",children:[s.jsxs("svg",{viewBox:"0 0 12 12",className:"size-3 flex-none text-muted-foreground","aria-hidden":"true",children:[s.jsx("circle",{cx:"5",cy:"5",r:"3.4",stroke:"currentColor",strokeWidth:"1.3",fill:"none"}),s.jsx("path",{d:"M7.6 7.6 10.5 10.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),s.jsx(Rme,{placeholder:o,className:"min-w-0 flex-1 border-0 bg-transparent p-0 text-[12.5px] text-foreground outline-none placeholder:text-muted-foreground"})]}),s.jsx(Jme,{children:s.jsx("div",{className:"px-2.5 py-3 text-[11.5px] leading-[1.5] text-muted-foreground",children:i})}),s.jsx(Dme,{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-[5px]",children:y=>s.jsxs(Xme,{value:y,disabled:y.disabled===!0,className:Te("grid cursor-pointer grid-cols-[14px_minmax(0,1fr)] items-center gap-2 rounded-sm px-[9px] py-[5px]","text-[12.5px] leading-[1.4] text-foreground select-none outline-none","transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:text-muted-foreground"),children:[s.jsx(Qme,{className:"col-start-1 flex text-primary",children:s.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:s.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}),s.jsx("span",{className:"col-start-2 min-w-0 truncate",children:y.label})]},y.value)})]})})})]})}const fF=v.createContext(void 0);function Uf(e){const t=v.useContext(fF);if(t===void 0&&!e)throw new Error(En(47));return t}const tge={...nT,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class nge extends $f{constructor(n,r,i){const o=new Wj;super(rge(n,o,r,i),sge(o),tge);on(this,"setOpen",(n,r)=>{const i=r.reason===ma,o=r.reason===Mc&&r.event.detail===0,c=!n&&(r.reason===em||r.reason==null),d=C5(r),f=this.select("activeTriggerId");if(!n&&r.reason===SE&&r.trigger==null&&f!=null&&(r.trigger=this.context.triggerElements.getById(f)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,r),r.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,r);const h=()=>{const g=WE(this.state,n,r.trigger,d());g.openChangeReason=r.reason,this.update(g)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(Pde,()=>{this.set("stickIfOpen",!1)}),br.flushSync(h)):h();let p;o?p="click":c?p="dismiss":r.reason===Xu&&(p="focus"),this.set("instantType",p)})}}function rge(e,t,n,r=!1){const i={...eT(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function sge(e){return{popupRef:v.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:v.createRef(),beforeContentFocusGuardRef:v.createRef(),stickIfOpenTimeout:new oi,triggerElements:e}}const hF=Fj(function({props:t}){const{children:n,open:r,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:c,modal:d=!1,handle:f,triggerId:h,defaultTriggerId:p=null}=t,g=ige(f,{modal:d,open:i,openProp:r,activeTriggerId:p,triggerIdProp:h});g.useControlledProp("openProp",r),g.useControlledProp("triggerIdProp",h);const x=g.useState("open"),y=g.useState("mounted"),j=g.useState("payload");g.useContextCallback("onOpenChange",o),g.useContextCallback("onOpenChangeComplete",c),A5(g,x),QE(g);const{forceUnmount:w}=ZE(x,g,()=>{g.update({stickIfOpen:!0,openChangeReason:null})});g.useSyncedValues({modal:d}),v.useEffect(()=>{x||g.context.stickIfOpenTimeout.clear()},[g,x]),v.useImperativeHandle(t.actionsRef,()=>({unmount:w,close:()=>g.setOpen(!1,at(NE))}),[w,g]);const S=x||y;return s.jsxs(fF.Provider,{value:g,children:[f&&s.jsx(YE,{handle:f,store:g}),S&&s.jsx(oge,{store:g,modal:d}),typeof n=="function"?n({payload:j}):n]})});function age(e){return Uf(!0)?s.jsx(hF,{props:e}):s.jsx(Hde,{children:s.jsx(hF,{props:e})})}function ige(e,t){const n=GE((r,i)=>new nge(t,r,i));return v.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function oge({store:e,modal:t}){const n=e.useState("floatingRootContext"),r=fx(n,{outsidePressEvent:{mouse:t==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),i=r.reference,o=r.floating;return JE(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:o}),null}const lge=300;function cge(e,t){const n=v.useRef(null);function r(o){br.flushSync(()=>{e.setOpen(!1,at(Xu,o.nativeEvent,o.currentTarget))}),wue(n.current)?.focus()}function i(o){const c=e.select("positionerElement");if(c&&Qp(o,c))e.context.beforeContentFocusGuardRef.current?.focus();else{br.flushSync(()=>{e.setOpen(!1,at(Xu,o.nativeEvent,o.currentTarget))});let d=yue(e.context.triggerFocusTargetRef.current||t.current);for(;d!==null&&nt(c,d);){const f=d;if(d=xE(d),d===f)break}d?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}const uge=PE(function(t,n){const{render:r,className:i,style:o,disabled:c=!1,nativeButton:d=!0,handle:f,payload:h,openOnHover:p=!1,delay:g=lge,closeDelay:x=0,id:y,...j}=t,w=Uf(!0),N=rT(f)??w;if(!N)throw new Error(En(74));const A=bs(y),E=N.useState("isTriggerActive",A),O=N.useState("floatingRootContext"),R=N.useState("isOpenedByTrigger",A),T=N.useState("triggerPopupId",A),P=v.useRef(null),{registerTrigger:M,isMountedByThisTrigger:_}=XE(A,P,N,{payload:h,disabled:c,openOnHover:p,closeDelay:x}),I=N.useState("openChangeReason"),L=N.useState("stickIfOpen"),D=N.useState("openMethod"),z=N.useState("focusManagerModal"),G=I5(O,{enabled:!c&&p&&(D!=="touch"||I!==Mc),mouseOnly:!0,move:!1,handleClose:z5(),restMs:g,delay:{close:x},triggerElementRef:P,isActiveTrigger:E,isClosing:()=>N.select("transitionStatus")==="ending"}),X=dx(O,{stickIfOpen:L}),Y=xT(()=>N.select("open"),J=>{N.set("openMethod",J)}),F=N.useState("triggerProps",_),{getButtonProps:K,buttonRef:U}=ai({disabled:c,native:d}),q={open(J){return J&&I===Mc?sE.open(J):jj.open(J)}},{preFocusGuardRef:W,handlePreFocusGuardFocus:ne,handleFocusTargetFocus:ie}=cge(N,P),H=wt("button",t,{state:{disabled:c,open:R},ref:[U,n,M,P],props:[X.reference,G,F,Y,{[DE]:"",id:A,"aria-haspopup":"dialog","aria-expanded":R,"aria-controls":T},j,K],stateAttributesMapping:q}),Q=s.jsx(v.Fragment,{children:H},A);return _&&!z?s.jsxs(v.Fragment,{children:[s.jsx(Df,{ref:W,onFocus:ne}),Q,s.jsx(Df,{ref:N.context.triggerFocusTargetRef,onFocus:ie})]}):Q}),pF=v.createContext(void 0);function dge(){const e=v.useContext(pF);if(e===void 0)throw new Error(En(45));return e}const fge=v.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t;return Uf().useState("mounted")||r?s.jsx(pF.Provider,{value:r,children:s.jsx(Vj,{ref:n,...i})}):null}),mF=v.createContext(void 0);function hge(){const e=v.useContext(mF);if(!e)throw new Error(En(46));return e}const pge=v.forwardRef(function(t,n){const{render:r,className:i,style:o,anchor:c,positionMethod:d,side:f,align:h,sideOffset:p,alignOffset:g,collisionBoundary:x="clipping-ancestors",collisionPadding:y,arrowPadding:j,sticky:w,disableAnchorTracking:S=!1,collisionAvoidance:N=qB,...A}=t,E=Uf(),O=dge(),R=Fde(),T=E.useState("floatingRootContext"),P=E.useState("mounted"),M=E.useState("open"),_=E.useState("openChangeReason"),I=E.useState("activeTriggerElement"),L=E.useState("modal"),D=E.useState("openMethod"),z=E.useState("positionerElement"),G=E.useState("instantType"),X=E.useState("transitionStatus"),Y=E.useState("adaptiveOrigin"),F=v.useRef(null),K=jE(z),U=r0({anchor:c,floatingRootContext:T,positionMethod:d,mounted:P,side:f,sideOffset:p,align:h,alignOffset:g,arrowPadding:j,collisionBoundary:x,collisionPadding:y,sticky:w,disableAnchorTracking:S,keepMounted:O,nodeId:R,collisionAvoidance:N,adaptiveOrigin:Y}),q=T.useState("domReferenceElement");Ue(()=>{const H=q,Q=F.current;if(H&&(F.current=H),Q&&H&&H!==Q){E.set("instantType",void 0);const J=new AbortController;return K(()=>{E.set("instantType","trigger-change")},J.signal),()=>{J.abort()}}},[q,K,E]);const W=L===!0&&_!==ma;CT(M&&W,D==="touch",z,I);const ne=E.useStateSetter("positionerElement"),ie={open:M,side:U.side,align:U.align,anchorHidden:U.anchorHidden,instant:G},V=s0(t,ie,{styles:U.positionerStyles,transitionStatus:X,props:A,refs:[n,ne],hidden:!P,inert:!M});return s.jsxs(mF.Provider,{value:U,children:[P&&W&&s.jsx(l0,{inert:vx(!M),cutout:I}),s.jsx(Ude,{id:R,children:V})]})}),mge=v.createContext(void 0);function gge(){const[e,t]=v.useState(0),n=Fe(()=>(t(i=>i+1),()=>{t(i=>Math.max(0,i-1))}));return{context:v.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}const vge=v.forwardRef(function(t,n){const{render:r,className:i,style:o,initialFocus:c,finalFocus:d,...f}=t,h=Uf(),p=hge(),g=B4()!=null,{context:x,hasClosePart:y}=gge(),j=h.useState("open"),w=h.useState("openMethod"),S=h.useState("instantType"),N=h.useState("transitionStatus"),A=h.useState("popupProps"),E=h.useState("titleElementId"),O=h.useState("descriptionElementId"),R=h.useState("modal"),T=h.useState("mounted"),P=h.useState("openChangeReason"),M=h.useState("activeTriggerElement"),_=h.useState("floatingRootContext"),I=_.useState("floatingId"),L=h.useState("disabled"),D=h.useState("openOnHover"),z=h.useState("closeDelay");Va({open:j,ref:h.context.popupRef,onComplete(){j&&h.context.onOpenChangeComplete?.(!0)}}),P5(_,{enabled:D&&!L,closeDelay:z});const G=c===void 0?k5(h.context.popupRef):c,X=R!==!1&&y;h.useSyncedValue("focusManagerModal",X);const Y=h.useStateSetter("popupElement"),F={open:j,side:p.side,align:p.align,instant:S,transitionStatus:N},K=wt("div",t,{state:F,ref:[n,h.context.popupRef,Y],props:[A,{id:I,role:"dialog",...hx,"aria-labelledby":E,"aria-describedby":O,onKeyDown(U){g&&i0.has(U.key)&&U.stopPropagation()}},gx(N),f],stateAttributesMapping:aE});return s.jsx(Kj,{context:_,openInteractionType:w,modal:X,disabled:!T||P===ma,initialFocus:G,returnFocus:d,restoreFocus:"popup",previousFocusableElement:nr(M)?M:void 0,nextFocusableElement:h.context.triggerFocusTargetRef,beforeContentFocusGuardRef:h.context.beforeContentFocusGuardRef,children:s.jsx(mge.Provider,{value:x,children:K})})}),xge=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,d=Uf(),f=bs(c.id);return d.useSyncedValueWithCleanup("titleElementId",f),wt("h2",t,{ref:n,props:[{id:f},c]})}),bge=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,d=Uf(),f=bs(c.id);return d.useSyncedValueWithCleanup("descriptionElementId",f),wt("p",t,{ref:n,props:[{id:f},c]})});function _l(e){return s.jsx(age,{"data-slot":"popover",...e})}function $c(e){return s.jsx(uge,{"data-slot":"popover-trigger",...e})}function Dl({className:e,sideOffset:t=6,align:n="start",side:r,alignOffset:i,collisionPadding:o=8,anchor:c,children:d,...f}){return s.jsx(fge,{children:s.jsx(pge,{className:"z-[35] outline-none",sideOffset:t,align:n,side:r,alignOffset:i,collisionPadding:o,anchor:c,children:s.jsx(vge,{"data-slot":"popover-content",className:Te("flex max-h-[min(70vh,560px)] flex-col overflow-hidden rounded-lg border border-border-strong bg-raised text-foreground shadow-3","outline-none","data-open:animate-in data-open:fade-in-0 data-open:slide-in-from-top-1","data-closed:animate-out data-closed:fade-out-0",e),...f,children:d})})})}function yge({className:e,...t}){return s.jsx("div",{"data-slot":"popover-header",className:Te("flex items-center gap-2 border-b border-hairline px-3 py-2",e),...t})}function wge({className:e,...t}){return s.jsx(xge,{"data-slot":"popover-title",className:Te("text-[12.5px] font-semibold text-foreground",e),...t})}function jge({className:e,...t}){return s.jsx(bge,{"data-slot":"popover-description",className:Te("text-[11.5px] leading-[1.55] text-muted-foreground",e),...t})}function Sge({page:e,pageCount:t,onPageChange:n,disabled:r=!1,className:i,infoFirst:o=!1}){const c=Math.max(1,Number(t)||1),d=Math.min(Math.max(1,Number(e)||1),c),f=s.jsx("span",{"data-slot":"pager-info",className:"text-[11.5px] text-subtle [font-variant-numeric:tabular-nums]",children:ue("第 {current} / {total} 页",{current:d,total:c})});return s.jsxs("div",{"data-slot":"pager",className:Te("flex items-center gap-2",i),children:[o&&f,s.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:r||d<=1,onClick:()=>n(d-1),children:ue("上一页")}),s.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:r||d>=c,onClick:()=>n(d+1),children:ue("下一页")}),!o&&f]})}const gF=v.createContext(!1);function Bc({className:e,render:t,children:n,...r}){const{containerRef:i,indicator:o}=G4('[data-slot="nav-item"]','[data-slot="nav-item"][data-active]'),c=ox({defaultTagName:"div",render:t,ref:i,props:{...r,"data-slot":"nav-list",className:Te("relative isolate flex min-h-0 flex-col gap-0.5",e),children:s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-slot":"nav-list-indicator","aria-hidden":"true",...o}),n]})}});return s.jsx(gF.Provider,{value:!0,children:c})}const kge=Tf(["relative flex h-auto w-full items-center justify-start gap-2.5 whitespace-normal text-left active:translate-y-0","border border-transparent rounded-sm","shadow-none","transition-[background-color,border-color,color] duration-150 ease-out","outline-none focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:["cursor-pointer px-2.5 py-2","text-[12.5px] font-medium text-sidebar-fg","hover:bg-nav-hover hover:text-foreground","data-[active]:border-nav-selected-border data-[active]:bg-nav-selected-bg data-[active]:font-semibold data-[active]:text-nav-selected-fg"],add:["cursor-pointer justify-center px-2 py-1.5","border-dashed border-border-strong bg-transparent","text-[11.5px] text-muted-foreground","hover:border-primary hover:text-primary-fg"]}},defaultVariants:{variant:"default"}});function Ri({className:e,variant:t,active:n=!1,count:r,icon:i,trailing:o,children:c,...d}){const f=v.useContext(gF);return s.jsxs(B,{type:"button",variant:"ghost","data-slot":"nav-item","data-active":n?"":void 0,"data-sliding":f?"":void 0,"aria-current":n?"true":void 0,className:Te(kge({variant:t}),f&&"data-[active]:border-transparent data-[active]:bg-transparent data-[active]:hover:bg-transparent",e),...d,children:[i,s.jsx("span",{"data-slot":"nav-item-label",className:"min-w-0 flex-1 truncate",children:c}),o,r!=null&&s.jsx("span",{"data-slot":"nav-item-count",className:Te("flex-none text-[10.5px] text-sidebar-muted [font-variant-numeric:tabular-nums]",n&&"text-inherit"),children:r})]})}function OT(e){return s.jsx(c4,{"data-slot":"sheet",...e})}function Nge(e){return s.jsx(xx,{"data-slot":"sheet-close",...e})}function Cge(e){return s.jsx(gT,{"data-slot":"sheet-portal",...e})}const vF=e=>s.jsx(vT,{"data-slot":"sheet-title",...e});function Age({className:e,...t}){return s.jsx(lT,{"data-slot":"sheet-overlay",className:Te("fixed inset-0 isolate z-30 bg-mask backdrop-blur-[3px]","transition-opacity duration-200","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function RT({className:e,children:t,showCloseButton:n=!0,showHandle:r=!0,side:i="bottom",keepMounted:o=!1,...c}){const d=i==="center",f=i==="right",h=i==="left";return s.jsxs(Cge,{keepMounted:o,children:[s.jsx(Age,{}),s.jsxs(mT,{"data-slot":"sheet-content",className:Te("fixed z-30 flex flex-col overflow-hidden border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.32,.9,.3,1)]",d?["top-1/2 left-1/2 max-h-[calc(100vh-48px)] w-[min(560px,calc(100vw-48px))]","-translate-x-1/2 -translate-y-1/2 rounded-lg","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985]","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards"]:f?["top-0 right-0 bottom-0 h-full w-[min(340px,86vw)] rounded-l-xl","data-open:animate-in data-open:slide-in-from-right data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-right data-closed:fade-out-0 data-closed:fill-mode-forwards"]:h?["top-0 left-0 bottom-0 h-full w-[min(340px,86vw)] rounded-r-xl","data-open:animate-in data-open:slide-in-from-left data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-left data-closed:fade-out-0 data-closed:fill-mode-forwards"]:["inset-x-0 bottom-0 max-h-[85svh] rounded-t-xl","data-open:animate-in data-open:slide-in-from-bottom data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-bottom data-closed:fade-out-0 data-closed:fill-mode-forwards"],e),...c,children:[r&&!d&&!f&&!h&&s.jsx("div",{"aria-hidden":"true",className:"mx-auto mt-2 mb-1 h-1 w-9.5 shrink-0 rounded-pill bg-border-strong"}),t,n&&s.jsxs(xx,{"data-slot":"sheet-close",render:s.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[s.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:s.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),s.jsx("span",{className:"sr-only",children:ue("关闭")})]})]})]})}function xF({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-header",className:Te("flex shrink-0 items-center gap-2.5 border-b border-hairline px-5 py-3 pr-10","[&_h2]:flex-1 [&_h2]:text-[15px] [&_h2]:font-semibold",e),...t})}function bF({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-body",className:Te("flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto px-5 py-4",e),...t})}function Ege({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-footer",className:Te("flex shrink-0 items-center gap-2 border-t border-hairline bg-surface-2 px-5 py-3 pb-[max(12px,env(safe-area-inset-bottom))]",e),...t})}function yF(e){const t=v.useMemo(()=>typeof window>"u"?null:window.matchMedia(e),[e]);return v.useSyncExternalStore(v.useCallback(n=>(t?.addEventListener("change",n),()=>t?.removeEventListener("change",n)),[t]),()=>t?.matches??!1,()=>!1)}function w0({open:e,onOpenChange:t,title:n,actions:r,children:i,breakpoint:o=767,side:c="right",inlineClassName:d,inlineAs:f="div",contentClassName:h,bodyClassName:p}){const g=yF(`(max-width: ${o}px)`);return v.useEffect(()=>{!g&&e&&t(!1)},[g,e,t]),v.useEffect(()=>{const x=()=>t(!1);return window.addEventListener("wb:navigation-close",x),()=>window.removeEventListener("wb:navigation-close",x)},[t]),g?s.jsx(OT,{open:e,onOpenChange:t,children:s.jsxs(RT,{side:c,keepMounted:!0,showHandle:!1,className:h,children:[s.jsxs(xF,{children:[s.jsx(vF,{children:n}),r]}),s.jsx(bF,{className:Te("gap-4 [&>*]:w-full [&>*]:min-w-0 [&>*]:max-w-none",p),children:i})]})}):s.jsx(f,{"data-slot":"responsive-sheet-inline",className:d,children:i})}function Tge(e){const{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[o,c]=qo({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:d,setMounted:f,transitionStatus:h}=Ic(o,!0,!0),p=bs(),[g,x]=v.useState(),y=g===null?void 0:g??p,j=Fe(w=>{const S=!o,N=at(Mc,w.nativeEvent);r(S,N),!N.isCanceled&&c(S)});return v.useMemo(()=>({defaultPanelId:p,disabled:i,handleTrigger:j,mounted:d,open:o,panelId:y,setMounted:f,setOpen:c,setPanelIdState:x,transitionStatus:h}),[p,i,j,d,o,y,f,c,x,h])}const wF=v.createContext(void 0);function jF(){const e=v.useContext(wF);if(e===void 0)throw new Error(En(15));return e}const Oge="data-open",Rge="data-closed",Pge=rE,Ige="data-panel-open",Mge={[Oge]:""},_ge={[Rge]:""},Dge={open(e){return e?{[Ige]:""}:null}},SF={...{open(e){return e?Mge:_ge}},...io},Lge=v.forwardRef(function(t,n){const{render:r,className:i,defaultOpen:o=!1,disabled:c=!1,onOpenChange:d,open:f,style:h,...p}=t,g=Fe(d),x=Tge({open:f,defaultOpen:o,onOpenChange:g,disabled:c}),y=v.useMemo(()=>({open:x.open,disabled:x.disabled,transitionStatus:x.transitionStatus}),[x.open,x.disabled,x.transitionStatus]),j=v.useMemo(()=>({...x,onOpenChange:g,state:y}),[x,g,y]),w=wt("div",t,{state:y,ref:n,props:p,stateAttributesMapping:SF});return s.jsx(wF.Provider,{value:j,children:w})}),zge={...Dge,...io},$ge=v.forwardRef(function(t,n){const{panelId:r,open:i,handleTrigger:o,state:c,disabled:d}=jF(),{className:f,disabled:h=d,render:p,nativeButton:g=!0,style:x,...y}=t,{getButtonProps:j,buttonRef:w}=ai({disabled:h,focusableWhenDisabled:!0,native:g});return wt("button",t,{state:c,ref:[n,w],props:[{"aria-controls":i?r:void 0,"aria-expanded":i,onClick:o},y,j],stateAttributesMapping:zge})}),Sx={height:void 0,width:void 0};function Bge(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:o,onOpenChange:c,open:d,setMounted:f,setOpen:h,transitionStatus:p}=e,g=v.useRef(null),x=v.useRef(null),[y,j]=v.useState(Sx),w=v.useRef(Sx),S=v.useRef(!1),N=v.useRef(d),A=v.useRef(!1),[E,O]=v.useState(!1),R=v.useRef(null),T=Ei(t,g),P=Fr(d),M=jE(g),_=!d&&!o,I=E?"idle":p,L=d&&(N.current||A.current),D=!d&&o&&x.current==="css-animation"&&y.height===void 0&&y.width===void 0?w.current:y,z=n&&_&&x.current!=="css-animation",G=Fe((U,q=!0)=>{q&&(w.current=U),j(U)}),X=Fe(()=>{R.current?.(),R.current=null}),Y=Fe(U=>{X(),R.current=()=>{R.current=null,U()}}),F=Fe(()=>{d&&o&&x.current==="css-animation"&&(A.current=!0)});Ue(()=>{!E||p==="starting"||O(!1)},[E,p]),v.useEffect(()=>()=>{F(),X()},[F,X]),Ue(()=>{const U=g.current;if(!U)return;!d&&R.current&&X();const q=Fge(U,L);if(x.current=q,d&&p==="idle"&&N.current&&q==="css-animation"){w.current=im(U);return}if(d&&p==="starting"){const ie=S.current;if(S.current=!1,q==="none"){G(im(U)),O(!0);return}if(q==="css-transition"){const Q=Uge(U);if(G(im(U)),!ie)return Q;const J=j0(U,"transition-duration","0s");return Y(J),O(!0),Q}G(im(U));const V=j0(U,"animation-name","none");if(!ie){V();return}const H=j0(U,"animation-duration","0s");V(),Y(H),O(!0);return}if(!d&&o&&(p==="idle"||p==="starting")){if(N.current=!1,A.current=!1,q==="none"){G(Sx,!1),f(!1);return}G(im(U));return}if(p!=="ending")return;if(q==="none"){f(!1);return}const W=im(U);if(!(W.height>0||W.width>0)){f(!1);return}G(W),q==="css-animation"&&j0(U,"animation-name","none")()},[o,d,X,G,f,Y,L,p]),Va({enabled:d&&o&&I==="idle",open:!0,ref:g,onComplete(){d&&G(Sx,!1)}}),v.useEffect(()=>{if(d||!o||I!=="ending"||!g.current)return;const q=new AbortController;let W=-1;function ne(){P.current||(f(!1),G(Sx,!1))}return W=li.request(()=>{M(ne,q.signal)}),()=>{li.cancel(W),q.abort()}},[P,o,d,I,M,G,f]),Ue(()=>{const U=g.current;!U||!n||!_||U.setAttribute("hidden","until-found")},[_,n]),v.useEffect(function(){const q=g.current;if(!q)return;function W(ne){const ie=at(Br,ne);c(!0,ie),!ie.isCanceled&&(S.current=!0,h(!0))}return Jt(q,"beforematch",W)},[c,h]);const K=i||n||o||d;return{height:D.height,props:{...z?{[Pge]:""}:void 0,hidden:_,id:r},ref:T,shouldPreventOpenAnimation:L,shouldRender:K,transitionStatus:I,width:D.width}}function im(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Fge(e,t){const n=tr(e).getComputedStyle(e),r=(n.animationName.split(",").map(o=>o.trim()).some(o=>o!==""&&o!=="none")||t)&&kF(n.animationDuration),i=kF(n.transitionDuration);return r&&i||i?"css-transition":r?"css-animation":"none"}function kF(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function j0(e,t,n){const r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function Uge(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,o])=>{if(o===""){e.style.removeProperty(i);return}e.style.setProperty(i,o)})}const r=li.request(n);return()=>{li.cancel(r),n()}}const Hge="--collapsible-panel-height",Vge="--collapsible-panel-width",Kge=v.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:o,render:c,id:d,style:f,...h}=t,{defaultPanelId:p,mounted:g,onOpenChange:x,open:y,setMounted:j,setPanelIdState:w,setOpen:S,state:N,transitionStatus:A}=jF(),E=i??!1,O=o??!1,R=d||void 0,T=R??p;Ue(()=>(w(F=>R??(F===null?void 0:F)),()=>{w(F=>F===R?null:F)}),[R,w]);const{height:P,props:M,ref:_,shouldPreventOpenAnimation:I,shouldRender:L,transitionStatus:D,width:z}=Bge({externalRef:n,hiddenUntilFound:E,id:T,keepMounted:O,mounted:g,onOpenChange:x,open:y,setMounted:j,setOpen:S,transitionStatus:A}),G={...N,transitionStatus:D},X=b3(f,G),Y=wt("div",{...t,style:void 0},{state:G,ref:_,props:[M,{style:{[Hge]:P===void 0?"auto":`${P}px`,[Vge]:z===void 0?"auto":`${z}px`}},h,X?{style:X}:void 0,I?{style:{animationName:"none"}}:void 0],stateAttributesMapping:SF});return L?Y:null});function Ll(e){return s.jsx(Lge,{"data-slot":"collapsible",...e})}function zl({className:e,render:t,...n}){return s.jsx($ge,{"data-slot":"collapsible-trigger",render:t??s.jsx(B,{variant:"ghost"}),className:e,...n})}function $l({className:e,...t}){return s.jsx(Kge,{"data-slot":"collapsible-content",className:Te("min-w-0",typeof e=="string"&&e),...t})}function It({className:e,variant:t="default",...n}){return s.jsx("div",{"data-slot":"alert",role:"alert",className:Te("rounded-md border px-3 py-2.5 text-[12.5px] leading-relaxed",t==="default"&&"border-border bg-surface-2 text-subtle",t==="destructive"&&"border-destructive-bd bg-destructive-soft text-destructive",t==="warning"&&"border-warning-bd bg-warning-soft text-warning",t==="success"&&"border-success-bd bg-success-soft text-success",e),...n})}function om({className:e,...t}){return s.jsx("div",{"data-slot":"alert-title",className:Te("font-semibold",e),...t})}function Xo({className:e,...t}){return s.jsx("div",{"data-slot":"alert-description",className:Te("text-[12px] leading-relaxed",e),...t})}function zt({className:e,...t}){return s.jsx("div",{"data-slot":"empty",className:Te("flex flex-col items-center justify-center gap-2 px-4 py-8 text-center text-[12.5px] leading-relaxed text-muted-foreground",e),...t})}function qge({className:e,...t}){return s.jsx("div",{"data-slot":"empty-title",className:Te("text-[13px] font-semibold text-foreground",e),...t})}function Gge({className:e,...t}){return s.jsx("div",{"data-slot":"empty-description",className:Te("text-[12px] leading-relaxed text-muted-foreground",e),...t})}function Hf({className:e,variant:t="success",pulse:n,...r}){return s.jsx("span",{"data-slot":"status-dot","aria-hidden":"true",className:Te("inline-block size-[7px] shrink-0 rounded-full",t==="success"&&"bg-success",t==="warning"&&"bg-warning",t==="destructive"&&"bg-destructive",t==="muted"&&"bg-muted-foreground",n&&"animate-pulse motion-reduce:animate-none",e),...r})}const Yge=new Set(["a","article","b","blockquote","br","code","del","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","kbd","li","ol","p","pre","s","section","small","span","strong","sub","sup","ul","col","colgroup"]),NF={button:B,input:Be,label:Ie,textarea:Ea,table:ea,thead:Ta,tbody:ga,tfoot:ape,tr:en,th:ft,td:Xe,caption:ipe},Wge=new Set(["text-align","white-space","word-break","overflow-wrap","font-weight","font-style","font-size","line-height","color","background-color","width","max-width","min-width","height","padding","margin","display","gap","flex","grid-column"]);function CF(e,t=!1){if(t&&/^data:image\/(?:png|jpe?g|gif|webp|avif);base64,/i.test(e)||/^(?:https?:\/\/|\/[^/]|\.\.?\/|#)/i.test(e))return e}function Xge(e){const t={};for(const n of e.attributes)n.name==="class"?t.className=n.value:n.name==="colspan"?t.colSpan=Number(n.value)||1:n.name==="rowspan"?t.rowSpan=Number(n.value)||1:n.name==="target"&&["_blank","_self"].includes(n.value)?t.target=n.value:n.name==="loading"&&["lazy","eager"].includes(n.value)?t.loading=n.value:["title","id","role","alt","scope","type","placeholder"].includes(n.name)||/^(aria-|data-)/.test(n.name)?t[n.name]=n.value:n.name==="href"?t.href=CF(n.value):n.name==="src"&&(t.src=CF(n.value,!0));if(e.tagName==="A"&&(t.rel="noopener noreferrer"),e instanceof HTMLElement){const n={};for(const r of e.style){if(!Wge.has(r))continue;const i=e.style.getPropertyValue(r);/url\(|expression\(/i.test(i)||(n[r.replace(/-([a-z])/g,(o,c)=>c.toUpperCase())]=i)}Object.keys(n).length&&(t.style=n)}return t}function S0(e,t=""){return Array.from(e).map((n,r)=>{const i=`${t}${r}`;if(n.nodeType===Node.TEXT_NODE)return n.textContent;if(!(n instanceof Element))return null;const o=n.tagName.toLowerCase();if(["script","style","iframe","object","embed"].includes(o))return null;const c=Xge(n),d=S0(n.childNodes,`${i}-`);if(o==="details"){const f=Array.from(n.children).find(h=>h.tagName==="SUMMARY");return s.jsxs(Ll,{defaultOpen:n.hasAttribute("open"),...c,children:[s.jsxs(zl,{className:Te("h-auto w-full justify-start whitespace-normal px-0 text-left",f?.className),children:[s.jsx("span",{className:"shrink-0 transition-transform in-data-panel-open:rotate-90","aria-hidden":"true",children:"▸"}),f?S0(f.childNodes,`${i}-summary-`):"…"]}),s.jsx($l,{keepMounted:!0,children:S0(Array.from(n.childNodes).filter(h=>h!==f),`${i}-body-`)})]},i)}if(o==="span"&&n.classList.contains("badge")){const f=n.classList.contains("ok")||n.classList.contains("phase-streaming")?"success":n.classList.contains("bad")?"destructive":n.classList.contains("warn")?"warning":n.classList.contains("brand")?"brand":"outline";return s.jsx(ye,{variant:f,shape:n.classList.contains("tag")?"tag":"pill",...c,children:d},i)}return o==="span"&&n.classList.contains("req-live-dot")?s.jsx(Hf,{pulse:!0,className:"size-[5px] bg-current"},i):o==="div"&&n.classList.contains("empty")?s.jsx(zt,{...c,children:d},i):o==="input"&&n.getAttribute("type")==="checkbox"?s.jsx(Wr,{checked:n.hasAttribute("checked"),readOnly:!0},i):o==="table"?s.jsx(ea,{container:!1,...c,children:d},i):NF[o]?v.createElement(NF[o],{key:i,...c},o==="input"?void 0:d):Yge.has(o)?["br","hr","img","col"].includes(o)?v.createElement(o,{key:i,...c}):v.createElement(o,{key:i,...c},d):s.jsx(v.Fragment,{children:d},i)})}function Qo({html:e,className:t,render:n,...r}){const i=v.useMemo(()=>{if(!e)return[];const o=new DOMParser().parseFromString(e,"text/html");return S0(o.body.childNodes)},[e]);return ox({defaultTagName:"div",render:n,props:{...r,"data-slot":"html-content",className:Te(t),children:i}})}const AF=v.createContext(void 0);function Qge(){const e=v.useContext(AF);if(e===void 0)throw new Error(En(38));return e}const Zge=v.forwardRef(function(t,n){const{format:r,getAriaValueText:i,locale:o,max:c=100,min:d=0,value:f,render:h,className:p,children:g,style:x,...y}=t,[j,w]=v.useState(),S=PB(f,d,c),N=Dc(Number.isNaN(S)?0:S,0,100),A=Dc(Number.isNaN(f)?d:f,d,c),E=r?Bj(A,o,r):Bj(N/100,o,{style:"percent"});let O=E;i&&(O=i(E,f));const R={"aria-labelledby":j,"aria-valuemax":c,"aria-valuemin":d,"aria-valuenow":A,"aria-valuetext":O,role:"meter",children:s.jsxs(v.Fragment,{children:[g,s.jsx("span",{role:"presentation",style:_c,children:"x"})]})},T=v.useMemo(()=>({formattedValue:E,percentageValue:N,setLabelId:w,value:f}),[E,N,w,f]),P=wt("div",t,{ref:n,props:[R,y]});return s.jsx(AF.Provider,{value:T,children:P})}),Jge=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t;return wt("div",t,{ref:n,props:c})}),eve=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,{percentageValue:d}=Qge();return wt("div",t,{ref:n,props:[{style:{insetInlineStart:0,height:"inherit",width:`${d}%`}},c]})});function lm({value:e,variant:t="default",className:n,trackClassName:r,indicatorClassName:i,...o}){const c=Te("block h-1 w-full overflow-hidden rounded-pill bg-hairline",r);return e===null?s.jsx("span",{"data-slot":"meter","aria-hidden":"true",className:Te("block w-full",n),children:s.jsx("span",{"data-slot":"meter-track",className:c})}):s.jsx(Zge,{render:s.jsx("span",{}),value:e,"data-slot":"meter",className:Te("block w-full",n),...o,children:s.jsx(Jge,{render:s.jsx("span",{}),"data-slot":"meter-track",className:c,children:s.jsx(eve,{render:s.jsx("span",{}),"data-slot":"meter-indicator",className:Te("block h-full rounded-[inherit] transition-[width] duration-300 motion-reduce:transition-none",t==="default"&&"bg-primary",t==="success"&&"bg-success",t==="warning"&&"bg-warning",t==="destructive"&&"bg-destructive",t==="muted"&&"bg-muted-foreground",i)})})})}function tt({className:e,size:t="default",render:n,...r}){return ox({defaultTagName:"div",render:n,props:{...r,"data-slot":"card","data-size":t,className:Te("group/card min-w-0 overflow-hidden rounded-lg border border-border bg-surface text-foreground shadow-1",e)}})}function fn({className:e,...t}){return s.jsx("div",{"data-slot":"card-header",className:Te("flex flex-wrap items-center gap-2.5 border-b border-border px-4 py-3 group-data-[size=sm]/card:px-3 group-data-[size=sm]/card:py-2",e),...t})}function PT({className:e,...t}){return s.jsx("h3",{"data-slot":"card-title",className:Te("m-0 text-[14px] font-semibold leading-snug",e),...t})}function tve({className:e,...t}){return s.jsx("p",{"data-slot":"card-description",className:Te("m-0 text-[12px] leading-relaxed text-subtle",e),...t})}function Ft({className:e,...t}){return s.jsx("div",{"data-slot":"card-content",className:Te("min-w-0 p-4 group-data-[size=sm]/card:p-3",e),...t})}function Zo({className:e,...t}){return s.jsx("div",{"data-slot":"card-footer",className:Te("flex flex-wrap items-center gap-2 border-t border-border px-4 py-2.5 text-[11.5px] leading-relaxed text-muted-foreground",e),...t})}function IT({className:e,...t}){return s.jsx(tt,{"data-slot":"metric-card",className:Te("rounded-md bg-surface-inset px-3.5 py-3",e),...t})}function EF({className:e,...t}){return s.jsx("div",{"data-slot":"metric-grid",className:Te("grid grid-cols-[repeat(auto-fit,minmax(min(178px,100%),1fr))] gap-2.5",e),...t})}function td(e,t={}){return new Promise(n=>{const r=document.createElement("div");document.body.append(r);const i=wn.createRoot(r),o=v.createRef();let c=!1;const d=f=>{c||(c=!0,queueMicrotask(()=>{i.unmount(),r.remove()}),n(f))};i.render(s.jsx(d4,{open:!0,onOpenChange:f=>{f||d(!1)},children:s.jsxs(h4,{initialFocus:o,children:[s.jsx(p4,{children:s.jsx(f4,{children:t.title||ue("请确认")})}),s.jsx(m4,{children:s.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-relaxed",children:e})}),s.jsxs(g4,{children:[s.jsx(B,{ref:o,variant:"outline",onClick:()=>d(!1),children:ue("取消")}),s.jsx(B,{variant:t.destructive===!1?"default":"destructive",onClick:()=>d(!0),children:t.confirmText||ue("确定")})]})]})}))})}function nve({state:e="idle",children:t,className:n,...r}){return s.jsxs(B,{variant:"outline","data-slot":"verification",className:Te("h-auto min-h-10 gap-3 px-3.5 py-2.5 text-[13px] disabled:opacity-100",e==="verified"&&"text-success",e==="error"&&"border-destructive-bd text-destructive",n),...r,children:[e==="verifying"?s.jsx(Ls,{}):s.jsx(Hf,{variant:e==="verified"?"success":e==="error"?"destructive":"muted"}),s.jsx("span",{className:"min-w-0",children:t})]})}function kx({className:e,render:t,variant:n="default",size:r="default",...i}){return ox({defaultTagName:"div",render:t,props:{...i,"data-slot":"item","data-size":r,className:Te("flex w-full min-w-0 items-center gap-2.5 rounded-md text-left text-foreground transition-colors",r==="sm"?"px-3 py-2 text-[12.5px]":"px-3.5 py-3 text-[13px]",n==="outline"&&"border border-border",n==="muted"&&"bg-surface-2","has-[[data-slot=item-content]]:justify-start",e)}})}function rve({className:e,...t}){return s.jsx("div",{"data-slot":"item-content",className:Te("min-w-0 flex-1",e),...t})}function sve({className:e,...t}){return s.jsx("div",{"data-slot":"item-title",className:Te("text-[13px] font-medium",e),...t})}function ave({className:e,...t}){return s.jsx("p",{"data-slot":"item-description",className:Te("m-0 mt-0.5 text-[12px] leading-relaxed text-muted-foreground",e),...t})}const ive=v.forwardRef(function(t,n){const{render:r,className:i,style:o,disabled:c=!1,...d}=t,[f,h]=v.useState(void 0),g=ZA(!0)?.disabled||c,y=wt("fieldset",t,{ref:n,state:{disabled:g},props:[{"aria-labelledby":f,disabled:g},d]}),j=v.useMemo(()=>({legendId:f,setLegendId:h,disabled:g}),[f,h,g]);return s.jsx(q3.Provider,{value:j,children:y})}),TF=Tf("min-w-0",{variants:{orientation:{vertical:"flex flex-col gap-1.5",horizontal:"flex flex-wrap items-center gap-2.5",responsive:"flex flex-col gap-1.5 min-[768px]:flex-row min-[768px]:items-center min-[768px]:gap-2.5"}},defaultVariants:{orientation:"vertical"}});function Et({className:e,orientation:t,...n}){return s.jsx(Tue,{"data-slot":"field",className:r=>Te(TF({orientation:t}),typeof e=="function"?e(r):e),...n})}function ws({className:e,orientation:t,...n}){return s.jsx("div",{"data-slot":"field-group",className:Te(t?TF({orientation:t}):"flex flex-col gap-3",e),...n})}function ove({className:e,...t}){return s.jsx(ive,{"data-slot":"field-set",className:n=>Te("m-0 min-w-0 border-0 p-0",typeof e=="function"?e(n):e),...t})}function Tt({className:e,...t}){return s.jsx(Rue,{"data-slot":"field-label",className:n=>Te("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",typeof e=="function"?e(n):e),...t})}function k0({className:e,...t}){return s.jsx("div",{"data-slot":"field-content",className:Te("min-w-0 flex-1",e),...t})}function nd({className:e,...t}){return s.jsx(Mue,{"data-slot":"field-description",className:n=>Te("m-0 text-[11.5px] leading-relaxed text-subtle",typeof e=="function"?e(n):e),...t})}const OF=v.createContext(void 0);function MT(){const e=v.useContext(OF);if(!e)throw new Error(En(73));return e}let RF=0;function PF(e){return RF+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${RF}`}function _T(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const n=e(t);return typeof n=="string"?{description:n}:n}return e}function DT(e){const t=new Map;let n=0,r=0;return e.forEach((i,o)=>{const c=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:o,visibleIndex:c?-1:n,offsetY:r}),r+=i.height||0,c||(n+=1)}),t}function LT(e,t){let n=0;return e.map(r=>{if(r.transitionStatus==="ending")return r;const i=n>=t;return n+=1,r.limited===i?r:{...r,limited:i}})}const Jo={toasts:e=>e.toasts,isEmpty:e=>e.toasts.length===0,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement};class lve extends $f{constructor(n){super({...n,toastMetadata:DT(n.toasts)},{},Jo);on(this,"timers",new Map);on(this,"areTimersPaused",!1);on(this,"setViewport",n=>{this.set("viewport",n)});on(this,"disposeEffect",()=>()=>{this.timers.forEach(n=>{n.timeout?.clear()}),this.timers.clear()});on(this,"addToast",n=>{const{timeout:r,limit:i}=this.state,o=n.id||PF("toast");if(n.id){const h=Jo.toast(this.state,n.id);if(h)if(h.transitionStatus==="ending")this.removeToast(n.id,!0);else{const{id:p,transitionStatus:g,...x}=n;return this.updateToastInternal(n.id,x,!0,!0),n.id}}const c={...n,id:o,updateKey:0,transitionStatus:"starting"},d=[c,...this.state.toasts];this.setToasts(LT(d,i));const f=c.timeout??r;return c.type!=="loading"&&f>0&&this.scheduleTimer(o,f,()=>this.closeToast(o)),Jo.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),o});on(this,"updateToast",(n,r)=>{const i=Jo.toast(this.state,n);!i||i.transitionStatus==="ending"||this.updateToastInternal(n,typeof r=="function"?r(i):r,!1,!0)});on(this,"updateToastInternal",(n,r,i=!1,o=!1)=>{const{timeout:c,toasts:d}=this.state,f=Jo.toast(this.state,n);if(!f||f.transitionStatus==="ending")return;const h={...f,...r,...o&&{updateKey:f.updateKey+1}};this.setToasts(d.map(N=>N.id===n?h:N));const p=h.timeout??c,g=f.timeout??c,x=Object.hasOwn(r,"timeout"),y=h.transitionStatus!=="ending"&&h.type!=="loading"&&p>0,j=this.timers.has(n),w=g!==p,S=f.type==="loading";if(!y&&j){this.clearTimer(n);return}y&&(!j||w||x||S||i)&&(this.clearTimer(n),this.scheduleTimer(n,p,()=>this.closeToast(n)),Jo.expandedOrOutOfFocus(this.state)&&this.pauseTimers())});on(this,"closeToast",n=>{const r=n===void 0,{limit:i,toasts:o}=this.state;let c;if(r)c=o,this.clearTimers();else{const h=Jo.toast(this.state,n);if(!h)return;c=[h],this.clearTimer(n)}const d=o.map(h=>r||h.id===n?{...h,transitionStatus:"ending",height:0}:h),f=LT(d,i);this.setToasts(f,!f.some(h=>h.transitionStatus!=="ending")),c.forEach(h=>{h.transitionStatus!=="ending"&&h.onClose?.()}),this.handleFocusManagement(n)});on(this,"promiseToast",(n,r)=>{const i=_T(r.loading),o=this.addToast({...i,type:"loading"}),c=n.then(d=>{const f=_T(r.success,d);return this.updateToast(o,{...f,type:"success",timeout:f.timeout}),d}).catch(d=>{const f=_T(r.error,d);return this.updateToast(o,{...f,type:"error",timeout:f.timeout}),Promise.reject(d)});return{}.hasOwnProperty.call(r,"setPromise")&&r.setPromise(c),c});on(this,"handleDocumentPointerDown",n=>{if(n.pointerType!=="touch")return;const r=or(n);nt(this.state.viewport,r)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}syncProviderProps(n,r){const i=this.state.limit!==r;if(this.state.timeout===n&&!i)return;const o={timeout:n,limit:r};if(i){const c=LT(this.state.toasts,r);o.toasts=c,o.toastMetadata=DT(c)}this.update(o)}removeToast(n,r=!1){const i=Jo.toastIndex(this.state,n);if(i===-1)return;const o=this.state.toasts[i];r||o?.onRemove?.();const c=[...this.state.toasts];c.splice(i,1),this.setToasts(c)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(n=>{n.timeout&&(n.timeout.clear(),n.remaining=Math.max(n.remaining-(Date.now()-n.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((n,r)=>{n.remaining=n.remaining>0?n.remaining:n.delay,n.timeout??(n.timeout=oi.create()),n.timeout.start(n.remaining,()=>{this.handleTimerFired(r),n.callback()}),n.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}scheduleTimer(n,r,i){const o=Date.now(),d=!Jo.expandedOrOutOfFocus(this.state)?oi.create():void 0;d?.start(r,()=>{this.handleTimerFired(n),i()}),this.timers.set(n,{timeout:d,start:o,delay:r,remaining:r,callback:i})}clearTimers(){this.timers.forEach(n=>{n.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(n){this.timers.get(n)?.timeout?.clear(),this.timers.delete(n),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(n){this.timers.delete(n),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){this.timers.size===0&&(this.areTimersPaused=!1)}setToasts(n,r=n.length===0){const i={toasts:n,toastMetadata:DT(n)};r&&(i.hovering=!1,i.focused=!1),this.update(i)}handleFocusManagement(n){const r=ys(vn(this.state.viewport));if(!this.state.viewport||!nt(this.state.viewport,r)||!Nj(r))return;if(n===void 0){this.restoreFocusToPrevElement();return}const i=Jo.toasts(this.state),o=Jo.toastIndex(this.state,n),c=(f,h)=>{for(let p=f;p>=0&&pnew lve({timeout:r,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Ij(c.disposeEffect),v.useEffect(function(){return o?o[" subscribe"](({action:h,options:p})=>{const g=p.id;h==="promise"&&p.promise?c.promiseToast(p.promise,p):h==="update"&&g?c.updateToast(g,p.updates):h==="close"?c.closeToast(g):c.addToast(p)}):void 0},[c,o]),s.jsxs(OF.Provider,{value:c,children:[s.jsx(uve,{store:c,timeout:r,limit:i}),n]})};function uve(e){const{store:t,timeout:n,limit:r}=e;return Ue(()=>{t.syncProviderProps(n,r)},[t,n,r]),null}const dve="--toast-frontmost-height",fve=v.forwardRef(function(t,n){const{render:r,className:i,style:o,children:c,...d}=t,f=MT(),h=Ds(),p=v.useRef(!1),g=v.useRef(!1),x=v.useRef(!1),y=f.useState("isEmpty"),j=f.useState("toasts"),w=f.useState("focused"),S=f.useState("expanded"),N=f.useState("prevFocusElement"),A=j[0]?.height,E=j.some(U=>U.transitionStatus==="ending"),O=j.filter(U=>U.priority==="high");v.useEffect(()=>{const U=f.state.viewport;if(!U||y)return;const q=tr(U),W=vn(U);function ne(H){H.key==="F6"&&or(H)!==U&&(H.preventDefault(),f.set("prevFocusElement",ys(W)),U?.focus({preventScroll:!0}),f.pauseTimers(),f.set("focused",!0))}function ie(H){or(H)===q&&(f.set("isWindowFocused",!1),f.pauseTimers())}function V(H){if(H.relatedTarget)return;const Q=or(H),J=ys(vn(U));(Q===q||!nt(U,Q)||!Nj(J))&&f.resumeTimers(),h.start(0,()=>f.set("isWindowFocused",!0))}return Go(Jt(q,"keydown",ne),Jt(q,"blur",ie,!0),Jt(q,"focus",V,!0),Jt(W,"pointerdown",f.handleDocumentPointerDown,!0))},[f,h,y]);function R(U){p.current=!0;const q=U.relatedTarget===f.state.viewport?j.find(W=>W.transitionStatus!=="ending"&&!W.limited):void 0;q?q.ref?.current?.focus():f.restoreFocusToPrevElement()}function T(U){U.key==="Tab"&&U.shiftKey&&or(U.nativeEvent)===f.state.viewport&&(U.preventDefault(),f.restoreFocusToPrevElement())}function P(){f.state.toasts.some(q=>q.transitionStatus==="ending")||x.current||!g.current||(f.state.isWindowFocused&&f.resumeTimers(),f.set("hovering",!1),g.current=!1)}v.useEffect(P,[E,f]);function M(){f.pauseTimers(),f.set("hovering",!0),g.current=!1}function _(){f.state.isWindowFocused&&f.resumeTimers()}function I(){g.current=!0,P()}function L(U){U.pointerType==="touch"&&(x.current=!0)}function D(U){U.pointerType==="touch"&&(x.current=!1,P())}function z(){if(p.current){p.current=!1;return}w||Nj(ys(vn(f.state.viewport)))&&(f.set("focused",!0),f.pauseTimers())}function G(U){!w||nt(f.state.viewport,U.relatedTarget)||(f.set("focused",!1),_())}const X={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:M,onMouseMove:M,onMouseLeave:I,onFocus:z,onBlur:G,onKeyDown:T,onClick:z,onPointerDown:L,onPointerUp:D,onPointerCancel:D,style:{[dve]:A?`${A}px`:void 0}},Y={expanded:S},F=!y&&N&&s.jsx(Df,{onFocus:R}),K=wt("div",t,{ref:[n,f.setViewport],state:Y,props:[X,d,{children:s.jsxs(v.Fragment,{children:[F,c,F]})}]});return s.jsxs(v.Fragment,{children:[F,K,!w&&O.length>0&&s.jsx("div",{style:_c,children:O.map(U=>s.jsxs("div",{role:"alert","aria-atomic":!0,children:[s.jsx("div",{children:U.title}),s.jsx("div",{children:U.description})]},U.id))})]})}),IF=v.createContext(void 0);function hve(){const e=v.useContext(IF);if(!e)throw new Error(En(66));return e}function pve(e,t){const n=tr(e).getComputedStyle(e).transform;let r=0,i=0,o=1;if(n&&n!=="none"){const c=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(c){const d=c[1].split(", ").map(parseFloat);d.length===6?(r=d[4],i=d[5],o=Math.sqrt(d[0]*d[0]+d[1]*d[1])):d.length===16&&(r=d[12],i=d[13],o=d[0])}}return{x:r,y:i,scale:o}}function zT(e,t,n){switch(e){case"up":return-n;case"down":return n;case"left":return-t;case"right":return t;default:return 0}}const mve="--toast-index",gve="--toast-offset-y",vve="--toast-height",xve="--toast-swipe-movement-x",bve="--toast-swipe-movement-y",yve="data-swipe-direction",wve={...io,swipeDirection(e){return e?{[yve]:e}:null}},MF=40,jve=10,_F=.5,Sve=1,kve=`${Dde},${Lde}`,Nve=v.forwardRef(function(t,n){const{toast:r,render:i,className:o,swipeDirection:c=["down","right"],style:d,...f}=t,h=r.positionerProps?.anchor!==void 0;let p=[];h||(p=Array.isArray(c)?c:[c]);const g=p.length>0,x=MT(),[y,j]=v.useState(void 0),[w,S]=v.useState(!1),[N,A]=v.useState(!1),[E,O]=v.useState({x:0,y:0}),[R,T]=v.useState({x:0,y:0,scale:1}),[P,M]=v.useState(),[_,I]=v.useState(),[L,D]=v.useState(null),z=v.useRef(null),G=v.useRef(void 0),X=v.useRef({x:0,y:0}),Y=v.useRef({x:0,y:0,scale:1}),F=v.useRef(void 0),K=v.useRef(0),U=v.useRef(!1),q=v.useRef({x:0,y:0}),W=v.useRef(!1),ne=v.useRef({x:0,y:0}),ie=v.useRef(null),V=v.useRef(null),H=x.useState("toastIndex",r.id),Q=x.useState("toastVisibleIndex",r.id),J=x.useState("toastOffsetY",r.id),oe=x.useState("focused"),ee=x.useState("expanded");Va({open:r.transitionStatus!=="ending",ref:z,onComplete(){r.transitionStatus==="ending"&&x.removeToast(r.id)}});const se=Fe((ve=!1)=>{const xe=z.current;if(!xe)return;const Re=xe.style.height;xe.style.height="auto";const we=xe.offsetHeight;xe.style.height=Re;function ge(){x.updateToastInternal(r.id,{ref:z,height:we,transitionStatus:void 0})}ve?br.flushSync(ge):ge()});Ue(()=>{const ve=G.current;r.transitionStatus!=="starting"&&ve===r.id||(ve!==void 0&&(j(void 0),T({x:0,y:0,scale:1}),le({x:0,y:0})),G.current=r.id,se())},[se,r.id,r.transitionStatus]);function le(ve){ne.current=ve,O(ve)}Ue(()=>()=>{V.current?.abort()},[]);function te(ve,xe){const Re=De=>De>0?De**_F:-(Math.abs(De)**_F),we=ve>0&&!p.includes("right")||ve<0&&!p.includes("left"),ge=xe>0&&!p.includes("down")||xe<0&&!p.includes("up");return{x:we?Re(ve):ve,y:ge?Re(xe):xe}}const re=Fe(ve=>{if(ve.pointerId!==ie.current)return;ie.current=null,V.current?.abort(),V.current=null,S(!1),A(!1),D(null);const xe=Y.current;if(ve.type==="pointercancel"||U.current){le({x:xe.x,y:xe.y}),j(void 0);return}const Re=ne.current,we=Re.x-xe.x,ge=Re.y-xe.y;let De;for(const Ge of p)if(zT(Ge,we,ge)>MF){De=Ge;break}De?(j(De),x.closeToast(r.id)):(le({x:xe.x,y:xe.y}),j(void 0))});function he(ve){if(ve.button!==0||(ve.pointerType==="touch"&&x.pauseTimers(),or(ve.nativeEvent)?.closest(`button,a,input,textarea,[role="button"],${kve}`)))return;U.current=!1,F.current=void 0,K.current=0,ie.current=ve.pointerId,X.current={x:ve.clientX,y:ve.clientY},q.current=X.current;const we=ve.currentTarget,ge=pve(we);Y.current=ge,T(ge),le({x:ge.x,y:ge.y}),x.set("hovering",!0),S(!0),A(!1),D(null),W.current=!0,V.current?.abort();const De=new AbortController;V.current=De;const Ge=vn(we);Ge.addEventListener("pointerup",re,{signal:De.signal}),Ge.addEventListener("pointercancel",re,{signal:De.signal}),we.setPointerCapture?.(ve.pointerId)}function pe(ve){if(ve.pointerId!==ie.current)return;ve.preventDefault(),W.current&&(X.current={x:ve.clientX,y:ve.clientY},W.current=!1);const{clientY:xe,clientX:Re,movementX:we,movementY:ge}=ve;(ge<0&&xe>q.current.y||ge>0&&xeq.current.x||we>0&&Re=Sve){A(!0);const Ut=p.includes("left")||p.includes("right"),Yt=p.includes("up")||p.includes("down");if(Ut&&Yt){const yt=Math.abs(De),un=Math.abs(Ge);$t=yt>un?"horizontal":"vertical",D($t)}}let Me;if(!F.current)$t==="vertical"?Ge>0?Me="down":Ge<0&&(Me="up"):$t==="horizontal"?De>0?Me="right":De<0&&(Me="left"):Math.abs(De)>=Math.abs(Ge)?Me=De>0?"right":"left":Me=Ge>0?"down":"up",Me&&p.includes(Me)&&(F.current=Me,K.current=zT(Me,De,Ge),j(Me));else{const bt=F.current,Ut=zT(bt,sn,Ot);Ut>MF?(U.current=!1,j(bt)):!(p.includes("left")&&p.includes("right"))&&!(p.includes("up")&&p.includes("down"))&&K.current-Ut>=jve&&(U.current=!0)}const Ht=te(De,Ge);let an=Y.current.x,Mt=Y.current.y;const _t=p.includes("left")||p.includes("right"),Ve=p.includes("up")||p.includes("down");$t!=="vertical"&&_t&&(an+=Ht.x),$t!=="horizontal"&&Ve&&(Mt+=Ht.y),le({x:an,y:Mt})}function Ne(ve){if(ve.key==="Escape"){if(!z.current||!nt(z.current,ys(vn(z.current))))return;x.closeToast(r.id)}}v.useEffect(()=>{const ve=z.current;if(!g||!ve)return;function xe(Re){ie.current===null||!nt(ve,or(Re))||Re.preventDefault()}return Jt(ve,"touchmove",xe,{passive:!1})},[g]);function me(){const ve=E.x-R.x,xe=E.y-R.y;return{transition:w?"none":void 0,transform:w?`translateX(${E.x}px) translateY(${E.y}px) scale(${R.scale})`:void 0,[xve]:`${ve}px`,[bve]:`${xe}px`}}const ce=r.priority==="high",ae={role:ce?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":P,"aria-describedby":_,"aria-hidden":ce&&!oe?!0:void 0,onPointerDown:g?he:void 0,onPointerMove:g?pe:void 0,onPointerUp:g?re:void 0,onPointerCancel:g?re:void 0,onKeyDown:Ne,inert:vx(r.limited),style:{...me(),[mve]:r.transitionStatus==="ending"?H:Q,[gve]:`${J}px`,[vve]:r.height?`${r.height}px`:void 0}},_e=v.useMemo(()=>({toast:r,setTitleId:M,setDescriptionId:I,recalculateHeight:se,visibleIndex:Q,expanded:ee}),[r,M,I,se,Q,ee]),de={transitionStatus:r.transitionStatus,expanded:ee,limited:r.limited||!1,type:r.type,swiping:w,swipeDirection:y},Se=wt("div",t,{ref:[n,z],state:de,stateAttributesMapping:wve,props:[ae,f]});return s.jsx(IF.Provider,{value:_e,children:Se})});function DF(e){return e==null||typeof e=="boolean"||e===""?!1:Array.isArray(e)?e.some(DF):!0}function Cve(e){return v.isValidElement(e)&&DF(e.props.children)}function LF(e,t,n){const{toast:r,setTitleId:i,setDescriptionId:o}=hve(),c=n==="title"?i:o,d=t??(n==="title"?r.title:r.description);return{id:Yp(e),children:d,type:r.type,setId:c}}function zF(e,t,n){const r=Cve(e);return Ue(()=>{if(r)return n(t),()=>{n(i=>i===t?void 0:i)}},[r,t,n]),r?e:null}const Ave=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,children:d,...f}=t,{id:h,children:p,type:g,setId:x}=LF(c,d,"description"),j=wt("p",t,{ref:n,state:{type:g},props:{...f,id:h,children:p}});return zF(j,h,x)}),Eve=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,children:d,...f}=t,{id:h,children:p,type:g,setId:x}=LF(c,d,"title"),j=wt("h2",t,{ref:n,state:{type:g},props:{...f,id:h,children:p}});return zF(j,h,x)}),Tve=v.forwardRef(function(t,n){return s.jsx(H5,{ref:n,...t})});function Ove(){const e=MT(),t=e.useState("toasts");return v.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function Rve(){const e=new Set;function t(n){e.forEach(r=>r(n))}return{" subscribe":function(r){return e.add(r),()=>{e.delete(r)}},add(n){const r=n.id||PF("toast"),i={...n,id:r,transitionStatus:"starting"};return t({action:"add",options:i}),r},close(n){t({action:"close",options:{id:n}})},update(n,r){t({action:"update",options:{id:n,updates:r}})},promise(n,r){let i=n;return t({action:"promise",options:{...r,promise:n,setPromise(o){i=o}}}),i}}}const $T=Rve(),Pve=cve;function Ive({className:e,...t}){return s.jsx(Eve,{"data-slot":"toast-title",className:n=>Te("m-0 text-[12.5px] font-semibold leading-relaxed [overflow-wrap:anywhere]",typeof e=="function"?e(n):e),...t})}function Mve({className:e,...t}){return s.jsx(Ave,{"data-slot":"toast-description",className:n=>Te("m-0 text-[12px] leading-relaxed text-subtle [overflow-wrap:anywhere]",typeof e=="function"?e(n):e),...t})}function _ve({className:e,...t}){return s.jsx(Nve,{"data-slot":"toast",className:Te("pointer-events-auto max-w-full rounded-lg border border-border bg-raised px-4 py-2.5 text-[12.5px] text-foreground shadow-3 outline-none","data-[type=success]:border-success-bd data-[type=success]:text-success","data-[type=error]:border-destructive-bd data-[type=error]:text-destructive","data-[type=warning]:border-warning-bd data-[type=warning]:text-warning","data-limited:hidden data-ending-style:opacity-0 transition-opacity duration-150",typeof e=="string"&&e),...t})}function Dve(){const{toasts:e}=Ove();return e.map(t=>s.jsxs(_ve,{toast:t,children:[s.jsx(Ive,{children:t.title}),t.description&&s.jsx(Mve,{className:"mt-1",children:t.description})]},t.id))}function $F({manager:e=$T,position:t="top-center",className:n}){return s.jsx(Pve,{toastManager:e,timeout:3500,limit:1,children:s.jsx(Tve,{children:s.jsx(fve,{"data-slot":"toast-viewport",className:Te("pointer-events-none fixed left-1/2 z-[100] flex w-max max-w-[84vw] -translate-x-1/2 flex-col items-center gap-2 outline-none",t==="top-center"?"top-4":"bottom-[calc(78px+env(safe-area-inset-bottom,0px))]",n),children:s.jsx(Dve,{})})})})}function Lve({className:e,...t}){return s.jsx("div",{"data-slot":"app-frame",className:Te("min-h-0 bg-background text-foreground",e),...t})}function cm({className:e,...t}){return s.jsx("aside",{"data-slot":"sidebar",className:Te("flex min-h-0 flex-col gap-3 border-r border-sidebar-border bg-sidebar p-3 text-sidebar-foreground",e),...t})}function zve({className:e,...t}){return s.jsx("div",{"data-slot":"sidebar-header",className:Te("shrink-0",e),...t})}function $ve({className:e,...t}){return s.jsx("nav",{"data-slot":"sidebar-content",className:Te("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",e),...t})}function Bve({className:e,...t}){return s.jsx("div",{"data-slot":"sidebar-footer",className:Te("flex shrink-0 flex-col gap-2 border-t border-sidebar-border pt-2.5",e),...t})}function BF({className:e,...t}){return s.jsx("div",{"data-slot":"sidebar-group-label",className:Te("px-2 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-[.09em] text-sidebar-muted",e),...t})}function FF({className:e,...t}){return s.jsx("header",{"data-slot":"page-header",className:Te("flex shrink-0 items-center justify-between gap-3",e),...t})}function Fve({className:e,...t}){return s.jsx("header",{"data-slot":"window-titlebar","data-tauri-drag-region":"",className:Te("flex h-8 shrink-0 items-center gap-2.5 overflow-hidden border-b border-sidebar-border bg-sidebar pl-3 text-sidebar-fg select-none",e),...t})}function BT({className:e,action:t,...n}){return s.jsx(B,{"data-slot":"window-control",variant:"ghost",className:Te("h-8 w-11 rounded-none p-0 shadow-none active:translate-y-0",t==="close"&&"hover:bg-destructive hover:text-white",e),...n})}const UF="w-auto flex-auto";function HF({onInput:e,domRef:t,icon:n,className:r,inputClassName:i,...o}){const c=f=>{t.current=f},d=f=>{e?.(f.currentTarget.value)};return n?s.jsxs(uo,{className:Te(UF,r),children:[s.jsx(ho,{ref:c,className:i,onInput:d,...o}),s.jsx(fo,{"aria-hidden":"true",children:n})]}):s.jsx(Be,{ref:c,className:Te(UF,i),onInput:d,...o})}function Uve(e,t){const n=wn.createRoot(e),r={current:null};return n.render(s.jsx(HF,{domRef:r,defaultValue:t.value,placeholder:t.placeholder,type:t.type??"search",icon:t.icon,"aria-label":t.ariaLabel,onInput:t.onInput})),{setValue(i){const o=r.current;o&&o.value!==i&&(o.value=i)},getValue(){return r.current?.value??""},focus(){r.current?.focus()},unmount(){n.unmount()}}}const Hve=[["id","id"],["type","type"],["name","name"],["title","title"],["placeholder","placeholder"],["min","min"],["max","max"],["step","step"],["autocomplete","autoComplete"]];function Vve(e){const t={defaultValue:e.value||void 0,inputClassName:e.className||void 0};for(const[c,d]of Hve){const f=e.getAttribute(c);f!=null&&(t[d]=f)}const n=e.getAttribute("maxlength");n!=null&&(t.maxLength=Number(n));const r=e.getAttribute("inputmode");r!=null&&(t.inputMode=r),e.hasAttribute("spellcheck")&&(t.spellCheck=e.spellcheck),e.disabled&&(t.disabled=!0),e.readOnly&&(t.readOnly=!0),e.hidden&&(t.hidden=!0);const i=e.getAttribute("aria-label");i!=null&&(t["aria-label"]=i);for(const c of e.getAttributeNames())!c.startsWith("data-")||c.startsWith("data-island-")||(t[c]=e.getAttribute(c)??"");const o=e.getAttribute("data-island-icon");return o!=null&&(t.icon=o),t}function VF(e){if(e.dataset.islandUpgraded)return;e.dataset.islandUpgraded="1";const t=Vve(e),n=e.parentElement?.classList.contains("input-affix")?e.parentElement:null;let r;n?(n.className=n.className.replace(/\binput-affix\b/,"").trim(),n.style.display="flex",n.style.alignItems="center",r=n):(r=document.createElement("span"),r.style.display="contents",e.replaceWith(r));const i={current:null},o=wn.createRoot(r);br.flushSync(()=>{o.render(s.jsx(HF,{...t,domRef:i}))})}function KF(e=document){if(e instanceof HTMLInputElement&&e.matches("[data-island-input]")){VF(e);return}e.querySelectorAll("input[data-island-input]").forEach(VF)}function Kve(){KF();const e=new MutationObserver(t=>{for(const n of t)for(const r of n.addedNodes)r instanceof Element&&KF(r)});return e.observe(document.body,{childList:!0,subtree:!0}),e}function qve(e,t){const n=wn.createRoot(e);let r={options:t.options,value:t.value,ariaLabel:t.ariaLabel,className:t.className};const i=()=>{n.render(s.jsx(dn,{options:r.options,value:r.value,onValueChange:t.onChange,"aria-label":r.ariaLabel,className:r.className}))};return i(),{setValue(o){o!==r.value&&(r={...r,value:o},i())},setOptions(o){r={...r,options:o},i()},unmount(){n.unmount()}}}window.wbUiKit={React:MA,createRoot:wn.createRoot,flushSync:br.flushSync,Badge:ye,Button:B,Checkbox:Wr,Input:Be,Label:Ie,Progress:nm,SegmentedControl:dn,Spinner:Ls,Switch:cn,Card:tt,CardHeader:fn,CardContent:Ft,CardFooter:Zo,Collapsible:Ll,CollapsibleTrigger:zl,CollapsibleContent:$l,HtmlContent:Qo,Toaster:$F,toastManager:$T,Select:{Root:ht,Trigger:mt,Value:pt,Content:gt,Item:qe,Group:ime,Label:ome,Separator:lme}};function a(e,t){const n=typeof window<"u"?window.wbI18n:void 0;return n&&typeof n.t=="function"?n.t(e,t):e}const rd=()=>window;let N0=[],Nx="overview",qF=a("报表"),GF=localStorage.getItem("workbuddy-desktop-theme")||"system",YF=[],WF="";const Fc=new Set;let Cx=0;const C0=()=>{Cx+=1;for(const e of Fc)e()};function XF({name:e,size:t=17}){return s.jsx("span",{className:"ico shrink-0","aria-hidden":"true",dangerouslySetInnerHTML:{__html:rd().wbIcons?.icon(e,t)||rd().wbIcons?.icon("plugins",t)||""}})}function Gve(){return v.useSyncExternalStore(e=>(Fc.add(e),()=>Fc.delete(e)),()=>Cx),s.jsx(s.Fragment,{children:N0.length?N0.map((e,t)=>s.jsxs(v.Fragment,{children:[s.jsx(BF,{className:"nav-group-label",children:rd().wbSidebarLayout?.groupLabel(e.label)||e.label}),e.items.map(n=>{const r=n.key==="requests"?"nav-count-requests":n.key==="logs"?"nav-count-logs":n.key==="settings"?"nav-count-update":"";return s.jsx(Ri,{className:`nav-item ${Nx===n.key?"active":""}`,active:Nx===n.key,"data-page":n.key,"data-icon":n.icon,icon:s.jsx(XF,{name:n.icon}),trailing:r?s.jsx(ye,{id:r,variant:"destructive",shape:"tag",className:"count min-w-5 px-1.5 py-0 text-[10.5px]",style:{display:"none"},children:n.key==="settings"?a("新"):"0"}):void 0,children:s.jsx("span",{className:"label",children:a(n.label)})},n.key)})]},`${e.label}-${t}`)):s.jsx(zt,{className:"nav-empty px-2 py-3 text-[11px]",children:a("侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。")})})}function Yve(){return v.useSyncExternalStore(e=>(Fc.add(e),()=>Fc.delete(e)),()=>Cx),s.jsx(dn,{className:"w-full",value:GF,"aria-label":a("显示模式"),options:[{value:"system",label:a("跟随系统")},{value:"light",label:a("浅色")},{value:"dark",label:a("深色")}],onValueChange:e=>rd().wbApp?.applyTheme(e)})}function Wve(){v.useSyncExternalStore(t=>(Fc.add(t),()=>Fc.delete(t)),()=>Cx);const e={ok:"success",warn:"warning",bad:"destructive",brand:"brand"};return s.jsx(s.Fragment,{children:YF.map((t,n)=>s.jsxs(ye,{variant:e[t.kind]||"outline",className:t.optional?"badge optional":"badge",children:[t.dot&&s.jsx(CE,{}),t.text]},n))})}function Xve(){v.useSyncExternalStore(i=>(Fc.add(i),()=>Fc.delete(i)),()=>Cx);const[e,t]=v.useState(!1),n=yF("(max-width: 767px)");v.useEffect(()=>{n||t(!1),window.dispatchEvent(new Event("wb:shell-layout")),rd().wbApp?.syncNavBadges()},[n]),v.useEffect(()=>{const i=()=>t(!1);return window.addEventListener("wb:navigation-close",i),()=>window.removeEventListener("wb:navigation-close",i)},[]);const r=s.jsxs(cm,{className:"sidebar",children:[s.jsxs(zve,{className:"brand",children:[s.jsx("div",{className:"brand-logo",children:s.jsx(XF,{name:"brand",size:32})}),s.jsx("div",{className:"brand-text",children:s.jsx("h1",{children:"Agent2API"})})]}),s.jsx(Bc,{render:s.jsx($ve,{}),className:"nav",id:"nav","aria-label":a("主导航"),onClick:i=>{const o=i.target.closest(".nav-item[data-page]");o?.dataset.page&&rd().wbApp?.showPage(o.dataset.page)},children:s.jsx(Gve,{})}),s.jsxs(Bve,{className:"sidebar-foot",children:[s.jsx("div",{className:"sidebar-status",id:"sidebar-status",title:a("本地网关监听状态")}),s.jsx("div",{id:"theme-switch",children:s.jsx(Yve,{})})]})]});return s.jsxs(Lve,{className:"shell","data-navigation-open":e?"true":void 0,children:[n?s.jsx(OT,{open:e,onOpenChange:t,children:s.jsxs(RT,{side:"left",keepMounted:!0,showHandle:!1,showCloseButton:!1,"aria-label":a("主导航"),className:"w-[min(280px,86vw)] rounded-none border-0 p-0",children:[s.jsx(Nge,{render:s.jsx(B,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 z-10"}),"aria-label":a("关闭菜单"),children:"✕"}),r]})}):r,s.jsxs("main",{className:"main",children:[s.jsxs(FF,{className:"topbar",children:[s.jsx(B,{variant:"ghost",size:"icon",className:"mobile-menu-btn","aria-label":a("切换菜单"),onClick:()=>t(!e),children:"☰"}),s.jsxs("div",{className:"crumb",children:[s.jsx("span",{children:"Agent2API"}),s.jsx("span",{className:"sep",children:"/"}),s.jsx("span",{className:"cur",id:"crumb-page",children:qF})]}),s.jsx("div",{className:"spacer"}),s.jsx("div",{className:"topbar-actions",id:"topbar-status",title:WF,children:s.jsx(Wve,{})})]}),s.jsx("div",{className:"content",children:s.jsxs("div",{className:"content-inner",children:[["assistant","overview","accounts","checkin","routing","gateway","agent","proxies","keys","docs","logs","tasks","requests","plugins","settings"].map(i=>s.jsx("section",{className:`page${Nx===i?" active":""}`,"data-page":i},i)),s.jsx("section",{className:`page${Nx.startsWith("plugin:")?" active":""}`,"data-page":"__plugin__",id:"plugin-page-host"})]})})]})]})}function Qve(){const e=document.getElementById("desktop-app");if(!e)return;const t=rd().wbSidebarLayout;t&&(N0=t.renderGroups(t.readLayout())),rd().wbShell={sidebar(r){N0=r,br.flushSync(C0)},page(r,i){Nx=r,qF=i,C0()},status(r,i=""){YF=r,WF=i,C0()},theme(r){GF=r,C0()},closeNavigation(){window.dispatchEvent(new Event("wb:navigation-close"))},toast(r,i="ok"){$T.add({id:"desktop-feedback",title:r,type:i==="err"?"error":i==="warn"?"warning":"success",timeout:3500})}},br.flushSync(()=>wn.createRoot(e).render(s.jsx(Xve,{})));const n=document.createElement("div");document.body.append(n),br.flushSync(()=>wn.createRoot(n).render(s.jsx($F,{})))}Qve();const QF="wb-tip-bubble",FT=new WeakSet;let Ir=null,um=!1,Ax=0,A0=0,ZF=0;const UT=new Set,HT=()=>{ZF+=1;for(const e of UT)e()},VT=e=>({text:e.getAttribute("data-tip")?.trim()||"",variant:e.getAttribute("data-tip-variant")});let E0=null;function T0(e){const t=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&t.bottom>0&&t.top{Ir&&!T0(Ir)&&el()})),E0?.observe(e),Ir.classList.add("active"),Ir.setAttribute("aria-describedby",QF),HT())}function Zve(){v.useSyncExternalStore(t=>(UT.add(t),()=>UT.delete(t)),()=>ZF);const e=Ir?VT(Ir):null;return s.jsx(a0,{children:s.jsx(Il,{open:!!Ir,disableHoverablePopup:!0,onOpenChange:t=>{!t&&!um&&el()},children:s.jsx(Ml,{id:QF,anchor:Ir,side:"bottom",variant:e?.variant==="plain"?"plain":"default",className:"pointer-events-none",children:e?.text.split(`
-`).map((t,n)=>{const r=/^\[(#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6})\]/.exec(t);return s.jsxs("span",{className:"flex items-start gap-1.5",children:[r&&s.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{background:r[1]}}),s.jsx("span",{children:r?t.slice(r[0].length):t})]},n)})})})})}function KT(e){FT.has(e)||!VT(e).text||(FT.add(e),e.classList.contains("tip-q")&&!e.textContent?.trim()&&(e.textContent="?"),e.matches("a[href], button, input, select, textarea, [tabindex]")||e.setAttribute("tabindex","0"))}function JF(){const e=document.createElement("div");document.body.append(e),br.flushSync(()=>wn.createRoot(e).render(s.jsx(Zve,{})));const t=o=>{o.matches("[data-tip]")&&KT(o),o.querySelectorAll("[data-tip]").forEach(KT)};t(document.body),new MutationObserver(o=>{Ir&&!T0(Ir)&&el();for(const c of o){c.type==="attributes"&&c.target instanceof Element&&(KT(c.target),c.target===Ir&&HT());for(const d of c.addedNodes)d instanceof Element&&t(d)}}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tip","data-tip-variant"]});const r=o=>o.target instanceof Element?o.target.closest("[data-tip]"):null;document.addEventListener("pointerover",o=>{if(!window.matchMedia("(hover: hover)").matches)return;const c=r(o);!c||o.relatedTarget instanceof Node&&c.contains(o.relatedTarget)||(window.clearTimeout(A0),window.clearTimeout(Ax),Ax=window.setTimeout(()=>O0(c),Ir?0:150))}),document.addEventListener("pointerout",o=>{const c=r(o);!c||o.relatedTarget instanceof Node&&c.contains(o.relatedTarget)||um||(window.clearTimeout(Ax),A0=window.setTimeout(()=>{Ir===c&&!um&&el()},80))}),document.addEventListener("focusin",o=>{const c=r(o);c?.matches(":focus-visible")&&O0(c)}),document.addEventListener("focusout",o=>{r(o)===Ir&&el()}),document.addEventListener("click",o=>{const c=r(o);if(!c){Ir&&el();return}Ir===c&&um?el():(O0(c),um=!0)},!0),document.addEventListener("keydown",o=>{o.key==="Escape"&&Ir&&el()});const i=()=>{Ir&&!T0(Ir)&&el()};window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),window.wbTooltip={open:O0,close:el,enhanced:o=>FT.has(o)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",JF,{once:!0}):JF();const sd=window.workbuddyDesktop;function qT({action:e,maximized:t=!1}){return s.jsx("svg",{viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="minimize"?s.jsx("path",{d:"M5 12h14"}):e==="close"?s.jsx("path",{d:"M6 6l12 12M18 6 6 18"}):t?s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:8.5,y:4.5,width:11,height:11,rx:1.5}),s.jsx("rect",{x:4.5,y:8.5,width:11,height:11,rx:1.5,className:"fill-sidebar"})]}):s.jsx("rect",{x:5.5,y:5.5,width:13,height:13,rx:1.5})})}function Jve({api:e}){const[t,n]=v.useState(!1),r=v.useCallback(async()=>{try{e.windowIsMaximized&&n(await e.windowIsMaximized())}catch{}},[e]);v.useEffect(()=>{r();const d=e.onWindowResize?.(()=>{r()});return typeof d=="function"?d:void 0},[e,r]);const i=e.platform==="macos",o=e.title||a("Agent2API · 多提供商本地网关"),c=window.wbIcons?.icon("brand",16)||"";return s.jsxs(Fve,{className:i?"titlebar is-macos pl-[84px] pr-3.5":"titlebar",children:[s.jsxs("div",{className:"titlebar-brand pointer-events-none flex min-w-0 items-center gap-2 text-[12.5px] font-semibold [&_*]:pointer-events-none",children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:c}}),s.jsx("span",{className:"txt truncate",children:o})]}),!i&&s.jsxs("div",{className:"ml-auto flex h-full shrink-0",children:[s.jsx(BT,{action:"minimize",title:a("最小化"),"aria-label":a("最小化"),onClick:()=>{e.windowMinimize?.().catch(()=>{})},children:s.jsx(qT,{action:"minimize"})}),s.jsx(BT,{action:"maximize",title:a(t?"还原":"最大化"),"aria-label":a(t?"还原":"最大化"),onClick:async()=>{try{await e.windowToggleMaximize?.(),await r()}catch(d){console.warn("切换窗口大小失败:",d)}},children:s.jsx(qT,{action:"maximize",maximized:t})}),s.jsx(BT,{action:"close",title:a("关闭"),"aria-label":a("关闭"),onClick:()=>{e.windowClose?.().catch(()=>{})},children:s.jsx(qT,{action:"close"})})]})]})}function exe(){if(!document.getElementById("desktop-app")||!sd?.platform||sd.platform==="web"||sd.platform!=="macos"&&(!sd.windowMinimize||!sd.windowToggleMaximize||!sd.windowClose))return;const e=document.createElement("div");document.body.prepend(e),document.body.classList.add("has-titlebar"),document.title=sd.title||a("Agent2API · 多提供商本地网关"),wn.createRoot(e).render(s.jsx(Jve,{api:sd}))}exe();const Uc=999;function GT(e){const t=e.resolved||e;if(t.protocol&&t.host&&t.port){const n=t.host.includes(":")&&!t.host.startsWith("[")?`[${t.host}]`:t.host;return`${String(t.protocol).toLowerCase()}://${n}:${t.port}`}return e.resolved?.label||""}function dm(e){const t=e.name||e.id,n=[e.source==="clash"?"Clash Verge":"",e.resolveError?a("解析失败"):GT(e),e.enabled===!1?a("已禁用"):""].filter(Boolean);return n.length?a("{name}({parts})",{name:t,parts:n.join(" · ")}):t}const tl="pool:";function rt(){return window}function vt(e,t){rt().wbApp?.toast?.(e,t)}function nl(e){const t=rt().wbApp?.esc;return t?t(e):String(e??"").replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n]||n)}function ci(e){const t=rt().wbApp?.formatTime;if(t)return t(e);const n=Number(e);return!Number.isFinite(n)||n<=0?"":new Date(n).toLocaleString("zh-CN")}function tn(e){return e instanceof Error?e.message:String(e)}function zn(e){if(e==null||e==="")return"—";const t=Number(e);return Number.isFinite(t)?String(Number(t.toFixed(2))):String(e)}const txe={workbuddy:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!0,identifier:["uid"],expiry:["expiresAt"]},"workbuddy-intl":{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["uid"],expiry:["expiresAt"]},raccoon:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"]},catpaw:{usage:!0,edition:!1,identifier:["uid"],expiry:["tokenExpiresAt"]},autoclaw:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"]},"autoclaw-intl":{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"],emailAsName:!0},qoder:{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"qoder-intl":{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"cline-free":{usage:!0,edition:!1,identifier:["account"],expiry:["expiresAt"]},"cline-pass":{usage:!0,edition:!1,identifier:["account"],expiry:["expiresAt"]},accio:{usage:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"accio-cn":{usage:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},zcode:{usage:!0,creditDetail:!0,claim:!0,planChannel:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"]},"zcode-intl":{usage:!0,creditDetail:!0,claim:!0,planChannel:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"]},codearts:{usage:!0,usageDetail:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"],concurrencyDefault:3},trae:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["uid"],expiry:["expiresAt"]},loomy:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""]},kuku:{usage:!0,edition:!1,identifier:["uid"],expiry:[""]},officeace:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["id"],expiry:["expiresAt"]},antigravity:{usage:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},chatglm:{usage:!0,creditDetail:!0,edition:!1,identifier:["uid"],expiry:[""],longLived:!0},modelscope:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},"modelscope-intl":{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},atomcode:{usage:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"]},commandcode:{usage:!1,edition:!1,identifier:["id"],expiry:[""],longLived:!0},lobsterai:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"]},monkeycode:{usage:!1,edition:!1,identifier:["userId"],expiry:["expiresAt"]},"monkeycode-intl":{usage:!1,edition:!1,identifier:["userId"],expiry:["expiresAt"]},orcaterm:{usage:!0,edition:!1,identifier:["uid"],expiry:["tokenExpireAt"]}},R0={usage:!1,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"],emailAsName:!1};let eU=new Map,tU=null;function nxe(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=new Map;for(const[n,r]of Object.entries(e))!n||!r||typeof r!="object"||Array.isArray(r)||t.set(n,sxe(r));eU=t}function rxe(){const e=rt().wbApp?.getState?.()?.accountFeatures;return e!==tU&&(tU=e,nxe(e)),eU}function sxe(e){return{usage:e.usage===!0,edition:e.edition===!0,identifier:nU(e.identifier,R0.identifier),expiry:nU(e.expiry,R0.expiry),longLived:e.long_lived===!0,emailAsName:e.email_as_name===!0,claim:e.claim===!0,planChannel:e.plan_channel===!0,usageDetail:e.usage_detail===!0,creditDetail:e.credit_detail===!0,creditExpiry:e.credit_expiry===!0,concurrencyDefault:Number(e.concurrency_default)>0?Number(e.concurrency_default):void 0,defaultLimiters:axe(e.default_limiters)}}function nU(e,t){if(typeof e=="string")return e?[e]:[];if(!Array.isArray(e))return t;const n=e.filter(r=>typeof r=="string"&&r.length>0);return n.length?n:[]}function axe(e){if(!Array.isArray(e))return;const t=[];for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;const r=n,i=Number(r.threshold);if(!Number.isFinite(i)||i<=0)continue;const o=r.kind==="token"?"token":r.kind==="balance"?"balance":null;if(!o)continue;const c=r.action==="disable"?"disable":"skip",d=Number(r.period_seconds),f=o==="token"&&Number.isFinite(d)&&d>0;t.push({type:o,action:c,threshold:i,enabled:!0,...f?{period:d,reset:"fixed"}:{},...o==="token"&&!f?{reset:"daily"}:{}})}return t}function Oa(e){if(!e)return R0;const t=rxe().get(e);return t||txe[e]||R0}function ixe(e,t){const n=Pi(e);if(!n)return null;const r=Object.prototype.hasOwnProperty.call(n,"totalLeft"),o=(Array.isArray(n.quotaSources)?n.quotaSources:[]).map(Pi).find(h=>h?.id==="account"),c=String(n.unit||o?.unit||(r?"积分":"")).trim(),d=Ii(r?n.totalLeft:n.available),f=n.unlimited===!0;return d===null&&!f?null:{label:Ex(c)?t("总积分"):t("可用合计"),unit:mo(c,t),remaining:d,unlimited:f}}function Pi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ii(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null}function rU(e){const t=Pi(e);return t?.snapshot===!0||t?.type==="magicubes"}function sU(e){const t=Pi(e);if(!t)return[];const n=Array.isArray(t.credits)?t.credits.filter(i=>Pi(i)):[];return Array.isArray(t.wallets)&&t.wallets.some(i=>Pi(i)?.type==="magicubes")?n.map(i=>{if(i.snapshot===!0||i.record===!0)return i;const{remain:o,...c}=i;switch(i.name){case"可用魔粒":return{...c,key:"available",name:"可用余额",balance:o,unit:"魔粒",snapshot:!0};case"冻结魔粒":return{...c,key:"frozen",name:"冻结余额",balance:o,unit:"魔粒",snapshot:!0};case"今日已用(次)":return{...c,key:"used-today",name:"今日已用",used:i.used??o,unit:"次",daily:!0,snapshot:!0};default:return i}}):n}function Ex(e){return e.trim()==="积分"||e.trim().toLowerCase()==="credits"}function mo(e,t){if(Ex(e))return t("积分");switch(e){case"额度":return t("额度");case"魔粒":return t("魔粒");case"次":return t("次");case"copilot_quota_units":return t("Copilot 额度单位");default:return e}}function aU(e,t){switch(e){case"Premium requests":return t("高级请求");case"Chat requests":return t("对话请求");case"Completions":return t("补全请求");default:return typeof e=="string"?t(e):""}}function iU(e,t,n){const r=typeof e.view=="string"?e.view.trim():"",i=Ii(e.remaining),o=Ii(e.limit),c=Ii(e.remainingPercent),d=typeof e.unit=="string"?mo(e.unit,t):"";return e.unlimited===!0&&(!r||r==="不限")?t("不限"):i!==null&&(!r||/^剩余 [-+\d.eE]+(?: \/ [-+\d.eE]+)?(?: .+)?$/.test(r))?[o===null?t("剩 {remaining}",{remaining:n(i)}):t("剩 {remaining} / {total}",{remaining:n(i),total:n(o)}),d].filter(Boolean).join(" "):c!==null&&(!r||/^剩余 [-+\d.]+%$/.test(r))?t("剩余 {percent}%",{percent:Math.round(Math.max(0,Math.min(100,c)))}):r?t(r):"—"}function oU(e,t,n){if(e.snapshot!==!0)return null;const r=Ii(e.used),i=r??Ii(e.balance)??Ii(e.remain),o=String(e.unit||"").trim(),c=String(e.name||"").trim(),d=c==="可用余额"?t("可用余额"):c==="冻结余额"?t("冻结余额"):c==="今日已用"?t("今日已用"):c==="今日发放"?t("今日发放"):c||t("明细"),f=i===null?"—":o==="次"?t("{count} 次",{count:n(i)}):o?`${n(i)} ${mo(o,t)}`:n(i);return{name:d,view:f,tone:r!==null||e.key==="frozen"||i===null||i<=0?"muted":"ok",daily:e.daily===!0}}function oxe(e,t,n){return sU(e).map(r=>oU(r,t,n)).filter(r=>r!==null)}function lU(e){const t=Pi(e);return!Array.isArray(t?.wallets)||!t.wallets.some(n=>String(Pi(n)?.type||"").startsWith("meter:"))?null:t.wallets.map(Pi).filter(n=>n!==null&&(n.creditRemaining!=null||n.creditTotal!=null||n.creditUsed!=null))}function YT(e,t,n){const r=Pi(e);if(!r)return[];const i=[],o=Pi(r.subscription);typeof o?.planName=="string"&&o.planName.trim()&&i.push(t("套餐 {name}",{name:o.planName})),typeof r.balanceView=="string"&&r.balanceView.trim()&&i.push(t(r.balanceView));for(const c of lU(r)??(Array.isArray(r.wallets)?r.wallets:[])){const d=Pi(c);if(!d)continue;const f=typeof d.balanceView=="string"&&d.balanceView.trim()?t(d.balanceView):Ii(d.balance)===null?"":n(Ii(d.balance));if(!f)continue;const h=typeof d.displayName=="string"?t(d.displayName):typeof d.type=="string"?d.type:t("明细");i.push([h,f].filter(Boolean).join(" "))}return[...new Set(i)]}function P0(e){const t=Pi(e);return Array.isArray(t?.warnings)?t.warnings.filter(n=>typeof n=="string"&&!!n.trim()):[]}let Vf={};function lxe(e){if(!e?.limiterStates)return!1;const t=JSON.stringify([Vf.limiterStates,Vf.quotaSources,Vf.limiterModels])!==JSON.stringify([e.limiterStates,e.quotaSources,e.limiterModels]);return Vf={tokenAt:e.tokenAt,limiterStates:e.limiterStates,quotaSources:e.quotaSources,limiterModels:e.limiterModels},t}function Tx(e,t=[]){return Array.isArray(e?.limiterGroups)?e.limiterGroups:t.map(n=>({enabled:n.enabled!==!1,action:n.action,target:"account",conditions:[{join:"or",sourceId:"",models:[],threshold:n.threshold,metric:n.type==="balance"?"remaining":"tokens",comparison:n.type==="balance"?"lt":"gte",...n.type==="token"?{window:{reset:n.reset==="daily"?"daily":"fixed",seconds:n.period||0}}:{}}]}))}function WT(e){const t=e?Vf.quotaSources?.[e.id]:void 0;return Array.isArray(t)?t.slice():[{id:"account",label:a("账号主额度"),provider:String(e?.provider||"")},{id:"local",label:a("本地用量保护"),provider:String(e?.provider||""),localOnly:!0}]}function cxe(e){const t=String(e?.provider||"");return(Vf.limiterModels?.[t]||[]).map(r=>({value:r.id,label:r.name&&r.name!==r.id?`${r.name}(${r.id})`:r.id}))}function XT(e){return e?Vf.limiterStates?.[e.id]||[]:[]}function Ox(e,t,n="skip"){if(!e)return!1;const r=Tx(e),i=XT(e);return r.some((o,c)=>o.enabled&&o.action===n&&i[c]?.hit&&(!t||o.conditions.some(d=>t==="token"?d.metric==="tokens"||d.metric==="requests":d.metric!=="tokens"&&d.metric!=="requests")))}function QT(e,t=e?.id||"account"){return t==="local"?a("本地用量保护"):t==="account"||!t?Ex(e?.unit||"")?a("总积分"):a("账号主额度"):e?.label?a(e.label):a("账号主额度")}function cU(e){const{remaining:t,total:n,used:r,remainingPercent:i,resetsAt:o,...c}=e;return c}function uU(e,t){const n=e.sourceId||(e.metric==="tokens"||e.metric==="requests"?"local":"account"),r=WT(t).find(p=>p.id===n),i=QT(r||e.source,n),o=e.models.length?e.models.join("、"):a("全部模型"),c=ZT(e.metric),d=e.comparison==="lt"?"<":e.comparison==="lte"?"≤":"≥",f=e.metric.endsWith("percent")?"%":e.metric==="tokens"?"Token":e.metric==="requests"?a("次"):mo(r?.unit||e.source?.unit||"",a),h=e.metric==="tokens"?dU(e.threshold):String(e.threshold);return`${i} · ${o} · ${c} ${d} ${h} ${f}`.trim()}function ZT(e){switch(e){case"remaining":return a("剩余额度");case"remaining_percent":return a("剩余比例");case"used":return a("已用额度");case"used_percent":return a("已用比例");case"tokens":return a("本地 Token 消耗");case"requests":return a("本地请求次数")}}function dU(e){return window.wbUnits?.formatTokens?.(e)||e.toLocaleString()}function uxe(e,t,n){if(!e?.known||e.value===null)return dxe(e?.reason);const r=WT(n).find(d=>d.id===(t.sourceId||"account")),i=mo(r?.unit||t.source?.unit||"",a),o=d=>t.metric==="tokens"?`${dU(d)} Token`:t.metric.endsWith("percent")?`${Number(d.toFixed(2))}%`:`${Number(d.toFixed(2))} ${t.metric==="requests"?a("次"):i}`.trim(),c=Object.entries(e.modelValues||{});return c.length?c.map(([d,f])=>`${d}:${o(f)}`).join(" · "):o(e.value)}function dxe(e){switch(e){case"此额度不属于账号当前使用的通道":return a("此额度不属于账号当前使用的通道");case"套餐尚未生效或已经到期":return a("套餐尚未生效或已经到期");case"上游额度无上限":return a("上游额度无上限");case"统计周期尚未开始或已经结束":return a("统计周期尚未开始或已经结束");default:return a("暂无读数")}}function fxe(e,t){const n=[];return e.forEach((r,i)=>{(i===0||r.join==="or")&&n.push([]),n[n.length-1].push(uU(r,t))}),n.map(r=>r.length>1?`(${r.join(` ${a("与")} `)})`:r[0]).join(` ${a("或")} `)}function I0(e){return e.needsReloginReason?.trim()||a("登录授权已失效,请重新登录;自动续期无法恢复已过期或已撤销的刷新令牌。")}const JT="workbuddy",hxe="raccoon";function In(e){const t=e?.provider;return typeof t=="string"&&t?t:JT}const pxe="opencode",mxe="https://opencode.ai/zen/go/v1";function fU(e,t){if(!e||e.clientEmulation!==pxe)return!1;const r=((typeof t=="string"?t.trim():"")||String(e.baseUrl||"")).trim().replace(/\/+$/,"").toLowerCase();return r?r!==mxe:!1}function gxe(e){const t=e?In(e):"";return t.startsWith("custom-")&&(rt().wbProviders?.customList?.()||[]).find(r=>r?.id===t)||null}function vxe(e){return e?fU(gxe(e),e.baseUrl):!1}function hU(e){const t=Array.isArray(e?.providers)?e.providers:[],n=Array.isArray(e?.accounts)?e.accounts:[],r=new Map;n.forEach(o=>{const c=In(o);r.set(c,(r.get(c)||0)+1)});const i=new Map;return t.forEach(o=>{o?.id&&i.set(String(o.id),{id:String(o.id),label:String(o.label||o.id),count:Number(o.count)||0})}),r.forEach((o,c)=>{i.has(c)||i.set(c,{id:c,label:rt().wbProviders?.labelOf?.(c)||c,count:o})}),[...i.values()]}function M0(e){return bxe(e,Oa(In(e)).identifier)}function xxe(e){for(const t of Oa(In(e)).identifier){const n=e?.[t];if(!(n==null||n===""))return t}return""}function bxe(e,t){for(const n of t){const r=e?.[n];if(!(r==null||r===""))return String(r)}return""}function pU(e){const t=Number(e)||0;return t<=0?0:t<1e11?t*1e3:t}function mU(e){const t=Oa(In(e)).expiry;for(const n of t){const r=pU(e?.[n]);if(r>0)return r}return 0}function ui(e){if(e?.isGuest===!0)return!1;const t=In(e);return t.startsWith("custom-")?!!e?.balanceQuery?.scheme:Oa(t).usage}const eO=30,gU=86400,vU=60,yxe=1800,wxe=86400,xU=1;function jxe(e){const t=e?Oa(e).defaultLimiters:void 0;return t&&(e!=="codearts"||t.every(n=>n.type==="balance"))?t.slice():e==="cline-free"?[]:[{type:"balance",action:"skip",threshold:xU,enabled:!0}]}function bU(e){const t=e?.usageQuery;if(!t||typeof t!="object")return{enabled:!0,interval:vU};const n=t.enabled===void 0?!0:t.enabled===!0,r=Number(t.interval)||0,i=r>=eO&&r<=gU;return{enabled:n,interval:n&&!i?vU:r}}function Sxe(e){if(!e||typeof e!="object")return!1;const t=e;if(t.type!=="balance"&&t.type!=="token"||t.action!=="skip"&&t.action!=="disable")return!1;const n=Number(t.threshold);if(!Number.isFinite(n)||n<=0)return!1;if(t.type==="token"&&t.reset!=="daily"){const r=Number(t.period);if(!Number.isInteger(r)||rwxe)return!1}return!0}function kxe(e){const t=e?.lowBalance;if(!t||typeof t!="object"||!t.mode)return jxe(In(e));const n=Number(t.threshold),r=Number.isFinite(n)&&n>0?n:xU;return t.mode!=="skip"&&t.mode!=="disable"?[]:[{type:"balance",action:t.mode,threshold:r,enabled:!0}]}function Kf(e){const t=e?.limiters;return Array.isArray(t)?t.filter(Sxe):kxe(e)}function Nxe(e){return Kf(e).filter(t=>t.type==="token")}function Cxe(e,t){const n=t*1e3;return e-e%n}function yU(e){return e.reset==="daily"?0:e.period??0}function tO(e,t=Date.now()){if(e===0){const n=new Date(t);return n.setHours(0,0,0,0),n.getTime()}return Cxe(t,e)}function nO(e,t,n=Date.now()){if(e.type!=="token")return null;const r=yU(e),i=(t||[]).find(o=>Number(o.kind)===r);return i&&Number(i.windowStart)===tO(r,n)?i:null}function rO(e,t){if(Array.isArray(e?.limiterGroups))return Ox(e,"balance");const n=Kf(e).filter(c=>c.type==="balance"&&c.action==="skip"&&c.enabled!==!1&&c.threshold>0);if(!n.length||!t||typeof t!="object")return!1;const r=t;if(r.unlimited)return!1;const i=r.totalLeft??r.available;if(i==null||i==="")return!1;const o=Number(i);return Number.isFinite(o)&&n.some(c=>oi.type==="token"&&i.action==="skip"&&i.enabled!==!1);if(!n.length||!t?.length)return!1;const r=Date.now();return n.some(i=>{const o=nO(i,t,r);return o!==null&&Number(o.used)>=i.threshold})}function Axe(e,t){return Array.isArray(e?.limiterGroups)?Ox(e,"token","disable"):Kf(e).some(n=>{if(n.type!=="token"||n.action!=="disable"||n.enabled===!1)return!1;const r=nO(n,t);return r!==null&&Number(r.used)>=n.threshold})}function Exe(e,t=Date.now()){const n=yU(e),r=tO(n,t),i=n===0?Math.max(0,tO(0,r+864e5+36e5)-t):Math.max(0,r+n*1e3-t);return{kind:n,startMs:r,remainingMs:i,daily:n===0}}function wU(e,t){if(e<=0)return"";const n=Math.ceil(e/6e4);if(t){const r=Math.ceil(e/36e5);return r>=1?a("今日剩 {n} 小时",{n:r}):a("今日剩 {n} 分钟",{n})}return n>=1?a("剩 {n} 分钟",{n}):a("剩不到 1 分钟")}function jU(e){const t=Number(e);if(!Number.isFinite(t))return"—";const n=window.wbUnits;return n?.formatTokens?n.formatTokens(t):String(Math.round(t))}function Txe(e){return e>0&&e%3600===0?a("{n} 小时",{n:e/3600}):e>0&&e%60===0?a("{n} 分钟",{n:e/60}):a("{n} 秒",{n:e})}function Rx(e){return e?.desktop===!0}function SU(e){return e?.chatSupported!==!1}function Oxe(e){return typeof e=="string"&&e.startsWith("custom-")}function Rxe(e){return a(e==="enterprise"?"企业":e==="ultimate"?"旗舰":"个人")}function _0(e,t){const n=Number(e?.priority??100)-Number(t?.priority??100);return n!==0?n:(Number(e?.addedAt)||0)-(Number(t?.addedAt)||0)}function Ka(e){return e?.enabled!==!1}function Px(e,t=""){const n=e?.rateLimits||{},r=Date.now();return t?Number(n[t]?.resetAt)>r:Object.values(n).some(i=>Number(i?.resetAt)>r)}function kU(e){return e?.edition==="intl"?"intl":"cn"}const NU="coding-plan",qf="start-plan";function D0(e){return!!Oa(In(e)).planChannel}function aO(e){return D0(e)?String(e?.zcodePlan||"").trim()===qf?qf:NU:""}function Pxe(e){return a(e===qf?"套餐池(Start Plan)":"编码套餐(Coding Plan)")}function CU(e){switch(String(e??"").trim()){case"pending":return a("待生效");case"active":return a("生效中");case"expired":return a("已过期");case"unknown":return a("状态未知");default:return String(e??"")}}function Ixe(e){const t=e?.claimPlans;if(!t||typeof t!="object"||Array.isArray(t))return[];const n=OU();return Object.entries(t).filter(([,r])=>Number(r)>0&&OU(Number(r))===n).map(([r])=>r)}function Mxe(e){return!!Oa(In(e)).usageDetail}function AU(e){return!!Oa(In(e)).creditDetail}function EU(e,t=Date.now()){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e,r=Array.isArray(n.credits)?n.credits:[];let i=null;for(const o of r){if(!o||typeof o!="object"||o.snapshot===!0||o.record===!0||o.daily===!0||o.unlimited===!0)continue;const c=Number(o.expireAt);if(!Number.isFinite(c)||c<=0||c<=t)continue;const d=o.remain;d!=null&&d!==""&&Number(d)<=0||(i===null||cString(i||"").toLowerCase().includes(n)):!0}function PU(e,t){return t.provider==="all"||In(e)===t.provider}function lO(e,t){return t.enabled==="all"?!0:t.enabled==="enabled"?Ka(e):!Ka(e)}function IU(e,t,n,r){if(t.limit==="all")return!0;if(!Ka(e))return!1;const i=Ix(e,n?.(e),r?.(e));return t.limit==="limited"?i:!i}function MU(e,t,n,r){return PU(e,t)&&lO(e,t)&&IU(e,t,n,r)&&RU(e,t)}function _xe(e,t,n,r){return(e||[]).filter(i=>MU(i,t,n,r))}function _U(e,t,n,r){const i=e||[],o=f=>i.filter(h=>PU(h,t)&&(f==="enabled"||lO(h,t))&&RU(h,t)),c=o("enabled"),d=o("limit");return{enabledAll:c.length,enabled:c.filter(Ka).length,disabled:c.filter(f=>!Ka(f)).length,limitAll:d.length,normal:d.filter(f=>Ka(f)&&!Ix(f,n?.(f),r?.(f))).length,limited:d.filter(f=>Ka(f)&&Ix(f,n?.(f),r?.(f))).length}}function cO(e){const t=e?.rateLimits;if(!t||typeof t!="object")return[];const n=Date.now();return Object.entries(t).map(([r,i])=>({model:r,...i&&typeof i=="object"?i:{}})).filter(r=>Number(r.resetAt)>n).sort((r,i)=>Number(r.resetAt)-Number(i.resetAt))}function uO(e,t){const n=new Map((t?.providerOrder||[]).flatMap(o=>t?.accountOrder[o]||[]).map((o,c)=>[o,c])),r=(e||[]).slice().sort(n.size?(o,c)=>(n.get(o.id)??1/0)-(n.get(c.id)??1/0):_0),i=new Map;return r.forEach((o,c)=>i.set(o.id,{position:c+1,total:r.length})),i}function DU(e){return[{key:"credit",on:iO(e),dir:"soon"},{key:"added",on:!1,dir:"new"}]}function Dxe(e,t,n,r=Date.now()){const i=(t||[]).filter(d=>d.on);if(!i.length)return e.slice();const o=e.map((d,f)=>({account:d,index:f})),c=new Map;for(const{account:d}of o)c.set(d.id,EU(n?.(d),r));return o.sort((d,f)=>{for(const h of i){const p=h.key==="added"?Lxe(h.dir,d.account,f.account):zxe(h.dir,c.get(d.account.id)??null,c.get(f.account.id)??null);if(p!==0)return p}return d.index-f.index}),o.map(d=>d.account)}function Lxe(e,t,n){const r=Number(t.addedAt)||0,i=Number(n.addedAt)||0;return e==="new"?i-r:r-i}function zxe(e,t,n){return t===null&&n===null?0:t===null?1:n===null?-1:e==="soon"?t-n:n-t}function $xe(e,t,n,r,i,o){const c=(e||[]).slice().sort(_0),d=[],f=new Map;for(const h of c){const p=In(h);f.has(p)||(f.set(p,[]),d.push(p)),f.get(p).push(h)}if(o){const h=new Map(o.providerOrder.map((p,g)=>[p,g]));d.sort((p,g)=>(h.get(p)??1/0)-(h.get(g)??1/0))}return d.map((h,p)=>{const g=f.get(h)||[],x=o?.accountOrder[h],y=new Map((x||[]).map((w,S)=>[w,S])),j=x?g.slice().sort((w,S)=>(y.get(w.id)??1/0)-(y.get(S.id)??1/0)):i?Dxe(g,i(h),n):g;return{provider:h,label:rt().wbProviders?.labelOf?.(h)||h,rank:o?.providerOrder.includes(h)?o.providerOrder.indexOf(h)+1:p+1,members:j,queueMembers:g,accounts:t?j.filter(t):j,enabled:j.filter(Ka).length,disabled:j.filter(w=>!Ka(w)).length,limited:j.filter(w=>Ka(w)&&Ix(w,n?.(w),r?.(w))).length}})}function go(e){if(!e)return"";const t=String(e.name||"").trim();if(e.nameCustom===!0&&t)return t;const n=String(e.email||"").trim();return Oa(In(e)).emailAsName&&n?n:e?.nickname||t||M0(e)||e?.id||""}const dO="已限流",LU=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function fO(e){const t=Number(e);if(!Number.isFinite(t)||t<=0||t<=Date.now())return dO;const n=new Date(t),r=n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}),i=Math.round((LU(n)-LU(new Date))/864e5);return i===0?a("今天 {clock}",{clock:r}):i===1?a("明天 {clock}",{clock:r}):a("{month}月{day}日 {clock}",{month:n.getMonth()+1,day:n.getDate(),clock:r})}function Bxe(e){const t=In(e);if(!Oa(t).edition)return"";const n=kU(e),r=e?.editionLabel,i=r||(n==="intl"?"国际版":"国内版");return(rt().wbProviders?.labelOf?.(t)||"").includes(i)?"":r||a(n==="intl"?"国际版":"国内版")}function Fxe(e){return[e.needsRelogin?{text:a("需要重新登录"),kind:"bad",title:I0(e)}:null,SU(e)?null:{text:a("仅账号管理"),kind:"plain",title:a("该提供商的推理转发尚未接入,账号不参与转发")},Oxe(In(e))&&e.hasCredentials===!1?{text:a("未配置凭证"),kind:"bad",title:a("这条自定义账号既没有 API Key,也没有勾选「无需鉴权」:转发时会被跳过,该提供商下的模型也不会出现在模型列表里。去账号「设置」里补上 Key,或勾选「该上游无需鉴权」")}:null,e.proxy?.error?{text:a("代理异常"),kind:"bad",title:a("{error}(转发时会回退直连)",{error:e.proxy.error})}:null,aO(e)===qf?{text:a("套餐池"),kind:"plain",title:a("转发走套餐池(Start Plan)通道(zcode.z.ai 的 Anthropic 端点,用账号里的体验额度 / 活动领取额度);在账号设置里可切回编码套餐")}:null].filter(t=>t!==null)}const zU="workbuddy-desktop-accounts-filters",$U="workbuddy-desktop-accounts-collapsed",hO="workbuddy-desktop-accounts-names-hidden",pO="workbuddy-desktop-accounts-group-total-filtered",Uxe="workbuddy-desktop-accounts-group-sort";function Hxe(){try{const e=JSON.parse(localStorage.getItem(Uxe)||"{}");if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e)){if(!Array.isArray(r))continue;const i=[];for(const o of r){if(!o||typeof o!="object")continue;const c=o;c.key==="credit"?i.push({key:"credit",on:c.on!==!1,dir:c.dir==="late"?"late":"soon"}):c.key==="added"&&i.push({key:"added",on:c.on!==!1,dir:c.dir==="old"?"old":"new"})}i.length&&(t[n]=i)}return t}catch{return{}}}function Vxe(){const e={provider:"all",enabled:"all",limit:"all",q:""},t=rt().wbFilterMemory?.load(zU,e)||e;return{provider:String(t.provider||"all"),enabled:String(t.enabled||"all"),limit:String(t.limit||"all"),q:""}}function Kxe(){try{const e=JSON.parse(localStorage.getItem($U)||"[]");return new Set(Array.isArray(e)?e.map(t=>String(t)).filter(Boolean):[])}catch{return new Set}}function BU(){return UU()}function FU(){return mO()}function UU(){try{return localStorage.getItem(hO)==="1"}catch{return!1}}function mO(){try{return localStorage.getItem(pO)==="1"}catch{return!1}}let Kn={version:0,listBusy:!1,listError:"",filter:Vxe(),collapsed:Kxe(),selected:new Set,connections:new Map,dialog:null,namesHidden:UU(),usageBusy:!1,usageInflight:new Set,groupTotalFiltered:mO(),groupSort:Hxe(),sorting:null,sortBusy:!1};const gO=new Set;function Mx(e){return gO.add(e),()=>{gO.delete(e)}}function qn(){return Kn}function Gn(e){Kn={...Kn,...e,version:Kn.version+1},gO.forEach(t=>t())}function Mi(){Gn({})}function ad(){return rt().wbApp?.getState?.()?.accounts}function Bl(){const e=ad()?.accounts;return Array.isArray(e)?e:[]}function qxe(){const e=ad()?.hiddenAccounts,t=e?.byProvider,n={};if(t&&typeof t=="object"&&!Array.isArray(t))for(const[c,d]of Object.entries(t)){const f=Number(d);Number.isFinite(f)&&f>0&&(n[c]=f)}const r=new Map;for(const c of Array.isArray(e?.providers)?e.providers:[]){if(!c||typeof c.id!="string"||!c.id)continue;const d=c.reason==="not_installed"||c.reason==="pack_disabled"||c.reason==="provider_disabled"?c.reason:"not_loaded";r.set(c.id,{id:c.id,label:typeof c.label=="string"&&c.label?c.label:c.id,count:Number(c.count)||0,reason:d})}const i=Object.entries(n).map(([c,d])=>{const f=r.get(c);return{id:c,count:d,label:f?.label||rt().wbProviders?.labelOf?.(c)||c,reason:f?.reason||"not_loaded"}}).sort((c,d)=>d.count-c.count),o=Number(e?.total);return{total:Number.isFinite(o)&&o>0?o:0,byProvider:n,providers:i}}function Fl(e){return Bl().find(t=>t.id===e)||null}function Gxe(e,t){const n=$xe(Bl(),i=>MU(i,Kn.filter,e,t),e,t,Hc,Kn.sorting||ad()?.sorting);return{groups:n.filter(i=>i.accounts.length>0),allGroups:n}}function Hc(e){const n=Kn.sorting?.rules[e]||ad()?.sorting?.rules[e]||Kn.groupSort[e];if(n){const r=n.map(i=>({...i}));return[...r,...DU(e).filter(i=>!r.some(o=>o.key===i.key)).map(i=>({...i,on:!1}))]}return DU(e)}function Yxe(e){return Object.prototype.hasOwnProperty.call(Kn.sorting?.configured||Kn.groupSort,e)}function HU(){return hU(ad())}function Wxe(e,t){return _U(Bl(),Kn.filter,e,t)}function Xxe(){return uO(Bl(),Kn.sorting||ad()?.sorting)}function L0(){rt().wbFilterMemory?.save(zU,{provider:Kn.filter.provider,enabled:Kn.filter.enabled,limit:Kn.filter.limit})}function Qxe(e){Kn.filter.q!==e&&Gn({filter:{...Kn.filter,q:e}})}function Zxe(e){const t=e||"all";Kn.filter.provider!==t&&(Gn({filter:{...Kn.filter,provider:t}}),L0())}function VU(e,t){const n={...Kn.filter,[e]:t};n.enabled==="disabled"&&n.limit!=="all"&&(n.limit="all"),Gn({filter:n}),L0()}function KU(){return Kn.filter.provider!=="all"||Kn.filter.enabled!=="all"||Kn.filter.limit!=="all"||Kn.filter.q.trim()!==""}function vO(){Gn({filter:{provider:"all",enabled:"all",limit:"all",q:""}}),L0()}function Jxe(){const e=Kn.filter.provider;e!=="all"&&(HU().some(t=>t.id===e)||(Gn({filter:{...Kn.filter,provider:"all"}}),L0()))}function qU(e){try{localStorage.setItem($U,JSON.stringify([...e]))}catch{}}function xO(e){const t=new Set(Kn.collapsed);t.has(e)?t.delete(e):t.add(e),qU(t),Gn({collapsed:t})}function ebe(e,t){const n=new Set(Kn.collapsed);for(const r of e)t?n.add(r):n.delete(r);qU(n),Gn({collapsed:n})}function tbe(e){return Kn.selected.has(e)}function nbe(e,t){const n=new Set(Kn.selected);t?n.add(e):n.delete(e),Gn({selected:n})}function GU(e,t){const n=new Set(Kn.selected);for(const r of e)t?n.add(r):n.delete(r);Gn({selected:n})}function rbe(){Gn({selected:new Set})}function sbe(){const e=!Kn.namesHidden;try{localStorage.setItem(hO,e?"1":"0")}catch{}Gn({namesHidden:e})}function abe(e){try{localStorage.setItem(hO,e?"1":"0")}catch{}Gn({namesHidden:e})}function ibe(){const e=mO();e!==Kn.groupTotalFiltered&&Gn({groupTotalFiltered:e})}function obe(e){try{localStorage.setItem(pO,e?"1":"0")}catch{}Gn({groupTotalFiltered:e})}function lbe(e){return"*".repeat(Math.min(Math.max(e.length,4),12))}let Ul=null,z0=null,bO=0,_x=null,fm=0,YU=!1,yO=null;function WU(e){return e.map(t=>[t.id,t.name||"",t.enabled===!1?0:1,t.protocol||"",t.host||"",t.resolved?.protocol||"",t.resolved?.host||"",t.resolved?.port??"",t.port??"",t.resolveError??"",t.usedBy?.length??0,t.usedByServices?.join(",")??""].join(":")).join("|")}function XU(e){return yO!==null&&WU(e)===yO}function QU(e){yO=WU(e)}const wO=new Set;function cbe(e){return wO.add(e),()=>{wO.delete(e)}}function $0(){wO.forEach(e=>e())}function ZU(){return Ul}function ube(){return _x}function JU(e){Array.isArray(e)&&(Ul=e,bO+=1,_x=null,fm=0,!XU(e)&&(QU(e),$0()))}async function jO(e={}){if(!e.force&&Ul)return Ul;const t=bO;z0||(z0=(async()=>{try{const o=await rt().workbuddyDesktop?.getProxyPool?.();if(!o||typeof o!="object"||!Array.isArray(o.items))throw new Error(a("代理池响应异常({type})",{type:typeof o}));return{items:o.items}}finally{z0=null}})());const r=(await z0).items,i=bO===t||Ul===null;return _x=null,!i&&Ul||(Ul=r,XU(r)||(QU(r),$0())),Ul}function dbe(){if(!(Ul||Date.now(){fm=0}).catch(e=>{_x=e instanceof Error?e.message:String(e),$0()})}}async function eH(){fm=0;try{await jO({force:!0})}catch(e){_x=e instanceof Error?e.message:String(e),$0()}}let tH=!1;function nH(){if(tH)return;const e=rt().wbApp;if(!e?.getRefreshStatus||!e.subscribeRefresh)return;tH=!0;const t=e.getRefreshStatus,n=()=>{const r=t(),i=qn();i.listBusy===r.pending&&i.listError===r.error||Gn({listBusy:r.pending,listError:r.error})};e.subscribeRefresh(n),n()}async function rH(e={}){nH();try{const t=rt().wbApp?.refresh;if(!t)throw new Error(a("账号列表刷新不可用,请重新打开页面"));const n=await t();return n&&rt().wbProviders?.refreshCustom?.(),e.feedback&&(n?vt(a("账号列表已刷新")):vt(a("刷新账号列表失败:{message}",{message:qn().listError||a("请求失败")}),"err")),n}catch(t){const n=tn(t);return Gn({listBusy:!1,listError:n}),e.feedback&&vt(a("刷新账号列表失败:{message}",{message:n}),"err"),!1}}const SO="workbuddy-desktop-accounts-group-sort";let B0=null,kO="",sH=0,aH,iH=0,oH="";function id(e){if(!e?.rules||!e.configured||!e.accountOrder||!Array.isArray(e.providerOrder)||e.updatedAth&&typeof h.on=="boolean"&&(h.key==="credit"&&(h.dir==="soon"||h.dir==="late")||h.key==="added"&&(h.dir==="new"||h.dir==="old"))).length!==d.length)){if(!qn().sorting?.rules[c]){i[c]=d;continue}id(await e.saveAccountSorting({provider:c,rules:d,onlyIfUnset:!0}))}const o=Object.keys(i).length===0;return o?localStorage.removeItem(SO):localStorage.setItem(SO,JSON.stringify(i)),o}function lH(){const e=ad()?.sorting;e&&e!==aH&&!qn().sortBusy&&(aH=e,id(e));const t=JSON.stringify(qn().sorting?.providerOrder||[]);qn().sortBusy||!B0&&qn().sorting&&kO!==t&&Date.now()>=sH&&(kO=t,B0=fbe().then(n=>{n||(B0=null)}).catch(n=>{B0=null,kO="",sH=Date.now()+6e4,vt(a("排序设置迁移失败:{message}",{message:tn(n)}),"err")}))}async function hbe(){const e=rt().workbuddyDesktop;if(!(!e?.getAccountSorting||qn().sortBusy))try{id(await e.getAccountSorting())}catch(t){vt(a("读取消耗排序失败:{message}",{message:tn(t)}),"err")}}async function cH(e,t){if(!e||qn().sortBusy)return;const n=rt().workbuddyDesktop;if(!n?.saveAccountSorting){vt(a("账号排序接口不可用,请确认网关与界面已更新"),"err");return}Gn({sortBusy:!0});try{id(await n.saveAccountSorting({provider:e,rules:t}));try{await rt().wbApp?.refresh?.()}catch(r){vt(a("排序已保存,但列表刷新失败:{message}",{message:tn(r)}),"err")}}catch(r){vt(a("排序未保存:{message}",{message:tn(r)}),"err")}finally{Gn({sortBusy:!1})}}function hm(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function od(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((i,o)=>od(i,t[o]));const n=hm(e),r=hm(t);return!!(n&&r&&Object.keys(n).length===Object.keys(r).length&&Object.entries(n).every(([i,o])=>Object.hasOwn(r,i)&&od(o,r[i])))}function uH(e){return e?{reset:e.reset||"fixed",seconds:e.seconds||0,startsAt:e.startsAt||0,endsAt:e.endsAt||0,utcOffsetMinutes:e.utcOffsetMinutes??null}:null}function pbe(e){return e?{id:e.id,label:e.label,provider:e.provider||"",channel:e.channel||"",planId:e.planId||"",planName:e.planName||"",models:e.models||[],unit:e.unit||"",remaining:null,total:null,used:null,remainingPercent:null,startsAt:e.startsAt||0,endsAt:e.endsAt||0,resetsAt:0,window:uH(e.window),unlimited:e.unlimited===!0,localEstimate:e.localEstimate===!0,localOnly:e.localOnly===!0}:null}function pm(e){return e.map(t=>({enabled:t.enabled!==!1,action:t.action||"skip",target:t.target||"models",conditions:t.conditions.map((n,r)=>({join:r===0?"or":n.join||"or",sourceId:n.sourceId.trim(),source:pbe(n.source),models:[...new Set(n.models.map(i=>i.trim()).filter(Boolean))].sort(),metric:n.metric,comparison:n.comparison,threshold:n.threshold,window:uH(n.window)}))}))}function dH(e,t){return Object.entries(t).every(([n,r])=>{if(n==="proxy"){const i=e.proxy?.config||e.proxy;if(r===null)return!i||i.source==="direct";const o=hm(r),c=hm(i);return!!(o&&c&&Object.entries(o).every(([d,f])=>od(f,c[d])))}if(n==="maxConcurrent"){const i=Number(r),o=e.provider==="codearts"?i===0?3:Math.min(i,64):i;return e.maxConcurrent===o}if(n==="limiterGroups")return Array.isArray(r)&&Array.isArray(e.limiterGroups)&&od(pm(e.limiterGroups),pm(r));if(n==="balanceToken")return e.hasBalanceToken===(r!==null&&r!=="");if(n==="apiKey")return e.hasApiKey===(r!==null&&r!=="");if(n==="balanceQuery"){const i=hm(r),o=hm(e.balanceQuery);return!!(i&&o&&Object.entries(i).every(([c,d])=>{const h={accessToken:"hasAccessToken",password:"hasPassword",token:"hasToken"}[c];return h?o[h]===(d!==null&&d!==""):od(o[c],d)}))}return od(e[n],r)})}async function mm(e,t){const n=rt().workbuddyDesktop;if(!n?.updateAccount)throw new Error(a("账号更新接口不可用,请重新打开页面"));const i=(await n.updateAccount(e,t))?.account,o=rt().wbApp?.getState?.()?.accounts?.accounts?.find(c=>c.id===e);if(!i||i.id!==e||o&&i.provider!==o.provider||!dH(i,t))throw new Error(a("账号更新结果未确认,请刷新后核对设置"));return i}function mbe(e){switch(e.action){case"enable":return{enabled:!0};case"disable":return{enabled:!1};case"proxy":return{proxy:e.proxy};case"concurrency":return{maxConcurrent:e.maxConcurrent};case"usageQuery":return{usageQuery:e.usageQuery};default:return{}}}function fH(e,t){if(!e||!Array.isArray(t.action==="remove"?e.removed:e.ok))throw new Error(a("批量操作未返回结果,请刷新后确认状态"));const n=t.action==="remove"?e.removed||[]:e.ok||[],r=new Set(t.ids),i=new Set;if([...n,...e.failed||[],...e.skipped||[]].some(f=>!f.id||!r.has(f.id)||i.has(f.id)?!0:(i.add(f.id),!1))||i.size!==r.size)throw new Error(a("批量操作结果不完整,请刷新后核对所选账号"));const c=e.list?.accounts;if(!Array.isArray(c))throw new Error(a("批量操作结果不完整,请刷新后核对所选账号"));const d=mbe(t);if(n.some(f=>{const h=c.find(g=>g.id===f.id);if(t.action==="remove")return!!h;if(!h||!dH(h,d))return!0;if(t.action!=="limiters")return!1;const p=h.limiterGroups;if(!Array.isArray(p))return!0;switch(t.limiterMode){case"append":return pm(t.limiterGroups||[]).some(g=>!pm(p).some(x=>od(x,g)));case"replace":return!od(pm(p),pm(t.limiterGroups||[]));case"enable":return p.some(g=>g.enabled!==!0);case"disable":return p.some(g=>g.enabled!==!1);case"clear":return p.length!==0;default:return!0}}))throw new Error(a("批量操作结果未确认,请刷新后核对设置"));return e}async function Vc(){const e=rt().wbApp;if(!e?.refresh)throw new Error(a("账号列表刷新接口不可用,请重新打开页面"));if(await e.refresh()!==!0)throw new Error(e.getRefreshStatus?.().error||a("账号列表刷新失败"))}const hH="usage_not_configured";function NO(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Gf(e){const t=Number(e);return Number.isFinite(t)&&t>0&&t<=864e13?t:0}function pH(e,t){if(!e.error)return{...e,lastUsage:null,lastSuccessAt:Gf(e.lastSuccessAt)||Gf(e.at)};const n=Object.prototype.hasOwnProperty.call(e,"lastUsage"),r=NO(n?e.lastUsage:t?.error?t.lastUsage:t?.usage),i=n?Gf(e.lastSuccessAt):Gf(e.lastSuccessAt)||Gf(t?.lastSuccessAt)||(t?.error?0:Gf(t?.at));return{...e,usage:null,lastUsage:r,lastSuccessAt:r?i:0}}function mH(e,t,n){const r=Math.max(0,n-e);return r<1e4?t("刚刚更新"):r<6e4?t("{n} 秒前更新",{n:Math.floor(r/1e3)}):r<36e5?t("{n} 分钟前更新",{n:Math.floor(r/6e4)}):r<864e5?t("{n} 小时前更新",{n:Math.floor(r/36e5)}):t("{n} 天前更新",{n:Math.floor(r/864e5)})}function gbe(e,t,n,r=Date.now()){if(!e.error||e.code===hH)return null;const i=NO(e.lastUsage)?Gf(e.lastSuccessAt):0,o=i?`${t("更新失败")} · ${mH(i,t,r)}`:t("查询失败"),c=i?n(i):"";return{text:o,detail:[t(e.error),c?t("上次成功查询:{time}",{time:c}):""].filter(Boolean).join(`
-`)}}const CO=hH,gm=new Map,Yf=new Map,vbe=()=>gm;function Wf(e){return e==null?null:typeof e=="string"?{message:e,notConfigured:!1}:e.error?{message:String(e.error),notConfigured:e.code===CO}:null}function AO(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function gH(e){Yf.set(e.id,e),gm.set(e.id,e.error?{error:e.error,code:e.code,lastUsage:e.lastUsage,lastSuccessAt:e.lastSuccessAt}:e.usage??void 0)}function Hl(e,t,n){if(t==null){gm.set(e,t);return}const r=Wf(t),i=r?{id:e,error:r.message,code:r.notConfigured?CO:null,at:n}:{id:e,usage:AO(t),error:null,at:n,lastSuccessAt:n};gH(pH(i,Yf.get(e)))}function vH(e,t){const n=String(e.id||"");if(!n)return!1;const r={id:n,usage:AO(e.usage),error:e.error?String(e.error):e.usage?null:a("余额响应为空"),code:typeof e.code=="string"||typeof e.code=="number"?e.code:null,at:Number(e.at)||t};Object.prototype.hasOwnProperty.call(e,"lastSuccessAt")&&(r.lastSuccessAt=Number(e.lastSuccessAt)||0),Object.prototype.hasOwnProperty.call(e,"lastUsage")&&(r.lastUsage=AO(e.lastUsage));const i=Yf.get(n);return i&&Number(i.at)>Number(r.at)?!1:(gH(pH(r,i)),!0)}function vo(e){if(e.isGuest===!0)return;const t=gm.get(e.id);if(!Wf(t))return t;const n=Yf.get(e.id),r=Math.max(Number(e.addedAt)||0,Number(e.updatedAt)||0);return(n?.at||0)>=r?t:n?.lastUsage??void 0}function xbe(e){const n=Yf.get(e.id)?.lastSuccessAt??0;return Number.isFinite(n)&&n>0&&n<=864e13?n:0}function bbe(e){const t=Wf(vo(e));if(!t||t.notConfigured)return null;const n=Yf.get(e.id);return n?gbe(n,a,ci):null}function ybe(e){let t=!1;for(const n of gm.keys())e.has(n)||(gm.delete(n),Yf.delete(n),t=!0);return t}const Dx=new Map;let xH=0,bH=0,yH=!1;function Xf(e){return e?Dx.get(e.id)||[]:[]}function wbe(e){const t=Number(e?.tokenAt)||0;if(!t||t===xH)return!1;const n=e?.tokenUsage;if(!n||typeof n!="object")return!1;xH=t;const r=new Map;for(const[o,c]of Object.entries(n)){if(!Array.isArray(c))continue;const d=[];for(const f of c){if(!f||typeof f!="object")continue;const h=Number(f.kind),p=Number(f.windowStart),g=Number(f.used);!Number.isFinite(h)||h<0||!Number.isFinite(p)||p<=0||!Number.isFinite(g)||g<0||d.push({kind:h,windowStart:p,used:g})}r.set(o,d)}const i=r.size!==Dx.size||[...r].some(([o,c])=>{const d=Dx.get(o);return!d||d.length!==c.length||c.some((f,h)=>f.used!==d[h]?.used||f.windowStart!==d[h]?.windowStart)});Dx.clear();for(const[o,c]of r)Dx.set(o,c);return i}function EO(){return Bl().filter(e=>ui(e)&&e.available!==!1)}function wH(e){const t=Array.isArray(e?.results)?e.results:[],n=Number(e?.at)||Date.now();let r=0;for(const i of t)i&&vH(i,n)&&r++;return r&&(Mi(),rt().wbApp?.renderTopbarStatus?.()),r}function jbe(e){if(!AU(e)||e.needsRelogin)return!1;const t=vo(e);return!t||typeof t!="object"||Array.isArray(t)||Wf(t)?!1:!Array.isArray(t.credits)}async function Sbe(){if(!yH){yH=!0;for(const e of Bl().filter(jbe))try{await zx(e.id)}catch(t){Hl(e.id,a("查询失败:{message}",{message:tn(t)}),Date.now()),Mi()}}}async function Lx(){try{const e=await rt().workbuddyDesktop?.getBalancesSnapshot?.(),t=lxe(e),n=!qn().sortBusy&&id(e?.sorting),r=wbe(e)||t||n;r&&(Mi(),rt().wbApp?.renderTopbarStatus?.());const i=Number(e?.at)||0;return!i||i===bH||(bH=i,!wH(e))?r:(Sbe(),!0)}catch{return!1}}async function zx(e){const t=await rt().workbuddyDesktop?.getAllBalances?.(e||void 0);await hbe();const n=Array.isArray(t?.results)?t.results:[],r=Date.now(),i=new Set;for(const o of n){if(!o?.id)continue;const c=String(o.id);e&&c!==e||(o.code==="refresh_token_expired"&&rt().wbApp?.refresh?.(),i.add(c),vH(o,r))}if(e)return i.has(e)||Hl(e,a("未返回余额数据"),r),Mi(),t;for(const o of EO())i.has(o.id)||Hl(o.id,a("未返回余额数据"),r);return Mi(),t}async function jH(){if(qn().usageBusy)return;const e=EO();if(!e.length){vt(a("暂无可查询余额的账号"),"err");return}Gn({usageBusy:!0}),e.forEach(t=>Hl(t.id,null,Date.now())),Mi();try{const t=(await zx(null))?.results||[],n=t.filter(c=>c.usage&&!c.error).length,r=t.filter(c=>c.code===CO).length,i=r?a("({n} 个未配置查询凭证)",{n:r}):"",o=t.length-n-r;vt(n+r===t.length?a("✅ 已更新 {n} 个账号的余额{suffix}",{n,suffix:i}):a("已更新 {ok}/{total} 个账号,{failed} 个失败",{ok:n,total:t.length,failed:o}),o?"err":"ok")}catch(t){const n=tn(t);e.forEach(r=>Hl(r.id,a("查询失败:{message}",{message:n}),Date.now())),Mi(),vt(a("余额查询失败:{message}",{message:n}),"err")}finally{Gn({usageBusy:!1})}}async function SH(e){if(qn().usageInflight.has(e))return;const t=new Set(qn().usageInflight);t.add(e),Hl(e,null,Date.now()),Gn({usageInflight:t});try{await zx(e)}finally{const n=new Set(qn().usageInflight);n.delete(e),Gn({usageInflight:n})}}async function kbe(e){if(!qn().usageInflight.has(e))try{await SH(e);const t=Wf(vbe().get(e));t?.notConfigured?vt(t.message,"ok"):t?vt(a("余额查询失败:{message}",{message:t.message}),"err"):vt(a("✅ 已更新余额"))}catch(t){Hl(e,a("查询失败:{message}",{message:tn(t)}),Date.now()),Mi(),vt(a("余额查询失败:{message}",{message:tn(t)}),"err")}}async function $x(e){if(e){const n=Fl(e);if(!n||!ui(n)||n.needsRelogin)return;try{await SH(e)}catch(r){Hl(e,a("查询失败:{message}",{message:tn(r)}),Date.now()),Mi()}return}if(qn().usageBusy)return;const t=EO();if(t.length){Gn({usageBusy:!0}),t.forEach(n=>Hl(n.id,null,Date.now())),Mi();try{await zx(null)}catch(n){const r=tn(n);t.forEach(i=>Hl(i.id,a("查询失败:{message}",{message:r}),Date.now())),Mi()}finally{Gn({usageBusy:!1})}}}function vm(e){if(!Fl(e)){vt(a("账号不存在,请刷新后重试"),"err");return}Gn({dialog:{kind:"settings",id:e}})}function Bx(){Gn({dialog:null})}function TO(e,t="enable"){const n=(Array.isArray(e)?e:[]).filter(r=>Fl(r));if(!n.length){vt(a("请先勾选要操作的账号"),"err");return}Gn({dialog:{kind:"batch",ids:n,action:t}})}function kH(e){e&&Gn({dialog:{kind:"group",provider:e}})}function Nbe(e){let t=ybe(e);const n=new Map(qn().connections);for(const o of[...n.keys()])e.has(o)||(n.delete(o),t=!0);const r=new Set(qn().usageInflight);for(const o of[...r])e.has(o)||(r.delete(o),t=!0);const i=new Set(qn().selected);for(const o of[...i])e.has(o)||(i.delete(o),t=!0);t&&Gn({connections:n,usageInflight:r,selected:i})}const Cbe=2e3;function NH(e){return qn().connections.get(e)||0}async function CH(){try{const e=await rt().workbuddyDesktop?.getAccountConnections?.(),t=e?.counts&&typeof e.counts=="object"?e.counts:{},n=new Map;for(const[r,i]of Object.entries(t)){const o=Number(i)||0;o>0&&n.set(r,o)}return Abe(n,qn().connections)||Gn({connections:n}),!0}catch{return!1}}function Abe(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e)if(t.get(n)!==r)return!1;return!0}let AH=null;function Ebe(){AH||(AH=setInterval(()=>{document.hidden||rt().wbApp?.currentPage!=="accounts"||CH()},Cbe))}async function EH(e,t){try{await mm(e,{enabled:t}),vt(a(t?"✅ 已启用":"✅ 已禁用"));try{await Vc()}catch(n){vt(a("账号已保存,但列表刷新失败:{error}",{error:tn(n)}),"err")}}catch(n){vt(a("操作失败:{message}",{message:tn(n)}),"err"),rt().wbApp?.refresh?.()}}async function TH(e,t){if(!e.length)return!1;try{return await rt().workbuddyDesktop?.reorderAccounts?.(e),vt(t?a("✅ 已保存:{note}",{note:t}):a("✅ 顺序已保存")),await rt().wbApp?.refresh?.(),!0}catch(n){return vt(a("顺序未保存:{message}",{message:tn(n)}),"err"),rt().wbApp?.refresh?.(),!1}}async function OH(e,t){if(e.length)try{const n=rt().workbuddyDesktop;if(!n?.batchAccounts)throw new Error(a("批量操作接口不可用,请重新打开页面"));const r={action:t?"enable":"disable",ids:e},i=fH(await n.batchAccounts(r),r),o=i.ok?.length||0,c=i.ok?.filter(f=>f.changes?.length).length||0,d=i.failed?.length||0;d||i.skipped?.length?vt(a("{verb}完成:成功 {ok} 个,未变更 {unchanged} 个,跳过 {skip} 个,失败 {fail} 个",{verb:a(t?"启用":"禁用"),ok:c,unchanged:o-c,skip:i.skipped?.length||0,fail:d}),d?"err":"ok"):vt(t?a("✅ 已启用 {n} 个账号",{n:o}):a("✅ 已禁用 {n} 个账号",{n:o}));try{await Vc()}catch(f){vt(a("批量操作已保存,但列表刷新失败:{error}",{error:tn(f)}),"err")}}catch(n){vt(a("操作失败:{message}",{message:tn(n)}),"err"),rt().wbApp?.refresh?.()}}async function Tbe(e,t){try{await rt().workbuddyDesktop?.clearRateLimits?.(e,t||null),vt(t?a("✅ 已清除 {model} 的限流标记",{model:t}):a("✅ 已清除该账号全部限流标记")),await rt().wbApp?.refresh?.()}catch(n){vt(a("清除失败:{message}",{message:tn(n)}),"err")}}async function Obe(e,t,n){if(t===RH){vm(e);return}if(t!==F0&&t!==n){if(t.startsWith(tl)){const r=t.slice(tl.length),i=(ZU()||[]).find(o=>o.id===r);if(i&&i.enabled===!1){vt(a("「{name}」已在「网络代理」页禁用,请先启用它或换一条",{name:i.name||r}),"err");return}}try{const r=t===""?null:{source:"pool",proxyId:t.slice(tl.length)};await mm(e,{proxy:r}),vt(`✅ ${a("代理已更新")}`)}catch(r){vt(a("保存失败:{message}",{message:tn(r)}),"err")}finally{try{await Vc()}catch(r){vt(a("刷新账号列表失败:{message}",{message:tn(r)}),"err")}}}}const F0="__proxy_custom__",RH="__proxy_custom_edit__";function Rbe(e,t,n=1){return{seat:t.get(e.id)||{position:1,total:1},rank:n,picked:tbe(e.id),usageEntry:vo(e),connections:NH(e.id)}}const Pbe={DEFAULT_PROVIDER_ID:JT,RACCOON_PROVIDER_ID:hxe,providerOf:In,providerFeatures:Oa,providerSummaries:hU,identifierOf:M0,tokenExpiryOf:mU,supportsUsage:ui,isDesktopAccount:Rx,supportsChat:SU,byPriorityOrder:_0,typeLabel:Rxe,isEnabled:Ka,isRateLimited:Px,isLimited:e=>Ix(e,e?vo(e):void 0,Xf(e)),accountEdition:kU,matchEnabled:lO,matchLimit:IU,visibleAccounts:_xe,filterCounts:_U,positionMap:uO,activeLimits:cO,editionSuffix:Bxe,formatResetText:fO};function Ibe(){nH(),window.wbAccountsView={render:()=>{lH(),Mi()},refreshList:rH,refreshCaches:Nbe,syncConnections:CH,refreshProxyPool:eH,applyBalances:wH,syncBalancesSnapshot:Lx,queryUsageFor:zx,queryAllUsage:jH,refreshUsageAfterCheckin:$x,supportsUsage:ui,isDesktopAccount:Rx,isEnabled:Ka,isRateLimited:Px},window.wbAccountsModel=Pbe,window.wbAccountPanel={open:vm,close:Bx,openBatch:TO,closeBatch:Bx,syncAddProvider:()=>rt().wbAccountAddForms?.syncAddProvider?.(),invalidate:()=>{eH()}}}const PH=[{value:"fixed",label:()=>a("固定周期")},{value:"rolling",label:()=>a("滚动窗口")},{value:"daily",label:()=>a("自然日")},{value:"weekly",label:()=>a("自然周")},{value:"monthly",label:()=>a("自然月")},{value:"total",label:()=>a("生效至到期累计(不自动回满)")}];function Mbe(){return{join:"or",sourceId:"local",models:[],metric:"tokens",comparison:"gte",threshold:5e5,window:{reset:"daily",utcOffsetMinutes:null}}}function IH(e){if(!e||!Number.isFinite(e))return"";const t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function MH(e){const t=e.metric==="tokens"&&e.threshold%1e8===0?"yi":e.metric==="tokens"&&e.threshold%1e4===0?"wan":"unit";return{condition:{...structuredClone(e),window:e.window||e.source?.window,sourceId:e.sourceId||(e.metric==="tokens"||e.metric==="requests"?"local":"account")},unit:t,threshold:String(e.threshold/(t==="yi"?1e8:t==="wan"?1e4:1)),period:String(((e.window||e.source?.window)?.seconds||3600)/3600),anchor:IH((e.window||e.source?.window)?.startsAt),end:IH((e.window||e.source?.window)?.endsAt)}}function _H(e){if(!e||e.id==="local"||e.localOnly)return["tokens","requests"];if(e.id==="account")return["remaining"];const t=[];return e.unlimited||(e.remaining!==null&&e.remaining!==void 0&&t.push("remaining"),e.used!==null&&e.used!==void 0&&t.push("used"),(e.remainingPercent!==null&&e.remainingPercent!==void 0||(e.total||0)>0)&&t.push("remaining_percent","used_percent")),e.window&&t.push("tokens","requests"),t.length?t:["tokens","requests"]}function _be({account:e,value:t,allowBalance:n=!0,onSave:r,onClose:i}){const[o,c]=v.useState(()=>MH(t)),[d,f]=v.useState(""),h=o.condition,p=WT(e).filter(_=>(n||_.id==="local")&&(In(e)!=="codearts"||_.id==="account"||Ex(_.unit||"")));h.source&&!p.some(_=>_.id===h.sourceId)&&p.push(h.source);const g=p.find(_=>_.id===h.sourceId),x=p.find(_=>_.id==="account"&&Ex(_.unit||"")),y=[...new Map(p.filter(_=>_.planId).map(_=>[_.planId,_.planName||_.planId])).entries()],j=g?.planId||"",w=p.filter(_=>_.id==="account"||(j?_.planId===j:!_.planId)),S=h.metric==="tokens"||h.metric==="requests",N=Number(o.threshold)*(o.unit==="yi"?1e8:o.unit==="wan"?1e4:1),A=h.metric==="tokens"&&o.unit!=="unit"&&o.threshold.trim()&&Number.isSafeInteger(N)&&N>0?N.toLocaleString("en-US"):"",E=x?.unlimited?a("不限"):x?.remaining==null?a("暂无读数"):`${zn(x.remaining)} ${a("积分")}`,O=g?.models?.length?g.models.map(_=>({value:_,label:_})):cxe(e);for(const _ of h.models)O.some(I=>I.value===_)||O.push({value:_,label:_});const R=[...new Set([..._H(g),h.metric])].filter(_=>In(e)!=="codearts"||_!=="tokens"&&_!=="requests"),T=_=>{f(""),c(I=>({...I,condition:{...I.condition,..._}}))},P=_=>{const I=p.find(z=>z.id===_);if(!I)return;const L=I.localOnly||I.localEstimate?"tokens":_H(I)[0],D=L==="tokens"?I.total||5e5:L.endsWith("percent")?5:1;c(MH({...h,sourceId:_,source:cU(I),models:I.models?.length===1?I.models.slice():[],metric:L,comparison:L.startsWith("remaining")?"lte":"gte",threshold:D,window:I.window||{reset:"daily",utcOffsetMinutes:null}})),f("")},M=()=>{const _=Number(o.threshold),I=h.metric==="tokens"?Math.round(_*(o.unit==="yi"?1e8:o.unit==="wan"?1e4:1)):_;if(!o.threshold.trim()||!Number.isFinite(I)||I<0){f(a("限制阈值必须是非负有限数字"));return}if(S&&(!Number.isSafeInteger(I)||I<=0)){f(a("本地消耗上限必须是大于 0 的安全整数"));return}if(h.metric.endsWith("percent")&&I>100){f(a("百分比阈值必须在 0~100 之间"));return}let L=h.window;if(S){if(L={...L,reset:L?.reset||"daily"},L.reset==="fixed"||L.reset==="rolling"){const D=Math.round(Number(o.period)*3600);if(!Number.isFinite(D)||D<60||D>2678400){f(a("统计窗口必须是 1 分钟~31 天"));return}L.seconds=D}if((L.reset==="total"||L.reset==="fixed")&&(L.startsAt=o.anchor?new Date(o.anchor).getTime():0,L.endsAt=o.end?new Date(o.end).getTime():0,!Number.isFinite(L.startsAt)||!Number.isFinite(L.endsAt)||L.endsAt>0&&L.endsAt<=L.startsAt)){f(a("统计结束时间必须晚于开始时间"));return}}r({...h,threshold:I,window:L,source:g&&g.id!=="account"&&g.id!=="local"?cU(g):null})};return s.jsx(St,{open:!0,onOpenChange:_=>{_||i()},children:s.jsxs(kt,{className:"w-[min(680px,calc(100vw-48px))]",showCloseButton:!0,overlayForceRender:!0,children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("编辑限制条件")})}),s.jsxs(Ct,{className:"space-y-3",children:[y.length?s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("套餐")}),s.jsxs(ht,{value:j,onValueChange:_=>{const I=p.find(L=>_?L.planId===_:!L.planId);I&&P(I.id)},children:[s.jsx(mt,{className:"min-w-0 flex-1",children:s.jsx(pt,{children:y.find(([_])=>_===j)?.[1]||a("通用额度/本地保护")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"",children:a("通用额度/本地保护")}),y.map(([_,I])=>s.jsx(qe,{value:_,children:I},_))]})]})]}):null,s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("额度来源")}),s.jsxs(ht,{value:h.sourceId||"account",onValueChange:_=>{_&&P(_)},children:[s.jsx(mt,{className:"min-w-0 flex-1",children:s.jsx(pt,{children:QT(g,h.sourceId||"account")})}),s.jsx(gt,{children:w.map(_=>s.jsx(qe,{value:_.id,children:QT(_)},_.id))})]})]}),x?s.jsxs(IT,{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-xs text-subtle",children:a("总积分")}),s.jsx("span",{className:"text-[13px] font-semibold tabular-nums",children:E}),s.jsx(B,{variant:"outline",size:"sm",className:"ml-auto",disabled:g?.id===x.id&&h.metric==="remaining",onClick:()=>P(x.id),children:a("按总积分设置限制")})]}),s.jsx("p",{className:"detail",children:a("总积分是当前可用积分的汇总,与余额列一致;不重复累加汇总行,不包含 Token、次数或其他单位的额度。")})]}):null,s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("模型范围")}),s.jsx(Ff,{value:h.models,options:O,onValueChange:_=>T({models:_}),placeholder:g?.models?.length?a("该额度中的全部模型"):a("全部模型"),className:"min-w-0 flex-1","aria-label":a("模型范围")})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("限制指标")}),s.jsxs(ht,{value:h.metric,onValueChange:_=>{_&&(T({metric:_,comparison:_.startsWith("remaining")?"lte":"gte"}),c(I=>({...I,threshold:"",unit:"unit"})))},children:[s.jsx(mt,{className:"min-w-[190px]",children:s.jsx(pt,{children:ZT(h.metric)})}),s.jsx(gt,{children:R.map(_=>s.jsx(qe,{value:_,children:ZT(_)},_))})]})]}),s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx("span",{className:"text-[12.5px] text-subtle",children:a("触发条件")}),s.jsxs(ht,{value:h.comparison,onValueChange:_=>T({comparison:_}),children:[s.jsx(mt,{className:"w-[92px]","aria-label":a("触发条件"),children:s.jsx(pt,{children:h.comparison==="lt"?"<":h.comparison==="lte"?"≤":"≥"})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"lt",children:"<"}),s.jsx(qe,{value:"lte",children:"≤"}),s.jsx(qe,{value:"gte",children:"≥"})]})]}),s.jsx(Be,{type:"number",min:0,className:"max-w-[160px]",value:o.threshold,onChange:_=>c({...o,threshold:_.currentTarget.value}),placeholder:a("阈值"),"aria-label":a("阈值")}),h.metric==="tokens"?s.jsxs(ht,{value:o.unit,onValueChange:_=>c({...o,unit:_}),children:[s.jsx(mt,{className:"w-[84px]","aria-label":a("Token 单位"),children:s.jsx(pt,{children:o.unit==="yi"?a("亿"):o.unit==="wan"?a("万"):a("个")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"yi",children:a("亿")}),s.jsx(qe,{value:"wan",children:a("万")}),s.jsx(qe,{value:"unit",children:a("个")})]})]}):s.jsx("span",{className:"detail",children:h.metric.endsWith("percent")?"%":h.metric==="requests"?a("次"):mo(g?.unit||"",a)})]}),A?s.jsx("p",{className:"detail",children:a("实际阈值:{value} Token",{value:A})}):null,S?s.jsxs(s.Fragment,{children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("统计周期")}),s.jsxs(ht,{value:h.window?.reset||"daily",onValueChange:_=>T({window:{...h.window,reset:_}}),children:[s.jsx(mt,{className:"min-w-0 flex-1",children:s.jsx(pt,{children:PH.find(_=>_.value===(h.window?.reset||"daily")).label()})}),s.jsx(gt,{children:PH.map(_=>s.jsx(qe,{value:_.value,children:_.label()},_.value))})]})]}),h.window?.reset==="fixed"||h.window?.reset==="rolling"?s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("窗口长度")}),s.jsx(Be,{type:"number",min:1/60,max:744,step:"any",value:o.period,className:"max-w-[130px]",onChange:_=>c({...o,period:_.currentTarget.value})}),s.jsx("span",{className:"detail",children:a("小时")})]}):null,h.window?.reset==="total"||h.window?.reset==="fixed"?s.jsxs(s.Fragment,{children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("累计起点")}),s.jsx(Be,{type:"datetime-local",value:o.anchor,onChange:_=>c({...o,anchor:_.currentTarget.value}),className:"min-w-0 flex-1"})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("到期时间")}),s.jsx(Be,{type:"datetime-local",value:o.end,onChange:_=>c({...o,end:_.currentTarget.value}),className:"min-w-0 flex-1"})]})]}):null,["daily","weekly","monthly"].includes(h.window?.reset||"daily")?s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("重置时区")}),s.jsxs(ht,{value:h.window?.utcOffsetMinutes===480?"beijing":h.window?.utcOffsetMinutes===0?"utc":"local",onValueChange:_=>T({window:{...h.window,reset:h.window?.reset||"daily",utcOffsetMinutes:_==="beijing"?480:_==="utc"?0:null}}),children:[s.jsx(mt,{className:"min-w-[190px]",children:s.jsx(pt,{children:h.window?.utcOffsetMinutes===480?a("北京时间(UTC+8)"):h.window?.utcOffsetMinutes===0?"UTC":a("服务器本地时区")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"local",children:a("服务器本地时区")}),s.jsx(qe,{value:"beijing",children:a("北京时间(UTC+8)")}),s.jsx(qe,{value:"utc",children:"UTC"})]})]})]}):null]}):null,s.jsx("p",{className:"detail",children:a(S?"本地统计只包含经过本网关的请求,不等于上游账单;清理请求日志不会清零。套餐选择用于限定保护范围,不会强制上游扣指定套餐。":"按上游额度查询的读数判定;模型共用同一个额度池时,选择模型不会拆分该池余额。")}),S&&O.length>0?s.jsx("p",{className:"detail",children:a("选中多个模型时,每个模型单独累计、单独比较阈值;不合并用量。")}):null,g?.localEstimate?s.jsx("p",{className:"detail text-warning",children:a("上游没有提供此额度的分桶用量,当前使用本地估算保护;在其他客户端产生的消耗不会计入。")}):null,g?.channel&&g.channel!==String(e?.quotaChannel||e?.zcodePlan||"")?s.jsx("p",{className:"detail text-warning",children:a("此额度不属于账号当前使用的通道,切换到对应通道后才参与判定。")}):null,d?s.jsx("p",{className:"detail text-destructive",children:d}):null]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"outline",onClick:i,children:a("取消")}),s.jsx(B,{onClick:M,children:a("保存条件")})]})]})})}function DH({account:e,draft:t,onChange:n,allowBalance:r=!0}){const[i,o]=v.useState(null),[c,d]=v.useState(!1);v.useEffect(()=>{Lx()},[e?.id]);const f=(w,S)=>{n(t.map((N,A)=>A===w?{...N,...S}:N))},h=()=>In(e)==="codearts"?{join:"or",sourceId:"account",models:[],metric:"remaining",comparison:"lt",threshold:1}:Mbe(),p=()=>o({group:-1,condition:-1,value:h()}),g=w=>{if(i){if(i.group<0)n([...t,{enabled:!0,action:"skip",target:"models",conditions:[w]}]);else{const N=t[i.group].conditions.slice();i.condition<0?N.push(w):N[i.condition]=w,f(i.group,{conditions:N})}o(null)}},x=async()=>{if(!(!e||c)){d(!0);try{await $x(e.id),await Lx()}finally{d(!1)}}},y=XT(e),j=e?Tx(e,Kf(e)):[];return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(B,{variant:"outline",onClick:p,children:a("+ 添加限制")}),e&&r?s.jsx(B,{variant:"ghost",disabled:c,onClick:()=>{x()},children:a(c?"查询中…":"刷新套餐与额度")}):null]}),s.jsx("p",{className:"detail",children:a("每组共用一个触发动作;第二条条件起可选择「与/或」。与优先于或,下面会显示明确分组。各条件组独立生效。")}),t.length?null:s.jsx("p",{className:"detail",children:a("还没有条件组:账号照常参与转发,不设置额度保护。")}),t.map((w,S)=>{const N=JSON.stringify(w)===JSON.stringify(j[S])?y[S]:void 0;return s.jsxs("div",{className:"rounded-lg border border-hairline p-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(cn,{checked:w.enabled,onCheckedChange:A=>f(S,{enabled:A}),"aria-label":a("启用该规则")}),s.jsx("span",{className:"text-[13px] font-medium",children:a("条件组 {n}",{n:S+1})}),N?s.jsx(ye,{shape:"tag",variant:w.enabled?N.hit?"warning":"success":"secondary",children:w.enabled?N.hit?a("已触发"):a("未触发"):a("已停用")}):null,s.jsx("div",{className:"flex-1"}),s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>n(t.filter((A,E)=>E!==S)),children:a("删除组")})]}),w.conditions.map((A,E)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md bg-control p-2",children:[E>0?s.jsxs(ht,{value:A.join,onValueChange:O=>f(S,{conditions:w.conditions.map((R,T)=>T===E?{...R,join:O}:R)}),children:[s.jsx(mt,{className:"w-[78px]",children:s.jsx(pt,{children:A.join==="and"?a("与"):a("或")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"and",children:a("与")}),s.jsx(qe,{value:"or",children:a("或")})]})]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:a("当")}),s.jsxs("div",{className:"min-w-0 flex-1 text-xs",children:[s.jsx("div",{className:"break-words",children:uU(A,e)}),N?s.jsx("div",{className:"text-muted-foreground mt-1",children:a("当前:{value}",{value:uxe(N.conditions[E],A,e)})}):null]}),s.jsx(B,{variant:"ghost",size:"xs",onClick:()=>o({group:S,condition:E,value:A}),children:a("编辑")}),s.jsx(B,{variant:"ghost",size:"xs",disabled:w.conditions.length===1,onClick:()=>f(S,{conditions:w.conditions.filter((O,R)=>R!==E).map((O,R)=>R===0?{...O,join:"or"}:O)}),children:a("删除")})]},E)),s.jsx(B,{variant:"ghost",size:"sm",onClick:()=>o({group:S,condition:-1,value:h()}),children:a("+ 添加条件")}),s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx(Ie,{children:a("触发动作")}),s.jsxs(ht,{value:w.action,onValueChange:A=>f(S,{action:A}),children:[s.jsx(mt,{className:"min-w-[190px]","aria-label":a("触发动作"),children:s.jsx(pt,{children:w.action==="disable"?a("禁用整个账号(手动恢复)"):a("跳过(自动恢复)")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"skip",children:a("跳过(自动恢复)")}),s.jsx(qe,{value:"disable",children:a("禁用整个账号(手动恢复)")})]})]}),w.action==="skip"?s.jsxs(ht,{value:w.target,onValueChange:A=>f(S,{target:A}),children:[s.jsx(mt,{className:"min-w-[170px]","aria-label":a("模型范围"),children:s.jsx(pt,{children:w.target==="account"?a("整个账号"):a("命中条件的模型")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"models",children:a("命中条件的模型")}),s.jsx(qe,{value:"account",children:a("整个账号")})]})]}):null]}),s.jsx("p",{className:"detail break-words",children:fxe(w.conditions,e)})]},S)}),e?null:s.jsx("p",{className:"detail",children:a("跨账号批量配置仅支持通用条件;套餐实例不能直接复制到其他账号。")}),i?s.jsx(_be,{account:e,value:i.value,allowBalance:r,onSave:g,onClose:()=>o(null)},`${i.group}:${i.condition}`):null]})}function Dbe(e,t){const n=Tx(e,Kf(e));return JSON.stringify(t)===JSON.stringify(n)?null:{patch:{limiterGroups:t}}}function LH(e){return structuredClone(Tx(e,Kf(e)))}const Lbe={seconds:1,minutes:60,hours:3600};function zbe(e){return e>0&&e%3600===0?{value:String(e/3600),unit:"hours"}:e>0&&e%60===0?{value:String(e/60),unit:"minutes"}:e>0?{value:String(e),unit:"seconds"}:{value:"5",unit:"minutes"}}function zH(e){const{enabled:t,interval:n}=bU(e),r=zbe(t?n:0);return{enabled:t,intervalInput:r.value,unit:r.unit}}function $H(e){if(!e.enabled)return{value:{enabled:!1,interval:0}};const t=Number(e.intervalInput),n=Math.round(t*Lbe[e.unit]);return!Number.isFinite(t)||t<=0?{error:a("请填写查询间隔")}:ngU?{error:a("查询间隔必须是 {min} 秒 ~ 24 小时",{min:eO})}:{value:{enabled:!0,interval:n}}}function $be(e,t){const n=$H(t);if("error"in n)return n;const r=n.value.interval,i={},o=bU(e);return(t.enabled!==o.enabled||t.enabled&&r!==o.interval)&&(i.usageQuery={enabled:t.enabled,interval:t.enabled?r:o.interval}),i.usageQuery?{patch:i}:null}function BH({draft:e,onChange:t,idPrefix:n="account-usage"}){const r=i=>t({...e,...i});return s.jsxs(s.Fragment,{children:[s.jsx(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:s.jsxs(Tt,{className:"inline-flex cursor-pointer items-center gap-2.5 font-normal",children:[s.jsx(cn,{checked:e.enabled,onCheckedChange:i=>r({enabled:i===!0}),"aria-label":a("自动查询余额")}),s.jsx("span",{className:"text-xs text-subtle",children:a("自动查询余额(按下面的间隔自动刷新余额列的读数)")})]})}),e.enabled?s.jsxs(ws,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsxs(Et,{className:"contents",children:[s.jsx(Tt,{htmlFor:`${n}-interval`,children:a("查询间隔")}),s.jsx(Be,{id:`${n}-interval`,type:"number",min:1,step:1,className:"max-w-[110px]",value:e.intervalInput,onChange:i=>r({intervalInput:i.currentTarget.value})})]}),s.jsxs(ht,{value:e.unit,onValueChange:i=>r({unit:i}),children:[s.jsx(mt,{className:"w-[92px]","aria-label":a("间隔单位"),children:s.jsx(pt,{children:e.unit==="hours"?a("小时"):e.unit==="minutes"?a("分钟"):a("秒")})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"seconds",children:a("秒")}),s.jsx(qe,{value:"minutes",children:a("分钟")}),s.jsx(qe,{value:"hours",children:a("小时")})]})]}),s.jsx("span",{className:"detail",children:a("30 秒 ~ 24 小时;手动查询会顺延下一轮")})]}):null]})}const FH=8;function xm(e){const t=e?.config?.source||e?.source,n=e?.config||null,r=t==="rotate";return{mode:t==="pool"?"pool":r?"rotate":t==="clash"?"clash":t==="custom"?"custom":t==="subscription"?"retired":"none",listenerUid:t==="clash"?String(n?.listenerUid||""):"",proxyId:t==="pool"?String(n?.proxyId||""):"",rotateAll:r?n?.all!==!1:!0,rotateIds:r&&Array.isArray(n?.proxyIds)?n.proxyIds.map(String):[],protocol:n?.protocol==="socks5"?"socks5":"http",host:n?.host||"",port:n?.port===void 0||n?.port===null?"":String(n.port),username:n?.username||"",password:n?.password||""}}function ld(e){if(e.mode==="none")return null;if(e.mode==="retired")throw new Error(a("原代理来源已下线,请选择已保存的代理、自定义地址或直连"));if(e.mode==="clash"){if(!e.listenerUid)throw new Error(a("请先选择 Clash Verge 出口"));return{source:"clash",listenerUid:e.listenerUid}}if(e.mode==="pool"){if(!e.proxyId)throw new Error(a("请先选择已保存的代理"));return{source:"pool",proxyId:e.proxyId}}if(e.mode==="rotate"){if(e.rotateAll)return{source:"rotate",all:!0};if(!e.rotateIds.length)throw new Error(a("轮询至少要选择一条代理(或改选「全部」)"));return{source:"rotate",all:!1,proxyIds:[...e.rotateIds]}}const t=e.host.trim(),n=Number(e.port);if(!t)throw new Error(a("请填写代理主机地址"));if(!Number.isInteger(n)||n<1||n>65535)throw new Error(a("代理端口必须是 1-65535 的整数"));return{source:"custom",protocol:e.protocol==="socks5"?"socks5":"http",host:t,port:n,username:e.username.trim(),password:e.password}}function UH(e){return`${e.name||e.uid} :${e.port}${e.profileActive===!1?a("(其他订阅,可能未生效)"):""}${e.enabled===!1?a("(已在 Clash 中禁用)"):""}`}function Fx({draft:e,onChange:t,idPrefix:n,allowRotate:r=!1}){const[i,o]=v.useState(!1),[c,d]=v.useState(null),[f,h]=v.useState(null),[p,g]=v.useState(""),[x,y]=v.useState(null),[j,w]=v.useState(""),S=x?.options||[],N=T=>t({...e,...T}),A=v.useCallback(()=>{w(""),Promise.resolve(rt().workbuddyDesktop?.getProxies?.()).then(T=>{if(!T?.clash||!Array.isArray(T.clash.options))throw new Error(a("代理列表响应异常"));y(T.clash)}).catch(T=>{y({available:!1,options:[]}),w(tn(T))})},[]);v.useEffect(()=>{e.mode==="clash"&&x===null&&A()},[e.mode,x,A]);const E=v.useCallback((T=!1)=>{g(""),jO({force:T}).then(P=>h(P)).catch(P=>{h([]),g(tn(P))})},[]);v.useEffect(()=>{(e.mode==="pool"||e.mode==="rotate")&&f===null&&E()},[e.mode,f,E]);function O(){return e.rotateAll?(f??[]).filter(T=>T.enabled!==!1).map(T=>T.id):[...e.rotateIds]}async function R(){if(i)return;if(e.mode==="rotate"){const P=O();if(!P.length){vt(a("轮询至少要选择一条代理(或改选「全部」)"),"err");return}const M=P.slice(0,FH);o(!0),d(a("正在连接上游…"));let _=0;const I=[];for(const z of M){const G=f?.find(X=>X.id===z)?.name||z;try{const X=await rt().workbuddyDesktop?.testProxyPoolItem?.(z);X?.success?_+=1:I.push(`${G}(${X?.error||a("连接失败")})`)}catch(X){I.push(`${G}(${tn(X)})`)}}const L=P.length-M.length,D=a("✅ {ok}/{total} 个出口可用",{ok:_,total:M.length})+(L>0?a("(只测了前 {limit} 个,还有 {rest} 个未测)",{limit:FH,rest:L}):"");d(s.jsxs("span",{className:I.length?"text-destructive":"text-success",children:[D,I.length?` ${nl(I.join(a(";")))}`:""]})),o(!1);return}if(e.mode==="pool"){if(!e.proxyId){vt(a("请先选择已保存的代理"),"err");return}o(!0),d(a("正在连接上游…"));try{const P=await rt().workbuddyDesktop?.testProxyPoolItem?.(e.proxyId);d(P?.success?s.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),P.ip?a(" 出口 IP {ip}",{ip:nl(P.ip)}):"",P.durationMs!==void 0&&P.durationMs!==""?` ${nl(String(P.durationMs))}ms`:""]}):s.jsxs("span",{className:"text-destructive",children:["❌ ",nl(P?.error||a("连接失败"))]}))}catch(P){d(s.jsxs("span",{className:"text-destructive",children:["❌ ",nl(tn(P))]}))}finally{o(!1)}return}let T;try{T=ld(e)}catch(P){vt(tn(P),"err");return}o(!0),d(a("正在连接上游…"));try{const P=await rt().workbuddyDesktop?.testProxy?.({proxy:T});P?.success?d(s.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),P.status!==void 0&&P.status!==""?` HTTP ${nl(String(P.status))}`:"",P.ip?a(" 出口 IP {ip}",{ip:nl(P.ip)}):"",P.durationMs!==void 0&&P.durationMs!==""?` ${nl(String(P.durationMs))}ms`:""]})):d(s.jsxs("span",{className:"text-destructive",children:["❌ ",nl(P?.error||a("连接失败"))]}))}catch(P){d(s.jsxs("span",{className:"text-destructive",children:["❌ ",nl(tn(P))]}))}finally{o(!1)}}return s.jsxs("div",{className:"flex flex-col",children:[e.mode==="retired"?s.jsx("p",{className:"mb-3 text-xs text-destructive",children:a("原代理来源已下线,请选择已保存的代理、自定义地址或直连")}):null,s.jsxs(bx,{value:e.mode,onValueChange:T=>N({mode:T}),className:"flex-row flex-wrap items-center gap-5","aria-label":a("代理方式"),children:[s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:"none"}),a("无代理(直连)")]}),s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:"pool"}),a("已保存的代理")]}),r?s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",title:a("逐请求轮换出口(换 IP):OpenCode Zen 免费档按 IP 限流,单个 IP 的额度用完会对它一律 429"),children:[s.jsx(Lc,{value:"rotate"}),a("轮询(换 IP)")]}):null,e.mode==="clash"?s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:"clash"}),"Clash Verge"]}):null,s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:"custom"}),a("自定义")]})]}),e.mode==="pool"?s.jsxs("div",{className:"mt-3",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:`${n}-pool-exit`,children:a("代理")}),s.jsxs(ht,{value:e.proxyId,disabled:!f?.length,onValueChange:T=>N({proxyId:String(T)}),children:[s.jsx(mt,{id:`${n}-pool-exit`,className:"min-w-[220px]",children:s.jsx(pt,{children:f?.find(T=>T.id===e.proxyId)?dm(f.find(T=>T.id===e.proxyId)):e.proxyId?a("当前代理不可用,请重新选择"):f===null?a("正在读取…"):f.length?a("请选择代理"):a("还没有保存的代理")})}),s.jsx(gt,{children:(f??[]).map(T=>s.jsx(qe,{value:T.id,disabled:T.enabled===!1,children:dm(T)},T.id))})]}),s.jsx(B,{variant:"outline",size:"sm",onClick:()=>E(!0),children:a("重新读取")})]}),s.jsx("div",{className:"detail mt-1.5",children:p?a("读取失败:{error}",{error:p}):f===null?a("正在读取代理列表…"):f.length?a("地址与端口由「网络代理」页管理:那边改一次、测一次,所有引用它的账号一起生效"):a("「网络代理」页还没有出口 —— 去那里添加手动地址或同步 Clash Verge 的端点")})]}):null,e.mode==="rotate"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1",children:[s.jsx(Wr,{id:`${n}-rotate-all`,checked:e.rotateAll,"aria-label":a("轮询全部代理节点"),onCheckedChange:T=>N({rotateAll:T===!0})}),s.jsx(Ie,{htmlFor:`${n}-rotate-all`,className:"cursor-pointer text-xs text-subtle",children:a("全部代理节点(推荐)")}),s.jsx("span",{className:"detail",children:a("「网络代理」页里每个启用的出口轮流使用;之后新加的出口自动加入")})]}),e.rotateAll?null:s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:`${n}-rotate-exits`,children:a("轮询的代理")}),s.jsx(Ff,{id:`${n}-rotate-exits`,value:e.rotateIds,onValueChange:T=>N({rotateIds:T.map(String)}),options:(f??[]).map(T=>({value:T.id,label:dm(T),disabled:T.enabled===!1})),placeholder:a("选择要轮询的代理(可多选)"),"aria-label":a("轮询的代理")}),s.jsx(B,{variant:"outline",size:"sm",onClick:()=>E(!0),children:a("重新读取")})]}),s.jsx("div",{className:"detail mt-1.5",children:p?a("读取失败:{error}",{error:p}):f===null?a("正在读取代理列表…"):f.length?a("每条请求换一个出口(按顺序轮流),上游看到的 IP 因此是变化的;出口的地址与端口由「网络代理」页管理"):a("「网络代理」页还没有出口 —— 去那里添加手动地址或同步 Clash Verge 的端点")})]}):null,e.mode==="clash"?s.jsxs("div",{className:"mt-3",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:`${n}-clash-exit`,children:a("出口")}),s.jsxs(ht,{value:e.listenerUid,disabled:!S.length,onValueChange:T=>N({listenerUid:String(T)}),children:[s.jsx(mt,{id:`${n}-clash-exit`,className:"min-w-[220px]",children:s.jsx(pt,{children:S.find(T=>T.uid===e.listenerUid)?UH(S.find(T=>T.uid===e.listenerUid)):e.listenerUid?a("当前代理不可用,请重新选择"):a("请选择出口")})}),s.jsx(gt,{children:S.filter(T=>T.uid).map(T=>s.jsx(qe,{value:String(T.uid),disabled:T.enabled===!1,children:UH(T)},T.uid))})]}),s.jsx(B,{variant:"outline",size:"sm",onClick:A,children:a("重新读取")})]}),s.jsx("p",{className:"detail mt-1.5",children:j?a("读取失败:{error}",{error:j}):x===null?a("正在读取 Clash Verge 配置…"):x.available===!1?a("不可用:{error}",{error:x.error||a("未检测到 Clash Verge 配置")}):a("读取自 {dir};端口由 Clash Verge 管理,这里实时同步",{dir:x.dir||"Clash Verge"})}),s.jsx("p",{className:"detail mt-1.5",children:a("既有 Clash Verge 直接引用继续可用;也可在「网络代理」页同步端点,再改选「已保存的代理」。")})]}):null,e.mode==="custom"?s.jsxs("div",{className:"mt-3",children:[s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsxs(Et,{className:"contents",children:[s.jsx(Tt,{htmlFor:`${n}-protocol`,children:a("协议")}),s.jsxs(ht,{value:e.protocol,onValueChange:T=>N({protocol:T}),children:[s.jsx(mt,{id:`${n}-protocol`,className:"min-w-[110px]",children:s.jsx(pt,{children:e.protocol==="socks5"?"SOCKS5":"HTTP"})}),s.jsxs(gt,{children:[s.jsx(qe,{value:"http",children:"HTTP"}),s.jsx(qe,{value:"socks5",children:"SOCKS5"})]})]})]}),s.jsxs(Et,{className:"contents",children:[s.jsx(Tt,{htmlFor:`${n}-host`,className:"ml-2",children:a("主机")}),s.jsx(Be,{id:`${n}-host`,className:"min-w-[140px]",placeholder:"127.0.0.1",value:e.host,onChange:T=>N({host:T.currentTarget.value})})]}),s.jsxs(Et,{className:"contents",children:[s.jsx(Tt,{htmlFor:`${n}-port`,children:a("端口")}),s.jsx(Be,{id:`${n}-port`,type:"number",min:1,max:65535,className:"max-w-[110px]",placeholder:"7890",value:e.port,onChange:T=>N({port:T.currentTarget.value})})]})]}),s.jsxs(ws,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsxs(Et,{className:"contents",children:[s.jsx(Tt,{htmlFor:`${n}-user`,children:a("用户名")}),s.jsx(Be,{id:`${n}-user`,placeholder:a("可选"),autoComplete:"off",value:e.username,onChange:T=>N({username:T.currentTarget.value})})]}),s.jsxs(Et,{className:"contents",children:[s.jsx(Tt,{htmlFor:`${n}-pass`,children:a("密码")}),s.jsx(Be,{id:`${n}-pass`,type:"password",placeholder:a("可选"),autoComplete:"new-password",value:e.password,onChange:T=>N({password:T.currentTarget.value})})]})]})]}):null,s.jsxs(ws,{orientation:"horizontal",className:"field-row mt-3",children:[s.jsx(B,{variant:"outline",size:"sm",disabled:i,onClick:()=>{R()},children:a(i?"测试中…":"测试出口")}),s.jsx("span",{className:"detail",children:c})]})]})}const OO=[{value:"enable",label:()=>a("启用")},{value:"disable",label:()=>a("禁用")},{value:"proxy",label:()=>a("修改代理")},{value:"concurrency",label:()=>a("设置并发上限")},{value:"usageQuery",label:()=>a("查询设置")},{value:"limiters",label:()=>a("限制器")},{value:"remove",label:()=>a("删除")}],RO=[{value:"append",label:()=>a("追加规则(保留原有)")},{value:"replace",label:()=>a("替换全部规则")},{value:"enable",label:()=>a("启用全部规则")},{value:"disable",label:()=>a("停用全部规则")},{value:"clear",label:()=>a("清空全部规则")}];function Qf(e){return go(e)||e?.id||""}function Bbe({ids:e,action:t,onClose:n}){const[r,i]=v.useState(OO.some(W=>W.value===t)?t:"enable"),[o,c]=v.useState(()=>xm(null)),[d,f]=v.useState(""),[h,p]=v.useState({enabled:!0,intervalInput:"",unit:"minutes"}),[g,x]=v.useState("append"),[y,j]=v.useState([]),[w,S]=v.useState(""),[N,A]=v.useState(!1),[E,O]=v.useState(""),R=v.useRef(!1),T=e.map(W=>Fl(W)).filter(W=>W!==null),P=T.filter(ui),M=r==="limiters"&&(g==="append"||g==="replace"),_=M&&y.some(W=>W.conditions.some(ne=>ne.metric!=="tokens"&&ne.metric!=="requests")),I=r==="usageQuery"||_?P:T,L=T.filter(W=>!I.includes(W)),D=r==="usageQuery"?P:T,z=D.find(W=>W.id===w),G=T.reduce((W,ne)=>Math.max(W,Number(Oa(In(ne)).concurrencyDefault)||0),0),X=T.length>0&&T.every(vxe),Y=r==="remove"||r==="limiters"&&(g==="replace"||g==="clear"),F=r==="limiters"?g==="append"?a("追加限制规则"):RO.find(W=>W.value===g).label():OO.find(W=>W.value===r).label();function K(){z&&(r==="usageQuery"?p(zH(z)):j(LH(z)),O(""),vt(a("已复制到草稿,执行后才会应用到所选账号")))}async function U(){const W=rt().wbConfirm?.ask;if(r==="remove"&&!await Promise.resolve(W?.({title:a("删除选中的账号"),html:a("确定删除选中的 {count} 个账号?此操作不可恢复,账号的登录态会一并移除。",{count:e.length}),okText:a("删除"),okClass:"danger"})??!1))return!1;if(r==="disable"||r==="remove"){const ne=new Set(e);if(!Bl().filter(V=>V.enabled!==!1&&!ne.has(V.id)).length){const V=a(r==="remove"?"删除":"禁用");return Promise.resolve(W?.({title:a("全部启用中的账号将被{what}",{what:V}),html:a("这会{what}所有启用中的账号,转发将不可用。确定继续?",{what:V}),okText:V,okClass:r==="remove"?"danger":"primary"})??!1)}}return r==="limiters"&&g==="replace"?Promise.resolve(W?.({title:a("替换选中账号的限制规则"),html:a("将用草稿中的 {rules} 条规则替换 {count} 个账号的全部限制规则,原有规则不会保留。确定继续?",{rules:y.length,count:I.length})+(L.length?`${a("以下 {count} 个账号不支持余额查询,本次会跳过:{names}",{count:L.length,names:nl(L.map(Qf).join(a("、")))})}
`:""),okText:a("替换全部规则"),okClass:"danger"})??!1):r==="limiters"&&g==="clear"?Promise.resolve(W?.({title:a("清空选中账号的限制规则"),html:a("确定清空 {count} 个账号的全部限制规则?余额与 Token 将不再设限;已禁用的账号不会自动启用。",{count:I.length}),okText:a("清空全部规则"),okClass:"danger"})??!1):!0}async function q(){if(R.current)return;if(!e.length){vt(a("没有选中的账号"),"err");return}if(!I.length){vt(a("没有适用于本次操作的账号"),"err");return}const W={action:r,ids:e};try{if(r==="proxy"&&(W.proxy=ld(o)),r==="concurrency"){const ne=Number(d.trim());if(!d.trim()||!Number.isFinite(ne)||ne<0)throw new Error(a("并发上限必须是 0~{max} 的整数",{max:Uc}));W.maxConcurrent=Math.min(Uc,Math.round(ne))}if(r==="usageQuery"){const ne=$H(h);if("error"in ne)throw new Error(ne.error);W.usageQuery=ne.value}if(r==="limiters"&&(W.limiterMode=g,M)){if(!y.length)throw new Error(a("请至少添加一条限制规则;清空请使用清空操作"));if(y.some(ne=>ne.conditions.some(ie=>ie.sourceId!==""&&ie.sourceId!=="local"&&ie.sourceId!=="account")))throw new Error(a("套餐实例不能跨账号复制,请改用通用额度或本地保护条件"));W.limiterGroups=structuredClone(y)}}catch(ne){O(s.jsx("span",{className:"text-destructive",children:tn(ne)})),vt(tn(ne),"err");return}R.current=!0,A(!0),O("");try{if(!await U())return;const ne=rt().workbuddyDesktop;if(!ne?.batchAccounts)throw new Error(a("批量操作接口不可用,请重新打开页面"));const ie=fH(await ne.batchAccounts(W),W),V=ie.ok||[],H=r==="remove"?(ie.removed||[]).length:V.filter(se=>se.changes?.length).length,Q=r==="remove"?0:V.length-H,J=ie.failed||[],oe=ie.skipped||[],ee=a("{verb}完成:成功 {ok} 个,未变更 {unchanged} 个,跳过 {skip} 个,失败 {fail} 个",{verb:F,ok:H,unchanged:Q,skip:oe.length,fail:J.length});vt(ee,J.length?"err":"ok"),J.length||oe.length?O(s.jsxs("div",{role:"status",className:"space-y-2",children:[s.jsx("p",{children:ee}),oe.length?s.jsxs("p",{children:[a("跳过 {count} 个:",{count:oe.length}),oe.map(se=>`${Qf(Fl(String(se.id)))||se.name||se.id}(${se.reason})`).join(a(";"))]}):null,J.length?s.jsxs("p",{className:"text-destructive",children:[a("失败 {count} 个:",{count:J.length}),J.map(se=>`${Qf(Fl(String(se.id)))||se.id}(${se.error})`).join(a(";"))]}):null]})):n();try{await Vc(),await Lx()}catch(se){vt(a("批量操作已保存,但列表刷新失败:{error}",{error:tn(se)}),"err")}}catch(ne){O(s.jsx("span",{className:"text-destructive",children:tn(ne)})),vt(a("批量操作失败:{error}",{error:tn(ne)}),"err")}finally{R.current=!1,A(!1)}}return s.jsx(St,{open:!0,onOpenChange:W=>{W||N||n()},children:s.jsxs(kt,{className:"w-[min(900px,calc(100vw-48px))]",showCloseButton:!N,children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("批量操作 · 已选 {count} 个账号",{count:e.length})})}),s.jsxs(Ct,{children:[s.jsxs(ove,{disabled:N,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[s.jsxs(Ln,{children:[s.jsx("h3",{children:a("将作用于以下账号")}),s.jsx("p",{className:"max-h-[84px] overflow-y-auto",children:I.map(Qf).join(a("、"))||a("没有适用于本次操作的账号")}),L.length?s.jsx("p",{children:a("以下 {count} 个账号不支持余额查询,本次会跳过:{names}",{count:L.length,names:L.map(Qf).join(a("、"))})}):null,r!=="remove"?s.jsx("p",{children:a("只修改本次选择的设置,不影响备注、凭证、转发顺序或其他设置。")}):null]}),s.jsxs(Ln,{children:[s.jsx("h3",{children:a("操作")}),s.jsx(bx,{value:r,onValueChange:W=>{i(W),O("")},disabled:N,className:"flex-row flex-wrap items-center gap-5","aria-label":a("批量动作"),children:OO.map(W=>s.jsxs(Ie,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[s.jsx(Lc,{value:W.value}),W.label()]},W.value))}),r==="proxy"?s.jsx("div",{className:"mt-2.5",children:s.jsx(Fx,{draft:o,onChange:c,idPrefix:"batch-proxy",allowRotate:X})}):null,r==="concurrency"?s.jsxs("div",{className:"mt-2.5",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"batch-conc-input",children:a("并发上限")}),s.jsx(Be,{id:"batch-conc-input",type:"number",min:0,max:Uc,step:1,className:"max-w-[110px]",placeholder:a("并发上限"),value:d,onChange:W=>f(W.currentTarget.value)}),s.jsx("span",{className:"detail",children:a("0 = 不限")})]}),s.jsx("p",{className:"detail mt-2.5",children:G>0?a("并发上限 0~{max};CodeArts 等有默认值的家填 0 即按本家默认;达到上限的账号会被跳过、请求转给其他账号",{max:Uc}):a("并发上限 0~{max};达到上限的账号会被跳过、请求转给其他账号",{max:Uc})})]}):null,r==="limiters"?s.jsxs("div",{className:"mt-2.5",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"batch-limiter-mode",children:a("规则操作")}),s.jsxs(ht,{value:g,onValueChange:W=>{x(W),O("")},children:[s.jsx(mt,{id:"batch-limiter-mode",className:"min-w-[220px]",children:s.jsx(pt,{children:RO.find(W=>W.value===g).label()})}),s.jsx(gt,{children:RO.map(W=>s.jsx(qe,{value:W.value,children:W.label()},W.value))})]})]}),s.jsx("p",{className:"detail mt-2.5",children:a(g==="append"?"保留各账号原有规则,只追加下面的规则;完全相同的规则不会重复添加。":g==="replace"?"用下面的规则统一替换各账号的全部规则,执行前会再次确认。":g==="clear"?"删除各账号的全部限制规则,执行前会再次确认。":"仅统一修改现有规则的开关,保留阈值、动作和重置方式;不改变账号的启用状态。")})]}):null,r==="usageQuery"||M?s.jsxs("div",{className:"mt-2.5",children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"batch-settings-source",children:a("复制自账号")}),s.jsxs(ht,{value:z?.id||"",disabled:!D.length,onValueChange:W=>S(String(W)),children:[s.jsx(mt,{id:"batch-settings-source",className:"min-w-0 flex-1",children:s.jsx(pt,{children:z?Qf(z):a("选择所选账号作为模板(可选)")})}),s.jsx(gt,{children:D.map(W=>s.jsx(qe,{value:W.id,children:Qf(W)},W.id))})]}),s.jsx(B,{variant:"outline",size:"sm",disabled:!z,onClick:K,children:a("复制当前设置")})]}),r==="usageQuery"?s.jsxs(s.Fragment,{children:[s.jsx(BH,{draft:h,onChange:p,idPrefix:"batch-usage"}),s.jsx("p",{className:"detail mt-2.5",children:a("统一设置自动查询的开关和间隔;不会复制或覆盖余额查询凭证。")})]}):s.jsx(DH,{draft:y,onChange:j,allowBalance:P.length>0})]}):null,r==="usageQuery"&&!h.enabled?s.jsx("p",{className:"detail mt-2.5",children:a("关闭自动查询后,余额限制器只能使用上次读数;手动查询仍可用。")}):null,r==="limiters"?s.jsx("p",{className:"detail mt-2.5",children:a("Token 规则按每个账号已有的窗口消耗判定,保存不会清零;停用或清空规则不会自动启用账号。")}):null]})]}),s.jsx("div",{className:"detail min-h-[18px]",children:E})]}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",disabled:N,onClick:n,children:a("取消")}),s.jsx(B,{variant:Y?"destructive":"default",disabled:N||!I.length,onClick:()=>{q()},children:N?a("执行中…"):a("执行({action})",{action:F})})]})]})})}function rl(e){if(e==null||e==="")return null;const t=Number(e);return Number.isFinite(t)?t:null}function bm(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function HH(e){return mo(e,a)}function Fbe(e){const t=sU(e),n=Date.now();return t.map(r=>{const i=oU(r,a,zn);if(i){const z=i.daily?a("每日重置"):null;return{name:i.name,view:i.view,tone:i.tone,percent:null,window:z,title:[i.name,i.view,z].filter(Boolean).join(" · "),spent:!1,snapshot:!0,amount:null}}const o=String(r?.name||"").trim()||a("积分包");if(r?.record===!0){const z=rl(r?.amount),G=String(r?.unit||"").trim(),X=rl(r?.at),Y=rl(r?.expireAt),F=z===null?"—":`${z>0?"+":""}${zn(z)}`,K=G&&F!=="—"?`${F} ${HH(G)}`:F,U=[];X!==null&&X>0&&U.push(bm(X)),Y!==null&&Y>0&&U.push(Y<=n?a("已过期"):a("{time} 到期",{time:bm(Y)}));const q=String(r?.remark||"").trim();return{name:o,view:K,tone:z!==null&&z<0?"muted":"ok",percent:null,window:U.length?U.join(" · "):null,title:[o,K,X!==null&&X>0?ci(X):"",Y!==null&&Y>0?a("到期 {time}",{time:ci(Y)}):"",q].filter(Boolean).join(" · "),spent:!1,amount:z}}const c=String(r?.unit||"").trim(),d=rl(r?.total),f=rl(r?.used),h=rl(r?.remain),p=r?.unlimited===!0,g=rl(r?.grantAt),x=rl(r?.startAt),y=rl(r?.expireAt),j=r?.daily===!0,w=r?.rolling===!0,S=rl(r?.resetAt),N=rl(r?.remainingPercent),A=String(r?.grantReason||"").trim(),E=y!==null&&y>0&&y<=n,O=d!==null&&d>0,R=p?a("不限"):h!==null?O?a("剩 {remaining} / {total}",{remaining:zn(h),total:zn(d)}):a("剩 {remaining}",{remaining:zn(h)}):f!==null?a("已用 {used}",{used:zn(f)}):N!==null?a("剩余 {percent}%",{percent:Math.round(N)}):"—",T=!p&&c&&R!=="—"?`${R} ${HH(c)}`:R,P=O&&h!==null?Math.max(0,Math.min(100,h/d*100)):N===null?null:Math.max(0,Math.min(100,N)),M=h!==null&&h<=0||h===null&&f!==null&&O&&f>=d,_=!p&&!j&&!w&&(M||E),I=[];g!==null&&g>0?I.push(a("{time} 领取",{time:bm(g)})):x!==null&&x>0&&I.push(a("{time} 生效",{time:bm(x)})),j?I.push(a("每日重置")):w&&S!==null&&S>0?I.push(a("重置 {date}",{date:bm(S)})):y!==null&&y>0&&I.push(E?a("已过期"):a("{time} 到期",{time:bm(y)})),A&&I.push(A);const L=E||h===0?"muted":P!==null&&P<20?"warn":h===null&&f===null&&!p?"muted":"ok",D=[o,T,g!==null&&g>0?a("领取 {time}",{time:ci(g)}):x!==null&&x>0?a("生效 {time}",{time:ci(x)}):"",y!==null&&y>0?E?a("已过期({time})",{time:ci(y)}):a("到期 {time}",{time:ci(y)}):"",j?a("每日重置(额度按周期回满,不是作废)"):"",A,P===null&&h!==null?a("上游未给总量,画不出剩余比例"):"",f!==null&&d!==null?a("已用 {used} / 共 {total}",{used:zn(f),total:zn(d)}):""].filter(Boolean).join(" · ");return{name:o,view:T,tone:L,percent:P,window:I.length?I.join(" · "):null,title:D,spent:_,amount:null}})}function VH({row:e}){return s.jsxs("div",{className:"usage-pop-row",title:e.title,children:[s.jsxs("div",{className:"usage-pop-line",children:[s.jsx("span",{className:"usage-pop-name",children:e.name}),s.jsx("span",{className:`usage-pop-view ${e.tone}`,children:e.view})]}),e.window?s.jsx("div",{className:"usage-pop-window",children:e.window}):null,e.percent!==null?s.jsx(lm,{value:e.percent,variant:e.tone==="ok"?"success":e.tone==="warn"?"warning":"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("剩余 {percent}%",{percent:Math.round(e.percent)})}):null]})}function PO({rows:e,subscriptionLine:t,aggregate:n,variant:r,kind:i,title:o,children:c}){const[d,f]=v.useState(!1),[h,p]=v.useState(!1),g=e.filter(A=>!A.spent),x=e.filter(A=>A.spent),y=e.length>0&&e.every(A=>A.snapshot)?a("余额详情"):a("积分明细"),j=r==="pool"?`usage-toggle usage-pool-line ${i}`:`usage-toggle ${i}`,w=v.useRef(null),S=v.useCallback(A=>{w.current=A,A&&(A.scrollTop=0)},[]),N=v.useCallback(()=>w.current??null,[]);return v.useLayoutEffect(()=>{if(!h)return;const A=w.current?.querySelector(".usage-pop-spent .usage-pop-row");A instanceof HTMLElement&&A.scrollIntoView({block:"nearest"})},[h]),s.jsxs(_l,{open:d,onOpenChange:f,children:[s.jsxs($c,{render:s.jsx(B,{size:"default",variant:"ghost",type:"button",className:j,title:o,"aria-label":y}),children:[r==="pool"?c:s.jsx("span",{className:"val",children:c}),s.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),s.jsx(Dl,{align:"center",sideOffset:6,className:"w-[320px]",initialFocus:N,children:s.jsxs("div",{className:"usage-pop-credit",ref:S,tabIndex:-1,children:[t?s.jsx("div",{className:"usage-pop-sub",children:t}):null,n?s.jsxs("div",{className:"usage-pop-total",children:[s.jsx("span",{className:"k",children:n.label}),s.jsxs("span",{className:"v",children:[n.unlimited?a("不限"):zn(n.remaining),!n.unlimited&&n.unit?s.jsxs(s.Fragment,{children:[" ",s.jsx("small",{children:n.unit})]}):null]})]}):null,s.jsx("div",{className:"usage-pop-group",children:y}),g.map((A,E)=>s.jsx(VH,{row:A},`${A.name}-${E}`)),x.length>0?s.jsxs("div",{className:"usage-pop-spent",children:[s.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"usage-pop-spent-head","aria-expanded":h,title:a("展开或收起(默认收起)"),onClick:()=>p(A=>!A),children:[s.jsx("span",{className:"caret","aria-hidden":!0}),s.jsx("span",{children:a("已用完 / 已过期")}),s.jsx("span",{className:"n",children:a("{count} 份",{count:x.length})})]}),h?x.map((A,E)=>s.jsx(VH,{row:A},`spent-${A.name}-${E}`)):null]}):null]})})]})}const Ube=new Set(["cursor","kiro","devin","factory","zed","grok","minimax-code","minimax-code-global","qwenwork","qwenwork-enterprise","kimi-work","opendesign","nous-portal","claude-subscription","codex-subscription","chatgpt-subscription","copilot-subscription","gemini-subscription"]);function IO(e){return Ube.has(e)}function Lt(){return window}function lr(e,t){Lt().wbApp?.toast?.(e,t)}function MO(e,t=0){if(typeof e=="string")return e.trim();if(e instanceof Error)return e.message.trim();if(!e||typeof e!="object"||t>3)return"";const n=e;for(const r of["message","error","msg","reason"]){const i=MO(n[r],t+1);if(i)return i}return""}function qa(e){const t=MO(e);return a(t||"未知错误")}function KH(e,t=0){if(e&&typeof e=="object"&&t<4){const n=e;for(const r of["status","statusCode","status_code","httpStatus"]){const i=n[r];if((typeof i=="number"||typeof i=="string")&&Number(i)===501)return!0}if(n.code==="not_implemented"||n.code==="auth_methods_unavailable"||n.error&&n.error!==e&&KH(n.error,t+1))return!0}return/\b501\b|auth\.methods[^\n]*(?:not implemented|no method|未实现|不支持)/i.test(MO(e))}function Zf(e){if(IO(e))return;const t=Lt().wbApp?.getState?.()?.accounts?.providers;return(Array.isArray(t)?t:Lt().wbProviders?.all?.()||[]).find(r=>r.id===e)}function Hbe(e){return(Lt().wbApp?.getState?.()?.accounts?.accounts||[]).filter(n=>(n?.provider||"workbuddy")===e).length}async function _O(e,t,n){const r=Lt().__TAURI_INTERNALS__;if(!r||typeof r.invoke!="function")throw new Error(a("桌面运行时不可用(Tauri 未初始化)"));const i=await r.invoke("api_request",{request:{method:e,path:t,body:n===void 0?null:n}});if(i&&typeof i=="object"){const o=i;if(o.success===!1)throw i;if(o.success===!0&&Object.hasOwn(o,"data"))return o.data}return i}function Jf(e){return _O("POST","/api/accounts",e)}function cd(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Vbe(e){const t=cd(e);if(!t)return;const n={};for(const r of["id","name","uid","userId","provider"])typeof t[r]=="string"&&(n[r]=t[r]);return n.id||n.uid||n.userId?n:void 0}function qH(e){let t=cd(e);if(t?.success===!1)throw e;t?.success===!0&&Object.hasOwn(t,"data")&&(t=cd(t.data));const n=cd(t?.payload),r=cd(t?.session)||cd(n?.session),i=[t,n,r].filter(h=>!!h);if(i.some(h=>h.canceled===!0||h.state==="canceled"||h.status==="canceled"))return{ok:!1,canceled:!0,silent:i.some(h=>h.silent===!0)};for(const h of i){if(h.error||h.ok===!1||h.success===!1||h.state==="failed"||h.status==="failed"||h.type==="error")throw new Error(qa(h.error||h));if(h.pending===!0||cd(h.pending)||h.accepted===!0||h.done===!1||h.state==="pending"||h.status==="pending")throw new Error(a("登录尚未完成,请继续通过共享登录桥等待结果"))}const o=i.map(h=>Vbe(h.account)).find(Boolean),c=i.find(h=>typeof h.accountUid=="string"&&!!h.accountUid||typeof h.accountId=="string"&&!!h.accountId||typeof h.nickname=="string"&&!!h.nickname);if(!o&&!c&&i.some(h=>(h.flow||h.authUrl)&&h.done!==!0))throw new Error(a("登录尚未完成,请继续通过共享登录桥等待结果"));if(!o&&!c&&t?.ok!==!0)throw new Error(r&&!Object.keys(r).length?a("登录桥返回了空会话,无法确认账号已添加"):a("登录桥未返回已完成的账号或会话,请重试"));const d=h=>{const p=i.map(g=>g[h]).find(g=>typeof g=="string"&&g.trim());return typeof p=="string"?p:void 0},f=i.map(h=>h.proxySaved).find(h=>typeof h=="boolean");return{ok:!0,canceled:!1,account:o,warning:d("warning"),instructions:d("instructions"),...typeof f=="boolean"?{proxySaved:f}:{},session:c?Object.fromEntries(["accountUid","accountId","nickname","edition","provider"].filter(h=>typeof c[h]=="string").map(h=>[h,c[h]])):void 0}}async function Kbe(e,t="cn",n="embedded",r,i){const o=i!==void 0&&i.methodIndex!==void 0;if(IO(e)||o&&!Zf(e))throw new Error(a("该提供商已不在运行时目录中,请返回列表重新选择"));try{const c=Lt().workbuddyDesktop;let d;if(o&&c?.platform!=="web"){const h=Lt().__TAURI_INTERNALS__;if(!h?.invoke)throw new Error(a("桌面运行时不可用(Tauri 未初始化)"));d=await h.invoke("start_login",{provider:e,edition:t,mode:n,socialRestore:r===!0,options:i})}else{if(!c?.startLogin)throw new Error(a("共享登录桥不可用,请重新打开面板"));d=await c.startLogin(t,n,e,r,i)}const f=qH(d);if(o&&!f.canceled){const h=f.account?.id||f.session?.accountUid||f.session?.accountId,p=f.account?.provider||f.session?.provider;if(!h||p&&p!==e)throw new Error(a("登录桥返回了空会话,无法确认账号已添加"))}return f}catch(c){const d=cd(c);if(d?.canceled===!0)return{ok:!1,canceled:!0,silent:d.silent===!0};throw new Error(qa(c))}}function ym(e){return e?.name||e?.uid||e?.userId||""}function DO(){Lt().wbAddAccountModal?.close?.()}async function Kc(e,t){DO(),await Lt().wbApp?.refresh?.(),lr(a("✅ {label}账号已添加{name}",{label:t,name:e?`:${e}`:""}))}const wm=new Map;function _i(e){return{defaultValue:wm.get(e)??"",onChange:t=>{const n=t.currentTarget.value;n?wm.set(e,n):wm.delete(e)}}}function eh(e,t){t?wm.set(e,t):wm.delete(e);const n=document.getElementById(e);(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&(n.value=t)}function xo(e){const t=document.getElementById(e);return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value.trim():(wm.get(e)??"").trim()}function LO(e){for(const t of e)eh(t,"")}const th={edition:"cn",loginMode:"embedded",socialRestore:!1};function GH(e){const t=e?.presetKey||"";return t&&Lt().wbPresetProviders?.presetOf?.(t)||null}function YH(e){const t=e?.presetKey||"";return t&&Lt().wbPresetProviders?.iconOf?.(t)||""}function qbe(e){const t=(Lt().wbProviders?.customList?.()||[]).find(n=>n.id===e);return YH(t)}function Gbe(e){if(!e)return"";try{const t=new URL(e);return t.host+t.pathname.replace(/\/+$/,"")}catch{return e}}function WH(e,t,n){if(e.protocol!==t)return!1;const r=i=>new URL(i.trim()).href.replace(/\/+$/,"");try{return r(e.baseUrl||"")===r(n)}catch{return!1}}const Ybe={provider:"doubaowork",label:a("豆包工作"),desktop:!0,webLogin:{noteHtml:a("在豆包官方页面完成登录,窗口会自动读取完整 Cookie 并加入账号列表;不需要安装豆包工作客户端。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),busyText:a("等待豆包工作登录完成…"),webHint:a("浏览器面板无法读取其它站点的 Cookie,请登录 www.doubao.com 后,使用「填写凭证」粘贴完整 Cookie。")},manualTitle:a("粘贴 Cookie"),manualNote:a("粘贴 www.doubao.com 的完整 Cookie(必须含 sessionid),也支持 Cookie JSON 数组或对象。复用豆包工作账号的额度;Cookie 失效后需重新登录,没有自动续期。"),fields:[{key:"cookie",label:"Cookie",rows:5,placeholder:"sessionid=…; sessionid_ss=…; ttwid=…"},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号昵称")}],desktopNote:a("读取本机已登录豆包工作客户端的 Cookie,每次请求实时读取;客户端需使用 --remote-debugging-port=9342 启动。本软件不修改、关闭或重启客户端。"),desktopHint:a("未开启客户端调试端口时,请使用网页登录或粘贴 Cookie。"),fileImport:{accept:".json,application/json",note:a("选择包含 Cookie 的 JSON 对象,或本软件导出的单账号 JSON 文件。导入后可独立使用,不需要持续运行豆包工作客户端。")}},sl=a("将在新标签页中打开授权页;完成后自动加入账号列表。"),zO=a("将在新标签页中打开授权页;完成后自动加入账号列表。若页面跳回本机地址后账号没有出现,按提示把地址栏里的完整回调地址粘贴回来即可。"),U0=100,Wbe=256,Xbe=e=>e.key==="name"?U0:Wbe,Vl={accept:".json,application/json",note:a("选择包含该提供商凭证的 JSON 文件,或本软件导出的单账号 JSON 文件。导入后凭证保存在网关,可独立使用。")},Qbe={provider:"raccoon",label:"小浣熊",addButton:a("添加小浣熊账号"),webLogin:{noteHtml:a("在打开的官方登录页里完成登录,成功后自动加入账号列表。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),busyText:a("等待小浣熊登录完成…"),webHint:sl},manualTitle:a("粘贴 token / refreshToken"),manualNoteHtml:a('refreshToken 可选,填了到期可自动续期;两者都能从小浣熊客户端登录态文件里取到。'),fields:[{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用凭证里的账号名")},{key:"token",label:"token",rows:3,placeholder:a("粘贴 access_token(一长串 JWT)")},{key:"refreshToken",inputKey:"refresh",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。客户端重新登录后点「刷新 Token」同步。"),fileImport:{accept:".json,application/json",note:a("选择小浣熊客户端的登录态文件 auth.json(Windows:C:\\Users\\<你的用户名>\\.box-agent\\config\\auth.json;macOS / Linux:~/.box-agent/config/auth.json)。导入后凭证直接落在网关、可独立转发,不再依赖本机客户端。")}},Zbe={provider:"catpaw",label:"CatPaw",webLogin:{noteHtml:a("用 CatPaw 账号完成登录(美团 passport),成功后自动加入账号列表。"),button:a("打开 CatPaw 网页登录"),busyText:a("等待 CatPaw 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的美团账号);完成后自动加入列表")}]},manualNote:a("token 是登录态 Cookie;CatPaw 没有刷新机制,过期后需在客户端重新登录。"),fields:[{key:"token",label:"token",rows:3,placeholder:a("CatPaw 的 X-Passport-Token(登录态 Cookie)")},{key:"uid",label:"uid",placeholder:a("必填,CatPaw 账号标识")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用登录名或 uid")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。客户端重新登录后重新导入即可。"),desktopHint:a("读取 ~/.meituan-catpaw/auth.json,需已在 CatPaw 客户端登录"),fileImport:{accept:".json,application/json",note:a("选择 CatPaw 客户端的登录态文件 auth.json(Windows:C:\\Users\\<你的用户名>\\.meituan-catpaw\\auth.json;macOS / Linux:~/.meituan-catpaw/auth.json)。导入后凭证直接落在网关、可独立转发,不再依赖本机客户端。")}},Jbe={provider:"autoclaw",label:a("AutoClaw 国内版"),fileImport:Vl,manualNote:a("token 支持 enc: 前缀(Windows 上自动解密)。未填 refreshToken 无法自动续期。"),smsLogin:{noteHtml:a("用绑定的手机号登录:点「获取验证码」后填入即可。这是国内版官方唯一的登录方式。")},fields:[{key:"token",label:"token",rows:3,placeholder:a("明文 JWT 或 auth.json 里的 enc: 加密值(自动解密)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("没有则无法自动续期")},{key:"deviceId",label:"deviceId",optional:!0,placeholder:a("可选,续期时带上")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用 userId")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。"),desktopHint:a("读取 %APPDATA%/AutoClaw/auth.json 并解密,仅 Windows"),desktopWindowsOnly:!0},eye={provider:"autoclaw-intl",label:a("AutoClaw 国际版"),fileImport:Vl,manualNote:a("国际版与国内版账号体系独立,请填国际版的凭证。未填 refreshToken 无法自动续期。"),oauthLogin:{title:a("网页登录(Zai / Google)"),noteHtml:a("点按钮后先过一次滑块验证(官方风控),随后打开登录页,登录完成即自动添加账号。
这是国际版官方唯一的登录方式;已在客户端登录过的,用「导入桌面端登录态」更快。"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;关窗即取消等待(Google 账号被拒时改用系统浏览器)")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的 Zai / Google 账号);完成后自动加入列表")}],webHint:sl},fields:[{key:"token",label:"token",rows:3,placeholder:a("明文 JWT(国际版账号的 access token)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("没有则无法自动续期")},{key:"deviceId",label:"deviceId",optional:!0,placeholder:a("可选,续期时带上")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用 userId")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。用 Zai / Google 登录客户端的用户走这一条。"),desktopHint:a("读取 %APPDATA%/AutoClaw/auth.json 并解密,仅 Windows"),desktopWindowsOnly:!0};function XH(e){const{provider:t,label:n,siteNote:r}=e;return{provider:t,label:n,desktop:!1,webLogin:{noteHtml:a("打开官方授权页完成设备码授权,登录的是{label}({site})的账号。",{label:n,site:r}),button:a("打开 Qoder 网页登录"),busyText:a("等待 Qoder 授权完成…"),edition:t==="qoder"?"cn":"global",modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口用全新环境,多账号互不影响;关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录账号);完成后自动加入列表")}]},manualTitle:a("使用个人访问令牌(PAT)"),manualNote:a("在{label}的 Qoder 账号设置 → Integrations 生成 PAT(别填 Google / GitHub 的令牌)。两个地区的账号与凭证不通用。",{label:n}),fields:[{key:"pat",label:"Qoder PAT",rows:3,placeholder:a("粘贴 Qoder 个人访问令牌(pt-…)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号昵称或邮箱")}]}}const tye=XH({provider:"qoder",label:a("中国版"),siteNote:"qoder.com.cn"}),nye=XH({provider:"qoder-intl",label:a("国际版"),siteNote:"qoder.com"});function QH(e){const{provider:t,label:n,poolNote:r}=e;return{provider:t,label:n,desktop:!0,webLogin:{noteHtml:a("打开授权页完成确认,账号自动加入 {label}{note}",{label:n,note:r}),button:a("打开 Cline 授权页"),busyText:a("等待 Cline 授权确认…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的 Cline 账号);完成后自动加入列表")}]},manualTitle:a("填写凭证"),manualNote:a("refreshToken 可选,填了可自动续期;两者都能从客户端登录态文件取到。同一个 Cline 账号两个池都能用,这里归入 {label}。",{label:n}),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("粘贴 workos:… 开头的令牌(不带前缀也会自动补上)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选,没有则无法自动续期")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号姓名、邮箱或令牌指纹")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。这一条归入 {label}。",{label:n}),desktopHint:a("读取 ~/.cline/data/settings/providers.json,需已在 Cline 客户端登录"),fileImport:{accept:".json,application/json",note:a("选择 Cline 客户端的登录态文件 providers.json(Windows:C:\\Users\\<你的用户名>\\.cline\\data\\settings\\providers.json;macOS / Linux:~/.cline/data/settings/providers.json)。导入后凭证直接落在网关、可独立转发,不再依赖本机客户端;这一条归入 {label}。",{label:n})}}}function ZH(e){const{provider:t,label:n,site:r,siteNote:i}=e;return{provider:t,label:n,webLogin:{noteHtml:a("打开 Accio {label}的官方登录页({site})并用你的 Accio 账号登录:登录成功后官方页面会跳回本机;同机自动完成,Docker / 远程面板按提示粘贴回调地址即可(授权码只在本机传给网关,界面不显示明文 token)。",{label:n,site:r}),button:a("打开 Accio {label}登录页",{label:n}),busyText:a("等待 Accio {label}登录完成…",{label:n}),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开登录页(会复用浏览器里已登录的 Accio 账号);完成登录后自动加入账号列表,关掉弹窗即取消等待")}],webHint:zO},manualTitle:a("填写凭证"),manualNoteHtml:a("accessToken 是 Accio 的登录凭证(一长串不透明 token,不是 JWT);refreshToken 可选,填了之后到期能自动续期。请填写 {label}账号的凭证 —— {siteNote}(最容易拿到的办法:直接用上方的「网页登录」,不需要手工找 token。)",{label:n,siteNote:i}),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("粘贴 Accio 的 accessToken")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选,没有则无法自动续期")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号昵称或邮箱")}]}}function JH(e){const{provider:t,label:n,site:r,planNote:i}=e;return{provider:t,label:n,fileImport:Vl,desktop:!1,webLogin:{noteHtml:a("打开 ZCode {label}的官方授权页并用你的账号登录。授权结果由 ZCode 服务端记录,网关在后台自动取回凭证并加入账号列表。",{label:n}),button:a("打开 ZCode {label}授权页",{label:n}),busyText:a("等待 ZCode {label}授权完成…",{label:n}),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;授权完成后自动加入账号列表。关掉窗口即取消等待。授权页最后可能提示无法打开 zcode:// 链接,这是正常的 —— 结果已由服务端记下")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的 ZCode 账号);授权完成后自动加入账号列表。页面最后可能提示无法打开 zcode:// 链接,属正常现象")}]},manualTitle:a("填写凭证"),manualNoteHtml:a("本家有两个**互不替代**的凭证,按你要用的功能填,至少填一个:编码套餐 API Key 用于转发推理(打 {site})与查询窗口限额(每 N 小时 / 每周的剩余比例);jwt 用于领取套餐与查询余额(打 zcode.z.ai 的 billing 网关,官方叫 Coding Plan JWT,是一串三段点分的字符串)。余额两把都能查、但读到的东西不同:jwt 读到余额桶与套餐到期,API Key 读到窗口限额;而领取只认 jwt、转发只认 API Key。请填写 {label}账号的凭证 —— {plan}(最容易拿到的办法:直接用上方的「网页登录」—— 它会替你把这个 API Key 换好,两个凭证一起拿到。)",{site:r,label:n,plan:i}),fields:[{key:"accessToken",label:a("编码套餐 API Key"),rows:3,optional:!0,placeholder:a("用于转发;形如 apiKey.secret 两段点分(不填则这个账号不能转发)")},{key:"jwt",label:"Coding Plan JWT",inputKey:"jwt",rows:3,optional:!0,placeholder:a("用于领取套餐与查询余额;不填则这个账号不能领取与查余额")},{key:"userId",label:a("用户 ID"),optional:!0,placeholder:a("可选;用于生成账号 id 与展示名")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动生成")}]}}const rye={provider:"codearts",label:"CodeArts",desktop:!1,webLogin:{noteHtml:a("打开华为云 CodeArts 的官方授权页登录:登录完成后官方页面会把浏览器带回网关自己的 /oauth/callback,网关用一次性授权码换取临时凭据并加入账号列表。
网关跑在另一台机器上时,网页端会提示把地址栏中的最终回调地址直接粘贴回面板。"),button:a("打开 CodeArts 授权页"),busyText:a("等待 CodeArts 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的华为云账号);浏览器与网关不在同一台机器时,按上方说明把最终回调地址粘贴回面板")}],webHint:zO},manualTitle:a("粘贴登录凭据"),manualNoteHtml:a('整份粘贴官方插件 / CLIProxyAPI 落盘的凭据 JSON(形如 {"codearts_provider_credential":{…}},铺平的也行)。
必填:access_key_id、secret_access_key、security_token。要能自动续期,必须连 refresh_token 与 oauth_context 一起粘 —— 临时凭据约一小时到期,缺这半块就续不回来,只能重新登录。'),fields:[{key:"credentialJson",label:a("凭据 JSON"),rows:8,jsonExpand:!0,placeholder:'{"codearts_provider_credential":{"access_key_id":"HSTA…","secret_access_key":"…","security_token":"…","expires_at":"2026-09-27T16:17:00.327Z","domain_id":"…","user_id":"…","user_name":"…","refresh_token":"eyJ…","oauth_context":{…}}}'},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用凭据里的 user_name")}]},sye={provider:"trae",label:"Trae",desktop:!1,webLogin:{noteHtml:a("打开 Trae SOLO 的官方授权页(trae.cn)并用你的 Trae 账号登录:授权完成后官方页面会跳回本机的一个临时端口;同机部署自动接收,Docker / 远程面板请按提示复制地址栏回调地址。"),button:a("打开 Trae 授权页"),busyText:a("等待 Trae 授权完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;授权完成后自动加入账号列表。远程面板可粘贴回调地址。关掉窗口即取消等待。链接 5 分钟内有效,超时或未点就会作废(可重新发起)")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的 Trae 账号);同机完成后自动加入,Docker / 远程面板按提示粘贴地址栏回调地址。")}],webHint:zO},manualTitle:a("填写凭证"),manualNoteHtml:a("accessToken 是 Trae 的 Cloud-IDE-JWT(三段点分),refreshToken 用于到期自动续期(本家 refreshToken 一次一换:换发一次旧的即作废,所以两份程序别同时刷同一个账号)。
手工粘贴时请连 machineId / deviceId 一起填:上游把它们与登录时上传的设备公钥绑在一起判设备,凭空换一对会撞 2xxxx 那族设备绑定拒绝。
没有这三样时的正路是用上方的「网页登录」;容器 / 远程部署形态按提示粘贴地址栏回调地址即可。"),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("Cloud-IDE-JWT(三段点分)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选;填了才能到期自动续期")},{key:"uid",label:a("用户 ID"),optional:!0,placeholder:a("可选;用于去重与展示名(留空时网关会问一次上游)")},{key:"machineId",label:"machineId",optional:!0,placeholder:a("可选;UUID 形态,与凭据同生共死")},{key:"deviceId",label:"deviceId",optional:!0,placeholder:a("可选;纯数字串(上游只收 8–24 位数字)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动用昵称")}]},aye={provider:"loomy",label:"Loomy",fileImport:Vl,smsLogin:{noteHtml:a("用 Loomy 账号绑定的手机号登录:点「获取验证码」后填入即可。这是本家最省事的入口。")},manualNote:a("粘贴的是登录 session(同时是模型网关的 token)。Loomy 没有续期接口,session 有效期约 14 天,过期后重新登录即可。"),fields:[{key:"session",label:"session",rows:3,placeholder:a("登录 session(一长串)")},{key:"userId",label:"userId",optional:!0,placeholder:a("可选,讯飞侧 userid")},{key:"phone",label:a("手机号"),optional:!0,placeholder:a("可选,展示用")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用脱敏手机号或 userId")}],desktop:!1},iye={provider:"kuku",label:"KukuAI",webLogin:{noteHtml:a("在打开的登录页里用百度账号登录 KukuAI 主站(手机验证码 / 扫码均可),登录成功后自动加入账号列表。网关会向百度换发 KukuAI 业务会话令牌(依赖本机已安装库库AI 客户端)。"),button:a("打开网页登录"),busyText:a("等待 KukuAI 登录完成…"),webHint:sl},manualTitle:a("粘贴 Cookie"),manualNote:a("BDUSS 必填;请粘贴**完整 Cookie**(Cookie 编辑器一键导出即可)—— 其中 **PTOKEN 必须保留**,网关要用它向百度换发 KukuAI 业务会话令牌,缺了它模型刷新会报「未登录」。支持整段 Cookie 头、Cookie 编辑器导出的 JSON 数组,或 {BDUSS, STOKEN} 对象。KukuAI 没有刷新机制,登录态过期后重新粘贴即可。"),fields:[{key:"cookie",label:"Cookie",rows:3,placeholder:a("BDUSS=…; STOKEN=…(或 Cookie 编辑器导出的 JSON)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号 uk")}],desktop:!0,desktopHint:a("读取本机 KukuAI 客户端登录态(%APPDATA%\\baidugenflowpro\\Network\\Cookies),需已在 KukuAI 客户端登录"),desktopNote:a("读本机客户端当前登录态(明文 Cookie,无需解密)。客户端运行时 Cookies 文件被独占占用,导入前请先关闭 KukuAI 客户端。"),fileImport:{binary:!0,accept:"",note:a("选择 KukuAI 客户端的 Cookies 文件(%APPDATA%\\baidugenflowpro\\Network\\Cookies):它是**二进制** SQLite 数据库(无扩展名,不是 JSON)。导入时读的是你选中文件的副本、不和运行中的客户端抢占用,因此**无需先关闭客户端**。导入后凭证直接落在网关、可独立转发。")}};function e6(e){const{provider:t,label:n,siteNote:r}=e;return{provider:t,label:n,desktop:!1,manualTitle:a("粘贴 session cookie"),manualNoteHtml:a("粘贴网页登录态 cookie monkeycode_ai_session 的值(在浏览器里复制整段 Cookie 直接粘贴也行,网关会自己剥出值)。
{siteNote}
MonkeyCode 没有续期接口:session 有效期约 30 天(硬限制),过期后重新登录网页、再粘贴一次即可。",{siteNote:r}),fields:[{key:"session",label:"session",rows:3,placeholder:a("monkeycode_ai_session 的值(也可直接粘贴整段 Cookie)")},{key:"imageId",label:a("任务镜像 id"),optional:!0,placeholder:a("可选:发起对话必需,留空则由网关从该账号已有任务里自动发现,发现不到时之后手动补")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用上游返回的账号名或账号 id")}]}}const oye=e6({provider:"monkeycode",label:a("MonkeyCode"),siteNote:a("这里填国内站(monkeycode-ai.com)的账号:请粘贴国内站的 session。国际站(monkeycode-ai.net)是另一家 provider、另一套账号,两边的凭证不通用。")}),lye=e6({provider:"monkeycode-intl",label:a("MonkeyCode 国际版"),siteNote:a("这里填国际站(monkeycode-ai.net)的账号:请粘贴国际站的 session。国内站(monkeycode-ai.com)是另一家 provider、另一套账号,两边的凭证不通用。")}),cye={provider:"commandcode",label:a("Command Code"),fileImport:Vl,desktop:!1,manualTitle:a("粘贴 API Key"),manualNote:a("粘贴 Command Code 的 API Key(user_ 开头;从官方 CLI 的 ~/.commandcode/auth.json 或网页 studio 获取)。整行 / 带引号 / 带 Bearer 前缀地粘都行,网关会自己剥成裸 key。key 不过期、也没有续期接口,失效后重新获取即可;添加时网关会做一次轻量探活,失败不影响添加。"),fields:[{key:"apiKey",label:"apiKey",rows:3,placeholder:a("user_ 开头的 API Key(也可直接粘贴 Authorization: Bearer … 整行)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用 key 尾号")}]},uye={provider:"antigravity",label:a("Antigravity"),desktop:!1,loginProxy:!0,webLogin:{noteHtml:a("在打开的登录页里登录 Google 账号(Antigravity 的授权页),授权完成后自动加入账号列表。"),button:a("打开 Antigravity 网页登录"),busyText:a("等待 Google 授权完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的 Google 账号);完成后自动加入列表")}]},manualTitle:a("粘贴 Google refresh token"),manualNoteHtml:a("粘贴 Antigravity 的 Google refresh token(以 1// 开头;直接粘贴含 refresh_token= 的整行也行)。
这是网页登录之外的手工入口(例如从已登录的官方 IDE 里导出)。refresh token 不会过期,access token 到期由网关自动续期;令牌丢了只能重新走 Google 授权,请妥善保存。"),fields:[{key:"refreshToken",label:"refreshToken",rows:2,placeholder:a("1// 开头的 Google refresh token(也可直接粘贴 refresh_token=… 整行)")},{key:"projectId",label:"projectId",optional:!0,placeholder:a("可选(cloudaicompanionProject):留空由网关自动发现")},{key:"email",label:"email",optional:!0,placeholder:a("可选:账号邮箱,用于展示与身份识别(换新令牌也能认回同一账号)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用邮箱或令牌尾号")}]},dye={provider:"officeace",label:a("OfficeAce 果办"),fileImport:Vl,desktop:!1,webLogin:{noteHtml:a("打开华为云授权页登录:登录完成后网关会自动轮询云端取回授权码并加入账号列表(不需要装 OfficeAce 桌面端,也无需手工回填回调地址)。"),button:a("打开授权页"),busyText:a("等待 OfficeAce 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的华为云账号);授权码由网关轮询云端取回,与浏览器跑在哪台机器无关,完成后自动加入账号列表")}],webHint:sl},manualTitle:a("粘贴网关凭据"),manualNoteHtml:a("从别的机器(或 OfficeAce 桌面端 models.json)取三项贴进来:模型网关基址(baseUrl,形如 https://modelgw-…/v2)与 modelAppKey / modelAppSecret。这三项就能转发(网关凭据不过期);控制面临时凭据(accessKeyId 等)可选,留空则额度/自动续期不可用,但不影响转发。"),fields:[{key:"baseUrl",label:a("模型网关基址"),placeholder:"https://modelgw-…huaweicloud-agentarts.com/v2"},{key:"modelAppKey",label:a("网关 Key"),placeholder:"model_app_key"},{key:"modelAppSecret",label:a("网关 Secret"),placeholder:"model_app_secret"},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空用「OfficeAce 果办」")}]},fye={provider:"orcaterm",label:"OrcaTerm",fileImport:{...Vl,accept:".json,.bin,application/json"},webLogin:{noteHtml:a("在打开的官方授权页里用微信扫码登录(页面会直接显示二维码)。扫码成功后自动加入账号列表。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;扫码完成后自动加入列表,关窗即取消等待"),busyText:a("等待 OrcaTerm 登录完成…"),webHint:sl},desktop:!0,desktopHint:a("读取本机 OrcaTerm 客户端登录态(%APPDATA%\\com.orcaterm-desktop.app\\data.bin),需已在 OrcaTerm 客户端登录"),desktopNote:a("读本机客户端当前登录的 OAuth 令牌(明文 JSON,无需解密)。导入后由网关自动续期,无需跟随客户端的 2 小时时效手动换令牌。"),manualTitle:a("粘贴 accessToken"),manualNoteHtml:a("粘贴 OrcaTerm 的 OAuth accessToken(JWT,三段点分;从桌面客户端 data.bin 或 Web 版 Cookie ot_session 获取)。直接粘贴含 Bearer / ot_session= 的整行也行,网关会自己剥成裸 token。添加后由网关自动续期(上游有续期接口),无需跟随 2 小时时效手动更换。"),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("JWT(三段点分;也可直接粘贴 Bearer 整行或 data.bin 内容)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号昵称或 userId")}]},hye={provider:"chatglm",label:"智谱清言",fileImport:Vl,guestLogin:{noteHtml:a("不需要登录:点下面的按钮,网关会直接在智谱清言换发一份访客凭证并加入账号列表(也可以先填个备注名)。访客凭证可以直接用来对话,免费额度由上游按设备发放。
注意:访客账号没有积分体系 —— 它与「会员积分」「每日登录积分」「活动领取」相关的接口一律需要登录,因此那些能力对访客会如实跳过(账号页的积分、签到中心都不显示读数)。想要积分就用「填写凭证」粘一个已登录账号的令牌,或「导入桌面端登录态」。"),button:a("添加访客账号"),busyText:a("正在换发访客凭证…"),namePlaceholder:a("可选,给这个访客账号起个备注名")},desktop:!0,desktopWindowsOnly:!0,desktopHint:a("读取本机智谱清言客户端登录态(%APPDATA%\\chatglm\\Network\\Cookies),需已在客户端登录"),desktopNote:a("读本机客户端当前的登录态。客户端的 Cookies 是 DPAPI 加密的(Chromium os_crypt),因此仅 Windows 可用;客户端正在运行时可能读不到该文件,先退出客户端再试即可(也可改用「填写凭证」粘贴令牌)。"),manualTitle:a("粘贴访问令牌"),manualNoteHtml:a("粘贴智谱清言的访问令牌(JWT,三段点分)。获取方式:浏览器打开 chatglm.cn 并登录后,在开发者工具的 Application → Cookies 里复制 chatglm_token 的值(也可以直接粘 chatglm_token=…; 整行)。粘贴后会先向上游校验一次,校验通过才落账号;登录账号的积分、签到能力都能用,之后由网关自动续期(上游有续期接口)。"),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("JWT(三段点分;也可直接粘贴 chatglm_token=… 整行)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号昵称")}]};function t6(e){const{provider:t,label:n,site:r,siteNote:i}=e;return{provider:t,label:n,fileImport:Vl,desktop:!1,manualTitle:a("粘贴 API 令牌"),manualNoteHtml:a("粘贴 ModelScope 的 API 令牌(ms- 开头,在 {site} 的「访问令牌」页获取)。
{siteNote}
这枚令牌两用:网关既用它调推理,也用它读账号身份、魔粒余额与每日签到。令牌长期有效、没有续期接口,失效后重新获取再粘一次即可。",{site:r,siteNote:i}),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("ms- 开头的 API 令牌")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用上游账号昵称")}]}}const pye=t6({provider:"modelscope",label:a("ModelScope 国内版"),site:"modelscope.cn",siteNote:a("这里填国内站(modelscope.cn)的账号:请粘贴国内站的令牌。国际站(modelscope.ai)是另一家 provider、另一套账号,两边的令牌不通用。")}),mye=t6({provider:"modelscope-intl",label:a("ModelScope 国际版"),site:"modelscope.ai",siteNote:a("这里填国际站(modelscope.ai)的账号:请粘贴国际站的令牌。国内站(modelscope.cn)是另一家 provider、另一套账号,两边的令牌不通用。")}),gye={provider:"atomcode",label:a("AtomCode"),fileImport:Vl,desktop:!1,webLogin:{noteHtml:a("打开 AtomGit 授权页登录:登录完成后网关会自动轮询代理取回令牌并加入账号列表(授权回调由代理终结,不回到本机,因此无需手工回填回调地址)。"),button:a("打开授权页"),busyText:a("等待 AtomCode 登录完成…")},manualTitle:a("粘贴令牌对"),manualNoteHtml:a("在 AtomGit 的 AtomCode 页面登出后取得两项贴进来:accessToken 与 refreshToken。续期令牌建议填写——本家令牌不是 JWT(约 7 天到期,读不到过期时间),没有它账号无法自动续期,到期只能重新登录。"),fields:[{key:"accessToken",label:a("访问令牌"),placeholder:"access_token"},{key:"refreshToken",label:a("续期令牌"),optional:!0,placeholder:"refresh_token"},{key:"userId",label:a("用户 ID"),optional:!0,placeholder:a("可选,用于生成账号标识")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空用「AtomCode」")}]},vye={provider:"lobsterai",label:a("LobsterAI"),desktop:!1,webLogin:{noteHtml:a("打开 LobsterAI(有道龙虾)的官方登录页(lobsterai.youdao.com)并用你的 LobsterAI 账号登录:登录成功后官方页面会跳回本机并自动加入账号列表 —— 回调落在网关自己的端口上,所以浏览器要与网关在同一台机器上;授权码只在本机传给网关,界面不显示明文 token。"),button:a("打开 LobsterAI 登录页"),busyText:a("等待 LobsterAI 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开登录页(会复用浏览器里已登录的 LobsterAI 账号);完成登录后自动加入账号列表,关掉弹窗即取消等待")}],webHint:sl},fields:[]},n6=[Qbe,Zbe,Jbe,eye,tye,nye,QH({provider:"cline-free",label:"Cline Free",poolNote:a("(免费额度池,模型名带 cline-free/ 前缀)。")}),QH({provider:"cline-pass",label:"Cline Pass",poolNote:a("(订阅池,模型名带 cline-pass/ 前缀,需要账号有对应订阅)。")}),ZH({provider:"accio",label:a("国际版"),site:"www.accio.com",siteNote:a("国际版与国内版是**两套独立的账号**(同一账号体系的两个站点),凭证不通用。")}),ZH({provider:"accio-cn",label:a("国内版"),site:"www.accio-ai.com",siteNote:a("国内版的登录站点是 www.accio-ai.com,与国际版不是同一站。")}),JH({provider:"zcode",label:a("国内版"),site:"open.bigmodel.cn",planNote:a("国内版与**国际版是两套独立的账号与套餐**,凭证与领取的套餐都不通用。")}),JH({provider:"zcode-intl",label:a("国际版"),site:"api.z.ai",planNote:a("国际版的推理站点是 api.z.ai,与国内版不是同一站;套餐也各自独立。")}),rye,sye,aye,iye,oye,lye,cye,uye,dye,fye,hye,pye,mye,gye,vye,Ybe],Ux="workbuddy",jm="custom",r6="WorkBuddy";function xye(e){return n6.find(t=>t.provider===e)}const s6=[{id:"guest",label:a("访客模式(免登录)")},{id:"oauth",label:a("网页登录(Zai / Google)")},{id:"sms",label:a("手机验证码登录")},{id:"web",label:a("网页登录")},{id:"manual",label:a("填写凭证")},{id:"file",label:a("导入凭证文件")},{id:"desktop",label:a("导入桌面端登录态")}],Sm=()=>Lt().workbuddyDesktop?.platform||"";function a6(e){if(e.desktop===!1)return!1;const t=Sm();return!(t==="web"||e.desktopWindowsOnly&&t!=="windows")}function i6(e,t){return s6.filter(n=>n.id==="guest"?!!e.guestLogin:n.id==="oauth"?!!e.oauthLogin:n.id==="sms"?!!e.smsLogin:n.id==="web"?!!e.webLogin&&(!e.webLogin?.region||t===e.webLogin.region):n.id==="file"?!!e.fileImport:n.id==="desktop"?a6(e):!0).map(n=>n.id)}const bye=e=>e.manualTitle||a("填写凭证添加"),yye=e=>e.manualNoteHtml?{html:e.manualNoteHtml}:{text:e.manualNote||""},wye=e=>e.addButton||a("添加 {name} 账号",{name:e.label}),H0=(e,t)=>`${e.provider}-${t.inputKey||t.key}-input`;function jye(e,t){return new Promise((n,r)=>{const i=new FileReader;i.onload=()=>n(String(i.result||"")),i.onerror=()=>r(new Error(t)),i.onabort=()=>r(new DOMException(t,"AbortError")),i.readAsDataURL(e)})}const Sye="agent2api-account";function V0(e){return!!(e&&typeof e=="object"&&!Array.isArray(e)&&e.format===Sye)}function $O(e,t,n){if(e.provider!==t)throw new Error(a("账号文件的提供商与当前选择不一致,请选择对应的提供商后再导入"));const r={...e,provider:t};return n&&(r.name=n),r}function kye(e){return V0(e)?e.provider==="workbuddy"?"cn":e.provider==="workbuddy-intl"?"intl":null:null}const km="max-w-full flex-wrap [&_[data-slot=segmented-item]]:h-7 [&_[data-slot=segmented-item]]:px-3 [&_[data-slot=segmented-item]]:text-[12.5px]",Nye=a("登录态文件路径:~/.box-agent/config/auth.json(Windows:C:\\Users\\<你的用户名>\\.box-agent\\config\\auth.json)");let BO=!1;async function Nm(e,t){if(!BO){BO=!0,e(!0);try{await t()}finally{BO=!1,e(!1)}}}function ud({html:e,text:t}){return e?s.jsx("p",{dangerouslySetInnerHTML:{__html:e}}):s.jsx("p",{children:t||""})}function Cye(e,t,n){let r;try{r=JSON.parse(t)}catch(i){return lr(a("{name} 不是合法 JSON:{reason}",{name:e.label,reason:qa(i)}),"err"),!1}return!r||typeof r!="object"||Array.isArray(r)?(lr(a("{name}要粘一个 JSON 对象(形如 {sample})",{name:e.label,sample:'{"codearts_provider_credential":{…}}'}),"err"),!1):(Object.assign(n,r),!0)}function Aye({config:e,region:t,visible:n}){const r=e.provider,[i,o]=v.useState(!1),[c,d]=v.useState(""),[f,h]=v.useState(()=>xm(void 0)),p=yye(e),g=e.fields.map(y=>H0(e,y));async function x(){const y={provider:e.provider};e.regionOptions?.length&&(y.mode=t);for(const j of e.fields){const w=xo(H0(e,j));if(!j.optional&&!w){lr(a("请填写 {label}",{label:j.label}),"err");return}if(w){if(j.jsonExpand){if(!Cye(j,w,y))return;continue}y[j.key]=w}}if(e.loginProxy)try{y.proxy=ld(f)}catch(j){lr(a("添加失败:{reason}",{reason:qa(j)}),"err");return}await Nm(o,async()=>{try{const j=await Jf(y);LO(g),d(""),await Kc(ym(j?.account),e.label)}catch(j){lr(a("添加失败:{reason}",{reason:qa(j)}),"err")}})}return s.jsxs(Ln,{hidden:!n,onClick:y=>{y.target.closest("[data-raccoon-hint]")&&(y.preventDefault(),d(Nye))},children:[s.jsx("h3",{children:bye(e)}),s.jsx(ud,{...p}),e.fields.map(y=>{const j=H0(e,y),w=y.optional?"":a("(必填)");return s.jsxs("div",{className:`field-row${y.rows?" stack":""}`,children:[s.jsxs(Ie,{htmlFor:j,children:[y.label,w]}),y.rows?s.jsx(Ea,{id:j,rows:y.rows,placeholder:y.placeholder,..._i(j)}):s.jsx(Be,{id:j,type:"text",maxLength:Xbe(y),placeholder:y.placeholder,..._i(j)})]},j)}),e.loginProxy?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[s.jsx(Ie,{children:a("登录出网代理")}),s.jsx(Fx,{draft:f,onChange:h,idPrefix:`${r}-manual-proxy`}),s.jsx("p",{className:"detail",children:a("添加时要用它出网校验凭证(例如 Antigravity 要打一次 Google 的 token 端点)。无头服务器上没有系统代理,这里不选就走直连。")})]}):null,s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx(B,{id:`${r}-add-button`,onClick:()=>{x()},disabled:i,children:i?a("添加中…"):wye(e)}),s.jsx("span",{className:"detail",id:`${r}-add-hint`,children:c})]})]})}function Eye({config:e,visible:t}){const n=e.provider,[r,i]=v.useState(!1);if(!a6(e)||!e.desktopNote)return null;async function o(){await Nm(i,async()=>{try{const c=await Jf({provider:e.provider,importDesktop:!0});await Kc(c?.account?.name||"",e.label)}catch(c){lr(a("导入失败:{reason}",{reason:qa(c)}),"err")}})}return s.jsxs(Ln,{hidden:!t,children:[s.jsx("h3",{children:a("从本机导入桌面端登录态")}),s.jsx("p",{children:e.desktopNote}),s.jsx(ws,{orientation:"horizontal",className:"field-row",children:s.jsx(B,{id:`${n}-desktop-button`,title:e.desktopHint,onClick:()=>{o()},disabled:r,children:a(r?"导入中…":"从本机导入桌面端登录态")})})]})}function Tye({config:e,visible:t}){const n=e.guestLogin,[r,i]=v.useState(!1);if(!n)return null;const o=H0(e,{key:"name"});async function c(){await Nm(i,async()=>{const f=document.getElementById(o)?.value.trim()||"";try{const h=await Jf({provider:e.provider,guest:!0,...f?{name:f}:{}});await Kc(h?.account?.name||"",e.label)}catch(h){lr(a("添加失败:{reason}",{reason:qa(h)}),"err")}})}return s.jsxs(Ln,{hidden:!t,children:[s.jsx("h3",{children:a("访客模式")}),n.noteHtml?s.jsx(ud,{html:n.noteHtml}):null,s.jsxs("div",{className:"form-field",children:[s.jsx(Ie,{htmlFor:o,children:a("备注名")}),s.jsx(Be,{id:o,type:"text",maxLength:U0,placeholder:n.namePlaceholder||a("可选"),..._i(o)})]}),s.jsx(ws,{orientation:"horizontal",className:"field-row",children:s.jsx(B,{id:`${e.provider}-guest-button`,onClick:()=>{c()},disabled:r,children:r?n.busyText||a("正在添加…"):n.button})})]})}function Oye(e){const t=e.indexOf(",");return t>=0?e.slice(t+1):e}function Rye({config:e,visible:t}){const[n,r]=v.useState(!1),[i,o]=v.useState(""),c=v.useRef(null),d=e.fileImport,f=`${e.provider}-file-name`;if(!d)return null;async function h(p){const g=e.fileImport;g&&await Nm(r,async()=>{try{const x=xo(f),y={provider:e.provider,authFileName:p.name};if(g.binary)if((await p.slice(0,64).text()).trimStart().startsWith("{")){const S=JSON.parse(await p.text());if(!V0(S))throw new Error(a("请选择客户端凭证文件,或本软件导出的单账号 JSON 文件"));Object.assign(y,$O(S,e.provider,x))}else y.authFileB64=Oye(await jye(p,a("文件读取失败")));else{const w=await p.text();let S;try{S=JSON.parse(w)}catch{lr(a("选择的文件不是合法 JSON"),"err");return}if(!S||typeof S!="object"||Array.isArray(S)){lr(a("不是有效的凭证文件:内容要是一个 JSON 对象"),"err");return}V0(S)?Object.assign(y,$O(S,e.provider,x)):y.authFileContent=w}x&&(y.name=x);const j=await Jf(y);o(""),await Kc(ym(j?.account),e.label)}catch(x){lr(a("导入失败:{reason}",{reason:qa(x)}),"err")}})}return s.jsxs(Ln,{hidden:!t,children:[s.jsx("h3",{children:a("导入凭证文件")}),s.jsx(ud,{text:d.note}),s.jsx("p",{className:"detail",children:a("也支持本软件导出的单账号 JSON 文件,保留账号凭证与附加信息。")}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{className:"lb-inline",htmlFor:f,children:a("备注名")}),s.jsx(Be,{id:f,type:"text",maxLength:U0,placeholder:a("可选,留空则用文件里的昵称"),..._i(f)})]}),s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx(Be,{ref:c,type:"file",accept:d.accept,hidden:!0,onChange:p=>{const g=p.target.files?.[0];p.target.value="",g&&(o(g.name),h(g))}}),s.jsx(B,{onClick:()=>c.current?.click(),disabled:n,children:a(n?"导入中…":"选择凭证文件导入")}),s.jsx("span",{className:"detail",children:i})]})]})}function Pye({config:e,mode:t,onModeChange:n,region:r,visible:i}){const o=e.webLogin,c=e.provider,d=v.useRef(t),f=v.useRef(r),h=v.useRef(null),[p,g]=v.useState(()=>xm(void 0)),x=v.useRef(p);x.current=p;const[y,j]=v.useState("");d.current=t,f.current=r;const w=Sm()==="web",[S,N]=v.useState(()=>({label:o?.button||"",hint:w?o?.webHint||sl:o?.hint||o?.modes?.[0]?.hint||"",disabled:!1,waiting:!1}));return v.useEffect(()=>{const A=Lt().wbWebLogin;if(!A||!o)return;const E=o.modes;return h.current=A.create({provider:c,buttonId:`${c}-web-button`,cancelId:`${c}-web-cancel`,hintId:`${c}-web-hint`,busyText:o.busyText,onStateChange:N,texts:()=>{const O=E?.find(R=>R.value===d.current);return{button:o.button,hint:w?o.webHint||sl:O?.hint||o.hint||""}},start:()=>{let O;if(e.loginProxy){try{O={proxy:ld(x.current)}}catch(R){throw j(qa(R)),R}j("")}return Lt().workbuddyDesktop?.startLogin(o.edition||f.current||"cn",d.current||"embedded",c,void 0,O)},onSuccess:async O=>{DO(),await Lt().wbApp?.refresh?.();const R=O?.payload?.warning;R?lr(a("账号已添加,但请留意:{warning}",{warning:R}),"err"):lr(a("✅ {label}账号已添加",{label:e.label}))}})??null,()=>{h.current?.dispose(),h.current=null}},[]),v.useEffect(()=>{h.current?.syncTexts()},[t]),o?s.jsxs(Ln,{hidden:!i,children:[s.jsx("h3",{children:a("网页登录")}),s.jsx(ud,{html:o.noteHtml}),o.modes?.length&&!w?s.jsxs("div",{className:"flex flex-col gap-2.5 border-l-2 border-border pl-[11px]",children:[s.jsx("span",{className:"text-[12.5px] text-subtle",children:a("打开方式")}),s.jsx(dn,{"aria-label":a("{label} 网页登录的打开方式",{label:e.label}),options:o.modes,value:t,onValueChange:n})]}):null,e.loginProxy?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[s.jsx(Ie,{children:a("登录出网代理")}),s.jsx(Fx,{draft:p,onChange:A=>{g(A),j("")},idPrefix:`${c}-login-proxy`,allowRotate:!1}),s.jsx("p",{className:"detail",children:a("授权页、换证与取账号信息都走这条线路。无头服务器上没有系统代理,这里不选就走直连(多数网络里到不了 Google)。")}),y?s.jsx(It,{variant:"destructive",children:s.jsx(Xo,{children:y})}):null]}):null,s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsxs(B,{id:`${c}-web-button`,disabled:S.disabled||w&&e.provider==="doubaowork",onClick:()=>h.current?.start(),children:[S.waiting&&s.jsx(Ls,{}),S.label]}),s.jsx(B,{id:`${c}-web-cancel`,variant:"outline",hidden:!S.waiting,onClick:()=>h.current?.cancel(),children:a("取消等待")}),s.jsx("span",{className:"detail",id:`${c}-web-hint`,children:S.hint})]})]}):null}function Iye({config:e,visible:t}){const n=e.smsLogin,r=e.provider;return v.useEffect(()=>{n&&Lt().wbSmsLogin?.create({provider:r,onSuccess:i=>Kc(ym(i?.account),e.label)})},[]),n?s.jsxs(Ln,{hidden:!t,children:[s.jsx("h3",{children:a("手机验证码登录")}),s.jsx(ud,{html:n.noteHtml,text:a("用 AutoClaw 账号绑定的手机号登录:点击「获取验证码」,收到短信后填入下方并登录。验证码由本机直接提交给官方接口,界面不显示 token。")}),s.jsxs("div",{className:"sms-form",children:[s.jsxs("div",{className:"sms-field",children:[s.jsxs(Ie,{className:"lb",htmlFor:`${r}-sms-phone`,children:[a("手机号"),s.jsx("i",{className:"req",children:"*"})]}),s.jsxs(uo,{children:[s.jsx(ho,{id:`${r}-sms-phone`,type:"text",maxLength:11,placeholder:a("11 位大陆手机号"),..._i(`${r}-sms-phone`)}),s.jsx(fo,{align:"inline-end",children:s.jsx(SB,{id:`${r}-sms-send`,className:"text-primary-fg",children:a("获取验证码")})})]})]}),s.jsxs("div",{className:"sms-field",children:[s.jsxs(Ie,{className:"lb",htmlFor:`${r}-sms-code`,children:[a("验证码"),s.jsx("i",{className:"req",children:"*"})]}),s.jsxs("div",{className:"sms-pair",children:[s.jsx(Be,{id:`${r}-sms-code`,className:"sms-code",type:"text",maxLength:6,placeholder:a("6 位数字")}),s.jsx(Ie,{className:"lb-inline",htmlFor:`${r}-sms-name`,children:a("备注名")}),s.jsx(Be,{id:`${r}-sms-name`,className:"sms-name",type:"text",placeholder:a("可选,留空则用脱敏手机号"),..._i(`${r}-sms-name`)})]})]}),s.jsxs("div",{className:"sms-foot",children:[s.jsx(B,{id:`${r}-sms-submit`,children:a("登录并添加")}),s.jsx("span",{className:"detail sms-hint",id:`${r}-sms-hint`})]})]})]}):null}function Mye({config:e,mode:t,onModeChange:n,visible:r}){const i=e.oauthLogin,o=e.provider,c=v.useRef(t),d=v.useRef(null);c.current=t;const f=Sm()==="web",h=()=>f?i?.webHint||sl:i?.modes?.find(p=>p.value===c.current)?.hint||i?.hint||"";return v.useEffect(()=>{const p=Lt().wbAutoclawOauth;!p||!i||(d.current=p.create({provider:o,mode:()=>c.current||"embedded",hint:h,cancelId:`${o}-oauth-cancel`,onSuccess:()=>Kc("",e.label)})??null)},[]),v.useEffect(()=>{d.current?.syncTexts()},[t]),i?s.jsxs(Ln,{hidden:!r,children:[s.jsx("h3",{children:i.title||a("网页登录")}),s.jsx(ud,{html:i.noteHtml}),i.modes?.length&&!f?s.jsxs("div",{className:"flex flex-col gap-2.5 border-l-2 border-border pl-[11px]",children:[s.jsx("span",{className:"text-[12.5px] text-subtle",children:a("打开方式")}),s.jsx(dn,{"aria-label":a("{label} 网页登录的打开方式",{label:e.label}),options:i.modes,value:t,onValueChange:n})]}):null,s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx(B,{id:`${o}-oauth-zai`,children:a("使用 Zai 账号登录")}),s.jsx(B,{id:`${o}-oauth-google`,variant:"outline",children:a("使用 Google 账号登录")}),s.jsx(B,{id:`${o}-oauth-cancel`,variant:"outline",hidden:!0,children:a("取消")})]}),s.jsx(ws,{orientation:"horizontal",className:"field-row",children:s.jsx("span",{className:"detail",id:`${o}-oauth-hint`,children:h()})})]}):null}function _ye({config:e,active:t}){const n=e.regionOptions?.[0]?.value??"",[r,i]=v.useState(n),[o,c]=v.useState(()=>i6(e,n)[0]),[d,f]=v.useState(e.webLogin?.modes?.[0]?.value??""),[h,p]=v.useState(e.oauthLogin?.modes?.[0]?.value??""),g=i6(e,r),x=g.includes(o)?o:g[0],y=v.useMemo(()=>s6.filter(j=>g.includes(j.id)).map(j=>({value:j.id,label:j.label})),[g.join(",")]);return s.jsxs("div",{className:"add-provider-block",hidden:!t,children:[e.regionOptions?.length?s.jsxs(Ln,{children:[s.jsx("h3",{children:a("地区")}),s.jsx(dn,{"aria-label":a("{label} 账号地区",{label:e.label}),className:km,options:e.regionOptions,value:r,onValueChange:i})]}):null,s.jsxs(Ln,{children:[s.jsx("h3",{children:a("添加方式")}),s.jsx(dn,{"aria-label":a("{label} 账号的添加方式",{label:e.label}),className:km,options:y,value:x,onValueChange:j=>c(j)})]}),s.jsx(Tye,{config:e,visible:x==="guest"}),s.jsx(Mye,{config:e,mode:h,onModeChange:p,visible:x==="oauth"}),s.jsx(Iye,{config:e,visible:x==="sms"}),s.jsx(Pye,{config:e,mode:d,onModeChange:f,region:r,visible:x==="web"}),s.jsx(Aye,{config:e,region:r,visible:x==="manual"}),s.jsx(Rye,{config:e,visible:x==="file"}),s.jsx(Eye,{config:e,visible:x==="desktop"})]})}const Dye=a("官方客户端凭证目录:Windows 是 C:\\Users\\<你的用户名>\\AppData\\Local\\CodeBuddyExtension\\Data\\Public\\auth,macOS 是 ~/Library/Application Support/CodeBuddyExtension/Data/Public/auth"),K0="workbuddy-file-name";function FO(e,t,n){const r=e[n],i=[];r&&typeof r=="object"&&!Array.isArray(r)&&i.push(r),i.push(e);for(const o of i)for(const c of t){const d=o[c];if(typeof d=="string"&&d.trim())return d.trim()}return""}function Lye(e){const t=FO(e,["domain"],"auth");return/workbuddy\.ai/i.test(t)?"intl":/workbuddy\.cn|codebuddy\.cn/i.test(t)?"cn":null}function zye({edition:e,visible:t}){const[n,r]=v.useState(!1),[i,o]=v.useState(""),c=v.useRef(null);async function d(f){await Nm(r,async()=>{try{let h;try{h=JSON.parse(await f.text())}catch{lr(a("选择的文件不是合法 JSON"),"err");return}if(!h||typeof h!="object"||Array.isArray(h)){lr(a("不是有效的凭证文件:内容要是一个 JSON 对象"),"err");return}const p=h,g=FO(p,["accessToken","token","access_token"],"auth"),x=FO(p,["uid"],"account");if(!g||!x){lr(a("不是有效的凭证文件:需要包含 accessToken 与 uid"),"err");return}const y=kye(p)??Lye(p),j=y??e;y&&y!==e&&lr(a("文件是{edition}凭证,已按该版本导入",{edition:a(y==="intl"?"国际版":"国内版")}),"warn");const w=xo(K0),S=V0(h)?$O(p,Hx(j),w):{...p,provider:Hx(j)};w&&(S.name=w);const N=await Jf(S);o(""),await Kc(ym(N?.account),j==="intl"?"WorkBuddy AI":"WorkBuddy")}catch(h){lr(a("导入失败:{reason}",{reason:qa(h)}),"err")}})}return s.jsxs(Ln,{hidden:!t,children:[s.jsx("h3",{children:a("导入凭证文件")}),s.jsx(ud,{text:a("选择官方客户端的登录态凭证文件(workbuddy-desktop.info / workbuddy-desktop-ai.info)或 wb2api 导出的账号 JSON(嵌套 / 扁平形均可)。")}),s.jsx("p",{className:"detail",children:a("也支持本软件导出的单账号 JSON 文件,保留账号凭证与附加信息。")}),s.jsx("p",{className:"detail",children:s.jsx("a",{href:"#",onClick:f=>{f.preventDefault(),o(Dye)},children:a("凭证文件在哪?")})}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{className:"lb-inline",htmlFor:K0,children:a("备注名")}),s.jsx(Be,{id:K0,type:"text",maxLength:100,placeholder:a("可选,留空则用文件里的昵称"),..._i(K0)})]}),s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx(Be,{ref:c,type:"file",accept:".info,.json,application/json",hidden:!0,onChange:f=>{const h=f.target.files?.[0];f.target.value="",h&&d(h)}}),s.jsx(B,{onClick:()=>c.current?.click(),disabled:n,children:a(n?"导入中…":"选择凭证文件导入")}),s.jsx("span",{className:"detail",children:i})]})]})}function $ye({edition:e,visible:t}){const[n,r]=v.useState(!1);async function i(){await Nm(r,async()=>{try{const o=await Jf({provider:Hx(e),importDesktop:!0});await Kc(ym(o?.account),e==="intl"?"WorkBuddy AI":"WorkBuddy")}catch(o){lr(a("导入失败:{reason}",{reason:qa(o)}),"err")}})}return s.jsxs(Ln,{hidden:!t,children:[s.jsx("h3",{children:a("从本机导入桌面端登录态")}),s.jsx(ud,{text:a("读本机官方客户端(Tencent WorkBuddy / WorkBuddy AI)当前登录的账号:自动定位其凭证目录里最新的登录态文件(需已在本机官方客户端登录)。导入后由网关自动续期,无需跟随 2 小时时效手动换令牌。")}),s.jsx(ws,{orientation:"horizontal",className:"field-row",children:s.jsx(B,{onClick:()=>{i()},disabled:n,children:a(n?"导入中…":"从本机导入桌面端登录态")})})]})}function Hx(e){return e==="intl"?"workbuddy-intl":"workbuddy"}function Bye({active:e}){const[t,n]=v.useState(th.edition),[r,i]=v.useState(th.loginMode),[o,c]=v.useState(th.socialRestore),d=Sm()==="web",[f,h]=v.useState(()=>({label:a("打开网页登录"),hint:d?sl:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),disabled:!1,waiting:!1})),[p,g]=v.useState("web"),x=v.useRef(t),y=v.useRef(r),j=v.useRef(o),w=v.useRef(null);x.current=t,y.current=r,j.current=o,v.useEffect(()=>{const P=Lt().wbWebLogin;if(P)return w.current=P.create({get provider(){return Hx(x.current)},buttonId:"web-login-button",cancelId:"web-login-cancel",hintId:"web-login-hint",busyText:a("等待网页登录…"),onStateChange:h,texts:()=>{if(d)return{button:a("打开网页登录"),hint:sl};const M=y.current==="external";return{button:a(M?"在浏览器中打开登录页":"打开网页登录"),hint:a(M?"系统浏览器打开(复用已登录账号);完成后自动加入列表":"内嵌窗口打开;完成后自动加入列表,关窗即取消等待")}},start:()=>Lt().workbuddyDesktop?.startLogin(x.current,y.current,Hx(x.current),j.current),onSuccess:async()=>{const M=x.current==="intl"?a("国际版"):a("国内版");DO(),await Lt().wbApp?.refresh?.(),lr(a("✅ 登录成功,{edition}账号已加入列表",{edition:M}))}})??null,()=>{w.current?.dispose(),w.current=null}},[]),v.useEffect(()=>{w.current?.syncTexts()},[t,r]);function S(P){const M=P==="intl"?"external":"embedded";n(P),th.edition=P,i(M),th.loginMode=M}function N(P){const M=P==="external"?"external":"embedded";i(M),th.loginMode=M}const A=t==="intl",O=A&&r==="embedded",R=a(O?"国际版登录页默认只显示邮箱登录,勾选后恢复 Google / GitHub / X 入口":A?"只有「内嵌窗口」能恢复第三方入口:系统浏览器里我们无法改动登录页":"国内版登录页没有 Google / GitHub 入口(它用微信 / 手机号 / 邮箱登录)"),T=p==="desktop"&&Sm()==="web"?"web":p;return s.jsxs("div",{className:"add-provider-block",hidden:!e,children:[s.jsxs(Ln,{children:[s.jsx("h3",{children:a("账号版本")}),s.jsx("p",{children:a("两版账号可同时保存,各自一份模型清单(国内版与国际版是两家提供商,可分别启用与映射)。")}),s.jsx(dn,{"aria-label":a("账号版本"),className:km,options:[{value:"cn",label:a("国内版(WorkBuddy)")},{value:"intl",label:a("国际版(WorkBuddy AI)")}],value:t,onValueChange:P=>S(P)})]}),s.jsxs(Ln,{children:[s.jsx("h3",{children:a("添加方式")}),s.jsx(dn,{"aria-label":a("{label} 账号的添加方式",{label:"WorkBuddy"}),className:km,options:[{value:"web",label:a("网页登录")},{value:"file",label:a("导入凭证文件")},...Sm()!=="web"?[{value:"desktop",label:a("导入桌面端登录态")}]:[]],value:T,onValueChange:P=>g(P)})]}),s.jsxs(Ln,{hidden:T!=="web",children:[s.jsx("h3",{children:a("网页登录")}),s.jsx("p",{children:a("完成登录后自动加入账号列表,昵称取自上游。")}),d?null:s.jsxs(s.Fragment,{children:[s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx("span",{className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("打开方式")}),s.jsx(dn,{"aria-label":a("网页登录的打开方式"),className:km,options:[{value:"embedded",label:a("内嵌窗口")},{value:"external",label:a("系统默认浏览器")}],value:r,onValueChange:N}),s.jsxs(Ie,{className:"flex items-center gap-2",title:R,children:[s.jsx(cn,{checked:o,disabled:!O,onCheckedChange:P=>{c(P),th.socialRestore=P}}),s.jsx("span",{className:"text-[12.5px] text-subtle",children:a("恢复 Google / GitHub 入口")})]})]}),s.jsx("p",{children:a("系统浏览器可复用已有登录态(国际版推荐);内嵌窗口更干净。")})]}),s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsxs(B,{id:"web-login-button",disabled:f.disabled,onClick:()=>w.current?.start(),children:[f.waiting&&s.jsx(Ls,{}),f.label]}),s.jsx(B,{id:"web-login-cancel",variant:"outline",hidden:!f.waiting,onClick:()=>w.current?.cancel(),children:a("取消等待")}),s.jsx("span",{className:"detail",id:"web-login-hint",children:f.hint})]})]}),s.jsx(zye,{edition:t,visible:T==="file"}),s.jsx($ye,{edition:t,visible:T==="desktop"})]})}const Cm="proxy",nh="web",q0="preset",G0="custom",Fye="import",Vx="preset:",UO="__new__";function Uye(e){return e===q0||e===G0||e===nh?e:Cm}const qc={workbuddy:"assets/providers/workbuddy.png","workbuddy-intl":"assets/providers/workbuddy.png",raccoon:"assets/providers/raccoon.png",catpaw:"assets/providers/catpaw.png",autoclaw:"assets/providers/autoclaw.png","autoclaw-intl":"assets/providers/autoclaw.png",qoder:"assets/providers/qoder.png","qoder-intl":"assets/providers/qoder.png","cline-free":"assets/providers/cline.png","cline-pass":"assets/providers/cline.png",accio:"assets/providers/accio.png","accio-cn":"assets/providers/accio.png",zcode:"assets/providers/zcode.png","zcode-intl":"assets/providers/zcode.png",codearts:"assets/providers/codearts.png",trae:"assets/providers/trae.png",loomy:"assets/providers/loomy.png",kuku:"assets/providers/kuku.png",monkeycode:"assets/providers/monkeycode.png","monkeycode-intl":"assets/providers/monkeycode.png",commandcode:"assets/providers/commandcode.png",antigravity:"assets/providers/antigravity.png",officeace:"assets/providers/officeace.png",orcaterm:"assets/providers/orcaterm.png",chatglm:"assets/providers/chatglm.png","deepseek-web":"assets/providers/deepseek.png",modelscope:"assets/providers/modelscope.png","modelscope-intl":"assets/providers/modelscope.png",atomcode:"assets/providers/atomcode.png",lobsterai:"assets/providers/lobsterai.png",doubaowork:"assets/providers/doubaowork.png",cursor:"assets/providers/cursor.svg",kiro:"assets/providers/kiro.svg",devin:"assets/providers/devin.svg",factory:"assets/providers/factory.svg",zed:"assets/providers/zed.svg",grok:"assets/providers/grok.svg","minimax-code":"assets/providers/minimax-code.svg","minimax-code-global":"assets/providers/minimax-code.svg",qwenwork:"assets/providers/qwenwork.svg","qwenwork-enterprise":"assets/providers/qwenwork.svg","kimi-work":"assets/providers/kimi-work.svg",opendesign:"assets/providers/opendesign.svg","nous-portal":"assets/providers/nous-portal.svg","claude-subscription":"assets/providers/anthropic.png","codex-subscription":"assets/providers/openai.png","chatgpt-subscription":"assets/providers/openai.png","copilot-subscription":"assets/providers/copilot.svg","gemini-subscription":"assets/providers/gemini-cli.svg"},Hye=new Set(["cline-pass"]);function HO(e){const t=Lt().wbProviders;if(e===q0)return(Lt().wbPresetProviders?.list||[]).map(f=>({id:Vx+f.key,label:f.name,count:0,preset:!0}));if(e===G0)return(t?.customList?.()||[]).map(f=>({id:f.id,label:f.name||f.id,count:Hbe(f.id),custom:!0,icon:YH(f),site:Gbe(f.baseUrl),template:GH(f)?.name}));const n=(t?.all?.()||[]).filter(f=>!IO(String(f?.id||""))).filter(f=>f.category==="web"==(e===nh)).filter(f=>e===nh||!Hye.has(String(f?.id||""))),r=(f,h)=>f==="minimax-code"?a("MiniMax Code 国内版"):f==="minimax-code-global"?a("MiniMax Code 国际版"):f==="qwenwork"?a("QwenWork 千问办公"):f==="qwenwork-enterprise"?a("QwenWork 千问办公企业版"):f===Ux?r6:a(Lt().wbProviders?.labelOf?.(f)||h),o=n.map(f=>{const h=String(f.id||"");return{id:h,label:r(h,String(f.label||f.id||"")),count:Number(f.count)||0}}).filter(f=>f.id!=="workbuddy-intl"),c=o.findIndex(f=>f.id==="autoclaw-intl"),d=o.findIndex(f=>f.id==="autoclaw");return d>=0&&c>d&&o.splice(d+1,0,o.splice(c,1)[0]),o}function Vye({item:e}){const t=e.id.startsWith(Vx)?Lt().wbPresetProviders?.iconOf?.(e.id.slice(Vx.length))||"":e.icon||qc[e.id];if(t)return s.jsx("span",{className:"add-provider-logo has-icon",children:s.jsx("img",{src:t,alt:"",loading:"lazy"})});const n=String(e.label||"?").trim().slice(0,1).toUpperCase()||"?";return s.jsx("span",{className:"add-provider-logo",children:n})}function Kye(e){return e.preset?a("使用模板新建提供商"):e.custom?e.count?a("{n} 个账号,点击添加",{n:e.count}):a("点击添加账号"):e.count?a("{n} 个账号",{n:e.count}):a("还没有账号")}function qye({item:e,onPick:t}){return s.jsxs(kx,{render:s.jsx(B,{variant:"outline"}),variant:"outline",className:"add-provider-card h-auto whitespace-normal text-left","data-provider":e.id,title:[e.label,e.site,e.template].filter(Boolean).join(" · "),role:"option",onClick:()=>t(e.id),children:[s.jsx(Vye,{item:e}),s.jsxs("span",{className:"add-provider-info",children:[s.jsx("span",{className:"add-provider-name",children:e.label}),e.site?s.jsx("span",{className:"add-provider-meta",children:[e.site,e.template].filter(Boolean).join(" · ")}):null,s.jsx("span",{className:"add-provider-meta",children:Kye(e)})]}),s.jsx("span",{className:"add-provider-go",children:"›"})]})}function Gye({onPick:e}){return s.jsxs(kx,{render:s.jsx(B,{variant:"dashed"}),variant:"outline",className:"add-provider-card is-new h-auto whitespace-normal text-left","data-provider":UO,role:"option",onClick:()=>e(UO),children:[s.jsx("span",{className:"add-provider-logo is-new",children:"+"}),s.jsxs("span",{className:"add-provider-info",children:[s.jsx("span",{className:"add-provider-name",children:a("新建自定义提供商")}),s.jsx("span",{className:"add-provider-meta",children:a("接入一个兼容上游")})]}),s.jsx("span",{className:"add-provider-go",children:"›"})]})}function Yye({accountType:e,onAccountTypeChange:t,search:n,onSearchChange:r,onPick:i,version:o,importing:c,importPanel:d}){const f=v.useMemo(()=>HO(Cm).length>0,[o]),h=v.useMemo(()=>HO(nh).length>0,[o]),g=e===Cm&&!f||e===nh&&!h?h?nh:q0:e,x=v.useMemo(()=>HO(g),[g,o]),y=n.trim().toLowerCase(),j=x.filter(S=>!y||[S.label,S.site,S.template].filter(Boolean).join(" ").toLowerCase().includes(y)),w=e===G0&&!y;return s.jsxs(Ln,{children:[s.jsx("h3",{children:a("选择提供商")}),s.jsxs("div",{className:"add-pick-row",style:c?{display:"none"}:void 0,children:[s.jsx(dn,{"aria-label":a("账号类型"),className:km,options:[...f?[{value:Cm,label:"Agent"}]:[],...h?[{value:nh,label:"Web"}]:[],{value:q0,label:a("API 模板")},{value:G0,label:a("已建 API")}],value:g,onValueChange:S=>t(Uye(S))}),s.jsx("span",{id:"add-search-wrap",className:"add-provider-search ml-auto max-w-[340px] min-w-0 flex-[1_1_200px]",children:s.jsxs(uo,{children:[s.jsx(fo,{children:"⌕"}),s.jsx(ho,{id:"add-provider-search",type:"search",placeholder:a("搜索提供商…"),autoComplete:"off","aria-label":a("搜索提供商"),value:n,onChange:S=>r(S.currentTarget.value)})]})})]}),d,s.jsxs("div",{className:"add-provider-grid",id:"add-provider-grid",role:"listbox","aria-label":a("选择要添加账号的提供商"),style:c?{display:"none"}:void 0,children:[w?s.jsx(Gye,{onPick:i}):null,j.map(S=>s.jsx(qye,{item:S,onPick:i},S.id)),!j.length&&y?s.jsx(zt,{className:"add-provider-empty",children:a("没有匹配「{keyword}」的提供商",{keyword:n.trim()})}):null,!j.length&&!y&&g===Cm?s.jsxs(zt,{className:"add-provider-empty",children:[s.jsx("p",{className:"mb-2",children:a("请安装并启用对应的提供商插件;列表为空时请刷新后重试。")}),s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"text-primary underline underline-offset-2",onClick:()=>Lt().wbApp?.showPage?.("plugins"),children:a("去安装提供商插件包")})]}):null]})]})}function Wye(e){return e==="credit"?{name:a("积分到期时间"),hint:a("按账号最早到期、且还有剩余的积分包比较"),options:[{value:"soon",label:a("最快到期优先")},{value:"late",label:a("最晚到期优先")}]}:{name:a("账号添加时间"),hint:a("所有提供商都有这个字段"),options:[{value:"new",label:a("最新添加优先")},{value:"old",label:a("最早添加优先")}]}}function Am(e,t){return t.filter(n=>n.on&&(n.key!=="credit"||iO(e)))}function dd(e){const t=e.some(r=>r.on&&r.key==="credit"),n=e.some(r=>r.on&&r.key==="added");return a(t&&n?"无法拖动:当前已按积分到期时间和账号添加时间自动排序。请先在「消耗顺序」中关闭这两项规则,再手动调整。":t?"无法拖动:当前已按积分到期时间自动排序。请先在「消耗顺序」中关闭该规则,再手动调整。":n?"无法拖动:当前已按账号添加时间自动排序。请先在「消耗顺序」中关闭该规则,再手动调整。":"自动消耗排序已启用,请先关闭规则再手动调整")}function Y0(e){return e.filter(t=>t.on).map(t=>t.key==="credit"?t.dir==="soon"?a("到期 近→远"):a("到期 远→近"):t.dir==="new"?a("添加 新→旧"):a("添加 旧→新")).join(" · ")}function Xye({rule:e,priority:t,isLast:n,state:r,busy:i,onChange:o}){const c=Wye(e.key),d=r==="unsupported",f=!d&&!e.on;return s.jsxs("div",{className:Te("grid items-center gap-2 rounded-sm px-1.5 py-1.5","grid-cols-[16px_15px_minmax(0,1fr)_132px_16px]","hover:bg-nav-hover",f&&"opacity-[.58]"),children:[s.jsx("span",{className:"text-center text-[10.5px] font-bold text-subtle tabular-nums",children:t}),s.jsx(Wr,{checked:e.on&&!d,disabled:d||i,"aria-label":c.name,onCheckedChange:h=>o({on:h===!0})}),s.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[s.jsx("span",{className:Te("text-xs font-medium",d&&"text-subtle",f&&"text-subtle"),children:c.name}),s.jsx("span",{className:Te("overflow-hidden text-ellipsis whitespace-nowrap text-[10.5px]",d?"text-warning":"text-subtle"),title:d?a("这一家查不到积分到期时间"):void 0,children:d?a("这一家查不到积分到期时间"):r==="no-data"?e.on?a("暂无数据:先查询一次余额,之后会自动按到期排序"):a("暂无数据:先查询一次余额,可按需启用到期排序"):c.hint})]}),d?s.jsx("span",{className:"rounded-xs border border-dashed border-border py-1 text-center text-[10.5px] text-subtle",children:a("不可用")}):s.jsxs(ht,{value:e.dir,disabled:!e.on||i,onValueChange:h=>o({dir:h}),children:[s.jsx(mt,{className:"h-[26px] w-full text-[11px]","aria-label":a("{name}的方向",{name:c.name}),children:s.jsx(pt,{children:c.options.find(h=>h.value===e.dir)?.label||""})}),s.jsx(gt,{children:c.options.map(h=>s.jsx(qe,{value:h.value,children:h.label},h.value))})]}),s.jsxs("span",{className:"flex flex-col gap-px",children:[s.jsx(B,{size:"default",variant:"ghost",type:"button",disabled:t<=1||i,className:"h-3 w-4 rounded-[3px] text-subtle hover:bg-nav-hover hover:text-foreground disabled:cursor-default disabled:opacity-30",title:a("提高优先级"),"aria-label":a("提高优先级"),onClick:()=>o({__move:"up"}),children:s.jsx("svg",{viewBox:"0 0 24 24",width:"10",height:"10",className:"mx-auto block",children:s.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",d:"m6 14 6-6 6 6"})})}),s.jsx(B,{size:"default",variant:"ghost",type:"button",disabled:n||i,className:"h-3 w-4 rounded-[3px] text-subtle hover:bg-nav-hover hover:text-foreground disabled:cursor-default disabled:opacity-30",title:a("降低优先级"),"aria-label":a("降低优先级"),onClick:()=>o({__move:"down"}),children:s.jsx("svg",{viewBox:"0 0 24 24",width:"10",height:"10",className:"mx-auto block",children:s.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",d:"m6 10 6 6 6-6"})})})]})]})}function o6({title:e,hint:t,children:n}){return s.jsxs("section",{className:"flex flex-col gap-1 border-t border-hairline pt-3.5 first:border-t-0 first:pt-0",children:[s.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[s.jsx("h4",{className:"m-0 text-xs font-bold",children:e}),t?s.jsx("span",{className:"text-[10.5px] text-subtle",children:t}):null]}),n]})}function l6({provider:e,onClose:t}){v.useSyncExternalStore(Mx,()=>qn().version);const n=Hc(e),r=rt().wbProviders?.labelOf?.(e)||e,i=qc[e],o=iO(e),c=qn().version,d=v.useMemo(()=>Bl().filter(y=>In(y)===e).some(y=>qn().sorting?qn().sorting?.creditExpiresAt[y.id]!=null:EU(vo(y))!==null),[e,c]),f=o?d?"ready":"no-data":"unsupported",h=Y0(n),p=Yxe(e),g=qn().sortBusy,x=(y,j)=>{const w=j.__move,S=n.map(A=>({...A})),N=S.findIndex(A=>A.key===y);if(!(N<0)){if(w){const A=w==="up"?N-1:N+1;if(A<0||A>=S.length)return;const[E]=S.splice(N,1);S.splice(A,0,E)}else S[N]={...S[N],...j};cH(e,S)}};return s.jsx(St,{open:!0,onOpenChange:y=>{!y&&!g&&t()},children:s.jsxs(kt,{className:"w-[min(560px,calc(100vw-48px))]",showCloseButton:!0,children:[s.jsxs(Nt,{children:[s.jsx("span",{className:"inline-flex size-[26px] flex-none items-center justify-center",children:i?s.jsx("img",{src:i,alt:"",className:"size-[26px] rounded-md object-contain",loading:"lazy"}):s.jsx("span",{className:"inline-flex size-[26px] items-center justify-center rounded-md bg-surface-3 text-[13px] font-bold text-muted-foreground",children:String(r||"?").trim().slice(0,1).toUpperCase()})}),s.jsx(jt,{children:a("{name} · 分组设置",{name:a(r)})})]}),s.jsxs(Ct,{children:[s.jsxs(o6,{title:a("消耗顺序"),hint:a("按优先级从上到下比较,勾选的项才参与"),children:[n.map((y,j)=>s.jsx(Xye,{rule:y,priority:j+1,isLast:j===n.length-1,state:y.key==="credit"?f:"ready",busy:g,onChange:w=>x(y.key,w)},y.key)),s.jsxs("div",{className:"grid grid-cols-[16px_15px_minmax(0,1fr)] items-center gap-2 px-1.5 py-1.5",children:[s.jsx("span",{className:"text-center text-[10.5px] font-bold text-subtle tabular-nums",children:n.length+1}),s.jsx("span",{className:"inline-flex items-center justify-center text-subtle",title:a("固定兜底,不受开关影响"),children:s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",children:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"4.5",y:"10",width:"15",height:"10.5",rx:"2"}),s.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]})})}),s.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[s.jsx("span",{className:"text-xs font-medium",children:a("组内手动顺序")}),s.jsx("span",{className:"text-[10.5px] text-subtle",children:a("上面所有规则都相同时,保持你拖出来的顺序")})]})]}),s.jsx("p",{className:"m-0 mt-2 rounded-xs bg-surface-inset px-2.5 py-2 text-[10.5px] leading-relaxed text-subtle",children:a("当前规则:{rules}。自动排序生效时,组内拖动把手会锁定;关掉全部规则即回到手动顺序。",{rules:h||a("仅按手动顺序")})}),s.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("账号页与全局路由共用此消耗顺序,网关按最新余额数据选路,不需要保持页面打开。模型独立顺序会覆盖全局。")}),s.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a(o?"本提供商默认启用最快到期优先,账号添加时间默认关闭;关闭全部规则可恢复手动顺序。":"本提供商不支持积分到期排序,默认保持手动顺序;可按需启用账号添加时间排序。")})]}),s.jsx(o6,{title:a("更多设置"),hint:a("后续加入"),children:s.jsx("div",{className:"flex flex-wrap gap-1.5",children:[a("默认展开 / 收起"),a("新账号落到组首 / 组尾"),a("组内并发上限"),a("余额低于阈值时的提示"),a("本组代理")].map(y=>s.jsx("span",{className:"inline-flex h-[22px] items-center rounded-pill border border-dashed border-border px-2.5 text-[10.5px] text-subtle",children:y},y))})})]}),s.jsxs(Pt,{children:[s.jsx(B,{variant:"ghost",size:"sm",disabled:!p||g,title:a(p?o?"恢复默认:最快到期优先,账号添加时间关闭":"恢复默认:仅按手动顺序":"当前已经是默认规则"),onClick:()=>{cH(e,null)},children:a("恢复默认")}),s.jsx("span",{className:"mr-auto text-[10.5px] text-subtle",children:a(g?"保存中…":"改动即时生效")}),s.jsx(B,{variant:"default",disabled:g,onClick:t,children:a("完成")})]})]})})}function Qye(e,t){if(!e)return a("读取中…");const n=e.error||e.configError;if(n)return a("读取失败:{error}",{error:n});if(e.required===!1)return a("当前模型请求免人机验证");if(t?.state==="verifying")return a("正在验证…");if(t?.state==="error")return a("验证失败:{error}",{error:t.error});if(t?.state==="paused")return a("已暂停验证,需要时请手动重试");const r=`${Number(e.ready)||0} / ${Number(e.target)||3}`;return Number(e.startPlanAccounts)?Number(e.ready)>0?a("验证码令牌:{counts}",{counts:r}):e.needsTokens===!0?a("套餐池请求需要验证,请主动开始验证后重试请求"):a("没有近期套餐池请求,不生成验证码令牌"):a("未启用套餐池账号,不生成验证码令牌")}function Zye({accountId:e,disabled:t=!1,onBusy:n}){const[r,i]=v.useState(null),[o,c]=v.useState(null),[d,f]=v.useState(""),h=v.useRef(null),p=v.useRef(!0),g=v.useCallback(async()=>{const j=rt().workbuddyDesktop;try{const w=j?.zcodeCaptchaStats?await j.zcodeCaptchaStats():{error:a("验证码令牌池接口不可用")};p.current&&(i(w||null),rt().wbZcodeCaptchaPool?.status&&c(rt().wbZcodeCaptchaPool?.status?.()||null))}catch(w){p.current&&i({error:tn(w)})}},[]);v.useEffect(()=>{p.current=!0,g();const j=window.setInterval(()=>{g()},15e3),w=()=>{c(rt().wbZcodeCaptchaPool?.status?.()||null),g()};return window.addEventListener("zcode-captcha-status",w),()=>{p.current=!1,h.current?.abort(),n?.(!1),window.clearInterval(j),window.removeEventListener("zcode-captcha-status",w)}},[g,n]);async function x(){const j=rt().wbZcodeCaptchaPool;if(h.current||!j?.verify)return;const w=new AbortController;h.current=w,f("preparing"),n?.(!0);try{await j.verify(e,w.signal,S=>{p.current&&f(S)})}catch(S){p.current&&!w.signal.aborted&&S?.name!=="CaptchaCancelledError"&&c({state:"error",error:tn(S)})}finally{h.current===w&&(h.current=null),p.current&&(f(""),n?.(!1),g())}}const y=!!d;return s.jsxs("div",{className:"mt-2.5 space-y-2",children:[s.jsx("p",{className:`detail${r?.error||r?.configError||o?.state==="error"?" text-destructive":""}`,children:Qye(r,o)}),s.jsx("p",{className:"detail",children:a("后台只读取状态,不会自动弹出验证码;验证结果一次性使用,短时间内过期。")}),s.jsxs("div",{className:"flex items-center gap-2",children:[r?.required!==!1&&Number(r?.startPlanAccounts)>0?s.jsx(B,{variant:"outline",size:"xs",disabled:t||y||!!(r?.error||r?.configError)||!rt().wbZcodeCaptchaPool?.verify,onClick:()=>{x()},children:a(y?"正在验证…":"开始验证")}):null,y?s.jsx(B,{variant:"outline",size:"xs",disabled:d==="submitting",onClick:()=>h.current?.abort(),children:a("取消验证")}):null,s.jsx(B,{variant:"ghost",size:"xs",disabled:y||t,onClick:()=>{g()},children:a("刷新")})]})]})}function Jye({plan:e,hasJwt:t,onChange:n}){return s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:"account-plan-channel",children:a("使用套餐")}),s.jsxs(ht,{value:e,onValueChange:r=>n(String(r)),children:[s.jsx(mt,{id:"account-plan-channel",className:"min-w-[220px]",children:s.jsx(pt,{children:Pxe(e)})}),s.jsxs(gt,{children:[s.jsx(qe,{value:NU,children:a("编码套餐(Coding Plan)— 走开放平台端点,消耗开放平台的额度(订阅套餐 / 资源包 / 充值余额)")}),s.jsx(qe,{value:qf,children:a("套餐池(Start Plan)— 走 zcode.z.ai 端点,消耗 ZCode 套餐池的额度(新用户体验额度 / 活动领取)")})]})]}),e===qf&&!t?s.jsx("span",{className:"detail text-destructive",children:a("该账号没有套餐登录态(jwt),套餐池通道会失败:请重新登录该账号")}):null,e===qf?s.jsx("p",{className:"detail",children:a("需要人机验证时,在该账号的「套餐明细」中主动开始验证。")}):null]})}const ewe={sub2api:{label:"Sub2API",endpoint:"{base}/v1/usage",note:a("用这条账号的 API Key 查询,不需要额外配置。"),fields:[]},new_api:{label:"NewAPI",endpoint:"{base}/api/user/self + /api/status",note:a("用 NewAPI 站点的个人访问令牌查询账户余额(不是这条账号的上游 API Key)。令牌在站点的「个人设置」里生成,只有旧版 / 定制站点才需要额外填用户 ID。"),fields:[{key:"accessToken",label:a("NewAPI 个人访问令牌"),secret:!0,placeholder:a("在 NewAPI 站点「个人设置」里生成的访问令牌"),hint:a("必填;留空 = 不修改,清除用右边的按钮")},{key:"userId",label:a("NewAPI 用户 ID"),placeholder:a("旧版 / 定制站点才需要,新版可留空"),hint:a("可留空:新版请求头只认令牌;旧版会把用户 ID 放进 New-Api-User 头")}]},deepseek:{label:"DeepSeek",endpoint:"{base}/user/balance",note:a("用这条账号的 API Key 查询,不需要额外配置。"),fields:[]},opencode:{label:"OpenCode Go",endpoint:"{base}/v1/usage",note:a("用这条账号的 API Key 查询订阅用量,不需要额外配置;读数展开成 5 小时 / 每周 / 每月三个窗口。"),fields:[]},sensenova:{label:"商汤日日新",endpoint:"platform.sensenova.cn 控制台",note:a("用商汤日日新控制台的账号密码查询(与推理用的 API Key 不是同一套)。网关会自动换取登录票并缓存,过期后自动重登,不需要手动维护。"),fields:[{key:"username",label:a("账号"),placeholder:a("商汤日日新控制台的登录账号"),hint:a("必填")},{key:"password",label:a("密码"),secret:!0,placeholder:a("商汤日日新控制台的登录密码"),hint:a("留空 = 不修改,清除用右边的按钮")}]},zhipu:{label:"智谱",endpoint:"bigmodel.cn 控制台",note:a("用 bigmodel.cn 控制台的访问令牌查询账户余额(人民币元)。令牌是登录后浏览器 Cookie `bigmodel_token_production` 的值:开发者工具 → 应用(Application)→ Cookie 里复制。"),fields:[{key:"token",label:a("访问令牌"),secret:!0,placeholder:a("bigmodel_token_production 的值"),hint:a("必填;留空 = 不修改,清除用右边的按钮")}]},zhipu_zai:{label:"智谱(z.ai 国际)",endpoint:"api.z.ai 控制台",note:a("用这条账号的 API Key 生成签名后查询账户余额(美元),不需要额外配置。要求 API Key 是 z.ai 的「id.secret」形态(控制台生成的 Key 就是)。"),fields:[]}};function Kx(e){return e?ewe[e]??null:null}function twe(e,t){return t.secret?t.key==="accessToken"?e?.hasAccessToken===!0:t.key==="password"?e?.hasPassword===!0:t.key==="token"?e?.hasToken===!0:!1:!1}function nwe(e){const t=String(e?.scheme||"");return t==="new_api"?e?.hasAccessToken===!0:t==="sensenova"?String(e?.username||"").trim()!==""&&e?.hasPassword===!0:t==="zhipu"?e?.hasToken===!0:!0}function rwe(e){return{userId:String(e?.userId||""),username:String(e?.username||""),accessToken:"",password:"",token:""}}function swe(e,t){const n=Kx(e);if(!n||!n.fields.length)return null;const r={};for(const i of n.fields){const o=String(t[i.key]??"").trim();if(i.secret){o&&(r[i.key]=o);continue}r[i.key]=o}return Object.keys(r).length?r:null}function awe({field:e,value:t,configured:n,onValue:r,onClear:i,clearBusy:o,idPrefix:c}){const d=`${c}-${e.key}`;return s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:d,children:e.label}),s.jsx(Be,{id:d,className:"min-w-[220px]",type:e.secret?"password":"text",autoComplete:e.secret?"new-password":"off",placeholder:n?a("已配置,留空则不修改"):e.placeholder,title:e.hint,value:t,onChange:f=>r(f.currentTarget.value)}),n&&i?s.jsx(B,{variant:"outline",size:"sm",disabled:o===!0,onClick:i,title:a("清除已配置的 {label}",{label:e.label}),children:a("清除")}):null]})}function iwe({spec:e,values:t,configured:n,onValue:r,onClear:i,clearBusy:o,idPrefix:c}){return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"detail mt-2.5",children:[a("余额查询方案:{label}",{label:e.label}),s.jsx("span",{className:"ml-1 text-subtle",children:e.endpoint})," — ",e.note]}),e.fields.map(d=>s.jsx(awe,{field:d,idPrefix:c,value:t[d.key]||"",configured:n[d.key]===!0,onValue:f=>r(d.key,f),onClear:i?()=>i(d.key):void 0,clearBusy:o},d.key))]})}const c6=64;function owe(e,t){const n=In(e);return t.filter(r=>r.id!==e.id&&In(r)===n)}function lwe(e){return go(e)||e?.id||""}function cwe({configured:e,value:t,onChange:n,onClear:r,clearBusy:i}){return s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:"account-balance-token-input",children:a("余额查询凭证")}),s.jsx(Be,{id:"account-balance-token-input",className:"min-w-[220px]",placeholder:a(e?"已配置,留空则不修改":"一般不用填"),title:a("积分查询已复用转发用的登录凭证,这里通常留空即可。只有旧版本填过、或从旧代理导入过凭证时才有值"),value:t,onChange:o=>n(o.currentTarget.value)}),e?s.jsx(B,{variant:"outline",size:"sm",disabled:i,onClick:r,title:a("清除已配置的余额查询凭证"),children:a("清除")}):null]})}function uwe({hasApiKey:e,noAuth:t,value:n,onValue:r,onToggleNoAuth:i,onClear:o,clearBusy:c}){return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:"account-api-key-input",children:a("API Key")}),s.jsx(Be,{id:"account-api-key-input",type:"password",autoComplete:"new-password",className:"min-w-[220px]",disabled:t,placeholder:e?a("已配置,留空则不修改"):"sk-…",title:a("上游的 API Key。留空 = 不修改(改凭证不会换账号 id);要清掉已配的凭证用右边的「清除」"),value:n,onChange:d=>r(d.currentTarget.value)}),e&&!t?s.jsx(B,{variant:"outline",size:"sm",disabled:c,onClick:o,title:a("清除已配置的 API Key(转发时会因缺少凭证被跳过)"),children:a("清除")}):null]}),s.jsx(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:s.jsxs(Tt,{className:"inline-flex cursor-pointer items-center gap-2.5 font-normal",children:[s.jsx(Wr,{checked:t,"aria-label":a("该上游无需鉴权"),onCheckedChange:d=>i(d===!0)}),s.jsx("span",{className:"text-xs text-subtle",children:a("该上游无需鉴权(转发与拉取模型都不发送鉴权头)")})]})}),s.jsxs("p",{className:"detail",children:[a("上游本来不要凭证时(本地 Ollama、OpenCode Zen 的免费档)勾上这一项:账号会被正常选路;只把 Key 留空"),s.jsx("strong",{children:a("又不勾")}),a("会被当成「未配置凭证」而跳过。")]})]})}function dwe({provider:e,name:t,protocol:n,baseUrl:r,count:i,emulation:o,onName:c,onProtocol:d,onBaseUrl:f,onEmulation:h,onRemove:p}){const g=rt().wbProviders?.PROTOCOL_OPTIONS||[{value:"openai",label:a("OpenAI 兼容")},{value:"anthropic",label:"Anthropic"}],x=g.find(y=>y.value===n)?.label||n;return s.jsxs(Ln,{children:[s.jsx("h3",{children:a("提供商")}),s.jsxs("p",{children:[a("这一栏改的是"),s.jsx("strong",{children:a("「{name}」本身",{name:e.name||e.id})}),a("(名下 {count} 个账号共用)",{count:i}),a("改协议 / Base URL 会改变它们的转发方式,正在进行的请求可能失败;模型清单与映射在「模型管理」页。")]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"account-provider-name",children:a("名称")}),s.jsx(Be,{id:"account-provider-name",maxLength:c6,className:"min-w-[220px]",placeholder:a("提供商显示名,1~{max} 个字符",{max:c6}),value:t,onChange:y=>c(y.currentTarget.value)})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:"account-provider-protocol",children:a("协议")}),s.jsxs(ht,{value:n,onValueChange:y=>d(String(y)),children:[s.jsx(mt,{id:"account-provider-protocol",className:"min-w-[180px]",children:s.jsx(pt,{children:x})}),s.jsx(gt,{children:g.map(y=>s.jsx(qe,{value:y.value,children:y.label},y.value))})]})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:[s.jsx(Tt,{htmlFor:"account-provider-baseurl",children:a("Base URL")}),s.jsx(Be,{id:"account-provider-baseurl",className:"min-w-[260px]",placeholder:a("OpenAI 兼容填到 /v1;Anthropic 填根地址"),value:r,onChange:y=>f(y.currentTarget.value)})]}),s.jsx(Et,{orientation:"horizontal",className:"field-row mt-2.5",children:s.jsxs(Tt,{className:"inline-flex cursor-pointer items-center gap-2.5 font-normal",children:[s.jsx(Wr,{checked:o==="opencode","aria-label":a("伪装 OpenCode 官方客户端"),onCheckedChange:y=>h(y===!0?"opencode":"")}),s.jsx("span",{className:"text-xs text-subtle",children:a("伪装 OpenCode 官方客户端(OpenCode Zen 免费档要它才放行)")})]})}),s.jsxs("p",{className:"detail",children:[a("开启后,网关按 OpenCode 官方 CLI 的形状发请求:没填 Key 的账号用匿名凭证"),s.jsx("code",{children:"public"}),a("、补官方会话头、请求体补两个占位工具(上游免费档的三道校验)。"),s.jsx("strong",{children:a("它会改写请求体")}),a(",只对 OpenCode Zen 这类上游有意义,别的家请关掉。")]}),s.jsxs(ws,{orientation:"horizontal",className:"field-row mt-3",children:[s.jsx(B,{variant:"destructive",onClick:p,children:a("删除提供商")}),s.jsx("span",{className:"detail",children:a("级联删除名下全部账号,不可恢复")})]})]})}function u6({id:e,onClose:t,initialAccount:n,initialPane:r="basic",routeContext:i}){const o=n||Fl(e),[c,d]=v.useState(o?.enabled!==!1),[f,h]=v.useState(o?.allowRouteSkip!==!1),[p,g]=v.useState(o?.name||""),[x,y]=v.useState(()=>xm(o?.proxy)),[j,w]=v.useState(""),[S,N]=v.useState(()=>aO(o)),[A,E]=v.useState(!1),[O,R]=v.useState(""),[T,P]=v.useState(null),[M,_]=v.useState(""),[I,L]=v.useState("chat_completions"),[D,z]=v.useState(""),[G,X]=v.useState(""),[Y,F]=v.useState(""),[K,U]=v.useState(o?.noAuth===!0),[q,W]=v.useState(()=>zH(o)),[ne,ie]=v.useState(()=>rwe(o?.balanceQuery)),[V,H]=v.useState(()=>LH(o)),[Q,J]=v.useState(r),[oe,ee]=v.useState(()=>String(Number(o?.maxConcurrent)||0));if(v.useEffect(()=>{let we=!0;P(null);const ge=n||Fl(e);return ge?(Promise.resolve(rt().wbCustomProvidersUi?.find?.(In(ge))).then(De=>{!we||!De||(P(De),_(De.name||""),L(De.protocol||"chat_completions"),z(De.baseUrl||""),X(typeof De.clientEmulation=="string"?De.clientEmulation:""))}).catch(()=>{}),()=>{we=!1}):()=>{we=!1}},[e]),!o)return s.jsx(St,{open:!0,onOpenChange:we=>{we||t()},children:s.jsxs(kt,{children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("账号设置")})}),s.jsx(Ct,{children:s.jsx("p",{className:"detail",children:a("账号不存在,请刷新后重试。")})}),s.jsxs(Pt,{children:[s.jsx("div",{className:"mr-auto"}),s.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const se=o,le=owe(se,Bl()),te=In(se)==="catpaw",re=In(se).startsWith("custom-"),he=fU(T,se.baseUrl)||x.mode==="rotate",pe=Kx(se.balanceQuery?.scheme),Ne={};for(const we of pe?.fields??[])Ne[we.key]=twe(se.balanceQuery,we);const me=!!(pe&&pe.fields.length)&&!nwe(se.balanceQuery);async function ce(){if(!A){E(!0);try{await mm(e,{balanceToken:null}),w(""),vt(a("✅ 已清除余额查询凭证"));try{await Vc()}catch(we){vt(a("账号已保存,但列表刷新失败:{error}",{error:tn(we)}),"err")}}catch(we){vt(a("清除失败:{error}",{error:tn(we)}),"err")}finally{E(!1)}}}async function ae(){if(!A){E(!0);try{await mm(e,{apiKey:null}),F(""),vt(a("✅ 已清除 API Key(该账号现在没有凭证,转发会被跳过)"));try{await Vc()}catch(we){vt(a("账号已保存,但列表刷新失败:{error}",{error:tn(we)}),"err")}}catch(we){vt(a("清除失败:{error}",{error:tn(we)}),"err")}finally{E(!1)}}}async function _e(we){if(!A){E(!0);try{await mm(e,{balanceQuery:{[we]:null}}),ie(ge=>({...ge,[we]:""})),vt(a("✅ 已清除查询凭证"));try{await Vc()}catch(ge){vt(a("账号已保存,但列表刷新失败:{error}",{error:tn(ge)}),"err")}}catch(ge){vt(a("清除失败:{error}",{error:tn(ge)}),"err")}finally{E(!1)}}}function de(){if(!re)return null;const we=Y.trim(),ge={};return we?ge.apiKey=we:K!==(se.noAuth===!0)&&(ge.noAuth=K),Object.keys(ge).length?ge:null}function Se(){if(!T)return null;const we=M.trim(),ge=D.trim();if(!we)return{error:a("请填写提供商名称")};if(!ge)return{error:a("请填写提供商的 Base URL")};const De=typeof T.clientEmulation=="string"?T.clientEmulation:"";return T.name===we&&T.protocol===I&&T.baseUrl===ge&&De===G?null:{id:T.id,name:we,protocol:I,baseUrl:ge,clientEmulation:G}}async function ve(){if(A)return;let we;try{we=ld(x)}catch(Mt){vt(tn(Mt),"err");return}const ge=Se();if(ge&&"error"in ge){R(s.jsx("span",{className:"text-destructive",children:ge.error}));return}const De=ui(se)?$be(se,q):null;if(De&&"error"in De){R(s.jsx("span",{className:"text-destructive",children:De.error}));return}const Ge=Dbe(se,V),Ot=swe(se.balanceQuery?.scheme,ne),sn=de()||{},$t=Number(oe);if(!Number.isFinite($t)||$t<0){vt(a("并发上限必须是 0~{max} 的整数",{max:Uc}),"err");return}const Me=Math.min(Uc,Math.round($t)),Ht=Number(se.maxConcurrent)||0,an=Me!==Ht?{maxConcurrent:Me}:{};E(!0);try{const Mt=te&&j.trim()?{balanceToken:j.trim()}:{},_t=D0(se)&&S!==aO(se)?{zcodePlan:S}:{},Ve=p.trim()||se.name,bt=await mm(e,{...Ve!==se.name?{name:Ve}:{},enabled:c,allowRouteSkip:f,proxy:we,...Mt,..._t,...sn,...an,...Ot?{balanceQuery:Ot}:{},...De&&"patch"in De?De.patch:{},...Ge&&"patch"in Ge?Ge.patch:{}});if((Ve!==se.name||se.nameCustom===!0)&&bt.nameCustom!==!0)throw new Error(a("账号更新结果未确认,请刷新后核对设置"));if(ge)try{const Ut=rt().wbCustomProvidersUi?.update;if(!Ut)throw new Error(a("账号更新接口不可用,请重新打开页面"));await Ut(ge)}catch(Ut){R(s.jsx("span",{className:"text-destructive",children:a("账号已保存,但提供商未更新:{error}",{error:tn(Ut)})}));try{await Vc()}catch(Yt){vt(a("账号已保存,但列表刷新失败:{error}",{error:tn(Yt)}),"err")}E(!1);return}t(),vt(a("✅ 账号设置已保存"));try{await Vc(),await Lx()}catch(Ut){vt(a("账号已保存,但列表刷新失败:{error}",{error:tn(Ut)}),"err")}}catch(Mt){R(s.jsx("span",{className:"text-destructive",children:tn(Mt)})),vt(a("保存失败:{error}",{error:tn(Mt)}),"err")}finally{E(!1)}}const xe=Number(Oa(In(se)).concurrencyDefault)||0,Re=te||re||D0(se);return s.jsx(St,{open:!0,onOpenChange:we=>{we||A||t()},children:s.jsxs(kt,{className:"w-[min(900px,calc(100vw-48px))]",children:[s.jsx(Nt,{children:s.jsx(jt,{children:a("账号设置 · {name}",{name:lwe(o)})})}),s.jsx(Ct,{className:"p-0",children:s.jsxs("div",{className:"acct-dlg",children:[s.jsx(cm,{className:"prov-rail acct-dlg-rail","aria-label":a("账号设置分组"),children:s.jsxs(Bc,{className:"rail-scroll",children:[s.jsx("div",{className:"rail-label",children:a("账号设置")}),[["basic",a("基本")],...Re?[["credential",a("凭证与套餐")]]:[],...ui(se)?[["query",a("查询设置")]]:[],["limiter",a("限制器")],["network",a("网络")]].map(([we,ge])=>s.jsx(Ri,{active:Q===we,title:ge,className:"shadow-none",onClick:()=>J(we),children:ge},we))]})}),s.jsxs("div",{className:"acct-dlg-main",children:[Q==="basic"?s.jsxs("div",{children:[s.jsxs("div",{className:"acct-dlg-pane-head",children:[s.jsx("h3",{children:a("基本")}),s.jsx("p",{children:a("这条账号是谁、排第几、能不能接请求。")})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{children:a("启用")}),s.jsx(cn,{checked:c,onCheckedChange:d,"aria-label":a("启用该账号")}),s.jsx("span",{className:"detail",children:a("关闭则不参与转发(余额查询照常,见「查询设置」)")})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"account-name-input",children:a("备注名")}),s.jsx(Be,{id:"account-name-input",maxLength:100,placeholder:a("账号显示名称"),className:"max-w-[280px]",value:p,onChange:we=>g(we.currentTarget.value)})]}),i||s.jsxs(ws,{orientation:"horizontal",className:"field-row",children:[s.jsx(Ie,{children:a("转发顺序")}),s.jsx("span",{className:"detail",children:a("在列表里拖:拖分组带调整整组顺位,拖行首把手调整组内先后(顺序由拖拽表达,不再填数字)")})]}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"account-route-skip",children:a("失败后允许换号")}),s.jsx(cn,{id:"account-route-skip",checked:f,onCheckedChange:h})]}),s.jsx("p",{className:"detail",children:a("关闭后,该账号转发失败时返回本次错误,不再顺延其他账号。禁用、无凭证和限制器等保护仍生效。")}),s.jsxs(Et,{orientation:"horizontal",className:"field-row",children:[s.jsx(Tt,{htmlFor:"account-conc-input",children:a("并发上限")}),s.jsx(Be,{id:"account-conc-input",type:"number",min:0,max:Uc,step:1,className:"max-w-[110px]",value:oe,onChange:we=>ee(we.currentTarget.value)}),s.jsx("span",{className:"detail",children:xe>0?a("0 = 按本家默认 {default}",{default:xe}):a("0 = 不限")})]}),s.jsx("p",{className:"detail acct-dlg-hint",children:xe>0?a("并发上限 填 0 即按本家默认 {default};填 1 或 2 就按填的算,更大的数会被本家上限截断(原列表 ⋯ 菜单的「并发上限」入口已并入这里)",{default:xe}):a("并发上限 0~{max};达到上限的账号跳过、请求转给其他账号(原列表 ⋯ 菜单的「并发上限」入口已并入这里)",{max:Uc})})]}):null,Q==="credential"&&Re?s.jsxs("div",{children:[s.jsxs("div",{className:"acct-dlg-pane-head",children:[s.jsx("h3",{children:a("凭证与套餐")}),s.jsx("p",{children:a("这一段按提供商出现:有什么配什么。")})]}),te?s.jsx(cwe,{configured:o.hasBalanceToken===!0,value:j,onChange:w,clearBusy:A,onClear:()=>{ce()}}):null,re?s.jsx(uwe,{hasApiKey:se.hasApiKey===!0,noAuth:K,value:Y,onValue:F,onToggleNoAuth:U,onClear:()=>{ae()},clearBusy:A}):null,D0(se)?s.jsx(Jye,{plan:S,hasJwt:o.canClaim===!0,onChange:N}):null,T?s.jsx(dwe,{provider:T,count:le.length+1,name:M,protocol:I,baseUrl:D,emulation:G,onName:_,onProtocol:L,onBaseUrl:z,onEmulation:X,onRemove:()=>{A||Promise.resolve(rt().wbCustomProvidersUi?.remove?.(T.id)).then(we=>{we&&t()})}}):null]}):null,Q==="query"&&ui(se)?s.jsxs("div",{children:[s.jsxs("div",{className:"acct-dlg-pane-head",children:[s.jsx("h3",{children:a("查询设置")}),s.jsx("p",{children:a("余额列读数的自动刷新;也是「限制器」余额规则的数据来源。")})]}),pe?s.jsx(iwe,{spec:pe,values:ne,configured:Ne,onValue:(we,ge)=>ie(De=>({...De,[we]:ge})),onClear:we=>{_e(we)},clearBusy:A,idPrefix:"account-balance-query"}):null,me?s.jsx("p",{className:"detail mt-2.5 text-subtle",children:a("查询凭证还没配齐:填好后余额列才有读数,在此之前会显示「未配置」。")}):null,s.jsx(BH,{draft:q,onChange:W})]}):null,Q==="limiter"?s.jsxs("div",{children:[s.jsxs("div",{className:"acct-dlg-pane-head",children:[s.jsx("h3",{children:a("限制器")}),s.jsx("p",{children:a("按规则限制该账号参与转发:没有规则(或全部停用)= 不限制;跳过档自动恢复,禁用档需手动启用。")})]}),s.jsx(DH,{account:se,draft:V,onChange:H,allowBalance:ui(se)})]}):null,Q==="network"?s.jsxs("div",{children:[s.jsxs("div",{className:"acct-dlg-pane-head",children:[s.jsx("h3",{children:a("网络")}),s.jsx("p",{children:a("这条账号访问上游走哪条线路。")})]}),s.jsx(Fx,{draft:x,onChange:y,idPrefix:"account-proxy",allowRotate:he}),o.proxy?.error?s.jsx("p",{className:"detail text-destructive",children:a("当前代理不可用:{error}(转发时会回退直连)",{error:o.proxy.error})}):null]}):null]})]})}),s.jsxs(Pt,{children:[s.jsx("div",{className:"detail mr-auto",style:{minHeight:18},children:O}),s.jsx(B,{variant:"outline",disabled:A,onClick:t,children:a("取消")}),s.jsx(B,{variant:"default",disabled:A,onClick:()=>{ve()},children:a(A?"保存中…":"保存")})]})]})})}function fwe(){const e=v.useSyncExternalStore(Mx,()=>qn());return e.dialog?e.dialog.kind==="settings"?s.jsx(u6,{id:e.dialog.id,onClose:Bx},e.dialog.id):e.dialog.kind==="group"?s.jsx(l6,{provider:e.dialog.provider,onClose:Bx},e.dialog.provider):s.jsx(Bbe,{ids:e.dialog.ids,action:e.dialog.action,onClose:Bx},e.dialog.ids.join(",")):null}function hwe(e){switch(e){case"not_installed":return a("插件未安装");case"pack_disabled":return a("插件包已停用");case"provider_disabled":return a("提供商已停用");case"not_loaded":return a("插件未加载")}}function d6({hidden:e,compact:t=!1}){const n=new Set(e.providers.map(c=>c.reason)),r=n.size===1&&n.has("not_installed"),i=n.size>0&&[...n].every(c=>c==="pack_disabled"||c==="provider_disabled"),o=a(r?"去「插件」页安装":i?"去「插件」页启用":"查看插件状态");return s.jsxs("div",{className:t?"acct-hidden-banner":"empty acct-hidden-note",role:"status",children:[s.jsxs("div",{className:"acct-hidden-main",children:[s.jsx("p",{className:"acct-hidden-title",children:t?a("另有 {n} 个账号因提供商插件未就绪,暂未显示",{n:e.total}):a("有 {n} 个账号因提供商插件未就绪,暂未显示",{n:e.total})}),e.providers.length?s.jsx("ul",{className:"acct-hidden-list",children:e.providers.map(c=>s.jsxs("li",{children:[s.jsx("span",{children:a("{label} ×{count}",{label:a(c.label),count:c.count})}),s.jsx(ye,{variant:"warning",shape:"tag",children:hwe(c.reason)})]},c.id))}):null,s.jsx("p",{className:"acct-hidden-foot",children:a("账号数据仍然保留,无需重新添加。安装或启用对应插件并成功加载后,账号会自动恢复显示。")})]}),s.jsx(B,{size:"sm",variant:t?"outline":"default",onClick:()=>rt().wbApp?.showPage?.("plugins"),children:o})]})}function pwe(e){const t=Math.round(e/6e4);if(t<1)return a("不到 1 分钟");if(t<60)return a("还有 {n} 分钟",{n:t});const n=Math.floor(t/60),r=t%60;return n<24?r?a("还有 {h} 小时 {m} 分",{h:n,m:r}):a("还有 {h} 小时",{h:n}):a("还有 {d} 天",{d:Math.floor(n/24)})}function mwe(e){const t=Date.now();return cO(e).map(n=>{const r=Number(n.resetAt),i=Number(n.at),o=fO(n.resetAt),c=o===dO,d=n.message||(n.status?a("上游返回 {status}",{status:n.status}):""),f=r-i,h=i>0&&Number.isFinite(f)&&f>0?Math.max(0,Math.min(100,(t-i)/f*100)):null,p=c?a("恢复时间未知"):pwe(r-t),g=c?"":a("{time} 恢复",{time:o});return{model:n.model,wait:p,tone:c?"muted":"warn",reset:g,reason:d,title:[n.model,p,g,d,a("到恢复时间后自动解除,无需手动操作")].filter(Boolean).join(" · "),progress:h}})}function gwe({accountName:e,rows:t,count:n,soonest:r,onClear:i}){const[o,c]=v.useState(!1),d=v.useRef(null),f=v.useCallback(g=>{d.current=g,g&&(g.scrollTop=0)},[]),h=v.useCallback(()=>d.current??null,[]),p=r===dO?a("待定"):r;return s.jsxs(s.Fragment,{children:[s.jsxs(_l,{open:o,onOpenChange:c,children:[s.jsxs($c,{render:s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"usage-toggle warn",title:a("点击查看各模型的限流明细"),"aria-label":a("限流明细")}),children:[s.jsx("span",{className:"val",children:a("{n} 个模型",{n})}),s.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),s.jsx(Dl,{align:"center",sideOffset:6,className:"w-[320px]",initialFocus:h,children:s.jsxs("div",{className:"usage-pop-limit",ref:f,tabIndex:-1,children:[e?s.jsx("div",{className:"usage-pop-sub",children:e}):null,s.jsx("div",{className:"usage-pop-group",children:a("限流明细")}),t.map(g=>s.jsxs("div",{className:"usage-pop-row",title:g.title,children:[s.jsxs("div",{className:"usage-pop-line",children:[s.jsx("span",{className:"usage-pop-name lp-pop-model",children:g.model}),s.jsx("span",{className:`usage-pop-view ${g.tone}`,children:g.wait})]}),s.jsxs("div",{className:"lp-pop-subline",children:[s.jsxs("span",{className:"lp-pop-reason",children:[g.reset?`${g.reset} · `:"",g.reason]}),s.jsx(B,{variant:"ghost",size:"xs",title:a("清掉本机的限流标记,立刻重新尝试该模型(上游若仍在限流会再次被标记)"),onClick:()=>i(g.model),children:a("清除")})]}),g.progress!==null?s.jsx(lm,{value:g.progress,variant:"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("冷却进度 {percent}%",{percent:Math.round(g.progress)})}):null]},g.model)),s.jsxs("div",{className:"lp-pop-foot",children:[s.jsx("span",{className:"lp-pop-note",children:a("{n} 个模型限流中 · 到恢复时间自动解除",{n})}),s.jsx(B,{variant:"outline",size:"xs",title:a("清掉该账号全部模型的限流标记"),onClick:()=>i(""),children:a("全部清除")})]})]})})]}),s.jsx("span",{className:"lim-sub",title:a("最早恢复"),children:a("最早 {soonest} 恢复",{soonest:p})})]})}function f6({account:e,onOpen:t}){if(e.enabled===!1||!Ox(e))return null;const n=XT(e),r=Tx(e),i=r.some((d,f)=>d.action==="skip"&&n[f]?.hit&&n[f]?.account),o=[...new Set(r.flatMap((d,f)=>d.action==="skip"&&n[f]?.hit?n[f].models:[]))],c=i||!o.length?a("限制器 · 账号已跳过"):a("限制器 · {n} 个模型",{n:o.length});return s.jsx(B,{variant:"ghost",size:"xs",className:"h-auto p-0",onClick:t,title:a(i?"账号级条件组已触发;点击查看限制器":"仅跳过命中条件的模型,其他模型仍可转发;点击查看限制器"),children:s.jsx(ye,{variant:"warning",shape:"tag",children:c})})}const rh=[20,50,100,200],VO=[20,50,100,200,"all"],Em=50,h6="workbuddy-desktop-table-size:";function p6(e){return e==="all"?a("全部"):String(e)}function W0(e,t=VO,n=Em){t.includes(n)||(n=t.includes(Em)?Em:t[0]);let r=null;try{r=localStorage.getItem(h6+e)}catch{return n}if(r===null||r.trim()==="")return n;if(r==="all")return t.includes("all")?"all":n;const i=Number(r);return Number.isFinite(i)&&t.includes(i)?i:n}function X0(e,t){try{localStorage.setItem(h6+e,String(t))}catch{}}function qx(e,t,n={}){const r=n.sizes??VO,i=n.defaultSize??Em,[o,c]=v.useState(()=>W0(t,r,i)),[d,f]=v.useState(1),h=Math.max(1,o==="all"?1:Math.ceil(e/o)),p=Math.min(Math.max(1,d),h);v.useEffect(()=>{p!==d&&f(p)},[p,d]);const g=v.useCallback(S=>{c(S),X0(t,S),f(1)},[t]),x=v.useCallback(S=>{f(Math.min(Math.max(1,Math.round(S)||1),h))},[h]),y=o==="all"?0:(p-1)*o,j=o==="all"?e:Math.min(e,y+o),w=v.useCallback(S=>o==="all"?S.slice():S.slice(y,j),[o,y,j]);return{size:o,page:p,pageCount:h,rangeStart:e?y+1:0,rangeEnd:e?j:0,paged:o!=="all",setSize:g,goto:x,slice:w}}function fd({total:e,page:t,pageCount:n,size:r,sizes:i=VO,onSizeChange:o,onPageChange:c,range:d=null,disabled:f=!1,leading:h,className:p}){const[g,x]=v.useState(String(t));v.useEffect(()=>x(String(t)),[t]);const y=()=>{const S=g.trim();if(!S){x(String(t));return}const N=Number(S);if(!Number.isFinite(N)){x(String(t));return}const A=Math.min(Math.max(1,Math.round(N)),n);x(String(A)),A!==t&&c(A)},j=n<=1,w=e===0?a("共 0 条"):d?a("共 {total} 条 · 当前第 {start}–{end} 条",{total:e,start:d.start,end:d.end}):a("共 {total} 条(全部显示)",{total:e});return s.jsxs(Zo,{className:p?`panel-foot table-foot-bar ${p}`:"panel-foot table-foot-bar",children:[h,s.jsx("div",{className:"spacer"}),s.jsxs("div",{className:"table-foot-ctl",children:[s.jsx("span",{className:"table-foot-count",children:w}),s.jsxs("span",{className:"table-foot-size",children:[a("每页"),s.jsxs(ht,{value:String(r),onValueChange:S=>o(S==="all"?"all":Number(S)),children:[s.jsx(mt,{className:"h-[26px] w-[86px]",disabled:f,"aria-label":a("每页条数"),children:s.jsx(pt,{children:p6(r)})}),s.jsx(gt,{children:i.map(S=>s.jsx(qe,{value:String(S),children:p6(S)},String(S)))})]}),a("条")]}),s.jsxs("span",{className:"table-foot-jump",children:[a("跳至"),s.jsx(Be,{className:"h-[26px] w-[52px] px-1 text-center",value:g,disabled:f||j,"aria-label":a("跳转到指定页"),title:j?a("当前只有一页"):a("跳转到第 1–{pageCount} 页",{pageCount:n}),inputMode:"numeric",onChange:S=>x(S.target.value),onKeyDown:S=>{S.key==="Enter"?(S.preventDefault(),y()):S.key==="Escape"&&x(String(t))},onBlur:y}),a("页")]}),s.jsx(Sge,{page:t,pageCount:n,onPageChange:c,disabled:f})]})]})}const KO=[{key:"pick",label:a("选择"),align:"center",legacyAlign:"left"},{key:"order",label:a("顺序"),title:a("组内先后:按住左边的把手上下拖动即可调整;整组的先后拖分组带的把手"),align:"center",legacyAlign:"left"},{key:"account",label:a("账号"),align:"center",legacyAlign:"left"},{key:"proxy",label:a("代理"),title:a("该账号出网走的代理(已保存的代理 / 自定义 / 直连);点击可修改"),align:"center"},{key:"connections",label:a("连接数"),title:a("此刻正在使用这个账号的请求数(含还在下发内容的流式请求);为 0 时不显示"),align:"center"},{key:"status",label:a("状态"),align:"center",legacyAlign:"left"},{key:"limits",label:a("限流"),title:a("该账号当前限流中的模型;点徽章看明细"),align:"center",legacyAlign:"left"},{key:"expiry",label:a("有效期"),align:"center",legacyAlign:"left"},{key:"usage",label:a("余额"),align:"center",legacyAlign:"left"},{key:"actions",label:a("操作"),align:"right"}],m6="agent2api-accounts-col-widths",Gx={pick:47,order:84,proxy:186,connections:56,status:80,limits:148,expiry:132,usage:308,actions:200},qO=new Set(["account"]),vwe=300,GO=56,xwe=new Set([...Object.keys(Gx),...qO]),Tm=(()=>{try{const e=JSON.parse(localStorage.getItem(m6)||"{}"),t={};for(const[n,r]of Object.entries(e||{})){const i=Number(r);xwe.has(n)&&Number.isFinite(i)&&i>=GO&&(t[n]=Math.round(i))}return t}catch{return{}}})();function g6(){try{localStorage.setItem(m6,JSON.stringify(Tm))}catch{}}function bwe(){return{...Gx,...Tm}}function ywe(e){let t=0;for(const n of e){const r=Tm[n];r?t+=r:qO.has(n)?t+=vwe:Gx[n]?t+=Gx[n]:t+=GO}return Math.round(t)}function v6(e,t){const n=e?.querySelector(`thead th:nth-child(${t+1})`),r=n?.getAttribute("data-col")||n?.className.match(/cell-([a-z]+)/)?.[1];if(!r)return null;const i=e?.querySelector(`colgroup col[data-col="${CSS.escape(r)}"]`)||e?.querySelectorAll("colgroup col")[t];return i?{key:r,col:i}:null}function wwe(e,t,n){const r=Math.max(GO,Math.round(n));e.style.width=r+"px",qO.has(t)||r!==Gx[t]?Tm[t]=r:delete Tm[t]}let YO=()=>{};function jwe(e,t){if(YO=t,!e)return;let n=null;e.addEventListener("pointerdown",r=>{if(r.button!==0)return;const i=r.target?.closest?.(".col-grip");if(!i)return;r.preventDefault();const o=i.closest("th"),c=o?.closest("table")||null,d=o?.parentElement?[...o.parentElement.children].indexOf(o):-1,f=v6(c,d);if(!f)return;const h=r.clientX,p=f.col.getBoundingClientRect().width;i.classList.add("active"),document.body.classList.add("col-resizing");try{i.setPointerCapture(r.pointerId)}catch{}n={...f,startX:h,startWidth:p,grip:i,pointerId:r.pointerId},window.addEventListener("pointermove",g),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),window.addEventListener("blur",x);function g(y){if(n){if(y.buttons===0){x();return}wwe(n.col,n.key,n.startWidth+y.clientX-n.startX)}}function x(){if(!n)return;const{grip:y,pointerId:j}=n;n=null,y.classList.remove("active"),document.body.classList.remove("col-resizing");try{y.releasePointerCapture(j)}catch{}window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x),window.removeEventListener("blur",x),g6(),YO()}}),e.addEventListener("dblclick",r=>{const i=r.target?.closest?.(".col-grip");if(!i)return;const o=i.closest("th"),c=o?.closest("table")||null,d=o?.parentElement?[...o.parentElement.children].indexOf(o):-1,f=v6(c,d);f&&(delete Tm[f.key],g6(),YO())})}function Swe(e){switch(e.trim().toLowerCase()){case"5h":return a("{n} 小时",{n:5});case"weekly":return a("每周");case"monthly":return a("每月");case"daily":return a("每日");default:return e.trim()}}function kwe(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=Array.isArray(e.windows)?e.windows:[],n=[];for(const[r,i]of t.entries()){if(!i||typeof i!="object"||Array.isArray(i))continue;const o=i,c=aU(o.label,a),d=typeof o.group=="string"?o.group.trim():"",f=Swe(typeof o.window=="string"?o.window:"")||c;if(!d&&!f)continue;const h=Ii(o.remainingPercent),p=h===null?null:Math.max(0,Math.min(100,h)),g=o.unlimited===!0,x=Ii(o.remaining)===null&&Ii(o.limit)===null&&!g,y=Ii(o.resetsAt);n.push({id:`${typeof o.key=="string"?o.key:[d,f].join("-")}-${r}`,group:d,label:c||[d,f].filter(Boolean).join(" · "),window:f,view:iU(o,a,zn),percent:p,percentText:x&&p!==null?`${zn(p)}%`:"",tone:g?"ok":p===null?"muted":p<20?"warn":"ok",unlimited:g,resetsAt:y!==null&&y>0&&y<=864e13?y:null})}return n}function Nwe(e){const t=new Map;for(const n of e){const r=n.group||n.id;let i=t.get(r);i||(i={id:r,name:n.group,rows:[]},t.set(r,i)),i.rows.push(n)}return[...t.values()]}function Cwe(e,t){const n=new Set(t.map(c=>c.label)),r=Array.isArray(e.windows)?e.windows:[],i=new Set(r.flatMap(c=>c&&typeof c=="object"&&typeof c.key=="string"&&c.key?[c.key]:[])),o=Array.isArray(e.wallets)?e.wallets.filter(c=>!c||typeof c!="object"||Array.isArray(c)?!1:c.type!=="quota_window"&&!i.has(c.key??c.type)&&!n.has(c.displayName)):[];return YT({...e,wallets:o,subscription:null},a,zn)}function Awe({row:e}){const t=e.percentText||e.view,n=e.percent===null?e.view:a("剩余 {percent}%",{percent:zn(e.percent)});return s.jsxs("span",{className:`usage-window-item ${e.tone}`,title:`${e.label} · ${n}`,children:[s.jsxs("span",{className:"usage-window-line",children:[s.jsx("span",{className:"usage-window-label",title:e.window,children:e.window}),s.jsx("span",{className:"usage-window-value",title:e.view,children:t})]}),e.percent!==null&&!e.unlimited?s.jsx(lm,{value:e.percent,variant:e.tone==="warn"?"warning":"success",className:"mt-1",trackClassName:"h-[3px]",indicatorClassName:e.tone==="ok"?"opacity-75":void 0,"aria-label":`${e.label} · ${n}`}):null]})}function Ewe({entry:e,rows:t,updatedAt:n,creditDetail:r,children:i}){const o=e&&typeof e=="object"?e:{},c=o.subscription&&typeof o.subscription=="object"?o.subscription:{},d=typeof c.planName=="string"?c.planName.trim():"",f=Nwe(t),h=t.some(E=>E.group),p=P0(o),g=Cwe(o,t),x=t.some(E=>!E.unlimited&&E.percent!==null&&E.percent<20),y=t.some(E=>!E.unlimited&&E.percent===null)||p.length>0,j=a(x?"部分窗口偏低":y?"部分读数未知":"额度充足"),w=x?"warn":y?"muted":"ok",S=n?mH(n,a,Date.now()):"",N=n?a("上次成功查询:{time}",{time:ci(n)}):"",A=t.every(E=>E.percentText||E.view==="—")?a("剩余比例"):a("分窗口额度");return s.jsx("span",{className:"usage-cell usage-window-cell",children:s.jsxs("span",{className:"usage-window-quota",children:[s.jsxs("span",{className:"usage-window-top",children:[d?s.jsx(ye,{variant:oO(d)?"secondary":"brand",shape:"tag",className:"usage-window-plan",title:d,children:TU(d)}):null,s.jsxs("span",{className:`usage-window-status ${w}`,title:j,children:[s.jsx(CE,{}),s.jsx("span",{children:j})]})]}),s.jsx("span",{className:`usage-window-grid${h?" grouped":" ungrouped"}`,style:{"--quota-columns":Math.min(3,f.length)},children:f.map(E=>s.jsxs("span",{className:"usage-window-group",children:[E.name?s.jsx("span",{className:"usage-window-group-name",title:E.name,children:E.name}):null,E.rows.map(O=>s.jsx(Awe,{row:O},O.id))]},E.id))}),s.jsxs("span",{className:"usage-window-foot",children:[s.jsxs("span",{className:"usage-window-updated",title:N,children:[s.jsxs("span",{className:"usage-window-caption",children:[A,S?" · ":""]}),S]}),s.jsxs(_l,{children:[s.jsxs($c,{render:s.jsx(B,{type:"button",size:"xs",variant:"ghost",className:"usage-window-detail"}),children:[a("重置详情"),s.jsx("span",{"aria-hidden":"true",className:"usage-window-caret",children:"⌄"})]}),s.jsxs(Dl,{align:"end",sideOffset:6,className:"usage-window-pop",children:[s.jsx(yge,{children:s.jsx(wge,{children:a("窗口重置时间")})}),s.jsxs("div",{className:"usage-window-pop-body",children:[t.map(E=>s.jsxs("div",{className:"usage-window-reset",children:[s.jsxs("div",{className:"usage-window-reset-head",children:[s.jsx("span",{title:E.label,children:E.label}),s.jsx("span",{className:`usage-window-reset-value ${E.tone}`,children:E.percentText||E.view})]}),E.resetsAt!==null?s.jsx("time",{dateTime:new Date(E.resetsAt).toISOString(),children:ci(E.resetsAt)}):s.jsx("span",{className:"usage-window-reset-unknown",children:a("未返回重置时间")})]},E.id)),g.length?s.jsx("div",{className:"usage-window-supplementary",children:g.map(E=>s.jsx("p",{children:E},E))}):null,p.map(E=>s.jsx("p",{className:"usage-window-warning",children:a(E)},E)),s.jsx(jge,{className:"usage-window-explanation",children:a("各窗口独立限制请求,不相加为总余额。")})]})]})]})]}),r?s.jsx("span",{className:"usage-window-credit",children:r}):null,i]})})}const Twe=["codearts"];function WO(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;const t=Number(e),n=Number.isFinite(t)?t<1e11?t*1e3:t:Date.parse(String(e));return Number.isFinite(n)&&n>0?n:null}function Owe(e,t){if(!Twe.includes(String(e.provider??"")))return[];if(e.hasAccessToken!==!0||e.hasRefreshToken!==!0)return[];const n=WO(e.refreshTokenExpiresAt??e.refreshExpiresAt);if(n===null&&e.refreshTokenLongLived!==!0)return[];const r=WO(e.accessTokenExpiresAt)??WO(t);return n!==null&&r!==null&&n===r?[]:[{label:"Access Token",expiresAt:r,longLived:!1},{label:"Refresh Token",expiresAt:n,longLived:n===null&&e.refreshTokenLongLived===!0}]}function Rwe(e,t,n=Date.now()){if(e.longLived)return t("长期有效");if(e.expiresAt===null)return"—";const r=e.expiresAt-n;return r<=0?t("已过期"):r<36e5?t("{n} 分钟后",{n:Math.max(1,Math.round(r/6e4))}):r<48*36e5?t("{n} 小时后",{n:Number((r/36e5).toFixed(1))}):t("{n} 天后",{n:Math.floor(r/864e5)})}let XO=!1;async function x6(e){if(XO){vt(a("账号正在导出,请稍候"));return}const t=rt().workbuddyDesktop;if(!t?.exportAccountFiles){vt(a("当前客户端不支持逐账号导出,请更新客户端"),"err");return}XO=!0;try{const n=rt().wbConfirm?.ask,r=a("导出文件包含登录凭证,可直接用于登录。请妥善保管,不要外传或上传到公共位置。")+(e.provider?`
${a("本组每个账号会分别保存为一个 JSON 文件,包含被筛选隐藏的账号。")}`:"")+(e.provider&&t.platform==="web"?`
${a("网页端会逐个下载文件;浏览器提示时请允许本网站下载多个文件。")}`:"");if(!(n?await n({title:e.provider?a("导出本组账号"):a("导出账号"),html:r,okText:a("导出")}):window.confirm(a("导出文件包含登录凭证,可直接用于登录。请妥善保管,不要外传或上传到公共位置。"))))return;const o=await t.exportAccountFiles(e);if(o?.canceled)return;if(!o)throw new Error(a("导出未返回结果"));const c=o.count||0,d=o.failed||[];if(d.length){const f=d[0],h=[f.name||f.id,f.error].filter(Boolean).join(":");vt(a("已导出 {count} 个账号文件,{failed} 个未导出:{reason}",{count:c,failed:d.length,reason:h}),"err")}else c?vt(o.downloadStarted?a("已发起 {count} 个账号文件的下载,请在浏览器下载列表确认",{count:c}):a("✅ 已导出 {count} 个账号文件",{count:c}),"ok"):vt(a("没有可导出的账号"))}catch(n){vt(a("账号导出失败:{reason}",{reason:tn(n)}),"err")}finally{XO=!1}}function Om(e,t){return rt().wbIcons?.icon?.(e,t)||""}function Pwe({account:e,rank:t,sortActive:n}){const r=a("组内第 {rank} 位",{rank:t});return s.jsxs("div",{className:"order-cell",children:[s.jsx("span",{className:`order-grip${n?" locked":""}`,role:"button",tabIndex:-1,"aria-label":a("拖动调整组内顺序"),"aria-disabled":n||void 0,title:n?dd(Am(In(e),Hc(In(e)))):a("按住拖动,调整这个账号在本组内的顺序"),dangerouslySetInnerHTML:{__html:Om("gripVertical",14)}}),s.jsx("span",{className:"order-rank",title:r,children:`#${t}`})]})}function Iwe({group:e,ids:t,collapsed:n}){const[r,i]=v.useState(!1),o="w-full justify-start px-2 font-normal";return s.jsxs(_l,{open:r,onOpenChange:i,children:[s.jsx($c,{render:s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn",title:a("本组操作")}),children:"⋯"}),s.jsx(Dl,{align:"end",sideOffset:4,className:"w-[196px] p-1.5",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("启用这一组里的全部账号(含被筛选隐藏的)"),onClick:()=>{i(!1),OH(t,!0)},children:a("全部启用({n})",{n:t.length})}),s.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("禁用这一组里的全部账号(含被筛选隐藏的)"),onClick:()=>{i(!1),OH(t,!1)},children:a("全部禁用({n})",{n:t.length})}),s.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("打开批量操作弹窗,并预选这一组的账号(改代理等动作在弹窗里挑参数)"),onClick:()=>{i(!1),TO(t,"proxy")},children:a("批量操作本组")}),s.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("导出本组全部账号,每个账号一个 JSON 文件(含被筛选隐藏的)"),onClick:()=>{i(!1),x6({provider:e.provider})},children:a("导出本组账号")}),s.jsx("div",{className:"my-1 h-px bg-hairline"}),s.jsx(B,{variant:"ghost",size:"sm",className:o,onClick:()=>{i(!1),xO(e.provider)},children:a(n?"展开这一组":"折叠这一组")})]})})]})}function Mwe(e,t="group"){const n={counted:0,total:e.length,sum:null,unlimited:0,unit:"",failed:0,uncountable:0,pending:0,partial:0,scope:t};let r=0;for(const i of e){const o=vo(i);if(o==null){n.pending++;continue}const c=Wf(o);if(c){c.notConfigured||n.failed++;continue}if(typeof o!="object"||Array.isArray(o)){n.uncountable++;continue}const d=o;if((d.statisticsError||P0(d).length>0)&&n.partial++,d.unlimited===!0){n.unlimited++;continue}const h=Object.prototype.hasOwnProperty.call(d,"totalLeft")?d.totalLeft:d.available;if(h==null||h===""){n.uncountable++;continue}const p=Number(h);if(!Number.isFinite(p)){n.uncountable++;continue}const g=String(d.unit||a("积分"));if(n.unit||(n.unit=g),g!==n.unit){n.uncountable++;continue}n.counted++,r+=p}return n.counted&&(n.sum=Number(r.toFixed(2))),n}function _we(e){const t=window.wbUnits;return e<1e4?Number.isInteger(e)&&t?.formatInt?t.formatInt(e):zn(e):t?.formatTokens?t.formatTokens(e):zn(e)}function Dwe(e){const t=[e.scope==="filtered"?a("当前筛选下 {n} 个账号的可用余额之和(随筛选、搜索变化,不受分页影响)",{n:e.total}):a("本组 {n} 个账号的可用余额之和,按整组统计(不受筛选、搜索影响)",{n:e.total})];return t.push(a("{n} 个已计入",{n:e.counted})),e.unlimited&&t.push(a("含 {n} 个不限额度账号,合计记为 ∞",{n:e.unlimited})),e.pending&&t.push(a("{n} 个还没查到(未查询或正在查询)",{n:e.pending})),e.failed&&t.push(a("{n} 个查询失败",{n:e.failed})),e.uncountable&&t.push(a("{n} 个读数没有绝对数(只给比例或无额度),未计入",{n:e.uncountable})),e.partial&&t.push(a("{n} 个读数只读到一半(读数可信但不完整)",{n:e.partial})),t.join(";")}function Lwe({balance:e}){const t=e.failed+e.partial>0,n=e.sum===null&&e.unlimited===0,r=t?"warn":n?"muted":"ok",i=e.unlimited>0?"∞":e.sum===null?"—":_we(e.sum),o=e.unit&&e.unit!=="积分"&&e.unit!==a("积分")?mo(e.unit,a):"",c=e.unlimited===0&&e.counted1&&o.length>0&&o.some(ui)?Mwe(o,i?"filtered":"group"):null,f=p=>{p.target?.closest?.("button, a, input, select, label, .queue-grip")||String(window.getSelection?.()||"").length>0||xO(e.provider)},h=Y0(Hc(e.provider));return s.jsx(en,{className:"grp-band","data-provider":e.provider,children:s.jsx(Xe,{colSpan:n,onClick:f,children:s.jsxs("div",{className:"grp-band-inner",children:[s.jsx("span",{className:"queue-grip",role:"button",tabIndex:-1,"aria-label":a("拖动调整整组顺序"),title:a("按住拖动,调整这一家的组顺位(整组一起动)"),dangerouslySetInnerHTML:{__html:Om("gripVertical",14)}}),s.jsx("span",{className:"grp-rank",title:a("组顺位:越小越先用(拖动分组带调整)"),children:a("第 {rank} 顺位",{rank:e.rank})}),s.jsx("span",{className:"grp-logo",children:r?s.jsx("img",{src:r,alt:"",loading:"lazy"}):s.jsx("span",{className:"grp-logo-txt",children:String(e.label||"?").trim().slice(0,1).toUpperCase()})}),s.jsx("span",{className:"grp-name",children:a(e.label)}),s.jsx("span",{className:"grp-stat",children:a("{total} 个账号 · 启用 {enabled} · 禁用 {disabled}{limited}",{total:e.members.length,enabled:e.enabled,disabled:e.disabled,limited:e.limited>0?a(" · 限流 {n}",{n:e.limited}):""})}),d?s.jsx(Lwe,{balance:d}):null,h?s.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"grp-sort-mark",title:a("当前排序规则:{rules}。点击调整",{rules:h}),onClick:()=>kH(e.provider),children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:Om("sort",10)}}),h]}):null,s.jsx("span",{className:"grp-spacer"}),s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn grp-fold","aria-expanded":!t,title:a(t?"展开这一组":"折叠这一组"),onClick:()=>xO(e.provider),dangerouslySetInnerHTML:{__html:Om("chevronDown",14)}}),s.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn",title:a("分组设置"),"aria-label":a("分组设置"),onClick:()=>kH(e.provider),dangerouslySetInnerHTML:{__html:Om("settings",14)}}),s.jsx(Iwe,{group:e,ids:e.accounts.map(p=>p.id),collapsed:t})]})})})}function $we({account:e}){const t=Ka(e),n=Fxe(e);!t&&Axe(e,Xf(e))&&n.push({text:a("Token 限额 · 已禁用"),kind:"bad",title:a("本周期 Token 消耗达到限制器的上限,账号已被自动禁用(窗口重置也不恢复,需手动启用)")});const r=go(e)||e.id;return s.jsxs(s.Fragment,{children:[s.jsx(cn,{checked:t,"aria-label":a("{action}{who}",{action:a(t?"禁用":"启用"),who:r}),title:a(t?"已启用,点击禁用(不参与转发)":"已禁用,点击启用"),onCheckedChange:i=>{EH(e.id,i)}}),n.length?s.jsx("div",{className:"status-tags",children:n.map(i=>s.jsx(ye,{shape:"tag",variant:i.kind==="bad"?"destructive":"secondary",title:i.title,children:i.text},i.text))}):null]})}function Bwe({account:e,onClear:t}){const n=cO(e);return n.length?s.jsx(gwe,{accountName:go(e),rows:mwe(e),count:n.length,soonest:fO(n[0].resetAt),onClear:t}):Array.isArray(e.limiterGroups)&&Ox(e)?s.jsx(f6,{account:e,onOpen:()=>vm(e.id)}):rO(e,vo(e))?s.jsx(ye,{variant:"warning",shape:"tag",title:a("余额低于限制器的阈值,转发时会跳过该账号(余额回升自动恢复)"),children:a("余额不足")}):sO(e,Xf(e))?s.jsx(ye,{variant:"warning",shape:"tag",title:a("本周期 Token 消耗达到限制器的上限,转发时会跳过该账号(窗口重置自动恢复)"),children:a("Token 限额")}):s.jsxs(ye,{variant:"success",shape:"tag",title:a("当前没有任何模型处于限流中"),children:[s.jsx(CE,{}),a("正常")]})}function Fwe({account:e}){const t=Oa(In(e)),n=t.edition?pU(e.expiresAt):mU(e),r=Owe(e,n);if(r.length)return s.jsx("div",{className:"flex flex-col items-center gap-1",children:r.map(d=>s.jsx(Uwe,{row:d},d.label))});if(t.longLived)return s.jsx("span",{title:a("主凭证没有固定到期时刻,到期由网关自动续期或本来就不会过期"),children:a("长期有效")});if(!n)return s.jsx("span",{className:"muted",title:a("记录里没有过期时间"),children:"—"});const i=n-Date.now();if(i<=0)return s.jsx(ye,{variant:"destructive",shape:"tag",title:a("凭证已过期;能否续期取决于登录方式,本机引用需由原客户端处理"),children:a("已过期")});const o=i<36e5?a("{n} 分钟后",{n:Math.max(1,Math.round(i/6e4))}):i<48*36e5?a("{n} 小时后",{n:(i/36e5).toFixed(1)}):a("{n} 天后",{n:Math.floor(i/24/36e5)}),c=ci(n);return s.jsx("span",{title:c?a("{text}过期({full})",{text:o,full:c}):a("{text}过期",{text:o}),children:o})}function Uwe({row:e}){const t=e.expiresAt!==null&&e.expiresAt<=Date.now(),n=e.expiresAt===null?a("记录里没有过期时间"):ci(e.expiresAt);return s.jsxs("div",{className:"flex items-center justify-center gap-1.5 whitespace-nowrap",title:`${e.label} · ${n}`,children:[s.jsx("span",{className:"text-[9px] text-subtle",translate:"no",children:e.label}),t?s.jsx(ye,{variant:"destructive",shape:"tag",children:a("已过期")}):s.jsx("span",{className:e.expiresAt===null&&!e.longLived?"muted":void 0,children:Rwe(e,a)})]})}function Hwe({account:e}){const t=NH(e.id);return t<=0?null:s.jsx("span",{className:"conn-count",title:a("{n} 个请求正在使用该账号(含还在下发内容的流式请求)",{n:t}),children:t})}function Vwe(e){return!e||typeof e!="object"||Array.isArray(e)?"":QO(e.subscription)}function QO(e){if(!e||typeof e!="object")return"";const t=e,n=[];t.planName&&n.push(a("套餐 {name}",{name:String(t.planName)})),t.status&&n.push(a("状态 {status}",{status:String(t.status)})),t.state&&String(t.state)!=="active"&&n.push(CU(t.state));const r=t.expireAt;if(r!=null&&r!==""){const i=Number(r),o=Number.isFinite(i)&&i>1e11?ci(i):String(r);o&&n.push(a("到期 {time}",{time:o}))}return Number.isFinite(Number(t.remainQuota))&&n.push(a("余量 {value}",{value:zn(t.remainQuota)})),Number.isFinite(Number(t.totalQuota))&&n.push(a("总量 {value}",{value:zn(t.totalQuota)})),n.join(" ")}function Kwe(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e.plans;return Array.isArray(t)?t.filter(n=>n&&typeof n=="object"&&String(n.state||"")==="pending"):[]}function qwe(e){const t=e.map(n=>{const r=String(n.name||n.planId||a("套餐")),i=Number(n.pendingUntil??n.startsAt);return Number.isFinite(i)&&i>0?a("{name}({time} 起生效)",{name:r,time:ci(i*1e3)}):r});return a(`已领到、还没到生效时间的套餐(生效后余额列会按它显示):
+`))):ne=wE(U)}Y(W,ne)}),P=Fe((_,I=!1)=>{if(w.clear(),A.current+=1,I)return;const L=p();L&&_!==""&&c?w.start(c,()=>{T(_)}):T(_,!L)}),M=v.useCallback((_,I={})=>Ai(j(I),h.valid===!1&&!h.disabled&&!_?{"aria-invalid":!0}:rr),[j,h.disabled,h.valid]);return v.useMemo(()=>({getValidationProps:M,inputRef:S,registeredInputs:N,registerInput:O,getInputControl:R,commit:T,change:P}),[M,N,O,R,T,P])}function Aue(e){const{change:t,commit:n,invalid:r,markedDirtyRef:i,name:o,setRegisteredFieldName:c,registeredFieldIdRef:d,setValidityData:f,validityData:h}=e,{formRef:p}=Ac(),g=v.useRef(null),x=v.useRef(null),y=v.useRef(!1),j=Fe(()=>{const R=x.current;if(R)return R.getValue?R.getValue():R.value});function w(R){return R.value===void 0?j():R.value}const S=Fe(()=>{const R=x.current;if(i.current=!0,!R){n(h.value);return}n(w(R))});function N(){const R=x.current;!R||!R.id||p.current.fields.set(R.id,{getValue:j,name:o??R.name,controlRef:R.controlRef,validityData:bE(h,r),validate:S})}function A(R=x.current?.id){R&&p.current.fields.delete(R)}function E(R){if(y.current)return;y.current=!0;const T=w(R);f(P=>P.initialValue===T?P:{...P,initialValue:T})}Ue(()=>{const R=x.current;!R||!R.id||(c(o?void 0:R.name),p.current.fields.set(R.id,{getValue:j,name:o??R.name,controlRef:R.controlRef,validityData:bE(h,r),validate:S}))},[p,j,r,o,c,S,h]),Ue(()=>{const R=p.current.fields;return()=>{const T=x.current?.id;T&&R.delete(T)}},[p]);const O=Fe((R,T)=>{if(!T){g.current===R&&(g.current=null,t(void 0,!0),A(),x.current=null,c(void 0),d.current=void 0);return}const P=x.current?.id,M=g.current;M&&M!==R&&t(void 0,!0),g.current=R,x.current=T,o||c(T.name),d.current=T.id,P&&P!==T.id&&A(P),E(T),N()});return[S,O]}const Eue=v.forwardRef(function(t,n){const{errors:r,validationMode:i,submitCountRef:o}=Ac(),{render:c,className:d,validate:f,validationDebounceTime:h=0,validationMode:p=i,name:g,disabled:x=!1,invalid:y,dirty:j,touched:w,actionsRef:S,style:N,...A}=t,E=ZA(!0)?.disabled,O=Fe(f||(()=>null)),R=E||x,[T,P]=v.useState(!1),[M,_]=v.useState(!1),[I,L]=v.useState(!1),[D,z]=v.useState(!1),G=j??M,X=w??T,Y=v.useRef(G),F=v.useRef(void 0),[K,U]=v.useState(),q=g??K;Ue(()=>{j!==void 0&&(Y.current=j)},[j]);const W=Fe(Ne=>{j===void 0&&(Ne&&(Y.current=!0),_(Ne))}),ne=Fe(Ne=>{w===void 0&&P(Ne)}),ie=Fe(()=>p==="onChange"||p==="onSubmit"&&o.current>0),V=q&&Object.hasOwn(r,q)?r[q]:null,H=!!(Array.isArray(V)?V.length:V),Q=y===!0||H,[J,oe]=v.useState({state:bj,error:"",errors:[],value:null,initialValue:null}),ee=!Q&&(R?null:J.state.valid),se=v.useMemo(()=>({disabled:R,touched:X,dirty:G,valid:ee,filled:I,focused:D}),[R,X,G,ee,I,D]),le=Cue({setValidityData:oe,validate:O,validityData:J,validationDebounceTime:h,invalid:Q,markedDirtyRef:Y,state:se,shouldValidateOnChange:ie,validationMode:p,registeredFieldIdRef:F}),[te,re]=Aue({change:le.change,commit:le.commit,invalid:Q,markedDirtyRef:Y,name:g,setRegisteredFieldName:U,registeredFieldIdRef:F,setValidityData:oe,validityData:J});v.useImperativeHandle(S,()=>({validate:te}),[te]);const he=v.useMemo(()=>({invalid:Q,name:q,validityData:J,setValidityData:oe,disabled:R,setTouched:ne,setDirty:W,setFilled:L,setFocused:z,validationMode:p,shouldValidateOnChange:ie,state:se,registerFieldControl:re,validation:le}),[Q,q,J,R,ne,W,L,z,p,ie,se,re,le]),pe=wt("div",t,{ref:n,state:se,props:A,stateAttributesMapping:Rl});return s.jsx(QA.Provider,{value:he,children:pe})}),Tue=v.forwardRef(function(t,n){return s.jsx(Mce,{children:s.jsx(Eue,{...t,ref:n})})}),Oue=v.createContext({disabled:!1});function _j(){return v.useContext(Oue)}const Rue=v.forwardRef(function(t,n){const{render:r,className:i,style:o,id:c,nativeLabel:d=!0,...f}=t,h=Oi(!1),p=_j(),{labelId:g}=ii(),x={...h.state,disabled:h.disabled||p.disabled},y=v.useRef(null),j=kue({id:g??c,native:d});return wt("label",t,{ref:[n,y],state:x,props:[j,f],stateAttributesMapping:Rl})}),Dj=null;class Pue{constructor(){on(this,"callbacks",[]);on(this,"callbacksCount",0);on(this,"nextId",1);on(this,"startId",1);on(this,"isScheduled",!1);on(this,"tick",t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let i=0;i=this.callbacks.length||this.callbacks[n]!==null&&(this.callbacks[n]=null,this.callbacksCount-=1)}}let Lj=new Pue;class li{constructor(){on(this,"currentId",Dj);on(this,"cancel",()=>{this.currentId!==Dj&&(Lj.cancel(this.currentId),this.currentId=Dj)});on(this,"disposeEffect",()=>this.cancel)}static create(){return new li}static request(t){return Lj.request(t)}static cancel(t){return Lj.cancel(t)}request(t){this.cancel(),this.currentId=Lj.request(()=>{this.currentId=Dj,t()})}}function Jp(){const e=hs(li.create).current;return Mj(e.disposeEffect),e}function Pc(e){return e==null?e:"current"in e?e.current:e}let zj=null;function Iue(e){if(!zj){const t=[];zj=t,queueMicrotask(()=>{zj=null,br.flushSync(()=>{for(const n of t)n()})})}zj.push(e)}function jE(e,t=!1,n=!1){const r=Jp();return Fe((i,o=null)=>{r.cancel();const c=Pc(e);if(c==null)return;const d=c,f=()=>{if(!n){br.flushSync(i);return}Iue(()=>{o?.aborted||i()})};if(typeof d.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function h(){Promise.all(d.getAnimations().map(p=>p.finished)).then(()=>{o?.aborted||f()},()=>{if(o?.aborted)return;if(d.getAnimations().some(g=>g.pending||g.playState!=="finished")){h();return}f()})}if(t){const p=rE;if(!d.hasAttribute(p)){r.request(h);return}const g=new MutationObserver(()=>{d.hasAttribute(p)||(g.disconnect(),h())});g.observe(d,{attributes:!0,attributeFilter:[p]}),o?.addEventListener("abort",()=>g.disconnect(),{once:!0});return}r.request(h)})}function Va(e){const{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:o}=e,c=Fe(o),d=jE(r,n,i);v.useEffect(()=>{if(!t)return;const f=new AbortController;return d(c,f.signal),()=>{f.abort()}},[t,n,c,d])}function Ic(e,t=!1,n=!1,r=!1){const[i,o]=v.useState(e&&t?"idle":void 0),[c,d]=v.useState(e&&!r);return e&&!c&&(d(!0),o("starting")),!e&&c&&i!=="ending"&&!n&&o("ending"),!e&&!c&&i==="ending"&&o(void 0),Ue(()=>{if(!e&&c&&i!=="ending"&&n){const f=li.request(()=>{o("ending")});return()=>{li.cancel(f)}}},[e,c,i,n]),Ue(()=>{if(!e||t)return;const f=li.request(()=>{o(void 0)});return()=>{li.cancel(f)}},[t,e]),Ue(()=>{if(!e||!t)return;e&&c&&i!=="idle"&&o("starting");const f=li.request(()=>{o("idle")});return()=>{li.cancel(f)}},[t,e,c,i]),{mounted:c,setMounted:d,transitionStatus:i}}const Mue=v.forwardRef(function(t,n){const{render:r,id:i,className:o,style:c,...d}=t,f=bs(i),h=Oi(!1),p=_j(),{setMessageIds:g}=ii(),x={...h.state,disabled:h.disabled||p.disabled};return Ue(()=>{if(f)return g(j=>j.concat(f)),()=>{g(j=>j.filter(w=>w!==f))}},[f,g]),wt("p",t,{ref:n,state:x,props:[{id:f},d],stateAttributesMapping:Rl})});function qo({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=v.useRef(e!==void 0),[o,c]=v.useState(t),d=i&&e!==void 0?e:o,f=v.useCallback(h=>{i||c(h)},[]);return[d,f]}function em(e,t,n,r,i=!0,o){const{registerFieldControl:c}=Oi(),d=hs(()=>Symbol());Ue(()=>{const f=d.current;if(!i){c(f,void 0);return}c(f,{controlRef:e,getValue:r,id:t,name:o,value:n})},[e,i,r,t,o,c,d,n]),Ue(()=>{const f=d.current;return()=>{c(f,void 0)}},[c,d])}function co(e,t){const n=v.useRef(e),r=Fe(t);Ue(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}const Br="none",Mc="trigger-press",ma="trigger-hover",$j="trigger-focus",Bj="outside-press",ax="item-press",SE="close-press",ix="input-change",Pl="input-clear",_ue="input-press",Xu="focus-out",tm="escape-key",kE="list-navigation",yB="keyboard",wB="pointer",jB="cancel-open",Due="disabled",NE="imperative-action",Lue="window-resize";function at(e,t,n,r){let i=!1,o=!1;const c=r??rr;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){o=!0},get isCanceled(){return i},get isPropagationAllowed(){return o},trigger:n,...c}}function zue(e,t,n){const r=n??rr;return{reason:e,event:t??new Event("base-ui"),...r}}const $ue=v.forwardRef(function(t,n){const{render:r,className:i,id:o,name:c,value:d,disabled:f=!1,onValueChange:h,defaultValue:p,autoFocus:g=!1,style:x,...y}=t,{state:j,name:w,disabled:S,setTouched:N,setDirty:A,validityData:E,setFocused:O,setFilled:R,validationMode:T,validation:P}=Oi(),{clearErrors:M,elementRef:_,submitCountRef:I}=Ac(),L=S||f,D=w??c,z={...j,disabled:L},{labelId:G}=ii(),X=Vu({id:o}),[Y]=qo({controlled:d,default:p,name:"FieldControl",state:"value"}),F=d!==void 0,K=F?Y:void 0,U=K==null?void 0:String(K),q=Fe(()=>P.inputRef.current?.value);em(P.inputRef,X,U,q,!L,c),Ue(()=>{const V=U??P.inputRef.current?.value;V!==void 0&&R(V!=="")},[U,P.inputRef,R]),co(U,()=>{U!==void 0&&(M(D),A(U!==(E.initialValue??"")),P.change(U))});const W=v.useRef(null),ne=Ds();return Ue(()=>{g&&W.current===ys(vn(W.current))&&O(!0)},[g,O]),wt("input",t,{ref:[n,W],state:z,props:[{id:X,disabled:L,name:D,ref:P.inputRef,"aria-labelledby":G,autoFocus:g,...F?{value:K}:{defaultValue:p},onChange(V){const H=V.currentTarget.value,Q=at(Br,V.nativeEvent);h?.(H,Q),!F&&(A(H!==(E.initialValue??"")),R(H!==""),!V.nativeEvent.defaultPrevented&&!Q.isCanceled&&(M(D),P.change(H)))},onFocus(){O(!0)},onBlur(V){if(N(!0),O(!1),T==="onBlur"){const H=V.currentTarget.value;P.commit(H),F&&queueMicrotask(()=>{const Q=P.inputRef.current?.value;Q!==void 0&&Q!==H&&Q!==(E.initialValue??"")&&P.commit(Q)})}},onKeyDown(V){if(V.currentTarget.tagName==="INPUT"&&V.key==="Enter"){N(!0);const H=V.currentTarget.value,Q=V.currentTarget.form;if(Q&&Q===_.current&&!V.defaultPrevented){const J=V.currentTarget,oe=I.current;ne.start(0,()=>{I.current===oe&&P.commit(J.value)})}else P.commit(H)}}},y,V=>P.getValidationProps(L,V)],stateAttributesMapping:Rl})}),Bue=v.forwardRef(function(t,n){return s.jsx($ue,{ref:n,...t})});function Be({className:e,type:t,ref:n,...r}){return t==="file"||t==="hidden"?s.jsx("input",{ref:n,type:t,"data-slot":"input",className:Te(e),...r}):s.jsx(Bue,{ref:n,type:t,"data-slot":"input",className:Te("h-[30px] w-full min-w-0 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] text-foreground outline-none max-[767px]:h-10 max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground","file:inline-flex file:border-0 file:bg-transparent file:text-foreground",e),...r})}function Ea({className:e,...t}){return s.jsx("textarea",{"data-slot":"textarea",className:Te("min-h-26 w-full resize-y rounded-md border border-control-border bg-control px-3 py-2.5","font-mono text-[12px] leading-[1.6] text-foreground outline-none max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground",e),...t})}function uo({className:e,...t}){return s.jsx("div",{"data-slot":"input-group",role:"group",className:Te("group/input-group relative flex h-[30px] w-full min-w-0 items-center rounded-md border border-control-border bg-control max-[767px]:h-10","transition-[border-color,box-shadow] duration-150 ease-out","outline-none","has-[[data-slot=input-group-control]:focus-visible]:border-primary","has-[[data-slot=input-group-control]:focus-visible]:shadow-focus","has-[[data-slot=input-group-control]:hover:not(:focus-visible)]:border-control-border-hover","has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>[data-slot=input-group-control]]:pl-1.5","has-[>[data-align=inline-end]]:[&>[data-slot=input-group-control]]:pr-1.5","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-start]]:[&>[data-slot=input-group-control]]:pb-1.5","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col","has-[>[data-align=block-end]]:[&>[data-slot=input-group-control]]:pt-1.5",e),...t})}const Fue=Of(["flex h-auto cursor-text items-center justify-center gap-1.5 select-none","text-[12px] font-medium text-muted-foreground","group-data-[disabled=true]/input-group:opacity-50"],{variants:{align:{"inline-start":"order-first pl-[9px] has-[>button]:-ml-1","inline-end":"order-last pr-[9px] has-[>button]:-mr-1","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-1.5","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-1.5"}},defaultVariants:{align:"inline-start"}});function fo({className:e,align:t="inline-start",...n}){return s.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Te(Fue({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const Uue=Of("flex items-center shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-xs px-1.5",sm:"h-8 gap-1.5 rounded-sm px-2.5","icon-xs":"size-6 rounded-xs p-0","icon-sm":"size-8 rounded-sm p-0"}},defaultVariants:{size:"xs"}});function SB({className:e,type:t="button",variant:n="ghost",size:r="xs",...i}){return s.jsx(B,{type:t,"data-size":r,variant:n,className:Te(Uue({size:r}),e),...i})}function ho({className:e,...t}){return s.jsx(Be,{"data-slot":"input-group-control",className:Te("flex-1 rounded-none border-0 bg-transparent shadow-none focus:border-0 focus:shadow-none",e),...t})}function ox(e){return wt(e.defaultTagName??"div",e,e)}const Hue=Of("inline-flex w-fit shrink-0 items-center justify-center gap-[5px] overflow-hidden whitespace-nowrap border font-semibold",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive",outline:"border-control-border bg-control text-subtle",ghost:"border-transparent bg-transparent text-muted-foreground",link:"border-transparent bg-transparent text-primary underline-offset-4 hover:underline",success:"border-success-bd bg-success-soft text-success",warning:"border-warning-bd bg-warning-soft text-warning",info:"border-info-bd bg-info-soft text-info",brand:"border-primary-bd bg-primary-soft text-primary-fg",cn:"border-cn-bd bg-cn-soft text-cn",intl:"border-intl-bd bg-intl-soft text-intl",sensitive:"border-sensitive-bd bg-sensitive-soft text-sensitive"},shape:{pill:"min-h-[21px] rounded-pill px-[9px] py-px text-[11.5px]",tag:"min-h-[19px] rounded-xs px-2 py-0 text-[11px]"}},defaultVariants:{variant:"default",shape:"pill"}});function ye({className:e,variant:t,shape:n,render:r,...i}){return ox({render:r,defaultTagName:"span",props:Ai({"data-slot":"badge"},i,{className:Te(Hue({variant:t,shape:n}),e)})})}function CE({className:e,...t}){return s.jsx("span",{className:Te("size-1.5 flex-none rounded-full bg-current",e),...t})}const kB=v.createContext(void 0);function NB(){const e=v.useContext(kB);if(e===void 0)throw new Error(En(13));return e}const AE={imageLoadingStatus:()=>null},Vue=v.forwardRef(function(t,n){const{className:r,render:i,style:o,...c}=t,[d,f]=v.useState("idle"),h={imageLoadingStatus:d},p=v.useMemo(()=>({imageLoadingStatus:d,setImageLoadingStatus:f}),[d,f]),g=wt("span",t,{state:h,ref:n,props:c,stateAttributesMapping:AE});return s.jsx(kB.Provider,{value:p,children:g})});function Kue(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},o){const c=v.useState("idle"),d=c[1];return Ue(()=>{if(!o)return Pn;if(!e&&!i)return d("error"),Pn;let f=!0;const h=new window.Image,p=g=>()=>{f&&d(g)};return d("loading"),h.onload=p("loaded"),h.onerror=p("error"),t&&(h.referrerPolicy=t),h.crossOrigin=n??null,r&&(h.sizes=r),i&&(h.srcset=i),e&&(h.src=e),h.complete&&d(h.naturalWidth>0?"loaded":"error"),()=>{f=!1}},[o,e,i,r,n,t,d]),c}const que={...AE,...io},Gue=v.forwardRef(function(t,n){const{className:r,render:i,onLoadingStatusChange:o,keepMounted:c=!1,style:d,sizes:f,srcSet:h,src:p,...g}=t,{setImageLoadingStatus:x}=NB(),[y,j]=Kue(p,t,!c),w=y==="loaded",{mounted:S,transitionStatus:N,setMounted:A}=Ic(w),E=v.useRef(null),O=v.useRef(!0);Ue(()=>{if(!c)return;const L=O.current;O.current=!1;const D=E.current;if(!D)return;if(!D.complete){j("loading");return}const z=D.naturalWidth>0?"loaded":"error";j(z),z==="loaded"&&L&&A(!0)},[c,p,h,f,g.crossOrigin,g.referrerPolicy,i,j,A]);const R=c?{"data-loading":y==="loading"?"":void 0,"data-error":y==="error"?"":void 0,"aria-hidden":y!=="loaded"||void 0,onLoad(){j("loaded")},onError(){j("error")}}:void 0,T=Fe(L=>{o?.(L),x(L)});Ue(()=>{y!=="idle"&&T(y)},[y,T]),Ue(()=>()=>x("idle"),[x]),Va({enabled:!w,open:w,ref:E,onComplete(){w||A(!1)}});const P={imageLoadingStatus:y,transitionStatus:c&&N==="ending"?void 0:N},M=c||S,_={};f!==void 0&&(_.sizes=f),h!==void 0&&(_.srcSet=h),p!==void 0&&(_.src=p);const I=wt("img",t,{state:P,ref:[n,E],props:[R,g,_],stateAttributesMapping:que,enabled:M});return M?I:null}),Yue=v.forwardRef(function(t,n){const{className:r,render:i,delay:o=0,style:c,...d}=t,{imageLoadingStatus:f}=NB(),[h,p]=v.useState(o===0),g=Ds();return v.useEffect(()=>(o>0?g.start(o,()=>p(!0)):p(!0),g.clear),[g,o]),wt("span",t,{state:{imageLoadingStatus:f},ref:n,props:d,stateAttributesMapping:AE,enabled:f!=="loaded"&&(o===0||h)})});function Wue({className:e,...t}){return s.jsx(Vue,{"data-slot":"avatar",className:n=>Te("relative inline-flex size-8 shrink-0 overflow-hidden rounded-full text-foreground",typeof e=="function"?e(n):e),...t})}function Xue({className:e,...t}){return s.jsx(Gue,{"data-slot":"avatar-image",className:n=>Te("absolute inset-0 block size-full object-cover data-loading:invisible data-error:invisible",typeof e=="function"?e(n):e),...t})}function Que({className:e,...t}){return s.jsx(Yue,{"data-slot":"avatar-fallback",className:n=>Te("absolute inset-0 flex items-center justify-center bg-control text-[12px] font-semibold text-subtle",typeof e=="function"?e(n):e),...t})}function ue(e,t){if(typeof window>"u")return e;const n=window.wbI18n;return n?n.t(e,t)??e:e}function Ls({className:e,...t}){return s.jsx("svg",{"data-slot":"spinner",role:"status","aria-label":ue("加载中"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:Te("size-4 animate-spin [animation-duration:0.7s]",e),...t,children:s.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Ie({className:e,...t}){return s.jsx("label",{"data-slot":"label",className:Te("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",e),...t})}const CB={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},_c={...CB,position:"fixed",top:0,left:0},nm={...CB,position:"absolute"},AB=v.createContext(void 0);function Zue(){const e=v.useContext(AB);if(e===void 0)throw new Error(En(63));return e}const Jue="data-checked",ede="data-unchecked",EB={...Rl,checked(e){return e?{[Jue]:""}:{[ede]:""}}},tde=v.forwardRef(function(t,n){const{checked:r,className:i,defaultChecked:o,"aria-labelledby":c,form:d,id:f,inputRef:h,name:p,nativeButton:g=!1,onCheckedChange:x,readOnly:y=!1,required:j=!1,disabled:w=!1,render:S,uncheckedValue:N,value:A,style:E,...O}=t,{clearErrors:R}=Ac(),{state:T,setTouched:P,setDirty:M,validityData:_,setFilled:I,setFocused:L,validationMode:D,disabled:z,name:G,validation:X}=Oi(),{labelId:Y}=ii(),F=z||w,K=G??p,U=v.useRef(null),q=Ei(U,h,X.inputRef),W=v.useRef(null),ne=bs(),ie=Vu({id:f}),V=g?void 0:ie,[H,Q]=qo({controlled:r,default:!!o,name:"Switch",state:"checked"});em(W,ne,H,void 0,!F,p),Ue(()=>{I(H)},[H,I]),co(H,()=>{R(K),M(H!==_.initialValue),X.change(H)});const{getButtonProps:J,buttonRef:oe}=ai({disabled:F,native:g}),ee=JA(c,Y,U,!g,V),se={id:g?ie:ne,role:"switch","aria-checked":H,"aria-readonly":y||void 0,"aria-required":j||void 0,"aria-labelledby":ee,onFocus(){F||L(!0)},onBlur(){const he=U.current;!he||F||(P(!0),L(!1),D==="onBlur"&&X.commit(he.checked))},onClick(he){if(y||F)return;he.preventDefault();const pe=U.current;pe&&Yp(pe,he)}},le={...X.getValidationProps(F),checked:H,disabled:F,form:d,id:V,name:K,required:j,style:K?nm:_c,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:q,onChange(he){if(he.nativeEvent.defaultPrevented)return;if(y){he.preventDefault();return}const pe=he.currentTarget.checked,Ne=at(Br,he.nativeEvent);x?.(pe,Ne),!Ne.isCanceled&&Q(pe)},onClick(he){he.stopPropagation()},onFocus(){W.current?.focus()},...A!==void 0?{value:A}:rr},te=v.useMemo(()=>({...T,checked:H,disabled:F,readOnly:y,required:j}),[T,H,F,y,j]),re=wt("span",t,{state:te,ref:[n,W,oe],props:[se,O,J,he=>X.getValidationProps(F,he)],stateAttributesMapping:EB});return s.jsxs(AB.Provider,{value:te,children:[re,!H&&K&&N!==void 0&&s.jsx("input",{type:"hidden",form:d,name:K,value:N,disabled:F}),s.jsx("input",{...le,suppressHydrationWarning:!0})]})}),nde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,d=Zue();return wt("span",t,{state:d,ref:n,stateAttributesMapping:EB,props:c})});function cn({className:e,size:t="default",variant:n="default",...r}){const i=t==="sm";return s.jsx(tde,{"data-slot":"switch",className:Te("relative inline-flex flex-none cursor-pointer items-center rounded-pill border-0 bg-border-strong p-0","transition-colors duration-[180ms] ease-out",n==="success"?"data-checked:bg-success":"data-checked:bg-primary","focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:opacity-50",i?"h-[14px] w-6":t==="touch"?"h-6 w-10":"h-[21px] w-9",e),...r,children:s.jsx(nde,{"data-slot":"switch-thumb",className:Te("block rounded-full bg-primary-on shadow-1","transition-transform duration-[180ms] [transition-timing-function:cubic-bezier(.3,1.4,.6,1)]",i?"size-[10px] translate-x-0.5 data-checked:translate-x-[10px]":t==="touch"?"size-5 translate-x-0.5 data-checked:translate-x-[18px]":"size-[17px] translate-x-0.5 data-checked:translate-x-[17px]")})})}function rde(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const r=t;if(r.type==="submit")return r}}return null}const sde="data-checked",ade="data-unchecked";function TB(e){return{checked(t){return e.indeterminate?{}:t?{[sde]:""}:{[ade]:""}},...Rl}}const ide=v.createContext(void 0);function ode(){return v.useContext(ide)}const OB=v.createContext(void 0);function lde(){const e=v.useContext(OB);if(e===void 0)throw new Error(En(14));return e}const cde="data-parent",ude=v.forwardRef(function(t,n){const{checked:r,className:i,defaultChecked:o=!1,"aria-labelledby":c,disabled:d=!1,form:f,id:h,indeterminate:p=!1,inputRef:g,name:x,onCheckedChange:y,parent:j=!1,readOnly:w=!1,render:S,required:N=!1,uncheckedValue:A,value:E,nativeButton:O=!1,style:R,...T}=t,{clearErrors:P}=Ac(),{disabled:M,name:_,setDirty:I,setFilled:L,setFocused:D,setTouched:z,state:G,validationMode:X,validityData:Y,validation:F}=Oi(),K=_j(),{labelId:U,registerControlId:q,getDescriptionProps:W}=ii(),ne=ode(),ie=ne?.allValues===void 0?void 0:ne.parent,V=ie!==void 0,H=M||K.disabled||ne?.disabled||d,Q=_??x,J=E??Q,oe=bs(),ee=ne?.registerControlId!==q,se=Vu({id:h||void 0,enabled:ee}),le=O?se:oe;let te={};V&&(j?te=ie.getParentProps():J!==void 0&&(te=ie.getChildProps(J)));const{checked:re=r,indeterminate:he=p,onCheckedChange:pe,...Ne}=te,me=ne?.value,ce=v.useRef(null),{getButtonProps:ae,buttonRef:_e}=ai({disabled:H,native:O}),de=ne?.validation??F,[Se,ve]=qo({controlled:J!==void 0&&me!==void 0&&!j?me.includes(J):re,default:o,name:"Checkbox",state:"checked"}),xe=V?!!re:Se,Re=V&&he||p;em(ce,oe,Se,void 0,!ne&&!H,x);const we=ie?.registerChildId,ge=v.useRef(null),De=de.registerInput,Ge=ne?J:void 0,Ot=v.useCallback(Ve=>De(Ve,{controlRef:ce,value:Ge}),[De,Ge]),sn=Ei(g,ge,j?void 0:Ot),$t=JA(c,U,ge,!O,se);Ue(()=>{ge.current&&(ge.current.indeterminate=Re),ne||L(Se)},[Se,Re,ne,L]),co(Se,()=>{ne||(P(Q),I(Se!==Y.initialValue),de.change(Se))});const Me=Ai({checked:Se,disabled:H,form:f,name:j?void 0:Q,id:O?void 0:se,required:N,ref:sn,style:Q?nm:_c,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Ve){if(Ve.nativeEvent.defaultPrevented)return;if(w){Ve.preventDefault();return}const bt=Ve.currentTarget.checked,Ut=at(Br,Ve.nativeEvent);if(y?.(bt,Ut),!Ut.isCanceled&&(pe?.(bt,Ut),!Ut.isCanceled&&(ve(bt),J!==void 0&&ne!==void 0&&!j&&!V))){const Yt=bt?[...ne.value,J]:ne.value.filter(yt=>yt!==J);ne.setValue(Yt,Ut)}},onClick(Ve){Ve.stopPropagation()},onFocus(){ce.current?.focus()}},E!==void 0?{value:(ne?Se&&E:E)||""}:rr,W,Ve=>de.getValidationProps(H,Ve));v.useEffect(()=>{if(!ie||J===void 0)return;const Ve=ie.disabledStatesRef.current;return Ve.set(J,H),()=>{Ve.delete(J)}},[ie,H,J]);const Ht=v.useMemo(()=>({...G,checked:xe,disabled:H,readOnly:w,required:N,indeterminate:Re}),[G,xe,H,w,N,Re]),an=TB(Ht),Mt=wt("span",t,{state:Ht,ref:[_e,ce,n],props:[{id:le,role:"checkbox","aria-checked":Re?"mixed":xe,"aria-readonly":w||void 0,"aria-required":N||void 0,"aria-labelledby":$t,[cde]:j?"":void 0,onFocus(){H||D(!0)},onBlur(){const Ve=ge.current;Ve&&(z(!0),D(!1),X==="onBlur"&&de.commit(ne?me:Ve.checked))},onKeyDown(Ve){if(Ve.key!=="Enter"||(Ve.preventBaseUIHandler(),Ve.defaultPrevented))return;const bt=ge.current?.form??null,Ut=Ve.currentTarget,Yt=Ve.nativeEvent,yt=Ve.preventDefault,un=Yt.preventDefault;let Tn=!1;Ve.preventDefault=()=>{Tn=!0,yt.call(Ve)},Yt.preventDefault=()=>{Tn=!0,un.call(Yt)},un.call(Yt),tr(Ut).queueMicrotask(()=>{Ve.preventDefault=yt,Yt.preventDefault=un,Tn||rde(bt)?.click()})},onClick(Ve){if(w||H)return;Ve.preventDefault();const bt=ge.current;bt&&Yp(bt,Ve)}},T,Ne,ae,W,Ve=>de.getValidationProps(H,Ve)],stateAttributesMapping:an}),_t=Mt.props.id;return Ue(()=>{if(!(!we||j||J===void 0||_t===void 0))return we(J,_t)},[we,j,J,_t]),s.jsxs(OB.Provider,{value:Ht,children:[Mt,!Se&&!ne&&Q&&!j&&A!==void 0&&s.jsx("input",{type:"hidden",form:f,name:Q,value:A,disabled:H}),s.jsx("input",{...Me,suppressHydrationWarning:!0})]})}),dde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,keepMounted:c=!1,...d}=t,f=lde(),h=f.checked||f.indeterminate,{mounted:p,transitionStatus:g,setMounted:x}=Ic(h),y=v.useRef(null),j={...f,transitionStatus:g};Va({batch:!0,enabled:!h,open:h,ref:y,onComplete(){h||x(!1)}});const S={...TB(f),...io},N=c||p,A=wt("span",t,{ref:[n,y],state:j,stateAttributesMapping:S,props:d});return N?A:null});function Wr({className:e,...t}){return s.jsx(ude,{"data-slot":"checkbox",className:Te("group/checkbox relative inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-[3px] border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...t,children:s.jsx(dde,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-primary-foreground data-unchecked:hidden",children:s.jsxs("svg",{viewBox:"0 0 12 12",className:"size-2.5","aria-hidden":"true",children:[s.jsx("path",{d:"M2 6h8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none",className:"hidden group-aria-[checked=indeterminate]/checkbox:block"}),s.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",className:"group-aria-[checked=indeterminate]/checkbox:hidden"})]})})})}function EE(e){return Array.isArray(e)?e.map(t=>EE(t)).join(","):e==null?"":String(e)}const RB=new Map;function fde(e,t){const n=JSON.stringify({locale:EE(e),options:t}),r=RB.get(n);if(r)return r;const i=new Intl.NumberFormat(e,t);return RB.set(n,i),i}function Fj(e,t,n){return e==null?"":fde(t,n).format(e)}function Dc(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function PB(e,t,n){return(e-t)*100/(n-t)}const IB=v.createContext(void 0);function MB(){const e=v.useContext(IB);if(e===void 0)throw new Error(En(51));return e}const hde="data-complete",pde="data-indeterminate",mde="data-progressing",TE={status(e){return e==="progressing"?{[mde]:""}:e==="complete"?{[hde]:""}:e==="indeterminate"?{[pde]:""}:null}},gde=v.forwardRef(function(t,n){const{format:r,getAriaValueText:i,locale:o,max:c=100,min:d=0,value:f,render:h,className:p,children:g,style:x,...y}=t,[j,w]=v.useState();let S="indeterminate",N=null,A=null,E="",O="indeterminate progress";if(f!=null&&Number.isFinite(f)){const _=PB(f,d,c);N=Dc(Number.isNaN(_)?0:_,0,100),A=Dc(f,d,c),S=A===c?"complete":"progressing",E=r?Fj(A,o,r):Fj(N/100,o,{style:"percent"}),O=E}const R=v.useMemo(()=>({status:S}),[S]),T={"aria-labelledby":j,"aria-valuemax":c,"aria-valuemin":d,"aria-valuenow":A??void 0,"aria-valuetext":i?i(E,f):O,role:"progressbar",children:s.jsxs(v.Fragment,{children:[g,s.jsx("span",{role:"presentation",style:_c,children:"x"})]})},P=v.useMemo(()=>({formattedValue:E,percentageValue:N,setLabelId:w,state:R,value:f}),[E,N,w,R,f]),M=wt("div",t,{state:R,ref:n,props:[T,y],stateAttributesMapping:TE});return s.jsx(IB.Provider,{value:P,children:M})}),vde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,{state:d}=MB();return wt("div",t,{state:d,ref:n,props:c,stateAttributesMapping:TE})}),xde=v.forwardRef(function(t,n){const{render:r,className:i,style:o,...c}=t,{percentageValue:d,state:f}=MB(),h=d==null?{}:{insetInlineStart:0,height:"inherit",width:`${d}%`};return wt("div",t,{state:f,ref:n,props:[{style:h},c],stateAttributesMapping:TE})});function rm({className:e,children:t,value:n,...r}){return s.jsxs(gde,{value:n,"data-slot":"progress",className:Te("flex w-full flex-wrap items-center gap-3",e),...r,children:[t,s.jsx(bde,{children:s.jsx(yde,{})})]})}function bde({className:e,...t}){return s.jsx(vde,{"data-slot":"progress-track",className:Te("relative flex h-1.5 w-full items-center overflow-x-hidden overflow-y-hidden rounded-pill bg-surface-3",e),...t})}function yde({className:e,...t}){return s.jsx(xde,{"data-slot":"progress-indicator",className:Te("h-full rounded-[inherit] bg-primary transition-[width] duration-300 ease-out data-[indeterminate]:w-1/3 data-[indeterminate]:animate-pulse",e),...t})}const OE=[];let RE;function wde(){return RE}function jde(e){OE.push(e)}function Uj(e){const t=(n,r)=>{const i=hs(Sde).current;let o;try{RE=i;for(const c of OE)c.before(i);o=e(n,r);for(const c of OE)c.after(i);i.didInitialize=!0}finally{RE=void 0}return o};return t.displayName=e.displayName||e.name,t}function PE(e){return v.forwardRef(Uj(e))}function Sde(){return{didInitialize:!1}}const _B=v.createContext(void 0);function lx(e){const t=v.useContext(_B);if(t===void 0&&!e)throw new Error(En(72));return t}function kde(e,t){return t!=null&&!qu(t)?0:typeof e=="function"?e():e}function Df(e,t,n){const r=kde(e,n);return typeof r=="number"?r:r?.[t]}function DB(e){return typeof e=="function"?e():e}function LB(e,t){return t||e==="click"||e==="mousedown"}function Nde(e){return e?.includes("mouse")&&e!=="mousedown"}const zB=v.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new oi,currentIdRef:{current:null},currentContextRef:{current:null}});function Cde(e,t){e.current=t.current}function Ade(e){const{children:t,delay:n,timeoutMs:r=0}=e,i=v.useRef(n),o=v.useRef(n),c=v.useRef(null),d=v.useRef(null),f=Ds();return Ue(()=>{if(o.current=n,!c.current){i.current=n;return}i.current={open:Df(i.current,"open"),close:Df(n,"close")}},[n,c,i,o]),s.jsx(zB.Provider,{value:v.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:o,currentIdRef:c,timeoutMs:r,currentContextRef:d,timeout:f}),[r,f]),children:t})}function Ede(e,t={open:!1}){const{open:n}=t,r="rootStore"in e?e.rootStore:e,i=r.useState("floatingId"),o=v.useContext(zB),{currentIdRef:c,delayRef:d,timeoutMs:f,initialDelayRef:h,currentContextRef:p,hasProvider:g,timeout:x}=o,[y,j]=v.useState(!1),w=v.useRef(n);return Ue(()=>{w.current=n},[n]),Ue(()=>{function S(){p.current?.setIsInstantPhase(!1),c.current=null,p.current=null,d.current=h.current,x.clear()}if(c.current&&!n&&c.current===i){if(j(!1),f){const N=i;return x.start(f,()=>{r.select("open")||c.current&&c.current!==N||S()}),()=>{(w.current||c.current!==N)&&x.clear()}}S()}},[n,i,c,d,f,h,p,x,r]),Ue(()=>{if(!n)return;const S=p.current,N=c.current;x.clear(),p.current={onOpenChange:r.setOpen,setIsInstantPhase:j},c.current=i,d.current={open:0,close:Df(h.current,"close")},N!==null&&N!==i?(j(!0),S?.setIsInstantPhase(!0),S?.onOpenChange(!1,at(Br))):(j(!1),S?.setIsInstantPhase(!1))},[n,i,r,c,d,h,p,x]),Ue(()=>()=>{if(c.current===i){if(p.current=null,!w.current)return;c.current=null,Cde(d,h),x.clear()}},[p,c,d,i,h,x]),v.useMemo(()=>({activeIdRef:c,hasProvider:g,delayRef:d,isInstantPhase:y}),[c,g,d,y])}function Jt(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Go(...e){return()=>{for(let t=0;t