From b128ce60db455000f3d6768a40c516f31d4f7fd2 Mon Sep 17 00:00:00 2001 From: Christ Date: Sat, 15 Aug 2026 01:02:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E4=B8=83=EF=BC=9A=E5=AE=8C?= =?UTF-8?q?=E6=88=90OrderList=20React=20feature=E5=8C=96=E4=B8=8E=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=88=B7=E6=96=B0=E8=BE=B9=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .commentlint/frontend-baseline.json | 1604 ++++++----------- docs/architecture/refactoring-master-plan.md | 4 +- frontend/app/features/orders/api.ts | 13 + .../orders/components/OrderFilterBar.tsx | 90 + .../orders/components/OrderImportModal.tsx | 94 + frontend/app/features/orders/hooks.ts | 349 ++++ frontend/app/features/orders/state.test.ts | 54 + frontend/app/features/orders/state.ts | 64 + frontend/app/features/orders/types.ts | 96 + frontend/components/OrderList.tsx | 325 +--- frontend/components/orderImportState.test.ts | 18 - frontend/components/orderImportState.ts | 34 +- frontend/services/api.test.ts | 14 + frontend/services/api.ts | 11 +- ...r-BFpWAqQX.js => icons-vendor-BJ6r5aOc.js} | 2 +- .../webui/static/assets/index-7zzRZ1Ef.js | 20 + .../webui/static/assets/index-DBrkfYTo.css | 1 + .../webui/static/assets/index-DFTgpFf2.css | 1 - .../webui/static/assets/index-D_XA_mO5.js | 20 - internal/webui/static/index.html | 6 +- 20 files changed, 1454 insertions(+), 1366 deletions(-) create mode 100644 frontend/app/features/orders/api.ts create mode 100644 frontend/app/features/orders/components/OrderFilterBar.tsx create mode 100644 frontend/app/features/orders/components/OrderImportModal.tsx create mode 100644 frontend/app/features/orders/hooks.ts create mode 100644 frontend/app/features/orders/state.test.ts create mode 100644 frontend/app/features/orders/state.ts create mode 100644 frontend/app/features/orders/types.ts delete mode 100644 frontend/components/orderImportState.test.ts rename internal/webui/static/assets/{icons-vendor-BFpWAqQX.js => icons-vendor-BJ6r5aOc.js} (99%) create mode 100644 internal/webui/static/assets/index-7zzRZ1Ef.js create mode 100644 internal/webui/static/assets/index-DBrkfYTo.css delete mode 100644 internal/webui/static/assets/index-DFTgpFf2.css delete mode 100644 internal/webui/static/assets/index-D_XA_mO5.js diff --git a/.commentlint/frontend-baseline.json b/.commentlint/frontend-baseline.json index 6e8a1ef..b2fca64 100644 --- a/.commentlint/frontend-baseline.json +++ b/.commentlint/frontend-baseline.json @@ -5591,405 +5591,153 @@ "kind": "function-expression", "name": "anonymous" }, - { - "file": "components/orderImportState.test.ts", - "line": 4, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/orderImportState.test.ts", - "line": 5, - "kind": "variable", - "name": "result" - }, - { - "file": "components/orderImportState.ts", - "line": 10, - "kind": "member", - "name": "failed_count" - }, - { - "file": "components/orderImportState.ts", - "line": 11, - "kind": "member", - "name": "results" - }, - { - "file": "components/orderImportState.ts", - "line": 14, - "kind": "variable", - "name": "normalizeOrderImportResult" - }, - { - "file": "components/orderImportState.ts", - "line": 18, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/orderImportState.ts", - "line": 2, - "kind": "member", - "name": "order_id" - }, - { - "file": "components/orderImportState.ts", - "line": 25, - "kind": "variable", - "name": "failedOrderImportRows" - }, - { - "file": "components/orderImportState.ts", - "line": 26, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/orderImportState.ts", - "line": 3, - "kind": "member", - "name": "success" - }, - { - "file": "components/orderImportState.ts", - "line": 4, - "kind": "member", - "name": "message" - }, - { - "file": "components/orderImportState.ts", - "line": 8, - "kind": "member", - "name": "total" - }, - { - "file": "components/orderImportState.ts", - "line": 9, - "kind": "member", - "name": "success_count" - }, { "file": "components/OrderList.tsx", - "line": 10, - "kind": "variable", - "name": "styles" - }, - { - "file": "components/OrderList.tsx", - "line": 100, - "kind": "variable", - "name": "itemTitleLower" - }, - { - "file": "components/OrderList.tsx", - "line": 115, - "kind": "variable", - "name": "namesMap" - }, - { - "file": "components/OrderList.tsx", - "line": 116, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 125, - "kind": "variable", - "name": "buildItemNamesMapFrom" - }, - { - "file": "components/OrderList.tsx", - "line": 126, - "kind": "variable", - "name": "namesMap" - }, - { - "file": "components/OrderList.tsx", - "line": 127, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 135, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 136, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 136, - "kind": "variable", - "name": "timer" - }, - { - "file": "components/OrderList.tsx", - "line": 140, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 143, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 147, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 148, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 152, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 157, - "kind": "variable", - "name": "accountMap" - }, - { - "file": "components/OrderList.tsx", - "line": 158, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 158, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 162, - "kind": "variable", - "name": "accountName" - }, - { - "file": "components/OrderList.tsx", - "line": 163, - "kind": "variable", - "name": "account" - }, - { - "file": "components/OrderList.tsx", - "line": 164, - "kind": "variable", - "name": "name" - }, - { - "file": "components/OrderList.tsx", - "line": 167, - "kind": "variable", - "name": "accountNickname" - }, - { - "file": "components/OrderList.tsx", - "line": 168, - "kind": "variable", - "name": "account" - }, - { - "file": "components/OrderList.tsx", - "line": 172, - "kind": "variable", - "name": "handleSync" - }, - { - "file": "components/OrderList.tsx", - "line": 175, - "kind": "variable", - "name": "result" - }, - { - "file": "components/OrderList.tsx", - "line": 180, - "kind": "variable", - "name": "error" - }, - { - "file": "components/OrderList.tsx", - "line": 188, - "kind": "variable", - "name": "handleShip" - }, - { - "file": "components/OrderList.tsx", - "line": 194, - "kind": "variable", - "name": "executeShip" - }, - { - "file": "components/OrderList.tsx", - "line": 198, - "kind": "variable", - "name": "res" - }, - { - "file": "components/OrderList.tsx", - "line": 199, - "kind": "variable", - "name": "result" - }, - { - "file": "components/OrderList.tsx", - "line": 20, - "kind": "variable", - "name": "labels" - }, - { - "file": "components/OrderList.tsx", - "line": 206, + "line": 104, "kind": "variable", "name": "e" }, { "file": "components/OrderList.tsx", - "line": 213, + "line": 11, + "kind": "member", + "name": "status" + }, + { + "file": "components/OrderList.tsx", + "line": 11, + "kind": "variable", + "name": "StatusBadge" + }, + { + "file": "components/OrderList.tsx", + "line": 111, "kind": "variable", "name": "handleViewDetail" }, { "file": "components/OrderList.tsx", - "line": 218, + "line": 116, "kind": "variable", "name": "handleEdit" }, { "file": "components/OrderList.tsx", - "line": 223, + "line": 12, + "kind": "variable", + "name": "styles" + }, + { + "file": "components/OrderList.tsx", + "line": 121, "kind": "variable", "name": "handleSaveEdit" }, { "file": "components/OrderList.tsx", - "line": 261, + "line": 159, "kind": "variable", "name": "error" }, { "file": "components/OrderList.tsx", - "line": 267, - "kind": "variable", - "name": "handleImportOrders" - }, - { - "file": "components/OrderList.tsx", - "line": 271, - "kind": "variable", - "name": "formData" - }, - { - "file": "components/OrderList.tsx", - "line": 273, - "kind": "variable", - "name": "result" - }, - { - "file": "components/OrderList.tsx", - "line": 282, - "kind": "variable", - "name": "error" - }, - { - "file": "components/OrderList.tsx", - "line": 289, - "kind": "variable", - "name": "closeImportModal" - }, - { - "file": "components/OrderList.tsx", - "line": 296, + "line": 165, "kind": "variable", "name": "handleSyncSingle" }, { "file": "components/OrderList.tsx", - "line": 299, + "line": 168, "kind": "variable", "name": "result" }, { "file": "components/OrderList.tsx", - "line": 305, + "line": 174, "kind": "variable", "name": "error" }, { "file": "components/OrderList.tsx", - "line": 313, + "line": 182, "kind": "variable", "name": "handleDelete" }, { "file": "components/OrderList.tsx", - "line": 319, + "line": 188, "kind": "function-expression", "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 323, + "line": 192, "kind": "variable", "name": "error" }, { "file": "components/OrderList.tsx", - "line": 344, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 369, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 37, + "line": 22, "kind": "variable", - "name": "OrderList" + "name": "labels" }, { "file": "components/OrderList.tsx", - "line": 372, + "line": 251, "kind": "function-expression", "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 38, - "kind": "variable", - "name": "[orders, setOrders]" - }, - { - "file": "components/OrderList.tsx", - "line": 385, + "line": 308, "kind": "function-expression", "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 389, + "line": 324, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 331, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 338, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 346, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 368, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 368, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 375, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 375, "kind": "function-expression", "name": "anonymous" }, @@ -5997,83 +5745,59 @@ "file": "components/OrderList.tsx", "line": 39, "kind": "variable", - "name": "[items, setItems]" + "name": "OrderList" }, { "file": "components/OrderList.tsx", - "line": 40, - "kind": "variable", - "name": "[accounts, setAccounts]" - }, - { - "file": "components/OrderList.tsx", - "line": 400, + "line": 392, "kind": "function-expression", "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 41, + "line": 44, "kind": "variable", - "name": "[itemNames, setItemNames]" - }, - { - "file": "components/OrderList.tsx", - "line": 42, - "kind": "variable", - "name": "[filter, setFilter]" - }, - { - "file": "components/OrderList.tsx", - "line": 420, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 43, - "kind": "variable", - "name": "[accountFilter, setAccountFilter]" + "name": "{ orders, accounts, filter, setFilter, accountFilter, setAccountFilter, searchText, setSearchText, page, setPage, totalPages, loading, loadOrders, accountName, accountNickname, getItemNameById }" }, { "file": "components/OrderList.tsx", "line": 45, "kind": "variable", - "name": "[debouncedSearch, setDebouncedSearch]" + "name": "[showDetailModal, setShowDetailModal]" }, { "file": "components/OrderList.tsx", "line": 46, "kind": "variable", - "name": "requestSequence" + "name": "[showEditModal, setShowEditModal]" }, { "file": "components/OrderList.tsx", "line": 47, "kind": "variable", - "name": "[page, setPage]" - }, - { - "file": "components/OrderList.tsx", - "line": 477, - "kind": "function-expression", - "name": "anonymous" + "name": "[selectedOrder, setSelectedOrder]" }, { "file": "components/OrderList.tsx", "line": 48, "kind": "variable", - "name": "[totalPages, setTotalPages]" + "name": "[editingOrder, setEditingOrder]" + }, + { + "file": "components/OrderList.tsx", + "line": 484, + "kind": "function-expression", + "name": "anonymous" }, { "file": "components/OrderList.tsx", "line": 49, "kind": "variable", - "name": "[loading, setLoading]" + "name": "[showShipModal, setShowShipModal]" }, { "file": "components/OrderList.tsx", - "line": 493, + "line": 491, "kind": "function-expression", "name": "anonymous" }, @@ -6081,53 +5805,47 @@ "file": "components/OrderList.tsx", "line": 50, "kind": "variable", - "name": "[showDetailModal, setShowDetailModal]" - }, - { - "file": "components/OrderList.tsx", - "line": 500, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 507, - "kind": "function-expression", - "name": "anonymous" + "name": "[shipOrderId, setShipOrderId]" }, { "file": "components/OrderList.tsx", "line": 51, "kind": "variable", - "name": "[showEditModal, setShowEditModal]" + "name": "[shipLoading, setShipLoading]" }, { "file": "components/OrderList.tsx", - "line": 515, + "line": 517, "kind": "function-expression", "name": "anonymous" }, + { + "file": "components/OrderList.tsx", + "line": 52, + "kind": "member", + "name": "message" + }, + { + "file": "components/OrderList.tsx", + "line": 52, + "kind": "member", + "name": "success" + }, { "file": "components/OrderList.tsx", "line": 52, "kind": "variable", - "name": "[showImportModal, setShowImportModal]" + "name": "[shipResult, setShipResult]" }, { "file": "components/OrderList.tsx", "line": 53, "kind": "variable", - "name": "[selectedOrder, setSelectedOrder]" + "name": "[syncingOrderId, setSyncingOrderId]" }, { "file": "components/OrderList.tsx", - "line": 537, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 537, + "line": 530, "kind": "function-expression", "name": "anonymous" }, @@ -6135,121 +5853,61 @@ "file": "components/OrderList.tsx", "line": 54, "kind": "variable", - "name": "[editingOrder, setEditingOrder]" - }, - { - "file": "components/OrderList.tsx", - "line": 544, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 544, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 55, - "kind": "variable", - "name": "[editForm, setEditForm]" - }, - { - "file": "components/OrderList.tsx", - "line": 56, - "kind": "variable", - "name": "[showShipModal, setShowShipModal]" - }, - { - "file": "components/OrderList.tsx", - "line": 561, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 57, - "kind": "variable", - "name": "[shipOrderId, setShipOrderId]" - }, - { - "file": "components/OrderList.tsx", - "line": 58, - "kind": "variable", - "name": "[shipLoading, setShipLoading]" - }, - { - "file": "components/OrderList.tsx", - "line": 59, - "kind": "member", - "name": "message" - }, - { - "file": "components/OrderList.tsx", - "line": 59, - "kind": "member", - "name": "success" - }, - { - "file": "components/OrderList.tsx", - "line": 59, - "kind": "variable", - "name": "[shipResult, setShipResult]" - }, - { - "file": "components/OrderList.tsx", - "line": 60, - "kind": "variable", - "name": "[importFile, setImportFile]" - }, - { - "file": "components/OrderList.tsx", - "line": 61, - "kind": "variable", - "name": "[importResult, setImportResult]" - }, - { - "file": "components/OrderList.tsx", - "line": 62, - "kind": "variable", - "name": "[importing, setImporting]" - }, - { - "file": "components/OrderList.tsx", - "line": 63, - "kind": "variable", - "name": "[syncingOrderId, setSyncingOrderId]" - }, - { - "file": "components/OrderList.tsx", - "line": 64, - "kind": "variable", "name": "[deletingOrderId, setDeletingOrderId]" }, { "file": "components/OrderList.tsx", - "line": 653, + "line": 550, "kind": "function-expression", "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 66, - "kind": "variable", - "name": "loadOrders" - }, - { - "file": "components/OrderList.tsx", - "line": 660, + "line": 586, "kind": "function-expression", "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 67, - "kind": "variable", - "name": "sequence" + "line": 605, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 628, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 647, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 656, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 668, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 677, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/OrderList.tsx", + "line": 687, + "kind": "function-expression", + "name": "anonymous" }, { "file": "components/OrderList.tsx", @@ -6259,117 +5917,51 @@ }, { "file": "components/OrderList.tsx", - "line": 71, - "kind": "variable", - "name": "res" + "line": 707, + "kind": "function-expression", + "name": "anonymous" }, { "file": "components/OrderList.tsx", - "line": 724, - "kind": "function-expression", - "name": "anonymous" + "line": 73, + "kind": "variable", + "name": "handleSync" }, { "file": "components/OrderList.tsx", "line": 75, "kind": "variable", - "name": "e" + "name": "result" }, { "file": "components/OrderList.tsx", - "line": 768, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 781, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 801, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 837, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 856, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 879, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 898, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 9, - "kind": "member", - "name": "status" - }, - { - "file": "components/OrderList.tsx", - "line": 9, + "line": 80, "kind": "variable", - "name": "StatusBadge" + "name": "error" }, { "file": "components/OrderList.tsx", - "line": 907, - "kind": "function-expression", - "name": "anonymous" + "line": 86, + "kind": "variable", + "name": "handleShip" }, { "file": "components/OrderList.tsx", - "line": 919, - "kind": "function-expression", - "name": "anonymous" + "line": 92, + "kind": "variable", + "name": "executeShip" }, { "file": "components/OrderList.tsx", - "line": 928, - "kind": "function-expression", - "name": "anonymous" + "line": 96, + "kind": "variable", + "name": "res" }, { "file": "components/OrderList.tsx", - "line": 938, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 949, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 95, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/OrderList.tsx", - "line": 958, - "kind": "function-expression", - "name": "anonymous" + "line": 97, + "kind": "variable", + "name": "result" }, { "file": "components/qrPolling.test.ts", @@ -10321,55 +9913,37 @@ }, { "file": "services/api.test.ts", - "line": 150, - "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 160, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.test.ts", - "line": 183, + "line": 163, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 184, + "line": 164, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 189, + "line": 174, "kind": "variable", "name": "result" }, + { + "file": "services/api.test.ts", + "line": 197, + "kind": "function-expression", + "name": "anonymous" + }, { "file": "services/api.test.ts", "line": 198, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 199, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 206, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 208, + "line": 203, "kind": "variable", "name": "result" }, @@ -10385,159 +9959,171 @@ "kind": "variable", "name": "fetchMock" }, + { + "file": "services/api.test.ts", + "line": 220, + "kind": "function-expression", + "name": "anonymous" + }, { "file": "services/api.test.ts", "line": 222, + "kind": "variable", + "name": "result" + }, + { + "file": "services/api.test.ts", + "line": 226, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 223, + "line": 227, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 232, + "line": 236, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 233, + "line": 237, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 244, + "line": 246, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 247, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 258, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 248, + "line": 262, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 263, + "line": 277, "kind": "variable", "name": "items" }, { "file": "services/api.test.ts", - "line": 278, + "line": 292, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 279, + "line": 293, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 290, + "line": 304, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 296, + "line": 310, "kind": "variable", "name": "settings" }, { "file": "services/api.test.ts", - "line": 301, + "line": 315, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 302, + "line": 316, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 313, + "line": 327, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 314, + "line": 328, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 314, + "line": 328, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 340, + "line": 354, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.test.ts", - "line": 341, - "kind": "variable", - "name": "fetchMock" - }, { "file": "services/api.test.ts", "line": 355, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 369, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 369, + "line": 383, "kind": "variable", "name": "accounts" }, { "file": "services/api.test.ts", - "line": 380, + "line": 394, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.test.ts", - "line": 381, - "kind": "variable", - "name": "fetchMock" - }, { "file": "services/api.test.ts", "line": 395, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 396, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 407, + "line": 409, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 408, + "line": 410, "kind": "variable", "name": "fetchMock" }, @@ -10555,15 +10141,15 @@ }, { "file": "services/api.test.ts", - "line": 439, - "kind": "variable", - "name": "status" + "line": 435, + "kind": "function-expression", + "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 447, - "kind": "function-expression", - "name": "anonymous" + "line": 436, + "kind": "variable", + "name": "fetchMock" }, { "file": "services/api.test.ts", @@ -10573,27 +10159,33 @@ }, { "file": "services/api.test.ts", - "line": 470, + "line": 453, "kind": "variable", - "name": "rules" + "name": "status" }, { "file": "services/api.test.ts", - "line": 484, + "line": 461, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 485, + "line": 484, "kind": "variable", - "name": "fetchMock" + "name": "rules" }, { "file": "services/api.test.ts", - "line": 494, + "line": 498, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 499, "kind": "variable", - "name": "rules" + "name": "fetchMock" }, { "file": "services/api.test.ts", @@ -10603,15 +10195,9 @@ }, { "file": "services/api.test.ts", - "line": 506, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 507, + "line": 508, "kind": "variable", - "name": "fetchMock" + "name": "rules" }, { "file": "services/api.test.ts", @@ -10621,73 +10207,67 @@ }, { "file": "services/api.test.ts", - "line": 522, + "line": 520, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 523, + "line": 521, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 532, + "line": 536, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 533, + "line": 537, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 544, + "line": 546, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 545, + "line": 547, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 560, + "line": 558, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 559, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 574, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 568, + "line": 582, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 569, - "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 580, - "kind": "variable", - "name": "body" - }, - { - "file": "services/api.test.ts", - "line": 587, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 588, + "line": 583, "kind": "variable", "name": "fetchMock" }, @@ -10697,6 +10277,12 @@ "kind": "function-expression", "name": "anonymous" }, + { + "file": "services/api.test.ts", + "line": 594, + "kind": "variable", + "name": "body" + }, { "file": "services/api.test.ts", "line": 60, @@ -10705,21 +10291,27 @@ }, { "file": "services/api.test.ts", - "line": 602, + "line": 601, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 603, + "line": 602, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 624, + "line": 616, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 617, "kind": "variable", - "name": "body" + "name": "fetchMock" }, { "file": "services/api.test.ts", @@ -10729,37 +10321,25 @@ }, { "file": "services/api.test.ts", - "line": 640, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.test.ts", - "line": 641, - "kind": "variable", - "name": "fetchMock" - }, - { - "file": "services/api.test.ts", - "line": 669, + "line": 638, "kind": "variable", "name": "body" }, { "file": "services/api.test.ts", - "line": 693, + "line": 654, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 694, + "line": 655, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 706, + "line": 683, "kind": "variable", "name": "body" }, @@ -10771,25 +10351,43 @@ }, { "file": "services/api.test.ts", - "line": 707, + "line": 708, + "kind": "variable", + "name": "fetchMock" + }, + { + "file": "services/api.test.ts", + "line": 720, + "kind": "variable", + "name": "body" + }, + { + "file": "services/api.test.ts", + "line": 721, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.test.ts", + "line": 721, "kind": "member", "name": "action_type" }, { "file": "services/api.test.ts", - "line": 715, + "line": 729, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.test.ts", - "line": 716, + "line": 730, "kind": "variable", "name": "fetchMock" }, { "file": "services/api.test.ts", - "line": 733, + "line": 747, "kind": "variable", "name": "body" }, @@ -10849,37 +10447,37 @@ }, { "file": "services/api.ts", - "line": 1000, + "line": 1001, "kind": "variable", "name": "setMessageNotification" }, { "file": "services/api.ts", - "line": 1004, + "line": 1005, "kind": "variable", "name": "deleteMessageNotification" }, { "file": "services/api.ts", - "line": 1008, + "line": 1009, "kind": "variable", "name": "deleteAccountNotifications" }, { "file": "services/api.ts", - "line": 1014, + "line": 1015, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 1018, + "line": 1019, "kind": "variable", "name": "setAccountBindings" }, { "file": "services/api.ts", - "line": 1028, + "line": 1029, "kind": "variable", "name": "getDefaultReplies" }, @@ -10891,31 +10489,31 @@ }, { "file": "services/api.ts", - "line": 1032, + "line": 1033, "kind": "variable", "name": "getDefaultReply" }, { "file": "services/api.ts", - "line": 1033, + "line": 1034, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 1043, + "line": 1044, "kind": "variable", "name": "updateDefaultReply" }, { "file": "services/api.ts", - "line": 1052, + "line": 1053, "kind": "variable", "name": "deleteDefaultReply" }, { "file": "services/api.ts", - "line": 1056, + "line": 1057, "kind": "variable", "name": "clearDefaultReplyRecords" }, @@ -11587,31 +11185,31 @@ }, { "file": "services/api.ts", - "line": 312, + "line": 313, "kind": "variable", "name": "params" }, { "file": "services/api.ts", - "line": 317, + "line": 318, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 320, + "line": 321, "kind": "variable", "name": "rawOrders" }, { "file": "services/api.ts", - "line": 321, + "line": 322, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 321, + "line": 322, "kind": "variable", "name": "orders" }, @@ -11623,61 +11221,61 @@ }, { "file": "services/api.ts", - "line": 337, + "line": 338, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 337, + "line": 338, "kind": "member", "name": "success" }, { "file": "services/api.ts", - "line": 337, + "line": 338, "kind": "variable", "name": "getOrderDetail" }, { "file": "services/api.ts", - "line": 338, + "line": 339, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 345, + "line": 346, "kind": "variable", "name": "updateOrder" }, { "file": "services/api.ts", - "line": 349, + "line": 350, "kind": "variable", "name": "deleteOrder" }, { "file": "services/api.ts", - "line": 353, + "line": 354, "kind": "variable", "name": "syncOrders" }, { "file": "services/api.ts", - "line": 354, + "line": 355, "kind": "variable", "name": "formData" }, { "file": "services/api.ts", - "line": 361, + "line": 362, "kind": "variable", "name": "syncSingleOrder" }, { "file": "services/api.ts", - "line": 365, + "line": 366, "kind": "variable", "name": "manualShipOrder" }, @@ -11689,87 +11287,81 @@ }, { "file": "services/api.ts", - "line": 372, + "line": 373, "kind": "variable", "name": "importOrders" }, { "file": "services/api.ts", - "line": 373, + "line": 374, "kind": "variable", "name": "isFormData" }, { "file": "services/api.ts", - "line": 378, + "line": 379, "kind": "variable", "name": "getAdminStats" }, { "file": "services/api.ts", - "line": 382, + "line": 383, "kind": "variable", "name": "getDashboardStats" }, { "file": "services/api.ts", - "line": 386, + "line": 387, "kind": "member", "name": "end_date" }, { "file": "services/api.ts", - "line": 386, + "line": 387, "kind": "member", "name": "start_date" }, { "file": "services/api.ts", - "line": 386, + "line": 387, "kind": "variable", "name": "getOrderAnalytics" }, { "file": "services/api.ts", - "line": 387, + "line": 388, "kind": "member", "name": "end_date" }, { "file": "services/api.ts", - "line": 387, + "line": 388, "kind": "member", "name": "start_date" }, { "file": "services/api.ts", - "line": 387, + "line": 388, "kind": "variable", "name": "params" }, { "file": "services/api.ts", - "line": 390, + "line": 391, "kind": "variable", "name": "endDate" }, { "file": "services/api.ts", - "line": 391, + "line": 392, "kind": "variable", "name": "startDate" }, - { - "file": "services/api.ts", - "line": 408, - "kind": "member", - "name": "orders" - }, { "file": "services/api.ts", "line": 409, "kind": "member", - "name": "total" + "name": "orders" }, { "file": "services/api.ts", @@ -11781,38 +11373,38 @@ "file": "services/api.ts", "line": 410, "kind": "member", + "name": "total" + }, + { + "file": "services/api.ts", + "line": 411, + "kind": "member", "name": "truncated" }, { "file": "services/api.ts", - "line": 413, + "line": 414, "kind": "member", "name": "end_date" }, { "file": "services/api.ts", - "line": 413, + "line": 414, "kind": "member", "name": "start_date" }, { "file": "services/api.ts", - "line": 413, + "line": 414, "kind": "variable", "name": "getValidOrders" }, { "file": "services/api.ts", - "line": 414, + "line": 415, "kind": "variable", "name": "res" }, - { - "file": "services/api.ts", - "line": 419, - "kind": "variable", - "name": "orders" - }, { "file": "services/api.ts", "line": 42, @@ -11822,12 +11414,18 @@ { "file": "services/api.ts", "line": 420, + "kind": "variable", + "name": "orders" + }, + { + "file": "services/api.ts", + "line": 421, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 420, + "line": 421, "kind": "variable", "name": "normalized" }, @@ -11839,13 +11437,13 @@ }, { "file": "services/api.ts", - "line": 434, + "line": 435, "kind": "variable", "name": "normalizeCard" }, { "file": "services/api.ts", - "line": 435, + "line": 436, "kind": "variable", "name": "apiConfig" }, @@ -11857,7 +11455,7 @@ }, { "file": "services/api.ts", - "line": 446, + "line": 447, "kind": "variable", "name": "cardPayload" }, @@ -11869,82 +11467,76 @@ }, { "file": "services/api.ts", - "line": 451, + "line": 452, "kind": "variable", "name": "getCards" }, { "file": "services/api.ts", - "line": 452, + "line": 453, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 453, + "line": 454, "kind": "variable", "name": "cards" }, { "file": "services/api.ts", - "line": 457, + "line": 458, "kind": "variable", "name": "createCard" }, { "file": "services/api.ts", - "line": 461, + "line": 462, "kind": "variable", "name": "updateCard" }, { "file": "services/api.ts", - "line": 465, + "line": 466, "kind": "variable", "name": "deleteCard" }, { "file": "services/api.ts", - "line": 469, + "line": 470, "kind": "variable", "name": "getCardDetails" }, { "file": "services/api.ts", - "line": 470, + "line": 471, "kind": "variable", "name": "card" }, { "file": "services/api.ts", - "line": 493, + "line": 494, "kind": "variable", "name": "normalizeBooleanFlag" }, { "file": "services/api.ts", - "line": 496, + "line": 497, "kind": "variable", "name": "getItems" }, { "file": "services/api.ts", - "line": 497, + "line": 498, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 498, + "line": 499, "kind": "variable", "name": "items" }, - { - "file": "services/api.ts", - "line": 499, - "kind": "function-expression", - "name": "anonymous" - }, { "file": "services/api.ts", "line": 50, @@ -11953,91 +11545,97 @@ }, { "file": "services/api.ts", - "line": 508, + "line": 500, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 509, "kind": "variable", "name": "syncItemsFromAccount" }, { "file": "services/api.ts", - "line": 512, + "line": 513, "kind": "variable", "name": "deleteItem" }, { "file": "services/api.ts", - "line": 516, + "line": 517, "kind": "variable", "name": "createItem" }, { "file": "services/api.ts", - "line": 520, + "line": 521, "kind": "variable", "name": "publishItem" }, { "file": "services/api.ts", - "line": 521, + "line": 522, "kind": "member", "name": "cookie_id" }, { "file": "services/api.ts", - "line": 522, + "line": 523, "kind": "member", "name": "title" }, { "file": "services/api.ts", - "line": 523, + "line": 524, "kind": "member", "name": "description" }, { "file": "services/api.ts", - "line": 524, + "line": 525, "kind": "member", "name": "price" }, { "file": "services/api.ts", - "line": 525, + "line": 526, "kind": "member", "name": "original_price" }, { "file": "services/api.ts", - "line": 526, + "line": 527, "kind": "member", "name": "quantity" }, { "file": "services/api.ts", - "line": 527, + "line": 528, "kind": "member", "name": "postage_mode" }, { "file": "services/api.ts", - "line": 528, + "line": 529, "kind": "member", "name": "postage" }, { "file": "services/api.ts", - "line": 529, + "line": 530, "kind": "member", "name": "images" }, { "file": "services/api.ts", - "line": 530, + "line": 531, "kind": "member", "name": "location" }, { "file": "services/api.ts", - "line": 532, + "line": 533, "kind": "variable", "name": "body" }, @@ -12049,16 +11647,10 @@ }, { "file": "services/api.ts", - "line": 542, + "line": 543, "kind": "variable", "name": "file" }, - { - "file": "services/api.ts", - "line": 549, - "kind": "member", - "name": "area" - }, { "file": "services/api.ts", "line": 55, @@ -12069,113 +11661,119 @@ "file": "services/api.ts", "line": 550, "kind": "member", - "name": "city" + "name": "area" }, { "file": "services/api.ts", "line": 551, "kind": "member", - "name": "division_id" + "name": "city" }, { "file": "services/api.ts", "line": 552, "kind": "member", - "name": "longitude" + "name": "division_id" }, { "file": "services/api.ts", "line": 553, "kind": "member", - "name": "latitude" + "name": "longitude" }, { "file": "services/api.ts", "line": 554, "kind": "member", - "name": "poi_id" + "name": "latitude" }, { "file": "services/api.ts", "line": 555, "kind": "member", - "name": "poi_name" + "name": "poi_id" }, { "file": "services/api.ts", "line": 556, "kind": "member", + "name": "poi_name" + }, + { + "file": "services/api.ts", + "line": 557, + "kind": "member", "name": "province" }, { "file": "services/api.ts", - "line": 559, + "line": 560, "kind": "variable", "name": "recommendPublishCategory" }, { "file": "services/api.ts", - "line": 571, + "line": 572, "kind": "variable", "name": "previewItemPublishBatch" }, { "file": "services/api.ts", - "line": 572, + "line": 573, "kind": "member", "name": "file" }, { "file": "services/api.ts", - "line": 573, + "line": 574, "kind": "member", "name": "imagesZip" }, { "file": "services/api.ts", - "line": 574, + "line": 575, "kind": "member", "name": "defaultCookieId" }, { "file": "services/api.ts", - "line": 575, + "line": 576, "kind": "member", "name": "fallbackCategory" }, { "file": "services/api.ts", - "line": 576, + "line": 577, "kind": "member", "name": "catId" }, { "file": "services/api.ts", - "line": 577, + "line": 578, "kind": "member", "name": "catName" }, { "file": "services/api.ts", - "line": 578, + "line": 579, "kind": "member", "name": "channelCatId" }, { "file": "services/api.ts", - "line": 579, + "line": 580, "kind": "member", "name": "tbCatId" }, { "file": "services/api.ts", - "line": 581, + "line": 582, "kind": "member", "name": "location" }, { "file": "services/api.ts", - "line": 583, + "line": 584, "kind": "variable", "name": "body" }, @@ -12187,61 +11785,55 @@ }, { "file": "services/api.ts", - "line": 595, + "line": 596, "kind": "variable", "name": "startItemPublishBatch" }, { "file": "services/api.ts", - "line": 599, + "line": 600, "kind": "variable", "name": "getItemPublishBatch" }, { "file": "services/api.ts", - "line": 603, + "line": 604, "kind": "variable", "name": "getItemPublishBatches" }, { "file": "services/api.ts", - "line": 604, + "line": 605, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 608, + "line": 609, "kind": "variable", "name": "deleteItemPublishBatch" }, { "file": "services/api.ts", - "line": 612, + "line": 613, "kind": "variable", "name": "cancelItemPublishBatch" }, { "file": "services/api.ts", - "line": 616, + "line": 617, "kind": "variable", "name": "retryFailedItemPublishBatch" }, { "file": "services/api.ts", - "line": 620, + "line": 621, "kind": "variable", "name": "updateItem" }, { "file": "services/api.ts", - "line": 625, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 633, + "line": 626, "kind": "function-expression", "name": "anonymous" }, @@ -12253,13 +11845,13 @@ }, { "file": "services/api.ts", - "line": 638, + "line": 635, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 651, + "line": 639, "kind": "function-expression", "name": "anonymous" }, @@ -12272,66 +11864,72 @@ { "file": "services/api.ts", "line": 653, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 654, "kind": "variable", "name": "cfg" }, { "file": "services/api.ts", - "line": 670, + "line": 671, "kind": "variable", "name": "getShippingRules" }, { "file": "services/api.ts", - "line": 671, + "line": 672, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 672, + "line": 673, "kind": "variable", "name": "rules" }, { "file": "services/api.ts", - "line": 677, + "line": 678, "kind": "member", "name": "cookieId" }, { "file": "services/api.ts", - "line": 678, + "line": 679, "kind": "member", "name": "triggerType" }, { "file": "services/api.ts", - "line": 679, + "line": 680, "kind": "member", "name": "enabled" }, { "file": "services/api.ts", - "line": 680, + "line": 681, "kind": "member", "name": "search" }, { "file": "services/api.ts", - "line": 681, + "line": 682, "kind": "member", "name": "page" }, { "file": "services/api.ts", - "line": 682, + "line": 683, "kind": "member", "name": "pageSize" }, { "file": "services/api.ts", - "line": 685, + "line": 686, "kind": "variable", "name": "getShippingRulesPage" }, @@ -12343,7 +11941,7 @@ }, { "file": "services/api.ts", - "line": 693, + "line": 694, "kind": "variable", "name": "res" }, @@ -12355,7 +11953,7 @@ }, { "file": "services/api.ts", - "line": 701, + "line": 702, "kind": "variable", "name": "rules" }, @@ -12367,28 +11965,22 @@ }, { "file": "services/api.ts", - "line": 710, + "line": 711, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 715, + "line": 716, "kind": "variable", "name": "orderAutomationActions" }, { "file": "services/api.ts", - "line": 717, + "line": 718, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.ts", - "line": 719, - "kind": "variable", - "name": "sendCards" - }, { "file": "services/api.ts", "line": 72, @@ -12398,8 +11990,8 @@ { "file": "services/api.ts", "line": 720, - "kind": "function-expression", - "name": "anonymous" + "kind": "variable", + "name": "sendCards" }, { "file": "services/api.ts", @@ -12415,577 +12007,583 @@ }, { "file": "services/api.ts", - "line": 722, + "line": 723, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "services/api.ts", + "line": 723, "kind": "variable", "name": "others" }, { "file": "services/api.ts", - "line": 725, + "line": 726, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.ts", - "line": 730, - "kind": "variable", - "name": "updateShippingRule" - }, { "file": "services/api.ts", "line": 731, "kind": "variable", - "name": "triggerType" + "name": "updateShippingRule" }, { "file": "services/api.ts", "line": 732, "kind": "variable", + "name": "triggerType" + }, + { + "file": "services/api.ts", + "line": 733, + "kind": "variable", "name": "triggerName" }, { "file": "services/api.ts", - "line": 737, + "line": 738, "kind": "variable", "name": "generatedName" }, { "file": "services/api.ts", - "line": 741, + "line": 742, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.ts", - "line": 741, - "kind": "variable", - "name": "preservedNonCardActions" - }, { "file": "services/api.ts", "line": 742, "kind": "variable", - "name": "baseActions" + "name": "preservedNonCardActions" }, { "file": "services/api.ts", "line": 743, - "kind": "function-expression", - "name": "anonymous" + "kind": "variable", + "name": "baseActions" }, { "file": "services/api.ts", - "line": 763, - "kind": "variable", - "name": "actions" + "line": 744, + "kind": "function-expression", + "name": "anonymous" }, { "file": "services/api.ts", "line": 764, "kind": "variable", + "name": "actions" + }, + { + "file": "services/api.ts", + "line": 765, + "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 772, + "line": 773, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 786, + "line": 787, "kind": "variable", "name": "deleteShippingRule" }, - { - "file": "services/api.ts", - "line": 789, - "kind": "member", - "name": "id" - }, { "file": "services/api.ts", "line": 790, "kind": "member", - "name": "cookie_id" + "name": "id" }, { "file": "services/api.ts", "line": 791, "kind": "member", - "name": "order_id" + "name": "cookie_id" }, { "file": "services/api.ts", "line": 792, "kind": "member", - "name": "trigger_type" + "name": "order_id" }, { "file": "services/api.ts", "line": 793, "kind": "member", - "name": "error_message" + "name": "trigger_type" }, { "file": "services/api.ts", "line": 794, "kind": "member", - "name": "issue_kind" + "name": "error_message" }, { "file": "services/api.ts", "line": 795, "kind": "member", - "name": "allowed_resolutions" + "name": "issue_kind" }, { "file": "services/api.ts", "line": 796, "kind": "member", - "name": "action_cursor" + "name": "allowed_resolutions" }, { "file": "services/api.ts", "line": 797, "kind": "member", - "name": "sent_count" + "name": "action_cursor" }, { "file": "services/api.ts", "line": 798, "kind": "member", - "name": "updated_at" + "name": "sent_count" }, { "file": "services/api.ts", - "line": 802, + "line": 799, "kind": "member", - "name": "id" + "name": "updated_at" }, { "file": "services/api.ts", "line": 803, "kind": "member", - "name": "cookie_id" + "name": "id" }, { "file": "services/api.ts", "line": 804, "kind": "member", - "name": "trigger_type" + "name": "cookie_id" }, { "file": "services/api.ts", "line": 805, "kind": "member", - "name": "error_message" + "name": "trigger_type" }, { "file": "services/api.ts", "line": 806, "kind": "member", - "name": "attempt_count" + "name": "error_message" }, { "file": "services/api.ts", "line": 807, "kind": "member", + "name": "attempt_count" + }, + { + "file": "services/api.ts", + "line": 808, + "kind": "member", "name": "updated_at" }, { "file": "services/api.ts", - "line": 810, + "line": 811, "kind": "member", "name": "pending_tasks" }, { "file": "services/api.ts", - "line": 810, + "line": 811, "kind": "member", "name": "runs" }, { "file": "services/api.ts", - "line": 810, + "line": 811, "kind": "variable", "name": "getAutomationIssues" }, { "file": "services/api.ts", - "line": 811, + "line": 812, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 818, + "line": 819, "kind": "variable", "name": "resolveAutomationRun" }, { "file": "services/api.ts", - "line": 821, + "line": 822, "kind": "variable", "name": "resolveDeferredAutomationTask" }, { "file": "services/api.ts", - "line": 826, + "line": 827, "kind": "member", "name": "id" }, { "file": "services/api.ts", - "line": 827, + "line": 828, "kind": "member", "name": "keyword" }, { "file": "services/api.ts", - "line": 828, + "line": 829, "kind": "member", "name": "reply" }, { "file": "services/api.ts", - "line": 829, + "line": 830, "kind": "member", "name": "item_id" }, { "file": "services/api.ts", - "line": 830, + "line": 831, "kind": "member", "name": "type" }, { "file": "services/api.ts", - "line": 831, + "line": 832, "kind": "member", "name": "image_url" }, { "file": "services/api.ts", - "line": 834, + "line": 835, "kind": "variable", "name": "normalizeKeywordRow" }, { "file": "services/api.ts", - "line": 843, + "line": 844, "kind": "variable", "name": "getKeywordRowsWithType" }, { "file": "services/api.ts", - "line": 844, + "line": 845, "kind": "variable", "name": "existing" }, { "file": "services/api.ts", - "line": 848, + "line": 849, "kind": "variable", "name": "getReplyRules" }, { "file": "services/api.ts", - "line": 850, + "line": 851, "kind": "variable", "name": "keywords" }, { "file": "services/api.ts", - "line": 851, + "line": 852, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.ts", - "line": 863, - "kind": "variable", - "name": "updateReplyRule" - }, { "file": "services/api.ts", "line": 864, "kind": "variable", - "name": "type" + "name": "updateReplyRule" }, { "file": "services/api.ts", "line": 865, "kind": "variable", + "name": "type" + }, + { + "file": "services/api.ts", + "line": 866, + "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 877, + "line": 878, "kind": "variable", "name": "deleteReplyRule" }, { "file": "services/api.ts", - "line": 882, + "line": 883, "kind": "variable", "name": "getSystemSettings" }, { "file": "services/api.ts", - "line": 883, + "line": 884, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 883, + "line": 884, "kind": "variable", "name": "res" }, { "file": "services/api.ts", - "line": 887, + "line": 888, "kind": "variable", "name": "updateSystemSettings" }, { "file": "services/api.ts", - "line": 888, + "line": 889, "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 889, + "line": 890, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 894, + "line": 895, "kind": "variable", "name": "getAccountAISettings" }, { "file": "services/api.ts", - "line": 898, + "line": 899, "kind": "variable", "name": "updateAccountAISettings" }, { "file": "services/api.ts", - "line": 899, + "line": 900, "kind": "variable", "name": "payload" }, - { - "file": "services/api.ts", - "line": 909, - "kind": "variable", - "name": "fetchAIModels" - }, { "file": "services/api.ts", "line": 910, "kind": "variable", + "name": "fetchAIModels" + }, + { + "file": "services/api.ts", + "line": 911, + "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 918, + "line": 919, "kind": "variable", "name": "parseNotificationEventTypes" }, { "file": "services/api.ts", - "line": 922, + "line": 923, "kind": "variable", "name": "parsed" }, { "file": "services/api.ts", - "line": 927, + "line": 928, "kind": "function-expression", "name": "anonymous" }, - { - "file": "services/api.ts", - "line": 930, - "kind": "variable", - "name": "stringifyNotificationEventTypes" - }, { "file": "services/api.ts", "line": 931, "kind": "variable", + "name": "stringifyNotificationEventTypes" + }, + { + "file": "services/api.ts", + "line": 932, + "kind": "variable", "name": "clean" }, { "file": "services/api.ts", - "line": 935, + "line": 936, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 935, + "line": 936, "kind": "member", "name": "success" }, - { - "file": "services/api.ts", - "line": 935, - "kind": "variable", - "name": "getNotificationChannels" - }, { "file": "services/api.ts", "line": 936, "kind": "variable", - "name": "result" + "name": "getNotificationChannels" }, { "file": "services/api.ts", "line": 937, + "kind": "variable", + "name": "result" + }, + { + "file": "services/api.ts", + "line": 938, "kind": "function-expression", "name": "anonymous" }, { "file": "services/api.ts", - "line": 937, + "line": 938, "kind": "variable", "name": "channels" }, { "file": "services/api.ts", - "line": 938, + "line": 939, "kind": "variable", "name": "parsedConfig" }, { "file": "services/api.ts", - "line": 958, + "line": 959, "kind": "member", "name": "config" }, { "file": "services/api.ts", - "line": 958, + "line": 959, "kind": "member", "name": "enabled" }, { "file": "services/api.ts", - "line": 958, + "line": 959, "kind": "member", "name": "event_types" }, { "file": "services/api.ts", - "line": 958, + "line": 959, "kind": "member", "name": "name" }, { "file": "services/api.ts", - "line": 958, + "line": 959, "kind": "member", "name": "type" }, { "file": "services/api.ts", - "line": 958, + "line": 959, "kind": "variable", "name": "createNotificationChannel" }, { "file": "services/api.ts", - "line": 966, + "line": 967, "kind": "member", "name": "config" }, { "file": "services/api.ts", - "line": 966, + "line": 967, "kind": "member", "name": "enabled" }, { "file": "services/api.ts", - "line": 966, + "line": 967, "kind": "member", "name": "event_types" }, { "file": "services/api.ts", - "line": 966, + "line": 967, "kind": "member", "name": "name" }, { "file": "services/api.ts", - "line": 966, + "line": 967, "kind": "member", "name": "type" }, { "file": "services/api.ts", - "line": 966, + "line": 967, "kind": "variable", "name": "updateNotificationChannel" }, { "file": "services/api.ts", - "line": 967, + "line": 968, "kind": "variable", "name": "payload" }, { "file": "services/api.ts", - "line": 977, + "line": 978, "kind": "variable", "name": "deleteNotificationChannel" }, { "file": "services/api.ts", - "line": 982, + "line": 983, "kind": "member", "name": "data" }, { "file": "services/api.ts", - "line": 982, + "line": 983, "kind": "member", "name": "success" }, { "file": "services/api.ts", - "line": 982, + "line": 983, "kind": "variable", "name": "getMessageNotifications" }, { "file": "services/api.ts", - "line": 983, + "line": 984, "kind": "variable", "name": "result" }, { "file": "services/api.ts", - "line": 984, + "line": 985, "kind": "variable", "name": "notifications" }, { "file": "services/api.ts", - "line": 985, + "line": 986, "kind": "variable", "name": "[cookieId, channelList]" }, { "file": "services/api.ts", - "line": 987, + "line": 988, "kind": "variable", "name": "item" }, diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index a265a15..ea0cb3a 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -173,7 +173,8 @@ app shell / routes - 已完成阶段 7 第二个 PR 切片“React ItemList feature 化与批量发布行为边界”:按 `app/features/items` 提取商品/批量 API 适配层、批量任务类型、批量 Hook 和阶段指示器组件;批量预检、任务恢复、轮询取消、失败重试和过期响应均由 feature 状态边界负责;行为测试覆盖预检门禁、取消状态、失败重试、历史任务筛选和过期轮询响应;前端类型检查、全量测试、注释检查和构建门禁通过,合并为一个可回滚提交; - 已完成阶段 7 第三个 PR 切片“React AccountList feature 化与账号运行状态行为边界”:按 `app/features/accounts` 提取账号 API 适配层、账号数据与运行状态 Hook、运行状态展示模型、账号编辑弹窗和登录/暂停状态模型;账号加载与运行状态轮询支持取消和请求代次门禁,密码登录响应按账号与代次隔离,旧组件入口保留兼容转发;行为测试覆盖账号切换、暂停/恢复、凭证失败、风控验证和过期响应;前端类型检查、全量测试、注释检查和构建门禁通过,合并为一个可回滚提交; - 已完成阶段 7 第四个 PR 切片“React CardList feature 化与卡密库存/批量追加行为边界”:按 `app/features/cards` 提取卡密 API 适配层、库存数据 Hook、批量导入/追加状态 Hook 和弹窗组件;卡密筛选、追加预览、提交取消、失败重试与账号切换过期响应均由 feature 状态边界负责,保留旧组件入口和 API 路径;新增状态模型测试并通过前端类型检查、全量测试、注释检查和构建门禁,合并为一个可回滚提交; -- 阶段 7 下一 PR 切片为“React OrderList feature 化与订单导入/刷新行为边界”:提取订单 API、导入/刷新 Hook 和订单筛选组件,补充导入预检、刷新取消、失败重试和过期响应测试; +- 已完成阶段 7 第五个 PR 切片“React OrderList feature 化与订单导入/刷新行为边界”:按 `app/features/orders` 提取订单 API 适配层、查询/分页 Hook、导入 Hook、筛选栏和导入弹窗;订单查询与辅助数据支持并行加载、取消和代次门禁,导入支持文件预检、取消、失败重试和导入后刷新;新增筛选、导入归一化、API 取消信号和过期响应测试,保留旧组件入口和 API 路径;前端类型检查、全量测试、注释检查和构建门禁通过,合并为一个可回滚提交; +- 阶段 7 下一 PR 切片为“React Notifications feature 化与渠道/事件绑定行为边界”:提取通知 API、渠道数据 Hook 和通知绑定组件,补充渠道校验、保存取消、失败重试和过期响应测试; - 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。 ## 6. 阶段 0:治理文档与强约束 @@ -596,3 +597,4 @@ npm --prefix frontend run build | 2026-08-14 | 完成阶段 7 第二个 PR 切片“React ItemList feature 化与批量发布行为边界” | 新增 `app/features/items` 的 API 适配层、批量任务类型、批量 Hook、批量状态模型和阶段指示器组件;批量预检、任务恢复、轮询过期响应、安全取消和失败重试均有独立状态边界;行为测试覆盖预检门禁、取消状态、失败重试、历史任务筛选和过期轮询响应;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React AccountList feature 化与账号运行状态行为边界 | | 2026-08-15 | 完成阶段 7 第三个 PR 切片“React AccountList feature 化与账号运行状态行为边界” | 新增 `app/features/accounts` 的 API 适配层、账号数据与运行状态 Hook、账号编辑弹窗、登录/暂停状态模型;账号加载和运行状态轮询具备取消与代次门禁,密码登录响应按账号与代次隔离,兼容入口保留;行为测试覆盖账号切换、暂停/恢复、凭证失败、风控验证和过期响应;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React CardList feature 化与卡密库存/批量追加行为边界 | | 2026-08-15 | 完成阶段 7 第四个 PR 切片“React CardList feature 化与卡密库存/批量追加行为边界” | 按 `app/features/cards` 提取卡密 API 适配层、库存数据 Hook、批量导入/追加状态 Hook 和弹窗组件;卡密筛选、追加预览、提交取消、失败重试与账号切换过期响应均由 feature 状态边界负责,保留旧组件入口和 API 路径;新增状态模型测试并通过前端类型检查、全量测试、注释检查和构建门禁,合并为一个可回滚提交 | 阶段 7:React OrderList feature 化与订单导入/刷新行为边界 | +| 2026-08-15 | 完成阶段 7 第五个 PR 切片“React OrderList feature 化与订单导入/刷新行为边界” | 按 `app/features/orders` 提取订单 API 适配层、查询/分页 Hook、导入 Hook、筛选栏和导入弹窗;订单查询与辅助数据支持并行加载、取消和代次门禁,导入支持文件预检、取消、失败重试和导入后刷新;新增筛选、导入归一化、API 取消信号和过期响应测试,保留旧组件入口和 API 路径;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React Notifications feature 化与渠道/事件绑定行为边界 | diff --git a/frontend/app/features/orders/api.ts b/frontend/app/features/orders/api.ts new file mode 100644 index 0000000..36bc3d3 --- /dev/null +++ b/frontend/app/features/orders/api.ts @@ -0,0 +1,13 @@ +export { + deleteOrder, + getAccountDetails, + getItems, + getOrders, + importOrders, + manualShipOrder, + syncOrders, + syncSingleOrder, + updateOrder, +} from '../../../services/api'; + +// 订单 feature 通过本文件声明服务 API 来源,页面不再直接依赖通用 API 模块。 diff --git a/frontend/app/features/orders/components/OrderFilterBar.tsx b/frontend/app/features/orders/components/OrderFilterBar.tsx new file mode 100644 index 0000000..8bddb5d --- /dev/null +++ b/frontend/app/features/orders/components/OrderFilterBar.tsx @@ -0,0 +1,90 @@ +import React from 'react'; +import { Search, User as UserIcon } from 'lucide-react'; +import type { AccountDetail } from '../../../../types'; +import { orderStatusOptions } from '../state'; + +// OrderFilterBarProps 描述订单状态、账号和文本筛选所需的页面状态。 +export interface OrderFilterBarProps { + // filter 是当前订单状态筛选值。 + filter: string; + // onFilterChange 响应订单状态筛选切换。 + onFilterChange: (value: string) => void; + // accountFilter 是当前账号筛选值。 + accountFilter: string; + // onAccountFilterChange 响应账号筛选切换。 + onAccountFilterChange: (value: string) => void; + // accounts 是账号下拉框的数据源。 + accounts: AccountDetail[]; + // accountName 将账号 ID 转换为展示名称。 + accountName: (cookieId: string) => string; + // searchText 是搜索框当前输入值。 + searchText: string; + // onSearchChange 响应订单搜索输入。 + onSearchChange: (value: string) => void; +} + +// OrderFilterBar 渲染订单状态、账号和关键词筛选工具栏。 +export const OrderFilterBar: React.FC = ({ + filter, + onFilterChange, + accountFilter, + onAccountFilterChange, + accounts, + accountName, + searchText, + onSearchChange, +}) => { + // handleStatusClick 将用户选择的状态传回订单页面。 + const handleStatusClick = (event: React.MouseEvent) => onFilterChange(event.currentTarget.dataset.status || 'all'); + // handleAccountChange 将用户选择的账号传回订单页面。 + const handleAccountChange = (event: React.ChangeEvent) => onAccountFilterChange(event.target.value); + // handleSearchChange 将用户输入传回订单页面。 + const handleSearchChange = (event: React.ChangeEvent) => onSearchChange(event.target.value); + + return ( +
+
+ {orderStatusOptions.map( + // option 是当前订单状态筛选标签配置。 + option => ( + + ), + )} +
+
+
+ + +
+
+ + +
+
+
+ ); +}; diff --git a/frontend/app/features/orders/components/OrderImportModal.tsx b/frontend/app/features/orders/components/OrderImportModal.tsx new file mode 100644 index 0000000..4a40d5a --- /dev/null +++ b/frontend/app/features/orders/components/OrderImportModal.tsx @@ -0,0 +1,94 @@ +import React from 'react'; +import { createPortal } from 'react-dom'; +import { Upload, X } from 'lucide-react'; +import { failedOrderImportRows } from '../state'; +import type { OrderImportState } from '../types'; + +// OrderImportModalProps 描述订单导入弹窗所需的状态和事件。 +export type OrderImportModalProps = OrderImportState; + +// OrderImportModal 渲染订单文件选择、结果展示和重试操作。 +export const OrderImportModal: React.FC = (state) => { + // handleFileChange 保存用户选择的订单文件并清理旧错误。 + const handleFileChange = (event: React.ChangeEvent) => { + state.setImportFile(event.target.files?.[0] || null); + }; + // handleClose 关闭订单导入弹窗。 + const handleClose = () => state.closeImportModal(); + // handleSubmit 提交当前订单导入文件。 + const handleSubmit = () => void state.handleImportOrders(); + // handleRetry 重试最近一次失败的订单导入。 + const handleRetry = () => void state.handleRetryImport(); + + if (!state.showImportModal) return null; + + return createPortal( +
+
+
+
+

插入订单

+ +
+
+
+
+ + +

支持 .xlsx、.csv、.tsv、.json 格式

+
+ {state.importFile && ( +
+
+ + {state.importFile.name} +
+
+ )} + {state.importError && ( +
+ {state.importError} + +
+ )} + {state.importResult && state.importResult.failed_count > 0 && ( +
+
+ 导入完成:成功 {state.importResult.success_count} 条,失败 {state.importResult.failed_count} 条 +
+
+ + + + + + {failedOrderImportRows(state.importResult).map( + // row 是需要展示失败原因的导入结果行。 + (row, index) => ( + + + + + ), + )} + +
订单ID失败原因
{row.order_id}{row.message || '导入失败'}
+
+
+ )} +
+
+
+ + +
+
+
+
, + document.body, + ); +}; diff --git a/frontend/app/features/orders/hooks.ts b/frontend/app/features/orders/hooks.ts new file mode 100644 index 0000000..54c370b --- /dev/null +++ b/frontend/app/features/orders/hooks.ts @@ -0,0 +1,349 @@ +import { useCallback, useEffect, useMemo, useRef, useState, type Dispatch, type SetStateAction } from 'react'; +import type { AccountDetail, Item, Order } from '../../../types'; +import { getAccountDetails, getItems, getOrders, importOrders } from './api'; +import { canSubmitOrderImport, isCurrentOrderRequest, normalizeOrderImportResult, orderErrorMessage, validateOrderImportFile } from './state'; +import type { OrderImportState, OrderQueryState } from './types'; + +// OrderQueryOptions 描述订单查询 Hook 的固定分页参数。 +interface OrderQueryOptions { + // pageSize 是每页请求的订单数量。 + pageSize: number; +} + +// useOrderQuery 统一管理订单列表加载、筛选、防抖和过期响应保护。 +export const useOrderQuery = (options: OrderQueryOptions = { pageSize: 20 }): OrderQueryState => { + // orders 保存当前页订单。 + const [orders, setOrders] = useState([]); + // items 保存用于补充订单商品名称的商品列表。 + const [items, setItems] = useState([]); + // accounts 保存订单账号筛选下拉框的数据。 + const [accounts, setAccounts] = useState([]); + // filter 保存订单状态筛选值。 + const [filter, setFilter] = useState('all'); + // accountFilter 保存账号筛选值。 + const [accountFilter, setAccountFilter] = useState(''); + // searchText 保存搜索框实时输入值。 + const [searchText, setSearchText] = useState(''); + // debouncedSearch 保存防抖后的服务端搜索值。 + const [debouncedSearch, setDebouncedSearch] = useState(''); + // page 保存当前分页页码。 + const [page, setPage] = useState(1); + // totalPages 保存服务端返回的总页数。 + const [totalPages, setTotalPages] = useState(1); + // loading 表示当前订单查询是否正在执行。 + const [loading, setLoading] = useState(false); + // orderGeneration 隔离筛选变化和手动刷新的旧订单响应。 + const orderGeneration = useRef(0); + // orderAbort 保存当前订单查询的取消控制器。 + const orderAbort = useRef(null); + // auxiliaryAbort 保存账号和商品辅助数据请求的取消控制器。 + const auxiliaryAbort = useRef(null); + + // loadOrders 按当前筛选条件加载订单并取消上一轮请求。 + const loadOrders = useCallback( + // 订单加载回调读取当前筛选条件并更新列表。 + async () => { + // generation 标记本次订单查询请求的代次。 + const generation = ++orderGeneration.current; + orderAbort.current?.abort(); + // controller 允许筛选条件变化时取消旧查询。 + const controller = new AbortController(); + orderAbort.current = controller; + setLoading(true); + try { + // result 是当前筛选条件下的分页订单结果。 + const result = await getOrders(accountFilter || undefined, filter, page, options.pageSize, debouncedSearch, { signal: controller.signal }); + if (!isCurrentOrderRequest(generation, orderGeneration.current)) return; + setOrders(result.data); + setTotalPages(result.total_pages); + } catch (error /* 订单查询异常 */) { + if (isCurrentOrderRequest(generation, orderGeneration.current) && !controller.signal.aborted) { + console.error('加载订单失败:', error); + } + } finally { + if (isCurrentOrderRequest(generation, orderGeneration.current)) setLoading(false); + } + }, + [accountFilter, debouncedSearch, filter, options.pageSize, page], + ); + + // useEffect 防抖搜索输入,避免每次键入都立即请求服务端。 + useEffect( + // 搜索防抖副作用延迟提交用户输入。 + () => { + // timer 是当前搜索输入对应的防抖定时器。 + const timer = window.setTimeout( + // 防抖定时器回调提交标准化搜索文本。 + () => { + setPage(1); + setDebouncedSearch(searchText.trim()); + }, + 300, + ); + return ( + // 防抖清理回调取消上一次搜索定时器。 + () => window.clearTimeout(timer) + ); + }, + [searchText], + ); + + // useEffect 在筛选条件变化时加载订单,并在离开页面时取消请求。 + useEffect( + // 订单查询副作用响应筛选变化并在卸载时取消请求。 + () => { + void loadOrders(); + return ( + // 订单查询清理回调使旧请求代次失效并取消网络请求。 + () => { + orderGeneration.current += 1; + orderAbort.current?.abort(); + } + ); + }, + [loadOrders], + ); + + // useEffect 加载订单展示所需的账号和商品辅助数据。 + useEffect( + // 辅助数据副作用并行读取账号和商品列表。 + () => { + // controller 允许页面卸载时取消辅助数据请求。 + const controller = new AbortController(); + auxiliaryAbort.current?.abort(); + auxiliaryAbort.current = controller; + void Promise.all([ + getAccountDetails({ signal: controller.signal }), + getItems(undefined, { signal: controller.signal }), + ]).then( + // 辅助数据成功回调只接受尚未取消的响应。 + ([accountList, itemsList]) => { + if (controller.signal.aborted) return; + setAccounts(accountList); + setItems(itemsList); + }, + ).catch( + // 辅助数据失败回调忽略主动取消产生的异常。 + (error: unknown) => { + if (!controller.signal.aborted) console.error('加载订单辅助数据失败:', error); + }, + ); + return ( + // 辅助数据清理回调取消账号和商品请求。 + () => controller.abort() + ); + }, + [], + ); + + // accountMap 将账号 ID 映射为账号详情,避免订单列表重复线性查找。 + const accountMap = useMemo( + // 账号索引回调构建稳定的 ID 到详情映射。 + () => new Map(accounts.map( + // account 是当前账号详情。 + account => [account.id, account], + )), + [accounts], + ); + // itemNames 将商品 ID 映射为商品标题,供订单行快速读取。 + const itemNames = useMemo( + // 商品索引回调构建稳定的商品 ID 到标题映射。 + () => { + // namesMap 是商品名称索引的可变构建结果。 + const namesMap: Record = {}; + items.forEach( + // item 是当前商品列表项。 + item => { + if (item.item_id) namesMap[`${item.cookie_id}:${item.item_id}`] = item.item_title || item.item_id; + }, + ); + return namesMap; + }, + [items], + ); + + // accountName 将账号 ID 格式化为筛选下拉框名称。 + const accountName = useCallback( + // 账号名称回调格式化筛选下拉框文本。 + (cookieId: string): string => { + // account 是当前订单所属账号详情。 + const account = accountMap.get(cookieId); + // name 是优先使用备注或昵称的展示名称。 + const name = account?.remark || account?.nickname; + return name ? `${name} · ${cookieId.slice(0, 6)}` : `账号 ${cookieId.slice(0, 8)}`; + }, + [accountMap], + ); + + // accountNickname 将账号 ID 格式化为订单行中的短名称。 + const accountNickname = useCallback( + // 账号昵称回调格式化订单行文本。 + (cookieId: string): string => { + // account 是当前订单所属账号详情。 + const account = accountMap.get(cookieId); + return account?.remark || account?.nickname || '未命名账号'; + }, + [accountMap], + ); + + // getItemNameById 按订单标题、商品索引和相似标题依次解析商品名称。 + const getItemNameById = useCallback( + // 商品名称回调按订单信息解析展示标题。 + (cookieId: string, itemId: string, orderItemTitle?: string): string => { + if (orderItemTitle?.trim()) return orderItemTitle; + // mappedName 是商品索引中直接命中的标题。 + const mappedName = itemNames[`${cookieId}:${itemId}`]; + if (mappedName) return mappedName; + // matchingItem 是标题相似度匹配到的商品。 + const matchingItem = items.find( + // item 是参与标题相似度匹配的商品。 + item => { + if (!orderItemTitle || !item.item_title) return false; + // orderTitleLower 是订单标题的标准化小写文本。 + const orderTitleLower = orderItemTitle.toLowerCase(); + // itemTitleLower 是商品标题的标准化小写文本。 + const itemTitleLower = item.item_title.toLowerCase(); + return itemTitleLower.includes(orderTitleLower) || orderTitleLower.includes(itemTitleLower); + }, + ); + return matchingItem?.item_title || '未知商品'; + }, + [itemNames, items], + ); + + return { + orders, + items, + accounts, + filter, + setFilter, + accountFilter, + setAccountFilter, + searchText, + setSearchText, + page, + setPage, + totalPages, + loading, + loadOrders, + accountName, + accountNickname, + getItemNameById, + }; +}; + +// useOrderImport 统一管理订单导入文件、取消、重试和导入后刷新。 +export const useOrderImport = (loadOrders: () => Promise): OrderImportState => { + // showImportModal 表示订单导入弹窗是否打开。 + const [showImportModal, setShowImportModal] = useState(false); + // importFile 保存当前选择的导入文件。 + const [importFile, setImportFile] = useState(null); + // importResult 保存最近一次导入的逐行结果。 + const [importResult, setImportResult] = useState | null>(null); + // importing 表示导入请求是否正在执行。 + const [importing, setImporting] = useState(false); + // importError 保存导入失败后的可重试错误。 + const [importError, setImportError] = useState(''); + // importGeneration 隔离关闭弹窗后的旧导入响应。 + const importGeneration = useRef(0); + // importAbort 保存当前导入请求的取消控制器。 + const importAbort = useRef(null); + + // openImportModal 打开订单导入弹窗并重置上一次结果。 + const openImportModal = useCallback( + // 打开弹窗回调清理上一次导入状态。 + () => { + setImportFile(null); + setImportResult(null); + setImportError(''); + setShowImportModal(true); + }, + [], + ); + + // closeImportModal 关闭弹窗并取消未完成的导入请求。 + const closeImportModal = useCallback( + // 关闭弹窗回调取消上传并使旧响应失效。 + () => { + importGeneration.current += 1; + importAbort.current?.abort(); + setImporting(false); + setShowImportModal(false); + setImportFile(null); + setImportResult(null); + setImportError(''); + }, + [], + ); + + // handleImportOrders 提交文件,刷新列表并保留失败文件供重试。 + const handleImportOrders = useCallback( + // 订单导入回调执行预检、上传和列表刷新。 + async () => { + if (!canSubmitOrderImport(importFile, importing)) return; + // file 是经过提交门禁确认存在的本次上传文件。 + const file = importFile; + if (!file) return; + // validationError 是文件预检失败时展示给用户的说明。 + const validationError = validateOrderImportFile(file); + if (validationError) { + setImportError(validationError); + return; + } + // generation 标记当前订单导入请求的代次。 + const generation = ++importGeneration.current; + importAbort.current?.abort(); + // controller 允许关闭弹窗时取消文件上传。 + const controller = new AbortController(); + importAbort.current = controller; + setImporting(true); + setImportResult(null); + setImportError(''); + try { + // formData 是上传订单文件的 multipart 请求体。 + const formData = new FormData(); + formData.append('file', file); + // result 是后端返回的订单导入统计。 + const result = normalizeOrderImportResult(await importOrders(formData, { signal: controller.signal })); + if (!isCurrentOrderRequest(generation, importGeneration.current)) return; + setImportResult(result); + setImportFile(null); + await loadOrders(); + if (result.failed_count === 0 && isCurrentOrderRequest(generation, importGeneration.current)) { + alert(`订单导入成功,共 ${result.success_count} 条`); + setShowImportModal(false); + setImportResult(null); + } + } catch (error: unknown /* 订单导入异常 */) { + if (isCurrentOrderRequest(generation, importGeneration.current) && !controller.signal.aborted) { + setImportError(orderErrorMessage(error, '导入失败,请检查文件格式')); + } + } finally { + if (isCurrentOrderRequest(generation, importGeneration.current)) setImporting(false); + } + }, + [importFile, importing, loadOrders], + ); + + // handleRetryImport 复用当前文件重试最近一次失败的导入。 + const handleRetryImport = useCallback( + // 导入重试回调复用当前文件和请求边界。 + async () => { + await handleImportOrders(); + }, + [handleImportOrders], + ); + + return { + showImportModal, + importFile, + setImportFile, + importResult, + importing, + importError, + openImportModal, + closeImportModal, + handleImportOrders, + handleRetryImport, + }; +}; diff --git a/frontend/app/features/orders/state.test.ts b/frontend/app/features/orders/state.test.ts new file mode 100644 index 0000000..cfa32ea --- /dev/null +++ b/frontend/app/features/orders/state.test.ts @@ -0,0 +1,54 @@ +import { expect, test } from 'vitest'; +import { + canSubmitOrderImport, + failedOrderImportRows, + isCurrentOrderRequest, + normalizeOrderImportResult, + orderStatusOptions, + validateOrderImportFile, +} from './state'; + +// createFile 创建订单导入预检使用的最小浏览器文件对象。 +const createFile = (name: string): File => new File(['order'], name, { type: 'text/plain' }); + +test('订单导入响应归一化并保留失败行详情', + // 导入结果测试验证汇总字段和失败行展示数据。 + () => { + // result 是包含成功和失败行的后端兼容响应。 + const result = normalizeOrderImportResult({ + total: 2, + success_count: 1, + failed_count: 1, + results: [ + { order_id: 'ok', success: true, message: '订单已导入' }, + { order_id: 'bad', success: false, message: '不支持的订单状态' }, + ], + }); + expect(result.failed_count).toBe(1); + expect(failedOrderImportRows(result)).toEqual([ + { order_id: 'bad', success: false, message: '不支持的订单状态' }, + ]); + }); + +test('订单导入预检阻止重复提交和不支持的文件格式', + // 导入预检测试验证文件格式和重复提交门禁。 + () => { + expect(canSubmitOrderImport(createFile('orders.csv'), false)).toBe(true); + expect(canSubmitOrderImport(createFile('orders.csv'), true)).toBe(false); + expect(validateOrderImportFile(createFile('orders.xlsx'))).toBe(''); + expect(validateOrderImportFile(createFile('orders.exe'))).toContain('仅支持'); + expect(validateOrderImportFile(null)).toBe('请选择订单文件'); + }); + +test('订单请求代次和筛选标签保持稳定边界', + // 查询边界测试验证旧响应隔离和筛选项顺序。 + () => { + expect(isCurrentOrderRequest(4, 4)).toBe(true); + expect(isCurrentOrderRequest(3, 4)).toBe(false); + expect(orderStatusOptions.map( + // option 是待验证顺序的筛选配置。 + option => option.key, + )).toEqual([ + 'all', 'processing', 'shipped', 'pending_ship', 'completed', 'cancelled', 'refunding', + ]); + }); diff --git a/frontend/app/features/orders/state.ts b/frontend/app/features/orders/state.ts new file mode 100644 index 0000000..c6aa0f6 --- /dev/null +++ b/frontend/app/features/orders/state.ts @@ -0,0 +1,64 @@ +import type { OrderImportResult, OrderImportRowResult } from './types'; + +// orderStatusOptions 是订单状态筛选标签的稳定配置。 +export const orderStatusOptions = [ + { key: 'all', label: '全部' }, + { key: 'processing', label: '处理中' }, + { key: 'shipped', label: '已发货' }, + { key: 'pending_ship', label: '待发货' }, + { key: 'completed', label: '已完成' }, + { key: 'cancelled', label: '已取消' }, + { key: 'refunding', label: '退款中' }, +] as const; + +// normalizeOrderImportResult 将后端兼容响应归一化为稳定的导入结果。 +export const normalizeOrderImportResult = (value: unknown): OrderImportResult => { + // payload 是待读取字段的未知响应对象。 + const payload = typeof value === 'object' && value !== null ? value as Record : {}; + // rawResults 是后端返回的逐行结果数组。 + const rawResults = Array.isArray(payload.results) ? payload.results : []; + return { + total: Number(payload.total || 0), + success_count: Number(payload.success_count || 0), + failed_count: Number(payload.failed_count || 0), + results: rawResults.map(normalizeOrderImportRow), + }; +}; + +// normalizeOrderImportRow 将单行未知响应转换为导入结果行。 +const normalizeOrderImportRow = (value: unknown): OrderImportRowResult => { + // row 是待归一化的单行未知对象。 + const row = typeof value === 'object' && value !== null ? value as Record : {}; + return { + order_id: String(row.order_id || 'unknown'), + success: row.success === true, + message: String(row.message || ''), + }; +}; + +// failedOrderImportRows 筛出需要在导入弹窗中展示的失败行。 +export const failedOrderImportRows = (result: OrderImportResult | null): OrderImportRowResult[] => + result?.results.filter(isFailedOrderImportRow) || []; + +// isFailedOrderImportRow 判断导入结果行是否失败。 +const isFailedOrderImportRow = (row: OrderImportRowResult): boolean => !row.success; + +// canSubmitOrderImport 检查订单导入是否具备文件且没有重复提交。 +export const canSubmitOrderImport = (file: File | null, importing: boolean): boolean => + file !== null && !importing; + +// validateOrderImportFile 检查订单导入文件是否使用支持的扩展名。 +export const validateOrderImportFile = (file: File | null): string => { + if (!file) return '请选择订单文件'; + // extension 是文件名中最后一个点号后的标准化扩展名。 + const extension = file.name.toLowerCase().split('.').pop() || ''; + return ['xlsx', 'csv', 'tsv', 'json'].includes(extension) ? '' : '仅支持 .xlsx、.csv、.tsv、.json 格式'; +}; + +// isCurrentOrderRequest 判断异步订单请求响应是否仍属于当前代次。 +export const isCurrentOrderRequest = (generation: number, currentGeneration: number): boolean => + generation === currentGeneration; + +// orderErrorMessage 将未知异常提取为稳定的用户可见说明。 +export const orderErrorMessage = (error: unknown, fallback: string): string => + error instanceof Error && error.message ? error.message : fallback; diff --git a/frontend/app/features/orders/types.ts b/frontend/app/features/orders/types.ts new file mode 100644 index 0000000..6e846f3 --- /dev/null +++ b/frontend/app/features/orders/types.ts @@ -0,0 +1,96 @@ +import type { Dispatch, SetStateAction } from 'react'; +import type { AccountDetail, Item, Order, OrderStatus } from '../../../types'; + +// OrderImportRowResult 描述订单导入接口返回的单行处理结果。 +export interface OrderImportRowResult { + // order_id 是当前导入行对应的订单号。 + order_id: string; + // success 表示当前订单是否导入成功。 + success: boolean; + // message 是当前订单的成功或失败说明。 + message: string; +} + +// OrderImportResult 描述订单导入接口返回的汇总结果。 +export interface OrderImportResult { + // total 是本次提交的订单总数。 + total: number; + // success_count 是成功导入的订单数。 + success_count: number; + // failed_count 是失败订单数。 + failed_count: number; + // results 保存每一行的处理详情。 + results: OrderImportRowResult[]; +} + +// OrderQueryState 暴露订单列表的查询数据、筛选条件和展示辅助方法。 +export interface OrderQueryState { + // orders 是当前页的订单列表。 + orders: Order[]; + // items 是用于补充商品标题的商品列表。 + items: Item[]; + // accounts 是订单账号筛选下拉框的数据源。 + accounts: AccountDetail[]; + // filter 是当前订单状态筛选条件。 + filter: string; + // setFilter 更新订单状态筛选条件。 + setFilter: Dispatch>; + // accountFilter 是当前账号筛选条件。 + accountFilter: string; + // setAccountFilter 更新账号筛选条件。 + setAccountFilter: Dispatch>; + // searchText 是搜索框当前输入值。 + searchText: string; + // setSearchText 更新搜索框当前输入值。 + setSearchText: Dispatch>; + // page 是当前分页页码。 + page: number; + // setPage 更新当前分页页码。 + setPage: Dispatch>; + // totalPages 是服务端返回的总页数。 + totalPages: number; + // loading 表示订单列表或刷新请求是否正在执行。 + loading: boolean; + // loadOrders 刷新当前筛选条件下的订单列表。 + loadOrders: () => Promise; + // accountName 将账号 ID 转换为筛选下拉框展示名称。 + accountName: (cookieId: string) => string; + // accountNickname 将账号 ID 转换为订单行展示名称。 + accountNickname: (cookieId: string) => string; + // getItemNameById 根据订单信息解析商品展示名称。 + getItemNameById: (cookieId: string, itemId: string, orderItemTitle?: string) => string; +} + +// OrderImportState 暴露订单导入弹窗的状态和事件处理函数。 +export interface OrderImportState { + // showImportModal 表示导入弹窗是否打开。 + showImportModal: boolean; + // importFile 是当前待提交的订单文件。 + importFile: File | null; + // setImportFile 更新当前待提交的订单文件。 + setImportFile: Dispatch>; + // importResult 保存最近一次导入的逐行结果。 + importResult: OrderImportResult | null; + // importing 表示订单导入请求是否正在执行。 + importing: boolean; + // importError 保存最近一次导入请求的错误说明。 + importError: string; + // openImportModal 打开弹窗并清理上一次导入状态。 + openImportModal: () => void; + // closeImportModal 关闭弹窗并取消当前导入请求。 + closeImportModal: () => void; + // handleImportOrders 提交当前文件并刷新订单列表。 + handleImportOrders: () => Promise; + // handleRetryImport 重试最近一次失败的导入请求。 + handleRetryImport: () => Promise; +} + +// OrderStatusOption 描述订单状态筛选标签的显示配置。 +export interface OrderStatusOption { + // key 是传给订单查询接口的状态值。 + key: string; + // label 是筛选标签的中文名称。 + label: string; + // status 是可选的强类型订单状态。 + status?: OrderStatus; +} diff --git a/frontend/components/OrderList.tsx b/frontend/components/OrderList.tsx index f49d709..27cb2b4 100644 --- a/frontend/components/OrderList.tsx +++ b/frontend/components/OrderList.tsx @@ -1,9 +1,11 @@ -import React, { useEffect, useMemo, useRef, useState } from 'react'; +import React, { useState } from 'react'; import { createPortal } from 'react-dom'; -import { AccountDetail, Order, OrderStatus, Item } from '../types'; -import { getOrders, syncOrders, syncSingleOrder, manualShipOrder, updateOrder, deleteOrder, importOrders, getItems, getAccountDetails } from '../services/api'; -import { Search, MoreHorizontal, Truck, RefreshCw, Copy, ChevronLeft, ChevronRight, PackageCheck, Edit, Eye, Plus, Save, X, User as UserIcon, Phone, MapPin, Upload, ExternalLink, Trash2 } from 'lucide-react'; -import { failedOrderImportRows, normalizeOrderImportResult, OrderImportResult } from './orderImportState'; +import type { Order, OrderStatus } from '../types'; +import { deleteOrder, manualShipOrder, syncOrders, syncSingleOrder, updateOrder } from '../app/features/orders/api'; +import { OrderFilterBar } from '../app/features/orders/components/OrderFilterBar'; +import { OrderImportModal } from '../app/features/orders/components/OrderImportModal'; +import { useOrderImport, useOrderQuery } from '../app/features/orders/hooks'; +import { Truck, RefreshCw, ChevronLeft, ChevronRight, PackageCheck, Edit, Eye, Plus, Save, X, User as UserIcon, ExternalLink, Trash2 } from 'lucide-react'; import { formatLocalDateTime } from '../dateTime'; const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => { @@ -35,142 +37,40 @@ const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => { }; const OrderList: React.FC = () => { - const [orders, setOrders] = useState([]); - const [items, setItems] = useState([]); - const [accounts, setAccounts] = useState([]); - const [itemNames, setItemNames] = useState>({}); - const [filter, setFilter] = useState('all'); - const [accountFilter, setAccountFilter] = useState(''); - const [searchText, setSearchText] = useState(''); // 搜索文本 - const [debouncedSearch, setDebouncedSearch] = useState(''); - const requestSequence = useRef(0); - const [page, setPage] = useState(1); - const [totalPages, setTotalPages] = useState(1); - const [loading, setLoading] = useState(false); + // orderQuery 负责订单查询、筛选、分页和展示辅助数据。 + const orderQuery = useOrderQuery(); + // importState 负责订单导入弹窗、上传取消和失败重试。 + const importState = useOrderImport(orderQuery.loadOrders); + const { orders, accounts, filter, setFilter, accountFilter, setAccountFilter, searchText, setSearchText, page, setPage, totalPages, loading, loadOrders, accountName, accountNickname, getItemNameById } = orderQuery; const [showDetailModal, setShowDetailModal] = useState(false); const [showEditModal, setShowEditModal] = useState(false); - const [showImportModal, setShowImportModal] = useState(false); const [selectedOrder, setSelectedOrder] = useState(null); const [editingOrder, setEditingOrder] = useState | null>(null); - const [editForm, setEditForm] = useState>({}); const [showShipModal, setShowShipModal] = useState(false); const [shipOrderId, setShipOrderId] = useState(''); const [shipLoading, setShipLoading] = useState(false); const [shipResult, setShipResult] = useState<{success: boolean; message: string} | null>(null); - const [importFile, setImportFile] = useState(null); - const [importResult, setImportResult] = useState(null); - const [importing, setImporting] = useState(false); const [syncingOrderId, setSyncingOrderId] = useState(null); const [deletingOrderId, setDeletingOrderId] = useState(null); - const loadOrders = async () => { - const sequence = ++requestSequence.current; - setLoading(true); - - try { - const res = await getOrders(accountFilter || undefined, filter, page, 20, debouncedSearch); - if (sequence !== requestSequence.current) return; - setOrders(res.data); - setTotalPages(res.total_pages); - } catch (e) { - console.error('加载订单失败:', e); - } finally { - if (sequence === requestSequence.current) setLoading(false); - } + // handleFilterChange 切换订单状态筛选并回到第一页。 + const handleFilterChange = (value: string) => { + setFilter(value); + setPage(1); + setSearchText(''); }; - - // 从订单的 item_id 查找对应的商品名称(通过标题匹配) - const getItemNameById = (cookieId: string, orderId: string, orderItemTitle?: string): string => { - // 如果订单有 item_title,优先使用 - if (orderItemTitle && orderItemTitle.trim()) { - return orderItemTitle; - } - - // 尝试通过 item_id 直接匹配 - if (itemNames[`${cookieId}:${orderId}`]) { - return itemNames[`${cookieId}:${orderId}`]; - } - - // 尝试在商品列表中查找相似标题的商品 - const matchingItem = items.find(item => { - // 如果订单有标题,尝试匹配商品标题 - if (orderItemTitle && item.item_title) { - // 检查是否包含关键词 - const orderTitleLower = orderItemTitle.toLowerCase(); - const itemTitleLower = item.item_title.toLowerCase(); - return itemTitleLower.includes(orderTitleLower) || orderTitleLower.includes(itemTitleLower); - } - return false; - }); - - if (matchingItem?.item_title) { - return matchingItem.item_title; - } - - return '未知商品'; + // handleAccountFilterChange 切换账号筛选并回到第一页。 + const handleAccountFilterChange = (value: string) => { + setAccountFilter(value); + setPage(1); }; - - // 从商品列表构建商品ID到商品名的映射 - const buildItemNamesMap = () => { - const namesMap: Record = {}; - items.forEach(item => { - // 使用 item_id 作为键,商品标题作为值 - if (item.item_id) { - namesMap[`${item.cookie_id}:${item.item_id}`] = item.item_title || item.item_id; - } - }); - setItemNames(namesMap); - }; - - const buildItemNamesMapFrom = (itemsList: Item[]) => { - const namesMap: Record = {}; - itemsList.forEach(item => { - if (item.item_id) { - namesMap[`${item.cookie_id}:${item.item_id}`] = item.item_title || item.item_id; - } - }); - setItemNames(namesMap); - }; - - useEffect(() => { - const timer = window.setTimeout(() => { - setPage(1); - setDebouncedSearch(searchText.trim()); - }, 300); - return () => window.clearTimeout(timer); - }, [searchText]); - - useEffect(() => { - loadOrders(); - }, [accountFilter, filter, page, debouncedSearch]); - - useEffect(() => { - Promise.all([getAccountDetails(), getItems()]).then(([accountList, itemsList]) => { - setAccounts(accountList); - setItems(itemsList); - buildItemNamesMapFrom(itemsList); - }).catch((e) => { - console.error('加载商品列表失败:', e); - }); - }, []); - - const accountMap = useMemo( - () => new Map(accounts.map(account => [account.id, account])), - [accounts], - ); - - const accountName = (cookieId: string) => { - const account = accountMap.get(cookieId); - const name = account?.remark || account?.nickname; - return name ? `${name} · ${cookieId.slice(0, 6)}` : `账号 ${cookieId.slice(0, 8)}`; - }; - const accountNickname = (cookieId: string) => { - const account = accountMap.get(cookieId); - return account?.remark || account?.nickname || '未命名账号'; + // handleSearchChange 更新订单搜索文本并回到第一页。 + const handleSearchChange = (value: string) => { + setSearchText(value); + setPage(1); }; const handleSync = async () => { - setLoading(true); try { const result = await syncOrders(accountFilter || undefined, filter); await loadOrders(); @@ -180,8 +80,6 @@ const OrderList: React.FC = () => { } catch (error: any) { console.error('同步订单失败:', error); alert(error?.message || '同步失败,请重试'); - } finally { - setLoading(false); } }; @@ -264,35 +162,6 @@ const OrderList: React.FC = () => { } }; - const handleImportOrders = async () => { - if (!importFile) return; - setImporting(true); - try { - const formData = new FormData(); - formData.append('file', importFile); - const result = normalizeOrderImportResult(await importOrders(formData)); - setImportResult(result); - setImportFile(null); - await loadOrders(); - if (result.failed_count === 0) { - setShowImportModal(false); - setImportResult(null); - alert(`订单导入成功,共 ${result.success_count} 条`); - } - } catch (error: any) { - alert(error?.message || '导入失败,请检查文件格式'); - } finally { - setImporting(false); - } - }; - - const closeImportModal = () => { - if (importing) return; - setShowImportModal(false); - setImportFile(null); - setImportResult(null); - }; - const handleSyncSingle = async (orderId: string) => { setSyncingOrderId(orderId); try { @@ -341,7 +210,7 @@ const OrderList: React.FC = () => { - ))} - -
-
- - -
-
- - { setSearchText(e.target.value); setPage(1); }} - className="ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0" - /> -
-
- + {/* Table */}
@@ -673,89 +504,7 @@ const OrderList: React.FC = () => { document.body )} - {/* Import Modal - 使用 Portal */} - {showImportModal && createPortal( -
-
-
-
-

插入订单

- -
-
- -
-
- - setImportFile(e.target.files?.[0] || null)} - className="w-full ios-input px-4 py-3 rounded-xl text-sm" - /> -

支持 .xlsx、.csv、.tsv、.json 格式

-
- - {importFile && ( -
-
- - {importFile.name} -
-
- )} - - {importResult && importResult.failed_count > 0 && ( -
-
- 导入完成:成功 {importResult.success_count} 条,失败 {importResult.failed_count} 条 -
-
- - - - - - {failedOrderImportRows(importResult).map((row, index) => ( - - - - - ))} - -
订单ID失败原因
{row.order_id}{row.message || '导入失败'}
-
-
- )} -
- -
-
- - -
-
-
-
, - document.body - )} + {/* Ship Modal - 发货方式选择 */} {showShipModal && createPortal( diff --git a/frontend/components/orderImportState.test.ts b/frontend/components/orderImportState.test.ts deleted file mode 100644 index 3bcfc3c..0000000 --- a/frontend/components/orderImportState.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { expect, test } from 'vitest'; -import { failedOrderImportRows, normalizeOrderImportResult } from './orderImportState'; - -test('order import state preserves row-level failure details for display', () => { - const result = normalizeOrderImportResult({ - total: 2, - success_count: 1, - failed_count: 1, - results: [ - { order_id: 'ok', success: true, message: '订单已导入' }, - { order_id: 'bad', success: false, message: '不支持的订单状态' }, - ], - }); - expect(result.failed_count).toBe(1); - expect(failedOrderImportRows(result)).toEqual([ - { order_id: 'bad', success: false, message: '不支持的订单状态' }, - ]); -}); diff --git a/frontend/components/orderImportState.ts b/frontend/components/orderImportState.ts index bc8f2f2..83b8cd7 100644 --- a/frontend/components/orderImportState.ts +++ b/frontend/components/orderImportState.ts @@ -1,26 +1,8 @@ -export interface OrderImportRowResult { - order_id: string; - success: boolean; - message: string; -} - -export interface OrderImportResult { - total: number; - success_count: number; - failed_count: number; - results: OrderImportRowResult[]; -} - -export const normalizeOrderImportResult = (value: any): OrderImportResult => ({ - total: Number(value?.total || 0), - success_count: Number(value?.success_count || 0), - failed_count: Number(value?.failed_count || 0), - results: Array.isArray(value?.results) ? value.results.map((row: any) => ({ - order_id: String(row?.order_id || 'unknown'), - success: row?.success === true, - message: String(row?.message || ''), - })) : [], -}); - -export const failedOrderImportRows = (result: OrderImportResult | null): OrderImportRowResult[] => - result?.results.filter(row => !row.success) || []; +export { + failedOrderImportRows, + normalizeOrderImportResult, +} from '../app/features/orders/state'; +export type { + OrderImportResult, + OrderImportRowResult, +} from '../app/features/orders/types'; diff --git a/frontend/services/api.test.ts b/frontend/services/api.test.ts index f3dae86..95d14d5 100644 --- a/frontend/services/api.test.ts +++ b/frontend/services/api.test.ts @@ -146,6 +146,20 @@ test('getOrders maps unsupported backend statuses to unknown', async () => { expect(result.data[0].status).toBe('unknown'); }); +test('订单查询和导入 API 转发外部取消信号', async () => { + // fetchMock 是同时验证订单查询和文件上传请求控制参数的替身。 + const fetchMock = vi.fn() + .mockResolvedValueOnce(jsonResponse({ data: [], total_pages: 1 })) + .mockResolvedValueOnce(jsonResponse({ success_count: 1, failed_count: 0, results: [] })); + vi.stubGlobal('fetch', fetchMock); + // controller 是 feature Hook 传入 API 的取消控制器。 + const controller = new AbortController(); + await getOrders(undefined, 'all', 1, 20, '', { signal: controller.signal }); + await importOrders(new FormData(), { signal: controller.signal }); + expect(fetchMock).toHaveBeenNthCalledWith(1, '/api/v1/orders?page=1&page_size=20', expect.objectContaining({ signal: expect.any(AbortSignal) })); + expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/v1/orders/import', expect.objectContaining({ signal: expect.any(AbortSignal) })); +}); + test('getShippingRulesPage sends filters and preserves pagination metadata', async () => { const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ data: [{ id: 7, name: '付款规则', trigger_type: 'order_paid', enabled: false, actions: [] }], diff --git a/frontend/services/api.ts b/frontend/services/api.ts index 80941e4..608a742 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -308,13 +308,14 @@ export const getOrders = async ( page: number = 1, pageSize: number = 20, search?: string, + options?: RequestControlOptions, ): Promise> => { const params: any = { page, page_size: pageSize }; if (cookieId) params.cookie_id = cookieId; if (status && status !== 'all') params.status = status; if (search?.trim()) params.search = search.trim(); - const res = await get & { orders?: Order[] /* 后端兼容的订单列表字段。 */ }>('/api/v1/orders', params); + const res = await get & { orders?: Order[] /* 后端兼容的订单列表字段。 */ }>('/api/v1/orders', params, options); // Handle backend response variations const rawOrders = res.orders || res.data || []; @@ -369,9 +370,9 @@ export const manualShipOrder = async (orderIds: string[], shipMode: 'status_only }); } -export const importOrders = async (data: Partial[] | FormData): Promise => { +export const importOrders = async (data: Partial[] | FormData, options?: RequestControlOptions): Promise => { const isFormData = data instanceof FormData; - return isFormData ? postForm('/api/v1/orders/import', data) : post('/api/v1/orders/import', data); + return isFormData ? postForm('/api/v1/orders/import', data, options) : post('/api/v1/orders/import', data, options); } // Stats @@ -493,8 +494,8 @@ export const appendCardData = async (cardId: string | number, content: string, o const normalizeBooleanFlag = (value: unknown): boolean => value === true || value === 1 || value === '1'; -export const getItems = async (cookieId?: string): Promise => { - const res = await get('/api/v1/items', cookieId ? { cookie_id: cookieId } : undefined); +export const getItems = async (cookieId?: string, options?: RequestControlOptions): Promise => { + const res = await get('/api/v1/items', cookieId ? { cookie_id: cookieId } : undefined, options); const items = Array.isArray(res) ? res : (res.items || []); return items.map((item: any) => ({ ...item, diff --git a/internal/webui/static/assets/icons-vendor-BFpWAqQX.js b/internal/webui/static/assets/icons-vendor-BJ6r5aOc.js similarity index 99% rename from internal/webui/static/assets/icons-vendor-BFpWAqQX.js rename to internal/webui/static/assets/icons-vendor-BJ6r5aOc.js index 5d1e745..1b4ca64 100644 --- a/internal/webui/static/assets/icons-vendor-BFpWAqQX.js +++ b/internal/webui/static/assets/icons-vendor-BJ6r5aOc.js @@ -413,4 +413,4 @@ import{r as h}from"./react-vendor-C_od1ZSF.js";/** * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const F1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],_0=e("zap",F1);export{k2 as $,O1 as A,Q1 as B,i2 as C,r2 as D,l2 as E,s0 as F,u2 as G,K2 as H,c0 as I,d0 as J,f2 as K,z2 as L,P2 as M,q2 as N,x2 as O,D2 as P,I2 as Q,O2 as R,X2 as S,y0 as T,i0 as U,n2 as V,N2 as W,M0 as X,v2 as Y,_0 as Z,e0 as _,K1 as a,m2 as a0,B2 as a1,d2 as a2,o2 as a3,y2 as a4,b2 as a5,Z1 as a6,j2 as a7,p2 as a8,e2 as a9,J2 as aa,A2 as ab,n0 as ac,h2 as ad,g2 as ae,w2 as af,G2 as ag,L2 as ah,p0 as ai,l0 as aj,r0 as ak,X1 as al,a0 as am,$2 as an,H2 as ao,Q2 as b,t2 as c,a2 as d,V2 as e,c2 as f,Y2 as g,E2 as h,h0 as i,C2 as j,U2 as k,T2 as l,t0 as m,J1 as n,Z2 as o,Y1 as p,s2 as q,M2 as r,_2 as s,k0 as t,G1 as u,S2 as v,R2 as w,F2 as x,o0 as y,W2 as z}; + */const F1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],_0=e("zap",F1);export{k2 as $,O1 as A,Q1 as B,i2 as C,r2 as D,l2 as E,d0 as F,u2 as G,W2 as H,s0 as I,c0 as J,f2 as K,z2 as L,P2 as M,q2 as N,x2 as O,D2 as P,I2 as Q,O2 as R,X2 as S,y0 as T,i0 as U,n2 as V,N2 as W,M0 as X,v2 as Y,_0 as Z,e0 as _,K1 as a,m2 as a0,B2 as a1,d2 as a2,o2 as a3,y2 as a4,b2 as a5,Z1 as a6,j2 as a7,p2 as a8,e2 as a9,J2 as aa,A2 as ab,n0 as ac,h2 as ad,g2 as ae,w2 as af,G2 as ag,L2 as ah,p0 as ai,l0 as aj,r0 as ak,X1 as al,a0 as am,$2 as an,H2 as ao,Q2 as b,t2 as c,a2 as d,V2 as e,c2 as f,Y2 as g,E2 as h,h0 as i,C2 as j,U2 as k,T2 as l,t0 as m,J1 as n,Z2 as o,Y1 as p,s2 as q,M2 as r,_2 as s,k0 as t,G1 as u,S2 as v,R2 as w,F2 as x,o0 as y,K2 as z}; diff --git a/internal/webui/static/assets/index-7zzRZ1Ef.js b/internal/webui/static/assets/index-7zzRZ1Ef.js new file mode 100644 index 0000000..ea1c432 --- /dev/null +++ b/internal/webui/static/assets/index-7zzRZ1Ef.js @@ -0,0 +1,20 @@ +import{j as e,r as l,c as Ns,b as Oe,d as Ga}from"./react-vendor-C_od1ZSF.js";import{L as Qa,U as ma,M as cs,C as _s,B as ua,S as pa,Z as ds,a as ft,b as vs,G as Is,c as ws,d as ks,e as Va,f as at,A as Os,D as Ka,g as Rs,P as ha,h as Et,E as ga,T as Ha,i as Za,j as we,X as Le,k as Ya,l as Xa,m as Cs,n as ba,o as Ye,p as Ve,q as ya,K as el,r as nt,s as st,Q as Ht,t as ot,u as yt,v as Rt,R as Ue,w as fa,x as tl,y as Qe,z as Nt,F as Pt,H as Xe,I as Ps,J as jt,N as sl,O as al,V as ll,W as ja,Y as Na,_ as _a,$ as rl,a0 as nl,a1 as Zt,a2 as Mt,a3 as xs,a4 as il,a5 as ol,a6 as ms,a7 as $s,a8 as cl,a9 as dl,aa as $t,ab as Es,ac as Jt,ad as va,ae as xl,af as ml,ag as Vt,ah as wa,ai as ul,aj as pl,ak as hl,al as gl,am as bl,an as yl,ao as Ts}from"./icons-vendor-BJ6r5aOc.js";import{R as Bt,B as fl,X as Ds,Y as Ms,T as qt,a as jl,C as Yt,A as Nl,b as _l,c as vl,P as Bs,d as qs,L as wl}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const f of r)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&n(p)}).observe(document,{childList:!0,subtree:!0});function a(r){const f={};return r.integrity&&(f.integrity=r.integrity),r.referrerPolicy&&(f.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?f.credentials="include":r.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function n(r){if(r.ep)return;r.ep=!0;const f=a(r);fetch(r.href,f)}})();const kl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,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"})})}),us=({sizeClass:t="w-12 h-12",logoClassName:s="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 ${t} 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:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),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(kl,{className:s})})]})]}),Cl=({activeTab:t,isAdmin:s=!1,collapsed:a,onToggleCollapsed:n,onNavigate:r,onLogout:f})=>{const[p,w]=l.useState({version:"dev",commit:"unknown"});l.useEffect(()=>{const u=new AbortController;return fetch("/health",{signal:u.signal}).then(C=>C.ok?C.json():Promise.reject(new Error("health request failed"))).then(C=>w({version:String(C.version||"dev"),commit:String(C.commit||"unknown")})).catch(C=>{C instanceof DOMException&&C.name}),()=>u.abort()},[]);const m=[{id:"dashboard",icon:Qa,label:"仪表盘"},{id:"accounts",icon:ma,label:"账号管理"},{id:"chat",icon:cs,label:"在线聊天"},{id:"cards",icon:_s,label:"卡密库存"},{id:"items",icon:ua,label:"商品列表"},{id:"orders",icon:pa,label:"订单管理"},{id:"rules",icon:ds,label:"自动化规则"},{id:"notifications",icon:ft,label:"通知设置"},...s?[{id:"settings",icon:vs,label:"系统与AI"}]:[]],k=/^\d+\.\d+\.\d+$/.test(p.version)?`v${p.version}`:p.version;return e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${a?"w-16":"w-64"}`,children:[e.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${a?"justify-center px-2":"gap-3 px-5"}`,children:[e.jsx(us,{sizeClass:"h-10 w-10"}),!a&&e.jsxs("div",{className:"min-w-0 leading-tight",children:[e.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),e.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),e.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${a?"px-2":"px-3"}`,"aria-label":"主导航",children:m.map(u=>{const C=u.icon,M=t===u.id;return e.jsx(Ns.Fragment,{children:e.jsxs("button",{type:"button",title:a?u.label:void 0,"aria-label":u.label,"aria-current":M?"page":void 0,onClick:()=>r(u.id),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${a?"justify-center":"gap-3 px-3.5"} ${M?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[e.jsx(C,{className:`h-[19px] w-[19px] shrink-0 ${M?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),!a&&e.jsx("span",{className:"truncate text-sm font-bold",children:u.label}),M&&!a&&e.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},u.id)})}),e.jsxs("div",{children:[e.jsx("div",{title:a?`版本 ${p.version} · ${p.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${a?"flex justify-center px-1":"px-6"}`,children:a?e.jsx(Is,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${p.version}`}):e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[e.jsx(Is,{className:"h-3.5 w-3.5"}),"运行版本"]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:k}),e.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:p.commit})]})]})}),e.jsxs("div",{className:`space-y-2 p-2 ${a?"":"p-3"}`,children:[e.jsxs("button",{type:"button",onClick:n,title:a?"展开侧边栏":"收起侧边栏","aria-label":a?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${a?"justify-center":"gap-3 px-3"}`,children:[a?e.jsx(ws,{className:"h-5 w-5"}):e.jsx(ks,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),e.jsxs("button",{type:"button",onClick:f,title:a?"退出登录":void 0,"aria-label":"退出登录",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${a?"justify-center":"gap-3 px-3"}`,children:[e.jsx(Va,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},Sl=3e4,Ll=10*6e4;let Xt=!1;const ka=()=>{Xt||typeof window>"u"||(Xt=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{Xt=!1}))},Al=t=>{if(!t)return"";const s=new URLSearchParams;for(const[n,r]of Object.entries(t))r!=null&&s.set(n,String(r));const a=s.toString();return a?`?${a}`:""},Kt=async(t,s,a={})=>{var k;const n=Al(a.params),r=`${s}${n}`,f=Ca(a.signal,a.timeoutMs??Sl);let p;try{p=await fetch(r,{method:t,credentials:"include",signal:f.signal,headers:{...a.body===void 0?{}:{"Content-Type":"application/json"}},body:a.body===void 0?void 0:JSON.stringify(a.body)})}catch(u){throw f.signal.aborted?new Error((k=a.signal)!=null&&k.aborted?"请求已取消":"请求超时,请稍后重试"):u}finally{f.cleanup()}const m=(p.headers.get("content-type")||"").includes("application/json");if(!p.ok){p.status===401&&!a.skipAuthLogout&&ka();const u=m?await p.json().catch(()=>{}):await p.text().catch(()=>{}),C=Sa(u,p.status);throw new Error(C)}return m?await p.json():await p.text()},Ne=async(t,s,a)=>Kt("GET",t,{params:s,...a}),fe=async(t,s,a)=>Kt("POST",t,{body:s,...a}),Fe=async(t,s,a)=>Kt("PUT",t,{body:s,...a}),Ke=async(t,s,a)=>Kt("DELETE",t,{params:s,...a}),vt=async(t,s,a={})=>{var m;const n=Ca(a.signal,a.timeoutMs??Ll);let r;try{r=await fetch(t,{method:"POST",credentials:"include",signal:n.signal,body:s})}catch(k){throw n.signal.aborted?new Error((m=a.signal)!=null&&m.aborted?"请求已取消":"上传超时,请稍后重试"):k}finally{n.cleanup()}const w=(r.headers.get("content-type")||"").includes("application/json")?await r.json().catch(()=>{}):await r.text().catch(()=>{});if(!r.ok){r.status===401&&ka();const k=Sa(w,r.status),u=new Error(k);throw u.payload=w,u}return w},Ca=(t,s)=>{const a=new AbortController,n=()=>a.abort(t==null?void 0:t.reason);t!=null&&t.aborted?n():t==null||t.addEventListener("abort",n,{once:!0});const r=globalThis.setTimeout(()=>a.abort(new DOMException("timeout","TimeoutError")),Math.max(1,s));return{signal:a.signal,cleanup:()=>{globalThis.clearTimeout(r),t==null||t.removeEventListener("abort",n)}}},Il=t=>{if(typeof t!="object"||t===null)return!1;const s=t;return typeof s.code=="string"&&typeof s.message=="string"},Sa=(t,s)=>typeof t=="string"?t:Il(t)?t.message:`请求失败: ${s}`,Gt=t=>{const s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${s}-${a}-${n}`},Ss=(t,s)=>{const a=new Date(t);return a.setHours(12,0,0,0),a.setDate(a.getDate()+s),a},ps=(t,s)=>({startDate:Gt(Ss(t,-(s-1))),endDate:Gt(t)}),Fs=(t,s=new Date,a="",n="")=>{if(t==="custom"&&a&&n){if(a>n)throw new Error("开始日期不能晚于结束日期");return{startDate:a,endDate:n}}return t==="yesterday"?ps(Ss(s,-1),1):ps(s,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Ol=t=>{const s=new Date(`${t.startDate}T12:00:00`),a=new Date(`${t.endDate}T12:00:00`),n=Math.round((a.getTime()-s.getTime())/864e5)+1,r=Ss(s,-1);return ps(r,n)},Rl=t=>{const s={...t};if("renewal_log_retention_days"in s){const a=Number(s.renewal_log_retention_days);s.renewal_log_retention_days=Number.isFinite(a)?a:10}return s},Pl=async t=>fe("/api/v1/session/login",t,{skipAuthLogout:!0}),$l=async t=>fe("/api/v1/session/initialize",{password:t},{skipAuthLogout:!0}),La=async()=>Ne("/api/v1/session"),El=async()=>fe("/api/v1/session/logout",{}),Tl=async t=>Fe("/api/v1/session/credentials",t),Dl=(t,s)=>{const a=t.avatar_url||"";if(!a)return"";try{const n=new URL(a,window.location.origin);return n.hostname.endsWith("alicdn.com")&&n.searchParams.set("_v",s),n.toString()}catch{return a}},Tt=async t=>{const s=await Ne("/api/v1/accounts/details",void 0,t),a=Date.now().toString();return s.map(n=>({id:n.id,value:"",cookie:"",enabled:n.enabled,auto_confirm:n.auto_confirm,remark:n.remark,note:n.remark,pause_duration:n.pause_duration,paused_until:Number(n.paused_until||0),paused:n.paused===!0,username:n.username||"",login_password:"",show_browser:n.show_browser===!0||n.show_browser===1||n.show_browser==="1"||n.show_browser==="true",nickname:n.nickname||n.remark||`账号 ${n.id.substring(0,6)}`,avatar_url:Dl(n,a),profile_error:n.profile_error||"",ai_enabled:!1,auto_rate_enabled:n.auto_rate_enabled,rate_content:n.rate_content||"不错的买家,交易愉快",auto_polish_enabled:n.auto_polish_enabled,polish_time:n.polish_time||"03:00",last_rate_scan_at:Number(n.last_rate_scan_at||0),last_polish_date:n.last_polish_date||"",last_polish_at:Number(n.last_polish_at||0)}))},Ml=async t=>Ne(`/api/v1/account-tasks/${t}`),zs=async(t,s)=>Fe(`/api/v1/account-tasks/${t}`,s),Bl=async(t,s)=>fe(`/api/v1/account-tasks/${t}/run`,{task_type:s},{timeoutMs:12e4}),es=async(t,s,a,n=!1)=>{const r=await Ne("/api/v1/chat/sessions",{account_id:t,cursor:s,refresh:n?1:void 0},n?{timeoutMs:6e4,...a}:a);return{sessions:r.sessions||[],has_more:r.has_more===!0,next_cursor:r.next_cursor}},hs=async(t,s,a,n,r)=>{const f=await Ne("/api/v1/chat/messages",{account_id:t,chat_id:s,cursor:a,before_id:n},r);return{messages:f.messages||[],has_more:f.has_more===!0,next_cursor:f.next_cursor,session:f.session}},ql=async(t,s,a,n)=>(await hs(t,s,void 0,a,n)).messages,Fl=async t=>fe("/api/v1/chat/messages",t),zl=async t=>{const s=new FormData;return Object.entries(t).forEach(([a,n])=>s.append(a,n)),vt("/api/v1/chat/images",s,{timeoutMs:12e4})},Us=async(t,s)=>fe("/api/v1/chat/read",{account_id:t,chat_id:s}),gs=async t=>Ne("/api/v1/accounts/runtime-status",void 0,t),Ul=async t=>fe("/api/v1/qr-login/generate",void 0,{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),Wl=async(t,s)=>Ne(`/api/v1/qr-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),Jl=async(t,s)=>fe(`/api/v1/qr-login/complete-verification/${t}`,{target_account_id:s||""}),Gl=async(t,s)=>Fe(`/api/v1/accounts/${t}/status`,{enabled:s}),Ql=async t=>Ke(`/api/v1/accounts/${t}`),Vl=async(t,s)=>Fe(`/api/v1/accounts/${t}/pause-duration`,{pause_duration:s}),Kl=async(t,s)=>Fe(`/api/v1/accounts/${t}/settings`,s),Hl=async t=>Ne(`/api/v1/accounts/${t}/long-login`),Zl=async(t,s)=>Fe(`/api/v1/accounts/${t}/long-login`,{enabled:s}),Yl=async t=>fe("/api/v1/password-login",t),Xl=async(t,s)=>Ne(`/api/v1/password-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),er=async t=>Ke(`/api/v1/password-login/cancel/${t}`),tr=async t=>fe(`/api/v1/accounts/${t}/refresh-profile`,{}),sr=async t=>Ne("/api/v1/settings/ai-reply",void 0,t),Aa=t=>{const s=String(t||"");return s==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(s)?s:"unknown"},ar=async(t,s,a=1,n=20,r,f)=>{const p={page:a,page_size:n};t&&(p.cookie_id=t),s&&s!=="all"&&(p.status=s),r!=null&&r.trim()&&(p.search=r.trim());const w=await Ne("/api/v1/orders",p,f),k=(w.orders||w.data||[]).map(u=>({...u,id:u.id||u.order_id,status:Aa(u.status||u.order_status),quantity:Number(u.quantity||1)}));return{success:!0,data:k,total:w.total||k.length,page:w.page||a,page_size:w.page_size||n,total_pages:w.total_pages||1}},lr=async(t,s)=>Fe(`/api/v1/orders/${t}`,s),rr=async t=>Ke(`/api/v1/orders/${t}`),nr=async(t,s)=>{const a=new FormData;return t&&a.append("cookie_id",t),s&&a.append("status",s),vt("/api/v1/orders/refresh",a)},ir=async t=>fe(`/api/v1/orders/${t}/refresh`),or=async(t,s)=>fe("/api/v1/orders/manual-ship",{order_ids:t,ship_mode:s}),cr=async(t,s)=>t instanceof FormData?vt("/api/v1/orders/import",t,s):fe("/api/v1/orders/import",t,s),dr=async()=>Ne("/api/v1/analytics/dashboard"),Ws=async(t=7)=>{let s;if(typeof t=="number"){const a=new Date,n=new Date;n.setDate(n.getDate()-t),s={start_date:Gt(n),end_date:Gt(a)}}else s=t;return Ne("/api/v1/analytics/orders",{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()})},xr=async t=>{const s=await Ne("/api/v1/analytics/orders/valid",{start_date:t.start_date,end_date:t.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()}),n=(Array.isArray(s)?s:s.orders||[]).map(r=>({...r,id:r.id||r.order_id,status:Aa(r.status||r.order_status),quantity:Number(r.quantity||1)}));return{orders:n,total:Array.isArray(s)?n.length:Number(s.total??n.length),truncated:Array.isArray(s)?!1:s.truncated===!0}},mr=t=>{let s=t.api_config;if(typeof s=="string"&&s.trim())try{s=JSON.parse(s)}catch{s=void 0}return{...t,api_config:s||void 0}},Ia=t=>({...t,api_config:t.api_config?JSON.stringify(t.api_config):""}),Ls=async t=>{const s=await Ne("/api/v1/cards",void 0,t);return(Array.isArray(s)?s:s.cards||[]).map(mr)},ur=async t=>fe("/api/v1/cards",Ia(t)),Js=async(t,s)=>Fe(`/api/v1/cards/${t}`,Ia(s)),pr=async t=>Ke(`/api/v1/cards/${t}`),hr=async(t,s)=>{const a=new FormData;return a.append("file",t),vt("/api/v1/cards/batch",a,s)},gr=async(t,s,a)=>fe(`/api/v1/cards/${t}/append-data`,{content:s},a),ts=t=>t===!0||t===1||t==="1",_t=async(t,s)=>{const a=await Ne("/api/v1/items",void 0,s);return(Array.isArray(a)?a:a.items||[]).map(r=>({...r,id:r.id||`${r.cookie_id}-${r.item_id}`,is_multi_spec:ts(r.is_multi_spec),is_multi_qty_ship:ts(r.is_multi_qty_ship??r.multi_quantity_delivery),multi_quantity_delivery:ts(r.multi_quantity_delivery??r.is_multi_qty_ship)}))},br=async t=>fe("/api/v1/items/get-all-from-account",{cookie_id:t}),yr=async(t,s)=>Ke(`/api/v1/items/${t}/${s}`),fr=async(t,s)=>fe(`/api/v1/items/${t}`,s),jr=async t=>{const s=new FormData;s.set("cookie_id",t.cookie_id),s.set("title",t.title),s.set("description",t.description),s.set("price",t.price),s.set("original_price",t.original_price||""),s.set("quantity",String(t.quantity)),s.set("postage_mode",t.postage_mode),s.set("postage",t.postage||""),t.location&&s.set("location",JSON.stringify(t.location));for(const a of t.images)s.append("images",a);return vt("/api/v1/items/publish",s)},Nr=async(t,s)=>fe("/api/v1/items/publish-categories/recommend",{cookie_id:t,keyword:s}),_r=async t=>{const s=new FormData;return s.set("file",t.file),t.imagesZip&&s.set("images_zip",t.imagesZip),t.defaultCookieId&&s.set("default_cookie_id",t.defaultCookieId),s.set("fallback_category_id",t.fallbackCategory.catId),s.set("fallback_category_name",t.fallbackCategory.catName),s.set("fallback_channel_category_id",t.fallbackCategory.channelCatId||""),s.set("fallback_tb_category_id",t.fallbackCategory.tbCatId||""),t.location&&s.set("location",JSON.stringify(t.location)),vt("/api/v1/items/publish-batches/preview",s)},vr=async t=>fe("/api/v1/items/publish-batches",{preview_id:t}),ht=async t=>Ne(`/api/v1/items/publish-batches/${t}`),Oa=async(t=20)=>{const s=await Ne("/api/v1/items/publish-batches",{limit:t});return Array.isArray(s)?s:s.batches||[]},wr=async t=>Ke(`/api/v1/items/publish-batches/${t}`),kr=async t=>fe(`/api/v1/items/publish-batches/${t}/cancel`,{}),Cr=async t=>fe(`/api/v1/items/publish-batches/${t}/retry-failed`,{}),Sr=async(t,s,a)=>Fe(`/api/v1/items/${t}/${s}`,a),Ra=t=>t.map(s=>{var a,n;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((a=(s.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:a.card_id)||0),card_group_name:((n=(s.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:n.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(r=>({id:r.id?String(r.id):void 0,action_type:r.action_type,card_id:Number(r.card_id||0),card_name:r.card_name||"",delivery_count:Number(r.delivery_count||1),message_template:r.message_template||"",delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}",enabled:r.enabled!==!1,sort_order:Number(r.sort_order||0)})),variants:(s.actions||[]).filter(r=>r.action_type==="send_card").map(r=>{let f={};try{f=JSON.parse(r.config_json||"{}")}catch{}return{id:r.id?String(r.id):void 0,spec_name:f.spec_name||"",spec_value:f.spec_value||"",card_id:Number(r.card_id||0),card_name:r.card_name||"",delivery_count:Number(r.delivery_count||1),enabled:r.enabled!==!1,delay_override:f.delay_override===!0,delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}"}})}}),bs=async()=>{const t=await Ne("/api/v1/automation-rules"),s=Array.isArray(t)?t:t.data||[];return Ra(s)},Lr=async({cookieId:t,triggerType:s,enabled:a,search:n,page:r=1,pageSize:f=10}={})=>{const p=await Ne("/api/v1/automation-rules",{page:r,page_size:f,cookie_id:t||void 0,trigger_type:s||void 0,enabled:a,search:(n==null?void 0:n.trim())||void 0}),w=Ra(Array.isArray(p)?p:p.data||[]);return{success:!0,data:w,total:Number(Array.isArray(p)?w.length:p.total??w.length),page:Number(Array.isArray(p)?r:p.page??r),page_size:Number(Array.isArray(p)?f:p.page_size??f),total_pages:Number(Array.isArray(p)?w.length?1:0:p.total_pages??(w.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(Array.isArray(p)?{}:p.trigger_counts||{}).map(([m,k])=>[m,Number(k)]))}},Ar=(t,s)=>{if(t!=="order_paid")return s.map((r,f)=>({...r,sort_order:r.sort_order||f+1}));const a=s.filter(r=>r.action_type==="send_card").map((r,f)=>({...r,sort_order:f+1})),n=s.filter(r=>r.action_type!=="send_card"&&r.action_type!=="confirm_shipment");return[...a,...n.map((r,f)=>({...r,sort_order:a.length+f+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:a.length+n.length+1}]},Gs=async t=>{const s=t.trigger_type||"order_paid",n=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[s]||"自动化规则",t.item_title||t.item_id||t.cookie_id||""].filter(Boolean).join(" - "),r=(t.actions||[]).filter(m=>m.action_type!=="send_card"&&m.action_type!=="confirm_shipment"),f=t.variants&&t.variants.length>0?[...t.variants.map((m,k)=>({action_type:"send_card",card_id:m.card_id,delivery_count:m.delivery_count||1,enabled:m.enabled!==!1,sort_order:k+1,delay_seconds:m.delay_seconds||0,config_json:JSON.stringify({spec_name:m.spec_name||"",spec_value:m.spec_value||"",delay_override:m.delay_override===!0})})),...r]:t.actions&&t.actions.length>0?t.actions:[{action_type:"send_card",card_id:t.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],p=Ar(s,f),w={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||n||"自动化规则",trigger_type:s,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:p.map((m,k)=>({action_type:m.action_type,card_id:m.card_id||0,delivery_count:m.delivery_count||1,message_template:m.message_template||"",delay_seconds:m.delay_seconds||0,config_json:m.config_json||"{}",enabled:m.enabled!==!1,sort_order:m.sort_order||k+1}))};return t.id?Fe(`/api/v1/automation-rules/${t.id}`,w):fe("/api/v1/automation-rules",w)},Ir=async t=>Ke(`/api/v1/automation-rules/${t}`),Or=async()=>{const t=await Ne("/api/v1/automation-issues");return{runs:Array.isArray(t==null?void 0:t.runs)?t.runs:[],pending_tasks:Array.isArray(t==null?void 0:t.pending_tasks)?t.pending_tasks:[]}},Rr=async(t,s)=>fe(`/api/v1/automation-runs/${t}/resolve`,{resolution:s}),Pr=async(t,s)=>fe(`/api/v1/automation-pending-tasks/${t}/resolve`,{resolution:s}),$r=t=>({id:String((t==null?void 0:t.id)||""),keyword:(t==null?void 0:t.keyword)||"",reply:(t==null?void 0:t.reply)||"",item_id:(t==null?void 0:t.item_id)||"",type:(t==null?void 0:t.type)==="image"?"image":"text",image_url:(t==null?void 0:t.image_url)||""}),Er=async t=>{const s=await Ne(`/api/v1/reply-rules/${t}/typed`);return Array.isArray(s)?s.map($r):[]},Tr=async t=>t?(await Er(t)).map(a=>({id:a.id,keyword:a.keyword||"",reply_content:a.reply||"",match_type:"fuzzy",enabled:!0,item_id:a.item_id||"",type:a.type==="image"?"image":"text",image_url:a.image_url||""})):[],Dr=async(t,s)=>{const a=t.type||"text",n={keyword:t.keyword||"",reply:a==="text"&&t.reply_content||"",item_id:t.item_id||"",type:a,image_url:a==="image"&&t.image_url||""};return t.id?Fe(`/api/v1/reply-rules/${s}/typed/${t.id}`,n):fe(`/api/v1/reply-rules/${s}/items`,n)},Mr=async(t,s)=>Ke(`/api/v1/reply-rules/${s}/typed/${t}`),Pa=async()=>{const t=await Ne("/api/v1/settings/system");return Rl(t.data||t)},$a=async t=>{const s=Object.fromEntries(Object.entries(t).filter(([,a])=>a!=null));return Fe("/api/v1/settings/system",s)},Br=async(t,s)=>Ne(`/api/v1/settings/ai-reply/${t}`,void 0,s),qr=async(t,s)=>{const a={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return Fe(`/api/v1/settings/ai-reply/${t}`,a)},Fr=async(t,s="")=>(await fe("/api/v1/settings/ai-models",{base_url:t,api_key:s})).models||[],zr=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},Ea=t=>{const s=Array.from(new Set((t||[]).filter(Boolean)));return s.length>0?JSON.stringify(s):""},Ta=async t=>({success:!0,data:(await Ne("/api/v1/notifications/channels",void 0,t)||[]).map(n=>{let r;try{r=typeof n.config=="string"?JSON.parse(n.config):n.config}catch{r={}}return{id:String(n.id),name:n.name,type:n.type==="ding_talk"?"dingtalk":n.type==="lark"?"feishu":n.type,config:r,event_types:zr(n.event_types),enabled:n.enabled,created_at:n.created_at,updated_at:n.updated_at}})}),Ur=async t=>fe("/api/v1/notifications/channels",{...t,config:JSON.stringify(t.config),event_types:Ea(t.event_types)}),Qs=async(t,s)=>{const a={...s};return"config"in s&&(a.config=JSON.stringify(s.config)),"event_types"in s&&(a.event_types=Ea(s.event_types)),Fe(`/api/v1/notifications/channels/${t}`,a)},Wr=async t=>Ke(`/api/v1/notifications/channels/${t}`),Jr=async(t,s)=>{const a=await Ne(`/api/v1/notifications/accounts/${t}/bindings`,void 0,s);return(a==null?void 0:a.channel_ids)||[]},Gr=async t=>fe(`/api/v1/notifications/channels/${t}/test`,{}),Vs=async()=>Ne("/api/v1/default-replies"),Qr=async t=>{const s=await Ne(`/api/v1/default-replies/${t}`);return{cookie_id:t,enabled:s.enabled||!1,reply_content:s.reply_content||"",reply_once:s.reply_once||!1,reply_image_url:s.reply_image_url||""}},Vr=async(t,s)=>Fe(`/api/v1/default-replies/${t}`,{enabled:s.enabled??!1,reply_content:s.reply_content||"",reply_once:s.reply_once??!1,reply_image_url:s.reply_image_url||""}),Kr=async t=>Ke(`/api/v1/default-replies/${t}`),Hr=async t=>fe(`/api/v1/default-replies/${t}/clear-records`,{}),St=t=>String(t).padStart(2,"0"),ys=t=>{if(t==null||t==="")return"-";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"-":[s.getFullYear(),St(s.getMonth()+1),St(s.getDate())].join("-")+" "+[St(s.getHours()),St(s.getMinutes()),St(s.getSeconds())].join(":")},ge=(t,s)=>s===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${s})`,Zr=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},Ft=({title:t,value:s,icon:a,colorClass:n,trend:r})=>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 ${n} 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 ${n} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(a,{className:`w-6 h-6 ${n.replace("bg-","text-")}`})}),r&&e.jsxs("span",{className:"text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(Ha,{className:"w-3 h-3"})," ",r]})]}),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:s}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),ss=()=>{var Te,Me;const[t,s]=l.useState(null),[a,n]=l.useState(null),[r,f]=l.useState(""),[p,w]=l.useState("7days"),[m,k]=l.useState(""),[u,C]=l.useState(""),[M,K]=l.useState(null),[W,j]=l.useState(""),[R,T]=l.useState([]),[X,V]=l.useState(0),[se,Z]=l.useState(!1),[F,S]=l.useState(!1),[P,ee]=l.useState([]),[d,G]=l.useState({}),U=l.useRef(0),E=[ge("brand"),ge("brand-highlight"),ge("success-500"),ge("warning-500"),ge("accent-500")],A=b=>`¥${Number(b||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`,L=async b=>{let N;try{N=Fs(b,new Date,m,u)}catch(re){f(re instanceof Error?re.message:"日期范围无效");return}const{startDate:ae,endDate:y}=N,le={start_date:ae,end_date:y},J=Ol(N),xe=++U.current;S(!0),f("");try{const[re,$e,Se]=await Promise.all([Ws(le),Ws({start_date:J.startDate,end_date:J.endDate}),xr(le)]);if(xe!==U.current)return;n(re),K($e),T(Se.orders),V(Se.total),Z(Se.truncated)}catch(re){xe===U.current&&f(re instanceof Error?re.message:"经营数据加载失败")}finally{xe===U.current&&S(!1)}},q=()=>{if(!a||!M)return null;const b=a.revenue_stats.total_amount,N=M.revenue_stats.total_amount;if(N===0)return b>0?"+100%":"0%";const ae=(b-N)/N*100;return`${ae>=0?"+":""}${ae.toFixed(1)}%`};if(l.useEffect(()=>{let b=!1;return Promise.all([dr(),_t()]).then(([N,ae])=>{if(b)return;s(N),ee(ae);const y={};ae.forEach(le=>{y[le.item_id]=le.item_title||le.item_id}),G(y)}).catch(N=>{b||f(N instanceof Error?N.message:"概览加载失败")}),()=>{b=!0}},[]),l.useEffect(()=>{p!=="custom"&&L(p)},[p]),r&&(!t||!a))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(at,{className:"w-8 h-8"}),e.jsx("span",{children:r}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:()=>window.location.reload(),children:"重新加载"})]});if(!t||!a)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(Os,{className:"w-8 h-8 animate-spin text-brand"})});const I=((Te=a.daily_stats)==null?void 0:Te.map(b=>({name:b.date.slice(5),amount:b.amount,orders:b.order_count,avgAmount:b.order_count>0?(b.amount/b.order_count).toFixed(2):0})))||[],B=a.item_stats||[],$=a.revenue_stats.total_orders||0,x=a.revenue_stats.total_amount||0,g=B.length>0?B.map(b=>({name:(d[b.item_id]||b.item_id).length>12?(d[b.item_id]||b.item_id).substring(0,12)+"...":d[b.item_id]||b.item_id,sales:b.order_count})).sort((b,N)=>N.sales-b.sales).slice(0,10):[],H=Math.max(...g.map(b=>b.sales),1),v=B.length>0?B.map(b=>({name:(d[b.item_id]||b.item_id).length>10?(d[b.item_id]||b.item_id).substring(0,10)+"...":d[b.item_id]||b.item_id,value:b.order_count,percent:$>0?b.order_count/$*100:0})).sort((b,N)=>N.value-b.value).slice(0,6).map((b,N)=>({...b,color:E[N%E.length]})):[],Q=B.length>0?B.map(b=>({name:(d[b.item_id]||b.item_id).length>12?(d[b.item_id]||b.item_id).substring(0,12)+"...":d[b.item_id]||b.item_id,value:b.total_amount,orderCount:b.order_count,percentage:x>0?b.total_amount/x*100:0})).sort((b,N)=>N.value-b.value).slice(0,5).map((b,N)=>({...b,color:E[N%E.length],percentage:b.percentage.toFixed(1)})):[],ce=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],de=((Me=ce.find(b=>b.key===p))==null?void 0:Me.label)||"所选范围";let _e;try{_e=Fs(p,new Date,m,u)}catch{_e={startDate:m,endDate:u}}const Ae=W.trim().toLowerCase(),Ee=R.filter(b=>{var N,ae,y,le;return((N=b.order_id)==null?void 0:N.toLowerCase().includes(Ae))||((ae=b.item_id)==null?void 0:ae.toLowerCase().includes(Ae))||((y=b.item_title)==null?void 0:y.toLowerCase().includes(Ae))||((le=b.buyer_id)==null?void 0:le.toLowerCase().includes(Ae))});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:[ce.map(b=>e.jsx("button",{onClick:()=>w(b.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${p===b.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:b.label},b.key)),p==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:m,onChange:b=>k(b.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:u,onChange:b=>C(b.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("button",{onClick:()=>{try{f(""),L("custom")}catch(b){f(b instanceof Error?b.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(Ft,{title:"累计营收 (CNY)",value:`¥${a.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:Ka,colorClass:"bg-blue-400",trend:q()||void 0}),e.jsx(Ft,{title:"活跃账号 / 总数",value:`${t.active_cookies} / ${t.total_cookies}`,icon:ma,colorClass:"bg-blue-500"}),e.jsx(Ft,{title:"订单数",value:a.revenue_stats.total_orders.toLocaleString(),icon:Rs,colorClass:"bg-blue-500"}),e.jsx(Ft,{title:"库存卡密余量",value:t.available_card_stock,icon:ha,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:[de,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:I.length===0||a.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(Rs,{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:"所选时间范围内暂无订单记录"})]}):I.length<=2?e.jsx(Bt,{width:"100%",height:"100%",children:e.jsxs(fl,{data:I,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Ds,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:ge("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(Ms,{axisLine:!1,tickLine:!1,tick:{fill:ge("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:b=>`¥${b}`}),e.jsx(qt,{contentStyle:{backgroundColor:ge("white"),borderRadius:"8px",border:`1px solid ${ge("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:ge("neutral-500"),fontWeight:500},itemStyle:{color:ge("brand"),fontWeight:600},cursor:{fill:ge("brand",.08)},formatter:b=>[`¥${Number(b).toFixed(2)}`,"营收"]}),e.jsx(jl,{dataKey:"amount",fill:ge("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:I.map((b,N)=>e.jsx(Yt,{fill:ge("brand"),stroke:"none",strokeWidth:0},`cell-${N}`))})]})}):e.jsx(Bt,{width:"100%",height:"100%",children:e.jsxs(Nl,{data:I,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:ge("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:ge("brand"),stopOpacity:0})]})}),e.jsx(Ds,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:ge("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(Ms,{axisLine:!1,tickLine:!1,tick:{fill:ge("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(_l,{vertical:!1,stroke:ge("neutral-100"),strokeDasharray:"3 3"}),e.jsx(qt,{contentStyle:{backgroundColor:ge("white"),borderRadius:"8px",border:`1px solid ${ge("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:ge("neutral-500"),fontWeight:500},itemStyle:{color:ge("brand"),fontWeight:600},cursor:{stroke:ge("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(vl,{type:"monotone",dataKey:"amount",stroke:ge("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:ge("white"),stroke:ge("brand"),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:g.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:g.map((b,N)=>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 ${N<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:N+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:b.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[b.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,b.sales/H*100)}%`}})})]},`${b.name}-${N}`))})})]}),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:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${$} 单`,children:v.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(Bt,{width:"100%",height:"100%",children:e.jsxs(Bs,{accessibilityLayer:!1,children:[e.jsx(qs,{data:v,cx:"50%",cy:"45%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:96,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:v.map((b,N)=>e.jsx(Yt,{fill:b.color},`cell-${N}`))}),e.jsx(qt,{formatter:b=>`${Number(b||0)} 单`,wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:ge("white"),border:`1px solid ${ge("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(wl,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:b=>e.jsx("span",{style:{color:ge("neutral-500"),fontWeight:500},children:b})})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9",children:[e.jsx("span",{className:"text-2xl font-extrabold text-gray-900 tabular-nums",children:$}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总订单"})]})]})})]})]}),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-surface-muted",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),se&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",R.length," / ",X," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:W,onChange:b=>j(b.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:F?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(Os,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):Ee.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(Et,{className:"w-7 h-7 text-gray-300"})}),Ae?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:["当前共有 ",R.length," 单参与统计,但没有订单号、商品、买家匹配“",W,"”。"]})]}):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:["日期范围:",_e.startDate," 至 ",_e.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",a.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full min-w-[760px] 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 whitespace-nowrap",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:Ee.map(b=>e.jsxs("tr",{className:"hover:bg-warning-50/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(Et,{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:b.item_title||b.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:b.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",b.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:b.buyer_id}),b.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:ys(b.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",b.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(Zr,{status:b.status||b.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=${b.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(ga,{className:"w-4 h-4"})})})]},b.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)"}),Q.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品金额分析,总金额 ${A(x)}`,children:[e.jsx(Bt,{width:"100%",height:"100%",children:e.jsxs(Bs,{accessibilityLayer:!1,children:[e.jsx(qs,{data:Q,cx:"50%",cy:"50%",innerRadius:60,outerRadius:92,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:98,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:Q.map((b,N)=>e.jsx(Yt,{fill:b.color||E[N%E.length]},`cell-${N}`))}),e.jsx(qt,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:ge("white"),border:`1px solid ${ge("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:b=>`¥${Number(b||0).toLocaleString()}`})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-lg font-extrabold text-gray-900 tabular-nums",children:A(x)}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总金额"})]})]}),e.jsx("div",{className:"space-y-3 mt-4",children:Q.map(b=>e.jsxs("div",{className:"flex justify-between items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:b.color||E[Q.indexOf(b)%E.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:b.name,children:b.name})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 whitespace-nowrap",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",b.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[b.percentage,"%"]})]})]},b.name))})]})]})]})]})},Yr=(t,s)=>t!==(s.pause_duration||0),Xr=(t,s)=>{const a=s.username!==(t.username||""),n=s.show_browser!==(t.show_browser||!1),r=s.login_password!=="",f=s.clear_password===!0;if(!a&&!n&&!r&&!f)return null;const p={username:s.username,show_browser:s.show_browser};return f?p.clear_password=!0:r&&(p.login_password=s.login_password),p},zt=(t,s,a,n)=>t===s&&a===n,en=t=>t.status==="success"?{sessionId:"",status:"success",message:t.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}:t.status==="processing"||t.status==="verification_required"?{sessionId:"",status:t.status,message:t.message||(t.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:t.qr_code_url||""}:{sessionId:"",status:"failed",message:t.error||t.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""},tn=(t,s)=>t&&s,sn=new Set(["expired","cancelled","error","not_found"]),as=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:s=>s===t}},an=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,a=null,n=-1,r=0;const f=()=>{r+=1,a==null||a.abort(),a=null,s!==null&&(t.clearInterval(s),s=null)};return{start:(w,m,k,u=2e3)=>{f();const C=r;a=new AbortController;const M=a.signal;s=t.setInterval(()=>{n===C||C!==r||(n=C,(async()=>{var K,W;try{const j=await m(w,M);if(j.status==="success"){f(),await k.onSuccess(j);return}if(j.status==="scanned"){(K=k.onScanned)==null||K.call(k,j);return}if(j.status==="verification_required"){(W=k.onVerificationRequired)==null||W.call(k,j);return}j.status&&sn.has(j.status)&&(f(),k.onTerminalError(j))}catch(j){if(M.aborted||C!==r)return;f(),k.onPollError(j)}finally{n===C&&(n=-1)}})())},u)},stop:f,isActive:()=>s!==null}},ln=({faceQrUrl:t,verificationScreenshot:s})=>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(Za,{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:t?e.jsx("img",{src:t,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):s?e.jsx("img",{src:s,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(we,{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:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Da=({src:t,alt:s,className:a=""})=>e.jsx("img",{src:t,alt:s,className:`block aspect-square h-auto w-full object-contain ${a}`.trim()}),Ks=({checked:t,onChange:s,label:a})=>e.jsx("button",{type:"button","aria-label":a,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),rn=({account:t,onClose:s,onSaved:a})=>{const[n,r]=l.useState({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),[f,p]=l.useState(!1),[w,m]=l.useState(""),[k,u]=l.useState(""),[C,M]=l.useState(null),K=async()=>{p(!0),u("");try{const j=await zs(t.id,n);r(j),a(j)}catch(j){u(j instanceof Error?j.message:"保存失败")}finally{p(!1)}},W=async j=>{m(j),u(""),M(null);try{await zs(t.id,n);const R=await Bl(t.id,j),T=await Ml(t.id);M(R.summary),r(T),a(T)}catch(R){u(R instanceof Error?R.message:"任务执行失败")}finally{m("")}};return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(Le,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(Ya,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(Ks,{checked:n.auto_rate_enabled,onChange:()=>r(j=>({...j,auto_rate_enabled:!j.auto_rate_enabled})),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:n.rate_content,maxLength:500,onChange:j=>r(R=>({...R,rate_content:j.target.value})),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",n.last_rate_scan_at?new Date(n.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:w!==""||!t.enabled,onClick:()=>void W("auto_rate"),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[w==="auto_rate"?e.jsx(we,{className:"h-4 w-4 animate-spin"}):e.jsx(Xa,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(Cs,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(Ks,{checked:n.auto_polish_enabled,onChange:()=>r(j=>({...j,auto_polish_enabled:!j.auto_polish_enabled})),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:n.polish_time,onChange:j=>r(R=>({...R,polish_time:j.target.value})),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:w!==""||!t.enabled,onClick:()=>void W("auto_polish"),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[w==="auto_polish"?e.jsx(we,{className:"h-4 w-4 animate-spin"}):e.jsx(ba,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",n.last_polish_at?new Date(n.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),C&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",C.found," 项,成功 ",C.success,",失败 ",C.failed,",跳过 ",C.skipped,"。",C.message||""]}),k&&e.jsx("div",{className:"rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:k})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:s,disabled:f||w!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:()=>void K(),disabled:f||w!==""||n.auto_rate_enabled&&!n.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[f?e.jsx(we,{className:"h-4 w-4 animate-spin"}):e.jsx(Ye,{className:"h-4 w-4"}),"保存"]})]})})]})})},nn=({account:t,editForm:s,setEditForm:a,saving:n,onClose:r,onSave:f,onRestartPause:p,longLogin:w,onToggleLongLogin:m,passwordLoginView:k,onPasswordLogin:u,onCancelPasswordLogin:C,notifChannels:M,selectedChannelIds:K,bindingsLoaded:W,bindingsLoading:j,bindingsLoadError:R,onRetryBindings:T,onToggleChannel:X,onSettingsDirty:V})=>{const se=(v,Q)=>{a(ce=>({...ce,[v]:Q}))},Z=()=>void r(),F=()=>void f(),S=v=>se("remark",v.target.value),P=v=>se("cookie",v.target.value),ee=()=>se("auto_confirm",!s.auto_confirm),d=v=>se("pause_duration",parseInt(v.target.value,10)||0),G=()=>void p(),U=()=>void m(),E=v=>se("username",v.target.value),A=v=>a(Q=>({...Q,login_password:v.target.value,clear_password:!1})),L=()=>se("showLoginPassword",!s.showLoginPassword),q=v=>a(Q=>({...Q,clear_password:v.target.checked,login_password:v.target.checked?"":Q.login_password})),I=()=>se("show_browser",!s.show_browser),B=()=>void C(),$=()=>void u(),x=()=>void T(),g=v=>{W&&(X(v),V())},H=v=>{const Q=K.includes(Number(v.id)),ce=()=>g(Number(v.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:ce,disabled:!W,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Q?"bg-brand border-brand":"bg-white border-gray-300"}`,children:Q&&e.jsx(Ve,{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:v.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[v.type,v.enabled?"":" · 已停用"]})]})]},v.id)};return Oe.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:t.nickname||t.remark||t.id})]}),e.jsx("button",{onClick:Z,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Le,{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:t.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:s.remark,onChange:S,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:s.cookie,onChange:P,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长度: ",s.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(Ve,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:ee,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.auto_confirm?"bg-brand":"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 ${s.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(ya,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:s.pause_duration,onChange:d,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:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),s.pause_duration>0&&!t.paused&&s.pause_duration===(t.pause_duration||0)&&e.jsx("button",{type:"button",disabled:n,onClick:G,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(el,{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:"状态直接读取并修改闲鱼官方长登录设置"}),w.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:w.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:w.loading||w.saving||!w.canOpen,onClick:U,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${w.enabled?"bg-brand":"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 ${w.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:s.username,onChange:E,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:s.showLoginPassword?"text":"password",value:s.login_password,onChange:A,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:L,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:s.showLoginPassword?e.jsx(nt,{className:"w-5 h-5"}):e.jsx(st,{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:s.clear_password,onChange:q,className:"w-4 h-4 accent-brand"}),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:I,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.show_browser?"bg-brand":"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 ${s.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 和保存的登录信息。"})]}),k.status==="processing"||k.status==="verification_required"?e.jsx("button",{type:"button",onClick:B,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:$,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),k.message&&e.jsx("div",{className:`text-sm font-medium ${k.status==="failed"?"text-red-700":k.status==="success"?"text-green-700":"text-blue-800"}`,children:k.message}),k.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 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),k.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Da,{src:k.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(M.length>0||j||R)&&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(ft,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),j&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(we,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),R&&!j&&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:R}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:x,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:M.map(H)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Z,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:n,children:"取消"}),e.jsxs("button",{onClick:F,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:n,children:[n?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Ve,{className:"w-4 h-4"}),n?"保存中...":"保存"]})]})})]})}),document.body)},on=(t,s)=>{if(!t||!s)return!1;const a=Date.parse(t),n=Date.parse(s);return Number.isFinite(a)&&Number.isFinite(n)&&nt.map(a=>{const n=s[a.id];return!n||on(a.runtime_updated_at,n.updated_at)?a:{...a,runtime_state:n.state,runtime_message:n.message||"",runtime_connected:n.connected,runtime_updated_at:n.updated_at}}),dn=t=>{if(!t.enabled||t.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(t.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"}}},xn=(t,s)=>t.map(a=>{var n,r,f,p,w;return{...a,ai_enabled:((n=s[a.id])==null?void 0:n.ai_enabled)??!1,max_discount_percent:((r=s[a.id])==null?void 0:r.max_discount_percent)??10,max_discount_amount:((f=s[a.id])==null?void 0:f.max_discount_amount)??100,max_bargain_rounds:((p=s[a.id])==null?void 0:p.max_bargain_rounds)??3,custom_prompts:((w=s[a.id])==null?void 0:w.custom_prompts)??""}}),mn=()=>{const[t,s]=l.useState([]),[a,n]=l.useState(!0),r=l.useRef(0),f=l.useRef(null),p=l.useCallback(async()=>{var k;const w=++r.current;(k=f.current)==null||k.abort();const m=new AbortController;f.current=m,n(!0);try{const u={signal:m.signal},[C,M]=await Promise.allSettled([Tt(u),sr(u)]);if(w!==r.current)return;if(C.status==="rejected")throw C.reason;const K=M.status==="fulfilled"?M.value:{};M.status==="rejected"&&console.error("加载 AI 设置失败:",M.reason),s(xn(C.value,K))}catch(u){w===r.current&&!m.signal.aborted&&console.error("加载账号失败:",u)}finally{w===r.current&&n(!1)}},[]);return l.useEffect(()=>{let w=!1,m=null;const k=new AbortController,u=async()=>{try{const M=await gs({signal:k.signal,timeoutMs:1e4});w||s(K=>cn(K,M))}catch(M){w||console.error("加载账号运行状态失败:",M)}finally{w||(m=window.setTimeout(()=>void u(),2e3))}};return p().finally(()=>{w||u()}),()=>{var M;w=!0,k.abort(),r.current+=1,(M=f.current)==null||M.abort(),m!==null&&window.clearTimeout(m)}},[p]),{accounts:t,setAccounts:s,loading:a,loadAccounts:p}},un=()=>{const{accounts:t,setAccounts:s,loading:a,loadAccounts:n}=mn(),[r,f]=l.useState(""),[p,w]=l.useState(""),[m,k]=l.useState(""),[u,C]=l.useState(null),[M,K]=l.useState(""),[W,j]=l.useState(!1),[R,T]=l.useState(""),[X,V]=l.useState("pending"),[se,Z]=l.useState(""),[F,S]=l.useState(""),[P,ee]=l.useState(""),[d,G]=l.useState(null),[U,E]=l.useState(null),[A,L]=l.useState(null),[q,I]=l.useState(null),[B,$]=l.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[x,g]=l.useState([]),[H,v]=l.useState([]),[Q,ce]=l.useState(!1),[de,_e]=l.useState(!1),[Ae,Ee]=l.useState(!1),[Te,Me]=l.useState(""),[b,N]=l.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),[ae,y]=l.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[le,J]=l.useState(!1),[xe,re]=l.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),$e=l.useRef(null),Se=l.useRef(null),Be=l.useRef(null),_=l.useRef(null),O=l.useRef(null),Y=l.useRef(null),te=l.useRef(null),ve=l.useRef(null),je=l.useRef(null),ue=l.useRef(null),be=l.useRef(0),pe=l.useRef("");$e.current===null&&($e.current=an()),Se.current===null&&(Se.current=as()),Be.current===null&&(Be.current=as()),_.current===null&&(_.current=as());const Re=()=>{je.current!==null&&(window.clearTimeout(je.current),je.current=null)},oe=()=>{ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null)},ke=()=>{var i;(i=$e.current)==null||i.stop()},ze=()=>{var i,h;(i=te.current)==null||i.abort(),(h=Se.current)==null||h.cancel(),ke(),Re(),j(!1)},De=()=>{Re(),je.current=window.setTimeout(()=>{je.current=null,j(!1),n()},1e3)};l.useEffect(()=>()=>{var i,h,D,ne,he,ie,Ce;ke(),(i=Se.current)==null||i.cancel(),(h=Be.current)==null||h.cancel(),(D=_.current)==null||D.cancel(),(ne=O.current)==null||ne.abort(),(he=Y.current)==null||he.abort(),(ie=te.current)==null||ie.abort(),(Ce=ve.current)==null||Ce.abort(),Re(),be.current+=1,oe()},[]);const lt=async(i,h)=>{await Gl(i,!h),n()},We=i=>{m||(K(""),C(i))},Je=()=>{m||(K(""),C(null))},wt=async()=>{const i=u;if(!(!i||m)){k(i.id),K("");try{await Ql(i.id),s(h=>h.filter(D=>D.id!==i.id)),C(null)}catch(h){console.error("删除账号失败:",h),K((h==null?void 0:h.message)||"删除账号失败,请稍后重试")}finally{k("")}}},kt=async i=>{w(i.id);try{const h=await tr(i.id);h!=null&&h.profile_error&&alert("资料刷新失败:"+h.profile_error),await n()}catch(h){console.error("刷新账号资料失败:",h),alert((h==null?void 0:h.message)||"刷新账号资料失败,请先重新授权该账号")}finally{w("")}},ct=async i=>{var ie,Ce;const h=Be.current.next();(ie=O.current)==null||ie.abort();const D=new AbortController;O.current=D,_e(!0),ce(!1),Ee(!1),Me("");const[ne,he]=await Promise.allSettled([Ta({signal:D.signal}),Jr(i,{signal:D.signal})]);(Ce=Be.current)!=null&&Ce.isCurrent(h)&&(ne.status==="fulfilled"?g(ne.value.data||[]):(g([]),Me("通知渠道列表加载失败,请重试")),he.status==="fulfilled"?(v(he.value||[]),ce(!0)):(v([]),Me("通知绑定加载失败;本次保存不会修改现有绑定")),_e(!1))},dt=i=>{v(h=>h.includes(i)?h.filter(D=>D!==i):[...h,i])},Ct=async i=>{var D;be.current+=1,pe.current=i.id,(D=ve.current)==null||D.abort(),oe(),re({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),L(i),N({remark:i.remark||i.note||"",cookie:i.cookie||i.value||"",auto_confirm:i.auto_confirm||!1,pause_duration:i.pause_duration||0,username:i.username||"",login_password:i.login_password||"",show_browser:i.show_browser||!1,showLoginPassword:!1,clear_password:!1}),E("edit"),$({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,h]=await Promise.allSettled([ct(i.id),Hl(i.id)]);h.status==="fulfilled"?$({loading:!1,saving:!1,canOpen:h.value.can_open_long_login,enabled:h.value.enabled,error:""}):$({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"})},xt=async()=>{if(!A||B.loading||B.saving||!B.canOpen)return;const i=!B.enabled;$(h=>({...h,saving:!0,error:""}));try{const h=await Zl(A.id,i);$({loading:!1,saving:!1,canOpen:h.can_open_long_login,enabled:h.enabled,error:""})}catch(h){$(D=>({...D,saving:!1,error:h instanceof Error?h.message:"保存登录信息设置失败"}))}},mt=async i=>{var ne,he,ie,Ce;const h=_.current.next();(ne=Y.current)==null||ne.abort();const D=new AbortController;Y.current=D,L(i),E("ai-settings"),J(!0);try{const Pe=await Br(i.id,{signal:D.signal});if(!((he=_.current)!=null&&he.isCurrent(h)))return;y({ai_enabled:Pe.ai_enabled??!1,max_discount_percent:Pe.max_discount_percent??10,max_discount_amount:Pe.max_discount_amount??100,max_bargain_rounds:Pe.max_bargain_rounds??3,custom_prompts:Pe.custom_prompts??""})}catch(Pe){(ie=_.current)!=null&&ie.isCurrent(h)&&console.error("Failed to load AI settings:",Pe)}finally{(Ce=_.current)!=null&&Ce.isCurrent(h)&&J(!1)}},He=async()=>{if(A){J(!0);try{const i={};b.remark!==(A.remark||A.note||"")&&(i.remark=b.remark),b.cookie&&b.cookie!==(A.cookie||A.value||"")&&(i.cookie=b.cookie),b.auto_confirm!==A.auto_confirm&&(i.auto_confirm=b.auto_confirm),Yr(b.pause_duration,A)&&(i.pause_duration=b.pause_duration);const h=Xr(A,b);h&&Object.assign(i,h),tn(Q,Ae)&&(i.channel_ids=H),Object.keys(i).length>0&&await Kl(A.id,i),E(null),n()}catch(i){console.error("更新账号失败:",i),alert("更新失败,请重试")}finally{J(!1)}}},ut=async()=>{if(!(!A||b.pause_duration<=0)){J(!0);try{const i=await Vl(A.id,b.pause_duration);L({...A,pause_duration:b.pause_duration,paused:(i==null?void 0:i.paused)===!0,paused_until:Number((i==null?void 0:i.paused_until)||0)}),await n()}catch(i){alert(i instanceof Error?i.message:"重新暂停失败")}finally{J(!1)}}},c=async()=>{if(A){J(!0);try{await qr(A.id,ae),E(null),n()}catch(i){console.error("更新AI设置失败:",i),alert("更新失败,请重试")}finally{J(!1)}}},z=async(i,h,D)=>{var he;(he=ve.current)==null||he.abort();const ne=new AbortController;ve.current=ne;try{const ie=await Xl(i,ne.signal);if(!zt(h,be.current,D,pe.current))return;const Ce={...en(ie),sessionId:i};if(ie.status==="success"){oe(),re(Ce),N(Pe=>({...Pe,login_password:"",showLoginPassword:!1})),await n();return}if(ie.status==="processing"||ie.status==="verification_required"){re(Ce),oe(),ue.current=window.setTimeout(()=>void z(i,h,D),1500);return}oe(),re(Ce)}catch(ie){if(!zt(h,be.current,D,pe.current))return;oe(),re({sessionId:i,status:"failed",message:ie instanceof Error?ie.message:"查询密码登录状态失败",qrCodeUrl:""})}},me=async()=>{var D;if(!A)return;const i=b.username.trim();if(!i||!b.login_password){alert("请先填写登录账号和本次登录密码");return}oe(),(D=ve.current)==null||D.abort();const h=++be.current;pe.current=A.id,re({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const ne=await Yl({account_id:A.id,account:i,password:b.login_password,show_browser:b.show_browser});if(!zt(h,be.current,A.id,pe.current))return;if(!ne.success||!ne.session_id)throw new Error(ne.message||"无法启动密码登录");re({sessionId:ne.session_id,status:"processing",message:ne.message||"登录处理中",qrCodeUrl:""}),await z(ne.session_id,h,A.id)}catch(ne){if(!zt(h,be.current,A.id,pe.current))return;re({sessionId:"",status:"failed",message:ne instanceof Error?ne.message:"启动密码登录失败",qrCodeUrl:""})}},Ie=async()=>{var h;const i=xe.sessionId;if(be.current+=1,pe.current="",(h=ve.current)==null||h.abort(),oe(),i)try{await er(i)}catch(D){console.error("取消密码登录失败",D)}re({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},Ge=async()=>{var i,h;(i=Be.current)==null||i.cancel(),(h=O.current)==null||h.abort(),(xe.status==="processing"||xe.status==="verification_required")&&await Ie(),E(null)},qe=()=>{var i,h;(i=_.current)==null||i.cancel(),(h=Y.current)==null||h.abort(),E(null)},pt=async(i,h)=>{const D=await Jl(i,h==null?void 0:h.id);if(!D.success||!D.account_id)throw new Error(D.message||"保存扫码授权失败");return D.account_id},et=async i=>{var he,ie,Ce,Pe;ke(),(he=te.current)==null||he.abort();const h=new AbortController;te.current=h;const D=Se.current.next();Re();const ne=i||null;G(ne),j(!0),V("loading"),Z(""),T(""),S(""),ee("");try{const ye=await Ul({signal:h.signal});if(!((ie=Se.current)!=null&&ie.isCurrent(D)))return;if(!ye.success||!ye.qr_code_url||!ye.session_id)throw new Error(ye.message||"闲鱼未返回可用的登录二维码");if(ye.success&&ye.qr_code_url&&ye.session_id){const Dt=ye.session_id;T(ye.qr_code_url),V("waiting"),(Ce=$e.current)==null||Ce.start(Dt,Wl,{onSuccess:async()=>{try{if(!await pt(Dt,ne)){V("error");return}}catch(Ze){console.error("保存扫码授权失败",Ze),V("error");return}V("success"),De()},onScanned:()=>{V("waiting")},onTerminalError:()=>{V("error")},onPollError:Ze=>{console.error("轮询扫码状态失败",Ze),V("error")},onVerificationRequired:Ze=>{V("verification"),Ze.face_qr_url&&ee(Ze.face_qr_url),Ze.verification_screenshot&&S(Ze.verification_screenshot)}})}}catch(ye){if(!((Pe=Se.current)!=null&&Pe.isCurrent(D)))return;Z(ye instanceof Error?ye.message:"二维码获取失败,请稍后重试"),V("error")}finally{te.current===h&&(te.current=null)}};if(a)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(we,{className:"w-8 h-8 text-brand animate-spin"})});const o=t.filter(i=>{const h=r.trim().toLowerCase();return h?[i.id,i.nickname,i.remark,i.note,i.username,i.runtime_message].some(D=>(D||"").toLowerCase().includes(h)):!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:r,onChange:i=>f(i.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>et(),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(Ht,{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:["当前显示 ",o.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[o.map(i=>{const h=dn(i),D=i.runtime_state==="auth_expired"||i.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.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(ot,{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 ${h.dot}`,children:i.runtime_state==="online"&&e.jsx(Ve,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:i.nickname||i.remark||`账号 ${i.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${h.badge}`,children:h.label}),i.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(yt,{className:"w-3 h-3"})," AI"]}),i.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx(Rt,{className:"h-3 w-3"})," 自动评价"]}),i.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(Cs,{className:"h-3 w-3"})," 每日擦亮"]}),i.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(Ve,{className:"h-3 w-3"})," 自动确认发货"]}),i.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:i.profile_error,children:[e.jsx(at,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:i.remark||i.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",i.id]})]}),i.runtime_message&&i.runtime_state!=="online"&&i.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${D?"text-red-700":"text-amber-700"}`,children:[e.jsx(at,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:i.runtime_message}),D&&e.jsxs("button",{type:"button",onClick:()=>et(i),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(Ht,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),i.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(ya,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>kt(i),disabled:p===i.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(Ue,{className:`w-5 h-5 ${p===i.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>et(i),className:`p-3 rounded-xl transition-colors ${D?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(Ht,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ct(i),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(fa,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>mt(i),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(yt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>I(i),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(ba,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>lt(i.id,i.enabled),className:`p-3 rounded-xl transition-colors ${i.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:i.enabled?"停用账号":"启用账号",children:e.jsx(tl,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>We(i),disabled:m!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:m===i.id?"删除中…":`删除账号 ${i.nickname||i.remark||i.id}`,children:m===i.id?e.jsx(we,{className:"w-5 h-5 animate-spin"}):e.jsx(Qe,{className:"w-5 h-5"})})]})]})]})]})},i.id)}),t.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(ot,{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:"请点击右上角扫码添加您的闲鱼账号"})]}),t.length>0&&o.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。"})]})]}),q&&Oe.createPortal(e.jsx(rn,{account:q,onClose:()=>I(null),onSaved:i=>{s(h=>h.map(D=>D.id===q.id?{...D,auto_rate_enabled:i.auto_rate_enabled,rate_content:i.rate_content,auto_polish_enabled:i.auto_polish_enabled,polish_time:i.polish_time,last_rate_scan_at:i.last_rate_scan_at,last_polish_date:i.last_polish_date,last_polish_at:i.last_polish_at}:D))}}),document.body),u&&Oe.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-modal",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(Qe,{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:Je,disabled:m!=="",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(Le,{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:u.nickname||u.remark||"未命名账号"}),u.remark&&u.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",u.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",u.id]})]}),m===u.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(we,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),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:"正在清理关联数据,请保持页面打开…"})]})]}),M&&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(at,{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:M})]})]})]}),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:Je,disabled:m!=="",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 wt(),disabled:m!=="",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:m===u.id?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),W&&Oe.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(Le,{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-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${X==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[X==="loading"&&e.jsx(we,{className:"w-10 h-10 text-brand animate-spin"}),X==="waiting"&&e.jsx(Da,{src:R,alt:"闲鱼登录二维码",className:"p-2"}),X==="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(Ve,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),X==="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:se||"请关闭窗口后重新发起扫码登录。"})]}),X==="verification"&&e.jsx(ln,{faceQrUrl:P,verificationScreenshot:F})]}),X!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),U==="edit"&&A&&e.jsx(nn,{account:A,editForm:b,setEditForm:N,saving:le,onClose:Ge,onSave:He,onRestartPause:ut,longLogin:B,onToggleLongLogin:xt,passwordLoginView:xe,onPasswordLogin:me,onCancelPasswordLogin:Ie,notifChannels:x,selectedChannelIds:H,bindingsLoaded:Q,bindingsLoading:de,bindingsLoadError:Te,onRetryBindings:()=>ct(A.id),onToggleChannel:dt,onSettingsDirty:()=>Ee(!0)}),U==="ai-settings"&&A&&Oe.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(yt,{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:qe,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Le,{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(yt,{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:()=>y({...ae,ai_enabled:!ae.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${ae.ai_enabled?"bg-brand":"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 ${ae.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:ae.max_discount_percent,onChange:i=>y({...ae,max_discount_percent:parseInt(i.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:ae.max_discount_amount,onChange:i=>y({...ae,max_discount_amount:parseInt(i.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:ae.max_bargain_rounds,onChange:i=>y({...ae,max_bargain_rounds:parseInt(i.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:ae.custom_prompts,onChange:i=>y({...ae,custom_prompts:i.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(vs,{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:qe,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:le,children:"取消"}),e.jsxs("button",{onClick:c,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:le,children:[le?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),le?"保存中...":"保存"]})]})})]})}),document.body)]})},pn=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],hn=t=>{const s=typeof t=="object"&&t!==null?t:{},a=Array.isArray(s.results)?s.results:[];return{total:Number(s.total||0),success_count:Number(s.success_count||0),failed_count:Number(s.failed_count||0),results:a.map(gn)}},gn=t=>{const s=typeof t=="object"&&t!==null?t:{};return{order_id:String(s.order_id||"unknown"),success:s.success===!0,message:String(s.message||"")}},bn=t=>(t==null?void 0:t.results.filter(yn))||[],yn=t=>!t.success,fn=(t,s)=>t!==null&&!s,jn=t=>{if(!t)return"请选择订单文件";const s=t.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(s)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},it=(t,s)=>t===s,Nn=(t,s)=>t instanceof Error&&t.message?t.message:s,_n=({filter:t,onFilterChange:s,accountFilter:a,onAccountFilterChange:n,accounts:r,accountName:f,searchText:p,onSearchChange:w})=>{const m=C=>s(C.currentTarget.dataset.status||"all"),k=C=>n(C.target.value),u=C=>w(C.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:pn.map(C=>e.jsx("button",{"data-status":C.key,onClick:m,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${t===C.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:C.label},C.key))}),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(ot,{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:a,onChange:k,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:"全部账号"}),r.map(C=>e.jsx("option",{value:C.id,children:f(C.id)},C.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-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:p,onChange:u,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},vn=t=>{const s=f=>{var p;t.setImportFile(((p=f.target.files)==null?void 0:p[0])||null)},a=()=>t.closeImportModal(),n=()=>void t.handleImportOrders(),r=()=>void t.handleRetryImport();return t.showImportModal?Oe.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:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Le,{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:s,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 格式"})]}),t.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:t.importFile.name})]})}),t.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:t.importError}),e.jsx("button",{type:"button",onClick:r,disabled:t.importing||!t.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),t.importResult&&t.importResult.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:["导入完成:成功 ",t.importResult.success_count," 条,失败 ",t.importResult.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:bn(t.importResult).map((f,p)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:f.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:f.message||"导入失败"})]},`${f.order_id}-${p}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:a,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:n,disabled:!t.importFile||t.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:t.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},wn=(t={pageSize:20})=>{const[s,a]=l.useState([]),[n,r]=l.useState([]),[f,p]=l.useState([]),[w,m]=l.useState("all"),[k,u]=l.useState(""),[C,M]=l.useState(""),[K,W]=l.useState(""),[j,R]=l.useState(1),[T,X]=l.useState(1),[V,se]=l.useState(!1),Z=l.useRef(0),F=l.useRef(null),S=l.useRef(null),P=l.useCallback(async()=>{var q;const A=++Z.current;(q=F.current)==null||q.abort();const L=new AbortController;F.current=L,se(!0);try{const I=await ar(k||void 0,w,j,t.pageSize,K,{signal:L.signal});if(!it(A,Z.current))return;a(I.data),X(I.total_pages)}catch(I){it(A,Z.current)&&!L.signal.aborted&&console.error("加载订单失败:",I)}finally{it(A,Z.current)&&se(!1)}},[k,K,w,t.pageSize,j]);l.useEffect(()=>{const A=window.setTimeout(()=>{R(1),W(C.trim())},300);return(()=>window.clearTimeout(A))},[C]),l.useEffect(()=>(P(),(()=>{var A;Z.current+=1,(A=F.current)==null||A.abort()})),[P]),l.useEffect(()=>{var L;const A=new AbortController;return(L=S.current)==null||L.abort(),S.current=A,Promise.all([Tt({signal:A.signal}),_t(void 0,{signal:A.signal})]).then(([q,I])=>{A.signal.aborted||(p(q),r(I))}).catch(q=>{A.signal.aborted||console.error("加载订单辅助数据失败:",q)}),(()=>A.abort())},[]);const ee=l.useMemo(()=>new Map(f.map(A=>[A.id,A])),[f]),d=l.useMemo(()=>{const A={};return n.forEach(L=>{L.item_id&&(A[`${L.cookie_id}:${L.item_id}`]=L.item_title||L.item_id)}),A},[n]),G=l.useCallback(A=>{const L=ee.get(A),q=(L==null?void 0:L.remark)||(L==null?void 0:L.nickname);return q?`${q} · ${A.slice(0,6)}`:`账号 ${A.slice(0,8)}`},[ee]),U=l.useCallback(A=>{const L=ee.get(A);return(L==null?void 0:L.remark)||(L==null?void 0:L.nickname)||"未命名账号"},[ee]),E=l.useCallback((A,L,q)=>{if(q!=null&&q.trim())return q;const I=d[`${A}:${L}`];if(I)return I;const B=n.find($=>{if(!q||!$.item_title)return!1;const x=q.toLowerCase(),g=$.item_title.toLowerCase();return g.includes(x)||x.includes(g)});return(B==null?void 0:B.item_title)||"未知商品"},[d,n]);return{orders:s,items:n,accounts:f,filter:w,setFilter:m,accountFilter:k,setAccountFilter:u,searchText:C,setSearchText:M,page:j,setPage:R,totalPages:T,loading:V,loadOrders:P,accountName:G,accountNickname:U,getItemNameById:E}},kn=t=>{const[s,a]=l.useState(!1),[n,r]=l.useState(null),[f,p]=l.useState(null),[w,m]=l.useState(!1),[k,u]=l.useState(""),C=l.useRef(0),M=l.useRef(null),K=l.useCallback(()=>{r(null),p(null),u(""),a(!0)},[]),W=l.useCallback(()=>{var T;C.current+=1,(T=M.current)==null||T.abort(),m(!1),a(!1),r(null),p(null),u("")},[]),j=l.useCallback(async()=>{var Z;if(!fn(n,w))return;const T=n;if(!T)return;const X=jn(T);if(X){u(X);return}const V=++C.current;(Z=M.current)==null||Z.abort();const se=new AbortController;M.current=se,m(!0),p(null),u("");try{const F=new FormData;F.append("file",T);const S=hn(await cr(F,{signal:se.signal}));if(!it(V,C.current))return;p(S),r(null),await t(),S.failed_count===0&&it(V,C.current)&&(alert(`订单导入成功,共 ${S.success_count} 条`),a(!1),p(null))}catch(F){it(V,C.current)&&!se.signal.aborted&&u(Nn(F,"导入失败,请检查文件格式"))}finally{it(V,C.current)&&m(!1)}},[n,w,t]),R=l.useCallback(async()=>{await j()},[j]);return{showImportModal:s,importFile:n,setImportFile:r,importResult:f,importing:w,importError:k,openImportModal:K,closeImportModal:W,handleImportOrders:j,handleRetryImport:R}},Hs=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},Cn=()=>{const t=wn(),s=kn(t.loadOrders),{orders:a,accounts:n,filter:r,setFilter:f,accountFilter:p,setAccountFilter:w,searchText:m,setSearchText:k,page:u,setPage:C,totalPages:M,loading:K,loadOrders:W,accountName:j,accountNickname:R,getItemNameById:T}=t,[X,V]=l.useState(!1),[se,Z]=l.useState(!1),[F,S]=l.useState(null),[P,ee]=l.useState(null),[d,G]=l.useState(!1),[U,E]=l.useState(""),[A,L]=l.useState(!1),[q,I]=l.useState(null),[B,$]=l.useState(null),[x,g]=l.useState(null),H=N=>{f(N),C(1),k("")},v=N=>{w(N),C(1)},Q=N=>{k(N),C(1)},ce=async()=>{try{const N=await nr(p||void 0,r);await W(),N!=null&&N.message&&alert(N.message)}catch(N){console.error("同步订单失败:",N),alert((N==null?void 0:N.message)||"同步失败,请重试")}},de=N=>{E(N),I(null),G(!0)},_e=async N=>{var ae;L(!0),I(null);try{const y=await or([U],N),le=(ae=y==null?void 0:y.results)==null?void 0:ae[0];le!=null&&le.success?(I({success:!0,message:le.message}),W()):I({success:!1,message:(le==null?void 0:le.message)||"发货失败"})}catch(y){I({success:!1,message:(y==null?void 0:y.message)||"请求失败"})}finally{L(!1)}},Ae=N=>{S(N),V(!0)},Ee=N=>{ee({...N}),Z(!0)},Te=async()=>{if(!(!P||!P.order_id))try{const N={};P.status!==void 0&&(N.order_status=P.status),P.buyer_id!==void 0&&(N.buyer_id=P.buyer_id),P.amount!==void 0&&(N.amount=P.amount),P.receiver_name!==void 0&&(N.receiver_name=P.receiver_name),P.receiver_phone!==void 0&&(N.receiver_phone=P.receiver_phone),P.receiver_address!==void 0&&(N.receiver_address=P.receiver_address),P.item_id!==void 0&&(N.item_id=P.item_id),P.quantity!==void 0&&(N.quantity=P.quantity),P.item_title!==void 0&&(N.item_title=P.item_title),await lr(P.order_id,N),Z(!1),ee(null),W()}catch(N){console.error("更新订单失败:",N),alert("更新失败,请重试")}},Me=async N=>{$(N);try{const ae=await ir(N);ae.success?await W():alert(ae.message||"同步失败")}catch(ae){console.error("同步订单失败:",ae),alert((ae==null?void 0:ae.message)||"同步失败,请重试")}finally{$(null)}},b=async N=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){g(N);try{await rr(N),a.length===1&&u>1?C(ae=>ae-1):await W()}catch(ae){console.error("删除订单失败:",ae),alert((ae==null?void 0:ae.message)||"删除失败,请重试"),await W()}finally{g(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:W,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(Ue,{className:`w-5 h-5 ${K?"animate-spin":""}`})}),e.jsxs("button",{onClick:s.openImportModal,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(Xe,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:ce,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(Ps,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(_n,{filter:r,onFilterChange:H,accountFilter:p,onAccountFilterChange:v,accounts:n,accountName:j,searchText:m,onSearchChange:Q}),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:a.map(N=>e.jsxs("tr",{className:"hover:bg-warning-50/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:N.item_image?e.jsx("img",{src:N.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(Et,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:T(N.cookie_id,N.item_id,N.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:R(N.cookie_id),children:[e.jsx(ot,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:R(N.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",N.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",N.quantity," • ",ys(N.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:N.buyer_id}),N.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:N.receiver_name})]}),N.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:N.receiver_phone})]}),N.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:N.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:N.amount?`¥${N.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Hs,{status:N.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[N.status==="pending_ship"&&e.jsx("button",{onClick:()=>de(N.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=${N.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(ga,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ae(N),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(st,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ee(N),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(jt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Me(N.order_id),disabled:B===N.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(Ue,{className:`w-4 h-4 ${B===N.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>b(N.order_id),disabled:x===N.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(Qe,{className:"w-4 h-4"})})]})]},N.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:["第 ",u," 页 / 共 ",M," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:u<=1,onClick:()=>C(N=>N-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(ks,{className:"w-5 h-5"})}),e.jsx("button",{disabled:u>=M,onClick:()=>C(N=>N+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(ws,{className:"w-5 h-5"})})]})]})]}),X&&F&&Oe.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(Le,{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:F.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:R(F.cookie_id),children:R(F.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Hs,{status:F.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:F.amount?`¥${F.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:F.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:ys(F.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:[F.item_image&&e.jsx("img",{src:F.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:T(F.cookie_id,F.item_id,F.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",F.item_id]}),F.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",F.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:F.buyer_id})]}),F.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:F.receiver_name})]}),F.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:F.receiver_phone})]}),F.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:F.receiver_address})]})]})]})]}),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 bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),F.status==="pending_ship"&&e.jsx("button",{onClick:()=>{V(!1),de(F.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),e.jsx(vn,{...s}),d&&Oe.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:()=>{G(!1),I(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Le,{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:()=>_e("status_only"),disabled:A,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(Ps,{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:()=>_e("full_delivery"),disabled:A,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand 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(Et,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),A&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(Ue,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),q&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${q.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[q.success?"✓ ":"✗ ",q.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{G(!1),I(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:q!=null&&q.success?"完成":"取消"})})]})}),document.body),se&&P&&Oe.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:()=>Z(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Le,{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:P.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:P.status,onChange:N=>ee({...P,status:N.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:P.buyer_id,onChange:N=>ee({...P,buyer_id:N.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:P.amount,onChange:N=>ee({...P,amount:N.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:P.receiver_name||"",onChange:N=>ee({...P,receiver_name:N.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:P.receiver_phone||"",onChange:N=>ee({...P,receiver_phone:N.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:P.receiver_address||"",onChange:N=>ee({...P,receiver_address:N.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:P.item_title||"",onChange:N=>ee({...P,item_title:N.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:()=>Z(!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:Te,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},Sn=({dataCards:t,downloadCardTemplate:s,...a})=>{var j;const n=R=>{var T;a.setBatchFile(((T=R.target.files)==null?void 0:T[0])||null)},r=R=>{a.setAppendContent(R.target.value)},f=R=>{a.setAppendTargetId(R.target.value)},p=()=>a.closeBatchModal(),w=()=>a.setBatchTab("create"),m=()=>a.setBatchTab("append"),k=()=>void a.handleRetryBatchCreate(),u=()=>void a.handleRetryBatchAppend(),C=a.batchResult&&"rows"in a.batchResult?a.batchResult:null,M=R=>e.jsxs("option",{value:String(R.id),children:[R.name,"(ID: ",R.id,")"]},R.id),K=()=>void a.handleBatchCreate(),W=()=>void a.handleBatchAppend();return a.showBatchModal?Oe.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:p,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Le,{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:w,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(sl,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:m,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Pt,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),a.batchTab==="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:s,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(al,{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(Pt,{className:"w-4 h-4"}),a.batchFile?a.batchFile.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:n})]})]}),((j=a.batchResult)==null?void 0:j.error)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.batchResult.error}),e.jsx("button",{type:"button",onClick:k,disabled:!a.batchFile||a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),C&&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:["共 ",C.total," 行 · 成功 ",C.created," · 失败 ",C.failed]}),C.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:C.rows.filter(R=>!R.success).map(R=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",R.row_no," 行「",R.name,"」:",R.error]},R.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:t.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:a.appendTargetId,onChange:f,className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:t.map(M)})]}),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:a.appendContent,onChange:r,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.jsxs("p",{className:"text-xs text-gray-500",children:["预览:",a.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),a.appendError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.appendError}),e.jsx("button",{type:"button",onClick:u,disabled:a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),a.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",a.appendResult.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:p,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),a.batchTab==="create"?e.jsxs("button",{onClick:K,disabled:!a.batchFile||a.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Pt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:W,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||t.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Xe,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},Ln=({type:t})=>{switch(t){case"text":return e.jsx(Na,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(ja,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(ll,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(_s,{className:"w-5 h-5 text-gray-500"})}},An=(t,s,a)=>{const n=a.trim().toLocaleLowerCase();return t.filter(r=>(!s||r.type===s)&&(!n||r.name.toLocaleLowerCase().includes(n)))},Ma=t=>t.split(` +`).map(s=>s.trim()).filter(Boolean),In=(t,s,a)=>!!(t&&Ma(s).length>0&&!a),gt=(t,s,a,n)=>t===s&&a===n,On=()=>{const[t,s]=l.useState([]),[a,n]=l.useState(!0),r=l.useRef(0),f=l.useRef(null),p=l.useCallback(async()=>{var k;const w=++r.current;(k=f.current)==null||k.abort();const m=new AbortController;f.current=m,n(!0);try{const u=await Ls({signal:m.signal});if(w!==r.current)return;s(u)}catch(u){w===r.current&&!m.signal.aborted&&console.error("加载卡密库存失败:",u)}finally{w===r.current&&n(!1)}},[]);return l.useEffect(()=>(p(),()=>{var m;r.current+=1,(m=f.current)==null||m.abort()}),[p]),{cards:t,setCards:s,loading:a,loadCards:p}},Rn=t=>{const s=t.dataCards,a=t.loadCards,[n,r]=l.useState(!1),[f,p]=l.useState("create"),[w,m]=l.useState(null),[k,u]=l.useState(null),[C,M]=l.useState(!1),[K,W]=l.useState(""),[j,R]=l.useState(""),[T,X]=l.useState(null),[V,se]=l.useState(""),Z=l.useRef(0),F=l.useRef(null),S=l.useRef(""),P=l.useMemo(()=>Ma(j),[j]),ee=l.useCallback(()=>{var L;p("create"),m(null),u(null),W((L=s[0])!=null&&L.id?String(s[0].id):""),R(""),X(null),se(""),r(!0)},[s]),d=l.useCallback(()=>{var L;Z.current+=1,(L=F.current)==null||L.abort(),M(!1),r(!1)},[]),G=l.useCallback(async()=>{var I;if(!w||C)return;const L=++Z.current;(I=F.current)==null||I.abort();const q=new AbortController;F.current=q,M(!0),u(null);try{const B=await hr(w,{signal:q.signal});if(!gt(L,Z.current,"",""))return;u(B),B.created>0&&await a()}catch(B){if(!gt(L,Z.current,"",""))return;u({error:(B==null?void 0:B.message)||"上传失败"})}finally{gt(L,Z.current,"","")&&M(!1)}},[C,w,a]),U=l.useCallback(async()=>{var B;if(!In(K,j,C))return;const L=K,q=++Z.current;S.current=L,(B=F.current)==null||B.abort();const I=new AbortController;F.current=I,M(!0),X(null),se("");try{const $=await gr(L,j,{signal:I.signal});if(!gt(q,Z.current,L,K))return;X({added:$.added}),R(""),await a()}catch($){if(!gt(q,Z.current,L,K))return;se(($==null?void 0:$.message)||"追加失败")}finally{gt(q,Z.current,L,K)&&M(!1)}},[j,K,C,a]),E=l.useCallback(async()=>{await G()},[G]),A=l.useCallback(async()=>{S.current&&K!==S.current||await U()},[K,U]);return{showBatchModal:n,setShowBatchModal:r,batchTab:f,setBatchTab:p,batchFile:w,setBatchFile:m,batchResult:k,batchBusy:C,appendTargetId:K,setAppendTargetId:W,appendContent:j,setAppendContent:R,appendResult:T,appendError:V,appendPreview:P,openBatchModal:ee,closeBatchModal:d,handleBatchCreate:G,handleBatchAppend:U,handleRetryBatchCreate:E,handleRetryBatchAppend:A}},Zs=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),Pn=()=>{const{cards:t,loadCards:s}=On(),[a,n]=l.useState(!1),[r,f]=l.useState(!1),[p,w]=l.useState(null),[m,k]=l.useState({}),[u,C]=l.useState(Zs),[M,K]=l.useState(""),[W,j]=l.useState(""),R=l.useMemo(()=>t.filter(d=>d.type==="data"),[t]),T=Rn({dataCards:R,loadCards:s}),X=d=>{var G,U,E,A,L;w(d),k({id:d.id,name:d.name||"",type:d.type||"text",api_url:((G=d.api_config)==null?void 0:G.url)||"",api_method:((U=d.api_config)==null?void 0:U.method)||"GET",api_timeout:((E=d.api_config)==null?void 0:E.timeout)||10,api_headers:((A=d.api_config)==null?void 0:A.headers)||"",api_params:((L=d.api_config)==null?void 0:L.params)||"",text_content:d.text_content||"",data_content:d.data_content||"",image_url:d.image_url||"",delay_seconds:d.delay_seconds||0,description:d.description||"",enabled:d.enabled}),n(!0)},V=async()=>{var d,G,U,E,A,L,q,I;if(p){if(!((d=m.name)!=null&&d.trim())){alert("请输入卡密名称");return}if(!m.type){alert("请选择卡密类型");return}try{const B={name:m.name.trim(),type:m.type,description:(G=m.description)==null?void 0:G.trim(),delay_seconds:m.delay_seconds||0,enabled:m.enabled??!0};m.type==="api"?B.api_config={url:((U=m.api_url)==null?void 0:U.trim())||"",method:m.api_method,timeout:m.api_timeout||10,headers:((E=m.api_headers)==null?void 0:E.trim())||void 0,params:((A=m.api_params)==null?void 0:A.trim())||void 0}:m.type==="text"?B.text_content=((L=m.text_content)==null?void 0:L.trim())||"":m.type==="data"?B.data_content=((q=m.data_content)==null?void 0:q.trim())||"":m.type==="image"&&(B.image_url=((I=m.image_url)==null?void 0:I.trim())||""),await Js(p.id,B),n(!1),await s()}catch(B){console.error("更新卡密失败:",B),alert("更新失败,请重试")}}},se=async d=>{if(confirm("确认删除该卡密吗?"))try{await pr(d),await s()}catch(G){console.error("删除卡密失败:",G),alert("删除失败,请重试")}},Z=async()=>{if(!u.name.trim()){alert("请输入卡密名称");return}if(!u.content.trim()){alert(u.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const d={name:u.name.trim(),type:u.type,description:u.description.trim(),enabled:u.enabled,delay_seconds:u.delay_seconds};u.type==="text"&&(d.text_content=u.content.trim()),u.type==="data"&&(d.data_content=u.content.trim()),u.type==="image"&&(d.image_url=u.content.trim()),u.type==="api"&&(d.api_config={url:u.content.trim(),method:u.api_method,timeout:u.api_timeout,headers:u.api_headers.trim()||void 0,params:u.api_params.trim()||void 0}),await ur(d),f(!1),C(Zs()),await s()}catch(d){console.error("添加卡密失败:",d),alert("添加失败,请重试")}},F=async d=>{try{await Js(d.id,{...d,enabled:!d.enabled}),await s()}catch(G){console.error("切换状态失败:",G)}},S=async d=>{try{await navigator.clipboard.writeText(String(d)),alert(`已复制卡密组ID:${d}`)}catch{prompt("复制卡密组ID",String(d))}},P=l.useMemo(()=>An(t,M,W),[t,W,M]),ee=()=>{const U=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["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(I=>`"${String(I).replace(/"/g,'""')}"`).join(",")).join(` +`),E=new Blob(["\uFEFF"+U],{type:"text/csv;charset=utf-8"}),A=URL.createObjectURL(E),L=document.createElement("a");L.href=A,L.download="卡密组批量导入模板.csv",document.body.appendChild(L),L.click(),L.remove(),URL.revokeObjectURL(A)};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:T.openBatchModal,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(Pt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>f(!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(Xe,{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-surface-muted 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(_a,{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:M,onChange:d=>K(d.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:W,onChange:d=>j(d.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:["显示 ",P.length," / ",t.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:P.map(d=>{let G="";return d.type==="data"&&d.data_content?G=`库存: ${d.data_content.split(` +`).filter(E=>E.trim()).length} 条`:d.type==="text"&&d.text_content?G=d.text_content:d.type==="api"&&d.api_config?G=d.api_config.url:d.type==="image"&&d.image_url&&(G="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/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(Ln,{type:d.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:d.name,children:d.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>S(d.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:d.id}),e.jsx(rl,{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 ${d.type==="text"?"bg-blue-50 text-blue-600":d.type==="data"?"bg-purple-50 text-purple-600":d.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:d.type==="text"?"文本":d.type==="data"?"批量":d.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:G,children:G})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:d.description||"-",children:d.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>F(d),className:`w-12 h-8 rounded-full relative transition-colors ${d.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 ${d.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:()=>X(d),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(jt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>se(d.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Qe,{className:"h-4 w-4"})})]})})]},d.id)})})]})}),P.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(ha,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),a&&p&&Oe.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:()=>n(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Le,{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:m.name||"",onChange:d=>k({...m,name:d.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:m.type||"text",onChange:d=>k({...m,type:d.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:"批量数据"}),(p==null?void 0:p.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),m.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:m.api_url||"",onChange:d=>k({...m,api_url:d.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:m.api_method||"GET",onChange:d=>k({...m,api_method:d.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:m.api_timeout||10,onChange:d=>k({...m,api_timeout:parseInt(d.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:m.api_headers||"",onChange:d=>k({...m,api_headers:d.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:m.api_params||"",onChange:d=>k({...m,api_params:d.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}'})]})]}),m.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:m.text_content||"",onChange:d=>k({...m,text_content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),m.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:m.data_content||"",onChange:d=>k({...m,data_content:d.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:m.data_content?m.data_content.split(` +`).filter(d=>d.trim()).length:0})," 条"]})]})]}),m.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:m.image_url||"",onChange:d=>k({...m,image_url:d.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 地址"})]}),m.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:m.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:d=>{d.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:m.delay_seconds||0,onChange:d=>k({...m,delay_seconds:parseInt(d.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:m.description||"",onChange:d=>k({...m,description:d.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:()=>k({...m,enabled:!m.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${m.enabled?"bg-brand":"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.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:V,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),r&&Oe.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:()=>f(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Le,{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:u.name,onChange:d=>C({...u,name:d.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:()=>C({...u,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${u.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(_s,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>C({...u,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${u.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Na,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>C({...u,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${u.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(ja,{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:u.type==="data"?"库存内容(一行一个)":u.type==="text"?"固定回复内容":u.type==="image"?"图片 URL":"API 地址"}),u.type==="api"?e.jsx("input",{type:"url",value:u.content,onChange:d=>C({...u,content:d.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):u.type==="image"?e.jsx("input",{type:"url",value:u.content,onChange:d=>C({...u,content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:u.content,onChange:d=>C({...u,content:d.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${u.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:u.type==="data"?`CODE-123456 +CODE-789012 +...`:"请输入每次发货时发送的固定文字"}),u.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:u.content.split(` +`).filter(d=>d.trim()).length})," 条"]})]}),u.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:u.api_method,onChange:d=>C({...u,api_method:d.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:u.api_timeout,onChange:d=>C({...u,api_timeout:parseInt(d.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:u.api_headers,onChange:d=>C({...u,api_headers:d.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:u.api_params,onChange:d=>C({...u,api_params:d.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:u.description,onChange:d=>C({...u,description:d.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:u.delay_seconds,onChange:d=>C({...u,delay_seconds:parseInt(d.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:()=>f(!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:Z,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(Sn,{dataCards:R,downloadCardTemplate:ee,...T})]})},Ys="ydisks-amap-js-api",$n="c9b68d4ce9a2a97f22a4a439404488ca";let Lt=null;const En=()=>$n,Tn=()=>window.AMap?Promise.resolve(window.AMap):Lt||(Lt=new Promise((t,s)=>{const a=document.getElementById(Ys),n=a||document.createElement("script"),r=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(p)},f=()=>{window.AMap?(r(),t(window.AMap)):(r(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},p=window.setTimeout(()=>{r(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=f,n.id=Ys,n.async=!0,n.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(En())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,n.onerror=()=>{r(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},a||document.head.appendChild(n)}).catch(t=>{throw Lt=null,t}),Lt),Qt=t=>Number.isFinite(t)&&t!==0,Dn=t=>{var r,f;const s=Number((r=t.location)==null?void 0:r.lng),a=Number((f=t.location)==null?void 0:f.lat),n={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:a,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!n.division_id||!n.province||!n.city||!n.poi_id||!n.poi_name||!Qt(s)||!Qt(a)||s<-180||s>180||a<-90||a>90?null:n},Mn=async(t,s)=>{if(!Qt(t)||!Qt(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const a=await Tn();return new Promise((n,r)=>{new a.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(p,w)=>{var k;if(p!=="complete"){if(p==="no_data"){n([]);return}r(new Error("高德地图附近地址查询失败,请稍后重试"));return}const m=(((k=w==null?void 0:w.poiList)==null?void 0:k.pois)||[]).map(Dn).filter(u=>u!==null);n(m)})})},Bn=t=>t.find(s=>s.status==="running"||s.status==="canceling"),fs=t=>t==="running"||t==="canceling",qn=t=>!!(t!=null&&t.preview_id&&Number(t.valid||0)>0),Fn=t=>!!(t!=null&&t.id&&Number(t.retryable||0)>0&&!fs(t.status)),zn=(t,s)=>t===s,Xs=t=>{switch(t){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 t||"-"}},ea=t=>{switch(t){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"}},Un=t=>{const[s,a]=l.useState(!1),[n,r]=l.useState("upload"),[f,p]=l.useState(null),[w,m]=l.useState(null),[k,u]=l.useState(""),[C,M]=l.useState(!1),[K,W]=l.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[j,R]=l.useState(null),[T,X]=l.useState(null),[V,se]=l.useState(null),[Z,F]=l.useState([]),[S,P]=l.useState(null),[ee,d]=l.useState(!1),G=l.useRef(!1),U=l.useRef(0),E=l.useCallback(async()=>{r("upload"),R(null),X(null),p(null),m(null),u(""),W({catId:"",catName:"",channelCatId:"",tbCatId:""}),F([]),P(null),a(!0),d(!0);try{const v=await Oa(20),Q=Bn(v);if(Q!=null&&Q.id){const ce=await ht(Q.id);se(ce),X(ce),r(["running","canceling"].includes(ce.status)?"running":"done")}}catch(v){console.error("恢复最近批量铺货任务失败:",v)}finally{d(!1)}},[]),A=l.useCallback(async()=>{const v=k.trim();if(!t.selectedAccount){alert("请先选择默认发布账号");return}if(!v){alert("请输入类目关键词");return}M(!0);try{const ce=(await Nr(t.selectedAccount,v)).category;W({catId:ce.cat_id,catName:ce.cat_name,channelCatId:ce.channel_cat_id,tbCatId:ce.tb_cat_id||""})}catch(Q){console.error("获取推荐类目失败:",Q),alert((Q==null?void 0:Q.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{M(!1)}},[k,t.selectedAccount]),L=l.useCallback(async()=>{if(V!=null&&V.id){d(!0),a(!0);try{const v=await ht(V.id);X(v),r(["running","canceling"].includes(v.status)?"running":"done")}catch(v){console.error("加载最近批量铺货结果失败:",v)}finally{d(!1)}}},[V==null?void 0:V.id]),q=l.useCallback(async()=>{if(!f){alert("请先上传商品表格");return}if(!t.selectedAccount){alert("请先选择默认发布账号");return}d(!0);try{const v=await _r({file:f,imagesZip:w,defaultCookieId:t.selectedAccount,fallbackCategory:K,location:S||void 0});R(v),X(null),r("preview")}catch(v){console.error("批量铺货预检失败:",v),alert((v==null?void 0:v.message)||"预检失败,请检查表格和图片 zip")}finally{d(!1)}},[K,f,w,S,t.selectedAccount]),I=l.useCallback(async()=>{if(j!=null&&j.preview_id){if(!qn(j)){alert("没有可发布的商品行");return}d(!0);try{const v=await vr(j.preview_id),Q=await ht(v.batch_id||j.preview_id);X(Q),se(Q),r(Q.status==="running"?"running":"done")}catch(v){console.error("启动批量铺货失败:",v),alert((v==null?void 0:v.message)||"启动发布任务失败")}finally{d(!1)}}},[j]),B=l.useCallback(async()=>{if(T!=null&&T.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){d(!0);try{const v=await kr(T.id),Q=await ht(T.id);X(Q),r((v==null?void 0:v.status)==="canceling"||Q.status==="canceling"?"running":"done")}catch(v){alert((v==null?void 0:v.message)||"取消失败")}finally{d(!1)}}},[T==null?void 0:T.id]),$=l.useCallback(async()=>{const v=j==null?void 0:j.preview_id;if(v&&n==="preview")try{await wr(v)}catch(Q){console.error("清理批量铺货预检失败:",Q)}R(null),r("upload")},[n,j==null?void 0:j.preview_id]),x=l.useCallback(async()=>{await $(),a(!1)},[$]),g=l.useCallback(async()=>{if(!(!(T!=null&&T.id)||!Fn(T))){d(!0);try{await Cr(T.id),X(await ht(T.id)),r("running")}catch(v){alert((v==null?void 0:v.message)||"重试失败")}finally{d(!1)}}},[T==null?void 0:T.id]);return l.useEffect(()=>{if(!s||!(T!=null&&T.id)||!fs(T.status))return;const v=++U.current,Q=async()=>{if(!G.current){G.current=!0;try{const de=await ht(T.id);if(!zn(v,U.current))return;X(de),se(de),fs(de.status)||(r("done"),await Promise.all([t.loadItems(),t.loadShippingRules()]))}catch(de){console.error("刷新批量铺货进度失败:",de)}finally{G.current=!1}}},ce=window.setInterval(()=>void Q(),3e3);return(()=>{window.clearInterval(ce),U.current+=1})},[T==null?void 0:T.id,T==null?void 0:T.status,t.loadItems,t.loadShippingRules,s]),{showBatchModal:s,setShowBatchModal:a,batchLoading:ee,batchPhase:n,setBatchPhase:r,batchFile:f,setBatchFile:p,batchImagesZip:w,setBatchImagesZip:m,batchCategoryKeyword:k,setBatchCategoryKeyword:u,batchCategoryLoading:C,batchFallbackCategory:K,setBatchFallbackCategory:W,batchPreview:j,setBatchPreview:R,batchDetail:T,setBatchDetail:X,recentBatch:V,setRecentBatch:se,batchLocations:Z,batchLocation:S,setBatchLocations:F,setBatchLocation:P,openBatchModal:E,handleRecommendBatchCategory:A,openRecentBatchResult:L,handlePreviewBatch:q,handleStartBatch:I,handleCancelBatch:B,abandonBatchPreview:$,closeBatchModal:x,handleRetryBatchFailed:g}},Wn=({phase:t})=>{const s=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:s.map(([a,n])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${t===a?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:n},a))})},Jn=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s:`¥${s}`:"-"},Gn=({onConfigureDelivery:t})=>{const[s,a]=l.useState([]),[n,r]=l.useState([]),[f,p]=l.useState([]),[w,m]=l.useState(""),[k,u]=l.useState(""),[C,M]=l.useState(!1),[K,W]=l.useState(!1),[j,R]=l.useState(!1),[T,X]=l.useState(!1),[V,se]=l.useState(!1),[Z,F]=l.useState(!1),[S,P]=l.useState([]),[ee,d]=l.useState(null),[G,U]=l.useState(null),[E,A]=l.useState({}),[L,q]=l.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[I,B]=l.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[$,x]=l.useState([]),g=l.useCallback(async()=>{const c=await _t();a(c)},[]),H=l.useCallback(async()=>{r(await bs())},[]),v=Un({selectedAccount:w,loadItems:g,loadShippingRules:H}),{showBatchModal:Q,setShowBatchModal:ce,batchLoading:de,batchPhase:_e,batchFile:Ae,setBatchFile:Ee,batchImagesZip:Te,setBatchImagesZip:Me,batchCategoryKeyword:b,setBatchCategoryKeyword:N,batchCategoryLoading:ae,batchFallbackCategory:y,setBatchFallbackCategory:le,batchPreview:J,batchDetail:xe,recentBatch:re,setRecentBatch:$e,batchLocations:Se,batchLocation:Be,setBatchLocations:_,setBatchLocation:O,openBatchModal:Y,handleRecommendBatchCategory:te,openRecentBatchResult:ve,handlePreviewBatch:je,handleStartBatch:ue,handleCancelBatch:be,abandonBatchPreview:pe,closeBatchModal:Re,handleRetryBatchFailed:oe}=v;l.useEffect(()=>{if(!V||I.images.length===0){x([]);return}const c=I.images.map((z,me)=>({key:z.name+me,url:URL.createObjectURL(z)}));return x(c),()=>{c.forEach(z=>URL.revokeObjectURL(z.url))}},[V,I.images]),l.useEffect(()=>{Promise.all([Tt(),_t(),bs(),Oa(20)]).then(([c,z,me,Ie])=>{p(c),a(z),r(me);const Ge=Ie.find(qe=>["running","canceling"].includes(qe.status))||Ie.find(qe=>qe.status!=="preview");$e(Ge||null)}).catch(c=>console.error("加载商品配置失败:",c))},[]);const ke=async()=>{if(!w)return alert("请先选择账号");M(!0);try{const c=await br(w);await g(),alert((c==null?void 0:c.message)||"商品同步完成")}catch(c){console.error("同步商品失败:",c),alert((c==null?void 0:c.message)||"同步失败,请重试")}finally{M(!1)}},ze=c=>{U(c),A({...c}),R(!0)},De=async()=>{if(G)try{await Sr(G.cookie_id,G.item_id,{item_title:E.item_title||"",item_description:E.item_description||"",item_category:E.item_category||"",item_price:E.item_price||"",item_detail:E.item_detail||G.item_detail||""}),await g(),await H(),R(!1),U(null)}catch(c){console.error("更新商品失败:",c),alert("更新失败,请重试")}},lt=async c=>{if(confirm(`确认删除商品"${c.item_title}"吗?`))try{await yr(c.cookie_id,c.item_id),a(z=>z.filter(me=>!(me.cookie_id===c.cookie_id&&me.item_id===c.item_id)))}catch(z){console.error("删除商品失败:",z),alert("删除失败,请重试")}},We=async()=>{try{if(!L.cookie_id||!L.item_id){alert("请选择账号并填写商品ID");return}await fr(L.cookie_id,{item_id:L.item_id,item_title:L.item_title,item_price:L.item_price,item_detail:L.item_image?JSON.stringify({item_image:L.item_image}):""}),await g(),X(!1),q({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(c){console.error("添加商品失败:",c),alert("添加失败,请重试")}},Je=async()=>{if(!I.cookie_id)return alert("请选择发布账号");if(!I.title.trim())return alert("请填写商品标题");if(!I.price.trim())return alert("请填写商品价格");if(!I.quantity||Number(I.quantity)<=0)return alert("库存数量必须大于 0");if(I.images.length===0)return alert("至少上传 1 张商品图片");if(I.postage_mode==="fixed"&&!I.postage.trim())return alert("请填写一口价邮费");W(!0);try{const c=await jr({...I,location:ee||void 0});if(await g(),se(!1),B({cookie_id:w||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),P([]),d(null),c!=null&&c.item_id){const z={id:c.item_id,cookie_id:I.cookie_id,item_id:c.item_id,item_title:c.item_title||I.title,item_price:c.item_price||I.price,item_image:c.item_image};t(z),alert("商品发布成功,ID: "+c.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(c){console.error("发布商品失败:",c);const z=c==null?void 0:c.payload;if((z==null?void 0:z.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((c==null?void 0:c.message)||"发布失败,请重试")}finally{W(!1)}},wt=()=>{const me=[["账号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(pt=>pt.map(et=>`"${String(et).replace(/"/g,'""')}"`).join(",")).join(` +`),Ie=new Blob(["\uFEFF"+me],{type:"text/csv;charset=utf-8"}),Ge=URL.createObjectURL(Ie),qe=document.createElement("a");qe.href=Ge,qe.download="批量铺货模板.csv",document.body.appendChild(qe),qe.click(),qe.remove(),URL.revokeObjectURL(Ge)},kt=()=>{q(c=>({...c,cookie_id:w||c.cookie_id})),X(!0)},ct=()=>{B(c=>({...c,cookie_id:w||c.cookie_id})),se(!0)},dt=async c=>{if(!(c?w:I.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");F(!0),navigator.geolocation.getCurrentPosition(async me=>{try{const Ie=await Mn(me.coords.longitude,me.coords.latitude);if(!Ie.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");c?(_(Ie),O(Ie[0])):(P(Ie),d(Ie[0]))}catch(Ie){alert((Ie==null?void 0:Ie.message)||"获取发货地失败")}finally{F(!1)}},me=>{F(!1),alert(me.code===me.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},Ct=c=>n.filter(z=>z.cookie_id===c.cookie_id&&z.item_id===c.item_id).length>0?n.filter(z=>z.cookie_id===c.cookie_id&&z.item_id===c.item_id):n.filter(z=>z.cookie_id===c.cookie_id&&!z.item_id),xt=l.useMemo(()=>new Map(f.map(c=>[c.id,c])),[f]),mt=l.useMemo(()=>k?s.filter(c=>c.cookie_id===k):s,[k,s]),He=c=>{const z=xt.get(c),me=(z==null?void 0:z.remark)||(z==null?void 0:z.nickname);return me?`${me} · ${c.slice(0,6)}`:`账号 ${c.slice(0,8)}`},ut=c=>{const z=xt.get(c);return(z==null?void 0:z.remark)||(z==null?void 0:z.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(nl,{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:k,onChange:c=>u(c.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),f.map(c=>e.jsx("option",{value:c.id,children:He(c.id)},c.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(ot,{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:w,onChange:c=>m(c.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),f.map(c=>e.jsx("option",{value:c.id,children:He(c.id)},c.id))]})]})]}),e.jsxs("button",{onClick:ke,disabled:C||!w,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(Ue,{className:`w-4 h-4 ${C?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:kt,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(Xe,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:ct,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Zt,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Y(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Mt,{className:"w-4 h-4"}),re&&["running","canceling"].includes(re.status)?"继续批量任务":"批量铺货"]}),re&&!["running","canceling"].includes(re.status)&&e.jsx("button",{onClick:()=>void ve(),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:[mt.map(c=>{const z=Ct(c),me=z.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:()=>ze(c),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(jt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>lt(c),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(Qe,{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:[c.item_image?e.jsx("img",{src:c.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(ua,{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:Jn(c.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:c.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:ut(c.cookie_id),children:[e.jsx(ot,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:ut(c.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: ",c.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${me?"text-emerald-600":"text-amber-600"}`,children:[me?e.jsx(xs,{className:"w-3 h-3"}):e.jsx(il,{className:"w-3 h-3"}),me?`${z.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>t(c),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${me?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ol,{className:"w-3.5 h-3.5"}),me?"查看发货规则":"关联发货规则"]}),e.jsx(ms,{className:"w-3.5 h-3.5"})]})})]},`${c.cookie_id}-${c.item_id}`)}),mt.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(pa,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),k?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),j&&G&&Oe.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: ",G.item_id]})]}),e.jsx("button",{onClick:()=>R(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Le,{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:E.item_title||"",onChange:c=>A({...E,item_title:c.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:E.item_price||"",onChange:c=>A({...E,item_price:c.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:E.item_category||"",onChange:c=>A({...E,item_category:c.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:E.item_description||"",onChange:c=>A({...E,item_description:c.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:De,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),T&&Oe.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:()=>X(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Le,{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:L.cookie_id,onChange:c=>q({...L,cookie_id:c.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(c=>e.jsx("option",{value:c.id,children:He(c.id)},c.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:L.item_id,onChange:c=>q({...L,item_id:c.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:L.item_price,onChange:c=>q({...L,item_price:c.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:L.item_title,onChange:c=>q({...L,item_title:c.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:L.item_image,onChange:c=>q({...L,item_image:c.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:We,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(Xe,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),V&&Oe.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:()=>se(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Le,{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:I.cookie_id,onChange:c=>{B({...I,cookie_id:c.target.value}),P([]),d(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(c=>e.jsx("option",{value:c.id,children:He(c.id)},c.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:I.title,onChange:c=>B({...I,title:c.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:I.quantity,onChange:c=>B({...I,quantity:c.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:I.description,onChange:c=>B({...I,description:c.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:I.price,onChange:c=>B({...I,price:c.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:I.original_price,onChange:c=>B({...I,original_price:c.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:I.postage_mode,onChange:c=>B({...I,postage_mode:c.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:"无需邮寄"})]})]})]}),I.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:I.postage,onChange:c=>B({...I,postage:c.target.value})})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:Z||!I.cookie_id,onClick:()=>void dt(!1),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx($s,{className:"h-4 w-4"}),Z?"定位中...":"获取当前位置"]})]}),S.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,S.indexOf(ee))),onChange:c=>d(S[Number(c.target.value)]||null),children:S.map((c,z)=>e.jsx("option",{value:String(z),children:[c.province,c.city,c.area,c.poi_name].filter(Boolean).join(" ")},`${c.division_id}-${c.poi_id}-${z}`))})]}),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(Mt,{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:I.images.length?"已选择 "+I.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:c=>B({...I,images:Array.from(c.target.files||[]).slice(0,9)})})]}),$.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:$.map(c=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:c.url,alt:"",className:"w-full h-full object-cover"})},c.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:K,onClick:Je,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Zt,{className:"w-4 h-4"}),K?"正在发布...":"发布到闲鱼"]})})]})}),document.body),Q&&Oe.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 Re(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Le,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(Wn,{phase:_e}),_e==="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:wt,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:w,onChange:c=>{m(c.target.value),_([]),O(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(c=>e.jsx("option",{value:c.id,children:He(c.id)},c.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(Nt,{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:b,onChange:c=>N(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),te())}})]}),e.jsxs("button",{type:"button",disabled:!w||!b.trim()||ae,onClick:()=>void te(),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(Nt,{className:"h-4 w-4"}),ae?"匹配中...":"获取类目"]})]}),y.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(xs,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:y.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",y.catId," · 频道 ",y.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>le({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(Le,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:Z||!w,onClick:()=>void dt(!0),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx($s,{className:"h-4 w-4"}),Z?"定位中...":"获取当前位置"]})]}),Se.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,Se.indexOf(Be))),onChange:c=>O(Se[Number(c.target.value)]||null),children:Se.map((c,z)=>e.jsx("option",{value:String(z),children:[c.province,c.city,c.area,c.poi_name].filter(Boolean).join(" ")},`${c.division_id}-${c.poi_id}-${z}`))})]}),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(Mt,{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:Ae?Ae.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:c=>{var z;return Ee(((z=c.target.files)==null?void 0:z[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(Mt,{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:Te?Te.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:c=>{var z;return Me(((z=c.target.files)==null?void 0:z[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(([c,z,me])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:c}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${z==="每个商品都要填"?"text-red-600":z==="可以留空"?"text-gray-500":"text-amber-700"}`,children:z}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:me})]},c))})]})})]})]}),_e==="preview"&&J&&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: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-2xl font-extrabold text-emerald-700 mt-1",children:J.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:J.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:J.rows.map(c=>{var z,me,Ie,Ge;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:c.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 ${c.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:c.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:c.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",c.price||"-"," / ",c.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:((z=c.category)==null?void 0:z.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((me=c.category)==null?void 0:me.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Ie=c.images)==null?void 0:Ie.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((Ge=c.errors)==null?void 0:Ge.join(";"))||"-"})]},c.row_no)})})]})})]}),(_e==="running"||_e==="done")&&xe&&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 ${ea(xe.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:Xs(xe.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:xe.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:xe.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:xe.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:xe.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:xe.rows.map(c=>{var z,me;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:c.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 ${ea(c.status)}`,children:Xs(c.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:c.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:((z=c.category)==null?void 0:z.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((me=c.category)==null?void 0:me.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:c.item_url?e.jsx("a",{href:c.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:c.item_id}):c.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:c.error_message||"-"})]},c.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[_e==="upload"&&e.jsxs("button",{disabled:de||!Ae||!w,onClick:je,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(Ue,{className:`w-4 h-4 ${de?"animate-spin":""}`}),de?"正在预检...":"开始预检"]}),_e==="preview"&&J&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:de,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:de||J.valid<=0,onClick:ue,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(Zt,{className:"w-4 h-4"}),de?"启动中...":`确认发布 ${J.valid} 个商品`]})]}),(_e==="running"||_e==="done")&&xe&&e.jsxs("div",{className:"flex gap-3 w-full",children:[xe.status==="running"?e.jsx("button",{disabled:de,onClick:be,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):xe.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(`/api/v1/items/publish-batches/${xe.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:"下载结果"}),xe.retryable>0&&!["running","canceling"].includes(xe.status)&&e.jsxs("button",{disabled:de,onClick:oe,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(Ue,{className:`w-4 h-4 ${de?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(xe.status)&&e.jsx("button",{onClick:()=>{ce(!1),g(),H()},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)]})},ta="https://dashscope.aliyuncs.com/compatible-mode/v1",Qn=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],Vn=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"]),Kn=()=>{const[t,s]=l.useState(null),[a,n]=l.useState(!1),[r,f]=l.useState(""),[p,w]=l.useState(!1),[m,k]=l.useState([]),[u,C]=l.useState(!1),[M,K]=l.useState(""),[W,j]=l.useState(!1),R=l.useRef(null),[T,X]=l.useState(!1),[V,se]=l.useState(!1),[Z,F]=l.useState(!1),[S,P]=l.useState(!1),[ee,d]=l.useState(!1),[G,U]=l.useState(null),[E,A]=l.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});l.useEffect(()=>{q(),La().then(g=>{g.username&&A(H=>({...H,new_username:g.username||""}))}).catch(()=>{})},[]),l.useEffect(()=>{const g=H=>{var v;(v=R.current)!=null&&v.contains(H.target)||j(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const L=async(g,H=!1)=>{const v=g||t,Q=(v==null?void 0:v.ai_api_url)||(v==null?void 0:v.ai_base_url)||ta;C(!0),K("");try{const ce=await Fr(Q,(v==null?void 0:v.ai_api_key)||"");k(ce),j(H&&ce.length>0),!(v!=null&&v.ai_model)&&ce.length>0&&s(de=>de&&{...de,ai_model:ce[0]})}catch(ce){k([]),j(!1),K(ce.message||"读取模型失败")}finally{C(!1)}},q=()=>{n(!0),f(""),Pa().then(g=>{s(g),L(g)}).catch(g=>{s(null),f(g.message||"加载配置失败")}).finally(()=>n(!1))},I=async()=>{if(t){w(!0);try{const g=Object.fromEntries(Object.entries(t).filter(([H,v])=>!Vn.has(H)&&v!==void 0&&v!==null));await $a(g),alert("系统配置已保存")}catch(g){alert("保存失败:"+g.message)}finally{w(!1)}}},B=async g=>{g.preventDefault(),U(null);const H=E.new_username.trim();if(H.length<3){U({type:"error",text:"用户名至少需要 3 个字符"});return}if(!E.current_password){U({type:"error",text:"请输入当前密码确认身份"});return}if(E.new_password&&E.new_password.length<8){U({type:"error",text:"新密码至少需要 8 个字符"});return}if(E.new_password!==E.confirm_password){U({type:"error",text:"两次输入的新密码不一致"});return}d(!0);try{const v=await Tl({current_password:E.current_password,new_username:H,new_password:E.new_password||void 0});if(!v.success){U({type:"error",text:v.message||"登录凭据更新失败"});return}U({type:"success",text:v.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(v){U({type:"error",text:v.message||"登录凭据更新失败"})}finally{d(!1)}};if(!t)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:r||(a?"加载配置中...":"暂无配置")});const $=t.ai_model||"",x=m;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(vs,{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:q,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(Ue,{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(cl,{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:t.log_level||"info",onChange:g=>s({...t,log_level:g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:Qn.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:t.log_format||"text",onChange:g=>s({...t,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:t.renewal_log_retention_days??10,onChange:g=>s({...t,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-brand text-white",children:e.jsx(Cs,{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:t.ai_api_url||ta,onChange:g=>s({...t,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:T?"text":"password",value:t.ai_api_key||"",onChange:g=>s({...t,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:()=>X(!T),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:T?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(st,{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:R,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:$,onFocus:()=>m.length>0&&j(!0),onChange:g=>{s({...t,ai_model:g.target.value}),m.length>0&&j(!0)},onKeyDown:g=>{g.key==="Escape"&&j(!1),g.key==="ArrowDown"&&m.length>0&&j(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>m.length>0&&j(g=>!g),disabled:m.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(dl,{className:`w-4 h-4 transition-transform ${W?"rotate-180":""}`})}),W&&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:x.length>0?x.map(g=>e.jsxs("button",{type:"button",onClick:()=>{s({...t,ai_model:g}),j(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:g}),g===$&&e.jsx(Ve,{className:"w-4 h-4 shrink-0 text-brand"})]},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:u,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(Ue,{className:`w-4 h-4 ${u?"animate-spin":""}`}),"读取模型"]})]}),M?e.jsx("p",{className:"text-xs text-red-500",children:M}):e.jsx("p",{className:"text-xs text-gray-500",children:m.length>0?`已从当前 API 地址读取到 ${m.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($t,{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:t["captcha.remote_service_url"]||"",onChange:g=>s({...t,"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:V?"text":"password",value:t["captcha.remote_secret_key"]||"",onChange:g=>s({...t,"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:()=>se(!V),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:V?"隐藏秘钥":"显示秘钥",children:V?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(st,{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(t["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:g=>s({...t,"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(Es,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:B,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(Jt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:E.new_username,onChange:g=>A({...E,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:Z?"text":"password",value:E.current_password,onChange:g=>A({...E,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:()=>F(!Z),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:Z?"隐藏密码":"显示密码",children:Z?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(st,{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:S?"text":"password",value:E.new_password,onChange:g=>A({...E,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:()=>P(!S),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:S?"隐藏密码":"显示密码",children:S?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(st,{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:S?"text":"password",value:E.confirm_password,onChange:g=>A({...E,confirm_password:g.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),G&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${G.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx($t,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:G.text})]}),e.jsxs("button",{type:"submit",disabled:ee||!E.new_username||!E.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(Es,{className:"w-4 h-4"}),ee?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:I,disabled:p,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(Ye,{className:"w-6 h-6"}),p?"保存中...":"保存所有配置"]})})]})},ls=(t,s)=>t.allowed_resolutions.includes(s),Hn=(t,s)=>({runs:t.runs.filter(a=>!s||a.cookie_id===s),pending_tasks:t.pending_tasks.filter(a=>!s||a.cookie_id===s)}),Zn=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",Yn=({runs:t,pendingTasks:s,onResolveRun:a,onResolveDeferredTask:n})=>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(at,{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:[t.map(r=>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:["账号 ",r.cookie_id," · 订单 ",r.order_id||"-"," · 已记录发送 ",r.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Zn(r.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:r.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[ls(r,"continue")&&e.jsx("button",{onClick:(()=>a(r.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),ls(r,"retry")&&e.jsx("button",{onClick:(()=>a(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),ls(r,"cancel")&&e.jsx("button",{onClick:(()=>a(r.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${r.id}`)),s.map(r=>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:["账号 ",r.cookie_id," · 延迟任务重试已达 ",r.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:r.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>n(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>n(r.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${r.id}`))]})]}),rs=()=>({submitting:!1,result:"idle"}),ns=t=>t.submitting?t:{submitting:!0,result:"idle"},is=(t,s)=>({submitting:!1,result:s?"success":"failure"}),sa=t=>t+1,os=(t,s,a,n)=>t===s&&a===n,Xn=t=>{const[s,a]=l.useState([]),[n,r]=l.useState({runs:[],pending_tasks:[]}),[f,p]=l.useState([]),[w,m]=l.useState({}),[k,u]=l.useState([]),[C,M]=l.useState([]),[K,W]=l.useState([]),[j,R]=l.useState(!1),T=l.useRef(0),X=l.useRef(0),[V,se]=l.useState(0),[Z,F]=l.useState(0),[S,P]=l.useState({}),ee=l.useCallback(async()=>{const L=Promise.all([Tt(),Ls(),_t(),Vs()]),[q,I,B,$]=await L;u(q),M(I),W(B),m($),t.setSelectedAccountId(x=>{var g;return x||((g=q[0])==null?void 0:g.id)||""})},[t.setSelectedAccountId]),d=l.useCallback(async()=>{var $;const L=sa(T.current);T.current=L;const q=Or().catch(x=>(console.warn("加载自动化异常列表失败,不阻断规则展示",x),null)),I=await Lr({cookieId:t.selectedAccountId||void 0,triggerType:t.automationTriggerFilter,enabled:t.automationStatusFilter==="all"?void 0:t.automationStatusFilter==="enabled",search:t.debouncedAutomationSearch,page:t.automationPage,pageSize:t.automationPageSize});if(!os(L,T.current,t.selectedAccountId,t.selectedAccountId))return;a(I.data),se(I.total),F(I.total_pages),P(I.trigger_counts||{}),I.page!==t.automationPage&&(($=t.onAutomationPageChange)==null||$.call(t,I.page));const B=await q;os(L,T.current,t.selectedAccountId,t.selectedAccountId)&&B&&r(B)},[t.automationPage,t.automationPageSize,t.automationStatusFilter,t.automationTriggerFilter,t.debouncedAutomationSearch,t.onAutomationPageChange,t.selectedAccountId]),G=l.useCallback(async()=>{const L=sa(X.current);X.current=L;const q=t.selectedAccountId;if(p([]),!q)return;const I=await Tr(q);os(L,X.current,q,t.selectedAccountId)&&p(I)},[t.selectedAccountId]),U=l.useCallback(async()=>{m(await Vs())},[]),E=l.useCallback(async()=>{R(!0);try{t.activeTab==="automation"?await d():t.activeTab==="reply"?await G():await U()}finally{R(!1)}},[d,U,G,t.activeTab]);return{automationRules:s,automationIssues:n,replyRules:f,defaultReplies:w,accounts:k,cards:C,items:K,automationTotal:V,automationTotalPages:Z,automationTriggerCounts:S,loading:j,setLoading:R,setAutomationRules:a,setCards:M,setItems:W,loadReferenceData:ee,loadAutomationRules:d,loadReplyRules:G,loadDefaultReplies:U,refresh:E}},tt={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Et},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:xl},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:va}},Ut=["order_paid","buyer_reviewed","review_missing_timeout"],ei="亲,商品使用满意的话,麻烦给个评价,谢谢~",At=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),Ba=t=>{if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}},rt=(t,s={})=>{const a=Ba(t);return JSON.stringify({after_shipped_hours:Number(a.after_shipped_hours||72),repeat_interval_hours:Number(a.repeat_interval_hours||24),max_attempts:Number(a.max_attempts||1),...s})},It=(t,s)=>{var n;const a=((n=tt[t])==null?void 0:n.label)||"自动化规则";return s?`${a} - ${s}`:a},aa=t=>{const s=(t||"").trim();return s?Object.values(tt).some(a=>s===a.label||s.startsWith(`${a.label} -`)):!0},Ot=(t,s=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:ei,enabled:!0,sort_order:1}];const a={action_type:"send_card",card_id:s,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[a,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[a]},ti=t=>{var a,n;if(t.trigger_type==="review_missing_timeout")return((n=(a=t.actions)==null?void 0:a.find(r=>r.action_type==="send_text"))==null?void 0:n.message_template)||"发送求评价文案";const s=(t.actions||[]).filter(r=>r.action_type==="send_card");return s.length?s.map(r=>r.card_name||`卡密 ${r.card_id}`).join(" / "):"未配置卡密库存"},la=(t,s=!1)=>{const a={blue:s?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:s?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:s?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return a[t]||a.blue},si=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Wt=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",ai=t=>t===!0||t===1||t==="1",li=({initialDeliveryTarget:t,onDeliveryTargetHandled:s})=>{var qe,pt,et;const[a,n]=l.useState("automation"),[r,f]=l.useState(""),[p,w]=l.useState(""),[m,k]=l.useState(""),[u,C]=l.useState(""),[M,K]=l.useState("all"),[W,j]=l.useState(1),[R,T]=l.useState(10),X=Xn({activeTab:a,selectedAccountId:r,automationTriggerFilter:u,automationStatusFilter:M,debouncedAutomationSearch:m,automationPage:W,automationPageSize:R,setSelectedAccountId:f,onAutomationPageChange:j}),{automationRules:V,automationIssues:se,replyRules:Z,defaultReplies:F,accounts:S,cards:P,items:ee,loading:d,setLoading:G,automationTotal:U,automationTotalPages:E,automationTriggerCounts:A,setAutomationRules:L,setCards:q,setItems:I,loadReferenceData:B,loadAutomationRules:$,loadReplyRules:x,loadDefaultReplies:g,refresh:H}=X,[v,Q]=l.useState(!1),[ce,de]=l.useState(!1),[_e,Ae]=l.useState(!1),[Ee,Te]=l.useState(rs),[Me,b]=l.useState(rs),[N,ae]=l.useState(rs),[y,le]=l.useState(null),[J,xe]=l.useState(null),[re,$e]=l.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});S.find(o=>o.id===r),l.useEffect(()=>{const o=window.setTimeout(()=>{j(1),k(p.trim())},300);return()=>window.clearTimeout(o)},[p]),l.useEffect(()=>{B().catch(o=>console.error("加载规则参考数据失败",o))},[B]),l.useEffect(()=>{H().catch(o=>console.error("刷新规则页面失败",o))},[H]);const Se=l.useMemo(()=>V.filter(o=>!r||o.cookie_id===r),[V,r]),Be=l.useMemo(()=>Hn(se,r),[se,r]),_=l.useMemo(()=>S.filter(o=>!r||o.id===r),[S,r]),O=l.useMemo(()=>{if(E<=1)return[];const o=Math.max(1,Math.min(W-2,E-4)),i=Math.min(E,o+4);return Array.from({length:i-o+1},(h,D)=>o+D)},[W,E]),Y=!!(p.trim()||u||M!=="all"),te=()=>{w(""),k(""),C(""),K("all"),j(1)},ve=l.useMemo(()=>{const o=(y==null?void 0:y.cookie_id)||r;return ee.filter(i=>i.cookie_id===o)},[y==null?void 0:y.cookie_id,ee,r]),je=l.useMemo(()=>{if(!(!(y!=null&&y.cookie_id)||!(y!=null&&y.item_id)))return ee.find(o=>o.cookie_id===y.cookie_id&&o.item_id===y.item_id)},[y==null?void 0:y.cookie_id,y==null?void 0:y.item_id,ee]),ue=ai(je==null?void 0:je.is_multi_spec),be=(y==null?void 0:y.trigger_type)||"order_paid",pe=tt[be],Re=Ba(y==null?void 0:y.config_json),oe=l.useCallback((o="order_paid",i=r,h="")=>{const D=ee.find(he=>he.cookie_id===i&&he.item_id===h),ne=(D==null?void 0:D.item_title)||h;return{name:It(o,ne),trigger_type:o,cookie_id:i,item_id:h,item_title:(D==null?void 0:D.item_title)||"",item_keyword:ne,card_group_id:0,priority:100,enabled:!0,config_json:o==="review_missing_timeout"?rt():"{}",actions:Ot(o),variants:o==="review_missing_timeout"?[]:[At()]}},[ee,r]),ke=l.useCallback(o=>{var h,D;const i=o.trigger_type||"order_paid";le({...o,trigger_type:i,config_json:i==="review_missing_timeout"?rt(o.config_json):o.config_json||"{}",actions:(h=o.actions)!=null&&h.length?o.actions.map(ne=>({...ne})):Ot(i,o.card_group_id),variants:(D=o.variants)!=null&&D.length?o.variants.map(ne=>({...ne})):i==="review_missing_timeout"?[]:[At()]}),Q(!0)},[]);l.useEffect(()=>{if(!t)return;let o=!1;return(async()=>{n("automation"),f(t.cookieId),G(!0);try{const[h,D,ne]=await Promise.all([bs(),_t(),Ls().catch(ie=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",ie),[]))]);if(o)return;L(h),I(D),q(ne);const he=h.find(ie=>ie.cookie_id===t.cookieId&&ie.item_id===t.itemId&&ie.trigger_type==="order_paid");if(he)ke(he);else{const ie=D.find(Ce=>Ce.cookie_id===t.cookieId&&Ce.item_id===t.itemId);le({...oe("order_paid",t.cookieId,t.itemId),item_title:(ie==null?void 0:ie.item_title)||"",item_keyword:(ie==null?void 0:ie.item_title)||t.itemId,name:It("order_paid",(ie==null?void 0:ie.item_title)||t.itemId)}),Q(!0)}}catch(h){console.error("打开商品自动化规则失败",h),alert("无法加载该商品的自动化规则")}finally{o||(G(!1),s==null||s())}})(),()=>{o=!0}},[oe,t,s,ke]);const ze=(o="order_paid")=>{if(!r){alert("请先选择账号");return}le(oe(o)),Q(!0)},De=o=>{var D,ne,he,ie,Ce;if(!y)return;const i=((ne=(D=y.variants)==null?void 0:D.find(Pe=>Pe.card_id))==null?void 0:ne.card_id)||((ie=(he=y.actions)==null?void 0:he.find(Pe=>Pe.action_type==="send_card"))==null?void 0:ie.card_id)||y.card_group_id||0,h=(je==null?void 0:je.item_title)||y.item_title||y.item_id||"";le({...y,trigger_type:o,name:aa(y.name)?It(o,h):y.name,card_group_id:i,config_json:o==="review_missing_timeout"?rt(y.config_json):"{}",actions:Ot(o,i),variants:o==="review_missing_timeout"?[]:(Ce=y.variants)!=null&&Ce.length?y.variants:[{...At(),card_id:i}]})},lt=o=>{if(!y)return;const i=ee.find(D=>D.cookie_id===(y.cookie_id||r)&&D.item_id===o),h=(i==null?void 0:i.item_title)||o;le({...y,item_id:o,item_title:(i==null?void 0:i.item_title)||"",item_keyword:h,name:aa(y.name)?It(be,h):y.name})},We=(qe=y==null?void 0:y.variants)!=null&&qe.length?y.variants:[At()],Je=(o,i)=>{var D;if(!y)return;const h=We.map((ne,he)=>he===o?{...ne,...i}:ne);le({...y,variants:h,card_group_id:((D=h[0])==null?void 0:D.card_id)||0})},wt=()=>{if(!y)return;const o=We[We.length-1];le({...y,variants:[...We,{...At(),spec_name:ue&&(o==null?void 0:o.spec_name)||"",spec_value:ue&&(o==null?void 0:o.spec_value)||""}]})},kt=async()=>{var ne,he,ie,Ce,Pe;if(!y||Ee.submitting)return;const o=y.trigger_type||"order_paid";if(!y.cookie_id){alert("请选择账号");return}const i=(ne=y.variants)!=null&&ne.length?y.variants:[];if(o!=="review_missing_timeout"){if(!i.length||i.some(ye=>!ye.card_id)){alert(o==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(ue&&i.some(ye=>!ye.spec_name.trim()||!ye.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(o==="review_missing_timeout"&&!(((ie=(he=y.actions)==null?void 0:he.find(Dt=>Dt.action_type==="send_text"))==null?void 0:ie.message_template)||"").trim()){alert("请填写求评价文案");return}const h=o==="review_missing_timeout"?[]:i.map(ye=>({...ye,spec_name:ue?ye.spec_name.trim():"",spec_value:ue?ye.spec_value.trim():"",delivery_count:Math.max(1,Number(ye.delivery_count)||1),enabled:ye.enabled!==!1}));Te(ns(Ee));let D=!1;try{await Gs({...y,trigger_type:o,name:(y.name||"").trim()||It(o,(je==null?void 0:je.item_title)||y.item_id||""),config_json:o==="review_missing_timeout"?rt(y.config_json):y.config_json||"{}",actions:(Ce=y.actions)!=null&&Ce.length?y.actions:Ot(o,((Pe=h[0])==null?void 0:Pe.card_id)||y.card_group_id||0),variants:h}),Q(!1),await Promise.all([$(),B()]),alert("保存成功"),D=!0}catch(ye){console.error("保存自动化规则失败:",ye),alert("保存失败:"+ye.message)}finally{Te(ye=>is(ye,D))}},ct=async o=>{if(confirm("确定删除该自动化规则吗?"))try{await Ir(o),await $(),alert("删除成功")}catch(i){alert("删除失败:"+i.message)}},dt=async o=>{try{await Gs({...o,enabled:!o.enabled}),await $()}catch(i){alert("操作失败:"+i.message)}},Ct=async(o,i)=>{if(confirm(i==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":i==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Rr(o,i),await $()}catch(D){alert("处理失败:"+D.message)}},xt=async(o,i)=>{if(confirm(i==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Pr(o,i),await $()}catch(h){alert("处理失败:"+h.message)}},mt=()=>{if(!r){alert("请先选择账号");return}xe({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),de(!0)},He=async()=>{var h,D,ne;if(!J||!r||Me.submitting)return;const o=J.type==="image"?!!((h=J.image_url)!=null&&h.trim()):!!((D=J.reply_content)!=null&&D.trim());if(!((ne=J.keyword)!=null&&ne.trim())||!o){alert("请填写关键词和回复内容");return}b(ns(Me));let i=!1;try{await Dr({...J,match_type:"fuzzy",enabled:!0},r),de(!1),await x(),alert("保存成功"),i=!0}catch(he){alert("保存失败:"+he.message)}finally{b(he=>is(he,i))}},ut=async o=>{if(!(!r||!confirm("确定删除该回复规则吗?")))try{await Mr(o,r),await x(),alert("删除成功")}catch(i){alert("删除失败:"+i.message)}},c=async(o=r)=>{if(!o){alert("请先选择账号");return}try{const i=await Qr(o);$e({cookie_id:o,enabled:i.enabled,reply_content:i.reply_content,reply_once:i.reply_once,reply_image_url:i.reply_image_url||""})}catch{$e({cookie_id:o,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}Ae(!0)},z=async()=>{if(N.submitting)return;if(!re.cookie_id){alert("请先选择账号");return}if(re.enabled&&!re.reply_content.trim()&&!re.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}ae(ns(N));let o=!1;try{await Vr(re.cookie_id,{enabled:re.enabled,reply_content:re.reply_content,reply_once:re.reply_once,reply_image_url:re.reply_image_url}),Ae(!1),await g(),alert("保存成功"),o=!0}catch(i){alert("保存失败:"+i.message)}finally{ae(i=>is(i,o))}},me=async o=>{if(confirm("确定删除该账号默认回复吗?"))try{await Kr(o),await g(),alert("删除成功")}catch(i){alert("删除失败:"+i.message)}},Ie=async o=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Hr(o),alert("清空成功")}catch(i){alert("清空失败:"+i.message)}},Ge=a==="automation"?"新建自动化":a==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"min-w-0 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:r,onChange:o=>{f(o.target.value),j(1)},className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),S.map(o=>e.jsx("option",{value:o.id,children:Wt(o)},o.id))]}),e.jsxs("button",{onClick:H,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(Ue,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:a==="automation"?()=>ze("order_paid"):a==="reply"?mt:()=>void c(),disabled:!r,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(Xe,{className:"w-4 h-4"}),Ge]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:ds},{id:"reply",label:"关键词回复",icon:Rt},{id:"default",label:"账号默认回复",icon:yt}].map(o=>{const i=o.icon;return e.jsxs("button",{onClick:()=>n(o.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${a===o.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(i,{className:"w-4 h-4"}),o.label]},o.id)})}),a==="automation"&&(Be.runs.length>0||Be.pending_tasks.length>0)&&e.jsx(Yn,{runs:Be.runs,pendingTasks:Be.pending_tasks,onResolveRun:(o,i)=>void Ct(o,i),onResolveDeferredTask:(o,i)=>void xt(o,i)}),a==="automation"&&e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]",children:[e.jsxs("aside",{className:"min-w-0 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:Ut.map(o=>{const i=tt[o],h=i.icon;return e.jsx("button",{type:"button",onClick:()=>ze(o),className:`w-full text-left rounded-2xl border p-4 transition-colors ${la(i.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(h,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:i.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:i.description})]})]})},o)})})]}),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:["共 ",U," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Ut.map(o=>{const i=tt[o],h=i.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(h,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:i.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:A[o]||0})]},o)})})]})]}),e.jsxs("section",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-surface-muted 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:p,onChange:o=>{w(o.target.value),j(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(_a,{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:u,onChange:o=>{C(o.target.value),j(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:"全部自动化类型"}),Ut.map(o=>e.jsx("option",{value:o,children:tt[o].shortLabel},o))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:M,onChange:o=>{K(o.target.value),j(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:"已禁用"})]}),Y&&e.jsx("button",{type:"button",onClick:te,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(Le,{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:["找到 ",U," 条规则"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Ue,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),d&&Se.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(Ue,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Se.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(ds,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:Y?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:Y?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Se.map(o=>{const i=tt[o.trigger_type],h=i.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 ${la(i.accent,!0)}`,children:e.jsx(h,{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:o.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${si(o.enabled)}`,children:o.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:i.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:o.item_title||o.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:ti(o)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>ke(o),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(jt,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>dt(o),className:`px-4 py-2 rounded-xl text-sm font-bold ${o.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:o.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>ct(o.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Qe,{className:"w-4 h-4"})})]})]})},o.id)}),U>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:["第 ",W," / ",Math.max(E,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:R,onChange:o=>{T(Number(o.target.value)),j(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(o=>e.jsxs("option",{value:o,children:[o," 条/页"]},o))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:W<=1||d,onClick:()=>j(o=>Math.max(1,o-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(ks,{className:"h-4 w-4"})}),O.map(o=>e.jsx("button",{type:"button",disabled:d,onClick:()=>j(o),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${o===W?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${o} 页`,"aria-current":o===W?"page":void 0,children:o},o)),e.jsx("button",{type:"button",disabled:W>=E||d,onClick:()=>j(o=>Math.min(E,o+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(ws,{className:"h-4 w-4"})})]})]})]})]}),a==="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(at,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[Z.map(o=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle 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:["“",o.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:o.type==="image"&&o.image_url?o.image_url:o.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:()=>{xe({...o}),de(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(jt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ut(o.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-5 h-5"})})]})]},o.id)),Z.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),a==="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(at,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[_.map(o=>{const i=F[o.id],h=!!(i!=null&&i.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 ${h?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-surface-subtle 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 ${h?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(yt,{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:Wt(o)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${h?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:h?"已启用":"未启用"}),(i==null?void 0:i.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:h?i.reply_content||i.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 c(o.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(jt,{className:"w-4 h-4"})}),h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void Ie(o.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 me(o.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-5 h-5"})})]})]})]},o.id)}),_.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),v&&y&&Oe.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:y.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:pe.description})]}),e.jsx("button",{onClick:()=>Q(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(Le,{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:Ut.map(o=>{const i=tt[o],h=i.icon,D=be===o;return e.jsx("button",{type:"button",onClick:()=>De(o),className:`w-full rounded-2xl p-4 text-left border transition-all ${D?"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(h,{className:`w-5 h-5 mt-0.5 ${D?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:i.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${D?"text-gray-500":"text-gray-400"}`,children:i.description})]})]})},o)})}),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:pe.flow.map((o,i)=>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:i+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:o})]},o))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-surface-subtle",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(xs,{className:"w-5 h-5 text-brand"}),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:y.name||"",onChange:o=>le({...y,name:o.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:y.cookie_id||"",onChange:o=>le({...y,cookie_id:o.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:"选择账号"}),S.map(o=>e.jsx("option",{value:o.id,children:Wt(o)},o.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:y.item_id||"",onChange:o=>lt(o.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),ve.map(o=>e.jsx("option",{value:o.item_id,children:o.item_title||o.item_id},`${o.cookie_id}-${o.item_id}`))]})]})]}),je&&be!=="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:je.item_title||je.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${ue?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:ue?"多规格商品":"普通商品"}),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:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),be!=="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(ml,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:be==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:ue?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:wt,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(Xe,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:We.map((o,i)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${ue?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[ue&&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:o.spec_name,onChange:h=>Je(i,{spec_name:h.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:o.spec_value,onChange:h=>Je(i,{spec_value:h.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:o.card_id||"",onChange:h=>Je(i,{card_id:Number(h.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),P.filter(h=>h.enabled&&h.type!=="api").map(h=>e.jsx("option",{value:h.id,children:h.name},h.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:o.delivery_count,onChange:h=>Je(i,{delivery_count:Math.max(1,Number(h.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:o.delay_override===!0,onChange:h=>Je(i,{delay_override:h.target.checked}),className:"accent-brand"}),"覆盖卡密默认延时"]}),o.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:o.delay_seconds||0,onChange:h=>Je(i,{delay_seconds:Math.max(0,Number(h.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:o.delay_override?`本动作延时 ${o.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:We.length===1,onClick:()=>le({...y,variants:We.filter((h,D)=>D!==i)}),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(Qe,{className:"w-4 h-4"})})]},o.id||i))})]}):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(va,{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(Re.after_shipped_hours||72),onChange:o=>le({...y,config_json:rt(y.config_json,{after_shipped_hours:Math.max(1,Number(o.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(Re.repeat_interval_hours||24),onChange:o=>le({...y,config_json:rt(y.config_json,{repeat_interval_hours:Math.max(1,Number(o.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(Re.max_attempts||1),onChange:o=>le({...y,config_json:rt(y.config_json,{max_attempts:Math.max(1,Number(o.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:((et=(pt=y.actions)==null?void 0:pt.find(o=>o.action_type==="send_text"))==null?void 0:et.message_template)||"",onChange:o=>{var i;return le({...y,actions:((i=y.actions)!=null&&i.length?y.actions:Ot("review_missing_timeout")).map(h=>h.action_type==="send_text"?{...h,message_template:o.target.value}:h)})},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:y.priority||100,onChange:o=>le({...y,priority:Number(o.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:y.enabled!==!1,onChange:o=>le({...y,enabled:o.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:()=>Q(!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:kt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),ce&&J&&Oe.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:J.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>de(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Le,{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:J.item_id||"",onChange:o=>xe({...J,item_id:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),ee.filter(o=>!r||o.cookie_id===r).map(o=>e.jsx("option",{value:o.item_id,children:o.item_title||o.item_id},`${o.cookie_id}-${o.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:J.type||"text",onChange:o=>{const i=o.target.value;xe({...J,type:i,reply_content:i==="text"?J.reply_content:"",image_url:i==="image"?J.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:J.keyword||"",onChange:o=>xe({...J,keyword:o.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),J.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:J.image_url||"",onChange:o=>xe({...J,image_url:o.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:J.reply_content||"",onChange:o=>xe({...J,reply_content:o.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:()=>de(!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:He,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Vt,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),_e&&Oe.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:()=>Ae(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(Le,{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:re.cookie_id,onChange:o=>$e({...re,cookie_id:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),S.map(o=>e.jsx("option",{value:o.id,children:Wt(o)},o.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:()=>$e({...re,enabled:!re.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${re.enabled?"bg-brand":"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 ${re.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:re.reply_content,onChange:o=>$e({...re,reply_content:o.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:re.reply_image_url,onChange:o=>$e({...re,reply_image_url:o.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:re.reply_once,onChange:o=>$e({...re,reply_once:o.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>Ae(!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:z,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},ri=t=>{const s=String(t.smtp_from||"").trim(),a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);return{...t,smtp_from_name:t.smtp_from_name||(a?"":s),smtp_from_address:t.smtp_from_address||(a?s:t.smtp_user||""),smtp_use_tls:ra(t.smtp_use_tls,!0),smtp_use_ssl:ra(t.smtp_use_ssl,!1)}},ra=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},As=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],js=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},qa=t=>{const s=Object.prototype.hasOwnProperty.call(t,"use_custom_smtp"),a=As.some(n=>String(t[n]??"").trim()!=="");return{...t,use_custom_smtp:s?js(t.use_custom_smtp,!1):a}},na=(t,s)=>{const a={...t,use_custom_smtp:!0};for(const n of As)String(a[n]??"").trim()===""&&s[n]!==void 0&&(a[n]=s[n]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=js(a.smtp_use_tls,!0),a.smtp_use_ssl=js(a.smtp_use_ssl,!1),a},ni=t=>{const s=qa(t),a={to_email:String(s.to_email??"").trim(),use_custom_smtp:s.use_custom_smtp===!0};if(a.use_custom_smtp)for(const n of As)a[n]=s[n];return a},bt={bark:{label:"Bark",icon:ft,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:Rt,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:Rt,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:Rt,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:ul,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:Vt,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:wa,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},Fa=[{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:"后台任务或系统级异常"}],ii=t=>!t||t.length===0?"全部事件":t.map(a=>{var n;return((n=Fa.find(r=>r.value===a))==null?void 0:n.label)||a}).join("、"),oi=({isAdmin:t=!1})=>{const[s,a]=l.useState([]),[n,r]=l.useState(!0),[f,p]=l.useState(!1),[w,m]=l.useState(null),[k,u]=l.useState(!1),[C,M]=l.useState(""),[K,W]=l.useState(null),[j,R]=l.useState({}),[T,X]=l.useState(!1),[V,se]=l.useState(!1),[Z,F]=l.useState(!1),[S,P]=l.useState({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),ee=async()=>{r(!0);try{const x=await Ta();a(x.data||[])}catch(x){console.error("加载通知渠道失败",x)}finally{r(!1)}},d=async()=>{try{const x=await Pa();R(ri(x||{}))}catch(x){console.error("加载 SMTP 配置失败",x)}},G=async()=>{X(!0);try{await $a({smtp_server:j.smtp_server||"",smtp_port:j.smtp_port||587,smtp_user:j.smtp_user||"",smtp_password:j.smtp_password||"",smtp_from_name:j.smtp_from_name||"",smtp_from_address:j.smtp_from_address||j.smtp_user||"",smtp_use_tls:j.smtp_use_tls!==!1,smtp_use_ssl:j.smtp_use_ssl===!0}),U("success","SMTP 配置已保存")}catch(x){U("error",(x==null?void 0:x.message)||"保存失败")}finally{X(!1)}};l.useEffect(()=>{ee(),t?d():R({})},[t]);const U=(x,g)=>{W({type:x,text:g}),window.setTimeout(()=>W(null),3e3)},E=()=>{m(null),P({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),F(!1),p(!0)},A=x=>{m(x);const g=x.type==="email"?qa({...x.config||{}}):null,H=g?g.use_custom_smtp===!0?na(g,j):g:{...x.config||{}};P({name:x.name,type:x.type,enabled:x.enabled,config:H,event_types:x.event_types||[]}),F(!1),p(!0)},L=async()=>{const x=bt[S.type];for(const H of x.fields)if(H.required&&!String(S.config[H.key]||"").trim()){U("error",`请填写 ${H.label}`);return}if(!S.name.trim()){U("error","请填写渠道名称");return}let g=S.config;if(S.type==="email"&&(g=ni(S.config),g.use_custom_smtp)){const v=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([Q])=>!String(g[Q]||"").trim());if(v){U("error",`请填写 ${v[1]}`);return}}u(!0);try{const H={name:S.name.trim(),type:S.type,config:g,event_types:S.event_types,enabled:S.enabled};w?await Qs(w.id,H):await Ur(H),p(!1),await ee(),U("success",w?"已更新":"已创建")}catch(H){console.error("保存失败",H),U("error",(H==null?void 0:H.message)||"保存失败")}finally{u(!1)}},q=async x=>{if(confirm(`确认删除渠道「${x.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await Wr(x.id),await ee(),U("success","已删除")}catch(g){U("error",(g==null?void 0:g.message)||"删除失败")}},I=async x=>{try{await Qs(x.id,{enabled:!x.enabled}),a(g=>g.map(H=>H.id===x.id?{...H,enabled:!H.enabled}:H))}catch(g){U("error",(g==null?void 0:g.message)||"切换失败")}},B=async x=>{M(x.id);try{await Gr(x.id),U("success","测试通知已发送,请检查对应渠道")}catch(g){U("error",(g==null?void 0:g.message)||"发送失败")}finally{M("")}},$=bt[S.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:ee,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(Ue,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:E,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(Xe,{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(ft,{className:"w-5 h-5 text-brand 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:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),n?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(we,{className:"w-8 h-8 text-brand animate-spin"})}):s.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(ft,{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:s.map(x=>{const g=bt[x.type]||bt.webhook,H=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(H,{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:x.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}),!x.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(v=>{var Q;return(Q=x.config)==null?void 0:Q[v.key]}).filter(Boolean).map((v,Q)=>e.jsx("span",{className:"mr-3",children:String(v).length>40?String(v).slice(0,40)+"…":String(v)},Q))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",ii(x.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>I(x),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${x.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:x.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>B(x),disabled:C===x.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[C===x.id?e.jsx(we,{className:"w-3 h-3 animate-spin"}):e.jsx(Vt,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>A(x),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(fa,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>q(x),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(Qe,{className:"w-4 h-4"})})]})]},x.id)})}),t&&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(wa,{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:j.smtp_server||"",onChange:x=>R({...j,smtp_server:x.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:j.smtp_port||587,onChange:x=>R({...j,smtp_port:parseInt(x.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:j.smtp_user||"",onChange:x=>R({...j,smtp_user:x.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:V?"text":"password",value:j.smtp_password||"",onChange:x=>R({...j,smtp_password:x.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>se(!V),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:V?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(st,{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:j.smtp_from_name||"",onChange:x=>R({...j,smtp_from_name:x.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:j.smtp_from_address||j.smtp_user||"",onChange:x=>R({...j,smtp_from_address:x.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:j.smtp_use_tls!==!1,onChange:x=>R({...j,smtp_use_tls:x.target.checked,smtp_use_ssl:x.target.checked?!1:j.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:j.smtp_use_ssl===!0,onChange:x=>R({...j,smtp_use_ssl:x.target.checked,smtp_use_tls:x.target.checked?!1:j.smtp_use_tls})}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:G,disabled:T,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[T?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),T?"保存中...":"保存 SMTP 配置"]})]}),f&&Oe.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:w?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>p(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Le,{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:S.name,onChange:x=>P({...S,name:x.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(bt).map(x=>{const g=bt[x],H=g.icon,v=S.type===x;return e.jsxs("button",{type:"button",onClick:()=>P({...S,type:x,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${v?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(H,{className:`w-5 h-5 ${v?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${v?"text-brand":"text-gray-600"}`,children:g.label})]},x)})})]}),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(ft,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",$.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:$.guide.steps.map((x,g)=>e.jsx("li",{children:x},g))}),$.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:$.guide.urlFormat})]}),$.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",$.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:$.fields.map(x=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[x.label,x.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:x.type==="password"?"password":x.type==="number"?"number":"text",value:String(S.config[x.key]||""),onChange:g=>P({...S,config:{...S.config,[x.key]:g.target.value}}),placeholder:x.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),x.help&&e.jsx("p",{className:"text-xs text-gray-500",children:x.help})]},x.key))}),S.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:S.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:()=>{const x=S.config.use_custom_smtp===!0;P({...S,config:x?{...S.config,use_custom_smtp:!1}:na(S.config,j)})},className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${S.config.use_custom_smtp===!0?"bg-brand":"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 ${S.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),S.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(S.config.smtp_server||""),onChange:x=>P({...S,config:{...S.config,smtp_server:x.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(S.config.smtp_port||587),onChange:x=>P({...S,config:{...S.config,smtp_port:x.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(S.config.smtp_user||""),onChange:x=>P({...S,config:{...S.config,smtp_user:x.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:Z?"text":"password",value:String(S.config.smtp_password||""),onChange:x=>P({...S,config:{...S.config,smtp_password:x.target.value}}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>F(x=>!x),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:Z?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(st,{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(S.config.smtp_from_name||""),onChange:x=>P({...S,config:{...S.config,smtp_from_name:x.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(S.config.smtp_from_address||""),onChange:x=>P({...S,config:{...S.config,smtp_from_address:x.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:S.config.smtp_use_tls!==!1,onChange:x=>P({...S,config:{...S.config,smtp_use_tls:x.target.checked,smtp_use_ssl:x.target.checked?!1:S.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:S.config.smtp_use_ssl===!0,onChange:x=>P({...S,config:{...S.config,smtp_use_ssl:x.target.checked,smtp_use_tls:x.target.checked?!1:S.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:Fa.map(x=>{const g=S.event_types.includes(x.value);return e.jsxs("button",{type:"button",onClick:()=>{const H=g?S.event_types.filter(v=>v!==x.value):[...S.event_types,x.value];P({...S,event_types:H})},className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${g?"border-brand 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-brand border-brand":"border-gray-300"}`,children:g&&e.jsx(Ve,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${g?"text-brand":"text-gray-800"}`,children:x.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:x.description})]},x.value)})})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>P({...S,enabled:!S.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${S.enabled?"bg-brand":"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 ${S.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:()=>p(!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:k,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[k?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Ve,{className:"w-4 h-4"}),k?"保存中...":"保存"]})]})]})}),document.body),K&&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 text-white ${K.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[K.type==="success"?e.jsx(Ve,{className:"w-4 h-4"}):e.jsx(Le,{className:"w-4 h-4"}),K.text]})]})},za=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],ci=t=>t,di=new Map(za.map(([t,s])=>[t,s])),ia=t=>t.split(/(\[[^\]]+\])/g).map((s,a)=>{const n=s.startsWith("[")?di.get(s.slice(1,-1)):void 0;return n?e.jsx("img",{src:n,alt:s,title:s,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(Ns.Fragment,{children:s},a)}),oa="ydisks.chat.account.v1",xi=t=>{if(!t)return"";const s=new Date(t<1e10?t*1e3:t),a=new Date;return s.toDateString()===a.toDateString()?s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},ca=t=>new Date(t<1e10?t*1e3:t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),mi=()=>{const[t,s]=l.useState([]),[a,n]=l.useState(""),[r,f]=l.useState({}),[p,w]=l.useState(""),[m,k]=l.useState([]),[u,C]=l.useState(""),[M,K]=l.useState(!1),[W,j]=l.useState(""),[R,T]=l.useState(!0),[X,V]=l.useState(!1),[se,Z]=l.useState(!1),[F,S]=l.useState(!1),[P,ee]=l.useState(),[d,G]=l.useState({}),[U,E]=l.useState({}),[A,L]=l.useState(!1),[q,I]=l.useState(!1),[B,$]=l.useState(!1),[x,g]=l.useState(""),[H,v]=l.useState("connecting"),Q=l.useRef(""),ce=l.useRef(""),de=l.useRef(null),_e=l.useRef({accountID:"",chatID:""}),Ae=l.useRef(!0),Ee=l.useRef(!1),Te=l.useRef(null),Me=l.useRef(new Set);l.useEffect(()=>{Q.current=a},[a]),l.useEffect(()=>{ce.current=p},[p]);const b=async _=>{const O=await es(_,void 0,void 0,!0);return f(Y=>({...Y,[_]:O.sessions})),G(Y=>({...Y,[_]:O.next_cursor})),E(Y=>({...Y,[_]:O.has_more})),O.sessions};l.useEffect(()=>{let _=!1;return(async()=>{var Y;T(!0);try{const[te,ve]=await Promise.all([Tt(),gs()]),ue=te.map(oe=>{var ke,ze;return{...oe,runtime_state:((ke=ve[oe.id])==null?void 0:ke.state)||(oe.enabled?"connecting":"disabled"),runtime_connected:((ze=ve[oe.id])==null?void 0:ze.connected)===!0}}).filter(oe=>oe.enabled),be=await Promise.all(ue.map(async oe=>[oe.id,await es(oe.id)]));if(_)return;s(ue),f(Object.fromEntries(be.map(([oe,ke])=>[oe,ke.sessions]))),G(Object.fromEntries(be.map(([oe,ke])=>[oe,ke.next_cursor]))),E(Object.fromEntries(be.map(([oe,ke])=>[oe,ke.has_more])));const pe=window.localStorage.getItem(oa)||"",Re=ue.some(oe=>oe.id===pe)?pe:((Y=ue[0])==null?void 0:Y.id)||"";n(Re)}catch(te){_||g(te instanceof Error?te.message:"加载聊天数据失败")}finally{_||T(!1)}})(),()=>{_=!0}},[]),l.useEffect(()=>{let _=!1,O=0,Y=null;const te=async()=>{Y=new AbortController;try{const ve=await gs({signal:Y.signal,timeoutMs:1e4});_||s(je=>je.map(ue=>{var be,pe;return{...ue,runtime_state:((be=ve[ue.id])==null?void 0:be.state)||ue.runtime_state,runtime_connected:((pe=ve[ue.id])==null?void 0:pe.connected)??ue.runtime_connected}}))}catch{}finally{_||(O=window.setTimeout(te,3e3))}};return O=window.setTimeout(te,3e3),()=>{_=!0,window.clearTimeout(O),Y==null||Y.abort()}},[]),l.useEffect(()=>{if(!a)return;window.localStorage.setItem(oa,a);const _=r[a]||[];w(O=>{var Y;return _.some(te=>te.chat_id===O)?O:((Y=_[0])==null?void 0:Y.chat_id)||""})},[a,r]),l.useEffect(()=>{!a||Me.current.has(a)||(Me.current.add(a),b(a).catch(_=>{g(_ instanceof Error?_.message:"同步会话失败")}))},[a]),l.useEffect(()=>{if(!a||!p){k([]);return}const _=new AbortController;return V(!0),Promise.all([hs(a,p,void 0,void 0,{signal:_.signal}),Us(a,p)]).then(([O])=>{k(O.messages),S(O.has_more),ee(O.next_cursor),O.session&&f(Y=>({...Y,[a]:(Y[a]||[]).map(te=>{var ve;return te.chat_id===((ve=O.session)==null?void 0:ve.chat_id)?O.session:te})})),f(Y=>({...Y,[a]:(Y[a]||[]).map(te=>te.chat_id===p?{...te,unread_count:0}:te)}))}).catch(O=>{_.signal.aborted||g(O instanceof Error?O.message:"加载消息失败")}).finally(()=>{_.signal.aborted||V(!1)}),()=>_.abort()},[a,p]);const N=async()=>{var Y;if(!a||!p||se||!F)return;const _=de.current,O=(_==null?void 0:_.scrollHeight)||0;Ee.current=!0,Z(!0),g("");try{const te=(Y=m[0])==null?void 0:Y.id,ve=await hs(a,p,P,te);k(je=>{const ue=new Set(je.map(be=>be.message_key));return[...ve.messages.filter(be=>!ue.has(be.message_key)),...je]}),S(ve.has_more),ee(ve.next_cursor),requestAnimationFrame(()=>{_&&(_.scrollTop+=_.scrollHeight-O)})}catch(te){Ee.current=!1,g(te instanceof Error?te.message:"加载历史消息失败")}finally{Z(!1)}};l.useEffect(()=>{let _=!1,O=0,Y=0,te=null;const ve=()=>{if(_)return;v("connecting");const je=window.location.protocol==="https:"?"wss:":"ws:";te=new WebSocket(`${je}//${window.location.host}/api/v1/chat/ws`),te.onopen=()=>{Y=0,v("online")},te.onmessage=ue=>{try{const pe=JSON.parse(ue.data).message;if(!pe)return;const Re=pe.account_id;f(oe=>{const ke=oe[Re]||[];return ke.some(De=>De.chat_id===pe.chat_id)?{...oe,[Re]:ke.map(De=>De.chat_id===pe.chat_id?{...De,last_message:pe.content,last_message_at:pe.sent_at,unread_count:pe.direction==="incoming"&&(Q.current!==Re||ce.current!==pe.chat_id)?De.unread_count+1:De.unread_count}:De).sort((De,lt)=>lt.last_message_at-De.last_message_at)}:(b(Re),oe)}),Q.current===Re&&ce.current===pe.chat_id&&(k(oe=>{const ke=oe.findIndex(ze=>ze.message_key===pe.message_key);return ke>=0?oe.map((ze,De)=>De===ke?pe:ze):[...oe,pe]}),pe.direction==="incoming"&&Us(Re,pe.chat_id))}catch{}},te.onclose=()=>{if(_)return;v("offline");const ue=Math.min(15e3,1e3*2**Math.min(Y++,4));O=window.setTimeout(ve,ue)},te.onerror=()=>te==null?void 0:te.close()};return ve(),()=>{_=!0,window.clearTimeout(O),te==null||te.close()}},[]);const ae=()=>{const _=de.current;if(!_)return;const O=_.scrollHeight-_.scrollTop-_.clientHeight;Ae.current=O<=48};l.useLayoutEffect(()=>{const _=_e.current.accountID!==a||_e.current.chatID!==p;_e.current={accountID:a,chatID:p},_&&(Ae.current=!0);const O=de.current;if(O){if(Ee.current){Ee.current=!1;return}(X||Ae.current)&&(O.scrollTop=O.scrollHeight)}},[a,p,m,X]);const y=t.find(_=>_.id===a),le=r[a]||[],J=le.find(_=>_.chat_id===p),xe=l.useMemo(()=>{const _=u.trim().toLowerCase();return le.filter(O=>M&&O.unread_count<=0?!1:_?[O.buyer_name,O.buyer_id,O.item_title,O.last_message].some(Y=>(Y||"").toLowerCase().includes(_)):!0)},[le,u,M]),re=_=>(r[_]||[]).reduce((O,Y)=>O+Y.unread_count,0),$e=async()=>{if(!(!a||A||!U[a])){L(!0),g("");try{const _=await es(a,d[a],void 0,!0);f(O=>({...O,[a]:_.sessions})),G(O=>({...O,[a]:_.next_cursor})),E(O=>({...O,[a]:_.has_more}))}catch(_){g(_ instanceof Error?_.message:"加载历史联系人失败")}finally{L(!1)}}},Se=async()=>{const _=W.trim();if(!(!_||!J||!a||B)){$(!0),g("");try{const O=await Fl({account_id:a,chat_id:J.chat_id,buyer_id:J.buyer_id,buyer_name:J.buyer_name,item_id:J.item_id,item_title:J.item_title,text:_});j(""),k(Y=>Y.some(te=>te.message_key===O.message.message_key)?Y.map(te=>te.message_key===O.message.message_key?O.message:te):[...Y,O.message])}catch(O){g(O instanceof Error?O.message:"消息发送失败"),ql(a,J.chat_id).then(k)}finally{$(!1)}}},Be=async _=>{if(!(!_||!J||!a||B)){$(!0),g("");try{const O=await zl({account_id:a,chat_id:J.chat_id,buyer_id:J.buyer_id,buyer_name:J.buyer_name,buyer_avatar_url:J.buyer_avatar_url,item_id:J.item_id,item_title:J.item_title,image:_});k(Y=>Y.some(te=>te.message_key===O.message.message_key)?Y.map(te=>te.message_key===O.message.message_key?O.message:te):[...Y,O.message])}catch(O){g(O instanceof Error?O.message:"图片发送失败")}finally{$(!1),Te.current&&(Te.current.value="")}}};return R?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(we,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${H==="online"?"bg-emerald-50 text-emerald-700":H==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[H==="online"?e.jsx(pl,{className:"h-3.5 w-3.5"}):e.jsx(hl,{className:"h-3.5 w-3.5"}),H==="online"?"实时同步中":H==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:t.map(_=>{const O=_.id===a,Y=re(_.id),te=_.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":O,onClick:()=>n(_.id),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${O?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${te?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:_.nickname||_.remark||_.id}),Y>0&&e.jsx("span",{className:"min-w-5 rounded-full bg-red-500 px-1.5 py-0.5 text-[10px] text-white",children:Y>99?"99+":Y})]},_.id)})})]}),t.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(cs,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Nt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:u,onChange:_=>C(_.target.value),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>K(_=>!_),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${M?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:M?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:()=>void b(a),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(Ue,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[xe.map(_=>e.jsxs("button",{type:"button",onClick:()=>w(_.chat_id),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${_.chat_id===p?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:_.buyer_avatar_url?e.jsx("img",{src:_.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(Jt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:_.buyer_name||`用户 ${_.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:xi(_.last_message_at)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:_.last_message||"暂无消息"}),_.unread_count>0&&e.jsx("span",{className:"ml-auto min-w-5 shrink-0 rounded-full bg-red-500 px-1.5 py-0.5 text-center text-[10px] font-bold text-white",children:_.unread_count})]}),_.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",_.item_title]})]})]},_.chat_id)),xe.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),U[a]&&!u&&!M&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:()=>void $e(),disabled:A,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[A&&e.jsx(we,{className:"h-3.5 w-3.5 animate-spin"}),A?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:J?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:J.buyer_name||J.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",J.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(y==null?void 0:y.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(y==null?void 0:y.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:de,onScroll:ae,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:X?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(we,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[F&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:se,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[se&&e.jsx(we,{className:"h-3.5 w-3.5 animate-spin"}),se?"正在加载":"加载更早消息"]})}),m.map(_=>{const O=_.direction==="outgoing";return _.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[ia(_.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:ca(_.sent_at)})]})},_.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${O?"justify-end":"justify-start"}`,children:[!O&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:J.buyer_avatar_url?e.jsx("img",{src:J.buyer_avatar_url,alt:J.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(Jt,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${O?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:O?(y==null?void 0:y.nickname)||(y==null?void 0:y.remark)||"我":J.buyer_name||_.sender_name||J.buyer_id}),_.message_type==="image"?e.jsx("a",{href:_.content,target:"_blank",rel:"noreferrer",className:`block overflow-hidden rounded-2xl border bg-white p-1 shadow-sm ${O?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:_.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):_.message_type==="video"?e.jsx("video",{src:_.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${O?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:ia(_.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[ca(_.sent_at),O&&(_.status==="failed"?e.jsx(at,{className:"h-3 w-3 text-red-500"}):_.status==="sent"?e.jsx(gl,{className:"h-3 w-3 text-sky-500"}):e.jsx(Ve,{className:"h-3 w-3"}))]})]}),O&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:y!=null&&y.avatar_url?e.jsx("img",{src:y.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(Jt,{className:"m-2 h-5 w-5 text-sky-600"})})]},_.message_key)})]})}),x&&e.jsx("div",{className:"border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:x}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>I(_=>!_),disabled:B||(y==null?void 0:y.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(bl,{className:"h-5 w-5"})}),q&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:za.map(([_,O])=>e.jsx("button",{type:"button",title:`[${_}]`,onClick:()=>{j(Y=>Y+`[${_}]`),I(!1)},className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:ci(O),alt:`[${_}]`,className:"h-8 w-8 object-contain"})},_))})]})]}),e.jsx("input",{ref:Te,type:"file",accept:"image/*",className:"hidden",onChange:_=>{var O;return void Be((O=_.target.files)==null?void 0:O[0])}}),e.jsx("button",{type:"button",onClick:()=>{var _;return(_=Te.current)==null?void 0:_.click()},disabled:B||(y==null?void 0:y.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(yl,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:W,onChange:_=>j(_.target.value),rows:2,maxLength:2e3,onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Se())},disabled:(y==null?void 0:y.runtime_state)!=="online",placeholder:(y==null?void 0:y.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:()=>void Se(),disabled:!W.trim()||B||(y==null?void 0:y.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:B?e.jsx(we,{className:"h-4 w-4 animate-spin"}):e.jsx(Vt,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(cs,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]})]})},Ua="ydisks.sidebar.v1",ui=()=>{try{return window.localStorage.getItem(Ua)==="collapsed"}catch{return!1}},pi=t=>{try{window.localStorage.setItem(Ua,t?"collapsed":"expanded")}catch{}},Wa={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/chat":"chat","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},da=Object.fromEntries(Object.entries(Wa).map(([t,s])=>[s,t])),xa=()=>Wa[window.location.pathname]||"dashboard",hi=()=>{const[t,s]=l.useState(!1),[a,n]=l.useState(!1),[r,f]=l.useState(xa),[p,w]=l.useState(!0),[m,k]=l.useState(!1),[u,C]=l.useState(""),[M,K]=l.useState(""),[W,j]=l.useState(!1),[R,T]=l.useState(""),[X,V]=l.useState(""),[se,Z]=l.useState(""),[F,S]=l.useState(!1),[P,ee]=l.useState(""),[d,G]=l.useState(),[U,E]=l.useState(ui),A=$=>{const x=$==="settings"&&!a?"dashboard":$,g=da[x];g&&g!==window.location.pathname&&window.history.pushState({},"",g),f(x)};l.useEffect(()=>{const $=()=>f(xa());return window.addEventListener("popstate",$),()=>window.removeEventListener("popstate",$)},[]),l.useEffect(()=>{La().then(x=>{if((x==null?void 0:x.initialized)===!1){k(!0),s(!1),n(!1);return}k(!1),x!=null&&x.authenticated?(s(!0),n(x.is_admin===!0)):n(!1)}).catch(()=>{s(!1),n(!1)}).finally(()=>w(!1));const $=()=>{s(!1),n(!1)};return window.addEventListener("auth:logout",$),()=>window.removeEventListener("auth:logout",$)},[]),l.useEffect(()=>{!p&&t&&!a&&r==="settings"&&(window.history.replaceState({},"",da.dashboard),f("dashboard"))},[p,t,a,r]);const L=async $=>{$.preventDefault(),j(!0),T("");try{const x=await Pl({username:u,password:M});x.success?(s(!0),n(x.is_admin===!0)):T(x.message||"登录失败")}catch(x){const g=x instanceof Error?x.message:String(x);T(g||"登录失败")}finally{j(!1)}},q=async $=>{if($.preventDefault(),ee(""),X.length<8){ee("密码至少需要 8 个字符");return}if(X!==se){ee("两次输入的密码不一致");return}S(!0);try{const x=await $l(X);if(!x.success){ee(x.message||"初始化失败,请重试");return}k(!1),s(!0),n(x.is_admin===!0),V(""),Z("")}catch(x){const g=x instanceof Error?x.message:String(x);ee(g||"初始化失败,请重试")}finally{S(!1)}},I=async()=>{try{await El()}catch($){console.error("退出登录失败",$)}finally{s(!1),n(!1)}};if(p)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-surface",children:e.jsx(we,{className:"w-8 h-8 text-brand animate-spin"})});if(m)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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(us,{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:"设置完成后会自动进入系统,管理员账号为 admin。"})]}),e.jsxs("form",{onSubmit:q,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(Ts,{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:"设置管理员密码(至少 8 个字符)",value:X,onChange:$=>V($.target.value),autoFocus:!0,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($t,{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:$=>Z($.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),P&&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($t,{className:"w-4 h-4"})," ",P]}),e.jsx("button",{type:"submit",disabled:F,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:F?e.jsx(we,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["设置密码并进入系统 ",e.jsx(ms,{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(!t)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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(us,{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:L,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(ot,{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:u,onChange:$=>C($.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(Ts,{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:M,onChange:$=>K($.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),R&&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($t,{className:"w-4 h-4"})," ",R]}),e.jsx("button",{type:"submit",disabled:W,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:W?e.jsx(we,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(ms,{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 B=()=>{switch(r){case"dashboard":return e.jsx(ss,{});case"accounts":return e.jsx(un,{});case"chat":return e.jsx(mi,{});case"orders":return e.jsx(Cn,{});case"cards":return e.jsx(Pn,{});case"items":return e.jsx(Gn,{onConfigureDelivery:$=>{G({cookieId:$.cookie_id,itemId:$.item_id,requestId:Date.now()}),A("rules")}});case"rules":return e.jsx(li,{initialDeliveryTarget:d,onDeliveryTargetHandled:()=>G(void 0)});case"notifications":return e.jsx(oi,{isAdmin:a});case"settings":return a?e.jsx(Kn,{}):e.jsx(ss,{});default:return e.jsx(ss,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[e.jsx(Cl,{activeTab:r,isAdmin:a,collapsed:U,onToggleCollapsed:()=>E($=>{const x=!$;return pi(x),x}),onNavigate:A,onLogout:I}),e.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${U?"ml-16":"ml-64"} ${r==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,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:`${r==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:B()})]})]})},Ja=document.getElementById("root");if(!Ja)throw new Error("Could not find root element to mount to");const gi=Ga.createRoot(Ja);gi.render(e.jsx(Ns.StrictMode,{children:e.jsx(hi,{})})); diff --git a/internal/webui/static/assets/index-DBrkfYTo.css b/internal/webui/static/assets/index-DBrkfYTo.css new file mode 100644 index 0000000..31753d4 --- /dev/null +++ b/internal/webui/static/assets/index-DBrkfYTo.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(147 197 253 / .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(147 197 253 / .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:rgb(var(--color-neutral-200) / 1)}: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:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}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}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.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}.collapse{visibility:collapse}.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}.inset-y-0{top:0;bottom: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-11{bottom:2.75rem}.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}.m-2{margin:.5rem}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.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-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-16{margin-left:4rem}.ml-64{margin-left:16rem}.ml-auto{margin-left:auto}.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}.inline-block{display:inline-block}.inline{display:inline}.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-1\.5{height:.375rem}.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{height:.5rem}.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-\[18px\]{height:18px}.h-\[19px\]{height:19px}.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-\[calc\(100vh-4rem\)\]{height:calc(100vh - 4rem)}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-80{max-height:20rem}.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-12{min-height:3rem}.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-\[560px\]{min-height:560px}.min-h-screen{min-height:100vh}.w-1\.5{width:.375rem}.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{width:.5rem}.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-\[18px\]{width:18px}.w-\[19\%\]{width:19%}.w-\[19px\]{width:19px}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[360px\]{width:360px}.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-5{min-width:1.25rem}.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}.min-w-\[760px\]{min-width:760px}.max-w-36{max-width:9rem}.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-\[1680px\]{max-width:1680px}.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-\[72\%\]{max-width:72%}.max-w-\[80px\]{max-width:80px}.max-w-\[82\%\]{max-width:82%}.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{flex-shrink:0}.shrink{flex-shrink:1}.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))}.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}.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))}.grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.grid-cols-\[320px_minmax\(0\,1fr\)\]{grid-template-columns:320px 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}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.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-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.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}.rounded-bl-md{border-bottom-left-radius:6px}.rounded-br-md{border-bottom-right-radius:6px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-y{border-top-width:1px;border-bottom-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-200) / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-brand{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(var(--color-success-100) / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-200) / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(var(--color-accent-100) / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-100) / var(--tw-border-opacity, 1))}.border-sky-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-sky-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-sky-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-slate-100{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-100) / var(--tw-border-opacity, 1))}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-200) / var(--tw-border-opacity, 1))}.border-slate-200\/80{border-color:rgb(var(--color-slate-200) / .8)}.border-transparent{border-color:var(--color-transparent)}.border-white{--tw-border-opacity: 1;border-color:rgb(var(--color-white) / var(--tw-border-opacity, 1))}.border-white\/10{border-color:rgb(var(--color-white) / .1)}.border-white\/80{border-color:rgb(var(--color-white) / .8)}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:rgb(var(--color-warning-100) / .7)}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-50) / var(--tw-bg-opacity, 1))}.bg-amber-50\/70{background-color:rgb(var(--color-warning-50) / .7)}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:rgb(var(--color-black) / .5)}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-blue-200\/30{background-color:rgb(var(--color-brand-200) / .3)}.bg-blue-200\/40{background-color:rgb(var(--color-brand-200) / .4)}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-400) / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-blue-50\/40{background-color:rgb(var(--color-brand-50) / .4)}.bg-blue-50\/50{background-color:rgb(var(--color-brand-50) / .5)}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:rgb(var(--color-brand-500) / .2)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.bg-brand{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.bg-canvas{--tw-bg-opacity: 1;background-color:rgb(var(--color-canvas) / var(--tw-bg-opacity, 1))}.bg-danger-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:rgb(var(--color-neutral-100) / .5)}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-300) / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:rgb(var(--color-neutral-50) / .7)}.bg-gray-50\/80{background-color:rgb(var(--color-neutral-50) / .8)}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-900) / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:rgb(var(--color-accent-50) / .5)}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-500) / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-600) / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:rgb(var(--color-danger-200) / .35)}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-600) / var(--tw-bg-opacity, 1))}.bg-sky-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-sky-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-200) / var(--tw-bg-opacity, 1))}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-50) / var(--tw-bg-opacity, 1))}.bg-slate-50\/40{background-color:rgb(var(--color-slate-50) / .4)}.bg-slate-50\/70{background-color:rgb(var(--color-slate-50) / .7)}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-900) / var(--tw-bg-opacity, 1))}.bg-success-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-surface{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface) / var(--tw-bg-opacity, 1))}.bg-surface-muted{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-muted) / var(--tw-bg-opacity, 1))}.bg-surface-subtle{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-subtle) / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:var(--color-transparent)}.bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:rgb(var(--color-white) / .05)}.bg-white\/80{background-color:rgb(var(--color-white) / .8)}.bg-white\/90{background-color:rgb(var(--color-white) / .9)}.bg-white\/95{background-color:rgb(var(--color-white) / .95)}.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: rgb(var(--color-brand-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-brand-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: rgb(var(--color-danger-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-danger-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(var(--color-white) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(var(--color-white) / 1) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: rgb(var(--color-warning-50) / 1) var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: var(--color-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-3\.5{padding-left:.875rem;padding-right:.875rem}.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-12{padding-top:3rem;padding-bottom:3rem}.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-0{padding-bottom:0}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pb-9{padding-bottom:2.25rem}.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}.pl-9{padding-left:2.25rem}.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}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-\[0\.22em\]{letter-spacing:.22em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-600{--tw-text-opacity: 1;color:rgb(var(--color-warning-600) / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(var(--color-warning-800) / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:rgb(var(--color-warning-800) / .8)}.text-amber-900{--tw-text-opacity: 1;color:rgb(var(--color-warning-900) / var(--tw-text-opacity, 1))}.text-amber-900\/90{color:rgb(var(--color-warning-900) / .9)}.text-blue-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(var(--color-brand-950) / var(--tw-text-opacity, 1))}.text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(var(--color-neutral-100) / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(var(--color-neutral-300) / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(var(--color-neutral-400) / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(var(--color-neutral-500) / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(var(--color-neutral-800) / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(var(--color-neutral-950) / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-ink{--tw-text-opacity: 1;color:rgb(var(--color-ink) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(var(--color-accent-500) / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(var(--color-accent-700) / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(var(--color-danger-700) / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(var(--color-danger-800) / var(--tw-text-opacity, 1))}.text-sky-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-sky-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-sky-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-sky-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-sky-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(var(--color-slate-300) / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(var(--color-slate-500) / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(var(--color-slate-600) / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(var(--color-slate-800) / var(--tw-text-opacity, 1))}.text-slate-900{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(var(--color-slate-950) / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.accent-brand{accent-color:rgb(var(--color-brand) / 1)}.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: var(--shadow-2xl);--tw-shadow-colored: var(--shadow-2xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-brand-active{--tw-shadow: var(--shadow-brand-active);--tw-shadow-colored: var(--shadow-brand-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat{--tw-shadow: var(--shadow-chat);--tw-shadow-colored: var(--shadow-chat);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-active{--tw-shadow: var(--shadow-chat-active);--tw-shadow-colored: var(--shadow-chat-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-input{--tw-shadow: var(--shadow-chat-input);--tw-shadow-colored: var(--shadow-chat-input);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: var(--shadow-inner);--tw-shadow-colored: var(--shadow-inner);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: var(--shadow-md);--tw-shadow-colored: var(--shadow-md);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-modal{--tw-shadow: var(--shadow-modal);--tw-shadow-colored: var(--shadow-modal);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-panel{--tw-shadow: var(--shadow-panel);--tw-shadow-colored: var(--shadow-panel);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sidebar{--tw-shadow: var(--shadow-sidebar);--tw-shadow-colored: var(--shadow-sidebar);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: var(--shadow-sm);--tw-shadow-colored: var(--shadow-sm);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: var(--shadow-xl);--tw-shadow-colored: var(--shadow-xl);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: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: rgb(var(--color-brand-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: rgb(var(--color-success-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: rgb(var(--color-neutral-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(var(--color-neutral-200) / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: rgb(var(--color-danger-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-sky-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.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-2{--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)}.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(var(--color-neutral-200) / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-white) / 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)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-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{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.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-300{transition-duration:.3s}.duration-500{transition-duration:.5s}:root{--color-transparent: transparent;--color-black: 0 0 0;--color-white: 255 255 255;--color-brand: 0 148 247;--color-brand-highlight: 0 113 227;--color-brand-light: 40 126 254;--color-ink: 29 29 31;--color-muted: 134 134 139;--color-line: 210 210 215;--color-canvas: 244 245 247;--color-surface: 255 255 255;--color-surface-subtle: 247 248 250;--color-surface-muted: 250 250 250;--color-neutral-50: 249 250 251;--color-neutral-100: 243 244 246;--color-neutral-200: 229 231 235;--color-neutral-300: 209 213 219;--color-neutral-400: 156 163 175;--color-neutral-500: 107 114 128;--color-neutral-600: 75 85 99;--color-neutral-700: 55 65 81;--color-neutral-800: 31 41 55;--color-neutral-900: 17 24 39;--color-neutral-950: 3 7 18;--color-slate-50: 248 250 252;--color-slate-100: 241 245 249;--color-slate-200: 226 232 240;--color-slate-300: 203 213 225;--color-slate-400: 148 163 184;--color-slate-500: 100 116 139;--color-slate-600: 71 85 105;--color-slate-700: 51 65 85;--color-slate-800: 30 41 59;--color-slate-900: 15 23 42;--color-slate-950: 2 6 23;--color-brand-50: 239 248 255;--color-brand-100: 223 241 255;--color-brand-200: 191 229 255;--color-brand-300: 143 210 255;--color-brand-400: 83 184 251;--color-brand-500: 0 148 247;--color-brand-600: 0 148 247;--color-brand-700: 0 113 227;--color-brand-800: 0 91 181;--color-brand-900: 0 75 147;--color-brand-950: 0 53 107;--color-success-50: 236 253 245;--color-success-100: 209 250 229;--color-success-200: 167 243 208;--color-success-300: 110 231 183;--color-success-400: 52 211 153;--color-success-500: 16 185 129;--color-success-600: 5 150 105;--color-success-700: 4 120 87;--color-success-800: 6 95 70;--color-success-900: 6 78 59;--color-success-950: 2 44 34;--color-warning-50: 255 251 235;--color-warning-100: 254 243 199;--color-warning-200: 253 230 138;--color-warning-300: 252 211 77;--color-warning-400: 251 191 36;--color-warning-500: 245 158 11;--color-warning-600: 217 119 6;--color-warning-700: 180 83 9;--color-warning-800: 146 64 14;--color-warning-900: 120 53 15;--color-warning-950: 69 26 3;--color-danger-50: 254 242 242;--color-danger-100: 254 226 226;--color-danger-200: 254 202 202;--color-danger-300: 252 165 165;--color-danger-400: 248 113 113;--color-danger-500: 239 68 68;--color-danger-600: 220 38 38;--color-danger-700: 185 28 28;--color-danger-800: 153 27 27;--color-danger-900: 127 29 29;--color-danger-950: 69 10 10;--color-info-50: 239 246 255;--color-info-100: 219 234 254;--color-info-200: 191 219 254;--color-info-300: 147 197 253;--color-info-400: 96 165 250;--color-info-500: 59 130 246;--color-info-600: 37 99 235;--color-info-700: 29 78 216;--color-info-800: 30 64 175;--color-info-900: 30 58 138;--color-info-950: 23 37 84;--color-accent-50: 250 245 255;--color-accent-100: 243 232 255;--color-accent-200: 233 213 255;--color-accent-300: 216 180 254;--color-accent-400: 192 132 252;--color-accent-500: 168 85 247;--color-accent-600: 147 51 234;--color-accent-700: 126 34 206;--color-accent-800: 107 33 168;--color-accent-900: 88 28 135;--color-accent-950: 59 7 100;--shadow-none: 0 0 0 var(--color-transparent);--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / .1), 0 1px 2px -1px rgb(var(--color-black) / .1);--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / .05);--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / .1), 0 2px 4px -2px rgb(var(--color-black) / .1);--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / .1), 0 4px 6px -4px rgb(var(--color-black) / .1);--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / .1), 0 8px 10px -6px rgb(var(--color-black) / .1);--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / .05);--shadow-card: 0 8px 24px rgb(var(--color-black) / .04);--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / .05);--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / .035);--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / .06);--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / .04);--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / .2);--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / .2);--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / .3)}*,:before,:after{--tw-ring-offset-color: rgb(var(--color-white));--tw-ring-color: rgb(var(--color-brand-400) / .5);--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);--tw-ring-shadow: 0 0 0 var(--color-transparent);--tw-shadow: 0 0 0 var(--color-transparent);--tw-shadow-colored: 0 0 0 var(--color-transparent)}.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:rgb(var(--color-canvas));color:rgb(var(--color-ink));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:rgb(var(--color-surface));border-radius:8px;border:1px solid rgb(var(--color-black) / .02);box-shadow:var(--shadow-card);transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px rgb(var(--color-black) / .06)}.dashboard-pie-chart .recharts-surface:focus,.dashboard-pie-chart .recharts-pie:focus,.dashboard-pie-chart .recharts-pie-sector:focus,.dashboard-pie-chart .recharts-sector:focus{outline:none}.dashboard-revenue-chart .recharts-surface:focus,.dashboard-revenue-chart .recharts-bar-rectangle:focus,.dashboard-revenue-chart .recharts-rectangle:focus,.dashboard-revenue-chart .recharts-curve:focus,.dashboard-revenue-chart .recharts-dot:focus,.dashboard-revenue-chart [class*=recharts-zIndex-layer_]:focus{outline:none!important}.dashboard-revenue-chart .recharts-bar-rectangle,.dashboard-revenue-chart .recharts-rectangle{stroke:none!important}.ios-input{background:rgb(var(--color-surface-subtle));border:1px solid var(--color-transparent);transition:all .3s cubic-bezier(.25,.8,.25,1);color:rgb(var(--color-ink));font-weight:500}.ios-input:focus{background:rgb(var(--color-surface));border-color:rgb(var(--color-brand));box-shadow:0 0 0 4px rgb(var(--color-brand) / .3);outline:none}.ios-input::-moz-placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-input::placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-btn-primary{background:rgb(var(--color-brand));color:rgb(var(--color-white));font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:rgb(var(--color-brand-highlight));transform:translateY(-1px);box-shadow:var(--shadow-brand-strong)}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:var(--shadow-brand-soft)}.ios-btn-primary:disabled{background:rgb(var(--color-neutral-100));color:rgb(var(--color-neutral-400));box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:rgb(var(--color-surface-subtle));color:rgb(var(--color-ink));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:rgb(var(--color-neutral-200));border-color:rgb(var(--color-neutral-300))}.ios-btn-danger{background:rgb(var(--color-danger-100));color:rgb(var(--color-danger-600));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:rgb(var(--color-danger-200));border-color:rgb(var(--color-danger-300))}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--color-transparent)}::-webkit-scrollbar-thumb{background:rgb(var(--color-black) / .1);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:rgb(var(--color-black) / .2)}@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:rgb(var(--color-brand));color:rgb(var(--color-white))}::selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}.text-brand{color:rgb(var(--color-brand))}.bg-brand{background-color:rgb(var(--color-brand))}.border-brand{border-color:rgb(var(--color-brand))}.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:rgb(var(--color-success-100));color:rgb(var(--color-success-800))}.status-badge-warning{background-color:rgb(var(--color-warning-100));color:rgb(var(--color-warning-800))}.status-badge-error{background-color:rgb(var(--color-danger-100));color:rgb(var(--color-danger-800))}.status-badge-info{background-color:rgb(var(--color-info-100));color:rgb(var(--color-info-800))}.loading-skeleton{background:linear-gradient(90deg,rgb(var(--color-neutral-100)),rgb(var(--color-neutral-200)),rgb(var(--color-neutral-100)));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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 rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);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}}.placeholder\:text-slate-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.placeholder\:text-slate-400::placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.focus-within\:border-sky-400:focus-within{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus-within\:ring-2:focus-within{--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-within\:ring-sky-100:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.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-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-300) / var(--tw-border-opacity, 1))}.hover\:border-brand:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-success-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-400) / var(--tw-border-opacity, 1))}.hover\:border-sky-200:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-700) / var(--tw-bg-opacity, 1))}.hover\:bg-brand:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.hover\:bg-brand-highlight:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-highlight) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:rgb(var(--color-success-50) / .5)}.hover\:bg-emerald-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-700) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-800) / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-700) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.hover\:bg-warning-50\/50:hover{background-color:rgb(var(--color-warning-50) / .5)}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:rgb(var(--color-white) / .1)}.hover\:bg-white\/80:hover{background-color:rgb(var(--color-white) / .8)}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-brand:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.hover\:text-sky-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.hover\:text-slate-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);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(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:border-sky-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.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-brand:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand) / var(--tw-ring-opacity, 1))}.focus\:ring-sky-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / 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(var(--color-danger-400) / var(--tw-bg-opacity, 1))}.disabled\:bg-slate-300:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / 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}.disabled\:shadow-none:disabled{--tw-shadow: var(--shadow-none);--tw-shadow-colored: var(--shadow-none);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / 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(var(--color-white) / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-64{width:16rem}.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\: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\:p-6{padding:1.5rem}.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}}@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\:grid-cols-\[minmax\(270px\,0\.72fr\)_minmax\(0\,1\.28fr\)\]{grid-template-columns:minmax(270px,.72fr) minmax(0,1.28fr)}.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-DFTgpFf2.css b/internal/webui/static/assets/index-DFTgpFf2.css deleted file mode 100644 index 8950923..0000000 --- a/internal/webui/static/assets/index-DFTgpFf2.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(147 197 253 / .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(147 197 253 / .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:rgb(var(--color-neutral-200) / 1)}: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:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}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}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.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}.collapse{visibility:collapse}.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}.inset-y-0{top:0;bottom: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-11{bottom:2.75rem}.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}.m-2{margin:.5rem}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.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-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-16{margin-left:4rem}.ml-64{margin-left:16rem}.ml-auto{margin-left:auto}.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}.inline-block{display:inline-block}.inline{display:inline}.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-1\.5{height:.375rem}.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{height:.5rem}.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-\[18px\]{height:18px}.h-\[19px\]{height:19px}.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-\[calc\(100vh-4rem\)\]{height:calc(100vh - 4rem)}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-80{max-height:20rem}.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-12{min-height:3rem}.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-\[560px\]{min-height:560px}.min-h-screen{min-height:100vh}.w-1\.5{width:.375rem}.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{width:.5rem}.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-\[18px\]{width:18px}.w-\[19\%\]{width:19%}.w-\[19px\]{width:19px}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[360px\]{width:360px}.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-5{min-width:1.25rem}.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}.min-w-\[760px\]{min-width:760px}.max-w-36{max-width:9rem}.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-\[1680px\]{max-width:1680px}.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-\[72\%\]{max-width:72%}.max-w-\[80px\]{max-width:80px}.max-w-\[82\%\]{max-width:82%}.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{flex-shrink:0}.shrink{flex-shrink:1}.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))}.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}.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))}.grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.grid-cols-\[320px_minmax\(0\,1fr\)\]{grid-template-columns:320px 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}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.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(var(--color-neutral-100) / var(--tw-divide-opacity, 1))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.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}.rounded-bl-md{border-bottom-left-radius:6px}.rounded-br-md{border-bottom-right-radius:6px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-y{border-top-width:1px;border-bottom-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-100) / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-200) / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-brand{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(var(--color-success-100) / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-200) / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(var(--color-accent-100) / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-100) / var(--tw-border-opacity, 1))}.border-sky-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-sky-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-sky-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-slate-100{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-100) / var(--tw-border-opacity, 1))}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-200) / var(--tw-border-opacity, 1))}.border-slate-200\/80{border-color:rgb(var(--color-slate-200) / .8)}.border-transparent{border-color:var(--color-transparent)}.border-white{--tw-border-opacity: 1;border-color:rgb(var(--color-white) / var(--tw-border-opacity, 1))}.border-white\/10{border-color:rgb(var(--color-white) / .1)}.border-white\/80{border-color:rgb(var(--color-white) / .8)}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:rgb(var(--color-warning-100) / .7)}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-50) / var(--tw-bg-opacity, 1))}.bg-amber-50\/70{background-color:rgb(var(--color-warning-50) / .7)}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:rgb(var(--color-black) / .5)}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-blue-200\/30{background-color:rgb(var(--color-brand-200) / .3)}.bg-blue-200\/40{background-color:rgb(var(--color-brand-200) / .4)}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-400) / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-blue-50\/40{background-color:rgb(var(--color-brand-50) / .4)}.bg-blue-50\/50{background-color:rgb(var(--color-brand-50) / .5)}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:rgb(var(--color-brand-500) / .2)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.bg-brand{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.bg-canvas{--tw-bg-opacity: 1;background-color:rgb(var(--color-canvas) / var(--tw-bg-opacity, 1))}.bg-danger-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:rgb(var(--color-neutral-100) / .5)}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:rgb(var(--color-neutral-200) / .5)}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-300) / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:rgb(var(--color-neutral-50) / .7)}.bg-gray-50\/80{background-color:rgb(var(--color-neutral-50) / .8)}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-900) / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:rgb(var(--color-accent-50) / .5)}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-500) / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-600) / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:rgb(var(--color-danger-200) / .35)}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-600) / var(--tw-bg-opacity, 1))}.bg-sky-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-sky-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-200) / var(--tw-bg-opacity, 1))}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-50) / var(--tw-bg-opacity, 1))}.bg-slate-50\/40{background-color:rgb(var(--color-slate-50) / .4)}.bg-slate-50\/70{background-color:rgb(var(--color-slate-50) / .7)}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-900) / var(--tw-bg-opacity, 1))}.bg-success-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-surface{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface) / var(--tw-bg-opacity, 1))}.bg-surface-muted{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-muted) / var(--tw-bg-opacity, 1))}.bg-surface-subtle{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-subtle) / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:var(--color-transparent)}.bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:rgb(var(--color-white) / .05)}.bg-white\/80{background-color:rgb(var(--color-white) / .8)}.bg-white\/90{background-color:rgb(var(--color-white) / .9)}.bg-white\/95{background-color:rgb(var(--color-white) / .95)}.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: rgb(var(--color-brand-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-brand-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: rgb(var(--color-danger-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-danger-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(var(--color-white) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(var(--color-white) / 1) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: rgb(var(--color-warning-50) / 1) var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: var(--color-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-3\.5{padding-left:.875rem;padding-right:.875rem}.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-12{padding-top:3rem;padding-bottom:3rem}.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-0{padding-bottom:0}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pb-9{padding-bottom:2.25rem}.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}.pl-9{padding-left:2.25rem}.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}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-\[0\.22em\]{letter-spacing:.22em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-600{--tw-text-opacity: 1;color:rgb(var(--color-warning-600) / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(var(--color-warning-800) / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:rgb(var(--color-warning-800) / .8)}.text-amber-900{--tw-text-opacity: 1;color:rgb(var(--color-warning-900) / var(--tw-text-opacity, 1))}.text-amber-900\/90{color:rgb(var(--color-warning-900) / .9)}.text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(var(--color-brand-950) / var(--tw-text-opacity, 1))}.text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(var(--color-neutral-100) / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(var(--color-neutral-300) / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(var(--color-neutral-400) / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(var(--color-neutral-500) / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(var(--color-neutral-800) / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(var(--color-neutral-950) / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-ink{--tw-text-opacity: 1;color:rgb(var(--color-ink) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(var(--color-accent-500) / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(var(--color-accent-700) / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(var(--color-danger-700) / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(var(--color-danger-800) / var(--tw-text-opacity, 1))}.text-sky-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-sky-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-sky-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-sky-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-sky-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(var(--color-slate-300) / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(var(--color-slate-500) / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(var(--color-slate-600) / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(var(--color-slate-800) / var(--tw-text-opacity, 1))}.text-slate-900{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(var(--color-slate-950) / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.accent-brand{accent-color:rgb(var(--color-brand) / 1)}.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: var(--shadow-2xl);--tw-shadow-colored: var(--shadow-2xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-brand-active{--tw-shadow: var(--shadow-brand-active);--tw-shadow-colored: var(--shadow-brand-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat{--tw-shadow: var(--shadow-chat);--tw-shadow-colored: var(--shadow-chat);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-active{--tw-shadow: var(--shadow-chat-active);--tw-shadow-colored: var(--shadow-chat-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-input{--tw-shadow: var(--shadow-chat-input);--tw-shadow-colored: var(--shadow-chat-input);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: var(--shadow-inner);--tw-shadow-colored: var(--shadow-inner);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: var(--shadow-md);--tw-shadow-colored: var(--shadow-md);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-modal{--tw-shadow: var(--shadow-modal);--tw-shadow-colored: var(--shadow-modal);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-panel{--tw-shadow: var(--shadow-panel);--tw-shadow-colored: var(--shadow-panel);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sidebar{--tw-shadow: var(--shadow-sidebar);--tw-shadow-colored: var(--shadow-sidebar);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: var(--shadow-sm);--tw-shadow-colored: var(--shadow-sm);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: var(--shadow-xl);--tw-shadow-colored: var(--shadow-xl);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: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: rgb(var(--color-brand-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: rgb(var(--color-success-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: rgb(var(--color-neutral-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(var(--color-neutral-200) / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: rgb(var(--color-danger-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-sky-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.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-2{--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)}.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(var(--color-neutral-200) / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-white) / 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)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-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{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.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-300{transition-duration:.3s}.duration-500{transition-duration:.5s}:root{--color-transparent: transparent;--color-black: 0 0 0;--color-white: 255 255 255;--color-brand: 0 148 247;--color-brand-highlight: 0 113 227;--color-brand-light: 40 126 254;--color-ink: 29 29 31;--color-muted: 134 134 139;--color-line: 210 210 215;--color-canvas: 244 245 247;--color-surface: 255 255 255;--color-surface-subtle: 247 248 250;--color-surface-muted: 250 250 250;--color-neutral-50: 249 250 251;--color-neutral-100: 243 244 246;--color-neutral-200: 229 231 235;--color-neutral-300: 209 213 219;--color-neutral-400: 156 163 175;--color-neutral-500: 107 114 128;--color-neutral-600: 75 85 99;--color-neutral-700: 55 65 81;--color-neutral-800: 31 41 55;--color-neutral-900: 17 24 39;--color-neutral-950: 3 7 18;--color-slate-50: 248 250 252;--color-slate-100: 241 245 249;--color-slate-200: 226 232 240;--color-slate-300: 203 213 225;--color-slate-400: 148 163 184;--color-slate-500: 100 116 139;--color-slate-600: 71 85 105;--color-slate-700: 51 65 85;--color-slate-800: 30 41 59;--color-slate-900: 15 23 42;--color-slate-950: 2 6 23;--color-brand-50: 239 248 255;--color-brand-100: 223 241 255;--color-brand-200: 191 229 255;--color-brand-300: 143 210 255;--color-brand-400: 83 184 251;--color-brand-500: 0 148 247;--color-brand-600: 0 148 247;--color-brand-700: 0 113 227;--color-brand-800: 0 91 181;--color-brand-900: 0 75 147;--color-brand-950: 0 53 107;--color-success-50: 236 253 245;--color-success-100: 209 250 229;--color-success-200: 167 243 208;--color-success-300: 110 231 183;--color-success-400: 52 211 153;--color-success-500: 16 185 129;--color-success-600: 5 150 105;--color-success-700: 4 120 87;--color-success-800: 6 95 70;--color-success-900: 6 78 59;--color-success-950: 2 44 34;--color-warning-50: 255 251 235;--color-warning-100: 254 243 199;--color-warning-200: 253 230 138;--color-warning-300: 252 211 77;--color-warning-400: 251 191 36;--color-warning-500: 245 158 11;--color-warning-600: 217 119 6;--color-warning-700: 180 83 9;--color-warning-800: 146 64 14;--color-warning-900: 120 53 15;--color-warning-950: 69 26 3;--color-danger-50: 254 242 242;--color-danger-100: 254 226 226;--color-danger-200: 254 202 202;--color-danger-300: 252 165 165;--color-danger-400: 248 113 113;--color-danger-500: 239 68 68;--color-danger-600: 220 38 38;--color-danger-700: 185 28 28;--color-danger-800: 153 27 27;--color-danger-900: 127 29 29;--color-danger-950: 69 10 10;--color-info-50: 239 246 255;--color-info-100: 219 234 254;--color-info-200: 191 219 254;--color-info-300: 147 197 253;--color-info-400: 96 165 250;--color-info-500: 59 130 246;--color-info-600: 37 99 235;--color-info-700: 29 78 216;--color-info-800: 30 64 175;--color-info-900: 30 58 138;--color-info-950: 23 37 84;--color-accent-50: 250 245 255;--color-accent-100: 243 232 255;--color-accent-200: 233 213 255;--color-accent-300: 216 180 254;--color-accent-400: 192 132 252;--color-accent-500: 168 85 247;--color-accent-600: 147 51 234;--color-accent-700: 126 34 206;--color-accent-800: 107 33 168;--color-accent-900: 88 28 135;--color-accent-950: 59 7 100;--shadow-none: 0 0 0 var(--color-transparent);--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / .1), 0 1px 2px -1px rgb(var(--color-black) / .1);--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / .05);--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / .1), 0 2px 4px -2px rgb(var(--color-black) / .1);--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / .1), 0 4px 6px -4px rgb(var(--color-black) / .1);--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / .1), 0 8px 10px -6px rgb(var(--color-black) / .1);--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / .05);--shadow-card: 0 8px 24px rgb(var(--color-black) / .04);--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / .05);--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / .035);--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / .06);--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / .04);--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / .2);--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / .2);--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / .3)}*,:before,:after{--tw-ring-offset-color: rgb(var(--color-white));--tw-ring-color: rgb(var(--color-brand-400) / .5);--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);--tw-ring-shadow: 0 0 0 var(--color-transparent);--tw-shadow: 0 0 0 var(--color-transparent);--tw-shadow-colored: 0 0 0 var(--color-transparent)}.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:rgb(var(--color-canvas));color:rgb(var(--color-ink));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:rgb(var(--color-surface));border-radius:8px;border:1px solid rgb(var(--color-black) / .02);box-shadow:var(--shadow-card);transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px rgb(var(--color-black) / .06)}.dashboard-pie-chart .recharts-surface:focus,.dashboard-pie-chart .recharts-pie:focus,.dashboard-pie-chart .recharts-pie-sector:focus,.dashboard-pie-chart .recharts-sector:focus{outline:none}.dashboard-revenue-chart .recharts-surface:focus,.dashboard-revenue-chart .recharts-bar-rectangle:focus,.dashboard-revenue-chart .recharts-rectangle:focus,.dashboard-revenue-chart .recharts-curve:focus,.dashboard-revenue-chart .recharts-dot:focus,.dashboard-revenue-chart [class*=recharts-zIndex-layer_]:focus{outline:none!important}.dashboard-revenue-chart .recharts-bar-rectangle,.dashboard-revenue-chart .recharts-rectangle{stroke:none!important}.ios-input{background:rgb(var(--color-surface-subtle));border:1px solid var(--color-transparent);transition:all .3s cubic-bezier(.25,.8,.25,1);color:rgb(var(--color-ink));font-weight:500}.ios-input:focus{background:rgb(var(--color-surface));border-color:rgb(var(--color-brand));box-shadow:0 0 0 4px rgb(var(--color-brand) / .3);outline:none}.ios-input::-moz-placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-input::placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-btn-primary{background:rgb(var(--color-brand));color:rgb(var(--color-white));font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:rgb(var(--color-brand-highlight));transform:translateY(-1px);box-shadow:var(--shadow-brand-strong)}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:var(--shadow-brand-soft)}.ios-btn-primary:disabled{background:rgb(var(--color-neutral-100));color:rgb(var(--color-neutral-400));box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:rgb(var(--color-surface-subtle));color:rgb(var(--color-ink));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:rgb(var(--color-neutral-200));border-color:rgb(var(--color-neutral-300))}.ios-btn-danger{background:rgb(var(--color-danger-100));color:rgb(var(--color-danger-600));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:rgb(var(--color-danger-200));border-color:rgb(var(--color-danger-300))}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--color-transparent)}::-webkit-scrollbar-thumb{background:rgb(var(--color-black) / .1);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:rgb(var(--color-black) / .2)}@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:rgb(var(--color-brand));color:rgb(var(--color-white))}::selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}.text-brand{color:rgb(var(--color-brand))}.bg-brand{background-color:rgb(var(--color-brand))}.border-brand{border-color:rgb(var(--color-brand))}.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:rgb(var(--color-success-100));color:rgb(var(--color-success-800))}.status-badge-warning{background-color:rgb(var(--color-warning-100));color:rgb(var(--color-warning-800))}.status-badge-error{background-color:rgb(var(--color-danger-100));color:rgb(var(--color-danger-800))}.status-badge-info{background-color:rgb(var(--color-info-100));color:rgb(var(--color-info-800))}.loading-skeleton{background:linear-gradient(90deg,rgb(var(--color-neutral-100)),rgb(var(--color-neutral-200)),rgb(var(--color-neutral-100)));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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 rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));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:rgb(var(--color-black) / .4);-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:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);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}}.placeholder\:text-slate-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.placeholder\:text-slate-400::placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.focus-within\:border-sky-400:focus-within{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus-within\:ring-2:focus-within{--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-within\:ring-sky-100:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.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-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-300) / var(--tw-border-opacity, 1))}.hover\:border-brand:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-success-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-400) / var(--tw-border-opacity, 1))}.hover\:border-sky-200:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-700) / var(--tw-bg-opacity, 1))}.hover\:bg-brand:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.hover\:bg-brand-highlight:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-highlight) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:rgb(var(--color-success-50) / .5)}.hover\:bg-emerald-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-700) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-800) / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-700) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.hover\:bg-warning-50\/50:hover{background-color:rgb(var(--color-warning-50) / .5)}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:rgb(var(--color-white) / .1)}.hover\:bg-white\/80:hover{background-color:rgb(var(--color-white) / .8)}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-brand:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.hover\:text-sky-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.hover\:text-slate-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);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(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:border-sky-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / 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-brand:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand) / var(--tw-ring-opacity, 1))}.focus\:ring-sky-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / 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(var(--color-danger-400) / var(--tw-bg-opacity, 1))}.disabled\:bg-slate-300:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / 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}.disabled\:shadow-none:disabled{--tw-shadow: var(--shadow-none);--tw-shadow-colored: var(--shadow-none);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / 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(var(--color-white) / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / 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-64{width:16rem}.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\:p-6{padding:1.5rem}.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}}@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\:grid-cols-\[minmax\(270px\,0\.72fr\)_minmax\(0\,1\.28fr\)\]{grid-template-columns:minmax(270px,.72fr) minmax(0,1.28fr)}.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-D_XA_mO5.js b/internal/webui/static/assets/index-D_XA_mO5.js deleted file mode 100644 index 27fc51c..0000000 --- a/internal/webui/static/assets/index-D_XA_mO5.js +++ /dev/null @@ -1,20 +0,0 @@ -import{j as e,r as l,c as js,b as Me,d as Ja}from"./react-vendor-C_od1ZSF.js";import{L as Ga,U as xa,M as os,C as Ns,B as ma,S as ua,Z as cs,a as ft,b as _s,G as As,c as vs,d as ws,e as Va,f as lt,A as Is,D as Qa,g as Os,P as pa,h as $t,E as ha,T as Ka,i as Ha,j as Se,X as Oe,k as Za,l as Ya,m as ks,n as ga,o as Xe,p as Qe,q as ba,K as Xa,r as nt,s as at,Q as Kt,t as it,u as bt,v as Ot,R as Je,w as fa,x as el,y as Ve,z as et,F as Rs,H as jt,I as yt,J as Rt,N as tl,O as sl,V as al,W as ya,Y as ja,_ as Na,$ as ll,a0 as rl,a1 as Ht,a2 as Dt,a3 as ds,a4 as nl,a5 as il,a6 as xs,a7 as Ps,a8 as ol,a9 as cl,aa as Pt,ab as $s,ac as Wt,ad as _a,ae as dl,af as xl,ag as Vt,ah as va,ai as ml,aj as ul,ak as pl,al as hl,am as gl,an as bl,ao as Ts}from"./icons-vendor-BFpWAqQX.js";import{R as Mt,B as fl,X as Es,Y as Ds,T as Bt,a as yl,C as Zt,A as jl,b as Nl,c as _l,P as Ms,d as Bs,L as vl}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const _ of i)if(_.type==="childList")for(const j of _.addedNodes)j.tagName==="LINK"&&j.rel==="modulepreload"&&n(j)}).observe(document,{childList:!0,subtree:!0});function a(i){const _={};return i.integrity&&(_.integrity=i.integrity),i.referrerPolicy&&(_.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?_.credentials="include":i.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function n(i){if(i.ep)return;i.ep=!0;const _=a(i);fetch(i.href,_)}})();const wl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,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"})})}),ms=({sizeClass:t="w-12 h-12",logoClassName:s="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 ${t} 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:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),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(wl,{className:s})})]})]}),kl=({activeTab:t,isAdmin:s=!1,collapsed:a,onToggleCollapsed:n,onNavigate:i,onLogout:_})=>{const[j,S]=l.useState({version:"dev",commit:"unknown"});l.useEffect(()=>{const g=new AbortController;return fetch("/health",{signal:g.signal}).then(I=>I.ok?I.json():Promise.reject(new Error("health request failed"))).then(I=>S({version:String(I.version||"dev"),commit:String(I.commit||"unknown")})).catch(I=>{I instanceof DOMException&&I.name}),()=>g.abort()},[]);const u=[{id:"dashboard",icon:Ga,label:"仪表盘"},{id:"accounts",icon:xa,label:"账号管理"},{id:"chat",icon:os,label:"在线聊天"},{id:"cards",icon:Ns,label:"卡密库存"},{id:"items",icon:ma,label:"商品列表"},{id:"orders",icon:ua,label:"订单管理"},{id:"rules",icon:cs,label:"自动化规则"},{id:"notifications",icon:ft,label:"通知设置"},...s?[{id:"settings",icon:_s,label:"系统与AI"}]:[]],w=/^\d+\.\d+\.\d+$/.test(j.version)?`v${j.version}`:j.version;return e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${a?"w-16":"w-64"}`,children:[e.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${a?"justify-center px-2":"gap-3 px-5"}`,children:[e.jsx(ms,{sizeClass:"h-10 w-10"}),!a&&e.jsxs("div",{className:"min-w-0 leading-tight",children:[e.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),e.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),e.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${a?"px-2":"px-3"}`,"aria-label":"主导航",children:u.map(g=>{const I=g.icon,M=t===g.id;return e.jsx(js.Fragment,{children:e.jsxs("button",{type:"button",title:a?g.label:void 0,"aria-label":g.label,"aria-current":M?"page":void 0,onClick:()=>i(g.id),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${a?"justify-center":"gap-3 px-3.5"} ${M?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[e.jsx(I,{className:`h-[19px] w-[19px] shrink-0 ${M?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),!a&&e.jsx("span",{className:"truncate text-sm font-bold",children:g.label}),M&&!a&&e.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},g.id)})}),e.jsxs("div",{children:[e.jsx("div",{title:a?`版本 ${j.version} · ${j.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${a?"flex justify-center px-1":"px-6"}`,children:a?e.jsx(As,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${j.version}`}):e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[e.jsx(As,{className:"h-3.5 w-3.5"}),"运行版本"]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:w}),e.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:j.commit})]})]})}),e.jsxs("div",{className:`space-y-2 p-2 ${a?"":"p-3"}`,children:[e.jsxs("button",{type:"button",onClick:n,title:a?"展开侧边栏":"收起侧边栏","aria-label":a?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${a?"justify-center":"gap-3 px-3"}`,children:[a?e.jsx(vs,{className:"h-5 w-5"}):e.jsx(ws,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),e.jsxs("button",{type:"button",onClick:_,title:a?"退出登录":void 0,"aria-label":"退出登录",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${a?"justify-center":"gap-3 px-3"}`,children:[e.jsx(Va,{className:"h-5 w-5"}),!a&&e.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},Cl=3e4,Sl=10*6e4;let Yt=!1;const wa=()=>{Yt||typeof window>"u"||(Yt=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{Yt=!1}))},Ll=t=>{if(!t)return"";const s=new URLSearchParams;for(const[n,i]of Object.entries(t))i!=null&&s.set(n,String(i));const a=s.toString();return a?`?${a}`:""},Qt=async(t,s,a={})=>{var w;const n=Ll(a.params),i=`${s}${n}`,_=ka(a.signal,a.timeoutMs??Cl);let j;try{j=await fetch(i,{method:t,credentials:"include",signal:_.signal,headers:{...a.body===void 0?{}:{"Content-Type":"application/json"}},body:a.body===void 0?void 0:JSON.stringify(a.body)})}catch(g){throw _.signal.aborted?new Error((w=a.signal)!=null&&w.aborted?"请求已取消":"请求超时,请稍后重试"):g}finally{_.cleanup()}const u=(j.headers.get("content-type")||"").includes("application/json");if(!j.ok){j.status===401&&!a.skipAuthLogout&&wa();const g=u?await j.json().catch(()=>{}):await j.text().catch(()=>{}),I=Ca(g,j.status);throw new Error(I)}return u?await j.json():await j.text()},Ce=async(t,s,a)=>Qt("GET",t,{params:s,...a}),we=async(t,s,a)=>Qt("POST",t,{body:s,...a}),ze=async(t,s,a)=>Qt("PUT",t,{body:s,...a}),He=async(t,s,a)=>Qt("DELETE",t,{params:s,...a}),_t=async(t,s,a={})=>{var u;const n=ka(a.signal,a.timeoutMs??Sl);let i;try{i=await fetch(t,{method:"POST",credentials:"include",signal:n.signal,body:s})}catch(w){throw n.signal.aborted?new Error((u=a.signal)!=null&&u.aborted?"请求已取消":"上传超时,请稍后重试"):w}finally{n.cleanup()}const S=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>{}):await i.text().catch(()=>{});if(!i.ok){i.status===401&&wa();const w=Ca(S,i.status),g=new Error(w);throw g.payload=S,g}return S},ka=(t,s)=>{const a=new AbortController,n=()=>a.abort(t==null?void 0:t.reason);t!=null&&t.aborted?n():t==null||t.addEventListener("abort",n,{once:!0});const i=globalThis.setTimeout(()=>a.abort(new DOMException("timeout","TimeoutError")),Math.max(1,s));return{signal:a.signal,cleanup:()=>{globalThis.clearTimeout(i),t==null||t.removeEventListener("abort",n)}}},Al=t=>{if(typeof t!="object"||t===null)return!1;const s=t;return typeof s.code=="string"&&typeof s.message=="string"},Ca=(t,s)=>typeof t=="string"?t:Al(t)?t.message:`请求失败: ${s}`,Jt=t=>{const s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${s}-${a}-${n}`},Cs=(t,s)=>{const a=new Date(t);return a.setHours(12,0,0,0),a.setDate(a.getDate()+s),a},us=(t,s)=>({startDate:Jt(Cs(t,-(s-1))),endDate:Jt(t)}),qs=(t,s=new Date,a="",n="")=>{if(t==="custom"&&a&&n){if(a>n)throw new Error("开始日期不能晚于结束日期");return{startDate:a,endDate:n}}return t==="yesterday"?us(Cs(s,-1),1):us(s,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Il=t=>{const s=new Date(`${t.startDate}T12:00:00`),a=new Date(`${t.endDate}T12:00:00`),n=Math.round((a.getTime()-s.getTime())/864e5)+1,i=Cs(s,-1);return us(i,n)},Ol=t=>{const s={...t};if("renewal_log_retention_days"in s){const a=Number(s.renewal_log_retention_days);s.renewal_log_retention_days=Number.isFinite(a)?a:10}return s},Rl=async t=>we("/api/v1/session/login",t,{skipAuthLogout:!0}),Pl=async t=>we("/api/v1/session/initialize",{password:t},{skipAuthLogout:!0}),Sa=async()=>Ce("/api/v1/session"),$l=async()=>we("/api/v1/session/logout",{}),Tl=async t=>ze("/api/v1/session/credentials",t),El=(t,s)=>{const a=t.avatar_url||"";if(!a)return"";try{const n=new URL(a,window.location.origin);return n.hostname.endsWith("alicdn.com")&&n.searchParams.set("_v",s),n.toString()}catch{return a}},Tt=async t=>{const s=await Ce("/api/v1/accounts/details",void 0,t),a=Date.now().toString();return s.map(n=>({id:n.id,value:"",cookie:"",enabled:n.enabled,auto_confirm:n.auto_confirm,remark:n.remark,note:n.remark,pause_duration:n.pause_duration,paused_until:Number(n.paused_until||0),paused:n.paused===!0,username:n.username||"",login_password:"",show_browser:n.show_browser===!0||n.show_browser===1||n.show_browser==="1"||n.show_browser==="true",nickname:n.nickname||n.remark||`账号 ${n.id.substring(0,6)}`,avatar_url:El(n,a),profile_error:n.profile_error||"",ai_enabled:!1,auto_rate_enabled:n.auto_rate_enabled,rate_content:n.rate_content||"不错的买家,交易愉快",auto_polish_enabled:n.auto_polish_enabled,polish_time:n.polish_time||"03:00",last_rate_scan_at:Number(n.last_rate_scan_at||0),last_polish_date:n.last_polish_date||"",last_polish_at:Number(n.last_polish_at||0)}))},Dl=async t=>Ce(`/api/v1/account-tasks/${t}`),Fs=async(t,s)=>ze(`/api/v1/account-tasks/${t}`,s),Ml=async(t,s)=>we(`/api/v1/account-tasks/${t}/run`,{task_type:s},{timeoutMs:12e4}),Xt=async(t,s,a,n=!1)=>{const i=await Ce("/api/v1/chat/sessions",{account_id:t,cursor:s,refresh:n?1:void 0},n?{timeoutMs:6e4,...a}:a);return{sessions:i.sessions||[],has_more:i.has_more===!0,next_cursor:i.next_cursor}},ps=async(t,s,a,n,i)=>{const _=await Ce("/api/v1/chat/messages",{account_id:t,chat_id:s,cursor:a,before_id:n},i);return{messages:_.messages||[],has_more:_.has_more===!0,next_cursor:_.next_cursor,session:_.session}},Bl=async(t,s,a,n)=>(await ps(t,s,void 0,a,n)).messages,ql=async t=>we("/api/v1/chat/messages",t),Fl=async t=>{const s=new FormData;return Object.entries(t).forEach(([a,n])=>s.append(a,n)),_t("/api/v1/chat/images",s,{timeoutMs:12e4})},zs=async(t,s)=>we("/api/v1/chat/read",{account_id:t,chat_id:s}),hs=async t=>Ce("/api/v1/accounts/runtime-status",void 0,t),zl=async t=>we("/api/v1/qr-login/generate",void 0,{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),Ul=async(t,s)=>Ce(`/api/v1/qr-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),Wl=async(t,s)=>we(`/api/v1/qr-login/complete-verification/${t}`,{target_account_id:s||""}),Jl=async(t,s)=>ze(`/api/v1/accounts/${t}/status`,{enabled:s}),Gl=async t=>He(`/api/v1/accounts/${t}`),Vl=async(t,s)=>ze(`/api/v1/accounts/${t}/pause-duration`,{pause_duration:s}),Ql=async(t,s)=>ze(`/api/v1/accounts/${t}/settings`,s),Kl=async t=>Ce(`/api/v1/accounts/${t}/long-login`),Hl=async(t,s)=>ze(`/api/v1/accounts/${t}/long-login`,{enabled:s}),Zl=async t=>we("/api/v1/password-login",t),Yl=async(t,s)=>Ce(`/api/v1/password-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),Xl=async t=>He(`/api/v1/password-login/cancel/${t}`),er=async t=>we(`/api/v1/accounts/${t}/refresh-profile`,{}),tr=async t=>Ce("/api/v1/settings/ai-reply",void 0,t),La=t=>{const s=String(t||"");return s==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(s)?s:"unknown"},sr=async(t,s,a=1,n=20,i)=>{const _={page:a,page_size:n};t&&(_.cookie_id=t),s&&s!=="all"&&(_.status=s),i!=null&&i.trim()&&(_.search=i.trim());const j=await Ce("/api/v1/orders",_),u=(j.orders||j.data||[]).map(w=>({...w,id:w.id||w.order_id,status:La(w.status||w.order_status),quantity:Number(w.quantity||1)}));return{success:!0,data:u,total:j.total||u.length,page:j.page||a,page_size:j.page_size||n,total_pages:j.total_pages||1}},ar=async(t,s)=>ze(`/api/v1/orders/${t}`,s),lr=async t=>He(`/api/v1/orders/${t}`),rr=async(t,s)=>{const a=new FormData;return t&&a.append("cookie_id",t),s&&a.append("status",s),_t("/api/v1/orders/refresh",a)},nr=async t=>we(`/api/v1/orders/${t}/refresh`),ir=async(t,s)=>we("/api/v1/orders/manual-ship",{order_ids:t,ship_mode:s}),or=async t=>t instanceof FormData?_t("/api/v1/orders/import",t):we("/api/v1/orders/import",t),cr=async()=>Ce("/api/v1/analytics/dashboard"),Us=async(t=7)=>{let s;if(typeof t=="number"){const a=new Date,n=new Date;n.setDate(n.getDate()-t),s={start_date:Jt(n),end_date:Jt(a)}}else s=t;return Ce("/api/v1/analytics/orders",{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()})},dr=async t=>{const s=await Ce("/api/v1/analytics/orders/valid",{start_date:t.start_date,end_date:t.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()}),n=(Array.isArray(s)?s:s.orders||[]).map(i=>({...i,id:i.id||i.order_id,status:La(i.status||i.order_status),quantity:Number(i.quantity||1)}));return{orders:n,total:Array.isArray(s)?n.length:Number(s.total??n.length),truncated:Array.isArray(s)?!1:s.truncated===!0}},xr=t=>{let s=t.api_config;if(typeof s=="string"&&s.trim())try{s=JSON.parse(s)}catch{s=void 0}return{...t,api_config:s||void 0}},Aa=t=>({...t,api_config:t.api_config?JSON.stringify(t.api_config):""}),Ss=async t=>{const s=await Ce("/api/v1/cards",void 0,t);return(Array.isArray(s)?s:s.cards||[]).map(xr)},mr=async t=>we("/api/v1/cards",Aa(t)),Ws=async(t,s)=>ze(`/api/v1/cards/${t}`,Aa(s)),ur=async t=>He(`/api/v1/cards/${t}`),pr=async(t,s)=>{const a=new FormData;return a.append("file",t),_t("/api/v1/cards/batch",a,s)},hr=async(t,s,a)=>we(`/api/v1/cards/${t}/append-data`,{content:s},a),es=t=>t===!0||t===1||t==="1",Nt=async t=>{const s=await Ce("/api/v1/items",void 0);return(Array.isArray(s)?s:s.items||[]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:es(n.is_multi_spec),is_multi_qty_ship:es(n.is_multi_qty_ship??n.multi_quantity_delivery),multi_quantity_delivery:es(n.multi_quantity_delivery??n.is_multi_qty_ship)}))},gr=async t=>we("/api/v1/items/get-all-from-account",{cookie_id:t}),br=async(t,s)=>He(`/api/v1/items/${t}/${s}`),fr=async(t,s)=>we(`/api/v1/items/${t}`,s),yr=async t=>{const s=new FormData;s.set("cookie_id",t.cookie_id),s.set("title",t.title),s.set("description",t.description),s.set("price",t.price),s.set("original_price",t.original_price||""),s.set("quantity",String(t.quantity)),s.set("postage_mode",t.postage_mode),s.set("postage",t.postage||""),t.location&&s.set("location",JSON.stringify(t.location));for(const a of t.images)s.append("images",a);return _t("/api/v1/items/publish",s)},jr=async(t,s)=>we("/api/v1/items/publish-categories/recommend",{cookie_id:t,keyword:s}),Nr=async t=>{const s=new FormData;return s.set("file",t.file),t.imagesZip&&s.set("images_zip",t.imagesZip),t.defaultCookieId&&s.set("default_cookie_id",t.defaultCookieId),s.set("fallback_category_id",t.fallbackCategory.catId),s.set("fallback_category_name",t.fallbackCategory.catName),s.set("fallback_channel_category_id",t.fallbackCategory.channelCatId||""),s.set("fallback_tb_category_id",t.fallbackCategory.tbCatId||""),t.location&&s.set("location",JSON.stringify(t.location)),_t("/api/v1/items/publish-batches/preview",s)},_r=async t=>we("/api/v1/items/publish-batches",{preview_id:t}),pt=async t=>Ce(`/api/v1/items/publish-batches/${t}`),Ia=async(t=20)=>{const s=await Ce("/api/v1/items/publish-batches",{limit:t});return Array.isArray(s)?s:s.batches||[]},vr=async t=>He(`/api/v1/items/publish-batches/${t}`),wr=async t=>we(`/api/v1/items/publish-batches/${t}/cancel`,{}),kr=async t=>we(`/api/v1/items/publish-batches/${t}/retry-failed`,{}),Cr=async(t,s,a)=>ze(`/api/v1/items/${t}/${s}`,a),Oa=t=>t.map(s=>{var a,n;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((a=(s.actions||[]).find(i=>i.action_type==="send_card"))==null?void 0:a.card_id)||0),card_group_name:((n=(s.actions||[]).find(i=>i.action_type==="send_card"))==null?void 0:n.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(i=>({id:i.id?String(i.id):void 0,action_type:i.action_type,card_id:Number(i.card_id||0),card_name:i.card_name||"",delivery_count:Number(i.delivery_count||1),message_template:i.message_template||"",delay_seconds:Number(i.delay_seconds||0),config_json:i.config_json||"{}",enabled:i.enabled!==!1,sort_order:Number(i.sort_order||0)})),variants:(s.actions||[]).filter(i=>i.action_type==="send_card").map(i=>{let _={};try{_=JSON.parse(i.config_json||"{}")}catch{}return{id:i.id?String(i.id):void 0,spec_name:_.spec_name||"",spec_value:_.spec_value||"",card_id:Number(i.card_id||0),card_name:i.card_name||"",delivery_count:Number(i.delivery_count||1),enabled:i.enabled!==!1,delay_override:_.delay_override===!0,delay_seconds:Number(i.delay_seconds||0),config_json:i.config_json||"{}"}})}}),gs=async()=>{const t=await Ce("/api/v1/automation-rules"),s=Array.isArray(t)?t:t.data||[];return Oa(s)},Sr=async({cookieId:t,triggerType:s,enabled:a,search:n,page:i=1,pageSize:_=10}={})=>{const j=await Ce("/api/v1/automation-rules",{page:i,page_size:_,cookie_id:t||void 0,trigger_type:s||void 0,enabled:a,search:(n==null?void 0:n.trim())||void 0}),S=Oa(Array.isArray(j)?j:j.data||[]);return{success:!0,data:S,total:Number(Array.isArray(j)?S.length:j.total??S.length),page:Number(Array.isArray(j)?i:j.page??i),page_size:Number(Array.isArray(j)?_:j.page_size??_),total_pages:Number(Array.isArray(j)?S.length?1:0:j.total_pages??(S.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(Array.isArray(j)?{}:j.trigger_counts||{}).map(([u,w])=>[u,Number(w)]))}},Lr=(t,s)=>{if(t!=="order_paid")return s.map((i,_)=>({...i,sort_order:i.sort_order||_+1}));const a=s.filter(i=>i.action_type==="send_card").map((i,_)=>({...i,sort_order:_+1})),n=s.filter(i=>i.action_type!=="send_card"&&i.action_type!=="confirm_shipment");return[...a,...n.map((i,_)=>({...i,sort_order:a.length+_+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:a.length+n.length+1}]},Js=async t=>{const s=t.trigger_type||"order_paid",n=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[s]||"自动化规则",t.item_title||t.item_id||t.cookie_id||""].filter(Boolean).join(" - "),i=(t.actions||[]).filter(u=>u.action_type!=="send_card"&&u.action_type!=="confirm_shipment"),_=t.variants&&t.variants.length>0?[...t.variants.map((u,w)=>({action_type:"send_card",card_id:u.card_id,delivery_count:u.delivery_count||1,enabled:u.enabled!==!1,sort_order:w+1,delay_seconds:u.delay_seconds||0,config_json:JSON.stringify({spec_name:u.spec_name||"",spec_value:u.spec_value||"",delay_override:u.delay_override===!0})})),...i]:t.actions&&t.actions.length>0?t.actions:[{action_type:"send_card",card_id:t.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],j=Lr(s,_),S={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||n||"自动化规则",trigger_type:s,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:j.map((u,w)=>({action_type:u.action_type,card_id:u.card_id||0,delivery_count:u.delivery_count||1,message_template:u.message_template||"",delay_seconds:u.delay_seconds||0,config_json:u.config_json||"{}",enabled:u.enabled!==!1,sort_order:u.sort_order||w+1}))};return t.id?ze(`/api/v1/automation-rules/${t.id}`,S):we("/api/v1/automation-rules",S)},Ar=async t=>He(`/api/v1/automation-rules/${t}`),Ir=async()=>{const t=await Ce("/api/v1/automation-issues");return{runs:Array.isArray(t==null?void 0:t.runs)?t.runs:[],pending_tasks:Array.isArray(t==null?void 0:t.pending_tasks)?t.pending_tasks:[]}},Or=async(t,s)=>we(`/api/v1/automation-runs/${t}/resolve`,{resolution:s}),Rr=async(t,s)=>we(`/api/v1/automation-pending-tasks/${t}/resolve`,{resolution:s}),Pr=t=>({id:String((t==null?void 0:t.id)||""),keyword:(t==null?void 0:t.keyword)||"",reply:(t==null?void 0:t.reply)||"",item_id:(t==null?void 0:t.item_id)||"",type:(t==null?void 0:t.type)==="image"?"image":"text",image_url:(t==null?void 0:t.image_url)||""}),$r=async t=>{const s=await Ce(`/api/v1/reply-rules/${t}/typed`);return Array.isArray(s)?s.map(Pr):[]},Tr=async t=>t?(await $r(t)).map(a=>({id:a.id,keyword:a.keyword||"",reply_content:a.reply||"",match_type:"fuzzy",enabled:!0,item_id:a.item_id||"",type:a.type==="image"?"image":"text",image_url:a.image_url||""})):[],Er=async(t,s)=>{const a=t.type||"text",n={keyword:t.keyword||"",reply:a==="text"&&t.reply_content||"",item_id:t.item_id||"",type:a,image_url:a==="image"&&t.image_url||""};return t.id?ze(`/api/v1/reply-rules/${s}/typed/${t.id}`,n):we(`/api/v1/reply-rules/${s}/items`,n)},Dr=async(t,s)=>He(`/api/v1/reply-rules/${s}/typed/${t}`),Ra=async()=>{const t=await Ce("/api/v1/settings/system");return Ol(t.data||t)},Pa=async t=>{const s=Object.fromEntries(Object.entries(t).filter(([,a])=>a!=null));return ze("/api/v1/settings/system",s)},Mr=async(t,s)=>Ce(`/api/v1/settings/ai-reply/${t}`,void 0,s),Br=async(t,s)=>{const a={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return ze(`/api/v1/settings/ai-reply/${t}`,a)},qr=async(t,s="")=>(await we("/api/v1/settings/ai-models",{base_url:t,api_key:s})).models||[],Fr=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},$a=t=>{const s=Array.from(new Set((t||[]).filter(Boolean)));return s.length>0?JSON.stringify(s):""},Ta=async t=>({success:!0,data:(await Ce("/api/v1/notifications/channels",void 0,t)||[]).map(n=>{let i;try{i=typeof n.config=="string"?JSON.parse(n.config):n.config}catch{i={}}return{id:String(n.id),name:n.name,type:n.type==="ding_talk"?"dingtalk":n.type==="lark"?"feishu":n.type,config:i,event_types:Fr(n.event_types),enabled:n.enabled,created_at:n.created_at,updated_at:n.updated_at}})}),zr=async t=>we("/api/v1/notifications/channels",{...t,config:JSON.stringify(t.config),event_types:$a(t.event_types)}),Gs=async(t,s)=>{const a={...s};return"config"in s&&(a.config=JSON.stringify(s.config)),"event_types"in s&&(a.event_types=$a(s.event_types)),ze(`/api/v1/notifications/channels/${t}`,a)},Ur=async t=>He(`/api/v1/notifications/channels/${t}`),Wr=async(t,s)=>{const a=await Ce(`/api/v1/notifications/accounts/${t}/bindings`,void 0,s);return(a==null?void 0:a.channel_ids)||[]},Jr=async t=>we(`/api/v1/notifications/channels/${t}/test`,{}),Vs=async()=>Ce("/api/v1/default-replies"),Gr=async t=>{const s=await Ce(`/api/v1/default-replies/${t}`);return{cookie_id:t,enabled:s.enabled||!1,reply_content:s.reply_content||"",reply_once:s.reply_once||!1,reply_image_url:s.reply_image_url||""}},Vr=async(t,s)=>ze(`/api/v1/default-replies/${t}`,{enabled:s.enabled??!1,reply_content:s.reply_content||"",reply_once:s.reply_once??!1,reply_image_url:s.reply_image_url||""}),Qr=async t=>He(`/api/v1/default-replies/${t}`),Kr=async t=>we(`/api/v1/default-replies/${t}/clear-records`,{}),Ct=t=>String(t).padStart(2,"0"),bs=t=>{if(t==null||t==="")return"-";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"-":[s.getFullYear(),Ct(s.getMonth()+1),Ct(s.getDate())].join("-")+" "+[Ct(s.getHours()),Ct(s.getMinutes()),Ct(s.getSeconds())].join(":")},ye=(t,s)=>s===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${s})`,Hr=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},qt=({title:t,value:s,icon:a,colorClass:n,trend:i})=>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 ${n} 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 ${n} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(a,{className:`w-6 h-6 ${n.replace("bg-","text-")}`})}),i&&e.jsxs("span",{className:"text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(Ka,{className:"w-3 h-3"})," ",i]})]}),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:s}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),ts=()=>{var Ee,Be;const[t,s]=l.useState(null),[a,n]=l.useState(null),[i,_]=l.useState(""),[j,S]=l.useState("7days"),[u,w]=l.useState(""),[g,I]=l.useState(""),[M,H]=l.useState(null),[Z,N]=l.useState(""),[$,E]=l.useState([]),[V,Y]=l.useState(0),[ae,se]=l.useState(!1),[oe,L]=l.useState(!1),[ee,le]=l.useState([]),[d,J]=l.useState({}),F=l.useRef(0),C=[ye("brand"),ye("brand-highlight"),ye("success-500"),ye("warning-500"),ye("accent-500")],B=h=>`¥${Number(h||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`,k=async h=>{let X;try{X=qs(h,new Date,u,g)}catch(te){_(te instanceof Error?te.message:"日期范围无效");return}const{startDate:pe,endDate:y}=X,ce={start_date:pe,end_date:y},D=Il(X),xe=++F.current;L(!0),_("");try{const[te,$e,Le]=await Promise.all([Us(ce),Us({start_date:D.startDate,end_date:D.endDate}),dr(ce)]);if(xe!==F.current)return;n(te),H($e),E(Le.orders),Y(Le.total),se(Le.truncated)}catch(te){xe===F.current&&_(te instanceof Error?te.message:"经营数据加载失败")}finally{xe===F.current&&L(!1)}},Q=()=>{if(!a||!M)return null;const h=a.revenue_stats.total_amount,X=M.revenue_stats.total_amount;if(X===0)return h>0?"+100%":"0%";const pe=(h-X)/X*100;return`${pe>=0?"+":""}${pe.toFixed(1)}%`};if(l.useEffect(()=>{let h=!1;return Promise.all([cr(),Nt()]).then(([X,pe])=>{if(h)return;s(X),le(pe);const y={};pe.forEach(ce=>{y[ce.item_id]=ce.item_title||ce.item_id}),J(y)}).catch(X=>{h||_(X instanceof Error?X.message:"概览加载失败")}),()=>{h=!0}},[]),l.useEffect(()=>{j!=="custom"&&k(j)},[j]),i&&(!t||!a))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(lt,{className:"w-8 h-8"}),e.jsx("span",{children:i}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:()=>window.location.reload(),children:"重新加载"})]});if(!t||!a)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(Is,{className:"w-8 h-8 animate-spin text-brand"})});const O=((Ee=a.daily_stats)==null?void 0:Ee.map(h=>({name:h.date.slice(5),amount:h.amount,orders:h.order_count,avgAmount:h.order_count>0?(h.amount/h.order_count).toFixed(2):0})))||[],z=a.item_stats||[],R=a.revenue_stats.total_orders||0,x=a.revenue_stats.total_amount||0,b=z.length>0?z.map(h=>({name:(d[h.item_id]||h.item_id).length>12?(d[h.item_id]||h.item_id).substring(0,12)+"...":d[h.item_id]||h.item_id,sales:h.order_count})).sort((h,X)=>X.sales-h.sales).slice(0,10):[],G=Math.max(...b.map(h=>h.sales),1),v=z.length>0?z.map(h=>({name:(d[h.item_id]||h.item_id).length>10?(d[h.item_id]||h.item_id).substring(0,10)+"...":d[h.item_id]||h.item_id,value:h.order_count,percent:R>0?h.order_count/R*100:0})).sort((h,X)=>X.value-h.value).slice(0,6).map((h,X)=>({...h,color:C[X%C.length]})):[],U=z.length>0?z.map(h=>({name:(d[h.item_id]||h.item_id).length>12?(d[h.item_id]||h.item_id).substring(0,12)+"...":d[h.item_id]||h.item_id,value:h.total_amount,orderCount:h.order_count,percentage:x>0?h.total_amount/x*100:0})).sort((h,X)=>X.value-h.value).slice(0,5).map((h,X)=>({...h,color:C[X%C.length],percentage:h.percentage.toFixed(1)})):[],ne=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],ie=((Be=ne.find(h=>h.key===j))==null?void 0:Be.label)||"所选范围";let _e;try{_e=qs(j,new Date,u,g)}catch{_e={startDate:u,endDate:g}}const Ae=Z.trim().toLowerCase(),Pe=$.filter(h=>{var X,pe,y,ce;return((X=h.order_id)==null?void 0:X.toLowerCase().includes(Ae))||((pe=h.item_id)==null?void 0:pe.toLowerCase().includes(Ae))||((y=h.item_title)==null?void 0:y.toLowerCase().includes(Ae))||((ce=h.buyer_id)==null?void 0:ce.toLowerCase().includes(Ae))});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(h=>e.jsx("button",{onClick:()=>S(h.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${j===h.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:h.label},h.key)),j==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:u,onChange:h=>w(h.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:g,onChange:h=>I(h.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("button",{onClick:()=>{try{_(""),k("custom")}catch(h){_(h instanceof Error?h.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(qt,{title:"累计营收 (CNY)",value:`¥${a.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:Qa,colorClass:"bg-blue-400",trend:Q()||void 0}),e.jsx(qt,{title:"活跃账号 / 总数",value:`${t.active_cookies} / ${t.total_cookies}`,icon:xa,colorClass:"bg-blue-500"}),e.jsx(qt,{title:"订单数",value:a.revenue_stats.total_orders.toLocaleString(),icon:Os,colorClass:"bg-blue-500"}),e.jsx(qt,{title:"库存卡密余量",value:t.available_card_stock,icon:pa,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:[ie,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:O.length===0||a.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(Os,{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:"所选时间范围内暂无订单记录"})]}):O.length<=2?e.jsx(Mt,{width:"100%",height:"100%",children:e.jsxs(fl,{data:O,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Es,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:ye("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(Ds,{axisLine:!1,tickLine:!1,tick:{fill:ye("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:h=>`¥${h}`}),e.jsx(Bt,{contentStyle:{backgroundColor:ye("white"),borderRadius:"8px",border:`1px solid ${ye("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:ye("neutral-500"),fontWeight:500},itemStyle:{color:ye("brand"),fontWeight:600},cursor:{fill:ye("brand",.08)},formatter:h=>[`¥${Number(h).toFixed(2)}`,"营收"]}),e.jsx(yl,{dataKey:"amount",fill:ye("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:O.map((h,X)=>e.jsx(Zt,{fill:ye("brand"),stroke:"none",strokeWidth:0},`cell-${X}`))})]})}):e.jsx(Mt,{width:"100%",height:"100%",children:e.jsxs(jl,{data:O,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:ye("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:ye("brand"),stopOpacity:0})]})}),e.jsx(Es,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:ye("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(Ds,{axisLine:!1,tickLine:!1,tick:{fill:ye("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(Nl,{vertical:!1,stroke:ye("neutral-100"),strokeDasharray:"3 3"}),e.jsx(Bt,{contentStyle:{backgroundColor:ye("white"),borderRadius:"8px",border:`1px solid ${ye("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:ye("neutral-500"),fontWeight:500},itemStyle:{color:ye("brand"),fontWeight:600},cursor:{stroke:ye("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(_l,{type:"monotone",dataKey:"amount",stroke:ye("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:ye("white"),stroke:ye("brand"),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:b.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:b.map((h,X)=>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 ${X<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:X+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:h.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[h.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,h.sales/G*100)}%`}})})]},`${h.name}-${X}`))})})]}),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:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${R} 单`,children:v.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(Mt,{width:"100%",height:"100%",children:e.jsxs(Ms,{accessibilityLayer:!1,children:[e.jsx(Bs,{data:v,cx:"50%",cy:"45%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:96,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:v.map((h,X)=>e.jsx(Zt,{fill:h.color},`cell-${X}`))}),e.jsx(Bt,{formatter:h=>`${Number(h||0)} 单`,wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:ye("white"),border:`1px solid ${ye("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(vl,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:h=>e.jsx("span",{style:{color:ye("neutral-500"),fontWeight:500},children:h})})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9",children:[e.jsx("span",{className:"text-2xl font-extrabold text-gray-900 tabular-nums",children:R}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总订单"})]})]})})]})]}),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-surface-muted",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),ae&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",$.length," / ",V," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:Z,onChange:h=>N(h.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(Is,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):Pe.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($t,{className:"w-7 h-7 text-gray-300"})}),Ae?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:["当前共有 ",$.length," 单参与统计,但没有订单号、商品、买家匹配“",Z,"”。"]})]}):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:["日期范围:",_e.startDate," 至 ",_e.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",a.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full min-w-[760px] 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 whitespace-nowrap",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:Pe.map(h=>e.jsxs("tr",{className:"hover:bg-warning-50/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($t,{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:h.item_title||h.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:h.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",h.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:h.buyer_id}),h.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:bs(h.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",h.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(Hr,{status:h.status||h.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=${h.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(ha,{className:"w-4 h-4"})})})]},h.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)"}),U.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品金额分析,总金额 ${B(x)}`,children:[e.jsx(Mt,{width:"100%",height:"100%",children:e.jsxs(Ms,{accessibilityLayer:!1,children:[e.jsx(Bs,{data:U,cx:"50%",cy:"50%",innerRadius:60,outerRadius:92,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:98,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:U.map((h,X)=>e.jsx(Zt,{fill:h.color||C[X%C.length]},`cell-${X}`))}),e.jsx(Bt,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:ye("white"),border:`1px solid ${ye("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:h=>`¥${Number(h||0).toLocaleString()}`})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-lg font-extrabold text-gray-900 tabular-nums",children:B(x)}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总金额"})]})]}),e.jsx("div",{className:"space-y-3 mt-4",children:U.map(h=>e.jsxs("div",{className:"flex justify-between items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:h.color||C[U.indexOf(h)%C.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:h.name,children:h.name})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 whitespace-nowrap",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",h.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[h.percentage,"%"]})]})]},h.name))})]})]})]})]})},Zr=(t,s)=>t!==(s.pause_duration||0),Yr=(t,s)=>{const a=s.username!==(t.username||""),n=s.show_browser!==(t.show_browser||!1),i=s.login_password!=="",_=s.clear_password===!0;if(!a&&!n&&!i&&!_)return null;const j={username:s.username,show_browser:s.show_browser};return _?j.clear_password=!0:i&&(j.login_password=s.login_password),j},Ft=(t,s,a,n)=>t===s&&a===n,Xr=t=>t.status==="success"?{sessionId:"",status:"success",message:t.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}:t.status==="processing"||t.status==="verification_required"?{sessionId:"",status:t.status,message:t.message||(t.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:t.qr_code_url||""}:{sessionId:"",status:"failed",message:t.error||t.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""},en=(t,s)=>t&&s,tn=new Set(["expired","cancelled","error","not_found"]),ss=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:s=>s===t}},sn=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,a=null,n=-1,i=0;const _=()=>{i+=1,a==null||a.abort(),a=null,s!==null&&(t.clearInterval(s),s=null)};return{start:(S,u,w,g=2e3)=>{_();const I=i;a=new AbortController;const M=a.signal;s=t.setInterval(()=>{n===I||I!==i||(n=I,(async()=>{var H,Z;try{const N=await u(S,M);if(N.status==="success"){_(),await w.onSuccess(N);return}if(N.status==="scanned"){(H=w.onScanned)==null||H.call(w,N);return}if(N.status==="verification_required"){(Z=w.onVerificationRequired)==null||Z.call(w,N);return}N.status&&tn.has(N.status)&&(_(),w.onTerminalError(N))}catch(N){if(M.aborted||I!==i)return;_(),w.onPollError(N)}finally{n===I&&(n=-1)}})())},g)},stop:_,isActive:()=>s!==null}},an=({faceQrUrl:t,verificationScreenshot:s})=>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(Ha,{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:t?e.jsx("img",{src:t,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):s?e.jsx("img",{src:s,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(Se,{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:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Ea=({src:t,alt:s,className:a=""})=>e.jsx("img",{src:t,alt:s,className:`block aspect-square h-auto w-full object-contain ${a}`.trim()}),Qs=({checked:t,onChange:s,label:a})=>e.jsx("button",{type:"button","aria-label":a,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),ln=({account:t,onClose:s,onSaved:a})=>{const[n,i]=l.useState({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),[_,j]=l.useState(!1),[S,u]=l.useState(""),[w,g]=l.useState(""),[I,M]=l.useState(null),H=async()=>{j(!0),g("");try{const N=await Fs(t.id,n);i(N),a(N)}catch(N){g(N instanceof Error?N.message:"保存失败")}finally{j(!1)}},Z=async N=>{u(N),g(""),M(null);try{await Fs(t.id,n);const $=await Ml(t.id,N),E=await Dl(t.id);M($.summary),i(E),a(E)}catch($){g($ instanceof Error?$.message:"任务执行失败")}finally{u("")}};return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(Oe,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(Za,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(Qs,{checked:n.auto_rate_enabled,onChange:()=>i(N=>({...N,auto_rate_enabled:!N.auto_rate_enabled})),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:n.rate_content,maxLength:500,onChange:N=>i($=>({...$,rate_content:N.target.value})),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",n.last_rate_scan_at?new Date(n.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:S!==""||!t.enabled,onClick:()=>void Z("auto_rate"),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[S==="auto_rate"?e.jsx(Se,{className:"h-4 w-4 animate-spin"}):e.jsx(Ya,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(ks,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(Qs,{checked:n.auto_polish_enabled,onChange:()=>i(N=>({...N,auto_polish_enabled:!N.auto_polish_enabled})),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:n.polish_time,onChange:N=>i($=>({...$,polish_time:N.target.value})),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:S!==""||!t.enabled,onClick:()=>void Z("auto_polish"),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[S==="auto_polish"?e.jsx(Se,{className:"h-4 w-4 animate-spin"}):e.jsx(ga,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",n.last_polish_at?new Date(n.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),I&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",I.found," 项,成功 ",I.success,",失败 ",I.failed,",跳过 ",I.skipped,"。",I.message||""]}),w&&e.jsx("div",{className:"rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:w})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:s,disabled:_||S!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:()=>void H(),disabled:_||S!==""||n.auto_rate_enabled&&!n.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[_?e.jsx(Se,{className:"h-4 w-4 animate-spin"}):e.jsx(Xe,{className:"h-4 w-4"}),"保存"]})]})})]})})},rn=({account:t,editForm:s,setEditForm:a,saving:n,onClose:i,onSave:_,onRestartPause:j,longLogin:S,onToggleLongLogin:u,passwordLoginView:w,onPasswordLogin:g,onCancelPasswordLogin:I,notifChannels:M,selectedChannelIds:H,bindingsLoaded:Z,bindingsLoading:N,bindingsLoadError:$,onRetryBindings:E,onToggleChannel:V,onSettingsDirty:Y})=>{const ae=(v,U)=>{a(ne=>({...ne,[v]:U}))},se=()=>void i(),oe=()=>void _(),L=v=>ae("remark",v.target.value),ee=v=>ae("cookie",v.target.value),le=()=>ae("auto_confirm",!s.auto_confirm),d=v=>ae("pause_duration",parseInt(v.target.value,10)||0),J=()=>void j(),F=()=>void u(),C=v=>ae("username",v.target.value),B=v=>a(U=>({...U,login_password:v.target.value,clear_password:!1})),k=()=>ae("showLoginPassword",!s.showLoginPassword),Q=v=>a(U=>({...U,clear_password:v.target.checked,login_password:v.target.checked?"":U.login_password})),O=()=>ae("show_browser",!s.show_browser),z=()=>void I(),R=()=>void g(),x=()=>void E(),b=v=>{Z&&(V(v),Y())},G=v=>{const U=H.includes(Number(v.id)),ne=()=>b(Number(v.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:ne,disabled:!Z,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${U?"bg-brand border-brand":"bg-white border-gray-300"}`,children:U&&e.jsx(Qe,{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:v.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[v.type,v.enabled?"":" · 已停用"]})]})]},v.id)};return Me.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:t.nickname||t.remark||t.id})]}),e.jsx("button",{onClick:se,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Oe,{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:t.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:s.remark,onChange:L,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:s.cookie,onChange:ee,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长度: ",s.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(Qe,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:le,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.auto_confirm?"bg-brand":"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 ${s.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(ba,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:s.pause_duration,onChange:d,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:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),s.pause_duration>0&&!t.paused&&s.pause_duration===(t.pause_duration||0)&&e.jsx("button",{type:"button",disabled:n,onClick:J,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(Xa,{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:"状态直接读取并修改闲鱼官方长登录设置"}),S.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:S.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:S.loading||S.saving||!S.canOpen,onClick:F,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${S.enabled?"bg-brand":"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 ${S.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:s.username,onChange:C,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:s.showLoginPassword?"text":"password",value:s.login_password,onChange:B,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:k,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:s.showLoginPassword?e.jsx(nt,{className:"w-5 h-5"}):e.jsx(at,{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:s.clear_password,onChange:Q,className:"w-4 h-4 accent-brand"}),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,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.show_browser?"bg-brand":"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 ${s.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 和保存的登录信息。"})]}),w.status==="processing"||w.status==="verification_required"?e.jsx("button",{type:"button",onClick:z,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:R,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),w.message&&e.jsx("div",{className:`text-sm font-medium ${w.status==="failed"?"text-red-700":w.status==="success"?"text-green-700":"text-blue-800"}`,children:w.message}),w.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 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),w.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Ea,{src:w.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(M.length>0||N||$)&&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(ft,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),N&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Se,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),$&&!N&&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:$}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:x,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:M.map(G)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:se,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:n,children:"取消"}),e.jsxs("button",{onClick:oe,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:n,children:[n?e.jsx(Se,{className:"w-4 h-4 animate-spin"}):e.jsx(Qe,{className:"w-4 h-4"}),n?"保存中...":"保存"]})]})})]})}),document.body)},nn=(t,s)=>{if(!t||!s)return!1;const a=Date.parse(t),n=Date.parse(s);return Number.isFinite(a)&&Number.isFinite(n)&&nt.map(a=>{const n=s[a.id];return!n||nn(a.runtime_updated_at,n.updated_at)?a:{...a,runtime_state:n.state,runtime_message:n.message||"",runtime_connected:n.connected,runtime_updated_at:n.updated_at}}),cn=t=>{if(!t.enabled||t.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(t.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"}}},dn=(t,s)=>t.map(a=>{var n,i,_,j,S;return{...a,ai_enabled:((n=s[a.id])==null?void 0:n.ai_enabled)??!1,max_discount_percent:((i=s[a.id])==null?void 0:i.max_discount_percent)??10,max_discount_amount:((_=s[a.id])==null?void 0:_.max_discount_amount)??100,max_bargain_rounds:((j=s[a.id])==null?void 0:j.max_bargain_rounds)??3,custom_prompts:((S=s[a.id])==null?void 0:S.custom_prompts)??""}}),xn=()=>{const[t,s]=l.useState([]),[a,n]=l.useState(!0),i=l.useRef(0),_=l.useRef(null),j=l.useCallback(async()=>{var w;const S=++i.current;(w=_.current)==null||w.abort();const u=new AbortController;_.current=u,n(!0);try{const g={signal:u.signal},[I,M]=await Promise.allSettled([Tt(g),tr(g)]);if(S!==i.current)return;if(I.status==="rejected")throw I.reason;const H=M.status==="fulfilled"?M.value:{};M.status==="rejected"&&console.error("加载 AI 设置失败:",M.reason),s(dn(I.value,H))}catch(g){S===i.current&&!u.signal.aborted&&console.error("加载账号失败:",g)}finally{S===i.current&&n(!1)}},[]);return l.useEffect(()=>{let S=!1,u=null;const w=new AbortController,g=async()=>{try{const M=await hs({signal:w.signal,timeoutMs:1e4});S||s(H=>on(H,M))}catch(M){S||console.error("加载账号运行状态失败:",M)}finally{S||(u=window.setTimeout(()=>void g(),2e3))}};return j().finally(()=>{S||g()}),()=>{var M;S=!0,w.abort(),i.current+=1,(M=_.current)==null||M.abort(),u!==null&&window.clearTimeout(u)}},[j]),{accounts:t,setAccounts:s,loading:a,loadAccounts:j}},mn=()=>{const{accounts:t,setAccounts:s,loading:a,loadAccounts:n}=xn(),[i,_]=l.useState(""),[j,S]=l.useState(""),[u,w]=l.useState(""),[g,I]=l.useState(null),[M,H]=l.useState(""),[Z,N]=l.useState(!1),[$,E]=l.useState(""),[V,Y]=l.useState("pending"),[ae,se]=l.useState(""),[oe,L]=l.useState(""),[ee,le]=l.useState(""),[d,J]=l.useState(null),[F,C]=l.useState(null),[B,k]=l.useState(null),[Q,O]=l.useState(null),[z,R]=l.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[x,b]=l.useState([]),[G,v]=l.useState([]),[U,ne]=l.useState(!1),[ie,_e]=l.useState(!1),[Ae,Pe]=l.useState(!1),[Ee,Be]=l.useState(""),[h,X]=l.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),[pe,y]=l.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[ce,D]=l.useState(!1),[xe,te]=l.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),$e=l.useRef(null),Le=l.useRef(null),De=l.useRef(null),f=l.useRef(null),A=l.useRef(null),W=l.useRef(null),K=l.useRef(null),ke=l.useRef(null),je=l.useRef(null),ue=l.useRef(null),be=l.useRef(0),he=l.useRef("");$e.current===null&&($e.current=sn()),Le.current===null&&(Le.current=ss()),De.current===null&&(De.current=ss()),f.current===null&&(f.current=ss());const Te=()=>{je.current!==null&&(window.clearTimeout(je.current),je.current=null)},m=()=>{ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null)},T=()=>{var r;(r=$e.current)==null||r.stop()},me=()=>{var r,p;(r=K.current)==null||r.abort(),(p=Le.current)==null||p.cancel(),T(),Te(),N(!1)},Ne=()=>{Te(),je.current=window.setTimeout(()=>{je.current=null,N(!1),n()},1e3)};l.useEffect(()=>()=>{var r,p,P,re,fe,de,Ie;T(),(r=Le.current)==null||r.cancel(),(p=De.current)==null||p.cancel(),(P=f.current)==null||P.cancel(),(re=A.current)==null||re.abort(),(fe=W.current)==null||fe.abort(),(de=K.current)==null||de.abort(),(Ie=ke.current)==null||Ie.abort(),Te(),be.current+=1,m()},[]);const Ke=async(r,p)=>{await Jl(r,!p),n()},Ue=r=>{u||(H(""),I(r))},We=()=>{u||(H(""),I(null))},vt=async()=>{const r=g;if(!(!r||u)){w(r.id),H("");try{await Gl(r.id),s(p=>p.filter(P=>P.id!==r.id)),I(null)}catch(p){console.error("删除账号失败:",p),H((p==null?void 0:p.message)||"删除账号失败,请稍后重试")}finally{w("")}}},wt=async r=>{S(r.id);try{const p=await er(r.id);p!=null&&p.profile_error&&alert("资料刷新失败:"+p.profile_error),await n()}catch(p){console.error("刷新账号资料失败:",p),alert((p==null?void 0:p.message)||"刷新账号资料失败,请先重新授权该账号")}finally{S("")}},ot=async r=>{var de,Ie;const p=De.current.next();(de=A.current)==null||de.abort();const P=new AbortController;A.current=P,_e(!0),ne(!1),Pe(!1),Be("");const[re,fe]=await Promise.allSettled([Ta({signal:P.signal}),Wr(r,{signal:P.signal})]);(Ie=De.current)!=null&&Ie.isCurrent(p)&&(re.status==="fulfilled"?b(re.value.data||[]):(b([]),Be("通知渠道列表加载失败,请重试")),fe.status==="fulfilled"?(v(fe.value||[]),ne(!0)):(v([]),Be("通知绑定加载失败;本次保存不会修改现有绑定")),_e(!1))},ct=r=>{v(p=>p.includes(r)?p.filter(P=>P!==r):[...p,r])},kt=async r=>{var P;be.current+=1,he.current=r.id,(P=ke.current)==null||P.abort(),m(),te({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),k(r),X({remark:r.remark||r.note||"",cookie:r.cookie||r.value||"",auto_confirm:r.auto_confirm||!1,pause_duration:r.pause_duration||0,username:r.username||"",login_password:r.login_password||"",show_browser:r.show_browser||!1,showLoginPassword:!1,clear_password:!1}),C("edit"),R({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,p]=await Promise.allSettled([ot(r.id),Kl(r.id)]);p.status==="fulfilled"?R({loading:!1,saving:!1,canOpen:p.value.can_open_long_login,enabled:p.value.enabled,error:""}):R({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"})},dt=async()=>{if(!B||z.loading||z.saving||!z.canOpen)return;const r=!z.enabled;R(p=>({...p,saving:!0,error:""}));try{const p=await Hl(B.id,r);R({loading:!1,saving:!1,canOpen:p.can_open_long_login,enabled:p.enabled,error:""})}catch(p){R(P=>({...P,saving:!1,error:p instanceof Error?p.message:"保存登录信息设置失败"}))}},xt=async r=>{var re,fe,de,Ie;const p=f.current.next();(re=W.current)==null||re.abort();const P=new AbortController;W.current=P,k(r),C("ai-settings"),D(!0);try{const qe=await Mr(r.id,{signal:P.signal});if(!((fe=f.current)!=null&&fe.isCurrent(p)))return;y({ai_enabled:qe.ai_enabled??!1,max_discount_percent:qe.max_discount_percent??10,max_discount_amount:qe.max_discount_amount??100,max_bargain_rounds:qe.max_bargain_rounds??3,custom_prompts:qe.custom_prompts??""})}catch(qe){(de=f.current)!=null&&de.isCurrent(p)&&console.error("Failed to load AI settings:",qe)}finally{(Ie=f.current)!=null&&Ie.isCurrent(p)&&D(!1)}},Ze=async()=>{if(B){D(!0);try{const r={};h.remark!==(B.remark||B.note||"")&&(r.remark=h.remark),h.cookie&&h.cookie!==(B.cookie||B.value||"")&&(r.cookie=h.cookie),h.auto_confirm!==B.auto_confirm&&(r.auto_confirm=h.auto_confirm),Zr(h.pause_duration,B)&&(r.pause_duration=h.pause_duration);const p=Yr(B,h);p&&Object.assign(r,p),en(U,Ae)&&(r.channel_ids=G),Object.keys(r).length>0&&await Ql(B.id,r),C(null),n()}catch(r){console.error("更新账号失败:",r),alert("更新失败,请重试")}finally{D(!1)}}},mt=async()=>{if(!(!B||h.pause_duration<=0)){D(!0);try{const r=await Vl(B.id,h.pause_duration);k({...B,pause_duration:h.pause_duration,paused:(r==null?void 0:r.paused)===!0,paused_until:Number((r==null?void 0:r.paused_until)||0)}),await n()}catch(r){alert(r instanceof Error?r.message:"重新暂停失败")}finally{D(!1)}}},c=async()=>{if(B){D(!0);try{await Br(B.id,pe),C(null),n()}catch(r){console.error("更新AI设置失败:",r),alert("更新失败,请重试")}finally{D(!1)}}},q=async(r,p,P)=>{var fe;(fe=ke.current)==null||fe.abort();const re=new AbortController;ke.current=re;try{const de=await Yl(r,re.signal);if(!Ft(p,be.current,P,he.current))return;const Ie={...Xr(de),sessionId:r};if(de.status==="success"){m(),te(Ie),X(qe=>({...qe,login_password:"",showLoginPassword:!1})),await n();return}if(de.status==="processing"||de.status==="verification_required"){te(Ie),m(),ue.current=window.setTimeout(()=>void q(r,p,P),1500);return}m(),te(Ie)}catch(de){if(!Ft(p,be.current,P,he.current))return;m(),te({sessionId:r,status:"failed",message:de instanceof Error?de.message:"查询密码登录状态失败",qrCodeUrl:""})}},ge=async()=>{var P;if(!B)return;const r=h.username.trim();if(!r||!h.login_password){alert("请先填写登录账号和本次登录密码");return}m(),(P=ke.current)==null||P.abort();const p=++be.current;he.current=B.id,te({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const re=await Zl({account_id:B.id,account:r,password:h.login_password,show_browser:h.show_browser});if(!Ft(p,be.current,B.id,he.current))return;if(!re.success||!re.session_id)throw new Error(re.message||"无法启动密码登录");te({sessionId:re.session_id,status:"processing",message:re.message||"登录处理中",qrCodeUrl:""}),await q(re.session_id,p,B.id)}catch(re){if(!Ft(p,be.current,B.id,he.current))return;te({sessionId:"",status:"failed",message:re instanceof Error?re.message:"启动密码登录失败",qrCodeUrl:""})}},Re=async()=>{var p;const r=xe.sessionId;if(be.current+=1,he.current="",(p=ke.current)==null||p.abort(),m(),r)try{await Xl(r)}catch(P){console.error("取消密码登录失败",P)}te({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},Ge=async()=>{var r,p;(r=De.current)==null||r.cancel(),(p=A.current)==null||p.abort(),(xe.status==="processing"||xe.status==="verification_required")&&await Re(),C(null)},Fe=()=>{var r,p;(r=f.current)==null||r.cancel(),(p=W.current)==null||p.abort(),C(null)},ut=async(r,p)=>{const P=await Wl(r,p==null?void 0:p.id);if(!P.success||!P.account_id)throw new Error(P.message||"保存扫码授权失败");return P.account_id},tt=async r=>{var fe,de,Ie,qe;T(),(fe=K.current)==null||fe.abort();const p=new AbortController;K.current=p;const P=Le.current.next();Te();const re=r||null;J(re),N(!0),Y("loading"),se(""),E(""),L(""),le("");try{const ve=await zl({signal:p.signal});if(!((de=Le.current)!=null&&de.isCurrent(P)))return;if(!ve.success||!ve.qr_code_url||!ve.session_id)throw new Error(ve.message||"闲鱼未返回可用的登录二维码");if(ve.success&&ve.qr_code_url&&ve.session_id){const Et=ve.session_id;E(ve.qr_code_url),Y("waiting"),(Ie=$e.current)==null||Ie.start(Et,Ul,{onSuccess:async()=>{try{if(!await ut(Et,re)){Y("error");return}}catch(Ye){console.error("保存扫码授权失败",Ye),Y("error");return}Y("success"),Ne()},onScanned:()=>{Y("waiting")},onTerminalError:()=>{Y("error")},onPollError:Ye=>{console.error("轮询扫码状态失败",Ye),Y("error")},onVerificationRequired:Ye=>{Y("verification"),Ye.face_qr_url&&le(Ye.face_qr_url),Ye.verification_screenshot&&L(Ye.verification_screenshot)}})}}catch(ve){if(!((qe=Le.current)!=null&&qe.isCurrent(P)))return;se(ve instanceof Error?ve.message:"二维码获取失败,请稍后重试"),Y("error")}finally{K.current===p&&(K.current=null)}};if(a)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(Se,{className:"w-8 h-8 text-brand animate-spin"})});const o=t.filter(r=>{const p=i.trim().toLowerCase();return p?[r.id,r.nickname,r.remark,r.note,r.username,r.runtime_message].some(P=>(P||"").toLowerCase().includes(p)):!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:i,onChange:r=>_(r.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>tt(),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(Kt,{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:["当前显示 ",o.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[o.map(r=>{const p=cn(r),P=r.runtime_state==="auth_expired"||r.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:r.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(it,{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 ${p.dot}`,children:r.runtime_state==="online"&&e.jsx(Qe,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:r.nickname||r.remark||`账号 ${r.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${p.badge}`,children:p.label}),r.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(bt,{className:"w-3 h-3"})," AI"]}),r.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx(Ot,{className:"h-3 w-3"})," 自动评价"]}),r.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(ks,{className:"h-3 w-3"})," 每日擦亮"]}),r.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(Qe,{className:"h-3 w-3"})," 自动确认发货"]}),r.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:r.profile_error,children:[e.jsx(lt,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:r.remark||r.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",r.id]})]}),r.runtime_message&&r.runtime_state!=="online"&&r.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${P?"text-red-700":"text-amber-700"}`,children:[e.jsx(lt,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:r.runtime_message}),P&&e.jsxs("button",{type:"button",onClick:()=>tt(r),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(Kt,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),r.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(ba,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>wt(r),disabled:j===r.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(Je,{className:`w-5 h-5 ${j===r.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>tt(r),className:`p-3 rounded-xl transition-colors ${P?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(Kt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>kt(r),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(fa,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>xt(r),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(bt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>O(r),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(ga,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ke(r.id,r.enabled),className:`p-3 rounded-xl transition-colors ${r.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:r.enabled?"停用账号":"启用账号",children:e.jsx(el,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Ue(r),disabled:u!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:u===r.id?"删除中…":`删除账号 ${r.nickname||r.remark||r.id}`,children:u===r.id?e.jsx(Se,{className:"w-5 h-5 animate-spin"}):e.jsx(Ve,{className:"w-5 h-5"})})]})]})]})]})},r.id)}),t.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(it,{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:"请点击右上角扫码添加您的闲鱼账号"})]}),t.length>0&&o.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。"})]})]}),Q&&Me.createPortal(e.jsx(ln,{account:Q,onClose:()=>O(null),onSaved:r=>{s(p=>p.map(P=>P.id===Q.id?{...P,auto_rate_enabled:r.auto_rate_enabled,rate_content:r.rate_content,auto_polish_enabled:r.auto_polish_enabled,polish_time:r.polish_time,last_rate_scan_at:r.last_rate_scan_at,last_polish_date:r.last_polish_date,last_polish_at:r.last_polish_at}:P))}}),document.body),g&&Me.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-modal",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(Ve,{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:We,disabled:u!=="",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(Oe,{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:g.nickname||g.remark||"未命名账号"}),g.remark&&g.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",g.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",g.id]})]}),u===g.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(Se,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),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:"正在清理关联数据,请保持页面打开…"})]})]}),M&&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(lt,{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:M})]})]})]}),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:We,disabled:u!=="",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 vt(),disabled:u!=="",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:u===g.id?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),Z&&Me.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(Oe,{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-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${V==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[V==="loading"&&e.jsx(Se,{className:"w-10 h-10 text-brand animate-spin"}),V==="waiting"&&e.jsx(Ea,{src:$,alt:"闲鱼登录二维码",className:"p-2"}),V==="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(Qe,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),V==="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:ae||"请关闭窗口后重新发起扫码登录。"})]}),V==="verification"&&e.jsx(an,{faceQrUrl:ee,verificationScreenshot:oe})]}),V!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),F==="edit"&&B&&e.jsx(rn,{account:B,editForm:h,setEditForm:X,saving:ce,onClose:Ge,onSave:Ze,onRestartPause:mt,longLogin:z,onToggleLongLogin:dt,passwordLoginView:xe,onPasswordLogin:ge,onCancelPasswordLogin:Re,notifChannels:x,selectedChannelIds:G,bindingsLoaded:U,bindingsLoading:ie,bindingsLoadError:Ee,onRetryBindings:()=>ot(B.id),onToggleChannel:ct,onSettingsDirty:()=>Pe(!0)}),F==="ai-settings"&&B&&Me.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(bt,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:B.nickname||B.remark||B.id})]}),e.jsx("button",{onClick:Fe,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Oe,{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(bt,{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:()=>y({...pe,ai_enabled:!pe.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${pe.ai_enabled?"bg-brand":"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 ${pe.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:pe.max_discount_percent,onChange:r=>y({...pe,max_discount_percent:parseInt(r.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:pe.max_discount_amount,onChange:r=>y({...pe,max_discount_amount:parseInt(r.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:pe.max_bargain_rounds,onChange:r=>y({...pe,max_bargain_rounds:parseInt(r.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:pe.custom_prompts,onChange:r=>y({...pe,custom_prompts:r.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(_s,{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:Fe,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:ce,children:"取消"}),e.jsxs("button",{onClick:c,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:ce,children:[ce?e.jsx(Se,{className:"w-4 h-4 animate-spin"}):e.jsx(Xe,{className:"w-4 h-4"}),ce?"保存中...":"保存"]})]})})]})}),document.body)]})},un=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(s=>({order_id:String((s==null?void 0:s.order_id)||"unknown"),success:(s==null?void 0:s.success)===!0,message:String((s==null?void 0:s.message)||"")})):[]}),pn=t=>(t==null?void 0:t.results.filter(s=>!s.success))||[],Ks=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand 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"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${s[t]||s.cancelled}`,children:a[t]||t})},hn=()=>{const[t,s]=l.useState([]),[a,n]=l.useState([]),[i,_]=l.useState([]),[j,S]=l.useState({}),[u,w]=l.useState("all"),[g,I]=l.useState(""),[M,H]=l.useState(""),[Z,N]=l.useState(""),$=l.useRef(0),[E,V]=l.useState(1),[Y,ae]=l.useState(1),[se,oe]=l.useState(!1),[L,ee]=l.useState(!1),[le,d]=l.useState(!1),[J,F]=l.useState(!1),[C,B]=l.useState(null),[k,Q]=l.useState(null),[O,z]=l.useState({}),[R,x]=l.useState(!1),[b,G]=l.useState(""),[v,U]=l.useState(!1),[ne,ie]=l.useState(null),[_e,Ae]=l.useState(null),[Pe,Ee]=l.useState(null),[Be,h]=l.useState(!1),[X,pe]=l.useState(null),[y,ce]=l.useState(null),D=async()=>{const m=++$.current;oe(!0);try{const T=await sr(g||void 0,u,E,20,Z);if(m!==$.current)return;s(T.data),ae(T.total_pages)}catch(T){console.error("加载订单失败:",T)}finally{m===$.current&&oe(!1)}},xe=(m,T,me)=>{if(me&&me.trim())return me;if(j[`${m}:${T}`])return j[`${m}:${T}`];const Ne=a.find(Ke=>{if(me&&Ke.item_title){const Ue=me.toLowerCase(),We=Ke.item_title.toLowerCase();return We.includes(Ue)||Ue.includes(We)}return!1});return Ne!=null&&Ne.item_title?Ne.item_title:"未知商品"},te=m=>{const T={};m.forEach(me=>{me.item_id&&(T[`${me.cookie_id}:${me.item_id}`]=me.item_title||me.item_id)}),S(T)};l.useEffect(()=>{const m=window.setTimeout(()=>{V(1),N(M.trim())},300);return()=>window.clearTimeout(m)},[M]),l.useEffect(()=>{D()},[g,u,E,Z]),l.useEffect(()=>{Promise.all([Tt(),Nt()]).then(([m,T])=>{_(m),n(T),te(T)}).catch(m=>{console.error("加载商品列表失败:",m)})},[]);const $e=l.useMemo(()=>new Map(i.map(m=>[m.id,m])),[i]),Le=m=>{const T=$e.get(m),me=(T==null?void 0:T.remark)||(T==null?void 0:T.nickname);return me?`${me} · ${m.slice(0,6)}`:`账号 ${m.slice(0,8)}`},De=m=>{const T=$e.get(m);return(T==null?void 0:T.remark)||(T==null?void 0:T.nickname)||"未命名账号"},f=async()=>{oe(!0);try{const m=await rr(g||void 0,u);await D(),m!=null&&m.message&&alert(m.message)}catch(m){console.error("同步订单失败:",m),alert((m==null?void 0:m.message)||"同步失败,请重试")}finally{oe(!1)}},A=m=>{G(m),ie(null),x(!0)},W=async m=>{var T;U(!0),ie(null);try{const me=await ir([b],m),Ne=(T=me==null?void 0:me.results)==null?void 0:T[0];Ne!=null&&Ne.success?(ie({success:!0,message:Ne.message}),D()):ie({success:!1,message:(Ne==null?void 0:Ne.message)||"发货失败"})}catch(me){ie({success:!1,message:(me==null?void 0:me.message)||"请求失败"})}finally{U(!1)}},K=m=>{B(m),ee(!0)},ke=m=>{Q({...m}),d(!0)},je=async()=>{if(!(!k||!k.order_id))try{const m={};k.status!==void 0&&(m.order_status=k.status),k.buyer_id!==void 0&&(m.buyer_id=k.buyer_id),k.amount!==void 0&&(m.amount=k.amount),k.receiver_name!==void 0&&(m.receiver_name=k.receiver_name),k.receiver_phone!==void 0&&(m.receiver_phone=k.receiver_phone),k.receiver_address!==void 0&&(m.receiver_address=k.receiver_address),k.item_id!==void 0&&(m.item_id=k.item_id),k.quantity!==void 0&&(m.quantity=k.quantity),k.item_title!==void 0&&(m.item_title=k.item_title),await ar(k.order_id,m),d(!1),Q(null),D()}catch(m){console.error("更新订单失败:",m),alert("更新失败,请重试")}},ue=async()=>{if(_e){h(!0);try{const m=new FormData;m.append("file",_e);const T=un(await or(m));Ee(T),Ae(null),await D(),T.failed_count===0&&(F(!1),Ee(null),alert(`订单导入成功,共 ${T.success_count} 条`))}catch(m){alert((m==null?void 0:m.message)||"导入失败,请检查文件格式")}finally{h(!1)}}},be=()=>{Be||(F(!1),Ae(null),Ee(null))},he=async m=>{pe(m);try{const T=await nr(m);T.success?await D():alert(T.message||"同步失败")}catch(T){console.error("同步订单失败:",T),alert((T==null?void 0:T.message)||"同步失败,请重试")}finally{pe(null)}},Te=async m=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){ce(m);try{await lr(m),t.length===1&&E>1?V(T=>T-1):await D()}catch(T){console.error("删除订单失败:",T),alert((T==null?void 0:T.message)||"删除失败,请重试"),await D()}finally{ce(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:D,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(Je,{className:`w-5 h-5 ${se?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{Ee(null),F(!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(et,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:f,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(Rs,{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-surface-muted",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(m=>e.jsx("button",{onClick:()=>{w(m.k),V(1),H("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${u===m.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:m.v},m.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(it,{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:g,onChange:m=>{I(m.target.value),V(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:"全部账号"}),i.map(m=>e.jsx("option",{value:m.id,children:Le(m.id)},m.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(jt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:M,onChange:m=>{H(m.target.value),V(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:t.map(m=>e.jsxs("tr",{className:"hover:bg-warning-50/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:m.item_image?e.jsx("img",{src:m.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($t,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:xe(m.cookie_id,m.item_id,m.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:De(m.cookie_id),children:[e.jsx(it,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:De(m.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",m.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",m.quantity," • ",bs(m.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:m.buyer_id}),m.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:m.receiver_name})]}),m.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:m.receiver_phone})]}),m.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:m.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:m.amount?`¥${m.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Ks,{status:m.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[m.status==="pending_ship"&&e.jsx("button",{onClick:()=>A(m.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=${m.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(ha,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>K(m),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(at,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ke(m),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(yt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>he(m.order_id),disabled:X===m.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(Je,{className:`w-4 h-4 ${X===m.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>Te(m.order_id),disabled:y===m.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(Ve,{className:"w-4 h-4"})})]})]},m.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:["第 ",E," 页 / 共 ",Y," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:E<=1,onClick:()=>V(m=>m-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(ws,{className:"w-5 h-5"})}),e.jsx("button",{disabled:E>=Y,onClick:()=>V(m=>m+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(vs,{className:"w-5 h-5"})})]})]})]}),L&&C&&Me.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:()=>ee(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Oe,{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:C.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:De(C.cookie_id),children:De(C.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Ks,{status:C.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:C.amount?`¥${C.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:C.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:bs(C.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:[C.item_image&&e.jsx("img",{src:C.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:xe(C.cookie_id,C.item_id,C.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",C.item_id]}),C.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",C.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:C.buyer_id})]}),C.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:C.receiver_name})]}),C.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:C.receiver_phone})]}),C.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:C.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>ee(!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:"关闭"}),C.status==="pending_ship"&&e.jsx("button",{onClick:()=>{ee(!1),A(C.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),J&&Me.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(Oe,{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:m=>{var T;return Ae(((T=m.target.files)==null?void 0:T[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 格式"})]}),_e&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:_e.name})]})}),Pe&&Pe.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:["导入完成:成功 ",Pe.success_count," 条,失败 ",Pe.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:pn(Pe).map((m,T)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:m.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:m.message||"导入失败"})]},`${m.order_id}-${T}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:be,disabled:Be,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:ue,disabled:!_e||Be,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:Be?"正在导入…":"导入订单"})]})})]})}),document.body),R&&Me.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:()=>{x(!1),ie(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Oe,{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:()=>W("status_only"),disabled:v,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(Rs,{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:()=>W("full_delivery"),disabled:v,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand 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($t,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),v&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(Je,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),ne&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${ne.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[ne.success?"✓ ":"✗ ",ne.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{x(!1),ie(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:ne!=null&&ne.success?"完成":"取消"})})]})}),document.body),le&&k&&Me.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(Oe,{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:k.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:k.status,onChange:m=>Q({...k,status:m.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:k.buyer_id,onChange:m=>Q({...k,buyer_id:m.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:k.amount,onChange:m=>Q({...k,amount:m.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:k.receiver_name||"",onChange:m=>Q({...k,receiver_name:m.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:k.receiver_phone||"",onChange:m=>Q({...k,receiver_phone:m.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:k.receiver_address||"",onChange:m=>Q({...k,receiver_address:m.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:k.item_title||"",onChange:m=>Q({...k,item_title:m.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:()=>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:je,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},gn=({dataCards:t,downloadCardTemplate:s,...a})=>{var N;const n=$=>{var E;a.setBatchFile(((E=$.target.files)==null?void 0:E[0])||null)},i=$=>{a.setAppendContent($.target.value)},_=$=>{a.setAppendTargetId($.target.value)},j=()=>a.closeBatchModal(),S=()=>a.setBatchTab("create"),u=()=>a.setBatchTab("append"),w=()=>void a.handleRetryBatchCreate(),g=()=>void a.handleRetryBatchAppend(),I=a.batchResult&&"rows"in a.batchResult?a.batchResult:null,M=$=>e.jsxs("option",{value:String($.id),children:[$.name,"(ID: ",$.id,")"]},$.id),H=()=>void a.handleBatchCreate(),Z=()=>void a.handleBatchAppend();return a.showBatchModal?Me.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:j,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Oe,{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:S,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(tl,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:u,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${a.batchTab==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Rt,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),a.batchTab==="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:s,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(sl,{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(Rt,{className:"w-4 h-4"}),a.batchFile?a.batchFile.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:n})]})]}),((N=a.batchResult)==null?void 0:N.error)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.batchResult.error}),e.jsx("button",{type:"button",onClick:w,disabled:!a.batchFile||a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),I&&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:["共 ",I.total," 行 · 成功 ",I.created," · 失败 ",I.failed]}),I.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:I.rows.filter($=>!$.success).map($=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",$.row_no," 行「",$.name,"」:",$.error]},$.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:t.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:a.appendTargetId,onChange:_,className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:t.map(M)})]}),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:a.appendContent,onChange:i,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.jsxs("p",{className:"text-xs text-gray-500",children:["预览:",a.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),a.appendError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.appendError}),e.jsx("button",{type:"button",onClick:g,disabled:a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),a.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",a.appendResult.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:j,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),a.batchTab==="create"?e.jsxs("button",{onClick:H,disabled:!a.batchFile||a.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(Se,{className:"w-4 h-4 animate-spin"}):e.jsx(Rt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:Z,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||t.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(Se,{className:"w-4 h-4 animate-spin"}):e.jsx(et,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},bn=({type:t})=>{switch(t){case"text":return e.jsx(ja,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(ya,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(al,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Ns,{className:"w-5 h-5 text-gray-500"})}},fn=(t,s,a)=>{const n=a.trim().toLocaleLowerCase();return t.filter(i=>(!s||i.type===s)&&(!n||i.name.toLocaleLowerCase().includes(n)))},Da=t=>t.split(` -`).map(s=>s.trim()).filter(Boolean),yn=(t,s,a)=>!!(t&&Da(s).length>0&&!a),ht=(t,s,a,n)=>t===s&&a===n,jn=()=>{const[t,s]=l.useState([]),[a,n]=l.useState(!0),i=l.useRef(0),_=l.useRef(null),j=l.useCallback(async()=>{var w;const S=++i.current;(w=_.current)==null||w.abort();const u=new AbortController;_.current=u,n(!0);try{const g=await Ss({signal:u.signal});if(S!==i.current)return;s(g)}catch(g){S===i.current&&!u.signal.aborted&&console.error("加载卡密库存失败:",g)}finally{S===i.current&&n(!1)}},[]);return l.useEffect(()=>(j(),()=>{var u;i.current+=1,(u=_.current)==null||u.abort()}),[j]),{cards:t,setCards:s,loading:a,loadCards:j}},Nn=t=>{const s=t.dataCards,a=t.loadCards,[n,i]=l.useState(!1),[_,j]=l.useState("create"),[S,u]=l.useState(null),[w,g]=l.useState(null),[I,M]=l.useState(!1),[H,Z]=l.useState(""),[N,$]=l.useState(""),[E,V]=l.useState(null),[Y,ae]=l.useState(""),se=l.useRef(0),oe=l.useRef(null),L=l.useRef(""),ee=l.useMemo(()=>Da(N),[N]),le=l.useCallback(()=>{var k;j("create"),u(null),g(null),Z((k=s[0])!=null&&k.id?String(s[0].id):""),$(""),V(null),ae(""),i(!0)},[s]),d=l.useCallback(()=>{var k;se.current+=1,(k=oe.current)==null||k.abort(),M(!1),i(!1)},[]),J=l.useCallback(async()=>{var O;if(!S||I)return;const k=++se.current;(O=oe.current)==null||O.abort();const Q=new AbortController;oe.current=Q,M(!0),g(null);try{const z=await pr(S,{signal:Q.signal});if(!ht(k,se.current,"",""))return;g(z),z.created>0&&await a()}catch(z){if(!ht(k,se.current,"",""))return;g({error:(z==null?void 0:z.message)||"上传失败"})}finally{ht(k,se.current,"","")&&M(!1)}},[I,S,a]),F=l.useCallback(async()=>{var z;if(!yn(H,N,I))return;const k=H,Q=++se.current;L.current=k,(z=oe.current)==null||z.abort();const O=new AbortController;oe.current=O,M(!0),V(null),ae("");try{const R=await hr(k,N,{signal:O.signal});if(!ht(Q,se.current,k,H))return;V({added:R.added}),$(""),await a()}catch(R){if(!ht(Q,se.current,k,H))return;ae((R==null?void 0:R.message)||"追加失败")}finally{ht(Q,se.current,k,H)&&M(!1)}},[N,H,I,a]),C=l.useCallback(async()=>{await J()},[J]),B=l.useCallback(async()=>{L.current&&H!==L.current||await F()},[H,F]);return{showBatchModal:n,setShowBatchModal:i,batchTab:_,setBatchTab:j,batchFile:S,setBatchFile:u,batchResult:w,batchBusy:I,appendTargetId:H,setAppendTargetId:Z,appendContent:N,setAppendContent:$,appendResult:E,appendError:Y,appendPreview:ee,openBatchModal:le,closeBatchModal:d,handleBatchCreate:J,handleBatchAppend:F,handleRetryBatchCreate:C,handleRetryBatchAppend:B}},Hs=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),_n=()=>{const{cards:t,loadCards:s}=jn(),[a,n]=l.useState(!1),[i,_]=l.useState(!1),[j,S]=l.useState(null),[u,w]=l.useState({}),[g,I]=l.useState(Hs),[M,H]=l.useState(""),[Z,N]=l.useState(""),$=l.useMemo(()=>t.filter(d=>d.type==="data"),[t]),E=Nn({dataCards:$,loadCards:s}),V=d=>{var J,F,C,B,k;S(d),w({id:d.id,name:d.name||"",type:d.type||"text",api_url:((J=d.api_config)==null?void 0:J.url)||"",api_method:((F=d.api_config)==null?void 0:F.method)||"GET",api_timeout:((C=d.api_config)==null?void 0:C.timeout)||10,api_headers:((B=d.api_config)==null?void 0:B.headers)||"",api_params:((k=d.api_config)==null?void 0:k.params)||"",text_content:d.text_content||"",data_content:d.data_content||"",image_url:d.image_url||"",delay_seconds:d.delay_seconds||0,description:d.description||"",enabled:d.enabled}),n(!0)},Y=async()=>{var d,J,F,C,B,k,Q,O;if(j){if(!((d=u.name)!=null&&d.trim())){alert("请输入卡密名称");return}if(!u.type){alert("请选择卡密类型");return}try{const z={name:u.name.trim(),type:u.type,description:(J=u.description)==null?void 0:J.trim(),delay_seconds:u.delay_seconds||0,enabled:u.enabled??!0};u.type==="api"?z.api_config={url:((F=u.api_url)==null?void 0:F.trim())||"",method:u.api_method,timeout:u.api_timeout||10,headers:((C=u.api_headers)==null?void 0:C.trim())||void 0,params:((B=u.api_params)==null?void 0:B.trim())||void 0}:u.type==="text"?z.text_content=((k=u.text_content)==null?void 0:k.trim())||"":u.type==="data"?z.data_content=((Q=u.data_content)==null?void 0:Q.trim())||"":u.type==="image"&&(z.image_url=((O=u.image_url)==null?void 0:O.trim())||""),await Ws(j.id,z),n(!1),await s()}catch(z){console.error("更新卡密失败:",z),alert("更新失败,请重试")}}},ae=async d=>{if(confirm("确认删除该卡密吗?"))try{await ur(d),await s()}catch(J){console.error("删除卡密失败:",J),alert("删除失败,请重试")}},se=async()=>{if(!g.name.trim()){alert("请输入卡密名称");return}if(!g.content.trim()){alert(g.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const d={name:g.name.trim(),type:g.type,description:g.description.trim(),enabled:g.enabled,delay_seconds:g.delay_seconds};g.type==="text"&&(d.text_content=g.content.trim()),g.type==="data"&&(d.data_content=g.content.trim()),g.type==="image"&&(d.image_url=g.content.trim()),g.type==="api"&&(d.api_config={url:g.content.trim(),method:g.api_method,timeout:g.api_timeout,headers:g.api_headers.trim()||void 0,params:g.api_params.trim()||void 0}),await mr(d),_(!1),I(Hs()),await s()}catch(d){console.error("添加卡密失败:",d),alert("添加失败,请重试")}},oe=async d=>{try{await Ws(d.id,{...d,enabled:!d.enabled}),await s()}catch(J){console.error("切换状态失败:",J)}},L=async d=>{try{await navigator.clipboard.writeText(String(d)),alert(`已复制卡密组ID:${d}`)}catch{prompt("复制卡密组ID",String(d))}},ee=l.useMemo(()=>fn(t,M,Z),[t,Z,M]),le=()=>{const F=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["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(O=>`"${String(O).replace(/"/g,'""')}"`).join(",")).join(` -`),C=new Blob(["\uFEFF"+F],{type:"text/csv;charset=utf-8"}),B=URL.createObjectURL(C),k=document.createElement("a");k.href=B,k.download="卡密组批量导入模板.csv",document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(B)};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:E.openBatchModal,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(Rt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>_(!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(et,{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-surface-muted 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(Na,{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:M,onChange:d=>H(d.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(jt,{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:d=>N(d.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:["显示 ",ee.length," / ",t.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:ee.map(d=>{let J="";return d.type==="data"&&d.data_content?J=`库存: ${d.data_content.split(` -`).filter(C=>C.trim()).length} 条`:d.type==="text"&&d.text_content?J=d.text_content:d.type==="api"&&d.api_config?J=d.api_config.url:d.type==="image"&&d.image_url&&(J="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/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(bn,{type:d.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:d.name,children:d.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>L(d.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:d.id}),e.jsx(ll,{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 ${d.type==="text"?"bg-blue-50 text-blue-600":d.type==="data"?"bg-purple-50 text-purple-600":d.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:d.type==="text"?"文本":d.type==="data"?"批量":d.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:J,children:J})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:d.description||"-",children:d.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>oe(d),className:`w-12 h-8 rounded-full relative transition-colors ${d.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 ${d.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:()=>V(d),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(yt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ae(d.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Ve,{className:"h-4 w-4"})})]})})]},d.id)})})]})}),ee.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(pa,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),a&&j&&Me.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:()=>n(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Oe,{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:u.name||"",onChange:d=>w({...u,name:d.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:u.type||"text",onChange:d=>w({...u,type:d.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:"批量数据"}),(j==null?void 0:j.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),u.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:u.api_url||"",onChange:d=>w({...u,api_url:d.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:u.api_method||"GET",onChange:d=>w({...u,api_method:d.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:u.api_timeout||10,onChange:d=>w({...u,api_timeout:parseInt(d.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:u.api_headers||"",onChange:d=>w({...u,api_headers:d.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:u.api_params||"",onChange:d=>w({...u,api_params:d.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}'})]})]}),u.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:u.text_content||"",onChange:d=>w({...u,text_content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),u.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:u.data_content||"",onChange:d=>w({...u,data_content:d.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:u.data_content?u.data_content.split(` -`).filter(d=>d.trim()).length:0})," 条"]})]})]}),u.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:u.image_url||"",onChange:d=>w({...u,image_url:d.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 地址"})]}),u.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:u.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:d=>{d.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:u.delay_seconds||0,onChange:d=>w({...u,delay_seconds:parseInt(d.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:u.description||"",onChange:d=>w({...u,description:d.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:()=>w({...u,enabled:!u.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${u.enabled?"bg-brand":"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 ${u.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:()=>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:Y,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),i&&Me.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:()=>_(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Oe,{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:g.name,onChange:d=>I({...g,name:d.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:()=>I({...g,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${g.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Ns,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>I({...g,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${g.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(ja,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>I({...g,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${g.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(ya,{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:g.type==="data"?"库存内容(一行一个)":g.type==="text"?"固定回复内容":g.type==="image"?"图片 URL":"API 地址"}),g.type==="api"?e.jsx("input",{type:"url",value:g.content,onChange:d=>I({...g,content:d.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):g.type==="image"?e.jsx("input",{type:"url",value:g.content,onChange:d=>I({...g,content:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:g.content,onChange:d=>I({...g,content:d.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${g.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:g.type==="data"?`CODE-123456 -CODE-789012 -...`:"请输入每次发货时发送的固定文字"}),g.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:g.content.split(` -`).filter(d=>d.trim()).length})," 条"]})]}),g.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:g.api_method,onChange:d=>I({...g,api_method:d.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:g.api_timeout,onChange:d=>I({...g,api_timeout:parseInt(d.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:g.api_headers,onChange:d=>I({...g,api_headers:d.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:g.api_params,onChange:d=>I({...g,api_params:d.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:g.description,onChange:d=>I({...g,description:d.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:g.delay_seconds,onChange:d=>I({...g,delay_seconds:parseInt(d.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:()=>_(!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:se,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(gn,{dataCards:$,downloadCardTemplate:le,...E})]})},Zs="ydisks-amap-js-api",vn="c9b68d4ce9a2a97f22a4a439404488ca";let St=null;const wn=()=>vn,kn=()=>window.AMap?Promise.resolve(window.AMap):St||(St=new Promise((t,s)=>{const a=document.getElementById(Zs),n=a||document.createElement("script"),i=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(j)},_=()=>{window.AMap?(i(),t(window.AMap)):(i(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},j=window.setTimeout(()=>{i(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=_,n.id=Zs,n.async=!0,n.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(wn())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,n.onerror=()=>{i(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},a||document.head.appendChild(n)}).catch(t=>{throw St=null,t}),St),Gt=t=>Number.isFinite(t)&&t!==0,Cn=t=>{var i,_;const s=Number((i=t.location)==null?void 0:i.lng),a=Number((_=t.location)==null?void 0:_.lat),n={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:a,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!n.division_id||!n.province||!n.city||!n.poi_id||!n.poi_name||!Gt(s)||!Gt(a)||s<-180||s>180||a<-90||a>90?null:n},Sn=async(t,s)=>{if(!Gt(t)||!Gt(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const a=await kn();return new Promise((n,i)=>{new a.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(j,S)=>{var w;if(j!=="complete"){if(j==="no_data"){n([]);return}i(new Error("高德地图附近地址查询失败,请稍后重试"));return}const u=(((w=S==null?void 0:S.poiList)==null?void 0:w.pois)||[]).map(Cn).filter(g=>g!==null);n(u)})})},Ln=t=>t.find(s=>s.status==="running"||s.status==="canceling"),fs=t=>t==="running"||t==="canceling",An=t=>!!(t!=null&&t.preview_id&&Number(t.valid||0)>0),In=t=>!!(t!=null&&t.id&&Number(t.retryable||0)>0&&!fs(t.status)),On=(t,s)=>t===s,Ys=t=>{switch(t){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 t||"-"}},Xs=t=>{switch(t){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"}},Rn=t=>{const[s,a]=l.useState(!1),[n,i]=l.useState("upload"),[_,j]=l.useState(null),[S,u]=l.useState(null),[w,g]=l.useState(""),[I,M]=l.useState(!1),[H,Z]=l.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[N,$]=l.useState(null),[E,V]=l.useState(null),[Y,ae]=l.useState(null),[se,oe]=l.useState([]),[L,ee]=l.useState(null),[le,d]=l.useState(!1),J=l.useRef(!1),F=l.useRef(0),C=l.useCallback(async()=>{i("upload"),$(null),V(null),j(null),u(null),g(""),Z({catId:"",catName:"",channelCatId:"",tbCatId:""}),oe([]),ee(null),a(!0),d(!0);try{const v=await Ia(20),U=Ln(v);if(U!=null&&U.id){const ne=await pt(U.id);ae(ne),V(ne),i(["running","canceling"].includes(ne.status)?"running":"done")}}catch(v){console.error("恢复最近批量铺货任务失败:",v)}finally{d(!1)}},[]),B=l.useCallback(async()=>{const v=w.trim();if(!t.selectedAccount){alert("请先选择默认发布账号");return}if(!v){alert("请输入类目关键词");return}M(!0);try{const ne=(await jr(t.selectedAccount,v)).category;Z({catId:ne.cat_id,catName:ne.cat_name,channelCatId:ne.channel_cat_id,tbCatId:ne.tb_cat_id||""})}catch(U){console.error("获取推荐类目失败:",U),alert((U==null?void 0:U.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{M(!1)}},[w,t.selectedAccount]),k=l.useCallback(async()=>{if(Y!=null&&Y.id){d(!0),a(!0);try{const v=await pt(Y.id);V(v),i(["running","canceling"].includes(v.status)?"running":"done")}catch(v){console.error("加载最近批量铺货结果失败:",v)}finally{d(!1)}}},[Y==null?void 0:Y.id]),Q=l.useCallback(async()=>{if(!_){alert("请先上传商品表格");return}if(!t.selectedAccount){alert("请先选择默认发布账号");return}d(!0);try{const v=await Nr({file:_,imagesZip:S,defaultCookieId:t.selectedAccount,fallbackCategory:H,location:L||void 0});$(v),V(null),i("preview")}catch(v){console.error("批量铺货预检失败:",v),alert((v==null?void 0:v.message)||"预检失败,请检查表格和图片 zip")}finally{d(!1)}},[H,_,S,L,t.selectedAccount]),O=l.useCallback(async()=>{if(N!=null&&N.preview_id){if(!An(N)){alert("没有可发布的商品行");return}d(!0);try{const v=await _r(N.preview_id),U=await pt(v.batch_id||N.preview_id);V(U),ae(U),i(U.status==="running"?"running":"done")}catch(v){console.error("启动批量铺货失败:",v),alert((v==null?void 0:v.message)||"启动发布任务失败")}finally{d(!1)}}},[N]),z=l.useCallback(async()=>{if(E!=null&&E.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){d(!0);try{const v=await wr(E.id),U=await pt(E.id);V(U),i((v==null?void 0:v.status)==="canceling"||U.status==="canceling"?"running":"done")}catch(v){alert((v==null?void 0:v.message)||"取消失败")}finally{d(!1)}}},[E==null?void 0:E.id]),R=l.useCallback(async()=>{const v=N==null?void 0:N.preview_id;if(v&&n==="preview")try{await vr(v)}catch(U){console.error("清理批量铺货预检失败:",U)}$(null),i("upload")},[n,N==null?void 0:N.preview_id]),x=l.useCallback(async()=>{await R(),a(!1)},[R]),b=l.useCallback(async()=>{if(!(!(E!=null&&E.id)||!In(E))){d(!0);try{await kr(E.id),V(await pt(E.id)),i("running")}catch(v){alert((v==null?void 0:v.message)||"重试失败")}finally{d(!1)}}},[E==null?void 0:E.id]);return l.useEffect(()=>{if(!s||!(E!=null&&E.id)||!fs(E.status))return;const v=++F.current,U=async()=>{if(!J.current){J.current=!0;try{const ie=await pt(E.id);if(!On(v,F.current))return;V(ie),ae(ie),fs(ie.status)||(i("done"),await Promise.all([t.loadItems(),t.loadShippingRules()]))}catch(ie){console.error("刷新批量铺货进度失败:",ie)}finally{J.current=!1}}},ne=window.setInterval(()=>void U(),3e3);return(()=>{window.clearInterval(ne),F.current+=1})},[E==null?void 0:E.id,E==null?void 0:E.status,t.loadItems,t.loadShippingRules,s]),{showBatchModal:s,setShowBatchModal:a,batchLoading:le,batchPhase:n,setBatchPhase:i,batchFile:_,setBatchFile:j,batchImagesZip:S,setBatchImagesZip:u,batchCategoryKeyword:w,setBatchCategoryKeyword:g,batchCategoryLoading:I,batchFallbackCategory:H,setBatchFallbackCategory:Z,batchPreview:N,setBatchPreview:$,batchDetail:E,setBatchDetail:V,recentBatch:Y,setRecentBatch:ae,batchLocations:se,batchLocation:L,setBatchLocations:oe,setBatchLocation:ee,openBatchModal:C,handleRecommendBatchCategory:B,openRecentBatchResult:k,handlePreviewBatch:Q,handleStartBatch:O,handleCancelBatch:z,abandonBatchPreview:R,closeBatchModal:x,handleRetryBatchFailed:b}},Pn=({phase:t})=>{const s=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:s.map(([a,n])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${t===a?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:n},a))})},$n=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s:`¥${s}`:"-"},Tn=({onConfigureDelivery:t})=>{const[s,a]=l.useState([]),[n,i]=l.useState([]),[_,j]=l.useState([]),[S,u]=l.useState(""),[w,g]=l.useState(""),[I,M]=l.useState(!1),[H,Z]=l.useState(!1),[N,$]=l.useState(!1),[E,V]=l.useState(!1),[Y,ae]=l.useState(!1),[se,oe]=l.useState(!1),[L,ee]=l.useState([]),[le,d]=l.useState(null),[J,F]=l.useState(null),[C,B]=l.useState({}),[k,Q]=l.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[O,z]=l.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[R,x]=l.useState([]),b=l.useCallback(async()=>{const c=await Nt();a(c)},[]),G=l.useCallback(async()=>{i(await gs())},[]),v=Rn({selectedAccount:S,loadItems:b,loadShippingRules:G}),{showBatchModal:U,setShowBatchModal:ne,batchLoading:ie,batchPhase:_e,batchFile:Ae,setBatchFile:Pe,batchImagesZip:Ee,setBatchImagesZip:Be,batchCategoryKeyword:h,setBatchCategoryKeyword:X,batchCategoryLoading:pe,batchFallbackCategory:y,setBatchFallbackCategory:ce,batchPreview:D,batchDetail:xe,recentBatch:te,setRecentBatch:$e,batchLocations:Le,batchLocation:De,setBatchLocations:f,setBatchLocation:A,openBatchModal:W,handleRecommendBatchCategory:K,openRecentBatchResult:ke,handlePreviewBatch:je,handleStartBatch:ue,handleCancelBatch:be,abandonBatchPreview:he,closeBatchModal:Te,handleRetryBatchFailed:m}=v;l.useEffect(()=>{if(!Y||O.images.length===0){x([]);return}const c=O.images.map((q,ge)=>({key:q.name+ge,url:URL.createObjectURL(q)}));return x(c),()=>{c.forEach(q=>URL.revokeObjectURL(q.url))}},[Y,O.images]),l.useEffect(()=>{Promise.all([Tt(),Nt(),gs(),Ia(20)]).then(([c,q,ge,Re])=>{j(c),a(q),i(ge);const Ge=Re.find(Fe=>["running","canceling"].includes(Fe.status))||Re.find(Fe=>Fe.status!=="preview");$e(Ge||null)}).catch(c=>console.error("加载商品配置失败:",c))},[]);const T=async()=>{if(!S)return alert("请先选择账号");M(!0);try{const c=await gr(S);await b(),alert((c==null?void 0:c.message)||"商品同步完成")}catch(c){console.error("同步商品失败:",c),alert((c==null?void 0:c.message)||"同步失败,请重试")}finally{M(!1)}},me=c=>{F(c),B({...c}),$(!0)},Ne=async()=>{if(J)try{await Cr(J.cookie_id,J.item_id,{item_title:C.item_title||"",item_description:C.item_description||"",item_category:C.item_category||"",item_price:C.item_price||"",item_detail:C.item_detail||J.item_detail||""}),await b(),await G(),$(!1),F(null)}catch(c){console.error("更新商品失败:",c),alert("更新失败,请重试")}},Ke=async c=>{if(confirm(`确认删除商品"${c.item_title}"吗?`))try{await br(c.cookie_id,c.item_id),a(q=>q.filter(ge=>!(ge.cookie_id===c.cookie_id&&ge.item_id===c.item_id)))}catch(q){console.error("删除商品失败:",q),alert("删除失败,请重试")}},Ue=async()=>{try{if(!k.cookie_id||!k.item_id){alert("请选择账号并填写商品ID");return}await fr(k.cookie_id,{item_id:k.item_id,item_title:k.item_title,item_price:k.item_price,item_detail:k.item_image?JSON.stringify({item_image:k.item_image}):""}),await b(),V(!1),Q({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(c){console.error("添加商品失败:",c),alert("添加失败,请重试")}},We=async()=>{if(!O.cookie_id)return alert("请选择发布账号");if(!O.title.trim())return alert("请填写商品标题");if(!O.price.trim())return alert("请填写商品价格");if(!O.quantity||Number(O.quantity)<=0)return alert("库存数量必须大于 0");if(O.images.length===0)return alert("至少上传 1 张商品图片");if(O.postage_mode==="fixed"&&!O.postage.trim())return alert("请填写一口价邮费");Z(!0);try{const c=await yr({...O,location:le||void 0});if(await b(),ae(!1),z({cookie_id:S||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),ee([]),d(null),c!=null&&c.item_id){const q={id:c.item_id,cookie_id:O.cookie_id,item_id:c.item_id,item_title:c.item_title||O.title,item_price:c.item_price||O.price,item_image:c.item_image};t(q),alert("商品发布成功,ID: "+c.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(c){console.error("发布商品失败:",c);const q=c==null?void 0:c.payload;if((q==null?void 0:q.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((c==null?void 0:c.message)||"发布失败,请重试")}finally{Z(!1)}},vt=()=>{const ge=[["账号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(ut=>ut.map(tt=>`"${String(tt).replace(/"/g,'""')}"`).join(",")).join(` -`),Re=new Blob(["\uFEFF"+ge],{type:"text/csv;charset=utf-8"}),Ge=URL.createObjectURL(Re),Fe=document.createElement("a");Fe.href=Ge,Fe.download="批量铺货模板.csv",document.body.appendChild(Fe),Fe.click(),Fe.remove(),URL.revokeObjectURL(Ge)},wt=()=>{Q(c=>({...c,cookie_id:S||c.cookie_id})),V(!0)},ot=()=>{z(c=>({...c,cookie_id:S||c.cookie_id})),ae(!0)},ct=async c=>{if(!(c?S:O.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");oe(!0),navigator.geolocation.getCurrentPosition(async ge=>{try{const Re=await Sn(ge.coords.longitude,ge.coords.latitude);if(!Re.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");c?(f(Re),A(Re[0])):(ee(Re),d(Re[0]))}catch(Re){alert((Re==null?void 0:Re.message)||"获取发货地失败")}finally{oe(!1)}},ge=>{oe(!1),alert(ge.code===ge.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},kt=c=>n.filter(q=>q.cookie_id===c.cookie_id&&q.item_id===c.item_id).length>0?n.filter(q=>q.cookie_id===c.cookie_id&&q.item_id===c.item_id):n.filter(q=>q.cookie_id===c.cookie_id&&!q.item_id),dt=l.useMemo(()=>new Map(_.map(c=>[c.id,c])),[_]),xt=l.useMemo(()=>w?s.filter(c=>c.cookie_id===w):s,[w,s]),Ze=c=>{const q=dt.get(c),ge=(q==null?void 0:q.remark)||(q==null?void 0:q.nickname);return ge?`${ge} · ${c.slice(0,6)}`:`账号 ${c.slice(0,8)}`},mt=c=>{const q=dt.get(c);return(q==null?void 0:q.remark)||(q==null?void 0:q.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(rl,{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:w,onChange:c=>g(c.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),_.map(c=>e.jsx("option",{value:c.id,children:Ze(c.id)},c.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(it,{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:S,onChange:c=>u(c.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),_.map(c=>e.jsx("option",{value:c.id,children:Ze(c.id)},c.id))]})]})]}),e.jsxs("button",{onClick:T,disabled:I||!S,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(Je,{className:`w-4 h-4 ${I?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:wt,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(et,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:ot,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Ht,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void W(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Dt,{className:"w-4 h-4"}),te&&["running","canceling"].includes(te.status)?"继续批量任务":"批量铺货"]}),te&&!["running","canceling"].includes(te.status)&&e.jsx("button",{onClick:()=>void ke(),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:[xt.map(c=>{const q=kt(c),ge=q.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:()=>me(c),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(yt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>Ke(c),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(Ve,{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:[c.item_image?e.jsx("img",{src:c.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(ma,{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:$n(c.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:c.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:mt(c.cookie_id),children:[e.jsx(it,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:mt(c.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: ",c.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${ge?"text-emerald-600":"text-amber-600"}`,children:[ge?e.jsx(ds,{className:"w-3 h-3"}):e.jsx(nl,{className:"w-3 h-3"}),ge?`${q.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>t(c),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${ge?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(il,{className:"w-3.5 h-3.5"}),ge?"查看发货规则":"关联发货规则"]}),e.jsx(xs,{className:"w-3.5 h-3.5"})]})})]},`${c.cookie_id}-${c.item_id}`)}),xt.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(ua,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),w?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),N&&J&&Me.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: ",J.item_id]})]}),e.jsx("button",{onClick:()=>$(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Oe,{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:C.item_title||"",onChange:c=>B({...C,item_title:c.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:C.item_price||"",onChange:c=>B({...C,item_price:c.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:C.item_category||"",onChange:c=>B({...C,item_category:c.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:C.item_description||"",onChange:c=>B({...C,item_description:c.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:Ne,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),E&&Me.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:()=>V(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Oe,{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:k.cookie_id,onChange:c=>Q({...k,cookie_id:c.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),_.map(c=>e.jsx("option",{value:c.id,children:Ze(c.id)},c.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:k.item_id,onChange:c=>Q({...k,item_id:c.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:k.item_price,onChange:c=>Q({...k,item_price:c.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:k.item_title,onChange:c=>Q({...k,item_title:c.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:k.item_image,onChange:c=>Q({...k,item_image:c.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:Ue,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(et,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),Y&&Me.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:()=>ae(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Oe,{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:O.cookie_id,onChange:c=>{z({...O,cookie_id:c.target.value}),ee([]),d(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),_.map(c=>e.jsx("option",{value:c.id,children:Ze(c.id)},c.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:O.title,onChange:c=>z({...O,title:c.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:O.quantity,onChange:c=>z({...O,quantity:c.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:O.description,onChange:c=>z({...O,description:c.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:O.price,onChange:c=>z({...O,price:c.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:O.original_price,onChange:c=>z({...O,original_price:c.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:O.postage_mode,onChange:c=>z({...O,postage_mode:c.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:"无需邮寄"})]})]})]}),O.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:O.postage,onChange:c=>z({...O,postage:c.target.value})})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:se||!O.cookie_id,onClick:()=>void ct(!1),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Ps,{className:"h-4 w-4"}),se?"定位中...":"获取当前位置"]})]}),L.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,L.indexOf(le))),onChange:c=>d(L[Number(c.target.value)]||null),children:L.map((c,q)=>e.jsx("option",{value:String(q),children:[c.province,c.city,c.area,c.poi_name].filter(Boolean).join(" ")},`${c.division_id}-${c.poi_id}-${q}`))})]}),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(Dt,{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:O.images.length?"已选择 "+O.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:c=>z({...O,images:Array.from(c.target.files||[]).slice(0,9)})})]}),R.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:R.map(c=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:c.url,alt:"",className:"w-full h-full object-cover"})},c.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:H,onClick:We,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ht,{className:"w-4 h-4"}),H?"正在发布...":"发布到闲鱼"]})})]})}),document.body),U&&Me.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 Te(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(Pn,{phase:_e}),_e==="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:vt,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:S,onChange:c=>{u(c.target.value),f([]),A(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),_.map(c=>e.jsx("option",{value:c.id,children:Ze(c.id)},c.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(jt,{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:h,onChange:c=>X(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),K())}})]}),e.jsxs("button",{type:"button",disabled:!S||!h.trim()||pe,onClick:()=>void K(),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(jt,{className:"h-4 w-4"}),pe?"匹配中...":"获取类目"]})]}),y.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(ds,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:y.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",y.catId," · 频道 ",y.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>ce({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(Oe,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:se||!S,onClick:()=>void ct(!0),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Ps,{className:"h-4 w-4"}),se?"定位中...":"获取当前位置"]})]}),Le.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,Le.indexOf(De))),onChange:c=>A(Le[Number(c.target.value)]||null),children:Le.map((c,q)=>e.jsx("option",{value:String(q),children:[c.province,c.city,c.area,c.poi_name].filter(Boolean).join(" ")},`${c.division_id}-${c.poi_id}-${q}`))})]}),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(Dt,{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:Ae?Ae.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:c=>{var q;return Pe(((q=c.target.files)==null?void 0:q[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(Dt,{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:Ee?Ee.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:c=>{var q;return Be(((q=c.target.files)==null?void 0:q[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(([c,q,ge])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:c}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${q==="每个商品都要填"?"text-red-600":q==="可以留空"?"text-gray-500":"text-amber-700"}`,children:q}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:ge})]},c))})]})})]})]}),_e==="preview"&&D&&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:D.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:D.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:D.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:D.rows.map(c=>{var q,ge,Re,Ge;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:c.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 ${c.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:c.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:c.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",c.price||"-"," / ",c.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:((q=c.category)==null?void 0:q.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((ge=c.category)==null?void 0:ge.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Re=c.images)==null?void 0:Re.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((Ge=c.errors)==null?void 0:Ge.join(";"))||"-"})]},c.row_no)})})]})})]}),(_e==="running"||_e==="done")&&xe&&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 ${Xs(xe.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:Ys(xe.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:xe.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:xe.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:xe.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:xe.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:xe.rows.map(c=>{var q,ge;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:c.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 ${Xs(c.status)}`,children:Ys(c.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:c.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:((q=c.category)==null?void 0:q.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((ge=c.category)==null?void 0:ge.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:c.item_url?e.jsx("a",{href:c.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:c.item_id}):c.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:c.error_message||"-"})]},c.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[_e==="upload"&&e.jsxs("button",{disabled:ie||!Ae||!S,onClick:je,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(Je,{className:`w-4 h-4 ${ie?"animate-spin":""}`}),ie?"正在预检...":"开始预检"]}),_e==="preview"&&D&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:ie,onClick:()=>void he(),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:ie||D.valid<=0,onClick:ue,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(Ht,{className:"w-4 h-4"}),ie?"启动中...":`确认发布 ${D.valid} 个商品`]})]}),(_e==="running"||_e==="done")&&xe&&e.jsxs("div",{className:"flex gap-3 w-full",children:[xe.status==="running"?e.jsx("button",{disabled:ie,onClick:be,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):xe.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(`/api/v1/items/publish-batches/${xe.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:"下载结果"}),xe.retryable>0&&!["running","canceling"].includes(xe.status)&&e.jsxs("button",{disabled:ie,onClick:m,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(Je,{className:`w-4 h-4 ${ie?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(xe.status)&&e.jsx("button",{onClick:()=>{ne(!1),b(),G()},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)]})},ea="https://dashscope.aliyuncs.com/compatible-mode/v1",En=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],Dn=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"]),Mn=()=>{const[t,s]=l.useState(null),[a,n]=l.useState(!1),[i,_]=l.useState(""),[j,S]=l.useState(!1),[u,w]=l.useState([]),[g,I]=l.useState(!1),[M,H]=l.useState(""),[Z,N]=l.useState(!1),$=l.useRef(null),[E,V]=l.useState(!1),[Y,ae]=l.useState(!1),[se,oe]=l.useState(!1),[L,ee]=l.useState(!1),[le,d]=l.useState(!1),[J,F]=l.useState(null),[C,B]=l.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});l.useEffect(()=>{Q(),Sa().then(b=>{b.username&&B(G=>({...G,new_username:b.username||""}))}).catch(()=>{})},[]),l.useEffect(()=>{const b=G=>{var v;(v=$.current)!=null&&v.contains(G.target)||N(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]);const k=async(b,G=!1)=>{const v=b||t,U=(v==null?void 0:v.ai_api_url)||(v==null?void 0:v.ai_base_url)||ea;I(!0),H("");try{const ne=await qr(U,(v==null?void 0:v.ai_api_key)||"");w(ne),N(G&&ne.length>0),!(v!=null&&v.ai_model)&&ne.length>0&&s(ie=>ie&&{...ie,ai_model:ne[0]})}catch(ne){w([]),N(!1),H(ne.message||"读取模型失败")}finally{I(!1)}},Q=()=>{n(!0),_(""),Ra().then(b=>{s(b),k(b)}).catch(b=>{s(null),_(b.message||"加载配置失败")}).finally(()=>n(!1))},O=async()=>{if(t){S(!0);try{const b=Object.fromEntries(Object.entries(t).filter(([G,v])=>!Dn.has(G)&&v!==void 0&&v!==null));await Pa(b),alert("系统配置已保存")}catch(b){alert("保存失败:"+b.message)}finally{S(!1)}}},z=async b=>{b.preventDefault(),F(null);const G=C.new_username.trim();if(G.length<3){F({type:"error",text:"用户名至少需要 3 个字符"});return}if(!C.current_password){F({type:"error",text:"请输入当前密码确认身份"});return}if(C.new_password&&C.new_password.length<8){F({type:"error",text:"新密码至少需要 8 个字符"});return}if(C.new_password!==C.confirm_password){F({type:"error",text:"两次输入的新密码不一致"});return}d(!0);try{const v=await Tl({current_password:C.current_password,new_username:G,new_password:C.new_password||void 0});if(!v.success){F({type:"error",text:v.message||"登录凭据更新失败"});return}F({type:"success",text:v.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(v){F({type:"error",text:v.message||"登录凭据更新失败"})}finally{d(!1)}};if(!t)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:i||(a?"加载配置中...":"暂无配置")});const R=t.ai_model||"",x=u;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(_s,{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:Q,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(Je,{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(ol,{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:t.log_level||"info",onChange:b=>s({...t,log_level:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:En.map(b=>e.jsx("option",{value:b.value,children:b.label},b.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:t.log_format||"text",onChange:b=>s({...t,log_format:b.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:t.renewal_log_retention_days??10,onChange:b=>s({...t,renewal_log_retention_days:parseInt(b.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-brand text-white",children:e.jsx(ks,{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:t.ai_api_url||ea,onChange:b=>s({...t,ai_api_url:b.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:E?"text":"password",value:t.ai_api_key||"",onChange:b=>s({...t,ai_api_key:b.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:()=>V(!E),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:E?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(at,{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:$,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:R,onFocus:()=>u.length>0&&N(!0),onChange:b=>{s({...t,ai_model:b.target.value}),u.length>0&&N(!0)},onKeyDown:b=>{b.key==="Escape"&&N(!1),b.key==="ArrowDown"&&u.length>0&&N(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>u.length>0&&N(b=>!b),disabled:u.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(cl,{className:`w-4 h-4 transition-transform ${Z?"rotate-180":""}`})}),Z&&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:x.length>0?x.map(b=>e.jsxs("button",{type:"button",onClick:()=>{s({...t,ai_model:b}),N(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:b}),b===R&&e.jsx(Qe,{className:"w-4 h-4 shrink-0 text-brand"})]},b)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>k(void 0,!0),disabled:g,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(Je,{className:`w-4 h-4 ${g?"animate-spin":""}`}),"读取模型"]})]}),M?e.jsx("p",{className:"text-xs text-red-500",children:M}):e.jsx("p",{className:"text-xs text-gray-500",children:u.length>0?`已从当前 API 地址读取到 ${u.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(Pt,{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:t["captcha.remote_service_url"]||"",onChange:b=>s({...t,"captcha.remote_service_url":b.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:t["captcha.remote_secret_key"]||"",onChange:b=>s({...t,"captcha.remote_secret_key":b.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:()=>ae(!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(nt,{className:"w-4 h-4"}):e.jsx(at,{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(t["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:b=>s({...t,"captcha.remote_pass_cookies":b.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($s,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:z,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(Wt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:C.new_username,onChange:b=>B({...C,new_username:b.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:se?"text":"password",value:C.current_password,onChange:b=>B({...C,current_password:b.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(!se),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:se?"隐藏密码":"显示密码",children:se?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(at,{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:L?"text":"password",value:C.new_password,onChange:b=>B({...C,new_password:b.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:()=>ee(!L),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:L?"隐藏密码":"显示密码",children:L?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(at,{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:L?"text":"password",value:C.confirm_password,onChange:b=>B({...C,confirm_password:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),J&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${J.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(Pt,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:J.text})]}),e.jsxs("button",{type:"submit",disabled:le||!C.new_username||!C.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($s,{className:"w-4 h-4"}),le?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:O,disabled:j,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(Xe,{className:"w-6 h-6"}),j?"保存中...":"保存所有配置"]})})]})},as=(t,s)=>t.allowed_resolutions.includes(s),Bn=(t,s)=>({runs:t.runs.filter(a=>!s||a.cookie_id===s),pending_tasks:t.pending_tasks.filter(a=>!s||a.cookie_id===s)}),qn=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",Fn=({runs:t,pendingTasks:s,onResolveRun:a,onResolveDeferredTask:n})=>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(lt,{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:[t.map(i=>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:["账号 ",i.cookie_id," · 订单 ",i.order_id||"-"," · 已记录发送 ",i.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:qn(i.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:i.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[as(i,"continue")&&e.jsx("button",{onClick:(()=>a(i.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),as(i,"retry")&&e.jsx("button",{onClick:(()=>a(i.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),as(i,"cancel")&&e.jsx("button",{onClick:(()=>a(i.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${i.id}`)),s.map(i=>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:["账号 ",i.cookie_id," · 延迟任务重试已达 ",i.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:i.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>n(i.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>n(i.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${i.id}`))]})]}),ls=()=>({submitting:!1,result:"idle"}),rs=t=>t.submitting?t:{submitting:!0,result:"idle"},ns=(t,s)=>({submitting:!1,result:s?"success":"failure"}),ta=t=>t+1,is=(t,s,a,n)=>t===s&&a===n,zn=t=>{const[s,a]=l.useState([]),[n,i]=l.useState({runs:[],pending_tasks:[]}),[_,j]=l.useState([]),[S,u]=l.useState({}),[w,g]=l.useState([]),[I,M]=l.useState([]),[H,Z]=l.useState([]),[N,$]=l.useState(!1),E=l.useRef(0),V=l.useRef(0),[Y,ae]=l.useState(0),[se,oe]=l.useState(0),[L,ee]=l.useState({}),le=l.useCallback(async()=>{const k=Promise.all([Tt(),Ss(),Nt(),Vs()]),[Q,O,z,R]=await k;g(Q),M(O),Z(z),u(R),t.setSelectedAccountId(x=>{var b;return x||((b=Q[0])==null?void 0:b.id)||""})},[t.setSelectedAccountId]),d=l.useCallback(async()=>{var R;const k=ta(E.current);E.current=k;const Q=Ir().catch(x=>(console.warn("加载自动化异常列表失败,不阻断规则展示",x),null)),O=await Sr({cookieId:t.selectedAccountId||void 0,triggerType:t.automationTriggerFilter,enabled:t.automationStatusFilter==="all"?void 0:t.automationStatusFilter==="enabled",search:t.debouncedAutomationSearch,page:t.automationPage,pageSize:t.automationPageSize});if(!is(k,E.current,t.selectedAccountId,t.selectedAccountId))return;a(O.data),ae(O.total),oe(O.total_pages),ee(O.trigger_counts||{}),O.page!==t.automationPage&&((R=t.onAutomationPageChange)==null||R.call(t,O.page));const z=await Q;is(k,E.current,t.selectedAccountId,t.selectedAccountId)&&z&&i(z)},[t.automationPage,t.automationPageSize,t.automationStatusFilter,t.automationTriggerFilter,t.debouncedAutomationSearch,t.onAutomationPageChange,t.selectedAccountId]),J=l.useCallback(async()=>{const k=ta(V.current);V.current=k;const Q=t.selectedAccountId;if(j([]),!Q)return;const O=await Tr(Q);is(k,V.current,Q,t.selectedAccountId)&&j(O)},[t.selectedAccountId]),F=l.useCallback(async()=>{u(await Vs())},[]),C=l.useCallback(async()=>{$(!0);try{t.activeTab==="automation"?await d():t.activeTab==="reply"?await J():await F()}finally{$(!1)}},[d,F,J,t.activeTab]);return{automationRules:s,automationIssues:n,replyRules:_,defaultReplies:S,accounts:w,cards:I,items:H,automationTotal:Y,automationTotalPages:se,automationTriggerCounts:L,loading:N,setLoading:$,setAutomationRules:a,setCards:M,setItems:Z,loadReferenceData:le,loadAutomationRules:d,loadReplyRules:J,loadDefaultReplies:F,refresh:C}},st={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:$t},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:dl},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:_a}},zt=["order_paid","buyer_reviewed","review_missing_timeout"],Un="亲,商品使用满意的话,麻烦给个评价,谢谢~",Lt=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),Ma=t=>{if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}},rt=(t,s={})=>{const a=Ma(t);return JSON.stringify({after_shipped_hours:Number(a.after_shipped_hours||72),repeat_interval_hours:Number(a.repeat_interval_hours||24),max_attempts:Number(a.max_attempts||1),...s})},At=(t,s)=>{var n;const a=((n=st[t])==null?void 0:n.label)||"自动化规则";return s?`${a} - ${s}`:a},sa=t=>{const s=(t||"").trim();return s?Object.values(st).some(a=>s===a.label||s.startsWith(`${a.label} -`)):!0},It=(t,s=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:Un,enabled:!0,sort_order:1}];const a={action_type:"send_card",card_id:s,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[a,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[a]},Wn=t=>{var a,n;if(t.trigger_type==="review_missing_timeout")return((n=(a=t.actions)==null?void 0:a.find(i=>i.action_type==="send_text"))==null?void 0:n.message_template)||"发送求评价文案";const s=(t.actions||[]).filter(i=>i.action_type==="send_card");return s.length?s.map(i=>i.card_name||`卡密 ${i.card_id}`).join(" / "):"未配置卡密库存"},aa=(t,s=!1)=>{const a={blue:s?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:s?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:s?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return a[t]||a.blue},Jn=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Ut=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",Gn=t=>t===!0||t===1||t==="1",Vn=({initialDeliveryTarget:t,onDeliveryTargetHandled:s})=>{var Fe,ut,tt;const[a,n]=l.useState("automation"),[i,_]=l.useState(""),[j,S]=l.useState(""),[u,w]=l.useState(""),[g,I]=l.useState(""),[M,H]=l.useState("all"),[Z,N]=l.useState(1),[$,E]=l.useState(10),V=zn({activeTab:a,selectedAccountId:i,automationTriggerFilter:g,automationStatusFilter:M,debouncedAutomationSearch:u,automationPage:Z,automationPageSize:$,setSelectedAccountId:_,onAutomationPageChange:N}),{automationRules:Y,automationIssues:ae,replyRules:se,defaultReplies:oe,accounts:L,cards:ee,items:le,loading:d,setLoading:J,automationTotal:F,automationTotalPages:C,automationTriggerCounts:B,setAutomationRules:k,setCards:Q,setItems:O,loadReferenceData:z,loadAutomationRules:R,loadReplyRules:x,loadDefaultReplies:b,refresh:G}=V,[v,U]=l.useState(!1),[ne,ie]=l.useState(!1),[_e,Ae]=l.useState(!1),[Pe,Ee]=l.useState(ls),[Be,h]=l.useState(ls),[X,pe]=l.useState(ls),[y,ce]=l.useState(null),[D,xe]=l.useState(null),[te,$e]=l.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});L.find(o=>o.id===i),l.useEffect(()=>{const o=window.setTimeout(()=>{N(1),w(j.trim())},300);return()=>window.clearTimeout(o)},[j]),l.useEffect(()=>{z().catch(o=>console.error("加载规则参考数据失败",o))},[z]),l.useEffect(()=>{G().catch(o=>console.error("刷新规则页面失败",o))},[G]);const Le=l.useMemo(()=>Y.filter(o=>!i||o.cookie_id===i),[Y,i]),De=l.useMemo(()=>Bn(ae,i),[ae,i]),f=l.useMemo(()=>L.filter(o=>!i||o.id===i),[L,i]),A=l.useMemo(()=>{if(C<=1)return[];const o=Math.max(1,Math.min(Z-2,C-4)),r=Math.min(C,o+4);return Array.from({length:r-o+1},(p,P)=>o+P)},[Z,C]),W=!!(j.trim()||g||M!=="all"),K=()=>{S(""),w(""),I(""),H("all"),N(1)},ke=l.useMemo(()=>{const o=(y==null?void 0:y.cookie_id)||i;return le.filter(r=>r.cookie_id===o)},[y==null?void 0:y.cookie_id,le,i]),je=l.useMemo(()=>{if(!(!(y!=null&&y.cookie_id)||!(y!=null&&y.item_id)))return le.find(o=>o.cookie_id===y.cookie_id&&o.item_id===y.item_id)},[y==null?void 0:y.cookie_id,y==null?void 0:y.item_id,le]),ue=Gn(je==null?void 0:je.is_multi_spec),be=(y==null?void 0:y.trigger_type)||"order_paid",he=st[be],Te=Ma(y==null?void 0:y.config_json),m=l.useCallback((o="order_paid",r=i,p="")=>{const P=le.find(fe=>fe.cookie_id===r&&fe.item_id===p),re=(P==null?void 0:P.item_title)||p;return{name:At(o,re),trigger_type:o,cookie_id:r,item_id:p,item_title:(P==null?void 0:P.item_title)||"",item_keyword:re,card_group_id:0,priority:100,enabled:!0,config_json:o==="review_missing_timeout"?rt():"{}",actions:It(o),variants:o==="review_missing_timeout"?[]:[Lt()]}},[le,i]),T=l.useCallback(o=>{var p,P;const r=o.trigger_type||"order_paid";ce({...o,trigger_type:r,config_json:r==="review_missing_timeout"?rt(o.config_json):o.config_json||"{}",actions:(p=o.actions)!=null&&p.length?o.actions.map(re=>({...re})):It(r,o.card_group_id),variants:(P=o.variants)!=null&&P.length?o.variants.map(re=>({...re})):r==="review_missing_timeout"?[]:[Lt()]}),U(!0)},[]);l.useEffect(()=>{if(!t)return;let o=!1;return(async()=>{n("automation"),_(t.cookieId),J(!0);try{const[p,P,re]=await Promise.all([gs(),Nt(),Ss().catch(de=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",de),[]))]);if(o)return;k(p),O(P),Q(re);const fe=p.find(de=>de.cookie_id===t.cookieId&&de.item_id===t.itemId&&de.trigger_type==="order_paid");if(fe)T(fe);else{const de=P.find(Ie=>Ie.cookie_id===t.cookieId&&Ie.item_id===t.itemId);ce({...m("order_paid",t.cookieId,t.itemId),item_title:(de==null?void 0:de.item_title)||"",item_keyword:(de==null?void 0:de.item_title)||t.itemId,name:At("order_paid",(de==null?void 0:de.item_title)||t.itemId)}),U(!0)}}catch(p){console.error("打开商品自动化规则失败",p),alert("无法加载该商品的自动化规则")}finally{o||(J(!1),s==null||s())}})(),()=>{o=!0}},[m,t,s,T]);const me=(o="order_paid")=>{if(!i){alert("请先选择账号");return}ce(m(o)),U(!0)},Ne=o=>{var P,re,fe,de,Ie;if(!y)return;const r=((re=(P=y.variants)==null?void 0:P.find(qe=>qe.card_id))==null?void 0:re.card_id)||((de=(fe=y.actions)==null?void 0:fe.find(qe=>qe.action_type==="send_card"))==null?void 0:de.card_id)||y.card_group_id||0,p=(je==null?void 0:je.item_title)||y.item_title||y.item_id||"";ce({...y,trigger_type:o,name:sa(y.name)?At(o,p):y.name,card_group_id:r,config_json:o==="review_missing_timeout"?rt(y.config_json):"{}",actions:It(o,r),variants:o==="review_missing_timeout"?[]:(Ie=y.variants)!=null&&Ie.length?y.variants:[{...Lt(),card_id:r}]})},Ke=o=>{if(!y)return;const r=le.find(P=>P.cookie_id===(y.cookie_id||i)&&P.item_id===o),p=(r==null?void 0:r.item_title)||o;ce({...y,item_id:o,item_title:(r==null?void 0:r.item_title)||"",item_keyword:p,name:sa(y.name)?At(be,p):y.name})},Ue=(Fe=y==null?void 0:y.variants)!=null&&Fe.length?y.variants:[Lt()],We=(o,r)=>{var P;if(!y)return;const p=Ue.map((re,fe)=>fe===o?{...re,...r}:re);ce({...y,variants:p,card_group_id:((P=p[0])==null?void 0:P.card_id)||0})},vt=()=>{if(!y)return;const o=Ue[Ue.length-1];ce({...y,variants:[...Ue,{...Lt(),spec_name:ue&&(o==null?void 0:o.spec_name)||"",spec_value:ue&&(o==null?void 0:o.spec_value)||""}]})},wt=async()=>{var re,fe,de,Ie,qe;if(!y||Pe.submitting)return;const o=y.trigger_type||"order_paid";if(!y.cookie_id){alert("请选择账号");return}const r=(re=y.variants)!=null&&re.length?y.variants:[];if(o!=="review_missing_timeout"){if(!r.length||r.some(ve=>!ve.card_id)){alert(o==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(ue&&r.some(ve=>!ve.spec_name.trim()||!ve.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(o==="review_missing_timeout"&&!(((de=(fe=y.actions)==null?void 0:fe.find(Et=>Et.action_type==="send_text"))==null?void 0:de.message_template)||"").trim()){alert("请填写求评价文案");return}const p=o==="review_missing_timeout"?[]:r.map(ve=>({...ve,spec_name:ue?ve.spec_name.trim():"",spec_value:ue?ve.spec_value.trim():"",delivery_count:Math.max(1,Number(ve.delivery_count)||1),enabled:ve.enabled!==!1}));Ee(rs(Pe));let P=!1;try{await Js({...y,trigger_type:o,name:(y.name||"").trim()||At(o,(je==null?void 0:je.item_title)||y.item_id||""),config_json:o==="review_missing_timeout"?rt(y.config_json):y.config_json||"{}",actions:(Ie=y.actions)!=null&&Ie.length?y.actions:It(o,((qe=p[0])==null?void 0:qe.card_id)||y.card_group_id||0),variants:p}),U(!1),await Promise.all([R(),z()]),alert("保存成功"),P=!0}catch(ve){console.error("保存自动化规则失败:",ve),alert("保存失败:"+ve.message)}finally{Ee(ve=>ns(ve,P))}},ot=async o=>{if(confirm("确定删除该自动化规则吗?"))try{await Ar(o),await R(),alert("删除成功")}catch(r){alert("删除失败:"+r.message)}},ct=async o=>{try{await Js({...o,enabled:!o.enabled}),await R()}catch(r){alert("操作失败:"+r.message)}},kt=async(o,r)=>{if(confirm(r==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":r==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Or(o,r),await R()}catch(P){alert("处理失败:"+P.message)}},dt=async(o,r)=>{if(confirm(r==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Rr(o,r),await R()}catch(p){alert("处理失败:"+p.message)}},xt=()=>{if(!i){alert("请先选择账号");return}xe({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),ie(!0)},Ze=async()=>{var p,P,re;if(!D||!i||Be.submitting)return;const o=D.type==="image"?!!((p=D.image_url)!=null&&p.trim()):!!((P=D.reply_content)!=null&&P.trim());if(!((re=D.keyword)!=null&&re.trim())||!o){alert("请填写关键词和回复内容");return}h(rs(Be));let r=!1;try{await Er({...D,match_type:"fuzzy",enabled:!0},i),ie(!1),await x(),alert("保存成功"),r=!0}catch(fe){alert("保存失败:"+fe.message)}finally{h(fe=>ns(fe,r))}},mt=async o=>{if(!(!i||!confirm("确定删除该回复规则吗?")))try{await Dr(o,i),await x(),alert("删除成功")}catch(r){alert("删除失败:"+r.message)}},c=async(o=i)=>{if(!o){alert("请先选择账号");return}try{const r=await Gr(o);$e({cookie_id:o,enabled:r.enabled,reply_content:r.reply_content,reply_once:r.reply_once,reply_image_url:r.reply_image_url||""})}catch{$e({cookie_id:o,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}Ae(!0)},q=async()=>{if(X.submitting)return;if(!te.cookie_id){alert("请先选择账号");return}if(te.enabled&&!te.reply_content.trim()&&!te.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}pe(rs(X));let o=!1;try{await Vr(te.cookie_id,{enabled:te.enabled,reply_content:te.reply_content,reply_once:te.reply_once,reply_image_url:te.reply_image_url}),Ae(!1),await b(),alert("保存成功"),o=!0}catch(r){alert("保存失败:"+r.message)}finally{pe(r=>ns(r,o))}},ge=async o=>{if(confirm("确定删除该账号默认回复吗?"))try{await Qr(o),await b(),alert("删除成功")}catch(r){alert("删除失败:"+r.message)}},Re=async o=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Kr(o),alert("清空成功")}catch(r){alert("清空失败:"+r.message)}},Ge=a==="automation"?"新建自动化":a==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"min-w-0 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:i,onChange:o=>{_(o.target.value),N(1)},className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),L.map(o=>e.jsx("option",{value:o.id,children:Ut(o)},o.id))]}),e.jsxs("button",{onClick:G,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(Je,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:a==="automation"?()=>me("order_paid"):a==="reply"?xt:()=>void c(),disabled:!i,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(et,{className:"w-4 h-4"}),Ge]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:cs},{id:"reply",label:"关键词回复",icon:Ot},{id:"default",label:"账号默认回复",icon:bt}].map(o=>{const r=o.icon;return e.jsxs("button",{onClick:()=>n(o.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${a===o.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(r,{className:"w-4 h-4"}),o.label]},o.id)})}),a==="automation"&&(De.runs.length>0||De.pending_tasks.length>0)&&e.jsx(Fn,{runs:De.runs,pendingTasks:De.pending_tasks,onResolveRun:(o,r)=>void kt(o,r),onResolveDeferredTask:(o,r)=>void dt(o,r)}),a==="automation"&&e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]",children:[e.jsxs("aside",{className:"min-w-0 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:zt.map(o=>{const r=st[o],p=r.icon;return e.jsx("button",{type:"button",onClick:()=>me(o),className:`w-full text-left rounded-2xl border p-4 transition-colors ${aa(r.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(p,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:r.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:r.description})]})]})},o)})})]}),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:["共 ",F," 条"]})]}),e.jsx("div",{className:"space-y-3",children:zt.map(o=>{const r=st[o],p=r.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(p,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:r.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:B[o]||0})]},o)})})]})]}),e.jsxs("section",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-surface-muted 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(jt,{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:j,onChange:o=>{S(o.target.value),N(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(Na,{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:o=>{I(o.target.value),N(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:"全部自动化类型"}),zt.map(o=>e.jsx("option",{value:o,children:st[o].shortLabel},o))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:M,onChange:o=>{H(o.target.value),N(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:"已禁用"})]}),W&&e.jsx("button",{type:"button",onClick:K,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(Oe,{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:["找到 ",F," 条规则"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Je,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),d&&Le.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(Je,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Le.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(cs,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:W?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:W?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Le.map(o=>{const r=st[o.trigger_type],p=r.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 ${aa(r.accent,!0)}`,children:e.jsx(p,{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:o.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${Jn(o.enabled)}`,children:o.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:r.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:o.item_title||o.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:Wn(o)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>T(o),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(yt,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>ct(o),className:`px-4 py-2 rounded-xl text-sm font-bold ${o.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:o.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>ot(o.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Ve,{className:"w-4 h-4"})})]})]})},o.id)}),F>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(C,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:$,onChange:o=>{E(Number(o.target.value)),N(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(o=>e.jsxs("option",{value:o,children:[o," 条/页"]},o))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:Z<=1||d,onClick:()=>N(o=>Math.max(1,o-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(ws,{className:"h-4 w-4"})}),A.map(o=>e.jsx("button",{type:"button",disabled:d,onClick:()=>N(o),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${o===Z?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${o} 页`,"aria-current":o===Z?"page":void 0,children:o},o)),e.jsx("button",{type:"button",disabled:Z>=C||d,onClick:()=>N(o=>Math.min(C,o+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(vs,{className:"h-4 w-4"})})]})]})]})]}),a==="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(lt,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[se.map(o=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle 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:["“",o.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:o.type==="image"&&o.image_url?o.image_url:o.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:()=>{xe({...o}),ie(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(yt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>mt(o.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]},o.id)),se.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),a==="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(lt,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[f.map(o=>{const r=oe[o.id],p=!!(r!=null&&r.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 ${p?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-surface-subtle 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 ${p?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(bt,{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:Ut(o)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${p?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:p?"已启用":"未启用"}),(r==null?void 0:r.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:p?r.reply_content||r.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 c(o.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(yt,{className:"w-4 h-4"})}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void Re(o.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 ge(o.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]})]},o.id)}),f.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),v&&y&&Me.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:y.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:he.description})]}),e.jsx("button",{onClick:()=>U(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(Oe,{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:zt.map(o=>{const r=st[o],p=r.icon,P=be===o;return e.jsx("button",{type:"button",onClick:()=>Ne(o),className:`w-full rounded-2xl p-4 text-left border transition-all ${P?"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(p,{className:`w-5 h-5 mt-0.5 ${P?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:r.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${P?"text-gray-500":"text-gray-400"}`,children:r.description})]})]})},o)})}),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:he.flow.map((o,r)=>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:r+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:o})]},o))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-surface-subtle",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(ds,{className:"w-5 h-5 text-brand"}),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:y.name||"",onChange:o=>ce({...y,name:o.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:y.cookie_id||"",onChange:o=>ce({...y,cookie_id:o.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:"选择账号"}),L.map(o=>e.jsx("option",{value:o.id,children:Ut(o)},o.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:y.item_id||"",onChange:o=>Ke(o.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),ke.map(o=>e.jsx("option",{value:o.item_id,children:o.item_title||o.item_id},`${o.cookie_id}-${o.item_id}`))]})]})]}),je&&be!=="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:je.item_title||je.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${ue?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:ue?"多规格商品":"普通商品"}),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:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),be!=="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(xl,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:be==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:ue?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:vt,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(et,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:Ue.map((o,r)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${ue?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[ue&&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:o.spec_name,onChange:p=>We(r,{spec_name:p.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:o.spec_value,onChange:p=>We(r,{spec_value:p.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:o.card_id||"",onChange:p=>We(r,{card_id:Number(p.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),ee.filter(p=>p.enabled&&p.type!=="api").map(p=>e.jsx("option",{value:p.id,children:p.name},p.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:o.delivery_count,onChange:p=>We(r,{delivery_count:Math.max(1,Number(p.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:o.delay_override===!0,onChange:p=>We(r,{delay_override:p.target.checked}),className:"accent-brand"}),"覆盖卡密默认延时"]}),o.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:o.delay_seconds||0,onChange:p=>We(r,{delay_seconds:Math.max(0,Number(p.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:o.delay_override?`本动作延时 ${o.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:Ue.length===1,onClick:()=>ce({...y,variants:Ue.filter((p,P)=>P!==r)}),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(Ve,{className:"w-4 h-4"})})]},o.id||r))})]}):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(_a,{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(Te.after_shipped_hours||72),onChange:o=>ce({...y,config_json:rt(y.config_json,{after_shipped_hours:Math.max(1,Number(o.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(Te.repeat_interval_hours||24),onChange:o=>ce({...y,config_json:rt(y.config_json,{repeat_interval_hours:Math.max(1,Number(o.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(Te.max_attempts||1),onChange:o=>ce({...y,config_json:rt(y.config_json,{max_attempts:Math.max(1,Number(o.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:((tt=(ut=y.actions)==null?void 0:ut.find(o=>o.action_type==="send_text"))==null?void 0:tt.message_template)||"",onChange:o=>{var r;return ce({...y,actions:((r=y.actions)!=null&&r.length?y.actions:It("review_missing_timeout")).map(p=>p.action_type==="send_text"?{...p,message_template:o.target.value}:p)})},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:y.priority||100,onChange:o=>ce({...y,priority:Number(o.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:y.enabled!==!1,onChange:o=>ce({...y,enabled:o.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:()=>U(!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:wt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),ne&&D&&Me.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:D.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>ie(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Oe,{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:D.item_id||"",onChange:o=>xe({...D,item_id:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),le.filter(o=>!i||o.cookie_id===i).map(o=>e.jsx("option",{value:o.item_id,children:o.item_title||o.item_id},`${o.cookie_id}-${o.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:D.type||"text",onChange:o=>{const r=o.target.value;xe({...D,type:r,reply_content:r==="text"?D.reply_content:"",image_url:r==="image"?D.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:D.keyword||"",onChange:o=>xe({...D,keyword:o.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),D.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:D.image_url||"",onChange:o=>xe({...D,image_url:o.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:D.reply_content||"",onChange:o=>xe({...D,reply_content:o.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:()=>ie(!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:Ze,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Vt,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),_e&&Me.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:()=>Ae(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(Oe,{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:te.cookie_id,onChange:o=>$e({...te,cookie_id:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),L.map(o=>e.jsx("option",{value:o.id,children:Ut(o)},o.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:()=>$e({...te,enabled:!te.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${te.enabled?"bg-brand":"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 ${te.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:te.reply_content,onChange:o=>$e({...te,reply_content:o.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:te.reply_image_url,onChange:o=>$e({...te,reply_image_url:o.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:te.reply_once,onChange:o=>$e({...te,reply_once:o.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>Ae(!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:q,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},Qn=t=>{const s=String(t.smtp_from||"").trim(),a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);return{...t,smtp_from_name:t.smtp_from_name||(a?"":s),smtp_from_address:t.smtp_from_address||(a?s:t.smtp_user||""),smtp_use_tls:la(t.smtp_use_tls,!0),smtp_use_ssl:la(t.smtp_use_ssl,!1)}},la=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},Ls=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],ys=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},Ba=t=>{const s=Object.prototype.hasOwnProperty.call(t,"use_custom_smtp"),a=Ls.some(n=>String(t[n]??"").trim()!=="");return{...t,use_custom_smtp:s?ys(t.use_custom_smtp,!1):a}},ra=(t,s)=>{const a={...t,use_custom_smtp:!0};for(const n of Ls)String(a[n]??"").trim()===""&&s[n]!==void 0&&(a[n]=s[n]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=ys(a.smtp_use_tls,!0),a.smtp_use_ssl=ys(a.smtp_use_ssl,!1),a},Kn=t=>{const s=Ba(t),a={to_email:String(s.to_email??"").trim(),use_custom_smtp:s.use_custom_smtp===!0};if(a.use_custom_smtp)for(const n of Ls)a[n]=s[n];return a},gt={bark:{label:"Bark",icon:ft,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:Ot,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:Ot,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:Ot,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:ml,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:Vt,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:va,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},qa=[{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:"后台任务或系统级异常"}],Hn=t=>!t||t.length===0?"全部事件":t.map(a=>{var n;return((n=qa.find(i=>i.value===a))==null?void 0:n.label)||a}).join("、"),Zn=({isAdmin:t=!1})=>{const[s,a]=l.useState([]),[n,i]=l.useState(!0),[_,j]=l.useState(!1),[S,u]=l.useState(null),[w,g]=l.useState(!1),[I,M]=l.useState(""),[H,Z]=l.useState(null),[N,$]=l.useState({}),[E,V]=l.useState(!1),[Y,ae]=l.useState(!1),[se,oe]=l.useState(!1),[L,ee]=l.useState({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),le=async()=>{i(!0);try{const x=await Ta();a(x.data||[])}catch(x){console.error("加载通知渠道失败",x)}finally{i(!1)}},d=async()=>{try{const x=await Ra();$(Qn(x||{}))}catch(x){console.error("加载 SMTP 配置失败",x)}},J=async()=>{V(!0);try{await Pa({smtp_server:N.smtp_server||"",smtp_port:N.smtp_port||587,smtp_user:N.smtp_user||"",smtp_password:N.smtp_password||"",smtp_from_name:N.smtp_from_name||"",smtp_from_address:N.smtp_from_address||N.smtp_user||"",smtp_use_tls:N.smtp_use_tls!==!1,smtp_use_ssl:N.smtp_use_ssl===!0}),F("success","SMTP 配置已保存")}catch(x){F("error",(x==null?void 0:x.message)||"保存失败")}finally{V(!1)}};l.useEffect(()=>{le(),t?d():$({})},[t]);const F=(x,b)=>{Z({type:x,text:b}),window.setTimeout(()=>Z(null),3e3)},C=()=>{u(null),ee({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),oe(!1),j(!0)},B=x=>{u(x);const b=x.type==="email"?Ba({...x.config||{}}):null,G=b?b.use_custom_smtp===!0?ra(b,N):b:{...x.config||{}};ee({name:x.name,type:x.type,enabled:x.enabled,config:G,event_types:x.event_types||[]}),oe(!1),j(!0)},k=async()=>{const x=gt[L.type];for(const G of x.fields)if(G.required&&!String(L.config[G.key]||"").trim()){F("error",`请填写 ${G.label}`);return}if(!L.name.trim()){F("error","请填写渠道名称");return}let b=L.config;if(L.type==="email"&&(b=Kn(L.config),b.use_custom_smtp)){const v=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([U])=>!String(b[U]||"").trim());if(v){F("error",`请填写 ${v[1]}`);return}}g(!0);try{const G={name:L.name.trim(),type:L.type,config:b,event_types:L.event_types,enabled:L.enabled};S?await Gs(S.id,G):await zr(G),j(!1),await le(),F("success",S?"已更新":"已创建")}catch(G){console.error("保存失败",G),F("error",(G==null?void 0:G.message)||"保存失败")}finally{g(!1)}},Q=async x=>{if(confirm(`确认删除渠道「${x.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await Ur(x.id),await le(),F("success","已删除")}catch(b){F("error",(b==null?void 0:b.message)||"删除失败")}},O=async x=>{try{await Gs(x.id,{enabled:!x.enabled}),a(b=>b.map(G=>G.id===x.id?{...G,enabled:!G.enabled}:G))}catch(b){F("error",(b==null?void 0:b.message)||"切换失败")}},z=async x=>{M(x.id);try{await Jr(x.id),F("success","测试通知已发送,请检查对应渠道")}catch(b){F("error",(b==null?void 0:b.message)||"发送失败")}finally{M("")}},R=gt[L.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:le,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(Je,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:C,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(et,{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(ft,{className:"w-5 h-5 text-brand 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:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),n?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(Se,{className:"w-8 h-8 text-brand animate-spin"})}):s.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(ft,{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:s.map(x=>{const b=gt[x.type]||gt.webhook,G=b.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(G,{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:x.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:b.label}),!x.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:b.fields.map(v=>{var U;return(U=x.config)==null?void 0:U[v.key]}).filter(Boolean).map((v,U)=>e.jsx("span",{className:"mr-3",children:String(v).length>40?String(v).slice(0,40)+"…":String(v)},U))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Hn(x.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>O(x),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${x.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:x.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>z(x),disabled:I===x.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[I===x.id?e.jsx(Se,{className:"w-3 h-3 animate-spin"}):e.jsx(Vt,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>B(x),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(fa,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Q(x),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(Ve,{className:"w-4 h-4"})})]})]},x.id)})}),t&&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(va,{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:N.smtp_server||"",onChange:x=>$({...N,smtp_server:x.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:N.smtp_port||587,onChange:x=>$({...N,smtp_port:parseInt(x.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:N.smtp_user||"",onChange:x=>$({...N,smtp_user:x.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:N.smtp_password||"",onChange:x=>$({...N,smtp_password:x.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>ae(!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(nt,{className:"w-4 h-4"}):e.jsx(at,{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:N.smtp_from_name||"",onChange:x=>$({...N,smtp_from_name:x.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:N.smtp_from_address||N.smtp_user||"",onChange:x=>$({...N,smtp_from_address:x.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:N.smtp_use_tls!==!1,onChange:x=>$({...N,smtp_use_tls:x.target.checked,smtp_use_ssl:x.target.checked?!1:N.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:N.smtp_use_ssl===!0,onChange:x=>$({...N,smtp_use_ssl:x.target.checked,smtp_use_tls:x.target.checked?!1:N.smtp_use_tls})}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:J,disabled:E,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[E?e.jsx(Se,{className:"w-4 h-4 animate-spin"}):e.jsx(Xe,{className:"w-4 h-4"}),E?"保存中...":"保存 SMTP 配置"]})]}),_&&Me.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:S?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>j(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Oe,{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:L.name,onChange:x=>ee({...L,name:x.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(gt).map(x=>{const b=gt[x],G=b.icon,v=L.type===x;return e.jsxs("button",{type:"button",onClick:()=>ee({...L,type:x,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${v?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(G,{className:`w-5 h-5 ${v?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${v?"text-brand":"text-gray-600"}`,children:b.label})]},x)})})]}),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(ft,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",R.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:R.guide.steps.map((x,b)=>e.jsx("li",{children:x},b))}),R.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:R.guide.urlFormat})]}),R.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",R.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:R.fields.map(x=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[x.label,x.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:x.type==="password"?"password":x.type==="number"?"number":"text",value:String(L.config[x.key]||""),onChange:b=>ee({...L,config:{...L.config,[x.key]:b.target.value}}),placeholder:x.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),x.help&&e.jsx("p",{className:"text-xs text-gray-500",children:x.help})]},x.key))}),L.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:L.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:()=>{const x=L.config.use_custom_smtp===!0;ee({...L,config:x?{...L.config,use_custom_smtp:!1}:ra(L.config,N)})},className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${L.config.use_custom_smtp===!0?"bg-brand":"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 ${L.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),L.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(L.config.smtp_server||""),onChange:x=>ee({...L,config:{...L.config,smtp_server:x.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(L.config.smtp_port||587),onChange:x=>ee({...L,config:{...L.config,smtp_port:x.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(L.config.smtp_user||""),onChange:x=>ee({...L,config:{...L.config,smtp_user:x.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:se?"text":"password",value:String(L.config.smtp_password||""),onChange:x=>ee({...L,config:{...L.config,smtp_password:x.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(x=>!x),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:se?e.jsx(nt,{className:"w-4 h-4"}):e.jsx(at,{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(L.config.smtp_from_name||""),onChange:x=>ee({...L,config:{...L.config,smtp_from_name:x.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(L.config.smtp_from_address||""),onChange:x=>ee({...L,config:{...L.config,smtp_from_address:x.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:L.config.smtp_use_tls!==!1,onChange:x=>ee({...L,config:{...L.config,smtp_use_tls:x.target.checked,smtp_use_ssl:x.target.checked?!1:L.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:L.config.smtp_use_ssl===!0,onChange:x=>ee({...L,config:{...L.config,smtp_use_ssl:x.target.checked,smtp_use_tls:x.target.checked?!1:L.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:qa.map(x=>{const b=L.event_types.includes(x.value);return e.jsxs("button",{type:"button",onClick:()=>{const G=b?L.event_types.filter(v=>v!==x.value):[...L.event_types,x.value];ee({...L,event_types:G})},className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${b?"border-brand 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 ${b?"bg-brand border-brand":"border-gray-300"}`,children:b&&e.jsx(Qe,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${b?"text-brand":"text-gray-800"}`,children:x.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:x.description})]},x.value)})})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>ee({...L,enabled:!L.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${L.enabled?"bg-brand":"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 ${L.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:()=>j(!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:k,disabled:w,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[w?e.jsx(Se,{className:"w-4 h-4 animate-spin"}):e.jsx(Qe,{className:"w-4 h-4"}),w?"保存中...":"保存"]})]})]})}),document.body),H&&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 text-white ${H.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[H.type==="success"?e.jsx(Qe,{className:"w-4 h-4"}):e.jsx(Oe,{className:"w-4 h-4"}),H.text]})]})},Fa=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],Yn=t=>t,Xn=new Map(Fa.map(([t,s])=>[t,s])),na=t=>t.split(/(\[[^\]]+\])/g).map((s,a)=>{const n=s.startsWith("[")?Xn.get(s.slice(1,-1)):void 0;return n?e.jsx("img",{src:n,alt:s,title:s,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(js.Fragment,{children:s},a)}),ia="ydisks.chat.account.v1",ei=t=>{if(!t)return"";const s=new Date(t<1e10?t*1e3:t),a=new Date;return s.toDateString()===a.toDateString()?s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},oa=t=>new Date(t<1e10?t*1e3:t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),ti=()=>{const[t,s]=l.useState([]),[a,n]=l.useState(""),[i,_]=l.useState({}),[j,S]=l.useState(""),[u,w]=l.useState([]),[g,I]=l.useState(""),[M,H]=l.useState(!1),[Z,N]=l.useState(""),[$,E]=l.useState(!0),[V,Y]=l.useState(!1),[ae,se]=l.useState(!1),[oe,L]=l.useState(!1),[ee,le]=l.useState(),[d,J]=l.useState({}),[F,C]=l.useState({}),[B,k]=l.useState(!1),[Q,O]=l.useState(!1),[z,R]=l.useState(!1),[x,b]=l.useState(""),[G,v]=l.useState("connecting"),U=l.useRef(""),ne=l.useRef(""),ie=l.useRef(null),_e=l.useRef({accountID:"",chatID:""}),Ae=l.useRef(!0),Pe=l.useRef(!1),Ee=l.useRef(null),Be=l.useRef(new Set);l.useEffect(()=>{U.current=a},[a]),l.useEffect(()=>{ne.current=j},[j]);const h=async f=>{const A=await Xt(f,void 0,void 0,!0);return _(W=>({...W,[f]:A.sessions})),J(W=>({...W,[f]:A.next_cursor})),C(W=>({...W,[f]:A.has_more})),A.sessions};l.useEffect(()=>{let f=!1;return(async()=>{var W;E(!0);try{const[K,ke]=await Promise.all([Tt(),hs()]),ue=K.map(m=>{var T,me;return{...m,runtime_state:((T=ke[m.id])==null?void 0:T.state)||(m.enabled?"connecting":"disabled"),runtime_connected:((me=ke[m.id])==null?void 0:me.connected)===!0}}).filter(m=>m.enabled),be=await Promise.all(ue.map(async m=>[m.id,await Xt(m.id)]));if(f)return;s(ue),_(Object.fromEntries(be.map(([m,T])=>[m,T.sessions]))),J(Object.fromEntries(be.map(([m,T])=>[m,T.next_cursor]))),C(Object.fromEntries(be.map(([m,T])=>[m,T.has_more])));const he=window.localStorage.getItem(ia)||"",Te=ue.some(m=>m.id===he)?he:((W=ue[0])==null?void 0:W.id)||"";n(Te)}catch(K){f||b(K instanceof Error?K.message:"加载聊天数据失败")}finally{f||E(!1)}})(),()=>{f=!0}},[]),l.useEffect(()=>{let f=!1,A=0,W=null;const K=async()=>{W=new AbortController;try{const ke=await hs({signal:W.signal,timeoutMs:1e4});f||s(je=>je.map(ue=>{var be,he;return{...ue,runtime_state:((be=ke[ue.id])==null?void 0:be.state)||ue.runtime_state,runtime_connected:((he=ke[ue.id])==null?void 0:he.connected)??ue.runtime_connected}}))}catch{}finally{f||(A=window.setTimeout(K,3e3))}};return A=window.setTimeout(K,3e3),()=>{f=!0,window.clearTimeout(A),W==null||W.abort()}},[]),l.useEffect(()=>{if(!a)return;window.localStorage.setItem(ia,a);const f=i[a]||[];S(A=>{var W;return f.some(K=>K.chat_id===A)?A:((W=f[0])==null?void 0:W.chat_id)||""})},[a,i]),l.useEffect(()=>{!a||Be.current.has(a)||(Be.current.add(a),h(a).catch(f=>{b(f instanceof Error?f.message:"同步会话失败")}))},[a]),l.useEffect(()=>{if(!a||!j){w([]);return}const f=new AbortController;return Y(!0),Promise.all([ps(a,j,void 0,void 0,{signal:f.signal}),zs(a,j)]).then(([A])=>{w(A.messages),L(A.has_more),le(A.next_cursor),A.session&&_(W=>({...W,[a]:(W[a]||[]).map(K=>{var ke;return K.chat_id===((ke=A.session)==null?void 0:ke.chat_id)?A.session:K})})),_(W=>({...W,[a]:(W[a]||[]).map(K=>K.chat_id===j?{...K,unread_count:0}:K)}))}).catch(A=>{f.signal.aborted||b(A instanceof Error?A.message:"加载消息失败")}).finally(()=>{f.signal.aborted||Y(!1)}),()=>f.abort()},[a,j]);const X=async()=>{var W;if(!a||!j||ae||!oe)return;const f=ie.current,A=(f==null?void 0:f.scrollHeight)||0;Pe.current=!0,se(!0),b("");try{const K=(W=u[0])==null?void 0:W.id,ke=await ps(a,j,ee,K);w(je=>{const ue=new Set(je.map(be=>be.message_key));return[...ke.messages.filter(be=>!ue.has(be.message_key)),...je]}),L(ke.has_more),le(ke.next_cursor),requestAnimationFrame(()=>{f&&(f.scrollTop+=f.scrollHeight-A)})}catch(K){Pe.current=!1,b(K instanceof Error?K.message:"加载历史消息失败")}finally{se(!1)}};l.useEffect(()=>{let f=!1,A=0,W=0,K=null;const ke=()=>{if(f)return;v("connecting");const je=window.location.protocol==="https:"?"wss:":"ws:";K=new WebSocket(`${je}//${window.location.host}/api/v1/chat/ws`),K.onopen=()=>{W=0,v("online")},K.onmessage=ue=>{try{const he=JSON.parse(ue.data).message;if(!he)return;const Te=he.account_id;_(m=>{const T=m[Te]||[];return T.some(Ne=>Ne.chat_id===he.chat_id)?{...m,[Te]:T.map(Ne=>Ne.chat_id===he.chat_id?{...Ne,last_message:he.content,last_message_at:he.sent_at,unread_count:he.direction==="incoming"&&(U.current!==Te||ne.current!==he.chat_id)?Ne.unread_count+1:Ne.unread_count}:Ne).sort((Ne,Ke)=>Ke.last_message_at-Ne.last_message_at)}:(h(Te),m)}),U.current===Te&&ne.current===he.chat_id&&(w(m=>{const T=m.findIndex(me=>me.message_key===he.message_key);return T>=0?m.map((me,Ne)=>Ne===T?he:me):[...m,he]}),he.direction==="incoming"&&zs(Te,he.chat_id))}catch{}},K.onclose=()=>{if(f)return;v("offline");const ue=Math.min(15e3,1e3*2**Math.min(W++,4));A=window.setTimeout(ke,ue)},K.onerror=()=>K==null?void 0:K.close()};return ke(),()=>{f=!0,window.clearTimeout(A),K==null||K.close()}},[]);const pe=()=>{const f=ie.current;if(!f)return;const A=f.scrollHeight-f.scrollTop-f.clientHeight;Ae.current=A<=48};l.useLayoutEffect(()=>{const f=_e.current.accountID!==a||_e.current.chatID!==j;_e.current={accountID:a,chatID:j},f&&(Ae.current=!0);const A=ie.current;if(A){if(Pe.current){Pe.current=!1;return}(V||Ae.current)&&(A.scrollTop=A.scrollHeight)}},[a,j,u,V]);const y=t.find(f=>f.id===a),ce=i[a]||[],D=ce.find(f=>f.chat_id===j),xe=l.useMemo(()=>{const f=g.trim().toLowerCase();return ce.filter(A=>M&&A.unread_count<=0?!1:f?[A.buyer_name,A.buyer_id,A.item_title,A.last_message].some(W=>(W||"").toLowerCase().includes(f)):!0)},[ce,g,M]),te=f=>(i[f]||[]).reduce((A,W)=>A+W.unread_count,0),$e=async()=>{if(!(!a||B||!F[a])){k(!0),b("");try{const f=await Xt(a,d[a],void 0,!0);_(A=>({...A,[a]:f.sessions})),J(A=>({...A,[a]:f.next_cursor})),C(A=>({...A,[a]:f.has_more}))}catch(f){b(f instanceof Error?f.message:"加载历史联系人失败")}finally{k(!1)}}},Le=async()=>{const f=Z.trim();if(!(!f||!D||!a||z)){R(!0),b("");try{const A=await ql({account_id:a,chat_id:D.chat_id,buyer_id:D.buyer_id,buyer_name:D.buyer_name,item_id:D.item_id,item_title:D.item_title,text:f});N(""),w(W=>W.some(K=>K.message_key===A.message.message_key)?W.map(K=>K.message_key===A.message.message_key?A.message:K):[...W,A.message])}catch(A){b(A instanceof Error?A.message:"消息发送失败"),Bl(a,D.chat_id).then(w)}finally{R(!1)}}},De=async f=>{if(!(!f||!D||!a||z)){R(!0),b("");try{const A=await Fl({account_id:a,chat_id:D.chat_id,buyer_id:D.buyer_id,buyer_name:D.buyer_name,buyer_avatar_url:D.buyer_avatar_url,item_id:D.item_id,item_title:D.item_title,image:f});w(W=>W.some(K=>K.message_key===A.message.message_key)?W.map(K=>K.message_key===A.message.message_key?A.message:K):[...W,A.message])}catch(A){b(A instanceof Error?A.message:"图片发送失败")}finally{R(!1),Ee.current&&(Ee.current.value="")}}};return $?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(Se,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${G==="online"?"bg-emerald-50 text-emerald-700":G==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[G==="online"?e.jsx(ul,{className:"h-3.5 w-3.5"}):e.jsx(pl,{className:"h-3.5 w-3.5"}),G==="online"?"实时同步中":G==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:t.map(f=>{const A=f.id===a,W=te(f.id),K=f.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":A,onClick:()=>n(f.id),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${A?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${K?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:f.nickname||f.remark||f.id}),W>0&&e.jsx("span",{className:"min-w-5 rounded-full bg-red-500 px-1.5 py-0.5 text-[10px] text-white",children:W>99?"99+":W})]},f.id)})})]}),t.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(os,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(jt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:g,onChange:f=>I(f.target.value),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>H(f=>!f),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${M?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:M?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:()=>void h(a),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(Je,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[xe.map(f=>e.jsxs("button",{type:"button",onClick:()=>S(f.chat_id),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${f.chat_id===j?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:f.buyer_avatar_url?e.jsx("img",{src:f.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(Wt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:f.buyer_name||`用户 ${f.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:ei(f.last_message_at)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:f.last_message||"暂无消息"}),f.unread_count>0&&e.jsx("span",{className:"ml-auto min-w-5 shrink-0 rounded-full bg-red-500 px-1.5 py-0.5 text-center text-[10px] font-bold text-white",children:f.unread_count})]}),f.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",f.item_title]})]})]},f.chat_id)),xe.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),F[a]&&!g&&!M&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:()=>void $e(),disabled:B,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[B&&e.jsx(Se,{className:"h-3.5 w-3.5 animate-spin"}),B?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:D?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:D.buyer_name||D.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",D.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(y==null?void 0:y.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(y==null?void 0:y.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:ie,onScroll:pe,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:V?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Se,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[oe&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:()=>void X(),disabled:ae,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[ae&&e.jsx(Se,{className:"h-3.5 w-3.5 animate-spin"}),ae?"正在加载":"加载更早消息"]})}),u.map(f=>{const A=f.direction==="outgoing";return f.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[na(f.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:oa(f.sent_at)})]})},f.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${A?"justify-end":"justify-start"}`,children:[!A&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:D.buyer_avatar_url?e.jsx("img",{src:D.buyer_avatar_url,alt:D.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(Wt,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${A?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:A?(y==null?void 0:y.nickname)||(y==null?void 0:y.remark)||"我":D.buyer_name||f.sender_name||D.buyer_id}),f.message_type==="image"?e.jsx("a",{href:f.content,target:"_blank",rel:"noreferrer",className:`block overflow-hidden rounded-2xl border bg-white p-1 shadow-sm ${A?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:f.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):f.message_type==="video"?e.jsx("video",{src:f.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${A?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:na(f.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[oa(f.sent_at),A&&(f.status==="failed"?e.jsx(lt,{className:"h-3 w-3 text-red-500"}):f.status==="sent"?e.jsx(hl,{className:"h-3 w-3 text-sky-500"}):e.jsx(Qe,{className:"h-3 w-3"}))]})]}),A&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:y!=null&&y.avatar_url?e.jsx("img",{src:y.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(Wt,{className:"m-2 h-5 w-5 text-sky-600"})})]},f.message_key)})]})}),x&&e.jsx("div",{className:"border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:x}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>O(f=>!f),disabled:z||(y==null?void 0:y.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(gl,{className:"h-5 w-5"})}),Q&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:Fa.map(([f,A])=>e.jsx("button",{type:"button",title:`[${f}]`,onClick:()=>{N(W=>W+`[${f}]`),O(!1)},className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:Yn(A),alt:`[${f}]`,className:"h-8 w-8 object-contain"})},f))})]})]}),e.jsx("input",{ref:Ee,type:"file",accept:"image/*",className:"hidden",onChange:f=>{var A;return void De((A=f.target.files)==null?void 0:A[0])}}),e.jsx("button",{type:"button",onClick:()=>{var f;return(f=Ee.current)==null?void 0:f.click()},disabled:z||(y==null?void 0:y.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(bl,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:Z,onChange:f=>N(f.target.value),rows:2,maxLength:2e3,onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),Le())},disabled:(y==null?void 0:y.runtime_state)!=="online",placeholder:(y==null?void 0:y.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:()=>void Le(),disabled:!Z.trim()||z||(y==null?void 0:y.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:z?e.jsx(Se,{className:"h-4 w-4 animate-spin"}):e.jsx(Vt,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(os,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]})]})},za="ydisks.sidebar.v1",si=()=>{try{return window.localStorage.getItem(za)==="collapsed"}catch{return!1}},ai=t=>{try{window.localStorage.setItem(za,t?"collapsed":"expanded")}catch{}},Ua={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/chat":"chat","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},ca=Object.fromEntries(Object.entries(Ua).map(([t,s])=>[s,t])),da=()=>Ua[window.location.pathname]||"dashboard",li=()=>{const[t,s]=l.useState(!1),[a,n]=l.useState(!1),[i,_]=l.useState(da),[j,S]=l.useState(!0),[u,w]=l.useState(!1),[g,I]=l.useState(""),[M,H]=l.useState(""),[Z,N]=l.useState(!1),[$,E]=l.useState(""),[V,Y]=l.useState(""),[ae,se]=l.useState(""),[oe,L]=l.useState(!1),[ee,le]=l.useState(""),[d,J]=l.useState(),[F,C]=l.useState(si),B=R=>{const x=R==="settings"&&!a?"dashboard":R,b=ca[x];b&&b!==window.location.pathname&&window.history.pushState({},"",b),_(x)};l.useEffect(()=>{const R=()=>_(da());return window.addEventListener("popstate",R),()=>window.removeEventListener("popstate",R)},[]),l.useEffect(()=>{Sa().then(x=>{if((x==null?void 0:x.initialized)===!1){w(!0),s(!1),n(!1);return}w(!1),x!=null&&x.authenticated?(s(!0),n(x.is_admin===!0)):n(!1)}).catch(()=>{s(!1),n(!1)}).finally(()=>S(!1));const R=()=>{s(!1),n(!1)};return window.addEventListener("auth:logout",R),()=>window.removeEventListener("auth:logout",R)},[]),l.useEffect(()=>{!j&&t&&!a&&i==="settings"&&(window.history.replaceState({},"",ca.dashboard),_("dashboard"))},[j,t,a,i]);const k=async R=>{R.preventDefault(),N(!0),E("");try{const x=await Rl({username:g,password:M});x.success?(s(!0),n(x.is_admin===!0)):E(x.message||"登录失败")}catch(x){const b=x instanceof Error?x.message:String(x);E(b||"登录失败")}finally{N(!1)}},Q=async R=>{if(R.preventDefault(),le(""),V.length<8){le("密码至少需要 8 个字符");return}if(V!==ae){le("两次输入的密码不一致");return}L(!0);try{const x=await Pl(V);if(!x.success){le(x.message||"初始化失败,请重试");return}w(!1),s(!0),n(x.is_admin===!0),Y(""),se("")}catch(x){const b=x instanceof Error?x.message:String(x);le(b||"初始化失败,请重试")}finally{L(!1)}},O=async()=>{try{await $l()}catch(R){console.error("退出登录失败",R)}finally{s(!1),n(!1)}};if(j)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-surface",children:e.jsx(Se,{className:"w-8 h-8 text-brand animate-spin"})});if(u)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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(ms,{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:"设置完成后会自动进入系统,管理员账号为 admin。"})]}),e.jsxs("form",{onSubmit:Q,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(Ts,{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:"设置管理员密码(至少 8 个字符)",value:V,onChange:R=>Y(R.target.value),autoFocus:!0,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(Pt,{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:R=>se(R.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),ee&&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(Pt,{className:"w-4 h-4"})," ",ee]}),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(Se,{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 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!t)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas 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-panel 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(ms,{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:k,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(it,{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:g,onChange:R=>I(R.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(Ts,{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:M,onChange:R=>H(R.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),$&&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(Pt,{className:"w-4 h-4"})," ",$]}),e.jsx("button",{type:"submit",disabled:Z,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:Z?e.jsx(Se,{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 z=()=>{switch(i){case"dashboard":return e.jsx(ts,{});case"accounts":return e.jsx(mn,{});case"chat":return e.jsx(ti,{});case"orders":return e.jsx(hn,{});case"cards":return e.jsx(_n,{});case"items":return e.jsx(Tn,{onConfigureDelivery:R=>{J({cookieId:R.cookie_id,itemId:R.item_id,requestId:Date.now()}),B("rules")}});case"rules":return e.jsx(Vn,{initialDeliveryTarget:d,onDeliveryTargetHandled:()=>J(void 0)});case"notifications":return e.jsx(Zn,{isAdmin:a});case"settings":return a?e.jsx(Mn,{}):e.jsx(ts,{});default:return e.jsx(ts,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[e.jsx(kl,{activeTab:i,isAdmin:a,collapsed:F,onToggleCollapsed:()=>C(R=>{const x=!R;return ai(x),x}),onNavigate:B,onLogout:O}),e.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${F?"ml-16":"ml-64"} ${i==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,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:`${i==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:z()})]})]})},Wa=document.getElementById("root");if(!Wa)throw new Error("Could not find root element to mount to");const ri=Ja.createRoot(Wa);ri.render(e.jsx(js.StrictMode,{children:e.jsx(li,{})})); diff --git a/internal/webui/static/index.html b/internal/webui/static/index.html index 31a87fe..b4e08c7 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -6,12 +6,12 @@ Ydisks闲鱼助手 - 自动发货与管家系统 - + - + - +