From 8fdc25483f219e6f11f95033f35ceec37569c131 Mon Sep 17 00:00:00 2001 From: Christ Date: Sat, 25 Jul 2026 21:31:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=89=B9=E9=87=8F=E9=93=BA=E8=B4=A7):=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=B3=E9=94=AE=E8=AF=8D=E7=B1=BB=E7=9B=AE?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E4=B8=8E=E6=9C=80=E7=BB=88=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- docs/index.html | 2 +- docs/wiki/批量铺货.md | 14 +- docs/wiki/账号、库存与商品.md | 4 +- docs/批量铺货使用文档.md | 27 +-- frontend/components/ItemList.tsx | 155 +++++++++-------- frontend/services/api.ts | 12 ++ internal/db/item_publish_batches.go | 2 +- internal/server/item_handlers.go | 1 + internal/server/item_handlers_test.go | 39 +++++ .../server/item_publish_batch_handlers.go | 100 +++++++++-- internal/server/publish_batch_run_test.go | 2 + internal/server/publish_batch_test.go | 18 +- .../webui/static/assets/index-BgaWj1th.css | 1 - .../webui/static/assets/index-C7AaUlyC.css | 1 + .../webui/static/assets/index-D1qb4SVL.js | 19 -- .../webui/static/assets/index-av934L0W.js | 19 ++ internal/webui/static/index.html | 4 +- internal/xianyu/mtop/publish.go | 162 +++++++++++++++--- internal/xianyu/mtop/publish_extra_test.go | 137 +++++++++++---- 20 files changed, 531 insertions(+), 194 deletions(-) delete mode 100644 internal/webui/static/assets/index-BgaWj1th.css create mode 100644 internal/webui/static/assets/index-C7AaUlyC.css delete mode 100644 internal/webui/static/assets/index-D1qb4SVL.js create mode 100644 internal/webui/static/assets/index-av934L0W.js diff --git a/README.md b/README.md index 7d92c44..3795568 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Ydisks 支持管理渠道、推广账号、原始链接、推广短链与域名 - 多个闲鱼账号的统一在线状态与消息管理 - 数字商品、兑换码、链接或图片内容的自动交付 - 付款后发货、评价赠品、超时求评价等自动化流程 -- 商品与订单同步、单商品发布及带逐行/批次类目兜底的表格批量铺货 +- 商品与订单同步、单商品发布及支持逐行/默认类目、自动识别和最终兜底的表格批量铺货 - 接入 OpenAI 兼容接口实现可控的 AI 客服回复 - 账号掉线、风控、续期和发货结果的多渠道通知 @@ -60,7 +60,7 @@ Ydisks 支持管理渠道、推广账号、原始链接、推广短链与域名 | 即时消息 | 闲鱼 WebSocket 长连接、消息收发、关键词回复、默认回复及仅回复一次 | | 自动化中心 | 付款后自动发货、评价后赠品、超时未评价提醒、失败任务恢复与幂等检查点 | | 卡密库存 | 文本、批量卡密和图片三种交付类型,库存追加、批量导入、规格与延迟发送 | -| 商品管理 | 商品同步、手工关联、单商品发布、CSV + ZIP 批量铺货、自动识别失败时的逐行/批次类目兜底、任务恢复与结果导出 | +| 商品管理 | 商品同步、手工关联、单商品发布、CSV + ZIP 批量铺货、关键词获取默认类目、逐行类目优先、自动识别与“电子资料”最终兜底、任务恢复与结果导出 | | 订单管理 | 订单同步、插入、编辑、平台发货、补发卡密、仅确认发货及异常状态处理 | | AI 回复 | OpenAI 兼容 API、模型发现、自定义提示词、议价轮次和让价范围控制 | | 数据看板 | 活跃账号、订单、营收、库存、商品销量与金额统计 | @@ -69,6 +69,8 @@ Ydisks 支持管理渠道、推广账号、原始链接、推广短链与域名 | 安全能力 | 管理端会话、敏感字段 AES-256-GCM 加密、日志脱敏和出站地址校验 | | 容器部署 | PostgreSQL 17、健康检查、持久化卷、GHCR amd64/arm64 多架构镜像 | +批量铺货的类目优先级为:表格当前行指定类目 > 上传页通过关键词获取的默认类目 > 闲鱼按标题、描述和图片自动识别 > “电子资料”最终兜底。模板类目字段可全部留空;如填写,类目 ID、名称和频道类目 ID 必须同时填写,淘宝类目 ID 按闲鱼响应提供的值填写。 + ## 系统架构 ```mermaid diff --git a/docs/index.html b/docs/index.html index c2b1753..e3d4b8c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1004,7 +1004,7 @@
📊

批量铺货与商品管理

-

轻松同步闲鱼在售商品,支持 CSV + ZIP 素材包批量发布、逐行与批次类目兜底、单商品手动挂载及自动化发货规则。

+

轻松同步闲鱼在售商品,支持 CSV + ZIP 素材包批量发布、关键词获取默认类目、逐行类目优先、自动识别与电子资料最终兜底、单商品手动挂载及自动化发货规则。

diff --git a/docs/wiki/批量铺货.md b/docs/wiki/批量铺货.md index 3352dfa..5522f0a 100644 --- a/docs/wiki/批量铺货.md +++ b/docs/wiki/批量铺货.md @@ -19,8 +19,8 @@ - 标题非空,价格大于 0;库存为正整数,留空默认 1。 - 邮费模式为 `free`/`包邮` 或 `fixed`/`固定邮费`;固定邮费时必须填邮费。 - 每件商品 1–9 张图片,多个用英文分号 `;` 分隔。可用公开 `https://` URL,或 ZIP 内相对路径。 -- 上传页必须填写“批次兜底类目 ID + 类目名称”。表格的“类目ID + 类目名称”可选,用于覆盖某一行的批次兜底配置;两列必须同时填写。 -- “频道类目ID”和“淘宝类目ID”通常留空,只有已取得同类闲鱼商品的准确值时才填写。 +- 上传页的默认类目可以留空。需要指定时,先选择账号,再输入关键词,由闲鱼推荐接口返回完整类目信息。表格的“类目ID + 类目名称 + 频道类目ID”可覆盖当前行;三列必须同时填写。 +- “淘宝类目ID”按闲鱼推荐响应填写;“电子资料”的值为空,应保持为空。 - 本地图片 ZIP 最大 200 MiB,单图最大 10 MiB;表格最大 20 MiB。 - CSV 使用 UTF-8,建议带 BOM;不要在表头增加空格。 @@ -40,23 +40,23 @@ 1. 在“商品管理”点击“批量铺货”。 2. 选择默认账号;表格某行未填账号 ID 时会使用它。 -3. 填写批次兜底类目 ID 和名称。优先从同类型、已经同步或发布成功的历史商品复用,页面会提示已知的历史类目。 +3. 默认类目可以留空;需要整批固定类目时,输入关键词并点击“获取类目”。 4. 选择表格;表格引用本地图片时同时选择 ZIP。 -5. 点击预检,确认每一行显示的兜底类目正确,再处理账号未授权、卡密组不存在、图片路径不匹配、固定邮费缺失或价格为 0 等错误。 +5. 点击预检,确认每一行的类目策略正确,再处理账号未授权、卡密组不存在、图片路径不匹配、固定邮费缺失或价格为 0 等错误。 6. 所有需发布行确认无误后启动任务;不要关闭正在运行的任务页面。 7. 在任务详情查看成功、失败与进行中行。需要时取消任务;正在提交的单件商品可能继续完成。 8. 对可重试失败项使用“重试失败”,并下载结果 CSV 留档。 ### 类目选择顺序 -系统仍会先让闲鱼根据标题、描述和图片自动识别类目。只有闲鱼明确返回“未能自动识别商品类目”时,系统才会使用后备配置:优先使用表格当前行的“类目ID + 类目名称”,否则使用上传页的批次兜底类目。接口超时、鉴权失败、风控等错误不会被兜底类目掩盖。 +类目优先级为:表格当前行指定类目 > 上传页通过关键词获取的默认类目 > 闲鱼根据商品标题、描述和图片自动识别 > “电子资料”最终兜底。只要用户指定了类目,就不会再由自动识别结果覆盖。接口超时、鉴权失败、风控等错误不会被最终兜底掩盖。 批量铺货发布的都是虚拟商品,不请求或提交实物发货地址;指定类目只解决商品类型识别,不会改变虚拟发货流程。 ## 3. 常见问题 - **图片找不到**:ZIP 内路径必须与表格完全一致,使用 `/`,不能以 `/` 开头或包含 `..`。 -- **未能自动识别类目**:新建批次时必须设置兜底类目;如果仍出现该提示,通常是旧批次没有保存兜底配置,请重新上传创建任务。不要把接口超时或鉴权错误误当成类目问题。 -- **类目 ID 从哪里取**:优先复用账号里同类型的历史商品类目。选择页面给出的历史类目,或从已同步商品的类目信息中复制 ID 和准确名称;不要猜测 ID。 +- **未能自动识别类目**:系统会自动使用“电子资料”最终兜底;接口超时、鉴权或风控错误仍会正常提示。 +- **类目 ID 从哪里取**:在上传页输入关键词获取,无需手工查找或填写底层 ID。 - **自动化不生效**:检查卡密组 ID、账号归属、启用列和库存;发布成功后仍应查看自动化规则是否已创建。 - **任务中断**:先重新打开批次详情确认状态,避免重复新建整批任务;仅重试失败行。 diff --git a/docs/wiki/账号、库存与商品.md b/docs/wiki/账号、库存与商品.md index 076dd0f..30d59fc 100644 --- a/docs/wiki/账号、库存与商品.md +++ b/docs/wiki/账号、库存与商品.md @@ -31,7 +31,7 @@ - 对已在闲鱼上存在的商品,选择同步全部或按页同步,确认商品归属到正确账号。 - 对单个新商品,使用发布入口填写标题、描述、价格、库存、邮费和图片。图片必须可用;提交前复核目标账号。 -- 批量铺货时必须指定批次兜底类目 ID 和名称。系统优先使用闲鱼自动识别结果,仅在无法识别时使用表格当前行的指定类目或批次兜底类目;类目信息应复用同类型历史商品,不要猜测 ID。 +- 批量铺货的默认类目可以留空,也可以通过关键词从闲鱼获取。优先级为逐行类目、页面默认类目、自动识别,最后才使用“电子资料”兜底。 - 批量铺货商品按虚拟商品发布,不依赖实物发货地址;类目兜底不会改变付款后的虚拟交付逻辑。 - 商品发布成功不等于已开启自动发货。仍需在“自动化规则”中按商品/规格绑定卡密组,或在批量铺货表格中一并声明自动化配置。 @@ -39,7 +39,7 @@ 1. 账号在线并已启用。 2. 商品已同步或发布成功,价格、库存和图片正确。 -3. 批量铺货的预检明细已显示正确的逐行兜底类目。 +3. 批量铺货的预检明细已显示正确的类目策略。 4. 所需卡密组启用且余量充足。 5. 自动化规则准确匹配商品;有规格时逐个规格确认。 6. 先用测试订单验证,检查订单列表、自动化异常列表和通知记录。 diff --git a/docs/批量铺货使用文档.md b/docs/批量铺货使用文档.md index 527dce5..63e8303 100644 --- a/docs/批量铺货使用文档.md +++ b/docs/批量铺货使用文档.md @@ -55,22 +55,23 @@ cookie_id,title,description,price,original_price,quantity,postage_mode,postage,i | 邮费 | 条件必填 | 数字。邮费模式为 `fixed` 时必填;`free` 时留空 | `8.00` | | 图片 | 是 | 1–9 张,多个用 `;` 分隔。每项是公网 URL 或图片包内相对路径 | `images/bundle-1.jpg;images/bundle-2.jpg` | -#### 指定类目字段(可选的逐行兜底) +#### 指定类目字段(可选的逐行默认类目) | 列 | 何时填写 | 格式 / 取值 | |---|---|---| -| 类目ID | 当前行需要覆盖批次兜底类目时 | 闲鱼商品类目 ID;必须和“类目名称”同时填写 | +| 类目ID | 当前行需要指定默认类目时 | 闲鱼商品类目 ID;必须和“类目名称、频道类目ID”同时填写 | | 类目名称 | 填写了“类目ID”时 | 与类目 ID 对应的准确名称 | -| 频道类目ID | 通常留空 | 仅在已从同类闲鱼商品取得准确值时填写 | -| 淘宝类目ID | 通常留空 | 仅在已从同类闲鱼商品取得准确值时填写 | +| 频道类目ID | 填写了“类目ID”时 | 必须填写闲鱼推荐响应中的准确频道类目 ID | +| 淘宝类目ID | 闲鱼响应有值时 | 按原样填写;“电子资料”没有该值,保持为空 | -上传页面还会要求运营人员填写一个必需的“批次兜底类目 ID + 类目名称”。系统对每行按以下顺序处理: +上传页面的默认类目可以留空。需要整批固定类目时,选择发布账号后输入关键词,由闲鱼推荐接口返回并保存完整类目信息。系统对每行按以下顺序处理: -1. 先调用闲鱼接口,根据标题、描述和图片自动识别类目。 -2. 自动识别成功时,使用闲鱼返回的类目,指定类目不会强行覆盖。 -3. 只有闲鱼明确未识别出类目时,才使用表格当前行的指定类目;当前行未填时使用上传页的批次兜底类目。 +1. 当前行填写了完整类目字段时,优先使用当前行类目。 +2. 否则,上传页已通过关键词选择默认类目时,使用页面默认类目。 +3. 前两项均为空时,调用闲鱼接口,根据标题、描述和图片自动识别。 +4. 闲鱼明确没有识别结果时,最终使用“电子资料”(类目 ID `50023914`、频道类目 ID `202036301`)。 -因此,即使表格完全不填写这四列,运营人员也必须在上传页设置批次兜底类目,保证每个待发布商品都有可用的后备类型。类目 ID 和名称应从同类型、已经同步或发布成功的闲鱼商品中取得,不要凭空编造。频道类目 ID 和淘宝类目 ID 没有可靠值时留空即可。 +因此,表格和上传页都不指定类目时,系统会先自动识别,并只在没有匹配结果时使用“电子资料”。接口超时、鉴权失败和风控错误不会被最终兜底掩盖。 #### 自动化字段(可选,不填或填"否"表示不启用) @@ -169,7 +170,7 @@ sub/product.jpg | 邮费模式 | `free` 或 `fixed`(或 `包邮` / `固定邮费`) | | 邮费 | 邮费模式为 `fixed` 时必填且 ≥ 0 | | 图片 | 1–9 张;本地路径必须在 ZIP 内存在;URL 必须是合法 `http(s)://` | -| 指定类目 | 当前行填写了任一类目字段时,“类目ID”和“类目名称”必须同时存在;批次兜底类目由上传者在页面必填 | +| 指定类目 | 当前行填写了任一类目字段时,“类目ID、类目名称、频道类目ID”必须同时存在;页面默认类目可为空 | | 付款发货 | 启用时:内容列必填至少一条卡密组;卡密组 ID 必须属于上传者;每件份数 > 0;延迟秒 ≥ 0 | | 评价赠品 | 同上 | | 求评价 | 启用时:等待小时 > 0、文案非空、最多次数 > 0 | @@ -200,7 +201,7 @@ sub/product.jpg 2222660684687,普通商品,仅发布不绑自动化,49.90,,10,fixed,8.00,https://cdn.example.com/p1.jpg,,,,,否,,否,,否,,, ``` -无需图片包(用的是 URL)。四个逐行类目列留空,上传时必须选择同类型商品对应的批次兜底类目。 +无需图片包(用的是 URL)。四个逐行类目列可留空;页面默认类目也留空时,系统会自动识别。 ### 7.2 完整自动化 + 本地图片包 @@ -233,8 +234,8 @@ images.zip - [ ] 每行标题非空、价格 > 0、库存 > 0 - [ ] 邮费模式只填 `free` / `fixed`(或 `包邮` / `固定邮费`);`fixed` 时邮费已填 - [ ] 每行图片 1–9 张,多个用 `;` 分隔 -- [ ] 已确认上传者会填写准确的批次兜底类目 ID 和名称 -- [ ] 需要逐行覆盖类目时,“类目ID”和“类目名称”同时填写;没有可靠的频道/淘宝类目 ID 时保持为空 +- [ ] 需要整批固定类目时,已在上传页通过关键词获取默认类目;否则保持为空 +- [ ] 需要逐行指定类目时,“类目ID、类目名称、频道类目ID”同时填写;淘宝类目 ID 按接口响应填写 - [ ] 用本地路径的图片,在 ZIP 内对应路径都能找到 - [ ] 用 URL 的图片,链接是 `http(s)://` 且可公开访问 - [ ] 启用了付款发货/评价赠品的行,内容列按 §3 格式填写,卡密组 ID 已知(或已标注需运营补填) diff --git a/frontend/components/ItemList.tsx b/frontend/components/ItemList.tsx index 7903340..606e11a 100644 --- a/frontend/components/ItemList.tsx +++ b/frontend/components/ItemList.tsx @@ -8,6 +8,7 @@ import { syncItemsFromAccount, createItem, publishItem, + recommendPublishCategory, previewItemPublishBatch, startItemPublishBatch, getItemPublishBatch, @@ -19,7 +20,7 @@ import { deleteItem, getShippingRules } from '../services/api'; -import { ArrowRight, Box, CheckCircle2, CircleDashed, Edit, Filter, Link2, PackagePlus, Plus, RefreshCw, Save, ShoppingBag, Trash2, UploadCloud, User, X } from 'lucide-react'; +import { ArrowRight, Box, CheckCircle2, CircleDashed, Edit, Filter, Link2, PackagePlus, Plus, RefreshCw, Save, Search, ShoppingBag, Trash2, UploadCloud, User, X } from 'lucide-react'; interface ItemListProps { onConfigureDelivery: (item: Item) => void; @@ -97,6 +98,8 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { const [batchPhase, setBatchPhase] = useState('upload'); const [batchFile, setBatchFile] = useState(null); const [batchImagesZip, setBatchImagesZip] = useState(null); + const [batchCategoryKeyword, setBatchCategoryKeyword] = useState(''); + const [batchCategoryLoading, setBatchCategoryLoading] = useState(false); const [batchFallbackCategory, setBatchFallbackCategory] = useState({ catId: '', catName: '', @@ -135,23 +138,6 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { }); const [publishImagePreviews, setPublishImagePreviews] = useState<{ key: string; url: string }[]>([]); - const knownCategories = useMemo(() => { - const unique = new Map(); - items.forEach(item => { - const catId = String(item.item_category || '').trim(); - if (!catId) return; - let catName = ''; - try { - const detail = JSON.parse(item.item_detail || '{}') as { category_name?: string }; - catName = String(detail.category_name || '').trim(); - } catch { - // 历史商品详情可能不是 JSON,仍保留可复用的类目 ID。 - } - if (!unique.has(catId) || catName) unique.set(catId, catName); - }); - return Array.from(unique, ([catId, catName]) => ({ catId, catName })); - }, [items]); - useEffect(() => { if (!showPublishModal || publishForm.images.length === 0) { setPublishImagePreviews([]); @@ -351,6 +337,7 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { setBatchDetail(null); setBatchFile(null); setBatchImagesZip(null); + setBatchCategoryKeyword(''); setBatchFallbackCategory({ catId: '', catName: '', channelCatId: '', tbCatId: '' }); setShowBatchModal(true); setBatchLoading(true); @@ -370,6 +357,28 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { } }; + const handleRecommendBatchCategory = async () => { + const keyword = batchCategoryKeyword.trim(); + if (!selectedAccount) return alert('请先选择默认发布账号'); + if (!keyword) return alert('请输入类目关键词'); + setBatchCategoryLoading(true); + try { + const result = await recommendPublishCategory(selectedAccount, keyword); + const category = result.category; + setBatchFallbackCategory({ + catId: category.cat_id, + catName: category.cat_name, + channelCatId: category.channel_cat_id, + tbCatId: category.tb_cat_id || '', + }); + } catch (error: any) { + console.error('获取推荐类目失败:', error); + alert(error?.message || '没有匹配到类目,请换一个更具体的关键词'); + } finally { + setBatchCategoryLoading(false); + } + }; + const openRecentBatchResult = async () => { if (!recentBatch?.id) return; setBatchLoading(true); @@ -388,9 +397,6 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { const handlePreviewBatch = async () => { if (!batchFile) return alert('请先上传商品表格'); if (!selectedAccount) return alert('请先选择默认发布账号'); - if (!batchFallbackCategory.catId.trim() || !batchFallbackCategory.catName.trim()) { - return alert('请同时填写批次兜底类目 ID 和类目名称'); - } setBatchLoading(true); try { const result = await previewItemPublishBatch({ @@ -953,58 +959,57 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => {

表格中“账号ID”为空时,会使用这里选择的账号。

-
+
-
批次兜底类目 *
-

闲鱼仍会先自动识别;只有明确识别不出类目时才使用这里的配置。表格中的“类目ID + 类目名称”可覆盖当前行。

+
默认类目 (可为空)
+

填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。

-
-
@@ -1078,10 +1083,10 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { ['邮费模式', '可以留空', '留空表示包邮;包邮填 free,固定邮费填 fixed'], ['邮费', '邮费模式填 fixed 时填写', '只填数字,例如 8.00'], ['图片', '每个商品都要填', '填写 zip 内图片路径或图片网址;多张图片用英文分号隔开'], - ['类目ID', '需要覆盖批次兜底类目时填写', '必须和“类目名称”同时填写;只覆盖当前商品行'], + ['类目ID', '需要指定当前行默认类目时填写', '必须和“类目名称、频道类目ID”同时填写;优先于自动识别'], ['类目名称', '填写了“类目ID”时必填', '填写该 ID 对应的准确类目名称'], - ['频道类目ID', '通常留空', '仅在已明确取得闲鱼频道类目 ID 时填写'], - ['淘宝类目ID', '通常留空', '仅在已明确取得淘宝类目 ID 时填写'], + ['频道类目ID', '覆盖类目时必填', '必须填写闲鱼返回的准确频道类目 ID'], + ['淘宝类目ID', '按闲鱼返回填写', '“电子资料”无淘宝类目 ID,保持为空'], ['付款发货启用', '需要付款后自动发货时填写', '填“是”表示开启;不需要时填“否”或留空'], ['付款发货内容', '“付款发货启用”填“是”时填写', '从“卡密库存”页面取得卡密组 ID,按上方示例填写'], ['评价赠品启用', '需要评价赠品时填写', '填“是”表示开启;不需要时填“否”或留空'], @@ -1129,7 +1134,7 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { 状态 标题 价格/库存 - 兜底类目 + 类目策略 图片 问题 @@ -1146,8 +1151,8 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { {row.title || '-'} ¥{row.price || '-'} / {row.quantity || 1} -
{row.category?.cat_name || '-'}
-
{row.category?.cat_id || '-'}
+
{row.category?.cat_name || '自动识别'}
+
{row.category?.cat_id || '失败后使用电子资料'}
{row.images?.length || 0} 张 {row.errors?.join(';') || '-'} @@ -1191,7 +1196,7 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { 行号 状态 标题 - 兜底类目 + 类目策略 商品ID 错误原因 @@ -1207,8 +1212,8 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => { {row.title} -
{row.category?.cat_name || '-'}
-
{row.category?.cat_id || '-'}
+
{row.category?.cat_name || '自动识别'}
+
{row.category?.cat_id || '失败后使用电子资料'}
{row.item_url ? {row.item_id} : (row.item_id || '-')} @@ -1225,7 +1230,7 @@ const ItemList: React.FC = ({ onConfigureDelivery }) => {
{batchPhase === 'upload' && ( - diff --git a/frontend/services/api.ts b/frontend/services/api.ts index b97f59a..050fc47 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -476,6 +476,18 @@ export const publishItem = async (form: { return postForm('/items/publish', body); } +export const recommendPublishCategory = async (cookieId: string, keyword: string): Promise<{ + success: boolean; + category: { + cat_id: string; + cat_name: string; + channel_cat_id: string; + tb_cat_id?: string; + }; +}> => { + return post('/items/publish-categories/recommend', { cookie_id: cookieId, keyword }); +}; + export const previewItemPublishBatch = async (form: { file: File; imagesZip?: File | null; diff --git a/internal/db/item_publish_batches.go b/internal/db/item_publish_batches.go index 68f7cb7..25b0370 100644 --- a/internal/db/item_publish_batches.go +++ b/internal/db/item_publish_batches.go @@ -49,7 +49,7 @@ type ItemPublishBatchRow struct { PostageMode string // 邮费模式:free/buyer/seller Postage string ImagesJSON string // 图片引用 JSON 数组(相对 UploadDir 的路径) - CategoryJSON string // 自动识别失败时使用的指定类目 JSON + CategoryJSON string // 用户指定的优先类目 JSON;为空时自动识别 AutomationJSON string // 发布后自动创建的自动化规则配置 JSON Status string // pending/running/success/failed ItemID string // 发布成功后回填的闲鱼商品 ID diff --git a/internal/server/item_handlers.go b/internal/server/item_handlers.go index a7e523a..15b56ce 100644 --- a/internal/server/item_handlers.go +++ b/internal/server/item_handlers.go @@ -23,6 +23,7 @@ func (s *Server) mountItemsReal(r chi.Router) { r.Post("/items/get-all-from-account", s.syncItemsFromAccount) r.Post("/items/get-by-page", s.syncItemsPageFromAccount) r.Post("/items/publish", s.publishItem) + r.Post("/items/publish-categories/recommend", s.recommendItemPublishCategory) r.Post("/items/publish-batches/preview", s.previewItemPublishBatch) r.Post("/items/publish-batches", s.startItemPublishBatch) r.Get("/items/publish-batches", s.listItemPublishBatches) diff --git a/internal/server/item_handlers_test.go b/internal/server/item_handlers_test.go index 40b182c..c776b5c 100644 --- a/internal/server/item_handlers_test.go +++ b/internal/server/item_handlers_test.go @@ -20,6 +20,45 @@ type stubPublishMTop struct { publish func(context.Context, string, mtop.PublishItemRequest) (*mtop.PublishItemResult, error) } +func TestRecommendItemPublishCategory(t *testing.T) { + srv, _, cleanup := newTestServer(t) + defer cleanup() + client := mtop.NewClient() + client.HTTPClient = &http.Client{Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) { + if req.URL.Query().Get("api") != "mtop.taobao.idle.kgraph.property.recommend" { + t.Fatalf("api=%q", req.URL.Query().Get("api")) + } + return &http.Response{ + StatusCode: http.StatusOK, + Header: make(http.Header), + Body: io.NopCloser(strings.NewReader( + `{"ret":["SUCCESS::调用成功"],"data":{"cardList":[{"cardData":{"propertyId":"-10000","propertyName":"分类","valuesList":[{"catId":"50023914","catName":"电子资料","channelCatId":"202036301","isClicked":"1"}]}}]}}`, + )), + Request: req, + }, nil + })} + srv.MTop = client + h := srv.Router() + cookie := loginHelper(t, h) + req := httptest.NewRequest(http.MethodPost, "/items/publish-categories/recommend", strings.NewReader(`{"cookie_id":"acc1","keyword":"课程资料"}`)) + req.Header.Set("Content-Type", "application/json") + req.AddCookie(cookie) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var response struct { + Category mtop.PublishCategory `json:"category"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &response); err != nil { + t.Fatalf("decode: %v", err) + } + if response.Category.CatID != "50023914" || response.Category.CatName != "电子资料" || response.Category.ChannelCatID != "202036301" { + t.Fatalf("category=%+v", response.Category) + } +} + func (s *stubPublishMTop) PublishItem(ctx context.Context, cookies string, req mtop.PublishItemRequest) (*mtop.PublishItemResult, error) { return s.publish(ctx, cookies, req) } diff --git a/internal/server/item_publish_batch_handlers.go b/internal/server/item_publish_batch_handlers.go index 4caf75f..451684c 100644 --- a/internal/server/item_publish_batch_handlers.go +++ b/internal/server/item_publish_batch_handlers.go @@ -94,6 +94,72 @@ type publishReviewRequestCfg struct { DelaySeconds int `json:"delay_seconds"` } +type publishCategoryRecommender interface { + RecommendPublishCategory(ctx context.Context, cookiesStr, keyword string) (mtop.PublishCategory, string, error) +} + +func (s *Server) recommendItemPublishCategory(w http.ResponseWriter, r *http.Request) { + var req struct { + CookieID string `json:"cookie_id"` + Keyword string `json:"keyword"` + } + if err := decodeJSON(r, &req); err != nil { + writeErr(w, http.StatusBadRequest, "请求格式错误") + return + } + req.CookieID = strings.TrimSpace(req.CookieID) + req.Keyword = strings.TrimSpace(req.Keyword) + if req.CookieID == "" { + writeErr(w, http.StatusBadRequest, "请先选择发布账号") + return + } + if req.Keyword == "" { + writeErr(w, http.StatusBadRequest, "请输入类目关键词") + return + } + _, userID, ok := s.cookieForCurrentUser(w, r, req.CookieID) + if !ok { + return + } + recommender, ok := s.mtopClient().(publishCategoryRecommender) + if !ok { + writeErr(w, http.StatusNotImplemented, "当前 MTOP 客户端不支持类目推荐") + return + } + + credentialUnlock := s.Store.LockAccountCredentials(req.CookieID) + defer credentialUnlock() + latest, err := s.Store.Cookies.GetDetails(r.Context(), req.CookieID) + if err != nil || latest == nil || latest.UserID != userID || !hasStoredCookieCredential(latest) { + writeErr(w, http.StatusConflict, "账号凭证已变化,请重试") + return + } + ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second) + defer cancel() + mtopCtx, cookieSession := withMTopCookieSnapshot(ctx, latest) + category, updatedCookies, callErr := recommender.RecommendPublishCategory(mtopCtx, latest.Value, req.Keyword) + _, _, handled, persistErr := s.persistMTopCookieSessionLocked(r.Context(), latest, cookieSession) + if persistErr != nil { + writeErr(w, http.StatusInternalServerError, "保存账号登录状态失败") + return + } + if !handled && updatedCookies != "" && updatedCookies != latest.Value { + if err := s.Store.Cookies.UpdateValueOwned(r.Context(), req.CookieID, updatedCookies, userID); err != nil { + writeErr(w, http.StatusInternalServerError, "保存账号登录状态失败") + return + } + } + if callErr != nil { + if errors.Is(callErr, mtop.ErrPublishCategoryUnrecognized) { + writeErr(w, http.StatusNotFound, "没有匹配到可发布类目,请换一个关键词") + return + } + writeErr(w, http.StatusBadGateway, callErr.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{"success": true, "category": category}) +} + func (s *Server) previewItemPublishBatch(w http.ResponseWriter, r *http.Request) { sess := auth.SessionFromContext(r.Context()) s.cleanupExpiredPublishUploads(r.Context()) @@ -119,8 +185,9 @@ func (s *Server) previewItemPublishBatch(w http.ResponseWriter, r *http.Request) ChannelCatID: strings.TrimSpace(r.FormValue("fallback_channel_category_id")), TBCatID: strings.TrimSpace(r.FormValue("fallback_tb_category_id")), } - if fallbackCategory.CatID == "" || fallbackCategory.CatName == "" { - writeErr(w, http.StatusBadRequest, "请同时填写批次兜底类目 ID 和类目名称") + hasDefaultCategory := fallbackCategory.CatID != "" || fallbackCategory.CatName != "" || fallbackCategory.ChannelCatID != "" || fallbackCategory.TBCatID != "" + if hasDefaultCategory && (fallbackCategory.CatID == "" || fallbackCategory.CatName == "" || fallbackCategory.ChannelCatID == "") { + writeErr(w, http.StatusBadRequest, "默认类目信息不完整,请重新通过关键词获取") return } source, sourceHeader, err := r.FormFile("file") @@ -536,7 +603,7 @@ func (s *Server) downloadItemPublishBatchResult(w http.ResponseWriter, r *http.R var buf bytes.Buffer buf.WriteString("\xEF\xBB\xBF") cw := csv.NewWriter(&buf) - _ = cw.Write([]string{"行号", "状态", "账号ID", "标题", "价格", "库存", "兜底类目ID", "兜底类目名称", "商品ID", "商品URL", "错误原因"}) + _ = cw.Write([]string{"行号", "状态", "账号ID", "标题", "价格", "库存", "默认类目ID", "默认类目名称", "商品ID", "商品URL", "错误原因"}) for _, row := range rows { var category mtop.PublishCategory _ = json.Unmarshal([]byte(row.CategoryJSON), &category) @@ -781,16 +848,19 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop. res := &mtop.PublishItemResult{ItemID: row.ItemID, ItemURL: row.ItemURL, Title: row.Title, PriceText: row.Price, Quantity: row.Quantity} var responseCookieErr error if row.ItemID == "" { + var preferredCategory *mtop.PublishCategory rawCategory := strings.TrimSpace(row.CategoryJSON) - if rawCategory == "" || rawCategory == "{}" { - return errors.New("批量任务缺少兜底类目,请重新上传并创建任务") - } - var fallbackCategory mtop.PublishCategory - if err := json.Unmarshal([]byte(rawCategory), &fallbackCategory); err != nil { - return errors.New("兜底类目配置损坏,请重新创建批量任务") - } - if strings.TrimSpace(fallbackCategory.CatID) == "" || strings.TrimSpace(fallbackCategory.CatName) == "" { - return errors.New("兜底类目缺少类目 ID 或类目名称,请重新创建批量任务") + if rawCategory != "" && rawCategory != "{}" { + var configured mtop.PublishCategory + if err := json.Unmarshal([]byte(rawCategory), &configured); err != nil { + return errors.New("默认类目配置损坏,请重新创建批量任务") + } + if strings.TrimSpace(configured.CatID) != "" || strings.TrimSpace(configured.CatName) != "" || strings.TrimSpace(configured.ChannelCatID) != "" || strings.TrimSpace(configured.TBCatID) != "" { + if strings.TrimSpace(configured.CatID) == "" || strings.TrimSpace(configured.CatName) == "" || strings.TrimSpace(configured.ChannelCatID) == "" { + return errors.New("默认类目信息不完整,请重新创建批量任务") + } + preferredCategory = &configured + } } images, err := loadBatchPublishImages(ctx, batch.UploadDir, row) if err != nil { @@ -830,7 +900,7 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop. PostageMode: row.PostageMode, PostageCents: postageCents, Virtual: true, - FallbackCategory: &fallbackCategory, + PreferredCategory: preferredCategory, Images: images, }) value, valueChanged, handled, persistErr := s.persistMTopCookieSessionLocked(ctx, latest, cookieSession) @@ -1064,8 +1134,8 @@ func (s *Server) parsePublishRows(ctx context.Context, userID int64, defaultCook hasRowCategory := rowCategory.CatID != "" || rowCategory.CatName != "" || rowCategory.ChannelCatID != "" || rowCategory.TBCatID != "" if hasRowCategory { row.Category = rowCategory - if rowCategory.CatID == "" || rowCategory.CatName == "" { - row.Errors = append(row.Errors, "指定行类目时必须同时填写类目ID和类目名称") + if rowCategory.CatID == "" || rowCategory.CatName == "" || rowCategory.ChannelCatID == "" { + row.Errors = append(row.Errors, "指定行类目时必须同时填写类目ID、类目名称和频道类目ID") } } else { row.Category = fallbackCategory diff --git a/internal/server/publish_batch_run_test.go b/internal/server/publish_batch_run_test.go index f023d93..99a80f9 100644 --- a/internal/server/publish_batch_run_test.go +++ b/internal/server/publish_batch_run_test.go @@ -97,6 +97,7 @@ func previewPublishBatch(t *testing.T, h http.Handler, cookie *http.Cookie) stri _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "虚拟商品") + _ = mw.WriteField("fallback_channel_category_id", "6001") csvField, _ := mw.CreateFormFile("file", "products.csv") csvField.Write([]byte("账号ID,标题,价格,库存,图片\nacc1,商品A,12.50,5,img/a.png\n")) zipField, _ := mw.CreateFormFile("images_zip", "images.zip") @@ -126,6 +127,7 @@ func previewTwoRowPublishBatch(t *testing.T, h http.Handler, cookie *http.Cookie _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "虚拟商品") + _ = mw.WriteField("fallback_channel_category_id", "6001") csvField, _ := mw.CreateFormFile("file", "products.csv") csvField.Write([]byte("账号ID,标题,价格,库存,图片\nacc1,商品A,12.50,5,img/a.png\nacc1,商品B,13.50,5,img/a.png\n")) zipField, _ := mw.CreateFormFile("images_zip", "images.zip") diff --git a/internal/server/publish_batch_test.go b/internal/server/publish_batch_test.go index 8b2137e..1d63b5e 100644 --- a/internal/server/publish_batch_test.go +++ b/internal/server/publish_batch_test.go @@ -81,6 +81,7 @@ func TestPreviewItemPublishBatchCSV(t *testing.T) { _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "虚拟商品") + _ = mw.WriteField("fallback_channel_category_id", "6001") csvField, _ := mw.CreateFormFile("file", "products.csv") csvField.Write([]byte("账号ID,标题,价格,库存,图片\nacc1,商品A,12.50,5,img/a.png\n")) zipField, _ := mw.CreateFormFile("images_zip", "images.zip") @@ -107,7 +108,7 @@ func TestPreviewItemPublishBatchCSV(t *testing.T) { } } -func TestPreviewItemPublishBatchRequiresFallbackCategory(t *testing.T) { +func TestPreviewItemPublishBatchAllowsEmptyDefaultCategory(t *testing.T) { srv, _, cleanup := newTestServer(t) defer cleanup() h := srv.Router() @@ -124,9 +125,16 @@ func TestPreviewItemPublishBatchRequiresFallbackCategory(t *testing.T) { req.AddCookie(cookie) rec := httptest.NewRecorder() h.ServeHTTP(rec, req) - if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "兜底类目") { + if rec.Code != http.StatusOK { t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) } + var res map[string]any + _ = json.Unmarshal(rec.Body.Bytes(), &res) + row := res["rows"].([]any)[0].(map[string]any) + category := row["category"].(map[string]any) + if category["cat_id"] != "" || category["cat_name"] != "" { + t.Fatalf("category should be empty: %+v", category) + } } func TestPreviewItemPublishBatchRowCategoryOverridesFallback(t *testing.T) { @@ -140,8 +148,9 @@ func TestPreviewItemPublishBatchRowCategoryOverridesFallback(t *testing.T) { _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "批次类目") + _ = mw.WriteField("fallback_channel_category_id", "6001") file, _ := mw.CreateFormFile("file", "products.csv") - file.Write([]byte("标题,价格,图片,类目ID,类目名称\n商品A,12.50,https://example.com/a.png,7001,行指定类目\n")) + file.Write([]byte("标题,价格,图片,类目ID,类目名称,频道类目ID\n商品A,12.50,https://example.com/a.png,7001,行指定类目,8001\n")) _ = mw.Close() req := httptest.NewRequest(http.MethodPost, "/items/publish-batches/preview", &buf) req.Header.Set("Content-Type", mw.FormDataContentType()) @@ -172,6 +181,7 @@ func TestPreviewItemPublishBatchNoFile(t *testing.T) { _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "虚拟商品") + _ = mw.WriteField("fallback_channel_category_id", "6001") _ = mw.Close() req := httptest.NewRequest(http.MethodPost, "/items/publish-batches/preview", &buf) @@ -246,6 +256,7 @@ func TestPreviewItemPublishBatchTooManyRows(t *testing.T) { _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "虚拟商品") + _ = mw.WriteField("fallback_channel_category_id", "6001") csvField, _ := mw.CreateFormFile("file", "products.csv") csvField.Write(csvBuf.Bytes()) _ = mw.Close() @@ -278,6 +289,7 @@ func TestPreviewItemPublishBatchZipTraversal(t *testing.T) { _ = mw.WriteField("default_cookie_id", "acc1") _ = mw.WriteField("fallback_category_id", "5001") _ = mw.WriteField("fallback_category_name", "虚拟商品") + _ = mw.WriteField("fallback_channel_category_id", "6001") csvField, _ := mw.CreateFormFile("file", "products.csv") csvField.Write([]byte("账号ID,标题,价格,库存,图片\nacc1,商品A,12.50,5,../escape.png\n")) zipField, _ := mw.CreateFormFile("images_zip", "images.zip") diff --git a/internal/webui/static/assets/index-BgaWj1th.css b/internal/webui/static/assets/index-BgaWj1th.css deleted file mode 100644 index cb0f469..0000000 --- a/internal/webui/static/assets/index-BgaWj1th.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-1{top:-.25rem;right:-.25rem;bottom:-.25rem;left:-.25rem}.inset-0{top:0;right:0;bottom:0;left:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-12{right:-3rem}.-right-6{right:-1.5rem}.-top-16{top:-4rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-0\.5{left:.125rem}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[-10\%\]{left:-10%}.right-0{right:0}.right-10{right:2.5rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-\[-10\%\]{right:-10%}.top-0{top:0}.top-0\.5{top:.125rem}.top-1{top:.25rem}.top-1\.5{top:.375rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-\[-10\%\]{top:-10%}.top-\[calc\(100\%\+6px\)\]{top:calc(100% + 6px)}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-\[10000\]{z-index:10000}.col-span-2{grid-column:span 2 / span 2}.col-span-full{grid-column:1 / -1}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-64{margin-left:16rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-32{height:8rem}.h-36{height:9rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[350px\]{height:350px}.h-\[48px\]{height:48px}.h-\[60\%\]{height:60%}.h-\[800px\]{height:800px}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[min\(64vh\,28rem\)\]{max-height:min(64vh,28rem)}.min-h-0{min-height:0px}.min-h-36{min-height:9rem}.min-h-56{min-height:14rem}.min-h-64{min-height:16rem}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[19\%\]{width:19%}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[60\%\]{width:60%}.w-\[7\%\]{width:7%}.w-\[8\%\]{width:8%}.w-\[800px\]{width:800px}.w-\[9\%\]{width:9%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-64{min-width:16rem}.min-w-9{min-width:2.25rem}.min-w-\[150px\]{min-width:150px}.min-w-\[200px\]{min-width:200px}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[12rem\]{max-width:12rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[15rem\]{max-width:15rem}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[400px\]{max-width:400px}.max-w-\[80px\]{max-width:80px}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-5{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-7{--tw-translate-x: 1.75rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-\[1\.02\]{--tw-scale-x: 1.02;--tw-scale-y: 1.02;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}@keyframes spin{to{transform:rotate(360deg)}}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-100>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(243 244 246 / var(--tw-divide-opacity, 1))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(249 250 251 / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:6px}.rounded-2xl,.rounded-3xl{border-radius:10px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:7px}.rounded-md{border-radius:6px}.rounded-xl{border-radius:8px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-\[\#0094f7\]{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(254 243 199 / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-amber-500{--tw-border-opacity: 1;border-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(219 234 254 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(209 250 229 / var(--tw-border-opacity, 1))}.border-emerald-500{--tw-border-opacity: 1;border-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(243 232 255 / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(254 226 226 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-white\/10{border-color:#ffffff1a}.border-white\/80{border-color:#fffc}.bg-\[\#0094f7\]{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F4F5F7\]{--tw-bg-opacity: 1;background-color:rgb(244 245 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F7F8FA\]{--tw-bg-opacity: 1;background-color:rgb(247 248 250 / var(--tw-bg-opacity, 1))}.bg-\[\#FAFAFA\]{--tw-bg-opacity: 1;background-color:rgb(250 250 250 / var(--tw-bg-opacity, 1))}.bg-\[\#f5f5f7\]{--tw-bg-opacity: 1;background-color:rgb(245 245 247 / var(--tw-bg-opacity, 1))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:#fef3c7b3}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-amber-50\/60{background-color:#fffbeb99}.bg-amber-50\/70{background-color:#fffbebb3}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-100\/70{background-color:#dbeafeb3}.bg-blue-200\/30{background-color:#bfdbfe4d}.bg-blue-200\/40{background-color:#bfdbfe66}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-50\/40{background-color:#eff6ff66}.bg-blue-50\/50{background-color:#eff6ff80}.bg-blue-50\/60{background-color:#eff6ff99}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:#3b82f633}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.bg-emerald-50\/60{background-color:#ecfdf599}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(5 150 105 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:#f3f4f680}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:#e5e7eb80}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:#f9fafbb3}.bg-gray-50\/80{background-color:#f9fafbcc}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(249 115 22 / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(253 242 248 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:#faf5ff80}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(168 85 247 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:#fecaca59}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(15 23 42 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:#ffffff0d}.bg-white\/80{background-color:#fffc}.bg-white\/90{background-color:#ffffffe6}.bg-white\/95{background-color:#fffffff2}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: #eff6ff var(--tw-gradient-from-position);--tw-gradient-to: rgb(239 246 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: #fef2f2 var(--tw-gradient-from-position);--tw-gradient-to: rgb(254 242 242 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(255 255 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), #fff var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: #fff7ed var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: transparent var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-12{padding:3rem}.p-16{padding:4rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-20{padding:5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-20{padding-top:5rem;padding-bottom:5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pl-10{padding-left:2.5rem}.pl-11{padding-left:2.75rem}.pl-14{padding-left:3.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pl-6{padding-left:1.5rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pr-9{padding-right:2.25rem}.pt-1{padding-top:.25rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-black{font-weight:900}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-relaxed{line-height:1.625}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.text-\[\#111\]{--tw-text-opacity: 1;color:rgb(17 17 17 / var(--tw-text-opacity, 1))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:#92400ecc}.text-amber-900{--tw-text-opacity: 1;color:rgb(120 53 15 / var(--tw-text-opacity, 1))}.text-amber-900\/90{color:#78350fe6}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(4 120 87 / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(6 95 70 / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(3 7 18 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(219 39 119 / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(168 85 247 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-red-900{--tw-text-opacity: 1;color:rgb(127 29 29 / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(2 6 23 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/30{color:#ffffff4d}.accent-\[\#0094f7\]{accent-color:#0094f7}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_20px_60px_-15px_rgba\(0\,0\,0\,0\.05\)\]{--tw-shadow: 0 20px 60px -15px rgba(0,0,0,.05);--tw-shadow-colored: 0 20px 60px -15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_24px_64px_rgba\(15\,23\,42\,0\.22\)\]{--tw-shadow: 0 24px 64px rgba(15,23,42,.22);--tw-shadow-colored: 0 24px 64px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[4px_0_24px_rgba\(0\,0\,0\,0\.02\)\]{--tw-shadow: 4px 0 24px rgba(0,0,0,.02);--tw-shadow-colored: 4px 0 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: inset 0 2px 4px 0 rgb(0 0 0 / .05);--tw-shadow-colored: inset 0 2px 4px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-100{--tw-shadow-color: #dbeafe;--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: #bfdbfe;--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: #d1fae5;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: #e5e7eb;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(229 231 235 / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: #fecaca;--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(229 231 235 / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(255 255 255 / var(--tw-ring-opacity, 1))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-2xl{--tw-blur: blur(40px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-\[120px\]{--tw-blur: blur(120px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur: blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-3xl{--tw-backdrop-blur: blur(64px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.squircle{-webkit-mask-image:url(/static/assets/squircle-rb6SKa34.svg);mask-image:url(/static/assets/squircle-rb6SKa34.svg);-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;border-radius:0}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;background-color:#f4f5f7;color:#fff;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:#fff;border-radius:8px;border:1px solid rgba(0,0,0,.02);box-shadow:0 8px 24px #0000000a;transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px #0000000f}.ios-input{background:#f7f8fa;border:1px solid transparent;transition:all .3s cubic-bezier(.25,.8,.25,1);color:#111;font-weight:500}.ios-input:focus{background:#fff;border-color:#0094f7;box-shadow:0 0 0 4px #0094f74d;outline:none}.ios-input::-moz-placeholder{color:#9ca3af;font-weight:400}.ios-input::placeholder{color:#9ca3af;font-weight:400}.ios-btn-primary{background:#0094f7;color:#fff;font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:#0071e3;transform:translateY(-1px);box-shadow:0 8px 20px #0094f74d}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:0 2px 8px #0094f733}.ios-btn-primary:disabled{background:#f0f0f0;color:#aaa;box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:#f7f8fa;color:#fff;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:#e5e7eb;border-color:#d1d5db}.ios-btn-danger{background:#fee2e2;color:#dc2626;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:#fecaca;border-color:#fca5a5}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#0000001a;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:#0003}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-in{animation:fadeIn .5s cubic-bezier(.16,1,.3,1) forwards}@keyframes slideUp{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.animate-slide-up{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}::-moz-selection{background:#0094f7;color:#fff}::selection{background:#0094f7;color:#fff}.text-brand{color:#0094f7}.bg-brand{background-color:#0094f7}.border-brand{border-color:#0094f7}.status-badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:600}.status-badge-success{background-color:#d1fae5;color:#065f46}.status-badge-warning{background-color:#fef3c7;color:#92400e}.status-badge-error{background-color:#fee2e2;color:#991b1b}.status-badge-info{background-color:#dbeafe;color:#1e40af}.loading-skeleton{background:linear-gradient(90deg,#f3f4f6,#e5e7eb,#f3f4f6);background-size:200% 100%;animation:loading 1.5s ease-in-out infinite}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-body{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:2rem}.modal-footer{flex-shrink:0;padding:1.5rem 2rem 2rem;border-top:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-container-lg{max-width:64rem}.modal-overlay-centered{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-overlay-centered .modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto 0;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}@media(max-width:768px){.ios-card{border-radius:6px}.ios-input{font-size:16px}.modal-container{max-width:calc(100% - 2rem);max-height:90vh;border-radius:8px}.modal-header,.modal-body,.modal-footer{padding-left:1.5rem;padding-right:1.5rem}}.hover\:translate-y-\[-4px\]:hover{--tw-translate-y: -4px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-\[\#0094f7\]:hover{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.hover\:border-amber-300:hover{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(110 231 183 / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.hover\:bg-\[\#0071e3\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 113 227 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#0094f7\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#FFFDE7\]\/50:hover{background-color:#fffde780}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:#ecfdf580}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(4 120 87 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:#ffffff1a}.hover\:text-\[\#0094f7\]:hover{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-400:focus{--tw-border-opacity: 1;border-color:rgb(96 165 250 / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[\#0094f7\]:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(0 148 247 / var(--tw-ring-opacity, 1))}.active\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-red-400:disabled{--tw-bg-opacity: 1;background-color:rgb(248 113 113 / var(--tw-bg-opacity, 1))}.disabled\:opacity-25:disabled{opacity:.25}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.disabled\:opacity-70:disabled{opacity:.7}.group:focus-within .group-focus-within\:text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-105{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-56{width:14rem}.sm\:w-72{width:18rem}.sm\:max-w-sm{max-width:24rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:grid-cols-\[1fr_180px\]{grid-template-columns:1fr 180px}.sm\:flex-row{flex-direction:row}.sm\:flex-wrap{flex-wrap:wrap}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:col-span-3{grid-column:span 3 / span 3}.md\:col-span-full{grid-column:1 / -1}.md\:w-auto{width:auto}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1\.4fr_110px_40px\]{grid-template-columns:1.4fr 110px 40px}.md\:grid-cols-\[180px_1fr\]{grid-template-columns:180px 1fr}.md\:grid-cols-\[1fr_1fr_1\.4fr_110px_40px\]{grid-template-columns:1fr 1fr 1.4fr 110px 40px}.md\:flex-row{flex-direction:row}.md\:items-end{align-items:flex-end}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l{border-left-width:1px}.md\:border-t-0{border-top-width:0px}.md\:p-12{padding:3rem}.md\:pl-6{padding-left:1.5rem}.md\:pt-0{padding-top:0}}@media(min-width:1024px){.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[320px_1fr\]{grid-template-columns:320px 1fr}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}.lg\:self-auto{align-self:auto}}@media(min-width:1280px){.xl\:w-36{width:9rem}.xl\:w-52{width:13rem}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:items-center{align-items:center}.xl\:justify-between{justify-content:space-between}}@media(min-width:1536px){.\32xl\:grid-cols-\[360px_1fr\]{grid-template-columns:360px 1fr}} diff --git a/internal/webui/static/assets/index-C7AaUlyC.css b/internal/webui/static/assets/index-C7AaUlyC.css new file mode 100644 index 0000000..4174551 --- /dev/null +++ b/internal/webui/static/assets/index-C7AaUlyC.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-1{top:-.25rem;right:-.25rem;bottom:-.25rem;left:-.25rem}.inset-0{top:0;right:0;bottom:0;left:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-12{right:-3rem}.-right-6{right:-1.5rem}.-top-16{top:-4rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-0\.5{left:.125rem}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[-10\%\]{left:-10%}.right-0{right:0}.right-10{right:2.5rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-\[-10\%\]{right:-10%}.top-0{top:0}.top-0\.5{top:.125rem}.top-1{top:.25rem}.top-1\.5{top:.375rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-\[-10\%\]{top:-10%}.top-\[calc\(100\%\+6px\)\]{top:calc(100% + 6px)}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-\[10000\]{z-index:10000}.col-span-2{grid-column:span 2 / span 2}.col-span-full{grid-column:1 / -1}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-64{margin-left:16rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-32{height:8rem}.h-36{height:9rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[350px\]{height:350px}.h-\[48px\]{height:48px}.h-\[60\%\]{height:60%}.h-\[800px\]{height:800px}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[min\(64vh\,28rem\)\]{max-height:min(64vh,28rem)}.min-h-0{min-height:0px}.min-h-36{min-height:9rem}.min-h-56{min-height:14rem}.min-h-64{min-height:16rem}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-\[42px\]{min-height:42px}.min-h-\[46px\]{min-height:46px}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[19\%\]{width:19%}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[60\%\]{width:60%}.w-\[7\%\]{width:7%}.w-\[8\%\]{width:8%}.w-\[800px\]{width:800px}.w-\[9\%\]{width:9%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-64{min-width:16rem}.min-w-9{min-width:2.25rem}.min-w-\[150px\]{min-width:150px}.min-w-\[200px\]{min-width:200px}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[12rem\]{max-width:12rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[15rem\]{max-width:15rem}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[400px\]{max-width:400px}.max-w-\[80px\]{max-width:80px}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-5{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-7{--tw-translate-x: 1.75rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-\[1\.02\]{--tw-scale-x: 1.02;--tw-scale-y: 1.02;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}@keyframes spin{to{transform:rotate(360deg)}}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-100>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(243 244 246 / var(--tw-divide-opacity, 1))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(249 250 251 / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:6px}.rounded-2xl,.rounded-3xl{border-radius:10px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:7px}.rounded-md{border-radius:6px}.rounded-xl{border-radius:8px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-\[\#0094f7\]{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(254 243 199 / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-amber-500{--tw-border-opacity: 1;border-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(219 234 254 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(209 250 229 / var(--tw-border-opacity, 1))}.border-emerald-500{--tw-border-opacity: 1;border-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(243 232 255 / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(254 226 226 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-white\/10{border-color:#ffffff1a}.border-white\/80{border-color:#fffc}.bg-\[\#0094f7\]{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F4F5F7\]{--tw-bg-opacity: 1;background-color:rgb(244 245 247 / var(--tw-bg-opacity, 1))}.bg-\[\#F7F8FA\]{--tw-bg-opacity: 1;background-color:rgb(247 248 250 / var(--tw-bg-opacity, 1))}.bg-\[\#FAFAFA\]{--tw-bg-opacity: 1;background-color:rgb(250 250 250 / var(--tw-bg-opacity, 1))}.bg-\[\#f5f5f7\]{--tw-bg-opacity: 1;background-color:rgb(245 245 247 / var(--tw-bg-opacity, 1))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:#fef3c7b3}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-amber-50\/60{background-color:#fffbeb99}.bg-amber-50\/70{background-color:#fffbebb3}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-100\/70{background-color:#dbeafeb3}.bg-blue-200\/30{background-color:#bfdbfe4d}.bg-blue-200\/40{background-color:#bfdbfe66}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-50\/40{background-color:#eff6ff66}.bg-blue-50\/50{background-color:#eff6ff80}.bg-blue-50\/60{background-color:#eff6ff99}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:#3b82f633}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.bg-emerald-50\/60{background-color:#ecfdf599}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(5 150 105 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:#f3f4f680}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:#e5e7eb80}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:#f9fafbb3}.bg-gray-50\/80{background-color:#f9fafbcc}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(249 115 22 / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(253 242 248 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:#faf5ff80}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(168 85 247 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:#fecaca59}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(15 23 42 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:#ffffff0d}.bg-white\/80{background-color:#fffc}.bg-white\/90{background-color:#ffffffe6}.bg-white\/95{background-color:#fffffff2}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: #eff6ff var(--tw-gradient-from-position);--tw-gradient-to: rgb(239 246 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: #fef2f2 var(--tw-gradient-from-position);--tw-gradient-to: rgb(254 242 242 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(255 255 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), #fff var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: #fff7ed var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: transparent var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-12{padding:3rem}.p-16{padding:4rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-20{padding:5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-20{padding-top:5rem;padding-bottom:5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pl-10{padding-left:2.5rem}.pl-11{padding-left:2.75rem}.pl-14{padding-left:3.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pl-6{padding-left:1.5rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pr-9{padding-right:2.25rem}.pt-1{padding-top:.25rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-black{font-weight:900}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-relaxed{line-height:1.625}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.text-\[\#111\]{--tw-text-opacity: 1;color:rgb(17 17 17 / var(--tw-text-opacity, 1))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:#92400ecc}.text-amber-900{--tw-text-opacity: 1;color:rgb(120 53 15 / var(--tw-text-opacity, 1))}.text-amber-900\/90{color:#78350fe6}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(4 120 87 / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(6 95 70 / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(3 7 18 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(219 39 119 / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(168 85 247 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-red-900{--tw-text-opacity: 1;color:rgb(127 29 29 / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(2 6 23 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/30{color:#ffffff4d}.accent-\[\#0094f7\]{accent-color:#0094f7}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_20px_60px_-15px_rgba\(0\,0\,0\,0\.05\)\]{--tw-shadow: 0 20px 60px -15px rgba(0,0,0,.05);--tw-shadow-colored: 0 20px 60px -15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_24px_64px_rgba\(15\,23\,42\,0\.22\)\]{--tw-shadow: 0 24px 64px rgba(15,23,42,.22);--tw-shadow-colored: 0 24px 64px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[4px_0_24px_rgba\(0\,0\,0\,0\.02\)\]{--tw-shadow: 4px 0 24px rgba(0,0,0,.02);--tw-shadow-colored: 4px 0 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: inset 0 2px 4px 0 rgb(0 0 0 / .05);--tw-shadow-colored: inset 0 2px 4px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-100{--tw-shadow-color: #dbeafe;--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: #bfdbfe;--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: #d1fae5;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: #e5e7eb;--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(229 231 235 / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: #fecaca;--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(229 231 235 / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(255 255 255 / var(--tw-ring-opacity, 1))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-2xl{--tw-blur: blur(40px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-\[120px\]{--tw-blur: blur(120px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur: blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-3xl{--tw-backdrop-blur: blur(64px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.squircle{-webkit-mask-image:url(/static/assets/squircle-rb6SKa34.svg);mask-image:url(/static/assets/squircle-rb6SKa34.svg);-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;border-radius:0}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;background-color:#f4f5f7;color:#fff;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:#fff;border-radius:8px;border:1px solid rgba(0,0,0,.02);box-shadow:0 8px 24px #0000000a;transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px #0000000f}.ios-input{background:#f7f8fa;border:1px solid transparent;transition:all .3s cubic-bezier(.25,.8,.25,1);color:#111;font-weight:500}.ios-input:focus{background:#fff;border-color:#0094f7;box-shadow:0 0 0 4px #0094f74d;outline:none}.ios-input::-moz-placeholder{color:#9ca3af;font-weight:400}.ios-input::placeholder{color:#9ca3af;font-weight:400}.ios-btn-primary{background:#0094f7;color:#fff;font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:#0071e3;transform:translateY(-1px);box-shadow:0 8px 20px #0094f74d}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:0 2px 8px #0094f733}.ios-btn-primary:disabled{background:#f0f0f0;color:#aaa;box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:#f7f8fa;color:#fff;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:#e5e7eb;border-color:#d1d5db}.ios-btn-danger{background:#fee2e2;color:#dc2626;font-weight:600;border:1px solid transparent;transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:#fecaca;border-color:#fca5a5}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#0000001a;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:#0003}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-in{animation:fadeIn .5s cubic-bezier(.16,1,.3,1) forwards}@keyframes slideUp{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.animate-slide-up{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}::-moz-selection{background:#0094f7;color:#fff}::selection{background:#0094f7;color:#fff}.text-brand{color:#0094f7}.bg-brand{background-color:#0094f7}.border-brand{border-color:#0094f7}.status-badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:600}.status-badge-success{background-color:#d1fae5;color:#065f46}.status-badge-warning{background-color:#fef3c7;color:#92400e}.status-badge-error{background-color:#fee2e2;color:#991b1b}.status-badge-info{background-color:#dbeafe;color:#1e40af}.loading-skeleton{background:linear-gradient(90deg,#f3f4f6,#e5e7eb,#f3f4f6);background-size:200% 100%;animation:loading 1.5s ease-in-out infinite}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-body{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:2rem}.modal-footer{flex-shrink:0;padding:1.5rem 2rem 2rem;border-top:1px solid #F3F4F6;background-color:#fff;z-index:10}.modal-container-lg{max-width:64rem}.modal-overlay-centered{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;justify-content:center;background-color:#0006;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-overlay-centered .modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto 0;display:flex;flex-direction:column;background-color:#fff;border-radius:10px;box-shadow:0 25px 50px -12px #00000040;overflow:hidden}@media(max-width:768px){.ios-card{border-radius:6px}.ios-input{font-size:16px}.modal-container{max-width:calc(100% - 2rem);max-height:90vh;border-radius:8px}.modal-header,.modal-body,.modal-footer{padding-left:1.5rem;padding-right:1.5rem}}.hover\:translate-y-\[-4px\]:hover{--tw-translate-y: -4px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-\[\#0094f7\]:hover{--tw-border-opacity: 1;border-color:rgb(0 148 247 / var(--tw-border-opacity, 1))}.hover\:border-amber-300:hover{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(110 231 183 / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.hover\:bg-\[\#0071e3\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 113 227 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#0094f7\]:hover{--tw-bg-opacity: 1;background-color:rgb(0 148 247 / var(--tw-bg-opacity, 1))}.hover\:bg-\[\#FFFDE7\]\/50:hover{background-color:#fffde780}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:#ecfdf580}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(4 120 87 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:#ffffff1a}.hover\:text-\[\#0094f7\]:hover{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-400:focus{--tw-border-opacity: 1;border-color:rgb(96 165 250 / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[\#0094f7\]:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(0 148 247 / var(--tw-ring-opacity, 1))}.active\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-red-400:disabled{--tw-bg-opacity: 1;background-color:rgb(248 113 113 / var(--tw-bg-opacity, 1))}.disabled\:opacity-25:disabled{opacity:.25}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.disabled\:opacity-70:disabled{opacity:.7}.group:focus-within .group-focus-within\:text-\[\#0094f7\]{--tw-text-opacity: 1;color:rgb(0 148 247 / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-105{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-56{width:14rem}.sm\:w-72{width:18rem}.sm\:max-w-sm{max-width:24rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:grid-cols-\[1fr_180px\]{grid-template-columns:1fr 180px}.sm\:flex-row{flex-direction:row}.sm\:flex-wrap{flex-wrap:wrap}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:col-span-3{grid-column:span 3 / span 3}.md\:col-span-full{grid-column:1 / -1}.md\:w-auto{width:auto}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1\.4fr_110px_40px\]{grid-template-columns:1.4fr 110px 40px}.md\:grid-cols-\[180px_1fr\]{grid-template-columns:180px 1fr}.md\:grid-cols-\[1fr_1fr_1\.4fr_110px_40px\]{grid-template-columns:1fr 1fr 1.4fr 110px 40px}.md\:flex-row{flex-direction:row}.md\:items-end{align-items:flex-end}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l{border-left-width:1px}.md\:border-t-0{border-top-width:0px}.md\:p-12{padding:3rem}.md\:pl-6{padding-left:1.5rem}.md\:pt-0{padding-top:0}}@media(min-width:1024px){.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[320px_1fr\]{grid-template-columns:320px 1fr}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}.lg\:self-auto{align-self:auto}}@media(min-width:1280px){.xl\:w-36{width:9rem}.xl\:w-52{width:13rem}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:items-center{align-items:center}.xl\:justify-between{justify-content:space-between}}@media(min-width:1536px){.\32xl\:grid-cols-\[360px_1fr\]{grid-template-columns:360px 1fr}} diff --git a/internal/webui/static/assets/index-D1qb4SVL.js b/internal/webui/static/assets/index-D1qb4SVL.js deleted file mode 100644 index 0b3c29d..0000000 --- a/internal/webui/static/assets/index-D1qb4SVL.js +++ /dev/null @@ -1,19 +0,0 @@ -import{j as e,r as i,b as Le,c as ba,d as ya}from"./react-vendor-DZnRGM0-.js";import{L as fa,U as Ut,S as Wt,C as Ys,B as Vt,Z as Zs,a as ps,b as rt,c as Gt,d as ja,e as ns,A as ht,D as Na,f as gt,P as Jt,g as ks,E as Qt,T as va,h as wa,i as Re,Q as zs,j as is,k as He,l as us,m as bt,R as Oe,n as Kt,o as _a,p as Je,X as _e,K as ka,q as rs,r as as,s as ss,t as es,u as yt,v as nt,w as hs,x as Yt,y as Zt,z as _s,F as Xt,G as Ca,H as ft,I as jt,J as Sa,M as La,N as Aa,O as Ia,V as Us,W as As,Y as Ht,_ as $a,$ as Ra,a0 as Xs,a1 as Pa,a2 as Da,a3 as Hs,a4 as Nt,a5 as Fa,a6 as Fs,a7 as ea,a8 as Ta,a9 as Ea,aa as it,ab as sa,ac as Ma,ad as Oa}from"./icons-vendor-RenKjhri.js";import{R as Is,B as qa,X as vt,Y as wt,T as Ws,a as Ba,C as Vs,A as za,b as Ua,c as Wa,P as _t,d as kt,L as Va}from"./charts-vendor-B_BfwiL0.js";import"./vendor-w5t2K9ux.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))d(x);new MutationObserver(x=>{for(const N of x)if(N.type==="childList")for(const S of N.addedNodes)S.tagName==="LINK"&&S.rel==="modulepreload"&&d(S)}).observe(document,{childList:!0,subtree:!0});function n(x){const N={};return x.integrity&&(N.integrity=x.integrity),x.referrerPolicy&&(N.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?N.credentials="include":x.crossOrigin==="anonymous"?N.credentials="omit":N.credentials="same-origin",N}function d(x){if(x.ep)return;x.ep=!0;const N=n(x);fetch(x.href,N)}})();const Ga=({className:s="w-full h-full text-white"})=>e.jsx("svg",{className:s,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),et=({sizeClass:s="w-12 h-12",logoClassName:t="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${s} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0094f7"}),e.jsx("stop",{offset:"100%",stopColor:"#287efe"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),e.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:e.jsx(Ga,{className:t})})]})]}),Ja=({activeTab:s,isAdmin:t=!1,onNavigate:n,onLogout:d})=>{const x=[{id:"dashboard",icon:fa,label:"仪表盘"},{id:"accounts",icon:Ut,label:"账号管理"},{id:"orders",icon:Wt,label:"订单管理"},{id:"cards",icon:Ys,label:"卡密库存"},{id:"items",icon:Vt,label:"商品列表"},{id:"rules",icon:Zs,label:"自动化规则"},{id:"notifications",icon:ps,label:"通知设置"},...t?[{id:"settings",icon:rt,label:"系统与AI"}]:[]];return e.jsxs("div",{className:"w-64 h-screen fixed left-0 top-0 bg-white border-r border-gray-100 flex flex-col justify-between z-20 shadow-[4px_0_24px_rgba(0,0,0,0.02)]",children:[e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-12 px-2",children:[e.jsx("div",{className:"shrink-0",children:e.jsx(et,{sizeClass:"w-10 h-10"})}),e.jsxs("h1",{className:"text-xl font-extrabold tracking-tight text-gray-900",children:["Ydisks闲鱼助手 ",e.jsx("span",{className:"text-xs bg-[#0094f7] text-white px-1.5 py-0.5 rounded ml-1",children:"PRO"})]})]}),e.jsx("nav",{className:"space-y-2",children:x.map(N=>{const S=N.icon,F=s===N.id;return e.jsxs("button",{onClick:()=>n(N.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all duration-300 group relative overflow-hidden ${F?"bg-[#0094f7] text-white font-bold shadow-lg shadow-blue-100 transform scale-[1.02]":"text-gray-500 hover:bg-gray-50 hover:text-gray-900"}`,children:[e.jsx(S,{className:`w-5 h-5 transition-colors ${F?"text-white":"text-gray-400 group-hover:text-gray-600"}`}),e.jsx("span",{className:"text-sm tracking-wide",children:N.label}),F&&e.jsx(Gt,{className:"w-4 h-4 absolute right-3 text-white/30 animate-pulse"})]},N.id)})})]}),e.jsx("div",{className:"p-6 border-t border-gray-50",children:e.jsxs("button",{onClick:d,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-500 hover:text-red-500 hover:bg-red-50 rounded-2xl transition-all duration-200 font-medium",children:[e.jsx(ja,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"退出登录"})]})})]})},Qa=3e4,Ka=10*6e4;let Gs=!1;const ta=()=>{Gs||typeof window>"u"||(Gs=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{Gs=!1}))},Ya=s=>{if(!s)return"";const t=new URLSearchParams;for(const[d,x]of Object.entries(s))x!=null&&t.set(d,String(x));const n=t.toString();return n?`?${n}`:""},Es=async(s,t,n={})=>{var R;const d=Ya(n.params),x=`${t}${d}`,N=aa(n.signal,n.timeoutMs??Qa);let S;try{S=await fetch(x,{method:s,credentials:"include",signal:N.signal,headers:{...n.body===void 0?{}:{"Content-Type":"application/json"}},body:n.body===void 0?void 0:JSON.stringify(n.body)})}catch(b){throw N.signal.aborted?new Error((R=n.signal)!=null&&R.aborted?"请求已取消":"请求超时,请稍后重试"):b}finally{N.cleanup()}const h=(S.headers.get("content-type")||"").includes("application/json");if(!S.ok){S.status===401&&!n.skipAuthLogout&&ta();const b=h?await S.json().catch(()=>{}):await S.text().catch(()=>{}),J=typeof b=="string"?b:(b==null?void 0:b.detail)||(b==null?void 0:b.message)||(b==null?void 0:b.msg);throw new Error(J||`请求失败: ${S.status}`)}return h?await S.json():await S.text()},fe=async(s,t,n)=>Es("GET",s,{params:t,...n}),Ne=async(s,t,n)=>Es("POST",s,{body:t,...n}),Fe=async(s,t,n)=>Es("PUT",s,{body:t,...n}),Ze=async(s,t,n)=>Es("DELETE",s,{params:t,...n}),Cs=async(s,t,n={})=>{var h;const d=aa(n.signal,n.timeoutMs??Ka);let x;try{x=await fetch(s,{method:"POST",credentials:"include",signal:d.signal,body:t})}catch(R){throw d.signal.aborted?new Error((h=n.signal)!=null&&h.aborted?"请求已取消":"上传超时,请稍后重试"):R}finally{d.cleanup()}const F=(x.headers.get("content-type")||"").includes("application/json")?await x.json().catch(()=>{}):await x.text().catch(()=>{});if(!x.ok){x.status===401&&ta();const R=typeof F=="string"?F:(F==null?void 0:F.detail)||(F==null?void 0:F.message)||(F==null?void 0:F.msg),b=new Error(R||"请求失败: "+x.status);throw b.payload=F,b}return F},aa=(s,t)=>{const n=new AbortController,d=()=>n.abort(s==null?void 0:s.reason);s!=null&&s.aborted?d():s==null||s.addEventListener("abort",d,{once:!0});const x=globalThis.setTimeout(()=>n.abort(new DOMException("timeout","TimeoutError")),Math.max(1,t));return{signal:n.signal,cleanup:()=>{globalThis.clearTimeout(x),s==null||s.removeEventListener("abort",d)}}},Ts=s=>{const t=s.getFullYear(),n=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${t}-${n}-${d}`},ot=(s,t)=>{const n=new Date(s);return n.setHours(12,0,0,0),n.setDate(n.getDate()+t),n},st=(s,t)=>({startDate:Ts(ot(s,-(t-1))),endDate:Ts(s)}),Ct=(s,t=new Date,n="",d="")=>{if(s==="custom"&&n&&d){if(n>d)throw new Error("开始日期不能晚于结束日期");return{startDate:n,endDate:d}}return s==="yesterday"?st(ot(t,-1),1):st(t,s==="3days"?3:s==="30days"?30:s==="today"?1:7)},Za=s=>{const t=new Date(`${s.startDate}T12:00:00`),n=new Date(`${s.endDate}T12:00:00`),d=Math.round((n.getTime()-t.getTime())/864e5)+1,x=ot(t,-1);return st(x,d)},Xa=s=>{const t={...s};if("renewal_log_retention_days"in t){const n=Number(t.renewal_log_retention_days);t.renewal_log_retention_days=Number.isFinite(n)?n:10}return t},Ha=async s=>Ne("/login",s,{skipAuthLogout:!0}),la=async()=>fe("/verify"),el=async()=>Ne("/logout",{}),sl=async s=>Fe("/account/credentials",s),tl=(s,t)=>{const n=s.avatar_url||"";if(!n)return"";try{const d=new URL(n,window.location.origin);return d.hostname.endsWith("alicdn.com")&&d.searchParams.set("_v",t),d.toString()}catch{return n}},Ms=async s=>{const t=await fe("/cookies/details",void 0,s),n=Date.now().toString();return t.map(d=>({id:d.id,value:"",cookie:"",enabled:d.enabled,auto_confirm:d.auto_confirm,remark:d.remark,note:d.remark,pause_duration:d.pause_duration,paused_until:Number(d.paused_until||0),paused:d.paused===!0,username:d.username||"",login_password:"",show_browser:d.show_browser===!0||d.show_browser===1||d.show_browser==="1"||d.show_browser==="true",nickname:d.nickname||d.remark||`账号 ${d.id.substring(0,6)}`,avatar_url:tl(d,n),profile_error:d.profile_error||"",ai_enabled:!1}))},al=async s=>fe("/cookies/runtime-status",void 0,s),ll=async s=>Ne("/qr-login/generate",void 0,s),rl=async(s,t)=>fe(`/qr-login/check/${s}`,void 0,{signal:t,timeoutMs:1e4}),nl=async(s,t)=>Ne(`/qr-login/complete-verification/${s}`,{target_account_id:t||""}),il=async(s,t)=>Fe(`/cookies/${s}/status`,{enabled:t}),ol=async s=>Ze(`/cookies/${s}`),cl=async(s,t)=>Fe(`/cookies/${s}/pause-duration`,{pause_duration:t}),dl=async(s,t)=>Fe(`/cookies/${s}/settings`,t),xl=async s=>fe(`/cookies/${s}/long-login`),ml=async(s,t)=>Fe(`/cookies/${s}/long-login`,{enabled:t}),ul=async s=>Ne("/password-login",s),pl=async(s,t)=>fe(`/password-login/check/${s}`,void 0,{signal:t,timeoutMs:1e4}),hl=async s=>Ze(`/password-login/cancel/${s}`),gl=async s=>Ne(`/cookies/${s}/refresh-profile`,{}),bl=async s=>fe("/ai-reply-settings",void 0,s),ra=s=>{const t=String(s||"");return t==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(t)?t:"unknown"},yl=async(s,t,n=1,d=20,x)=>{const N={page:n,page_size:d};s&&(N.cookie_id=s),t&&t!=="all"&&(N.status=t),x!=null&&x.trim()&&(N.search=x.trim());const S=await fe("/api/orders",N),h=(S.orders||S.data||[]).map(R=>({...R,id:R.id||R.order_id,status:ra(R.status||R.order_status),quantity:Number(R.quantity||1)}));return{success:!0,data:h,total:S.total||h.length,page:S.page||n,page_size:S.page_size||d,total_pages:S.total_pages||1}},fl=async(s,t)=>Fe(`/api/orders/${s}`,t),jl=async s=>Ze(`/api/orders/${s}`),Nl=async(s,t)=>{const n=new FormData;return s&&n.append("cookie_id",s),t&&n.append("status",t),Cs("/api/orders/refresh",n)},vl=async s=>Ne(`/api/orders/${s}/refresh`),wl=async(s,t)=>Ne("/api/orders/manual-ship",{order_ids:s,ship_mode:t}),_l=async s=>s instanceof FormData?Cs("/api/orders/import",s):Ne("/api/orders/import",s),kl=async()=>fe("/dashboard/stats"),St=async(s=7)=>{let t;if(typeof s=="number"){const n=new Date,d=new Date;d.setDate(d.getDate()-s),t={start_date:Ts(d),end_date:Ts(n)}}else t=s;return fe("/analytics/orders",{...t,timezone_offset_minutes:-new Date().getTimezoneOffset()})},Cl=async s=>{const t=await fe("/analytics/orders/valid",{start_date:s.start_date,end_date:s.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()}),d=(Array.isArray(t)?t:t.orders||[]).map(x=>({...x,id:x.id||x.order_id,status:ra(x.status||x.order_status),quantity:Number(x.quantity||1)}));return{orders:d,total:Array.isArray(t)?d.length:Number(t.total??d.length),truncated:Array.isArray(t)?!1:t.truncated===!0}},Sl=s=>{let t=s.api_config;if(typeof t=="string"&&t.trim())try{t=JSON.parse(t)}catch{t=void 0}return{...s,api_config:t||void 0}},na=s=>({...s,api_config:s.api_config?JSON.stringify(s.api_config):""}),Xe=async()=>{const s=await fe("/cards");return(Array.isArray(s)?s:s.cards||[]).map(Sl)},Ll=async s=>Ne("/cards",na(s)),Lt=async(s,t)=>Fe(`/cards/${s}`,na(t)),Al=async s=>Ze(`/cards/${s}`),Il=async s=>{const t=new FormData;return t.append("file",s),Cs("/cards/batch",t)},$l=async(s,t)=>Ne(`/cards/${s}/append-data`,{content:t}),Js=s=>s===!0||s===1||s==="1",gs=async s=>{const t=await fe("/items",void 0);return(Array.isArray(t)?t:t.items||[]).map(d=>({...d,id:d.id||`${d.cookie_id}-${d.item_id}`,is_multi_spec:Js(d.is_multi_spec),is_multi_qty_ship:Js(d.is_multi_qty_ship??d.multi_quantity_delivery),multi_quantity_delivery:Js(d.multi_quantity_delivery??d.is_multi_qty_ship)}))},Rl=async s=>Ne("/items/get-all-from-account",{cookie_id:s}),Pl=async(s,t)=>Ze(`/items/${s}/${t}`),Dl=async(s,t)=>Ne(`/items/${s}`,t),Fl=async s=>{const t=new FormData;t.set("cookie_id",s.cookie_id),t.set("title",s.title),t.set("description",s.description),t.set("price",s.price),t.set("original_price",s.original_price||""),t.set("quantity",String(s.quantity)),t.set("postage_mode",s.postage_mode),t.set("postage",s.postage||"");for(const n of s.images)t.append("images",n);return Cs("/items/publish",t)},Tl=async s=>{const t=new FormData;return t.set("file",s.file),s.imagesZip&&t.set("images_zip",s.imagesZip),s.defaultCookieId&&t.set("default_cookie_id",s.defaultCookieId),t.set("fallback_category_id",s.fallbackCategory.catId),t.set("fallback_category_name",s.fallbackCategory.catName),t.set("fallback_channel_category_id",s.fallbackCategory.channelCatId||""),t.set("fallback_tb_category_id",s.fallbackCategory.tbCatId||""),Cs("/items/publish-batches/preview",t)},El=async s=>Ne("/items/publish-batches",{preview_id:s}),xs=async s=>fe(`/items/publish-batches/${s}`),At=async(s=20)=>{const t=await fe("/items/publish-batches",{limit:s});return Array.isArray(t)?t:t.batches||[]},Ml=async s=>Ze(`/items/publish-batches/${s}`),Ol=async s=>Ne(`/items/publish-batches/${s}/cancel`,{}),ql=async s=>Ne(`/items/publish-batches/${s}/retry-failed`,{}),Bl=async(s,t,n)=>Fe(`/items/${s}/${t}`,n),ia=s=>s.map(t=>{var n,d;return{id:String(t.id),name:t.name||"",trigger_type:t.trigger_type||"order_paid",item_keyword:t.item_title||t.item_id||"",cookie_id:t.cookie_id||"",item_id:t.item_id||"",item_title:t.item_title||"",card_group_id:Number(((n=(t.actions||[]).find(x=>x.action_type==="send_card"))==null?void 0:n.card_id)||0),card_group_name:((d=(t.actions||[]).find(x=>x.action_type==="send_card"))==null?void 0:d.card_name)||"",priority:t.priority||100,enabled:t.enabled||!1,config_json:t.config_json||"{}",actions:(t.actions||[]).map(x=>({id:x.id?String(x.id):void 0,action_type:x.action_type,card_id:Number(x.card_id||0),card_name:x.card_name||"",delivery_count:Number(x.delivery_count||1),message_template:x.message_template||"",delay_seconds:Number(x.delay_seconds||0),config_json:x.config_json||"{}",enabled:x.enabled!==!1,sort_order:Number(x.sort_order||0)})),variants:(t.actions||[]).filter(x=>x.action_type==="send_card").map(x=>{let N={};try{N=JSON.parse(x.config_json||"{}")}catch{}return{id:x.id?String(x.id):void 0,spec_name:N.spec_name||"",spec_value:N.spec_value||"",card_id:Number(x.card_id||0),card_name:x.card_name||"",delivery_count:Number(x.delivery_count||1),enabled:x.enabled!==!1,delay_override:N.delay_override===!0,delay_seconds:Number(x.delay_seconds||0),config_json:x.config_json||"{}"}})}}),tt=async()=>{const s=await fe("/automation-rules"),t=Array.isArray(s)?s:s.data||s.rules||[];return ia(t)},zl=async({cookieId:s,triggerType:t,enabled:n,search:d,page:x=1,pageSize:N=10}={})=>{const S=await fe("/automation-rules",{page:x,page_size:N,cookie_id:s||void 0,trigger_type:t||void 0,enabled:n,search:(d==null?void 0:d.trim())||void 0}),F=ia(Array.isArray(S)?S:S.data||S.rules||[]);return{success:!0,data:F,total:Number(S.total??F.length),page:Number(S.page??x),page_size:Number(S.page_size??N),total_pages:Number(S.total_pages??(F.length?1:0))}},Ul=(s,t)=>{if(s!=="order_paid")return t.map((x,N)=>({...x,sort_order:x.sort_order||N+1}));const n=t.filter(x=>x.action_type==="send_card").map((x,N)=>({...x,sort_order:N+1})),d=t.filter(x=>x.action_type!=="send_card"&&x.action_type!=="confirm_shipment");return[...n,...d.map((x,N)=>({...x,sort_order:n.length+N+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:n.length+d.length+1}]},It=async s=>{const t=s.trigger_type||"order_paid",d=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[t]||"自动化规则",s.item_title||s.item_id||s.cookie_id||""].filter(Boolean).join(" - "),x=(s.actions||[]).filter(h=>h.action_type!=="send_card"&&h.action_type!=="confirm_shipment"),N=s.variants&&s.variants.length>0?[...s.variants.map((h,R)=>({action_type:"send_card",card_id:h.card_id,delivery_count:h.delivery_count||1,enabled:h.enabled!==!1,sort_order:R+1,delay_seconds:h.delay_seconds||0,config_json:JSON.stringify({spec_name:h.spec_name||"",spec_value:h.spec_value||"",delay_override:h.delay_override===!0})})),...x]:s.actions&&s.actions.length>0?s.actions:[{action_type:"send_card",card_id:s.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],S=Ul(t,N),F={cookie_id:s.cookie_id||"",item_id:s.item_id||"",name:(s.name||"").trim()||d||"自动化规则",trigger_type:t,enabled:s.enabled??!0,priority:s.priority||100,config_json:s.config_json||"{}",actions:S.map((h,R)=>({action_type:h.action_type,card_id:h.card_id||0,delivery_count:h.delivery_count||1,message_template:h.message_template||"",delay_seconds:h.delay_seconds||0,config_json:h.config_json||"{}",enabled:h.enabled!==!1,sort_order:h.sort_order||R+1}))};return s.id?Fe(`/automation-rules/${s.id}`,F):Ne("/automation-rules",F)},Wl=async s=>Ze(`/automation-rules/${s}`),Vl=async()=>{const s=await fe("/automation-issues");return{runs:Array.isArray(s==null?void 0:s.runs)?s.runs:[],pending_tasks:Array.isArray(s==null?void 0:s.pending_tasks)?s.pending_tasks:[]}},Gl=async(s,t)=>Ne(`/automation-runs/${s}/resolve`,{resolution:t}),Jl=async(s,t)=>Ne(`/automation-pending-tasks/${s}/resolve`,{resolution:t}),Ql=s=>({id:String((s==null?void 0:s.id)||""),keyword:(s==null?void 0:s.keyword)||"",reply:(s==null?void 0:s.reply)||"",item_id:(s==null?void 0:s.item_id)||"",type:(s==null?void 0:s.type)==="image"?"image":"text",image_url:(s==null?void 0:s.image_url)||""}),Kl=async s=>{const t=await fe(`/keywords-with-type/${s}`);return Array.isArray(t)?t.map(Ql):[]},Yl=async s=>s?(await Kl(s)).map(n=>({id:n.id,keyword:n.keyword||"",reply_content:n.reply||"",match_type:"fuzzy",enabled:!0,item_id:n.item_id||"",type:n.type==="image"?"image":"text",image_url:n.image_url||""})):[],Zl=async(s,t)=>{const n=s.type||"text",d={keyword:s.keyword||"",reply:n==="text"&&s.reply_content||"",item_id:s.item_id||"",type:n,image_url:n==="image"&&s.image_url||""};return s.id?Fe(`/keywords-with-type/${t}/${s.id}`,d):Ne(`/keywords-with-item-id/${t}`,d)},Xl=async(s,t)=>Ze(`/keywords-with-type/${t}/${s}`),oa=async()=>{const s=await fe("/system-settings");return Xa(s.data||s)},ca=async s=>{const t=Object.fromEntries(Object.entries(s).filter(([,n])=>n!=null));return Fe("/system-settings",t)},Hl=async(s,t)=>fe(`/ai-reply-settings/${s}`,void 0,t),er=async(s,t)=>{const n={ai_enabled:t.ai_enabled??!1,max_discount_percent:t.max_discount_percent??10,max_discount_amount:t.max_discount_amount??100,max_bargain_rounds:t.max_bargain_rounds??3,custom_prompts:t.custom_prompts??""};return Fe(`/ai-reply-settings/${s}`,n)},sr=async(s,t="")=>(await Ne("/ai-models",{base_url:s,api_key:t})).models||[],tr=s=>{if(Array.isArray(s))return s.filter(Boolean);if(typeof s!="string"||!s.trim())return[];try{const t=JSON.parse(s);if(Array.isArray(t))return t.filter(Boolean)}catch{}return s.split(/[,\s;]+/).map(t=>t.trim()).filter(Boolean)},da=s=>{const t=Array.from(new Set((s||[]).filter(Boolean)));return t.length>0?JSON.stringify(t):""},xa=async s=>({success:!0,data:(await fe("/notification-channels",void 0,s)||[]).map(d=>{let x;try{x=typeof d.config=="string"?JSON.parse(d.config):d.config}catch{x={}}return{id:String(d.id),name:d.name,type:d.type==="ding_talk"?"dingtalk":d.type==="lark"?"feishu":d.type,config:x,event_types:tr(d.event_types),enabled:d.enabled,created_at:d.created_at,updated_at:d.updated_at}})}),ar=async s=>Ne("/notification-channels",{...s,config:JSON.stringify(s.config),event_types:da(s.event_types)}),$t=async(s,t)=>{const n={...t};return"config"in t&&(n.config=JSON.stringify(t.config)),"event_types"in t&&(n.event_types=da(t.event_types)),Fe(`/notification-channels/${s}`,n)},lr=async s=>Ze(`/notification-channels/${s}`),rr=async(s,t)=>{const n=await fe(`/message-notifications/${s}`,void 0,t);return(n==null?void 0:n.channel_ids)||[]},nr=async s=>Ne(`/notification-channels/${s}/test`,{}),Rt=async()=>fe("/api/default-replies"),ir=async s=>{const t=await fe(`/api/default-reply/${s}`);return{cookie_id:s,enabled:t.enabled||!1,reply_content:t.reply_content||"",reply_once:t.reply_once||!1,reply_image_url:t.reply_image_url||""}},or=async(s,t)=>Fe(`/api/default-reply/${s}`,{enabled:t.enabled??!1,reply_content:t.reply_content||"",reply_once:t.reply_once??!1,reply_image_url:t.reply_image_url||""}),cr=async s=>Ze(`/api/default-reply/${s}`),dr=async s=>Ne(`/api/default-reply/${s}/clear-records`,{}),js=s=>String(s).padStart(2,"0"),at=s=>{if(s==null||s==="")return"-";const t=s instanceof Date?s:new Date(s);return Number.isNaN(t.getTime())?"-":[t.getFullYear(),js(t.getMonth()+1),js(t.getDate())].join("-")+" "+[js(t.getHours()),js(t.getMinutes()),js(t.getSeconds())].join(":")},xr=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},n={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:n[s]||s})},$s=({title:s,value:t,icon:n,colorClass:d,trend:x})=>e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col justify-between hover:translate-y-[-4px] transition-all duration-300 h-full relative overflow-hidden group border-0",children:[e.jsx("div",{className:`absolute -right-6 -top-6 w-32 h-32 ${d} opacity-10 rounded-full group-hover:scale-125 transition-transform duration-500 blur-2xl`}),e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`p-4 rounded-2xl ${d} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(n,{className:`w-6 h-6 ${d.replace("bg-","text-")}`})}),x&&e.jsxs("span",{className:"text-xs font-bold text-white bg-[#0094f7] px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(va,{className:"w-3 h-3"})," ",x]})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h3",{className:"text-3xl font-extrabold text-gray-900 tracking-tight font-feature-settings-tnum",children:t}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:s})]})]}),Qs=()=>{var o,_;const[s,t]=i.useState(null),[n,d]=i.useState(null),[x,N]=i.useState(""),[S,F]=i.useState("7days"),[h,R]=i.useState(""),[b,J]=i.useState(""),[ae,le]=i.useState(null),[oe,k]=i.useState(""),[B,re]=i.useState([]),[Q,H]=i.useState(0),[z,xe]=i.useState(!1),[ce,w]=i.useState(!1),[D,U]=i.useState([]),[G,me]=i.useState({}),A=i.useRef(0),I=["#0094f7","#3B82F6","#10B981","#F59E0B","#8B5CF6"],Z=async r=>{let v;try{v=Ct(r,new Date,h,b)}catch(ue){N(ue instanceof Error?ue.message:"日期范围无效");return}const{startDate:O,endDate:V}=v,q={start_date:O,end_date:V},he=Za(v),te=++A.current;w(!0),N("");try{const[ue,Ie,ve]=await Promise.all([St(q),St({start_date:he.startDate,end_date:he.endDate}),Cl(q)]);if(te!==A.current)return;d(ue),le(Ie),re(ve.orders),H(ve.total),xe(ve.truncated)}catch(ue){te===A.current&&N(ue instanceof Error?ue.message:"经营数据加载失败")}finally{te===A.current&&w(!1)}},L=()=>{if(!n||!ae)return null;const r=n.revenue_stats.total_amount,v=ae.revenue_stats.total_amount;if(v===0)return r>0?"+100%":"0%";const O=(r-v)/v*100;return`${O>=0?"+":""}${O.toFixed(1)}%`};if(i.useEffect(()=>{let r=!1;return Promise.all([kl(),gs()]).then(([v,O])=>{if(r)return;t(v),U(O);const V={};O.forEach(q=>{V[q.item_id]=q.item_title||q.item_id}),me(V)}).catch(v=>{r||N(v instanceof Error?v.message:"概览加载失败")}),()=>{r=!0}},[]),i.useEffect(()=>{S!=="custom"&&Z(S)},[S]),x&&(!s||!n))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(ns,{className:"w-8 h-8"}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:()=>window.location.reload(),children:"重新加载"})]});if(!s||!n)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(ht,{className:"w-8 h-8 animate-spin text-[#0094f7]"})});const se=((o=n.daily_stats)==null?void 0:o.map(r=>({name:r.date.slice(5),amount:r.amount,orders:r.order_count,avgAmount:r.order_count>0?(r.amount/r.order_count).toFixed(2):0})))||[],ee=n.item_stats||[],ke=n.revenue_stats.total_orders||0,T=n.revenue_stats.total_amount||0,m=ee.length>0?ee.map(r=>({name:(G[r.item_id]||r.item_id).length>12?(G[r.item_id]||r.item_id).substring(0,12)+"...":G[r.item_id]||r.item_id,sales:r.order_count})).sort((r,v)=>v.sales-r.sales).slice(0,10):[],g=Math.max(...m.map(r=>r.sales),1),E=ee.length>0?ee.map(r=>({name:(G[r.item_id]||r.item_id).length>10?(G[r.item_id]||r.item_id).substring(0,10)+"...":G[r.item_id]||r.item_id,value:r.order_count,percent:ke>0?r.order_count/ke*100:0})).sort((r,v)=>v.value-r.value).slice(0,6).map((r,v)=>({...r,color:I[v%I.length]})):[],P=ee.length>0?ee.map(r=>({name:(G[r.item_id]||r.item_id).length>12?(G[r.item_id]||r.item_id).substring(0,12)+"...":G[r.item_id]||r.item_id,value:r.total_amount,orderCount:r.order_count,percentage:T>0?r.total_amount/T*100:0})).sort((r,v)=>v.value-r.value).slice(0,5).map((r,v)=>({...r,color:I[v%I.length],percentage:r.percentage.toFixed(1)})):[],ne=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],ge=((_=ne.find(r=>r.key===S))==null?void 0:_.label)||"所选范围";let K;try{K=Ct(S,new Date,h,b)}catch{K={startDate:h,endDate:b}}const ye=oe.trim().toLowerCase(),C=B.filter(r=>{var v,O,V,q;return((v=r.order_id)==null?void 0:v.toLowerCase().includes(ye))||((O=r.item_id)==null?void 0:O.toLowerCase().includes(ye))||((V=r.item_title)==null?void 0:V.toLowerCase().includes(ye))||((q=r.buyer_id)==null?void 0:q.toLowerCase().includes(ye))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"运营概览"}),e.jsx("p",{className:"text-gray-500 mt-2 text-base",children:"欢迎回来,以下是闲鱼店铺的实时经营数据。"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-sm font-bold text-gray-700 bg-white px-5 py-2.5 rounded-full shadow-sm border border-gray-100 flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-green-500 rounded-full animate-pulse"}),"系统正常运行"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[ne.map(r=>e.jsx("button",{onClick:()=>F(r.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${S===r.key?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:r.label},r.key)),S==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:h,onChange:r=>R(r.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:b,onChange:r=>J(r.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),e.jsx("button",{onClick:()=>{try{N(""),Z("custom")}catch(r){N(r instanceof Error?r.message:"日期范围无效")}},className:"px-4 py-2 rounded-xl text-sm font-bold bg-black text-white hover:bg-gray-800 transition-colors",children:"应用"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsx($s,{title:"累计营收 (CNY)",value:`¥${n.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:Na,colorClass:"bg-blue-400",trend:L()||void 0}),e.jsx($s,{title:"活跃账号 / 总数",value:`${s.active_cookies} / ${s.total_cookies}`,icon:Ut,colorClass:"bg-blue-500"}),e.jsx($s,{title:"订单数",value:n.revenue_stats.total_orders.toLocaleString(),icon:gt,colorClass:"bg-blue-500"}),e.jsx($s,{title:"库存卡密余量",value:s.available_card_stock,icon:Jt,colorClass:"bg-purple-500"})]}),e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[ge,"的销售额走势"]})]}),e.jsx("div",{className:"h-[350px] w-full",children:se.length===0||n.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(gt,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所选时间范围内暂无订单记录"})]}):se.length<=2?e.jsx(Is,{width:"100%",height:"100%",children:e.jsxs(qa,{data:se,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(vt,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#374151",fontSize:14,fontWeight:600},dy:10}),e.jsx(wt,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},tickFormatter:r=>`¥${r}`}),e.jsx(Ws,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{fill:"rgba(0, 148, 247, 0.08)"},formatter:r=>[`¥${Number(r).toFixed(2)}`,"营收"]}),e.jsx(Ba,{dataKey:"amount",fill:"#0094f7",maxBarSize:72,radius:[12,12,0,0],stroke:"#000000",strokeWidth:0,children:se.map((r,v)=>e.jsx(Vs,{fill:["#0094f7","#FCD34D","#0071e3"][v%3]},`cell-${v}`))})]})}):e.jsx(Is,{width:"100%",height:"100%",children:e.jsxs(za,{data:se,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0094f7",stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:"#0094f7",stopOpacity:0})]})}),e.jsx(vt,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},dy:15}),e.jsx(wt,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500}}),e.jsx(Ua,{vertical:!1,stroke:"#F3F4F6",strokeDasharray:"3 3"}),e.jsx(Ws,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{stroke:"#0094f7",strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(Wa,{type:"monotone",dataKey:"amount",stroke:"#0094f7",strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:"#fff",stroke:"#0094f7",strokeWidth:2}})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品销量排行"}),e.jsx("div",{className:"h-[280px]",children:m.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx("div",{className:"h-full space-y-4 overflow-y-auto pr-2",children:m.map((r,v)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${v<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:v+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:r.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[r.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#0094f7]",style:{width:`${Math.max(8,r.sales/g*100)}%`}})})]},`${r.name}-${v}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"h-[280px]",children:E.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx(Is,{width:"100%",height:"100%",children:e.jsxs(_t,{children:[e.jsx(kt,{data:E,cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",label:({name:r,payload:v})=>`${r} ${Number((v==null?void 0:v.percent)||0).toFixed(1)}%`,labelLine:!1,children:E.map((r,v)=>e.jsx(Vs,{fill:r.color},`cell-${v}`))}),e.jsx(Va,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:r=>e.jsx("span",{style:{color:"#6B7280",fontWeight:500},children:r})})]})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-gray-50 flex justify-between items-center bg-[#FAFAFA]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),z&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",B.length," / ",Q," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:oe,onChange:r=>k(r.target.value),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:ce?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(ht,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):C.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx(ks,{className:"w-7 h-7 text-gray-300"})}),ye?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"没有匹配的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-md",children:["当前共有 ",B.length," 单参与统计,但没有订单号、商品、买家匹配“",oe,"”。"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"当前范围内没有参与统计的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-lg leading-6",children:["日期范围:",K.startDate," 至 ",K.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",n.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-4",children:"订单信息"}),e.jsx("th",{className:"px-6 py-4",children:"买家信息"}),e.jsx("th",{className:"px-6 py-4",children:"金额"}),e.jsx("th",{className:"px-6 py-4",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:C.map(r=>e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:e.jsx(ks,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:r.item_title||r.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:r.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",r.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:r.buyer_id}),r.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:at(r.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",r.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(xr,{status:r.status||r.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${r.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(Qt,{className:"w-4 h-4"})})})]},r.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),P.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-[300px] relative",children:e.jsx(Is,{width:"100%",height:"100%",children:e.jsxs(_t,{children:[e.jsx(kt,{data:P,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",label:({name:r,payload:v})=>`${r} ${(v==null?void 0:v.percentage)||"0.0"}%`,children:P.map((r,v)=>e.jsx(Vs,{fill:r.color||I[v%I.length]},`cell-${v}`))}),e.jsx(Ws,{contentStyle:{backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},formatter:r=>`¥${Number(r||0).toLocaleString()}`})]})})}),e.jsx("div",{className:"space-y-3 mt-4",children:P.map(r=>e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:r.color||I[P.indexOf(r)%I.length]}}),e.jsx("span",{className:"text-gray-600 font-medium",children:r.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",r.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[r.percentage,"%"]})]})]},r.name))})]})]})]})]})},mr=(s,t)=>{const n=t.pause_duration||0;return s!==n},ur=(s,t)=>{const n=t.username!==(s.username||""),d=t.show_browser!==(s.show_browser||!1),x=t.login_password!=="",N=t.clear_password===!0;if(!n&&!d&&!x&&!N)return null;const S={username:t.username,show_browser:t.show_browser};return N?S.clear_password=!0:x&&(S.login_password=t.login_password),S},pr=(s,t)=>s&&t,hr=(s,t)=>{if(!s||!t)return!1;const n=Date.parse(s),d=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(d)&&ds.map(n=>{const d=t[n.id];return!d||hr(n.runtime_updated_at,d.updated_at)?n:{...n,runtime_state:d.state,runtime_message:d.message||"",runtime_connected:d.connected,runtime_updated_at:d.updated_at}}),br=new Set(["expired","cancelled","error","not_found"]),Rs=()=>{let s=0;return{next:()=>(s+=1,s),cancel:()=>{s+=1},isCurrent:t=>t===s}},yr=(s={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let t=null,n=null,d=-1,x=0;const N=()=>{x+=1,n==null||n.abort(),n=null,t!==null&&(s.clearInterval(t),t=null)};return{start:(F,h,R,b=2e3)=>{N();const J=x;n=new AbortController;const ae=n.signal;t=s.setInterval(()=>{d===J||J!==x||(d=J,(async()=>{var le,oe;try{const k=await h(F,ae);if(k.status==="success"){N(),await R.onSuccess(k);return}if(k.status==="scanned"){(le=R.onScanned)==null||le.call(R,k);return}if(k.status==="verification_required"){(oe=R.onVerificationRequired)==null||oe.call(R,k);return}k.status&&br.has(k.status)&&(N(),R.onTerminalError(k))}catch(k){if(ae.aborted||J!==x)return;N(),R.onPollError(k)}finally{d===J&&(d=-1)}})())},b)},stop:N,isActive:()=>t!==null}},fr=({faceQrUrl:s,verificationScreenshot:t})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(wa,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:s?e.jsx("img",{src:s,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):t?e.jsx("img",{src:t,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(Re,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Pt=({src:s,alt:t,className:n=""})=>e.jsx("img",{src:s,alt:t,className:`block aspect-square h-auto w-full object-contain ${n}`.trim()}),jr=()=>{const[s,t]=i.useState([]),[n,d]=i.useState(!0),[x,N]=i.useState(""),[S,F]=i.useState(""),[h,R]=i.useState(""),[b,J]=i.useState(null),[ae,le]=i.useState(""),[oe,k]=i.useState(!1),[B,re]=i.useState(""),[Q,H]=i.useState("pending"),[z,xe]=i.useState(""),[ce,w]=i.useState(""),[D,U]=i.useState(null),[G,me]=i.useState(null),[A,I]=i.useState(null),[Z,L]=i.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[se,ee]=i.useState([]),[ke,T]=i.useState([]),[m,g]=i.useState(!1),[E,P]=i.useState(!1),[ne,ge]=i.useState(!1),[K,ye]=i.useState(""),[C,o]=i.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),[_,r]=i.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[v,O]=i.useState(!1),[V,q]=i.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),he=i.useRef(null),te=i.useRef(null),ue=i.useRef(null),Ie=i.useRef(null),ve=i.useRef(null),Ve=i.useRef(null),$e=i.useRef(null),Te=i.useRef(null),qe=i.useRef(null),Ee=i.useRef(null),Ge=i.useRef(null),Be=i.useRef(null),Pe=i.useRef(0);he.current===null&&(he.current=yr()),te.current===null&&(te.current=Rs()),ue.current===null&&(ue.current=Rs()),Ie.current===null&&(Ie.current=Rs()),ve.current===null&&(ve.current=Rs());const Qe=()=>{Ge.current!==null&&(window.clearTimeout(Ge.current),Ge.current=null)},be=()=>{Be.current!==null&&(window.clearTimeout(Be.current),Be.current=null)},Ae=()=>{var c;(c=he.current)==null||c.stop()},ze=()=>{var c,j;(c=qe.current)==null||c.abort(),(j=te.current)==null||j.cancel(),Ae(),Qe(),k(!1)},u=()=>{Qe(),Ge.current=window.setTimeout(()=>{Ge.current=null,k(!1),$()},1e3)},$=async()=>{var W,a,p,f,M;const c=ue.current.next();(W=Ve.current)==null||W.abort();const j=new AbortController;Ve.current=j,d(!0);try{const X={signal:j.signal},[de,pe]=await Promise.allSettled([Ms(X),bl(X)]);if(!((a=ue.current)!=null&&a.isCurrent(c)))return;if(de.status==="rejected")throw de.reason;const Se=de.value,je=pe.status==="fulfilled"?pe.value:{};pe.status==="rejected"&&console.error("Failed to load AI settings:",pe.reason);const Bs=Se.map(ds=>{var dt,xt,mt,ut,pt;return{...ds,ai_enabled:((dt=je[ds.id])==null?void 0:dt.ai_enabled)??!1,max_discount_percent:((xt=je[ds.id])==null?void 0:xt.max_discount_percent)??10,max_discount_amount:((mt=je[ds.id])==null?void 0:mt.max_discount_amount)??100,max_bargain_rounds:((ut=je[ds.id])==null?void 0:ut.max_bargain_rounds)??3,custom_prompts:((pt=je[ds.id])==null?void 0:pt.custom_prompts)??""}});(p=ue.current)!=null&&p.isCurrent(c)&&t(Bs)}catch(X){(f=ue.current)!=null&&f.isCurrent(c)&&!j.signal.aborted&&console.error("Failed to load accounts:",X)}finally{(M=ue.current)!=null&&M.isCurrent(c)&&d(!1)}};i.useEffect(()=>{let c=!1,j=null;const W=new AbortController,a=async()=>{try{const p=await al({signal:W.signal,timeoutMs:1e4});c||t(f=>gr(f,p))}catch(p){c||console.error("Failed to load account runtime statuses:",p)}finally{c||(j=window.setTimeout(()=>void a(),2e3))}};return $().finally(()=>{c||a()}),()=>{c=!0,W.abort(),j!==null&&window.clearTimeout(j)}},[]),i.useEffect(()=>()=>{var c,j,W,a,p,f,M,X,de;Ae(),(c=te.current)==null||c.cancel(),(j=ue.current)==null||j.cancel(),(W=Ie.current)==null||W.cancel(),(a=ve.current)==null||a.cancel(),(p=Ve.current)==null||p.abort(),(f=$e.current)==null||f.abort(),(M=Te.current)==null||M.abort(),(X=qe.current)==null||X.abort(),(de=Ee.current)==null||de.abort(),Qe(),Pe.current+=1,be()},[]);const ie=c=>{if(!c.enabled||c.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(c.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},we=async(c,j)=>{await il(c,!j),$()},Ke=c=>{h||(le(""),J(c))},Ye=()=>{h||(le(""),J(null))},Ue=async()=>{const c=b;if(!(!c||h)){R(c.id),le("");try{await ol(c.id),t(j=>j.filter(W=>W.id!==c.id)),J(null)}catch(j){console.error("删除账号失败:",j),le((j==null?void 0:j.message)||"删除账号失败,请稍后重试")}finally{R("")}}},We=async c=>{F(c.id);try{const j=await gl(c.id);j!=null&&j.profile_error&&alert("资料刷新失败:"+j.profile_error),await $()}catch(j){console.error("刷新账号资料失败:",j),alert((j==null?void 0:j.message)||"刷新账号资料失败,请先重新授权该账号")}finally{F("")}},l=async c=>{var f,M;const j=Ie.current.next();(f=$e.current)==null||f.abort();const W=new AbortController;$e.current=W,P(!0),g(!1),ge(!1),ye("");const[a,p]=await Promise.allSettled([xa({signal:W.signal}),rr(c,{signal:W.signal})]);(M=Ie.current)!=null&&M.isCurrent(j)&&(a.status==="fulfilled"?ee(a.value.data||[]):(ee([]),ye("通知渠道列表加载失败,请重试")),p.status==="fulfilled"?(T(p.value||[]),g(!0)):(T([]),ye("通知绑定加载失败;本次保存不会修改现有绑定")),P(!1))},y=async c=>{var W;Pe.current+=1,(W=Ee.current)==null||W.abort(),be(),q({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),I(c),o({remark:c.remark||c.note||"",cookie:c.cookie||c.value||"",auto_confirm:c.auto_confirm||!1,pause_duration:c.pause_duration||0,username:c.username||"",login_password:c.login_password||"",show_browser:c.show_browser||!1,showLoginPassword:!1,clear_password:!1}),me("edit"),L({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,j]=await Promise.allSettled([l(c.id),xl(c.id)]);j.status==="fulfilled"?L({loading:!1,saving:!1,canOpen:j.value.can_open_long_login,enabled:j.value.enabled,error:""}):L({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"})},Y=async()=>{if(!A||Z.loading||Z.saving||!Z.canOpen)return;const c=!Z.enabled;L(j=>({...j,saving:!0,error:""}));try{const j=await ml(A.id,c);L({loading:!1,saving:!1,canOpen:j.can_open_long_login,enabled:j.enabled,error:""})}catch(j){L(W=>({...W,saving:!1,error:j instanceof Error?j.message:"保存登录信息设置失败"}))}},Ce=async c=>{var a,p,f,M;const j=ve.current.next();(a=Te.current)==null||a.abort();const W=new AbortController;Te.current=W,I(c),me("ai-settings"),O(!0);try{const X=await Hl(c.id,{signal:W.signal});if(!((p=ve.current)!=null&&p.isCurrent(j)))return;r({ai_enabled:X.ai_enabled??!1,max_discount_percent:X.max_discount_percent??10,max_discount_amount:X.max_discount_amount??100,max_bargain_rounds:X.max_bargain_rounds??3,custom_prompts:X.custom_prompts??""})}catch(X){(f=ve.current)!=null&&f.isCurrent(j)&&console.error("Failed to load AI settings:",X)}finally{(M=ve.current)!=null&&M.isCurrent(j)&&O(!1)}},Me=async()=>{if(A){O(!0);try{const c={};C.remark!==(A.remark||A.note||"")&&(c.remark=C.remark),C.cookie&&C.cookie!==(A.cookie||A.value||"")&&(c.cookie=C.cookie),C.auto_confirm!==A.auto_confirm&&(c.auto_confirm=C.auto_confirm),mr(C.pause_duration,A)&&(c.pause_duration=C.pause_duration);const j=ur(A,C);j&&Object.assign(c,j),pr(m,ne)&&(c.channel_ids=ke),Object.keys(c).length>0&&await dl(A.id,c),me(null),$()}catch(c){console.error("更新账号失败:",c),alert("更新失败,请重试")}finally{O(!1)}}},De=async()=>{if(!(!A||C.pause_duration<=0)){O(!0);try{const c=await cl(A.id,C.pause_duration);I({...A,pause_duration:C.pause_duration,paused:(c==null?void 0:c.paused)===!0,paused_until:Number((c==null?void 0:c.paused_until)||0)}),await $()}catch(c){alert(c instanceof Error?c.message:"重新暂停失败")}finally{O(!1)}}},os=async()=>{if(A){O(!0);try{await er(A.id,_),me(null),$()}catch(c){console.error("更新AI设置失败:",c),alert("更新失败,请重试")}finally{O(!1)}}},cs=async(c,j)=>{var a;(a=Ee.current)==null||a.abort();const W=new AbortController;Ee.current=W;try{const p=await pl(c,W.signal);if(j!==Pe.current)return;if(p.status==="success"){be(),q({sessionId:c,status:"success",message:p.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}),o(f=>({...f,login_password:"",showLoginPassword:!1})),await $();return}if(p.status==="processing"||p.status==="verification_required"){q({sessionId:c,status:p.status,message:p.message||(p.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:p.qr_code_url||""}),be(),Be.current=window.setTimeout(()=>void cs(c,j),1500);return}be(),q({sessionId:c,status:"failed",message:p.error||p.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""})}catch(p){if(j!==Pe.current)return;be(),q({sessionId:c,status:"failed",message:p instanceof Error?p.message:"查询密码登录状态失败",qrCodeUrl:""})}},Os=async()=>{var W;if(!A)return;const c=C.username.trim();if(!c||!C.login_password){alert("请先填写登录账号和本次登录密码");return}be(),(W=Ee.current)==null||W.abort();const j=++Pe.current;q({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const a=await ul({account_id:A.id,account:c,password:C.login_password,show_browser:C.show_browser});if(j!==Pe.current)return;if(!a.success||!a.session_id)throw new Error(a.message||"无法启动密码登录");q({sessionId:a.session_id,status:"processing",message:a.message||"登录处理中",qrCodeUrl:""}),await cs(a.session_id,j)}catch(a){if(j!==Pe.current)return;q({sessionId:"",status:"failed",message:a instanceof Error?a.message:"启动密码登录失败",qrCodeUrl:""})}},Ss=async()=>{var j;const c=V.sessionId;if(Pe.current+=1,(j=Ee.current)==null||j.abort(),be(),c)try{await hl(c)}catch(W){console.error("取消密码登录失败",W)}q({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},bs=async()=>{var c,j;(c=Ie.current)==null||c.cancel(),(j=$e.current)==null||j.abort(),(V.status==="processing"||V.status==="verification_required")&&await Ss(),me(null)},Ls=()=>{var c,j;(c=ve.current)==null||c.cancel(),(j=Te.current)==null||j.abort(),me(null)},qs=async(c,j)=>{const W=await nl(c,j==null?void 0:j.id);if(!W.success||!W.account_id)throw new Error(W.message||"保存扫码授权失败");return W.account_id},ys=async c=>{var p,f,M,X;Ae(),(p=qe.current)==null||p.abort();const j=new AbortController;qe.current=j;const W=te.current.next();Qe();const a=c||null;U(a),k(!0),H("loading"),re(""),xe(""),w("");try{const de=await ll({signal:j.signal});if(!((f=te.current)!=null&&f.isCurrent(W)))return;if(de.success&&de.qr_code_url&&de.session_id){const pe=de.session_id;re(de.qr_code_url),H("waiting"),(M=he.current)==null||M.start(pe,rl,{onSuccess:async()=>{try{if(!await qs(pe,a)){H("error");return}}catch(Se){console.error("保存扫码授权失败",Se),H("error");return}H("success"),u()},onScanned:()=>{H("waiting")},onTerminalError:()=>{H("error")},onPollError:Se=>{console.error("轮询扫码状态失败",Se),H("error")},onVerificationRequired:Se=>{H("verification"),Se.face_qr_url&&w(Se.face_qr_url),Se.verification_screenshot&&xe(Se.verification_screenshot)}})}}catch{if(!((X=te.current)!=null&&X.isCurrent(W)))return;H("error")}};if(n)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(Re,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});const fs=s.filter(c=>{const j=x.trim().toLowerCase();return j?[c.id,c.nickname,c.remark,c.note,c.username,c.runtime_message].some(W=>(W||"").toLowerCase().includes(j)):!0});return e.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:x,onChange:c=>N(c.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>ys(),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(zs,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs("div",{className:"font-bold",children:["当前显示 ",fs.length," / ",s.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[fs.map(c=>{const j=ie(c),W=c.runtime_state==="auth_expired"||c.runtime_state==="verification_required";return e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col lg:flex-row lg:items-center justify-between gap-5 group hover:border-[#0094f7] transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-5 sm:gap-8 min-w-0",children:[e.jsxs("div",{className:"relative",children:[c.avatar_url?e.jsx("img",{src:c.avatar_url,alt:c.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(is,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${j.dot}`,children:c.runtime_state==="online"&&e.jsx(He,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:c.nickname||c.remark||`账号 ${c.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${j.badge}`,children:j.label}),c.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(us,{className:"w-3 h-3"})," AI"]}),c.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:c.profile_error,children:[e.jsx(ns,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"text-sm text-gray-500 font-medium mb-3 space-y-1",children:[e.jsx("p",{children:c.remark||c.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",c.id]})]}),c.runtime_message&&c.runtime_state!=="online"&&c.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${W?"text-red-700":"text-amber-700"}`,children:[e.jsx(ns,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:c.runtime_message}),W&&e.jsxs("button",{type:"button",onClick:()=>ys(c),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(zs,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),e.jsxs("div",{className:"flex gap-2",children:[c.auto_confirm&&e.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[e.jsx(He,{className:"w-3 h-3"})," 自动确认发货"]}),c.paused&&e.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[e.jsx(bt,{className:"w-3 h-3"})," 暂停处理中"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 self-end lg:self-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>We(c),disabled:S===c.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(Oe,{className:`w-5 h-5 ${S===c.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>ys(c),className:`p-3 rounded-xl transition-colors ${W?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(zs,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>y(c),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Kt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ce(c),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(us,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>we(c.id,c.enabled),className:`p-3 rounded-xl transition-colors ${c.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:c.enabled?"停用账号":"启用账号",children:e.jsx(_a,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ke(c),disabled:h!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:h===c.id?"删除中…":`删除账号 ${c.nickname||c.remark||c.id}`,children:h===c.id?e.jsx(Re,{className:"w-5 h-5 animate-spin"}):e.jsx(Je,{className:"w-5 h-5"})})]})]},c.id)}),s.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(is,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),s.length>0&&fs.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),b&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-[0_24px_64px_rgba(15,23,42,0.22)]",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Je,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:Ye,disabled:h!=="",className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(_e,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:b.nickname||b.remark||"未命名账号"}),b.remark&&b.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",b.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",b.id]})]}),h===b.id&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx(Re,{className:"h-5 w-5 flex-shrink-0 animate-spin text-[#0094f7]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),ae&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(ns,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:ae})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:Ye,disabled:h!=="",className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void Ue(),disabled:h!=="",className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:h===b.id?e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),oe&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:ze,className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:D?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:D?`请用闲鱼APP扫码,为「${D.nickname||D.remark||D.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-[#F7F8FA] rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${Q==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[Q==="loading"&&e.jsx(Re,{className:"w-10 h-10 text-[#0094f7] animate-spin"}),Q==="waiting"&&e.jsx(Pt,{src:B,alt:"闲鱼登录二维码",className:"p-2"}),Q==="success"&&e.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(He,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),Q==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:"请关闭窗口后重新发起扫码登录。"})]}),Q==="verification"&&e.jsx(fr,{faceQrUrl:ce,verificationScreenshot:z})]}),Q!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),G==="edit"&&A&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:A.nickname||A.remark||A.id})]}),e.jsx("button",{onClick:()=>void bs(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),e.jsx("input",{type:"text",value:A.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),e.jsx("input",{type:"text",value:C.remark,onChange:c=>o({...C,remark:c.target.value}),placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),e.jsx("textarea",{value:C.cookie,onChange:c=>o({...C,cookie:c.target.value}),placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",C.cookie.length," 字符"]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(He,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:()=>o({...C,auto_confirm:!C.auto_confirm}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${C.auto_confirm?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${C.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(bt,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:C.pause_duration,onChange:c=>o({...C,pause_duration:parseInt(c.target.value)||0}),placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),C.pause_duration>0&&!A.paused&&C.pause_duration===(A.pause_duration||0)&&e.jsx("button",{type:"button",disabled:v,onClick:()=>void De(),className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",children:"立即按当前时长重新暂停"})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(ka,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),Z.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:Z.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:Z.loading||Z.saving||!Z.canOpen,onClick:()=>void Y(),className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${Z.enabled?"bg-[#0094f7]":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${Z.enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),e.jsx("input",{type:"text",value:C.username,onChange:c=>o({...C,username:c.target.value}),placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:C.showLoginPassword?"text":"password",value:C.login_password,onChange:c=>o({...C,login_password:c.target.value,clear_password:!1}),placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:()=>o({...C,showLoginPassword:!C.showLoginPassword}),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:C.showLoginPassword?e.jsx(rs,{className:"w-5 h-5"}):e.jsx(as,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:C.clear_password,onChange:c=>o({...C,clear_password:c.target.checked,login_password:c.target.checked?"":C.login_password}),className:"w-4 h-4 accent-[#0094f7]"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),e.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),e.jsx("button",{type:"button",onClick:()=>o({...C,show_browser:!C.show_browser}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${C.show_browser?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${C.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),V.status==="processing"||V.status==="verification_required"?e.jsx("button",{type:"button",onClick:Ss,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:Os,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),V.message&&e.jsx("div",{className:`text-sm font-medium ${V.status==="failed"?"text-red-700":V.status==="success"?"text-green-700":"text-blue-800"}`,children:V.message}),V.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),V.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Pt,{src:V.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(se.length>0||E||K)&&e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[e.jsx(ps,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),E&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Re,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),K&&!E&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:K}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:()=>l(A.id),children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:se.map(c=>{const j=ke.includes(Number(c.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:()=>{m&&(T(W=>j?W.filter(a=>a!==Number(c.id)):[...W,Number(c.id)]),ge(!0))},disabled:!m,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${j?"bg-[#0094f7] border-[#0094f7]":"bg-white border-gray-300"}`,children:j&&e.jsx(He,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:c.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[c.type,c.enabled?"":" · 已停用"]})]})]},c.id)})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>void bs(),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:v,children:"取消"}),e.jsxs("button",{onClick:Me,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:v,children:[v?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(ss,{className:"w-4 h-4"}),v?"保存中...":"保存"]})]})})]})}),document.body),G==="ai-settings"&&A&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[e.jsx(us,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:A.nickname||A.remark||A.id})]}),e.jsx("button",{onClick:Ls,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(us,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),e.jsx("button",{type:"button",onClick:()=>r({..._,ai_enabled:!_.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${_.ai_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${_.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),e.jsx("input",{type:"number",value:_.max_discount_percent,onChange:c=>r({..._,max_discount_percent:parseInt(c.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10 表示最多降价 10%;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),e.jsx("input",{type:"number",value:_.max_discount_amount,onChange:c=>r({..._,max_discount_amount:parseInt(c.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100 表示最多降价 100 元;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),e.jsx("input",{type:"number",value:_.max_bargain_rounds,onChange:c=>r({..._,max_bargain_rounds:parseInt(c.target.value)||1}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),e.jsx("textarea",{value:_.custom_prompts,onChange:c=>r({..._,custom_prompts:c.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... - -例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(rt,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Ls,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:v,children:"取消"}),e.jsxs("button",{onClick:os,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:v,children:[v?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(ss,{className:"w-4 h-4"}),v?"保存中...":"保存"]})]})})]})}),document.body)]})},Nr=s=>({total:Number((s==null?void 0:s.total)||0),success_count:Number((s==null?void 0:s.success_count)||0),failed_count:Number((s==null?void 0:s.failed_count)||0),results:Array.isArray(s==null?void 0:s.results)?s.results.map(t=>({order_id:String((t==null?void 0:t.order_id)||"unknown"),success:(t==null?void 0:t.success)===!0,message:String((t==null?void 0:t.message)||"")})):[]}),vr=s=>(s==null?void 0:s.results.filter(t=>!t.success))||[],Dt=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},n={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:n[s]||s})},wr=()=>{const[s,t]=i.useState([]),[n,d]=i.useState([]),[x,N]=i.useState([]),[S,F]=i.useState({}),[h,R]=i.useState("all"),[b,J]=i.useState(""),[ae,le]=i.useState(""),[oe,k]=i.useState(""),B=i.useRef(0),[re,Q]=i.useState(1),[H,z]=i.useState(1),[xe,ce]=i.useState(!1),[w,D]=i.useState(!1),[U,G]=i.useState(!1),[me,A]=i.useState(!1),[I,Z]=i.useState(null),[L,se]=i.useState(null),[ee,ke]=i.useState({}),[T,m]=i.useState(!1),[g,E]=i.useState(""),[P,ne]=i.useState(!1),[ge,K]=i.useState(null),[ye,C]=i.useState(null),[o,_]=i.useState(null),[r,v]=i.useState(!1),[O,V]=i.useState(null),[q,he]=i.useState(null),te=async()=>{const u=++B.current;ce(!0);try{const $=await yl(b||void 0,h,re,20,oe);if(u!==B.current)return;t($.data),z($.total_pages)}catch($){console.error("加载订单失败:",$)}finally{u===B.current&&ce(!1)}},ue=(u,$,ie)=>{if(ie&&ie.trim())return ie;if(S[`${u}:${$}`])return S[`${u}:${$}`];const we=n.find(Ke=>{if(ie&&Ke.item_title){const Ye=ie.toLowerCase(),Ue=Ke.item_title.toLowerCase();return Ue.includes(Ye)||Ye.includes(Ue)}return!1});return we!=null&&we.item_title?we.item_title:"未知商品"},Ie=u=>{const $={};u.forEach(ie=>{ie.item_id&&($[`${ie.cookie_id}:${ie.item_id}`]=ie.item_title||ie.item_id)}),F($)};i.useEffect(()=>{const u=window.setTimeout(()=>{Q(1),k(ae.trim())},300);return()=>window.clearTimeout(u)},[ae]),i.useEffect(()=>{te()},[b,h,re,oe]),i.useEffect(()=>{Promise.all([Ms(),gs()]).then(([u,$])=>{N(u),d($),Ie($)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const ve=i.useMemo(()=>new Map(x.map(u=>[u.id,u])),[x]),Ve=u=>{const $=ve.get(u),ie=($==null?void 0:$.remark)||($==null?void 0:$.nickname);return ie?`${ie} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},$e=u=>{const $=ve.get(u);return($==null?void 0:$.remark)||($==null?void 0:$.nickname)||"未命名账号"},Te=async()=>{ce(!0);try{const u=await Nl(b||void 0,h);await te(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{ce(!1)}},qe=u=>{E(u),K(null),m(!0)},Ee=async u=>{var $;ne(!0),K(null);try{const ie=await wl([g],u),we=($=ie==null?void 0:ie.results)==null?void 0:$[0];we!=null&&we.success?(K({success:!0,message:we.message}),te()):K({success:!1,message:(we==null?void 0:we.message)||"发货失败"})}catch(ie){K({success:!1,message:(ie==null?void 0:ie.message)||"请求失败"})}finally{ne(!1)}},Ge=u=>{Z(u),D(!0)},Be=u=>{se({...u}),G(!0)},Pe=async()=>{if(!(!L||!L.order_id))try{const u={};L.status!==void 0&&(u.order_status=L.status),L.buyer_id!==void 0&&(u.buyer_id=L.buyer_id),L.amount!==void 0&&(u.amount=L.amount),L.receiver_name!==void 0&&(u.receiver_name=L.receiver_name),L.receiver_phone!==void 0&&(u.receiver_phone=L.receiver_phone),L.receiver_address!==void 0&&(u.receiver_address=L.receiver_address),L.item_id!==void 0&&(u.item_id=L.item_id),L.quantity!==void 0&&(u.quantity=L.quantity),L.item_title!==void 0&&(u.item_title=L.item_title),await fl(L.order_id,u),G(!1),se(null),te()}catch(u){console.error("更新订单失败:",u),alert("更新失败,请重试")}},Qe=async()=>{if(ye){v(!0);try{const u=new FormData;u.append("file",ye);const $=Nr(await _l(u));_($),C(null),await te(),$.failed_count===0&&(A(!1),_(null),alert(`订单导入成功,共 ${$.success_count} 条`))}catch(u){alert((u==null?void 0:u.message)||"导入失败,请检查文件格式")}finally{v(!1)}}},be=()=>{r||(A(!1),C(null),_(null))},Ae=async u=>{V(u);try{const $=await vl(u);$.success?await te():alert($.message||"同步失败")}catch($){console.error("同步订单失败:",$),alert(($==null?void 0:$.message)||"同步失败,请重试")}finally{V(null)}},ze=async u=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){he(u);try{await jl(u),s.length===1&&re>1?Q($=>$-1):await te()}catch($){console.error("删除订单失败:",$),alert(($==null?void 0:$.message)||"删除失败,请重试"),await te()}finally{he(null)}}};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:te,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(Oe,{className:`w-5 h-5 ${xe?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{_(null),A(!0)},className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(es,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:Te,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(yt,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-[#FAFAFA]",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:[{k:"all",v:"全部"},{k:"processing",v:"处理中"},{k:"shipped",v:"已发货"},{k:"pending_ship",v:"待发货"},{k:"completed",v:"已完成"},{k:"cancelled",v:"已取消"},{k:"refunding",v:"退款中"}].map(u=>e.jsx("button",{onClick:()=>{R(u.k),Q(1),le("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${h===u.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:u.v},u.k))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(is,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:b,onChange:u=>{J(u.target.value),Q(1)},className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),x.map(u=>e.jsx("option",{value:u.id,children:Ve(u.id)},u.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(nt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-[#0094f7] transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:ae,onChange:u=>{le(u.target.value),Q(1)},className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:s.map(u=>e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:u.item_image?e.jsx("img",{src:u.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(ks,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:ue(u.cookie_id,u.item_id,u.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:$e(u.cookie_id),children:[e.jsx(is,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:$e(u.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",u.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",u.quantity," • ",at(u.created_at)]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:u.buyer_id}),u.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:u.receiver_name})]}),u.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:u.receiver_phone})]}),u.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:u.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:u.amount?`¥${u.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Dt,{status:u.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[u.status==="pending_ship"&&e.jsx("button",{onClick:()=>qe(u.order_id),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${u.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ge(u),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(as,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Be(u),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(hs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ae(u.order_id),disabled:O===u.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(Oe,{className:`w-4 h-4 ${O===u.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>ze(u.order_id),disabled:q===u.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(Je,{className:"w-4 h-4"})})]})]},u.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",re," 页 / 共 ",H," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:re<=1,onClick:()=>Q(u=>u-1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(Yt,{className:"w-5 h-5"})}),e.jsx("button",{disabled:re>=H,onClick:()=>Q(u=>u+1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(Zt,{className:"w-5 h-5"})})]})]})]}),w&&I&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:()=>D(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:I.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:$e(I.cookie_id),children:$e(I.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Dt,{status:I.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:I.amount?`¥${I.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:I.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:at(I.created_at)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[I.item_image&&e.jsx("img",{src:I.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:ue(I.cookie_id,I.item_id,I.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",I.item_id]}),I.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",I.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:I.buyer_id})]}),I.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:I.receiver_name})]}),I.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:I.receiver_phone})]}),I.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:I.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>D(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),I.status==="pending_ship"&&e.jsx("button",{onClick:()=>{D(!1),qe(I.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),me&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:be,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:u=>{var $;return C((($=u.target.files)==null?void 0:$[0])||null)},className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),ye&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_s,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:ye.name})]})}),o&&o.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",o.success_count," 条,失败 ",o.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:vr(o).map((u,$)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:u.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:u.message||"导入失败"})]},`${u.order_id}-${$}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:be,disabled:r,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:Qe,disabled:!ye||r,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:r?"正在导入…":"导入订单"})]})})]})}),document.body),T&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:()=>{m(!1),K(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:()=>Ee("status_only"),disabled:P,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(yt,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:()=>Ee("full_delivery"),disabled:P,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-[#0094f7] hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(ks,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),P&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(Oe,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),ge&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${ge.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[ge.success?"✓ ":"✗ ",ge.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{m(!1),K(null)},className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:ge!=null&&ge.success?"完成":"取消"})})]})}),document.body),U&&L&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:()=>G(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:L.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:L.status,onChange:u=>se({...L,status:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:L.buyer_id,onChange:u=>se({...L,buyer_id:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:L.amount,onChange:u=>se({...L,amount:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:L.receiver_name||"",onChange:u=>se({...L,receiver_name:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:L.receiver_phone||"",onChange:u=>se({...L,receiver_phone:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:L.receiver_address||"",onChange:u=>se({...L,receiver_address:u.target.value}),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:L.item_title||"",onChange:u=>se({...L,item_title:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>G(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Pe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},_r=(s,t,n)=>{const d=n.trim().toLocaleLowerCase();return s.filter(x=>(!t||x.type===t)&&(!d||x.name.toLocaleLowerCase().includes(d)))},Ft=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),kr=()=>{const[s,t]=i.useState([]),[n,d]=i.useState(!1),[x,N]=i.useState(!1),[S,F]=i.useState(null),[h,R]=i.useState({}),[b,J]=i.useState(Ft),[ae,le]=i.useState(!1),[oe,k]=i.useState("create"),[B,re]=i.useState(null),[Q,H]=i.useState(null),[z,xe]=i.useState(!1),[ce,w]=i.useState(""),[D,U]=i.useState(""),[G,me]=i.useState(null),[A,I]=i.useState(""),[Z,L]=i.useState("");i.useEffect(()=>{Xe().then(t)},[]);const se=({type:o})=>{switch(o){case"text":return e.jsx(ft,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(jt,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(Aa,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Ys,{className:"w-5 h-5 text-gray-500"})}},ee=o=>{var _,r,v,O,V;F(o),R({id:o.id,name:o.name||"",type:o.type||"text",api_url:((_=o.api_config)==null?void 0:_.url)||"",api_method:((r=o.api_config)==null?void 0:r.method)||"GET",api_timeout:((v=o.api_config)==null?void 0:v.timeout)||10,api_headers:((O=o.api_config)==null?void 0:O.headers)||"",api_params:((V=o.api_config)==null?void 0:V.params)||"",text_content:o.text_content||"",data_content:o.data_content||"",image_url:o.image_url||"",delay_seconds:o.delay_seconds||0,description:o.description||"",enabled:o.enabled}),d(!0)},ke=async()=>{var o,_,r,v,O,V,q,he;if(S){if(!((o=h.name)!=null&&o.trim())){alert("请输入卡密名称");return}if(!h.type){alert("请选择卡密类型");return}try{const te={name:h.name.trim(),type:h.type,description:(_=h.description)==null?void 0:_.trim(),delay_seconds:h.delay_seconds||0,enabled:h.enabled??!0};h.type==="api"?te.api_config={url:((r=h.api_url)==null?void 0:r.trim())||"",method:h.api_method,timeout:h.api_timeout||10,headers:((v=h.api_headers)==null?void 0:v.trim())||void 0,params:((O=h.api_params)==null?void 0:O.trim())||void 0}:h.type==="text"?te.text_content=((V=h.text_content)==null?void 0:V.trim())||"":h.type==="data"?te.data_content=((q=h.data_content)==null?void 0:q.trim())||"":h.type==="image"&&(te.image_url=((he=h.image_url)==null?void 0:he.trim())||""),await Lt(S.id,te),d(!1),Xe().then(t)}catch(te){console.error("更新卡密失败:",te),alert("更新失败,请重试")}}},T=async o=>{if(confirm("确认删除该卡密吗?"))try{await Al(o),Xe().then(t)}catch(_){console.error("删除卡密失败:",_),alert("删除失败,请重试")}},m=async()=>{if(!b.name.trim()){alert("请输入卡密名称");return}if(!b.content.trim()){alert(b.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const o={name:b.name.trim(),type:b.type,description:b.description.trim(),enabled:b.enabled,delay_seconds:b.delay_seconds};b.type==="text"&&(o.text_content=b.content.trim()),b.type==="data"&&(o.data_content=b.content.trim()),b.type==="image"&&(o.image_url=b.content.trim()),b.type==="api"&&(o.api_config={url:b.content.trim(),method:b.api_method,timeout:b.api_timeout,headers:b.api_headers.trim()||void 0,params:b.api_params.trim()||void 0}),await Ll(o),N(!1),J(Ft()),Xe().then(t)}catch(o){console.error("添加卡密失败:",o),alert("添加失败,请重试")}},g=async o=>{try{await Lt(o.id,{...o,enabled:!o.enabled}),Xe().then(t)}catch(_){console.error("切换状态失败:",_)}},E=async o=>{try{await navigator.clipboard.writeText(String(o)),alert(`已复制卡密组ID:${o}`)}catch{prompt("复制卡密组ID",String(o))}},P=s.filter(o=>o.type==="data"),ne=i.useMemo(()=>_r(s,A,Z),[s,Z,A]),ge=()=>{const r=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 -VIP-MONTH-002 -VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(q=>q.map(he=>`"${String(he).replace(/"/g,'""')}"`).join(",")).join(` -`),v=new Blob(["\uFEFF"+r],{type:"text/csv;charset=utf-8"}),O=URL.createObjectURL(v),V=document.createElement("a");V.href=O,V.download="卡密组批量导入模板.csv",document.body.appendChild(V),V.click(),V.remove(),URL.revokeObjectURL(O)},K=async()=>{if(B){xe(!0),H(null);try{const o=await Il(B);if(H(o),o.created>0){const _=await Xe();t(_)}}catch(o){H({error:(o==null?void 0:o.message)||"上传失败"})}finally{xe(!1)}}},ye=async()=>{if(!(!ce||!D.trim())){xe(!0),me(null);try{const o=await $l(ce,D);me({added:o.added}),U("");const _=await Xe();t(_)}catch(o){alert("追加失败:"+((o==null?void 0:o.message)||"未知错误"))}finally{xe(!1)}}},C=()=>{var o;k("create"),re(null),H(null),w((o=P[0])!=null&&o.id?String(P[0].id):""),U(""),me(null),le(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:C,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(_s,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>N(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(es,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Xt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:A,onChange:o=>I(o.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:Z,onChange:o=>L(o.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",ne.length," / ",s.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:ne.map(o=>{let _="";return o.type==="data"&&o.data_content?_=`库存: ${o.data_content.split(` -`).filter(v=>v.trim()).length} 条`:o.type==="text"&&o.text_content?_=o.text_content:o.type==="api"&&o.api_config?_=o.api_config.url:o.type==="image"&&o.image_url&&(_="图片链接"),e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(se,{type:o.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:o.name,children:o.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>E(o.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:o.id}),e.jsx(Ca,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${o.type==="text"?"bg-blue-50 text-blue-600":o.type==="data"?"bg-purple-50 text-purple-600":o.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:o.type==="text"?"文本":o.type==="data"?"批量":o.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:_,children:_})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:o.description||"-",children:o.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>g(o),className:`w-12 h-8 rounded-full relative transition-colors ${o.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${o.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>ee(o),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(hs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T(o.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Je,{className:"h-4 w-4"})})]})})]},o.id)})})]})}),ne.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Jt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:s.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),n&&S&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>d(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:h.name||"",onChange:o=>R({...h,name:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:h.type||"text",onChange:o=>R({...h,type:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(S==null?void 0:S.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),h.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:h.api_url||"",onChange:o=>R({...h,api_url:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求方法"}),e.jsxs("select",{value:h.api_method||"GET",onChange:o=>R({...h,api_method:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"超时时间(秒)"}),e.jsx("input",{type:"number",value:h.api_timeout||10,onChange:o=>R({...h,api_timeout:parseInt(o.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"60"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求头(JSON 格式)"}),e.jsx("textarea",{value:h.api_headers||"",onChange:o=>R({...h,api_headers:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"Authorization": "Bearer token"}'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求参数(JSON 格式)"}),e.jsx("textarea",{value:h.api_params||"",onChange:o=>R({...h,api_params:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"type": "card", "count": 1}'})]})]}),h.type==="text"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"固定文字配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"文字内容"}),e.jsx("textarea",{value:h.text_content||"",onChange:o=>R({...h,text_content:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),h.type==="data"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"批量数据配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"数据内容(一行一个)"}),e.jsx("textarea",{value:h.data_content||"",onChange:o=>R({...h,data_content:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: -卡号1:密码1 -卡号2:密码2 -或者 -兑换码1 -兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:h.data_content?h.data_content.split(` -`).filter(o=>o.trim()).length:0})," 条"]})]})]}),h.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:h.image_url||"",onChange:o=>R({...h,image_url:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),h.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:h.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:o=>{o.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:h.delay_seconds||0,onChange:o=>R({...h,delay_seconds:parseInt(o.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:h.description||"",onChange:o=>R({...h,description:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>R({...h,enabled:!h.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${h.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${h.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>d(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:ke,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),x&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>N(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:b.name,onChange:o=>J({...b,name:o.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>J({...b,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="data"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Ys,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>J({...b,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="text"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(ft,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>J({...b,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="image"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(jt,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:b.type==="data"?"库存内容(一行一个)":b.type==="text"?"固定回复内容":b.type==="image"?"图片 URL":"API 地址"}),b.type==="api"?e.jsx("input",{type:"url",value:b.content,onChange:o=>J({...b,content:o.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):b.type==="image"?e.jsx("input",{type:"url",value:b.content,onChange:o=>J({...b,content:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:b.content,onChange:o=>J({...b,content:o.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${b.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:b.type==="data"?`CODE-123456 -CODE-789012 -...`:"请输入每次发货时发送的固定文字"}),b.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-[#0094f7]",children:b.content.split(` -`).filter(o=>o.trim()).length})," 条"]})]}),b.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:b.api_method,onChange:o=>J({...b,api_method:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:b.api_timeout,onChange:o=>J({...b,api_timeout:parseInt(o.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:b.api_headers,onChange:o=>J({...b,api_headers:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:b.api_params,onChange:o=>J({...b,api_params:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:b.description,onChange:o=>J({...b,description:o.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:b.delay_seconds,onChange:o=>J({...b,delay_seconds:parseInt(o.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>N(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:m,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(es,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),ae&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>le(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>k("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${oe==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Sa,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>k("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${oe==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(_s,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),oe==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:ge,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(La,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx(_s,{className:"w-4 h-4"}),B?B.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:o=>{var _;return re(((_=o.target.files)==null?void 0:_[0])||null)}})]})]}),Q&&!Q.error&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",Q.total," 行 · 成功 ",Q.created," · 失败 ",Q.failed]}),Q.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:Q.rows.filter(o=>!o.success).map(o=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",o.row_no," 行「",o.name,"」:",o.error]},o.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:P.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:ce,onChange:o=>w(o.target.value),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:P.map(o=>e.jsxs("option",{value:String(o.id),children:[o.name,"(ID: ",o.id,")"]},o.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:D,onChange:o=>U(o.target.value),placeholder:`VIP-001 -VIP-002 -VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),G&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",G.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>le(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),oe==="create"?e.jsxs("button",{onClick:K,disabled:!B||z,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[z?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(_s,{className:"w-4 h-4"}),z?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:ye,disabled:!ce||!D.trim()||z||P.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[z?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(es,{className:"w-4 h-4"}),z?"处理中...":"追加卡密"]})]})]})}),document.body)]})},Cr=s=>s.find(t=>t.status==="running"||t.status==="canceling"),Sr=s=>{const t=String(s||"").trim();return t?/^[¥¥]/.test(t)?t:`¥${t}`:"-"},Lr=({onConfigureDelivery:s})=>{const[t,n]=i.useState([]),[d,x]=i.useState([]),[N,S]=i.useState([]),[F,h]=i.useState(""),[R,b]=i.useState(""),[J,ae]=i.useState(!1),[le,oe]=i.useState(!1),[k,B]=i.useState(!1),[re,Q]=i.useState(!1),[H,z]=i.useState(!1),[xe,ce]=i.useState(!1),[w,D]=i.useState(!1),[U,G]=i.useState("upload"),[me,A]=i.useState(null),[I,Z]=i.useState(null),[L,se]=i.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[ee,ke]=i.useState(null),[T,m]=i.useState(null),[g,E]=i.useState(null),P=i.useRef(!1),[ne,ge]=i.useState(null),[K,ye]=i.useState({}),[C,o]=i.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[_,r]=i.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[v,O]=i.useState([]),V=i.useMemo(()=>{const l=new Map;return t.forEach(y=>{const Y=String(y.item_category||"").trim();if(!Y)return;let Ce="";try{const Me=JSON.parse(y.item_detail||"{}");Ce=String(Me.category_name||"").trim()}catch{}(!l.has(Y)||Ce)&&l.set(Y,Ce)}),Array.from(l,([y,Y])=>({catId:y,catName:Y}))},[t]);i.useEffect(()=>{if(!xe||_.images.length===0){O([]);return}const l=_.images.map((y,Y)=>({key:y.name+Y,url:URL.createObjectURL(y)}));return O(l),()=>{l.forEach(y=>URL.revokeObjectURL(y.url))}},[xe,_.images]);const q=async()=>{const l=await gs();n(l)},he=async()=>{x(await tt())};i.useEffect(()=>{Promise.all([Ms(),gs(),tt(),At(20)]).then(([l,y,Y,Ce])=>{S(l),n(y),x(Y);const Me=Ce.find(De=>["running","canceling"].includes(De.status))||Ce.find(De=>De.status!=="preview");E(Me||null)}).catch(l=>console.error("加载商品配置失败:",l))},[]),i.useEffect(()=>{if(!w||!(T!=null&&T.id)||!["running","canceling"].includes(T.status))return;const l=window.setInterval(async()=>{if(!P.current){P.current=!0;try{const y=await xs(T.id);m(y),E(y),["running","canceling"].includes(y.status)||(G("done"),await q(),await he())}catch(y){console.error("刷新批量铺货进度失败:",y)}finally{P.current=!1}}},3e3);return()=>{window.clearInterval(l)}},[w,T==null?void 0:T.id,T==null?void 0:T.status]);const te=async()=>{if(!F)return alert("请先选择账号");ae(!0);try{const l=await Rl(F);await q(),alert((l==null?void 0:l.message)||"商品同步完成")}catch(l){console.error("同步商品失败:",l),alert((l==null?void 0:l.message)||"同步失败,请重试")}finally{ae(!1)}},ue=l=>{ge(l),ye({...l}),Q(!0)},Ie=async()=>{if(ne)try{await Bl(ne.cookie_id,ne.item_id,{item_title:K.item_title||"",item_description:K.item_description||"",item_category:K.item_category||"",item_price:K.item_price||"",item_detail:K.item_detail||ne.item_detail||""}),await q(),await he(),Q(!1),ge(null)}catch(l){console.error("更新商品失败:",l),alert("更新失败,请重试")}},ve=async l=>{if(confirm(`确认删除商品"${l.item_title}"吗?`))try{await Pl(l.cookie_id,l.item_id),n(y=>y.filter(Y=>!(Y.cookie_id===l.cookie_id&&Y.item_id===l.item_id)))}catch(y){console.error("删除商品失败:",y),alert("删除失败,请重试")}},Ve=async()=>{try{if(!C.cookie_id||!C.item_id){alert("请选择账号并填写商品ID");return}await Dl(C.cookie_id,{item_id:C.item_id,item_title:C.item_title,item_price:C.item_price,item_detail:C.item_image?JSON.stringify({item_image:C.item_image}):""}),await q(),z(!1),o({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(l){console.error("添加商品失败:",l),alert("添加失败,请重试")}},$e=async()=>{if(!_.cookie_id)return alert("请选择发布账号");if(!_.title.trim())return alert("请填写商品标题");if(!_.price.trim())return alert("请填写商品价格");if(!_.quantity||Number(_.quantity)<=0)return alert("库存数量必须大于 0");if(_.images.length===0)return alert("至少上传 1 张商品图片");if(_.postage_mode==="fixed"&&!_.postage.trim())return alert("请填写一口价邮费");oe(!0);try{const l=await Fl(_);if(await q(),ce(!1),r({cookie_id:F||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),l!=null&&l.item_id){const y={id:l.item_id,cookie_id:_.cookie_id,item_id:l.item_id,item_title:l.item_title||_.title,item_price:l.item_price||_.price,item_image:l.item_image};s(y),alert("商品发布成功,ID: "+l.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(l){console.error("发布商品失败:",l);const y=l==null?void 0:l.payload;if((y==null?void 0:y.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((l==null?void 0:l.message)||"发布失败,请重试")}finally{oe(!1)}},Te=async()=>{G("upload"),ke(null),m(null),A(null),Z(null),se({catId:"",catName:"",channelCatId:"",tbCatId:""}),D(!0),B(!0);try{const l=await At(20),y=Cr(l);if(y!=null&&y.id){const Y=await xs(y.id);E(Y),m(Y),G(["running","canceling"].includes(Y.status)?"running":"done")}}catch(l){console.error("恢复最近批量铺货任务失败:",l)}finally{B(!1)}},qe=async()=>{if(g!=null&&g.id){B(!0),D(!0);try{const l=await xs(g.id);m(l),G(["running","canceling"].includes(l.status)?"running":"done")}catch(l){console.error("加载最近批量铺货结果失败:",l)}finally{B(!1)}}},Ee=async()=>{if(!me)return alert("请先上传商品表格");if(!F)return alert("请先选择默认发布账号");if(!L.catId.trim()||!L.catName.trim())return alert("请同时填写批次兜底类目 ID 和类目名称");B(!0);try{const l=await Tl({file:me,imagesZip:I,defaultCookieId:F,fallbackCategory:L});ke(l),m(null),G("preview")}catch(l){console.error("批量铺货预检失败:",l),alert((l==null?void 0:l.message)||"预检失败,请检查表格和图片 zip")}finally{B(!1)}},Ge=async()=>{if(ee!=null&&ee.preview_id){if(ee.valid<=0)return alert("没有可发布的商品行");B(!0);try{const l=await El(ee.preview_id),y=await xs(l.batch_id||ee.preview_id);m(y),E(y),G(y.status==="running"?"running":"done")}catch(l){console.error("启动批量铺货失败:",l),alert((l==null?void 0:l.message)||"启动发布任务失败")}finally{B(!1)}}},Be=async()=>{if(T!=null&&T.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){B(!0);try{const l=await Ol(T.id),y=await xs(T.id);m(y),G((l==null?void 0:l.status)==="canceling"||y.status==="canceling"?"running":"done")}catch(l){alert((l==null?void 0:l.message)||"取消失败")}finally{B(!1)}}},Pe=async()=>{const l=ee==null?void 0:ee.preview_id;if(l&&U==="preview")try{await Ml(l)}catch(y){console.error("清理批量铺货预检失败:",y)}ke(null),G("upload")},Qe=async()=>{await Pe(),D(!1)},be=async()=>{if(T!=null&&T.id){B(!0);try{await ql(T.id),m(await xs(T.id)),G("running")}catch(l){alert((l==null?void 0:l.message)||"重试失败")}finally{B(!1)}}},Ae=()=>{const Y=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目ID","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","","","","","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","","","","","否","","否","","否","","",""]]].map(os=>os.map(cs=>`"${String(cs).replace(/"/g,'""')}"`).join(",")).join(` -`),Ce=new Blob(["\uFEFF"+Y],{type:"text/csv;charset=utf-8"}),Me=URL.createObjectURL(Ce),De=document.createElement("a");De.href=Me,De.download="批量铺货模板.csv",document.body.appendChild(De),De.click(),De.remove(),URL.revokeObjectURL(Me)},ze=()=>{o(l=>({...l,cookie_id:F||l.cookie_id})),z(!0)},u=()=>{r(l=>({...l,cookie_id:F||l.cookie_id})),ce(!0)},$=l=>d.filter(y=>y.cookie_id===l.cookie_id&&y.item_id===l.item_id).length>0?d.filter(y=>y.cookie_id===l.cookie_id&&y.item_id===l.item_id):d.filter(y=>y.cookie_id===l.cookie_id&&!y.item_id),ie=l=>{switch(l){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return l||"-"}},we=l=>{switch(l){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},Ke=i.useMemo(()=>new Map(N.map(l=>[l.id,l])),[N]),Ye=i.useMemo(()=>R?t.filter(l=>l.cookie_id===R):t,[R,t]),Ue=l=>{const y=Ke.get(l),Y=(y==null?void 0:y.remark)||(y==null?void 0:y.nickname);return Y?`${Y} · ${l.slice(0,6)}`:`账号 ${l.slice(0,8)}`},We=l=>{const y=Ke.get(l);return(y==null?void 0:y.remark)||(y==null?void 0:y.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ia,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:R,onChange:l=>b(l.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),N.map(l=>e.jsx("option",{value:l.id,children:Ue(l.id)},l.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(is,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:F,onChange:l=>h(l.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),N.map(l=>e.jsx("option",{value:l.id,children:Ue(l.id)},l.id))]})]})]}),e.jsxs("button",{onClick:te,disabled:J||!F,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Oe,{className:`w-4 h-4 ${J?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ze,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(es,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:u,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Us,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Te(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(As,{className:"w-4 h-4"}),g&&["running","canceling"].includes(g.status)?"继续批量任务":"批量铺货"]}),g&&!["running","canceling"].includes(g.status)&&e.jsx("button",{onClick:()=>void qe(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[Ye.map(l=>{const y=$(l),Y=y.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[e.jsx("button",{onClick:()=>ue(l),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-[#0094f7] hover:text-white transition-colors",title:"编辑",children:e.jsx(hs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>ve(l),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:e.jsx(Je,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[l.item_image?e.jsx("img",{src:l.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(Vt,{className:"w-8 h-8"})}),e.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:Sr(l.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:l.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:We(l.cookie_id),children:[e.jsx(is,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:We(l.cookie_id)})]}),e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[e.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",l.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${Y?"text-emerald-600":"text-amber-600"}`,children:[Y?e.jsx(Ht,{className:"w-3 h-3"}):e.jsx($a,{className:"w-3 h-3"}),Y?`${y.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>s(l),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${Y?"bg-gray-900 text-white hover:bg-black":"bg-[#0094f7] text-white hover:bg-[#0071e3] shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ra,{className:"w-3.5 h-3.5"}),Y?"查看发货规则":"关联发货规则"]}),e.jsx(Xs,{className:"w-3.5 h-3.5"})]})})]},`${l.cookie_id}-${l.item_id}`)}),Ye.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(Wt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),R?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),re&&ne&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",ne.item_id]})]}),e.jsx("button",{onClick:()=>Q(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:K.item_title||"",onChange:l=>ye({...K,item_title:l.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:K.item_price||"",onChange:l=>ye({...K,item_price:l.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:K.item_category||"",onChange:l=>ye({...K,item_category:l.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:K.item_description||"",onChange:l=>ye({...K,item_description:l.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:Ie,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),H&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),e.jsx("button",{onClick:()=>z(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:C.cookie_id,onChange:l=>o({...C,cookie_id:l.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),N.map(l=>e.jsx("option",{value:l.id,children:Ue(l.id)},l.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:C.item_id,onChange:l=>o({...C,item_id:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:C.item_price,onChange:l=>o({...C,item_price:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:C.item_title,onChange:l=>o({...C,item_title:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:C.item_image,onChange:l=>o({...C,item_image:l.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:Ve,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(es,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),xe&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:()=>ce(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:_.cookie_id,onChange:l=>r({..._,cookie_id:l.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),N.map(l=>e.jsx("option",{value:l.id,children:Ue(l.id)},l.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:_.title,onChange:l=>r({..._,title:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:_.quantity,onChange:l=>r({..._,quantity:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:_.description,onChange:l=>r({..._,description:l.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:_.price,onChange:l=>r({..._,price:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:_.original_price,onChange:l=>r({..._,original_price:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:_.postage_mode,onChange:l=>r({..._,postage_mode:l.target.value}),children:[e.jsx("option",{value:"free",children:"包邮"}),e.jsx("option",{value:"distance",children:"按距离计费"}),e.jsx("option",{value:"fixed",children:"一口价邮费"}),e.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),_.postage_mode==="fixed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:_.postage,onChange:l=>r({..._,postage:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),e.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[e.jsx(As,{className:"w-8 h-8 text-emerald-600 mb-2"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:_.images.length?"已选择 "+_.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:l=>r({..._,images:Array.from(l.target.files||[]).slice(0,9)})})]}),v.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:v.map(l=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:l.url,alt:"",className:"w-full h-full object-cover"})},l.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:le,onClick:$e,className:"w-full bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Us,{className:"w-4 h-4"}),le?"正在发布...":"发布到闲鱼"]})})]})}),document.body),w&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),e.jsx("button",{onClick:()=>void Qe(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(_e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]].map(([l,y])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${U===l?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:y},l))}),U==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),e.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",e.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),e.jsx("button",{type:"button",onClick:Ae,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:F,onChange:l=>h(l.target.value),children:[e.jsx("option",{value:"",children:"选择账号"}),N.map(l=>e.jsx("option",{value:l.id,children:Ue(l.id)},l.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["批次兜底类目 ",e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"闲鱼仍会先自动识别;只有明确识别不出类目时才使用这里的配置。表格中的“类目ID + 类目名称”可覆盖当前行。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[e.jsxs("label",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-xs font-bold text-gray-700",children:"类目 ID"}),e.jsx("input",{className:"w-full ios-input px-3 py-2.5 rounded-xl bg-white",list:"known-publish-categories",placeholder:"例如 50023717",value:L.catId,onChange:l=>{const y=l.target.value,Y=V.find(Ce=>Ce.catId===y.trim());se(Ce=>({...Ce,catId:y,catName:(Y==null?void 0:Y.catName)||(y?Ce.catName:"")}))}}),e.jsx("datalist",{id:"known-publish-categories",children:V.map(l=>e.jsx("option",{value:l.catId,children:l.catName||"历史商品类目"},l.catId))})]}),e.jsxs("label",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-xs font-bold text-gray-700",children:"类目名称"}),e.jsx("input",{className:"w-full ios-input px-3 py-2.5 rounded-xl bg-white",placeholder:"例如 其他虚拟商品",value:L.catName,onChange:l=>se(y=>({...y,catName:l.target.value}))})]})]}),e.jsxs("details",{className:"group text-xs text-gray-600",children:[e.jsx("summary",{className:"cursor-pointer select-none font-bold text-amber-900",children:"高级类目字段(通常留空)"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 md:grid-cols-2",children:[e.jsxs("label",{className:"space-y-1.5",children:[e.jsx("span",{className:"font-bold text-gray-700",children:"频道类目 ID"}),e.jsx("input",{className:"w-full ios-input px-3 py-2.5 rounded-xl bg-white",value:L.channelCatId,onChange:l=>se(y=>({...y,channelCatId:l.target.value}))})]}),e.jsxs("label",{className:"space-y-1.5",children:[e.jsx("span",{className:"font-bold text-gray-700",children:"淘宝类目 ID"}),e.jsx("input",{className:"w-full ios-input px-3 py-2.5 rounded-xl bg-white",value:L.tbCatId,onChange:l=>se(y=>({...y,tbCatId:l.target.value}))})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[e.jsx(As,{className:"w-9 h-9 text-blue-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:me?me.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:l=>{var y;return A(((y=l.target.files)==null?void 0:y[0])||null)}})]}),e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[e.jsx(As,{className:"w-9 h-9 text-emerald-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:I?I.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:l=>{var y;return Z(((y=l.target.files)==null?void 0:y[0])||null)}})]})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[e.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101"}),e.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),e.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),e.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),e.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",e.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"字段"}),e.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),e.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要覆盖批次兜底类目时填写","必须和“类目名称”同时填写;只覆盖当前商品行"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","通常留空","仅在已明确取得闲鱼频道类目 ID 时填写"],["淘宝类目ID","通常留空","仅在已明确取得淘宝类目 ID 时填写"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([l,y,Y])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:l}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${y==="每个商品都要填"?"text-red-600":y==="可以留空"?"text-gray-500":"text-amber-700"}`,children:y}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:Y})]},l))})]})})]})]}),U==="preview"&&ee&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),e.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:ee.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),e.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:ee.valid})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),e.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:ee.invalid})]})]}),e.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),e.jsx("th",{className:"px-4 py-3",children:"兜底类目"}),e.jsx("th",{className:"px-4 py-3",children:"图片"}),e.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:ee.rows.map(l=>{var y,Y,Ce,Me;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:l.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${l.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:l.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:l.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",l.price||"-"," / ",l.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((y=l.category)==null?void 0:y.cat_name)||"-"}),e.jsx("div",{className:"font-mono text-gray-400",children:((Y=l.category)==null?void 0:Y.cat_id)||"-"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Ce=l.images)==null?void 0:Ce.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((Me=l.errors)==null?void 0:Me.join(";"))||"-"})]},l.row_no)})})]})})]}),(U==="running"||U==="done")&&T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("div",{className:`rounded-2xl p-4 border ${we(T.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:ie(T.status)})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),e.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:T.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),e.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:T.success})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),e.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:T.failed})]}),e.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[e.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),e.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:T.pending})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"兜底类目"}),e.jsx("th",{className:"px-4 py-3",children:"商品ID"}),e.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:T.rows.map(l=>{var y,Y;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:l.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${we(l.status)}`,children:ie(l.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:l.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((y=l.category)==null?void 0:y.cat_name)||"-"}),e.jsx("div",{className:"font-mono text-gray-400",children:((Y=l.category)==null?void 0:Y.cat_id)||"-"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:l.item_url?e.jsx("a",{href:l.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:l.item_id}):l.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:l.error_message||"-"})]},l.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[U==="upload"&&e.jsxs("button",{disabled:k||!me||!F||!L.catId.trim()||!L.catName.trim(),onClick:Ee,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Oe,{className:`w-4 h-4 ${k?"animate-spin":""}`}),k?"正在预检...":"开始预检"]}),U==="preview"&&ee&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:k,onClick:()=>void Pe(),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),e.jsxs("button",{disabled:k||ee.valid<=0,onClick:Ge,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Us,{className:"w-4 h-4"}),k?"启动中...":`确认发布 ${ee.valid} 个商品`]})]}),(U==="running"||U==="done")&&T&&e.jsxs("div",{className:"flex gap-3 w-full",children:[T.status==="running"?e.jsx("button",{disabled:k,onClick:Be,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):T.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:()=>window.open(`/items/publish-batches/${T.id}/result.csv`,"_blank"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),T.retryable>0&&!["running","canceling"].includes(T.status)&&e.jsxs("button",{disabled:k,onClick:be,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Oe,{className:`w-4 h-4 ${k?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(T.status)&&e.jsx("button",{onClick:()=>{D(!1),q(),he()},className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})},Tt="https://dashscope.aliyuncs.com/compatible-mode/v1",Ar=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],Ir=new Set(["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),$r=()=>{const[s,t]=i.useState(null),[n,d]=i.useState(!1),[x,N]=i.useState(""),[S,F]=i.useState(!1),[h,R]=i.useState([]),[b,J]=i.useState(!1),[ae,le]=i.useState(""),[oe,k]=i.useState(!1),B=i.useRef(null),[re,Q]=i.useState(!1),[H,z]=i.useState(!1),[xe,ce]=i.useState(!1),[w,D]=i.useState(!1),[U,G]=i.useState(!1),[me,A]=i.useState(null),[I,Z]=i.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});i.useEffect(()=>{se(),la().then(g=>{g.username&&Z(E=>({...E,new_username:g.username||""}))}).catch(()=>{})},[]),i.useEffect(()=>{const g=E=>{var P;(P=B.current)!=null&&P.contains(E.target)||k(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const L=async(g,E=!1)=>{const P=g||s,ne=(P==null?void 0:P.ai_api_url)||(P==null?void 0:P.ai_base_url)||Tt;J(!0),le("");try{const ge=await sr(ne,(P==null?void 0:P.ai_api_key)||"");R(ge),k(E&&ge.length>0),!(P!=null&&P.ai_model)&&ge.length>0&&t(K=>K&&{...K,ai_model:ge[0]})}catch(ge){R([]),k(!1),le(ge.message||"读取模型失败")}finally{J(!1)}},se=()=>{d(!0),N(""),oa().then(g=>{t(g),L(g)}).catch(g=>{t(null),N(g.message||"加载配置失败")}).finally(()=>d(!1))},ee=async()=>{if(s){F(!0);try{const g=Object.fromEntries(Object.entries(s).filter(([E,P])=>!Ir.has(E)&&P!==void 0&&P!==null));await ca(g),alert("系统配置已保存")}catch(g){alert("保存失败:"+g.message)}finally{F(!1)}}},ke=async g=>{g.preventDefault(),A(null);const E=I.new_username.trim();if(E.length<3){A({type:"error",text:"用户名至少需要 3 个字符"});return}if(!I.current_password){A({type:"error",text:"请输入当前密码确认身份"});return}if(I.new_password&&I.new_password.length<8){A({type:"error",text:"新密码至少需要 8 个字符"});return}if(I.new_password!==I.confirm_password){A({type:"error",text:"两次输入的新密码不一致"});return}G(!0);try{const P=await sl({current_password:I.current_password,new_username:E,new_password:I.new_password||void 0});if(!P.success){A({type:"error",text:P.message||"登录凭据更新失败"});return}A({type:"success",text:P.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(P){A({type:"error",text:P.message||"登录凭据更新失败"})}finally{G(!1)}};if(!s)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:x||(n?"加载配置中...":"暂无配置")});const T=s.ai_model||"",m=h;return e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-fade-in pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-2xl flex items-center justify-center",children:e.jsx(rt,{className:"w-6 h-6 text-gray-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900",children:"系统设置"}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"配置全局自动化规则与系统参数"})]})]}),e.jsxs("button",{onClick:se,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Oe,{className:"w-4 h-4"}),"刷新"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-100 text-gray-600",children:e.jsx(Pa,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:s.log_level||"info",onChange:g=>t({...s,log_level:g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:Ar.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:s.log_format||"text",onChange:g=>t({...s,log_format:g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:s.renewal_log_retention_days??10,onChange:g=>t({...s,renewal_log_retention_days:parseInt(g.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"365"}),e.jsx("p",{className:"text-xs text-gray-500",children:"0 表示不自动清理续期日志"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-[#0094f7] text-white",children:e.jsx(Gt,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:s.ai_api_url||Tt,onChange:g=>t({...s,ai_api_url:g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://api.openai.com/v1"}),e.jsx("p",{className:"text-xs text-gray-500",children:"无需补全 /chat/completions"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:re?"text":"password",value:s.ai_api_key||"",onChange:g=>t({...s,ai_api_key:g.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:"sk-..."}),e.jsx("button",{type:"button",onClick:()=>Q(!re),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:re?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(as,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"模型"}),e.jsxs("div",{ref:B,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:T,onFocus:()=>h.length>0&&k(!0),onChange:g=>{t({...s,ai_model:g.target.value}),h.length>0&&k(!0)},onKeyDown:g=>{g.key==="Escape"&&k(!1),g.key==="ArrowDown"&&h.length>0&&k(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>h.length>0&&k(g=>!g),disabled:h.length===0,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 disabled:opacity-30","aria-label":"展开模型列表",children:e.jsx(Da,{className:`w-4 h-4 transition-transform ${oe?"rotate-180":""}`})}),oe&&e.jsx("div",{className:"absolute left-0 right-0 top-[calc(100%+6px)] z-40 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-xl shadow-gray-200/70 py-1",children:m.length>0?m.map(g=>e.jsxs("button",{type:"button",onClick:()=>{t({...s,ai_model:g}),k(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-[#0094f7] flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:g}),g===T&&e.jsx(He,{className:"w-4 h-4 shrink-0 text-[#0094f7]"})]},g)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>L(void 0,!0),disabled:b,className:"px-4 py-3 rounded-xl bg-gray-100 text-gray-700 hover:bg-gray-200 disabled:opacity-60 font-bold flex items-center justify-center gap-2 whitespace-nowrap",children:[e.jsx(Oe,{className:`w-4 h-4 ${b?"animate-spin":""}`}),"读取模型"]})]}),ae?e.jsx("p",{className:"text-xs text-red-500",children:ae}):e.jsx("p",{className:"text-xs text-gray-500",children:h.length>0?`已从当前 API 地址读取到 ${h.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),e.jsxs("div",{className:"p-3 bg-blue-50 rounded-xl text-xs text-blue-700",children:[e.jsx("strong",{children:"常见 AI 服务:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5",children:[e.jsx("li",{children:"阿里云通义千问: https://dashscope.aliyuncs.com/compatible-mode/v1"}),e.jsx("li",{children:"OpenAI: https://api.openai.com/v1"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-amber-500 text-white",children:e.jsx(Hs,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务地址"}),e.jsx("input",{type:"url",value:s["captcha.remote_service_url"]||"",onChange:g=>t({...s,"captcha.remote_service_url":g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://example.com/internal/captcha/solve"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务秘钥"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:H?"text":"password",value:s["captcha.remote_secret_key"]||"",onChange:g=>t({...s,"captcha.remote_secret_key":g.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>z(!H),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:H?"隐藏秘钥":"显示秘钥",children:H?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(as,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(s["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:g=>t({...s,"captcha.remote_pass_cookies":g.target.checked}),className:"mt-0.5 w-4 h-4 rounded border-gray-300"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-bold text-amber-900",children:"允许向远程服务传递账号 Cookie"}),e.jsx("span",{className:"block mt-1 text-xs text-amber-700",children:"默认关闭。仅在信任远程服务且需要由其自动重取过期验证链接时开启。"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"配置地址和秘钥后优先调用远程服务;只有网络不可用或超时才回退本机引擎,远程明确返回失败时不会重复触发本机验证。"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-900 text-white",children:e.jsx(Nt,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:ke,className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"登录用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fa,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:I.new_username,onChange:g=>Z({...I,new_username:g.target.value}),className:"w-full ios-input pl-11 pr-4 py-3 rounded-xl text-sm",autoComplete:"username"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"当前密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:xe?"text":"password",value:I.current_password,onChange:g=>Z({...I,current_password:g.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm",placeholder:"用于确认当前身份",autoComplete:"current-password"}),e.jsx("button",{type:"button",onClick:()=>ce(!xe),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:xe?"隐藏密码":"显示密码",children:xe?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(as,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"新密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:w?"text":"password",value:I.new_password,onChange:g=>Z({...I,new_password:g.target.value}),className:"w-full ios-input px-4 py-3 pr-11 rounded-xl text-sm",placeholder:"不修改则留空",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>D(!w),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:w?"隐藏密码":"显示密码",children:w?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(as,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"确认新密码"}),e.jsx("input",{type:w?"text":"password",value:I.confirm_password,onChange:g=>Z({...I,confirm_password:g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),me&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${me.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(Hs,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:me.text})]}),e.jsxs("button",{type:"submit",disabled:U||!I.new_username||!I.current_password,className:"w-full bg-gray-900 hover:bg-black text-white px-5 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 transition-colors disabled:opacity-40",children:[e.jsx(Nt,{className:"w-4 h-4"}),U?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:ee,disabled:S,className:"ios-btn-primary px-10 py-5 rounded-xl text-lg shadow-2xl shadow-blue-200 flex items-center gap-3 transform hover:scale-105 active:scale-95 transition-all disabled:opacity-70",children:[e.jsx(ss,{className:"w-6 h-6"}),S?"保存中...":"保存所有配置"]})})]})},Ks=(s,t)=>s.allowed_resolutions.includes(t),Rr=(s,t)=>({runs:s.runs.filter(n=>!t||n.cookie_id===t),pending_tasks:s.pending_tasks.filter(n=>!t||n.cookie_id===t)}),Pr=s=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[s]||"自动化异常",Dr=(s,t,n,d,x,N)=>s!==t||n!==d?!1:(N(x),!0),ts={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:ks},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:Ta},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:ea}},Ps=["order_paid","buyer_reviewed","review_missing_timeout"],Fr="亲,商品使用满意的话,麻烦给个评价,谢谢~",Ns=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),ma=s=>{if(!s)return{};try{const t=JSON.parse(s);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}},ls=(s,t={})=>{const n=ma(s);return JSON.stringify({after_shipped_hours:Number(n.after_shipped_hours||72),repeat_interval_hours:Number(n.repeat_interval_hours||24),max_attempts:Number(n.max_attempts||1),...t})},vs=(s,t)=>{var d;const n=((d=ts[s])==null?void 0:d.label)||"自动化规则";return t?`${n} - ${t}`:n},Et=s=>{const t=(s||"").trim();return t?Object.values(ts).some(n=>t===n.label||t.startsWith(`${n.label} -`)):!0},ws=(s,t=0)=>{if(s==="review_missing_timeout")return[{action_type:"send_text",message_template:Fr,enabled:!0,sort_order:1}];const n={action_type:"send_card",card_id:t,delivery_count:1,enabled:!0,sort_order:1};return s==="order_paid"?[n,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[n]},Tr=s=>{var n,d;if(s.trigger_type==="review_missing_timeout")return((d=(n=s.actions)==null?void 0:n.find(x=>x.action_type==="send_text"))==null?void 0:d.message_template)||"发送求评价文案";const t=(s.actions||[]).filter(x=>x.action_type==="send_card");return t.length?t.map(x=>x.card_name||`卡密 ${x.card_id}`).join(" / "):"未配置卡密库存"},Mt=(s,t=!1)=>{const n={blue:t?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:t?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:t?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return n[s]||n.blue},Er=s=>s?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Ds=s=>(s==null?void 0:s.nickname)||(s==null?void 0:s.remark)||(s==null?void 0:s.id)||"未知账号",Mr=s=>s===!0||s===1||s==="1",Or=({initialDeliveryTarget:s,onDeliveryTargetHandled:t})=>{var c,j,W;const[n,d]=i.useState("automation"),[x,N]=i.useState([]),[S,F]=i.useState({runs:[],pending_tasks:[]}),[h,R]=i.useState([]),[b,J]=i.useState({}),[ae,le]=i.useState([]),[oe,k]=i.useState([]),[B,re]=i.useState([]),[Q,H]=i.useState(!1),[z,xe]=i.useState(""),[ce,w]=i.useState(""),[D,U]=i.useState(""),[G,me]=i.useState(""),[A,I]=i.useState("all"),[Z,L]=i.useState(1),[se,ee]=i.useState(10),[ke,T]=i.useState(0),[m,g]=i.useState(0),E=i.useRef(0),P=i.useRef(0),ne=i.useRef("");ne.current=z;const[ge,K]=i.useState(!1),[ye,C]=i.useState(!1),[o,_]=i.useState(!1),[r,v]=i.useState(null),[O,V]=i.useState(null),[q,he]=i.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});ae.find(a=>a.id===z);const te=i.useCallback(async()=>{const[a,p,f,M]=await Promise.all([Ms(),Xe(),gs(),Rt()]);le(a),k(p),re(f),J(M),xe(X=>{var de;return X||((de=a[0])==null?void 0:de.id)||""})},[]),ue=i.useCallback(async()=>{const a=++E.current,p=Vl().catch(X=>(console.warn("加载自动化异常列表失败,不阻断规则展示",X),null)),f=await zl({cookieId:z||void 0,triggerType:G,enabled:A==="all"?void 0:A==="enabled",search:D,page:Z,pageSize:se});if(a!==E.current)return;N(f.data),T(f.total),g(f.total_pages),f.page!==Z&&L(f.page);const M=await p;a===E.current&&M&&F(M)},[Z,se,A,G,D,z]),Ie=i.useCallback(async()=>{const a=z;if(a!==ne.current)return;const p=++P.current;if(R([]),!a)return;const f=await Yl(a);Dr(p,P.current,a,ne.current,f,R)},[z]),ve=i.useCallback(async()=>{J(await Rt())},[]),Ve=i.useCallback(async()=>{H(!0);try{n==="automation"?await ue():n==="reply"?await Ie():await ve()}finally{H(!1)}},[n,ue,ve,Ie]);i.useEffect(()=>{const a=window.setTimeout(()=>{L(1),U(ce.trim())},300);return()=>window.clearTimeout(a)},[ce]),i.useEffect(()=>{te().catch(a=>console.error("加载规则参考数据失败",a))},[te]),i.useEffect(()=>{Ve().catch(a=>console.error("刷新规则页面失败",a))},[Ve]);const $e=i.useMemo(()=>x.filter(a=>!z||a.cookie_id===z),[x,z]),Te=i.useMemo(()=>Rr(S,z),[S,z]),qe=i.useMemo(()=>ae.filter(a=>!z||a.id===z),[ae,z]),Ee=i.useMemo(()=>{var p;const a={order_paid:[],buyer_reviewed:[],review_missing_timeout:[]};for(const f of $e)(p=a[f.trigger_type])==null||p.push(f);return a},[$e]),Ge=i.useMemo(()=>{if(m<=1)return[];const a=Math.max(1,Math.min(Z-2,m-4)),p=Math.min(m,a+4);return Array.from({length:p-a+1},(f,M)=>a+M)},[Z,m]),Be=!!(ce.trim()||G||A!=="all"),Pe=()=>{w(""),U(""),me(""),I("all"),L(1)},Qe=i.useMemo(()=>{const a=(r==null?void 0:r.cookie_id)||z;return B.filter(p=>p.cookie_id===a)},[r==null?void 0:r.cookie_id,B,z]),be=i.useMemo(()=>{if(!(!(r!=null&&r.cookie_id)||!(r!=null&&r.item_id)))return B.find(a=>a.cookie_id===r.cookie_id&&a.item_id===r.item_id)},[r==null?void 0:r.cookie_id,r==null?void 0:r.item_id,B]),Ae=Mr(be==null?void 0:be.is_multi_spec),ze=(r==null?void 0:r.trigger_type)||"order_paid",u=ts[ze],$=ma(r==null?void 0:r.config_json),ie=i.useCallback((a="order_paid",p=z,f="")=>{const M=B.find(de=>de.cookie_id===p&&de.item_id===f),X=(M==null?void 0:M.item_title)||f;return{name:vs(a,X),trigger_type:a,cookie_id:p,item_id:f,item_title:(M==null?void 0:M.item_title)||"",item_keyword:X,card_group_id:0,priority:100,enabled:!0,config_json:a==="review_missing_timeout"?ls():"{}",actions:ws(a),variants:a==="review_missing_timeout"?[]:[Ns()]}},[B,z]),we=i.useCallback(a=>{var f,M;const p=a.trigger_type||"order_paid";v({...a,trigger_type:p,config_json:p==="review_missing_timeout"?ls(a.config_json):a.config_json||"{}",actions:(f=a.actions)!=null&&f.length?a.actions.map(X=>({...X})):ws(p,a.card_group_id),variants:(M=a.variants)!=null&&M.length?a.variants.map(X=>({...X})):p==="review_missing_timeout"?[]:[Ns()]}),K(!0)},[]);i.useEffect(()=>{if(!s)return;let a=!1;return(async()=>{d("automation"),xe(s.cookieId),H(!0);try{const[f,M,X]=await Promise.all([tt(),gs(),Xe().catch(pe=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",pe),[]))]);if(a)return;N(f),re(M),k(X);const de=f.find(pe=>pe.cookie_id===s.cookieId&&pe.item_id===s.itemId&&pe.trigger_type==="order_paid");if(de)we(de);else{const pe=M.find(Se=>Se.cookie_id===s.cookieId&&Se.item_id===s.itemId);v({...ie("order_paid",s.cookieId,s.itemId),item_title:(pe==null?void 0:pe.item_title)||"",item_keyword:(pe==null?void 0:pe.item_title)||s.itemId,name:vs("order_paid",(pe==null?void 0:pe.item_title)||s.itemId)}),K(!0)}}catch(f){console.error("打开商品自动化规则失败",f),alert("无法加载该商品的自动化规则")}finally{a||(H(!1),t==null||t())}})(),()=>{a=!0}},[ie,s,t,we]);const Ke=(a="order_paid")=>{if(!z){alert("请先选择账号");return}v(ie(a)),K(!0)},Ye=a=>{var M,X,de,pe,Se;if(!r)return;const p=((X=(M=r.variants)==null?void 0:M.find(je=>je.card_id))==null?void 0:X.card_id)||((pe=(de=r.actions)==null?void 0:de.find(je=>je.action_type==="send_card"))==null?void 0:pe.card_id)||r.card_group_id||0,f=(be==null?void 0:be.item_title)||r.item_title||r.item_id||"";v({...r,trigger_type:a,name:Et(r.name)?vs(a,f):r.name,card_group_id:p,config_json:a==="review_missing_timeout"?ls(r.config_json):"{}",actions:ws(a,p),variants:a==="review_missing_timeout"?[]:(Se=r.variants)!=null&&Se.length?r.variants:[{...Ns(),card_id:p}]})},Ue=a=>{if(!r)return;const p=B.find(M=>M.cookie_id===(r.cookie_id||z)&&M.item_id===a),f=(p==null?void 0:p.item_title)||a;v({...r,item_id:a,item_title:(p==null?void 0:p.item_title)||"",item_keyword:f,name:Et(r.name)?vs(ze,f):r.name})},We=(c=r==null?void 0:r.variants)!=null&&c.length?r.variants:[Ns()],l=(a,p)=>{var M;if(!r)return;const f=We.map((X,de)=>de===a?{...X,...p}:X);v({...r,variants:f,card_group_id:((M=f[0])==null?void 0:M.card_id)||0})},y=()=>{if(!r)return;const a=We[We.length-1];v({...r,variants:[...We,{...Ns(),spec_name:Ae&&(a==null?void 0:a.spec_name)||"",spec_value:Ae&&(a==null?void 0:a.spec_value)||""}]})},Y=async()=>{var M,X,de,pe,Se;if(!r)return;const a=r.trigger_type||"order_paid";if(!r.cookie_id){alert("请选择账号");return}const p=(M=r.variants)!=null&&M.length?r.variants:[];if(a!=="review_missing_timeout"){if(!p.length||p.some(je=>!je.card_id)){alert(a==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(Ae&&p.some(je=>!je.spec_name.trim()||!je.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(a==="review_missing_timeout"&&!(((de=(X=r.actions)==null?void 0:X.find(Bs=>Bs.action_type==="send_text"))==null?void 0:de.message_template)||"").trim()){alert("请填写求评价文案");return}const f=a==="review_missing_timeout"?[]:p.map(je=>({...je,spec_name:Ae?je.spec_name.trim():"",spec_value:Ae?je.spec_value.trim():"",delivery_count:Math.max(1,Number(je.delivery_count)||1),enabled:je.enabled!==!1}));try{await It({...r,trigger_type:a,name:(r.name||"").trim()||vs(a,(be==null?void 0:be.item_title)||r.item_id||""),config_json:a==="review_missing_timeout"?ls(r.config_json):r.config_json||"{}",actions:(pe=r.actions)!=null&&pe.length?r.actions:ws(a,((Se=f[0])==null?void 0:Se.card_id)||r.card_group_id||0),variants:f}),K(!1),await Promise.all([ue(),te()]),alert("保存成功")}catch(je){console.error("保存自动化规则失败:",je),alert("保存失败:"+je.message)}},Ce=async a=>{if(confirm("确定删除该自动化规则吗?"))try{await Wl(a),await ue(),alert("删除成功")}catch(p){alert("删除失败:"+p.message)}},Me=async a=>{try{await It({...a,enabled:!a.enabled}),await ue()}catch(p){alert("操作失败:"+p.message)}},De=async(a,p)=>{if(confirm(p==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":p==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Gl(a,p),await ue()}catch(M){alert("处理失败:"+M.message)}},os=async(a,p)=>{if(confirm(p==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Jl(a,p),await ue()}catch(f){alert("处理失败:"+f.message)}},cs=()=>{if(!z){alert("请先选择账号");return}V({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),C(!0)},Os=async()=>{var p,f,M;if(!O||!z)return;const a=O.type==="image"?!!((p=O.image_url)!=null&&p.trim()):!!((f=O.reply_content)!=null&&f.trim());if(!((M=O.keyword)!=null&&M.trim())||!a){alert("请填写关键词和回复内容");return}try{await Zl({...O,match_type:"fuzzy",enabled:!0},z),C(!1),await Ie(),alert("保存成功")}catch(X){alert("保存失败:"+X.message)}},Ss=async a=>{if(!(!z||!confirm("确定删除该回复规则吗?")))try{await Xl(a,z),await Ie(),alert("删除成功")}catch(p){alert("删除失败:"+p.message)}},bs=async(a=z)=>{if(!a){alert("请先选择账号");return}try{const p=await ir(a);he({cookie_id:a,enabled:p.enabled,reply_content:p.reply_content,reply_once:p.reply_once,reply_image_url:p.reply_image_url||""})}catch{he({cookie_id:a,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}_(!0)},Ls=async()=>{if(!q.cookie_id){alert("请先选择账号");return}if(q.enabled&&!q.reply_content.trim()&&!q.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}try{await or(q.cookie_id,{enabled:q.enabled,reply_content:q.reply_content,reply_once:q.reply_once,reply_image_url:q.reply_image_url}),_(!1),await ve(),alert("保存成功")}catch(a){alert("保存失败:"+a.message)}},qs=async a=>{if(confirm("确定删除该账号默认回复吗?"))try{await cr(a),await ve(),alert("删除成功")}catch(p){alert("删除失败:"+p.message)}},ys=async a=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await dr(a),alert("清空成功")}catch(p){alert("清空失败:"+p.message)}},fs=n==="automation"?"新建自动化":n==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-3",children:[e.jsxs("select",{value:z,onChange:a=>{xe(a.target.value),L(1)},className:"ios-input px-4 py-3 rounded-2xl text-sm min-w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),ae.map(a=>e.jsx("option",{value:a.id,children:Ds(a)},a.id))]}),e.jsxs("button",{onClick:Ve,className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 flex items-center justify-center gap-2 whitespace-nowrap transition-colors",children:[e.jsx(Oe,{className:`w-4 h-4 ${Q?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:n==="automation"?()=>Ke("order_paid"):n==="reply"?cs:()=>void bs(),disabled:!z,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 whitespace-nowrap disabled:opacity-50",children:[e.jsx(es,{className:"w-4 h-4"}),fs]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:Zs},{id:"reply",label:"关键词回复",icon:Fs},{id:"default",label:"账号默认回复",icon:us}].map(a=>{const p=a.icon;return e.jsxs("button",{onClick:()=>d(a.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${n===a.id?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(p,{className:"w-4 h-4"}),a.label]},a.id)})}),n==="automation"&&(Te.runs.length>0||Te.pending_tasks.length>0)&&e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ns,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[Te.runs.map(a=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",a.cookie_id," · 订单 ",a.order_id||"-"," · 已记录发送 ",a.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Pr(a.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:a.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[Ks(a,"continue")&&e.jsx("button",{onClick:()=>void De(a.id,"continue"),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Ks(a,"retry")&&e.jsx("button",{onClick:()=>void De(a.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Ks(a,"cancel")&&e.jsx("button",{onClick:()=>void De(a.id,"cancel"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${a.id}`)),Te.pending_tasks.map(a=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",a.cookie_id," · 延迟任务重试已达 ",a.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:a.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>void os(a.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:()=>void os(a.id,"dismiss"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${a.id}`))]})]}),n==="automation"&&e.jsxs("div",{className:"grid grid-cols-1 2xl:grid-cols-[360px_1fr] gap-6",children:[e.jsxs("aside",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsx("h3",{className:"font-black text-gray-900 mb-1",children:"新建规则"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"先选自动化类型,再配置对应动作。"}),e.jsx("div",{className:"space-y-3",children:Ps.map(a=>{const p=ts[a],f=p.icon;return e.jsx("button",{type:"button",onClick:()=>Ke(a),className:`w-full text-left rounded-2xl border p-4 transition-colors ${Mt(p.accent)}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/80 flex items-center justify-center shrink-0",children:e.jsx(f,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:p.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:p.description})]})]})},a)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"font-black text-gray-900",children:"本页规则构成"}),e.jsxs("span",{className:"text-xs font-bold text-gray-400",children:["共 ",ke," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Ps.map(a=>{const p=ts[a],f=p.icon;return e.jsxs("div",{className:"flex items-center justify-between rounded-2xl bg-gray-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(f,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:p.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:Ee[a].length})]},a)})})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-[#FAFAFA] p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"搜索自动化规则",placeholder:"搜索规则名、商品名或商品 ID...",value:ce,onChange:a=>{w(a.target.value),L(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]}),e.jsxs("div",{className:"relative xl:w-52",children:[e.jsx(Xt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按自动化类型筛选",value:G,onChange:a=>{me(a.target.value),L(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部自动化类型"}),Ps.map(a=>e.jsx("option",{value:a,children:ts[a].shortLabel},a))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:A,onChange:a=>{I(a.target.value),L(1)},className:"ios-input rounded-xl border-none bg-white px-4 py-2.5 text-sm shadow-sm xl:w-36",children:[e.jsx("option",{value:"all",children:"全部状态"}),e.jsx("option",{value:"enabled",children:"已启用"}),e.jsx("option",{value:"disabled",children:"已禁用"})]}),Be&&e.jsx("button",{type:"button",onClick:Pe,className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white text-gray-500 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900",title:"清除筛选","aria-label":"清除筛选",children:e.jsx(_e,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs font-bold text-gray-400",children:[e.jsxs("span",{children:["找到 ",ke," 条规则"]}),Q&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Oe,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),Q&&$e.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(Oe,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):$e.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(Zs,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:Be?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:Be?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):$e.map(a=>{const p=ts[a.trigger_type],f=p.icon;return e.jsx("article",{className:"bg-white rounded-xl border border-gray-100 p-5 shadow-sm hover:shadow-lg transition-all",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 ${Mt(p.accent,!0)}`,children:e.jsx(f,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-lg font-black text-gray-900 truncate",children:a.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${Er(a.enabled)}`,children:a.enabled?"已启用":"已禁用"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-bold",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:p.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:a.item_title||a.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:Tr(a)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>we(a),className:"px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-bold flex items-center gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>Me(a),className:`px-4 py-2 rounded-xl text-sm font-bold ${a.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:a.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>Ce(a.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Je,{className:"w-4 h-4"})})]})]})},a.id)}),ke>0&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-gray-500",children:[e.jsxs("span",{children:["第 ",Z," / ",Math.max(m,1)," 页"]}),e.jsx("span",{className:"h-4 w-px bg-gray-200"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"sr-only",children:"每页显示数量"}),e.jsx("select",{value:se,onChange:a=>{ee(Number(a.target.value)),L(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(a=>e.jsxs("option",{value:a,children:[a," 条/页"]},a))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:Z<=1||Q,onClick:()=>L(a=>Math.max(1,a-1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页",title:"上一页",children:e.jsx(Yt,{className:"h-4 w-4"})}),Ge.map(a=>e.jsx("button",{type:"button",disabled:Q,onClick:()=>L(a),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${a===Z?"bg-[#0094f7] text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${a} 页`,"aria-current":a===Z?"page":void 0,children:a},a)),e.jsx("button",{type:"button",disabled:Z>=m||Q,onClick:()=>L(a=>Math.min(m,a+1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页",title:"下一页",children:e.jsx(Zt,{className:"h-4 w-4"})})]})]})]})]}),n==="reply"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(ns,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[h.map(a=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg transition-all gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"px-3 py-1 bg-black text-white rounded-lg text-xs font-bold",children:"包含匹配"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",a.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:a.type==="image"&&a.image_url?a.image_url:a.reply_content})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>{V({...a}),C(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(hs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ss(a.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Je,{className:"w-5 h-5"})})]})]},a.id)),h.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),n==="default"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(ns,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[qe.map(a=>{const p=b[a.id],f=!!(p!=null&&p.enabled);return e.jsxs("div",{className:`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${f?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center ${f?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(us,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg truncate",children:Ds(a)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${f?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:f?"已启用":"未启用"}),(p==null?void 0:p.reply_once)&&e.jsx("span",{className:"px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700",children:"只回复一次"})]}),e.jsx("div",{className:"text-sm text-gray-600 line-clamp-2",children:f?p.reply_content||p.reply_image_url||"已配置默认回复":"未配置默认回复"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>void bs(a.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(hs,{className:"w-4 h-4"})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void ys(a.id),className:"px-3 py-2 text-xs font-bold text-blue-600 hover:bg-blue-50 rounded-xl transition-colors",children:"清空记录"}),e.jsx("button",{onClick:()=>void qs(a.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Je,{className:"w-5 h-5"})})]})]})]},a.id)}),qe.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),ge&&r&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"72rem",maxHeight:"92vh"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-black text-gray-900",children:r.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:u.description})]}),e.jsx("button",{onClick:()=>K(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] min-h-0",children:[e.jsxs("aside",{className:"bg-slate-900 text-white p-5 overflow-y-auto",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"选择自动化类型"}),e.jsx("div",{className:"space-y-3",children:Ps.map(a=>{const p=ts[a],f=p.icon,M=ze===a;return e.jsx("button",{type:"button",onClick:()=>Ye(a),className:`w-full rounded-2xl p-4 text-left border transition-all ${M?"bg-white text-slate-950 border-white":"bg-white/5 text-white border-white/10 hover:bg-white/10"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(f,{className:`w-5 h-5 mt-0.5 ${M?"text-[#0094f7]":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:p.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${M?"text-gray-500":"text-gray-400"}`,children:p.description})]})]})},a)})}),e.jsxs("div",{className:"mt-6 rounded-2xl bg-white/5 border border-white/10 p-4",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"执行流程"}),e.jsx("div",{className:"space-y-3",children:u.flow.map((a,p)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white text-slate-950 text-xs font-black flex items-center justify-center",children:p+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:a})]},a))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-[#F7F8FA]",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Ht,{className:"w-5 h-5 text-[#0094f7]"}),e.jsx("h4",{className:"font-black text-gray-900",children:"生效范围"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"规则名称"}),e.jsx("input",{type:"text",value:r.name||"",onChange:a=>v({...r,name:a.target.value}),placeholder:"不填时按类型和商品自动生成",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:r.cookie_id||"",onChange:a=>v({...r,cookie_id:a.target.value,item_id:"",item_title:"",item_keyword:""}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),ae.map(a=>e.jsx("option",{value:a.id,children:Ds(a)},a.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:r.item_id||"",onChange:a=>Ue(a.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),Qe.map(a=>e.jsx("option",{value:a.item_id,children:a.item_title||a.item_id},`${a.cookie_id}-${a.item_id}`))]})]})]}),be&&ze!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:be.item_title||be.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${Ae?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:Ae?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),ze!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ea,{className:"w-5 h-5 text-[#0094f7]"}),e.jsx("h4",{className:"font-black text-gray-900",children:ze==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:Ae?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:y,className:"px-3 py-2 rounded-xl bg-gray-900 text-white text-xs font-bold hover:bg-black flex items-center gap-1.5",children:[e.jsx(es,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:We.map((a,p)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${Ae?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[Ae&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格名称"}),e.jsx("input",{value:a.spec_name,onChange:f=>l(p,{spec_name:f.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:套餐"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格值"}),e.jsx("input",{value:a.spec_value,onChange:f=>l(p,{spec_value:f.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:30天"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"卡密库存"}),e.jsxs("select",{value:a.card_id||"",onChange:f=>l(p,{card_id:Number(f.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),oe.filter(f=>f.enabled&&f.type!=="api").map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"每件份数"}),e.jsx("input",{type:"number",min:"1",max:"100",value:a.delivery_count,onChange:f=>l(p,{delivery_count:Math.max(1,Number(f.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsxs("div",{className:"md:col-span-full flex flex-wrap items-center gap-3 rounded-xl bg-gray-50 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-bold text-gray-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.delay_override===!0,onChange:f=>l(p,{delay_override:f.target.checked}),className:"accent-[#0094f7]"}),"覆盖卡密默认延时"]}),a.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:a.delay_seconds||0,onChange:f=>l(p,{delay_seconds:Math.max(0,Number(f.target.value)||0)}),className:"w-28 ios-input px-2 py-1.5 rounded-lg text-xs","aria-label":"动作延时秒数"}),e.jsx("span",{className:"text-xs text-gray-500",children:a.delay_override?`本动作延时 ${a.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:We.length===1,onClick:()=>v({...r,variants:We.filter((f,M)=>M!==p)}),className:"w-10 h-10 flex items-center justify-center rounded-lg text-red-500 hover:bg-red-50 disabled:opacity-25",title:"删除发货内容",children:e.jsx(Je,{className:"w-4 h-4"})})]},a.id||p))})]}):e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ea,{className:"w-5 h-5 text-amber-600"}),e.jsx("h4",{className:"font-black text-gray-900",children:"求评价计划"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"发货后等待小时"}),e.jsx("input",{type:"number",min:"1",value:Number($.after_shipped_hours||72),onChange:a=>v({...r,config_json:ls(r.config_json,{after_shipped_hours:Math.max(1,Number(a.target.value)||72)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"再次求评间隔小时"}),e.jsx("input",{type:"number",min:"1",value:Number($.repeat_interval_hours||24),onChange:a=>v({...r,config_json:ls(r.config_json,{repeat_interval_hours:Math.max(1,Number(a.target.value)||24)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最多求评次数"}),e.jsx("input",{type:"number",min:"1",value:Number($.max_attempts||1),onChange:a=>v({...r,config_json:ls(r.config_json,{max_attempts:Math.max(1,Number(a.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((W=(j=r.actions)==null?void 0:j.find(a=>a.action_type==="send_text"))==null?void 0:W.message_template)||"",onChange:a=>{var p;return v({...r,actions:((p=r.actions)!=null&&p.length?r.actions:ws("review_missing_timeout")).map(f=>f.action_type==="send_text"?{...f,message_template:a.target.value}:f)})},className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none"})]})]})]}),e.jsx("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[180px_1fr] gap-4 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"优先级"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"数字越小优先级越高;同一账号、商品和触发条件只执行优先级最高的一条规则。"}),e.jsx("input",{type:"number",value:r.priority||100,onChange:a=>v({...r,priority:Number(a.target.value)||100}),min:"1",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"h-[48px] flex items-center gap-3 px-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsx("input",{type:"checkbox",checked:r.enabled!==!1,onChange:a=>v({...r,enabled:a.target.checked}),className:"w-4 h-4 rounded"}),"启用规则"]})]})})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[e.jsx("button",{onClick:()=>K(!1),className:"flex-1 px-6 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200",children:"取消"}),e.jsxs("button",{onClick:Y,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),ye&&O&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:O.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>C(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:O.item_id||"",onChange:a=>V({...O,item_id:a.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),B.filter(a=>!z||a.cookie_id===z).map(a=>e.jsx("option",{value:a.item_id,children:a.item_title||a.item_id},`${a.cookie_id}-${a.item_id}`))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复类型"}),e.jsxs("select",{value:O.type||"text",onChange:a=>{const p=a.target.value;V({...O,type:p,reply_content:p==="text"?O.reply_content:"",image_url:p==="image"?O.image_url:""})},className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"文字"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关键词"}),e.jsx("input",{type:"text",value:O.keyword||"",onChange:a=>V({...O,keyword:a.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),O.type==="image"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{value:O.image_url||"",onChange:a=>V({...O,image_url:a.target.value}),placeholder:"https://...",className:"w-full ios-input px-4 py-3 rounded-xl"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:O.reply_content||"",onChange:a=>V({...O,reply_content:a.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>C(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Os,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(it,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),o&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"账号默认回复"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"关键词和 AI 都未处理时,才会使用默认回复。"})]}),e.jsx("button",{onClick:()=>_(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:q.cookie_id,onChange:a=>he({...q,cookie_id:a.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),ae.map(a=>e.jsx("option",{value:a.id,children:Ds(a)},a.id))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"启用默认回复"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"启用后,未命中关键词时自动发送"})]}),e.jsx("button",{type:"button",onClick:()=>he({...q,enabled:!q.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${q.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${q.enabled?"translate-x-7":"translate-x-1"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:q.reply_content,onChange:a=>he({...q,reply_content:a.target.value}),placeholder:"输入默认回复内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复图片 URL(可选)"}),e.jsx("input",{type:"text",value:q.reply_image_url,onChange:a=>he({...q,reply_image_url:a.target.value}),placeholder:"https://example.com/image.jpg",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsxs("span",{children:["只回复一次",e.jsx("span",{className:"block text-xs text-gray-500 font-medium mt-1",children:"同一会话只发送一次默认回复"})]}),e.jsx("input",{type:"checkbox",checked:q.reply_once,onChange:a=>he({...q,reply_once:a.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>_(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ls,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},qr=s=>{const t=String(s.smtp_from||"").trim(),n=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);return{...s,smtp_from_name:s.smtp_from_name||(n?"":t),smtp_from_address:s.smtp_from_address||(n?t:s.smtp_user||""),smtp_use_tls:Ot(s.smtp_use_tls,!0),smtp_use_ssl:Ot(s.smtp_use_ssl,!1)}},Ot=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},ct=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],lt=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},ua=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),n=ct.some(d=>String(s[d]??"").trim()!=="");return{...s,use_custom_smtp:t?lt(s.use_custom_smtp,!1):n}},qt=(s,t)=>{const n={...s,use_custom_smtp:!0};for(const d of ct)String(n[d]??"").trim()===""&&t[d]!==void 0&&(n[d]=t[d]);return n.smtp_port||(n.smtp_port=587),n.smtp_from_address||(n.smtp_from_address=n.smtp_user||""),n.smtp_use_tls=lt(n.smtp_use_tls,!0),n.smtp_use_ssl=lt(n.smtp_use_ssl,!1),n},Br=s=>{const t=ua(s),n={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(n.use_custom_smtp)for(const d of ct)n[d]=t[d];return n},ms={bark:{label:"Bark",icon:ps,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"Ydisks闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app//这是测试推送内容","URL 路径里 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:Fs,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:Fs,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:Fs,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:Ma,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:it,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的用户 ID",required:!0}],guide:{steps:["在 Telegram 搜索 @BotFather,发送 /newbot,按提示创建机器人,拿到 Bot Token","把你的 Bot 拉进一个群,或私聊它发一条消息","浏览器访问 https://api.telegram.org/bot<你的Token>/getUpdates",'从返回 JSON 里找 "chat":{"id":xxx},xxx 就是 Chat ID(群是负数,私聊是正数)'],urlFormat:"Bot Token: 123456:ABC-DEF... Chat ID: -1001234567890",note:"群聊需先把 Bot 设为管理员才能发消息。"}},email:{label:"邮件",icon:sa,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},pa=[{value:"account_offline",label:"掉线通知",description:"账号过期、断线或登录态失效"},{value:"account_recovered",label:"恢复通知",description:"自动恢复成功并重新在线"},{value:"account_disabled",label:"禁用通知",description:"连续失败、账密错误等导致账号停用"},{value:"security_verification",label:"风控验证",description:"滑块、人脸、扫码验证等安全校验"},{value:"delivery_result",label:"交易通知",description:"订单发货、卡密发送等交易结果"},{value:"token_renewal",label:"续期通知",description:"Cookie/token 续期和自动恢复过程"},{value:"system_error",label:"系统错误",description:"后台任务或系统级异常"}],zr=s=>!s||s.length===0?"全部事件":s.map(n=>{var d;return((d=pa.find(x=>x.value===n))==null?void 0:d.label)||n}).join("、"),Ur=({isAdmin:s=!1})=>{const[t,n]=i.useState([]),[d,x]=i.useState(!0),[N,S]=i.useState(!1),[F,h]=i.useState(null),[R,b]=i.useState(!1),[J,ae]=i.useState(""),[le,oe]=i.useState(null),[k,B]=i.useState({}),[re,Q]=i.useState(!1),[H,z]=i.useState(!1),[xe,ce]=i.useState(!1),[w,D]=i.useState({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),U=async()=>{x(!0);try{const m=await xa();n(m.data||[])}catch(m){console.error("加载通知渠道失败",m)}finally{x(!1)}},G=async()=>{try{const m=await oa();B(qr(m||{}))}catch(m){console.error("加载 SMTP 配置失败",m)}},me=async()=>{Q(!0);try{await ca({smtp_server:k.smtp_server||"",smtp_port:k.smtp_port||587,smtp_user:k.smtp_user||"",smtp_password:k.smtp_password||"",smtp_from_name:k.smtp_from_name||"",smtp_from_address:k.smtp_from_address||k.smtp_user||"",smtp_use_tls:k.smtp_use_tls!==!1,smtp_use_ssl:k.smtp_use_ssl===!0}),A("success","SMTP 配置已保存")}catch(m){A("error",(m==null?void 0:m.message)||"保存失败")}finally{Q(!1)}};i.useEffect(()=>{U(),s?G():B({})},[s]);const A=(m,g)=>{oe({type:m,text:g}),window.setTimeout(()=>oe(null),3e3)},I=()=>{h(null),D({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),ce(!1),S(!0)},Z=m=>{h(m);const g=m.type==="email"?ua({...m.config||{}}):null,E=g?g.use_custom_smtp===!0?qt(g,k):g:{...m.config||{}};D({name:m.name,type:m.type,enabled:m.enabled,config:E,event_types:m.event_types||[]}),ce(!1),S(!0)},L=async()=>{const m=ms[w.type];for(const E of m.fields)if(E.required&&!String(w.config[E.key]||"").trim()){A("error",`请填写 ${E.label}`);return}if(!w.name.trim()){A("error","请填写渠道名称");return}let g=w.config;if(w.type==="email"&&(g=Br(w.config),g.use_custom_smtp)){const P=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([ne])=>!String(g[ne]||"").trim());if(P){A("error",`请填写 ${P[1]}`);return}}b(!0);try{const E={name:w.name.trim(),type:w.type,config:g,event_types:w.event_types,enabled:w.enabled};F?await $t(F.id,E):await ar(E),S(!1),await U(),A("success",F?"已更新":"已创建")}catch(E){console.error("保存失败",E),A("error",(E==null?void 0:E.message)||"保存失败")}finally{b(!1)}},se=async m=>{if(confirm(`确认删除渠道「${m.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await lr(m.id),await U(),A("success","已删除")}catch(g){A("error",(g==null?void 0:g.message)||"删除失败")}},ee=async m=>{try{await $t(m.id,{enabled:!m.enabled}),n(g=>g.map(E=>E.id===m.id?{...E,enabled:!E.enabled}:E))}catch(g){A("error",(g==null?void 0:g.message)||"切换失败")}},ke=async m=>{ae(m.id);try{await nr(m.id),A("success","测试通知已发送,请检查对应渠道")}catch(g){A("error",(g==null?void 0:g.message)||"发送失败")}finally{ae("")}},T=ms[w.type];return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"通知设置"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"配置通知渠道,账号异常时主动推送告警"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:U,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Oe,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:I,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(es,{className:"w-4 h-4"}),"新建渠道"]})]})]}),e.jsx("div",{className:"ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ps,{className:"w-5 h-5 text-[#0094f7] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-gray-700 leading-6",children:["配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:",e.jsxs("ul",{className:"mt-2 space-y-1 text-gray-600",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"账号 session 失效"}),":系统正在尝试自动恢复(警告)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"自动恢复失败"}),":账号已停止,需人工处理(严重)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),d?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(Re,{className:"w-8 h-8 text-[#0094f7] animate-spin"})}):t.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(ps,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"还没有配置任何通知渠道"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"点击右上角「新建渠道」开始配置"})]}):e.jsx("div",{className:"space-y-3",children:t.map(m=>{const g=ms[m.type]||ms.webhook,E=g.icon;return e.jsxs("div",{className:"ios-card rounded-xl p-5 bg-white flex items-center gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-gray-100 flex items-center justify-center flex-shrink-0",children:e.jsx(E,{className:"w-5 h-5 text-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-gray-900 truncate",children:m.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:g.label}),!m.enabled&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-400 font-medium",children:"已停用"})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 truncate",children:g.fields.map(P=>{var ne;return(ne=m.config)==null?void 0:ne[P.key]}).filter(Boolean).map((P,ne)=>e.jsx("span",{className:"mr-3",children:String(P).length>40?String(P).slice(0,40)+"…":String(P)},ne))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",zr(m.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ee(m),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${m.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:m.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>ke(m),disabled:J===m.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-[#0094f7] hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[J===m.id?e.jsx(Re,{className:"w-3 h-3 animate-spin"}):e.jsx(it,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>Z(m),className:"w-8 h-8 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors",title:"编辑",children:e.jsx(Kt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>se(m),className:"w-8 h-8 rounded-lg bg-red-50 hover:bg-red-100 flex items-center justify-center text-red-500 transition-colors",title:"删除",children:e.jsx(Je,{className:"w-4 h-4"})})]})]},m.id)})}),s&&e.jsxs("section",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-extrabold text-gray-800",children:"SMTP 邮件配置"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"系统级邮件发送服务,供邮件通知渠道复用"})]}),e.jsx("div",{className:"p-2 rounded-xl bg-blue-50 text-blue-600",children:e.jsx(sa,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 服务器"}),e.jsx("input",{type:"text",value:k.smtp_server||"",onChange:m=>B({...k,smtp_server:m.target.value}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 端口"}),e.jsx("input",{type:"number",value:k.smtp_port||587,onChange:m=>B({...k,smtp_port:parseInt(m.target.value)||587}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱"}),e.jsx("input",{type:"email",value:k.smtp_user||"",onChange:m=>B({...k,smtp_user:m.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"邮箱密码 / 授权码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:H?"text":"password",value:k.smtp_password||"",onChange:m=>B({...k,smtp_password:m.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>z(!H),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:H?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(as,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:k.smtp_from_name||"",onChange:m=>B({...k,smtp_from_name:m.target.value}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱地址"}),e.jsx("input",{type:"email",value:k.smtp_from_address||k.smtp_user||"",onChange:m=>B({...k,smtp_from_address:m.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:k.smtp_use_tls!==!1,onChange:m=>B({...k,smtp_use_tls:m.target.checked,smtp_use_ssl:m.target.checked?!1:k.smtp_use_ssl})}),"STARTTLS(常用于 587 端口)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:k.smtp_use_ssl===!0,onChange:m=>B({...k,smtp_use_ssl:m.target.checked,smtp_use_tls:m.target.checked?!1:k.smtp_use_tls})}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:me,disabled:re,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[re?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(ss,{className:"w-4 h-4"}),re?"保存中...":"保存 SMTP 配置"]})]}),N&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"36rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:F?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>S(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(_e,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道名称"}),e.jsx("input",{type:"text",value:w.name,onChange:m=>D({...w,name:m.target.value}),placeholder:"例如:我的 Bark",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道类型"}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Object.keys(ms).map(m=>{const g=ms[m],E=g.icon,P=w.type===m;return e.jsxs("button",{type:"button",onClick:()=>D({...w,type:m,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${P?"border-[#0094f7] bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(E,{className:`w-5 h-5 ${P?"text-[#0094f7]":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${P?"text-[#0094f7]":"text-gray-600"}`,children:g.label})]},m)})})]}),e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",T.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:T.guide.steps.map((m,g)=>e.jsx("li",{children:m},g))}),T.guide.urlFormat&&e.jsxs("div",{className:"text-xs text-amber-900/90",children:[e.jsx("span",{className:"font-bold",children:"格式示例:"}),e.jsx("code",{className:"mt-1 block bg-amber-100/70 px-2.5 py-1.5 rounded-lg break-all font-mono text-[11px]",children:T.guide.urlFormat})]}),T.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",T.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:T.fields.map(m=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[m.label,m.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:m.type==="password"?"password":m.type==="number"?"number":"text",value:String(w.config[m.key]||""),onChange:g=>D({...w,config:{...w.config,[m.key]:g.target.value}}),placeholder:m.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),m.help&&e.jsx("p",{className:"text-xs text-gray-500",children:m.help})]},m.key))}),w.type==="email"&&e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"SMTP 来源"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:w.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:()=>{const m=w.config.use_custom_smtp===!0;D({...w,config:m?{...w.config,use_custom_smtp:!1}:qt(w.config,k)})},className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${w.config.use_custom_smtp===!0?"bg-[#0094f7]":"bg-gray-300"}`,"aria-label":"使用独立 SMTP",children:e.jsx("span",{className:`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${w.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),w.config.use_custom_smtp===!0&&e.jsxs("div",{className:"space-y-4 border-t border-blue-100 bg-white/80 p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 服务器 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:String(w.config.smtp_server||""),onChange:m=>D({...w,config:{...w.config,smtp_server:m.target.value}}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 端口 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:String(w.config.smtp_port||587),onChange:m=>D({...w,config:{...w.config,smtp_port:m.target.value}}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["登录邮箱 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(w.config.smtp_user||""),onChange:m=>D({...w,config:{...w.config,smtp_user:m.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["密码 / 授权码 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:xe?"text":"password",value:String(w.config.smtp_password||""),onChange:m=>D({...w,config:{...w.config,smtp_password:m.target.value}}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>ce(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:xe?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(as,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:String(w.config.smtp_from_name||""),onChange:m=>D({...w,config:{...w.config,smtp_from_name:m.target.value}}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["发件邮箱地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(w.config.smtp_from_address||""),onChange:m=>D({...w,config:{...w.config,smtp_from_address:m.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:w.config.smtp_use_tls!==!1,onChange:m=>D({...w,config:{...w.config,smtp_use_tls:m.target.checked,smtp_use_ssl:m.target.checked?!1:w.config.smtp_use_ssl}})}),"STARTTLS(常用于 587)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:w.config.smtp_use_ssl===!0,onChange:m=>D({...w,config:{...w.config,smtp_use_ssl:m.target.checked,smtp_use_tls:m.target.checked?!1:w.config.smtp_use_tls}})}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"通知内容"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"不选择表示接收全部通知;选择后仅接收勾选类型。"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:pa.map(m=>{const g=w.event_types.includes(m.value);return e.jsxs("button",{type:"button",onClick:()=>{const E=g?w.event_types.filter(P=>P!==m.value):[...w.event_types,m.value];D({...w,event_types:E})},className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${g?"border-[#0094f7] bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center ${g?"bg-[#0094f7] border-[#0094f7]":"border-gray-300"}`,children:g&&e.jsx(He,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${g?"text-[#0094f7]":"text-gray-800"}`,children:m.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:m.description})]},m.value)})})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>D({...w,enabled:!w.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${w.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${w.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>S(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"取消"}),e.jsxs("button",{onClick:L,disabled:R,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[R?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),R?"保存中...":"保存"]})]})]})}),document.body),le&&e.jsxs("div",{className:"fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in",style:{background:le.type==="success"?"#10b981":"#ef4444",color:"white"},children:[le.type==="success"?e.jsx(He,{className:"w-4 h-4"}):e.jsx(_e,{className:"w-4 h-4"}),le.text]})]})},ha={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},Bt=Object.fromEntries(Object.entries(ha).map(([s,t])=>[t,s])),zt=()=>ha[window.location.pathname]||"dashboard",Wr=/Win/i.test(navigator.platform||navigator.userAgent),Vr=()=>{const[s,t]=i.useState(!1),[n,d]=i.useState(!1),[x,N]=i.useState(zt),[S,F]=i.useState(!0),[h,R]=i.useState(!1),[b,J]=i.useState(""),[ae,le]=i.useState(""),[oe,k]=i.useState(!1),[B,re]=i.useState(""),[Q,H]=i.useState(),z=D=>{const U=D==="settings"&&!n?"dashboard":D,G=Bt[U];G&&G!==window.location.pathname&&window.history.pushState({},"",G),N(U)};i.useEffect(()=>{const D=()=>N(zt());return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[]),i.useEffect(()=>{la().then(U=>{if((U==null?void 0:U.initialized)===!1){R(!0),t(!1),d(!1);return}R(!1),U!=null&&U.authenticated?(t(!0),d(U.is_admin===!0)):d(!1)}).catch(()=>{t(!1),d(!1)}).finally(()=>F(!1));const D=()=>{t(!1),d(!1)};return window.addEventListener("auth:logout",D),()=>window.removeEventListener("auth:logout",D)},[]),i.useEffect(()=>{!S&&s&&!n&&x==="settings"&&(window.history.replaceState({},"",Bt.dashboard),N("dashboard"))},[S,s,n,x]);const xe=async D=>{D.preventDefault(),k(!0),re("");try{const U=await Ha({username:b,password:ae});U.success?(t(!0),d(U.is_admin===!0)):re(U.message||"登录失败")}catch(U){const G=U instanceof Error?U.message:String(U);re(G||"登录失败")}finally{k(!1)}},ce=async()=>{try{await el()}catch(D){console.error("退出登录失败",D)}finally{t(!1),d(!1)}};if(S)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#f5f5f7]",children:e.jsx(Re,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});if(h)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-xl border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"mx-auto mb-6 flex justify-center",children:e.jsx(et,{sizeClass:"w-24 h-24"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"系统尚未初始化"}),e.jsx("p",{className:"text-gray-600 font-medium",children:"为避免默认口令风险,管理员必须通过服务器本机 CLI 初始化。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-gray-50 border border-gray-100",children:[e.jsx("div",{className:"text-sm font-bold text-gray-900 mb-2",children:"请在服务器上执行:"}),e.jsx("pre",{className:"text-xs bg-black text-white p-4 rounded-2xl overflow-x-auto",children:Wr?'.\\xianyu-server.exe -init-admin -db data\\xianyu_data.db -admin-password "请设置密码"':"./xianyu-server -init-admin -db data/xianyu_data.db -admin-password '请设置密码'"}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"完成后刷新页面即可进入登录。"})]}),e.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group",children:["我已初始化,刷新 ",e.jsx(Xs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-lg border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"group mx-auto mb-6 flex cursor-pointer justify-center",children:e.jsx(et,{sizeClass:"w-24 h-24",logoClassName:"w-full h-full text-white group-hover:scale-110 transition-transform"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"欢迎回来"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Ydisks闲鱼助手 · 自动发货与管家系统"})]}),e.jsxs("form",{onSubmit:xe,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(is,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"text",placeholder:"管理员账号",value:b,onChange:D=>J(D.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Oa,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"密码",value:ae,onChange:D=>le(D.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),B&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(Hs,{className:"w-4 h-4"})," ",B]}),e.jsx("button",{type:"submit",disabled:oe,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:oe?e.jsx(Re,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(Xs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100",children:e.jsx("div",{className:"mt-6 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Ydisks闲鱼助手 v1.0"})})})]})]});const w=()=>{switch(x){case"dashboard":return e.jsx(Qs,{});case"accounts":return e.jsx(jr,{});case"orders":return e.jsx(wr,{});case"cards":return e.jsx(kr,{});case"items":return e.jsx(Lr,{onConfigureDelivery:D=>{H({cookieId:D.cookie_id,itemId:D.item_id,requestId:Date.now()}),z("rules")}});case"rules":return e.jsx(Or,{initialDeliveryTarget:Q,onDeliveryTargetHandled:()=>H(void 0)});case"notifications":return e.jsx(Ur,{isAdmin:n});case"settings":return n?e.jsx($r,{}):e.jsx(Qs,{});default:return e.jsx(Qs,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-[#F4F5F7] text-[#111]",children:[e.jsx(Ja,{activeTab:x,isAdmin:n,onNavigate:z,onLogout:ce}),e.jsxs("main",{className:"flex-1 ml-64 p-8 md:p-12 overflow-y-auto h-screen relative scroll-smooth",children:[e.jsx("div",{className:"fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"}),e.jsx("div",{className:"max-w-[1400px] mx-auto pb-10",children:w()})]})]})},ga=document.getElementById("root");if(!ga)throw new Error("Could not find root element to mount to");const Gr=ba.createRoot(ga);Gr.render(e.jsx(ya.StrictMode,{children:e.jsx(Vr,{})})); diff --git a/internal/webui/static/assets/index-av934L0W.js b/internal/webui/static/assets/index-av934L0W.js new file mode 100644 index 0000000..b1cca1e --- /dev/null +++ b/internal/webui/static/assets/index-av934L0W.js @@ -0,0 +1,19 @@ +import{j as e,r as i,b as Le,c as ba,d as ya}from"./react-vendor-DZnRGM0-.js";import{L as fa,U as Wt,S as Vt,C as Zs,B as Gt,Z as Xs,a as ys,b as it,c as Jt,d as ja,e as cs,A as gt,D as Na,f as bt,P as Kt,g as Ls,E as Qt,T as va,h as wa,i as $e,Q as Us,j as ds,k as ss,l as bs,m as yt,R as Oe,n as Yt,o as _a,p as Je,X as ve,K as ka,q as os,r as rs,s as as,t as ts,u as ft,v as As,w as fs,x as Zt,y as Xt,z as Ss,F as Ht,G as Ca,H as jt,I as Nt,J as Sa,M as La,N as Aa,O as Ia,V as Ws,W as $s,Y as Hs,_ as $a,$ as Ra,a0 as et,a1 as Pa,a2 as Da,a3 as st,a4 as vt,a5 as Fa,a6 as Es,a7 as ea,a8 as Ta,a9 as Ea,aa as ot,ab as sa,ac as Ma,ad as Oa}from"./icons-vendor-RenKjhri.js";import{R as Rs,B as qa,X as wt,Y as _t,T as Vs,a as Ba,C as Gs,A as za,b as Ua,c as Wa,P as kt,d as Ct,L as Va}from"./charts-vendor-B_BfwiL0.js";import"./vendor-w5t2K9ux.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))d(x);new MutationObserver(x=>{for(const w of x)if(w.type==="childList")for(const S of w.addedNodes)S.tagName==="LINK"&&S.rel==="modulepreload"&&d(S)}).observe(document,{childList:!0,subtree:!0});function r(x){const w={};return x.integrity&&(w.integrity=x.integrity),x.referrerPolicy&&(w.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?w.credentials="include":x.crossOrigin==="anonymous"?w.credentials="omit":w.credentials="same-origin",w}function d(x){if(x.ep)return;x.ep=!0;const w=r(x);fetch(x.href,w)}})();const Ga=({className:s="w-full h-full text-white"})=>e.jsx("svg",{className:s,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),tt=({sizeClass:s="w-12 h-12",logoClassName:t="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${s} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0094f7"}),e.jsx("stop",{offset:"100%",stopColor:"#287efe"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),e.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:e.jsx(Ga,{className:t})})]})]}),Ja=({activeTab:s,isAdmin:t=!1,onNavigate:r,onLogout:d})=>{const x=[{id:"dashboard",icon:fa,label:"仪表盘"},{id:"accounts",icon:Wt,label:"账号管理"},{id:"orders",icon:Vt,label:"订单管理"},{id:"cards",icon:Zs,label:"卡密库存"},{id:"items",icon:Gt,label:"商品列表"},{id:"rules",icon:Xs,label:"自动化规则"},{id:"notifications",icon:ys,label:"通知设置"},...t?[{id:"settings",icon:it,label:"系统与AI"}]:[]];return e.jsxs("div",{className:"w-64 h-screen fixed left-0 top-0 bg-white border-r border-gray-100 flex flex-col justify-between z-20 shadow-[4px_0_24px_rgba(0,0,0,0.02)]",children:[e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-12 px-2",children:[e.jsx("div",{className:"shrink-0",children:e.jsx(tt,{sizeClass:"w-10 h-10"})}),e.jsxs("h1",{className:"text-xl font-extrabold tracking-tight text-gray-900",children:["Ydisks闲鱼助手 ",e.jsx("span",{className:"text-xs bg-[#0094f7] text-white px-1.5 py-0.5 rounded ml-1",children:"PRO"})]})]}),e.jsx("nav",{className:"space-y-2",children:x.map(w=>{const S=w.icon,F=s===w.id;return e.jsxs("button",{onClick:()=>r(w.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all duration-300 group relative overflow-hidden ${F?"bg-[#0094f7] text-white font-bold shadow-lg shadow-blue-100 transform scale-[1.02]":"text-gray-500 hover:bg-gray-50 hover:text-gray-900"}`,children:[e.jsx(S,{className:`w-5 h-5 transition-colors ${F?"text-white":"text-gray-400 group-hover:text-gray-600"}`}),e.jsx("span",{className:"text-sm tracking-wide",children:w.label}),F&&e.jsx(Jt,{className:"w-4 h-4 absolute right-3 text-white/30 animate-pulse"})]},w.id)})})]}),e.jsx("div",{className:"p-6 border-t border-gray-50",children:e.jsxs("button",{onClick:d,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-500 hover:text-red-500 hover:bg-red-50 rounded-2xl transition-all duration-200 font-medium",children:[e.jsx(ja,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"退出登录"})]})})]})},Ka=3e4,Qa=10*6e4;let Js=!1;const ta=()=>{Js||typeof window>"u"||(Js=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{Js=!1}))},Ya=s=>{if(!s)return"";const t=new URLSearchParams;for(const[d,x]of Object.entries(s))x!=null&&t.set(d,String(x));const r=t.toString();return r?`?${r}`:""},Os=async(s,t,r={})=>{var R;const d=Ya(r.params),x=`${t}${d}`,w=aa(r.signal,r.timeoutMs??Ka);let S;try{S=await fetch(x,{method:s,credentials:"include",signal:w.signal,headers:{...r.body===void 0?{}:{"Content-Type":"application/json"}},body:r.body===void 0?void 0:JSON.stringify(r.body)})}catch(b){throw w.signal.aborted?new Error((R=r.signal)!=null&&R.aborted?"请求已取消":"请求超时,请稍后重试"):b}finally{w.cleanup()}const g=(S.headers.get("content-type")||"").includes("application/json");if(!S.ok){S.status===401&&!r.skipAuthLogout&&ta();const b=g?await S.json().catch(()=>{}):await S.text().catch(()=>{}),G=typeof b=="string"?b:(b==null?void 0:b.detail)||(b==null?void 0:b.message)||(b==null?void 0:b.msg);throw new Error(G||`请求失败: ${S.status}`)}return g?await S.json():await S.text()},be=async(s,t,r)=>Os("GET",s,{params:t,...r}),ye=async(s,t,r)=>Os("POST",s,{body:t,...r}),De=async(s,t,r)=>Os("PUT",s,{body:t,...r}),Qe=async(s,t,r)=>Os("DELETE",s,{params:t,...r}),Is=async(s,t,r={})=>{var g;const d=aa(r.signal,r.timeoutMs??Qa);let x;try{x=await fetch(s,{method:"POST",credentials:"include",signal:d.signal,body:t})}catch(R){throw d.signal.aborted?new Error((g=r.signal)!=null&&g.aborted?"请求已取消":"上传超时,请稍后重试"):R}finally{d.cleanup()}const F=(x.headers.get("content-type")||"").includes("application/json")?await x.json().catch(()=>{}):await x.text().catch(()=>{});if(!x.ok){x.status===401&&ta();const R=typeof F=="string"?F:(F==null?void 0:F.detail)||(F==null?void 0:F.message)||(F==null?void 0:F.msg),b=new Error(R||"请求失败: "+x.status);throw b.payload=F,b}return F},aa=(s,t)=>{const r=new AbortController,d=()=>r.abort(s==null?void 0:s.reason);s!=null&&s.aborted?d():s==null||s.addEventListener("abort",d,{once:!0});const x=globalThis.setTimeout(()=>r.abort(new DOMException("timeout","TimeoutError")),Math.max(1,t));return{signal:r.signal,cleanup:()=>{globalThis.clearTimeout(x),s==null||s.removeEventListener("abort",d)}}},Ms=s=>{const t=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${t}-${r}-${d}`},ct=(s,t)=>{const r=new Date(s);return r.setHours(12,0,0,0),r.setDate(r.getDate()+t),r},at=(s,t)=>({startDate:Ms(ct(s,-(t-1))),endDate:Ms(s)}),St=(s,t=new Date,r="",d="")=>{if(s==="custom"&&r&&d){if(r>d)throw new Error("开始日期不能晚于结束日期");return{startDate:r,endDate:d}}return s==="yesterday"?at(ct(t,-1),1):at(t,s==="3days"?3:s==="30days"?30:s==="today"?1:7)},Za=s=>{const t=new Date(`${s.startDate}T12:00:00`),r=new Date(`${s.endDate}T12:00:00`),d=Math.round((r.getTime()-t.getTime())/864e5)+1,x=ct(t,-1);return at(x,d)},Xa=s=>{const t={...s};if("renewal_log_retention_days"in t){const r=Number(t.renewal_log_retention_days);t.renewal_log_retention_days=Number.isFinite(r)?r:10}return t},Ha=async s=>ye("/login",s,{skipAuthLogout:!0}),la=async()=>be("/verify"),el=async()=>ye("/logout",{}),sl=async s=>De("/account/credentials",s),tl=(s,t)=>{const r=s.avatar_url||"";if(!r)return"";try{const d=new URL(r,window.location.origin);return d.hostname.endsWith("alicdn.com")&&d.searchParams.set("_v",t),d.toString()}catch{return r}},qs=async s=>{const t=await be("/cookies/details",void 0,s),r=Date.now().toString();return t.map(d=>({id:d.id,value:"",cookie:"",enabled:d.enabled,auto_confirm:d.auto_confirm,remark:d.remark,note:d.remark,pause_duration:d.pause_duration,paused_until:Number(d.paused_until||0),paused:d.paused===!0,username:d.username||"",login_password:"",show_browser:d.show_browser===!0||d.show_browser===1||d.show_browser==="1"||d.show_browser==="true",nickname:d.nickname||d.remark||`账号 ${d.id.substring(0,6)}`,avatar_url:tl(d,r),profile_error:d.profile_error||"",ai_enabled:!1}))},al=async s=>be("/cookies/runtime-status",void 0,s),ll=async s=>ye("/qr-login/generate",void 0,s),rl=async(s,t)=>be(`/qr-login/check/${s}`,void 0,{signal:t,timeoutMs:1e4}),nl=async(s,t)=>ye(`/qr-login/complete-verification/${s}`,{target_account_id:t||""}),il=async(s,t)=>De(`/cookies/${s}/status`,{enabled:t}),ol=async s=>Qe(`/cookies/${s}`),cl=async(s,t)=>De(`/cookies/${s}/pause-duration`,{pause_duration:t}),dl=async(s,t)=>De(`/cookies/${s}/settings`,t),xl=async s=>be(`/cookies/${s}/long-login`),ml=async(s,t)=>De(`/cookies/${s}/long-login`,{enabled:t}),ul=async s=>ye("/password-login",s),pl=async(s,t)=>be(`/password-login/check/${s}`,void 0,{signal:t,timeoutMs:1e4}),hl=async s=>Qe(`/password-login/cancel/${s}`),gl=async s=>ye(`/cookies/${s}/refresh-profile`,{}),bl=async s=>be("/ai-reply-settings",void 0,s),ra=s=>{const t=String(s||"");return t==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(t)?t:"unknown"},yl=async(s,t,r=1,d=20,x)=>{const w={page:r,page_size:d};s&&(w.cookie_id=s),t&&t!=="all"&&(w.status=t),x!=null&&x.trim()&&(w.search=x.trim());const S=await be("/api/orders",w),g=(S.orders||S.data||[]).map(R=>({...R,id:R.id||R.order_id,status:ra(R.status||R.order_status),quantity:Number(R.quantity||1)}));return{success:!0,data:g,total:S.total||g.length,page:S.page||r,page_size:S.page_size||d,total_pages:S.total_pages||1}},fl=async(s,t)=>De(`/api/orders/${s}`,t),jl=async s=>Qe(`/api/orders/${s}`),Nl=async(s,t)=>{const r=new FormData;return s&&r.append("cookie_id",s),t&&r.append("status",t),Is("/api/orders/refresh",r)},vl=async s=>ye(`/api/orders/${s}/refresh`),wl=async(s,t)=>ye("/api/orders/manual-ship",{order_ids:s,ship_mode:t}),_l=async s=>s instanceof FormData?Is("/api/orders/import",s):ye("/api/orders/import",s),kl=async()=>be("/dashboard/stats"),Lt=async(s=7)=>{let t;if(typeof s=="number"){const r=new Date,d=new Date;d.setDate(d.getDate()-s),t={start_date:Ms(d),end_date:Ms(r)}}else t=s;return be("/analytics/orders",{...t,timezone_offset_minutes:-new Date().getTimezoneOffset()})},Cl=async s=>{const t=await be("/analytics/orders/valid",{start_date:s.start_date,end_date:s.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()}),d=(Array.isArray(t)?t:t.orders||[]).map(x=>({...x,id:x.id||x.order_id,status:ra(x.status||x.order_status),quantity:Number(x.quantity||1)}));return{orders:d,total:Array.isArray(t)?d.length:Number(t.total??d.length),truncated:Array.isArray(t)?!1:t.truncated===!0}},Sl=s=>{let t=s.api_config;if(typeof t=="string"&&t.trim())try{t=JSON.parse(t)}catch{t=void 0}return{...s,api_config:t||void 0}},na=s=>({...s,api_config:s.api_config?JSON.stringify(s.api_config):""}),es=async()=>{const s=await be("/cards");return(Array.isArray(s)?s:s.cards||[]).map(Sl)},Ll=async s=>ye("/cards",na(s)),At=async(s,t)=>De(`/cards/${s}`,na(t)),Al=async s=>Qe(`/cards/${s}`),Il=async s=>{const t=new FormData;return t.append("file",s),Is("/cards/batch",t)},$l=async(s,t)=>ye(`/cards/${s}/append-data`,{content:t}),Ks=s=>s===!0||s===1||s==="1",js=async s=>{const t=await be("/items",void 0);return(Array.isArray(t)?t:t.items||[]).map(d=>({...d,id:d.id||`${d.cookie_id}-${d.item_id}`,is_multi_spec:Ks(d.is_multi_spec),is_multi_qty_ship:Ks(d.is_multi_qty_ship??d.multi_quantity_delivery),multi_quantity_delivery:Ks(d.multi_quantity_delivery??d.is_multi_qty_ship)}))},Rl=async s=>ye("/items/get-all-from-account",{cookie_id:s}),Pl=async(s,t)=>Qe(`/items/${s}/${t}`),Dl=async(s,t)=>ye(`/items/${s}`,t),Fl=async s=>{const t=new FormData;t.set("cookie_id",s.cookie_id),t.set("title",s.title),t.set("description",s.description),t.set("price",s.price),t.set("original_price",s.original_price||""),t.set("quantity",String(s.quantity)),t.set("postage_mode",s.postage_mode),t.set("postage",s.postage||"");for(const r of s.images)t.append("images",r);return Is("/items/publish",t)},Tl=async(s,t)=>ye("/items/publish-categories/recommend",{cookie_id:s,keyword:t}),El=async s=>{const t=new FormData;return t.set("file",s.file),s.imagesZip&&t.set("images_zip",s.imagesZip),s.defaultCookieId&&t.set("default_cookie_id",s.defaultCookieId),t.set("fallback_category_id",s.fallbackCategory.catId),t.set("fallback_category_name",s.fallbackCategory.catName),t.set("fallback_channel_category_id",s.fallbackCategory.channelCatId||""),t.set("fallback_tb_category_id",s.fallbackCategory.tbCatId||""),Is("/items/publish-batches/preview",t)},Ml=async s=>ye("/items/publish-batches",{preview_id:s}),hs=async s=>be(`/items/publish-batches/${s}`),It=async(s=20)=>{const t=await be("/items/publish-batches",{limit:s});return Array.isArray(t)?t:t.batches||[]},Ol=async s=>Qe(`/items/publish-batches/${s}`),ql=async s=>ye(`/items/publish-batches/${s}/cancel`,{}),Bl=async s=>ye(`/items/publish-batches/${s}/retry-failed`,{}),zl=async(s,t,r)=>De(`/items/${s}/${t}`,r),ia=s=>s.map(t=>{var r,d;return{id:String(t.id),name:t.name||"",trigger_type:t.trigger_type||"order_paid",item_keyword:t.item_title||t.item_id||"",cookie_id:t.cookie_id||"",item_id:t.item_id||"",item_title:t.item_title||"",card_group_id:Number(((r=(t.actions||[]).find(x=>x.action_type==="send_card"))==null?void 0:r.card_id)||0),card_group_name:((d=(t.actions||[]).find(x=>x.action_type==="send_card"))==null?void 0:d.card_name)||"",priority:t.priority||100,enabled:t.enabled||!1,config_json:t.config_json||"{}",actions:(t.actions||[]).map(x=>({id:x.id?String(x.id):void 0,action_type:x.action_type,card_id:Number(x.card_id||0),card_name:x.card_name||"",delivery_count:Number(x.delivery_count||1),message_template:x.message_template||"",delay_seconds:Number(x.delay_seconds||0),config_json:x.config_json||"{}",enabled:x.enabled!==!1,sort_order:Number(x.sort_order||0)})),variants:(t.actions||[]).filter(x=>x.action_type==="send_card").map(x=>{let w={};try{w=JSON.parse(x.config_json||"{}")}catch{}return{id:x.id?String(x.id):void 0,spec_name:w.spec_name||"",spec_value:w.spec_value||"",card_id:Number(x.card_id||0),card_name:x.card_name||"",delivery_count:Number(x.delivery_count||1),enabled:x.enabled!==!1,delay_override:w.delay_override===!0,delay_seconds:Number(x.delay_seconds||0),config_json:x.config_json||"{}"}})}}),lt=async()=>{const s=await be("/automation-rules"),t=Array.isArray(s)?s:s.data||s.rules||[];return ia(t)},Ul=async({cookieId:s,triggerType:t,enabled:r,search:d,page:x=1,pageSize:w=10}={})=>{const S=await be("/automation-rules",{page:x,page_size:w,cookie_id:s||void 0,trigger_type:t||void 0,enabled:r,search:(d==null?void 0:d.trim())||void 0}),F=ia(Array.isArray(S)?S:S.data||S.rules||[]);return{success:!0,data:F,total:Number(S.total??F.length),page:Number(S.page??x),page_size:Number(S.page_size??w),total_pages:Number(S.total_pages??(F.length?1:0))}},Wl=(s,t)=>{if(s!=="order_paid")return t.map((x,w)=>({...x,sort_order:x.sort_order||w+1}));const r=t.filter(x=>x.action_type==="send_card").map((x,w)=>({...x,sort_order:w+1})),d=t.filter(x=>x.action_type!=="send_card"&&x.action_type!=="confirm_shipment");return[...r,...d.map((x,w)=>({...x,sort_order:r.length+w+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:r.length+d.length+1}]},$t=async s=>{const t=s.trigger_type||"order_paid",d=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[t]||"自动化规则",s.item_title||s.item_id||s.cookie_id||""].filter(Boolean).join(" - "),x=(s.actions||[]).filter(g=>g.action_type!=="send_card"&&g.action_type!=="confirm_shipment"),w=s.variants&&s.variants.length>0?[...s.variants.map((g,R)=>({action_type:"send_card",card_id:g.card_id,delivery_count:g.delivery_count||1,enabled:g.enabled!==!1,sort_order:R+1,delay_seconds:g.delay_seconds||0,config_json:JSON.stringify({spec_name:g.spec_name||"",spec_value:g.spec_value||"",delay_override:g.delay_override===!0})})),...x]:s.actions&&s.actions.length>0?s.actions:[{action_type:"send_card",card_id:s.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],S=Wl(t,w),F={cookie_id:s.cookie_id||"",item_id:s.item_id||"",name:(s.name||"").trim()||d||"自动化规则",trigger_type:t,enabled:s.enabled??!0,priority:s.priority||100,config_json:s.config_json||"{}",actions:S.map((g,R)=>({action_type:g.action_type,card_id:g.card_id||0,delivery_count:g.delivery_count||1,message_template:g.message_template||"",delay_seconds:g.delay_seconds||0,config_json:g.config_json||"{}",enabled:g.enabled!==!1,sort_order:g.sort_order||R+1}))};return s.id?De(`/automation-rules/${s.id}`,F):ye("/automation-rules",F)},Vl=async s=>Qe(`/automation-rules/${s}`),Gl=async()=>{const s=await be("/automation-issues");return{runs:Array.isArray(s==null?void 0:s.runs)?s.runs:[],pending_tasks:Array.isArray(s==null?void 0:s.pending_tasks)?s.pending_tasks:[]}},Jl=async(s,t)=>ye(`/automation-runs/${s}/resolve`,{resolution:t}),Kl=async(s,t)=>ye(`/automation-pending-tasks/${s}/resolve`,{resolution:t}),Ql=s=>({id:String((s==null?void 0:s.id)||""),keyword:(s==null?void 0:s.keyword)||"",reply:(s==null?void 0:s.reply)||"",item_id:(s==null?void 0:s.item_id)||"",type:(s==null?void 0:s.type)==="image"?"image":"text",image_url:(s==null?void 0:s.image_url)||""}),Yl=async s=>{const t=await be(`/keywords-with-type/${s}`);return Array.isArray(t)?t.map(Ql):[]},Zl=async s=>s?(await Yl(s)).map(r=>({id:r.id,keyword:r.keyword||"",reply_content:r.reply||"",match_type:"fuzzy",enabled:!0,item_id:r.item_id||"",type:r.type==="image"?"image":"text",image_url:r.image_url||""})):[],Xl=async(s,t)=>{const r=s.type||"text",d={keyword:s.keyword||"",reply:r==="text"&&s.reply_content||"",item_id:s.item_id||"",type:r,image_url:r==="image"&&s.image_url||""};return s.id?De(`/keywords-with-type/${t}/${s.id}`,d):ye(`/keywords-with-item-id/${t}`,d)},Hl=async(s,t)=>Qe(`/keywords-with-type/${t}/${s}`),oa=async()=>{const s=await be("/system-settings");return Xa(s.data||s)},ca=async s=>{const t=Object.fromEntries(Object.entries(s).filter(([,r])=>r!=null));return De("/system-settings",t)},er=async(s,t)=>be(`/ai-reply-settings/${s}`,void 0,t),sr=async(s,t)=>{const r={ai_enabled:t.ai_enabled??!1,max_discount_percent:t.max_discount_percent??10,max_discount_amount:t.max_discount_amount??100,max_bargain_rounds:t.max_bargain_rounds??3,custom_prompts:t.custom_prompts??""};return De(`/ai-reply-settings/${s}`,r)},tr=async(s,t="")=>(await ye("/ai-models",{base_url:s,api_key:t})).models||[],ar=s=>{if(Array.isArray(s))return s.filter(Boolean);if(typeof s!="string"||!s.trim())return[];try{const t=JSON.parse(s);if(Array.isArray(t))return t.filter(Boolean)}catch{}return s.split(/[,\s;]+/).map(t=>t.trim()).filter(Boolean)},da=s=>{const t=Array.from(new Set((s||[]).filter(Boolean)));return t.length>0?JSON.stringify(t):""},xa=async s=>({success:!0,data:(await be("/notification-channels",void 0,s)||[]).map(d=>{let x;try{x=typeof d.config=="string"?JSON.parse(d.config):d.config}catch{x={}}return{id:String(d.id),name:d.name,type:d.type==="ding_talk"?"dingtalk":d.type==="lark"?"feishu":d.type,config:x,event_types:ar(d.event_types),enabled:d.enabled,created_at:d.created_at,updated_at:d.updated_at}})}),lr=async s=>ye("/notification-channels",{...s,config:JSON.stringify(s.config),event_types:da(s.event_types)}),Rt=async(s,t)=>{const r={...t};return"config"in t&&(r.config=JSON.stringify(t.config)),"event_types"in t&&(r.event_types=da(t.event_types)),De(`/notification-channels/${s}`,r)},rr=async s=>Qe(`/notification-channels/${s}`),nr=async(s,t)=>{const r=await be(`/message-notifications/${s}`,void 0,t);return(r==null?void 0:r.channel_ids)||[]},ir=async s=>ye(`/notification-channels/${s}/test`,{}),Pt=async()=>be("/api/default-replies"),or=async s=>{const t=await be(`/api/default-reply/${s}`);return{cookie_id:s,enabled:t.enabled||!1,reply_content:t.reply_content||"",reply_once:t.reply_once||!1,reply_image_url:t.reply_image_url||""}},cr=async(s,t)=>De(`/api/default-reply/${s}`,{enabled:t.enabled??!1,reply_content:t.reply_content||"",reply_once:t.reply_once??!1,reply_image_url:t.reply_image_url||""}),dr=async s=>Qe(`/api/default-reply/${s}`),xr=async s=>ye(`/api/default-reply/${s}/clear-records`,{}),ws=s=>String(s).padStart(2,"0"),rt=s=>{if(s==null||s==="")return"-";const t=s instanceof Date?s:new Date(s);return Number.isNaN(t.getTime())?"-":[t.getFullYear(),ws(t.getMonth()+1),ws(t.getDate())].join("-")+" "+[ws(t.getHours()),ws(t.getMinutes()),ws(t.getSeconds())].join(":")},mr=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},r={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:r[s]||s})},Ps=({title:s,value:t,icon:r,colorClass:d,trend:x})=>e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col justify-between hover:translate-y-[-4px] transition-all duration-300 h-full relative overflow-hidden group border-0",children:[e.jsx("div",{className:`absolute -right-6 -top-6 w-32 h-32 ${d} opacity-10 rounded-full group-hover:scale-125 transition-transform duration-500 blur-2xl`}),e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`p-4 rounded-2xl ${d} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(r,{className:`w-6 h-6 ${d.replace("bg-","text-")}`})}),x&&e.jsxs("span",{className:"text-xs font-bold text-white bg-[#0094f7] px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(va,{className:"w-3 h-3"})," ",x]})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h3",{className:"text-3xl font-extrabold text-gray-900 tracking-tight font-feature-settings-tnum",children:t}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:s})]})]}),Qs=()=>{var o,D;const[s,t]=i.useState(null),[r,d]=i.useState(null),[x,w]=i.useState(""),[S,F]=i.useState("7days"),[g,R]=i.useState(""),[b,G]=i.useState(""),[se,re]=i.useState(null),[ie,k]=i.useState(""),[B,ne]=i.useState([]),[J,Y]=i.useState(0),[z,xe]=i.useState(!1),[oe,_]=i.useState(!1),[T,U]=i.useState([]),[V,me]=i.useState({}),L=i.useRef(0),A=["#0094f7","#3B82F6","#10B981","#F59E0B","#8B5CF6"],K=async n=>{let y;try{y=St(n,new Date,g,b)}catch(ee){w(ee instanceof Error?ee.message:"日期范围无效");return}const{startDate:E,endDate:C}=y,M={start_date:E,end_date:C},he=Za(y),X=++L.current;_(!0),w("");try{const[ee,Se,Ne]=await Promise.all([Lt(M),Lt({start_date:he.startDate,end_date:he.endDate}),Cl(M)]);if(X!==L.current)return;d(ee),re(Se),ne(Ne.orders),Y(Ne.total),xe(Ne.truncated)}catch(ee){X===L.current&&w(ee instanceof Error?ee.message:"经营数据加载失败")}finally{X===L.current&&_(!1)}},I=()=>{if(!r||!se)return null;const n=r.revenue_stats.total_amount,y=se.revenue_stats.total_amount;if(y===0)return n>0?"+100%":"0%";const E=(n-y)/y*100;return`${E>=0?"+":""}${E.toFixed(1)}%`};if(i.useEffect(()=>{let n=!1;return Promise.all([kl(),js()]).then(([y,E])=>{if(n)return;t(y),U(E);const C={};E.forEach(M=>{C[M.item_id]=M.item_title||M.item_id}),me(C)}).catch(y=>{n||w(y instanceof Error?y.message:"概览加载失败")}),()=>{n=!0}},[]),i.useEffect(()=>{S!=="custom"&&K(S)},[S]),x&&(!s||!r))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(cs,{className:"w-8 h-8"}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:()=>window.location.reload(),children:"重新加载"})]});if(!s||!r)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(gt,{className:"w-8 h-8 animate-spin text-[#0094f7]"})});const ae=((o=r.daily_stats)==null?void 0:o.map(n=>({name:n.date.slice(5),amount:n.amount,orders:n.order_count,avgAmount:n.order_count>0?(n.amount/n.order_count).toFixed(2):0})))||[],we=r.item_stats||[],Ce=r.revenue_stats.total_orders||0,ue=r.revenue_stats.total_amount||0,m=we.length>0?we.map(n=>({name:(V[n.item_id]||n.item_id).length>12?(V[n.item_id]||n.item_id).substring(0,12)+"...":V[n.item_id]||n.item_id,sales:n.order_count})).sort((n,y)=>y.sales-n.sales).slice(0,10):[],h=Math.max(...m.map(n=>n.sales),1),q=we.length>0?we.map(n=>({name:(V[n.item_id]||n.item_id).length>10?(V[n.item_id]||n.item_id).substring(0,10)+"...":V[n.item_id]||n.item_id,value:n.order_count,percent:Ce>0?n.order_count/Ce*100:0})).sort((n,y)=>y.value-n.value).slice(0,6).map((n,y)=>({...n,color:A[y%A.length]})):[],j=we.length>0?we.map(n=>({name:(V[n.item_id]||n.item_id).length>12?(V[n.item_id]||n.item_id).substring(0,12)+"...":V[n.item_id]||n.item_id,value:n.total_amount,orderCount:n.order_count,percentage:ue>0?n.total_amount/ue*100:0})).sort((n,y)=>y.value-n.value).slice(0,5).map((n,y)=>({...n,color:A[y%A.length],percentage:n.percentage.toFixed(1)})):[],te=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],le=((D=te.find(n=>n.key===S))==null?void 0:D.label)||"所选范围";let H;try{H=St(S,new Date,g,b)}catch{H={startDate:g,endDate:b}}const je=ie.trim().toLowerCase(),P=B.filter(n=>{var y,E,C,M;return((y=n.order_id)==null?void 0:y.toLowerCase().includes(je))||((E=n.item_id)==null?void 0:E.toLowerCase().includes(je))||((C=n.item_title)==null?void 0:C.toLowerCase().includes(je))||((M=n.buyer_id)==null?void 0:M.toLowerCase().includes(je))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"运营概览"}),e.jsx("p",{className:"text-gray-500 mt-2 text-base",children:"欢迎回来,以下是闲鱼店铺的实时经营数据。"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-sm font-bold text-gray-700 bg-white px-5 py-2.5 rounded-full shadow-sm border border-gray-100 flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-green-500 rounded-full animate-pulse"}),"系统正常运行"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[te.map(n=>e.jsx("button",{onClick:()=>F(n.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${S===n.key?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:n.label},n.key)),S==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:g,onChange:n=>R(n.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:b,onChange:n=>G(n.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"}),e.jsx("button",{onClick:()=>{try{w(""),K("custom")}catch(n){w(n instanceof Error?n.message:"日期范围无效")}},className:"px-4 py-2 rounded-xl text-sm font-bold bg-black text-white hover:bg-gray-800 transition-colors",children:"应用"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsx(Ps,{title:"累计营收 (CNY)",value:`¥${r.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:Na,colorClass:"bg-blue-400",trend:I()||void 0}),e.jsx(Ps,{title:"活跃账号 / 总数",value:`${s.active_cookies} / ${s.total_cookies}`,icon:Wt,colorClass:"bg-blue-500"}),e.jsx(Ps,{title:"订单数",value:r.revenue_stats.total_orders.toLocaleString(),icon:bt,colorClass:"bg-blue-500"}),e.jsx(Ps,{title:"库存卡密余量",value:s.available_card_stock,icon:Kt,colorClass:"bg-purple-500"})]}),e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[le,"的销售额走势"]})]}),e.jsx("div",{className:"h-[350px] w-full",children:ae.length===0||r.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(bt,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所选时间范围内暂无订单记录"})]}):ae.length<=2?e.jsx(Rs,{width:"100%",height:"100%",children:e.jsxs(qa,{data:ae,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(wt,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#374151",fontSize:14,fontWeight:600},dy:10}),e.jsx(_t,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},tickFormatter:n=>`¥${n}`}),e.jsx(Vs,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{fill:"rgba(0, 148, 247, 0.08)"},formatter:n=>[`¥${Number(n).toFixed(2)}`,"营收"]}),e.jsx(Ba,{dataKey:"amount",fill:"#0094f7",maxBarSize:72,radius:[12,12,0,0],stroke:"#000000",strokeWidth:0,children:ae.map((n,y)=>e.jsx(Gs,{fill:["#0094f7","#FCD34D","#0071e3"][y%3]},`cell-${y}`))})]})}):e.jsx(Rs,{width:"100%",height:"100%",children:e.jsxs(za,{data:ae,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0094f7",stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:"#0094f7",stopOpacity:0})]})}),e.jsx(wt,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500},dy:15}),e.jsx(_t,{axisLine:!1,tickLine:!1,tick:{fill:"#9CA3AF",fontSize:13,fontWeight:500}}),e.jsx(Ua,{vertical:!1,stroke:"#F3F4F6",strokeDasharray:"3 3"}),e.jsx(Vs,{contentStyle:{backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1)",padding:"12px 16px"},labelStyle:{color:"#6b7280",fontWeight:500},itemStyle:{color:"#0094f7",fontWeight:600},cursor:{stroke:"#0094f7",strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(Wa,{type:"monotone",dataKey:"amount",stroke:"#0094f7",strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:"#fff",stroke:"#0094f7",strokeWidth:2}})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品销量排行"}),e.jsx("div",{className:"h-[280px]",children:m.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx("div",{className:"h-full space-y-4 overflow-y-auto pr-2",children:m.map((n,y)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${y<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:y+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:n.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[n.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#0094f7]",style:{width:`${Math.max(8,n.sales/h*100)}%`}})})]},`${n.name}-${y}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"h-[280px]",children:q.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx(Rs,{width:"100%",height:"100%",children:e.jsxs(kt,{children:[e.jsx(Ct,{data:q,cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",label:({name:n,payload:y})=>`${n} ${Number((y==null?void 0:y.percent)||0).toFixed(1)}%`,labelLine:!1,children:q.map((n,y)=>e.jsx(Gs,{fill:n.color},`cell-${y}`))}),e.jsx(Va,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:n=>e.jsx("span",{style:{color:"#6B7280",fontWeight:500},children:n})})]})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-gray-50 flex justify-between items-center bg-[#FAFAFA]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),z&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",B.length," / ",J," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:ie,onChange:n=>k(n.target.value),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:oe?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(gt,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):P.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx(Ls,{className:"w-7 h-7 text-gray-300"})}),je?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"没有匹配的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-md",children:["当前共有 ",B.length," 单参与统计,但没有订单号、商品、买家匹配“",ie,"”。"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"当前范围内没有参与统计的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-lg leading-6",children:["日期范围:",H.startDate," 至 ",H.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",r.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-4",children:"订单信息"}),e.jsx("th",{className:"px-6 py-4",children:"买家信息"}),e.jsx("th",{className:"px-6 py-4",children:"金额"}),e.jsx("th",{className:"px-6 py-4",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:P.map(n=>e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:e.jsx(Ls,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:n.item_title||n.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:n.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",n.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:n.buyer_id}),n.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:rt(n.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",n.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(mr,{status:n.status||n.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${n.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(Qt,{className:"w-4 h-4"})})})]},n.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),j.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-[300px] relative",children:e.jsx(Rs,{width:"100%",height:"100%",children:e.jsxs(kt,{children:[e.jsx(Ct,{data:j,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",label:({name:n,payload:y})=>`${n} ${(y==null?void 0:y.percentage)||"0.0"}%`,children:j.map((n,y)=>e.jsx(Gs,{fill:n.color||A[y%A.length]},`cell-${y}`))}),e.jsx(Vs,{contentStyle:{backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},formatter:n=>`¥${Number(n||0).toLocaleString()}`})]})})}),e.jsx("div",{className:"space-y-3 mt-4",children:j.map(n=>e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:n.color||A[j.indexOf(n)%A.length]}}),e.jsx("span",{className:"text-gray-600 font-medium",children:n.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",n.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[n.percentage,"%"]})]})]},n.name))})]})]})]})]})},ur=(s,t)=>{const r=t.pause_duration||0;return s!==r},pr=(s,t)=>{const r=t.username!==(s.username||""),d=t.show_browser!==(s.show_browser||!1),x=t.login_password!=="",w=t.clear_password===!0;if(!r&&!d&&!x&&!w)return null;const S={username:t.username,show_browser:t.show_browser};return w?S.clear_password=!0:x&&(S.login_password=t.login_password),S},hr=(s,t)=>s&&t,gr=(s,t)=>{if(!s||!t)return!1;const r=Date.parse(s),d=Date.parse(t);return Number.isFinite(r)&&Number.isFinite(d)&&ds.map(r=>{const d=t[r.id];return!d||gr(r.runtime_updated_at,d.updated_at)?r:{...r,runtime_state:d.state,runtime_message:d.message||"",runtime_connected:d.connected,runtime_updated_at:d.updated_at}}),yr=new Set(["expired","cancelled","error","not_found"]),Ds=()=>{let s=0;return{next:()=>(s+=1,s),cancel:()=>{s+=1},isCurrent:t=>t===s}},fr=(s={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let t=null,r=null,d=-1,x=0;const w=()=>{x+=1,r==null||r.abort(),r=null,t!==null&&(s.clearInterval(t),t=null)};return{start:(F,g,R,b=2e3)=>{w();const G=x;r=new AbortController;const se=r.signal;t=s.setInterval(()=>{d===G||G!==x||(d=G,(async()=>{var re,ie;try{const k=await g(F,se);if(k.status==="success"){w(),await R.onSuccess(k);return}if(k.status==="scanned"){(re=R.onScanned)==null||re.call(R,k);return}if(k.status==="verification_required"){(ie=R.onVerificationRequired)==null||ie.call(R,k);return}k.status&&yr.has(k.status)&&(w(),R.onTerminalError(k))}catch(k){if(se.aborted||G!==x)return;w(),R.onPollError(k)}finally{d===G&&(d=-1)}})())},b)},stop:w,isActive:()=>t!==null}},jr=({faceQrUrl:s,verificationScreenshot:t})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(wa,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:s?e.jsx("img",{src:s,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):t?e.jsx("img",{src:t,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx($e,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Dt=({src:s,alt:t,className:r=""})=>e.jsx("img",{src:s,alt:t,className:`block aspect-square h-auto w-full object-contain ${r}`.trim()}),Nr=()=>{const[s,t]=i.useState([]),[r,d]=i.useState(!0),[x,w]=i.useState(""),[S,F]=i.useState(""),[g,R]=i.useState(""),[b,G]=i.useState(null),[se,re]=i.useState(""),[ie,k]=i.useState(!1),[B,ne]=i.useState(""),[J,Y]=i.useState("pending"),[z,xe]=i.useState(""),[oe,_]=i.useState(""),[T,U]=i.useState(null),[V,me]=i.useState(null),[L,A]=i.useState(null),[K,I]=i.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[ae,we]=i.useState([]),[Ce,ue]=i.useState([]),[m,h]=i.useState(!1),[q,j]=i.useState(!1),[te,le]=i.useState(!1),[H,je]=i.useState(""),[P,o]=i.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),[D,n]=i.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[y,E]=i.useState(!1),[C,M]=i.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),he=i.useRef(null),X=i.useRef(null),ee=i.useRef(null),Se=i.useRef(null),Ne=i.useRef(null),We=i.useRef(null),Ie=i.useRef(null),Fe=i.useRef(null),qe=i.useRef(null),Te=i.useRef(null),Ve=i.useRef(null),Ee=i.useRef(null),Re=i.useRef(0);he.current===null&&(he.current=fr()),X.current===null&&(X.current=Ds()),ee.current===null&&(ee.current=Ds()),Se.current===null&&(Se.current=Ds()),Ne.current===null&&(Ne.current=Ds());const Ke=()=>{Ve.current!==null&&(window.clearTimeout(Ve.current),Ve.current=null)},ge=()=>{Ee.current!==null&&(window.clearTimeout(Ee.current),Ee.current=null)},Ae=()=>{var c;(c=he.current)==null||c.stop()},Me=()=>{var c,v;(c=qe.current)==null||c.abort(),(v=X.current)==null||v.cancel(),Ae(),Ke(),k(!1)},u=()=>{Ke(),Ve.current=window.setTimeout(()=>{Ve.current=null,k(!1),$()},1e3)},$=async()=>{var W,a,p,f,O;const c=ee.current.next();(W=We.current)==null||W.abort();const v=new AbortController;We.current=v,d(!0);try{const Q={signal:v.signal},[de,pe]=await Promise.allSettled([qs(Q),bl(Q)]);if(!((a=ee.current)!=null&&a.isCurrent(c)))return;if(de.status==="rejected")throw de.reason;const ke=de.value,fe=pe.status==="fulfilled"?pe.value:{};pe.status==="rejected"&&console.error("Failed to load AI settings:",pe.reason);const zs=ke.map(ps=>{var xt,mt,ut,pt,ht;return{...ps,ai_enabled:((xt=fe[ps.id])==null?void 0:xt.ai_enabled)??!1,max_discount_percent:((mt=fe[ps.id])==null?void 0:mt.max_discount_percent)??10,max_discount_amount:((ut=fe[ps.id])==null?void 0:ut.max_discount_amount)??100,max_bargain_rounds:((pt=fe[ps.id])==null?void 0:pt.max_bargain_rounds)??3,custom_prompts:((ht=fe[ps.id])==null?void 0:ht.custom_prompts)??""}});(p=ee.current)!=null&&p.isCurrent(c)&&t(zs)}catch(Q){(f=ee.current)!=null&&f.isCurrent(c)&&!v.signal.aborted&&console.error("Failed to load accounts:",Q)}finally{(O=ee.current)!=null&&O.isCurrent(c)&&d(!1)}};i.useEffect(()=>{let c=!1,v=null;const W=new AbortController,a=async()=>{try{const p=await al({signal:W.signal,timeoutMs:1e4});c||t(f=>br(f,p))}catch(p){c||console.error("Failed to load account runtime statuses:",p)}finally{c||(v=window.setTimeout(()=>void a(),2e3))}};return $().finally(()=>{c||a()}),()=>{c=!0,W.abort(),v!==null&&window.clearTimeout(v)}},[]),i.useEffect(()=>()=>{var c,v,W,a,p,f,O,Q,de;Ae(),(c=X.current)==null||c.cancel(),(v=ee.current)==null||v.cancel(),(W=Se.current)==null||W.cancel(),(a=Ne.current)==null||a.cancel(),(p=We.current)==null||p.abort(),(f=Ie.current)==null||f.abort(),(O=Fe.current)==null||O.abort(),(Q=qe.current)==null||Q.abort(),(de=Te.current)==null||de.abort(),Ke(),Re.current+=1,ge()},[]);const ce=c=>{if(!c.enabled||c.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(c.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},_e=async(c,v)=>{await il(c,!v),$()},Ye=c=>{g||(re(""),G(c))},Ze=()=>{g||(re(""),G(null))},Xe=async()=>{const c=b;if(!(!c||g)){R(c.id),re("");try{await ol(c.id),t(v=>v.filter(W=>W.id!==c.id)),G(null)}catch(v){console.error("删除账号失败:",v),re((v==null?void 0:v.message)||"删除账号失败,请稍后重试")}finally{R("")}}},Be=async c=>{F(c.id);try{const v=await gl(c.id);v!=null&&v.profile_error&&alert("资料刷新失败:"+v.profile_error),await $()}catch(v){console.error("刷新账号资料失败:",v),alert((v==null?void 0:v.message)||"刷新账号资料失败,请先重新授权该账号")}finally{F("")}},ze=async c=>{var f,O;const v=Se.current.next();(f=Ie.current)==null||f.abort();const W=new AbortController;Ie.current=W,j(!0),h(!1),le(!1),je("");const[a,p]=await Promise.allSettled([xa({signal:W.signal}),nr(c,{signal:W.signal})]);(O=Se.current)!=null&&O.isCurrent(v)&&(a.status==="fulfilled"?we(a.value.data||[]):(we([]),je("通知渠道列表加载失败,请重试")),p.status==="fulfilled"?(ue(p.value||[]),h(!0)):(ue([]),je("通知绑定加载失败;本次保存不会修改现有绑定")),j(!1))},xs=async c=>{var W;Re.current+=1,(W=Te.current)==null||W.abort(),ge(),M({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),A(c),o({remark:c.remark||c.note||"",cookie:c.cookie||c.value||"",auto_confirm:c.auto_confirm||!1,pause_duration:c.pause_duration||0,username:c.username||"",login_password:c.login_password||"",show_browser:c.show_browser||!1,showLoginPassword:!1,clear_password:!1}),me("edit"),I({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,v]=await Promise.allSettled([ze(c.id),xl(c.id)]);v.status==="fulfilled"?I({loading:!1,saving:!1,canOpen:v.value.can_open_long_login,enabled:v.value.enabled,error:""}):I({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"})},He=async()=>{if(!L||K.loading||K.saving||!K.canOpen)return;const c=!K.enabled;I(v=>({...v,saving:!0,error:""}));try{const v=await ml(L.id,c);I({loading:!1,saving:!1,canOpen:v.can_open_long_login,enabled:v.enabled,error:""})}catch(v){I(W=>({...W,saving:!1,error:v instanceof Error?v.message:"保存登录信息设置失败"}))}},ms=async c=>{var a,p,f,O;const v=Ne.current.next();(a=Fe.current)==null||a.abort();const W=new AbortController;Fe.current=W,A(c),me("ai-settings"),E(!0);try{const Q=await er(c.id,{signal:W.signal});if(!((p=Ne.current)!=null&&p.isCurrent(v)))return;n({ai_enabled:Q.ai_enabled??!1,max_discount_percent:Q.max_discount_percent??10,max_discount_amount:Q.max_discount_amount??100,max_bargain_rounds:Q.max_bargain_rounds??3,custom_prompts:Q.custom_prompts??""})}catch(Q){(f=Ne.current)!=null&&f.isCurrent(v)&&console.error("Failed to load AI settings:",Q)}finally{(O=Ne.current)!=null&&O.isCurrent(v)&&E(!1)}},l=async()=>{if(L){E(!0);try{const c={};P.remark!==(L.remark||L.note||"")&&(c.remark=P.remark),P.cookie&&P.cookie!==(L.cookie||L.value||"")&&(c.cookie=P.cookie),P.auto_confirm!==L.auto_confirm&&(c.auto_confirm=P.auto_confirm),ur(P.pause_duration,L)&&(c.pause_duration=P.pause_duration);const v=pr(L,P);v&&Object.assign(c,v),hr(m,te)&&(c.channel_ids=Ce),Object.keys(c).length>0&&await dl(L.id,c),me(null),$()}catch(c){console.error("更新账号失败:",c),alert("更新失败,请重试")}finally{E(!1)}}},N=async()=>{if(!(!L||P.pause_duration<=0)){E(!0);try{const c=await cl(L.id,P.pause_duration);A({...L,pause_duration:P.pause_duration,paused:(c==null?void 0:c.paused)===!0,paused_until:Number((c==null?void 0:c.paused_until)||0)}),await $()}catch(c){alert(c instanceof Error?c.message:"重新暂停失败")}finally{E(!1)}}},Z=async()=>{if(L){E(!0);try{await sr(L.id,D),me(null),$()}catch(c){console.error("更新AI设置失败:",c),alert("更新失败,请重试")}finally{E(!1)}}},Ue=async(c,v)=>{var a;(a=Te.current)==null||a.abort();const W=new AbortController;Te.current=W;try{const p=await pl(c,W.signal);if(v!==Re.current)return;if(p.status==="success"){ge(),M({sessionId:c,status:"success",message:p.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}),o(f=>({...f,login_password:"",showLoginPassword:!1})),await $();return}if(p.status==="processing"||p.status==="verification_required"){M({sessionId:c,status:p.status,message:p.message||(p.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:p.qr_code_url||""}),ge(),Ee.current=window.setTimeout(()=>void Ue(c,v),1500);return}ge(),M({sessionId:c,status:"failed",message:p.error||p.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""})}catch(p){if(v!==Re.current)return;ge(),M({sessionId:c,status:"failed",message:p instanceof Error?p.message:"查询密码登录状态失败",qrCodeUrl:""})}},Ge=async()=>{var W;if(!L)return;const c=P.username.trim();if(!c||!P.login_password){alert("请先填写登录账号和本次登录密码");return}ge(),(W=Te.current)==null||W.abort();const v=++Re.current;M({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const a=await ul({account_id:L.id,account:c,password:P.login_password,show_browser:P.show_browser});if(v!==Re.current)return;if(!a.success||!a.session_id)throw new Error(a.message||"无法启动密码登录");M({sessionId:a.session_id,status:"processing",message:a.message||"登录处理中",qrCodeUrl:""}),await Ue(a.session_id,v)}catch(a){if(v!==Re.current)return;M({sessionId:"",status:"failed",message:a instanceof Error?a.message:"启动密码登录失败",qrCodeUrl:""})}},Pe=async()=>{var v;const c=C.sessionId;if(Re.current+=1,(v=Te.current)==null||v.abort(),ge(),c)try{await hl(c)}catch(W){console.error("取消密码登录失败",W)}M({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},ns=async()=>{var c,v;(c=Se.current)==null||c.cancel(),(v=Ie.current)==null||v.abort(),(C.status==="processing"||C.status==="verification_required")&&await Pe(),me(null)},us=()=>{var c,v;(c=Ne.current)==null||c.cancel(),(v=Fe.current)==null||v.abort(),me(null)},Bs=async(c,v)=>{const W=await nl(c,v==null?void 0:v.id);if(!W.success||!W.account_id)throw new Error(W.message||"保存扫码授权失败");return W.account_id},Ns=async c=>{var p,f,O,Q;Ae(),(p=qe.current)==null||p.abort();const v=new AbortController;qe.current=v;const W=X.current.next();Ke();const a=c||null;U(a),k(!0),Y("loading"),ne(""),xe(""),_("");try{const de=await ll({signal:v.signal});if(!((f=X.current)!=null&&f.isCurrent(W)))return;if(de.success&&de.qr_code_url&&de.session_id){const pe=de.session_id;ne(de.qr_code_url),Y("waiting"),(O=he.current)==null||O.start(pe,rl,{onSuccess:async()=>{try{if(!await Bs(pe,a)){Y("error");return}}catch(ke){console.error("保存扫码授权失败",ke),Y("error");return}Y("success"),u()},onScanned:()=>{Y("waiting")},onTerminalError:()=>{Y("error")},onPollError:ke=>{console.error("轮询扫码状态失败",ke),Y("error")},onVerificationRequired:ke=>{Y("verification"),ke.face_qr_url&&_(ke.face_qr_url),ke.verification_screenshot&&xe(ke.verification_screenshot)}})}}catch{if(!((Q=X.current)!=null&&Q.isCurrent(W)))return;Y("error")}};if(r)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx($e,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});const vs=s.filter(c=>{const v=x.trim().toLowerCase();return v?[c.id,c.nickname,c.remark,c.note,c.username,c.runtime_message].some(W=>(W||"").toLowerCase().includes(v)):!0});return e.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:x,onChange:c=>w(c.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>Ns(),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(Us,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs("div",{className:"font-bold",children:["当前显示 ",vs.length," / ",s.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[vs.map(c=>{const v=ce(c),W=c.runtime_state==="auth_expired"||c.runtime_state==="verification_required";return e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col lg:flex-row lg:items-center justify-between gap-5 group hover:border-[#0094f7] transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-5 sm:gap-8 min-w-0",children:[e.jsxs("div",{className:"relative",children:[c.avatar_url?e.jsx("img",{src:c.avatar_url,alt:c.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(ds,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${v.dot}`,children:c.runtime_state==="online"&&e.jsx(ss,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:c.nickname||c.remark||`账号 ${c.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${v.badge}`,children:v.label}),c.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(bs,{className:"w-3 h-3"})," AI"]}),c.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:c.profile_error,children:[e.jsx(cs,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"text-sm text-gray-500 font-medium mb-3 space-y-1",children:[e.jsx("p",{children:c.remark||c.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",c.id]})]}),c.runtime_message&&c.runtime_state!=="online"&&c.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${W?"text-red-700":"text-amber-700"}`,children:[e.jsx(cs,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:c.runtime_message}),W&&e.jsxs("button",{type:"button",onClick:()=>Ns(c),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(Us,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),e.jsxs("div",{className:"flex gap-2",children:[c.auto_confirm&&e.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[e.jsx(ss,{className:"w-3 h-3"})," 自动确认发货"]}),c.paused&&e.jsxs("span",{className:"text-xs bg-blue-50 text-blue-700 px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5",children:[e.jsx(yt,{className:"w-3 h-3"})," 暂停处理中"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 self-end lg:self-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>Be(c),disabled:S===c.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(Oe,{className:`w-5 h-5 ${S===c.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>Ns(c),className:`p-3 rounded-xl transition-colors ${W?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(Us,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>xs(c),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Yt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>ms(c),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(bs,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>_e(c.id,c.enabled),className:`p-3 rounded-xl transition-colors ${c.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:c.enabled?"停用账号":"启用账号",children:e.jsx(_a,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ye(c),disabled:g!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:g===c.id?"删除中…":`删除账号 ${c.nickname||c.remark||c.id}`,children:g===c.id?e.jsx($e,{className:"w-5 h-5 animate-spin"}):e.jsx(Je,{className:"w-5 h-5"})})]})]},c.id)}),s.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(ds,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),s.length>0&&vs.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),b&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-[0_24px_64px_rgba(15,23,42,0.22)]",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Je,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:Ze,disabled:g!=="",className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(ve,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:b.nickname||b.remark||"未命名账号"}),b.remark&&b.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",b.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",b.id]})]}),g===b.id&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx($e,{className:"h-5 w-5 flex-shrink-0 animate-spin text-[#0094f7]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),se&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(cs,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:se})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:Ze,disabled:g!=="",className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void Xe(),disabled:g!=="",className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:g===b.id?e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),ie&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:Me,className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:T?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:T?`请用闲鱼APP扫码,为「${T.nickname||T.remark||T.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-[#F7F8FA] rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${J==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[J==="loading"&&e.jsx($e,{className:"w-10 h-10 text-[#0094f7] animate-spin"}),J==="waiting"&&e.jsx(Dt,{src:B,alt:"闲鱼登录二维码",className:"p-2"}),J==="success"&&e.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(ss,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),J==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:"请关闭窗口后重新发起扫码登录。"})]}),J==="verification"&&e.jsx(jr,{faceQrUrl:oe,verificationScreenshot:z})]}),J!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),V==="edit"&&L&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:L.nickname||L.remark||L.id})]}),e.jsx("button",{onClick:()=>void ns(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),e.jsx("input",{type:"text",value:L.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),e.jsx("input",{type:"text",value:P.remark,onChange:c=>o({...P,remark:c.target.value}),placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),e.jsx("textarea",{value:P.cookie,onChange:c=>o({...P,cookie:c.target.value}),placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",P.cookie.length," 字符"]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:()=>o({...P,auto_confirm:!P.auto_confirm}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${P.auto_confirm?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${P.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(yt,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:P.pause_duration,onChange:c=>o({...P,pause_duration:parseInt(c.target.value)||0}),placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),P.pause_duration>0&&!L.paused&&P.pause_duration===(L.pause_duration||0)&&e.jsx("button",{type:"button",disabled:y,onClick:()=>void N(),className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",children:"立即按当前时长重新暂停"})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(ka,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),K.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:K.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:K.loading||K.saving||!K.canOpen,onClick:()=>void He(),className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${K.enabled?"bg-[#0094f7]":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${K.enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),e.jsx("input",{type:"text",value:P.username,onChange:c=>o({...P,username:c.target.value}),placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:P.showLoginPassword?"text":"password",value:P.login_password,onChange:c=>o({...P,login_password:c.target.value,clear_password:!1}),placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:()=>o({...P,showLoginPassword:!P.showLoginPassword}),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:P.showLoginPassword?e.jsx(os,{className:"w-5 h-5"}):e.jsx(rs,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:P.clear_password,onChange:c=>o({...P,clear_password:c.target.checked,login_password:c.target.checked?"":P.login_password}),className:"w-4 h-4 accent-[#0094f7]"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),e.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),e.jsx("button",{type:"button",onClick:()=>o({...P,show_browser:!P.show_browser}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${P.show_browser?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${P.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),C.status==="processing"||C.status==="verification_required"?e.jsx("button",{type:"button",onClick:Pe,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:Ge,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),C.message&&e.jsx("div",{className:`text-sm font-medium ${C.status==="failed"?"text-red-700":C.status==="success"?"text-green-700":"text-blue-800"}`,children:C.message}),C.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),C.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Dt,{src:C.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(ae.length>0||q||H)&&e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[e.jsx(ys,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),q&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx($e,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),H&&!q&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:H}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:()=>ze(L.id),children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:ae.map(c=>{const v=Ce.includes(Number(c.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:()=>{m&&(ue(W=>v?W.filter(a=>a!==Number(c.id)):[...W,Number(c.id)]),le(!0))},disabled:!m,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${v?"bg-[#0094f7] border-[#0094f7]":"bg-white border-gray-300"}`,children:v&&e.jsx(ss,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:c.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[c.type,c.enabled?"":" · 已停用"]})]})]},c.id)})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>void ns(),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:y,children:"取消"}),e.jsxs("button",{onClick:l,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:y,children:[y?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(as,{className:"w-4 h-4"}),y?"保存中...":"保存"]})]})})]})}),document.body),V==="ai-settings"&&L&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[e.jsx(bs,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:L.nickname||L.remark||L.id})]}),e.jsx("button",{onClick:us,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(bs,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),e.jsx("button",{type:"button",onClick:()=>n({...D,ai_enabled:!D.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${D.ai_enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${D.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),e.jsx("input",{type:"number",value:D.max_discount_percent,onChange:c=>n({...D,max_discount_percent:parseInt(c.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10 表示最多降价 10%;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),e.jsx("input",{type:"number",value:D.max_discount_amount,onChange:c=>n({...D,max_discount_amount:parseInt(c.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100 表示最多降价 100 元;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),e.jsx("input",{type:"number",value:D.max_bargain_rounds,onChange:c=>n({...D,max_bargain_rounds:parseInt(c.target.value)||1}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),e.jsx("textarea",{value:D.custom_prompts,onChange:c=>n({...D,custom_prompts:c.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... + +例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(it,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:us,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:y,children:"取消"}),e.jsxs("button",{onClick:Z,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:y,children:[y?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(as,{className:"w-4 h-4"}),y?"保存中...":"保存"]})]})})]})}),document.body)]})},vr=s=>({total:Number((s==null?void 0:s.total)||0),success_count:Number((s==null?void 0:s.success_count)||0),failed_count:Number((s==null?void 0:s.failed_count)||0),results:Array.isArray(s==null?void 0:s.results)?s.results.map(t=>({order_id:String((t==null?void 0:t.order_id)||"unknown"),success:(t==null?void 0:t.success)===!0,message:String((t==null?void 0:t.message)||"")})):[]}),wr=s=>(s==null?void 0:s.results.filter(t=>!t.success))||[],Ft=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},r={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:r[s]||s})},_r=()=>{const[s,t]=i.useState([]),[r,d]=i.useState([]),[x,w]=i.useState([]),[S,F]=i.useState({}),[g,R]=i.useState("all"),[b,G]=i.useState(""),[se,re]=i.useState(""),[ie,k]=i.useState(""),B=i.useRef(0),[ne,J]=i.useState(1),[Y,z]=i.useState(1),[xe,oe]=i.useState(!1),[_,T]=i.useState(!1),[U,V]=i.useState(!1),[me,L]=i.useState(!1),[A,K]=i.useState(null),[I,ae]=i.useState(null),[we,Ce]=i.useState({}),[ue,m]=i.useState(!1),[h,q]=i.useState(""),[j,te]=i.useState(!1),[le,H]=i.useState(null),[je,P]=i.useState(null),[o,D]=i.useState(null),[n,y]=i.useState(!1),[E,C]=i.useState(null),[M,he]=i.useState(null),X=async()=>{const u=++B.current;oe(!0);try{const $=await yl(b||void 0,g,ne,20,ie);if(u!==B.current)return;t($.data),z($.total_pages)}catch($){console.error("加载订单失败:",$)}finally{u===B.current&&oe(!1)}},ee=(u,$,ce)=>{if(ce&&ce.trim())return ce;if(S[`${u}:${$}`])return S[`${u}:${$}`];const _e=r.find(Ye=>{if(ce&&Ye.item_title){const Ze=ce.toLowerCase(),Xe=Ye.item_title.toLowerCase();return Xe.includes(Ze)||Ze.includes(Xe)}return!1});return _e!=null&&_e.item_title?_e.item_title:"未知商品"},Se=u=>{const $={};u.forEach(ce=>{ce.item_id&&($[`${ce.cookie_id}:${ce.item_id}`]=ce.item_title||ce.item_id)}),F($)};i.useEffect(()=>{const u=window.setTimeout(()=>{J(1),k(se.trim())},300);return()=>window.clearTimeout(u)},[se]),i.useEffect(()=>{X()},[b,g,ne,ie]),i.useEffect(()=>{Promise.all([qs(),js()]).then(([u,$])=>{w(u),d($),Se($)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const Ne=i.useMemo(()=>new Map(x.map(u=>[u.id,u])),[x]),We=u=>{const $=Ne.get(u),ce=($==null?void 0:$.remark)||($==null?void 0:$.nickname);return ce?`${ce} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},Ie=u=>{const $=Ne.get(u);return($==null?void 0:$.remark)||($==null?void 0:$.nickname)||"未命名账号"},Fe=async()=>{oe(!0);try{const u=await Nl(b||void 0,g);await X(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{oe(!1)}},qe=u=>{q(u),H(null),m(!0)},Te=async u=>{var $;te(!0),H(null);try{const ce=await wl([h],u),_e=($=ce==null?void 0:ce.results)==null?void 0:$[0];_e!=null&&_e.success?(H({success:!0,message:_e.message}),X()):H({success:!1,message:(_e==null?void 0:_e.message)||"发货失败"})}catch(ce){H({success:!1,message:(ce==null?void 0:ce.message)||"请求失败"})}finally{te(!1)}},Ve=u=>{K(u),T(!0)},Ee=u=>{ae({...u}),V(!0)},Re=async()=>{if(!(!I||!I.order_id))try{const u={};I.status!==void 0&&(u.order_status=I.status),I.buyer_id!==void 0&&(u.buyer_id=I.buyer_id),I.amount!==void 0&&(u.amount=I.amount),I.receiver_name!==void 0&&(u.receiver_name=I.receiver_name),I.receiver_phone!==void 0&&(u.receiver_phone=I.receiver_phone),I.receiver_address!==void 0&&(u.receiver_address=I.receiver_address),I.item_id!==void 0&&(u.item_id=I.item_id),I.quantity!==void 0&&(u.quantity=I.quantity),I.item_title!==void 0&&(u.item_title=I.item_title),await fl(I.order_id,u),V(!1),ae(null),X()}catch(u){console.error("更新订单失败:",u),alert("更新失败,请重试")}},Ke=async()=>{if(je){y(!0);try{const u=new FormData;u.append("file",je);const $=vr(await _l(u));D($),P(null),await X(),$.failed_count===0&&(L(!1),D(null),alert(`订单导入成功,共 ${$.success_count} 条`))}catch(u){alert((u==null?void 0:u.message)||"导入失败,请检查文件格式")}finally{y(!1)}}},ge=()=>{n||(L(!1),P(null),D(null))},Ae=async u=>{C(u);try{const $=await vl(u);$.success?await X():alert($.message||"同步失败")}catch($){console.error("同步订单失败:",$),alert(($==null?void 0:$.message)||"同步失败,请重试")}finally{C(null)}},Me=async u=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){he(u);try{await jl(u),s.length===1&&ne>1?J($=>$-1):await X()}catch($){console.error("删除订单失败:",$),alert(($==null?void 0:$.message)||"删除失败,请重试"),await X()}finally{he(null)}}};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:X,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(Oe,{className:`w-5 h-5 ${xe?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{D(null),L(!0)},className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(ts,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:Fe,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(ft,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-[#FAFAFA]",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:[{k:"all",v:"全部"},{k:"processing",v:"处理中"},{k:"shipped",v:"已发货"},{k:"pending_ship",v:"待发货"},{k:"completed",v:"已完成"},{k:"cancelled",v:"已取消"},{k:"refunding",v:"退款中"}].map(u=>e.jsx("button",{onClick:()=>{R(u.k),J(1),re("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${g===u.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:u.v},u.k))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ds,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:b,onChange:u=>{G(u.target.value),J(1)},className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),x.map(u=>e.jsx("option",{value:u.id,children:We(u.id)},u.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(As,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-[#0094f7] transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:se,onChange:u=>{re(u.target.value),J(1)},className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:s.map(u=>e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:u.item_image?e.jsx("img",{src:u.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(Ls,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:ee(u.cookie_id,u.item_id,u.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:Ie(u.cookie_id),children:[e.jsx(ds,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:Ie(u.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",u.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",u.quantity," • ",rt(u.created_at)]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:u.buyer_id}),u.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:u.receiver_name})]}),u.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:u.receiver_phone})]}),u.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:u.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:u.amount?`¥${u.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Ft,{status:u.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[u.status==="pending_ship"&&e.jsx("button",{onClick:()=>qe(u.order_id),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${u.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ve(u),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(rs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ee(u),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(fs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ae(u.order_id),disabled:E===u.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(Oe,{className:`w-4 h-4 ${E===u.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>Me(u.order_id),disabled:M===u.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(Je,{className:"w-4 h-4"})})]})]},u.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",ne," 页 / 共 ",Y," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:ne<=1,onClick:()=>J(u=>u-1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(Zt,{className:"w-5 h-5"})}),e.jsx("button",{disabled:ne>=Y,onClick:()=>J(u=>u+1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(Xt,{className:"w-5 h-5"})})]})]})]}),_&&A&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:()=>T(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:A.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:Ie(A.cookie_id),children:Ie(A.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Ft,{status:A.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:A.amount?`¥${A.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:A.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:rt(A.created_at)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[A.item_image&&e.jsx("img",{src:A.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:ee(A.cookie_id,A.item_id,A.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",A.item_id]}),A.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",A.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:A.buyer_id})]}),A.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:A.receiver_name})]}),A.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:A.receiver_phone})]}),A.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:A.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>T(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),A.status==="pending_ship"&&e.jsx("button",{onClick:()=>{T(!1),qe(A.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),me&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:ge,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:u=>{var $;return P((($=u.target.files)==null?void 0:$[0])||null)},className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),je&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:je.name})]})}),o&&o.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",o.success_count," 条,失败 ",o.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:wr(o).map((u,$)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:u.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:u.message||"导入失败"})]},`${u.order_id}-${$}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:ge,disabled:n,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:Ke,disabled:!je||n,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:n?"正在导入…":"导入订单"})]})})]})}),document.body),ue&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:()=>{m(!1),H(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:()=>Te("status_only"),disabled:j,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(ft,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:()=>Te("full_delivery"),disabled:j,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-[#0094f7] hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ls,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),j&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(Oe,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),le&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${le.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[le.success?"✓ ":"✗ ",le.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{m(!1),H(null)},className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:le!=null&&le.success?"完成":"取消"})})]})}),document.body),U&&I&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:()=>V(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:I.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:I.status,onChange:u=>ae({...I,status:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:I.buyer_id,onChange:u=>ae({...I,buyer_id:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:I.amount,onChange:u=>ae({...I,amount:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:I.receiver_name||"",onChange:u=>ae({...I,receiver_name:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:I.receiver_phone||"",onChange:u=>ae({...I,receiver_phone:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:I.receiver_address||"",onChange:u=>ae({...I,receiver_address:u.target.value}),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:I.item_title||"",onChange:u=>ae({...I,item_title:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>V(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Re,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},kr=(s,t,r)=>{const d=r.trim().toLocaleLowerCase();return s.filter(x=>(!t||x.type===t)&&(!d||x.name.toLocaleLowerCase().includes(d)))},Tt=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),Cr=()=>{const[s,t]=i.useState([]),[r,d]=i.useState(!1),[x,w]=i.useState(!1),[S,F]=i.useState(null),[g,R]=i.useState({}),[b,G]=i.useState(Tt),[se,re]=i.useState(!1),[ie,k]=i.useState("create"),[B,ne]=i.useState(null),[J,Y]=i.useState(null),[z,xe]=i.useState(!1),[oe,_]=i.useState(""),[T,U]=i.useState(""),[V,me]=i.useState(null),[L,A]=i.useState(""),[K,I]=i.useState("");i.useEffect(()=>{es().then(t)},[]);const ae=({type:o})=>{switch(o){case"text":return e.jsx(jt,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Nt,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(Aa,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Zs,{className:"w-5 h-5 text-gray-500"})}},we=o=>{var D,n,y,E,C;F(o),R({id:o.id,name:o.name||"",type:o.type||"text",api_url:((D=o.api_config)==null?void 0:D.url)||"",api_method:((n=o.api_config)==null?void 0:n.method)||"GET",api_timeout:((y=o.api_config)==null?void 0:y.timeout)||10,api_headers:((E=o.api_config)==null?void 0:E.headers)||"",api_params:((C=o.api_config)==null?void 0:C.params)||"",text_content:o.text_content||"",data_content:o.data_content||"",image_url:o.image_url||"",delay_seconds:o.delay_seconds||0,description:o.description||"",enabled:o.enabled}),d(!0)},Ce=async()=>{var o,D,n,y,E,C,M,he;if(S){if(!((o=g.name)!=null&&o.trim())){alert("请输入卡密名称");return}if(!g.type){alert("请选择卡密类型");return}try{const X={name:g.name.trim(),type:g.type,description:(D=g.description)==null?void 0:D.trim(),delay_seconds:g.delay_seconds||0,enabled:g.enabled??!0};g.type==="api"?X.api_config={url:((n=g.api_url)==null?void 0:n.trim())||"",method:g.api_method,timeout:g.api_timeout||10,headers:((y=g.api_headers)==null?void 0:y.trim())||void 0,params:((E=g.api_params)==null?void 0:E.trim())||void 0}:g.type==="text"?X.text_content=((C=g.text_content)==null?void 0:C.trim())||"":g.type==="data"?X.data_content=((M=g.data_content)==null?void 0:M.trim())||"":g.type==="image"&&(X.image_url=((he=g.image_url)==null?void 0:he.trim())||""),await At(S.id,X),d(!1),es().then(t)}catch(X){console.error("更新卡密失败:",X),alert("更新失败,请重试")}}},ue=async o=>{if(confirm("确认删除该卡密吗?"))try{await Al(o),es().then(t)}catch(D){console.error("删除卡密失败:",D),alert("删除失败,请重试")}},m=async()=>{if(!b.name.trim()){alert("请输入卡密名称");return}if(!b.content.trim()){alert(b.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const o={name:b.name.trim(),type:b.type,description:b.description.trim(),enabled:b.enabled,delay_seconds:b.delay_seconds};b.type==="text"&&(o.text_content=b.content.trim()),b.type==="data"&&(o.data_content=b.content.trim()),b.type==="image"&&(o.image_url=b.content.trim()),b.type==="api"&&(o.api_config={url:b.content.trim(),method:b.api_method,timeout:b.api_timeout,headers:b.api_headers.trim()||void 0,params:b.api_params.trim()||void 0}),await Ll(o),w(!1),G(Tt()),es().then(t)}catch(o){console.error("添加卡密失败:",o),alert("添加失败,请重试")}},h=async o=>{try{await At(o.id,{...o,enabled:!o.enabled}),es().then(t)}catch(D){console.error("切换状态失败:",D)}},q=async o=>{try{await navigator.clipboard.writeText(String(o)),alert(`已复制卡密组ID:${o}`)}catch{prompt("复制卡密组ID",String(o))}},j=s.filter(o=>o.type==="data"),te=i.useMemo(()=>kr(s,L,K),[s,K,L]),le=()=>{const n=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 +VIP-MONTH-002 +VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(M=>M.map(he=>`"${String(he).replace(/"/g,'""')}"`).join(",")).join(` +`),y=new Blob(["\uFEFF"+n],{type:"text/csv;charset=utf-8"}),E=URL.createObjectURL(y),C=document.createElement("a");C.href=E,C.download="卡密组批量导入模板.csv",document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(E)},H=async()=>{if(B){xe(!0),Y(null);try{const o=await Il(B);if(Y(o),o.created>0){const D=await es();t(D)}}catch(o){Y({error:(o==null?void 0:o.message)||"上传失败"})}finally{xe(!1)}}},je=async()=>{if(!(!oe||!T.trim())){xe(!0),me(null);try{const o=await $l(oe,T);me({added:o.added}),U("");const D=await es();t(D)}catch(o){alert("追加失败:"+((o==null?void 0:o.message)||"未知错误"))}finally{xe(!1)}}},P=()=>{var o;k("create"),ne(null),Y(null),_((o=j[0])!=null&&o.id?String(j[0].id):""),U(""),me(null),re(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:P,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Ss,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>w(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(ts,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Ht,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:L,onChange:o=>A(o.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(As,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:K,onChange:o=>I(o.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",te.length," / ",s.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:te.map(o=>{let D="";return o.type==="data"&&o.data_content?D=`库存: ${o.data_content.split(` +`).filter(y=>y.trim()).length} 条`:o.type==="text"&&o.text_content?D=o.text_content:o.type==="api"&&o.api_config?D=o.api_config.url:o.type==="image"&&o.image_url&&(D="图片链接"),e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(ae,{type:o.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:o.name,children:o.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>q(o.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:o.id}),e.jsx(Ca,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${o.type==="text"?"bg-blue-50 text-blue-600":o.type==="data"?"bg-purple-50 text-purple-600":o.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:o.type==="text"?"文本":o.type==="data"?"批量":o.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:D,children:D})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:o.description||"-",children:o.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>h(o),className:`w-12 h-8 rounded-full relative transition-colors ${o.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${o.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>we(o),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(fs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ue(o.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Je,{className:"h-4 w-4"})})]})})]},o.id)})})]})}),te.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Kt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:s.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),r&&S&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>d(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g.name||"",onChange:o=>R({...g,name:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:g.type||"text",onChange:o=>R({...g,type:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(S==null?void 0:S.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),g.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:g.api_url||"",onChange:o=>R({...g,api_url:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求方法"}),e.jsxs("select",{value:g.api_method||"GET",onChange:o=>R({...g,api_method:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"超时时间(秒)"}),e.jsx("input",{type:"number",value:g.api_timeout||10,onChange:o=>R({...g,api_timeout:parseInt(o.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"60"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求头(JSON 格式)"}),e.jsx("textarea",{value:g.api_headers||"",onChange:o=>R({...g,api_headers:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"Authorization": "Bearer token"}'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求参数(JSON 格式)"}),e.jsx("textarea",{value:g.api_params||"",onChange:o=>R({...g,api_params:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"type": "card", "count": 1}'})]})]}),g.type==="text"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"固定文字配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"文字内容"}),e.jsx("textarea",{value:g.text_content||"",onChange:o=>R({...g,text_content:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),g.type==="data"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"批量数据配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"数据内容(一行一个)"}),e.jsx("textarea",{value:g.data_content||"",onChange:o=>R({...g,data_content:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: +卡号1:密码1 +卡号2:密码2 +或者 +兑换码1 +兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:g.data_content?g.data_content.split(` +`).filter(o=>o.trim()).length:0})," 条"]})]})]}),g.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:g.image_url||"",onChange:o=>R({...g,image_url:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),g.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:g.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:o=>{o.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g.delay_seconds||0,onChange:o=>R({...g,delay_seconds:parseInt(o.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:g.description||"",onChange:o=>R({...g,description:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>R({...g,enabled:!g.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${g.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${g.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>d(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ce,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),x&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>w(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:b.name,onChange:o=>G({...b,name:o.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>G({...b,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="data"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Zs,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>G({...b,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="text"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(jt,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>G({...b,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="image"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Nt,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:b.type==="data"?"库存内容(一行一个)":b.type==="text"?"固定回复内容":b.type==="image"?"图片 URL":"API 地址"}),b.type==="api"?e.jsx("input",{type:"url",value:b.content,onChange:o=>G({...b,content:o.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):b.type==="image"?e.jsx("input",{type:"url",value:b.content,onChange:o=>G({...b,content:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:b.content,onChange:o=>G({...b,content:o.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${b.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:b.type==="data"?`CODE-123456 +CODE-789012 +...`:"请输入每次发货时发送的固定文字"}),b.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-[#0094f7]",children:b.content.split(` +`).filter(o=>o.trim()).length})," 条"]})]}),b.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:b.api_method,onChange:o=>G({...b,api_method:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:b.api_timeout,onChange:o=>G({...b,api_timeout:parseInt(o.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:b.api_headers,onChange:o=>G({...b,api_headers:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:b.api_params,onChange:o=>G({...b,api_params:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:b.description,onChange:o=>G({...b,description:o.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:b.delay_seconds,onChange:o=>G({...b,delay_seconds:parseInt(o.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:m,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),se&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>re(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>k("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ie==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Sa,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>k("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ie==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Ss,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),ie==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:le,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(La,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx(Ss,{className:"w-4 h-4"}),B?B.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:o=>{var D;return ne(((D=o.target.files)==null?void 0:D[0])||null)}})]})]}),J&&!J.error&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",J.total," 行 · 成功 ",J.created," · 失败 ",J.failed]}),J.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:J.rows.filter(o=>!o.success).map(o=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",o.row_no," 行「",o.name,"」:",o.error]},o.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:j.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:oe,onChange:o=>_(o.target.value),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:j.map(o=>e.jsxs("option",{value:String(o.id),children:[o.name,"(ID: ",o.id,")"]},o.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:T,onChange:o=>U(o.target.value),placeholder:`VIP-001 +VIP-002 +VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),V&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",V.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>re(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),ie==="create"?e.jsxs("button",{onClick:H,disabled:!B||z,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[z?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ss,{className:"w-4 h-4"}),z?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:je,disabled:!oe||!T.trim()||z||j.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[z?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(ts,{className:"w-4 h-4"}),z?"处理中...":"追加卡密"]})]})]})}),document.body)]})},Sr=s=>s.find(t=>t.status==="running"||t.status==="canceling"),Lr=s=>{const t=String(s||"").trim();return t?/^[¥¥]/.test(t)?t:`¥${t}`:"-"},Ar=({onConfigureDelivery:s})=>{const[t,r]=i.useState([]),[d,x]=i.useState([]),[w,S]=i.useState([]),[F,g]=i.useState(""),[R,b]=i.useState(""),[G,se]=i.useState(!1),[re,ie]=i.useState(!1),[k,B]=i.useState(!1),[ne,J]=i.useState(!1),[Y,z]=i.useState(!1),[xe,oe]=i.useState(!1),[_,T]=i.useState(!1),[U,V]=i.useState("upload"),[me,L]=i.useState(null),[A,K]=i.useState(null),[I,ae]=i.useState(""),[we,Ce]=i.useState(!1),[ue,m]=i.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[h,q]=i.useState(null),[j,te]=i.useState(null),[le,H]=i.useState(null),je=i.useRef(!1),[P,o]=i.useState(null),[D,n]=i.useState({}),[y,E]=i.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[C,M]=i.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[he,X]=i.useState([]);i.useEffect(()=>{if(!xe||C.images.length===0){X([]);return}const l=C.images.map((N,Z)=>({key:N.name+Z,url:URL.createObjectURL(N)}));return X(l),()=>{l.forEach(N=>URL.revokeObjectURL(N.url))}},[xe,C.images]);const ee=async()=>{const l=await js();r(l)},Se=async()=>{x(await lt())};i.useEffect(()=>{Promise.all([qs(),js(),lt(),It(20)]).then(([l,N,Z,Ue])=>{S(l),r(N),x(Z);const Ge=Ue.find(Pe=>["running","canceling"].includes(Pe.status))||Ue.find(Pe=>Pe.status!=="preview");H(Ge||null)}).catch(l=>console.error("加载商品配置失败:",l))},[]),i.useEffect(()=>{if(!_||!(j!=null&&j.id)||!["running","canceling"].includes(j.status))return;const l=window.setInterval(async()=>{if(!je.current){je.current=!0;try{const N=await hs(j.id);te(N),H(N),["running","canceling"].includes(N.status)||(V("done"),await ee(),await Se())}catch(N){console.error("刷新批量铺货进度失败:",N)}finally{je.current=!1}}},3e3);return()=>{window.clearInterval(l)}},[_,j==null?void 0:j.id,j==null?void 0:j.status]);const Ne=async()=>{if(!F)return alert("请先选择账号");se(!0);try{const l=await Rl(F);await ee(),alert((l==null?void 0:l.message)||"商品同步完成")}catch(l){console.error("同步商品失败:",l),alert((l==null?void 0:l.message)||"同步失败,请重试")}finally{se(!1)}},We=l=>{o(l),n({...l}),J(!0)},Ie=async()=>{if(P)try{await zl(P.cookie_id,P.item_id,{item_title:D.item_title||"",item_description:D.item_description||"",item_category:D.item_category||"",item_price:D.item_price||"",item_detail:D.item_detail||P.item_detail||""}),await ee(),await Se(),J(!1),o(null)}catch(l){console.error("更新商品失败:",l),alert("更新失败,请重试")}},Fe=async l=>{if(confirm(`确认删除商品"${l.item_title}"吗?`))try{await Pl(l.cookie_id,l.item_id),r(N=>N.filter(Z=>!(Z.cookie_id===l.cookie_id&&Z.item_id===l.item_id)))}catch(N){console.error("删除商品失败:",N),alert("删除失败,请重试")}},qe=async()=>{try{if(!y.cookie_id||!y.item_id){alert("请选择账号并填写商品ID");return}await Dl(y.cookie_id,{item_id:y.item_id,item_title:y.item_title,item_price:y.item_price,item_detail:y.item_image?JSON.stringify({item_image:y.item_image}):""}),await ee(),z(!1),E({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(l){console.error("添加商品失败:",l),alert("添加失败,请重试")}},Te=async()=>{if(!C.cookie_id)return alert("请选择发布账号");if(!C.title.trim())return alert("请填写商品标题");if(!C.price.trim())return alert("请填写商品价格");if(!C.quantity||Number(C.quantity)<=0)return alert("库存数量必须大于 0");if(C.images.length===0)return alert("至少上传 1 张商品图片");if(C.postage_mode==="fixed"&&!C.postage.trim())return alert("请填写一口价邮费");ie(!0);try{const l=await Fl(C);if(await ee(),oe(!1),M({cookie_id:F||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),l!=null&&l.item_id){const N={id:l.item_id,cookie_id:C.cookie_id,item_id:l.item_id,item_title:l.item_title||C.title,item_price:l.item_price||C.price,item_image:l.item_image};s(N),alert("商品发布成功,ID: "+l.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(l){console.error("发布商品失败:",l);const N=l==null?void 0:l.payload;if((N==null?void 0:N.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((l==null?void 0:l.message)||"发布失败,请重试")}finally{ie(!1)}},Ve=async()=>{V("upload"),q(null),te(null),L(null),K(null),ae(""),m({catId:"",catName:"",channelCatId:"",tbCatId:""}),T(!0),B(!0);try{const l=await It(20),N=Sr(l);if(N!=null&&N.id){const Z=await hs(N.id);H(Z),te(Z),V(["running","canceling"].includes(Z.status)?"running":"done")}}catch(l){console.error("恢复最近批量铺货任务失败:",l)}finally{B(!1)}},Ee=async()=>{const l=I.trim();if(!F)return alert("请先选择默认发布账号");if(!l)return alert("请输入类目关键词");Ce(!0);try{const Z=(await Tl(F,l)).category;m({catId:Z.cat_id,catName:Z.cat_name,channelCatId:Z.channel_cat_id,tbCatId:Z.tb_cat_id||""})}catch(N){console.error("获取推荐类目失败:",N),alert((N==null?void 0:N.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{Ce(!1)}},Re=async()=>{if(le!=null&&le.id){B(!0),T(!0);try{const l=await hs(le.id);te(l),V(["running","canceling"].includes(l.status)?"running":"done")}catch(l){console.error("加载最近批量铺货结果失败:",l)}finally{B(!1)}}},Ke=async()=>{if(!me)return alert("请先上传商品表格");if(!F)return alert("请先选择默认发布账号");B(!0);try{const l=await El({file:me,imagesZip:A,defaultCookieId:F,fallbackCategory:ue});q(l),te(null),V("preview")}catch(l){console.error("批量铺货预检失败:",l),alert((l==null?void 0:l.message)||"预检失败,请检查表格和图片 zip")}finally{B(!1)}},ge=async()=>{if(h!=null&&h.preview_id){if(h.valid<=0)return alert("没有可发布的商品行");B(!0);try{const l=await Ml(h.preview_id),N=await hs(l.batch_id||h.preview_id);te(N),H(N),V(N.status==="running"?"running":"done")}catch(l){console.error("启动批量铺货失败:",l),alert((l==null?void 0:l.message)||"启动发布任务失败")}finally{B(!1)}}},Ae=async()=>{if(j!=null&&j.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){B(!0);try{const l=await ql(j.id),N=await hs(j.id);te(N),V((l==null?void 0:l.status)==="canceling"||N.status==="canceling"?"running":"done")}catch(l){alert((l==null?void 0:l.message)||"取消失败")}finally{B(!1)}}},Me=async()=>{const l=h==null?void 0:h.preview_id;if(l&&U==="preview")try{await Ol(l)}catch(N){console.error("清理批量铺货预检失败:",N)}q(null),V("upload")},u=async()=>{await Me(),T(!1)},$=async()=>{if(j!=null&&j.id){B(!0);try{await Bl(j.id),te(await hs(j.id)),V("running")}catch(l){alert((l==null?void 0:l.message)||"重试失败")}finally{B(!1)}}},ce=()=>{const Z=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目ID","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","","","","","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","","","","","否","","否","","否","","",""]]].map(ns=>ns.map(us=>`"${String(us).replace(/"/g,'""')}"`).join(",")).join(` +`),Ue=new Blob(["\uFEFF"+Z],{type:"text/csv;charset=utf-8"}),Ge=URL.createObjectURL(Ue),Pe=document.createElement("a");Pe.href=Ge,Pe.download="批量铺货模板.csv",document.body.appendChild(Pe),Pe.click(),Pe.remove(),URL.revokeObjectURL(Ge)},_e=()=>{E(l=>({...l,cookie_id:F||l.cookie_id})),z(!0)},Ye=()=>{M(l=>({...l,cookie_id:F||l.cookie_id})),oe(!0)},Ze=l=>d.filter(N=>N.cookie_id===l.cookie_id&&N.item_id===l.item_id).length>0?d.filter(N=>N.cookie_id===l.cookie_id&&N.item_id===l.item_id):d.filter(N=>N.cookie_id===l.cookie_id&&!N.item_id),Xe=l=>{switch(l){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return l||"-"}},Be=l=>{switch(l){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},ze=i.useMemo(()=>new Map(w.map(l=>[l.id,l])),[w]),xs=i.useMemo(()=>R?t.filter(l=>l.cookie_id===R):t,[R,t]),He=l=>{const N=ze.get(l),Z=(N==null?void 0:N.remark)||(N==null?void 0:N.nickname);return Z?`${Z} · ${l.slice(0,6)}`:`账号 ${l.slice(0,8)}`},ms=l=>{const N=ze.get(l);return(N==null?void 0:N.remark)||(N==null?void 0:N.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ia,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:R,onChange:l=>b(l.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ds,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:F,onChange:l=>g(l.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]})]}),e.jsxs("button",{onClick:Ne,disabled:G||!F,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Oe,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:_e,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ye,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Ws,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Ve(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx($s,{className:"w-4 h-4"}),le&&["running","canceling"].includes(le.status)?"继续批量任务":"批量铺货"]}),le&&!["running","canceling"].includes(le.status)&&e.jsx("button",{onClick:()=>void Re(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[xs.map(l=>{const N=Ze(l),Z=N.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[e.jsx("button",{onClick:()=>We(l),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-[#0094f7] hover:text-white transition-colors",title:"编辑",children:e.jsx(fs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>Fe(l),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:e.jsx(Je,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[l.item_image?e.jsx("img",{src:l.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(Gt,{className:"w-8 h-8"})}),e.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:Lr(l.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:l.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:ms(l.cookie_id),children:[e.jsx(ds,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:ms(l.cookie_id)})]}),e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[e.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",l.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${Z?"text-emerald-600":"text-amber-600"}`,children:[Z?e.jsx(Hs,{className:"w-3 h-3"}):e.jsx($a,{className:"w-3 h-3"}),Z?`${N.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>s(l),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${Z?"bg-gray-900 text-white hover:bg-black":"bg-[#0094f7] text-white hover:bg-[#0071e3] shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ra,{className:"w-3.5 h-3.5"}),Z?"查看发货规则":"关联发货规则"]}),e.jsx(et,{className:"w-3.5 h-3.5"})]})})]},`${l.cookie_id}-${l.item_id}`)}),xs.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(Vt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),R?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),ne&&P&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",P.item_id]})]}),e.jsx("button",{onClick:()=>J(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:D.item_title||"",onChange:l=>n({...D,item_title:l.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:D.item_price||"",onChange:l=>n({...D,item_price:l.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:D.item_category||"",onChange:l=>n({...D,item_category:l.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:D.item_description||"",onChange:l=>n({...D,item_description:l.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:Ie,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),Y&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),e.jsx("button",{onClick:()=>z(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:y.cookie_id,onChange:l=>E({...y,cookie_id:l.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:y.item_id,onChange:l=>E({...y,item_id:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:y.item_price,onChange:l=>E({...y,item_price:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:y.item_title,onChange:l=>E({...y,item_title:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:y.item_image,onChange:l=>E({...y,item_image:l.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:qe,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),xe&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:()=>oe(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:C.cookie_id,onChange:l=>M({...C,cookie_id:l.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:C.title,onChange:l=>M({...C,title:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:C.quantity,onChange:l=>M({...C,quantity:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:C.description,onChange:l=>M({...C,description:l.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:C.price,onChange:l=>M({...C,price:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:C.original_price,onChange:l=>M({...C,original_price:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:C.postage_mode,onChange:l=>M({...C,postage_mode:l.target.value}),children:[e.jsx("option",{value:"free",children:"包邮"}),e.jsx("option",{value:"distance",children:"按距离计费"}),e.jsx("option",{value:"fixed",children:"一口价邮费"}),e.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),C.postage_mode==="fixed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:C.postage,onChange:l=>M({...C,postage:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),e.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[e.jsx($s,{className:"w-8 h-8 text-emerald-600 mb-2"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:C.images.length?"已选择 "+C.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:l=>M({...C,images:Array.from(l.target.files||[]).slice(0,9)})})]}),he.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:he.map(l=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:l.url,alt:"",className:"w-full h-full object-cover"})},l.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:re,onClick:Te,className:"w-full bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ws,{className:"w-4 h-4"}),re?"正在发布...":"发布到闲鱼"]})})]})}),document.body),_&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),e.jsx("button",{onClick:()=>void u(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]].map(([l,N])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${U===l?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:N},l))}),U==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),e.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",e.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),e.jsx("button",{type:"button",onClick:ce,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:F,onChange:l=>g(l.target.value),children:[e.jsx("option",{value:"",children:"选择账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["默认类目 ",e.jsx("span",{className:"font-medium text-gray-500",children:"(可为空)"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("label",{className:"relative flex-1",children:[e.jsx("span",{className:"sr-only",children:"类目关键词"}),e.jsx(As,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{className:"w-full ios-input rounded-xl bg-white py-2.5 pl-10 pr-3",placeholder:"输入关键词,例如:课程资料、设计素材",value:I,onChange:l=>ae(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),Ee())}})]}),e.jsxs("button",{type:"button",disabled:!F||!I.trim()||we,onClick:()=>void Ee(),className:"ios-btn-primary flex min-h-[42px] items-center justify-center gap-2 rounded-xl px-4 text-sm font-bold disabled:opacity-50",children:[e.jsx(As,{className:"h-4 w-4"}),we?"匹配中...":"获取类目"]})]}),ue.catId?e.jsxs("div",{className:"flex min-h-[46px] items-center justify-between gap-3 border-t border-amber-200 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(Hs,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:ue.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",ue.catId," · 频道 ",ue.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>m({catId:"",catName:"",channelCatId:"",tbCatId:""}),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",children:e.jsx(ve,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[e.jsx($s,{className:"w-9 h-9 text-blue-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:me?me.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:l=>{var N;return L(((N=l.target.files)==null?void 0:N[0])||null)}})]}),e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[e.jsx($s,{className:"w-9 h-9 text-emerald-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:A?A.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:l=>{var N;return K(((N=l.target.files)==null?void 0:N[0])||null)}})]})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[e.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101"}),e.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),e.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),e.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),e.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",e.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"字段"}),e.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),e.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要指定当前行默认类目时填写","必须和“类目名称、频道类目ID”同时填写;优先于自动识别"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","覆盖类目时必填","必须填写闲鱼返回的准确频道类目 ID"],["淘宝类目ID","按闲鱼返回填写","“电子资料”无淘宝类目 ID,保持为空"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([l,N,Z])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:l}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${N==="每个商品都要填"?"text-red-600":N==="可以留空"?"text-gray-500":"text-amber-700"}`,children:N}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:Z})]},l))})]})})]})]}),U==="preview"&&h&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),e.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:h.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),e.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:h.valid})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),e.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:h.invalid})]})]}),e.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"图片"}),e.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:h.rows.map(l=>{var N,Z,Ue,Ge;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:l.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${l.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:l.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:l.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",l.price||"-"," / ",l.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((N=l.category)==null?void 0:N.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((Z=l.category)==null?void 0:Z.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Ue=l.images)==null?void 0:Ue.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((Ge=l.errors)==null?void 0:Ge.join(";"))||"-"})]},l.row_no)})})]})})]}),(U==="running"||U==="done")&&j&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("div",{className:`rounded-2xl p-4 border ${Be(j.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:Xe(j.status)})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),e.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:j.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),e.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:j.success})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),e.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:j.failed})]}),e.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[e.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),e.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:j.pending})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"商品ID"}),e.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:j.rows.map(l=>{var N,Z;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:l.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${Be(l.status)}`,children:Xe(l.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:l.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((N=l.category)==null?void 0:N.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((Z=l.category)==null?void 0:Z.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:l.item_url?e.jsx("a",{href:l.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:l.item_id}):l.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:l.error_message||"-"})]},l.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[U==="upload"&&e.jsxs("button",{disabled:k||!me||!F,onClick:Ke,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Oe,{className:`w-4 h-4 ${k?"animate-spin":""}`}),k?"正在预检...":"开始预检"]}),U==="preview"&&h&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:k,onClick:()=>void Me(),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),e.jsxs("button",{disabled:k||h.valid<=0,onClick:ge,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Ws,{className:"w-4 h-4"}),k?"启动中...":`确认发布 ${h.valid} 个商品`]})]}),(U==="running"||U==="done")&&j&&e.jsxs("div",{className:"flex gap-3 w-full",children:[j.status==="running"?e.jsx("button",{disabled:k,onClick:Ae,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):j.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:()=>window.open(`/items/publish-batches/${j.id}/result.csv`,"_blank"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),j.retryable>0&&!["running","canceling"].includes(j.status)&&e.jsxs("button",{disabled:k,onClick:$,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Oe,{className:`w-4 h-4 ${k?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(j.status)&&e.jsx("button",{onClick:()=>{T(!1),ee(),Se()},className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})},Et="https://dashscope.aliyuncs.com/compatible-mode/v1",Ir=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],$r=new Set(["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),Rr=()=>{const[s,t]=i.useState(null),[r,d]=i.useState(!1),[x,w]=i.useState(""),[S,F]=i.useState(!1),[g,R]=i.useState([]),[b,G]=i.useState(!1),[se,re]=i.useState(""),[ie,k]=i.useState(!1),B=i.useRef(null),[ne,J]=i.useState(!1),[Y,z]=i.useState(!1),[xe,oe]=i.useState(!1),[_,T]=i.useState(!1),[U,V]=i.useState(!1),[me,L]=i.useState(null),[A,K]=i.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});i.useEffect(()=>{ae(),la().then(h=>{h.username&&K(q=>({...q,new_username:h.username||""}))}).catch(()=>{})},[]),i.useEffect(()=>{const h=q=>{var j;(j=B.current)!=null&&j.contains(q.target)||k(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const I=async(h,q=!1)=>{const j=h||s,te=(j==null?void 0:j.ai_api_url)||(j==null?void 0:j.ai_base_url)||Et;G(!0),re("");try{const le=await tr(te,(j==null?void 0:j.ai_api_key)||"");R(le),k(q&&le.length>0),!(j!=null&&j.ai_model)&&le.length>0&&t(H=>H&&{...H,ai_model:le[0]})}catch(le){R([]),k(!1),re(le.message||"读取模型失败")}finally{G(!1)}},ae=()=>{d(!0),w(""),oa().then(h=>{t(h),I(h)}).catch(h=>{t(null),w(h.message||"加载配置失败")}).finally(()=>d(!1))},we=async()=>{if(s){F(!0);try{const h=Object.fromEntries(Object.entries(s).filter(([q,j])=>!$r.has(q)&&j!==void 0&&j!==null));await ca(h),alert("系统配置已保存")}catch(h){alert("保存失败:"+h.message)}finally{F(!1)}}},Ce=async h=>{h.preventDefault(),L(null);const q=A.new_username.trim();if(q.length<3){L({type:"error",text:"用户名至少需要 3 个字符"});return}if(!A.current_password){L({type:"error",text:"请输入当前密码确认身份"});return}if(A.new_password&&A.new_password.length<8){L({type:"error",text:"新密码至少需要 8 个字符"});return}if(A.new_password!==A.confirm_password){L({type:"error",text:"两次输入的新密码不一致"});return}V(!0);try{const j=await sl({current_password:A.current_password,new_username:q,new_password:A.new_password||void 0});if(!j.success){L({type:"error",text:j.message||"登录凭据更新失败"});return}L({type:"success",text:j.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(j){L({type:"error",text:j.message||"登录凭据更新失败"})}finally{V(!1)}};if(!s)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:x||(r?"加载配置中...":"暂无配置")});const ue=s.ai_model||"",m=g;return e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-fade-in pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-2xl flex items-center justify-center",children:e.jsx(it,{className:"w-6 h-6 text-gray-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900",children:"系统设置"}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"配置全局自动化规则与系统参数"})]})]}),e.jsxs("button",{onClick:ae,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Oe,{className:"w-4 h-4"}),"刷新"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-100 text-gray-600",children:e.jsx(Pa,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:s.log_level||"info",onChange:h=>t({...s,log_level:h.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:Ir.map(h=>e.jsx("option",{value:h.value,children:h.label},h.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:s.log_format||"text",onChange:h=>t({...s,log_format:h.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:s.renewal_log_retention_days??10,onChange:h=>t({...s,renewal_log_retention_days:parseInt(h.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"365"}),e.jsx("p",{className:"text-xs text-gray-500",children:"0 表示不自动清理续期日志"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-[#0094f7] text-white",children:e.jsx(Jt,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:s.ai_api_url||Et,onChange:h=>t({...s,ai_api_url:h.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://api.openai.com/v1"}),e.jsx("p",{className:"text-xs text-gray-500",children:"无需补全 /chat/completions"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ne?"text":"password",value:s.ai_api_key||"",onChange:h=>t({...s,ai_api_key:h.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:"sk-..."}),e.jsx("button",{type:"button",onClick:()=>J(!ne),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:ne?e.jsx(os,{className:"w-4 h-4"}):e.jsx(rs,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"模型"}),e.jsxs("div",{ref:B,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:ue,onFocus:()=>g.length>0&&k(!0),onChange:h=>{t({...s,ai_model:h.target.value}),g.length>0&&k(!0)},onKeyDown:h=>{h.key==="Escape"&&k(!1),h.key==="ArrowDown"&&g.length>0&&k(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>g.length>0&&k(h=>!h),disabled:g.length===0,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 disabled:opacity-30","aria-label":"展开模型列表",children:e.jsx(Da,{className:`w-4 h-4 transition-transform ${ie?"rotate-180":""}`})}),ie&&e.jsx("div",{className:"absolute left-0 right-0 top-[calc(100%+6px)] z-40 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-xl shadow-gray-200/70 py-1",children:m.length>0?m.map(h=>e.jsxs("button",{type:"button",onClick:()=>{t({...s,ai_model:h}),k(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-[#0094f7] flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:h}),h===ue&&e.jsx(ss,{className:"w-4 h-4 shrink-0 text-[#0094f7]"})]},h)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>I(void 0,!0),disabled:b,className:"px-4 py-3 rounded-xl bg-gray-100 text-gray-700 hover:bg-gray-200 disabled:opacity-60 font-bold flex items-center justify-center gap-2 whitespace-nowrap",children:[e.jsx(Oe,{className:`w-4 h-4 ${b?"animate-spin":""}`}),"读取模型"]})]}),se?e.jsx("p",{className:"text-xs text-red-500",children:se}):e.jsx("p",{className:"text-xs text-gray-500",children:g.length>0?`已从当前 API 地址读取到 ${g.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),e.jsxs("div",{className:"p-3 bg-blue-50 rounded-xl text-xs text-blue-700",children:[e.jsx("strong",{children:"常见 AI 服务:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5",children:[e.jsx("li",{children:"阿里云通义千问: https://dashscope.aliyuncs.com/compatible-mode/v1"}),e.jsx("li",{children:"OpenAI: https://api.openai.com/v1"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-amber-500 text-white",children:e.jsx(st,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务地址"}),e.jsx("input",{type:"url",value:s["captcha.remote_service_url"]||"",onChange:h=>t({...s,"captcha.remote_service_url":h.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://example.com/internal/captcha/solve"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务秘钥"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:Y?"text":"password",value:s["captcha.remote_secret_key"]||"",onChange:h=>t({...s,"captcha.remote_secret_key":h.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>z(!Y),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:Y?"隐藏秘钥":"显示秘钥",children:Y?e.jsx(os,{className:"w-4 h-4"}):e.jsx(rs,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(s["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:h=>t({...s,"captcha.remote_pass_cookies":h.target.checked}),className:"mt-0.5 w-4 h-4 rounded border-gray-300"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-bold text-amber-900",children:"允许向远程服务传递账号 Cookie"}),e.jsx("span",{className:"block mt-1 text-xs text-amber-700",children:"默认关闭。仅在信任远程服务且需要由其自动重取过期验证链接时开启。"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"配置地址和秘钥后优先调用远程服务;只有网络不可用或超时才回退本机引擎,远程明确返回失败时不会重复触发本机验证。"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-900 text-white",children:e.jsx(vt,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:Ce,className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"登录用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fa,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:A.new_username,onChange:h=>K({...A,new_username:h.target.value}),className:"w-full ios-input pl-11 pr-4 py-3 rounded-xl text-sm",autoComplete:"username"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"当前密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:xe?"text":"password",value:A.current_password,onChange:h=>K({...A,current_password:h.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm",placeholder:"用于确认当前身份",autoComplete:"current-password"}),e.jsx("button",{type:"button",onClick:()=>oe(!xe),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:xe?"隐藏密码":"显示密码",children:xe?e.jsx(os,{className:"w-4 h-4"}):e.jsx(rs,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"新密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:_?"text":"password",value:A.new_password,onChange:h=>K({...A,new_password:h.target.value}),className:"w-full ios-input px-4 py-3 pr-11 rounded-xl text-sm",placeholder:"不修改则留空",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>T(!_),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:_?"隐藏密码":"显示密码",children:_?e.jsx(os,{className:"w-4 h-4"}):e.jsx(rs,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"确认新密码"}),e.jsx("input",{type:_?"text":"password",value:A.confirm_password,onChange:h=>K({...A,confirm_password:h.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),me&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${me.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(st,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:me.text})]}),e.jsxs("button",{type:"submit",disabled:U||!A.new_username||!A.current_password,className:"w-full bg-gray-900 hover:bg-black text-white px-5 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 transition-colors disabled:opacity-40",children:[e.jsx(vt,{className:"w-4 h-4"}),U?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:we,disabled:S,className:"ios-btn-primary px-10 py-5 rounded-xl text-lg shadow-2xl shadow-blue-200 flex items-center gap-3 transform hover:scale-105 active:scale-95 transition-all disabled:opacity-70",children:[e.jsx(as,{className:"w-6 h-6"}),S?"保存中...":"保存所有配置"]})})]})},Ys=(s,t)=>s.allowed_resolutions.includes(t),Pr=(s,t)=>({runs:s.runs.filter(r=>!t||r.cookie_id===t),pending_tasks:s.pending_tasks.filter(r=>!t||r.cookie_id===t)}),Dr=s=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[s]||"自动化异常",Fr=(s,t,r,d,x,w)=>s!==t||r!==d?!1:(w(x),!0),ls={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Ls},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:Ta},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:ea}},Fs=["order_paid","buyer_reviewed","review_missing_timeout"],Tr="亲,商品使用满意的话,麻烦给个评价,谢谢~",_s=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),ma=s=>{if(!s)return{};try{const t=JSON.parse(s);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}},is=(s,t={})=>{const r=ma(s);return JSON.stringify({after_shipped_hours:Number(r.after_shipped_hours||72),repeat_interval_hours:Number(r.repeat_interval_hours||24),max_attempts:Number(r.max_attempts||1),...t})},ks=(s,t)=>{var d;const r=((d=ls[s])==null?void 0:d.label)||"自动化规则";return t?`${r} - ${t}`:r},Mt=s=>{const t=(s||"").trim();return t?Object.values(ls).some(r=>t===r.label||t.startsWith(`${r.label} -`)):!0},Cs=(s,t=0)=>{if(s==="review_missing_timeout")return[{action_type:"send_text",message_template:Tr,enabled:!0,sort_order:1}];const r={action_type:"send_card",card_id:t,delivery_count:1,enabled:!0,sort_order:1};return s==="order_paid"?[r,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[r]},Er=s=>{var r,d;if(s.trigger_type==="review_missing_timeout")return((d=(r=s.actions)==null?void 0:r.find(x=>x.action_type==="send_text"))==null?void 0:d.message_template)||"发送求评价文案";const t=(s.actions||[]).filter(x=>x.action_type==="send_card");return t.length?t.map(x=>x.card_name||`卡密 ${x.card_id}`).join(" / "):"未配置卡密库存"},Ot=(s,t=!1)=>{const r={blue:t?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:t?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:t?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return r[s]||r.blue},Mr=s=>s?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Ts=s=>(s==null?void 0:s.nickname)||(s==null?void 0:s.remark)||(s==null?void 0:s.id)||"未知账号",Or=s=>s===!0||s===1||s==="1",qr=({initialDeliveryTarget:s,onDeliveryTargetHandled:t})=>{var c,v,W;const[r,d]=i.useState("automation"),[x,w]=i.useState([]),[S,F]=i.useState({runs:[],pending_tasks:[]}),[g,R]=i.useState([]),[b,G]=i.useState({}),[se,re]=i.useState([]),[ie,k]=i.useState([]),[B,ne]=i.useState([]),[J,Y]=i.useState(!1),[z,xe]=i.useState(""),[oe,_]=i.useState(""),[T,U]=i.useState(""),[V,me]=i.useState(""),[L,A]=i.useState("all"),[K,I]=i.useState(1),[ae,we]=i.useState(10),[Ce,ue]=i.useState(0),[m,h]=i.useState(0),q=i.useRef(0),j=i.useRef(0),te=i.useRef("");te.current=z;const[le,H]=i.useState(!1),[je,P]=i.useState(!1),[o,D]=i.useState(!1),[n,y]=i.useState(null),[E,C]=i.useState(null),[M,he]=i.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});se.find(a=>a.id===z);const X=i.useCallback(async()=>{const[a,p,f,O]=await Promise.all([qs(),es(),js(),Pt()]);re(a),k(p),ne(f),G(O),xe(Q=>{var de;return Q||((de=a[0])==null?void 0:de.id)||""})},[]),ee=i.useCallback(async()=>{const a=++q.current,p=Gl().catch(Q=>(console.warn("加载自动化异常列表失败,不阻断规则展示",Q),null)),f=await Ul({cookieId:z||void 0,triggerType:V,enabled:L==="all"?void 0:L==="enabled",search:T,page:K,pageSize:ae});if(a!==q.current)return;w(f.data),ue(f.total),h(f.total_pages),f.page!==K&&I(f.page);const O=await p;a===q.current&&O&&F(O)},[K,ae,L,V,T,z]),Se=i.useCallback(async()=>{const a=z;if(a!==te.current)return;const p=++j.current;if(R([]),!a)return;const f=await Zl(a);Fr(p,j.current,a,te.current,f,R)},[z]),Ne=i.useCallback(async()=>{G(await Pt())},[]),We=i.useCallback(async()=>{Y(!0);try{r==="automation"?await ee():r==="reply"?await Se():await Ne()}finally{Y(!1)}},[r,ee,Ne,Se]);i.useEffect(()=>{const a=window.setTimeout(()=>{I(1),U(oe.trim())},300);return()=>window.clearTimeout(a)},[oe]),i.useEffect(()=>{X().catch(a=>console.error("加载规则参考数据失败",a))},[X]),i.useEffect(()=>{We().catch(a=>console.error("刷新规则页面失败",a))},[We]);const Ie=i.useMemo(()=>x.filter(a=>!z||a.cookie_id===z),[x,z]),Fe=i.useMemo(()=>Pr(S,z),[S,z]),qe=i.useMemo(()=>se.filter(a=>!z||a.id===z),[se,z]),Te=i.useMemo(()=>{var p;const a={order_paid:[],buyer_reviewed:[],review_missing_timeout:[]};for(const f of Ie)(p=a[f.trigger_type])==null||p.push(f);return a},[Ie]),Ve=i.useMemo(()=>{if(m<=1)return[];const a=Math.max(1,Math.min(K-2,m-4)),p=Math.min(m,a+4);return Array.from({length:p-a+1},(f,O)=>a+O)},[K,m]),Ee=!!(oe.trim()||V||L!=="all"),Re=()=>{_(""),U(""),me(""),A("all"),I(1)},Ke=i.useMemo(()=>{const a=(n==null?void 0:n.cookie_id)||z;return B.filter(p=>p.cookie_id===a)},[n==null?void 0:n.cookie_id,B,z]),ge=i.useMemo(()=>{if(!(!(n!=null&&n.cookie_id)||!(n!=null&&n.item_id)))return B.find(a=>a.cookie_id===n.cookie_id&&a.item_id===n.item_id)},[n==null?void 0:n.cookie_id,n==null?void 0:n.item_id,B]),Ae=Or(ge==null?void 0:ge.is_multi_spec),Me=(n==null?void 0:n.trigger_type)||"order_paid",u=ls[Me],$=ma(n==null?void 0:n.config_json),ce=i.useCallback((a="order_paid",p=z,f="")=>{const O=B.find(de=>de.cookie_id===p&&de.item_id===f),Q=(O==null?void 0:O.item_title)||f;return{name:ks(a,Q),trigger_type:a,cookie_id:p,item_id:f,item_title:(O==null?void 0:O.item_title)||"",item_keyword:Q,card_group_id:0,priority:100,enabled:!0,config_json:a==="review_missing_timeout"?is():"{}",actions:Cs(a),variants:a==="review_missing_timeout"?[]:[_s()]}},[B,z]),_e=i.useCallback(a=>{var f,O;const p=a.trigger_type||"order_paid";y({...a,trigger_type:p,config_json:p==="review_missing_timeout"?is(a.config_json):a.config_json||"{}",actions:(f=a.actions)!=null&&f.length?a.actions.map(Q=>({...Q})):Cs(p,a.card_group_id),variants:(O=a.variants)!=null&&O.length?a.variants.map(Q=>({...Q})):p==="review_missing_timeout"?[]:[_s()]}),H(!0)},[]);i.useEffect(()=>{if(!s)return;let a=!1;return(async()=>{d("automation"),xe(s.cookieId),Y(!0);try{const[f,O,Q]=await Promise.all([lt(),js(),es().catch(pe=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",pe),[]))]);if(a)return;w(f),ne(O),k(Q);const de=f.find(pe=>pe.cookie_id===s.cookieId&&pe.item_id===s.itemId&&pe.trigger_type==="order_paid");if(de)_e(de);else{const pe=O.find(ke=>ke.cookie_id===s.cookieId&&ke.item_id===s.itemId);y({...ce("order_paid",s.cookieId,s.itemId),item_title:(pe==null?void 0:pe.item_title)||"",item_keyword:(pe==null?void 0:pe.item_title)||s.itemId,name:ks("order_paid",(pe==null?void 0:pe.item_title)||s.itemId)}),H(!0)}}catch(f){console.error("打开商品自动化规则失败",f),alert("无法加载该商品的自动化规则")}finally{a||(Y(!1),t==null||t())}})(),()=>{a=!0}},[ce,s,t,_e]);const Ye=(a="order_paid")=>{if(!z){alert("请先选择账号");return}y(ce(a)),H(!0)},Ze=a=>{var O,Q,de,pe,ke;if(!n)return;const p=((Q=(O=n.variants)==null?void 0:O.find(fe=>fe.card_id))==null?void 0:Q.card_id)||((pe=(de=n.actions)==null?void 0:de.find(fe=>fe.action_type==="send_card"))==null?void 0:pe.card_id)||n.card_group_id||0,f=(ge==null?void 0:ge.item_title)||n.item_title||n.item_id||"";y({...n,trigger_type:a,name:Mt(n.name)?ks(a,f):n.name,card_group_id:p,config_json:a==="review_missing_timeout"?is(n.config_json):"{}",actions:Cs(a,p),variants:a==="review_missing_timeout"?[]:(ke=n.variants)!=null&&ke.length?n.variants:[{..._s(),card_id:p}]})},Xe=a=>{if(!n)return;const p=B.find(O=>O.cookie_id===(n.cookie_id||z)&&O.item_id===a),f=(p==null?void 0:p.item_title)||a;y({...n,item_id:a,item_title:(p==null?void 0:p.item_title)||"",item_keyword:f,name:Mt(n.name)?ks(Me,f):n.name})},Be=(c=n==null?void 0:n.variants)!=null&&c.length?n.variants:[_s()],ze=(a,p)=>{var O;if(!n)return;const f=Be.map((Q,de)=>de===a?{...Q,...p}:Q);y({...n,variants:f,card_group_id:((O=f[0])==null?void 0:O.card_id)||0})},xs=()=>{if(!n)return;const a=Be[Be.length-1];y({...n,variants:[...Be,{..._s(),spec_name:Ae&&(a==null?void 0:a.spec_name)||"",spec_value:Ae&&(a==null?void 0:a.spec_value)||""}]})},He=async()=>{var O,Q,de,pe,ke;if(!n)return;const a=n.trigger_type||"order_paid";if(!n.cookie_id){alert("请选择账号");return}const p=(O=n.variants)!=null&&O.length?n.variants:[];if(a!=="review_missing_timeout"){if(!p.length||p.some(fe=>!fe.card_id)){alert(a==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(Ae&&p.some(fe=>!fe.spec_name.trim()||!fe.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(a==="review_missing_timeout"&&!(((de=(Q=n.actions)==null?void 0:Q.find(zs=>zs.action_type==="send_text"))==null?void 0:de.message_template)||"").trim()){alert("请填写求评价文案");return}const f=a==="review_missing_timeout"?[]:p.map(fe=>({...fe,spec_name:Ae?fe.spec_name.trim():"",spec_value:Ae?fe.spec_value.trim():"",delivery_count:Math.max(1,Number(fe.delivery_count)||1),enabled:fe.enabled!==!1}));try{await $t({...n,trigger_type:a,name:(n.name||"").trim()||ks(a,(ge==null?void 0:ge.item_title)||n.item_id||""),config_json:a==="review_missing_timeout"?is(n.config_json):n.config_json||"{}",actions:(pe=n.actions)!=null&&pe.length?n.actions:Cs(a,((ke=f[0])==null?void 0:ke.card_id)||n.card_group_id||0),variants:f}),H(!1),await Promise.all([ee(),X()]),alert("保存成功")}catch(fe){console.error("保存自动化规则失败:",fe),alert("保存失败:"+fe.message)}},ms=async a=>{if(confirm("确定删除该自动化规则吗?"))try{await Vl(a),await ee(),alert("删除成功")}catch(p){alert("删除失败:"+p.message)}},l=async a=>{try{await $t({...a,enabled:!a.enabled}),await ee()}catch(p){alert("操作失败:"+p.message)}},N=async(a,p)=>{if(confirm(p==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":p==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Jl(a,p),await ee()}catch(O){alert("处理失败:"+O.message)}},Z=async(a,p)=>{if(confirm(p==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Kl(a,p),await ee()}catch(f){alert("处理失败:"+f.message)}},Ue=()=>{if(!z){alert("请先选择账号");return}C({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),P(!0)},Ge=async()=>{var p,f,O;if(!E||!z)return;const a=E.type==="image"?!!((p=E.image_url)!=null&&p.trim()):!!((f=E.reply_content)!=null&&f.trim());if(!((O=E.keyword)!=null&&O.trim())||!a){alert("请填写关键词和回复内容");return}try{await Xl({...E,match_type:"fuzzy",enabled:!0},z),P(!1),await Se(),alert("保存成功")}catch(Q){alert("保存失败:"+Q.message)}},Pe=async a=>{if(!(!z||!confirm("确定删除该回复规则吗?")))try{await Hl(a,z),await Se(),alert("删除成功")}catch(p){alert("删除失败:"+p.message)}},ns=async(a=z)=>{if(!a){alert("请先选择账号");return}try{const p=await or(a);he({cookie_id:a,enabled:p.enabled,reply_content:p.reply_content,reply_once:p.reply_once,reply_image_url:p.reply_image_url||""})}catch{he({cookie_id:a,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}D(!0)},us=async()=>{if(!M.cookie_id){alert("请先选择账号");return}if(M.enabled&&!M.reply_content.trim()&&!M.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}try{await cr(M.cookie_id,{enabled:M.enabled,reply_content:M.reply_content,reply_once:M.reply_once,reply_image_url:M.reply_image_url}),D(!1),await Ne(),alert("保存成功")}catch(a){alert("保存失败:"+a.message)}},Bs=async a=>{if(confirm("确定删除该账号默认回复吗?"))try{await dr(a),await Ne(),alert("删除成功")}catch(p){alert("删除失败:"+p.message)}},Ns=async a=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await xr(a),alert("清空成功")}catch(p){alert("清空失败:"+p.message)}},vs=r==="automation"?"新建自动化":r==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-3",children:[e.jsxs("select",{value:z,onChange:a=>{xe(a.target.value),I(1)},className:"ios-input px-4 py-3 rounded-2xl text-sm min-w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),se.map(a=>e.jsx("option",{value:a.id,children:Ts(a)},a.id))]}),e.jsxs("button",{onClick:We,className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 flex items-center justify-center gap-2 whitespace-nowrap transition-colors",children:[e.jsx(Oe,{className:`w-4 h-4 ${J?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:r==="automation"?()=>Ye("order_paid"):r==="reply"?Ue:()=>void ns(),disabled:!z,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 whitespace-nowrap disabled:opacity-50",children:[e.jsx(ts,{className:"w-4 h-4"}),vs]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:Xs},{id:"reply",label:"关键词回复",icon:Es},{id:"default",label:"账号默认回复",icon:bs}].map(a=>{const p=a.icon;return e.jsxs("button",{onClick:()=>d(a.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${r===a.id?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(p,{className:"w-4 h-4"}),a.label]},a.id)})}),r==="automation"&&(Fe.runs.length>0||Fe.pending_tasks.length>0)&&e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(cs,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[Fe.runs.map(a=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",a.cookie_id," · 订单 ",a.order_id||"-"," · 已记录发送 ",a.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Dr(a.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:a.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[Ys(a,"continue")&&e.jsx("button",{onClick:()=>void N(a.id,"continue"),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Ys(a,"retry")&&e.jsx("button",{onClick:()=>void N(a.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Ys(a,"cancel")&&e.jsx("button",{onClick:()=>void N(a.id,"cancel"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${a.id}`)),Fe.pending_tasks.map(a=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",a.cookie_id," · 延迟任务重试已达 ",a.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:a.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>void Z(a.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:()=>void Z(a.id,"dismiss"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${a.id}`))]})]}),r==="automation"&&e.jsxs("div",{className:"grid grid-cols-1 2xl:grid-cols-[360px_1fr] gap-6",children:[e.jsxs("aside",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsx("h3",{className:"font-black text-gray-900 mb-1",children:"新建规则"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"先选自动化类型,再配置对应动作。"}),e.jsx("div",{className:"space-y-3",children:Fs.map(a=>{const p=ls[a],f=p.icon;return e.jsx("button",{type:"button",onClick:()=>Ye(a),className:`w-full text-left rounded-2xl border p-4 transition-colors ${Ot(p.accent)}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/80 flex items-center justify-center shrink-0",children:e.jsx(f,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:p.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:p.description})]})]})},a)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"font-black text-gray-900",children:"本页规则构成"}),e.jsxs("span",{className:"text-xs font-bold text-gray-400",children:["共 ",Ce," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Fs.map(a=>{const p=ls[a],f=p.icon;return e.jsxs("div",{className:"flex items-center justify-between rounded-2xl bg-gray-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(f,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:p.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:Te[a].length})]},a)})})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-[#FAFAFA] p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(As,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"搜索自动化规则",placeholder:"搜索规则名、商品名或商品 ID...",value:oe,onChange:a=>{_(a.target.value),I(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]}),e.jsxs("div",{className:"relative xl:w-52",children:[e.jsx(Ht,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按自动化类型筛选",value:V,onChange:a=>{me(a.target.value),I(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部自动化类型"}),Fs.map(a=>e.jsx("option",{value:a,children:ls[a].shortLabel},a))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:L,onChange:a=>{A(a.target.value),I(1)},className:"ios-input rounded-xl border-none bg-white px-4 py-2.5 text-sm shadow-sm xl:w-36",children:[e.jsx("option",{value:"all",children:"全部状态"}),e.jsx("option",{value:"enabled",children:"已启用"}),e.jsx("option",{value:"disabled",children:"已禁用"})]}),Ee&&e.jsx("button",{type:"button",onClick:Re,className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white text-gray-500 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900",title:"清除筛选","aria-label":"清除筛选",children:e.jsx(ve,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs font-bold text-gray-400",children:[e.jsxs("span",{children:["找到 ",Ce," 条规则"]}),J&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Oe,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),J&&Ie.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(Oe,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Ie.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(Xs,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:Ee?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:Ee?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Ie.map(a=>{const p=ls[a.trigger_type],f=p.icon;return e.jsx("article",{className:"bg-white rounded-xl border border-gray-100 p-5 shadow-sm hover:shadow-lg transition-all",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 ${Ot(p.accent,!0)}`,children:e.jsx(f,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-lg font-black text-gray-900 truncate",children:a.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${Mr(a.enabled)}`,children:a.enabled?"已启用":"已禁用"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-bold",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:p.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:a.item_title||a.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:Er(a)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>_e(a),className:"px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-bold flex items-center gap-2",children:[e.jsx(fs,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>l(a),className:`px-4 py-2 rounded-xl text-sm font-bold ${a.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:a.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>ms(a.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Je,{className:"w-4 h-4"})})]})]})},a.id)}),Ce>0&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-gray-500",children:[e.jsxs("span",{children:["第 ",K," / ",Math.max(m,1)," 页"]}),e.jsx("span",{className:"h-4 w-px bg-gray-200"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"sr-only",children:"每页显示数量"}),e.jsx("select",{value:ae,onChange:a=>{we(Number(a.target.value)),I(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(a=>e.jsxs("option",{value:a,children:[a," 条/页"]},a))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:K<=1||J,onClick:()=>I(a=>Math.max(1,a-1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页",title:"上一页",children:e.jsx(Zt,{className:"h-4 w-4"})}),Ve.map(a=>e.jsx("button",{type:"button",disabled:J,onClick:()=>I(a),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${a===K?"bg-[#0094f7] text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${a} 页`,"aria-current":a===K?"page":void 0,children:a},a)),e.jsx("button",{type:"button",disabled:K>=m||J,onClick:()=>I(a=>Math.min(m,a+1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页",title:"下一页",children:e.jsx(Xt,{className:"h-4 w-4"})})]})]})]})]}),r==="reply"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(cs,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[g.map(a=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg transition-all gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"px-3 py-1 bg-black text-white rounded-lg text-xs font-bold",children:"包含匹配"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",a.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:a.type==="image"&&a.image_url?a.image_url:a.reply_content})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>{C({...a}),P(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(fs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Pe(a.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Je,{className:"w-5 h-5"})})]})]},a.id)),g.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),r==="default"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(cs,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[qe.map(a=>{const p=b[a.id],f=!!(p!=null&&p.enabled);return e.jsxs("div",{className:`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${f?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center ${f?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(bs,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg truncate",children:Ts(a)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${f?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:f?"已启用":"未启用"}),(p==null?void 0:p.reply_once)&&e.jsx("span",{className:"px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700",children:"只回复一次"})]}),e.jsx("div",{className:"text-sm text-gray-600 line-clamp-2",children:f?p.reply_content||p.reply_image_url||"已配置默认回复":"未配置默认回复"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>void ns(a.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(fs,{className:"w-4 h-4"})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void Ns(a.id),className:"px-3 py-2 text-xs font-bold text-blue-600 hover:bg-blue-50 rounded-xl transition-colors",children:"清空记录"}),e.jsx("button",{onClick:()=>void Bs(a.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Je,{className:"w-5 h-5"})})]})]})]},a.id)}),qe.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),le&&n&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"72rem",maxHeight:"92vh"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-black text-gray-900",children:n.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:u.description})]}),e.jsx("button",{onClick:()=>H(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] min-h-0",children:[e.jsxs("aside",{className:"bg-slate-900 text-white p-5 overflow-y-auto",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"选择自动化类型"}),e.jsx("div",{className:"space-y-3",children:Fs.map(a=>{const p=ls[a],f=p.icon,O=Me===a;return e.jsx("button",{type:"button",onClick:()=>Ze(a),className:`w-full rounded-2xl p-4 text-left border transition-all ${O?"bg-white text-slate-950 border-white":"bg-white/5 text-white border-white/10 hover:bg-white/10"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(f,{className:`w-5 h-5 mt-0.5 ${O?"text-[#0094f7]":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:p.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${O?"text-gray-500":"text-gray-400"}`,children:p.description})]})]})},a)})}),e.jsxs("div",{className:"mt-6 rounded-2xl bg-white/5 border border-white/10 p-4",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"执行流程"}),e.jsx("div",{className:"space-y-3",children:u.flow.map((a,p)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white text-slate-950 text-xs font-black flex items-center justify-center",children:p+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:a})]},a))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-[#F7F8FA]",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Hs,{className:"w-5 h-5 text-[#0094f7]"}),e.jsx("h4",{className:"font-black text-gray-900",children:"生效范围"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"规则名称"}),e.jsx("input",{type:"text",value:n.name||"",onChange:a=>y({...n,name:a.target.value}),placeholder:"不填时按类型和商品自动生成",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:n.cookie_id||"",onChange:a=>y({...n,cookie_id:a.target.value,item_id:"",item_title:"",item_keyword:""}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),se.map(a=>e.jsx("option",{value:a.id,children:Ts(a)},a.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:n.item_id||"",onChange:a=>Xe(a.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),Ke.map(a=>e.jsx("option",{value:a.item_id,children:a.item_title||a.item_id},`${a.cookie_id}-${a.item_id}`))]})]})]}),ge&&Me!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:ge.item_title||ge.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${Ae?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:Ae?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),Me!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ea,{className:"w-5 h-5 text-[#0094f7]"}),e.jsx("h4",{className:"font-black text-gray-900",children:Me==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:Ae?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:xs,className:"px-3 py-2 rounded-xl bg-gray-900 text-white text-xs font-bold hover:bg-black flex items-center gap-1.5",children:[e.jsx(ts,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:Be.map((a,p)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${Ae?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[Ae&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格名称"}),e.jsx("input",{value:a.spec_name,onChange:f=>ze(p,{spec_name:f.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:套餐"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格值"}),e.jsx("input",{value:a.spec_value,onChange:f=>ze(p,{spec_value:f.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:30天"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"卡密库存"}),e.jsxs("select",{value:a.card_id||"",onChange:f=>ze(p,{card_id:Number(f.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),ie.filter(f=>f.enabled&&f.type!=="api").map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"每件份数"}),e.jsx("input",{type:"number",min:"1",max:"100",value:a.delivery_count,onChange:f=>ze(p,{delivery_count:Math.max(1,Number(f.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsxs("div",{className:"md:col-span-full flex flex-wrap items-center gap-3 rounded-xl bg-gray-50 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-bold text-gray-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.delay_override===!0,onChange:f=>ze(p,{delay_override:f.target.checked}),className:"accent-[#0094f7]"}),"覆盖卡密默认延时"]}),a.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:a.delay_seconds||0,onChange:f=>ze(p,{delay_seconds:Math.max(0,Number(f.target.value)||0)}),className:"w-28 ios-input px-2 py-1.5 rounded-lg text-xs","aria-label":"动作延时秒数"}),e.jsx("span",{className:"text-xs text-gray-500",children:a.delay_override?`本动作延时 ${a.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:Be.length===1,onClick:()=>y({...n,variants:Be.filter((f,O)=>O!==p)}),className:"w-10 h-10 flex items-center justify-center rounded-lg text-red-500 hover:bg-red-50 disabled:opacity-25",title:"删除发货内容",children:e.jsx(Je,{className:"w-4 h-4"})})]},a.id||p))})]}):e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ea,{className:"w-5 h-5 text-amber-600"}),e.jsx("h4",{className:"font-black text-gray-900",children:"求评价计划"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"发货后等待小时"}),e.jsx("input",{type:"number",min:"1",value:Number($.after_shipped_hours||72),onChange:a=>y({...n,config_json:is(n.config_json,{after_shipped_hours:Math.max(1,Number(a.target.value)||72)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"再次求评间隔小时"}),e.jsx("input",{type:"number",min:"1",value:Number($.repeat_interval_hours||24),onChange:a=>y({...n,config_json:is(n.config_json,{repeat_interval_hours:Math.max(1,Number(a.target.value)||24)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最多求评次数"}),e.jsx("input",{type:"number",min:"1",value:Number($.max_attempts||1),onChange:a=>y({...n,config_json:is(n.config_json,{max_attempts:Math.max(1,Number(a.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((W=(v=n.actions)==null?void 0:v.find(a=>a.action_type==="send_text"))==null?void 0:W.message_template)||"",onChange:a=>{var p;return y({...n,actions:((p=n.actions)!=null&&p.length?n.actions:Cs("review_missing_timeout")).map(f=>f.action_type==="send_text"?{...f,message_template:a.target.value}:f)})},className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none"})]})]})]}),e.jsx("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[180px_1fr] gap-4 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"优先级"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"数字越小优先级越高;同一账号、商品和触发条件只执行优先级最高的一条规则。"}),e.jsx("input",{type:"number",value:n.priority||100,onChange:a=>y({...n,priority:Number(a.target.value)||100}),min:"1",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"h-[48px] flex items-center gap-3 px-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsx("input",{type:"checkbox",checked:n.enabled!==!1,onChange:a=>y({...n,enabled:a.target.checked}),className:"w-4 h-4 rounded"}),"启用规则"]})]})})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[e.jsx("button",{onClick:()=>H(!1),className:"flex-1 px-6 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200",children:"取消"}),e.jsxs("button",{onClick:He,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),je&&E&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:E.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>P(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:E.item_id||"",onChange:a=>C({...E,item_id:a.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),B.filter(a=>!z||a.cookie_id===z).map(a=>e.jsx("option",{value:a.item_id,children:a.item_title||a.item_id},`${a.cookie_id}-${a.item_id}`))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复类型"}),e.jsxs("select",{value:E.type||"text",onChange:a=>{const p=a.target.value;C({...E,type:p,reply_content:p==="text"?E.reply_content:"",image_url:p==="image"?E.image_url:""})},className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"文字"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关键词"}),e.jsx("input",{type:"text",value:E.keyword||"",onChange:a=>C({...E,keyword:a.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),E.type==="image"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{value:E.image_url||"",onChange:a=>C({...E,image_url:a.target.value}),placeholder:"https://...",className:"w-full ios-input px-4 py-3 rounded-xl"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:E.reply_content||"",onChange:a=>C({...E,reply_content:a.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>P(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ge,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ot,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),o&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"账号默认回复"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"关键词和 AI 都未处理时,才会使用默认回复。"})]}),e.jsx("button",{onClick:()=>D(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:M.cookie_id,onChange:a=>he({...M,cookie_id:a.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),se.map(a=>e.jsx("option",{value:a.id,children:Ts(a)},a.id))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"启用默认回复"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"启用后,未命中关键词时自动发送"})]}),e.jsx("button",{type:"button",onClick:()=>he({...M,enabled:!M.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${M.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${M.enabled?"translate-x-7":"translate-x-1"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:M.reply_content,onChange:a=>he({...M,reply_content:a.target.value}),placeholder:"输入默认回复内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复图片 URL(可选)"}),e.jsx("input",{type:"text",value:M.reply_image_url,onChange:a=>he({...M,reply_image_url:a.target.value}),placeholder:"https://example.com/image.jpg",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsxs("span",{children:["只回复一次",e.jsx("span",{className:"block text-xs text-gray-500 font-medium mt-1",children:"同一会话只发送一次默认回复"})]}),e.jsx("input",{type:"checkbox",checked:M.reply_once,onChange:a=>he({...M,reply_once:a.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>D(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:us,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},Br=s=>{const t=String(s.smtp_from||"").trim(),r=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);return{...s,smtp_from_name:s.smtp_from_name||(r?"":t),smtp_from_address:s.smtp_from_address||(r?t:s.smtp_user||""),smtp_use_tls:qt(s.smtp_use_tls,!0),smtp_use_ssl:qt(s.smtp_use_ssl,!1)}},qt=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},dt=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],nt=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},ua=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),r=dt.some(d=>String(s[d]??"").trim()!=="");return{...s,use_custom_smtp:t?nt(s.use_custom_smtp,!1):r}},Bt=(s,t)=>{const r={...s,use_custom_smtp:!0};for(const d of dt)String(r[d]??"").trim()===""&&t[d]!==void 0&&(r[d]=t[d]);return r.smtp_port||(r.smtp_port=587),r.smtp_from_address||(r.smtp_from_address=r.smtp_user||""),r.smtp_use_tls=nt(r.smtp_use_tls,!0),r.smtp_use_ssl=nt(r.smtp_use_ssl,!1),r},zr=s=>{const t=ua(s),r={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(r.use_custom_smtp)for(const d of dt)r[d]=t[d];return r},gs={bark:{label:"Bark",icon:ys,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"Ydisks闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app//这是测试推送内容","URL 路径里 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:Es,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:Es,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:Es,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:Ma,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:ot,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的用户 ID",required:!0}],guide:{steps:["在 Telegram 搜索 @BotFather,发送 /newbot,按提示创建机器人,拿到 Bot Token","把你的 Bot 拉进一个群,或私聊它发一条消息","浏览器访问 https://api.telegram.org/bot<你的Token>/getUpdates",'从返回 JSON 里找 "chat":{"id":xxx},xxx 就是 Chat ID(群是负数,私聊是正数)'],urlFormat:"Bot Token: 123456:ABC-DEF... Chat ID: -1001234567890",note:"群聊需先把 Bot 设为管理员才能发消息。"}},email:{label:"邮件",icon:sa,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},pa=[{value:"account_offline",label:"掉线通知",description:"账号过期、断线或登录态失效"},{value:"account_recovered",label:"恢复通知",description:"自动恢复成功并重新在线"},{value:"account_disabled",label:"禁用通知",description:"连续失败、账密错误等导致账号停用"},{value:"security_verification",label:"风控验证",description:"滑块、人脸、扫码验证等安全校验"},{value:"delivery_result",label:"交易通知",description:"订单发货、卡密发送等交易结果"},{value:"token_renewal",label:"续期通知",description:"Cookie/token 续期和自动恢复过程"},{value:"system_error",label:"系统错误",description:"后台任务或系统级异常"}],Ur=s=>!s||s.length===0?"全部事件":s.map(r=>{var d;return((d=pa.find(x=>x.value===r))==null?void 0:d.label)||r}).join("、"),Wr=({isAdmin:s=!1})=>{const[t,r]=i.useState([]),[d,x]=i.useState(!0),[w,S]=i.useState(!1),[F,g]=i.useState(null),[R,b]=i.useState(!1),[G,se]=i.useState(""),[re,ie]=i.useState(null),[k,B]=i.useState({}),[ne,J]=i.useState(!1),[Y,z]=i.useState(!1),[xe,oe]=i.useState(!1),[_,T]=i.useState({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),U=async()=>{x(!0);try{const m=await xa();r(m.data||[])}catch(m){console.error("加载通知渠道失败",m)}finally{x(!1)}},V=async()=>{try{const m=await oa();B(Br(m||{}))}catch(m){console.error("加载 SMTP 配置失败",m)}},me=async()=>{J(!0);try{await ca({smtp_server:k.smtp_server||"",smtp_port:k.smtp_port||587,smtp_user:k.smtp_user||"",smtp_password:k.smtp_password||"",smtp_from_name:k.smtp_from_name||"",smtp_from_address:k.smtp_from_address||k.smtp_user||"",smtp_use_tls:k.smtp_use_tls!==!1,smtp_use_ssl:k.smtp_use_ssl===!0}),L("success","SMTP 配置已保存")}catch(m){L("error",(m==null?void 0:m.message)||"保存失败")}finally{J(!1)}};i.useEffect(()=>{U(),s?V():B({})},[s]);const L=(m,h)=>{ie({type:m,text:h}),window.setTimeout(()=>ie(null),3e3)},A=()=>{g(null),T({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),oe(!1),S(!0)},K=m=>{g(m);const h=m.type==="email"?ua({...m.config||{}}):null,q=h?h.use_custom_smtp===!0?Bt(h,k):h:{...m.config||{}};T({name:m.name,type:m.type,enabled:m.enabled,config:q,event_types:m.event_types||[]}),oe(!1),S(!0)},I=async()=>{const m=gs[_.type];for(const q of m.fields)if(q.required&&!String(_.config[q.key]||"").trim()){L("error",`请填写 ${q.label}`);return}if(!_.name.trim()){L("error","请填写渠道名称");return}let h=_.config;if(_.type==="email"&&(h=zr(_.config),h.use_custom_smtp)){const j=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([te])=>!String(h[te]||"").trim());if(j){L("error",`请填写 ${j[1]}`);return}}b(!0);try{const q={name:_.name.trim(),type:_.type,config:h,event_types:_.event_types,enabled:_.enabled};F?await Rt(F.id,q):await lr(q),S(!1),await U(),L("success",F?"已更新":"已创建")}catch(q){console.error("保存失败",q),L("error",(q==null?void 0:q.message)||"保存失败")}finally{b(!1)}},ae=async m=>{if(confirm(`确认删除渠道「${m.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await rr(m.id),await U(),L("success","已删除")}catch(h){L("error",(h==null?void 0:h.message)||"删除失败")}},we=async m=>{try{await Rt(m.id,{enabled:!m.enabled}),r(h=>h.map(q=>q.id===m.id?{...q,enabled:!q.enabled}:q))}catch(h){L("error",(h==null?void 0:h.message)||"切换失败")}},Ce=async m=>{se(m.id);try{await ir(m.id),L("success","测试通知已发送,请检查对应渠道")}catch(h){L("error",(h==null?void 0:h.message)||"发送失败")}finally{se("")}},ue=gs[_.type];return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"通知设置"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"配置通知渠道,账号异常时主动推送告警"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:U,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Oe,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:A,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"新建渠道"]})]})]}),e.jsx("div",{className:"ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ys,{className:"w-5 h-5 text-[#0094f7] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-gray-700 leading-6",children:["配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:",e.jsxs("ul",{className:"mt-2 space-y-1 text-gray-600",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"账号 session 失效"}),":系统正在尝试自动恢复(警告)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"自动恢复失败"}),":账号已停止,需人工处理(严重)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),d?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx($e,{className:"w-8 h-8 text-[#0094f7] animate-spin"})}):t.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(ys,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"还没有配置任何通知渠道"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"点击右上角「新建渠道」开始配置"})]}):e.jsx("div",{className:"space-y-3",children:t.map(m=>{const h=gs[m.type]||gs.webhook,q=h.icon;return e.jsxs("div",{className:"ios-card rounded-xl p-5 bg-white flex items-center gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-gray-100 flex items-center justify-center flex-shrink-0",children:e.jsx(q,{className:"w-5 h-5 text-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-gray-900 truncate",children:m.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:h.label}),!m.enabled&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-400 font-medium",children:"已停用"})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 truncate",children:h.fields.map(j=>{var te;return(te=m.config)==null?void 0:te[j.key]}).filter(Boolean).map((j,te)=>e.jsx("span",{className:"mr-3",children:String(j).length>40?String(j).slice(0,40)+"…":String(j)},te))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Ur(m.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>we(m),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${m.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:m.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>Ce(m),disabled:G===m.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-[#0094f7] hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[G===m.id?e.jsx($e,{className:"w-3 h-3 animate-spin"}):e.jsx(ot,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>K(m),className:"w-8 h-8 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors",title:"编辑",children:e.jsx(Yt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ae(m),className:"w-8 h-8 rounded-lg bg-red-50 hover:bg-red-100 flex items-center justify-center text-red-500 transition-colors",title:"删除",children:e.jsx(Je,{className:"w-4 h-4"})})]})]},m.id)})}),s&&e.jsxs("section",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-extrabold text-gray-800",children:"SMTP 邮件配置"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"系统级邮件发送服务,供邮件通知渠道复用"})]}),e.jsx("div",{className:"p-2 rounded-xl bg-blue-50 text-blue-600",children:e.jsx(sa,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 服务器"}),e.jsx("input",{type:"text",value:k.smtp_server||"",onChange:m=>B({...k,smtp_server:m.target.value}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 端口"}),e.jsx("input",{type:"number",value:k.smtp_port||587,onChange:m=>B({...k,smtp_port:parseInt(m.target.value)||587}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱"}),e.jsx("input",{type:"email",value:k.smtp_user||"",onChange:m=>B({...k,smtp_user:m.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"邮箱密码 / 授权码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:Y?"text":"password",value:k.smtp_password||"",onChange:m=>B({...k,smtp_password:m.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>z(!Y),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:Y?e.jsx(os,{className:"w-4 h-4"}):e.jsx(rs,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:k.smtp_from_name||"",onChange:m=>B({...k,smtp_from_name:m.target.value}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱地址"}),e.jsx("input",{type:"email",value:k.smtp_from_address||k.smtp_user||"",onChange:m=>B({...k,smtp_from_address:m.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:k.smtp_use_tls!==!1,onChange:m=>B({...k,smtp_use_tls:m.target.checked,smtp_use_ssl:m.target.checked?!1:k.smtp_use_ssl})}),"STARTTLS(常用于 587 端口)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:k.smtp_use_ssl===!0,onChange:m=>B({...k,smtp_use_ssl:m.target.checked,smtp_use_tls:m.target.checked?!1:k.smtp_use_tls})}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:me,disabled:ne,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[ne?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(as,{className:"w-4 h-4"}),ne?"保存中...":"保存 SMTP 配置"]})]}),w&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"36rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:F?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>S(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道名称"}),e.jsx("input",{type:"text",value:_.name,onChange:m=>T({..._,name:m.target.value}),placeholder:"例如:我的 Bark",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道类型"}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Object.keys(gs).map(m=>{const h=gs[m],q=h.icon,j=_.type===m;return e.jsxs("button",{type:"button",onClick:()=>T({..._,type:m,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${j?"border-[#0094f7] bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(q,{className:`w-5 h-5 ${j?"text-[#0094f7]":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${j?"text-[#0094f7]":"text-gray-600"}`,children:h.label})]},m)})})]}),e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",ue.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:ue.guide.steps.map((m,h)=>e.jsx("li",{children:m},h))}),ue.guide.urlFormat&&e.jsxs("div",{className:"text-xs text-amber-900/90",children:[e.jsx("span",{className:"font-bold",children:"格式示例:"}),e.jsx("code",{className:"mt-1 block bg-amber-100/70 px-2.5 py-1.5 rounded-lg break-all font-mono text-[11px]",children:ue.guide.urlFormat})]}),ue.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",ue.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:ue.fields.map(m=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[m.label,m.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:m.type==="password"?"password":m.type==="number"?"number":"text",value:String(_.config[m.key]||""),onChange:h=>T({..._,config:{..._.config,[m.key]:h.target.value}}),placeholder:m.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),m.help&&e.jsx("p",{className:"text-xs text-gray-500",children:m.help})]},m.key))}),_.type==="email"&&e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"SMTP 来源"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:_.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:()=>{const m=_.config.use_custom_smtp===!0;T({..._,config:m?{..._.config,use_custom_smtp:!1}:Bt(_.config,k)})},className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${_.config.use_custom_smtp===!0?"bg-[#0094f7]":"bg-gray-300"}`,"aria-label":"使用独立 SMTP",children:e.jsx("span",{className:`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${_.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),_.config.use_custom_smtp===!0&&e.jsxs("div",{className:"space-y-4 border-t border-blue-100 bg-white/80 p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 服务器 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:String(_.config.smtp_server||""),onChange:m=>T({..._,config:{..._.config,smtp_server:m.target.value}}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 端口 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:String(_.config.smtp_port||587),onChange:m=>T({..._,config:{..._.config,smtp_port:m.target.value}}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["登录邮箱 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(_.config.smtp_user||""),onChange:m=>T({..._,config:{..._.config,smtp_user:m.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["密码 / 授权码 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:xe?"text":"password",value:String(_.config.smtp_password||""),onChange:m=>T({..._,config:{..._.config,smtp_password:m.target.value}}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>oe(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:xe?e.jsx(os,{className:"w-4 h-4"}):e.jsx(rs,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:String(_.config.smtp_from_name||""),onChange:m=>T({..._,config:{..._.config,smtp_from_name:m.target.value}}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["发件邮箱地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(_.config.smtp_from_address||""),onChange:m=>T({..._,config:{..._.config,smtp_from_address:m.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:_.config.smtp_use_tls!==!1,onChange:m=>T({..._,config:{..._.config,smtp_use_tls:m.target.checked,smtp_use_ssl:m.target.checked?!1:_.config.smtp_use_ssl}})}),"STARTTLS(常用于 587)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:_.config.smtp_use_ssl===!0,onChange:m=>T({..._,config:{..._.config,smtp_use_ssl:m.target.checked,smtp_use_tls:m.target.checked?!1:_.config.smtp_use_tls}})}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"通知内容"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"不选择表示接收全部通知;选择后仅接收勾选类型。"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:pa.map(m=>{const h=_.event_types.includes(m.value);return e.jsxs("button",{type:"button",onClick:()=>{const q=h?_.event_types.filter(j=>j!==m.value):[..._.event_types,m.value];T({..._,event_types:q})},className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${h?"border-[#0094f7] bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center ${h?"bg-[#0094f7] border-[#0094f7]":"border-gray-300"}`,children:h&&e.jsx(ss,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${h?"text-[#0094f7]":"text-gray-800"}`,children:m.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:m.description})]},m.value)})})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>T({..._,enabled:!_.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${_.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${_.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>S(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"取消"}),e.jsxs("button",{onClick:I,disabled:R,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[R?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(ss,{className:"w-4 h-4"}),R?"保存中...":"保存"]})]})]})}),document.body),re&&e.jsxs("div",{className:"fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in",style:{background:re.type==="success"?"#10b981":"#ef4444",color:"white"},children:[re.type==="success"?e.jsx(ss,{className:"w-4 h-4"}):e.jsx(ve,{className:"w-4 h-4"}),re.text]})]})},ha={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},zt=Object.fromEntries(Object.entries(ha).map(([s,t])=>[t,s])),Ut=()=>ha[window.location.pathname]||"dashboard",Vr=/Win/i.test(navigator.platform||navigator.userAgent),Gr=()=>{const[s,t]=i.useState(!1),[r,d]=i.useState(!1),[x,w]=i.useState(Ut),[S,F]=i.useState(!0),[g,R]=i.useState(!1),[b,G]=i.useState(""),[se,re]=i.useState(""),[ie,k]=i.useState(!1),[B,ne]=i.useState(""),[J,Y]=i.useState(),z=T=>{const U=T==="settings"&&!r?"dashboard":T,V=zt[U];V&&V!==window.location.pathname&&window.history.pushState({},"",V),w(U)};i.useEffect(()=>{const T=()=>w(Ut());return window.addEventListener("popstate",T),()=>window.removeEventListener("popstate",T)},[]),i.useEffect(()=>{la().then(U=>{if((U==null?void 0:U.initialized)===!1){R(!0),t(!1),d(!1);return}R(!1),U!=null&&U.authenticated?(t(!0),d(U.is_admin===!0)):d(!1)}).catch(()=>{t(!1),d(!1)}).finally(()=>F(!1));const T=()=>{t(!1),d(!1)};return window.addEventListener("auth:logout",T),()=>window.removeEventListener("auth:logout",T)},[]),i.useEffect(()=>{!S&&s&&!r&&x==="settings"&&(window.history.replaceState({},"",zt.dashboard),w("dashboard"))},[S,s,r,x]);const xe=async T=>{T.preventDefault(),k(!0),ne("");try{const U=await Ha({username:b,password:se});U.success?(t(!0),d(U.is_admin===!0)):ne(U.message||"登录失败")}catch(U){const V=U instanceof Error?U.message:String(U);ne(V||"登录失败")}finally{k(!1)}},oe=async()=>{try{await el()}catch(T){console.error("退出登录失败",T)}finally{t(!1),d(!1)}};if(S)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#f5f5f7]",children:e.jsx($e,{className:"w-8 h-8 text-[#0094f7] animate-spin"})});if(g)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-xl border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"mx-auto mb-6 flex justify-center",children:e.jsx(tt,{sizeClass:"w-24 h-24"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"系统尚未初始化"}),e.jsx("p",{className:"text-gray-600 font-medium",children:"为避免默认口令风险,管理员必须通过服务器本机 CLI 初始化。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-gray-50 border border-gray-100",children:[e.jsx("div",{className:"text-sm font-bold text-gray-900 mb-2",children:"请在服务器上执行:"}),e.jsx("pre",{className:"text-xs bg-black text-white p-4 rounded-2xl overflow-x-auto",children:Vr?'.\\xianyu-server.exe -init-admin -db data\\xianyu_data.db -admin-password "请设置密码"':"./xianyu-server -init-admin -db data/xianyu_data.db -admin-password '请设置密码'"}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"完成后刷新页面即可进入登录。"})]}),e.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group",children:["我已初始化,刷新 ",e.jsx(et,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-lg border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"group mx-auto mb-6 flex cursor-pointer justify-center",children:e.jsx(tt,{sizeClass:"w-24 h-24",logoClassName:"w-full h-full text-white group-hover:scale-110 transition-transform"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"欢迎回来"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Ydisks闲鱼助手 · 自动发货与管家系统"})]}),e.jsxs("form",{onSubmit:xe,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(ds,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"text",placeholder:"管理员账号",value:b,onChange:T=>G(T.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Oa,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"密码",value:se,onChange:T=>re(T.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),B&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(st,{className:"w-4 h-4"})," ",B]}),e.jsx("button",{type:"submit",disabled:ie,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:ie?e.jsx($e,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(et,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100",children:e.jsx("div",{className:"mt-6 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Ydisks闲鱼助手 v1.0"})})})]})]});const _=()=>{switch(x){case"dashboard":return e.jsx(Qs,{});case"accounts":return e.jsx(Nr,{});case"orders":return e.jsx(_r,{});case"cards":return e.jsx(Cr,{});case"items":return e.jsx(Ar,{onConfigureDelivery:T=>{Y({cookieId:T.cookie_id,itemId:T.item_id,requestId:Date.now()}),z("rules")}});case"rules":return e.jsx(qr,{initialDeliveryTarget:J,onDeliveryTargetHandled:()=>Y(void 0)});case"notifications":return e.jsx(Wr,{isAdmin:r});case"settings":return r?e.jsx(Rr,{}):e.jsx(Qs,{});default:return e.jsx(Qs,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-[#F4F5F7] text-[#111]",children:[e.jsx(Ja,{activeTab:x,isAdmin:r,onNavigate:z,onLogout:oe}),e.jsxs("main",{className:"flex-1 ml-64 p-8 md:p-12 overflow-y-auto h-screen relative scroll-smooth",children:[e.jsx("div",{className:"fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"}),e.jsx("div",{className:"max-w-[1400px] mx-auto pb-10",children:_()})]})]})},ga=document.getElementById("root");if(!ga)throw new Error("Could not find root element to mount to");const Jr=ba.createRoot(ga);Jr.render(e.jsx(ya.StrictMode,{children:e.jsx(Gr,{})})); diff --git a/internal/webui/static/index.html b/internal/webui/static/index.html index 7dbb96d..9afed53 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -6,12 +6,12 @@ Ydisks闲鱼助手 - 自动发货与管家系统 - + - +
diff --git a/internal/xianyu/mtop/publish.go b/internal/xianyu/mtop/publish.go index 9d1ddd6..338f75f 100644 --- a/internal/xianyu/mtop/publish.go +++ b/internal/xianyu/mtop/publish.go @@ -65,7 +65,7 @@ type PublishImage struct { } // PublishCategory 是发布商品时可使用的人工兜底类目。 -// CatID 和 CatName 必填;频道类目、淘宝类目 ID 没有时可以留空。 +// CatID、CatName 和 ChannelCatID 必填;部分闲鱼类目没有 TBCatID。 type PublishCategory struct { CatID string `json:"cat_id"` CatName string `json:"cat_name"` @@ -73,6 +73,16 @@ type PublishCategory struct { TBCatID string `json:"tb_cat_id,omitempty"` } +// DefaultVirtualPublishCategory 是从闲鱼类目推荐响应中核实的“电子资料”类目。 +// 该类目没有 tbCatId,发布时必须保留为空而不是伪造淘宝类目 ID。 +func DefaultVirtualPublishCategory() PublishCategory { + return PublishCategory{ + CatID: "50023914", + CatName: "电子资料", + ChannelCatID: "202036301", + } +} + type PublishItemRequest struct { Title string Description string @@ -82,9 +92,9 @@ type PublishItemRequest struct { PostageMode string PostageCents int64 // Virtual 表示商品只通过系统的虚拟发货流程交付,不需要实物发货地址。 - Virtual bool - FallbackCategory *PublishCategory - Images []PublishImage + Virtual bool + PreferredCategory *PublishCategory + Images []PublishImage } type PublishItemResult struct { @@ -125,8 +135,8 @@ func (c *ClientImpl) PublishItem(ctx context.Context, cookiesStr string, req Pub if len(req.Images) > 9 { return nil, errors.New("商品图片最多 9 张") } - if req.FallbackCategory != nil && !validPublishCategory(*req.FallbackCategory) { - return nil, errors.New("兜底类目必须同时填写类目 ID 和类目名称") + if req.PreferredCategory != nil && !validPublishCategory(*req.PreferredCategory) { + return nil, errors.New("默认类目必须同时包含类目 ID、类目名称和频道类目 ID") } currentCookies := cookiesStr if session := cookieSessionFromContext(ctx); session != nil { @@ -143,15 +153,22 @@ func (c *ClientImpl) PublishItem(ctx context.Context, cookiesStr string, req Pub } uploaded = append(uploaded, res) } - category, updated, err := c.recommendPublishCategory(ctx, currentCookies, req.Title, req.Description, uploaded) - if updated != "" { - currentCookies = updated - } - if err != nil { - if errors.Is(err, ErrPublishCategoryUnrecognized) && req.FallbackCategory != nil { - category = fallbackPublishCategory(*req.FallbackCategory) - } else { - return nil, err + var category map[string]any + var updated string + var err error + if req.PreferredCategory != nil { + category = fallbackPublishCategory(*req.PreferredCategory) + } else { + category, updated, err = c.recommendPublishCategory(ctx, currentCookies, req.Title, req.Description, uploaded) + if updated != "" { + currentCookies = updated + } + if err != nil { + if errors.Is(err, ErrPublishCategoryUnrecognized) { + category = fallbackPublishCategory(DefaultVirtualPublishCategory()) + } else { + return nil, err + } } } var location map[string]any @@ -167,6 +184,29 @@ func (c *ClientImpl) PublishItem(ctx context.Context, cookiesStr string, req Pub return c.publishItemOnce(ctx, currentCookies, req, uploaded, category, location) } +// RecommendPublishCategory 根据关键词调用闲鱼推荐接口,返回可直接用于发布的完整类目。 +func (c *ClientImpl) RecommendPublishCategory(ctx context.Context, cookiesStr, keyword string) (PublishCategory, string, error) { + keyword = strings.TrimSpace(keyword) + if keyword == "" { + return PublishCategory{}, cookiesStr, errors.New("类目关键词不能为空") + } + data, updated, err := c.recommendPublishCategory(ctx, cookiesStr, keyword, keyword, nil) + if err != nil { + return PublishCategory{}, updated, err + } + cat := mapFromAny(data["categoryPredictResult"]) + category := PublishCategory{ + CatID: strings.TrimSpace(mtopString(cat["catId"])), + CatName: strings.TrimSpace(mtopString(cat["catName"])), + ChannelCatID: strings.TrimSpace(mtopString(cat["channelCatId"])), + TBCatID: strings.TrimSpace(mtopString(cat["tbCatId"])), + } + if !validPublishCategory(category) { + return PublishCategory{}, updated, fmt.Errorf("%w: 推荐结果缺少完整类目路径", ErrPublishCategoryUnrecognized) + } + return category, updated, nil +} + func (c *ClientImpl) uploadPublishImage(ctx context.Context, cookiesStr string, img PublishImage) (uploadedImage, string, error) { hc := c.HTTPClient if hc == nil { @@ -262,9 +302,11 @@ func (c *ClientImpl) recommendPublishCategory(ctx context.Context, cookiesStr, t "publishScene": "mainPublish", "scene": "newPublishChoice", "description": desc, - "imageInfos": imageInfos, "uniqueCode": strconv.FormatInt(time.Now().UnixMicro(), 10), } + if len(imageInfos) > 0 { + data["imageInfos"] = imageInfos + } decoded, updated, err := c.callMTop(ctx, cookiesStr, RecommendItemAPI, "mtop.taobao.idle.kgraph.property.recommend", "2.0", "a21ybx.publish.0.0", "a21ybx.item.sidebar.1.67321598K9Vgx8", "67321598K9Vgx8", data) if err != nil { return nil, updated, err @@ -277,24 +319,85 @@ func (c *ClientImpl) recommendPublishCategory(ctx context.Context, cookiesStr, t return nil, updated, fmt.Errorf("%w: 类目推荐响应缺少 data", ErrPublishCategoryUnrecognized) } cat := mapFromAny(dataMap["categoryPredictResult"]) - if cat == nil || mtopString(cat["catId"]) == "" { + if !validPublishCategoryMap(cat) { + // 部分账号/场景仅在 cardList 的“分类”卡片返回已选中的类目, + // 不返回 categoryPredictResult。将其转换为统一的发布类目结构。 + if selected := selectedCategoryFromCards(dataMap); selected != nil { + cat = selected + dataMap["categoryPredictResult"] = selected + } + } + if !validPublishCategoryMap(cat) { return nil, updated, ErrPublishCategoryUnrecognized } return dataMap, updated, nil } +func validPublishCategoryMap(category map[string]any) bool { + return category != nil && + strings.TrimSpace(mtopString(category["catId"])) != "" && + strings.TrimSpace(mtopString(category["catName"])) != "" && + strings.TrimSpace(mtopString(category["channelCatId"])) != "" +} + +func selectedCategoryFromCards(data map[string]any) map[string]any { + cards, _ := data["cardList"].([]any) + for _, rawCard := range cards { + cardData := mapFromAny(mapFromAny(rawCard)["cardData"]) + if cardData == nil || mtopString(cardData["propertyId"]) != "-10000" { + continue + } + values, _ := cardData["valuesList"].([]any) + for _, rawValue := range values { + value := mapFromAny(rawValue) + if value == nil || !publishLabelSelected(value["isClicked"]) || mtopString(value["catId"]) == "" { + continue + } + return map[string]any{ + "catId": mtopString(value["catId"]), + "catName": mtopString(value["catName"]), + "channelCatId": mtopString(value["channelCatId"]), + "tbCatId": mtopString(value["tbCatId"]), + } + } + } + return nil +} + func validPublishCategory(category PublishCategory) bool { - return strings.TrimSpace(category.CatID) != "" && strings.TrimSpace(category.CatName) != "" + return strings.TrimSpace(category.CatID) != "" && + strings.TrimSpace(category.CatName) != "" && + strings.TrimSpace(category.ChannelCatID) != "" } func fallbackPublishCategory(category PublishCategory) map[string]any { + category = PublishCategory{ + CatID: strings.TrimSpace(category.CatID), + CatName: strings.TrimSpace(category.CatName), + ChannelCatID: strings.TrimSpace(category.ChannelCatID), + TBCatID: strings.TrimSpace(category.TBCatID), + } return map[string]any{ "categoryPredictResult": map[string]any{ - "catId": strings.TrimSpace(category.CatID), - "catName": strings.TrimSpace(category.CatName), - "channelCatId": strings.TrimSpace(category.ChannelCatID), - "tbCatId": strings.TrimSpace(category.TBCatID), + "catId": category.CatID, + "catName": category.CatName, + "channelCatId": category.ChannelCatID, + "tbCatId": category.TBCatID, }, + // 闲鱼将分类作为已选择的标签一并提交;仅传 itemCatDTO 会导致 + // 部分频道类目无法还原完整路径。 + "cardList": []any{map[string]any{ + "cardData": map[string]any{ + "propertyId": "-10000", + "propertyName": "分类", + "valuesList": []any{map[string]any{ + "catName": category.CatName, + "channelCatId": category.ChannelCatID, + "tbCatId": category.TBCatID, + "isClicked": true, + }}, + }, + }}, } } @@ -519,8 +622,7 @@ func publishLabels(category map[string]any) []any { values, _ := cardData["valuesList"].([]any) for _, rawValue := range values { value := mapFromAny(rawValue) - clicked, _ := value["isClicked"].(bool) - if !clicked { + if !publishLabelSelected(value["isClicked"]) { continue } propertyID := mtopString(cardData["propertyId"]) @@ -552,6 +654,18 @@ func publishLabels(category map[string]any) []any { return out } +func publishLabelSelected(value any) bool { + if selected, ok := value.(bool); ok { + return selected + } + switch strings.ToLower(strings.TrimSpace(mtopString(value))) { + case "1", "true": + return true + default: + return false + } +} + func classifyPublishError(ret []string, decoded map[string]any) error { bodyBytes, _ := json.Marshal(decoded) body := string(bodyBytes) diff --git a/internal/xianyu/mtop/publish_extra_test.go b/internal/xianyu/mtop/publish_extra_test.go index 8660895..81b6024 100644 --- a/internal/xianyu/mtop/publish_extra_test.go +++ b/internal/xianyu/mtop/publish_extra_test.go @@ -61,7 +61,7 @@ func TestPublishItemValidationFailures(t *testing.T) { {"zero quantity", PublishItemRequest{Title: "T", PriceCents: 100, Quantity: 0, Images: []PublishImage{{}}}, "库存数量必须大于 0"}, {"no images", PublishItemRequest{Title: "T", PriceCents: 100, Quantity: 1}, "至少上传 1 张商品图片"}, {"too many images", PublishItemRequest{Title: "T", PriceCents: 100, Quantity: 1, Images: make([]PublishImage, 10)}, "商品图片最多 9 张"}, - {"incomplete fallback category", PublishItemRequest{Title: "T", PriceCents: 100, Quantity: 1, FallbackCategory: &PublishCategory{CatID: "5001"}, Images: []PublishImage{{}}}, "兜底类目必须同时填写"}, + {"incomplete preferred category", PublishItemRequest{Title: "T", PriceCents: 100, Quantity: 1, PreferredCategory: &PublishCategory{CatID: "5001"}, Images: []PublishImage{{}}}, "默认类目必须同时包含"}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { @@ -140,11 +140,10 @@ func TestPublishItemUploadImageFailure(t *testing.T) { }} client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}} req := PublishItemRequest{ - Title: "T", - PriceCents: 1000, - Quantity: 1, - FallbackCategory: &PublishCategory{CatID: "5001", CatName: "虚拟商品"}, - Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, + Title: "T", + PriceCents: 1000, + Quantity: 1, + Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, } _, err := client.PublishItem(context.Background(), consignCookies, req) if err == nil || !strings.Contains(err.Error(), "图片上传响应缺少 url") { @@ -165,11 +164,10 @@ func TestPublishItemRecommendCategoryFailure(t *testing.T) { }} client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}} req := PublishItemRequest{ - Title: "T", - PriceCents: 1000, - Quantity: 1, - FallbackCategory: &PublishCategory{CatID: "5001", CatName: "虚拟商品"}, - Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, + Title: "T", + PriceCents: 1000, + Quantity: 1, + Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, } _, err := client.PublishItem(context.Background(), consignCookies, req) if err == nil { @@ -182,7 +180,7 @@ func TestPublishItemRecommendCategoryFailure(t *testing.T) { } // TestPublishItemRecommendCategoryMissingData: ret 成功但 data 缺 categoryPredictResult。 -func TestPublishItemRecommendCategoryMissingData(t *testing.T) { +func TestPublishItemRecommendCategoryMissingDataUsesElectronicMaterials(t *testing.T) { png1 := tinyPNG(t) dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{ "_upload": func(w http.ResponseWriter, r *http.Request) { @@ -191,20 +189,24 @@ func TestPublishItemRecommendCategoryMissingData(t *testing.T) { "mtop.taobao.idle.kgraph.property.recommend": func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{}}`) }, + "mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"fallback-item"}}`) + }, }} client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}} req := PublishItemRequest{ Title: "T", PriceCents: 1000, Quantity: 1, + Virtual: true, Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, } - _, err := client.PublishItem(context.Background(), consignCookies, req) - if err == nil || !strings.Contains(err.Error(), "未能自动识别商品类目") { + result, err := client.PublishItem(context.Background(), consignCookies, req) + if err != nil { t.Fatalf("err=%v", err) } - if !errors.Is(err, ErrPublishCategoryUnrecognized) { - t.Fatalf("err=%v want ErrPublishCategoryUnrecognized", err) + if result.CategoryID != "50023914" || result.CategoryName != "电子资料" { + t.Fatalf("result=%+v", result) } } @@ -273,7 +275,51 @@ func TestPublishVirtualItemSkipsLocation(t *testing.T) { } } -func TestPublishVirtualItemUsesFallbackCategoryWhenRecommendationIsEmpty(t *testing.T) { +func TestPublishVirtualItemUsesPreferredCategoryWithoutRecommendation(t *testing.T) { + png1 := tinyPNG(t) + var publishedData map[string]any + recommendCalled := false + dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{ + "_upload": func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `{"object":{"url":"https://cdn/a.jpg","pix":"800x600"}}`) + }, + "mtop.taobao.idle.kgraph.property.recommend": func(w http.ResponseWriter, r *http.Request) { + recommendCalled = true + fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{}}`) + }, + "mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, r *http.Request) { + publishedData, _ = parseDataURL(readBody(r)) + fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"fallback-item-1"}}`) + }, + }} + client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}} + res, err := client.PublishItem(context.Background(), consignCookies, PublishItemRequest{ + Title: "虚拟商品", + PriceCents: 1000, + Quantity: 1, + Virtual: true, + PreferredCategory: &PublishCategory{CatID: "5001", CatName: "虚拟服务", ChannelCatID: "6001", TBCatID: "7001"}, + Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, + }) + if err != nil { + t.Fatalf("err=%v", err) + } + if recommendCalled { + t.Fatal("配置默认类目后不应调用自动推荐接口") + } + if res.CategoryID != "5001" || res.CategoryName != "虚拟服务" { + t.Fatalf("category result=%+v", res) + } + category, _ := publishedData["itemCatDTO"].(map[string]any) + if category["catId"] != "5001" || category["catName"] != "虚拟服务" || category["channelCatId"] != "6001" || category["tbCatId"] != "7001" { + t.Fatalf("published category=%+v", category) + } + if _, exists := publishedData["itemAddrDTO"]; exists { + t.Fatalf("虚拟商品不应发送 itemAddrDTO: %+v", publishedData["itemAddrDTO"]) + } +} + +func TestPublishVirtualItemUsesElectronicMaterialsWhenRecommendationIsEmpty(t *testing.T) { png1 := tinyPNG(t) var publishedData map[string]any dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{ @@ -285,31 +331,27 @@ func TestPublishVirtualItemUsesFallbackCategoryWhenRecommendationIsEmpty(t *test }, "mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, r *http.Request) { publishedData, _ = parseDataURL(readBody(r)) - fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"fallback-item-1"}}`) + fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"electronic-item-1"}}`) }, }} client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}} res, err := client.PublishItem(context.Background(), consignCookies, PublishItemRequest{ - Title: "虚拟商品", - PriceCents: 1000, - Quantity: 1, - Virtual: true, - FallbackCategory: &PublishCategory{CatID: "5001", CatName: "虚拟服务", ChannelCatID: "6001", TBCatID: "7001"}, - Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, + Title: "无法识别的虚拟商品", + PriceCents: 1000, + Quantity: 1, + Virtual: true, + Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}}, }) if err != nil { t.Fatalf("err=%v", err) } - if res.CategoryID != "5001" || res.CategoryName != "虚拟服务" { + if res.CategoryID != "50023914" || res.CategoryName != "电子资料" { t.Fatalf("category result=%+v", res) } category, _ := publishedData["itemCatDTO"].(map[string]any) - if category["catId"] != "5001" || category["catName"] != "虚拟服务" || category["channelCatId"] != "6001" || category["tbCatId"] != "7001" { + if category["channelCatId"] != "202036301" { t.Fatalf("published category=%+v", category) } - if _, exists := publishedData["itemAddrDTO"]; exists { - t.Fatalf("虚拟商品不应发送 itemAddrDTO: %+v", publishedData["itemAddrDTO"]) - } } // TestPublishItemFinalPublishFailure: 发布接口返回 token 过期错误。 @@ -511,6 +553,43 @@ func TestRecommendPublishCategorySuccess(t *testing.T) { _ = png1 } +func TestRecommendPublishCategoryUsesSelectedCategoryCard(t *testing.T) { + imgs := []uploadedImage{{URL: "https://cdn/a.jpg", Width: 800, Height: 600}} + dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{ + "mtop.taobao.idle.kgraph.property.recommend": func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"cardList":[{"cardData":{"propertyId":"-10000","propertyName":"分类","valuesList":[{"catId":"50023914","catName":"电子资料","channelCatId":"202036301","isClicked":"1"}]}}]}}`) + }, + }} + client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}} + category, _, err := client.recommendPublishCategory(context.Background(), consignCookies, "其他虚拟资料", "其他虚拟资料", imgs) + if err != nil { + t.Fatalf("err=%v", err) + } + selected := category["categoryPredictResult"].(map[string]any) + if selected["catId"] != "50023914" || selected["catName"] != "电子资料" || selected["channelCatId"] != "202036301" { + t.Fatalf("selected=%+v", selected) + } + if labels := publishLabels(category); len(labels) != 1 { + t.Fatalf("labels=%+v", labels) + } +} + +func TestDefaultVirtualPublishCategoryIncludesSelectedCategoryLabel(t *testing.T) { + category := DefaultVirtualPublishCategory() + if category.CatID != "50023914" || category.CatName != "电子资料" || category.ChannelCatID != "202036301" || category.TBCatID != "" { + t.Fatalf("default category=%+v", category) + } + fallback := fallbackPublishCategory(category) + labels := publishLabels(fallback) + if len(labels) != 1 { + t.Fatalf("labels=%+v", labels) + } + label := labels[0].(map[string]any) + if label["channelCateId"] != "202036301" || label["channelCateName"] != "电子资料" || label["propertyId"] != "-10000" { + t.Fatalf("label=%+v", label) + } +} + func TestRecommendPublishCategoryDataNil(t *testing.T) { imgs := []uploadedImage{{URL: "u", Width: 1, Height: 1}} dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{