diff --git a/api/openapi.yaml b/api/openapi.yaml index bc134a6..077fe6b 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -451,7 +451,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/AutoConfirmResponse' '400': description: 统一错误响应 content: @@ -492,13 +492,19 @@ paths: schema: type: string security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AutoConfirmRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/OperationResponse' '400': description: 统一错误响应 content: @@ -540,13 +546,19 @@ paths: schema: type: string security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AccountLoginInfoRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/OperationResponse' '400': description: 统一错误响应 content: @@ -594,7 +606,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/LongLoginResponse' '400': description: 统一错误响应 content: @@ -635,13 +647,19 @@ paths: schema: type: string security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LongLoginSettingsRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/LongLoginResponse' '400': description: 统一错误响应 content: @@ -689,7 +707,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/PauseDurationResponse' '400': description: 统一错误响应 content: @@ -730,13 +748,19 @@ paths: schema: type: string security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PauseDurationRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/CookieSettingsResponse' '400': description: 统一错误响应 content: @@ -784,7 +808,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/CookieProfileResponse' '400': description: 统一错误响应 content: @@ -826,13 +850,19 @@ paths: schema: type: string security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AccountRemarkRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/OperationResponse' '400': description: 统一错误响应 content: @@ -874,13 +904,19 @@ paths: schema: type: string security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AccountSettingsUpdateRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/CookieSettingsResponse' '400': description: 统一错误响应 content: @@ -1018,7 +1054,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/RuntimeStatusMap' '400': description: 统一错误响应 content: @@ -5799,13 +5835,19 @@ paths: operationId: postApiV1SettingsAiModels summary: postApiV1SettingsAiModels security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AIModelsRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/AIModelsResponse' '400': description: 统一错误响应 content: @@ -5984,7 +6026,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/SystemSettingsResponse' '400': description: 统一错误响应 content: @@ -6019,13 +6061,19 @@ paths: operationId: putApiV1SettingsSystem summary: putApiV1SettingsSystem security: [{cookieAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SystemSettingsUpdateRequest' responses: '200': description: 成功 content: application/json: schema: - $ref: '#/components/schemas/ApiResponse' + $ref: '#/components/schemas/OperationResponse' '400': description: 统一错误响应 content: @@ -6501,6 +6549,185 @@ components: properties: enabled: type: boolean + AccountSettingsUpdateRequest: + type: object + properties: + cookie: + type: string + remark: + type: string + auto_confirm: + type: boolean + pause_duration: + type: integer + minimum: 0 + maximum: 1440 + username: + type: string + login_password: + type: string + clear_password: + type: boolean + show_browser: + type: boolean + channel_ids: + type: array + items: + type: integer + AccountLoginInfoRequest: + type: object + properties: + username: + type: string + login_password: + type: string + clear_password: + type: boolean + show_browser: + type: boolean + LongLoginSettingsRequest: + type: object + required: [enabled] + properties: + enabled: + type: boolean + LongLoginResponse: + type: object + required: [can_open_long_login, enabled] + properties: + can_open_long_login: + type: boolean + enabled: + type: boolean + AutoConfirmRequest: + type: object + required: [auto_confirm] + properties: + auto_confirm: + type: boolean + AutoConfirmResponse: + type: object + required: [auto_confirm] + properties: + auto_confirm: + type: boolean + AccountRemarkRequest: + type: object + required: [remark] + properties: + remark: + type: string + maxLength: 500 + PauseDurationRequest: + type: object + required: [pause_duration] + properties: + pause_duration: + type: integer + minimum: 0 + maximum: 1440 + PauseDurationResponse: + type: object + required: [pause_duration, paused_until, paused] + properties: + pause_duration: + type: integer + paused_until: + type: integer + paused: + type: boolean + CookieSettingsResponse: + type: object + required: [success, paused_until, paused] + properties: + success: + type: boolean + paused_until: + type: integer + paused: + type: boolean + CookieProfileResponse: + type: object + required: [success, id, nickname, avatar_url, profile_error] + properties: + success: + type: boolean + id: + type: string + nickname: + type: string + avatar_url: + type: string + profile_error: + type: string + RuntimeStatus: + type: object + required: [state, connected, failures, updated_at] + properties: + state: + type: string + enum: [starting, connecting, online, reconnecting, auth_expired, verification_required, runtime_conflict, error, stopped, disabled] + message: + type: string + connected: + type: boolean + failures: + type: integer + updated_at: + type: string + format: date-time + RuntimeStatusMap: + type: object + additionalProperties: + $ref: '#/components/schemas/RuntimeStatus' + AIModelsRequest: + type: object + required: [base_url] + properties: + base_url: + type: string + api_key: + type: string + AIModelsResponse: + type: object + required: [models] + properties: + models: + type: array + items: + type: string + SecretSettingChange: + type: object + required: [action] + properties: + action: + type: string + enum: [retain, replace, clear] + value: + type: string + SystemSettingValueMap: + type: object + additionalProperties: + oneOf: + - type: string + - type: number + - type: boolean + SystemSettingsUpdateRequest: + type: object + properties: + values: + $ref: '#/components/schemas/SystemSettingValueMap' + secrets: + type: object + additionalProperties: + $ref: '#/components/schemas/SecretSettingChange' + SystemSettingsResponse: + type: object + additionalProperties: + oneOf: + - type: string + - type: number + - type: boolean SessionStatusResponse: type: object required: [authenticated, initialized, is_admin] diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index c70aab9..f44ce5b 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -20,8 +20,8 @@ | --- | --- | --- | | 既有架构基线:稳定性、组合根、生命周期、React、DB、质量收口 | 已完成(不可回退) | 历史实现和证据留在 `refactoring-progress.md`,不重做、不改写历史。 | | 1. 契约基础设施与全路由登记 | 已完成 | OpenAPI、生成漂移和真实 Router 双向门禁已建立,未改变业务运行时形状。 | -| 2. 类型化客户端与登录账号主链路 | 当前阶段 | 迁移 session、system、accounts、QR 风控和永久关闭的 password-login。 | -| 3. 查询、聊天与订单主链路 | 待执行 | 迁移 dashboard、admin、chat、orders、刷新任务和 WebSocket 消息。 | +| 2. 类型化客户端与登录账号主链路 | 已完成 | session、system、accounts、QR 风控和永久关闭的 password-login 已迁移并完成真实响应校验。 | +| 3. 查询、聊天与订单主链路 | 当前阶段 | 迁移 dashboard、admin、chat、orders、刷新任务和 WebSocket 消息。 | | 4. 商品、卡券和文件传输 | 待执行 | 迁移 items、批量发布、cards、上传与 CSV。 | | 5. 自动化、设置和通知动态契约 | 待执行 | 迁移 rules、automation、settings、notifications 和账号绑定。 | | 6. 全量封闭与旧手写契约退场 | 待执行 | 关闭原始 HTTP client 旁路,删除手写 transport DTO 和名单式门禁。 | diff --git a/docs/architecture/refactoring-progress.md b/docs/architecture/refactoring-progress.md index e75c4d2..8385b11 100644 --- a/docs/architecture/refactoring-progress.md +++ b/docs/architecture/refactoring-progress.md @@ -3,6 +3,65 @@ 本文件只记录已经完成阶段的最终提交与验收证据。唯一阶段状态和顺序由 `refactoring-master-plan.md` 定义;阶段内工作、临时提交、切片和局部成功一律不记录。 +## OpenAPI 阶段二:类型化客户端与登录账号主链路 + +- 最终提交绑定:`阶段二:迁移登录账号与风控接口到生成契约`。 +- 交付范围:以 `openapi-fetch` 和生成 `paths/types` 为唯一新增请求运行时,保留 Cookie、默认超时、外部 + AbortSignal、取消/超时错误、401 合并登出、ApiError 和 JSON/FormData 兼容行为。session、accounts、QR + 风控、system 设置与 AI 模型探测已迁移;账户 adapter 仍输出既有 UI model,生成 transport 类型未进入 + React state 或组件 props。密码登录的三个永久关闭 operation 保留 501 错误契约,未触碰冻结 CAPTCHA 调用链。 +- OpenAPI 收紧:账户运行状态、聚合设置、长期登录、自动确认、备注、暂停时长、资料刷新、登录资料和系统 + 设置均使用具名请求/响应 schema;动态系统键限制为字符串、数值或布尔值,敏感设置使用 retain/replace/clear + 三态命令。后端额外非敏感字段仍按非对称规则允许,账号与系统响应测试独立阻断 Cookie、密码、SMTP 密码 + 和 AI 密钥泄漏。 + +### 强制验收原始输出 + +```text +$ make api-check +api-check: 通过;OpenAPI 生成漂移检查和 chi 路由双向覆盖通过。 + +$ go run ./tools/architecturecheck +architecturecheck: 通过 + +$ go test ./internal/server -run '^TestOpenAPI(AccountAndSystem|SessionAndQR)Responses$' -count=1 +PASS + +$ go test ./... -count=1 +所有 Go 测试包通过。 + +$ go vet ./... +(无输出,退出码 0) + +$ make lint +golangci-lint run ./... +0 issues. + +$ npm test --prefix frontend +Test Files 67 passed (67) +Tests 405 passed (405) + +$ npm run typecheck --prefix frontend +(无输出,退出码 0) + +$ npm run build --prefix frontend +vite 构建成功,嵌入前端产物已重建。 + +$ make comments +commentlint: 通过(Go 与 TypeScript/TSX 均无缺少中文注释或模板化注释) + +$ git diff --check +(无输出,退出码 0) +``` + +### 验收边界 + +- 覆盖率:本阶段未修改覆盖率目标,未运行覆盖率命令。 +- 浏览器:未使用 `RUN_BROWSER_INTEGRATION=1`;未修改 `internal/browser` 或冻结 CAPTCHA 文件。 +- 外部服务:长期登录成功响应依赖真实平台 `returnValue`,本地契约测试验证其 502 统一错误 envelope;未运行真实账号、 + MySQL 或 PostgreSQL。 +- 生成物:生成的 `frontend/shared/api-contract/generated/schema.ts` 与新的嵌入前端构建产物随阶段提交,未手工修改生成文件。 + ## 阶段二:Server 组合根和应用服务迁移 - 最终提交绑定:本文件随最终提交 `阶段二:完成 Server 组合根和应用服务迁移` 一并进入 `HEAD`。 diff --git a/frontend/app/features/accounts/api.ts b/frontend/app/features/accounts/api.ts index 64ffceb..990130f 100644 --- a/frontend/app/features/accounts/api.ts +++ b/frontend/app/features/accounts/api.ts @@ -14,7 +14,8 @@ NotificationEventType, OperationResponse, QRLoginGenerateResponse,QRLoginStatusResponse,QRLoginVerificationResponse } from '../../../shared/api-contract/accounts'; -import { del,get,post,put,type RequestControlOptions } from '../../../shared/http/client'; +import { contractClient, runContractRequest } from '../../../shared/api-contract/client'; +import { get,post,put,type RequestControlOptions } from '../../../shared/http/client'; import { collectionFrom,objectFrom } from '../../../shared/http/contract'; export type * from '../../../shared/api-contract/accounts'; @@ -27,7 +28,10 @@ export type QRLoginStatusResult = Pick< // Accounts // addAccount 新增账号。 export const addAccount = async (id: string, value: string, loginMethod?: string): Promise => { - return post('/api/v1/accounts', { id, value, login_method: loginMethod }); + return runContractRequest(/* signal 是本次账号创建请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/accounts', { + body: { id, value, login_method: loginMethod }, + signal, + })); }; // accountAvatarURL 生成账号头像地址。 @@ -51,7 +55,7 @@ const accountAvatarURL = (item: AccountSummaryResponse, version: string): string // getAccountDetails 读取账号详情。 export const getAccountDetails = async (options?: RequestControlOptions): Promise => { // data 数据,用于当前 API 处理流程。 - const response = await get('/api/v1/accounts/details', undefined, options); + const response = await runContractRequest(/* signal 是本次账号详情读取请求的超时与取消控制信号。 */ signal => contractClient.GET('/api/v1/accounts/details', { signal }), options); // data 是兼容数组、null 和历史 data 包裹后的账号摘要列表。 const data = collectionFrom(response, ['data', 'accounts', 'details']); // avatarVersion 头像缓存版本,用于当前 API 处理流程。 @@ -105,21 +109,29 @@ export interface AccountRuntimeStatus { // getAccountRuntimeStatuses 读取账号运行状态。 export const getAccountRuntimeStatuses = async (options?: RequestControlOptions): Promise> => { - const response = await get('/api/v1/accounts/runtime-status', undefined, options); - // statuses 是兼容直接映射、statuses 包裹和 null 的运行状态索引。 - const statuses = objectFrom>(response, ['statuses', 'data', 'result']); - return statuses || {}; + // response 是按账号 ID 索引的非敏感运行状态快照。 + const response = await runContractRequest( + /* signal 是本次账号运行状态读取请求的超时与取消控制信号。 */ signal => contractClient.GET('/api/v1/accounts/runtime-status', { signal }), + options, + ); + return response; }; // generateQRLogin 生成二维码登录会话。 export const generateQRLogin = async (options?: RequestControlOptions): Promise => { // 风控后匿名 token 接口可能超过通用的 30 秒请求窗口;后端总生成窗口为 2 分钟。 - return post('/api/v1/qr-login/generate', undefined, { ...options, timeoutMs: options?.timeoutMs ?? 130_000 }); + return runContractRequest( + /* signal 是本次二维码生成请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/qr-login/generate', { signal }), + { ...options, timeoutMs: options?.timeoutMs ?? 130_000 }, + ); }; // checkQRLoginStatus 查询二维码登录状态。 export const checkQRLoginStatus = async (sessionId: string, signal?: AbortSignal): Promise => { - return get(`/api/v1/qr-login/check/${sessionId}`, undefined, { signal, timeoutMs: 10_000 }); + return runContractRequest( + /* requestSignal 是本次二维码轮询请求的超时与取消控制信号。 */ requestSignal => contractClient.GET('/api/v1/qr-login/check/{session_id}', { params: { path: { session_id: sessionId } }, signal: requestSignal }), + { signal, timeoutMs: 10_000 }, + ); }; // completeQRVerification 完成二维码登录验证。 @@ -127,9 +139,11 @@ export const completeQRVerification = async ( sessionId: string, targetAccountId?: string, ): Promise => { - return post(`/api/v1/qr-login/complete-verification/${sessionId}`, { - target_account_id: targetAccountId || '', - }); + return runContractRequest(/* requestSignal 是本次风控完成请求的超时与取消控制信号。 */ requestSignal => contractClient.POST('/api/v1/qr-login/complete-verification/{session_id}', { + params: { path: { session_id: sessionId } }, + body: { target_account_id: targetAccountId || '' }, + signal: requestSignal, + })); }; @@ -139,32 +153,55 @@ export const completeQRVerification = async ( // updateAccountStatus 更新账号状态。 export const updateAccountStatus = async (id: string, enabled: boolean): Promise => { - return put(`/api/v1/accounts/${id}/status`, { enabled }); + return runContractRequest(/* signal 是本次账号状态更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/status', { + params: { path: { cid: id } }, + body: { enabled }, + signal, + })); }; // deleteAccount 删除账号。 export const deleteAccount = async (id: string): Promise => { - return del(`/api/v1/accounts/${id}`); + return runContractRequest(/* signal 是本次账号删除请求的超时与取消控制信号。 */ signal => contractClient.DELETE('/api/v1/accounts/{cid}', { + params: { path: { cid: id } }, + signal, + })); }; // updateAccountRemark 更新账号备注。 export const updateAccountRemark = async (id: string, remark: string): Promise => { - return put(`/api/v1/accounts/${id}/remark`, { remark }); + return runContractRequest(/* signal 是本次账号备注更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/remark', { + params: { path: { cid: id } }, + body: { remark }, + signal, + })); }; // updateAccountAutoConfirm 更新账号自动确认设置。 export const updateAccountAutoConfirm = async (id: string, autoConfirm: boolean): Promise => { - return put(`/api/v1/accounts/${id}/auto-confirm`, { auto_confirm: autoConfirm }); + return runContractRequest(/* signal 是本次账号自动确认更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/auto-confirm', { + params: { path: { cid: id } }, + body: { auto_confirm: autoConfirm }, + signal, + })); }; // updateAccountPauseDuration 更新账号暂停时长。 export const updateAccountPauseDuration = async (id: string, pauseDuration: number, options?: RequestControlOptions): Promise => { - return put(`/api/v1/accounts/${id}/pause-duration`, { pause_duration: pauseDuration }, options); + return runContractRequest(/* signal 是本次账号暂停时长更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/pause-duration', { + params: { path: { cid: id } }, + body: { pause_duration: pauseDuration }, + signal, + }), options); }; // updateAccountCookie 更新账号登录凭证。 export const updateAccountCookie = async (id: string, value: string, loginMethod?: string): Promise => { - return put(`/api/v1/accounts/${id}`, { id, value, login_method: loginMethod }); + return runContractRequest(/* signal 是本次账号凭据更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}', { + params: { path: { cid: id } }, + body: { id, value, login_method: loginMethod }, + signal, + })); }; export interface AccountSettingsUpdate { @@ -181,7 +218,11 @@ export interface AccountSettingsUpdate { // updateAccountSettings 更新账号设置。 export const updateAccountSettings = async (id: string, data: AccountSettingsUpdate, options?: RequestControlOptions): Promise => { - return put(`/api/v1/accounts/${id}/settings`, data, options); + return runContractRequest(/* signal 是本次账号聚合设置更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/settings', { + params: { path: { cid: id } }, + body: data, + signal, + }), options); }; export interface LongLoginSettings { @@ -191,12 +232,19 @@ export interface LongLoginSettings { // getLongLoginSettings 读取长期登录设置。 export const getLongLoginSettings = async (id: string, options?: RequestControlOptions): Promise => { - return get(`/api/v1/accounts/${id}/long-login`, undefined, options); + return runContractRequest(/* signal 是本次长期登录设置读取请求的超时与取消控制信号。 */ signal => contractClient.GET('/api/v1/accounts/{cid}/long-login', { + params: { path: { cid: id } }, + signal, + }), options); }; // setLongLoginSettings 设置长期登录开关。 export const setLongLoginSettings = async (id: string, enabled: boolean, options?: RequestControlOptions): Promise => { - return put(`/api/v1/accounts/${id}/long-login`, { enabled }, options); + return runContractRequest(/* signal 是本次长期登录设置更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/long-login', { + params: { path: { cid: id } }, + body: { enabled }, + signal, + }), options); }; export interface PasswordLoginStartResponse { @@ -226,22 +274,36 @@ export const passwordLogin = async (data: { /** password 表示密码。 */ password: string; /** show_browser 表示是否显示浏览器。 */ show_browser?: boolean; }, options?: RequestControlOptions): Promise => { - return post('/api/v1/password-login', data, options); + return runContractRequest(/* signal 是永久关闭的密码登录请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/password-login', { + body: data, + signal, + }), options); }; // checkPasswordLoginStatus 查询密码登录状态。 export const checkPasswordLoginStatus = async (sessionId: string, signal?: AbortSignal): Promise => { - return get(`/api/v1/password-login/check/${sessionId}`, undefined, { signal, timeoutMs: 10_000 }); + // result 是永久关闭 operation 的理论成功类型;真实服务端恒定返回 password_login_disabled 错误。 + const result = runContractRequest(/* requestSignal 是永久关闭的密码登录查询请求的超时与取消控制信号。 */ requestSignal => contractClient.GET('/api/v1/password-login/check/{session_id}', { + params: { path: { session_id: sessionId } }, + signal: requestSignal, + }), { signal, timeoutMs: 10_000 }); + return result as unknown as Promise; }; // cancelPasswordLogin 取消密码登录。 export const cancelPasswordLogin = async (sessionId: string, options?: RequestControlOptions): Promise => { - return del(`/api/v1/password-login/cancel/${sessionId}`, undefined, options); + return runContractRequest(/* signal 是永久关闭的密码登录取消请求的超时与取消控制信号。 */ signal => contractClient.DELETE('/api/v1/password-login/cancel/{session_id}', { + params: { path: { session_id: sessionId } }, + signal, + }), options); }; // refreshAccountProfile 刷新账号资料。 export const refreshAccountProfile = async (id: string): Promise => { - return post(`/api/v1/accounts/${id}/refresh-profile`, {}); + return runContractRequest(/* signal 是本次账号资料刷新请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/accounts/{cid}/refresh-profile', { + params: { path: { cid: id } }, + signal, + })); }; // updateAccountLoginInfo 更新账号登录信息。 @@ -251,7 +313,11 @@ export const updateAccountLoginInfo = async (id: string, data: { /** clear_password 表示是否清理登录密码。 */ clear_password?: boolean; /** show_browser 表示是否显示浏览器。 */ show_browser?: boolean; }): Promise => { - return put(`/api/v1/accounts/${id}/login-info`, data); + return runContractRequest(/* signal 是本次账号登录信息更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/accounts/{cid}/login-info', { + params: { path: { cid: id } }, + body: data, + signal, + })); }; // getAllAISettings 读取全部人工智能设置。 diff --git a/frontend/app/features/session/api.ts b/frontend/app/features/session/api.ts index 7fc902b..190807b 100644 --- a/frontend/app/features/session/api.ts +++ b/frontend/app/features/session/api.ts @@ -1,5 +1,5 @@ import type { OperationResponse,SessionResponse } from '../../../shared/api-contract/session'; -import { get,post,type RequestControlOptions } from '../../../shared/http/client'; +import { contractClient, runContractRequest, type ContractRequestOptions } from '../../../shared/api-contract/client'; export type * from '../../../shared/api-contract/session'; /** 会话状态接口返回的只读传输契约。 */ @@ -29,13 +29,32 @@ export interface LoginRequest { } /** 以用户名密码或邮箱验证码建立管理会话。 */ -export const login = async (data: LoginRequest): Promise => post('/api/v1/session/login', data, { skipAuthLogout: true }); +export const login = async (data: LoginRequest): Promise => { + // response 是生成契约校验后的登录成功响应。 + const response = await runContractRequest( + /* signal 是本次登录请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/session/login', { body: data, signal }), + { skipAuthLogout: true }, + ); + return { ...response, token: response.token ?? undefined }; +}; /** 用首次设置的管理员密码完成系统初始化并建立会话。 */ -export const initializeAdmin = async (password: string): Promise => post('/api/v1/session/initialize', { password }, { skipAuthLogout: true }); +export const initializeAdmin = async (password: string): Promise => { + // response 是生成契约校验后的首次初始化成功响应。 + const response = await runContractRequest( + /* signal 是本次初始化请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/session/initialize', { body: { password }, signal }), + { skipAuthLogout: true }, + ); + return { ...response, token: response.token ?? undefined }; +}; /** 读取当前浏览器的认证与初始化状态,调用者可取消页面卸载前的请求。 */ -export const verifySession = async (options?: RequestControlOptions): Promise => get('/api/v1/session', undefined, options); +export const verifySession = async (options?: ContractRequestOptions): Promise => + runContractRequest(/* signal 是本次会话校验请求的超时与取消控制信号。 */ signal => contractClient.GET('/api/v1/session', { signal }), options); /** 结束当前浏览器会话。 */ -export const logout = async (): Promise => post('/api/v1/session/logout', {}); +export const logout = async (): Promise => { + // response 是注销接口仅返回的用户可见提示。 + const response = await runContractRequest(/* signal 是本次注销请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/session/logout', { body: {}, signal })); + return { success: true, message: response.message }; +}; diff --git a/frontend/app/features/settings/api.ts b/frontend/app/features/settings/api.ts index 08dc993..bc16abe 100644 --- a/frontend/app/features/settings/api.ts +++ b/frontend/app/features/settings/api.ts @@ -1,5 +1,6 @@ -import type { AIModelsResponse,OperationResponse,SystemSettings } from '../../../shared/api-contract/settings'; -import { get,post,put,type RequestControlOptions } from '../../../shared/http/client'; +import type { OperationResponse,SystemSettings } from '../../../shared/api-contract/settings'; +import { contractClient, runContractRequest } from '../../../shared/api-contract/client'; +import { type RequestControlOptions } from '../../../shared/http/client'; export type * from '../../../shared/api-contract/settings'; /** 设置页面使用的会话状态传输契约,避免跨 feature 依赖。 */ @@ -27,7 +28,7 @@ export type SensitiveSettingChange = { /** 系统设置更新请求,将普通配置与敏感命令分开传输。 */ export type SystemSettingsUpdate = { /** 非敏感配置字段。 */ - values?: Record; + values?: Record; /** 由服务端解释的敏感值变更命令。 */ secrets?: Record; }; @@ -36,10 +37,10 @@ export type SystemSettingsUpdate = { const SENSITIVE_SYSTEM_SETTING_KEYS = new Set(['ai_api_key', 'smtp_password', 'qq_reply_secret_key', 'captcha.remote_secret_key']); /** 将历史设置草稿转换为服务端要求的普通值与敏感命令结构。 */ -const normalizeSystemSettingsUpdate = (settings: Partial | SystemSettingsUpdate): Record => { - if ('values' in settings || 'secrets' in settings) return settings; +const normalizeSystemSettingsUpdate = (settings: Partial | SystemSettingsUpdate): SystemSettingsUpdate => { + if ('values' in settings || 'secrets' in settings) return settings as SystemSettingsUpdate; // values 保存普通设置,永不容纳秘密文本。 - const values: Record = {}; + const values: Record = {}; // secrets 保存服务端需要独立处理的敏感设置命令。 const secrets: Record = {}; for (const /* key、value 是当前待分流的设置键和值。 */ [key, value] of Object.entries(settings)) { @@ -48,7 +49,7 @@ const normalizeSystemSettingsUpdate = (settings: Partial | Syste secrets[key] = value === '' ? { action: 'clear' } : { action: 'replace', value: String(value) }; continue; } - values[key] = value; + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') values[key] = value; } return Object.keys(secrets).length > 0 ? { values, secrets } : values; }; @@ -72,29 +73,37 @@ const normalizeSettings = (settings: Record): SystemSettings => }; /** 修改当前管理员的密码。 */ -export const changePassword = async (currentPassword: string, newPassword: string): Promise => post('/api/v1/session/password', { current_password: currentPassword, new_password: newPassword }); +export const changePassword = async (currentPassword: string, newPassword: string): Promise => + runContractRequest(/* signal 是本次管理员密码更新请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/session/password', { body: { current_password: currentPassword, new_password: newPassword }, signal })); /** 修改当前管理员的登录名称与可选密码。 */ -export const updateLoginCredentials = async (data: { /** 当前密码用于服务端重新验证身份。 */ current_password: string; /** 新的管理员名称。 */ new_username: string; /** 可选的新密码。 */ new_password?: string }, options?: RequestControlOptions): Promise => put('/api/v1/session/credentials', data, options); +export const updateLoginCredentials = async (data: { /** 当前密码用于服务端重新验证身份。 */ current_password: string; /** 新的管理员名称。 */ new_username: string; /** 可选的新密码。 */ new_password?: string }, options?: RequestControlOptions): Promise => + runContractRequest(/* signal 是本次管理员凭据更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/session/credentials', { body: data, signal }), options); /** 获取系统设置;仅保留敏感值是否已配置的状态,不接收敏感明文。 */ export const getSystemSettings = async (options?: RequestControlOptions): Promise => { - // response 是服务端可能包裹在 data 中的设置响应。 - const response = await get<{ /** settings 是当前系统配置对象。 */ data?: Record; /** settings 是未包裹的兼容设置对象。 */ settings?: Record } & Record>('/api/v1/settings/system', undefined, options); - // settings 是去除 transport 包裹后的配置对象。 - const settings = response.data || response.settings || response; - return normalizeSettings(settings); + // response 是 OpenAPI 约束的脱敏系统设置键值对象。 + const response = await runContractRequest(/* signal 是本次系统设置读取请求的超时与取消控制信号。 */ signal => contractClient.GET('/api/v1/settings/system', { signal }), options); + return normalizeSettings(response); }; /** 保存普通系统配置和敏感设置命令。 */ -export const updateSystemSettings = async (settings: Partial | SystemSettingsUpdate, options?: RequestControlOptions): Promise => put('/api/v1/settings/system', normalizeSystemSettingsUpdate(settings), options); +export const updateSystemSettings = async (settings: Partial | SystemSettingsUpdate, options?: RequestControlOptions): Promise => + runContractRequest(/* signal 是本次系统设置更新请求的超时与取消控制信号。 */ signal => contractClient.PUT('/api/v1/settings/system', { + body: normalizeSystemSettingsUpdate(settings), + signal, + }), options); /** 向服务端请求指定人工智能服务的可用模型列表。 */ export const fetchAIModels = async (baseURL: string, apiKey = '', options?: RequestControlOptions): Promise => { // response 是模型发现接口的具名响应。 - const response = await post('/api/v1/settings/ai-models', { base_url: baseURL, api_key: apiKey }, options); + const response = await runContractRequest(/* signal 是本次模型发现请求的超时与取消控制信号。 */ signal => contractClient.POST('/api/v1/settings/ai-models', { + body: { base_url: baseURL, api_key: apiKey }, + signal, + }), options); return Array.isArray(response.models) ? response.models : []; }; /** 在保存登录凭据前读取当前会话状态。 */ -export const verifySession = async (options?: RequestControlOptions): Promise => get('/api/v1/session', undefined, options); +export const verifySession = async (options?: RequestControlOptions): Promise => + runContractRequest(/* signal 是本次设置页会话校验请求的超时与取消控制信号。 */ signal => contractClient.GET('/api/v1/session', { signal }), options); diff --git a/frontend/featureArchitecture.test.ts b/frontend/featureArchitecture.test.ts index 7aa1b3e..7a907ab 100644 --- a/frontend/featureArchitecture.test.ts +++ b/frontend/featureArchitecture.test.ts @@ -102,7 +102,7 @@ describe('React feature dependency boundaries', () => { test('production React code does not call fetch or axios outside the request boundary', () => { // violations 保存页面或组件中直接发起网络请求的源码路径。 const violations = productionSources() - .filter(file => file.relativePath !== 'shared/http/client.ts' && /\bfetch\s*\(|\baxios\b/.test(file.source) /* file 是当前待审计直接网络调用的生产模块。 */) + .filter(file => !['shared/http/client.ts', 'shared/api-contract/client.ts'].includes(file.relativePath) && /\bfetch\s*\(|\baxios\b/.test(file.source) /* file 是当前待审计直接网络调用的生产模块。 */) .map(file => file.relativePath /* 输出越过 HTTP 客户端的模块路径。 */); expect(violations).toEqual([]); diff --git a/frontend/shared/api-contract/client.ts b/frontend/shared/api-contract/client.ts new file mode 100644 index 0000000..210f67e --- /dev/null +++ b/frontend/shared/api-contract/client.ts @@ -0,0 +1,81 @@ +import createClient from 'openapi-fetch'; + +import { ApiError, controlledSignal, notifyAuthExpired, type RequestControlOptions } from '../http/client'; + +import type { paths } from './generated/schema'; + +// contractRequestTimeoutMs 是非上传契约请求沿用的默认超时,保持旧 HTTP client 的用户体验。 +const contractRequestTimeoutMs = 30_000; + +// ContractRequestOptions 是类型化 operation 运行时使用的取消、超时与登录态控制参数。 +export type ContractRequestOptions = RequestControlOptions & { + // skipAuthLogout 防止登录和首次初始化失败时错误清理现有页面状态。 + skipAuthLogout?: boolean; +}; + +// ContractResult 是 openapi-fetch 对单个 operation 的成功数据、错误数据和原始响应封装。 +type ContractResult = { + // data 是成功状态码且符合 OpenAPI 响应类型时解析出的数据。 + data?: T; + // error 是非成功状态码解析出的统一错误 envelope 或未知载荷。 + error?: unknown; + // response 是保留状态码和响应头的底层响应对象。 + response: Response; +}; + +// contractFetch 为 openapi-fetch 注入现有浏览器 Cookie 与请求地址兼容语义。 +const contractFetch: typeof fetch = async (input, init) => { + // response 是使用既有 Cookie 策略发出的 HTTP 响应。 + // requestURL 是 openapi-fetch 根据 baseUrl 生成的绝对地址;测试环境需还原为相对路径以复用既有 fetch fixture。 + const requestURL = new URL(typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url); + // request 是合并 openapi-fetch 已构造请求与可选 init 后的完整请求对象。 + const request = input instanceof Request ? input : new Request(input, init); + // body 是恢复为文本的 JSON 请求载荷;GET/HEAD 不能携带请求体。 + const body = request.method === 'GET' || request.method === 'HEAD' ? undefined : await request.clone().text(); + // fetchInput 是测试环境还原后的相对 API 地址,浏览器环境继续保留绝对 origin。 + const fetchInput = requestURL.origin === 'http://localhost' ? `${requestURL.pathname}${requestURL.search}` : input; + // response 是使用旧 client 等价方法、请求体、取消信号和 Cookie 策略发出的 HTTP 响应。 + const response = await fetch(fetchInput, { + method: request.method, + headers: request.headers, + body, + signal: request.signal, + credentials: 'include', + }); + return response; +}; + +// contractClient 是唯一持有生成 paths 类型并执行版本化 HTTP operation 的共享实例。 +// contractBaseUrl 是浏览器生产环境的当前 origin;Node 测试使用可被 fetch fixture 还原的占位 origin。 +const contractBaseUrl = typeof location === 'undefined' ? 'http://localhost' : location.origin; + +export const contractClient = createClient({ baseUrl: contractBaseUrl, fetch: contractFetch }); + +// runContractRequest 执行类型化 operation,并恢复旧 client 的超时、取消和 ApiError 行为。 +export async function runContractRequest( + execute: (signal: AbortSignal) => Promise>, + options: ContractRequestOptions = {}, +): Promise { + // control 统一管理外部 AbortSignal 与默认请求超时。 + const control = controlledSignal(options.signal, options.timeoutMs ?? contractRequestTimeoutMs); + try { + // result 是 openapi-fetch 返回的成功或错误响应封装。 + const result = await execute(control.signal); + if (result.response.status === 401 && !options.skipAuthLogout) notifyAuthExpired(); + if (result.error !== undefined) { + throw new ApiError(result.response.status, result.error); + } + if (result.data === undefined) { + throw new ApiError(result.response.status, undefined); + } + return result.data; + } catch (error /* error 是底层 fetch、响应解析或 ApiError 抛出的原始失败原因。 */) { + // error 是底层 fetch、响应解析或 ApiError 抛出的原始失败原因。 + if (control.signal.aborted) { + throw new Error(options.signal?.aborted ? '请求已取消' : '请求超时,请稍后重试'); + } + throw error; + } finally { + control.cleanup(); + } +} diff --git a/frontend/shared/api-contract/generated/schema.ts b/frontend/shared/api-contract/generated/schema.ts index c430907..7eb6589 100644 --- a/frontend/shared/api-contract/generated/schema.ts +++ b/frontend/shared/api-contract/generated/schema.ts @@ -1893,6 +1893,95 @@ export interface components { AccountStatusRequest: { enabled: boolean; }; + AccountSettingsUpdateRequest: { + cookie?: string; + remark?: string; + auto_confirm?: boolean; + pause_duration?: number; + username?: string; + login_password?: string; + clear_password?: boolean; + show_browser?: boolean; + channel_ids?: number[]; + }; + AccountLoginInfoRequest: { + username?: string; + login_password?: string; + clear_password?: boolean; + show_browser?: boolean; + }; + LongLoginSettingsRequest: { + enabled: boolean; + }; + LongLoginResponse: { + can_open_long_login: boolean; + enabled: boolean; + }; + AutoConfirmRequest: { + auto_confirm: boolean; + }; + AutoConfirmResponse: { + auto_confirm: boolean; + }; + AccountRemarkRequest: { + remark: string; + }; + PauseDurationRequest: { + pause_duration: number; + }; + PauseDurationResponse: { + pause_duration: number; + paused_until: number; + paused: boolean; + }; + CookieSettingsResponse: { + success: boolean; + paused_until: number; + paused: boolean; + }; + CookieProfileResponse: { + success: boolean; + id: string; + nickname: string; + avatar_url: string; + profile_error: string; + }; + RuntimeStatus: { + /** @enum {string} */ + state: "starting" | "connecting" | "online" | "reconnecting" | "auth_expired" | "verification_required" | "runtime_conflict" | "error" | "stopped" | "disabled"; + message?: string; + connected: boolean; + failures: number; + /** Format: date-time */ + updated_at: string; + }; + RuntimeStatusMap: { + [key: string]: components["schemas"]["RuntimeStatus"]; + }; + AIModelsRequest: { + base_url: string; + api_key?: string; + }; + AIModelsResponse: { + models: string[]; + }; + SecretSettingChange: { + /** @enum {string} */ + action: "retain" | "replace" | "clear"; + value?: string; + }; + SystemSettingValueMap: { + [key: string]: string | number | boolean; + }; + SystemSettingsUpdateRequest: { + values?: components["schemas"]["SystemSettingValueMap"]; + secrets?: { + [key: string]: components["schemas"]["SecretSettingChange"]; + }; + }; + SystemSettingsResponse: { + [key: string]: string | number | boolean; + }; SessionStatusResponse: { authenticated: boolean; initialized: boolean; @@ -2571,7 +2660,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["AutoConfirmResponse"]; }; }; /** @description 统一错误响应 */ @@ -2630,7 +2719,11 @@ export interface operations { }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["AutoConfirmRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -2638,7 +2731,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["OperationResponse"]; }; }; /** @description 统一错误响应 */ @@ -2697,7 +2790,11 @@ export interface operations { }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["AccountLoginInfoRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -2705,7 +2802,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["OperationResponse"]; }; }; /** @description 统一错误响应 */ @@ -2772,7 +2869,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["LongLoginResponse"]; }; }; /** @description 统一错误响应 */ @@ -2831,7 +2928,11 @@ export interface operations { }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["LongLoginSettingsRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -2839,7 +2940,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["LongLoginResponse"]; }; }; /** @description 统一错误响应 */ @@ -2906,7 +3007,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["PauseDurationResponse"]; }; }; /** @description 统一错误响应 */ @@ -2965,7 +3066,11 @@ export interface operations { }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["PauseDurationRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -2973,7 +3078,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["CookieSettingsResponse"]; }; }; /** @description 统一错误响应 */ @@ -3040,7 +3145,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["CookieProfileResponse"]; }; }; /** @description 统一错误响应 */ @@ -3099,7 +3204,11 @@ export interface operations { }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["AccountRemarkRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -3107,7 +3216,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["OperationResponse"]; }; }; /** @description 统一错误响应 */ @@ -3166,7 +3275,11 @@ export interface operations { }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["AccountSettingsUpdateRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -3174,7 +3287,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["CookieSettingsResponse"]; }; }; /** @description 统一错误响应 */ @@ -3375,7 +3488,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["RuntimeStatusMap"]; }; }; /** @description 统一错误响应 */ @@ -10301,7 +10414,11 @@ export interface operations { path?: never; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["AIModelsRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -10309,7 +10426,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["AIModelsResponse"]; }; }; /** @description 统一错误响应 */ @@ -10573,7 +10690,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["SystemSettingsResponse"]; }; }; /** @description 统一错误响应 */ @@ -10630,7 +10747,11 @@ export interface operations { path?: never; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["SystemSettingsUpdateRequest"]; + }; + }; responses: { /** @description 成功 */ 200: { @@ -10638,7 +10759,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ApiResponse"]; + "application/json": components["schemas"]["OperationResponse"]; }; }; /** @description 统一错误响应 */ diff --git a/frontend/shared/http/client.ts b/frontend/shared/http/client.ts index e350b46..5359c70 100644 --- a/frontend/shared/http/client.ts +++ b/frontend/shared/http/client.ts @@ -55,14 +55,15 @@ export class ApiError extends Error { } } -const notifyAuthExpired = () => { +// notifyAuthExpired 合并同一批未授权响应,避免多个并发请求反复触发会话清理。 +export const notifyAuthExpired = () => { if (authLogoutPending || typeof window === 'undefined') return; authLogoutPending = true; window.dispatchEvent(new Event('auth:logout')); queueMicrotask(() => { authLogoutPending = false; } /* 微任务结束后允许下一次未授权响应重新触发登出通知。 */); -}; /* notifyAuthExpired 合并同一批 401 响应,避免重复触发会话清理。 */ +}; const buildQueryString = (params?: QueryParams): string => { if (!params) return ''; @@ -154,7 +155,8 @@ export const postForm = async (url: string, body: FormData, options: RequestC return payload as T; }; /* postForm 表示postForm。 */ -const controlledSignal = (external: AbortSignal | undefined, timeoutMs: number) => { +// controlledSignal 组合外部取消与内部超时,调用方必须在请求结束后执行 cleanup。 +export const controlledSignal = (external: AbortSignal | undefined, timeoutMs: number) => { const controller = new AbortController(); /* controller 表示controller。 */ const abortFromExternal = () => controller.abort(external?.reason); /* abortFromExternal 表示abortFromExternal。 */ if (external?.aborted) abortFromExternal(); diff --git a/internal/server/openapi_response_contract_test.go b/internal/server/openapi_response_contract_test.go new file mode 100644 index 0000000..185f65c --- /dev/null +++ b/internal/server/openapi_response_contract_test.go @@ -0,0 +1,208 @@ +package server + +import ( + "bytes" + "context" + "io" + "net/http" + "net/http/httptest" + "path/filepath" + "strings" + "testing" + + "github.com/getkin/kin-openapi/openapi3" + "github.com/getkin/kin-openapi/openapi3filter" + "github.com/getkin/kin-openapi/routers/legacy" +) + +// assertOpenAPIResponse 验证真实 HTTP 响应的状态码、Content-Type 和 JSON 形状符合对应 OpenAPI operation。 +func assertOpenAPIResponse(t *testing.T, request *http.Request, recorder *httptest.ResponseRecorder) { + t.Helper() + // specPath 是从 Server 包测试目录定位的唯一 OpenAPI 契约文件。 + specPath := filepath.Join("..", "..", "api", "openapi.yaml") + // document、loadErr 分别是解析后的契约文档和加载失败原因。 + document, loadErr := openapi3.NewLoader().LoadFromFile(specPath) + if loadErr != nil { + t.Fatalf("加载 OpenAPI 契约失败: %v", loadErr) + } + // router、routerErr 分别是将 OpenAPI operation 映射到 HTTP 请求的路由器和构建失败原因。 + router, routerErr := legacy.NewRouter(document) + if routerErr != nil { + t.Fatalf("构建 OpenAPI 路由器失败: %v", routerErr) + } + // route、pathParams、findErr 分别是匹配到的 operation、解析出的路径参数和匹配失败原因。 + route, pathParams, findErr := router.FindRoute(request) + if findErr != nil { + t.Fatalf("OpenAPI 未匹配请求 %s %s: %v", request.Method, request.URL.Path, findErr) + } + // requestInput 是响应校验需要的 operation 与路径参数上下文。 + requestInput := &openapi3filter.RequestValidationInput{Request: request, PathParams: pathParams, Route: route} + // responseInput 是实际响应的状态、头和可重复读取的 JSON 内容。 + responseInput := &openapi3filter.ResponseValidationInput{ + RequestValidationInput: requestInput, + Status: recorder.Code, + Header: recorder.Result().Header, + Body: io.NopCloser(bytes.NewReader(recorder.Body.Bytes())), + } + // validationErr 表示真实 handler 输出违反 OpenAPI 响应契约的具体原因。 + if validationErr := openapi3filter.ValidateResponse(context.Background(), responseInput); validationErr != nil { + t.Fatalf("响应不符合 OpenAPI: %s %s status=%d body=%s err=%v", request.Method, request.URL.Path, recorder.Code, recorder.Body.String(), validationErr) + } +} + +// assertOpenAPISuccessResponse 验证预期成功的真实路由既返回 200,又满足对应 operation 的响应契约。 +func assertOpenAPISuccessResponse(t *testing.T, request *http.Request, recorder *httptest.ResponseRecorder) { + t.Helper() + if recorder.Code != http.StatusOK { + t.Fatalf("成功响应状态错误: %s %s status=%d body=%s", request.Method, request.URL.Path, recorder.Code, recorder.Body.String()) + } + assertOpenAPIResponse(t, request, recorder) +} + +// TestOpenAPISessionAndQRResponses 验证阶段二会话与二维码主链路的成功、未认证和风控响应均满足真实契约。 +func TestOpenAPISessionAndQRResponses(t *testing.T) { + // srv、store、cleanup 分别是测试 Server、持久化夹具和资源释放函数。 + srv, store, cleanup := newTestServer(t) + defer cleanup() + setTestQRLogin(srv, &fakeQRLoginService{status: map[string]any{"status": "verification_required", "face_qr_url": "https://example.invalid/face.png", "verification_screenshot": "https://example.invalid/screenshot.png"}}) + // handler 是包含认证和版本化路由的真实 chi Router。 + handler := srv.Router() + // loginRequest 是登录成功的版本化请求。 + loginRequest := httptest.NewRequest(http.MethodPost, "/api/v1/session/login", bytes.NewBufferString(`{"username":"admin","password":"pw"}`)) + // loginRecorder 是捕获版本化登录响应的测试记录器。 + loginRecorder := httptest.NewRecorder() + handler.ServeHTTP(loginRecorder, loginRequest) + assertOpenAPISuccessResponse(t, loginRequest, loginRecorder) + // sessionCookie 是登录响应建立的认证 Cookie,用于后续 QR operation。 + sessionCookie := loginHelper(t, handler) + // verifyRequest 是携带认证 Cookie 的会话状态读取请求。 + verifyRequest := httptest.NewRequest(http.MethodGet, "/api/v1/session", nil) + verifyRequest.AddCookie(sessionCookie) + // verifyRecorder 是捕获版本化会话校验响应的测试记录器。 + verifyRecorder := httptest.NewRecorder() + handler.ServeHTTP(verifyRecorder, verifyRequest) + assertOpenAPISuccessResponse(t, verifyRequest, verifyRecorder) + // unauthenticatedQRRequest 是缺少认证 Cookie 的二维码请求,必须返回统一 401 错误 envelope。 + unauthenticatedQRRequest := httptest.NewRequest(http.MethodPost, "/api/v1/qr-login/generate", nil) + // unauthenticatedQRRecorder 是捕获未认证二维码请求错误响应的测试记录器。 + unauthenticatedQRRecorder := httptest.NewRecorder() + handler.ServeHTTP(unauthenticatedQRRecorder, unauthenticatedQRRequest) + assertOpenAPIResponse(t, unauthenticatedQRRequest, unauthenticatedQRRecorder) + // qrSessionID 是为状态查询建立的归属会话标识。 + qrSessionID := "openapi-qr-session" + // ownQRSession 建立当前管理员对二维码会话的归属记录。 + ownQRSession(t, srv, store, qrSessionID) + // qrStatusRequest 是包含风控展示字段的二维码状态请求。 + qrStatusRequest := httptest.NewRequest(http.MethodGet, "/api/v1/qr-login/check/"+qrSessionID, nil) + qrStatusRequest.AddCookie(sessionCookie) + // qrStatusRecorder 是捕获二维码风控状态响应的测试记录器。 + qrStatusRecorder := httptest.NewRecorder() + handler.ServeHTTP(qrStatusRecorder, qrStatusRequest) + assertOpenAPIResponse(t, qrStatusRequest, qrStatusRecorder) +} + +// TestOpenAPIAccountAndSystemResponses 验证阶段二账户与系统设置主链路的真实成功响应和未认证错误都符合 OpenAPI。 +func TestOpenAPIAccountAndSystemResponses(t *testing.T) { + // srv、_、cleanup 分别是测试 Server、无需直接访问的存储和测试资源释放函数。 + srv, _, cleanup := newTestServer(t) + defer cleanup() + // handler 是包含账户和系统设置版本化路由的真实 chi Router。 + handler := srv.Router() + // sessionCookie 是管理员会话 Cookie,用于构造受保护 operation 的成功场景。 + sessionCookie := loginHelper(t, handler) + // unauthenticatedRequest 是未携带会话的账户运行状态请求,必须使用统一错误响应。 + unauthenticatedRequest := httptest.NewRequest(http.MethodGet, "/api/v1/accounts/runtime-status", nil) + // unauthenticatedRecorder 是捕获未认证账户状态响应的记录器。 + unauthenticatedRecorder := httptest.NewRecorder() + handler.ServeHTTP(unauthenticatedRecorder, unauthenticatedRequest) + assertOpenAPIResponse(t, unauthenticatedRequest, unauthenticatedRecorder) + + // runtimeRequest 是读取当前用户账号运行状态的成功请求。 + runtimeRequest := httptest.NewRequest(http.MethodGet, "/api/v1/accounts/runtime-status", nil) + runtimeRequest.AddCookie(sessionCookie) + // runtimeRecorder 是捕获运行状态映射的记录器。 + runtimeRecorder := httptest.NewRecorder() + handler.ServeHTTP(runtimeRecorder, runtimeRequest) + assertOpenAPISuccessResponse(t, runtimeRequest, runtimeRecorder) + if strings.Contains(runtimeRecorder.Body.String(), "cookie") || strings.Contains(runtimeRecorder.Body.String(), "password") { + t.Fatalf("账号运行状态泄漏敏感字段: %s", runtimeRecorder.Body.String()) + } + + // longLoginRequest 是读取账号长期登录状态的请求;测试平台未提供长登录 returnValue,因此验证统一错误响应。 + longLoginRequest := httptest.NewRequest(http.MethodGet, "/api/v1/accounts/acc1/long-login", nil) + longLoginRequest.AddCookie(sessionCookie) + // longLoginRecorder 是捕获长期登录状态响应的记录器。 + longLoginRecorder := httptest.NewRecorder() + handler.ServeHTTP(longLoginRecorder, longLoginRequest) + assertOpenAPIResponse(t, longLoginRequest, longLoginRecorder) + + // settingsRequest 是保存账号备注、暂停时长和自动确认开关的聚合成功请求。 + settingsRequest := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/settings", strings.NewReader(`{"remark":"OpenAPI 账号","pause_duration":10,"auto_confirm":true}`)) + settingsRequest.AddCookie(sessionCookie) + // settingsRecorder 是捕获账号聚合设置响应的记录器。 + settingsRecorder := httptest.NewRecorder() + handler.ServeHTTP(settingsRecorder, settingsRequest) + assertOpenAPISuccessResponse(t, settingsRequest, settingsRecorder) + + // autoConfirmRequest 是单独保存自动确认开关的成功请求。 + autoConfirmRequest := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/auto-confirm", strings.NewReader(`{"auto_confirm":false}`)) + autoConfirmRequest.AddCookie(sessionCookie) + // autoConfirmRecorder 是捕获自动确认操作响应的记录器。 + autoConfirmRecorder := httptest.NewRecorder() + handler.ServeHTTP(autoConfirmRecorder, autoConfirmRequest) + assertOpenAPISuccessResponse(t, autoConfirmRequest, autoConfirmRecorder) + + // pauseRequest 是更新账号自动化暂停时长的成功请求。 + pauseRequest := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/pause-duration", strings.NewReader(`{"pause_duration":15}`)) + pauseRequest.AddCookie(sessionCookie) + // pauseRecorder 是捕获暂停设置响应的记录器。 + pauseRecorder := httptest.NewRecorder() + handler.ServeHTTP(pauseRecorder, pauseRequest) + assertOpenAPISuccessResponse(t, pauseRequest, pauseRecorder) + + // remarkRequest 是更新非敏感账号备注的成功请求。 + remarkRequest := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/remark", strings.NewReader(`{"remark":"OpenAPI 新备注"}`)) + remarkRequest.AddCookie(sessionCookie) + // remarkRecorder 是捕获账号备注操作响应的记录器。 + remarkRecorder := httptest.NewRecorder() + handler.ServeHTTP(remarkRecorder, remarkRequest) + assertOpenAPISuccessResponse(t, remarkRequest, remarkRecorder) + + // profileRequest 是刷新账号公开资料的成功请求。 + profileRequest := httptest.NewRequest(http.MethodPost, "/api/v1/accounts/acc1/refresh-profile", nil) + profileRequest.AddCookie(sessionCookie) + // profileRecorder 是捕获账号资料刷新响应的记录器。 + profileRecorder := httptest.NewRecorder() + handler.ServeHTTP(profileRecorder, profileRequest) + assertOpenAPISuccessResponse(t, profileRequest, profileRecorder) + + // loginInfoRequest 是只更新展示浏览器选项且不携带登录秘密的成功请求。 + loginInfoRequest := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/login-info", strings.NewReader(`{"username":"openapi-user","show_browser":false}`)) + loginInfoRequest.AddCookie(sessionCookie) + // loginInfoRecorder 是捕获登录资料操作响应的记录器。 + loginInfoRecorder := httptest.NewRecorder() + handler.ServeHTTP(loginInfoRecorder, loginInfoRequest) + assertOpenAPISuccessResponse(t, loginInfoRequest, loginInfoRecorder) + if strings.Contains(loginInfoRecorder.Body.String(), "password") { + t.Fatalf("账号登录资料响应泄漏密码字段: %s", loginInfoRecorder.Body.String()) + } + + // systemRequest 是读取脱敏系统设置的管理员成功请求。 + systemRequest := httptest.NewRequest(http.MethodGet, "/api/v1/settings/system", nil) + systemRequest.AddCookie(sessionCookie) + // systemRecorder 是捕获系统设置键值对象的记录器。 + systemRecorder := httptest.NewRecorder() + handler.ServeHTTP(systemRecorder, systemRequest) + assertOpenAPISuccessResponse(t, systemRequest, systemRecorder) + if strings.Contains(systemRecorder.Body.String(), "smtp_password") || strings.Contains(systemRecorder.Body.String(), "ai_api_key") { + t.Fatalf("系统设置响应泄漏敏感字段: %s", systemRecorder.Body.String()) + } + + // updateSystemRequest 是修改普通日志级别设置的成功请求。 + updateSystemRequest := httptest.NewRequest(http.MethodPut, "/api/v1/settings/system", strings.NewReader(`{"values":{"log_level":"info"}}`)) + updateSystemRequest.AddCookie(sessionCookie) + // updateSystemRecorder 是捕获系统设置保存响应的记录器。 + updateSystemRecorder := httptest.NewRecorder() + handler.ServeHTTP(updateSystemRecorder, updateSystemRequest) + assertOpenAPISuccessResponse(t, updateSystemRequest, updateSystemRecorder) +} diff --git a/internal/webui/static/assets/AccountList-DgwrfNi_.js b/internal/webui/static/assets/AccountList-DgwrfNi_.js new file mode 100644 index 0000000..52281f5 --- /dev/null +++ b/internal/webui/static/assets/AccountList-DgwrfNi_.js @@ -0,0 +1,3 @@ +import{b as ie,j as e,a as n,c as Oe}from"./react-vendor-l-BBvuKH.js";import{r as O,c as Pe,g as ce,o as qe,p as Le,a as G,b as Ge}from"./index-WrujSo30.js";import{n as ue,X as de,f as ze,L as J,o as Te,p as We,q as Ve,r as Ie,s as Ee,U as De,t as ae,u as Ke,k as _e,Q as Ne,v as $e,R as He,w as Je,x as Xe,y as ve,K as Ye,z as Ze,F as Fe,e as es,H as ss}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const ts=(t,s)=>{const r=t.avatar_url||"";if(!r)return"";try{const a=new URL(r,window.location.origin);return a.hostname.endsWith("alicdn.com")&&a.searchParams.set("_v",s),a.toString()}catch{return r}},as=async t=>{const s=await O(l=>G.GET("/api/v1/accounts/details",{signal:l}),t),r=Pe(s,["data","accounts","details"]),a=Date.now().toString();return r.map(l=>({id:l.id,cookie_configured:l.has_cookie===!0,enabled:l.enabled,auto_confirm:l.auto_confirm,remark:l.remark,pause_duration:l.pause_duration,paused_until:Number(l.paused_until||0),paused:l.paused===!0,username:l.username||"",login_password_configured:void 0,show_browser:l.show_browser===!0||l.show_browser===1||l.show_browser==="1"||l.show_browser==="true",nickname:l.nickname||l.remark||`账号 ${l.id.substring(0,6)}`,avatar_url:ts(l,a),profile_error:l.profile_error||"",ai_enabled:!1,auto_rate_enabled:l.auto_rate_enabled,rate_content:l.rate_content||"不错的买家,交易愉快",auto_polish_enabled:l.auto_polish_enabled,polish_time:l.polish_time||"03:00",last_rate_scan_at:Number(l.last_rate_scan_at||0),last_polish_date:l.last_polish_date||"",last_polish_at:Number(l.last_polish_at||0)}))},rs=async t=>await O(r=>G.GET("/api/v1/accounts/runtime-status",{signal:r}),t),ns=async t=>O(s=>G.POST("/api/v1/qr-login/generate",{signal:s}),{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),ls=async(t,s)=>O(r=>G.GET("/api/v1/qr-login/check/{session_id}",{params:{path:{session_id:t}},signal:r}),{signal:s,timeoutMs:1e4}),os=async(t,s)=>O(r=>G.POST("/api/v1/qr-login/complete-verification/{session_id}",{params:{path:{session_id:t}},body:{target_account_id:s||""},signal:r})),is=async(t,s)=>O(r=>G.PUT("/api/v1/accounts/{cid}/status",{params:{path:{cid:t}},body:{enabled:s},signal:r})),cs=async t=>O(s=>G.DELETE("/api/v1/accounts/{cid}",{params:{path:{cid:t}},signal:s})),ds=async(t,s,r)=>O(a=>G.PUT("/api/v1/accounts/{cid}/pause-duration",{params:{path:{cid:t}},body:{pause_duration:s},signal:a}),r),us=async(t,s,r)=>O(a=>G.PUT("/api/v1/accounts/{cid}/settings",{params:{path:{cid:t}},body:s,signal:a}),r),xs=async(t,s)=>O(r=>G.GET("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:t}},signal:r}),s),ms=async(t,s,r)=>O(a=>G.PUT("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:t}},body:{enabled:s},signal:a}),r),bs=async(t,s)=>O(r=>G.POST("/api/v1/password-login",{body:t,signal:r}),s),hs=async(t,s)=>O(a=>G.GET("/api/v1/password-login/check/{session_id}",{params:{path:{session_id:t}},signal:a}),{signal:s,timeoutMs:1e4}),gs=async(t,s)=>O(r=>G.DELETE("/api/v1/password-login/cancel/{session_id}",{params:{path:{session_id:t}},signal:r}),s),ps=async t=>O(s=>G.POST("/api/v1/accounts/{cid}/refresh-profile",{params:{path:{cid:t}},signal:s})),fs=async t=>{const s=await ce("/api/v1/settings/ai-reply",void 0,t);return qe(s,["settings","data","result"])||{}},ys=async(t,s)=>ce(`/api/v1/settings/ai-reply/${t}`,void 0,s),js=async(t,s,r)=>{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 Le(`/api/v1/settings/ai-reply/${t}`,a,r)},ws=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)},_s=async t=>{const s=await ce("/api/v1/notifications/channels",void 0,t);return{success:!0,data:Pe(s,["data","channels","items"]).map(a=>{const l={},c=a.type==="ding_talk"?"dingtalk":a.type==="lark"?"feishu":a.type;return{id:String(a.id),name:a.name,type:c,config:l,event_types:ws(a.event_types),enabled:a.enabled}})}},Ns=async(t,s)=>{const r=await ce(`/api/v1/notifications/accounts/${t}/bindings`,void 0,s),a=qe(r,["data","result"])||{};return Array.isArray(a.channel_ids)?a.channel_ids:[]},vs=({account:t,settings:s,saving:r,onChange:a,onClose:l,onSave:c})=>{const i=u=>a({...s,...u}),d=()=>i({ai_enabled:!s.ai_enabled}),b=u=>i({max_discount_percent:parseInt(u.target.value,10)||0}),m=u=>i({max_discount_amount:parseInt(u.target.value,10)||0}),f=u=>i({max_bargain_rounds:parseInt(u.target.value,10)||1}),h=u=>i({custom_prompts:u.target.value});return ie.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(ue,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{onClick:l,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0","aria-label":"关闭 AI 设置",children:e.jsx(de,{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(ue,{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:d,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.ai_enabled?"bg-brand":"bg-gray-300"}`,"aria-label":"切换 AI 自动回复",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.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:s.max_discount_percent,onChange:b,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:s.max_discount_amount,onChange:m,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:s.max_bargain_rounds,onChange:f,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:s.custom_prompts,onChange:h,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(ze,{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:l,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:r,children:"取消"}),e.jsxs("button",{onClick:(()=>void c()),className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:r,children:[r?e.jsx(J,{className:"w-4 h-4 animate-spin"}):e.jsx(Te,{className:"w-4 h-4"}),r?"保存中...":"保存"]})]})})]})}),document.body)},ke=async(t,s)=>ce(`/api/v1/account-tasks/${t}`,void 0,s),Ce=async(t,s,r)=>Le(`/api/v1/account-tasks/${t}`,s,r),ks=async(t,s,r)=>Ge(`/api/v1/account-tasks/${t}/run`,{task_type:s},{timeoutMs:12e4,...r}),Se=t=>({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}),Z=(t,s,r)=>t===s&&!r.aborted,je=(t,s)=>t instanceof Error?t.message:s,we=t=>t instanceof Error&&t.message==="请求已取消",Re=(t,s)=>!t&&s==="",Cs=({account:t,onSaved:s})=>{const[r,a]=n.useState(()=>Se(t)),[l,c]=n.useState(!0),[i,d]=n.useState(!1),[b,m]=n.useState(""),[f,h]=n.useState(""),[u,A]=n.useState(null),[k,g]=n.useState(null),p=n.useRef(0),L=n.useRef(null);n.useEffect(()=>{var N;const S=++p.current;(N=L.current)==null||N.abort();const j=new AbortController;return L.current=j,a(Se(t)),A(null),h(""),d(!1),m(""),g(null),c(!0),ke(t.id,{signal:j.signal}).then(R=>{Z(p.current,S,j.signal)&&a(R)}).catch(R=>{Z(p.current,S,j.signal)&&!we(R)&&h(je(R,"加载任务设置失败"))}).finally(()=>{Z(p.current,S,j.signal)&&c(!1)}),(()=>j.abort())},[t.id]),n.useEffect(()=>(()=>{var S;return(S=L.current)==null?void 0:S.abort()}),[]);const U=n.useCallback(async()=>{var N;if(!Re(i,b))return;const S=++p.current;(N=L.current)==null||N.abort();const j=new AbortController;L.current=j,d(!0),h(""),g(null);try{const R=await Ce(t.id,r,{signal:j.signal});if(!Z(p.current,S,j.signal))return;a(R),s(R)}catch(R){Z(p.current,S,j.signal)&&!we(R)&&(h(je(R,"保存失败")),g(()=>U))}finally{Z(p.current,S,j.signal)&&d(!1)}},[t.id,r,s,b,i]),M=n.useCallback(async S=>{var R;if(!Re(i,b)||!t.enabled)return;const j=++p.current;(R=L.current)==null||R.abort();const N=new AbortController;L.current=N,m(S),h(""),A(null),g(null);try{await Ce(t.id,r,{signal:N.signal});const w=await ks(t.id,S,{signal:N.signal}),P=await ke(t.id,{signal:N.signal});if(!Z(p.current,j,N.signal))return;A(w.summary),a(P),s(P)}catch(w){Z(p.current,j,N.signal)&&!we(w)&&(h(je(w,"任务执行失败")),g(()=>(()=>M(S))))}finally{Z(p.current,j,N.signal)&&m("")}},[t.enabled,t.id,r,s,b,i]),I=n.useCallback(async()=>{k&&await k()},[k]);return{form:r,loading:l,saving:i,running:b,summary:u,error:f,retryAvailable:k!==null,setForm:a,save:U,run:M,retry:I}},Ae=({checked:t,onChange:s,label:r})=>e.jsx("button",{type:"button","aria-label":r,"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":""}`})}),Ss=({account:t,onClose:s,onSaved:r})=>{const{form:a,loading:l,saving:c,running:i,error:d,summary:b,retryAvailable:m,setForm:f,save:h,run:u,retry:A}=Cs({account:t,onSaved:r});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(de,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[l&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",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(We,{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(Ae,{checked:a.auto_rate_enabled,onChange:(()=>f(k=>({...k,auto_rate_enabled:!k.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:a.rate_content,maxLength:500,onChange:(k=>f(g=>({...g,rate_content:k.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:["最近扫描:",a.last_rate_scan_at?new Date(a.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:i!==""||!t.enabled,onClick:(()=>void u("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:[i==="auto_rate"?e.jsx(J,{className:"h-4 w-4 animate-spin"}):e.jsx(Ve,{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(Ie,{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(Ae,{checked:a.auto_polish_enabled,onChange:(()=>f(k=>({...k,auto_polish_enabled:!k.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:a.polish_time,onChange:(k=>f(g=>({...g,polish_time:k.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:i!==""||!t.enabled,onClick:(()=>void u("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:[i==="auto_polish"?e.jsx(J,{className:"h-4 w-4 animate-spin"}):e.jsx(Ee,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",a.last_polish_at?new Date(a.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),b&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",b.found," 项,成功 ",b.success,",失败 ",b.failed,",跳过 ",b.skipped,"。",b.message||""]}),d&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:[e.jsx("span",{children:d}),m&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>void A()),children:"重试"})]})]}),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:c||i!=="",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:c||i!==""||a.auto_rate_enabled&&!a.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:[c?e.jsx(J,{className:"h-4 w-4 animate-spin"}):e.jsx(Te,{className:"h-4 w-4"}),"保存"]})]})})]})})},Rs=(t,s)=>{if(!t||!s)return!1;const r=Date.parse(t),a=Date.parse(s);return Number.isFinite(r)&&Number.isFinite(a)&&at.map(r=>{const a=s[r.id];return!a||Rs(r.runtime_updated_at,a.updated_at)?r:{...r,runtime_state:a.state,runtime_message:a.message||"",runtime_connected:a.connected,runtime_updated_at:a.updated_at}}),Ps=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"runtime_conflict":return{label:"运行状态冲突",badge:"bg-red-100 text-red-700",dot:"bg-red-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"}}},qs=Oe.memo(function({account:s,refreshing:r,deleting:a,onRefreshProfile:l,onReauthorize:c,onEdit:i,onAI:d,onTasks:b,onToggle:m,onDelete:f}){const h=Ps(s),u=s.runtime_state==="auth_expired"||s.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:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.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(De,{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:s.runtime_state==="online"&&e.jsx(ae,{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:s.nickname||s.remark||`账号 ${s.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}),s.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(ue,{className:"w-3 h-3"})," AI"]}),s.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(Ke,{className:"h-3 w-3"})," 自动评价"]}),s.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(Ie,{className:"h-3 w-3"})," 每日擦亮"]}),s.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(ae,{className:"h-3 w-3"})," 自动确认发货"]}),s.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:s.profile_error,children:[e.jsx(_e,{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:s.remark||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",s.id]})]}),s.runtime_message&&s.runtime_state!=="online"&&s.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${u?"text-red-700":"text-amber-700"}`,children:[e.jsx(_e,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:s.runtime_message}),u&&e.jsxs("button",{type:"button",onClick:(()=>c(s)),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(Ne,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),s.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($e,{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:(()=>l(s)),disabled:r,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(He,{className:`w-5 h-5 ${r?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>c(s)),className:`p-3 rounded-xl transition-colors ${u?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(Ne,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>i(s)),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Je,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>d(s)),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(ue,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>b(s)),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(Ee,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>m(s.id,s.enabled)),className:`p-3 rounded-xl transition-colors ${s.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:s.enabled?"停用账号":"启用账号",children:e.jsx(Xe,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>f(s)),disabled:a,className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:a?"删除中…":`删除账号 ${s.nickname||s.remark||s.id}`,children:a?e.jsx(J,{className:"w-5 h-5 animate-spin"}):e.jsx(ve,{className:"w-5 h-5"})})]})]})]})]})})}),Ls=({account:t,deleting:s,error:r,onClose:a,onConfirm:l})=>ie.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:a,disabled:s,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(de,{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:t.nickname||t.remark||"未命名账号"}),t.remark&&t.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",t.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",t.id]})]}),s&&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(J,{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:"正在清理关联数据,请保持页面打开…"})]})]}),r&&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(_e,{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:r})]})]})]}),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:a,disabled:s,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 l()),disabled:s,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:s?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),Qe=({src:t,alt:s,className:r=""})=>e.jsx("img",{src:t,alt:s,className:`block aspect-square h-auto w-full object-contain ${r}`.trim()}),Ts=({account:t,editForm:s,setEditForm:r,saving:a,onClose:l,onSave:c,onRestartPause:i,longLogin:d,onToggleLongLogin:b,passwordLoginView:m,onPasswordLogin:f,onCancelPasswordLogin:h,notifChannels:u,selectedChannelIds:A,bindingsLoaded:k,bindingsLoading:g,bindingsLoadError:p,onRetryBindings:L,onToggleChannel:U,onSettingsDirty:M})=>{const I=(C,K)=>{r(se=>({...se,[C]:K}))},S=()=>void l(),j=()=>void c(),N=C=>I("remark",C.target.value),R=C=>I("cookie",C.target.value),w=()=>I("auto_confirm",!s.auto_confirm),P=C=>I("pause_duration",parseInt(C.target.value,10)||0),D=()=>void i(),Y=()=>void b(),X=C=>I("username",C.target.value),V=C=>r(K=>({...K,login_password:C.target.value,clear_password:!1})),H=()=>I("showLoginPassword",!s.showLoginPassword),z=C=>r(K=>({...K,clear_password:C.target.checked,login_password:C.target.checked?"":K.login_password})),T=()=>I("show_browser",!s.show_browser),W=()=>void h(),$=()=>void f(),Q=()=>void L(),ee=C=>{k&&(U(C),M())},re=C=>{const K=A.includes(Number(C.id)),se=()=>ee(Number(C.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:se,disabled:!k,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${K?"bg-brand border-brand":"bg-white border-gray-300"}`,children:K&&e.jsx(ae,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:C.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[C.type,C.enabled?"":" · 已停用"]})]})]},C.id)};return ie.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:S,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(de,{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:N,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:R,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(ae,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:w,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($e,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:s.pause_duration,onChange:P,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:a,onClick:D,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(Ye,{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:"状态直接读取并修改闲鱼官方长登录设置"}),d.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:d.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:d.loading||d.saving||!d.canOpen,onClick:Y,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${d.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 ${d.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:X,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:V,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:H,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:s.showLoginPassword?e.jsx(Ze,{className:"w-5 h-5"}):e.jsx(Fe,{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:z,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:T,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 和保存的登录信息。"})]}),m.status==="processing"||m.status==="verification_required"?e.jsx("button",{type:"button",onClick:W,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:"密码登录刷新授权"})]}),m.message&&e.jsx("div",{className:`text-sm font-medium ${m.status==="failed"?"text-red-700":m.status==="success"?"text-green-700":"text-blue-800"}`,children:m.message}),m.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 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),m.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Qe,{src:m.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(u.length>0||g||p)&&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(es,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),g&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),p&&!g&&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:p}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:Q,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:u.map(re)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:S,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:a,children:"取消"}),e.jsxs("button",{onClick:j,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:a,children:[a?e.jsx(J,{className:"w-4 h-4 animate-spin"}):e.jsx(ae,{className:"w-4 h-4"}),a?"保存中...":"保存"]})]})})]})}),document.body)},Is=({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(ss,{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(J,{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:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Es=({target:t,status:s,codeUrl:r,errorMessage:a,faceQrUrl:l,verificationScreenshot:c,onClose:i})=>ie.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:i,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","aria-label":"关闭二维码登录",children:e.jsx(de,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:t?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:t?`请用闲鱼APP扫码,为「${t.nickname||t.remark||t.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${s==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[s==="loading"&&e.jsx(J,{className:"w-10 h-10 text-brand animate-spin"}),s==="waiting"&&e.jsx(Qe,{src:r,alt:"闲鱼登录二维码",className:"p-2"}),s==="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(ae,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),s==="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:a||"请关闭窗口后重新发起扫码登录。"})]}),s==="verification"&&e.jsx(Is,{faceQrUrl:l,verificationScreenshot:c})]}),s!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),Ds=(t,s)=>t.map(r=>{var a,l,c,i,d;return{...r,ai_enabled:((a=s[r.id])==null?void 0:a.ai_enabled)??!1,max_discount_percent:((l=s[r.id])==null?void 0:l.max_discount_percent)??10,max_discount_amount:((c=s[r.id])==null?void 0:c.max_discount_amount)??100,max_bargain_rounds:((i=s[r.id])==null?void 0:i.max_bargain_rounds)??3,custom_prompts:((d=s[r.id])==null?void 0:d.custom_prompts)??""}}),$s=()=>{const[t,s]=n.useState([]),[r,a]=n.useState(!0),l=n.useRef(0),c=n.useRef(null),i=n.useCallback(async()=>{var m;const d=++l.current;(m=c.current)==null||m.abort();const b=new AbortController;c.current=b,a(!0);try{const f={signal:b.signal},[h,u]=await Promise.allSettled([as(f),fs(f)]);if(d!==l.current)return;if(h.status==="rejected")throw h.reason;const A=u.status==="fulfilled"?u.value:{};u.status==="rejected"&&console.error("加载 AI 设置失败:",u.reason),s(Ds(h.value,A))}catch(f){d===l.current&&!b.signal.aborted&&console.error("加载账号失败:",f)}finally{d===l.current&&a(!1)}},[]);return n.useEffect(()=>{let d=!1,b=null;const m=new AbortController,f=async()=>{try{const u=await rs({signal:m.signal,timeoutMs:1e4});d||s(A=>As(A,u))}catch(u){d||console.error("加载账号运行状态失败:",u)}finally{d||(b=window.setTimeout(()=>void f(),2e3))}};return i().finally(()=>{d||f()}),()=>{var u;d=!0,m.abort(),l.current+=1,(u=c.current)==null||u.abort(),b!==null&&window.clearTimeout(b)}},[i]),{accounts:t,setAccounts:s,loading:r,loadAccounts:i}},Qs=new Set(["expired","cancelled","error","not_found"]),Us=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:(s=>s===t)}},Ms=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,r=null,a=-1,l=0;const c=()=>{l+=1,r==null||r.abort(),r=null,s!==null&&(t.clearInterval(s),s=null)};return{start:(d,b,m,f=2e3)=>{c();const h=l;r=new AbortController;const u=r.signal;s=t.setInterval(()=>{a===h||h!==l||(a=h,(async()=>{var A,k;try{const g=await b(d,u);if(g.status==="success"){c(),await m.onSuccess(g);return}if(g.status==="scanned"){(A=m.onScanned)==null||A.call(m,g);return}if(g.status==="verification_required"){(k=m.onVerificationRequired)==null||k.call(m,g);return}g.status&&Qs.has(g.status)&&(c(),m.onTerminalError(g))}catch(g){if(u.aborted||h!==l)return;c(),m.onPollError(g)}finally{a===h&&(a=-1)}})())},f)},stop:c,isActive:(()=>s!==null)}},Bs=({onLoginSuccess:t})=>{const[s,r]=n.useState(!1),[a,l]=n.useState(""),[c,i]=n.useState("pending"),[d,b]=n.useState(""),[m,f]=n.useState(""),[h,u]=n.useState(""),[A,k]=n.useState(null),g=n.useRef(null),p=n.useRef(null),L=n.useRef(null),U=n.useRef(null);g.current===null&&(g.current=Ms()),p.current===null&&(p.current=Us());const M=()=>{U.current!==null&&(window.clearTimeout(U.current),U.current=null)},I=()=>{var w;(w=g.current)==null||w.stop()},S=()=>{var w,P;(w=L.current)==null||w.abort(),(P=p.current)==null||P.cancel(),I(),M(),r(!1)},j=()=>{M(),U.current=window.setTimeout(()=>{U.current=null,r(!1),t()},1e3)};n.useEffect(()=>()=>{var P,D;I(),(P=p.current)==null||P.cancel(),(D=L.current)==null||D.abort(),M()},[]);const N=async(w,P)=>{const D=await os(w,P==null?void 0:P.id);if(!D.success||!D.account_id)throw new Error("保存扫码授权失败");return D.account_id};return{showQRModal:s,qrCodeUrl:a,qrStatus:c,qrErrorMessage:d,verificationScreenshot:m,faceQrUrl:h,qrReauthTarget:A,startQRLogin:async w=>{var X,V,H,z;I(),(X=L.current)==null||X.abort();const P=new AbortController;L.current=P;const D=p.current.next();M();const Y=w||null;k(Y),r(!0),i("loading"),b(""),l(""),f(""),u("");try{const T=await ns({signal:P.signal});if(!((V=p.current)!=null&&V.isCurrent(D)))return;if(!T.success||!T.qr_code_url||!T.session_id)throw new Error(T.message||"闲鱼未返回可用的登录二维码");const W=T.session_id;l(T.qr_code_url),i("waiting"),(H=g.current)==null||H.start(W,ls,{onSuccess:(async()=>{try{await N(W,Y)}catch($){console.error("保存扫码授权失败",$),i("error");return}i("success"),j()}),onScanned:(()=>{i("waiting")}),onTerminalError:(()=>{i("error")}),onPollError:($=>{console.error("轮询扫码状态失败",$),i("error")}),onVerificationRequired:($=>{i("verification"),$.face_qr_url&&u($.face_qr_url),$.verification_screenshot&&f($.verification_screenshot)})})}catch(T){if(!((z=p.current)!=null&&z.isCurrent(D))||P.signal.aborted)return;b(T instanceof Error?T.message:"二维码获取失败,请稍后重试"),i("error")}finally{L.current===P&&(L.current=null)}},closeQRModal:S}},Os=(t,s)=>t&&s,Gs=(t,s)=>t!==(s.pause_duration||0),zs=(t,s)=>{const r=s.username!==(t.username||""),a=s.show_browser!==(t.show_browser||!1),l=s.login_password!=="",c=s.clear_password===!0;if(!r&&!a&&!l&&!c)return null;const i={username:s.username,show_browser:s.show_browser};return c?i.clear_password=!0:l&&(i.login_password=s.login_password),i},F=(t,s,r,a)=>t===s&&r===a,Ws=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:""},Vs=({editingAccount:t,setEditingAccount:s,setActiveModal:r,editForm:a,setEditForm:l,loadAccounts:c})=>{const[i,d]=n.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[b,m]=n.useState([]),[f,h]=n.useState([]),[u,A]=n.useState(!1),[k,g]=n.useState(!1),[p,L]=n.useState(!1),[U,M]=n.useState(""),[I,S]=n.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[j,N]=n.useState(!1),[R,w]=n.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),P=n.useRef(0),D=n.useRef(null),Y=n.useRef(0),X=n.useRef(null),V=n.useRef(0),H=n.useRef(null),z=n.useRef(0),T=n.useRef(""),W=n.useRef(null),$=n.useRef(null),Q=n.useCallback(()=>{$.current!==null&&(window.clearTimeout($.current),$.current=null)},[]),ee=n.useCallback(async o=>{var B;const x=++P.current;(B=D.current)==null||B.abort();const v=new AbortController;D.current=v,g(!0),A(!1),L(!1),M("");const[E,_]=await Promise.allSettled([_s({signal:v.signal}),Ns(o,{signal:v.signal})]);F(x,P.current,o,o)&&(E.status==="fulfilled"?m(E.value.data||[]):(m([]),M("通知渠道列表加载失败,请重试")),_.status==="fulfilled"?(h(_.value||[]),A(!0)):(h([]),M("通知绑定加载失败;本次保存不会修改现有绑定")),g(!1))},[]),re=n.useCallback(o=>{h(x=>x.includes(o)?x.filter(v=>v!==o):[...x,o]),L(!0)},[]),C=n.useCallback(async o=>{var _,B;const x=++Y.current;(_=X.current)==null||_.abort();const v=new AbortController;X.current=v,z.current+=1,T.current=o.id,(B=W.current)==null||B.abort(),Q(),w({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),s(o),l({remark:o.remark||"",cookie:"",auto_confirm:o.auto_confirm||!1,pause_duration:o.pause_duration||0,username:o.username||"",login_password:"",show_browser:o.show_browser||!1,showLoginPassword:!1,clear_password:!1}),r("edit"),d({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,E]=await Promise.allSettled([ee(o.id),xs(o.id,{signal:v.signal})]);x===Y.current&&(E.status==="fulfilled"?d({loading:!1,saving:!1,canOpen:E.value.can_open_long_login,enabled:E.value.enabled,error:""}):d({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"}))},[Q,ee,r,l,s]),K=n.useCallback(async()=>{if(!t||i.loading||i.saving||!i.canOpen)return;const o=!i.enabled;d(x=>({...x,saving:!0,error:""}));try{const x=await ms(t.id,o);d({loading:!1,saving:!1,canOpen:x.can_open_long_login,enabled:x.enabled,error:""})}catch(x){d(v=>({...v,saving:!1,error:x instanceof Error?x.message:"保存登录信息设置失败"}))}},[t,i]),se=n.useCallback(async o=>{var E;const x=++V.current;(E=H.current)==null||E.abort();const v=new AbortController;H.current=v,s(o),r("ai-settings"),N(!0);try{const _=await ys(o.id,{signal:v.signal});if(!F(x,V.current,o.id,o.id))return;S({ai_enabled:_.ai_enabled??!1,max_discount_percent:_.max_discount_percent??10,max_discount_amount:_.max_discount_amount??100,max_bargain_rounds:_.max_bargain_rounds??3,custom_prompts:_.custom_prompts??""})}catch(_){F(x,V.current,o.id,o.id)&&console.error("加载 AI 设置失败:",_)}finally{F(x,V.current,o.id,o.id)&&N(!1)}},[r,s]),xe=n.useCallback(async()=>{if(!(!t||j)){N(!0);try{await js(t.id,I),r(null),await c()}catch(o){console.error("更新 AI 设置失败:",o)}finally{N(!1)}}},[I,t,c,j,r]),me=n.useCallback(async()=>{if(!(!t||j)){N(!0);try{const o={};a.remark!==(t.remark||"")&&(o.remark=a.remark),a.cookie&&(o.cookie=a.cookie),a.auto_confirm!==t.auto_confirm&&(o.auto_confirm=a.auto_confirm),Gs(a.pause_duration,t)&&(o.pause_duration=a.pause_duration);const x=zs(t,a);x&&Object.assign(o,x),Os(u,p)&&(o.channel_ids=f),Object.keys(o).length>0&&await us(t.id,o),r(null),await c()}catch(o){console.error("更新账号失败:",o)}finally{N(!1)}}},[p,u,a,t,c,f,j,r]),be=n.useCallback(async()=>{if(!(!t||a.pause_duration<=0||j)){N(!0);try{const o=await ds(t.id,a.pause_duration);s(x=>x&&{...x,pause_duration:a.pause_duration,paused:(o==null?void 0:o.paused)===!0,paused_until:Number((o==null?void 0:o.paused_until)||0)}),await c()}catch(o){console.error("重新暂停失败:",o)}finally{N(!1)}}},[a.pause_duration,t,c,j,s]),ne=n.useCallback(async(o,x,v)=>{var _;(_=W.current)==null||_.abort();const E=new AbortController;W.current=E;try{const B=await hs(o,E.signal);if(!F(x,z.current,v,T.current))return;const oe={...Ws(B),sessionId:o};if(B.status==="success"){Q(),w(oe),l(fe=>({...fe,login_password:"",showLoginPassword:!1})),await c();return}if(B.status==="processing"||B.status==="verification_required"){w(oe),Q(),$.current=window.setTimeout(()=>void ne(o,x,v),1500);return}Q(),w(oe)}catch(B){if(!F(x,z.current,v,T.current))return;Q(),w({sessionId:o,status:"failed",message:B instanceof Error?B.message:"查询密码登录状态失败",qrCodeUrl:""})}},[Q,c,l]),he=n.useCallback(async()=>{var E;if(!t)return;const o=a.username.trim();if(!o||!a.login_password)return;Q(),(E=W.current)==null||E.abort();const x=++z.current;T.current=t.id;const v=new AbortController;W.current=v,w({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const _=await bs({account_id:t.id,account:o,password:a.login_password,show_browser:a.show_browser},{signal:v.signal});if(!F(x,z.current,t.id,T.current))return;if(!_.success||!_.session_id)throw new Error(_.message||"无法启动密码登录");w({sessionId:_.session_id,status:"processing",message:_.message||"登录处理中",qrCodeUrl:""}),await ne(_.session_id,x,t.id)}catch(_){if(!F(x,z.current,t.id,T.current))return;w({sessionId:"",status:"failed",message:_ instanceof Error?_.message:"启动密码登录失败",qrCodeUrl:""})}},[Q,a.login_password,a.show_browser,a.username,t,ne]),le=n.useCallback(async()=>{var x;const o=R.sessionId;z.current+=1,T.current="",(x=W.current)==null||x.abort(),Q(),o&&await gs(o).catch(()=>{}),w({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},[Q,R.sessionId]),ge=n.useCallback(async()=>{var o,x,v;(o=D.current)==null||o.abort(),Y.current+=1,(x=X.current)==null||x.abort(),(v=H.current)==null||v.abort(),(R.status==="processing"||R.status==="verification_required")&&await le(),r(null)},[le,R.status,r]),pe=n.useCallback(()=>{var o;V.current+=1,(o=H.current)==null||o.abort(),r(null)},[r]);return n.useEffect(()=>(()=>{var o,x,v,E;(o=D.current)==null||o.abort(),(x=X.current)==null||x.abort(),(v=H.current)==null||v.abort(),(E=W.current)==null||E.abort(),Q()}),[Q]),{longLogin:i,notifChannels:b,selectedChannelIds:f,bindingsLoaded:u,bindingsLoading:k,bindingsDirty:p,bindingsLoadError:U,aiSettings:I,saving:j,passwordLoginView:R,setAiSettings:S,setBindingsDirty:L,setEditForm:l,openEditModal:C,closeEditModal:ge,openAIModal:se,closeAIModal:pe,loadNotificationBindings:ee,toggleNotificationChannel:re,handleLongLoginToggle:K,handleSaveAISettings:xe,handleSaveEdit:me,handleRestartPause:be,handlePasswordLogin:he,handleCancelPasswordLogin:le}},Ys=()=>{const{accounts:t,setAccounts:s,loading:r,loadAccounts:a}=$s(),[l,c]=n.useState(""),[i,d]=n.useState(""),[b,m]=n.useState(""),[f,h]=n.useState(null),[u,A]=n.useState(""),[k,g]=n.useState(null),[p,L]=n.useState(null),[U,M]=n.useState(null),[I,S]=n.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),j=Vs({editingAccount:p,setEditingAccount:L,setActiveModal:g,editForm:I,setEditForm:S,loadAccounts:a}),{longLogin:N,notifChannels:R,selectedChannelIds:w,bindingsLoaded:P,bindingsLoading:D,bindingsLoadError:Y,aiSettings:X,saving:V,passwordLoginView:H,setAiSettings:z,setBindingsDirty:T,openEditModal:W,closeEditModal:$,openAIModal:Q,closeAIModal:ee,loadNotificationBindings:re,toggleNotificationChannel:C,handleLongLoginToggle:K,handleSaveAISettings:se,handleSaveEdit:xe,handleRestartPause:me,handlePasswordLogin:be,handleCancelPasswordLogin:ne}=j,he=Bs({onLoginSuccess:a}),{showQRModal:le,qrCodeUrl:ge,qrStatus:pe,qrErrorMessage:o,verificationScreenshot:x,faceQrUrl:v,qrReauthTarget:E,startQRLogin:_,closeQRModal:B}=he,oe=async(y,q)=>{await is(y,!q),a()},fe=y=>{b||(A(""),h(y))},Ue=()=>{b||(A(""),h(null))},Me=async()=>{const y=f;if(!(!y||b)){m(y.id),A("");try{await cs(y.id),s(q=>q.filter(te=>te.id!==y.id)),h(null)}catch(q){console.error("删除账号失败:",q),A((q==null?void 0:q.message)||"删除账号失败,请稍后重试")}finally{m("")}}},Be=async y=>{d(y.id);try{const q=await ps(y.id);q!=null&&q.profile_error&&alert("资料刷新失败:"+q.profile_error),await a()}catch(q){console.error("刷新账号资料失败:",q),alert((q==null?void 0:q.message)||"刷新账号资料失败,请先重新授权该账号")}finally{d("")}};if(r)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(J,{className:"w-8 h-8 text-brand animate-spin"})});const ye=t.filter(y=>{const q=l.trim().toLowerCase();return q?[y.id,y.nickname,y.remark,y.username,y.runtime_message].some(te=>(te||"").toLowerCase().includes(q)):!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:l,onChange:(y=>c(y.target.value)),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:(()=>_()),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(Ne,{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:["当前显示 ",ye.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[ye.map(y=>e.jsx(qs,{account:y,refreshing:i===y.id,deleting:b===y.id,onRefreshProfile:Be,onReauthorize:_,onEdit:W,onAI:Q,onTasks:M,onToggle:oe,onDelete:fe},y.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(De,{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&&ye.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。"})]})]}),U&&ie.createPortal(e.jsx(Ss,{account:U,onClose:(()=>M(null)),onSaved:(y=>{s(q=>q.map(te=>te.id===U.id?{...te,auto_rate_enabled:y.auto_rate_enabled,rate_content:y.rate_content,auto_polish_enabled:y.auto_polish_enabled,polish_time:y.polish_time,last_rate_scan_at:y.last_rate_scan_at,last_polish_date:y.last_polish_date,last_polish_at:y.last_polish_at}:te))})}),document.body),f&&e.jsx(Ls,{account:f,deleting:b===f.id,error:u,onClose:Ue,onConfirm:Me}),le&&e.jsx(Es,{target:E,status:pe,codeUrl:ge,errorMessage:o,faceQrUrl:v,verificationScreenshot:x,onClose:B}),k==="edit"&&p&&e.jsx(Ts,{account:p,editForm:I,setEditForm:S,saving:V,onClose:$,onSave:xe,onRestartPause:me,longLogin:N,onToggleLongLogin:K,passwordLoginView:H,onPasswordLogin:be,onCancelPasswordLogin:ne,notifChannels:R,selectedChannelIds:w,bindingsLoaded:P,bindingsLoading:D,bindingsLoadError:Y,onRetryBindings:(()=>re(p.id)),onToggleChannel:C,onSettingsDirty:(()=>T(!0))}),k==="ai-settings"&&p&&e.jsx(vs,{account:p,settings:X,saving:V,onChange:z,onClose:ee,onSave:se})]})};export{Ys as default}; diff --git a/internal/webui/static/assets/AccountList-bbR-Z2_J.js b/internal/webui/static/assets/AccountList-bbR-Z2_J.js deleted file mode 100644 index 15e2c80..0000000 --- a/internal/webui/static/assets/AccountList-bbR-Z2_J.js +++ /dev/null @@ -1,3 +0,0 @@ -import{b as ie,j as e,r as n,c as Oe}from"./react-vendor-C_od1ZSF.js";import{g as X,c as Pe,o as ke,p as ae,a as ce,d as Le}from"./index-zEvleK2K.js";import{n as ue,X as de,f as ze,L as K,o as Ie,p as Ge,q as We,r as Te,s as $e,U as De,t as te,u as Ve,k as _e,Q as ve,v as Ee,R as Ke,w as He,x as Je,y as Ne,K as Xe,z as Ye,F as Ze,e as Fe,H as es}from"./icons-vendor-DwxdQTKt.js";const ss=(s,t)=>{const r=s.avatar_url||"";if(!r)return"";try{const a=new URL(r,window.location.origin);return a.hostname.endsWith("alicdn.com")&&a.searchParams.set("_v",t),a.toString()}catch{return r}},ts=async s=>{const t=await X("/api/v1/accounts/details",void 0,s),r=Pe(t,["data","accounts","details"]),a=Date.now().toString();return r.map(o=>({id:o.id,cookie_configured:o.has_cookie===!0,enabled:o.enabled,auto_confirm:o.auto_confirm,remark:o.remark,pause_duration:o.pause_duration,paused_until:Number(o.paused_until||0),paused:o.paused===!0,username:o.username||"",login_password_configured:void 0,show_browser:o.show_browser===!0||o.show_browser===1||o.show_browser==="1"||o.show_browser==="true",nickname:o.nickname||o.remark||`账号 ${o.id.substring(0,6)}`,avatar_url:ss(o,a),profile_error:o.profile_error||"",ai_enabled:!1,auto_rate_enabled:o.auto_rate_enabled,rate_content:o.rate_content||"不错的买家,交易愉快",auto_polish_enabled:o.auto_polish_enabled,polish_time:o.polish_time||"03:00",last_rate_scan_at:Number(o.last_rate_scan_at||0),last_polish_date:o.last_polish_date||"",last_polish_at:Number(o.last_polish_at||0)}))},as=async s=>{const t=await X("/api/v1/accounts/runtime-status",void 0,s);return ke(t,["statuses","data","result"])||{}},rs=async s=>ce("/api/v1/qr-login/generate",void 0,{...s,timeoutMs:(s==null?void 0:s.timeoutMs)??13e4}),ns=async(s,t)=>X(`/api/v1/qr-login/check/${s}`,void 0,{signal:t,timeoutMs:1e4}),ls=async(s,t)=>ce(`/api/v1/qr-login/complete-verification/${s}`,{target_account_id:t||""}),os=async(s,t)=>ae(`/api/v1/accounts/${s}/status`,{enabled:t}),is=async s=>Le(`/api/v1/accounts/${s}`),cs=async(s,t,r)=>ae(`/api/v1/accounts/${s}/pause-duration`,{pause_duration:t},r),ds=async(s,t,r)=>ae(`/api/v1/accounts/${s}/settings`,t,r),us=async(s,t)=>X(`/api/v1/accounts/${s}/long-login`,void 0,t),xs=async(s,t,r)=>ae(`/api/v1/accounts/${s}/long-login`,{enabled:t},r),ms=async(s,t)=>ce("/api/v1/password-login",s,t),bs=async(s,t)=>X(`/api/v1/password-login/check/${s}`,void 0,{signal:t,timeoutMs:1e4}),hs=async(s,t)=>Le(`/api/v1/password-login/cancel/${s}`,void 0,t),gs=async s=>ce(`/api/v1/accounts/${s}/refresh-profile`,{}),ps=async s=>{const t=await X("/api/v1/settings/ai-reply",void 0,s);return ke(t,["settings","data","result"])||{}},fs=async(s,t)=>X(`/api/v1/settings/ai-reply/${s}`,void 0,t),ys=async(s,t,r)=>{const a={ai_enabled:t.ai_enabled??!1,max_discount_percent:t.max_discount_percent??10,max_discount_amount:t.max_discount_amount??100,max_bargain_rounds:t.max_bargain_rounds??3,custom_prompts:t.custom_prompts??""};return ae(`/api/v1/settings/ai-reply/${s}`,a,r)},js=s=>{if(Array.isArray(s))return s.filter(Boolean);if(typeof s!="string"||!s.trim())return[];try{const t=JSON.parse(s);if(Array.isArray(t))return t.filter(Boolean)}catch{}return s.split(/[,\s;]+/).map(t=>t.trim()).filter(Boolean)},ws=async s=>{const t=await X("/api/v1/notifications/channels",void 0,s);return{success:!0,data:Pe(t,["data","channels","items"]).map(a=>{const o={},c=a.type==="ding_talk"?"dingtalk":a.type==="lark"?"feishu":a.type;return{id:String(a.id),name:a.name,type:c,config:o,event_types:js(a.event_types),enabled:a.enabled}})}},_s=async(s,t)=>{const r=await X(`/api/v1/notifications/accounts/${s}/bindings`,void 0,t),a=ke(r,["data","result"])||{};return Array.isArray(a.channel_ids)?a.channel_ids:[]},vs=({account:s,settings:t,saving:r,onChange:a,onClose:o,onSave:c})=>{const i=u=>a({...t,...u}),d=()=>i({ai_enabled:!t.ai_enabled}),b=u=>i({max_discount_percent:parseInt(u.target.value,10)||0}),m=u=>i({max_discount_amount:parseInt(u.target.value,10)||0}),f=u=>i({max_bargain_rounds:parseInt(u.target.value,10)||1}),h=u=>i({custom_prompts:u.target.value});return ie.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(ue,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s.nickname||s.remark||s.id})]}),e.jsx("button",{onClick:o,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0","aria-label":"关闭 AI 设置",children:e.jsx(de,{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(ue,{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:d,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${t.ai_enabled?"bg-brand":"bg-gray-300"}`,"aria-label":"切换 AI 自动回复",children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${t.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:t.max_discount_percent,onChange:b,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:t.max_discount_amount,onChange:m,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:t.max_bargain_rounds,onChange:f,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:t.custom_prompts,onChange:h,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(ze,{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:o,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:r,children:"取消"}),e.jsxs("button",{onClick:(()=>void c()),className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:r,children:[r?e.jsx(K,{className:"w-4 h-4 animate-spin"}):e.jsx(Ie,{className:"w-4 h-4"}),r?"保存中...":"保存"]})]})})]})}),document.body)},Ce=async(s,t)=>X(`/api/v1/account-tasks/${s}`,void 0,t),Se=async(s,t,r)=>ae(`/api/v1/account-tasks/${s}`,t,r),Ns=async(s,t,r)=>ce(`/api/v1/account-tasks/${s}/run`,{task_type:t},{timeoutMs:12e4,...r}),Re=s=>({account_id:s.id,auto_rate_enabled:s.auto_rate_enabled===!0,rate_content:s.rate_content||"不错的买家,交易愉快",auto_polish_enabled:s.auto_polish_enabled===!0,polish_time:s.polish_time||"03:00",last_rate_scan_at:s.last_rate_scan_at,last_polish_date:s.last_polish_date,last_polish_at:s.last_polish_at}),Y=(s,t,r)=>s===t&&!r.aborted,je=(s,t)=>s instanceof Error?s.message:t,we=s=>s instanceof Error&&s.message==="请求已取消",Ae=(s,t)=>!s&&t==="",ks=({account:s,onSaved:t})=>{const[r,a]=n.useState(()=>Re(s)),[o,c]=n.useState(!0),[i,d]=n.useState(!1),[b,m]=n.useState(""),[f,h]=n.useState(""),[u,A]=n.useState(null),[k,g]=n.useState(null),p=n.useRef(0),L=n.useRef(null);n.useEffect(()=>{var v;const S=++p.current;(v=L.current)==null||v.abort();const j=new AbortController;return L.current=j,a(Re(s)),A(null),h(""),d(!1),m(""),g(null),c(!0),Ce(s.id,{signal:j.signal}).then(R=>{Y(p.current,S,j.signal)&&a(R)}).catch(R=>{Y(p.current,S,j.signal)&&!we(R)&&h(je(R,"加载任务设置失败"))}).finally(()=>{Y(p.current,S,j.signal)&&c(!1)}),(()=>j.abort())},[s.id]),n.useEffect(()=>(()=>{var S;return(S=L.current)==null?void 0:S.abort()}),[]);const U=n.useCallback(async()=>{var v;if(!Ae(i,b))return;const S=++p.current;(v=L.current)==null||v.abort();const j=new AbortController;L.current=j,d(!0),h(""),g(null);try{const R=await Se(s.id,r,{signal:j.signal});if(!Y(p.current,S,j.signal))return;a(R),t(R)}catch(R){Y(p.current,S,j.signal)&&!we(R)&&(h(je(R,"保存失败")),g(()=>U))}finally{Y(p.current,S,j.signal)&&d(!1)}},[s.id,r,t,b,i]),M=n.useCallback(async S=>{var R;if(!Ae(i,b)||!s.enabled)return;const j=++p.current;(R=L.current)==null||R.abort();const v=new AbortController;L.current=v,m(S),h(""),A(null),g(null);try{await Se(s.id,r,{signal:v.signal});const w=await Ns(s.id,S,{signal:v.signal}),q=await Ce(s.id,{signal:v.signal});if(!Y(p.current,j,v.signal))return;A(w.summary),a(q),t(q)}catch(w){Y(p.current,j,v.signal)&&!we(w)&&(h(je(w,"任务执行失败")),g(()=>(()=>M(S))))}finally{Y(p.current,j,v.signal)&&m("")}},[s.enabled,s.id,r,t,b,i]),T=n.useCallback(async()=>{k&&await k()},[k]);return{form:r,loading:o,saving:i,running:b,summary:u,error:f,retryAvailable:k!==null,setForm:a,save:U,run:M,retry:T}},qe=({checked:s,onChange:t,label:r})=>e.jsx("button",{type:"button","aria-label":r,"aria-pressed":s,onClick:t,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${s?"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 ${s?"translate-x-6":""}`})}),Cs=({account:s,onClose:t,onSaved:r})=>{const{form:a,loading:o,saving:c,running:i,error:d,summary:b,retryAvailable:m,setForm:f,save:h,run:u,retry:A}=ks({account:s,onSaved:r});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:s.nickname||s.remark||s.id})]}),e.jsx("button",{type:"button",onClick:t,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[o&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",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(Ge,{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(qe,{checked:a.auto_rate_enabled,onChange:(()=>f(k=>({...k,auto_rate_enabled:!k.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:a.rate_content,maxLength:500,onChange:(k=>f(g=>({...g,rate_content:k.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:["最近扫描:",a.last_rate_scan_at?new Date(a.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:i!==""||!s.enabled,onClick:(()=>void u("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:[i==="auto_rate"?e.jsx(K,{className:"h-4 w-4 animate-spin"}):e.jsx(We,{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(Te,{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(qe,{checked:a.auto_polish_enabled,onChange:(()=>f(k=>({...k,auto_polish_enabled:!k.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:a.polish_time,onChange:(k=>f(g=>({...g,polish_time:k.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:i!==""||!s.enabled,onClick:(()=>void u("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:[i==="auto_polish"?e.jsx(K,{className:"h-4 w-4 animate-spin"}):e.jsx($e,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",a.last_polish_at?new Date(a.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),b&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",b.found," 项,成功 ",b.success,",失败 ",b.failed,",跳过 ",b.skipped,"。",b.message||""]}),d&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:[e.jsx("span",{children:d}),m&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>void A()),children:"重试"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:t,disabled:c||i!=="",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:c||i!==""||a.auto_rate_enabled&&!a.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:[c?e.jsx(K,{className:"h-4 w-4 animate-spin"}):e.jsx(Ie,{className:"h-4 w-4"}),"保存"]})]})})]})})},Ss=(s,t)=>{if(!s||!t)return!1;const r=Date.parse(s),a=Date.parse(t);return Number.isFinite(r)&&Number.isFinite(a)&&as.map(r=>{const a=t[r.id];return!a||Ss(r.runtime_updated_at,a.updated_at)?r:{...r,runtime_state:a.state,runtime_message:a.message||"",runtime_connected:a.connected,runtime_updated_at:a.updated_at}}),As=s=>{if(!s.enabled||s.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(s.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"runtime_conflict":return{label:"运行状态冲突",badge:"bg-red-100 text-red-700",dot:"bg-red-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"}}},qs=Oe.memo(function({account:t,refreshing:r,deleting:a,onRefreshProfile:o,onReauthorize:c,onEdit:i,onAI:d,onTasks:b,onToggle:m,onDelete:f}){const h=As(t),u=t.runtime_state==="auth_expired"||t.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:[t.avatar_url?e.jsx("img",{src:t.avatar_url,alt:t.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(De,{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:t.runtime_state==="online"&&e.jsx(te,{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:t.nickname||t.remark||`账号 ${t.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}),t.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(ue,{className:"w-3 h-3"})," AI"]}),t.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(Ve,{className:"h-3 w-3"})," 自动评价"]}),t.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(Te,{className:"h-3 w-3"})," 每日擦亮"]}),t.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(te,{className:"h-3 w-3"})," 自动确认发货"]}),t.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:t.profile_error,children:[e.jsx(_e,{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:t.remark||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",t.id]})]}),t.runtime_message&&t.runtime_state!=="online"&&t.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${u?"text-red-700":"text-amber-700"}`,children:[e.jsx(_e,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:t.runtime_message}),u&&e.jsxs("button",{type:"button",onClick:(()=>c(t)),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(ve,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),t.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(Ee,{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:(()=>o(t)),disabled:r,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(Ke,{className:`w-5 h-5 ${r?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>c(t)),className:`p-3 rounded-xl transition-colors ${u?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(ve,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>i(t)),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(He,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>d(t)),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(ue,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>b(t)),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx($e,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>m(t.id,t.enabled)),className:`p-3 rounded-xl transition-colors ${t.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:t.enabled?"停用账号":"启用账号",children:e.jsx(Je,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>f(t)),disabled:a,className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:a?"删除中…":`删除账号 ${t.nickname||t.remark||t.id}`,children:a?e.jsx(K,{className:"w-5 h-5 animate-spin"}):e.jsx(Ne,{className:"w-5 h-5"})})]})]})]})]})})}),Ps=({account:s,deleting:t,error:r,onClose:a,onConfirm:o})=>ie.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(Ne,{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:a,disabled:t,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(de,{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:s.nickname||s.remark||"未命名账号"}),s.remark&&s.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",s.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",s.id]})]}),t&&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(K,{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:"正在清理关联数据,请保持页面打开…"})]})]}),r&&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(_e,{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:r})]})]})]}),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:a,disabled:t,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 o()),disabled:t,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:t?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),Qe=({src:s,alt:t,className:r=""})=>e.jsx("img",{src:s,alt:t,className:`block aspect-square h-auto w-full object-contain ${r}`.trim()}),Ls=({account:s,editForm:t,setEditForm:r,saving:a,onClose:o,onSave:c,onRestartPause:i,longLogin:d,onToggleLongLogin:b,passwordLoginView:m,onPasswordLogin:f,onCancelPasswordLogin:h,notifChannels:u,selectedChannelIds:A,bindingsLoaded:k,bindingsLoading:g,bindingsLoadError:p,onRetryBindings:L,onToggleChannel:U,onSettingsDirty:M})=>{const T=(C,W)=>{r(ee=>({...ee,[C]:W}))},S=()=>void o(),j=()=>void c(),v=C=>T("remark",C.target.value),R=C=>T("cookie",C.target.value),w=()=>T("auto_confirm",!t.auto_confirm),q=C=>T("pause_duration",parseInt(C.target.value,10)||0),D=()=>void i(),J=()=>void b(),H=C=>T("username",C.target.value),G=C=>r(W=>({...W,login_password:C.target.value,clear_password:!1})),V=()=>T("showLoginPassword",!t.showLoginPassword),O=C=>r(W=>({...W,clear_password:C.target.checked,login_password:C.target.checked?"":W.login_password})),I=()=>T("show_browser",!t.show_browser),z=()=>void h(),E=()=>void f(),Q=()=>void L(),F=C=>{k&&(U(C),M())},re=C=>{const W=A.includes(Number(C.id)),ee=()=>F(Number(C.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:ee,disabled:!k,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${W?"bg-brand border-brand":"bg-white border-gray-300"}`,children:W&&e.jsx(te,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:C.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[C.type,C.enabled?"":" · 已停用"]})]})]},C.id)};return ie.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:s.nickname||s.remark||s.id})]}),e.jsx("button",{onClick:S,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(de,{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:s.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:t.remark,onChange:v,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:t.cookie,onChange:R,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长度: ",t.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(te,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:w,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${t.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 ${t.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(Ee,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:t.pause_duration,onChange:q,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:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),t.pause_duration>0&&!s.paused&&t.pause_duration===(s.pause_duration||0)&&e.jsx("button",{type:"button",disabled:a,onClick:D,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(Xe,{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:"状态直接读取并修改闲鱼官方长登录设置"}),d.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:d.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:d.loading||d.saving||!d.canOpen,onClick:J,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${d.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 ${d.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:t.username,onChange:H,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:t.showLoginPassword?"text":"password",value:t.login_password,onChange:G,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:V,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.showLoginPassword?e.jsx(Ye,{className:"w-5 h-5"}):e.jsx(Ze,{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:t.clear_password,onChange:O,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 ${t.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 ${t.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 和保存的登录信息。"})]}),m.status==="processing"||m.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:E,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),m.message&&e.jsx("div",{className:`text-sm font-medium ${m.status==="failed"?"text-red-700":m.status==="success"?"text-green-700":"text-blue-800"}`,children:m.message}),m.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 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),m.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Qe,{src:m.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(u.length>0||g||p)&&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(Fe,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),g&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(K,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),p&&!g&&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:p}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:Q,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:u.map(re)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:S,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:a,children:"取消"}),e.jsxs("button",{onClick:j,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:a,children:[a?e.jsx(K,{className:"w-4 h-4 animate-spin"}):e.jsx(te,{className:"w-4 h-4"}),a?"保存中...":"保存"]})]})})]})}),document.body)},Is=({faceQrUrl:s,verificationScreenshot:t})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(es,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:s?e.jsx("img",{src:s,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):t?e.jsx("img",{src:t,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(K,{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:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Ts=({target:s,status:t,codeUrl:r,errorMessage:a,faceQrUrl:o,verificationScreenshot:c,onClose:i})=>ie.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:i,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","aria-label":"关闭二维码登录",children:e.jsx(de,{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:s?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:s?`请用闲鱼APP扫码,为「${s.nickname||s.remark||s.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 ${t==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[t==="loading"&&e.jsx(K,{className:"w-10 h-10 text-brand animate-spin"}),t==="waiting"&&e.jsx(Qe,{src:r,alt:"闲鱼登录二维码",className:"p-2"}),t==="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(te,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),t==="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:a||"请关闭窗口后重新发起扫码登录。"})]}),t==="verification"&&e.jsx(Is,{faceQrUrl:o,verificationScreenshot:c})]}),t!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),$s=(s,t)=>s.map(r=>{var a,o,c,i,d;return{...r,ai_enabled:((a=t[r.id])==null?void 0:a.ai_enabled)??!1,max_discount_percent:((o=t[r.id])==null?void 0:o.max_discount_percent)??10,max_discount_amount:((c=t[r.id])==null?void 0:c.max_discount_amount)??100,max_bargain_rounds:((i=t[r.id])==null?void 0:i.max_bargain_rounds)??3,custom_prompts:((d=t[r.id])==null?void 0:d.custom_prompts)??""}}),Ds=()=>{const[s,t]=n.useState([]),[r,a]=n.useState(!0),o=n.useRef(0),c=n.useRef(null),i=n.useCallback(async()=>{var m;const d=++o.current;(m=c.current)==null||m.abort();const b=new AbortController;c.current=b,a(!0);try{const f={signal:b.signal},[h,u]=await Promise.allSettled([ts(f),ps(f)]);if(d!==o.current)return;if(h.status==="rejected")throw h.reason;const A=u.status==="fulfilled"?u.value:{};u.status==="rejected"&&console.error("加载 AI 设置失败:",u.reason),t($s(h.value,A))}catch(f){d===o.current&&!b.signal.aborted&&console.error("加载账号失败:",f)}finally{d===o.current&&a(!1)}},[]);return n.useEffect(()=>{let d=!1,b=null;const m=new AbortController,f=async()=>{try{const u=await as({signal:m.signal,timeoutMs:1e4});d||t(A=>Rs(A,u))}catch(u){d||console.error("加载账号运行状态失败:",u)}finally{d||(b=window.setTimeout(()=>void f(),2e3))}};return i().finally(()=>{d||f()}),()=>{var u;d=!0,m.abort(),o.current+=1,(u=c.current)==null||u.abort(),b!==null&&window.clearTimeout(b)}},[i]),{accounts:s,setAccounts:t,loading:r,loadAccounts:i}},Es=new Set(["expired","cancelled","error","not_found"]),Qs=()=>{let s=0;return{next:()=>(s+=1,s),cancel:()=>{s+=1},isCurrent:(t=>t===s)}},Us=(s={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let t=null,r=null,a=-1,o=0;const c=()=>{o+=1,r==null||r.abort(),r=null,t!==null&&(s.clearInterval(t),t=null)};return{start:(d,b,m,f=2e3)=>{c();const h=o;r=new AbortController;const u=r.signal;t=s.setInterval(()=>{a===h||h!==o||(a=h,(async()=>{var A,k;try{const g=await b(d,u);if(g.status==="success"){c(),await m.onSuccess(g);return}if(g.status==="scanned"){(A=m.onScanned)==null||A.call(m,g);return}if(g.status==="verification_required"){(k=m.onVerificationRequired)==null||k.call(m,g);return}g.status&&Es.has(g.status)&&(c(),m.onTerminalError(g))}catch(g){if(u.aborted||h!==o)return;c(),m.onPollError(g)}finally{a===h&&(a=-1)}})())},f)},stop:c,isActive:(()=>t!==null)}},Ms=({onLoginSuccess:s})=>{const[t,r]=n.useState(!1),[a,o]=n.useState(""),[c,i]=n.useState("pending"),[d,b]=n.useState(""),[m,f]=n.useState(""),[h,u]=n.useState(""),[A,k]=n.useState(null),g=n.useRef(null),p=n.useRef(null),L=n.useRef(null),U=n.useRef(null);g.current===null&&(g.current=Us()),p.current===null&&(p.current=Qs());const M=()=>{U.current!==null&&(window.clearTimeout(U.current),U.current=null)},T=()=>{var w;(w=g.current)==null||w.stop()},S=()=>{var w,q;(w=L.current)==null||w.abort(),(q=p.current)==null||q.cancel(),T(),M(),r(!1)},j=()=>{M(),U.current=window.setTimeout(()=>{U.current=null,r(!1),s()},1e3)};n.useEffect(()=>()=>{var q,D;T(),(q=p.current)==null||q.cancel(),(D=L.current)==null||D.abort(),M()},[]);const v=async(w,q)=>{const D=await ls(w,q==null?void 0:q.id);if(!D.success||!D.account_id)throw new Error("保存扫码授权失败");return D.account_id};return{showQRModal:t,qrCodeUrl:a,qrStatus:c,qrErrorMessage:d,verificationScreenshot:m,faceQrUrl:h,qrReauthTarget:A,startQRLogin:async w=>{var H,G,V,O;T(),(H=L.current)==null||H.abort();const q=new AbortController;L.current=q;const D=p.current.next();M();const J=w||null;k(J),r(!0),i("loading"),b(""),o(""),f(""),u("");try{const I=await rs({signal:q.signal});if(!((G=p.current)!=null&&G.isCurrent(D)))return;if(!I.success||!I.qr_code_url||!I.session_id)throw new Error(I.message||"闲鱼未返回可用的登录二维码");const z=I.session_id;o(I.qr_code_url),i("waiting"),(V=g.current)==null||V.start(z,ns,{onSuccess:(async()=>{try{await v(z,J)}catch(E){console.error("保存扫码授权失败",E),i("error");return}i("success"),j()}),onScanned:(()=>{i("waiting")}),onTerminalError:(()=>{i("error")}),onPollError:(E=>{console.error("轮询扫码状态失败",E),i("error")}),onVerificationRequired:(E=>{i("verification"),E.face_qr_url&&u(E.face_qr_url),E.verification_screenshot&&f(E.verification_screenshot)})})}catch(I){if(!((O=p.current)!=null&&O.isCurrent(D))||q.signal.aborted)return;b(I instanceof Error?I.message:"二维码获取失败,请稍后重试"),i("error")}finally{L.current===q&&(L.current=null)}},closeQRModal:S}},Bs=(s,t)=>s&&t,Os=(s,t)=>s!==(t.pause_duration||0),zs=(s,t)=>{const r=t.username!==(s.username||""),a=t.show_browser!==(s.show_browser||!1),o=t.login_password!=="",c=t.clear_password===!0;if(!r&&!a&&!o&&!c)return null;const i={username:t.username,show_browser:t.show_browser};return c?i.clear_password=!0:o&&(i.login_password=t.login_password),i},Z=(s,t,r,a)=>s===t&&r===a,Gs=s=>s.status==="success"?{sessionId:"",status:"success",message:s.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}:s.status==="processing"||s.status==="verification_required"?{sessionId:"",status:s.status,message:s.message||(s.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:s.qr_code_url||""}:{sessionId:"",status:"failed",message:s.error||s.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""},Ws=({editingAccount:s,setEditingAccount:t,setActiveModal:r,editForm:a,setEditForm:o,loadAccounts:c})=>{const[i,d]=n.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[b,m]=n.useState([]),[f,h]=n.useState([]),[u,A]=n.useState(!1),[k,g]=n.useState(!1),[p,L]=n.useState(!1),[U,M]=n.useState(""),[T,S]=n.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[j,v]=n.useState(!1),[R,w]=n.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),q=n.useRef(0),D=n.useRef(null),J=n.useRef(0),H=n.useRef(null),G=n.useRef(0),V=n.useRef(null),O=n.useRef(0),I=n.useRef(""),z=n.useRef(null),E=n.useRef(null),Q=n.useCallback(()=>{E.current!==null&&(window.clearTimeout(E.current),E.current=null)},[]),F=n.useCallback(async l=>{var B;const x=++q.current;(B=D.current)==null||B.abort();const N=new AbortController;D.current=N,g(!0),A(!1),L(!1),M("");const[$,_]=await Promise.allSettled([ws({signal:N.signal}),_s(l,{signal:N.signal})]);Z(x,q.current,l,l)&&($.status==="fulfilled"?m($.value.data||[]):(m([]),M("通知渠道列表加载失败,请重试")),_.status==="fulfilled"?(h(_.value||[]),A(!0)):(h([]),M("通知绑定加载失败;本次保存不会修改现有绑定")),g(!1))},[]),re=n.useCallback(l=>{h(x=>x.includes(l)?x.filter(N=>N!==l):[...x,l]),L(!0)},[]),C=n.useCallback(async l=>{var _,B;const x=++J.current;(_=H.current)==null||_.abort();const N=new AbortController;H.current=N,O.current+=1,I.current=l.id,(B=z.current)==null||B.abort(),Q(),w({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),t(l),o({remark:l.remark||"",cookie:"",auto_confirm:l.auto_confirm||!1,pause_duration:l.pause_duration||0,username:l.username||"",login_password:"",show_browser:l.show_browser||!1,showLoginPassword:!1,clear_password:!1}),r("edit"),d({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,$]=await Promise.allSettled([F(l.id),us(l.id,{signal:N.signal})]);x===J.current&&($.status==="fulfilled"?d({loading:!1,saving:!1,canOpen:$.value.can_open_long_login,enabled:$.value.enabled,error:""}):d({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"}))},[Q,F,r,o,t]),W=n.useCallback(async()=>{if(!s||i.loading||i.saving||!i.canOpen)return;const l=!i.enabled;d(x=>({...x,saving:!0,error:""}));try{const x=await xs(s.id,l);d({loading:!1,saving:!1,canOpen:x.can_open_long_login,enabled:x.enabled,error:""})}catch(x){d(N=>({...N,saving:!1,error:x instanceof Error?x.message:"保存登录信息设置失败"}))}},[s,i]),ee=n.useCallback(async l=>{var $;const x=++G.current;($=V.current)==null||$.abort();const N=new AbortController;V.current=N,t(l),r("ai-settings"),v(!0);try{const _=await fs(l.id,{signal:N.signal});if(!Z(x,G.current,l.id,l.id))return;S({ai_enabled:_.ai_enabled??!1,max_discount_percent:_.max_discount_percent??10,max_discount_amount:_.max_discount_amount??100,max_bargain_rounds:_.max_bargain_rounds??3,custom_prompts:_.custom_prompts??""})}catch(_){Z(x,G.current,l.id,l.id)&&console.error("加载 AI 设置失败:",_)}finally{Z(x,G.current,l.id,l.id)&&v(!1)}},[r,t]),xe=n.useCallback(async()=>{if(!(!s||j)){v(!0);try{await ys(s.id,T),r(null),await c()}catch(l){console.error("更新 AI 设置失败:",l)}finally{v(!1)}}},[T,s,c,j,r]),me=n.useCallback(async()=>{if(!(!s||j)){v(!0);try{const l={};a.remark!==(s.remark||"")&&(l.remark=a.remark),a.cookie&&(l.cookie=a.cookie),a.auto_confirm!==s.auto_confirm&&(l.auto_confirm=a.auto_confirm),Os(a.pause_duration,s)&&(l.pause_duration=a.pause_duration);const x=zs(s,a);x&&Object.assign(l,x),Bs(u,p)&&(l.channel_ids=f),Object.keys(l).length>0&&await ds(s.id,l),r(null),await c()}catch(l){console.error("更新账号失败:",l)}finally{v(!1)}}},[p,u,a,s,c,f,j,r]),be=n.useCallback(async()=>{if(!(!s||a.pause_duration<=0||j)){v(!0);try{const l=await cs(s.id,a.pause_duration);t(x=>x&&{...x,pause_duration:a.pause_duration,paused:(l==null?void 0:l.paused)===!0,paused_until:Number((l==null?void 0:l.paused_until)||0)}),await c()}catch(l){console.error("重新暂停失败:",l)}finally{v(!1)}}},[a.pause_duration,s,c,j,t]),ne=n.useCallback(async(l,x,N)=>{var _;(_=z.current)==null||_.abort();const $=new AbortController;z.current=$;try{const B=await bs(l,$.signal);if(!Z(x,O.current,N,I.current))return;const oe={...Gs(B),sessionId:l};if(B.status==="success"){Q(),w(oe),o(fe=>({...fe,login_password:"",showLoginPassword:!1})),await c();return}if(B.status==="processing"||B.status==="verification_required"){w(oe),Q(),E.current=window.setTimeout(()=>void ne(l,x,N),1500);return}Q(),w(oe)}catch(B){if(!Z(x,O.current,N,I.current))return;Q(),w({sessionId:l,status:"failed",message:B instanceof Error?B.message:"查询密码登录状态失败",qrCodeUrl:""})}},[Q,c,o]),he=n.useCallback(async()=>{var $;if(!s)return;const l=a.username.trim();if(!l||!a.login_password)return;Q(),($=z.current)==null||$.abort();const x=++O.current;I.current=s.id;const N=new AbortController;z.current=N,w({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const _=await ms({account_id:s.id,account:l,password:a.login_password,show_browser:a.show_browser},{signal:N.signal});if(!Z(x,O.current,s.id,I.current))return;if(!_.success||!_.session_id)throw new Error(_.message||"无法启动密码登录");w({sessionId:_.session_id,status:"processing",message:_.message||"登录处理中",qrCodeUrl:""}),await ne(_.session_id,x,s.id)}catch(_){if(!Z(x,O.current,s.id,I.current))return;w({sessionId:"",status:"failed",message:_ instanceof Error?_.message:"启动密码登录失败",qrCodeUrl:""})}},[Q,a.login_password,a.show_browser,a.username,s,ne]),le=n.useCallback(async()=>{var x;const l=R.sessionId;O.current+=1,I.current="",(x=z.current)==null||x.abort(),Q(),l&&await hs(l).catch(()=>{}),w({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},[Q,R.sessionId]),ge=n.useCallback(async()=>{var l,x,N;(l=D.current)==null||l.abort(),J.current+=1,(x=H.current)==null||x.abort(),(N=V.current)==null||N.abort(),(R.status==="processing"||R.status==="verification_required")&&await le(),r(null)},[le,R.status,r]),pe=n.useCallback(()=>{var l;G.current+=1,(l=V.current)==null||l.abort(),r(null)},[r]);return n.useEffect(()=>(()=>{var l,x,N,$;(l=D.current)==null||l.abort(),(x=H.current)==null||x.abort(),(N=V.current)==null||N.abort(),($=z.current)==null||$.abort(),Q()}),[Q]),{longLogin:i,notifChannels:b,selectedChannelIds:f,bindingsLoaded:u,bindingsLoading:k,bindingsDirty:p,bindingsLoadError:U,aiSettings:T,saving:j,passwordLoginView:R,setAiSettings:S,setBindingsDirty:L,setEditForm:o,openEditModal:C,closeEditModal:ge,openAIModal:ee,closeAIModal:pe,loadNotificationBindings:F,toggleNotificationChannel:re,handleLongLoginToggle:W,handleSaveAISettings:xe,handleSaveEdit:me,handleRestartPause:be,handlePasswordLogin:he,handleCancelPasswordLogin:le}},Js=()=>{const{accounts:s,setAccounts:t,loading:r,loadAccounts:a}=Ds(),[o,c]=n.useState(""),[i,d]=n.useState(""),[b,m]=n.useState(""),[f,h]=n.useState(null),[u,A]=n.useState(""),[k,g]=n.useState(null),[p,L]=n.useState(null),[U,M]=n.useState(null),[T,S]=n.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),j=Ws({editingAccount:p,setEditingAccount:L,setActiveModal:g,editForm:T,setEditForm:S,loadAccounts:a}),{longLogin:v,notifChannels:R,selectedChannelIds:w,bindingsLoaded:q,bindingsLoading:D,bindingsLoadError:J,aiSettings:H,saving:G,passwordLoginView:V,setAiSettings:O,setBindingsDirty:I,openEditModal:z,closeEditModal:E,openAIModal:Q,closeAIModal:F,loadNotificationBindings:re,toggleNotificationChannel:C,handleLongLoginToggle:W,handleSaveAISettings:ee,handleSaveEdit:xe,handleRestartPause:me,handlePasswordLogin:be,handleCancelPasswordLogin:ne}=j,he=Ms({onLoginSuccess:a}),{showQRModal:le,qrCodeUrl:ge,qrStatus:pe,qrErrorMessage:l,verificationScreenshot:x,faceQrUrl:N,qrReauthTarget:$,startQRLogin:_,closeQRModal:B}=he,oe=async(y,P)=>{await os(y,!P),a()},fe=y=>{b||(A(""),h(y))},Ue=()=>{b||(A(""),h(null))},Me=async()=>{const y=f;if(!(!y||b)){m(y.id),A("");try{await is(y.id),t(P=>P.filter(se=>se.id!==y.id)),h(null)}catch(P){console.error("删除账号失败:",P),A((P==null?void 0:P.message)||"删除账号失败,请稍后重试")}finally{m("")}}},Be=async y=>{d(y.id);try{const P=await gs(y.id);P!=null&&P.profile_error&&alert("资料刷新失败:"+P.profile_error),await a()}catch(P){console.error("刷新账号资料失败:",P),alert((P==null?void 0:P.message)||"刷新账号资料失败,请先重新授权该账号")}finally{d("")}};if(r)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(K,{className:"w-8 h-8 text-brand animate-spin"})});const ye=s.filter(y=>{const P=o.trim().toLowerCase();return P?[y.id,y.nickname,y.remark,y.username,y.runtime_message].some(se=>(se||"").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:o,onChange:(y=>c(y.target.value)),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:(()=>_()),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(ve,{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:["当前显示 ",ye.length," / ",s.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[ye.map(y=>e.jsx(qs,{account:y,refreshing:i===y.id,deleting:b===y.id,onRefreshProfile:Be,onReauthorize:_,onEdit:z,onAI:Q,onTasks:M,onToggle:oe,onDelete:fe},y.id)),s.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(De,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),s.length>0&&ye.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。"})]})]}),U&&ie.createPortal(e.jsx(Cs,{account:U,onClose:(()=>M(null)),onSaved:(y=>{t(P=>P.map(se=>se.id===U.id?{...se,auto_rate_enabled:y.auto_rate_enabled,rate_content:y.rate_content,auto_polish_enabled:y.auto_polish_enabled,polish_time:y.polish_time,last_rate_scan_at:y.last_rate_scan_at,last_polish_date:y.last_polish_date,last_polish_at:y.last_polish_at}:se))})}),document.body),f&&e.jsx(Ps,{account:f,deleting:b===f.id,error:u,onClose:Ue,onConfirm:Me}),le&&e.jsx(Ts,{target:$,status:pe,codeUrl:ge,errorMessage:l,faceQrUrl:N,verificationScreenshot:x,onClose:B}),k==="edit"&&p&&e.jsx(Ls,{account:p,editForm:T,setEditForm:S,saving:G,onClose:E,onSave:xe,onRestartPause:me,longLogin:v,onToggleLongLogin:W,passwordLoginView:V,onPasswordLogin:be,onCancelPasswordLogin:ne,notifChannels:R,selectedChannelIds:w,bindingsLoaded:q,bindingsLoading:D,bindingsLoadError:J,onRetryBindings:(()=>re(p.id)),onToggleChannel:C,onSettingsDirty:(()=>I(!0))}),k==="ai-settings"&&p&&e.jsx(vs,{account:p,settings:H,saving:G,onChange:O,onClose:F,onSave:ee})]})};export{Js as default}; diff --git a/internal/webui/static/assets/CardList-CvCo2zF6.js b/internal/webui/static/assets/CardList-CfmBeFUG.js similarity index 96% rename from internal/webui/static/assets/CardList-CvCo2zF6.js rename to internal/webui/static/assets/CardList-CfmBeFUG.js index 236f189..f4e8fd7 100644 --- a/internal/webui/static/assets/CardList-CvCo2zF6.js +++ b/internal/webui/static/assets/CardList-CfmBeFUG.js @@ -1,10 +1,10 @@ -import{r as i,b as z,j as e}from"./react-vendor-C_od1ZSF.js";import{g as Z,c as ee,p as te,d as ae,a as H,b as se}from"./index-zEvleK2K.js";import{X as G,W as le,J as O,Y as ne,L as V,N as U,C as W,_ as re,$ as X,a0 as Y,a1 as oe,I as ie,a2 as ce,V as de,y as xe,P as pe,o as me}from"./icons-vendor-DwxdQTKt.js";const he=l=>{let n=l.api_config;if(typeof n=="string"&&n.trim())try{n=JSON.parse(n)}catch{n=void 0}return{...l,api_config:n||void 0}},K=l=>({...l,api_config:l.api_config?JSON.stringify(l.api_config):""}),ue=async l=>{const n=await Z("/api/v1/cards",void 0,l);return ee(n,["cards","data","items"]).map(he)},be=async l=>H("/api/v1/cards",K(l)),J=async(l,n)=>te(`/api/v1/cards/${l}`,K(n)),ge=async l=>ae(`/api/v1/cards/${l}`),ye=async(l,n)=>{const a=new FormData;return a.append("file",l),se("/api/v1/cards/batch",a,n)},fe=async(l,n,a)=>H(`/api/v1/cards/${l}/append-data`,{content:n},a),je=(l,n,a)=>{const u=a.trim().toLocaleLowerCase();return l.filter(m=>(!n||m.type===n)&&(!u||m.name.toLocaleLowerCase().includes(u)))},Q=l=>l.split(` +import{a as i,b as z,j as e}from"./react-vendor-l-BBvuKH.js";import{g as Z,c as ee,p as te,e as ae,b as H,d as se}from"./index-WrujSo30.js";import{X as G,W as le,J as O,Y as ne,L as V,N as U,C as W,_ as re,$ as X,a0 as Y,a1 as oe,I as ie,a2 as ce,V as de,y as xe,P as pe,o as me}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const he=l=>{let n=l.api_config;if(typeof n=="string"&&n.trim())try{n=JSON.parse(n)}catch{n=void 0}return{...l,api_config:n||void 0}},K=l=>({...l,api_config:l.api_config?JSON.stringify(l.api_config):""}),ue=async l=>{const n=await Z("/api/v1/cards",void 0,l);return ee(n,["cards","data","items"]).map(he)},be=async l=>H("/api/v1/cards",K(l)),J=async(l,n)=>te(`/api/v1/cards/${l}`,K(n)),ge=async l=>ae(`/api/v1/cards/${l}`),ye=async(l,n)=>{const a=new FormData;return a.append("file",l),se("/api/v1/cards/batch",a,n)},fe=async(l,n,a)=>H(`/api/v1/cards/${l}/append-data`,{content:n},a),je=(l,n,a)=>{const u=a.trim().toLocaleLowerCase();return l.filter(m=>(!n||m.type===n)&&(!u||m.name.toLocaleLowerCase().includes(u)))},Q=l=>l.split(` `).map(n=>n.trim()).filter(Boolean),Ne=(l,n,a)=>!!(l&&Q(n).length>0&&!a),F=(l,n,a,u)=>l===n&&a===u,q=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),D=(l,n)=>l instanceof Error?l.message:n,ve=({cards:l,loadCards:n})=>{const[a,u]=i.useState(!1),[m,_]=i.useState(!1),[f,j]=i.useState(null),[d,A]=i.useState({}),[c,y]=i.useState(q),[N,b]=i.useState(""),[r,x]=i.useState(""),s=i.useMemo(()=>l.filter(o=>o.type==="data"),[l]),h=i.useMemo(()=>je(l,N,r),[l,r,N]),E=i.useCallback(o=>{var t,g,k,S,C;j(o),A({id:o.id,name:o.name||"",type:o.type||"text",api_url:((t=o.api_config)==null?void 0:t.url)||"",api_method:((g=o.api_config)==null?void 0:g.method)||"GET",api_timeout:((k=o.api_config)==null?void 0:k.timeout)||10,api_headers:((S=o.api_config)==null?void 0:S.headers)||"",api_params:((C=o.api_config)==null?void 0:C.params)||"",text_content:o.text_content||"",data_content:o.data_content||"",image_url:o.image_url||"",delay_seconds:o.delay_seconds||0,description:o.description||"",enabled:o.enabled}),u(!0)},[]),M=i.useCallback(async()=>{var o,t,g,k,S,C,p,B;if(f){if(!((o=d.name)!=null&&o.trim())){alert("请输入卡密名称");return}if(!d.type){alert("请选择卡密类型");return}try{const w={name:d.name.trim(),type:d.type,description:(t=d.description)==null?void 0:t.trim(),delay_seconds:d.delay_seconds||0,enabled:d.enabled??!0};d.type==="api"?w.api_config={url:((g=d.api_url)==null?void 0:g.trim())||"",method:d.api_method||"GET",timeout:d.api_timeout||10,headers:((k=d.api_headers)==null?void 0:k.trim())||void 0,params:((S=d.api_params)==null?void 0:S.trim())||void 0}:d.type==="text"?w.text_content=((C=d.text_content)==null?void 0:C.trim())||"":d.type==="data"?w.data_content=((p=d.data_content)==null?void 0:p.trim())||"":d.type==="image"&&(w.image_url=((B=d.image_url)==null?void 0:B.trim())||""),await J(f.id,w),u(!1),await n()}catch(w){console.error("更新卡密失败:",w),alert(D(w,"更新失败,请重试"))}}},[d,n,f]),R=i.useCallback(async o=>{if(confirm("确认删除该卡密吗?"))try{await ge(o),await n()}catch(t){console.error("删除卡密失败:",t),alert(D(t,"删除失败,请重试"))}},[n]),v=i.useCallback(async()=>{if(!c.name.trim()){alert("请输入卡密名称");return}if(!c.content.trim()){alert(c.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const o={name:c.name.trim(),type:c.type,description:c.description.trim(),enabled:c.enabled,delay_seconds:c.delay_seconds};c.type==="text"&&(o.text_content=c.content.trim()),c.type==="data"&&(o.data_content=c.content.trim()),c.type==="image"&&(o.image_url=c.content.trim()),c.type==="api"&&(o.api_config={url:c.content.trim(),method:c.api_method,timeout:c.api_timeout,headers:c.api_headers.trim()||void 0,params:c.api_params.trim()||void 0}),await be(o),_(!1),y(q()),await n()}catch(o){console.error("添加卡密失败:",o),alert(D(o,"添加失败,请重试"))}},[c,n]),T=i.useCallback(async o=>{try{await J(o.id,{...o,enabled:!o.enabled}),await n()}catch(t){console.error("切换状态失败:",t)}},[n]),P=i.useCallback(async o=>{try{await navigator.clipboard.writeText(String(o)),alert(`已复制卡密组ID:${o}`)}catch{prompt("复制卡密组ID",String(o))}},[]),$=i.useCallback(()=>{const g=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 VIP-MONTH-002 VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(p=>p.map(B=>`"${String(B).replace(/"/g,'""')}"`).join(",")).join(` `),k=new Blob(["\uFEFF"+g],{type:"text/csv;charset=utf-8"}),S=URL.createObjectURL(k),C=document.createElement("a");C.href=S,C.download="卡密组批量导入模板.csv",document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(S)},[]);return{dataCards:s,filteredCards:h,typeFilter:N,setTypeFilter:b,nameSearch:r,setNameSearch:x,showEditModal:a,setShowEditModal:u,showAddModal:m,setShowAddModal:_,selectedCard:f,editForm:d,setEditForm:A,addForm:c,setAddForm:y,handleEdit:E,handleSaveEdit:M,handleDelete:R,handleAddCard:v,toggleCardStatus:T,copyCardID:P,downloadCardTemplate:$}},we=({dataCards:l,downloadCardTemplate:n,...a})=>{var x;const u=s=>{var h;a.setBatchFile(((h=s.target.files)==null?void 0:h[0])||null)},m=s=>{a.setAppendContent(s.target.value)},_=s=>{a.setAppendTargetId(s.target.value)},f=()=>a.closeBatchModal(),j=()=>a.setBatchTab("create"),d=()=>a.setBatchTab("append"),A=()=>void a.handleRetryBatchCreate(),c=()=>void a.handleRetryBatchAppend(),y=a.batchResult&&"rows"in a.batchResult?a.batchResult:null,N=s=>e.jsxs("option",{value:String(s.id),children:[s.name,"(ID: ",s.id,")"]},s.id),b=()=>void a.handleBatchCreate(),r=()=>void a.handleBatchAppend();return a.showBatchModal?z.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:f,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(G,{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:j,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(le,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:d,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(O,{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:n,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(ne,{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(O,{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:u})]})]}),((x=a.batchResult)==null?void 0:x.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:A,disabled:!a.batchFile||a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),y&&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:["共 ",y.total," 行 · 成功 ",y.created," · 失败 ",y.failed]}),y.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:y.rows.filter(s=>!s.success).map(s=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",s.row_no," 行「",s.name,"」:",s.error]},s.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:l.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:l.map(N)})]}),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:m,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:c,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:f,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:b,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(V,{className:"w-4 h-4 animate-spin"}):e.jsx(O,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:r,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||l.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(V,{className:"w-4 h-4 animate-spin"}):e.jsx(U,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},Ce=({type:l})=>{switch(l){case"text":return e.jsx(Y,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(X,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(re,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(W,{className:"w-5 h-5 text-gray-500"})}},_e=()=>{const[l,n]=i.useState([]),[a,u]=i.useState(!0),m=i.useRef(0),_=i.useRef(null),f=i.useCallback(async()=>{var A;const j=++m.current;(A=_.current)==null||A.abort();const d=new AbortController;_.current=d,u(!0);try{const c=await ue({signal:d.signal});if(j!==m.current)return;n(c)}catch(c){j===m.current&&!d.signal.aborted&&console.error("加载卡密库存失败:",c)}finally{j===m.current&&u(!1)}},[]);return i.useEffect(()=>(f(),()=>{var d;m.current+=1,(d=_.current)==null||d.abort()}),[f]),{cards:l,setCards:n,loading:a,loadCards:f}},ke=l=>{const n=l.dataCards,a=l.loadCards,[u,m]=i.useState(!1),[_,f]=i.useState("create"),[j,d]=i.useState(null),[A,c]=i.useState(null),[y,N]=i.useState(!1),[b,r]=i.useState(""),[x,s]=i.useState(""),[h,E]=i.useState(null),[M,R]=i.useState(""),v=i.useRef(0),T=i.useRef(null),P=i.useRef("");i.useEffect(()=>(()=>{var p;v.current+=1,(p=T.current)==null||p.abort()}),[]);const $=i.useMemo(()=>Q(x),[x]),o=i.useCallback(()=>{var p;f("create"),d(null),c(null),r((p=n[0])!=null&&p.id?String(n[0].id):""),s(""),E(null),R(""),m(!0)},[n]),t=i.useCallback(()=>{var p;v.current+=1,(p=T.current)==null||p.abort(),N(!1),m(!1)},[]),g=i.useCallback(async()=>{var w;if(!j||y)return;const p=++v.current;(w=T.current)==null||w.abort();const B=new AbortController;T.current=B,N(!0),c(null);try{const I=await ye(j,{signal:B.signal});if(!F(p,v.current,"",""))return;c(I),I.created>0&&await a()}catch(I){if(!F(p,v.current,"",""))return;c({error:(I==null?void 0:I.message)||"上传失败"})}finally{F(p,v.current,"","")&&N(!1)}},[y,j,a]),k=i.useCallback(async()=>{var I;if(!Ne(b,x,y))return;const p=b,B=++v.current;P.current=p,(I=T.current)==null||I.abort();const w=new AbortController;T.current=w,N(!0),E(null),R("");try{const L=await fe(p,x,{signal:w.signal});if(!F(B,v.current,p,b))return;E({added:L.added}),s(""),await a()}catch(L){if(!F(B,v.current,p,b))return;R((L==null?void 0:L.message)||"追加失败")}finally{F(B,v.current,p,b)&&N(!1)}},[x,b,y,a]),S=i.useCallback(async()=>{await g()},[g]),C=i.useCallback(async()=>{P.current&&b!==P.current||await k()},[b,k]);return{showBatchModal:u,setShowBatchModal:m,batchTab:_,setBatchTab:f,batchFile:j,setBatchFile:d,batchResult:A,batchBusy:y,appendTargetId:b,setAppendTargetId:r,appendContent:x,setAppendContent:s,appendResult:h,appendError:M,appendPreview:$,openBatchModal:o,closeBatchModal:t,handleBatchCreate:g,handleBatchAppend:k,handleRetryBatchCreate:S,handleRetryBatchAppend:C}},Te=()=>{const{cards:l,loadCards:n}=_e(),a=ve({cards:l,loadCards:n}),{dataCards:u,filteredCards:m,typeFilter:_,setTypeFilter:f,nameSearch:j,setNameSearch:d,showEditModal:A,setShowEditModal:c,showAddModal:y,setShowAddModal:N,selectedCard:b,editForm:r,setEditForm:x,addForm:s,setAddForm:h,handleEdit:E,handleSaveEdit:M,handleDelete:R,handleAddCard:v,toggleCardStatus:T,copyCardID:P,downloadCardTemplate:$}=a,o=ke({dataCards:u,loadCards:n});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:o.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(O,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:(()=>N(!0)),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(U,{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(oe,{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:_,onChange:(t=>f(t.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(ie,{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:j,onChange:(t=>d(t.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:["显示 ",m.length," / ",l.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:m.map(t=>{let g="";return t.type==="data"&&t.data_content?g=`库存: ${t.data_content.split(` +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:c,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:f,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:b,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(V,{className:"w-4 h-4 animate-spin"}):e.jsx(O,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:r,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||l.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(V,{className:"w-4 h-4 animate-spin"}):e.jsx(U,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},Ce=({type:l})=>{switch(l){case"text":return e.jsx(Y,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(X,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(re,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(W,{className:"w-5 h-5 text-gray-500"})}},_e=()=>{const[l,n]=i.useState([]),[a,u]=i.useState(!0),m=i.useRef(0),_=i.useRef(null),f=i.useCallback(async()=>{var A;const j=++m.current;(A=_.current)==null||A.abort();const d=new AbortController;_.current=d,u(!0);try{const c=await ue({signal:d.signal});if(j!==m.current)return;n(c)}catch(c){j===m.current&&!d.signal.aborted&&console.error("加载卡密库存失败:",c)}finally{j===m.current&&u(!1)}},[]);return i.useEffect(()=>(f(),()=>{var d;m.current+=1,(d=_.current)==null||d.abort()}),[f]),{cards:l,setCards:n,loading:a,loadCards:f}},ke=l=>{const n=l.dataCards,a=l.loadCards,[u,m]=i.useState(!1),[_,f]=i.useState("create"),[j,d]=i.useState(null),[A,c]=i.useState(null),[y,N]=i.useState(!1),[b,r]=i.useState(""),[x,s]=i.useState(""),[h,E]=i.useState(null),[M,R]=i.useState(""),v=i.useRef(0),T=i.useRef(null),P=i.useRef("");i.useEffect(()=>(()=>{var p;v.current+=1,(p=T.current)==null||p.abort()}),[]);const $=i.useMemo(()=>Q(x),[x]),o=i.useCallback(()=>{var p;f("create"),d(null),c(null),r((p=n[0])!=null&&p.id?String(n[0].id):""),s(""),E(null),R(""),m(!0)},[n]),t=i.useCallback(()=>{var p;v.current+=1,(p=T.current)==null||p.abort(),N(!1),m(!1)},[]),g=i.useCallback(async()=>{var w;if(!j||y)return;const p=++v.current;(w=T.current)==null||w.abort();const B=new AbortController;T.current=B,N(!0),c(null);try{const I=await ye(j,{signal:B.signal});if(!F(p,v.current,"",""))return;c(I),I.created>0&&await a()}catch(I){if(!F(p,v.current,"",""))return;c({error:(I==null?void 0:I.message)||"上传失败"})}finally{F(p,v.current,"","")&&N(!1)}},[y,j,a]),k=i.useCallback(async()=>{var I;if(!Ne(b,x,y))return;const p=b,B=++v.current;P.current=p,(I=T.current)==null||I.abort();const w=new AbortController;T.current=w,N(!0),E(null),R("");try{const L=await fe(p,x,{signal:w.signal});if(!F(B,v.current,p,b))return;E({added:L.added}),s(""),await a()}catch(L){if(!F(B,v.current,p,b))return;R((L==null?void 0:L.message)||"追加失败")}finally{F(B,v.current,p,b)&&N(!1)}},[x,b,y,a]),S=i.useCallback(async()=>{await g()},[g]),C=i.useCallback(async()=>{P.current&&b!==P.current||await k()},[b,k]);return{showBatchModal:u,setShowBatchModal:m,batchTab:_,setBatchTab:f,batchFile:j,setBatchFile:d,batchResult:A,batchBusy:y,appendTargetId:b,setAppendTargetId:r,appendContent:x,setAppendContent:s,appendResult:h,appendError:M,appendPreview:$,openBatchModal:o,closeBatchModal:t,handleBatchCreate:g,handleBatchAppend:k,handleRetryBatchCreate:S,handleRetryBatchAppend:C}},Ie=()=>{const{cards:l,loadCards:n}=_e(),a=ve({cards:l,loadCards:n}),{dataCards:u,filteredCards:m,typeFilter:_,setTypeFilter:f,nameSearch:j,setNameSearch:d,showEditModal:A,setShowEditModal:c,showAddModal:y,setShowAddModal:N,selectedCard:b,editForm:r,setEditForm:x,addForm:s,setAddForm:h,handleEdit:E,handleSaveEdit:M,handleDelete:R,handleAddCard:v,toggleCardStatus:T,copyCardID:P,downloadCardTemplate:$}=a,o=ke({dataCards:u,loadCards:n});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:o.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(O,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:(()=>N(!0)),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(U,{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(oe,{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:_,onChange:(t=>f(t.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(ie,{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:j,onChange:(t=>d(t.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:["显示 ",m.length," / ",l.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:m.map(t=>{let g="";return t.type==="data"&&t.data_content?g=`库存: ${t.data_content.split(` `).filter(S=>S.trim()).length} 条`:t.type==="text"&&t.text_content?g=t.text_content:t.type==="api"&&t.api_config?g=t.api_config.url:t.type==="image"&&t.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(Ce,{type:t.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:t.name,children:t.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:(()=>P(t.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:t.id}),e.jsx(ce,{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 ${t.type==="text"?"bg-blue-50 text-blue-600":t.type==="data"?"bg-purple-50 text-purple-600":t.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:t.type==="text"?"文本":t.type==="data"?"批量":t.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:t.description||"-",children:t.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:(()=>T(t)),"aria-label":`切换卡密 ${t.name} 状态`,className:`w-12 h-8 rounded-full relative transition-colors ${t.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 ${t.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:(()=>E(t)),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(de,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>R(t.id)),"aria-label":`删除卡密 ${t.name}`,className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(xe,{className:"h-4 w-4"})})]})})]},t.id)})})]})}),m.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(pe,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:l.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),A&&b&&z.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:(()=>c(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(G,{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:r.name||"",onChange:(t=>x({...r,name:t.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:r.type||"text",onChange:(t=>x({...r,type:t.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:"批量数据"}),(b==null?void 0:b.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),r.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:r.api_url||"",onChange:(t=>x({...r,api_url:t.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:r.api_method||"GET",onChange:(t=>x({...r,api_method:t.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:r.api_timeout||10,onChange:(t=>x({...r,api_timeout:parseInt(t.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:r.api_headers||"",onChange:(t=>x({...r,api_headers:t.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:r.api_params||"",onChange:(t=>x({...r,api_params:t.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}'})]})]}),r.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:r.text_content||"",onChange:(t=>x({...r,text_content:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),r.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:r.data_content||"",onChange:(t=>x({...r,data_content:t.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 @@ -14,4 +14,4 @@ VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 `).filter(t=>t.trim()).length:0})," 条"]})]})]}),r.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:r.image_url||"",onChange:(t=>x({...r,image_url:t.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;发货时会临时下载并上传到闲鱼"})]}),r.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:r.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:(t=>{t.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:r.delay_seconds||0,onChange:(t=>x({...r,delay_seconds:parseInt(t.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:r.description||"",onChange:(t=>x({...r,description:t.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:(()=>x({...r,enabled:!r.enabled})),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${r.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 ${r.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:(()=>c(!1)),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:M,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(me,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),y&&z.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:(()=>N(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(G,{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:s.name,onChange:(t=>h({...s,name:t.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:(()=>h({...s,type:"data",content:""})),className:`p-3 rounded-xl font-bold transition-all ${s.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(W,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:(()=>h({...s,type:"text",content:""})),className:`p-3 rounded-xl font-bold transition-all ${s.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Y,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:(()=>h({...s,type:"image",content:""})),className:`p-3 rounded-xl font-bold transition-all ${s.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(X,{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:s.type==="data"?"库存内容(一行一个)":s.type==="text"?"固定回复内容":s.type==="image"?"图片 URL":"API 地址"}),s.type==="api"?e.jsx("input",{type:"url",value:s.content,onChange:(t=>h({...s,content:t.target.value})),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):s.type==="image"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"url",value:s.content,onChange:(t=>h({...s,content:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}),e.jsx("p",{className:"text-xs text-gray-500",children:"仅保存图片 URL;发货时会临时下载并上传到闲鱼"})]}):e.jsx("textarea",{value:s.content,onChange:(t=>h({...s,content:t.target.value})),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${s.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:s.type==="data"?`CODE-123456 CODE-789012 ...`:"请输入每次发货时发送的固定文字"}),s.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:s.content.split(` -`).filter(t=>t.trim()).length})," 条"]})]}),s.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:s.api_method,onChange:(t=>h({...s,api_method:t.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:s.api_timeout,onChange:(t=>h({...s,api_timeout:parseInt(t.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:s.api_headers,onChange:(t=>h({...s,api_headers:t.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:s.api_params,onChange:(t=>h({...s,api_params:t.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:s.description,onChange:(t=>h({...s,description:t.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:s.delay_seconds,onChange:(t=>h({...s,delay_seconds:parseInt(t.target.value)||0})),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:(()=>N(!1)),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick: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(U,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(we,{dataCards:u,downloadCardTemplate:$,...o})]})};export{Te as default}; +`).filter(t=>t.trim()).length})," 条"]})]}),s.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:s.api_method,onChange:(t=>h({...s,api_method:t.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:s.api_timeout,onChange:(t=>h({...s,api_timeout:parseInt(t.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:s.api_headers,onChange:(t=>h({...s,api_headers:t.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:s.api_params,onChange:(t=>h({...s,api_params:t.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:s.description,onChange:(t=>h({...s,description:t.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:s.delay_seconds,onChange:(t=>h({...s,delay_seconds:parseInt(t.target.value)||0})),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:(()=>N(!1)),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick: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(U,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(we,{dataCards:u,downloadCardTemplate:$,...o})]})};export{Ie as default}; diff --git a/internal/webui/static/assets/Chat-CKN6Wl0-.js b/internal/webui/static/assets/Chat-MUERwcqZ.js similarity index 99% rename from internal/webui/static/assets/Chat-CKN6Wl0-.js rename to internal/webui/static/assets/Chat-MUERwcqZ.js index 37be50f..6168dfd 100644 --- a/internal/webui/static/assets/Chat-CKN6Wl0-.js +++ b/internal/webui/static/assets/Chat-MUERwcqZ.js @@ -1 +1 @@ -import{j as e,c as x0,r as i}from"./react-vendor-C_od1ZSF.js";import{L as re}from"./vendor-Es4K8PXl.js";import{e as M0,f as le,h as F0,m as P0,s as ce,i as oe,j as pe,k as me,l as z0}from"./index-zEvleK2K.js";import{L as X,ak as ge,al as de,M as B0,I as xe,R as ue,ad as U0,k as he,am as _e,t as J0,an as be,ao as fe,ah as Q0,X as je}from"./icons-vendor-DwxdQTKt.js";const Z0=[["尊嘟假嘟","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"]],we=o=>o,Ne=new Map(Z0.map(([o,p])=>[o,p])),Ce=o=>o.split(/(\[[^\]]+\])/g).map((p,a)=>{const n=p.startsWith("[")?Ne.get(p.slice(1,-1)):void 0;return n?e.jsx("img",{src:n,alt:p,title:p,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(x0.Fragment,{children:p},a)}),q0=o=>{const p=Number.isFinite(o)?Math.max(0,Math.floor(o)):0;return p>99?"99+":String(p)},W0=o=>(Number.isFinite(o)?Math.max(0,Math.floor(o)):0)<10?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold leading-none text-white":"inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-red-500 px-1.5 text-[10px] font-bold leading-none text-white",V0=(o,p)=>o.filter(a=>a.direction==="incoming"&&a.message_type!=="system"&&!a.message_key.startsWith("in-")).map(a=>({messageId:a.message_key,sessionId:p,cid:`${p}@goofish`,conversationType:1})),ye=(o,p,a)=>{const n=p.trim().toLowerCase();return o.filter(u=>a&&u.unread_count<=0?!1:n?[u.buyer_name,u.buyer_id,u.item_title,u.last_message].some(y=>(y||"").toLowerCase().includes(n)):!0)},Oe=(o,p)=>{const a=new Set(o.map(n=>n.message_key));return[...p.filter(n=>!a.has(n.message_key)),...o]},T0=(o,p)=>{const a=o.findIndex(n=>n.message_key===p.message_key);return a<0?[...o,p]:o.map((n,u)=>u===a?p:n)},ve=(o,p)=>{if(p.direction!=="incoming"||p.message_type==="system")return o;const a=p.sent_at>0?p.sent_at:Date.now();return o.map(n=>n.chat_id===p.chat_id&&n.direction==="outgoing"&&n.status==="sent"&&n.sent_at<=p.sent_at?{...n,read_status:2,read_at:a}:n)},w=(o,p,a)=>o===p&&!a.aborted,K=o=>o instanceof Error&&o.message==="请求已取消",ke=o=>{if(!o)return"";const p=new Date(o<1e10?o*1e3:o),a=new Date;return p.toDateString()===a.toDateString()?p.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):p.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},Se=o=>new Date(o<1e10?o*1e3:o).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Re=()=>{const[o,p]=i.useState([]),[a,n]=i.useState(""),[u,y]=i.useState({}),[h,Y]=i.useState(""),[I,k]=i.useState([]),[$,y0]=i.useState(""),[T,O0]=i.useState(!1),[A,u0]=i.useState(""),[D,O]=i.useState(null),[B,L]=i.useState(!0),[M,h0]=i.useState(!1),[J,_0]=i.useState(!1),[e0,b0]=i.useState(!1),[f0,t0]=i.useState(),[s0,a0]=i.useState({}),[i0,n0]=i.useState({}),[r0,l0]=i.useState(!1),[v0,k0]=i.useState(!1),[N,U]=i.useState(!1),[S0,j]=i.useState(""),[R0,E0]=i.useState("connecting"),[Q,c0]=i.useState(null),[W,o0]=i.useState(null),S=i.useRef(""),V=i.useRef(""),H=i.useRef(null),Z=i.useRef({accountID:"",chatID:""}),p0=i.useRef(!0),s=i.useRef(!1),x=i.useRef(null),v=i.useRef(new Set),R=i.useRef(0),F=i.useRef(null),P=i.useRef(0),I0=i.useRef(null),z=i.useRef(0),m0=i.useRef(null),g0=i.useRef(0),j0=i.useRef(null),E=i.useRef(0),G=i.useRef(null);i.useEffect(()=>{S.current=a},[a]),i.useEffect(()=>{V.current=h},[h]);const d0=i.useCallback(async t=>{var m;const r=++R.current;(m=F.current)==null||m.abort();const l=new AbortController;F.current=l;try{const c=await M0(t,void 0,{signal:l.signal},!0);if(!w(R.current,r,l.signal))return[];const g=c.sessions.map(d=>t===S.current&&d.chat_id===V.current?{...d,unread_count:0}:d);return y(d=>({...d,[t]:g})),a0(d=>({...d,[t]:c.next_cursor})),n0(d=>({...d,[t]:c.has_more})),g}catch(c){return w(R.current,r,l.signal)&&!K(c)&&j(c instanceof Error?c.message:"同步会话失败"),[]}},[]);i.useEffect(()=>{const t=new AbortController;return(async()=>{var l;L(!0);try{const[m,c]=await Promise.all([me({signal:t.signal}),z0({signal:t.signal})]),d=m.map(f=>{var q,H0;return{...f,runtime_state:((q=c[f.id])==null?void 0:q.state)||(f.enabled?"connecting":"disabled"),runtime_connected:((H0=c[f.id])==null?void 0:H0.connected)===!0}}).filter(f=>f.enabled),b=await Promise.all(d.map(async f=>[f.id,await M0(f.id,void 0,{signal:t.signal})]));if(t.signal.aborted)return;p(d),y(Object.fromEntries(b.map(([f,q])=>[f,q.sessions]))),a0(Object.fromEntries(b.map(([f,q])=>[f,q.next_cursor]))),n0(Object.fromEntries(b.map(([f,q])=>[f,q.has_more])));const C=window.localStorage.getItem("ydisks.chat.account.v1")||"",L0=d.some(f=>f.id===C)?C:((l=d[0])==null?void 0:l.id)||"";n(L0)}catch(m){t.signal.aborted||j(m instanceof Error?m.message:"加载聊天数据失败")}finally{t.signal.aborted||L(!1)}})(),(()=>t.abort())},[]),i.useEffect(()=>{let t=!1,r=0,l=null;const m=async()=>{l=new AbortController;try{const c=await z0({signal:l.signal,timeoutMs:1e4});t||p(g=>g.map(d=>{var b,C;return{...d,runtime_state:((b=c[d.id])==null?void 0:b.state)||d.runtime_state,runtime_connected:((C=c[d.id])==null?void 0:C.connected)??d.runtime_connected}}))}catch{}finally{t||(r=window.setTimeout(m,3e3))}};return r=window.setTimeout(m,3e3),(()=>{t=!0,window.clearTimeout(r),l==null||l.abort()})},[]),i.useEffect(()=>{if(!a)return;window.localStorage.setItem("ydisks.chat.account.v1",a);const t=u[a]||[];Y(r=>{var l;return t.some(m=>m.chat_id===r)?r:((l=t[0])==null?void 0:l.chat_id)||""})},[a,u]),i.useEffect(()=>{const t=Object.keys(u).length;if(B||o.length>0&&t===0)return;const r=Object.values(u).some(l=>l.some(m=>m.unread_count>0));le(r)},[o.length,B,u]),i.useEffect(()=>{!a||v.current.has(a)||(v.current.add(a),d0(a))},[a,d0]),i.useEffect(()=>{var l,m;if(!a||!h){P.current+=1,z.current+=1,(l=m0.current)==null||l.abort(),s.current=!1,k([]);return}const t=++P.current;(m=I0.current)==null||m.abort();const r=new AbortController;return I0.current=r,h0(!0),F0(a,h,void 0,void 0,{signal:r.signal}).then(c=>{if(!w(P.current,t,r.signal))return;const g=V0(c.messages,h);P0(a,h,g,{signal:r.signal}),k(c.messages),b0(c.has_more),t0(c.next_cursor),c.session&&y(d=>({...d,[a]:(d[a]||[]).map(b=>{var C;return b.chat_id===((C=c.session)==null?void 0:C.chat_id)?c.session:b})})),y(d=>({...d,[a]:(d[a]||[]).map(b=>b.chat_id===h?{...b,unread_count:0}:b)}))}).catch(c=>{w(P.current,t,r.signal)&&!K(c)&&j(c instanceof Error?c.message:"加载消息失败")}).finally(()=>{w(P.current,t,r.signal)&&h0(!1)}),(()=>r.abort())},[a,h]),i.useEffect(()=>{var t;(t=j0.current)==null||t.abort(),g0.current+=1},[a]),i.useEffect(()=>{var t;(t=G.current)==null||t.abort(),E.current+=1},[a,h]),i.useEffect(()=>{O(null)},[a,h]),i.useEffect(()=>{var t;z.current+=1,(t=m0.current)==null||t.abort(),s.current=!1},[a,h]),i.useEffect(()=>(()=>{var t,r,l,m,c;(t=F.current)==null||t.abort(),(r=I0.current)==null||r.abort(),z.current+=1,(l=m0.current)==null||l.abort(),(m=j0.current)==null||m.abort(),(c=G.current)==null||c.abort()}),[]),i.useEffect(()=>{const t=D;return(()=>{t&&URL.revokeObjectURL(t.url)})},[D]);const G0=i.useCallback(async()=>{var g,d;if(!a||!h||J||!e0)return;const t=H.current,r=(t==null?void 0:t.scrollHeight)||0,l=P.current,m=++z.current;(g=m0.current)==null||g.abort();const c=new AbortController;m0.current=c,s.current=!0,_0(!0),j("");try{const b=(d=I[0])==null?void 0:d.id,C=await F0(a,h,f0,b,{signal:c.signal});if(!w(P.current,l,c.signal)||m!==z.current)return;k(L0=>Oe(L0,C.messages)),b0(C.has_more),t0(C.next_cursor),requestAnimationFrame(()=>{m===z.current&&!c.signal.aborted&&t&&(t.scrollTop+=t.scrollHeight-r)})}catch(b){s.current=!1,K(b)||j(b instanceof Error?b.message:"加载历史消息失败")}finally{m===z.current&&_0(!1)}},[a,h,e0,f0,I,J]),A0=i.useCallback(t=>{const r=t.account_id;if(y(l=>{const m=l[r]||[];return m.some(g=>g.chat_id===t.chat_id)?{...l,[r]:m.map(g=>g.chat_id===t.chat_id?{...g,last_message:t.content,last_message_at:t.sent_at,unread_count:t.direction==="incoming"&&t.message_type!=="system"&&(S.current!==r||V.current!==t.chat_id)?g.unread_count+1:g.unread_count}:g).sort((g,d)=>d.last_message_at-g.last_message_at)}:(d0(r),l)}),S.current===r&&V.current===t.chat_id&&(k(l=>ve(T0(l,t),t)),t.direction==="incoming"&&t.message_type!=="system")){const l=V0([t],t.chat_id);P0(r,t.chat_id,l)}},[d0]);i.useEffect(()=>ce(r=>{if(r.type==="connection"){E0(r.state);return}A0(r.message)}),[A0]);const X0=i.useCallback(()=>{const t=H.current;if(!t)return;const r=t.scrollHeight-t.scrollTop-t.clientHeight;p0.current=r<=48},[]);i.useLayoutEffect(()=>{const t=Z.current.accountID!==a||Z.current.chatID!==h;Z.current={accountID:a,chatID:h},t&&(p0.current=!0);const r=H.current;if(r){if(s.current){s.current=!1;return}(M||p0.current)&&(r.scrollTop=r.scrollHeight)}},[a,h,I,M]);const K0=o.find(t=>t.id===a),w0=u[a]||[],_=w0.find(t=>t.chat_id===h),Y0=i.useMemo(()=>ye(w0,$,T),[w0,$,T]),$0=i.useCallback(t=>(u[t]||[]).reduce((r,l)=>r+l.unread_count,0),[u]),ee=i.useCallback(async()=>{var m;if(!a||r0||!i0[a])return;const t=++g0.current;(m=j0.current)==null||m.abort();const r=new AbortController;j0.current=r;const l=a;l0(!0),j("");try{const c=await M0(l,s0[l],{signal:r.signal},!0);if(!w(g0.current,t,r.signal))return;y(g=>({...g,[l]:c.sessions})),a0(g=>({...g,[l]:c.next_cursor})),n0(g=>({...g,[l]:c.has_more}))}catch(c){w(g0.current,t,r.signal)&&!K(c)&&j(c instanceof Error?c.message:"加载历史联系人失败")}finally{w(g0.current,t,r.signal)&&l0(!1)}},[a,s0,r0,i0]),N0=i.useCallback(async(t,r)=>{var c;if(!_||!a||N)return;const l=++E.current;(c=G.current)==null||c.abort();const m=new AbortController;G.current=m,U(!0),j("");try{const g=await oe({account_id:a,chat_id:_.chat_id,buyer_id:_.buyer_id,buyer_name:_.buyer_name,item_id:_.item_id,item_title:_.item_title,text:t},{signal:m.signal});if(!w(E.current,l,m.signal))return;u0(""),c0(null),k(d=>T0(d,g.message))}catch(g){w(E.current,l,m.signal)&&(r&&c0(t),K(g)||j(g instanceof Error?g.message:"消息发送失败"))}finally{w(E.current,l,m.signal)&&U(!1)}},[a,_,N]),C0=i.useCallback(async(t,r)=>{var c;if(!_||!a||N)return;const l=++E.current;(c=G.current)==null||c.abort();const m=new AbortController;G.current=m,U(!0),j("");try{const g=await pe({account_id:a,chat_id:_.chat_id,buyer_id:_.buyer_id,buyer_name:_.buyer_name,buyer_avatar_url:_.buyer_avatar_url,item_id:_.item_id,item_title:_.item_title,image:t},{signal:m.signal});if(!w(E.current,l,m.signal))return;o0(null),k(d=>T0(d,g.message))}catch(g){w(E.current,l,m.signal)&&(r&&o0(t),K(g)||j(g instanceof Error?g.message:"图片发送失败"))}finally{w(E.current,l,m.signal)&&(U(!1),x.current&&(x.current.value=""))}},[a,_,N]),te=i.useCallback(async()=>{const t=A.trim();!t||!_||!a||N||await N0(t,!0)},[a,A,_,N0,N]),D0=i.useCallback(async t=>{if(!(!t||!_||!a||N)){if(!t.type.startsWith("image/")){j("仅支持粘贴/发送图片文件");return}j(""),O({file:t,url:URL.createObjectURL(t)})}},[a,_,N]),se=i.useCallback(async t=>{const r=t.find(l=>l.type.startsWith("image/"));r&&await D0(r)},[D0]),ae=i.useCallback(()=>{O(null),x.current&&(x.current.value="")},[]),ie=i.useCallback(async()=>{if(!D||!_||!a||N)return;const t=D.file;O(null),await C0(t,!0)},[a,D,_,C0,N]),ne=i.useCallback(async()=>{Q?await N0(Q,!1):W&&await C0(W,!1)},[W,Q,C0,N0]);return{accounts:o,activeAccountID:a,activeSessions:w0,selectedSession:_,activeAccount:K0,messages:I,search:$,unreadOnly:T,draft:A,loading:B,messagesLoading:M,olderLoading:J,hasOlder:e0,contactsLoading:r0,hasMoreContacts:i0[a]===!0,emojiOpen:v0,sending:N,error:S0,liveState:R0,pendingImage:D,activeChatID:h,filteredSessions:Y0,scrollRef:H,imageInputRef:x,setActiveAccountID:n,setActiveChatID:Y,setSearch:y0,setUnreadOnly:O0,setDraft:u0,setEmojiOpen:k0,reloadSessions:d0,loadMoreContacts:ee,loadOlderMessages:G0,handleMessageScroll:X0,handleSend:te,handleImage:D0,handlePastedImages:se,confirmSendImage:ie,closeImagePreview:ae,retrySend:ne,retryAvailable:!!(Q||W),unreadForAccount:$0,emojiURL:we,xianyuEmojis:Z0,renderXianyuText:Ce,formatClock:ke,messageTime:Se}},Me=()=>{const{accounts:o,activeAccountID:p,activeChatID:a,activeAccount:n,selectedSession:u,filteredSessions:y,messages:h,search:Y,unreadOnly:I,draft:k,loading:$,messagesLoading:y0,olderLoading:T,hasOlder:O0,contactsLoading:A,hasMoreContacts:u0,emojiOpen:D,sending:O,error:B,liveState:L,pendingImage:M,scrollRef:h0,imageInputRef:J,setActiveAccountID:_0,setActiveChatID:e0,setSearch:b0,setUnreadOnly:f0,setDraft:t0,setEmojiOpen:s0,reloadSessions:a0,loadMoreContacts:i0,loadOlderMessages:n0,handleMessageScroll:r0,handleSend:l0,handleImage:v0,handlePastedImages:k0,confirmSendImage:N,closeImagePreview:U,retrySend:S0,retryAvailable:j,unreadForAccount:R0,emojiURL:E0,xianyuEmojis:Q,renderXianyuText:c0,formatClock:W,messageTime:o0}=Re(),S=x0.useMemo(()=>h.filter(s=>s.message_type==="image"),[h]),V=x0.useMemo(()=>S.map(s=>({src:s.content,alt:"聊天图片"})),[S]),[H,Z]=x0.useState(-1),p0=x0.useCallback(s=>{Z(S.findIndex(x=>x.message_key===s))},[S]);return $?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(X,{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 ${L==="online"?"bg-emerald-50 text-emerald-700":L==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[L==="online"?e.jsx(ge,{className:"h-3.5 w-3.5"}):e.jsx(de,{className:"h-3.5 w-3.5"}),L==="online"?"实时同步中":L==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:o.map(s=>{const x=s.id===p,v=R0(s.id),R=q0(v),F=s.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":x,onClick:(()=>_0(s.id)),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${x?"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 ${F?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:s.nickname||s.remark||s.id}),v>0&&e.jsx("span",{"aria-label":`未读消息 ${R} 条`,className:W0(v),children:R})]},s.id)})})]}),o.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(B0,{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(xe,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:Y,onChange:(s=>b0(s.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:(()=>f0(s=>!s)),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${I?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:I?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:(()=>void a0(p)),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:[y.map(s=>e.jsxs("button",{type:"button",onClick:(()=>e0(s.chat_id)),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${s.chat_id===a?"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:s.buyer_avatar_url?e.jsx("img",{src:s.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(U0,{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:s.buyer_name||`用户 ${s.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:W(s.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:s.last_message||"暂无消息"}),s.unread_count>0&&e.jsx("span",{"aria-label":`未读消息 ${q0(s.unread_count)} 条`,className:`ml-auto ${W0(s.unread_count)}`,children:q0(s.unread_count)})]}),s.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",s.item_title]})]})]},s.chat_id)),y.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),u0&&!Y&&!I&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:(()=>void i0()),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(X,{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:u?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:u.buyer_name||u.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",u.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(n==null?void 0:n.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(n==null?void 0:n.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:h0,onScroll:r0,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:y0?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(X,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[O0&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:(()=>void n0()),disabled:T,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:[T&&e.jsx(X,{className:"h-3.5 w-3.5 animate-spin"}),T?"正在加载":"加载更早消息"]})}),h.map(s=>{const x=s.direction==="outgoing";return s.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:[c0(s.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:o0(s.sent_at)})]})},s.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${x?"justify-end":"justify-start"}`,children:[!x&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:u.buyer_avatar_url?e.jsx("img",{src:u.buyer_avatar_url,alt:u.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(U0,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${x?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:x?(n==null?void 0:n.nickname)||(n==null?void 0:n.remark)||"我":u.buyer_name||s.sender_name||u.buyer_id}),s.message_type==="image"?e.jsx("button",{type:"button",title:"点击预览大图",onClick:p0.bind(null,s.message_key),className:`block cursor-zoom-in overflow-hidden rounded-2xl border bg-white p-1 text-left shadow-sm ${x?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:s.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):s.message_type==="video"?e.jsx("video",{src:s.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 ${x?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:c0(s.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[o0(s.sent_at),x&&(s.status==="failed"?e.jsx(he,{className:"h-3 w-3 text-red-500","aria-label":"发送失败"}):s.read_status===2?e.jsx(_e,{className:"h-3 w-3 text-sky-500","aria-label":"对方已读"}):s.status==="sent"?e.jsx(J0,{className:"h-3 w-3 text-sky-500","aria-label":"已发送未读"}):e.jsx(J0,{className:"h-3 w-3","aria-label":"发送中"}))]})]}),x&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:n!=null&&n.avatar_url?e.jsx("img",{src:n.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(U0,{className:"m-2 h-5 w-5 text-sky-600"})})]},s.message_key)})]})}),B&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:[e.jsx("span",{children:B}),j&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>void S0()),children:"重试发送"})]}),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:(()=>s0(s=>!s)),disabled:O||(n==null?void 0:n.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(be,{className:"h-5 w-5"})}),D&&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:Q.map(([s,x])=>e.jsx("button",{type:"button",title:`[${s}]`,onClick:(()=>{t0(v=>v+`[${s}]`),s0(!1)}),className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:E0(x),alt:`[${s}]`,className:"h-8 w-8 object-contain"})},s))})]})]}),e.jsx("input",{ref:J,type:"file",accept:"image/*",className:"hidden",onChange:(s=>{var x;return void v0((x=s.target.files)==null?void 0:x[0])})}),e.jsx("button",{type:"button",onClick:(()=>{var s;return(s=J.current)==null?void 0:s.click()}),disabled:O||(n==null?void 0:n.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(fe,{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:k,onChange:(s=>t0(s.target.value)),rows:2,maxLength:2e3,onKeyDown:(s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),l0())}),onPaste:(s=>{var R;const x=Array.from(((R=s.clipboardData)==null?void 0:R.files)||[]);x.find(F=>F.type.startsWith("image/"))&&(s.preventDefault(),k0(x))}),disabled:(n==null?void 0:n.runtime_state)!=="online",placeholder:(n==null?void 0:n.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行,Ctrl + V 粘贴图片":"账号离线,暂时无法发送",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 l0()),disabled:!k.trim()||O||(n==null?void 0:n.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:O?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsx(Q0,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(B0,{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:"该账号的新消息会实时出现在左侧列表。"})]})})]}),M&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-950/60 p-4",onClick:U,children:e.jsxs("div",{className:"flex max-h-full w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl",onClick:(s=>s.stopPropagation()),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-slate-200 px-5 py-3",children:[e.jsx("div",{className:"text-sm font-black text-slate-900",children:"发送图片预览"}),e.jsx("button",{type:"button",title:"取消",onClick:U,className:"rounded-lg p-1.5 text-slate-400 transition hover:bg-slate-100 hover:text-slate-700",children:e.jsx(je,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-slate-100 p-4",children:e.jsx("img",{src:M.url,alt:"待发送图片预览",className:"max-h-[55vh] max-w-full rounded-xl object-contain"})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3",children:[e.jsxs("div",{className:"min-w-0 truncate text-xs text-slate-500",children:[M.file.name||"粘贴的图片"," · ",(M.file.size/1024).toFixed(0)," KB"]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:U,className:"rounded-xl px-4 py-2 text-sm font-bold text-slate-600 transition hover:bg-slate-100",children:"取消"}),e.jsxs("button",{type:"button",onClick:(()=>void N()),disabled:O||(n==null?void 0:n.runtime_state)!=="online",className:"flex items-center gap-2 rounded-xl bg-sky-500 px-4 py-2 text-sm font-bold text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:opacity-50",children:[O?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsx(Q0,{className:"h-4 w-4"}),"发送"]})]})]})]})}),e.jsx(re,{open:H>=0,index:Math.max(H,0),close:(()=>Z(-1)),slides:V})]})};export{Me as default}; +import{j as e,c as x0,a as i}from"./react-vendor-l-BBvuKH.js";import{L as re}from"./vendor-cRYyTeIw.js";import{f as M0,h as le,i as F0,m as P0,s as ce,j as oe,k as pe,l as me,n as z0}from"./index-WrujSo30.js";import{L as X,ak as ge,al as de,M as B0,I as xe,R as ue,ad as U0,k as he,am as _e,t as J0,an as be,ao as fe,ah as Q0,X as je}from"./icons-vendor-Bgrth_9N.js";const Z0=[["尊嘟假嘟","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"]],we=o=>o,Ne=new Map(Z0.map(([o,p])=>[o,p])),Ce=o=>o.split(/(\[[^\]]+\])/g).map((p,a)=>{const n=p.startsWith("[")?Ne.get(p.slice(1,-1)):void 0;return n?e.jsx("img",{src:n,alt:p,title:p,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(x0.Fragment,{children:p},a)}),q0=o=>{const p=Number.isFinite(o)?Math.max(0,Math.floor(o)):0;return p>99?"99+":String(p)},W0=o=>(Number.isFinite(o)?Math.max(0,Math.floor(o)):0)<10?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold leading-none text-white":"inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-red-500 px-1.5 text-[10px] font-bold leading-none text-white",V0=(o,p)=>o.filter(a=>a.direction==="incoming"&&a.message_type!=="system"&&!a.message_key.startsWith("in-")).map(a=>({messageId:a.message_key,sessionId:p,cid:`${p}@goofish`,conversationType:1})),ye=(o,p,a)=>{const n=p.trim().toLowerCase();return o.filter(u=>a&&u.unread_count<=0?!1:n?[u.buyer_name,u.buyer_id,u.item_title,u.last_message].some(y=>(y||"").toLowerCase().includes(n)):!0)},Oe=(o,p)=>{const a=new Set(o.map(n=>n.message_key));return[...p.filter(n=>!a.has(n.message_key)),...o]},T0=(o,p)=>{const a=o.findIndex(n=>n.message_key===p.message_key);return a<0?[...o,p]:o.map((n,u)=>u===a?p:n)},ve=(o,p)=>{if(p.direction!=="incoming"||p.message_type==="system")return o;const a=p.sent_at>0?p.sent_at:Date.now();return o.map(n=>n.chat_id===p.chat_id&&n.direction==="outgoing"&&n.status==="sent"&&n.sent_at<=p.sent_at?{...n,read_status:2,read_at:a}:n)},w=(o,p,a)=>o===p&&!a.aborted,K=o=>o instanceof Error&&o.message==="请求已取消",ke=o=>{if(!o)return"";const p=new Date(o<1e10?o*1e3:o),a=new Date;return p.toDateString()===a.toDateString()?p.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):p.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},Se=o=>new Date(o<1e10?o*1e3:o).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Re=()=>{const[o,p]=i.useState([]),[a,n]=i.useState(""),[u,y]=i.useState({}),[h,Y]=i.useState(""),[I,k]=i.useState([]),[$,y0]=i.useState(""),[T,O0]=i.useState(!1),[A,u0]=i.useState(""),[D,O]=i.useState(null),[B,L]=i.useState(!0),[M,h0]=i.useState(!1),[J,_0]=i.useState(!1),[e0,b0]=i.useState(!1),[f0,t0]=i.useState(),[s0,a0]=i.useState({}),[i0,n0]=i.useState({}),[r0,l0]=i.useState(!1),[v0,k0]=i.useState(!1),[N,U]=i.useState(!1),[S0,j]=i.useState(""),[R0,E0]=i.useState("connecting"),[Q,c0]=i.useState(null),[W,o0]=i.useState(null),S=i.useRef(""),V=i.useRef(""),H=i.useRef(null),Z=i.useRef({accountID:"",chatID:""}),p0=i.useRef(!0),s=i.useRef(!1),x=i.useRef(null),v=i.useRef(new Set),R=i.useRef(0),F=i.useRef(null),P=i.useRef(0),I0=i.useRef(null),z=i.useRef(0),m0=i.useRef(null),g0=i.useRef(0),j0=i.useRef(null),E=i.useRef(0),G=i.useRef(null);i.useEffect(()=>{S.current=a},[a]),i.useEffect(()=>{V.current=h},[h]);const d0=i.useCallback(async t=>{var m;const r=++R.current;(m=F.current)==null||m.abort();const l=new AbortController;F.current=l;try{const c=await M0(t,void 0,{signal:l.signal},!0);if(!w(R.current,r,l.signal))return[];const g=c.sessions.map(d=>t===S.current&&d.chat_id===V.current?{...d,unread_count:0}:d);return y(d=>({...d,[t]:g})),a0(d=>({...d,[t]:c.next_cursor})),n0(d=>({...d,[t]:c.has_more})),g}catch(c){return w(R.current,r,l.signal)&&!K(c)&&j(c instanceof Error?c.message:"同步会话失败"),[]}},[]);i.useEffect(()=>{const t=new AbortController;return(async()=>{var l;L(!0);try{const[m,c]=await Promise.all([me({signal:t.signal}),z0({signal:t.signal})]),d=m.map(f=>{var q,H0;return{...f,runtime_state:((q=c[f.id])==null?void 0:q.state)||(f.enabled?"connecting":"disabled"),runtime_connected:((H0=c[f.id])==null?void 0:H0.connected)===!0}}).filter(f=>f.enabled),b=await Promise.all(d.map(async f=>[f.id,await M0(f.id,void 0,{signal:t.signal})]));if(t.signal.aborted)return;p(d),y(Object.fromEntries(b.map(([f,q])=>[f,q.sessions]))),a0(Object.fromEntries(b.map(([f,q])=>[f,q.next_cursor]))),n0(Object.fromEntries(b.map(([f,q])=>[f,q.has_more])));const C=window.localStorage.getItem("ydisks.chat.account.v1")||"",L0=d.some(f=>f.id===C)?C:((l=d[0])==null?void 0:l.id)||"";n(L0)}catch(m){t.signal.aborted||j(m instanceof Error?m.message:"加载聊天数据失败")}finally{t.signal.aborted||L(!1)}})(),(()=>t.abort())},[]),i.useEffect(()=>{let t=!1,r=0,l=null;const m=async()=>{l=new AbortController;try{const c=await z0({signal:l.signal,timeoutMs:1e4});t||p(g=>g.map(d=>{var b,C;return{...d,runtime_state:((b=c[d.id])==null?void 0:b.state)||d.runtime_state,runtime_connected:((C=c[d.id])==null?void 0:C.connected)??d.runtime_connected}}))}catch{}finally{t||(r=window.setTimeout(m,3e3))}};return r=window.setTimeout(m,3e3),(()=>{t=!0,window.clearTimeout(r),l==null||l.abort()})},[]),i.useEffect(()=>{if(!a)return;window.localStorage.setItem("ydisks.chat.account.v1",a);const t=u[a]||[];Y(r=>{var l;return t.some(m=>m.chat_id===r)?r:((l=t[0])==null?void 0:l.chat_id)||""})},[a,u]),i.useEffect(()=>{const t=Object.keys(u).length;if(B||o.length>0&&t===0)return;const r=Object.values(u).some(l=>l.some(m=>m.unread_count>0));le(r)},[o.length,B,u]),i.useEffect(()=>{!a||v.current.has(a)||(v.current.add(a),d0(a))},[a,d0]),i.useEffect(()=>{var l,m;if(!a||!h){P.current+=1,z.current+=1,(l=m0.current)==null||l.abort(),s.current=!1,k([]);return}const t=++P.current;(m=I0.current)==null||m.abort();const r=new AbortController;return I0.current=r,h0(!0),F0(a,h,void 0,void 0,{signal:r.signal}).then(c=>{if(!w(P.current,t,r.signal))return;const g=V0(c.messages,h);P0(a,h,g,{signal:r.signal}),k(c.messages),b0(c.has_more),t0(c.next_cursor),c.session&&y(d=>({...d,[a]:(d[a]||[]).map(b=>{var C;return b.chat_id===((C=c.session)==null?void 0:C.chat_id)?c.session:b})})),y(d=>({...d,[a]:(d[a]||[]).map(b=>b.chat_id===h?{...b,unread_count:0}:b)}))}).catch(c=>{w(P.current,t,r.signal)&&!K(c)&&j(c instanceof Error?c.message:"加载消息失败")}).finally(()=>{w(P.current,t,r.signal)&&h0(!1)}),(()=>r.abort())},[a,h]),i.useEffect(()=>{var t;(t=j0.current)==null||t.abort(),g0.current+=1},[a]),i.useEffect(()=>{var t;(t=G.current)==null||t.abort(),E.current+=1},[a,h]),i.useEffect(()=>{O(null)},[a,h]),i.useEffect(()=>{var t;z.current+=1,(t=m0.current)==null||t.abort(),s.current=!1},[a,h]),i.useEffect(()=>(()=>{var t,r,l,m,c;(t=F.current)==null||t.abort(),(r=I0.current)==null||r.abort(),z.current+=1,(l=m0.current)==null||l.abort(),(m=j0.current)==null||m.abort(),(c=G.current)==null||c.abort()}),[]),i.useEffect(()=>{const t=D;return(()=>{t&&URL.revokeObjectURL(t.url)})},[D]);const G0=i.useCallback(async()=>{var g,d;if(!a||!h||J||!e0)return;const t=H.current,r=(t==null?void 0:t.scrollHeight)||0,l=P.current,m=++z.current;(g=m0.current)==null||g.abort();const c=new AbortController;m0.current=c,s.current=!0,_0(!0),j("");try{const b=(d=I[0])==null?void 0:d.id,C=await F0(a,h,f0,b,{signal:c.signal});if(!w(P.current,l,c.signal)||m!==z.current)return;k(L0=>Oe(L0,C.messages)),b0(C.has_more),t0(C.next_cursor),requestAnimationFrame(()=>{m===z.current&&!c.signal.aborted&&t&&(t.scrollTop+=t.scrollHeight-r)})}catch(b){s.current=!1,K(b)||j(b instanceof Error?b.message:"加载历史消息失败")}finally{m===z.current&&_0(!1)}},[a,h,e0,f0,I,J]),A0=i.useCallback(t=>{const r=t.account_id;if(y(l=>{const m=l[r]||[];return m.some(g=>g.chat_id===t.chat_id)?{...l,[r]:m.map(g=>g.chat_id===t.chat_id?{...g,last_message:t.content,last_message_at:t.sent_at,unread_count:t.direction==="incoming"&&t.message_type!=="system"&&(S.current!==r||V.current!==t.chat_id)?g.unread_count+1:g.unread_count}:g).sort((g,d)=>d.last_message_at-g.last_message_at)}:(d0(r),l)}),S.current===r&&V.current===t.chat_id&&(k(l=>ve(T0(l,t),t)),t.direction==="incoming"&&t.message_type!=="system")){const l=V0([t],t.chat_id);P0(r,t.chat_id,l)}},[d0]);i.useEffect(()=>ce(r=>{if(r.type==="connection"){E0(r.state);return}A0(r.message)}),[A0]);const X0=i.useCallback(()=>{const t=H.current;if(!t)return;const r=t.scrollHeight-t.scrollTop-t.clientHeight;p0.current=r<=48},[]);i.useLayoutEffect(()=>{const t=Z.current.accountID!==a||Z.current.chatID!==h;Z.current={accountID:a,chatID:h},t&&(p0.current=!0);const r=H.current;if(r){if(s.current){s.current=!1;return}(M||p0.current)&&(r.scrollTop=r.scrollHeight)}},[a,h,I,M]);const K0=o.find(t=>t.id===a),w0=u[a]||[],_=w0.find(t=>t.chat_id===h),Y0=i.useMemo(()=>ye(w0,$,T),[w0,$,T]),$0=i.useCallback(t=>(u[t]||[]).reduce((r,l)=>r+l.unread_count,0),[u]),ee=i.useCallback(async()=>{var m;if(!a||r0||!i0[a])return;const t=++g0.current;(m=j0.current)==null||m.abort();const r=new AbortController;j0.current=r;const l=a;l0(!0),j("");try{const c=await M0(l,s0[l],{signal:r.signal},!0);if(!w(g0.current,t,r.signal))return;y(g=>({...g,[l]:c.sessions})),a0(g=>({...g,[l]:c.next_cursor})),n0(g=>({...g,[l]:c.has_more}))}catch(c){w(g0.current,t,r.signal)&&!K(c)&&j(c instanceof Error?c.message:"加载历史联系人失败")}finally{w(g0.current,t,r.signal)&&l0(!1)}},[a,s0,r0,i0]),N0=i.useCallback(async(t,r)=>{var c;if(!_||!a||N)return;const l=++E.current;(c=G.current)==null||c.abort();const m=new AbortController;G.current=m,U(!0),j("");try{const g=await oe({account_id:a,chat_id:_.chat_id,buyer_id:_.buyer_id,buyer_name:_.buyer_name,item_id:_.item_id,item_title:_.item_title,text:t},{signal:m.signal});if(!w(E.current,l,m.signal))return;u0(""),c0(null),k(d=>T0(d,g.message))}catch(g){w(E.current,l,m.signal)&&(r&&c0(t),K(g)||j(g instanceof Error?g.message:"消息发送失败"))}finally{w(E.current,l,m.signal)&&U(!1)}},[a,_,N]),C0=i.useCallback(async(t,r)=>{var c;if(!_||!a||N)return;const l=++E.current;(c=G.current)==null||c.abort();const m=new AbortController;G.current=m,U(!0),j("");try{const g=await pe({account_id:a,chat_id:_.chat_id,buyer_id:_.buyer_id,buyer_name:_.buyer_name,buyer_avatar_url:_.buyer_avatar_url,item_id:_.item_id,item_title:_.item_title,image:t},{signal:m.signal});if(!w(E.current,l,m.signal))return;o0(null),k(d=>T0(d,g.message))}catch(g){w(E.current,l,m.signal)&&(r&&o0(t),K(g)||j(g instanceof Error?g.message:"图片发送失败"))}finally{w(E.current,l,m.signal)&&(U(!1),x.current&&(x.current.value=""))}},[a,_,N]),te=i.useCallback(async()=>{const t=A.trim();!t||!_||!a||N||await N0(t,!0)},[a,A,_,N0,N]),D0=i.useCallback(async t=>{if(!(!t||!_||!a||N)){if(!t.type.startsWith("image/")){j("仅支持粘贴/发送图片文件");return}j(""),O({file:t,url:URL.createObjectURL(t)})}},[a,_,N]),se=i.useCallback(async t=>{const r=t.find(l=>l.type.startsWith("image/"));r&&await D0(r)},[D0]),ae=i.useCallback(()=>{O(null),x.current&&(x.current.value="")},[]),ie=i.useCallback(async()=>{if(!D||!_||!a||N)return;const t=D.file;O(null),await C0(t,!0)},[a,D,_,C0,N]),ne=i.useCallback(async()=>{Q?await N0(Q,!1):W&&await C0(W,!1)},[W,Q,C0,N0]);return{accounts:o,activeAccountID:a,activeSessions:w0,selectedSession:_,activeAccount:K0,messages:I,search:$,unreadOnly:T,draft:A,loading:B,messagesLoading:M,olderLoading:J,hasOlder:e0,contactsLoading:r0,hasMoreContacts:i0[a]===!0,emojiOpen:v0,sending:N,error:S0,liveState:R0,pendingImage:D,activeChatID:h,filteredSessions:Y0,scrollRef:H,imageInputRef:x,setActiveAccountID:n,setActiveChatID:Y,setSearch:y0,setUnreadOnly:O0,setDraft:u0,setEmojiOpen:k0,reloadSessions:d0,loadMoreContacts:ee,loadOlderMessages:G0,handleMessageScroll:X0,handleSend:te,handleImage:D0,handlePastedImages:se,confirmSendImage:ie,closeImagePreview:ae,retrySend:ne,retryAvailable:!!(Q||W),unreadForAccount:$0,emojiURL:we,xianyuEmojis:Z0,renderXianyuText:Ce,formatClock:ke,messageTime:Se}},Me=()=>{const{accounts:o,activeAccountID:p,activeChatID:a,activeAccount:n,selectedSession:u,filteredSessions:y,messages:h,search:Y,unreadOnly:I,draft:k,loading:$,messagesLoading:y0,olderLoading:T,hasOlder:O0,contactsLoading:A,hasMoreContacts:u0,emojiOpen:D,sending:O,error:B,liveState:L,pendingImage:M,scrollRef:h0,imageInputRef:J,setActiveAccountID:_0,setActiveChatID:e0,setSearch:b0,setUnreadOnly:f0,setDraft:t0,setEmojiOpen:s0,reloadSessions:a0,loadMoreContacts:i0,loadOlderMessages:n0,handleMessageScroll:r0,handleSend:l0,handleImage:v0,handlePastedImages:k0,confirmSendImage:N,closeImagePreview:U,retrySend:S0,retryAvailable:j,unreadForAccount:R0,emojiURL:E0,xianyuEmojis:Q,renderXianyuText:c0,formatClock:W,messageTime:o0}=Re(),S=x0.useMemo(()=>h.filter(s=>s.message_type==="image"),[h]),V=x0.useMemo(()=>S.map(s=>({src:s.content,alt:"聊天图片"})),[S]),[H,Z]=x0.useState(-1),p0=x0.useCallback(s=>{Z(S.findIndex(x=>x.message_key===s))},[S]);return $?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(X,{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 ${L==="online"?"bg-emerald-50 text-emerald-700":L==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[L==="online"?e.jsx(ge,{className:"h-3.5 w-3.5"}):e.jsx(de,{className:"h-3.5 w-3.5"}),L==="online"?"实时同步中":L==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:o.map(s=>{const x=s.id===p,v=R0(s.id),R=q0(v),F=s.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":x,onClick:(()=>_0(s.id)),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${x?"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 ${F?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:s.nickname||s.remark||s.id}),v>0&&e.jsx("span",{"aria-label":`未读消息 ${R} 条`,className:W0(v),children:R})]},s.id)})})]}),o.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(B0,{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(xe,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:Y,onChange:(s=>b0(s.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:(()=>f0(s=>!s)),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${I?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:I?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:(()=>void a0(p)),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:[y.map(s=>e.jsxs("button",{type:"button",onClick:(()=>e0(s.chat_id)),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${s.chat_id===a?"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:s.buyer_avatar_url?e.jsx("img",{src:s.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(U0,{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:s.buyer_name||`用户 ${s.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:W(s.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:s.last_message||"暂无消息"}),s.unread_count>0&&e.jsx("span",{"aria-label":`未读消息 ${q0(s.unread_count)} 条`,className:`ml-auto ${W0(s.unread_count)}`,children:q0(s.unread_count)})]}),s.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",s.item_title]})]})]},s.chat_id)),y.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),u0&&!Y&&!I&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:(()=>void i0()),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(X,{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:u?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:u.buyer_name||u.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",u.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(n==null?void 0:n.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(n==null?void 0:n.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:h0,onScroll:r0,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:y0?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(X,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[O0&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:(()=>void n0()),disabled:T,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:[T&&e.jsx(X,{className:"h-3.5 w-3.5 animate-spin"}),T?"正在加载":"加载更早消息"]})}),h.map(s=>{const x=s.direction==="outgoing";return s.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:[c0(s.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:o0(s.sent_at)})]})},s.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${x?"justify-end":"justify-start"}`,children:[!x&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:u.buyer_avatar_url?e.jsx("img",{src:u.buyer_avatar_url,alt:u.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(U0,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${x?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:x?(n==null?void 0:n.nickname)||(n==null?void 0:n.remark)||"我":u.buyer_name||s.sender_name||u.buyer_id}),s.message_type==="image"?e.jsx("button",{type:"button",title:"点击预览大图",onClick:p0.bind(null,s.message_key),className:`block cursor-zoom-in overflow-hidden rounded-2xl border bg-white p-1 text-left shadow-sm ${x?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:s.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):s.message_type==="video"?e.jsx("video",{src:s.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 ${x?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:c0(s.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[o0(s.sent_at),x&&(s.status==="failed"?e.jsx(he,{className:"h-3 w-3 text-red-500","aria-label":"发送失败"}):s.read_status===2?e.jsx(_e,{className:"h-3 w-3 text-sky-500","aria-label":"对方已读"}):s.status==="sent"?e.jsx(J0,{className:"h-3 w-3 text-sky-500","aria-label":"已发送未读"}):e.jsx(J0,{className:"h-3 w-3","aria-label":"发送中"}))]})]}),x&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:n!=null&&n.avatar_url?e.jsx("img",{src:n.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(U0,{className:"m-2 h-5 w-5 text-sky-600"})})]},s.message_key)})]})}),B&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:[e.jsx("span",{children:B}),j&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>void S0()),children:"重试发送"})]}),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:(()=>s0(s=>!s)),disabled:O||(n==null?void 0:n.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(be,{className:"h-5 w-5"})}),D&&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:Q.map(([s,x])=>e.jsx("button",{type:"button",title:`[${s}]`,onClick:(()=>{t0(v=>v+`[${s}]`),s0(!1)}),className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:E0(x),alt:`[${s}]`,className:"h-8 w-8 object-contain"})},s))})]})]}),e.jsx("input",{ref:J,type:"file",accept:"image/*",className:"hidden",onChange:(s=>{var x;return void v0((x=s.target.files)==null?void 0:x[0])})}),e.jsx("button",{type:"button",onClick:(()=>{var s;return(s=J.current)==null?void 0:s.click()}),disabled:O||(n==null?void 0:n.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(fe,{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:k,onChange:(s=>t0(s.target.value)),rows:2,maxLength:2e3,onKeyDown:(s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),l0())}),onPaste:(s=>{var R;const x=Array.from(((R=s.clipboardData)==null?void 0:R.files)||[]);x.find(F=>F.type.startsWith("image/"))&&(s.preventDefault(),k0(x))}),disabled:(n==null?void 0:n.runtime_state)!=="online",placeholder:(n==null?void 0:n.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行,Ctrl + V 粘贴图片":"账号离线,暂时无法发送",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 l0()),disabled:!k.trim()||O||(n==null?void 0:n.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:O?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsx(Q0,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(B0,{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:"该账号的新消息会实时出现在左侧列表。"})]})})]}),M&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-950/60 p-4",onClick:U,children:e.jsxs("div",{className:"flex max-h-full w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl",onClick:(s=>s.stopPropagation()),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-slate-200 px-5 py-3",children:[e.jsx("div",{className:"text-sm font-black text-slate-900",children:"发送图片预览"}),e.jsx("button",{type:"button",title:"取消",onClick:U,className:"rounded-lg p-1.5 text-slate-400 transition hover:bg-slate-100 hover:text-slate-700",children:e.jsx(je,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-slate-100 p-4",children:e.jsx("img",{src:M.url,alt:"待发送图片预览",className:"max-h-[55vh] max-w-full rounded-xl object-contain"})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3",children:[e.jsxs("div",{className:"min-w-0 truncate text-xs text-slate-500",children:[M.file.name||"粘贴的图片"," · ",(M.file.size/1024).toFixed(0)," KB"]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:U,className:"rounded-xl px-4 py-2 text-sm font-bold text-slate-600 transition hover:bg-slate-100",children:"取消"}),e.jsxs("button",{type:"button",onClick:(()=>void N()),disabled:O||(n==null?void 0:n.runtime_state)!=="online",className:"flex items-center gap-2 rounded-xl bg-sky-500 px-4 py-2 text-sm font-bold text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:opacity-50",children:[O?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsx(Q0,{className:"h-4 w-4"}),"发送"]})]})]})]})}),e.jsx(re,{open:H>=0,index:Math.max(H,0),close:(()=>Z(-1)),slides:V})]})};export{Me as default}; diff --git a/internal/webui/static/assets/Dashboard-C9RwPfK-.js b/internal/webui/static/assets/Dashboard-Ba2fUvQH.js similarity index 98% rename from internal/webui/static/assets/Dashboard-C9RwPfK-.js rename to internal/webui/static/assets/Dashboard-Ba2fUvQH.js index d023624..73bd640 100644 --- a/internal/webui/static/assets/Dashboard-C9RwPfK-.js +++ b/internal/webui/static/assets/Dashboard-Ba2fUvQH.js @@ -1 +1 @@ -import{j as e,r as c}from"./react-vendor-C_od1ZSF.js";import{f as me}from"./dateTime-DDi7rqpW.js";import{j as de,k as ge,l as te,D as he,c as pe,P as be,m as se,E as fe,T as ye}from"./icons-vendor-DwxdQTKt.js";import{R as E,B as je,X as ae,Y as re,T as F,a as ve,C as U,A as Ne,b as we,c as _e,P as ne,d as le,L as ke}from"./charts-vendor-deWqkrdG.js";import{g as q,c as xe,o as De}from"./index-zEvleK2K.js";import"./vendor-Es4K8PXl.js";const M=t=>{const a=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${a}-${s}-${l}`},H=(t,a)=>{const s=new Date(t);return s.setHours(12,0,0,0),s.setDate(s.getDate()+a),s},X=(t,a)=>({startDate:M(H(t,-(a-1))),endDate:M(t)}),ue=(t,a=new Date,s="",l="")=>{if(t==="custom"&&s&&l){if(s>l)throw new Error("开始日期不能晚于结束日期");return{startDate:s,endDate:l}}return t==="yesterday"?X(H(a,-1),1):X(a,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Se=t=>{const a=new Date(`${t.startDate}T12:00:00`),s=new Date(`${t.endDate}T12:00:00`),l=Math.round((s.getTime()-a.getTime())/864e5)+1,n=H(a,-1);return X(n,l)},i=(t,a)=>a===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${a})`,Ce=({chartData:t,selectedRangeLabel:a,totalAmount:s})=>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:[a,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:t.length===0||s===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(de,{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:"所选时间范围内暂无订单记录"})]}):t.length<=2?e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(je,{data:t,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(ae,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(re,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:(l=>`¥${l}`)}),e.jsx(F,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{fill:i("brand",.08)},formatter:(l=>[`¥${Number(l).toFixed(2)}`,"营收"])}),e.jsx(ve,{dataKey:"amount",fill:i("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:t.map((l,n)=>e.jsx(U,{fill:i("brand"),stroke:"none",strokeWidth:0},`cell-${n}`))})]})}):e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(Ne,{data:t,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:i("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:i("brand"),stopOpacity:0})]})}),e.jsx(ae,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(re,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(we,{vertical:!1,stroke:i("neutral-100"),strokeDasharray:"3 3"}),e.jsx(F,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{stroke:i("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(_e,{type:"monotone",dataKey:"amount",stroke:i("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:i("white"),stroke:i("brand"),strokeWidth:2}})]})})})]}),oe=t=>{const a=String(t||"");return a==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(a)?a:"unknown"},$e=async t=>q("/api/v1/analytics/dashboard",void 0,t),Re=async(t,a)=>{const s=await q("/api/v1/items",void 0,a);return xe(s,["items","data","results"]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:n.is_multi_spec===!0||n.is_multi_spec===1,multi_quantity_delivery:n.multi_quantity_delivery===!0||n.multi_quantity_delivery===1}))},ie=async(t=7,a)=>{let s;if(typeof t=="number"){const l=new Date,n=new Date;n.setDate(n.getDate()-t),s={start_date:M(n),end_date:M(l)}}else s=t;return q("/api/v1/analytics/orders",{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()},a)},Le=async(t,a)=>{const s=await q("/api/v1/analytics/orders/valid",{...t,timezone_offset_minutes:-new Date().getTimezoneOffset()},a),l=De(s,["data","result"])||{},o=xe(s,["orders","data","items"]).map(b=>({...b,id:b.order_id,status:oe(b.status||b.order_status),order_status:oe(b.order_status),quantity:Number(b.quantity||1)}));return{orders:o,total:Number(l.total??o.length),truncated:l.truncated===!0}},Oe=t=>{const a={};return t.forEach(s=>{a[s.item_id]=s.item_title||s.item_id}),a},Te=t=>{var a;return((a=t.daily_stats)==null?void 0:a.map(s=>({name:s.date.slice(5),amount:s.amount,orders:s.order_count,avgAmount:s.order_count>0?(s.amount/s.order_count).toFixed(2):0})))||[]},Ae=(t,a)=>(t.item_stats||[]).map(s=>{const l=a[s.item_id]||s.item_id;return{name:l.length>12?`${l.substring(0,12)}...`:l,sales:s.order_count}}).sort((s,l)=>l.sales-s.sales).slice(0,10),ze=(t,a,s)=>{const l=t.revenue_stats.total_orders||0;return(t.item_stats||[]).map(n=>{const o=a[n.item_id]||n.item_id;return{name:o.length>10?`${o.substring(0,10)}...`:o,value:n.order_count,percent:l>0?n.order_count/l*100:0}}).sort((n,o)=>o.value-n.value).slice(0,6).map((n,o)=>({...n,color:s[o%s.length]}))},Pe=(t,a,s)=>{const l=t.revenue_stats.total_amount||0;return(t.item_stats||[]).map(n=>{const o=a[n.item_id]||n.item_id;return{name:o.length>12?`${o.substring(0,12)}...`:o,value:n.total_amount,orderCount:n.order_count,percentage:l>0?n.total_amount/l*100:0}}).sort((n,o)=>o.value-n.value).slice(0,5).map((n,o)=>({...n,color:s[o%s.length],percentage:n.percentage.toFixed(1)}))},We=(t,a)=>{if(!t||!a)return null;const s=t.revenue_stats.total_amount,l=a.revenue_stats.total_amount;if(l===0)return s>0?"+100%":"0%";const n=(s-l)/l*100;return`${n>=0?"+":""}${n.toFixed(1)}%`},Ee=t=>({today:"今天",yesterday:"昨天","3days":"三天内","7days":"7天内","30days":"一个月内",custom:"自定义"})[t.range]||"所选范围",Fe=t=>Math.max(...t.map(a=>a.sales),1),P=(t,a,s)=>t===a&&!s.aborted,ce=t=>t instanceof Error&&t.message==="请求已取消",G=(t,a)=>t instanceof Error?t.message:a,Me=t=>{const{range:a,customStartDate:s,customEndDate:l,customRangeVersion:n}=t,[o,b]=c.useState(null),[_,I]=c.useState(null),[K,v]=c.useState({overview:"idle",range:"idle",error:""}),[d,A]=c.useState(0),R=c.useRef(0),S=c.useRef(0),L=c.useMemo(()=>({range:a,customStartDate:s,customEndDate:l}),[l,s,a]),D=c.useCallback(()=>A(u=>u+1),[]);c.useEffect(()=>{const u=++S.current,h=new AbortController;return v(m=>({...m,overview:"loading",error:""})),Promise.all([$e({signal:h.signal}),Re(void 0,{signal:h.signal})]).then(([m,g])=>{P(S.current,u,h.signal)&&(b({stats:m,items:g,itemNames:Oe(g)}),v(p=>({...p,overview:"success"})))}).catch(m=>{!P(S.current,u,h.signal)||ce(m)||v(g=>({...g,overview:"error",error:G(m,"概览加载失败")}))}),(()=>h.abort())},[d]),c.useEffect(()=>{let u;try{u=ue(a,new Date,s,l)}catch(p){v(w=>({...w,range:"error",error:G(p,"日期范围无效")}));return}const h=Se(u),m=++R.current,g=new AbortController;return v(p=>({...p,range:"loading",error:""})),Promise.all([ie({start_date:u.startDate,end_date:u.endDate},{signal:g.signal}),ie({start_date:h.startDate,end_date:h.endDate},{signal:g.signal}),Le({start_date:u.startDate,end_date:u.endDate},{signal:g.signal})]).then(([p,w,Y])=>{P(R.current,m,g.signal)&&(I({analytics:p,previousAnalytics:w,validOrders:Y,dateRange:u}),v($=>({...$,range:"success"})))}).catch(p=>{!P(R.current,m,g.signal)||ce(p)||v(w=>({...w,range:"error",error:G(p,"经营数据加载失败")}))}),(()=>g.abort())},[n,a,d]);const C=c.useMemo(()=>o&&_?{...o,..._}:null,[o,_]),k=(o==null?void 0:o.itemNames)||{},x=(_==null?void 0:_.analytics)||null,z=c.useMemo(()=>x?Te(x):[],[x]),N=c.useMemo(()=>x?Ae(x,k):[],[x,k]),f=c.useMemo(()=>["rgb(var(--color-brand))","rgb(var(--color-brand-highlight))","rgb(var(--color-success-500))","rgb(var(--color-warning-500))","rgb(var(--color-accent-500))"],[]),O=c.useMemo(()=>x?ze(x,k,f):[],[x,f,k]),B=c.useMemo(()=>x?Pe(x,k,f):[],[x,f,k]),V=c.useMemo(()=>Fe(N),[N]);return{data:C,status:K,chartData:z,productSalesData:N,sourceData:O,categoryData:B,maxProductSales:V,trendPercent:We(x,(C==null?void 0:C.previousAnalytics)||null),selectedRangeLabel:Ee(L),refresh:D}},j=(t,a)=>`rgb(var(--color-${t}))`,qe=({status:t})=>{const a={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"},s={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 ${a[t]||a.cancelled}`,children:s[t]||t})},W=({title:t,value:a,icon:s,colorClass:l,trend:n})=>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 ${l} 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 ${l} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(s,{className:`w-6 h-6 ${l.replace("bg-","text-")}`})}),n&&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(ye,{className:"w-3 h-3"})," ",n]})]}),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:a}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),Ue=()=>{const[t,a]=c.useState("7days"),[s,l]=c.useState(""),[n,o]=c.useState(""),[b,_]=c.useState(""),[I,K]=c.useState(0),v=Me({range:t,customStartDate:s,customEndDate:n,customRangeVersion:I}),{data:d,status:A,chartData:R,productSalesData:S,sourceData:L,categoryData:D,maxProductSales:C,trendPercent:k,selectedRangeLabel:x,refresh:z}=v,N=(d==null?void 0:d.stats)||null,f=(d==null?void 0:d.analytics)||null,O=(d==null?void 0:d.validOrders.orders)||[],B=(d==null?void 0:d.validOrders.total)||0,V=(d==null?void 0:d.validOrders.truncated)||!1,u=A.range==="loading",h=A.error,m=[j("brand"),j("brand-highlight"),j("success-500"),j("warning-500"),j("accent-500")],g=r=>`¥${Number(r||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`;if(h&&(!N||!f))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(ge,{className:"w-8 h-8"}),e.jsx("span",{children:h}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:z,children:"重新加载"})]});if(!N||!f)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(te,{className:"w-8 h-8 animate-spin text-brand"})});const p=f.revenue_stats.total_orders||0,w=f.revenue_stats.total_amount||0,Y=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}];let $;try{$=ue(t,new Date,s,n)}catch{$={startDate:s,endDate:n}}const T=b.trim().toLowerCase(),J=O.filter(r=>{var y,Q,Z,ee;return((y=r.order_id)==null?void 0:y.toLowerCase().includes(T))||((Q=r.item_id)==null?void 0:Q.toLowerCase().includes(T))||((Z=r.item_title)==null?void 0:Z.toLowerCase().includes(T))||((ee=r.buyer_id)==null?void 0:ee.toLowerCase().includes(T))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[h&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:z,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:[Y.map(r=>e.jsx("button",{onClick:(()=>a(r.key)),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${t===r.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:r.label},r.key)),t==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:s,onChange:(r=>l(r.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:n,onChange:(r=>o(r.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:(()=>K(r=>r+1)),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(W,{title:"累计营收 (CNY)",value:`¥${f.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:he,colorClass:"bg-blue-400",trend:k||void 0}),e.jsx(W,{title:"活跃账号 / 总数",value:`${N.active_cookies} / ${N.total_cookies}`,icon:pe,colorClass:"bg-blue-500"}),e.jsx(W,{title:"订单数",value:f.revenue_stats.total_orders.toLocaleString(),icon:de,colorClass:"bg-blue-500"}),e.jsx(W,{title:"库存卡密余量",value:N.available_card_stock,icon:be,colorClass:"bg-purple-500"})]}),e.jsx(Ce,{chartData:R,selectedRangeLabel:x,totalAmount:w}),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:S.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:S.map((r,y)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${y<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:y+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:r.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[r.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,r.sales/C*100)}%`}})})]},`${r.name}-${y}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${p} 单`,children:L.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(ne,{accessibilityLayer:!1,children:[e.jsx(le,{data:L,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:L.map((r,y)=>e.jsx(U,{fill:r.color},`cell-${y}`))}),e.jsx(F,{formatter:(r=>`${Number(r||0)} 单`),wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:j("white"),border:`1px solid ${j("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(ke,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:(r=>e.jsx("span",{style:{color:j("neutral-500"),fontWeight:500},children:r}))})]})}),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:p}),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:"参与统计的订单"}),V&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",O.length," / ",B," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:b,onChange:(r=>_(r.target.value)),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:u?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(te,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):J.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(se,{className:"w-7 h-7 text-gray-300"})}),T?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:["当前共有 ",O.length," 单参与统计,但没有订单号、商品、买家匹配“",b,"”。"]})]}):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:["日期范围:",$.startDate," 至 ",$.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",f.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:J.map(r=>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(se,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:r.item_title||r.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:r.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",r.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:r.buyer_id}),r.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:me(r.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",r.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(qe,{status:r.status||r.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${r.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(fe,{className:"w-4 h-4"})})})]},r.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),D.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":`商品金额分析,总金额 ${g(w)}`,children:[e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(ne,{accessibilityLayer:!1,children:[e.jsx(le,{data:D,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:D.map((r,y)=>e.jsx(U,{fill:r.color||m[y%m.length]},`cell-${y}`))}),e.jsx(F,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:j("white"),border:`1px solid ${j("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:(r=>`¥${Number(r||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:g(w)}),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:D.map(r=>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:r.color||m[D.indexOf(r)%m.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:r.name,children:r.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:["¥",r.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[r.percentage,"%"]})]})]},r.name))})]})]})]})]})};export{qe as StatusBadge,Ue as default}; +import{j as e,a as c}from"./react-vendor-l-BBvuKH.js";import{f as me}from"./dateTime-DDi7rqpW.js";import{j as de,k as ge,l as te,D as he,c as pe,P as be,m as se,E as fe,T as ye}from"./icons-vendor-Bgrth_9N.js";import{R as E,B as je,X as ae,Y as re,T as F,a as ve,C as U,A as Ne,b as we,c as _e,P as ne,d as le,L as ke}from"./charts-vendor-DlHaeEQJ.js";import{g as q,c as xe,o as De}from"./index-WrujSo30.js";import"./vendor-cRYyTeIw.js";const M=t=>{const a=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${a}-${s}-${l}`},H=(t,a)=>{const s=new Date(t);return s.setHours(12,0,0,0),s.setDate(s.getDate()+a),s},X=(t,a)=>({startDate:M(H(t,-(a-1))),endDate:M(t)}),ue=(t,a=new Date,s="",l="")=>{if(t==="custom"&&s&&l){if(s>l)throw new Error("开始日期不能晚于结束日期");return{startDate:s,endDate:l}}return t==="yesterday"?X(H(a,-1),1):X(a,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Se=t=>{const a=new Date(`${t.startDate}T12:00:00`),s=new Date(`${t.endDate}T12:00:00`),l=Math.round((s.getTime()-a.getTime())/864e5)+1,n=H(a,-1);return X(n,l)},i=(t,a)=>a===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${a})`,Ce=({chartData:t,selectedRangeLabel:a,totalAmount:s})=>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:[a,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:t.length===0||s===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(de,{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:"所选时间范围内暂无订单记录"})]}):t.length<=2?e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(je,{data:t,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(ae,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(re,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:(l=>`¥${l}`)}),e.jsx(F,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{fill:i("brand",.08)},formatter:(l=>[`¥${Number(l).toFixed(2)}`,"营收"])}),e.jsx(ve,{dataKey:"amount",fill:i("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:t.map((l,n)=>e.jsx(U,{fill:i("brand"),stroke:"none",strokeWidth:0},`cell-${n}`))})]})}):e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(Ne,{data:t,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:i("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:i("brand"),stopOpacity:0})]})}),e.jsx(ae,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(re,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(we,{vertical:!1,stroke:i("neutral-100"),strokeDasharray:"3 3"}),e.jsx(F,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{stroke:i("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(_e,{type:"monotone",dataKey:"amount",stroke:i("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:i("white"),stroke:i("brand"),strokeWidth:2}})]})})})]}),oe=t=>{const a=String(t||"");return a==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(a)?a:"unknown"},$e=async t=>q("/api/v1/analytics/dashboard",void 0,t),Re=async(t,a)=>{const s=await q("/api/v1/items",void 0,a);return xe(s,["items","data","results"]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:n.is_multi_spec===!0||n.is_multi_spec===1,multi_quantity_delivery:n.multi_quantity_delivery===!0||n.multi_quantity_delivery===1}))},ie=async(t=7,a)=>{let s;if(typeof t=="number"){const l=new Date,n=new Date;n.setDate(n.getDate()-t),s={start_date:M(n),end_date:M(l)}}else s=t;return q("/api/v1/analytics/orders",{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()},a)},Le=async(t,a)=>{const s=await q("/api/v1/analytics/orders/valid",{...t,timezone_offset_minutes:-new Date().getTimezoneOffset()},a),l=De(s,["data","result"])||{},o=xe(s,["orders","data","items"]).map(b=>({...b,id:b.order_id,status:oe(b.status||b.order_status),order_status:oe(b.order_status),quantity:Number(b.quantity||1)}));return{orders:o,total:Number(l.total??o.length),truncated:l.truncated===!0}},Oe=t=>{const a={};return t.forEach(s=>{a[s.item_id]=s.item_title||s.item_id}),a},Te=t=>{var a;return((a=t.daily_stats)==null?void 0:a.map(s=>({name:s.date.slice(5),amount:s.amount,orders:s.order_count,avgAmount:s.order_count>0?(s.amount/s.order_count).toFixed(2):0})))||[]},Ae=(t,a)=>(t.item_stats||[]).map(s=>{const l=a[s.item_id]||s.item_id;return{name:l.length>12?`${l.substring(0,12)}...`:l,sales:s.order_count}}).sort((s,l)=>l.sales-s.sales).slice(0,10),ze=(t,a,s)=>{const l=t.revenue_stats.total_orders||0;return(t.item_stats||[]).map(n=>{const o=a[n.item_id]||n.item_id;return{name:o.length>10?`${o.substring(0,10)}...`:o,value:n.order_count,percent:l>0?n.order_count/l*100:0}}).sort((n,o)=>o.value-n.value).slice(0,6).map((n,o)=>({...n,color:s[o%s.length]}))},Pe=(t,a,s)=>{const l=t.revenue_stats.total_amount||0;return(t.item_stats||[]).map(n=>{const o=a[n.item_id]||n.item_id;return{name:o.length>12?`${o.substring(0,12)}...`:o,value:n.total_amount,orderCount:n.order_count,percentage:l>0?n.total_amount/l*100:0}}).sort((n,o)=>o.value-n.value).slice(0,5).map((n,o)=>({...n,color:s[o%s.length],percentage:n.percentage.toFixed(1)}))},We=(t,a)=>{if(!t||!a)return null;const s=t.revenue_stats.total_amount,l=a.revenue_stats.total_amount;if(l===0)return s>0?"+100%":"0%";const n=(s-l)/l*100;return`${n>=0?"+":""}${n.toFixed(1)}%`},Ee=t=>({today:"今天",yesterday:"昨天","3days":"三天内","7days":"7天内","30days":"一个月内",custom:"自定义"})[t.range]||"所选范围",Fe=t=>Math.max(...t.map(a=>a.sales),1),P=(t,a,s)=>t===a&&!s.aborted,ce=t=>t instanceof Error&&t.message==="请求已取消",G=(t,a)=>t instanceof Error?t.message:a,Me=t=>{const{range:a,customStartDate:s,customEndDate:l,customRangeVersion:n}=t,[o,b]=c.useState(null),[_,I]=c.useState(null),[K,v]=c.useState({overview:"idle",range:"idle",error:""}),[d,A]=c.useState(0),R=c.useRef(0),S=c.useRef(0),L=c.useMemo(()=>({range:a,customStartDate:s,customEndDate:l}),[l,s,a]),D=c.useCallback(()=>A(u=>u+1),[]);c.useEffect(()=>{const u=++S.current,h=new AbortController;return v(m=>({...m,overview:"loading",error:""})),Promise.all([$e({signal:h.signal}),Re(void 0,{signal:h.signal})]).then(([m,g])=>{P(S.current,u,h.signal)&&(b({stats:m,items:g,itemNames:Oe(g)}),v(p=>({...p,overview:"success"})))}).catch(m=>{!P(S.current,u,h.signal)||ce(m)||v(g=>({...g,overview:"error",error:G(m,"概览加载失败")}))}),(()=>h.abort())},[d]),c.useEffect(()=>{let u;try{u=ue(a,new Date,s,l)}catch(p){v(w=>({...w,range:"error",error:G(p,"日期范围无效")}));return}const h=Se(u),m=++R.current,g=new AbortController;return v(p=>({...p,range:"loading",error:""})),Promise.all([ie({start_date:u.startDate,end_date:u.endDate},{signal:g.signal}),ie({start_date:h.startDate,end_date:h.endDate},{signal:g.signal}),Le({start_date:u.startDate,end_date:u.endDate},{signal:g.signal})]).then(([p,w,Y])=>{P(R.current,m,g.signal)&&(I({analytics:p,previousAnalytics:w,validOrders:Y,dateRange:u}),v($=>({...$,range:"success"})))}).catch(p=>{!P(R.current,m,g.signal)||ce(p)||v(w=>({...w,range:"error",error:G(p,"经营数据加载失败")}))}),(()=>g.abort())},[n,a,d]);const C=c.useMemo(()=>o&&_?{...o,..._}:null,[o,_]),k=(o==null?void 0:o.itemNames)||{},x=(_==null?void 0:_.analytics)||null,z=c.useMemo(()=>x?Te(x):[],[x]),N=c.useMemo(()=>x?Ae(x,k):[],[x,k]),f=c.useMemo(()=>["rgb(var(--color-brand))","rgb(var(--color-brand-highlight))","rgb(var(--color-success-500))","rgb(var(--color-warning-500))","rgb(var(--color-accent-500))"],[]),O=c.useMemo(()=>x?ze(x,k,f):[],[x,f,k]),B=c.useMemo(()=>x?Pe(x,k,f):[],[x,f,k]),V=c.useMemo(()=>Fe(N),[N]);return{data:C,status:K,chartData:z,productSalesData:N,sourceData:O,categoryData:B,maxProductSales:V,trendPercent:We(x,(C==null?void 0:C.previousAnalytics)||null),selectedRangeLabel:Ee(L),refresh:D}},j=(t,a)=>`rgb(var(--color-${t}))`,qe=({status:t})=>{const a={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"},s={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 ${a[t]||a.cancelled}`,children:s[t]||t})},W=({title:t,value:a,icon:s,colorClass:l,trend:n})=>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 ${l} 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 ${l} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(s,{className:`w-6 h-6 ${l.replace("bg-","text-")}`})}),n&&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(ye,{className:"w-3 h-3"})," ",n]})]}),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:a}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),Ue=()=>{const[t,a]=c.useState("7days"),[s,l]=c.useState(""),[n,o]=c.useState(""),[b,_]=c.useState(""),[I,K]=c.useState(0),v=Me({range:t,customStartDate:s,customEndDate:n,customRangeVersion:I}),{data:d,status:A,chartData:R,productSalesData:S,sourceData:L,categoryData:D,maxProductSales:C,trendPercent:k,selectedRangeLabel:x,refresh:z}=v,N=(d==null?void 0:d.stats)||null,f=(d==null?void 0:d.analytics)||null,O=(d==null?void 0:d.validOrders.orders)||[],B=(d==null?void 0:d.validOrders.total)||0,V=(d==null?void 0:d.validOrders.truncated)||!1,u=A.range==="loading",h=A.error,m=[j("brand"),j("brand-highlight"),j("success-500"),j("warning-500"),j("accent-500")],g=r=>`¥${Number(r||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`;if(h&&(!N||!f))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(ge,{className:"w-8 h-8"}),e.jsx("span",{children:h}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:z,children:"重新加载"})]});if(!N||!f)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(te,{className:"w-8 h-8 animate-spin text-brand"})});const p=f.revenue_stats.total_orders||0,w=f.revenue_stats.total_amount||0,Y=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}];let $;try{$=ue(t,new Date,s,n)}catch{$={startDate:s,endDate:n}}const T=b.trim().toLowerCase(),J=O.filter(r=>{var y,Q,Z,ee;return((y=r.order_id)==null?void 0:y.toLowerCase().includes(T))||((Q=r.item_id)==null?void 0:Q.toLowerCase().includes(T))||((Z=r.item_title)==null?void 0:Z.toLowerCase().includes(T))||((ee=r.buyer_id)==null?void 0:ee.toLowerCase().includes(T))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[h&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:z,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:[Y.map(r=>e.jsx("button",{onClick:(()=>a(r.key)),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${t===r.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:r.label},r.key)),t==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:s,onChange:(r=>l(r.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:n,onChange:(r=>o(r.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:(()=>K(r=>r+1)),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(W,{title:"累计营收 (CNY)",value:`¥${f.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:he,colorClass:"bg-blue-400",trend:k||void 0}),e.jsx(W,{title:"活跃账号 / 总数",value:`${N.active_cookies} / ${N.total_cookies}`,icon:pe,colorClass:"bg-blue-500"}),e.jsx(W,{title:"订单数",value:f.revenue_stats.total_orders.toLocaleString(),icon:de,colorClass:"bg-blue-500"}),e.jsx(W,{title:"库存卡密余量",value:N.available_card_stock,icon:be,colorClass:"bg-purple-500"})]}),e.jsx(Ce,{chartData:R,selectedRangeLabel:x,totalAmount:w}),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:S.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:S.map((r,y)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${y<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:y+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:r.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[r.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,r.sales/C*100)}%`}})})]},`${r.name}-${y}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${p} 单`,children:L.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(ne,{accessibilityLayer:!1,children:[e.jsx(le,{data:L,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:L.map((r,y)=>e.jsx(U,{fill:r.color},`cell-${y}`))}),e.jsx(F,{formatter:(r=>`${Number(r||0)} 单`),wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:j("white"),border:`1px solid ${j("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(ke,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:(r=>e.jsx("span",{style:{color:j("neutral-500"),fontWeight:500},children:r}))})]})}),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:p}),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:"参与统计的订单"}),V&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",O.length," / ",B," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:b,onChange:(r=>_(r.target.value)),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:u?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(te,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):J.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(se,{className:"w-7 h-7 text-gray-300"})}),T?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:["当前共有 ",O.length," 单参与统计,但没有订单号、商品、买家匹配“",b,"”。"]})]}):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:["日期范围:",$.startDate," 至 ",$.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",f.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:J.map(r=>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(se,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:r.item_title||r.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:r.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",r.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:r.buyer_id}),r.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:me(r.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",r.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(qe,{status:r.status||r.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${r.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(fe,{className:"w-4 h-4"})})})]},r.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),D.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":`商品金额分析,总金额 ${g(w)}`,children:[e.jsx(E,{width:"100%",height:"100%",children:e.jsxs(ne,{accessibilityLayer:!1,children:[e.jsx(le,{data:D,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:D.map((r,y)=>e.jsx(U,{fill:r.color||m[y%m.length]},`cell-${y}`))}),e.jsx(F,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:j("white"),border:`1px solid ${j("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:(r=>`¥${Number(r||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:g(w)}),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:D.map(r=>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:r.color||m[D.indexOf(r)%m.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:r.name,children:r.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:["¥",r.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[r.percentage,"%"]})]})]},r.name))})]})]})]})]})};export{qe as StatusBadge,Ue as default}; diff --git a/internal/webui/static/assets/ItemList-CZPbhJDg.js b/internal/webui/static/assets/ItemList-CH6EVxKe.js similarity index 69% rename from internal/webui/static/assets/ItemList-CZPbhJDg.js rename to internal/webui/static/assets/ItemList-CH6EVxKe.js index 3e1317a..63217c9 100644 --- a/internal/webui/static/assets/ItemList-CZPbhJDg.js +++ b/internal/webui/static/assets/ItemList-CH6EVxKe.js @@ -1,2 +1,2 @@ -import{j as e,r,b as we}from"./react-vendor-C_od1ZSF.js";import{g as je,c as Qe,a as ce,b as et,d as tt,A as yt,p as ft}from"./index-zEvleK2K.js";import{a3 as jt,U as De,R as Se,N as Te,a4 as Pe,a5 as _e,V as vt,y as Nt,B as wt,a6 as Ue,a7 as _t,a8 as kt,A as Ct,d as It,X as be,o as St,a9 as ze,I as Oe}from"./icons-vendor-DwxdQTKt.js";const Ke="ydisks-amap-js-api",Pt="c9b68d4ce9a2a97f22a4a439404488ca";let ye=null;const Bt=()=>Pt,qt=()=>window.AMap?Promise.resolve(window.AMap):ye||(ye=new Promise((s,l)=>{const i=document.getElementById(Ke),m=i||document.createElement("script"),u=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(R)},f=()=>{window.AMap?(u(),s(window.AMap)):(u(),l(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},R=window.setTimeout(()=>{u(),l(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=f,m.id=Ke,m.async=!0,m.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(Bt())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,m.onerror=()=>{u(),l(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},i||document.head.appendChild(m)}).catch(s=>{throw ye=null,s}),ye),ke=s=>Number.isFinite(s)&&s!==0,Lt=s=>{var u,f;const l=Number((u=s.location)==null?void 0:u.lng),i=Number((f=s.location)==null?void 0:f.lat),m={area:String(s.adname||"").trim(),city:String(s.cityname||"").trim(),division_id:String(s.adcode||"").trim(),longitude:l,latitude:i,poi_id:String(s.id||"").trim(),poi_name:String(s.name||"").trim(),province:String(s.pname||"").trim()};return!m.division_id||!m.province||!m.city||!m.poi_id||!m.poi_name||!ke(l)||!ke(i)||l<-180||l>180||i<-90||i>90?null:m},At=async(s,l,i={})=>{if(!ke(s)||!ke(l)||s<-180||s>180||l<-90||l>90)throw new Error("经纬度无效");const m=await qt();return new Promise((u,f)=>{var G,E;let R=!1;const k=Math.max(1,i.timeoutMs??1e4),A=M=>{var p;R||(R=!0,globalThis.clearTimeout(Z),(p=i.signal)==null||p.removeEventListener("abort",I),M())},I=()=>A(()=>f(new DOMException("aborted","AbortError"))),Z=globalThis.setTimeout(()=>A(()=>f(new Error("高德地图附近地址查询超时,请稍后重试"))),k);if((G=i.signal)!=null&&G.aborted){I();return}(E=i.signal)==null||E.addEventListener("abort",I,{once:!0}),new m.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[s,l],1e3,(M,p)=>{var d;if(R)return;if(M!=="complete"){if(M==="no_data"){A(()=>u([]));return}A(()=>f(new Error("高德地图附近地址查询失败,请稍后重试")));return}const B=(((d=p==null?void 0:p.poiList)==null?void 0:d.pois)||[]).map(Lt).filter(j=>j!==null);A(()=>u(B))})})},Et=async s=>je("/api/v1/accounts/details",void 0,s),Je=async s=>je("/api/v1/automation-rules",void 0,s),Mt=(s,l,i)=>At(s,l,i),Be=(s,l)=>{if(s instanceof yt)switch(s.code){case"stock_permission_missing":return"发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。";case"conflict":case"item_conflict":return"商品状态已发生变化,请刷新后重试。";case"external_result_unknown":case"manual_review_required":return"平台结果暂时无法确认,请先人工核对闲鱼状态,再决定是否重试。";case"retryable":case"temporarily_unavailable":return"平台暂时不可用,请稍后重试。";default:return s.message||l}if(s instanceof Error)return s.message;const i=typeof s=="object"&&s!==null&&"message"in s?s.message:void 0;return typeof i=="string"?i:l},qe=s=>s===!0||s===1||s==="1",Ze=async(s,l)=>{const i=await je("/api/v1/items",void 0,l);return Qe(i,["items","data","results"]).map(u=>({...u,id:u.id||`${u.cookie_id}-${u.item_id}`,is_multi_spec:qe(u.is_multi_spec),is_multi_qty_ship:qe(u.is_multi_qty_ship??u.multi_quantity_delivery),multi_quantity_delivery:qe(u.multi_quantity_delivery??u.is_multi_qty_ship)}))},Rt=async s=>ce("/api/v1/items/get-all-from-account",{cookie_id:s}),Ft=async(s,l)=>tt(`/api/v1/items/${s}/${l}`),Gt=async(s,l)=>ce(`/api/v1/items/${s}`,l),$t=async s=>{const l=new FormData;l.set("cookie_id",s.cookie_id),l.set("title",s.title),l.set("description",s.description),l.set("price",s.price),l.set("original_price",s.original_price||""),l.set("quantity",String(s.quantity)),l.set("postage_mode",s.postage_mode),l.set("postage",s.postage||""),s.location&&l.set("location",JSON.stringify(s.location));for(const i of s.images)l.append("images",i);return et("/api/v1/items/publish",l)},Dt=async(s,l,i)=>ce("/api/v1/items/publish-categories/recommend",{cookie_id:s,keyword:l},i),Tt=async(s,l)=>{const i=new FormData;return i.set("file",s.file),s.imagesZip&&i.set("images_zip",s.imagesZip),s.defaultCookieId&&i.set("default_cookie_id",s.defaultCookieId),i.set("fallback_category_id",s.fallbackCategory.catId),i.set("fallback_category_name",s.fallbackCategory.catName),i.set("fallback_channel_category_id",s.fallbackCategory.channelCatId||""),i.set("fallback_tb_category_id",s.fallbackCategory.tbCatId||""),s.location&&i.set("location",JSON.stringify(s.location)),i.set("publish_interval_seconds",String(s.publishIntervalSeconds??5)),et("/api/v1/items/publish-batches/preview",i,l)},Ut=async(s,l)=>ce("/api/v1/items/publish-batches",{preview_id:s},l),ie=async(s,l)=>je(`/api/v1/items/publish-batches/${s}`,void 0,l),st=async(s=20,l)=>{const i=await je("/api/v1/items/publish-batches",{limit:s},l);return Qe(i,["batches","data","items"])},Ve=async(s,l)=>tt(`/api/v1/items/publish-batches/${s}`,void 0,l),zt=async(s,l)=>ce(`/api/v1/items/publish-batches/${s}/cancel`,{},l),Ot=async(s,l)=>ce(`/api/v1/items/publish-batches/${s}/retry-failed`,{},l),Kt=async(s,l,i)=>ft(`/api/v1/items/${s}/${l}`,i),Jt=s=>s.find(l=>l.status==="pending"||l.status==="running"||l.status==="canceling"),fe=s=>s==="pending"||s==="running"||s==="canceling",Zt=s=>!!(s!=null&&s.preview_id&&Number(s.valid||0)>0),Vt=s=>!!(s!=null&&s.id&&Number(s.retryable||0)>0&&!fe(s.status)),Wt=(s,l)=>s===l,We=s=>{switch(s){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 s||"-"}},Ye=s=>{switch(s){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"}},Yt=({phase:s})=>{const l=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.map(([i,m])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${s===i?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:m},i))})},Ht=s=>{const[l,i]=r.useState(!1),[m,u]=r.useState("upload"),[f,R]=r.useState(null),[k,A]=r.useState(null),[I,Z]=r.useState(""),[T,G]=r.useState(!1),[E,M]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[p,B]=r.useState(null),[d,j]=r.useState(null),[S,V]=r.useState(null),[W,Y]=r.useState([]),[U,$]=r.useState(null),[K,C]=r.useState(5),[se,g]=r.useState(!1),y=r.useRef(0),b=r.useRef(null),v=r.useCallback(()=>{var h;(h=b.current)==null||h.abort();const a=new AbortController;b.current=a;const n=++y.current;return{controller:a,requestGeneration:n}},[]),x=r.useCallback((a,n)=>a===y.current&&n===b.current&&!n.signal.aborted,[]);r.useEffect(()=>(()=>{var a;(a=b.current)==null||a.abort(),y.current+=1}),[]);const ae=r.useCallback(async()=>{const a=v();u("upload"),B(null),j(null),R(null),A(null),Z(""),M({catId:"",catName:"",channelCatId:"",tbCatId:""}),Y([]),$(null),C(5),i(!0),g(!0);try{const n=await st(20,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;const h=Jt(n);if(h!=null&&h.id){const q=await ie(h.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;V(q),j(q),C(q.publish_interval_seconds||5),u(fe(q.status)?"running":"done")}}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("恢复最近批量铺货任务失败:",n)}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[v,x]),H=r.useCallback(async()=>{const a=I.trim();if(!s.selectedAccount){alert("请先选择默认发布账号");return}if(!a){alert("请输入类目关键词");return}const n=v();G(!0);try{const h=await Dt(s.selectedAccount,a,{signal:n.controller.signal});if(!x(n.requestGeneration,n.controller))return;const q=h.category;M({catId:q.cat_id,catName:q.cat_name,channelCatId:q.channel_cat_id,tbCatId:q.tb_cat_id||""})}catch(h){if(!x(n.requestGeneration,n.controller))return;console.error("获取推荐类目失败:",h),alert((h==null?void 0:h.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{x(n.requestGeneration,n.controller)&&G(!1)}},[I,v,x,s.selectedAccount]),z=r.useCallback(async()=>{if(!(S!=null&&S.id))return;const a=v();g(!0),i(!0);try{const n=await ie(S.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(n),C(n.publish_interval_seconds||5),u(fe(n.status)?"running":"done")}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("加载最近批量铺货结果失败:",n)}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[v,x,S==null?void 0:S.id]),D=r.useCallback(async()=>{if(!f){alert("请先上传商品表格");return}if(!s.selectedAccount){alert("请先选择默认发布账号");return}const a=v();g(!0);try{const n=await Tt({file:f,imagesZip:k,defaultCookieId:s.selectedAccount,fallbackCategory:E,location:U||void 0,publishIntervalSeconds:K},{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;B(n),j(null),u("preview")}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("批量铺货预检失败:",n),alert((n==null?void 0:n.message)||"预检失败,请检查表格和图片 zip")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[E,f,k,U,K,v,x,s.selectedAccount]),te=r.useCallback(async()=>{if(!(p!=null&&p.preview_id))return;if(!Zt(p)){alert("没有可发布的商品行");return}const a=v();g(!0);try{const n=await Ut(p.preview_id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;const h=await ie(n.batch_id||p.preview_id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(h),V(h),u(h.status==="running"?"running":"done")}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("启动批量铺货失败:",n),alert((n==null?void 0:n.message)||"启动发布任务失败")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[p,v,x]),oe=r.useCallback(async()=>{if(!(d!=null&&d.id)||!confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。"))return;const a=v();g(!0);try{const n=await zt(d.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;const h=await ie(d.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(h),u((n==null?void 0:n.status)==="canceling"||h.status==="canceling"?"running":"done")}catch(n){if(!x(a.requestGeneration,a.controller))return;alert((n==null?void 0:n.message)||"取消失败")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[d==null?void 0:d.id,v,x]),le=r.useCallback(async()=>{const a=p==null?void 0:p.preview_id,n=v();if(a&&m==="preview")try{await Ve(a,{signal:n.controller.signal})}catch(h){if(!x(n.requestGeneration,n.controller))return;console.error("清理批量铺货预检失败:",h)}x(n.requestGeneration,n.controller)&&(B(null),u("upload"))},[m,p==null?void 0:p.preview_id,v,x]),de=r.useCallback(async()=>{var n;const a=p==null?void 0:p.preview_id;if((n=b.current)==null||n.abort(),y.current+=1,B(null),u("upload"),i(!1),a&&m==="preview")try{await Ve(a)}catch(h){console.error("关闭批量铺货弹窗时清理预检失败:",h)}},[m,p==null?void 0:p.preview_id]),xe=r.useCallback(async()=>{if(!(d!=null&&d.id)||!Vt(d))return;const a=v();g(!0);try{if(await Ot(d.id,{signal:a.controller.signal}),!x(a.requestGeneration,a.controller))return;const n=await ie(d.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(n),u("running")}catch(n){if(!x(a.requestGeneration,a.controller))return;alert((n==null?void 0:n.message)||"重试失败")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[d,v,x]);return r.useEffect(()=>{if(!l||!(d!=null&&d.id)||!fe(d.status))return;const a=++y.current,n=new AbortController;let h=!1;const q=async()=>{if(!(h||n.signal.aborted)){h=!0;try{const N=await ie(d.id,{signal:n.signal});if(!Wt(a,y.current))return;j(N),V(N),fe(N.status)||(u("done"),await Promise.all([s.loadItems(),s.loadShippingRules()]))}catch(N){n.signal.aborted||console.error("刷新批量铺货进度失败:",N)}finally{h=!1}}},o=window.setInterval(()=>void q(),3e3);return(()=>{window.clearInterval(o),n.abort(),y.current+=1})},[d==null?void 0:d.id,d==null?void 0:d.status,s.loadItems,s.loadShippingRules,l]),{showBatchModal:l,setShowBatchModal:i,batchLoading:se,batchPhase:m,setBatchPhase:u,batchFile:f,setBatchFile:R,batchImagesZip:k,setBatchImagesZip:A,batchCategoryKeyword:I,setBatchCategoryKeyword:Z,batchCategoryLoading:T,batchFallbackCategory:E,setBatchFallbackCategory:M,batchPreview:p,setBatchPreview:B,batchDetail:d,setBatchDetail:j,recentBatch:S,setRecentBatch:V,batchLocations:W,batchLocation:U,setBatchLocations:Y,setBatchLocation:$,batchPublishIntervalSeconds:K,setBatchPublishIntervalSeconds:C,openBatchModal:ae,handleRecommendBatchCategory:H,openRecentBatchResult:z,handlePreviewBatch:D,handleStartBatch:te,handleCancelBatch:oe,abandonBatchPreview:le,closeBatchModal:de,handleRetryBatchFailed:xe}},He=()=>({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),Xe=(s="")=>({cookie_id:s,title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),Xt=({selectedAccount:s,setSelectedAccount:l,setItems:i,loadItems:m,loadShippingRules:u,onConfigureDelivery:f,setBatchLocations:R,setBatchLocation:k})=>{const[A,I]=r.useState(!1),[Z,T]=r.useState(!1),[G,E]=r.useState(!1),[M,p]=r.useState(!1),[B,d]=r.useState(!1),[j,S]=r.useState(!1),[V,W]=r.useState([]),[Y,U]=r.useState(null),[$,K]=r.useState(null),[C,se]=r.useState({}),[g,y]=r.useState(He),[b,v]=r.useState(Xe),[x,ae]=r.useState([]),H=r.useRef(null),z=r.useRef(0);r.useEffect(()=>{if(!B||b.images.length===0){ae([]);return}const o=b.images.map((N,L)=>({key:N.name+L,url:URL.createObjectURL(N)}));return ae(o),(()=>o.forEach(N=>URL.revokeObjectURL(N.url)))},[b.images,B]);const D=r.useCallback(()=>{var o;(o=H.current)==null||o.abort(),H.current=null,z.current+=1,S(!1)},[]);r.useEffect(()=>D,[D]),r.useEffect(()=>{B||D()},[D,B]);const te=r.useCallback(async()=>{if(!s)return alert("请先选择账号");I(!0);try{const o=await Rt(s);await m(),alert((o==null?void 0:o.message)||"商品同步完成")}catch(o){console.error("同步商品失败:",o),alert(Be(o,"同步失败,请重试"))}finally{I(!1)}},[m,s]),oe=r.useCallback(o=>{K(o),se({...o}),E(!0)},[]),le=r.useCallback(async()=>{if($)try{await Kt($.cookie_id,$.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||$.item_detail||""}),await m(),await u(),E(!1),K(null)}catch(o){console.error("更新商品失败:",o),alert("更新失败,请重试")}},[C,m,u,$]),de=r.useCallback(async o=>{if(confirm(`确认删除商品"${o.item_title}"吗?`))try{await Ft(o.cookie_id,o.item_id),i(N=>N.filter(L=>!(L.cookie_id===o.cookie_id&&L.item_id===o.item_id)))}catch(N){console.error("删除商品失败:",N),alert("删除失败,请重试")}},[i]),xe=r.useCallback(async()=>{try{if(!g.cookie_id||!g.item_id){alert("请选择账号并填写商品ID");return}await Gt(g.cookie_id,{item_id:g.item_id,item_title:g.item_title,item_price:g.item_price,item_detail:g.item_image?JSON.stringify({item_image:g.item_image}):""}),await m(),p(!1),y(He())}catch(o){console.error("添加商品失败:",o),alert("添加失败,请重试")}},[g,m]),ve=r.useCallback(async()=>{if(!b.cookie_id)return alert("请选择发布账号");if(!b.title.trim())return alert("请填写商品标题");if(!b.price.trim())return alert("请填写商品价格");if(!b.quantity||Number(b.quantity)<=0)return alert("库存数量必须大于 0");if(b.images.length===0)return alert("至少上传 1 张商品图片");if(b.postage_mode==="fixed"&&!b.postage.trim())return alert("请填写一口价邮费");T(!0);try{const o=await $t({...b,location:Y||void 0});if(await m(),d(!1),v(Xe(s||"")),W([]),U(null),o!=null&&o.item_id){const N={id:o.item_id,cookie_id:b.cookie_id,item_id:o.item_id,item_title:o.item_title||b.title,item_price:o.item_price||b.price,item_image:o.item_image};f(N),alert("商品发布成功,ID: "+o.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(o){console.error("发布商品失败:",o),alert(Be(o,"发布失败,请重试"))}finally{T(!1)}},[m,f,b,Y,s]),a=r.useCallback(()=>{const L=[["账号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(ue=>ue.map(me=>`"${String(me).replace(/"/g,'""')}"`).join(",")).join(` -`),X=new Blob(["\uFEFF"+L],{type:"text/csv;charset=utf-8"}),F=URL.createObjectURL(X),P=document.createElement("a");P.href=F,P.download="批量铺货模板.csv",document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(F)},[]),n=r.useCallback(()=>{y(o=>({...o,cookie_id:s||o.cookie_id})),p(!0)},[s]),h=r.useCallback(()=>{v(o=>({...o,cookie_id:s||o.cookie_id})),d(!0)},[s]),q=r.useCallback(async o=>{if(!(o?s:b.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");D();const L=new AbortController;H.current=L;const X=++z.current;S(!0);try{const F=await new Promise((ue,me)=>{const Ce=Q=>ue(Q),re=Q=>me(Q);navigator.geolocation.getCurrentPosition(Ce,re,{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})});if(L.signal.aborted||X!==z.current)return;const P=await Mt(F.coords.longitude,F.coords.latitude,{signal:L.signal});if(L.signal.aborted||X!==z.current)return;if(!P.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");o?(R(P),k(P[0])):(W(P),U(P[0]))}catch(F){if(L.signal.aborted||X!==z.current)return;if(typeof F=="object"&&F!==null&&"code"in F){const P=F;alert(P.code===P.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")}else alert(Be(F,"获取发货地失败"))}finally{X===z.current&&(H.current=null,S(!1))}},[D,b.cookie_id,s,k,R]);return{selectedAccount:s,setSelectedAccount:l,loading:A,publishing:Z,showEditModal:G,setShowEditModal:E,showAddModal:M,setShowAddModal:p,showPublishModal:B,setShowPublishModal:d,locationLoading:j,publishLocations:V,setPublishLocations:W,publishLocation:Y,setPublishLocation:U,selectedItem:$,editForm:C,setEditForm:se,addForm:g,setAddForm:y,publishForm:b,setPublishForm:v,publishImagePreviews:x,handleSync:te,handleEdit:oe,handleSaveEdit:le,handleDelete:de,handleAddItem:xe,handlePublishItem:ve,downloadPublishTemplate:a,openAddModal:n,openPublishModal:h,locateForPublish:q}},Qt=s=>{const l=String(s||"").trim();return l?/^[¥¥]/.test(l)?l:`¥${l}`:"-"},as=({onConfigureDelivery:s})=>{const[l,i]=r.useState([]),[m,u]=r.useState([]),[f,R]=r.useState([]),[k,A]=r.useState(""),[I,Z]=r.useState(""),T=r.useRef(0),G=r.useRef(0),E=r.useCallback(async()=>{const t=++T.current,c=await Ze();t===T.current&&i(c)},[]),M=r.useCallback(async()=>{const t=++G.current,c=await Je();t===G.current&&u(c)},[]),p=Ht({selectedAccount:k,loadItems:E,loadShippingRules:M}),{showBatchModal:B,batchLoading:d,batchPhase:j,batchFile:S,setBatchFile:V,batchImagesZip:W,setBatchImagesZip:Y,batchCategoryKeyword:U,setBatchCategoryKeyword:$,batchCategoryLoading:K,batchFallbackCategory:C,setBatchFallbackCategory:se,batchPreview:g,batchDetail:y,recentBatch:b,setRecentBatch:v,batchLocations:x,batchLocation:ae,batchPublishIntervalSeconds:H,setBatchPublishIntervalSeconds:z,setBatchLocations:D,setBatchLocation:te,openBatchModal:oe,handleRecommendBatchCategory:le,openRecentBatchResult:de,handlePreviewBatch:xe,handleStartBatch:ve,handleCancelBatch:a,abandonBatchPreview:n,closeBatchModal:h,handleRetryBatchFailed:q}=p,o=Xt({selectedAccount:k,setSelectedAccount:A,setItems:i,loadItems:E,loadShippingRules:M,onConfigureDelivery:s,setBatchLocations:D,setBatchLocation:te}),{loading:N,publishing:L,showEditModal:X,setShowEditModal:F,showAddModal:P,setShowAddModal:ue,showPublishModal:me,setShowPublishModal:Ce,locationLoading:re,publishLocations:Q,setPublishLocations:at,publishLocation:lt,setPublishLocation:Le,selectedItem:Ae,editForm:ee,setEditForm:Ne,addForm:O,setAddForm:he,publishForm:w,setPublishForm:J,publishImagePreviews:Ee,handleSync:rt,handleEdit:nt,handleSaveEdit:it,handleDelete:ct,handleAddItem:ot,handlePublishItem:dt,downloadPublishTemplate:xt,openAddModal:ut,openPublishModal:mt,locateForPublish:Me}=o;r.useEffect(()=>{const t=new AbortController,c=++T.current,_=++G.current;let ge=!0;return Promise.all([Et({signal:t.signal}),Ze(void 0,{signal:t.signal}),Je({signal:t.signal}),st(20,{signal:t.signal})]).then(([ne,pt,gt,$e])=>{if(!ge||t.signal.aborted||c!==T.current||_!==G.current)return;R(ne),i(pt),u(gt);const bt=$e.find(Ie=>["running","canceling"].includes(Ie.status))||$e.find(Ie=>Ie.status!=="preview");v(bt||null)}).catch(ne=>{t.signal.aborted||console.error("加载商品配置失败:",ne)}),(()=>{ge=!1,t.abort()})},[]);const ht=t=>m.filter(c=>c.cookie_id===t.cookie_id&&c.item_id===t.item_id).length>0?m.filter(c=>c.cookie_id===t.cookie_id&&c.item_id===t.item_id):m.filter(c=>c.cookie_id===t.cookie_id&&!c.item_id),Re=r.useMemo(()=>new Map(f.map(t=>[t.id,t])),[f]),Fe=r.useMemo(()=>I?l.filter(t=>t.cookie_id===I):l,[I,l]),pe=t=>{const c=Re.get(t),_=(c==null?void 0:c.remark)||(c==null?void 0:c.nickname);return _?`${_} · ${t.slice(0,6)}`:`账号 ${t.slice(0,8)}`},Ge=t=>{const c=Re.get(t);return(c==null?void 0:c.remark)||(c==null?void 0:c.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(jt,{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:I,onChange:(t=>Z(t.target.value)),children:[e.jsx("option",{value:"",children:"全部账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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(De,{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:k,onChange:(t=>A(t.target.value)),children:[e.jsx("option",{value:"",children:"请选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.id))]})]})]}),e.jsxs("button",{onClick:rt,disabled:N||!k,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(Se,{className:`w-4 h-4 ${N?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ut,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(Te,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:mt,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(Pe,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:(()=>void oe()),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(_e,{className:"w-4 h-4"}),b&&["running","canceling"].includes(b.status)?"继续批量任务":"批量铺货"]}),b&&!["running","canceling"].includes(b.status)&&e.jsx("button",{onClick:(()=>void de()),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:[Fe.map(t=>{const c=ht(t),_=c.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:(()=>nt(t)),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(vt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:(()=>ct(t)),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(Nt,{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:[t.item_image?e.jsx("img",{src:t.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(wt,{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:Qt(t.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:t.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:Ge(t.cookie_id),children:[e.jsx(De,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:Ge(t.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: ",t.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${_?"text-emerald-600":"text-amber-600"}`,children:[_?e.jsx(Ue,{className:"w-3 h-3"}):e.jsx(_t,{className:"w-3 h-3"}),_?`${c.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:(()=>s(t)),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${_?"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(kt,{className:"w-3.5 h-3.5"}),_?"查看发货规则":"关联发货规则"]}),e.jsx(Ct,{className:"w-3.5 h-3.5"})]})})]},`${t.cookie_id}-${t.item_id}`)}),Fe.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(It,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),I?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),X&&Ae&&we.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: ",Ae.item_id]})]}),e.jsx("button",{onClick:(()=>F(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(be,{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:ee.item_title||"",onChange:(t=>Ne({...ee,item_title:t.target.value}))}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:ee.item_price||"",onChange:(t=>Ne({...ee,item_price:t.target.value}))}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:ee.item_category||"",onChange:(t=>Ne({...ee,item_category:t.target.value}))}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:ee.item_description||"",onChange:(t=>Ne({...ee,item_description:t.target.value}))})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:it,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(St,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),P&&we.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:(()=>ue(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(be,{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:O.cookie_id,onChange:(t=>he({...O,cookie_id:t.target.value})),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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:O.item_id,onChange:(t=>he({...O,item_id:t.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:O.item_price,onChange:(t=>he({...O,item_price:t.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:O.item_title,onChange:(t=>he({...O,item_title:t.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:O.item_image,onChange:(t=>he({...O,item_image:t.target.value}))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:ot,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(Te,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),me&&we.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:(()=>Ce(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(be,{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:w.cookie_id,onChange:(t=>{J({...w,cookie_id:t.target.value}),at([]),Le(null)}),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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:w.title,onChange:(t=>J({...w,title:t.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:w.quantity,onChange:(t=>J({...w,quantity:t.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:w.description,onChange:(t=>J({...w,description:t.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:w.price,onChange:(t=>J({...w,price:t.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:w.original_price,onChange:(t=>J({...w,original_price:t.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:w.postage_mode,onChange:(t=>J({...w,postage_mode:t.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:"无需邮寄"})]})]})]}),w.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:w.postage,onChange:(t=>J({...w,postage:t.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:re||!w.cookie_id,onClick:(()=>void Me(!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(ze,{className:"h-4 w-4"}),re?"定位中...":"获取当前位置"]})]}),Q.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,Q.indexOf(lt))),onChange:(t=>Le(Q[Number(t.target.value)]||null)),children:Q.map((t,c)=>e.jsx("option",{value:String(c),children:[t.province,t.city,t.area,t.poi_name].filter(Boolean).join(" ")},`${t.division_id}-${t.poi_id}-${c}`))})]}),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(_e,{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:w.images.length?"已选择 "+w.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:(t=>J({...w,images:Array.from(t.target.files||[]).slice(0,9)}))})]}),Ee.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:Ee.map(t=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:t.url,alt:"",className:"w-full h-full object-cover"})},t.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:L,onClick:dt,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(Pe,{className:"w-4 h-4"}),L?"正在发布...":"发布到闲鱼"]})})]})}),document.body),B&&we.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 h()),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(be,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(Yt,{phase:j}),j==="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:xt,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:k,onChange:(t=>{A(t.target.value),D([]),te(null)}),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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(Oe,{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:U,onChange:(t=>$(t.target.value)),onKeyDown:(t=>{t.key==="Enter"&&(t.preventDefault(),le())})})]}),e.jsxs("button",{type:"button",disabled:!k||!U.trim()||K,onClick:(()=>void le()),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(Oe,{className:"h-4 w-4"}),K?"匹配中...":"获取类目"]})]}),C.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(Ue,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:C.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",C.catId," · 频道 ",C.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:(()=>se({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(be,{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:re||!k,onClick:(()=>void Me(!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(ze,{className:"h-4 w-4"}),re?"定位中...":"获取当前位置"]})]}),x.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,x.indexOf(ae))),onChange:(t=>te(x[Number(t.target.value)]||null)),children:x.map((t,c)=>e.jsx("option",{value:String(c),children:[t.province,t.city,t.area,t.poi_name].filter(Boolean).join(" ")},`${t.division_id}-${t.poi_id}-${c}`))})]}),e.jsx("div",{className:"rounded-xl border border-violet-200 bg-violet-50 p-4 space-y-2",children:e.jsxs("label",{className:"flex items-center justify-between gap-4",htmlFor:"batch-publish-interval",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-extrabold text-gray-900",children:"商品发布强制间隔"}),e.jsx("span",{className:"mt-1 block text-xs text-violet-800",children:"图片会提前上传,只有最终发布请求之间至少等待该时间。"})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("input",{id:"batch-publish-interval",type:"number",min:1,max:3600,step:1,inputMode:"numeric",className:"ios-input w-24 rounded-xl bg-white px-3 py-2 text-right",value:H,onChange:(t=>z(Math.min(3600,Math.max(1,Number(t.target.value)||1))))}),e.jsx("span",{className:"text-sm font-bold text-violet-900",children:"秒"})]})]})}),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(_e,{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:S?S.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:(t=>{var c;return V(((c=t.target.files)==null?void 0:c[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(_e,{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:W?W.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:(t=>{var c;return Y(((c=t.target.files)==null?void 0:c[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(([t,c,_])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:t}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${c==="每个商品都要填"?"text-red-600":c==="可以留空"?"text-gray-500":"text-amber-700"}`,children:c}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:_})]},t))})]})})]})]}),j==="preview"&&g&&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:g.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:g.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:g.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:g.rows.map(t=>{var c,_,ge,ne;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.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 ${t.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:t.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:t.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",t.price||"-"," / ",t.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:((c=t.category)==null?void 0:c.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((_=t.category)==null?void 0:_.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((ge=t.images)==null?void 0:ge.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((ne=t.errors)==null?void 0:ne.join(";"))||"-"})]},t.row_no)})})]})})]}),(j==="running"||j==="done")&&y&&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 ${Ye(y.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:We(y.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:y.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:y.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:y.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:y.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:y.rows.map(t=>{var c,_;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.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 ${Ye(t.status)}`,children:We(t.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:t.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:((c=t.category)==null?void 0:c.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((_=t.category)==null?void 0:_.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:t.item_url?e.jsx("a",{href:t.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:t.item_id}):t.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:t.error_message||"-"})]},t.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[j==="upload"&&e.jsxs("button",{disabled:d||!S||!k,onClick:xe,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(Se,{className:`w-4 h-4 ${d?"animate-spin":""}`}),d?"正在预检...":"开始预检"]}),j==="preview"&&g&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:d,onClick:(()=>void n()),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:d||g.valid<=0,onClick:ve,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(Pe,{className:"w-4 h-4"}),d?"启动中...":`确认发布 ${g.valid} 个商品`]})]}),(j==="running"||j==="done")&&y&&e.jsxs("div",{className:"flex gap-3 w-full",children:[y.status==="running"?e.jsx("button",{disabled:d,onClick:a,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):y.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/${y.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:"下载结果"}),y.retryable>0&&!["running","canceling"].includes(y.status)&&e.jsxs("button",{disabled:d,onClick:q,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(Se,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(y.status)&&e.jsx("button",{onClick:(()=>{h(),E(),M()}),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)]})};export{as as default}; +import{j as e,a as r,b as we}from"./react-vendor-l-BBvuKH.js";import{g as je,c as Qe,b as ce,d as et,e as tt,A as yt,p as ft}from"./index-WrujSo30.js";import{a3 as jt,U as De,R as Se,N as Te,a4 as Pe,a5 as _e,V as vt,y as Nt,B as wt,a6 as Ue,a7 as _t,a8 as kt,A as Ct,d as It,X as be,o as St,a9 as ze,I as Oe}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const Ke="ydisks-amap-js-api",Pt="c9b68d4ce9a2a97f22a4a439404488ca";let ye=null;const Bt=()=>Pt,qt=()=>window.AMap?Promise.resolve(window.AMap):ye||(ye=new Promise((s,l)=>{const i=document.getElementById(Ke),m=i||document.createElement("script"),u=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(R)},f=()=>{window.AMap?(u(),s(window.AMap)):(u(),l(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},R=window.setTimeout(()=>{u(),l(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=f,m.id=Ke,m.async=!0,m.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(Bt())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,m.onerror=()=>{u(),l(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},i||document.head.appendChild(m)}).catch(s=>{throw ye=null,s}),ye),ke=s=>Number.isFinite(s)&&s!==0,Lt=s=>{var u,f;const l=Number((u=s.location)==null?void 0:u.lng),i=Number((f=s.location)==null?void 0:f.lat),m={area:String(s.adname||"").trim(),city:String(s.cityname||"").trim(),division_id:String(s.adcode||"").trim(),longitude:l,latitude:i,poi_id:String(s.id||"").trim(),poi_name:String(s.name||"").trim(),province:String(s.pname||"").trim()};return!m.division_id||!m.province||!m.city||!m.poi_id||!m.poi_name||!ke(l)||!ke(i)||l<-180||l>180||i<-90||i>90?null:m},At=async(s,l,i={})=>{if(!ke(s)||!ke(l)||s<-180||s>180||l<-90||l>90)throw new Error("经纬度无效");const m=await qt();return new Promise((u,f)=>{var G,E;let R=!1;const k=Math.max(1,i.timeoutMs??1e4),A=M=>{var p;R||(R=!0,globalThis.clearTimeout(Z),(p=i.signal)==null||p.removeEventListener("abort",I),M())},I=()=>A(()=>f(new DOMException("aborted","AbortError"))),Z=globalThis.setTimeout(()=>A(()=>f(new Error("高德地图附近地址查询超时,请稍后重试"))),k);if((G=i.signal)!=null&&G.aborted){I();return}(E=i.signal)==null||E.addEventListener("abort",I,{once:!0}),new m.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[s,l],1e3,(M,p)=>{var d;if(R)return;if(M!=="complete"){if(M==="no_data"){A(()=>u([]));return}A(()=>f(new Error("高德地图附近地址查询失败,请稍后重试")));return}const B=(((d=p==null?void 0:p.poiList)==null?void 0:d.pois)||[]).map(Lt).filter(j=>j!==null);A(()=>u(B))})})},Et=async s=>je("/api/v1/accounts/details",void 0,s),Je=async s=>je("/api/v1/automation-rules",void 0,s),Mt=(s,l,i)=>At(s,l,i),Be=(s,l)=>{if(s instanceof yt)switch(s.code){case"stock_permission_missing":return"发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。";case"conflict":case"item_conflict":return"商品状态已发生变化,请刷新后重试。";case"external_result_unknown":case"manual_review_required":return"平台结果暂时无法确认,请先人工核对闲鱼状态,再决定是否重试。";case"retryable":case"temporarily_unavailable":return"平台暂时不可用,请稍后重试。";default:return s.message||l}if(s instanceof Error)return s.message;const i=typeof s=="object"&&s!==null&&"message"in s?s.message:void 0;return typeof i=="string"?i:l},qe=s=>s===!0||s===1||s==="1",Ze=async(s,l)=>{const i=await je("/api/v1/items",void 0,l);return Qe(i,["items","data","results"]).map(u=>({...u,id:u.id||`${u.cookie_id}-${u.item_id}`,is_multi_spec:qe(u.is_multi_spec),is_multi_qty_ship:qe(u.is_multi_qty_ship??u.multi_quantity_delivery),multi_quantity_delivery:qe(u.multi_quantity_delivery??u.is_multi_qty_ship)}))},Rt=async s=>ce("/api/v1/items/get-all-from-account",{cookie_id:s}),Ft=async(s,l)=>tt(`/api/v1/items/${s}/${l}`),Gt=async(s,l)=>ce(`/api/v1/items/${s}`,l),$t=async s=>{const l=new FormData;l.set("cookie_id",s.cookie_id),l.set("title",s.title),l.set("description",s.description),l.set("price",s.price),l.set("original_price",s.original_price||""),l.set("quantity",String(s.quantity)),l.set("postage_mode",s.postage_mode),l.set("postage",s.postage||""),s.location&&l.set("location",JSON.stringify(s.location));for(const i of s.images)l.append("images",i);return et("/api/v1/items/publish",l)},Dt=async(s,l,i)=>ce("/api/v1/items/publish-categories/recommend",{cookie_id:s,keyword:l},i),Tt=async(s,l)=>{const i=new FormData;return i.set("file",s.file),s.imagesZip&&i.set("images_zip",s.imagesZip),s.defaultCookieId&&i.set("default_cookie_id",s.defaultCookieId),i.set("fallback_category_id",s.fallbackCategory.catId),i.set("fallback_category_name",s.fallbackCategory.catName),i.set("fallback_channel_category_id",s.fallbackCategory.channelCatId||""),i.set("fallback_tb_category_id",s.fallbackCategory.tbCatId||""),s.location&&i.set("location",JSON.stringify(s.location)),i.set("publish_interval_seconds",String(s.publishIntervalSeconds??5)),et("/api/v1/items/publish-batches/preview",i,l)},Ut=async(s,l)=>ce("/api/v1/items/publish-batches",{preview_id:s},l),ie=async(s,l)=>je(`/api/v1/items/publish-batches/${s}`,void 0,l),st=async(s=20,l)=>{const i=await je("/api/v1/items/publish-batches",{limit:s},l);return Qe(i,["batches","data","items"])},Ve=async(s,l)=>tt(`/api/v1/items/publish-batches/${s}`,void 0,l),zt=async(s,l)=>ce(`/api/v1/items/publish-batches/${s}/cancel`,{},l),Ot=async(s,l)=>ce(`/api/v1/items/publish-batches/${s}/retry-failed`,{},l),Kt=async(s,l,i)=>ft(`/api/v1/items/${s}/${l}`,i),Jt=s=>s.find(l=>l.status==="pending"||l.status==="running"||l.status==="canceling"),fe=s=>s==="pending"||s==="running"||s==="canceling",Zt=s=>!!(s!=null&&s.preview_id&&Number(s.valid||0)>0),Vt=s=>!!(s!=null&&s.id&&Number(s.retryable||0)>0&&!fe(s.status)),Wt=(s,l)=>s===l,We=s=>{switch(s){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 s||"-"}},Ye=s=>{switch(s){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"}},Yt=({phase:s})=>{const l=[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]];return e.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.map(([i,m])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${s===i?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:m},i))})},Ht=s=>{const[l,i]=r.useState(!1),[m,u]=r.useState("upload"),[f,R]=r.useState(null),[k,A]=r.useState(null),[I,Z]=r.useState(""),[T,G]=r.useState(!1),[E,M]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[p,B]=r.useState(null),[d,j]=r.useState(null),[S,V]=r.useState(null),[W,Y]=r.useState([]),[U,$]=r.useState(null),[K,C]=r.useState(5),[se,g]=r.useState(!1),y=r.useRef(0),b=r.useRef(null),v=r.useCallback(()=>{var h;(h=b.current)==null||h.abort();const a=new AbortController;b.current=a;const n=++y.current;return{controller:a,requestGeneration:n}},[]),x=r.useCallback((a,n)=>a===y.current&&n===b.current&&!n.signal.aborted,[]);r.useEffect(()=>(()=>{var a;(a=b.current)==null||a.abort(),y.current+=1}),[]);const ae=r.useCallback(async()=>{const a=v();u("upload"),B(null),j(null),R(null),A(null),Z(""),M({catId:"",catName:"",channelCatId:"",tbCatId:""}),Y([]),$(null),C(5),i(!0),g(!0);try{const n=await st(20,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;const h=Jt(n);if(h!=null&&h.id){const q=await ie(h.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;V(q),j(q),C(q.publish_interval_seconds||5),u(fe(q.status)?"running":"done")}}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("恢复最近批量铺货任务失败:",n)}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[v,x]),H=r.useCallback(async()=>{const a=I.trim();if(!s.selectedAccount){alert("请先选择默认发布账号");return}if(!a){alert("请输入类目关键词");return}const n=v();G(!0);try{const h=await Dt(s.selectedAccount,a,{signal:n.controller.signal});if(!x(n.requestGeneration,n.controller))return;const q=h.category;M({catId:q.cat_id,catName:q.cat_name,channelCatId:q.channel_cat_id,tbCatId:q.tb_cat_id||""})}catch(h){if(!x(n.requestGeneration,n.controller))return;console.error("获取推荐类目失败:",h),alert((h==null?void 0:h.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{x(n.requestGeneration,n.controller)&&G(!1)}},[I,v,x,s.selectedAccount]),z=r.useCallback(async()=>{if(!(S!=null&&S.id))return;const a=v();g(!0),i(!0);try{const n=await ie(S.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(n),C(n.publish_interval_seconds||5),u(fe(n.status)?"running":"done")}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("加载最近批量铺货结果失败:",n)}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[v,x,S==null?void 0:S.id]),D=r.useCallback(async()=>{if(!f){alert("请先上传商品表格");return}if(!s.selectedAccount){alert("请先选择默认发布账号");return}const a=v();g(!0);try{const n=await Tt({file:f,imagesZip:k,defaultCookieId:s.selectedAccount,fallbackCategory:E,location:U||void 0,publishIntervalSeconds:K},{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;B(n),j(null),u("preview")}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("批量铺货预检失败:",n),alert((n==null?void 0:n.message)||"预检失败,请检查表格和图片 zip")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[E,f,k,U,K,v,x,s.selectedAccount]),te=r.useCallback(async()=>{if(!(p!=null&&p.preview_id))return;if(!Zt(p)){alert("没有可发布的商品行");return}const a=v();g(!0);try{const n=await Ut(p.preview_id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;const h=await ie(n.batch_id||p.preview_id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(h),V(h),u(h.status==="running"?"running":"done")}catch(n){if(!x(a.requestGeneration,a.controller))return;console.error("启动批量铺货失败:",n),alert((n==null?void 0:n.message)||"启动发布任务失败")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[p,v,x]),oe=r.useCallback(async()=>{if(!(d!=null&&d.id)||!confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。"))return;const a=v();g(!0);try{const n=await zt(d.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;const h=await ie(d.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(h),u((n==null?void 0:n.status)==="canceling"||h.status==="canceling"?"running":"done")}catch(n){if(!x(a.requestGeneration,a.controller))return;alert((n==null?void 0:n.message)||"取消失败")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[d==null?void 0:d.id,v,x]),le=r.useCallback(async()=>{const a=p==null?void 0:p.preview_id,n=v();if(a&&m==="preview")try{await Ve(a,{signal:n.controller.signal})}catch(h){if(!x(n.requestGeneration,n.controller))return;console.error("清理批量铺货预检失败:",h)}x(n.requestGeneration,n.controller)&&(B(null),u("upload"))},[m,p==null?void 0:p.preview_id,v,x]),de=r.useCallback(async()=>{var n;const a=p==null?void 0:p.preview_id;if((n=b.current)==null||n.abort(),y.current+=1,B(null),u("upload"),i(!1),a&&m==="preview")try{await Ve(a)}catch(h){console.error("关闭批量铺货弹窗时清理预检失败:",h)}},[m,p==null?void 0:p.preview_id]),xe=r.useCallback(async()=>{if(!(d!=null&&d.id)||!Vt(d))return;const a=v();g(!0);try{if(await Ot(d.id,{signal:a.controller.signal}),!x(a.requestGeneration,a.controller))return;const n=await ie(d.id,{signal:a.controller.signal});if(!x(a.requestGeneration,a.controller))return;j(n),u("running")}catch(n){if(!x(a.requestGeneration,a.controller))return;alert((n==null?void 0:n.message)||"重试失败")}finally{x(a.requestGeneration,a.controller)&&g(!1)}},[d,v,x]);return r.useEffect(()=>{if(!l||!(d!=null&&d.id)||!fe(d.status))return;const a=++y.current,n=new AbortController;let h=!1;const q=async()=>{if(!(h||n.signal.aborted)){h=!0;try{const N=await ie(d.id,{signal:n.signal});if(!Wt(a,y.current))return;j(N),V(N),fe(N.status)||(u("done"),await Promise.all([s.loadItems(),s.loadShippingRules()]))}catch(N){n.signal.aborted||console.error("刷新批量铺货进度失败:",N)}finally{h=!1}}},o=window.setInterval(()=>void q(),3e3);return(()=>{window.clearInterval(o),n.abort(),y.current+=1})},[d==null?void 0:d.id,d==null?void 0:d.status,s.loadItems,s.loadShippingRules,l]),{showBatchModal:l,setShowBatchModal:i,batchLoading:se,batchPhase:m,setBatchPhase:u,batchFile:f,setBatchFile:R,batchImagesZip:k,setBatchImagesZip:A,batchCategoryKeyword:I,setBatchCategoryKeyword:Z,batchCategoryLoading:T,batchFallbackCategory:E,setBatchFallbackCategory:M,batchPreview:p,setBatchPreview:B,batchDetail:d,setBatchDetail:j,recentBatch:S,setRecentBatch:V,batchLocations:W,batchLocation:U,setBatchLocations:Y,setBatchLocation:$,batchPublishIntervalSeconds:K,setBatchPublishIntervalSeconds:C,openBatchModal:ae,handleRecommendBatchCategory:H,openRecentBatchResult:z,handlePreviewBatch:D,handleStartBatch:te,handleCancelBatch:oe,abandonBatchPreview:le,closeBatchModal:de,handleRetryBatchFailed:xe}},He=()=>({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),Xe=(s="")=>({cookie_id:s,title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),Xt=({selectedAccount:s,setSelectedAccount:l,setItems:i,loadItems:m,loadShippingRules:u,onConfigureDelivery:f,setBatchLocations:R,setBatchLocation:k})=>{const[A,I]=r.useState(!1),[Z,T]=r.useState(!1),[G,E]=r.useState(!1),[M,p]=r.useState(!1),[B,d]=r.useState(!1),[j,S]=r.useState(!1),[V,W]=r.useState([]),[Y,U]=r.useState(null),[$,K]=r.useState(null),[C,se]=r.useState({}),[g,y]=r.useState(He),[b,v]=r.useState(Xe),[x,ae]=r.useState([]),H=r.useRef(null),z=r.useRef(0);r.useEffect(()=>{if(!B||b.images.length===0){ae([]);return}const o=b.images.map((N,L)=>({key:N.name+L,url:URL.createObjectURL(N)}));return ae(o),(()=>o.forEach(N=>URL.revokeObjectURL(N.url)))},[b.images,B]);const D=r.useCallback(()=>{var o;(o=H.current)==null||o.abort(),H.current=null,z.current+=1,S(!1)},[]);r.useEffect(()=>D,[D]),r.useEffect(()=>{B||D()},[D,B]);const te=r.useCallback(async()=>{if(!s)return alert("请先选择账号");I(!0);try{const o=await Rt(s);await m(),alert((o==null?void 0:o.message)||"商品同步完成")}catch(o){console.error("同步商品失败:",o),alert(Be(o,"同步失败,请重试"))}finally{I(!1)}},[m,s]),oe=r.useCallback(o=>{K(o),se({...o}),E(!0)},[]),le=r.useCallback(async()=>{if($)try{await Kt($.cookie_id,$.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||$.item_detail||""}),await m(),await u(),E(!1),K(null)}catch(o){console.error("更新商品失败:",o),alert("更新失败,请重试")}},[C,m,u,$]),de=r.useCallback(async o=>{if(confirm(`确认删除商品"${o.item_title}"吗?`))try{await Ft(o.cookie_id,o.item_id),i(N=>N.filter(L=>!(L.cookie_id===o.cookie_id&&L.item_id===o.item_id)))}catch(N){console.error("删除商品失败:",N),alert("删除失败,请重试")}},[i]),xe=r.useCallback(async()=>{try{if(!g.cookie_id||!g.item_id){alert("请选择账号并填写商品ID");return}await Gt(g.cookie_id,{item_id:g.item_id,item_title:g.item_title,item_price:g.item_price,item_detail:g.item_image?JSON.stringify({item_image:g.item_image}):""}),await m(),p(!1),y(He())}catch(o){console.error("添加商品失败:",o),alert("添加失败,请重试")}},[g,m]),ve=r.useCallback(async()=>{if(!b.cookie_id)return alert("请选择发布账号");if(!b.title.trim())return alert("请填写商品标题");if(!b.price.trim())return alert("请填写商品价格");if(!b.quantity||Number(b.quantity)<=0)return alert("库存数量必须大于 0");if(b.images.length===0)return alert("至少上传 1 张商品图片");if(b.postage_mode==="fixed"&&!b.postage.trim())return alert("请填写一口价邮费");T(!0);try{const o=await $t({...b,location:Y||void 0});if(await m(),d(!1),v(Xe(s||"")),W([]),U(null),o!=null&&o.item_id){const N={id:o.item_id,cookie_id:b.cookie_id,item_id:o.item_id,item_title:o.item_title||b.title,item_price:o.item_price||b.price,item_image:o.item_image};f(N),alert("商品发布成功,ID: "+o.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(o){console.error("发布商品失败:",o),alert(Be(o,"发布失败,请重试"))}finally{T(!1)}},[m,f,b,Y,s]),a=r.useCallback(()=>{const L=[["账号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(ue=>ue.map(me=>`"${String(me).replace(/"/g,'""')}"`).join(",")).join(` +`),X=new Blob(["\uFEFF"+L],{type:"text/csv;charset=utf-8"}),F=URL.createObjectURL(X),P=document.createElement("a");P.href=F,P.download="批量铺货模板.csv",document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(F)},[]),n=r.useCallback(()=>{y(o=>({...o,cookie_id:s||o.cookie_id})),p(!0)},[s]),h=r.useCallback(()=>{v(o=>({...o,cookie_id:s||o.cookie_id})),d(!0)},[s]),q=r.useCallback(async o=>{if(!(o?s:b.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");D();const L=new AbortController;H.current=L;const X=++z.current;S(!0);try{const F=await new Promise((ue,me)=>{const Ce=Q=>ue(Q),re=Q=>me(Q);navigator.geolocation.getCurrentPosition(Ce,re,{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})});if(L.signal.aborted||X!==z.current)return;const P=await Mt(F.coords.longitude,F.coords.latitude,{signal:L.signal});if(L.signal.aborted||X!==z.current)return;if(!P.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");o?(R(P),k(P[0])):(W(P),U(P[0]))}catch(F){if(L.signal.aborted||X!==z.current)return;if(typeof F=="object"&&F!==null&&"code"in F){const P=F;alert(P.code===P.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")}else alert(Be(F,"获取发货地失败"))}finally{X===z.current&&(H.current=null,S(!1))}},[D,b.cookie_id,s,k,R]);return{selectedAccount:s,setSelectedAccount:l,loading:A,publishing:Z,showEditModal:G,setShowEditModal:E,showAddModal:M,setShowAddModal:p,showPublishModal:B,setShowPublishModal:d,locationLoading:j,publishLocations:V,setPublishLocations:W,publishLocation:Y,setPublishLocation:U,selectedItem:$,editForm:C,setEditForm:se,addForm:g,setAddForm:y,publishForm:b,setPublishForm:v,publishImagePreviews:x,handleSync:te,handleEdit:oe,handleSaveEdit:le,handleDelete:de,handleAddItem:xe,handlePublishItem:ve,downloadPublishTemplate:a,openAddModal:n,openPublishModal:h,locateForPublish:q}},Qt=s=>{const l=String(s||"").trim();return l?/^[¥¥]/.test(l)?l:`¥${l}`:"-"},ls=({onConfigureDelivery:s})=>{const[l,i]=r.useState([]),[m,u]=r.useState([]),[f,R]=r.useState([]),[k,A]=r.useState(""),[I,Z]=r.useState(""),T=r.useRef(0),G=r.useRef(0),E=r.useCallback(async()=>{const t=++T.current,c=await Ze();t===T.current&&i(c)},[]),M=r.useCallback(async()=>{const t=++G.current,c=await Je();t===G.current&&u(c)},[]),p=Ht({selectedAccount:k,loadItems:E,loadShippingRules:M}),{showBatchModal:B,batchLoading:d,batchPhase:j,batchFile:S,setBatchFile:V,batchImagesZip:W,setBatchImagesZip:Y,batchCategoryKeyword:U,setBatchCategoryKeyword:$,batchCategoryLoading:K,batchFallbackCategory:C,setBatchFallbackCategory:se,batchPreview:g,batchDetail:y,recentBatch:b,setRecentBatch:v,batchLocations:x,batchLocation:ae,batchPublishIntervalSeconds:H,setBatchPublishIntervalSeconds:z,setBatchLocations:D,setBatchLocation:te,openBatchModal:oe,handleRecommendBatchCategory:le,openRecentBatchResult:de,handlePreviewBatch:xe,handleStartBatch:ve,handleCancelBatch:a,abandonBatchPreview:n,closeBatchModal:h,handleRetryBatchFailed:q}=p,o=Xt({selectedAccount:k,setSelectedAccount:A,setItems:i,loadItems:E,loadShippingRules:M,onConfigureDelivery:s,setBatchLocations:D,setBatchLocation:te}),{loading:N,publishing:L,showEditModal:X,setShowEditModal:F,showAddModal:P,setShowAddModal:ue,showPublishModal:me,setShowPublishModal:Ce,locationLoading:re,publishLocations:Q,setPublishLocations:at,publishLocation:lt,setPublishLocation:Le,selectedItem:Ae,editForm:ee,setEditForm:Ne,addForm:O,setAddForm:he,publishForm:w,setPublishForm:J,publishImagePreviews:Ee,handleSync:rt,handleEdit:nt,handleSaveEdit:it,handleDelete:ct,handleAddItem:ot,handlePublishItem:dt,downloadPublishTemplate:xt,openAddModal:ut,openPublishModal:mt,locateForPublish:Me}=o;r.useEffect(()=>{const t=new AbortController,c=++T.current,_=++G.current;let ge=!0;return Promise.all([Et({signal:t.signal}),Ze(void 0,{signal:t.signal}),Je({signal:t.signal}),st(20,{signal:t.signal})]).then(([ne,pt,gt,$e])=>{if(!ge||t.signal.aborted||c!==T.current||_!==G.current)return;R(ne),i(pt),u(gt);const bt=$e.find(Ie=>["running","canceling"].includes(Ie.status))||$e.find(Ie=>Ie.status!=="preview");v(bt||null)}).catch(ne=>{t.signal.aborted||console.error("加载商品配置失败:",ne)}),(()=>{ge=!1,t.abort()})},[]);const ht=t=>m.filter(c=>c.cookie_id===t.cookie_id&&c.item_id===t.item_id).length>0?m.filter(c=>c.cookie_id===t.cookie_id&&c.item_id===t.item_id):m.filter(c=>c.cookie_id===t.cookie_id&&!c.item_id),Re=r.useMemo(()=>new Map(f.map(t=>[t.id,t])),[f]),Fe=r.useMemo(()=>I?l.filter(t=>t.cookie_id===I):l,[I,l]),pe=t=>{const c=Re.get(t),_=(c==null?void 0:c.remark)||(c==null?void 0:c.nickname);return _?`${_} · ${t.slice(0,6)}`:`账号 ${t.slice(0,8)}`},Ge=t=>{const c=Re.get(t);return(c==null?void 0:c.remark)||(c==null?void 0:c.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(jt,{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:I,onChange:(t=>Z(t.target.value)),children:[e.jsx("option",{value:"",children:"全部账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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(De,{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:k,onChange:(t=>A(t.target.value)),children:[e.jsx("option",{value:"",children:"请选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.id))]})]})]}),e.jsxs("button",{onClick:rt,disabled:N||!k,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(Se,{className:`w-4 h-4 ${N?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ut,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(Te,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:mt,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(Pe,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:(()=>void oe()),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(_e,{className:"w-4 h-4"}),b&&["running","canceling"].includes(b.status)?"继续批量任务":"批量铺货"]}),b&&!["running","canceling"].includes(b.status)&&e.jsx("button",{onClick:(()=>void de()),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:[Fe.map(t=>{const c=ht(t),_=c.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:(()=>nt(t)),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(vt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:(()=>ct(t)),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(Nt,{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:[t.item_image?e.jsx("img",{src:t.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(wt,{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:Qt(t.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:t.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:Ge(t.cookie_id),children:[e.jsx(De,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:Ge(t.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: ",t.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${_?"text-emerald-600":"text-amber-600"}`,children:[_?e.jsx(Ue,{className:"w-3 h-3"}):e.jsx(_t,{className:"w-3 h-3"}),_?`${c.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:(()=>s(t)),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${_?"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(kt,{className:"w-3.5 h-3.5"}),_?"查看发货规则":"关联发货规则"]}),e.jsx(Ct,{className:"w-3.5 h-3.5"})]})})]},`${t.cookie_id}-${t.item_id}`)}),Fe.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(It,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),I?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),X&&Ae&&we.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: ",Ae.item_id]})]}),e.jsx("button",{onClick:(()=>F(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(be,{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:ee.item_title||"",onChange:(t=>Ne({...ee,item_title:t.target.value}))}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:ee.item_price||"",onChange:(t=>Ne({...ee,item_price:t.target.value}))}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:ee.item_category||"",onChange:(t=>Ne({...ee,item_category:t.target.value}))}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:ee.item_description||"",onChange:(t=>Ne({...ee,item_description:t.target.value}))})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:it,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(St,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),P&&we.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:(()=>ue(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(be,{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:O.cookie_id,onChange:(t=>he({...O,cookie_id:t.target.value})),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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:O.item_id,onChange:(t=>he({...O,item_id:t.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:O.item_price,onChange:(t=>he({...O,item_price:t.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:O.item_title,onChange:(t=>he({...O,item_title:t.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:O.item_image,onChange:(t=>he({...O,item_image:t.target.value}))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:ot,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(Te,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),me&&we.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:(()=>Ce(!1)),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(be,{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:w.cookie_id,onChange:(t=>{J({...w,cookie_id:t.target.value}),at([]),Le(null)}),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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:w.title,onChange:(t=>J({...w,title:t.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:w.quantity,onChange:(t=>J({...w,quantity:t.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:w.description,onChange:(t=>J({...w,description:t.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:w.price,onChange:(t=>J({...w,price:t.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:w.original_price,onChange:(t=>J({...w,original_price:t.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:w.postage_mode,onChange:(t=>J({...w,postage_mode:t.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:"无需邮寄"})]})]})]}),w.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:w.postage,onChange:(t=>J({...w,postage:t.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:re||!w.cookie_id,onClick:(()=>void Me(!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(ze,{className:"h-4 w-4"}),re?"定位中...":"获取当前位置"]})]}),Q.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,Q.indexOf(lt))),onChange:(t=>Le(Q[Number(t.target.value)]||null)),children:Q.map((t,c)=>e.jsx("option",{value:String(c),children:[t.province,t.city,t.area,t.poi_name].filter(Boolean).join(" ")},`${t.division_id}-${t.poi_id}-${c}`))})]}),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(_e,{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:w.images.length?"已选择 "+w.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:(t=>J({...w,images:Array.from(t.target.files||[]).slice(0,9)}))})]}),Ee.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:Ee.map(t=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:t.url,alt:"",className:"w-full h-full object-cover"})},t.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:L,onClick:dt,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(Pe,{className:"w-4 h-4"}),L?"正在发布...":"发布到闲鱼"]})})]})}),document.body),B&&we.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 h()),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(be,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx(Yt,{phase:j}),j==="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:xt,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:k,onChange:(t=>{A(t.target.value),D([]),te(null)}),children:[e.jsx("option",{value:"",children:"选择账号"}),f.map(t=>e.jsx("option",{value:t.id,children:pe(t.id)},t.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(Oe,{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:U,onChange:(t=>$(t.target.value)),onKeyDown:(t=>{t.key==="Enter"&&(t.preventDefault(),le())})})]}),e.jsxs("button",{type:"button",disabled:!k||!U.trim()||K,onClick:(()=>void le()),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(Oe,{className:"h-4 w-4"}),K?"匹配中...":"获取类目"]})]}),C.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(Ue,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:C.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",C.catId," · 频道 ",C.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:(()=>se({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(be,{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:re||!k,onClick:(()=>void Me(!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(ze,{className:"h-4 w-4"}),re?"定位中...":"获取当前位置"]})]}),x.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,x.indexOf(ae))),onChange:(t=>te(x[Number(t.target.value)]||null)),children:x.map((t,c)=>e.jsx("option",{value:String(c),children:[t.province,t.city,t.area,t.poi_name].filter(Boolean).join(" ")},`${t.division_id}-${t.poi_id}-${c}`))})]}),e.jsx("div",{className:"rounded-xl border border-violet-200 bg-violet-50 p-4 space-y-2",children:e.jsxs("label",{className:"flex items-center justify-between gap-4",htmlFor:"batch-publish-interval",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-extrabold text-gray-900",children:"商品发布强制间隔"}),e.jsx("span",{className:"mt-1 block text-xs text-violet-800",children:"图片会提前上传,只有最终发布请求之间至少等待该时间。"})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("input",{id:"batch-publish-interval",type:"number",min:1,max:3600,step:1,inputMode:"numeric",className:"ios-input w-24 rounded-xl bg-white px-3 py-2 text-right",value:H,onChange:(t=>z(Math.min(3600,Math.max(1,Number(t.target.value)||1))))}),e.jsx("span",{className:"text-sm font-bold text-violet-900",children:"秒"})]})]})}),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(_e,{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:S?S.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:(t=>{var c;return V(((c=t.target.files)==null?void 0:c[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(_e,{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:W?W.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:(t=>{var c;return Y(((c=t.target.files)==null?void 0:c[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(([t,c,_])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:t}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${c==="每个商品都要填"?"text-red-600":c==="可以留空"?"text-gray-500":"text-amber-700"}`,children:c}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:_})]},t))})]})})]})]}),j==="preview"&&g&&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:g.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:g.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:g.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:g.rows.map(t=>{var c,_,ge,ne;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.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 ${t.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:t.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:t.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",t.price||"-"," / ",t.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:((c=t.category)==null?void 0:c.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((_=t.category)==null?void 0:_.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((ge=t.images)==null?void 0:ge.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((ne=t.errors)==null?void 0:ne.join(";"))||"-"})]},t.row_no)})})]})})]}),(j==="running"||j==="done")&&y&&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 ${Ye(y.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:We(y.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:y.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:y.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:y.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:y.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:y.rows.map(t=>{var c,_;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.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 ${Ye(t.status)}`,children:We(t.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:t.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:((c=t.category)==null?void 0:c.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((_=t.category)==null?void 0:_.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:t.item_url?e.jsx("a",{href:t.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:t.item_id}):t.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:t.error_message||"-"})]},t.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[j==="upload"&&e.jsxs("button",{disabled:d||!S||!k,onClick:xe,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(Se,{className:`w-4 h-4 ${d?"animate-spin":""}`}),d?"正在预检...":"开始预检"]}),j==="preview"&&g&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:d,onClick:(()=>void n()),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:d||g.valid<=0,onClick:ve,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(Pe,{className:"w-4 h-4"}),d?"启动中...":`确认发布 ${g.valid} 个商品`]})]}),(j==="running"||j==="done")&&y&&e.jsxs("div",{className:"flex gap-3 w-full",children:[y.status==="running"?e.jsx("button",{disabled:d,onClick:a,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):y.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/${y.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:"下载结果"}),y.retryable>0&&!["running","canceling"].includes(y.status)&&e.jsxs("button",{disabled:d,onClick:q,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(Se,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(y.status)&&e.jsx("button",{onClick:(()=>{h(),E(),M()}),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)]})};export{ls as default}; diff --git a/internal/webui/static/assets/Notifications-DHwrazHy.js b/internal/webui/static/assets/Notifications-DHwrazHy.js new file mode 100644 index 0000000..80b336c --- /dev/null +++ b/internal/webui/static/assets/Notifications-DHwrazHy.js @@ -0,0 +1 @@ +import{j as e,b as _e,a as d}from"./react-vendor-l-BBvuKH.js";import{ai as ee,ah as se,aj as Ne,u as K,e as W,L as I,w as ve,y as ke,t as Q,X as te,z as ae,F as ne,o as we,R as Se,N as Ce}from"./icons-vendor-Bgrth_9N.js";import{g as le,p as re,b as oe,e as Te}from"./index-WrujSo30.js";import"./vendor-cRYyTeIw.js";const H=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],G=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},ie=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),a=H.some(n=>String(s[n]??"").trim()!=="");return{...s,use_custom_smtp:t?G(s.use_custom_smtp,!1):a}},ce=(s,t)=>{const a={...s,use_custom_smtp:!0};for(const n of H)String(a[n]??"").trim()===""&&t[n]!==void 0&&(a[n]=t[n]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=G(a.smtp_use_tls,!0),a.smtp_use_ssl=G(a.smtp_use_ssl,!1),a},de=s=>{const t=ie(s),a={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(a.use_custom_smtp)for(const n of H)a[n]=t[n];return a},B={bark:{label:"Bark",icon:W,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:K,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:K,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:K,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:Ne,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:se,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:ee,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},pe=[{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:"后台任务或系统级异常"}],Y=()=>({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),Pe=s=>!s||s.length===0?"全部事件":s.map(t=>{var a;return((a=pe.find(n=>n.value===t))==null?void 0:a.label)||t}).join("、"),Ee=(s,t)=>{const a=s.type==="email"?ie({...s.config||{}}):null,n=a?a.use_custom_smtp===!0?ce(a,t):a:{...s.config||{}};return{name:s.name,type:s.type,enabled:s.enabled,config:n,event_types:s.event_types||[]}},Me=s=>{const a=B[s.type].fields.find(n=>n.required&&!String(s.config[n.key]||"").trim());if(a)return`请填写 ${a.label}`;if(!s.name.trim())return"请填写渠道名称";if(s.type==="email"){const n=de(s.config);if(n.use_custom_smtp){const k=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([h])=>!String(n[h]||"").trim());if(k)return`请填写 ${k[1]}`}}return""},qe=s=>({name:s.name.trim(),type:s.type,config:s.type==="email"?de(s.config):s.config,event_types:s.event_types,enabled:s.enabled}),g=(s,t)=>s===t,F=(s,t)=>s instanceof Error&&s.message?s.message:t,Le=({channels:s,testingId:t,onEdit:a,onDelete:n,onToggleEnabled:b,onTest:k})=>{const h=r=>s.find(o=>o.id===r.currentTarget.dataset.channelId)||null,_=r=>{const o=h(r);o&&b(o)},S=r=>{const o=h(r);o&&k(o)},E=r=>{const o=h(r);o&&a(o)},j=r=>{const o=h(r);o&&n(o)},M=r=>{const o=B[r.type]||B.webhook,P=o.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(P,{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:r.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:o.label}),!r.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:o.fields.map(x=>{var w;return(w=r.config)==null?void 0:w[x.key]}).filter(Boolean).map((x,w)=>e.jsx("span",{className:"mr-3",children:String(x).length>40?`${String(x).slice(0,40)}…`:String(x)},w))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Pe(r.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{"data-channel-id":r.id,onClick:_,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${r.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:r.enabled?"启用中":"已停用"}),e.jsxs("button",{"data-channel-id":r.id,onClick:S,disabled:t===r.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:[t===r.id?e.jsx(I,{className:"w-3 h-3 animate-spin"}):e.jsx(se,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{"data-channel-id":r.id,onClick:E,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(ve,{className:"w-4 h-4"})}),e.jsx("button",{"data-channel-id":r.id,onClick:j,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(ke,{className:"w-4 h-4"})})]})]},r.id)};return s.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(W,{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(M)})},Re=({selectedEvents:s,onToggleEvent:t})=>{const a=n=>{const b=n.currentTarget.dataset.event;b&&t(b)};return 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:pe.map(n=>{const b=s.includes(n.value);return e.jsxs("button",{type:"button","data-event":n.value,onClick:a,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(Q,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${b?"text-brand":"text-gray-800"}`,children:n.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:n.description})]},n.value)})})]})},Ae=({showModal:s,editing:t,form:a,setForm:n,smtp:b,showChannelSmtpPassword:k,setShowChannelSmtpPassword:h,saving:_,onClose:S,onSave:E})=>{const j=B[a.type],M=l=>n(p=>({...p,name:l.target.value})),r=l=>{const p=l.currentTarget.dataset.type;p&&n(N=>({...N,type:p,config:{}}))},o=l=>{const p=l.currentTarget.dataset.field;p&&n(N=>({...N,config:{...N.config,[p]:l.target.value}}))},P=()=>n(l=>({...l,config:l.config.use_custom_smtp===!0?{...l.config,use_custom_smtp:!1}:ce(l.config,b)})),x=l=>n(p=>({...p,config:{...p.config,smtp_use_tls:l.target.checked,smtp_use_ssl:l.target.checked?!1:p.config.smtp_use_ssl}})),w=l=>n(p=>({...p,config:{...p.config,smtp_use_ssl:l.target.checked,smtp_use_tls:l.target.checked?!1:p.config.smtp_use_tls}})),U=l=>n(p=>({...p,event_types:p.event_types.includes(l)?p.event_types.filter(N=>N!==l):[...p.event_types,l]})),O=()=>n(l=>({...l,enabled:!l.enabled})),z=()=>h(l=>!l),J=(l,p)=>e.jsx("li",{children:l},p);return s?_e.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:t?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:S,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(te,{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:a.name,onChange:M,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(B).map(l=>{const p=B[l],N=p.icon,q=a.type===l;return e.jsxs("button",{"data-type":l,type:"button",onClick:r,className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${q?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(N,{className:`w-5 h-5 ${q?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${q?"text-brand":"text-gray-600"}`,children:p.label})]},l)})})]}),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(W,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",j.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:j.guide.steps.map(J)}),j.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:j.guide.urlFormat})]}),j.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",j.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:j.fields.map(l=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[l.label,l.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{"data-field":l.key,type:l.type==="password"?"password":l.type==="number"?"number":"text",value:String(a.config[l.key]||""),onChange:o,placeholder:l.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),l.help&&e.jsx("p",{className:"text-xs text-gray-500",children:l.help})]},l.key))}),a.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:a.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:P,className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${a.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 ${a.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),a.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",{"data-field":"smtp_server",type:"text",value:String(a.config.smtp_server||""),onChange:o,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",{"data-field":"smtp_port",type:"number",value:String(a.config.smtp_port||587),onChange:o,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",{"data-field":"smtp_user",type:"email",value:String(a.config.smtp_user||""),onChange:o,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",{"data-field":"smtp_password",type:k?"text":"password",value:String(a.config.smtp_password||""),onChange:o,placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:z,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:k?e.jsx(ae,{className:"w-4 h-4"}):e.jsx(ne,{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",{"data-field":"smtp_from_name",type:"text",value:String(a.config.smtp_from_name||""),onChange:o,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",{"data-field":"smtp_from_address",type:"email",value:String(a.config.smtp_from_address||""),onChange:o,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:a.config.smtp_use_tls!==!1,onChange:x}),"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:a.config.smtp_use_ssl===!0,onChange:w}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsx(Re,{selectedEvents:a.event_types,onToggleEvent:U}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:O,className:`relative w-11 h-6 rounded-full transition-colors ${a.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 ${a.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:S,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:E,disabled:_,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[_?e.jsx(I,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),_?"保存中...":"保存"]})]})]})}),document.body):null},Be=({smtp:s,setSmtp:t,smtpSaving:a,showPassword:n,setShowPassword:b,onSave:k})=>{const h=r=>{const o=r.currentTarget.dataset.field;o&&t(P=>({...P,[o]:r.target.value}))},_=r=>{t(o=>({...o,smtp_port:parseInt(r.target.value,10)||587}))},S=r=>{t(o=>({...o,smtp_use_tls:r.target.checked,smtp_use_ssl:r.target.checked?!1:o.smtp_use_ssl}))},E=r=>{t(o=>({...o,smtp_use_ssl:r.target.checked,smtp_use_tls:r.target.checked?!1:o.smtp_use_tls}))},j=r=>{t(o=>({...o,smtp_password:r.target.value}))},M=()=>b(r=>!r);return 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(ee,{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",{"data-field":"smtp_server",type:"text",value:s.smtp_server||"",onChange:h,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:s.smtp_port||587,onChange:_,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",{"data-field":"smtp_user",type:"email",value:s.smtp_user||"",onChange:h,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:n?"text":"password",value:s.smtp_password||"",onChange:j,placeholder:s.smtp_password_configured?"已配置,如需替换请输入新密码":"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:M,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:n?e.jsx(ae,{className:"w-4 h-4"}):e.jsx(ne,{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",{"data-field":"smtp_from_name",type:"text",value:s.smtp_from_name||"",onChange:h,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",{"data-field":"smtp_from_address",type:"email",value:s.smtp_from_address||s.smtp_user||"",onChange:h,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:s.smtp_use_tls!==!1,onChange:S}),"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:s.smtp_use_ssl===!0,onChange:E}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:k,disabled:a,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a?e.jsx(I,{className:"w-4 h-4 animate-spin"}):e.jsx(we,{className:"w-4 h-4"}),a?"保存中...":"保存 SMTP 配置"]})]})},$e=s=>{if(Array.isArray(s))return s.filter(Boolean);if(typeof s!="string"||!s.trim())return[];try{const t=JSON.parse(s);if(Array.isArray(t))return t.filter(Boolean)}catch{}return s.split(/[,\s;]+/).map(t=>t.trim()).filter(Boolean)},me=s=>{const t=Array.from(new Set((s||[]).filter(Boolean)));return t.length>0?JSON.stringify(t):""},Fe=s=>{const t={},a=s.type==="ding_talk"?"dingtalk":s.type==="lark"?"feishu":s.type;return{id:String(s.id),name:s.name,type:a,config:t,event_types:$e(s.event_types),enabled:s.enabled}},Oe=async s=>{const t=await le("/api/v1/notifications/channels",void 0,s);return{success:!0,data:(Array.isArray(t)?t:t.data||t.channels||[]).map(Fe)}},De=async(s,t)=>oe("/api/v1/notifications/channels",{...s,config:JSON.stringify(s.config),event_types:me(s.event_types)},t),Z=async(s,t,a)=>{const n={...t};return"config"in t&&(n.config=JSON.stringify(t.config)),"event_types"in t&&(n.event_types=me(t.event_types)),re(`/api/v1/notifications/channels/${s}`,n,a)},We=async(s,t)=>Te(`/api/v1/notifications/channels/${s}`,void 0,t),Ie=async(s,t)=>oe(`/api/v1/notifications/channels/${s}/test`,{},t),Ue=s=>{const t={...s};if("renewal_log_retention_days"in t){const a=Number(t.renewal_log_retention_days);t.renewal_log_retention_days=Number.isFinite(a)?a:10}return t},ze=async s=>{const t=await le("/api/v1/settings/system",void 0,s);return Ue(t.data||t.settings||t)},Je=async(s,t)=>re("/api/v1/settings/system",s,t),Xe=s=>{const[t,a]=d.useState([]),[n,b]=d.useState(!0),[k,h]=d.useState(!1),[_,S]=d.useState(null),[E,j]=d.useState(!1),[M,r]=d.useState(""),[o,P]=d.useState(null),[x,w]=d.useState({}),[U,O]=d.useState(!1),[z,J]=d.useState(!1),[l,p]=d.useState(!1),[N,q]=d.useState(Y),$=d.useRef(0),X=d.useRef(null),C=d.useRef(0),R=d.useRef(null),y=d.useRef(0),T=d.useRef(null),A=d.useRef(null),f=d.useCallback((i,c)=>{P({type:i,text:c}),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{A.current=null,P(null)},3e3)},[]),L=d.useCallback(async()=>{var m;const i=++$.current;(m=X.current)==null||m.abort();const c=new AbortController;X.current=c,b(!0);try{const u=await Oe({signal:c.signal});if(!g(i,$.current))return;a(u.data||[])}catch(u){g(i,$.current)&&!c.signal.aborted&&console.error("加载通知渠道失败",u)}finally{g(i,$.current)&&b(!1)}},[]),V=d.useCallback(async()=>{var m;const i=++C.current;(m=R.current)==null||m.abort();const c=new AbortController;R.current=c;try{const u=await ze({signal:c.signal});g(i,C.current)&&w(u||{})}catch(u){g(i,C.current)&&!c.signal.aborted&&console.error("加载 SMTP 配置失败",u)}},[]);d.useEffect(()=>{var i;return L(),s?V():(C.current+=1,(i=R.current)==null||i.abort(),w({})),(()=>{var c,m;$.current+=1,(c=X.current)==null||c.abort(),C.current+=1,(m=R.current)==null||m.abort()})},[s,L,V]),d.useEffect(()=>(()=>{A.current!==null&&window.clearTimeout(A.current)}),[]);const ue=d.useCallback(()=>{S(null),q(Y()),p(!1),h(!0)},[]),xe=d.useCallback(i=>{S(i),q(Ee(i,x)),p(!1),h(!0)},[x]),ge=d.useCallback(()=>{var i;y.current+=1,(i=T.current)==null||i.abort(),j(!1),h(!1)},[]),he=d.useCallback(async()=>{var u;const i=Me(N);if(i){f("error",i);return}const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m,j(!0);try{const v=qe(N);if(_?await Z(_.id,v,{signal:m.signal}):await De(v,{signal:m.signal}),!g(c,y.current)||(h(!1),await L(),!g(c,y.current)))return;f("success",_?"已更新":"已创建")}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"保存失败"))}finally{g(c,y.current)&&j(!1)}},[_,N,L,f]),be=d.useCallback(async i=>{var u;if(!confirm(`确认删除渠道「${i.name}」吗?已绑定该渠道的账号会自动解绑。`))return;const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m;try{if(await We(i.id,{signal:m.signal}),!g(c,y.current)||(await L(),!g(c,y.current)))return;f("success","已删除")}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"删除失败"))}},[L,f]),ye=d.useCallback(async i=>{var u;const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m;try{if(await Z(i.id,{enabled:!i.enabled},{signal:m.signal}),!g(c,y.current))return;a(v=>v.map(D=>D.id===i.id?{...D,enabled:!D.enabled}:D))}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"切换失败"))}},[f]),fe=d.useCallback(async i=>{var u;r(i.id);const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m;try{await Ie(i.id,{signal:m.signal}),g(c,y.current)&&f("success","测试通知已发送,请检查对应渠道")}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"发送失败"))}finally{g(c,y.current)&&r("")}},[f]),je=d.useCallback(async()=>{var m;const i=++C.current;(m=R.current)==null||m.abort();const c=new AbortController;R.current=c,O(!0);try{const u={smtp_server:x.smtp_server||"",smtp_port:x.smtp_port||587,smtp_user:x.smtp_user||"",smtp_from_name:x.smtp_from_name||"",smtp_from_address:x.smtp_from_address||x.smtp_user||"",smtp_use_tls:x.smtp_use_tls!==!1,smtp_use_ssl:x.smtp_use_ssl===!0};Object.prototype.hasOwnProperty.call(x,"smtp_password")&&(u.smtp_password=x.smtp_password),await Je(u,{signal:c.signal}),g(i,C.current)&&f("success","SMTP 配置已保存")}catch(u){g(i,C.current)&&!c.signal.aborted&&f("error",F(u,"保存失败"))}finally{g(i,C.current)&&O(!1)}},[f,x]);return{channels:t,loading:n,showModal:k,editing:_,saving:E,testingId:M,toast:o,smtp:x,smtpSaving:U,showSmtpPassword:z,showChannelSmtpPassword:l,form:N,setForm:q,setSmtp:w,setShowSmtpPassword:J,setShowChannelSmtpPassword:p,loadChannels:L,openCreate:ue,openEdit:xe,closeModal:ge,showToast:f,handleSave:he,handleDelete:be,handleToggleEnabled:ye,handleTest:fe,handleSaveSmtp:je}},Ve=({isAdmin:s=!1})=>{const t=Xe(s);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:t.loadChannels,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(Se,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:t.openCreate,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(Ce,{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(W,{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:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),t.loading?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(I,{className:"w-8 h-8 text-brand animate-spin"})}):e.jsx(Le,{channels:t.channels,testingId:t.testingId,onEdit:t.openEdit,onDelete:t.handleDelete,onToggleEnabled:t.handleToggleEnabled,onTest:t.handleTest}),s&&e.jsx(Be,{smtp:t.smtp,setSmtp:t.setSmtp,smtpSaving:t.smtpSaving,showPassword:t.showSmtpPassword,setShowPassword:t.setShowSmtpPassword,onSave:t.handleSaveSmtp}),e.jsx(Ae,{showModal:t.showModal,editing:t.editing,form:t.form,setForm:t.setForm,smtp:t.smtp,showChannelSmtpPassword:t.showChannelSmtpPassword,setShowChannelSmtpPassword:t.setShowChannelSmtpPassword,saving:t.saving,onClose:t.closeModal,onSave:t.handleSave}),t.toast&&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 ${t.toast.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[t.toast.type==="success"?e.jsx(Q,{className:"w-4 h-4"}):e.jsx(te,{className:"w-4 h-4"}),t.toast.text]})]})};export{Ve as default}; diff --git a/internal/webui/static/assets/Notifications-DUiNU4WL.js b/internal/webui/static/assets/Notifications-DUiNU4WL.js deleted file mode 100644 index 86b26a9..0000000 --- a/internal/webui/static/assets/Notifications-DUiNU4WL.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,b as _e,r as d}from"./react-vendor-C_od1ZSF.js";import{ai as ee,ah as se,aj as Ne,u as K,e as W,L as I,w as ve,y as ke,t as Q,X as te,z as ae,F as ne,o as we,R as Se,N as Ce}from"./icons-vendor-DwxdQTKt.js";import{g as le,p as re,a as oe,d as Te}from"./index-zEvleK2K.js";const H=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],G=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},ie=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),a=H.some(n=>String(s[n]??"").trim()!=="");return{...s,use_custom_smtp:t?G(s.use_custom_smtp,!1):a}},ce=(s,t)=>{const a={...s,use_custom_smtp:!0};for(const n of H)String(a[n]??"").trim()===""&&t[n]!==void 0&&(a[n]=t[n]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=G(a.smtp_use_tls,!0),a.smtp_use_ssl=G(a.smtp_use_ssl,!1),a},de=s=>{const t=ie(s),a={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(a.use_custom_smtp)for(const n of H)a[n]=t[n];return a},B={bark:{label:"Bark",icon:W,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:K,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:K,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:K,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:Ne,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:se,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:ee,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},pe=[{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:"后台任务或系统级异常"}],Y=()=>({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),Pe=s=>!s||s.length===0?"全部事件":s.map(t=>{var a;return((a=pe.find(n=>n.value===t))==null?void 0:a.label)||t}).join("、"),Ee=(s,t)=>{const a=s.type==="email"?ie({...s.config||{}}):null,n=a?a.use_custom_smtp===!0?ce(a,t):a:{...s.config||{}};return{name:s.name,type:s.type,enabled:s.enabled,config:n,event_types:s.event_types||[]}},Me=s=>{const a=B[s.type].fields.find(n=>n.required&&!String(s.config[n.key]||"").trim());if(a)return`请填写 ${a.label}`;if(!s.name.trim())return"请填写渠道名称";if(s.type==="email"){const n=de(s.config);if(n.use_custom_smtp){const k=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([h])=>!String(n[h]||"").trim());if(k)return`请填写 ${k[1]}`}}return""},qe=s=>({name:s.name.trim(),type:s.type,config:s.type==="email"?de(s.config):s.config,event_types:s.event_types,enabled:s.enabled}),g=(s,t)=>s===t,F=(s,t)=>s instanceof Error&&s.message?s.message:t,Le=({channels:s,testingId:t,onEdit:a,onDelete:n,onToggleEnabled:b,onTest:k})=>{const h=r=>s.find(o=>o.id===r.currentTarget.dataset.channelId)||null,_=r=>{const o=h(r);o&&b(o)},S=r=>{const o=h(r);o&&k(o)},E=r=>{const o=h(r);o&&a(o)},j=r=>{const o=h(r);o&&n(o)},M=r=>{const o=B[r.type]||B.webhook,P=o.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(P,{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:r.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:o.label}),!r.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:o.fields.map(x=>{var w;return(w=r.config)==null?void 0:w[x.key]}).filter(Boolean).map((x,w)=>e.jsx("span",{className:"mr-3",children:String(x).length>40?`${String(x).slice(0,40)}…`:String(x)},w))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Pe(r.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{"data-channel-id":r.id,onClick:_,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${r.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:r.enabled?"启用中":"已停用"}),e.jsxs("button",{"data-channel-id":r.id,onClick:S,disabled:t===r.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:[t===r.id?e.jsx(I,{className:"w-3 h-3 animate-spin"}):e.jsx(se,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{"data-channel-id":r.id,onClick:E,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(ve,{className:"w-4 h-4"})}),e.jsx("button",{"data-channel-id":r.id,onClick:j,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(ke,{className:"w-4 h-4"})})]})]},r.id)};return s.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(W,{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(M)})},Re=({selectedEvents:s,onToggleEvent:t})=>{const a=n=>{const b=n.currentTarget.dataset.event;b&&t(b)};return 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:pe.map(n=>{const b=s.includes(n.value);return e.jsxs("button",{type:"button","data-event":n.value,onClick:a,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(Q,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${b?"text-brand":"text-gray-800"}`,children:n.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:n.description})]},n.value)})})]})},Ae=({showModal:s,editing:t,form:a,setForm:n,smtp:b,showChannelSmtpPassword:k,setShowChannelSmtpPassword:h,saving:_,onClose:S,onSave:E})=>{const j=B[a.type],M=l=>n(p=>({...p,name:l.target.value})),r=l=>{const p=l.currentTarget.dataset.type;p&&n(N=>({...N,type:p,config:{}}))},o=l=>{const p=l.currentTarget.dataset.field;p&&n(N=>({...N,config:{...N.config,[p]:l.target.value}}))},P=()=>n(l=>({...l,config:l.config.use_custom_smtp===!0?{...l.config,use_custom_smtp:!1}:ce(l.config,b)})),x=l=>n(p=>({...p,config:{...p.config,smtp_use_tls:l.target.checked,smtp_use_ssl:l.target.checked?!1:p.config.smtp_use_ssl}})),w=l=>n(p=>({...p,config:{...p.config,smtp_use_ssl:l.target.checked,smtp_use_tls:l.target.checked?!1:p.config.smtp_use_tls}})),U=l=>n(p=>({...p,event_types:p.event_types.includes(l)?p.event_types.filter(N=>N!==l):[...p.event_types,l]})),O=()=>n(l=>({...l,enabled:!l.enabled})),z=()=>h(l=>!l),J=(l,p)=>e.jsx("li",{children:l},p);return s?_e.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:t?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:S,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(te,{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:a.name,onChange:M,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(B).map(l=>{const p=B[l],N=p.icon,q=a.type===l;return e.jsxs("button",{"data-type":l,type:"button",onClick:r,className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${q?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(N,{className:`w-5 h-5 ${q?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${q?"text-brand":"text-gray-600"}`,children:p.label})]},l)})})]}),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(W,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",j.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:j.guide.steps.map(J)}),j.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:j.guide.urlFormat})]}),j.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",j.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:j.fields.map(l=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[l.label,l.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{"data-field":l.key,type:l.type==="password"?"password":l.type==="number"?"number":"text",value:String(a.config[l.key]||""),onChange:o,placeholder:l.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),l.help&&e.jsx("p",{className:"text-xs text-gray-500",children:l.help})]},l.key))}),a.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:a.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:P,className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${a.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 ${a.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),a.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",{"data-field":"smtp_server",type:"text",value:String(a.config.smtp_server||""),onChange:o,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",{"data-field":"smtp_port",type:"number",value:String(a.config.smtp_port||587),onChange:o,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",{"data-field":"smtp_user",type:"email",value:String(a.config.smtp_user||""),onChange:o,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",{"data-field":"smtp_password",type:k?"text":"password",value:String(a.config.smtp_password||""),onChange:o,placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:z,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:k?e.jsx(ae,{className:"w-4 h-4"}):e.jsx(ne,{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",{"data-field":"smtp_from_name",type:"text",value:String(a.config.smtp_from_name||""),onChange:o,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",{"data-field":"smtp_from_address",type:"email",value:String(a.config.smtp_from_address||""),onChange:o,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:a.config.smtp_use_tls!==!1,onChange:x}),"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:a.config.smtp_use_ssl===!0,onChange:w}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsx(Re,{selectedEvents:a.event_types,onToggleEvent:U}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:O,className:`relative w-11 h-6 rounded-full transition-colors ${a.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 ${a.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:S,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:E,disabled:_,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[_?e.jsx(I,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),_?"保存中...":"保存"]})]})]})}),document.body):null},Be=({smtp:s,setSmtp:t,smtpSaving:a,showPassword:n,setShowPassword:b,onSave:k})=>{const h=r=>{const o=r.currentTarget.dataset.field;o&&t(P=>({...P,[o]:r.target.value}))},_=r=>{t(o=>({...o,smtp_port:parseInt(r.target.value,10)||587}))},S=r=>{t(o=>({...o,smtp_use_tls:r.target.checked,smtp_use_ssl:r.target.checked?!1:o.smtp_use_ssl}))},E=r=>{t(o=>({...o,smtp_use_ssl:r.target.checked,smtp_use_tls:r.target.checked?!1:o.smtp_use_tls}))},j=r=>{t(o=>({...o,smtp_password:r.target.value}))},M=()=>b(r=>!r);return 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(ee,{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",{"data-field":"smtp_server",type:"text",value:s.smtp_server||"",onChange:h,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:s.smtp_port||587,onChange:_,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",{"data-field":"smtp_user",type:"email",value:s.smtp_user||"",onChange:h,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:n?"text":"password",value:s.smtp_password||"",onChange:j,placeholder:s.smtp_password_configured?"已配置,如需替换请输入新密码":"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:M,className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:n?e.jsx(ae,{className:"w-4 h-4"}):e.jsx(ne,{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",{"data-field":"smtp_from_name",type:"text",value:s.smtp_from_name||"",onChange:h,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",{"data-field":"smtp_from_address",type:"email",value:s.smtp_from_address||s.smtp_user||"",onChange:h,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:s.smtp_use_tls!==!1,onChange:S}),"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:s.smtp_use_ssl===!0,onChange:E}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:k,disabled:a,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a?e.jsx(I,{className:"w-4 h-4 animate-spin"}):e.jsx(we,{className:"w-4 h-4"}),a?"保存中...":"保存 SMTP 配置"]})]})},$e=s=>{if(Array.isArray(s))return s.filter(Boolean);if(typeof s!="string"||!s.trim())return[];try{const t=JSON.parse(s);if(Array.isArray(t))return t.filter(Boolean)}catch{}return s.split(/[,\s;]+/).map(t=>t.trim()).filter(Boolean)},me=s=>{const t=Array.from(new Set((s||[]).filter(Boolean)));return t.length>0?JSON.stringify(t):""},Fe=s=>{const t={},a=s.type==="ding_talk"?"dingtalk":s.type==="lark"?"feishu":s.type;return{id:String(s.id),name:s.name,type:a,config:t,event_types:$e(s.event_types),enabled:s.enabled}},Oe=async s=>{const t=await le("/api/v1/notifications/channels",void 0,s);return{success:!0,data:(Array.isArray(t)?t:t.data||t.channels||[]).map(Fe)}},De=async(s,t)=>oe("/api/v1/notifications/channels",{...s,config:JSON.stringify(s.config),event_types:me(s.event_types)},t),Z=async(s,t,a)=>{const n={...t};return"config"in t&&(n.config=JSON.stringify(t.config)),"event_types"in t&&(n.event_types=me(t.event_types)),re(`/api/v1/notifications/channels/${s}`,n,a)},We=async(s,t)=>Te(`/api/v1/notifications/channels/${s}`,void 0,t),Ie=async(s,t)=>oe(`/api/v1/notifications/channels/${s}/test`,{},t),Ue=s=>{const t={...s};if("renewal_log_retention_days"in t){const a=Number(t.renewal_log_retention_days);t.renewal_log_retention_days=Number.isFinite(a)?a:10}return t},ze=async s=>{const t=await le("/api/v1/settings/system",void 0,s);return Ue(t.data||t.settings||t)},Je=async(s,t)=>re("/api/v1/settings/system",s,t),Xe=s=>{const[t,a]=d.useState([]),[n,b]=d.useState(!0),[k,h]=d.useState(!1),[_,S]=d.useState(null),[E,j]=d.useState(!1),[M,r]=d.useState(""),[o,P]=d.useState(null),[x,w]=d.useState({}),[U,O]=d.useState(!1),[z,J]=d.useState(!1),[l,p]=d.useState(!1),[N,q]=d.useState(Y),$=d.useRef(0),X=d.useRef(null),C=d.useRef(0),R=d.useRef(null),y=d.useRef(0),T=d.useRef(null),A=d.useRef(null),f=d.useCallback((i,c)=>{P({type:i,text:c}),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{A.current=null,P(null)},3e3)},[]),L=d.useCallback(async()=>{var m;const i=++$.current;(m=X.current)==null||m.abort();const c=new AbortController;X.current=c,b(!0);try{const u=await Oe({signal:c.signal});if(!g(i,$.current))return;a(u.data||[])}catch(u){g(i,$.current)&&!c.signal.aborted&&console.error("加载通知渠道失败",u)}finally{g(i,$.current)&&b(!1)}},[]),V=d.useCallback(async()=>{var m;const i=++C.current;(m=R.current)==null||m.abort();const c=new AbortController;R.current=c;try{const u=await ze({signal:c.signal});g(i,C.current)&&w(u||{})}catch(u){g(i,C.current)&&!c.signal.aborted&&console.error("加载 SMTP 配置失败",u)}},[]);d.useEffect(()=>{var i;return L(),s?V():(C.current+=1,(i=R.current)==null||i.abort(),w({})),(()=>{var c,m;$.current+=1,(c=X.current)==null||c.abort(),C.current+=1,(m=R.current)==null||m.abort()})},[s,L,V]),d.useEffect(()=>(()=>{A.current!==null&&window.clearTimeout(A.current)}),[]);const ue=d.useCallback(()=>{S(null),q(Y()),p(!1),h(!0)},[]),xe=d.useCallback(i=>{S(i),q(Ee(i,x)),p(!1),h(!0)},[x]),ge=d.useCallback(()=>{var i;y.current+=1,(i=T.current)==null||i.abort(),j(!1),h(!1)},[]),he=d.useCallback(async()=>{var u;const i=Me(N);if(i){f("error",i);return}const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m,j(!0);try{const v=qe(N);if(_?await Z(_.id,v,{signal:m.signal}):await De(v,{signal:m.signal}),!g(c,y.current)||(h(!1),await L(),!g(c,y.current)))return;f("success",_?"已更新":"已创建")}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"保存失败"))}finally{g(c,y.current)&&j(!1)}},[_,N,L,f]),be=d.useCallback(async i=>{var u;if(!confirm(`确认删除渠道「${i.name}」吗?已绑定该渠道的账号会自动解绑。`))return;const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m;try{if(await We(i.id,{signal:m.signal}),!g(c,y.current)||(await L(),!g(c,y.current)))return;f("success","已删除")}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"删除失败"))}},[L,f]),ye=d.useCallback(async i=>{var u;const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m;try{if(await Z(i.id,{enabled:!i.enabled},{signal:m.signal}),!g(c,y.current))return;a(v=>v.map(D=>D.id===i.id?{...D,enabled:!D.enabled}:D))}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"切换失败"))}},[f]),fe=d.useCallback(async i=>{var u;r(i.id);const c=++y.current;(u=T.current)==null||u.abort();const m=new AbortController;T.current=m;try{await Ie(i.id,{signal:m.signal}),g(c,y.current)&&f("success","测试通知已发送,请检查对应渠道")}catch(v){g(c,y.current)&&!m.signal.aborted&&f("error",F(v,"发送失败"))}finally{g(c,y.current)&&r("")}},[f]),je=d.useCallback(async()=>{var m;const i=++C.current;(m=R.current)==null||m.abort();const c=new AbortController;R.current=c,O(!0);try{const u={smtp_server:x.smtp_server||"",smtp_port:x.smtp_port||587,smtp_user:x.smtp_user||"",smtp_from_name:x.smtp_from_name||"",smtp_from_address:x.smtp_from_address||x.smtp_user||"",smtp_use_tls:x.smtp_use_tls!==!1,smtp_use_ssl:x.smtp_use_ssl===!0};Object.prototype.hasOwnProperty.call(x,"smtp_password")&&(u.smtp_password=x.smtp_password),await Je(u,{signal:c.signal}),g(i,C.current)&&f("success","SMTP 配置已保存")}catch(u){g(i,C.current)&&!c.signal.aborted&&f("error",F(u,"保存失败"))}finally{g(i,C.current)&&O(!1)}},[f,x]);return{channels:t,loading:n,showModal:k,editing:_,saving:E,testingId:M,toast:o,smtp:x,smtpSaving:U,showSmtpPassword:z,showChannelSmtpPassword:l,form:N,setForm:q,setSmtp:w,setShowSmtpPassword:J,setShowChannelSmtpPassword:p,loadChannels:L,openCreate:ue,openEdit:xe,closeModal:ge,showToast:f,handleSave:he,handleDelete:be,handleToggleEnabled:ye,handleTest:fe,handleSaveSmtp:je}},He=({isAdmin:s=!1})=>{const t=Xe(s);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:t.loadChannels,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(Se,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:t.openCreate,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(Ce,{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(W,{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:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),t.loading?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(I,{className:"w-8 h-8 text-brand animate-spin"})}):e.jsx(Le,{channels:t.channels,testingId:t.testingId,onEdit:t.openEdit,onDelete:t.handleDelete,onToggleEnabled:t.handleToggleEnabled,onTest:t.handleTest}),s&&e.jsx(Be,{smtp:t.smtp,setSmtp:t.setSmtp,smtpSaving:t.smtpSaving,showPassword:t.showSmtpPassword,setShowPassword:t.setShowSmtpPassword,onSave:t.handleSaveSmtp}),e.jsx(Ae,{showModal:t.showModal,editing:t.editing,form:t.form,setForm:t.setForm,smtp:t.smtp,showChannelSmtpPassword:t.showChannelSmtpPassword,setShowChannelSmtpPassword:t.setShowChannelSmtpPassword,saving:t.saving,onClose:t.closeModal,onSave:t.handleSave}),t.toast&&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 ${t.toast.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[t.toast.type==="success"?e.jsx(Q,{className:"w-4 h-4"}):e.jsx(te,{className:"w-4 h-4"}),t.toast.text]})]})};export{He as default}; diff --git a/internal/webui/static/assets/OrderList-CXbMt2fz.js b/internal/webui/static/assets/OrderList-CXbMt2fz.js new file mode 100644 index 0000000..98c64c9 --- /dev/null +++ b/internal/webui/static/assets/OrderList-CXbMt2fz.js @@ -0,0 +1 @@ +import{j as e,b as X,a}from"./react-vendor-l-BBvuKH.js";import{f as Z}from"./dateTime-DDi7rqpW.js";import{U as re,I as ie,X as H,J as ce,R as K,N as oe,O as ee,m as se,E as de,F as xe,V as me,y as ue,h as he,g as ge,o as pe}from"./icons-vendor-Bgrth_9N.js";import{g as U,o as be,c as ye,d as le,b as Y,p as fe,e as ne}from"./index-WrujSo30.js";import"./vendor-cRYyTeIw.js";const ve=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],je=s=>{const t=typeof s=="object"&&s!==null?s:{},i=Array.isArray(t.results)?t.results:[];return{total:Number(t.total||0),success_count:Number(t.success_count||0),failed_count:Number(t.failed_count||0),results:i.map(Ne)}},Ne=s=>{const t=typeof s=="object"&&s!==null?s:{};return{order_id:String(t.order_id||"unknown"),success:t.success===!0,message:String(t.message||"")}},we=s=>(s==null?void 0:s.results.filter(_e))||[],_e=s=>!s.success,ke=(s,t)=>s!==null&&!t,Ce=s=>{if(!s)return"请选择订单文件";const t=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(t)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},T=(s,t)=>s===t,Se=(s,t)=>s instanceof Error&&s.message?s.message:t,Ee=({filter:s,onFilterChange:t,accountFilter:i,onAccountFilterChange:u,accounts:b,accountName:m,searchText:h,onSearchChange:N})=>{const g=l=>t(l.currentTarget.dataset.status||"all"),f=l=>u(l.target.value),y=l=>N(l.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:ve.map(l=>e.jsx("button",{"data-status":l.key,onClick:g,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===l.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:l.label},l.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(re,{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:i,onChange:f,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:"全部账号"}),b.map(l=>e.jsx("option",{value:l.id,children:m(l.id)},l.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(ie,{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:h,onChange:y,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Oe=s=>{const t=m=>{var h;s.setImportFile(((h=m.target.files)==null?void 0:h[0])||null)},i=()=>s.closeImportModal(),u=()=>void s.handleImportOrders(),b=()=>void s.handleRetryImport();return s.showImportModal?X.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:i,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:t,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 格式"})]}),s.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(ce,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:s.importFile.name})]})}),s.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:s.importError}),e.jsx("button",{type:"button",onClick:b,disabled:s.importing||!s.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.importResult&&s.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:["导入完成:成功 ",s.importResult.success_count," 条,失败 ",s.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:we(s.importResult).map((m,h)=>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}-${h}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:i,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:u,disabled:!s.importFile||s.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:s.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},Me=180,te=5e3,Ie=async s=>U("/api/v1/accounts/details",void 0,s),Fe=async(s,t)=>U("/api/v1/items",void 0,t),Re=s=>{const t=String(s||"");return t==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(t)?t:"unknown"},De=async(s,t,i=1,u=20,b,m)=>{const h={page:i,page_size:u};s&&(h.cookie_id=s),t&&t!=="all"&&(h.status=t),b!=null&&b.trim()&&(h.search=b.trim());const N=await U("/api/v1/orders",h,m),g=be(N,["data","result"])||{},y=(Array.isArray(g.orders)?g.orders:ye(g.data,["data","orders","items"])).map(l=>({...l,id:l.id||l.order_id,status:Re(l.status||l.order_status),quantity:Number(l.quantity||1)}));return{success:!0,data:y,total:g.total||y.length,page:g.page||i,page_size:g.page_size||u,total_pages:g.total_pages||1}},$e=async(s,t)=>fe(`/api/v1/orders/${s}`,t),Ae=async s=>ne(`/api/v1/orders/${s}`),Le=async(s,t,i)=>{const u=new FormData;s&&u.append("cookie_id",s),t&&u.append("status",t);const b=await le("/api/v1/orders/refresh",u,i),m=Me,h=500;let N=0;try{for(;N{const S=()=>{globalThis.clearTimeout(R),n(new Error("请求已取消"))},R=globalThis.setTimeout(()=>{var k;(k=i==null?void 0:i.signal)==null||k.removeEventListener("abort",S),l()},y);i!=null&&i.signal&&(i.signal.aborted?S():i.signal.addEventListener("abort",S,{once:!0}))}),N+=1}}finally{}const g=await Pe(b.job_id);if(g.status==="succeeded"&&g.result)return g.result;throw g.status==="failed"?new Error(g.error_message||"订单刷新任务失败"):new Error("订单刷新任务等待超时,已请求取消")},Pe=async s=>{try{await Te(s,{timeoutMs:te})}catch{}return U(`/api/v1/orders/refresh/${s}`,void 0,{timeoutMs:te})},Te=async(s,t)=>ne(`/api/v1/orders/refresh/${s}`,void 0,t),qe=async s=>Y(`/api/v1/orders/${s}/refresh`),ze=async(s,t)=>Y("/api/v1/orders/manual-ship",{order_ids:s,ship_mode:t}),Be=async(s,t)=>s instanceof FormData?le("/api/v1/orders/import",s,t):Y("/api/v1/orders/import",s,t),Je=(s={pageSize:20})=>{const[t,i]=a.useState([]),[u,b]=a.useState([]),[m,h]=a.useState([]),[N,g]=a.useState("all"),[f,y]=a.useState(""),[l,n]=a.useState(""),[S,R]=a.useState(""),[k,E]=a.useState(1),[_,L]=a.useState(1),[I,c]=a.useState(!1),w=a.useRef(0),v=a.useRef(null),F=a.useRef(null),$=a.useCallback(async()=>{var j;const d=++w.current;(j=v.current)==null||j.abort();const x=new AbortController;v.current=x,c(!0);try{const O=await De(f||void 0,N,k,s.pageSize,S,{signal:x.signal});if(!T(d,w.current))return;i(O.data),L(O.total_pages)}catch(O){T(d,w.current)&&!x.signal.aborted&&console.error("加载订单失败:",O)}finally{T(d,w.current)&&c(!1)}},[f,S,N,s.pageSize,k]);a.useEffect(()=>{const d=window.setTimeout(()=>{E(1),R(l.trim())},300);return(()=>window.clearTimeout(d))},[l]),a.useEffect(()=>($(),(()=>{var d;w.current+=1,(d=v.current)==null||d.abort()})),[$]),a.useEffect(()=>{var x;const d=new AbortController;return(x=F.current)==null||x.abort(),F.current=d,Promise.all([Ie({signal:d.signal}),Fe(void 0,{signal:d.signal})]).then(([j,O])=>{d.signal.aborted||(h(j),b(O))}).catch(j=>{d.signal.aborted||console.error("加载订单辅助数据失败:",j)}),(()=>d.abort())},[]);const C=a.useMemo(()=>new Map(m.map(d=>[d.id,d])),[m]),D=a.useMemo(()=>{const d={};return u.forEach(x=>{x.item_id&&(d[`${x.cookie_id}:${x.item_id}`]=x.item_title||x.item_id)}),d},[u]),J=a.useCallback(d=>{const x=C.get(d),j=(x==null?void 0:x.remark)||(x==null?void 0:x.nickname);return j?`${j} · ${d.slice(0,6)}`:`账号 ${d.slice(0,8)}`},[C]),G=a.useCallback(d=>{const x=C.get(d);return(x==null?void 0:x.remark)||(x==null?void 0:x.nickname)||"未命名账号"},[C]),q=a.useCallback((d,x,j)=>{if(j!=null&&j.trim())return j;const O=D[`${d}:${x}`];if(O)return O;const M=u.find(z=>{if(!j||!z.item_title)return!1;const B=j.toLowerCase(),P=z.item_title.toLowerCase();return P.includes(B)||B.includes(P)});return(M==null?void 0:M.item_title)||"未知商品"},[D,u]);return{orders:t,items:u,accounts:m,filter:N,setFilter:g,accountFilter:f,setAccountFilter:y,searchText:l,setSearchText:n,page:k,setPage:E,totalPages:_,loading:I,loadOrders:$,accountName:J,accountNickname:G,getItemNameById:q}},Ge=s=>{const[t,i]=a.useState(!1),[u,b]=a.useState(null),[m,h]=a.useState(null),[N,g]=a.useState(!1),[f,y]=a.useState(""),l=a.useRef(0),n=a.useRef(null);a.useEffect(()=>(()=>{var _;l.current+=1,(_=n.current)==null||_.abort()}),[]);const S=a.useCallback(()=>{b(null),h(null),y(""),i(!0)},[]),R=a.useCallback(()=>{var _;l.current+=1,(_=n.current)==null||_.abort(),g(!1),i(!1),b(null),h(null),y("")},[]),k=a.useCallback(async()=>{var w;if(!ke(u,N))return;const _=u;if(!_)return;const L=Ce(_);if(L){y(L);return}const I=++l.current;(w=n.current)==null||w.abort();const c=new AbortController;n.current=c,g(!0),h(null),y("");try{const v=new FormData;v.append("file",_);const F=je(await Be(v,{signal:c.signal}));if(!T(I,l.current))return;h(F),b(null),await s(),F.failed_count===0&&T(I,l.current)&&(alert(`订单导入成功,共 ${F.success_count} 条`),i(!1),h(null))}catch(v){T(I,l.current)&&!c.signal.aborted&&y(Se(v,"导入失败,请检查文件格式"))}finally{T(I,l.current)&&g(!1)}},[u,N,s]),E=a.useCallback(async()=>{await k()},[k]);return{showImportModal:t,importFile:u,setImportFile:b,importResult:m,importing:N,importError:f,openImportModal:S,closeImportModal:R,handleImportOrders:k,handleRetryImport:E}},W=(s,t)=>s instanceof Error?s.message:t,Ue=({orders:s,page:t,accountFilter:i,filter:u,setPage:b,loadOrders:m})=>{const[h,N]=a.useState(!1),[g,f]=a.useState(null),[y,l]=a.useState(!1),[n,S]=a.useState(null),[R,k]=a.useState(!1),[E,_]=a.useState(""),[L,I]=a.useState(!1),[c,w]=a.useState(null),[v,F]=a.useState(null),[$,C]=a.useState(null),D=a.useRef(0),J=a.useCallback(async()=>{const o=++D.current;try{const p=await Le(i||void 0,u);if(o!==D.current||(await m(),o!==D.current))return;p.message&&alert(p.message)}catch(p){if(o!==D.current)return;console.error("同步订单失败:",p),alert(W(p,"同步失败,请重试"))}},[i,u,m]),G=a.useCallback(o=>{_(o),w(null),k(!0)},[]),q=a.useCallback(async o=>{var p;I(!0),w(null);try{const A=(p=(await ze([E],o)).results)==null?void 0:p[0];A!=null&&A.success?(w({success:!0,message:A.message}),m()):w({success:!1,message:(A==null?void 0:A.message)||"发货失败"})}catch(Q){w({success:!1,message:W(Q,"请求失败")})}finally{I(!1)}},[m,E]),d=a.useCallback(o=>{f(o),N(!0)},[]),x=a.useCallback(o=>{S({...o}),l(!0)},[]),j=a.useCallback(o=>{S(p=>p&&{...p,...o})},[]),O=a.useCallback(async()=>{if(n!=null&&n.order_id)try{const o={};n.status!==void 0&&(o.order_status=n.status),n.buyer_id!==void 0&&(o.buyer_id=n.buyer_id),n.amount!==void 0&&(o.amount=n.amount),n.receiver_name!==void 0&&(o.receiver_name=n.receiver_name),n.receiver_phone!==void 0&&(o.receiver_phone=n.receiver_phone),n.receiver_address!==void 0&&(o.receiver_address=n.receiver_address),n.item_id!==void 0&&(o.item_id=n.item_id),n.quantity!==void 0&&(o.quantity=n.quantity),n.item_title!==void 0&&(o.item_title=n.item_title),await $e(n.order_id,o),l(!1),S(null),await m()}catch(o){console.error("更新订单失败:",o),alert("更新失败,请重试")}},[n,m]),M=a.useCallback(async o=>{F(o);try{const p=await qe(o);p.success?await m():alert(p.message||"同步失败")}catch(p){console.error("同步订单失败:",p),alert(W(p,"同步失败,请重试"))}finally{F(null)}},[m]),z=a.useCallback(async o=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){C(o);try{await Ae(o),s.length===1&&t>1?b(p=>p-1):await m()}catch(p){console.error("删除订单失败:",p),alert(W(p,"删除失败,请重试")),await m()}finally{C(null)}}},[m,s.length,t,b]),B=a.useCallback(()=>N(!1),[]),P=a.useCallback(()=>l(!1),[]),V=a.useCallback(()=>{k(!1),w(null)},[]);return{showDetailModal:h,selectedOrder:g,showEditModal:y,editingOrder:n,showShipModal:R,shipOrderId:E,shipLoading:L,shipResult:c,syncingOrderId:v,deletingOrderId:$,handleSync:J,handleShip:G,executeShip:q,handleViewDetail:d,handleEdit:x,handleSaveEdit:O,updateEditingOrder:j,handleSyncSingle:M,handleDelete:z,closeDetailModal:B,closeEditModal:P,closeShipModal:V}},ae=({status:s})=>{const t={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"},i={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:i[s]||s})},Ke=()=>{const s=Je(),t=Ge(s.loadOrders),{orders:i,accounts:u,filter:b,setFilter:m,accountFilter:h,setAccountFilter:N,searchText:g,setSearchText:f,page:y,setPage:l,totalPages:n,loading:S,loadOrders:R,accountName:k,accountNickname:E,getItemNameById:_}=s,L=Ue({orders:i,page:y,accountFilter:h,filter:b,setPage:l,loadOrders:R}),{showDetailModal:I,selectedOrder:c,showEditModal:w,editingOrder:v,showShipModal:F,shipLoading:$,shipResult:C,syncingOrderId:D,deletingOrderId:J,handleSync:G,handleShip:q,executeShip:d,handleViewDetail:x,handleEdit:j,handleSaveEdit:O,updateEditingOrder:M,handleSyncSingle:z,handleDelete:B,closeDetailModal:P,closeEditModal:V,closeShipModal:o}=L,p=r=>{m(r),l(1),f("")},Q=r=>{N(r),l(1)},A=r=>{f(r),l(1)};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:R,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(K,{className:`w-5 h-5 ${S?"animate-spin":""}`})}),e.jsxs("button",{onClick:t.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(oe,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:G,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(ee,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Ee,{filter:b,onFilterChange:p,accountFilter:h,onAccountFilterChange:Q,accounts:u,accountName:k,searchText:g,onSearchChange:A}),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:i.map(r=>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:r.item_image?e.jsx("img",{src:r.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(se,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:_(r.cookie_id,r.item_id,r.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:E(r.cookie_id),children:[e.jsx(re,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:E(r.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",r.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",r.quantity," • ",Z(r.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:r.buyer_id}),r.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:r.receiver_name})]}),r.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:r.receiver_phone})]}),r.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:r.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:r.amount?`¥${r.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(ae,{status:r.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[r.status==="pending_ship"&&e.jsx("button",{onClick:(()=>q(r.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=${r.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(de,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>x(r)),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(xe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>j(r)),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(me,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>z(r.order_id)),disabled:D===r.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(K,{className:`w-4 h-4 ${D===r.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>B(r.order_id)),disabled:J===r.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(ue,{className:"w-4 h-4"})})]})]},r.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:["第 ",y," 页 / 共 ",n," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:y<=1,onClick:(()=>l(r=>r-1)),"aria-label":"上一页",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(he,{className:"w-5 h-5"})}),e.jsx("button",{disabled:y>=n,onClick:(()=>l(r=>r+1)),"aria-label":"下一页",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(ge,{className:"w-5 h-5"})})]})]})]}),I&&c&&X.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:P,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:E(c.cookie_id),children:E(c.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(ae,{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:Z(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:_(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:P,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:(()=>{P(),q(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),e.jsx(Oe,{...t}),F&&X.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:o,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:(()=>d("status_only")),disabled:$,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(ee,{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:(()=>d("full_delivery")),disabled:$,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(se,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),$&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(K,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),C&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${C.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[C.success?"✓ ":"✗ ",C.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:o,className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:C!=null&&C.success?"完成":"取消"})})]})}),document.body),w&&v&&X.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,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:v.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:v.status,onChange:(r=>M({status:r.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:v.buyer_id,onChange:(r=>M({buyer_id:r.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:v.amount,onChange:(r=>M({amount:r.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:v.receiver_name||"",onChange:(r=>M({receiver_name:r.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:v.receiver_phone||"",onChange:(r=>M({receiver_phone:r.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:v.receiver_address||"",onChange:(r=>M({receiver_address:r.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:v.item_title||"",onChange:(r=>M({item_title:r.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:V,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:O,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(pe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})};export{Ke as default}; diff --git a/internal/webui/static/assets/OrderList-Dma_R9-T.js b/internal/webui/static/assets/OrderList-Dma_R9-T.js deleted file mode 100644 index 93e6e9f..0000000 --- a/internal/webui/static/assets/OrderList-Dma_R9-T.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,b as X,r as a}from"./react-vendor-C_od1ZSF.js";import{f as Z}from"./dateTime-DDi7rqpW.js";import{U as re,I as ie,X as H,J as ce,R as K,N as oe,O as ee,m as se,E as de,F as xe,V as me,y as ue,h as he,g as ge,o as pe}from"./icons-vendor-DwxdQTKt.js";import{g as U,o as be,c as ye,b as le,a as Y,p as fe,d as ne}from"./index-zEvleK2K.js";const ve=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],je=s=>{const t=typeof s=="object"&&s!==null?s:{},i=Array.isArray(t.results)?t.results:[];return{total:Number(t.total||0),success_count:Number(t.success_count||0),failed_count:Number(t.failed_count||0),results:i.map(Ne)}},Ne=s=>{const t=typeof s=="object"&&s!==null?s:{};return{order_id:String(t.order_id||"unknown"),success:t.success===!0,message:String(t.message||"")}},we=s=>(s==null?void 0:s.results.filter(_e))||[],_e=s=>!s.success,ke=(s,t)=>s!==null&&!t,Ce=s=>{if(!s)return"请选择订单文件";const t=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(t)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},T=(s,t)=>s===t,Se=(s,t)=>s instanceof Error&&s.message?s.message:t,Ee=({filter:s,onFilterChange:t,accountFilter:i,onAccountFilterChange:u,accounts:b,accountName:m,searchText:h,onSearchChange:N})=>{const g=l=>t(l.currentTarget.dataset.status||"all"),f=l=>u(l.target.value),y=l=>N(l.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:ve.map(l=>e.jsx("button",{"data-status":l.key,onClick:g,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===l.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:l.label},l.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(re,{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:i,onChange:f,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:"全部账号"}),b.map(l=>e.jsx("option",{value:l.id,children:m(l.id)},l.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(ie,{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:h,onChange:y,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Oe=s=>{const t=m=>{var h;s.setImportFile(((h=m.target.files)==null?void 0:h[0])||null)},i=()=>s.closeImportModal(),u=()=>void s.handleImportOrders(),b=()=>void s.handleRetryImport();return s.showImportModal?X.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:i,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:t,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 格式"})]}),s.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(ce,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:s.importFile.name})]})}),s.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:s.importError}),e.jsx("button",{type:"button",onClick:b,disabled:s.importing||!s.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.importResult&&s.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:["导入完成:成功 ",s.importResult.success_count," 条,失败 ",s.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:we(s.importResult).map((m,h)=>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}-${h}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:i,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:u,disabled:!s.importFile||s.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:s.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},Me=180,te=5e3,Ie=async s=>U("/api/v1/accounts/details",void 0,s),Fe=async(s,t)=>U("/api/v1/items",void 0,t),Re=s=>{const t=String(s||"");return t==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(t)?t:"unknown"},De=async(s,t,i=1,u=20,b,m)=>{const h={page:i,page_size:u};s&&(h.cookie_id=s),t&&t!=="all"&&(h.status=t),b!=null&&b.trim()&&(h.search=b.trim());const N=await U("/api/v1/orders",h,m),g=be(N,["data","result"])||{},y=(Array.isArray(g.orders)?g.orders:ye(g.data,["data","orders","items"])).map(l=>({...l,id:l.id||l.order_id,status:Re(l.status||l.order_status),quantity:Number(l.quantity||1)}));return{success:!0,data:y,total:g.total||y.length,page:g.page||i,page_size:g.page_size||u,total_pages:g.total_pages||1}},$e=async(s,t)=>fe(`/api/v1/orders/${s}`,t),Ae=async s=>ne(`/api/v1/orders/${s}`),Le=async(s,t,i)=>{const u=new FormData;s&&u.append("cookie_id",s),t&&u.append("status",t);const b=await le("/api/v1/orders/refresh",u,i),m=Me,h=500;let N=0;try{for(;N{const S=()=>{globalThis.clearTimeout(R),n(new Error("请求已取消"))},R=globalThis.setTimeout(()=>{var k;(k=i==null?void 0:i.signal)==null||k.removeEventListener("abort",S),l()},y);i!=null&&i.signal&&(i.signal.aborted?S():i.signal.addEventListener("abort",S,{once:!0}))}),N+=1}}finally{}const g=await Pe(b.job_id);if(g.status==="succeeded"&&g.result)return g.result;throw g.status==="failed"?new Error(g.error_message||"订单刷新任务失败"):new Error("订单刷新任务等待超时,已请求取消")},Pe=async s=>{try{await Te(s,{timeoutMs:te})}catch{}return U(`/api/v1/orders/refresh/${s}`,void 0,{timeoutMs:te})},Te=async(s,t)=>ne(`/api/v1/orders/refresh/${s}`,void 0,t),qe=async s=>Y(`/api/v1/orders/${s}/refresh`),ze=async(s,t)=>Y("/api/v1/orders/manual-ship",{order_ids:s,ship_mode:t}),Be=async(s,t)=>s instanceof FormData?le("/api/v1/orders/import",s,t):Y("/api/v1/orders/import",s,t),Je=(s={pageSize:20})=>{const[t,i]=a.useState([]),[u,b]=a.useState([]),[m,h]=a.useState([]),[N,g]=a.useState("all"),[f,y]=a.useState(""),[l,n]=a.useState(""),[S,R]=a.useState(""),[k,E]=a.useState(1),[_,L]=a.useState(1),[I,c]=a.useState(!1),w=a.useRef(0),v=a.useRef(null),F=a.useRef(null),$=a.useCallback(async()=>{var j;const d=++w.current;(j=v.current)==null||j.abort();const x=new AbortController;v.current=x,c(!0);try{const O=await De(f||void 0,N,k,s.pageSize,S,{signal:x.signal});if(!T(d,w.current))return;i(O.data),L(O.total_pages)}catch(O){T(d,w.current)&&!x.signal.aborted&&console.error("加载订单失败:",O)}finally{T(d,w.current)&&c(!1)}},[f,S,N,s.pageSize,k]);a.useEffect(()=>{const d=window.setTimeout(()=>{E(1),R(l.trim())},300);return(()=>window.clearTimeout(d))},[l]),a.useEffect(()=>($(),(()=>{var d;w.current+=1,(d=v.current)==null||d.abort()})),[$]),a.useEffect(()=>{var x;const d=new AbortController;return(x=F.current)==null||x.abort(),F.current=d,Promise.all([Ie({signal:d.signal}),Fe(void 0,{signal:d.signal})]).then(([j,O])=>{d.signal.aborted||(h(j),b(O))}).catch(j=>{d.signal.aborted||console.error("加载订单辅助数据失败:",j)}),(()=>d.abort())},[]);const C=a.useMemo(()=>new Map(m.map(d=>[d.id,d])),[m]),D=a.useMemo(()=>{const d={};return u.forEach(x=>{x.item_id&&(d[`${x.cookie_id}:${x.item_id}`]=x.item_title||x.item_id)}),d},[u]),J=a.useCallback(d=>{const x=C.get(d),j=(x==null?void 0:x.remark)||(x==null?void 0:x.nickname);return j?`${j} · ${d.slice(0,6)}`:`账号 ${d.slice(0,8)}`},[C]),G=a.useCallback(d=>{const x=C.get(d);return(x==null?void 0:x.remark)||(x==null?void 0:x.nickname)||"未命名账号"},[C]),q=a.useCallback((d,x,j)=>{if(j!=null&&j.trim())return j;const O=D[`${d}:${x}`];if(O)return O;const M=u.find(z=>{if(!j||!z.item_title)return!1;const B=j.toLowerCase(),P=z.item_title.toLowerCase();return P.includes(B)||B.includes(P)});return(M==null?void 0:M.item_title)||"未知商品"},[D,u]);return{orders:t,items:u,accounts:m,filter:N,setFilter:g,accountFilter:f,setAccountFilter:y,searchText:l,setSearchText:n,page:k,setPage:E,totalPages:_,loading:I,loadOrders:$,accountName:J,accountNickname:G,getItemNameById:q}},Ge=s=>{const[t,i]=a.useState(!1),[u,b]=a.useState(null),[m,h]=a.useState(null),[N,g]=a.useState(!1),[f,y]=a.useState(""),l=a.useRef(0),n=a.useRef(null);a.useEffect(()=>(()=>{var _;l.current+=1,(_=n.current)==null||_.abort()}),[]);const S=a.useCallback(()=>{b(null),h(null),y(""),i(!0)},[]),R=a.useCallback(()=>{var _;l.current+=1,(_=n.current)==null||_.abort(),g(!1),i(!1),b(null),h(null),y("")},[]),k=a.useCallback(async()=>{var w;if(!ke(u,N))return;const _=u;if(!_)return;const L=Ce(_);if(L){y(L);return}const I=++l.current;(w=n.current)==null||w.abort();const c=new AbortController;n.current=c,g(!0),h(null),y("");try{const v=new FormData;v.append("file",_);const F=je(await Be(v,{signal:c.signal}));if(!T(I,l.current))return;h(F),b(null),await s(),F.failed_count===0&&T(I,l.current)&&(alert(`订单导入成功,共 ${F.success_count} 条`),i(!1),h(null))}catch(v){T(I,l.current)&&!c.signal.aborted&&y(Se(v,"导入失败,请检查文件格式"))}finally{T(I,l.current)&&g(!1)}},[u,N,s]),E=a.useCallback(async()=>{await k()},[k]);return{showImportModal:t,importFile:u,setImportFile:b,importResult:m,importing:N,importError:f,openImportModal:S,closeImportModal:R,handleImportOrders:k,handleRetryImport:E}},W=(s,t)=>s instanceof Error?s.message:t,Ue=({orders:s,page:t,accountFilter:i,filter:u,setPage:b,loadOrders:m})=>{const[h,N]=a.useState(!1),[g,f]=a.useState(null),[y,l]=a.useState(!1),[n,S]=a.useState(null),[R,k]=a.useState(!1),[E,_]=a.useState(""),[L,I]=a.useState(!1),[c,w]=a.useState(null),[v,F]=a.useState(null),[$,C]=a.useState(null),D=a.useRef(0),J=a.useCallback(async()=>{const o=++D.current;try{const p=await Le(i||void 0,u);if(o!==D.current||(await m(),o!==D.current))return;p.message&&alert(p.message)}catch(p){if(o!==D.current)return;console.error("同步订单失败:",p),alert(W(p,"同步失败,请重试"))}},[i,u,m]),G=a.useCallback(o=>{_(o),w(null),k(!0)},[]),q=a.useCallback(async o=>{var p;I(!0),w(null);try{const A=(p=(await ze([E],o)).results)==null?void 0:p[0];A!=null&&A.success?(w({success:!0,message:A.message}),m()):w({success:!1,message:(A==null?void 0:A.message)||"发货失败"})}catch(Q){w({success:!1,message:W(Q,"请求失败")})}finally{I(!1)}},[m,E]),d=a.useCallback(o=>{f(o),N(!0)},[]),x=a.useCallback(o=>{S({...o}),l(!0)},[]),j=a.useCallback(o=>{S(p=>p&&{...p,...o})},[]),O=a.useCallback(async()=>{if(n!=null&&n.order_id)try{const o={};n.status!==void 0&&(o.order_status=n.status),n.buyer_id!==void 0&&(o.buyer_id=n.buyer_id),n.amount!==void 0&&(o.amount=n.amount),n.receiver_name!==void 0&&(o.receiver_name=n.receiver_name),n.receiver_phone!==void 0&&(o.receiver_phone=n.receiver_phone),n.receiver_address!==void 0&&(o.receiver_address=n.receiver_address),n.item_id!==void 0&&(o.item_id=n.item_id),n.quantity!==void 0&&(o.quantity=n.quantity),n.item_title!==void 0&&(o.item_title=n.item_title),await $e(n.order_id,o),l(!1),S(null),await m()}catch(o){console.error("更新订单失败:",o),alert("更新失败,请重试")}},[n,m]),M=a.useCallback(async o=>{F(o);try{const p=await qe(o);p.success?await m():alert(p.message||"同步失败")}catch(p){console.error("同步订单失败:",p),alert(W(p,"同步失败,请重试"))}finally{F(null)}},[m]),z=a.useCallback(async o=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){C(o);try{await Ae(o),s.length===1&&t>1?b(p=>p-1):await m()}catch(p){console.error("删除订单失败:",p),alert(W(p,"删除失败,请重试")),await m()}finally{C(null)}}},[m,s.length,t,b]),B=a.useCallback(()=>N(!1),[]),P=a.useCallback(()=>l(!1),[]),V=a.useCallback(()=>{k(!1),w(null)},[]);return{showDetailModal:h,selectedOrder:g,showEditModal:y,editingOrder:n,showShipModal:R,shipOrderId:E,shipLoading:L,shipResult:c,syncingOrderId:v,deletingOrderId:$,handleSync:J,handleShip:G,executeShip:q,handleViewDetail:d,handleEdit:x,handleSaveEdit:O,updateEditingOrder:j,handleSyncSingle:M,handleDelete:z,closeDetailModal:B,closeEditModal:P,closeShipModal:V}},ae=({status:s})=>{const t={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"},i={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:i[s]||s})},He=()=>{const s=Je(),t=Ge(s.loadOrders),{orders:i,accounts:u,filter:b,setFilter:m,accountFilter:h,setAccountFilter:N,searchText:g,setSearchText:f,page:y,setPage:l,totalPages:n,loading:S,loadOrders:R,accountName:k,accountNickname:E,getItemNameById:_}=s,L=Ue({orders:i,page:y,accountFilter:h,filter:b,setPage:l,loadOrders:R}),{showDetailModal:I,selectedOrder:c,showEditModal:w,editingOrder:v,showShipModal:F,shipLoading:$,shipResult:C,syncingOrderId:D,deletingOrderId:J,handleSync:G,handleShip:q,executeShip:d,handleViewDetail:x,handleEdit:j,handleSaveEdit:O,updateEditingOrder:M,handleSyncSingle:z,handleDelete:B,closeDetailModal:P,closeEditModal:V,closeShipModal:o}=L,p=r=>{m(r),l(1),f("")},Q=r=>{N(r),l(1)},A=r=>{f(r),l(1)};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:R,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(K,{className:`w-5 h-5 ${S?"animate-spin":""}`})}),e.jsxs("button",{onClick:t.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(oe,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:G,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(ee,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Ee,{filter:b,onFilterChange:p,accountFilter:h,onAccountFilterChange:Q,accounts:u,accountName:k,searchText:g,onSearchChange:A}),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:i.map(r=>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:r.item_image?e.jsx("img",{src:r.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(se,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:_(r.cookie_id,r.item_id,r.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:E(r.cookie_id),children:[e.jsx(re,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:E(r.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",r.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",r.quantity," • ",Z(r.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:r.buyer_id}),r.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:r.receiver_name})]}),r.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:r.receiver_phone})]}),r.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:r.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:r.amount?`¥${r.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(ae,{status:r.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[r.status==="pending_ship"&&e.jsx("button",{onClick:(()=>q(r.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=${r.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(de,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>x(r)),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(xe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>j(r)),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(me,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>z(r.order_id)),disabled:D===r.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(K,{className:`w-4 h-4 ${D===r.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>B(r.order_id)),disabled:J===r.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(ue,{className:"w-4 h-4"})})]})]},r.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:["第 ",y," 页 / 共 ",n," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:y<=1,onClick:(()=>l(r=>r-1)),"aria-label":"上一页",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(he,{className:"w-5 h-5"})}),e.jsx("button",{disabled:y>=n,onClick:(()=>l(r=>r+1)),"aria-label":"下一页",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(ge,{className:"w-5 h-5"})})]})]})]}),I&&c&&X.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:P,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:E(c.cookie_id),children:E(c.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(ae,{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:Z(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:_(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:P,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:(()=>{P(),q(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),e.jsx(Oe,{...t}),F&&X.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:o,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:(()=>d("status_only")),disabled:$,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(ee,{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:(()=>d("full_delivery")),disabled:$,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(se,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),$&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(K,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),C&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${C.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[C.success?"✓ ":"✗ ",C.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:o,className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:C!=null&&C.success?"完成":"取消"})})]})}),document.body),w&&v&&X.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,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:v.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:v.status,onChange:(r=>M({status:r.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:v.buyer_id,onChange:(r=>M({buyer_id:r.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:v.amount,onChange:(r=>M({amount:r.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:v.receiver_name||"",onChange:(r=>M({receiver_name:r.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:v.receiver_phone||"",onChange:(r=>M({receiver_phone:r.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:v.receiver_address||"",onChange:(r=>M({receiver_address:r.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:v.item_title||"",onChange:(r=>M({item_title:r.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:V,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:O,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(pe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})};export{He as default}; diff --git a/internal/webui/static/assets/Rules-4H5_byLi.js b/internal/webui/static/assets/Rules-4H5_byLi.js new file mode 100644 index 0000000..aff5e6c --- /dev/null +++ b/internal/webui/static/assets/Rules-4H5_byLi.js @@ -0,0 +1 @@ +import{j as e,a as o,b as Fe}from"./react-vendor-l-BBvuKH.js";import{k as Je,ae as it,af as vt,m as Nt,R as Te,N as Ye,Z as He,u as wt,n as et,I as kt,a1 as Ct,X as ke,V as ze,y as Ce,h as St,g as Rt,a6 as At,ag as $t,o as tt,ah as Mt}from"./icons-vendor-Bgrth_9N.js";import{g as Z,o as Ae,c as Ge,p as Ke,b as fe,e as Ue}from"./index-WrujSo30.js";import"./vendor-cRYyTeIw.js";const Ee=(t,a)=>t.allowed_resolutions.includes(a),Pt=(t,a)=>({runs:t.runs.filter(i=>!a||i.cookie_id===a),pending_tasks:t.pending_tasks.filter(i=>!a||i.cookie_id===a)}),Lt=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",It=({runs:t,pendingTasks:a,onResolveRun:i,onResolveDeferredTask:u})=>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(Je,{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:Lt(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:[Ee(r,"continue")&&e.jsx("button",{onClick:(()=>i(r.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Ee(r,"retry")&&e.jsx("button",{onClick:(()=>i(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Ee(r,"cancel")&&e.jsx("button",{onClick:(()=>i(r.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${r.id}`)),a.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:(()=>u(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:(()=>u(r.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${r.id}`))]})]}),Dt=async t=>Z("/api/v1/accounts/details",void 0,t),ot=async t=>Z("/api/v1/cards",void 0,t),dt=async(t,a)=>Z("/api/v1/items",void 0,a),ct=t=>t.map(a=>{var i,u;return{id:String(a.id),name:a.name||"",trigger_type:a.trigger_type||"order_paid",item_keyword:a.item_title||a.item_id||"",cookie_id:a.cookie_id||"",item_id:a.item_id||"",item_title:a.item_title||"",card_group_id:Number(((i=(a.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:i.card_id)||0),card_group_name:((u=(a.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:u.card_name)||"",priority:a.priority||100,enabled:a.enabled||!1,config_json:a.config_json||"{}",actions:(a.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:(a.actions||[]).filter(r=>r.action_type==="send_card").map(r=>{let y={};try{y=JSON.parse(r.config_json||"{}")}catch{}return{id:r.id?String(r.id):void 0,spec_name:y.spec_name||"",spec_value:y.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:y.delay_override===!0,delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}"}})}}),Ft=async()=>{const t=await Z("/api/v1/automation-rules"),a=Ge(t,["data","rules","items"]);return ct(a)},Tt=async({cookieId:t,triggerType:a,enabled:i,search:u,page:r=1,pageSize:y=10}={})=>{const A=await Z("/api/v1/automation-rules",{page:r,page_size:y,cookie_id:t||void 0,trigger_type:a||void 0,enabled:i,search:(u==null?void 0:u.trim())||void 0}),C=Ae(A,["data","result"])||{},m=ct(Ge(A,["data","rules","items"]));return{success:!0,data:m,total:Number(C.total??m.length),page:Number(C.page??r),page_size:Number(C.page_size??y),total_pages:Number(C.total_pages??(m.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(C.trigger_counts||{}).map(([I,T])=>[I,Number(T)]))}},zt=(t,a)=>{if(t!=="order_paid")return a.map((r,y)=>({...r,sort_order:r.sort_order||y+1}));const i=a.filter(r=>r.action_type==="send_card").map((r,y)=>({...r,sort_order:y+1})),u=a.filter(r=>r.action_type!=="send_card"&&r.action_type!=="confirm_shipment");return[...i,...u.map((r,y)=>({...r,sort_order:i.length+y+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:i.length+u.length+1}]},st=async t=>{const a=t.trigger_type||"order_paid",u=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[a]||"自动化规则",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"),y=t.variants&&t.variants.length>0?[...t.variants.map((m,I)=>({action_type:"send_card",card_id:m.card_id,delivery_count:m.delivery_count||1,enabled:m.enabled!==!1,sort_order:I+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}],A=zt(a,y),C={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||u||"自动化规则",trigger_type:a,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:A.map((m,I)=>({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||I+1}))};return t.id?Ke(`/api/v1/automation-rules/${t.id}`,C):fe("/api/v1/automation-rules",C)},Et=async t=>Ue(`/api/v1/automation-rules/${t}`),Ot=async()=>{const t=await Z("/api/v1/automation-issues"),a=Ae(t,["data","result"])||{};return{runs:Array.isArray(a==null?void 0:a.runs)?a.runs:[],pending_tasks:Array.isArray(a==null?void 0:a.pending_tasks)?a.pending_tasks:[]}},qt=async(t,a)=>fe(`/api/v1/automation-runs/${t}/resolve`,{resolution:a}),Vt=async(t,a)=>fe(`/api/v1/automation-pending-tasks/${t}/resolve`,{resolution:a}),Bt=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)||""}),Jt=async t=>{const a=await Z(`/api/v1/reply-rules/${t}/typed`);return Ge(a,["data","items","rules"]).map(Bt)},Gt=async t=>t?(await Jt(t)).map(i=>({id:i.id,keyword:i.keyword||"",reply_content:i.reply||"",match_type:"fuzzy",enabled:!0,item_id:i.item_id||"",type:i.type==="image"?"image":"text",image_url:i.image_url||""})):[],Kt=async(t,a)=>{const i=t.type||"text",u={keyword:t.keyword||"",reply:i==="text"&&t.reply_content||"",item_id:t.item_id||"",type:i,image_url:i==="image"&&t.image_url||""};return t.id?Ke(`/api/v1/reply-rules/${a}/typed/${t.id}`,u):fe(`/api/v1/reply-rules/${a}/items`,u)},Ut=async(t,a)=>Ue(`/api/v1/reply-rules/${a}/typed/${t}`),at=async()=>{const t=await Z("/api/v1/default-replies");return Ae(t,["data","replies","items"])||{}},Wt=async t=>{const a=await Z(`/api/v1/default-replies/${t}`),i=Ae(a,["data","result"])||{};return{cookie_id:t,enabled:i.enabled||!1,reply_content:i.reply_content||"",reply_once:i.reply_once||!1,reply_image_url:i.reply_image_url||""}},Zt=async(t,a)=>Ke(`/api/v1/default-replies/${t}`,{enabled:a.enabled??!1,reply_content:a.reply_content||"",reply_once:a.reply_once??!1,reply_image_url:a.reply_image_url||""}),Xt=async t=>Ue(`/api/v1/default-replies/${t}`),Qt=async t=>fe(`/api/v1/default-replies/${t}/clear-records`,{}),Oe=()=>({submitting:!1,result:"idle"}),qe=t=>t.submitting?t:{submitting:!0,result:"idle"},Ve=(t,a)=>({...t,submitting:!1,result:a?"success":"failure"}),rt=t=>t+1,Be=(t,a,i,u)=>t===a&&i===u,Yt=t=>{const[a,i]=o.useState([]),[u,r]=o.useState({runs:[],pending_tasks:[]}),[y,A]=o.useState([]),[C,m]=o.useState({}),[I,T]=o.useState([]),[J,w]=o.useState([]),[G,D]=o.useState([]),[v,X]=o.useState(!1),q=o.useRef(0),re=o.useRef(0),[Q,K]=o.useState(0),[le,Y]=o.useState(0),[V,H]=o.useState({}),U=o.useCallback(async()=>{const P=Promise.all([Dt(),ot(),dt(),at()]),[_,j,F,ee]=await P;T(_),w(j),D(F),m(ee),t.setSelectedAccountId(ne=>{var E;return ne||((E=_[0])==null?void 0:E.id)||""})},[t.setSelectedAccountId]),n=o.useCallback(async()=>{var ee;const P=rt(q.current);q.current=P;const _=Ot().catch(ne=>(console.warn("加载自动化异常列表失败,不阻断规则展示",ne),null)),j=await Tt({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(!Be(P,q.current,t.selectedAccountId,t.selectedAccountId))return;i(j.data),K(j.total),Y(j.total_pages),H(j.trigger_counts||{}),j.page!==t.automationPage&&((ee=t.onAutomationPageChange)==null||ee.call(t,j.page));const F=await _;Be(P,q.current,t.selectedAccountId,t.selectedAccountId)&&F&&r(F)},[t.automationPage,t.automationPageSize,t.automationStatusFilter,t.automationTriggerFilter,t.debouncedAutomationSearch,t.onAutomationPageChange,t.selectedAccountId]),$=o.useCallback(async()=>{const P=rt(re.current);re.current=P;const _=t.selectedAccountId;if(A([]),!_)return;const j=await Gt(_);Be(P,re.current,_,t.selectedAccountId)&&A(j)},[t.selectedAccountId]),R=o.useCallback(async()=>{m(await at())},[]),z=o.useCallback(async()=>{X(!0);try{t.activeTab==="automation"?await n():t.activeTab==="reply"?await $():await R()}finally{X(!1)}},[n,R,$,t.activeTab]);return{automationRules:a,automationIssues:u,replyRules:y,defaultReplies:C,accounts:I,cards:J,items:G,automationTotal:Q,automationTotalPages:le,automationTriggerCounts:V,loading:v,setLoading:X,setAutomationRules:i,setCards:w,setItems:D,loadReferenceData:U,loadAutomationRules:n,loadReplyRules:$,loadDefaultReplies:R,refresh:z}},ae={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Nt},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:vt},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:it}},Se=["order_paid","buyer_reviewed","review_missing_timeout"],Ht="亲,商品使用满意的话,麻烦给个评价,谢谢~",he=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),mt=t=>{if(!t)return{};try{const a=JSON.parse(t);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}},ce=(t,a={})=>{const i=mt(t);return JSON.stringify({after_shipped_hours:Number(i.after_shipped_hours||72),repeat_interval_hours:Number(i.repeat_interval_hours||24),max_attempts:Number(i.max_attempts||1),...a})},ye=(t,a)=>{var u;const i=((u=ae[t])==null?void 0:u.label)||"自动化规则";return a?`${i} - ${a}`:i},lt=t=>{const a=(t||"").trim();return a?Object.values(ae).some(i=>a===i.label||a.startsWith(`${i.label} -`)):!0},_e=(t,a=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:Ht,enabled:!0,sort_order:1}];const i={action_type:"send_card",card_id:a,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[i,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[i]},es=t=>{var i,u;if(t.trigger_type==="review_missing_timeout")return((u=(i=t.actions)==null?void 0:i.find(r=>r.action_type==="send_text"))==null?void 0:u.message_template)||"发送求评价文案";const a=(t.actions||[]).filter(r=>r.action_type==="send_card");return a.length?a.map(r=>r.card_name||`卡密 ${r.card_id}`).join(" / "):"未配置卡密库存"},nt=(t,a=!1)=>{const i={blue:a?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:a?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:a?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return i[t]||i.blue},ts=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Re=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",ss=t=>t===!0||t===1||t==="1",as=({selectedAccountId:t,setSelectedAccountId:a,setActiveTab:i,items:u,setAutomationRules:r,setCards:y,setItems:A,setLoading:C,loadAutomationRules:m,loadReferenceData:I,loadReplyRules:T,loadDefaultReplies:J,initialDeliveryTarget:w,onDeliveryTargetHandled:G})=>{var xe;const[D,v]=o.useState(!1),[X,q]=o.useState(!1),[re,Q]=o.useState(!1),[K,le]=o.useState(Oe),[Y,V]=o.useState(Oe),[H,U]=o.useState(Oe),[n,$]=o.useState(null),[R,z]=o.useState(null),[M,P]=o.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""}),_=o.useMemo(()=>n!=null&&n.cookie_id&&n.item_id?u.find(l=>l.cookie_id===n.cookie_id&&l.item_id===n.item_id):void 0,[n==null?void 0:n.cookie_id,n==null?void 0:n.item_id,u]),j=ss(_==null?void 0:_.is_multi_spec),F=(n==null?void 0:n.trigger_type)||"order_paid",ee=ae[F],ne=mt(n==null?void 0:n.config_json),E=(xe=n==null?void 0:n.variants)!=null&&xe.length?n.variants:[he()],W=o.useCallback((l="order_paid",d=t,b="")=>{const p=u.find(N=>N.cookie_id===d&&N.item_id===b),h=(p==null?void 0:p.item_title)||b;return{name:ye(l,h),trigger_type:l,cookie_id:d,item_id:b,item_title:(p==null?void 0:p.item_title)||"",item_keyword:h,card_group_id:0,priority:100,enabled:!0,config_json:l==="review_missing_timeout"?ce():"{}",actions:_e(l),variants:l==="review_missing_timeout"?[]:[he()]}},[u,t]),ue=o.useCallback(l=>{var b,p;const d=l.trigger_type||"order_paid";$({...l,trigger_type:d,config_json:d==="review_missing_timeout"?ce(l.config_json):l.config_json||"{}",actions:(b=l.actions)!=null&&b.length?l.actions.map(h=>({...h})):_e(d,l.card_group_id),variants:(p=l.variants)!=null&&p.length?l.variants.map(h=>({...h})):d==="review_missing_timeout"?[]:[he()]}),v(!0)},[]);o.useEffect(()=>{if(!w)return;let l=!1;return(async()=>{i("automation"),a(w.cookieId),C(!0);try{const[b,p,h]=await Promise.all([Ft(),dt(),ot().catch(f=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",f),[]))]);if(l)return;r(b),A(p),y(h);const N=b.find(f=>f.cookie_id===w.cookieId&&f.item_id===w.itemId&&f.trigger_type==="order_paid");if(N)ue(N);else{const f=p.find(B=>B.cookie_id===w.cookieId&&B.item_id===w.itemId);$({...W("order_paid",w.cookieId,w.itemId),item_title:(f==null?void 0:f.item_title)||"",item_keyword:(f==null?void 0:f.item_title)||w.itemId,name:ye("order_paid",(f==null?void 0:f.item_title)||w.itemId)}),v(!0)}}catch(b){console.error("打开商品自动化规则失败",b),alert("无法加载该商品的自动化规则")}finally{l||(C(!1),G==null||G())}})(),(()=>{l=!0})},[W,w,G,ue,i,r,y,A,C,a]);const $e=o.useCallback((l="order_paid")=>{if(!t){alert("请先选择账号");return}$(W(l)),v(!0)},[W,t]),je=o.useCallback(l=>{var p,h,N,f,B;if(!n)return;const d=((h=(p=n.variants)==null?void 0:p.find(se=>se.card_id))==null?void 0:h.card_id)||((f=(N=n.actions)==null?void 0:N.find(se=>se.action_type==="send_card"))==null?void 0:f.card_id)||n.card_group_id||0,b=(_==null?void 0:_.item_title)||n.item_title||n.item_id||"";$({...n,trigger_type:l,name:lt(n.name)?ye(l,b):n.name,card_group_id:d,config_json:l==="review_missing_timeout"?ce(n.config_json):"{}",actions:_e(l,d),variants:l==="review_missing_timeout"?[]:(B=n.variants)!=null&&B.length?n.variants:[{...he(),card_id:d}]})},[n,_]),Me=o.useCallback(l=>{if(!n)return;const d=u.find(p=>p.cookie_id===(n.cookie_id||t)&&p.item_id===l),b=(d==null?void 0:d.item_title)||l;$({...n,item_id:l,item_title:(d==null?void 0:d.item_title)||"",item_keyword:b,name:lt(n.name)?ye(F,b):n.name})},[F,n,u,t]),pe=o.useCallback((l,d)=>{var p;if(!n)return;const b=E.map((h,N)=>N===l?{...h,...d}:h);$({...n,variants:b,card_group_id:((p=b[0])==null?void 0:p.card_id)||0})},[E,n]),Pe=o.useCallback(()=>{if(!n)return;const l=E[E.length-1];$({...n,variants:[...E,{...he(),spec_name:j&&(l==null?void 0:l.spec_name)||"",spec_value:j&&(l==null?void 0:l.spec_value)||""}]})},[E,n,j]),ve=o.useCallback(async()=>{var h,N,f,B,se;if(!n||K.submitting)return;const l=n.trigger_type||"order_paid";if(!n.cookie_id)return alert("请选择账号");const d=(h=n.variants)!=null&&h.length?n.variants:[];if(l!=="review_missing_timeout"){if(!d.length||d.some(k=>!k.card_id))return alert(l==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");if(j&&d.some(k=>!k.spec_name.trim()||!k.spec_value.trim()))return alert("多规格商品必须填写每一行的规格名称和规格值")}if(l==="review_missing_timeout"&&!(((f=(N=n.actions)==null?void 0:N.find(Le=>Le.action_type==="send_text"))==null?void 0:f.message_template)||"").trim())return alert("请填写求评价文案");const b=l==="review_missing_timeout"?[]:d.map(k=>({...k,spec_name:j?k.spec_name.trim():"",spec_value:j?k.spec_value.trim():"",delivery_count:Math.max(1,Number(k.delivery_count)||1),enabled:k.enabled!==!1}));le(qe(K));let p=!1;try{await st({...n,trigger_type:l,name:(n.name||"").trim()||ye(l,(_==null?void 0:_.item_title)||n.item_id||""),config_json:l==="review_missing_timeout"?ce(n.config_json):n.config_json||"{}",actions:(B=n.actions)!=null&&B.length?n.actions:_e(l,((se=b[0])==null?void 0:se.card_id)||n.card_group_id||0),variants:b}),v(!1),await Promise.all([m(),I()]),alert("保存成功"),p=!0}catch(k){console.error("保存自动化规则失败:",k),alert("保存失败:"+k.message)}finally{le(k=>Ve(k,p))}},[K,n,j,m,I,_]),g=o.useCallback(async l=>{if(confirm("确定删除该自动化规则吗?"))try{await Et(l),await m(),alert("删除成功")}catch(d){alert("删除失败:"+d.message)}},[m]),O=o.useCallback(async l=>{try{await st({...l,enabled:!l.enabled}),await m()}catch(d){alert("操作失败:"+d.message)}},[m]),S=o.useCallback(async(l,d)=>{if(confirm(d==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":d==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await qt(l,d),await m()}catch(p){alert("处理失败:"+p.message)}},[m]),te=o.useCallback(async(l,d)=>{if(confirm(d==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Vt(l,d),await m()}catch(b){alert("处理失败:"+b.message)}},[m]),L=o.useCallback(()=>{if(!t)return alert("请先选择账号");z({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),q(!0)},[t]),ie=o.useCallback(async()=>{var b,p,h;if(!R||!t||Y.submitting)return;const l=R.type==="image"?!!((b=R.image_url)!=null&&b.trim()):!!((p=R.reply_content)!=null&&p.trim());if(!((h=R.keyword)!=null&&h.trim())||!l)return alert("请填写关键词和回复内容");V(qe(Y));let d=!1;try{await Kt({...R,match_type:"fuzzy",enabled:!0},t),q(!1),await T(),alert("保存成功"),d=!0}catch(N){alert("保存失败:"+N.message)}finally{V(N=>Ve(N,d))}},[R,T,Y,t]),ge=o.useCallback(async l=>{if(!(!t||!confirm("确定删除该回复规则吗?")))try{await Ut(l,t),await T(),alert("删除成功")}catch(d){alert("删除失败:"+d.message)}},[T,t]),oe=o.useCallback(async(l=t)=>{if(!l)return alert("请先选择账号");try{const d=await Wt(l);P({cookie_id:l,enabled:d.enabled,reply_content:d.reply_content,reply_once:d.reply_once,reply_image_url:d.reply_image_url||""})}catch{P({cookie_id:l,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}Q(!0)},[t]),me=o.useCallback(async()=>{if(H.submitting)return;if(!M.cookie_id)return alert("请先选择账号");if(M.enabled&&!M.reply_content.trim()&&!M.reply_image_url.trim())return alert("启用默认回复时,请填写回复内容或图片 URL");U(qe(H));let l=!1;try{await Zt(M.cookie_id,{enabled:M.enabled,reply_content:M.reply_content,reply_once:M.reply_once,reply_image_url:M.reply_image_url}),Q(!1),await J(),alert("保存成功"),l=!0}catch(d){alert("保存失败:"+d.message)}finally{U(d=>Ve(d,l))}},[M,H,J]),Ne=o.useCallback(async l=>{if(confirm("确定删除该账号默认回复吗?"))try{await Xt(l),await J(),alert("删除成功")}catch(d){alert("删除失败:"+d.message)}},[J]),be=o.useCallback(async l=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Qt(l),alert("清空成功")}catch(d){alert("清空失败:"+d.message)}},[]);return{showAutomationModal:D,setShowAutomationModal:v,showReplyModal:X,setShowReplyModal:q,showDefaultModal:re,setShowDefaultModal:Q,automationSubmitState:K,replySubmitState:Y,defaultReplySubmitState:H,editingAutomationRule:n,setEditingAutomationRule:$,editingReplyRule:R,setEditingReplyRule:z,defaultForm:M,setDefaultForm:P,selectedRuleItem:_,isMultiSpecRule:j,currentTrigger:F,currentMeta:ee,reviewConfig:ne,displayVariants:E,buildAutomationDraft:W,openAutomationRule:ue,openNewAutomationRule:$e,handleTriggerChange:je,handleAutomationItemChange:Me,updateVariant:pe,appendDeliveryContent:Pe,handleSaveAutomationRule:ve,handleDeleteAutomation:g,handleToggleAutomation:O,handleResolveRunIssue:S,handleResolveDeferredIssue:te,handleAddReplyRule:L,handleSaveReplyRule:ie,handleDeleteReply:ge,openDefaultReplyModal:oe,handleSaveDefaultReply:me,handleDeleteDefaultReply:Ne,handleClearDefaultReplyRecords:be}},os=({initialDeliveryTarget:t,onDeliveryTargetHandled:a})=>{var Xe,Qe;const[i,u]=o.useState("automation"),[r,y]=o.useState(""),[A,C]=o.useState(""),[m,I]=o.useState(""),[T,J]=o.useState(""),[w,G]=o.useState("all"),[D,v]=o.useState(1),[X,q]=o.useState(10),re=Yt({activeTab:i,selectedAccountId:r,automationTriggerFilter:T,automationStatusFilter:w,debouncedAutomationSearch:m,automationPage:D,automationPageSize:X,setSelectedAccountId:y,onAutomationPageChange:v}),{automationRules:Q,automationIssues:K,replyRules:le,defaultReplies:Y,accounts:V,cards:H,items:U,loading:n,setLoading:$,automationTotal:R,automationTotalPages:z,automationTriggerCounts:M,setAutomationRules:P,setCards:_,setItems:j,loadReferenceData:F,loadAutomationRules:ee,loadReplyRules:ne,loadDefaultReplies:E,refresh:W}=re,ue=as({selectedAccountId:r,setSelectedAccountId:y,setActiveTab:u,items:U,setAutomationRules:P,setCards:_,setItems:j,setLoading:$,loadAutomationRules:ee,loadReferenceData:F,loadReplyRules:ne,loadDefaultReplies:E,initialDeliveryTarget:t,onDeliveryTargetHandled:a}),{showAutomationModal:$e,setShowAutomationModal:je,showReplyModal:Me,setShowReplyModal:pe,showDefaultModal:Pe,setShowDefaultModal:ve,editingAutomationRule:g,setEditingAutomationRule:O,editingReplyRule:S,setEditingReplyRule:te,defaultForm:L,setDefaultForm:ie,selectedRuleItem:ge,isMultiSpecRule:oe,currentTrigger:me,currentMeta:Ne,reviewConfig:be,displayVariants:xe,openAutomationRule:l,openNewAutomationRule:d,handleTriggerChange:b,handleAutomationItemChange:p,updateVariant:h,appendDeliveryContent:N,handleSaveAutomationRule:f,handleDeleteAutomation:B,handleToggleAutomation:se,handleResolveRunIssue:k,handleResolveDeferredIssue:Le,handleAddReplyRule:xt,handleSaveReplyRule:ut,handleDeleteReply:pt,openDefaultReplyModal:We,handleSaveDefaultReply:gt,handleDeleteDefaultReply:bt,handleClearDefaultReplyRecords:ht}=ue;o.useEffect(()=>{const s=window.setTimeout(()=>{v(1),I(A.trim())},300);return(()=>window.clearTimeout(s))},[A]),o.useEffect(()=>{F().catch(s=>console.error("加载规则参考数据失败",s))},[F]),o.useEffect(()=>{W().catch(s=>console.error("刷新规则页面失败",s))},[W]);const Ie=o.useMemo(()=>Q.filter(s=>!r||s.cookie_id===r),[Q,r]),we=o.useMemo(()=>Pt(K,r),[K,r]),Ze=o.useMemo(()=>V.filter(s=>!r||s.id===r),[V,r]),yt=o.useMemo(()=>{if(z<=1)return[];const s=Math.max(1,Math.min(D-2,z-4)),c=Math.min(z,s+4);return Array.from({length:c-s+1},(x,de)=>s+de)},[D,z]),De=!!(A.trim()||T||w!=="all"),_t=()=>{C(""),I(""),J(""),G("all"),v(1)},ft=o.useMemo(()=>{const s=(g==null?void 0:g.cookie_id)||r;return U.filter(c=>c.cookie_id===s)},[g==null?void 0:g.cookie_id,U,r]),jt=i==="automation"?"新建自动化":i==="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:(s=>{y(s.target.value),v(1)}),className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),V.map(s=>e.jsx("option",{value:s.id,children:Re(s)},s.id))]}),e.jsxs("button",{onClick:W,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(Te,{className:`w-4 h-4 ${n?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:i==="automation"?(()=>d("order_paid")):i==="reply"?xt:(()=>void We()),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(Ye,{className:"w-4 h-4"}),jt]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:He},{id:"reply",label:"关键词回复",icon:wt},{id:"default",label:"账号默认回复",icon:et}].map(s=>{const c=s.icon;return e.jsxs("button",{onClick:(()=>u(s.id)),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${i===s.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(c,{className:"w-4 h-4"}),s.label]},s.id)})}),i==="automation"&&(we.runs.length>0||we.pending_tasks.length>0)&&e.jsx(It,{runs:we.runs,pendingTasks:we.pending_tasks,onResolveRun:((s,c)=>void k(s,c)),onResolveDeferredTask:((s,c)=>void Le(s,c))}),i==="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:Se.map(s=>{const c=ae[s],x=c.icon;return e.jsx("button",{type:"button",onClick:(()=>d(s)),className:`w-full text-left rounded-2xl border p-4 transition-colors ${nt(c.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(x,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:c.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:c.description})]})]})},s)})})]}),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:["共 ",R," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Se.map(s=>{const c=ae[s],x=c.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(x,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:c.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:M[s]||0})]},s)})})]})]}),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(kt,{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:A,onChange:(s=>{C(s.target.value),v(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(Ct,{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:T,onChange:(s=>{J(s.target.value),v(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:"全部自动化类型"}),Se.map(s=>e.jsx("option",{value:s,children:ae[s].shortLabel},s))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:w,onChange:(s=>{G(s.target.value),v(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:"已禁用"})]}),De&&e.jsx("button",{type:"button",onClick:_t,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(ke,{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:["找到 ",R," 条规则"]}),n&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Te,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),n&&Ie.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Ie.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(He,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:De?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:De?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Ie.map(s=>{const c=ae[s.trigger_type],x=c.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 ${nt(c.accent,!0)}`,children:e.jsx(x,{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:s.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${ts(s.enabled)}`,children:s.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:c.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:s.item_title||s.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:es(s)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:(()=>l(s)),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(ze,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:(()=>se(s)),className:`px-4 py-2 rounded-xl text-sm font-bold ${s.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:s.enabled?"禁用":"启用"}),e.jsx("button",{onClick:(()=>B(s.id)),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Ce,{className:"w-4 h-4"})})]})]})},s.id)}),R>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:["第 ",D," / ",Math.max(z,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:X,onChange:(s=>{q(Number(s.target.value)),v(1)}),className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(s=>e.jsxs("option",{value:s,children:[s," 条/页"]},s))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:D<=1||n,onClick:(()=>v(s=>Math.max(1,s-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(St,{className:"h-4 w-4"})}),yt.map(s=>e.jsx("button",{type:"button",disabled:n,onClick:(()=>v(s)),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${s===D?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${s} 页`,"aria-current":s===D?"page":void 0,children:s},s)),e.jsx("button",{type:"button",disabled:D>=z||n,onClick:(()=>v(s=>Math.min(z,s+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(Rt,{className:"h-4 w-4"})})]})]})]})]}),i==="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(Je,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[le.map(s=>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:["“",s.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:s.type==="image"&&s.image_url?s.image_url:s.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:(()=>{te({...s}),pe(!0)}),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>pt(s.id)),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ce,{className:"w-5 h-5"})})]})]},s.id)),le.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),i==="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(Je,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[Ze.map(s=>{const c=Y[s.id],x=!!(c!=null&&c.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 ${x?"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 ${x?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(et,{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:Re(s)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${x?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:x?"已启用":"未启用"}),(c==null?void 0:c.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:x?c.reply_content||c.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 We(s.id)),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:(()=>void ht(s.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 bt(s.id)),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ce,{className:"w-5 h-5"})})]})]})]},s.id)}),Ze.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),$e&&g&&Fe.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:g.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:Ne.description})]}),e.jsx("button",{onClick:(()=>je(!1)),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(ke,{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:Se.map(s=>{const c=ae[s],x=c.icon,de=me===s;return e.jsx("button",{type:"button",onClick:(()=>b(s)),className:`w-full rounded-2xl p-4 text-left border transition-all ${de?"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(x,{className:`w-5 h-5 mt-0.5 ${de?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:c.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${de?"text-gray-500":"text-gray-400"}`,children:c.description})]})]})},s)})}),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:Ne.flow.map((s,c)=>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:c+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:s})]},s))})]})]}),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(At,{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:g.name||"",onChange:(s=>O({...g,name:s.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:g.cookie_id||"",onChange:(s=>O({...g,cookie_id:s.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:"选择账号"}),V.map(s=>e.jsx("option",{value:s.id,children:Re(s)},s.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:g.item_id||"",onChange:(s=>p(s.target.value)),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),ft.map(s=>e.jsx("option",{value:s.item_id,children:s.item_title||s.item_id},`${s.cookie_id}-${s.item_id}`))]})]})]}),ge&&me!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:ge.item_title||ge.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${oe?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:oe?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),me!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($t,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:me==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:oe?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:N,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(Ye,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:xe.map((s,c)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${oe?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[oe&&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:s.spec_name,onChange:(x=>h(c,{spec_name:x.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:s.spec_value,onChange:(x=>h(c,{spec_value:x.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:s.card_id||"",onChange:(x=>h(c,{card_id:Number(x.target.value)})),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),H.filter(x=>x.enabled&&x.type!=="api").map(x=>e.jsx("option",{value:x.id,children:x.name},x.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:s.delivery_count,onChange:(x=>h(c,{delivery_count:Math.max(1,Number(x.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:s.delay_override===!0,onChange:(x=>h(c,{delay_override:x.target.checked})),className:"accent-brand"}),"覆盖卡密默认延时"]}),s.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:s.delay_seconds||0,onChange:(x=>h(c,{delay_seconds:Math.max(0,Number(x.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:s.delay_override?`本动作延时 ${s.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:xe.length===1,onClick:(()=>O({...g,variants:xe.filter((x,de)=>de!==c)})),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(Ce,{className:"w-4 h-4"})})]},s.id||c))})]}):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(it,{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(be.after_shipped_hours||72),onChange:(s=>O({...g,config_json:ce(g.config_json,{after_shipped_hours:Math.max(1,Number(s.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(be.repeat_interval_hours||24),onChange:(s=>O({...g,config_json:ce(g.config_json,{repeat_interval_hours:Math.max(1,Number(s.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(be.max_attempts||1),onChange:(s=>O({...g,config_json:ce(g.config_json,{max_attempts:Math.max(1,Number(s.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:((Qe=(Xe=g.actions)==null?void 0:Xe.find(s=>s.action_type==="send_text"))==null?void 0:Qe.message_template)||"",onChange:(s=>{var c;return O({...g,actions:((c=g.actions)!=null&&c.length?g.actions:_e("review_missing_timeout")).map(x=>x.action_type==="send_text"?{...x,message_template:s.target.value}:x)})}),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:g.priority||100,onChange:(s=>O({...g,priority:Number(s.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:g.enabled!==!1,onChange:(s=>O({...g,enabled:s.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:(()=>je(!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:f,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),Me&&S&&Fe.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:S.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:(()=>pe(!1)),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:S.item_id||"",onChange:(s=>te({...S,item_id:s.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),U.filter(s=>!r||s.cookie_id===r).map(s=>e.jsx("option",{value:s.item_id,children:s.item_title||s.item_id},`${s.cookie_id}-${s.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:S.type||"text",onChange:(s=>{const c=s.target.value;te({...S,type:c,reply_content:c==="text"?S.reply_content:"",image_url:c==="image"?S.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:S.keyword||"",onChange:(s=>te({...S,keyword:s.target.value})),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),S.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:S.image_url||"",onChange:(s=>te({...S,image_url:s.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:S.reply_content||"",onChange:(s=>te({...S,reply_content:s.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:(()=>pe(!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:ut,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),Pe&&Fe.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:(()=>ve(!1)),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(ke,{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:L.cookie_id,onChange:(s=>ie({...L,cookie_id:s.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),V.map(s=>e.jsx("option",{value:s.id,children:Re(s)},s.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:(()=>ie({...L,enabled:!L.enabled})),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${L.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 ${L.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:L.reply_content,onChange:(s=>ie({...L,reply_content:s.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:L.reply_image_url,onChange:(s=>ie({...L,reply_image_url:s.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:L.reply_once,onChange:(s=>ie({...L,reply_once:s.target.checked})),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:(()=>ve(!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:gt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})};export{os as default}; diff --git a/internal/webui/static/assets/Rules-CeggCy2B.js b/internal/webui/static/assets/Rules-CeggCy2B.js deleted file mode 100644 index 331c81e..0000000 --- a/internal/webui/static/assets/Rules-CeggCy2B.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as o,b as Fe}from"./react-vendor-C_od1ZSF.js";import{k as Je,ae as it,af as vt,m as Nt,R as Te,N as Ye,Z as He,u as wt,n as et,I as kt,a1 as Ct,X as ke,V as ze,y as Ce,h as St,g as Rt,a6 as At,ag as $t,o as tt,ah as Mt}from"./icons-vendor-DwxdQTKt.js";import{g as Z,o as Ae,c as Ge,p as Ke,a as fe,d as Ue}from"./index-zEvleK2K.js";const Ee=(t,a)=>t.allowed_resolutions.includes(a),Pt=(t,a)=>({runs:t.runs.filter(i=>!a||i.cookie_id===a),pending_tasks:t.pending_tasks.filter(i=>!a||i.cookie_id===a)}),Lt=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",It=({runs:t,pendingTasks:a,onResolveRun:i,onResolveDeferredTask:u})=>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(Je,{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:Lt(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:[Ee(r,"continue")&&e.jsx("button",{onClick:(()=>i(r.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Ee(r,"retry")&&e.jsx("button",{onClick:(()=>i(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Ee(r,"cancel")&&e.jsx("button",{onClick:(()=>i(r.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${r.id}`)),a.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:(()=>u(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:(()=>u(r.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${r.id}`))]})]}),Dt=async t=>Z("/api/v1/accounts/details",void 0,t),ot=async t=>Z("/api/v1/cards",void 0,t),dt=async(t,a)=>Z("/api/v1/items",void 0,a),ct=t=>t.map(a=>{var i,u;return{id:String(a.id),name:a.name||"",trigger_type:a.trigger_type||"order_paid",item_keyword:a.item_title||a.item_id||"",cookie_id:a.cookie_id||"",item_id:a.item_id||"",item_title:a.item_title||"",card_group_id:Number(((i=(a.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:i.card_id)||0),card_group_name:((u=(a.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:u.card_name)||"",priority:a.priority||100,enabled:a.enabled||!1,config_json:a.config_json||"{}",actions:(a.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:(a.actions||[]).filter(r=>r.action_type==="send_card").map(r=>{let y={};try{y=JSON.parse(r.config_json||"{}")}catch{}return{id:r.id?String(r.id):void 0,spec_name:y.spec_name||"",spec_value:y.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:y.delay_override===!0,delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}"}})}}),Ft=async()=>{const t=await Z("/api/v1/automation-rules"),a=Ge(t,["data","rules","items"]);return ct(a)},Tt=async({cookieId:t,triggerType:a,enabled:i,search:u,page:r=1,pageSize:y=10}={})=>{const A=await Z("/api/v1/automation-rules",{page:r,page_size:y,cookie_id:t||void 0,trigger_type:a||void 0,enabled:i,search:(u==null?void 0:u.trim())||void 0}),C=Ae(A,["data","result"])||{},m=ct(Ge(A,["data","rules","items"]));return{success:!0,data:m,total:Number(C.total??m.length),page:Number(C.page??r),page_size:Number(C.page_size??y),total_pages:Number(C.total_pages??(m.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(C.trigger_counts||{}).map(([I,T])=>[I,Number(T)]))}},zt=(t,a)=>{if(t!=="order_paid")return a.map((r,y)=>({...r,sort_order:r.sort_order||y+1}));const i=a.filter(r=>r.action_type==="send_card").map((r,y)=>({...r,sort_order:y+1})),u=a.filter(r=>r.action_type!=="send_card"&&r.action_type!=="confirm_shipment");return[...i,...u.map((r,y)=>({...r,sort_order:i.length+y+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:i.length+u.length+1}]},st=async t=>{const a=t.trigger_type||"order_paid",u=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[a]||"自动化规则",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"),y=t.variants&&t.variants.length>0?[...t.variants.map((m,I)=>({action_type:"send_card",card_id:m.card_id,delivery_count:m.delivery_count||1,enabled:m.enabled!==!1,sort_order:I+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}],A=zt(a,y),C={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||u||"自动化规则",trigger_type:a,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:A.map((m,I)=>({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||I+1}))};return t.id?Ke(`/api/v1/automation-rules/${t.id}`,C):fe("/api/v1/automation-rules",C)},Et=async t=>Ue(`/api/v1/automation-rules/${t}`),Ot=async()=>{const t=await Z("/api/v1/automation-issues"),a=Ae(t,["data","result"])||{};return{runs:Array.isArray(a==null?void 0:a.runs)?a.runs:[],pending_tasks:Array.isArray(a==null?void 0:a.pending_tasks)?a.pending_tasks:[]}},qt=async(t,a)=>fe(`/api/v1/automation-runs/${t}/resolve`,{resolution:a}),Vt=async(t,a)=>fe(`/api/v1/automation-pending-tasks/${t}/resolve`,{resolution:a}),Bt=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)||""}),Jt=async t=>{const a=await Z(`/api/v1/reply-rules/${t}/typed`);return Ge(a,["data","items","rules"]).map(Bt)},Gt=async t=>t?(await Jt(t)).map(i=>({id:i.id,keyword:i.keyword||"",reply_content:i.reply||"",match_type:"fuzzy",enabled:!0,item_id:i.item_id||"",type:i.type==="image"?"image":"text",image_url:i.image_url||""})):[],Kt=async(t,a)=>{const i=t.type||"text",u={keyword:t.keyword||"",reply:i==="text"&&t.reply_content||"",item_id:t.item_id||"",type:i,image_url:i==="image"&&t.image_url||""};return t.id?Ke(`/api/v1/reply-rules/${a}/typed/${t.id}`,u):fe(`/api/v1/reply-rules/${a}/items`,u)},Ut=async(t,a)=>Ue(`/api/v1/reply-rules/${a}/typed/${t}`),at=async()=>{const t=await Z("/api/v1/default-replies");return Ae(t,["data","replies","items"])||{}},Wt=async t=>{const a=await Z(`/api/v1/default-replies/${t}`),i=Ae(a,["data","result"])||{};return{cookie_id:t,enabled:i.enabled||!1,reply_content:i.reply_content||"",reply_once:i.reply_once||!1,reply_image_url:i.reply_image_url||""}},Zt=async(t,a)=>Ke(`/api/v1/default-replies/${t}`,{enabled:a.enabled??!1,reply_content:a.reply_content||"",reply_once:a.reply_once??!1,reply_image_url:a.reply_image_url||""}),Xt=async t=>Ue(`/api/v1/default-replies/${t}`),Qt=async t=>fe(`/api/v1/default-replies/${t}/clear-records`,{}),Oe=()=>({submitting:!1,result:"idle"}),qe=t=>t.submitting?t:{submitting:!0,result:"idle"},Ve=(t,a)=>({...t,submitting:!1,result:a?"success":"failure"}),rt=t=>t+1,Be=(t,a,i,u)=>t===a&&i===u,Yt=t=>{const[a,i]=o.useState([]),[u,r]=o.useState({runs:[],pending_tasks:[]}),[y,A]=o.useState([]),[C,m]=o.useState({}),[I,T]=o.useState([]),[J,w]=o.useState([]),[G,D]=o.useState([]),[v,X]=o.useState(!1),q=o.useRef(0),re=o.useRef(0),[Q,K]=o.useState(0),[le,Y]=o.useState(0),[V,H]=o.useState({}),U=o.useCallback(async()=>{const P=Promise.all([Dt(),ot(),dt(),at()]),[_,j,F,ee]=await P;T(_),w(j),D(F),m(ee),t.setSelectedAccountId(ne=>{var E;return ne||((E=_[0])==null?void 0:E.id)||""})},[t.setSelectedAccountId]),n=o.useCallback(async()=>{var ee;const P=rt(q.current);q.current=P;const _=Ot().catch(ne=>(console.warn("加载自动化异常列表失败,不阻断规则展示",ne),null)),j=await Tt({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(!Be(P,q.current,t.selectedAccountId,t.selectedAccountId))return;i(j.data),K(j.total),Y(j.total_pages),H(j.trigger_counts||{}),j.page!==t.automationPage&&((ee=t.onAutomationPageChange)==null||ee.call(t,j.page));const F=await _;Be(P,q.current,t.selectedAccountId,t.selectedAccountId)&&F&&r(F)},[t.automationPage,t.automationPageSize,t.automationStatusFilter,t.automationTriggerFilter,t.debouncedAutomationSearch,t.onAutomationPageChange,t.selectedAccountId]),$=o.useCallback(async()=>{const P=rt(re.current);re.current=P;const _=t.selectedAccountId;if(A([]),!_)return;const j=await Gt(_);Be(P,re.current,_,t.selectedAccountId)&&A(j)},[t.selectedAccountId]),R=o.useCallback(async()=>{m(await at())},[]),z=o.useCallback(async()=>{X(!0);try{t.activeTab==="automation"?await n():t.activeTab==="reply"?await $():await R()}finally{X(!1)}},[n,R,$,t.activeTab]);return{automationRules:a,automationIssues:u,replyRules:y,defaultReplies:C,accounts:I,cards:J,items:G,automationTotal:Q,automationTotalPages:le,automationTriggerCounts:V,loading:v,setLoading:X,setAutomationRules:i,setCards:w,setItems:D,loadReferenceData:U,loadAutomationRules:n,loadReplyRules:$,loadDefaultReplies:R,refresh:z}},ae={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Nt},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:vt},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:it}},Se=["order_paid","buyer_reviewed","review_missing_timeout"],Ht="亲,商品使用满意的话,麻烦给个评价,谢谢~",he=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),mt=t=>{if(!t)return{};try{const a=JSON.parse(t);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}},ce=(t,a={})=>{const i=mt(t);return JSON.stringify({after_shipped_hours:Number(i.after_shipped_hours||72),repeat_interval_hours:Number(i.repeat_interval_hours||24),max_attempts:Number(i.max_attempts||1),...a})},ye=(t,a)=>{var u;const i=((u=ae[t])==null?void 0:u.label)||"自动化规则";return a?`${i} - ${a}`:i},lt=t=>{const a=(t||"").trim();return a?Object.values(ae).some(i=>a===i.label||a.startsWith(`${i.label} -`)):!0},_e=(t,a=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:Ht,enabled:!0,sort_order:1}];const i={action_type:"send_card",card_id:a,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[i,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[i]},es=t=>{var i,u;if(t.trigger_type==="review_missing_timeout")return((u=(i=t.actions)==null?void 0:i.find(r=>r.action_type==="send_text"))==null?void 0:u.message_template)||"发送求评价文案";const a=(t.actions||[]).filter(r=>r.action_type==="send_card");return a.length?a.map(r=>r.card_name||`卡密 ${r.card_id}`).join(" / "):"未配置卡密库存"},nt=(t,a=!1)=>{const i={blue:a?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:a?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:a?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return i[t]||i.blue},ts=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Re=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",ss=t=>t===!0||t===1||t==="1",as=({selectedAccountId:t,setSelectedAccountId:a,setActiveTab:i,items:u,setAutomationRules:r,setCards:y,setItems:A,setLoading:C,loadAutomationRules:m,loadReferenceData:I,loadReplyRules:T,loadDefaultReplies:J,initialDeliveryTarget:w,onDeliveryTargetHandled:G})=>{var xe;const[D,v]=o.useState(!1),[X,q]=o.useState(!1),[re,Q]=o.useState(!1),[K,le]=o.useState(Oe),[Y,V]=o.useState(Oe),[H,U]=o.useState(Oe),[n,$]=o.useState(null),[R,z]=o.useState(null),[M,P]=o.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""}),_=o.useMemo(()=>n!=null&&n.cookie_id&&n.item_id?u.find(l=>l.cookie_id===n.cookie_id&&l.item_id===n.item_id):void 0,[n==null?void 0:n.cookie_id,n==null?void 0:n.item_id,u]),j=ss(_==null?void 0:_.is_multi_spec),F=(n==null?void 0:n.trigger_type)||"order_paid",ee=ae[F],ne=mt(n==null?void 0:n.config_json),E=(xe=n==null?void 0:n.variants)!=null&&xe.length?n.variants:[he()],W=o.useCallback((l="order_paid",d=t,b="")=>{const p=u.find(N=>N.cookie_id===d&&N.item_id===b),h=(p==null?void 0:p.item_title)||b;return{name:ye(l,h),trigger_type:l,cookie_id:d,item_id:b,item_title:(p==null?void 0:p.item_title)||"",item_keyword:h,card_group_id:0,priority:100,enabled:!0,config_json:l==="review_missing_timeout"?ce():"{}",actions:_e(l),variants:l==="review_missing_timeout"?[]:[he()]}},[u,t]),ue=o.useCallback(l=>{var b,p;const d=l.trigger_type||"order_paid";$({...l,trigger_type:d,config_json:d==="review_missing_timeout"?ce(l.config_json):l.config_json||"{}",actions:(b=l.actions)!=null&&b.length?l.actions.map(h=>({...h})):_e(d,l.card_group_id),variants:(p=l.variants)!=null&&p.length?l.variants.map(h=>({...h})):d==="review_missing_timeout"?[]:[he()]}),v(!0)},[]);o.useEffect(()=>{if(!w)return;let l=!1;return(async()=>{i("automation"),a(w.cookieId),C(!0);try{const[b,p,h]=await Promise.all([Ft(),dt(),ot().catch(f=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",f),[]))]);if(l)return;r(b),A(p),y(h);const N=b.find(f=>f.cookie_id===w.cookieId&&f.item_id===w.itemId&&f.trigger_type==="order_paid");if(N)ue(N);else{const f=p.find(B=>B.cookie_id===w.cookieId&&B.item_id===w.itemId);$({...W("order_paid",w.cookieId,w.itemId),item_title:(f==null?void 0:f.item_title)||"",item_keyword:(f==null?void 0:f.item_title)||w.itemId,name:ye("order_paid",(f==null?void 0:f.item_title)||w.itemId)}),v(!0)}}catch(b){console.error("打开商品自动化规则失败",b),alert("无法加载该商品的自动化规则")}finally{l||(C(!1),G==null||G())}})(),(()=>{l=!0})},[W,w,G,ue,i,r,y,A,C,a]);const $e=o.useCallback((l="order_paid")=>{if(!t){alert("请先选择账号");return}$(W(l)),v(!0)},[W,t]),je=o.useCallback(l=>{var p,h,N,f,B;if(!n)return;const d=((h=(p=n.variants)==null?void 0:p.find(se=>se.card_id))==null?void 0:h.card_id)||((f=(N=n.actions)==null?void 0:N.find(se=>se.action_type==="send_card"))==null?void 0:f.card_id)||n.card_group_id||0,b=(_==null?void 0:_.item_title)||n.item_title||n.item_id||"";$({...n,trigger_type:l,name:lt(n.name)?ye(l,b):n.name,card_group_id:d,config_json:l==="review_missing_timeout"?ce(n.config_json):"{}",actions:_e(l,d),variants:l==="review_missing_timeout"?[]:(B=n.variants)!=null&&B.length?n.variants:[{...he(),card_id:d}]})},[n,_]),Me=o.useCallback(l=>{if(!n)return;const d=u.find(p=>p.cookie_id===(n.cookie_id||t)&&p.item_id===l),b=(d==null?void 0:d.item_title)||l;$({...n,item_id:l,item_title:(d==null?void 0:d.item_title)||"",item_keyword:b,name:lt(n.name)?ye(F,b):n.name})},[F,n,u,t]),pe=o.useCallback((l,d)=>{var p;if(!n)return;const b=E.map((h,N)=>N===l?{...h,...d}:h);$({...n,variants:b,card_group_id:((p=b[0])==null?void 0:p.card_id)||0})},[E,n]),Pe=o.useCallback(()=>{if(!n)return;const l=E[E.length-1];$({...n,variants:[...E,{...he(),spec_name:j&&(l==null?void 0:l.spec_name)||"",spec_value:j&&(l==null?void 0:l.spec_value)||""}]})},[E,n,j]),ve=o.useCallback(async()=>{var h,N,f,B,se;if(!n||K.submitting)return;const l=n.trigger_type||"order_paid";if(!n.cookie_id)return alert("请选择账号");const d=(h=n.variants)!=null&&h.length?n.variants:[];if(l!=="review_missing_timeout"){if(!d.length||d.some(k=>!k.card_id))return alert(l==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");if(j&&d.some(k=>!k.spec_name.trim()||!k.spec_value.trim()))return alert("多规格商品必须填写每一行的规格名称和规格值")}if(l==="review_missing_timeout"&&!(((f=(N=n.actions)==null?void 0:N.find(Le=>Le.action_type==="send_text"))==null?void 0:f.message_template)||"").trim())return alert("请填写求评价文案");const b=l==="review_missing_timeout"?[]:d.map(k=>({...k,spec_name:j?k.spec_name.trim():"",spec_value:j?k.spec_value.trim():"",delivery_count:Math.max(1,Number(k.delivery_count)||1),enabled:k.enabled!==!1}));le(qe(K));let p=!1;try{await st({...n,trigger_type:l,name:(n.name||"").trim()||ye(l,(_==null?void 0:_.item_title)||n.item_id||""),config_json:l==="review_missing_timeout"?ce(n.config_json):n.config_json||"{}",actions:(B=n.actions)!=null&&B.length?n.actions:_e(l,((se=b[0])==null?void 0:se.card_id)||n.card_group_id||0),variants:b}),v(!1),await Promise.all([m(),I()]),alert("保存成功"),p=!0}catch(k){console.error("保存自动化规则失败:",k),alert("保存失败:"+k.message)}finally{le(k=>Ve(k,p))}},[K,n,j,m,I,_]),g=o.useCallback(async l=>{if(confirm("确定删除该自动化规则吗?"))try{await Et(l),await m(),alert("删除成功")}catch(d){alert("删除失败:"+d.message)}},[m]),O=o.useCallback(async l=>{try{await st({...l,enabled:!l.enabled}),await m()}catch(d){alert("操作失败:"+d.message)}},[m]),S=o.useCallback(async(l,d)=>{if(confirm(d==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":d==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await qt(l,d),await m()}catch(p){alert("处理失败:"+p.message)}},[m]),te=o.useCallback(async(l,d)=>{if(confirm(d==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Vt(l,d),await m()}catch(b){alert("处理失败:"+b.message)}},[m]),L=o.useCallback(()=>{if(!t)return alert("请先选择账号");z({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),q(!0)},[t]),ie=o.useCallback(async()=>{var b,p,h;if(!R||!t||Y.submitting)return;const l=R.type==="image"?!!((b=R.image_url)!=null&&b.trim()):!!((p=R.reply_content)!=null&&p.trim());if(!((h=R.keyword)!=null&&h.trim())||!l)return alert("请填写关键词和回复内容");V(qe(Y));let d=!1;try{await Kt({...R,match_type:"fuzzy",enabled:!0},t),q(!1),await T(),alert("保存成功"),d=!0}catch(N){alert("保存失败:"+N.message)}finally{V(N=>Ve(N,d))}},[R,T,Y,t]),ge=o.useCallback(async l=>{if(!(!t||!confirm("确定删除该回复规则吗?")))try{await Ut(l,t),await T(),alert("删除成功")}catch(d){alert("删除失败:"+d.message)}},[T,t]),oe=o.useCallback(async(l=t)=>{if(!l)return alert("请先选择账号");try{const d=await Wt(l);P({cookie_id:l,enabled:d.enabled,reply_content:d.reply_content,reply_once:d.reply_once,reply_image_url:d.reply_image_url||""})}catch{P({cookie_id:l,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}Q(!0)},[t]),me=o.useCallback(async()=>{if(H.submitting)return;if(!M.cookie_id)return alert("请先选择账号");if(M.enabled&&!M.reply_content.trim()&&!M.reply_image_url.trim())return alert("启用默认回复时,请填写回复内容或图片 URL");U(qe(H));let l=!1;try{await Zt(M.cookie_id,{enabled:M.enabled,reply_content:M.reply_content,reply_once:M.reply_once,reply_image_url:M.reply_image_url}),Q(!1),await J(),alert("保存成功"),l=!0}catch(d){alert("保存失败:"+d.message)}finally{U(d=>Ve(d,l))}},[M,H,J]),Ne=o.useCallback(async l=>{if(confirm("确定删除该账号默认回复吗?"))try{await Xt(l),await J(),alert("删除成功")}catch(d){alert("删除失败:"+d.message)}},[J]),be=o.useCallback(async l=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Qt(l),alert("清空成功")}catch(d){alert("清空失败:"+d.message)}},[]);return{showAutomationModal:D,setShowAutomationModal:v,showReplyModal:X,setShowReplyModal:q,showDefaultModal:re,setShowDefaultModal:Q,automationSubmitState:K,replySubmitState:Y,defaultReplySubmitState:H,editingAutomationRule:n,setEditingAutomationRule:$,editingReplyRule:R,setEditingReplyRule:z,defaultForm:M,setDefaultForm:P,selectedRuleItem:_,isMultiSpecRule:j,currentTrigger:F,currentMeta:ee,reviewConfig:ne,displayVariants:E,buildAutomationDraft:W,openAutomationRule:ue,openNewAutomationRule:$e,handleTriggerChange:je,handleAutomationItemChange:Me,updateVariant:pe,appendDeliveryContent:Pe,handleSaveAutomationRule:ve,handleDeleteAutomation:g,handleToggleAutomation:O,handleResolveRunIssue:S,handleResolveDeferredIssue:te,handleAddReplyRule:L,handleSaveReplyRule:ie,handleDeleteReply:ge,openDefaultReplyModal:oe,handleSaveDefaultReply:me,handleDeleteDefaultReply:Ne,handleClearDefaultReplyRecords:be}},is=({initialDeliveryTarget:t,onDeliveryTargetHandled:a})=>{var Xe,Qe;const[i,u]=o.useState("automation"),[r,y]=o.useState(""),[A,C]=o.useState(""),[m,I]=o.useState(""),[T,J]=o.useState(""),[w,G]=o.useState("all"),[D,v]=o.useState(1),[X,q]=o.useState(10),re=Yt({activeTab:i,selectedAccountId:r,automationTriggerFilter:T,automationStatusFilter:w,debouncedAutomationSearch:m,automationPage:D,automationPageSize:X,setSelectedAccountId:y,onAutomationPageChange:v}),{automationRules:Q,automationIssues:K,replyRules:le,defaultReplies:Y,accounts:V,cards:H,items:U,loading:n,setLoading:$,automationTotal:R,automationTotalPages:z,automationTriggerCounts:M,setAutomationRules:P,setCards:_,setItems:j,loadReferenceData:F,loadAutomationRules:ee,loadReplyRules:ne,loadDefaultReplies:E,refresh:W}=re,ue=as({selectedAccountId:r,setSelectedAccountId:y,setActiveTab:u,items:U,setAutomationRules:P,setCards:_,setItems:j,setLoading:$,loadAutomationRules:ee,loadReferenceData:F,loadReplyRules:ne,loadDefaultReplies:E,initialDeliveryTarget:t,onDeliveryTargetHandled:a}),{showAutomationModal:$e,setShowAutomationModal:je,showReplyModal:Me,setShowReplyModal:pe,showDefaultModal:Pe,setShowDefaultModal:ve,editingAutomationRule:g,setEditingAutomationRule:O,editingReplyRule:S,setEditingReplyRule:te,defaultForm:L,setDefaultForm:ie,selectedRuleItem:ge,isMultiSpecRule:oe,currentTrigger:me,currentMeta:Ne,reviewConfig:be,displayVariants:xe,openAutomationRule:l,openNewAutomationRule:d,handleTriggerChange:b,handleAutomationItemChange:p,updateVariant:h,appendDeliveryContent:N,handleSaveAutomationRule:f,handleDeleteAutomation:B,handleToggleAutomation:se,handleResolveRunIssue:k,handleResolveDeferredIssue:Le,handleAddReplyRule:xt,handleSaveReplyRule:ut,handleDeleteReply:pt,openDefaultReplyModal:We,handleSaveDefaultReply:gt,handleDeleteDefaultReply:bt,handleClearDefaultReplyRecords:ht}=ue;o.useEffect(()=>{const s=window.setTimeout(()=>{v(1),I(A.trim())},300);return(()=>window.clearTimeout(s))},[A]),o.useEffect(()=>{F().catch(s=>console.error("加载规则参考数据失败",s))},[F]),o.useEffect(()=>{W().catch(s=>console.error("刷新规则页面失败",s))},[W]);const Ie=o.useMemo(()=>Q.filter(s=>!r||s.cookie_id===r),[Q,r]),we=o.useMemo(()=>Pt(K,r),[K,r]),Ze=o.useMemo(()=>V.filter(s=>!r||s.id===r),[V,r]),yt=o.useMemo(()=>{if(z<=1)return[];const s=Math.max(1,Math.min(D-2,z-4)),c=Math.min(z,s+4);return Array.from({length:c-s+1},(x,de)=>s+de)},[D,z]),De=!!(A.trim()||T||w!=="all"),_t=()=>{C(""),I(""),J(""),G("all"),v(1)},ft=o.useMemo(()=>{const s=(g==null?void 0:g.cookie_id)||r;return U.filter(c=>c.cookie_id===s)},[g==null?void 0:g.cookie_id,U,r]),jt=i==="automation"?"新建自动化":i==="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:(s=>{y(s.target.value),v(1)}),className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),V.map(s=>e.jsx("option",{value:s.id,children:Re(s)},s.id))]}),e.jsxs("button",{onClick:W,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(Te,{className:`w-4 h-4 ${n?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:i==="automation"?(()=>d("order_paid")):i==="reply"?xt:(()=>void We()),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(Ye,{className:"w-4 h-4"}),jt]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:He},{id:"reply",label:"关键词回复",icon:wt},{id:"default",label:"账号默认回复",icon:et}].map(s=>{const c=s.icon;return e.jsxs("button",{onClick:(()=>u(s.id)),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${i===s.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(c,{className:"w-4 h-4"}),s.label]},s.id)})}),i==="automation"&&(we.runs.length>0||we.pending_tasks.length>0)&&e.jsx(It,{runs:we.runs,pendingTasks:we.pending_tasks,onResolveRun:((s,c)=>void k(s,c)),onResolveDeferredTask:((s,c)=>void Le(s,c))}),i==="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:Se.map(s=>{const c=ae[s],x=c.icon;return e.jsx("button",{type:"button",onClick:(()=>d(s)),className:`w-full text-left rounded-2xl border p-4 transition-colors ${nt(c.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(x,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:c.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:c.description})]})]})},s)})})]}),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:["共 ",R," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Se.map(s=>{const c=ae[s],x=c.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(x,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:c.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:M[s]||0})]},s)})})]})]}),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(kt,{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:A,onChange:(s=>{C(s.target.value),v(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(Ct,{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:T,onChange:(s=>{J(s.target.value),v(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:"全部自动化类型"}),Se.map(s=>e.jsx("option",{value:s,children:ae[s].shortLabel},s))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:w,onChange:(s=>{G(s.target.value),v(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:"已禁用"})]}),De&&e.jsx("button",{type:"button",onClick:_t,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(ke,{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:["找到 ",R," 条规则"]}),n&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Te,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),n&&Ie.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):Ie.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(He,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:De?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:De?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):Ie.map(s=>{const c=ae[s.trigger_type],x=c.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 ${nt(c.accent,!0)}`,children:e.jsx(x,{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:s.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${ts(s.enabled)}`,children:s.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:c.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:s.item_title||s.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:es(s)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:(()=>l(s)),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(ze,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:(()=>se(s)),className:`px-4 py-2 rounded-xl text-sm font-bold ${s.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:s.enabled?"禁用":"启用"}),e.jsx("button",{onClick:(()=>B(s.id)),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Ce,{className:"w-4 h-4"})})]})]})},s.id)}),R>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:["第 ",D," / ",Math.max(z,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:X,onChange:(s=>{q(Number(s.target.value)),v(1)}),className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(s=>e.jsxs("option",{value:s,children:[s," 条/页"]},s))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:D<=1||n,onClick:(()=>v(s=>Math.max(1,s-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(St,{className:"h-4 w-4"})}),yt.map(s=>e.jsx("button",{type:"button",disabled:n,onClick:(()=>v(s)),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${s===D?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${s} 页`,"aria-current":s===D?"page":void 0,children:s},s)),e.jsx("button",{type:"button",disabled:D>=z||n,onClick:(()=>v(s=>Math.min(z,s+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(Rt,{className:"h-4 w-4"})})]})]})]})]}),i==="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(Je,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[le.map(s=>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:["“",s.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:s.type==="image"&&s.image_url?s.image_url:s.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:(()=>{te({...s}),pe(!0)}),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>pt(s.id)),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ce,{className:"w-5 h-5"})})]})]},s.id)),le.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),i==="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(Je,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[Ze.map(s=>{const c=Y[s.id],x=!!(c!=null&&c.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 ${x?"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 ${x?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(et,{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:Re(s)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${x?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:x?"已启用":"未启用"}),(c==null?void 0:c.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:x?c.reply_content||c.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 We(s.id)),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(ze,{className:"w-4 h-4"})}),x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:(()=>void ht(s.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 bt(s.id)),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Ce,{className:"w-5 h-5"})})]})]})]},s.id)}),Ze.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),$e&&g&&Fe.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:g.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:Ne.description})]}),e.jsx("button",{onClick:(()=>je(!1)),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(ke,{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:Se.map(s=>{const c=ae[s],x=c.icon,de=me===s;return e.jsx("button",{type:"button",onClick:(()=>b(s)),className:`w-full rounded-2xl p-4 text-left border transition-all ${de?"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(x,{className:`w-5 h-5 mt-0.5 ${de?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:c.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${de?"text-gray-500":"text-gray-400"}`,children:c.description})]})]})},s)})}),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:Ne.flow.map((s,c)=>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:c+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:s})]},s))})]})]}),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(At,{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:g.name||"",onChange:(s=>O({...g,name:s.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:g.cookie_id||"",onChange:(s=>O({...g,cookie_id:s.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:"选择账号"}),V.map(s=>e.jsx("option",{value:s.id,children:Re(s)},s.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:g.item_id||"",onChange:(s=>p(s.target.value)),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),ft.map(s=>e.jsx("option",{value:s.item_id,children:s.item_title||s.item_id},`${s.cookie_id}-${s.item_id}`))]})]})]}),ge&&me!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:ge.item_title||ge.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${oe?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:oe?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),me!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($t,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:me==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:oe?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:N,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(Ye,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:xe.map((s,c)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${oe?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[oe&&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:s.spec_name,onChange:(x=>h(c,{spec_name:x.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:s.spec_value,onChange:(x=>h(c,{spec_value:x.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:s.card_id||"",onChange:(x=>h(c,{card_id:Number(x.target.value)})),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),H.filter(x=>x.enabled&&x.type!=="api").map(x=>e.jsx("option",{value:x.id,children:x.name},x.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:s.delivery_count,onChange:(x=>h(c,{delivery_count:Math.max(1,Number(x.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:s.delay_override===!0,onChange:(x=>h(c,{delay_override:x.target.checked})),className:"accent-brand"}),"覆盖卡密默认延时"]}),s.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:s.delay_seconds||0,onChange:(x=>h(c,{delay_seconds:Math.max(0,Number(x.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:s.delay_override?`本动作延时 ${s.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:xe.length===1,onClick:(()=>O({...g,variants:xe.filter((x,de)=>de!==c)})),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(Ce,{className:"w-4 h-4"})})]},s.id||c))})]}):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(it,{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(be.after_shipped_hours||72),onChange:(s=>O({...g,config_json:ce(g.config_json,{after_shipped_hours:Math.max(1,Number(s.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(be.repeat_interval_hours||24),onChange:(s=>O({...g,config_json:ce(g.config_json,{repeat_interval_hours:Math.max(1,Number(s.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(be.max_attempts||1),onChange:(s=>O({...g,config_json:ce(g.config_json,{max_attempts:Math.max(1,Number(s.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:((Qe=(Xe=g.actions)==null?void 0:Xe.find(s=>s.action_type==="send_text"))==null?void 0:Qe.message_template)||"",onChange:(s=>{var c;return O({...g,actions:((c=g.actions)!=null&&c.length?g.actions:_e("review_missing_timeout")).map(x=>x.action_type==="send_text"?{...x,message_template:s.target.value}:x)})}),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:g.priority||100,onChange:(s=>O({...g,priority:Number(s.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:g.enabled!==!1,onChange:(s=>O({...g,enabled:s.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:(()=>je(!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:f,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),Me&&S&&Fe.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:S.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:(()=>pe(!1)),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(ke,{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:S.item_id||"",onChange:(s=>te({...S,item_id:s.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),U.filter(s=>!r||s.cookie_id===r).map(s=>e.jsx("option",{value:s.item_id,children:s.item_title||s.item_id},`${s.cookie_id}-${s.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:S.type||"text",onChange:(s=>{const c=s.target.value;te({...S,type:c,reply_content:c==="text"?S.reply_content:"",image_url:c==="image"?S.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:S.keyword||"",onChange:(s=>te({...S,keyword:s.target.value})),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),S.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:S.image_url||"",onChange:(s=>te({...S,image_url:s.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:S.reply_content||"",onChange:(s=>te({...S,reply_content:s.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:(()=>pe(!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:ut,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),Pe&&Fe.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:(()=>ve(!1)),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(ke,{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:L.cookie_id,onChange:(s=>ie({...L,cookie_id:s.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),V.map(s=>e.jsx("option",{value:s.id,children:Re(s)},s.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:(()=>ie({...L,enabled:!L.enabled})),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${L.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 ${L.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:L.reply_content,onChange:(s=>ie({...L,reply_content:s.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:L.reply_image_url,onChange:(s=>ie({...L,reply_image_url:s.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:L.reply_once,onChange:(s=>ie({...L,reply_once:s.target.checked})),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:(()=>ve(!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:gt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})};export{is as default}; diff --git a/internal/webui/static/assets/Settings-BmdW4Gos.js b/internal/webui/static/assets/Settings-BmdW4Gos.js deleted file mode 100644 index 03ae232..0000000 --- a/internal/webui/static/assets/Settings-BmdW4Gos.js +++ /dev/null @@ -1 +0,0 @@ -import{r,j as e}from"./react-vendor-C_od1ZSF.js";import{a as xe,g as re,p as le}from"./index-zEvleK2K.js";import{f as ue,R as se,aa as pe,r as me,z as R,F as O,ab as he,t as ge,S as te,ac as ae,ad as ye,o as fe}from"./icons-vendor-DwxdQTKt.js";const ne="https://dashscope.aliyuncs.com/compatible-mode/v1",be=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],we=new Set(["ai_api_key_configured","smtp_password_configured","qq_reply_secret_key_configured","captcha.remote_secret_key_configured","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"]),oe=new Set(["ai_api_key","smtp_password","qq_reply_secret_key","captcha.remote_secret_key"]),je=s=>{if("values"in s||"secrets"in s)return s;const a={},o={};for(const[d,h]of Object.entries(s))if(h!=null){if(oe.has(d)){o[d]=h===""?{action:"clear"}:{action:"replace",value:String(h)};continue}a[d]=h}return Object.keys(o).length>0?{values:a,secrets:o}:a},ve=s=>{const a={...s};for(const o of oe){const d=`${o}_configured`;d in a&&(a[d]=a[d]===!0||a[d]==="true")}if("renewal_log_retention_days"in a){const o=Number(a.renewal_log_retention_days);a.renewal_log_retention_days=Number.isFinite(o)?o:10}return a},_e=async(s,a)=>le("/api/v1/session/credentials",s,a),Ne=async s=>{const a=await re("/api/v1/settings/system",void 0,s),o=a.data||a.settings||a;return ve(o)},Se=async(s,a)=>le("/api/v1/settings/system",je(s),a),ke=async(s,a="",o)=>{const d=await xe("/api/v1/settings/ai-models",{base_url:s,api_key:a},o);return Array.isArray(d.models)?d.models:[]},Ce=async s=>re("/api/v1/session",void 0,s),Ee=s=>Object.fromEntries(Object.entries(s).filter(([a,o])=>!we.has(a)&&o!==void 0&&o!==null)),Ae=s=>s.new_username.trim().length<3?"用户名至少需要 3 个字符":s.current_password?s.new_password&&s.new_password.length<8?"新密码至少需要 8 个字符":s.new_password!==s.confirm_password?"两次输入的新密码不一致":"":"请输入当前密码确认身份",f=(s,a,o)=>s===a&&!o.aborted,D=s=>s instanceof Error&&s.message==="请求已取消",K=(s,a)=>s instanceof Error?s.message:a,Ie=(s="")=>({new_username:s,current_password:"",new_password:"",confirm_password:""}),T=(s,a)=>({type:s,text:a}),Me=()=>{const[s,a]=r.useState(null),[o,d]=r.useState(!1),[h,p]=r.useState(""),[S,A]=r.useState(!1),[P,k]=r.useState(""),[C,w]=r.useState([]),[j,I]=r.useState(!1),[M,x]=r.useState(""),[$,v]=r.useState(!1),[z,q]=r.useState(!1),[U,u]=r.useState(!1),[b,F]=r.useState(!1),[G,V]=r.useState(!1),[Y,_]=r.useState(!1),[L,y]=r.useState(null),[t,X]=r.useState(()=>Ie()),[ce,J]=r.useState("idle"),Z=r.useRef(null),ee=r.useRef(null),m=r.useRef(0),W=r.useRef(null);ee.current=s;const E=r.useCallback(()=>{var c;(c=W.current)==null||c.abort();const n=new AbortController;return W.current=n,m.current+=1,{controller:n,sequence:m.current}},[]),B=r.useCallback(async(n,c=!1,l)=>{const i=n||ee.current,g=(i==null?void 0:i.ai_api_url)||(i==null?void 0:i.ai_base_url)||ne;I(!0),x("");try{const N=await ke(g,(i==null?void 0:i.ai_api_key)||"",{signal:l});if(l!=null&&l.aborted)return;w(N),v(c&&N.length>0),!(i!=null&&i.ai_model)&&N.length>0&&a(Q=>Q&&{...Q,ai_model:N[0]})}catch(N){if(l!=null&&l.aborted||D(N))return;w([]),v(!1),x(K(N,"读取模型失败"))}finally{l!=null&&l.aborted||I(!1)}},[]),H=r.useCallback(()=>{const{controller:n,sequence:c}=E();d(!0),J("loading"),p(""),Promise.all([Ne({signal:n.signal}),Ce({signal:n.signal})]).then(([l,i])=>{f(m.current,c,n.signal)&&(a(l),i.username&&X(g=>({...g,new_username:i.username||""})),B(l,!1,n.signal),J("success"))}).catch(l=>{!f(m.current,c,n.signal)||D(l)||(a(null),p(K(l,"加载配置失败")),J("error"))}).finally(()=>{f(m.current,c,n.signal)&&d(!1)})},[E,B]);r.useEffect(()=>(H(),(()=>{var n;return(n=W.current)==null?void 0:n.abort()})),[H]),r.useEffect(()=>{const n=c=>{var l;(l=Z.current)!=null&&l.contains(c.target)||v(!1)};return document.addEventListener("mousedown",n),(()=>document.removeEventListener("mousedown",n))},[]);const ie=r.useCallback(async()=>{if(!s||S)return;const{controller:n,sequence:c}=E();A(!0),k("");try{if(await Se(Ee(s),{signal:n.signal}),!f(m.current,c,n.signal))return;window.alert("系统配置已保存")}catch(l){if(!f(m.current,c,n.signal)||D(l))return;k(K(l,"保存配置失败"))}finally{f(m.current,c,n.signal)&&A(!1)}},[E,S,s]),de=r.useCallback(async n=>{n.preventDefault(),y(null);const c=Ae(t);if(c){y(T("error",c));return}const{controller:l,sequence:i}=E();_(!0);try{const g=await _e({current_password:t.current_password,new_username:t.new_username.trim(),new_password:t.new_password||void 0},{signal:l.signal});if(!f(m.current,i,l.signal))return;if(!g.success){y(T("error",g.message||"登录凭据更新失败"));return}y(T("success",g.message||"登录凭据已更新")),window.setTimeout(()=>window.location.reload(),1400)}catch(g){if(!f(m.current,i,l.signal)||D(g))return;y(T("error",K(g,"登录凭据更新失败")))}finally{f(m.current,i,l.signal)&&_(!1)}},[E,t]);return{settings:s,loading:o,loadError:h,saving:S,saveError:P,aiModels:C,modelsLoading:j,modelError:M,modelDropdownOpen:$,showApiKey:z,showCaptchaSecret:U,showCurrentPassword:b,showNewPassword:G,credentialsSaving:Y,credentialsMessage:L,credentials:t,requestStatus:ce,modelPickerRef:Z,loadSettings:H,loadAIModels:((n,c)=>void B(n,c)),handleSave:ie,handleCredentialsSave:de,setSettings:a,setModelDropdownOpen:v,setShowApiKey:q,setShowCaptchaSecret:u,setShowCurrentPassword:F,setShowNewPassword:V,setCredentials:X,setCredentialsMessage:y}},Re=()=>{const{settings:s,loading:a,loadError:o,saving:d,saveError:h,aiModels:p,modelsLoading:S,modelError:A,modelDropdownOpen:P,showApiKey:k,showCaptchaSecret:C,showCurrentPassword:w,showNewPassword:j,credentialsSaving:I,credentialsMessage:M,credentials:x,modelPickerRef:$,loadSettings:v,loadAIModels:z,handleSave:q,handleCredentialsSave:U,setSettings:u,setModelDropdownOpen:b,setShowApiKey:F,setShowCaptchaSecret:G,setShowCurrentPassword:V,setShowNewPassword:Y,setCredentials:_}=Me();if(!s)return e.jsxs("div",{className:"p-8 text-center text-gray-400 space-y-3",children:[o||(a?"加载配置中...":"暂无配置"),!a&&o&&e.jsx("div",{children:e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:v,children:"重新加载"})})]});const L=s.ai_model||"",y=p;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(ue,{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:v,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(se,{className:"w-4 h-4"}),"刷新"]})]}),h&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>{}),children:"重试保存"})]}),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(pe,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:s.log_level||"info",onChange:(t=>u({...s,log_level:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:be.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:s.log_format||"text",onChange:(t=>u({...s,log_format:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:s.renewal_log_retention_days??10,onChange:(t=>u({...s,renewal_log_retention_days:parseInt(t.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(me,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:s.ai_api_url||ne,onChange:(t=>u({...s,ai_api_url:t.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:k?"text":"password",value:s.ai_api_key||"",onChange:(t=>u({...s,ai_api_key:t.target.value})),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:s.ai_api_key_configured?"已配置,如需替换请输入新密钥":"sk-..."}),e.jsx("button",{type:"button",onClick:(()=>F(!k)),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:k?e.jsx(R,{className:"w-4 h-4"}):e.jsx(O,{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:L,onFocus:(()=>p.length>0&&b(!0)),onChange:(t=>{u({...s,ai_model:t.target.value}),p.length>0&&b(!0)}),onKeyDown:(t=>{t.key==="Escape"&&b(!1),t.key==="ArrowDown"&&p.length>0&&b(!0)}),className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:(()=>p.length>0&&b(t=>!t)),disabled:p.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(he,{className:`w-4 h-4 transition-transform ${P?"rotate-180":""}`})}),P&&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:y.length>0?y.map(t=>e.jsxs("button",{type:"button",onClick:(()=>{u({...s,ai_model:t}),b(!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:t}),t===L&&e.jsx(ge,{className:"w-4 h-4 shrink-0 text-brand"})]},t)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:(()=>z(void 0,!0)),disabled:S,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(se,{className:`w-4 h-4 ${S?"animate-spin":""}`}),"读取模型"]})]}),A?e.jsx("p",{className:"text-xs text-red-500",children:A}):e.jsx("p",{className:"text-xs text-gray-500",children:p.length>0?`已从当前 API 地址读取到 ${p.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(te,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务地址"}),e.jsx("input",{type:"url",value:s["captcha.remote_service_url"]||"",onChange:(t=>u({...s,"captcha.remote_service_url":t.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:C?"text":"password",value:s["captcha.remote_secret_key"]||"",onChange:(t=>u({...s,"captcha.remote_secret_key":t.target.value})),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off",placeholder:s["captcha.remote_secret_key_configured"]?"已配置,如需替换请输入新密钥":"请输入服务秘钥"}),e.jsx("button",{type:"button",onClick:(()=>G(!C)),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:C?"隐藏秘钥":"显示秘钥",children:C?e.jsx(R,{className:"w-4 h-4"}):e.jsx(O,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(s["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:(t=>u({...s,"captcha.remote_pass_cookies":t.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(ae,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:U,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(ye,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:x.new_username,onChange:(t=>_({...x,new_username:t.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:w?"text":"password",value:x.current_password,onChange:(t=>_({...x,current_password:t.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:(()=>V(!w)),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:w?"隐藏密码":"显示密码",children:w?e.jsx(R,{className:"w-4 h-4"}):e.jsx(O,{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:j?"text":"password",value:x.new_password,onChange:(t=>_({...x,new_password:t.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:(()=>Y(!j)),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:j?"隐藏密码":"显示密码",children:j?e.jsx(R,{className:"w-4 h-4"}):e.jsx(O,{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:j?"text":"password",value:x.confirm_password,onChange:(t=>_({...x,confirm_password:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),M&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${M.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(te,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:M.text})]}),e.jsxs("button",{type:"submit",disabled:I||!x.new_username||!x.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(ae,{className:"w-4 h-4"}),I?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:q,disabled:d,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(fe,{className:"w-6 h-6"}),d?"保存中...":"保存所有配置"]})})]})};export{Re as default}; diff --git a/internal/webui/static/assets/Settings-WRDun9wT.js b/internal/webui/static/assets/Settings-WRDun9wT.js new file mode 100644 index 0000000..477f761 --- /dev/null +++ b/internal/webui/static/assets/Settings-WRDun9wT.js @@ -0,0 +1 @@ +import{a as r,j as e}from"./react-vendor-l-BBvuKH.js";import{r as M,a as q}from"./index-WrujSo30.js";import{f as xe,R as ae,aa as ue,r as pe,z as T,F as D,ab as me,t as he,S as re,ac as le,ad as ge,o as ye}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const ne="https://dashscope.aliyuncs.com/compatible-mode/v1",fe=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],be=new Set(["ai_api_key_configured","smtp_password_configured","qq_reply_secret_key_configured","captcha.remote_secret_key_configured","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"]),oe=new Set(["ai_api_key","smtp_password","qq_reply_secret_key","captcha.remote_secret_key"]),we=s=>{if("values"in s||"secrets"in s)return s;const a={},n={};for(const[d,x]of Object.entries(s))if(x!=null){if(oe.has(d)){n[d]=x===""?{action:"clear"}:{action:"replace",value:String(x)};continue}(typeof x=="string"||typeof x=="number"||typeof x=="boolean")&&(a[d]=x)}return Object.keys(n).length>0?{values:a,secrets:n}:a},je=s=>{const a={...s};for(const n of oe){const d=`${n}_configured`;d in a&&(a[d]=a[d]===!0||a[d]==="true")}if("renewal_log_retention_days"in a){const n=Number(a.renewal_log_retention_days);a.renewal_log_retention_days=Number.isFinite(n)?n:10}return a},ve=async(s,a)=>M(n=>q.PUT("/api/v1/session/credentials",{body:s,signal:n}),a),_e=async s=>{const a=await M(n=>q.GET("/api/v1/settings/system",{signal:n}),s);return je(a)},Ne=async(s,a)=>M(n=>q.PUT("/api/v1/settings/system",{body:we(s),signal:n}),a),Se=async(s,a="",n)=>{const d=await M(x=>q.POST("/api/v1/settings/ai-models",{body:{base_url:s,api_key:a},signal:x}),n);return Array.isArray(d.models)?d.models:[]},ke=async s=>M(a=>q.GET("/api/v1/session",{signal:a}),s),Ce=s=>Object.fromEntries(Object.entries(s).filter(([a,n])=>!be.has(a)&&n!==void 0&&n!==null)),Ee=s=>s.new_username.trim().length<3?"用户名至少需要 3 个字符":s.current_password?s.new_password&&s.new_password.length<8?"新密码至少需要 8 个字符":s.new_password!==s.confirm_password?"两次输入的新密码不一致":"":"请输入当前密码确认身份",f=(s,a,n)=>s===a&&!n.aborted,K=s=>s instanceof Error&&s.message==="请求已取消",U=(s,a)=>s instanceof Error?s.message:a,Ae=(s="")=>({new_username:s,current_password:"",new_password:"",confirm_password:""}),$=(s,a)=>({type:s,text:a}),Ie=()=>{const[s,a]=r.useState(null),[n,d]=r.useState(!1),[x,m]=r.useState(""),[S,A]=r.useState(!1),[R,k]=r.useState(""),[C,w]=r.useState([]),[j,I]=r.useState(!1),[P,u]=r.useState(""),[z,v]=r.useState(!1),[G,L]=r.useState(!1),[F,p]=r.useState(!1),[b,V]=r.useState(!1),[Y,J]=r.useState(!1),[W,_]=r.useState(!1),[O,y]=r.useState(null),[t,ee]=r.useState(()=>Ae()),[ce,B]=r.useState("idle"),se=r.useRef(null),te=r.useRef(null),h=r.useRef(0),H=r.useRef(null);te.current=s;const E=r.useCallback(()=>{var c;(c=H.current)==null||c.abort();const o=new AbortController;return H.current=o,h.current+=1,{controller:o,sequence:h.current}},[]),Q=r.useCallback(async(o,c=!1,l)=>{const i=o||te.current,g=(i==null?void 0:i.ai_api_url)||(i==null?void 0:i.ai_base_url)||ne;I(!0),u("");try{const N=await Se(g,(i==null?void 0:i.ai_api_key)||"",{signal:l});if(l!=null&&l.aborted)return;w(N),v(c&&N.length>0),!(i!=null&&i.ai_model)&&N.length>0&&a(Z=>Z&&{...Z,ai_model:N[0]})}catch(N){if(l!=null&&l.aborted||K(N))return;w([]),v(!1),u(U(N,"读取模型失败"))}finally{l!=null&&l.aborted||I(!1)}},[]),X=r.useCallback(()=>{const{controller:o,sequence:c}=E();d(!0),B("loading"),m(""),Promise.all([_e({signal:o.signal}),ke({signal:o.signal})]).then(([l,i])=>{f(h.current,c,o.signal)&&(a(l),i.username&&ee(g=>({...g,new_username:i.username||""})),Q(l,!1,o.signal),B("success"))}).catch(l=>{!f(h.current,c,o.signal)||K(l)||(a(null),m(U(l,"加载配置失败")),B("error"))}).finally(()=>{f(h.current,c,o.signal)&&d(!1)})},[E,Q]);r.useEffect(()=>(X(),(()=>{var o;return(o=H.current)==null?void 0:o.abort()})),[X]),r.useEffect(()=>{const o=c=>{var l;(l=se.current)!=null&&l.contains(c.target)||v(!1)};return document.addEventListener("mousedown",o),(()=>document.removeEventListener("mousedown",o))},[]);const ie=r.useCallback(async()=>{if(!s||S)return;const{controller:o,sequence:c}=E();A(!0),k("");try{if(await Ne(Ce(s),{signal:o.signal}),!f(h.current,c,o.signal))return;window.alert("系统配置已保存")}catch(l){if(!f(h.current,c,o.signal)||K(l))return;k(U(l,"保存配置失败"))}finally{f(h.current,c,o.signal)&&A(!1)}},[E,S,s]),de=r.useCallback(async o=>{o.preventDefault(),y(null);const c=Ee(t);if(c){y($("error",c));return}const{controller:l,sequence:i}=E();_(!0);try{const g=await ve({current_password:t.current_password,new_username:t.new_username.trim(),new_password:t.new_password||void 0},{signal:l.signal});if(!f(h.current,i,l.signal))return;if(!g.success){y($("error",g.message||"登录凭据更新失败"));return}y($("success",g.message||"登录凭据已更新")),window.setTimeout(()=>window.location.reload(),1400)}catch(g){if(!f(h.current,i,l.signal)||K(g))return;y($("error",U(g,"登录凭据更新失败")))}finally{f(h.current,i,l.signal)&&_(!1)}},[E,t]);return{settings:s,loading:n,loadError:x,saving:S,saveError:R,aiModels:C,modelsLoading:j,modelError:P,modelDropdownOpen:z,showApiKey:G,showCaptchaSecret:F,showCurrentPassword:b,showNewPassword:Y,credentialsSaving:W,credentialsMessage:O,credentials:t,requestStatus:ce,modelPickerRef:se,loadSettings:X,loadAIModels:((o,c)=>void Q(o,c)),handleSave:ie,handleCredentialsSave:de,setSettings:a,setModelDropdownOpen:v,setShowApiKey:L,setShowCaptchaSecret:p,setShowCurrentPassword:V,setShowNewPassword:J,setCredentials:ee,setCredentialsMessage:y}},Le=()=>{const{settings:s,loading:a,loadError:n,saving:d,saveError:x,aiModels:m,modelsLoading:S,modelError:A,modelDropdownOpen:R,showApiKey:k,showCaptchaSecret:C,showCurrentPassword:w,showNewPassword:j,credentialsSaving:I,credentialsMessage:P,credentials:u,modelPickerRef:z,loadSettings:v,loadAIModels:G,handleSave:L,handleCredentialsSave:F,setSettings:p,setModelDropdownOpen:b,setShowApiKey:V,setShowCaptchaSecret:Y,setShowCurrentPassword:J,setShowNewPassword:W,setCredentials:_}=Ie();if(!s)return e.jsxs("div",{className:"p-8 text-center text-gray-400 space-y-3",children:[n||(a?"加载配置中...":"暂无配置"),!a&&n&&e.jsx("div",{children:e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:v,children:"重新加载"})})]});const O=s.ai_model||"",y=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(xe,{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:v,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(ae,{className:"w-4 h-4"}),"刷新"]})]}),x&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:[e.jsx("span",{children:x}),e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>{}),children:"重试保存"})]}),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(ue,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:s.log_level||"info",onChange:(t=>p({...s,log_level:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:fe.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:s.log_format||"text",onChange:(t=>p({...s,log_format:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:s.renewal_log_retention_days??10,onChange:(t=>p({...s,renewal_log_retention_days:parseInt(t.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(pe,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:s.ai_api_url||ne,onChange:(t=>p({...s,ai_api_url:t.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:k?"text":"password",value:s.ai_api_key||"",onChange:(t=>p({...s,ai_api_key:t.target.value})),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:s.ai_api_key_configured?"已配置,如需替换请输入新密钥":"sk-..."}),e.jsx("button",{type:"button",onClick:(()=>V(!k)),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:k?e.jsx(T,{className:"w-4 h-4"}):e.jsx(D,{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:z,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:O,onFocus:(()=>m.length>0&&b(!0)),onChange:(t=>{p({...s,ai_model:t.target.value}),m.length>0&&b(!0)}),onKeyDown:(t=>{t.key==="Escape"&&b(!1),t.key==="ArrowDown"&&m.length>0&&b(!0)}),className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:(()=>m.length>0&&b(t=>!t)),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(me,{className:`w-4 h-4 transition-transform ${R?"rotate-180":""}`})}),R&&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:y.length>0?y.map(t=>e.jsxs("button",{type:"button",onClick:(()=>{p({...s,ai_model:t}),b(!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:t}),t===O&&e.jsx(he,{className:"w-4 h-4 shrink-0 text-brand"})]},t)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:(()=>G(void 0,!0)),disabled:S,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(ae,{className:`w-4 h-4 ${S?"animate-spin":""}`}),"读取模型"]})]}),A?e.jsx("p",{className:"text-xs text-red-500",children:A}):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(re,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务地址"}),e.jsx("input",{type:"url",value:s["captcha.remote_service_url"]||"",onChange:(t=>p({...s,"captcha.remote_service_url":t.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:C?"text":"password",value:s["captcha.remote_secret_key"]||"",onChange:(t=>p({...s,"captcha.remote_secret_key":t.target.value})),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off",placeholder:s["captcha.remote_secret_key_configured"]?"已配置,如需替换请输入新密钥":"请输入服务秘钥"}),e.jsx("button",{type:"button",onClick:(()=>Y(!C)),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:C?"隐藏秘钥":"显示秘钥",children:C?e.jsx(T,{className:"w-4 h-4"}):e.jsx(D,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(s["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:(t=>p({...s,"captcha.remote_pass_cookies":t.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(le,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:F,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(ge,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:u.new_username,onChange:(t=>_({...u,new_username:t.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:w?"text":"password",value:u.current_password,onChange:(t=>_({...u,current_password:t.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:(()=>J(!w)),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:w?"隐藏密码":"显示密码",children:w?e.jsx(T,{className:"w-4 h-4"}):e.jsx(D,{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:j?"text":"password",value:u.new_password,onChange:(t=>_({...u,new_password:t.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:(()=>W(!j)),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:j?"隐藏密码":"显示密码",children:j?e.jsx(T,{className:"w-4 h-4"}):e.jsx(D,{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:j?"text":"password",value:u.confirm_password,onChange:(t=>_({...u,confirm_password:t.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),P&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${P.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(re,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:P.text})]}),e.jsxs("button",{type:"submit",disabled:I||!u.new_username||!u.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(le,{className:"w-4 h-4"}),I?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:L,disabled:d,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"}),d?"保存中...":"保存所有配置"]})})]})};export{Le as default}; diff --git a/internal/webui/static/assets/charts-vendor-deWqkrdG.js b/internal/webui/static/assets/charts-vendor-DlHaeEQJ.js similarity index 99% rename from internal/webui/static/assets/charts-vendor-deWqkrdG.js rename to internal/webui/static/assets/charts-vendor-DlHaeEQJ.js index 11d7ea3..330f896 100644 --- a/internal/webui/static/assets/charts-vendor-deWqkrdG.js +++ b/internal/webui/static/assets/charts-vendor-DlHaeEQJ.js @@ -1,4 +1,4 @@ -import{r as d,b as fo,R as Sp}from"./react-vendor-C_od1ZSF.js";import{c as Z,g as Qt,u as cu,w as Ip,a as P,s as Ca,b as Te,t as Ep,p as re,d as Qe,e as q,f as kp,D as G,I as su,r as Xf,E as jp,h as Cp,i as Tp,j as ir,k as dn,l as $p,m as Mp,n as Dp,P as _p}from"./vendor-Es4K8PXl.js";var Np=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function vo(e){if(typeof e!="string")return!1;var t=Np;return t.includes(e)}var Lp=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],Rp=new Set(Lp);function Zf(e){return typeof e!="string"?!1:Rp.has(e)}function Qf(e){return typeof e=="string"&&e.startsWith("data-")}function Le(e){if(typeof e!="object"||e===null)return{};var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(Zf(r)||Qf(r))&&(t[r]=e[r]);return t}function Jt(e){if(e==null)return null;if(d.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Le(t)}return typeof e=="object"&&!Array.isArray(e)?Le(e):null}function Ke(e){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(Zf(r)||Qf(r)||vo(r))&&(t[r]=e[r]);return t}function Bp(e){return e==null?null:d.isValidElement(e)?Ke(e.props):typeof e=="object"&&!Array.isArray(e)?Ke(e):null}var zp=["children","width","height","viewBox","className","style","title","desc"];function $i(){return $i=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=e.children,n=e.width,a=e.height,i=e.viewBox,o=e.className,l=e.style,u=e.title,c=e.desc,s=Kp(e,zp),f=i||{width:n,height:a,x:0,y:0},v=Z("recharts-surface",o);return d.createElement("svg",$i({},Ke(s),{className:v,width:n,height:a,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:t}),d.createElement("title",null,u),d.createElement("desc",null,c),r)}),Fp=["children","className"];function Mi(){return Mi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=e.children,n=e.className,a=Up(e,Fp),i=Z("recharts-layer",n);return d.createElement("g",Mi({className:i},Ke(a),{ref:t}),r)}),Jf=d.createContext(null),Vp=()=>d.useContext(Jf);function te(e){return function(){return e}}const ed=Math.cos,Vn=Math.sin,et=Math.sqrt,Gn=Math.PI,Ta=2*Gn,Di=Math.PI,_i=2*Di,Vt=1e-6,Gp=_i-Vt;function td(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return td;const r=10**t;return function(n){this._+=n[0];for(let a=1,i=n.length;aVt)if(!(Math.abs(f*u-c*s)>Vt)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let h=n-o,m=a-l,p=u*u+c*c,y=h*h+m*m,g=Math.sqrt(p),x=Math.sqrt(v),A=i*Math.tan((Di-Math.acos((p+v-y)/(2*g*x)))/2),w=A/x,O=A/g;Math.abs(w-1)>Vt&&this._append`L${t+w*s},${r+w*f}`,this._append`A${i},${i},0,0,${+(f*h>s*m)},${this._x1=t+O*u},${this._y1=r+O*c}`}}arc(t,r,n,a,i,o){if(t=+t,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),u=n*Math.sin(a),c=t+l,s=r+u,f=1^o,v=o?a-i:i-a;this._x1===null?this._append`M${c},${s}`:(Math.abs(this._x1-c)>Vt||Math.abs(this._y1-s)>Vt)&&this._append`L${c},${s}`,n&&(v<0&&(v=v%_i+_i),v>Gp?this._append`A${n},${n},0,1,${f},${t-l},${r-u}A${n},${n},0,1,${f},${this._x1=c},${this._y1=s}`:v>Vt&&this._append`A${n},${n},0,${+(v>=Di)},${f},${this._x1=t+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(t,r,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function mo(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new qp(t)}function po(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rd(e){this._context=e}rd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function $a(e){return new rd(e)}function nd(e){return e[0]}function ad(e){return e[1]}function id(e,t){var r=te(!0),n=null,a=$a,i=null,o=mo(l);e=typeof e=="function"?e:e===void 0?nd:te(e),t=typeof t=="function"?t:t===void 0?ad:te(t);function l(u){var c,s=(u=po(u)).length,f,v=!1,h;for(n==null&&(i=a(h=o())),c=0;c<=s;++c)!(c=h;--m)l.point(A[m],w[m]);l.lineEnd(),l.areaEnd()}g&&(A[v]=+e(y,v,f),w[v]=+t(y,v,f),l.point(n?+n(y,v,f):A[v],r?+r(y,v,f):w[v]))}if(x)return l=null,x+""||null}function s(){return id().defined(a).curve(o).context(i)}return c.x=function(f){return arguments.length?(e=typeof f=="function"?f:te(+f),n=null,c):e},c.x0=function(f){return arguments.length?(e=typeof f=="function"?f:te(+f),c):e},c.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:te(+f),c):n},c.y=function(f){return arguments.length?(t=typeof f=="function"?f:te(+f),r=null,c):t},c.y0=function(f){return arguments.length?(t=typeof f=="function"?f:te(+f),c):t},c.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:te(+f),c):r},c.lineX0=c.lineY0=function(){return s().x(e).y(t)},c.lineY1=function(){return s().x(e).y(r)},c.lineX1=function(){return s().x(n).y(t)},c.defined=function(f){return arguments.length?(a=typeof f=="function"?f:te(!!f),c):a},c.curve=function(f){return arguments.length?(o=f,i!=null&&(l=o(i)),c):o},c.context=function(f){return arguments.length?(f==null?i=l=null:l=o(i=f),c):i},c}class od{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function Xp(e){return new od(e,!0)}function Zp(e){return new od(e,!1)}const yo={draw(e,t){const r=et(t/Gn);e.moveTo(r,0),e.arc(0,0,r,0,Ta)}},Qp={draw(e,t){const r=et(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},ld=et(1/3),Jp=ld*2,ey={draw(e,t){const r=et(t/Jp),n=r*ld;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},ty={draw(e,t){const r=et(t),n=-r/2;e.rect(n,n,r,r)}},ry=.8908130915292852,ud=Vn(Gn/10)/Vn(7*Gn/10),ny=Vn(Ta/10)*ud,ay=-ed(Ta/10)*ud,iy={draw(e,t){const r=et(t*ry),n=ny*r,a=ay*r;e.moveTo(0,-r),e.lineTo(n,a);for(let i=1;i<5;++i){const o=Ta*i/5,l=ed(o),u=Vn(o);e.lineTo(u*r,-l*r),e.lineTo(l*n-u*a,u*n+l*a)}e.closePath()}},vi=et(3),oy={draw(e,t){const r=-et(t/(vi*3));e.moveTo(0,r*2),e.lineTo(-vi*r,-r),e.lineTo(vi*r,-r),e.closePath()}},We=-.5,Fe=et(3)/2,Ni=1/et(12),ly=(Ni/2+1)*3,uy={draw(e,t){const r=et(t/ly),n=r/2,a=r*Ni,i=n,o=r*Ni+r,l=-i,u=o;e.moveTo(n,a),e.lineTo(i,o),e.lineTo(l,u),e.lineTo(We*n-Fe*a,Fe*n+We*a),e.lineTo(We*i-Fe*o,Fe*i+We*o),e.lineTo(We*l-Fe*u,Fe*l+We*u),e.lineTo(We*n+Fe*a,We*a-Fe*n),e.lineTo(We*i+Fe*o,We*o-Fe*i),e.lineTo(We*l+Fe*u,We*u-Fe*l),e.closePath()}};function cy(e,t){let r=null,n=mo(a);e=typeof e=="function"?e:te(e||yo),t=typeof t=="function"?t:te(t===void 0?64:+t);function a(){let i;if(r||(r=i=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:te(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:te(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function Yn(){}function qn(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function cd(e){this._context=e}cd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:qn(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function sy(e){return new cd(e)}function sd(e){this._context=e}sd.prototype={areaStart:Yn,areaEnd:Yn,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function fy(e){return new sd(e)}function fd(e){this._context=e}fd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function dy(e){return new fd(e)}function dd(e){this._context=e}dd.prototype={areaStart:Yn,areaEnd:Yn,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function vy(e){return new dd(e)}function fu(e){return e<0?-1:1}function du(e,t,r){var n=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(n||a<0&&-0),o=(r-e._y1)/(a||n<0&&-0),l=(i*a+o*n)/(n+a);return(fu(i)+fu(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function vu(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function hi(e,t,r){var n=e._x0,a=e._y0,i=e._x1,o=e._y1,l=(i-n)/3;e._context.bezierCurveTo(n+l,a+l*t,i-l,o-l*r,i,o)}function Xn(e){this._context=e}Xn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:hi(this,this._t0,vu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,hi(this,vu(this,r=du(this,e,t)),r);break;default:hi(this,this._t0,r=du(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function vd(e){this._context=new hd(e)}(vd.prototype=Object.create(Xn.prototype)).point=function(e,t){Xn.prototype.point.call(this,t,e)};function hd(e){this._context=e}hd.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,a,i){this._context.bezierCurveTo(t,e,n,r,i,a)}};function hy(e){return new Xn(e)}function my(e){return new vd(e)}function md(e){this._context=e}md.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=hu(e),a=hu(t),i=0,o=1;o=0;--t)a[t]=(o[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function yy(e){return new Ma(e,.5)}function gy(e){return new Ma(e,0)}function by(e){return new Ma(e,1)}function er(e,t){if((o=e.length)>1)for(var r=1,n,a,i=e[t[0]],o,l=i.length;r=0;)r[t]=t;return r}function xy(e,t){return e[t]}function wy(e){const t=[];return t.key=e,t}function Ay(){var e=te([]),t=Li,r=er,n=xy;function a(i){var o=Array.from(e.apply(this,arguments),wy),l,u=o.length,c=-1,s;for(const f of i)for(l=0,++c;l0){for(var r,n,a=0,i=e[0].length,o;a0){for(var r=0,n=e[t[0]],a,i=n.length;r0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,n=1,a,i,o;n1&&arguments[1]!==void 0?arguments[1]:Iy,r=10**t,n=Math.round(e*r)/r;return Object.is(n,-0)?0:n}function Se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var l=r[o-1];return typeof l=="string"?a+l+i:l!==void 0?a+Tt(l)+i:a+i},"")}var we=e=>e===0?0:e>0?1:-1,Je=e=>typeof e=="number"&&e!=+e,tr=e=>typeof e=="string"&&e.length>1&&e.indexOf("%")===e.length-1,$=e=>(typeof e=="number"||e instanceof Number)&&!Je(e),ut=e=>$(e)||typeof e=="string",Ey=0,nn=e=>{var t=++Ey;return"".concat(e||"").concat(t)},Ce=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!$(t)&&typeof t!="string")return n;var i;if(tr(t)){if(r==null)return n;var o=t.indexOf("%");i=r*parseFloat(t.slice(0,o))/100}else i=+t;return Je(i)&&(i=n),a&&r!=null&&i>r&&(i=r),i},pd=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,r={},n=0;nn&&(typeof t=="function"?t(n):Qt(n,t))===r)}var ie=e=>e===null||typeof e>"u",vn=e=>ie(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function _e(e){return e!=null}function or(){}var ky=["type","size","sizeType"];function Ri(){return Ri=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(vn(e));return gd[t]||yo},Ny=(e,t,r)=>{if(t==="area")return e;switch(r){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var n=18*Dy;return 1.25*e*e*(Math.tan(n)-Math.tan(n*2)*Math.tan(n)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Ly=(e,t)=>{gd["symbol".concat(vn(e))]=t},bd=e=>{var t=e.type,r=t===void 0?"circle":t,n=e.size,a=n===void 0?64:n,i=e.sizeType,o=i===void 0?"area":i,l=$y(e,ky),u=pu(pu({},l),{},{type:r,size:a,sizeType:o}),c="circle";typeof r=="string"&&(c=r);var s=()=>{var p=_y(c),y=cy().type(p).size(Ny(a,o,c)),g=y();if(g!==null)return g},f=u.className,v=u.cx,h=u.cy,m=Ke(u);return $(v)&&$(h)&&$(a)?d.createElement("path",Ri({},m,{className:Z("recharts-symbols",f),transform:"translate(".concat(v,", ").concat(h,")"),d:s()})):null};bd.registerSymbol=Ly;var xd=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,go=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var r=e;if(d.isValidElement(e)&&(r=e.props),typeof r!="object"&&typeof r!="function")return null;var n={};return Object.keys(r).forEach(a=>{vo(a)&&typeof r[a]=="function"&&(n[a]=(i=>r[a](r,i)))}),n},Ry=(e,t,r)=>n=>(e(t,r,n),null),hn=(e,t,r)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var n=null;return Object.keys(e).forEach(a=>{var i=e[a];vo(a)&&typeof i=="function"&&(n||(n={}),n[a]=Ry(i,t,r))}),n};function yu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function By(e){for(var t=1;t(o[l]===void 0&&n[l]!==void 0&&(o[l]=n[l]),o),r);return i}function Zn(){return Zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=e.children,n=e.width,a=e.height,i=e.viewBox,o=e.className,l=e.style,u=e.title,c=e.desc,s=Kp(e,zp),f=i||{width:n,height:a,x:0,y:0},v=Z("recharts-surface",o);return d.createElement("svg",$i({},Ke(s),{className:v,width:n,height:a,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:t}),d.createElement("title",null,u),d.createElement("desc",null,c),r)}),Fp=["children","className"];function Mi(){return Mi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=e.children,n=e.className,a=Up(e,Fp),i=Z("recharts-layer",n);return d.createElement("g",Mi({className:i},Ke(a),{ref:t}),r)}),Jf=d.createContext(null),Vp=()=>d.useContext(Jf);function te(e){return function(){return e}}const ed=Math.cos,Vn=Math.sin,et=Math.sqrt,Gn=Math.PI,Ta=2*Gn,Di=Math.PI,_i=2*Di,Vt=1e-6,Gp=_i-Vt;function td(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return td;const r=10**t;return function(n){this._+=n[0];for(let a=1,i=n.length;aVt)if(!(Math.abs(f*u-c*s)>Vt)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let h=n-o,m=a-l,p=u*u+c*c,y=h*h+m*m,g=Math.sqrt(p),x=Math.sqrt(v),A=i*Math.tan((Di-Math.acos((p+v-y)/(2*g*x)))/2),w=A/x,O=A/g;Math.abs(w-1)>Vt&&this._append`L${t+w*s},${r+w*f}`,this._append`A${i},${i},0,0,${+(f*h>s*m)},${this._x1=t+O*u},${this._y1=r+O*c}`}}arc(t,r,n,a,i,o){if(t=+t,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),u=n*Math.sin(a),c=t+l,s=r+u,f=1^o,v=o?a-i:i-a;this._x1===null?this._append`M${c},${s}`:(Math.abs(this._x1-c)>Vt||Math.abs(this._y1-s)>Vt)&&this._append`L${c},${s}`,n&&(v<0&&(v=v%_i+_i),v>Gp?this._append`A${n},${n},0,1,${f},${t-l},${r-u}A${n},${n},0,1,${f},${this._x1=c},${this._y1=s}`:v>Vt&&this._append`A${n},${n},0,${+(v>=Di)},${f},${this._x1=t+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(t,r,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function mo(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new qp(t)}function po(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rd(e){this._context=e}rd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function $a(e){return new rd(e)}function nd(e){return e[0]}function ad(e){return e[1]}function id(e,t){var r=te(!0),n=null,a=$a,i=null,o=mo(l);e=typeof e=="function"?e:e===void 0?nd:te(e),t=typeof t=="function"?t:t===void 0?ad:te(t);function l(u){var c,s=(u=po(u)).length,f,v=!1,h;for(n==null&&(i=a(h=o())),c=0;c<=s;++c)!(c=h;--m)l.point(A[m],w[m]);l.lineEnd(),l.areaEnd()}g&&(A[v]=+e(y,v,f),w[v]=+t(y,v,f),l.point(n?+n(y,v,f):A[v],r?+r(y,v,f):w[v]))}if(x)return l=null,x+""||null}function s(){return id().defined(a).curve(o).context(i)}return c.x=function(f){return arguments.length?(e=typeof f=="function"?f:te(+f),n=null,c):e},c.x0=function(f){return arguments.length?(e=typeof f=="function"?f:te(+f),c):e},c.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:te(+f),c):n},c.y=function(f){return arguments.length?(t=typeof f=="function"?f:te(+f),r=null,c):t},c.y0=function(f){return arguments.length?(t=typeof f=="function"?f:te(+f),c):t},c.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:te(+f),c):r},c.lineX0=c.lineY0=function(){return s().x(e).y(t)},c.lineY1=function(){return s().x(e).y(r)},c.lineX1=function(){return s().x(n).y(t)},c.defined=function(f){return arguments.length?(a=typeof f=="function"?f:te(!!f),c):a},c.curve=function(f){return arguments.length?(o=f,i!=null&&(l=o(i)),c):o},c.context=function(f){return arguments.length?(f==null?i=l=null:l=o(i=f),c):i},c}class od{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function Xp(e){return new od(e,!0)}function Zp(e){return new od(e,!1)}const yo={draw(e,t){const r=et(t/Gn);e.moveTo(r,0),e.arc(0,0,r,0,Ta)}},Qp={draw(e,t){const r=et(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},ld=et(1/3),Jp=ld*2,ey={draw(e,t){const r=et(t/Jp),n=r*ld;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},ty={draw(e,t){const r=et(t),n=-r/2;e.rect(n,n,r,r)}},ry=.8908130915292852,ud=Vn(Gn/10)/Vn(7*Gn/10),ny=Vn(Ta/10)*ud,ay=-ed(Ta/10)*ud,iy={draw(e,t){const r=et(t*ry),n=ny*r,a=ay*r;e.moveTo(0,-r),e.lineTo(n,a);for(let i=1;i<5;++i){const o=Ta*i/5,l=ed(o),u=Vn(o);e.lineTo(u*r,-l*r),e.lineTo(l*n-u*a,u*n+l*a)}e.closePath()}},vi=et(3),oy={draw(e,t){const r=-et(t/(vi*3));e.moveTo(0,r*2),e.lineTo(-vi*r,-r),e.lineTo(vi*r,-r),e.closePath()}},We=-.5,Fe=et(3)/2,Ni=1/et(12),ly=(Ni/2+1)*3,uy={draw(e,t){const r=et(t/ly),n=r/2,a=r*Ni,i=n,o=r*Ni+r,l=-i,u=o;e.moveTo(n,a),e.lineTo(i,o),e.lineTo(l,u),e.lineTo(We*n-Fe*a,Fe*n+We*a),e.lineTo(We*i-Fe*o,Fe*i+We*o),e.lineTo(We*l-Fe*u,Fe*l+We*u),e.lineTo(We*n+Fe*a,We*a-Fe*n),e.lineTo(We*i+Fe*o,We*o-Fe*i),e.lineTo(We*l+Fe*u,We*u-Fe*l),e.closePath()}};function cy(e,t){let r=null,n=mo(a);e=typeof e=="function"?e:te(e||yo),t=typeof t=="function"?t:te(t===void 0?64:+t);function a(){let i;if(r||(r=i=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:te(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:te(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function Yn(){}function qn(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function cd(e){this._context=e}cd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:qn(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function sy(e){return new cd(e)}function sd(e){this._context=e}sd.prototype={areaStart:Yn,areaEnd:Yn,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function fy(e){return new sd(e)}function fd(e){this._context=e}fd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:qn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function dy(e){return new fd(e)}function dd(e){this._context=e}dd.prototype={areaStart:Yn,areaEnd:Yn,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function vy(e){return new dd(e)}function fu(e){return e<0?-1:1}function du(e,t,r){var n=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(n||a<0&&-0),o=(r-e._y1)/(a||n<0&&-0),l=(i*a+o*n)/(n+a);return(fu(i)+fu(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function vu(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function hi(e,t,r){var n=e._x0,a=e._y0,i=e._x1,o=e._y1,l=(i-n)/3;e._context.bezierCurveTo(n+l,a+l*t,i-l,o-l*r,i,o)}function Xn(e){this._context=e}Xn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:hi(this,this._t0,vu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,hi(this,vu(this,r=du(this,e,t)),r);break;default:hi(this,this._t0,r=du(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function vd(e){this._context=new hd(e)}(vd.prototype=Object.create(Xn.prototype)).point=function(e,t){Xn.prototype.point.call(this,t,e)};function hd(e){this._context=e}hd.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,a,i){this._context.bezierCurveTo(t,e,n,r,i,a)}};function hy(e){return new Xn(e)}function my(e){return new vd(e)}function md(e){this._context=e}md.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=hu(e),a=hu(t),i=0,o=1;o=0;--t)a[t]=(o[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function yy(e){return new Ma(e,.5)}function gy(e){return new Ma(e,0)}function by(e){return new Ma(e,1)}function er(e,t){if((o=e.length)>1)for(var r=1,n,a,i=e[t[0]],o,l=i.length;r=0;)r[t]=t;return r}function xy(e,t){return e[t]}function wy(e){const t=[];return t.key=e,t}function Ay(){var e=te([]),t=Li,r=er,n=xy;function a(i){var o=Array.from(e.apply(this,arguments),wy),l,u=o.length,c=-1,s;for(const f of i)for(l=0,++c;l0){for(var r,n,a=0,i=e[0].length,o;a0){for(var r=0,n=e[t[0]],a,i=n.length;r0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,n=1,a,i,o;n1&&arguments[1]!==void 0?arguments[1]:Iy,r=10**t,n=Math.round(e*r)/r;return Object.is(n,-0)?0:n}function Se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var l=r[o-1];return typeof l=="string"?a+l+i:l!==void 0?a+Tt(l)+i:a+i},"")}var we=e=>e===0?0:e>0?1:-1,Je=e=>typeof e=="number"&&e!=+e,tr=e=>typeof e=="string"&&e.length>1&&e.indexOf("%")===e.length-1,$=e=>(typeof e=="number"||e instanceof Number)&&!Je(e),ut=e=>$(e)||typeof e=="string",Ey=0,nn=e=>{var t=++Ey;return"".concat(e||"").concat(t)},Ce=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!$(t)&&typeof t!="string")return n;var i;if(tr(t)){if(r==null)return n;var o=t.indexOf("%");i=r*parseFloat(t.slice(0,o))/100}else i=+t;return Je(i)&&(i=n),a&&r!=null&&i>r&&(i=r),i},pd=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,r={},n=0;nn&&(typeof t=="function"?t(n):Qt(n,t))===r)}var ie=e=>e===null||typeof e>"u",vn=e=>ie(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function _e(e){return e!=null}function or(){}var ky=["type","size","sizeType"];function Ri(){return Ri=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(vn(e));return gd[t]||yo},Ny=(e,t,r)=>{if(t==="area")return e;switch(r){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var n=18*Dy;return 1.25*e*e*(Math.tan(n)-Math.tan(n*2)*Math.tan(n)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Ly=(e,t)=>{gd["symbol".concat(vn(e))]=t},bd=e=>{var t=e.type,r=t===void 0?"circle":t,n=e.size,a=n===void 0?64:n,i=e.sizeType,o=i===void 0?"area":i,l=$y(e,ky),u=pu(pu({},l),{},{type:r,size:a,sizeType:o}),c="circle";typeof r=="string"&&(c=r);var s=()=>{var p=_y(c),y=cy().type(p).size(Ny(a,o,c)),g=y();if(g!==null)return g},f=u.className,v=u.cx,h=u.cy,m=Ke(u);return $(v)&&$(h)&&$(a)?d.createElement("path",Ri({},m,{className:Z("recharts-symbols",f),transform:"translate(".concat(v,", ").concat(h,")"),d:s()})):null};bd.registerSymbol=Ly;var xd=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,go=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var r=e;if(d.isValidElement(e)&&(r=e.props),typeof r!="object"&&typeof r!="function")return null;var n={};return Object.keys(r).forEach(a=>{vo(a)&&typeof r[a]=="function"&&(n[a]=(i=>r[a](r,i)))}),n},Ry=(e,t,r)=>n=>(e(t,r,n),null),hn=(e,t,r)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var n=null;return Object.keys(e).forEach(a=>{var i=e[a];vo(a)&&typeof i=="function"&&(n||(n={}),n[a]=Ry(i,t,r))}),n};function yu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function By(e){for(var t=1;t(o[l]===void 0&&n[l]!==void 0&&(o[l]=n[l]),o),r);return i}function Zn(){return Zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var h=f.formatter||a,m=Z({"recharts-legend-item":!0,["legend-item-".concat(v)]:!0,inactive:f.inactive});if(f.type==="none")return null;var p=typeof l=="object"?wd({},l):{};p.color=f.inactive?i:p.color||f.color;var y=h?h(f.value,f,v):f.value;return d.createElement("li",Zn({className:m,style:c,key:"legend-item-".concat(v)},hn(e,f,v)),d.createElement(ho,{width:r,height:r,viewBox:u,style:s,"aria-label":"".concat(f.value," legend icon")},d.createElement(Yy,{data:f,iconType:o,inactiveColor:i})),d.createElement("span",{className:"recharts-legend-item-text",style:p},y))})}var Xy=e=>{var t=Ae(e,Vy),r=t.payload,n=t.layout,a=t.align;if(!r||!r.length)return null;var i={padding:0,margin:0,textAlign:n==="horizontal"?a:"left"};return d.createElement("ul",{className:"recharts-default-legend",style:i},d.createElement(qy,Zn({},t,{payload:r})))};function Ad(e,t,r){return t===!0?cu(e,r):typeof t=="function"?cu(e,t):e}var bo=d.createContext(null),Zy=e=>e,ee=()=>{var e=d.useContext(bo);return e?e.store.dispatch:Zy},Fn=()=>{},Qy=()=>Fn,Jy=(e,t)=>e===t;function M(e){var t=d.useContext(bo),r=d.useMemo(()=>t?n=>{if(n!=null)return e(n)}:Fn,[t,e]);return Ip.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:Qy,t?t.store.getState:Fn,t?t.store.getState:Fn,r,Jy)}var Pd=e=>e.legend.settings,eg=e=>e.legend.size,tg=e=>e.legend.payload,rg=P([tg,Pd],(e,t)=>{var r=t.itemSorter,n=e.flat(1);return r?Ca(n,r):n});function ng(){return M(rg)}function ag(e,t){return ug(e)||lg(e,t)||og(e,t)||ig()}function ig(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. diff --git a/internal/webui/static/assets/icons-vendor-DwxdQTKt.js b/internal/webui/static/assets/icons-vendor-Bgrth_9N.js similarity index 99% rename from internal/webui/static/assets/icons-vendor-DwxdQTKt.js rename to internal/webui/static/assets/icons-vendor-Bgrth_9N.js index dff17a0..4e643bb 100644 --- a/internal/webui/static/assets/icons-vendor-DwxdQTKt.js +++ b/internal/webui/static/assets/icons-vendor-Bgrth_9N.js @@ -1,4 +1,4 @@ -import{r as h}from"./react-vendor-C_od1ZSF.js";/** +import{a as h}from"./react-vendor-l-BBvuKH.js";/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. diff --git a/internal/webui/static/assets/index-WrujSo30.js b/internal/webui/static/assets/index-WrujSo30.js new file mode 100644 index 0000000..004f6a2 --- /dev/null +++ b/internal/webui/static/assets/index-WrujSo30.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Ba2fUvQH.js","assets/react-vendor-l-BBvuKH.js","assets/dateTime-DDi7rqpW.js","assets/icons-vendor-Bgrth_9N.js","assets/charts-vendor-DlHaeEQJ.js","assets/vendor-cRYyTeIw.js","assets/vendor-DUblxfbA.css","assets/AccountList-DgwrfNi_.js","assets/OrderList-CXbMt2fz.js","assets/CardList-CfmBeFUG.js","assets/ItemList-CH6EVxKe.js","assets/Settings-WRDun9wT.js","assets/Rules-4H5_byLi.js","assets/Notifications-DHwrazHy.js","assets/Chat-MUERwcqZ.js"])))=>i.map(i=>d[i]); +import{c as M,j as s,a as l,d as ne}from"./react-vendor-l-BBvuKH.js";import{o as re}from"./vendor-cRYyTeIw.js";import{L as V,a as U,S as ae,U as oe,A as ie,b as ce,c as le,M as de,C as ue,B as he,d as me,Z as fe,e as pe,f as ge,G as q,g as xe,h as ye,i as be}from"./icons-vendor-Bgrth_9N.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();class we extends M.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReload=()=>{window.location.reload()}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{hasError:n}=this.state,{children:t}=this.props;return n?s.jsx("main",{className:"flex min-h-screen items-center justify-center bg-canvas p-6 text-ink",children:s.jsxs("section",{className:"max-w-md text-center",children:[s.jsx("h1",{className:"text-xl font-semibold",children:"页面暂时无法显示"}),s.jsx("button",{className:"ios-btn-primary mt-6 px-4 py-2",type:"button",onClick:this.handleReload,children:"重新加载"})]})}):t}}const ve=3e4,je=10*6e4;let k=!1;class N extends Error{constructor(n,t){super(Ee(t,n)),this.name="ApiError",this.status=n,this.code=E(t)?t.code:`http_${n}`,this.requestId=E(t)?t.request_id:void 0,this.request_id=this.requestId,this.details=E(t)?t.details:void 0,this.payload=t}}const $=()=>{k||typeof window>"u"||(k=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{k=!1}))},Le=e=>{if(!e)return"";const n=new URLSearchParams;for(const[o,r]of Object.entries(e))r!=null&&n.set(o,String(r));const t=n.toString();return t?`?${t}`:""},A=async(e,n,t={})=>{var d;const o=Le(t.params),r=`${n}${o}`,i=D(t.signal,t.timeoutMs??ve);let a;try{a=await fetch(r,{method:e,credentials:"include",signal:i.signal,headers:{...t.body===void 0?{}:{"Content-Type":"application/json"}},body:t.body===void 0?void 0:JSON.stringify(t.body)})}catch(h){throw i.signal.aborted?new Error((d=t.signal)!=null&&d.aborted?"请求已取消":"请求超时,请稍后重试"):h}finally{i.cleanup()}const u=(a.headers.get("content-type")||"").includes("application/json");if(!a.ok){a.status===401&&!t.skipAuthLogout&&$();const h=await H(a,u);throw new N(a.status,h)}return u?await a.json():await a.text()},j=async(e,n,t)=>A("GET",e,{params:n,...t}),G=async(e,n,t)=>A("POST",e,{body:n,...t}),mt=async(e,n,t)=>A("PUT",e,{body:n,...t}),ft=async(e,n,t)=>A("DELETE",e,{params:n,...t}),Ce=async(e,n,t={})=>{var u;const o=D(t.signal,t.timeoutMs??je);let r;try{r=await fetch(e,{method:"POST",credentials:"include",signal:o.signal,body:n})}catch(d){throw o.signal.aborted?new Error((u=t.signal)!=null&&u.aborted?"请求已取消":"上传超时,请稍后重试"):d}finally{o.cleanup()}const a=(r.headers.get("content-type")||"").includes("application/json"),c=await H(r,a);if(!r.ok)throw r.status===401&&$(),new N(r.status,c);return c},D=(e,n)=>{const t=new AbortController,o=()=>t.abort(e==null?void 0:e.reason);e!=null&&e.aborted?o():e==null||e.addEventListener("abort",o,{once:!0});const r=globalThis.setTimeout(()=>t.abort(new DOMException("timeout","TimeoutError")),Math.max(1,n));return{signal:t.signal,cleanup:()=>{globalThis.clearTimeout(r),e==null||e.removeEventListener("abort",o)}}},H=async(e,n)=>n?e.json().catch(()=>{}):e.text().catch(()=>{}),E=e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.code=="string"&&typeof n.message=="string"},Ee=(e,n)=>typeof e=="string"?e:E(e)?e.message:`请求失败: ${n}`,Ne=3e4,Se=async(e,n)=>{const t=new URL(typeof e=="string"?e:e instanceof URL?e.toString():e.url),o=e instanceof Request?e:new Request(e,n),r=o.method==="GET"||o.method==="HEAD"?void 0:await o.clone().text(),i=t.origin==="http://localhost"?`${t.pathname}${t.search}`:e;return await fetch(i,{method:o.method,headers:o.headers,body:r,signal:o.signal,credentials:"include"})},_e=typeof location>"u"?"http://localhost":location.origin,P=re({baseUrl:_e,fetch:Se});async function T(e,n={}){var o;const t=D(n.signal,n.timeoutMs??Ne);try{const r=await e(t.signal);if(r.response.status===401&&!n.skipAuthLogout&&$(),r.error!==void 0)throw new N(r.response.status,r.error);if(r.data===void 0)throw new N(r.response.status,void 0);return r.data}catch(r){throw t.signal.aborted?new Error((o=n.signal)!=null&&o.aborted?"请求已取消":"请求超时,请稍后重试"):r}finally{t.cleanup()}}const Ae=async e=>{const n=await T(t=>P.POST("/api/v1/session/login",{body:e,signal:t}),{skipAuthLogout:!0});return{...n,token:n.token??void 0}},Pe=async e=>{const n=await T(t=>P.POST("/api/v1/session/initialize",{body:{password:e},signal:t}),{skipAuthLogout:!0});return{...n,token:n.token??void 0}},Te=async e=>T(n=>P.GET("/api/v1/session",{signal:n}),e),ke=async()=>({success:!0,message:(await T(n=>P.POST("/api/v1/session/logout",{body:{},signal:n}))).message}),J=l.createContext(void 0),Re=({children:e})=>{const[n,t]=l.useState(!1),[o,r]=l.useState(!1),[i,a]=l.useState(!0),[c,u]=l.useState(!1),d=()=>{t(!1),r(!1)};l.useEffect(()=>{const g=new AbortController;let p=!0;Te({signal:g.signal}).then(y=>{if(p){if((y==null?void 0:y.initialized)===!1){u(!0),d();return}u(!1),y!=null&&y.authenticated?(t(!0),r(y.is_admin===!0)):d()}}).catch(y=>{!p||y instanceof DOMException&&y.name==="AbortError"||(u(!1),d())}).finally(()=>{p&&a(!1)});const m=()=>d();return window.addEventListener("auth:logout",m),(()=>{p=!1,g.abort(),window.removeEventListener("auth:logout",m)})},[]);const h=async g=>{const p=await Ae(g);return p.success&&(u(!1),t(!0),r(p.is_admin===!0)),p},x=async g=>{const p=await Pe(g);return p.success&&(u(!1),t(!0),r(p.is_admin===!0)),p},f=async()=>{try{await ke()}finally{d()}};return s.jsx(J.Provider,{value:{checkingAuth:i,isLoggedIn:n,isAdmin:o,needsInit:c,signIn:h,initialize:x,signOut:f},children:e})},Z=()=>{const e=l.useContext(J);if(!e)throw new Error("useSession 必须在 SessionProvider 内使用");return e},Y="ydisks.sidebar.v1",Ie=()=>{try{return window.localStorage.getItem(Y)==="collapsed"}catch{return!1}},Oe=e=>{try{window.localStorage.setItem(Y,e?"collapsed":"expanded")}catch{}},Me=({className:e="w-full h-full text-white"})=>s.jsx("svg",{className:e,viewBox:"0 0 256 256","aria-hidden":"true",children:s.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:s.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"})})}),K=({sizeClass:e="w-12 h-12",logoClassName:n="w-full h-full text-white"})=>s.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[s.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),s.jsxs("div",{className:`relative ${e} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[s.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[s.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),s.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),s.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)"})]}),s.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:s.jsx(Me,{className:n})})]})]}),$e=()=>{const{checkingAuth:e,needsInit:n,signIn:t,initialize:o}=Z(),[r,i]=l.useState(""),[a,c]=l.useState(""),[u,d]=l.useState(""),[h,x]=l.useState(""),[f,g]=l.useState(!1),[p,m]=l.useState(""),y=async b=>{b.preventDefault(),g(!0),m("");try{const w=await t({username:r,password:a});w.success||m(w.message||"登录失败")}catch(w){m(w instanceof Error&&w.message||"登录失败")}finally{g(!1)}},L=async b=>{if(b.preventDefault(),m(""),u.length<8){m("密码至少需要 8 个字符");return}if(u!==h){m("两次输入的密码不一致");return}g(!0);try{const w=await o(u);if(!w.success){m(w.message||"初始化失败,请重试");return}d(""),x("")}catch(w){m(w instanceof Error&&w.message||"初始化失败,请重试")}finally{g(!1)}};if(e)return s.jsx("main",{className:"flex min-h-screen items-center justify-center bg-surface","aria-label":"正在校验会话",children:s.jsx(V,{className:"h-8 w-8 animate-spin text-brand"})});const te=n?"首次设置管理员密码":"欢迎回来",se=n?"设置完成后会自动进入系统,管理员账号为 admin。":"Ydisks闲鱼助手 · 自动发货与管家系统";return s.jsx("main",{className:"flex min-h-screen items-center justify-center bg-canvas p-4 font-sans",children:s.jsxs("section",{className:"w-full max-w-lg rounded-xl border border-white bg-white/80 p-8 shadow-panel backdrop-blur-3xl md:p-12",children:[s.jsxs("header",{className:"mb-8 text-center",children:[s.jsx("div",{className:"mx-auto mb-6 flex justify-center",children:s.jsx(K,{sizeClass:"h-24 w-24"})}),s.jsx("h1",{className:"text-3xl font-extrabold text-gray-900",children:te}),s.jsx("p",{className:"mt-2 font-medium text-gray-600",children:se})]}),n?s.jsxs("form",{className:"space-y-5",onSubmit:L,children:[s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"设置管理员密码"}),s.jsx(U,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),s.jsx("input",{autoFocus:!0,className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(b=>d(b.target.value)),placeholder:"设置管理员密码(至少 8 个字符)",type:"password",value:u})]}),s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"确认管理员密码"}),s.jsx(ae,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),s.jsx("input",{className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(b=>x(b.target.value)),placeholder:"再次输入密码",type:"password",value:h})]}),s.jsx(z,{submitting:f,text:"设置密码并进入系统"})]}):s.jsxs("form",{className:"space-y-5",onSubmit:y,children:[s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"管理员账号"}),s.jsx(oe,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),s.jsx("input",{autoFocus:!0,className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(b=>i(b.target.value)),placeholder:"管理员账号",type:"text",value:r})]}),s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"管理员密码"}),s.jsx(U,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),s.jsx("input",{className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(b=>c(b.target.value)),placeholder:"密码",type:"password",value:a})]}),s.jsx(z,{submitting:f,text:"立即登录"})]}),p?s.jsx("p",{className:"mt-5 rounded-xl bg-red-50 p-3 text-center text-sm font-medium text-red-600",children:p}):null]})})},z=({submitting:e,text:n})=>s.jsx("button",{className:"ios-btn-primary flex h-14 w-full items-center justify-center gap-2 rounded-xl text-lg disabled:opacity-70",disabled:e,type:"submit",children:e?s.jsx(V,{className:"h-5 w-5 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx("span",{children:n}),s.jsx(ie,{className:"h-5 w-5"})]})}),De="modulepreload",Ue=function(e){return"/static/"+e},F={},v=function(n,t,o){let r=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=a(t.map(d=>{if(d=Ue(d),d in F)return;F[d]=!0;const h=d.endsWith(".css"),x=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${x}`))return;const f=document.createElement("link");if(f.rel=h?"stylesheet":De,h||(f.as="script"),f.crossOrigin="",f.href=d,u&&f.setAttribute("nonce",u),document.head.appendChild(f),h)return new Promise((g,p)=>{f.addEventListener("load",g),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return r.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return n().catch(i)})},qe=({activeTab:e,isAdmin:n=!1,collapsed:t,onToggleCollapsed:o,onNavigate:r,onLogout:i,buildInfo:a,hasUnreadChatMessage:c=!1})=>{const u=[{id:"dashboard",icon:ce,label:"仪表盘"},{id:"accounts",icon:le,label:"账号管理"},{id:"chat",icon:de,label:"在线聊天"},{id:"cards",icon:ue,label:"卡密库存"},{id:"items",icon:he,label:"商品列表"},{id:"orders",icon:me,label:"订单管理"},{id:"rules",icon:fe,label:"自动化规则"},{id:"notifications",icon:pe,label:"通知设置"},...n?[{id:"settings",icon:ge,label:"系统与AI"}]:[]],d=/^\d+\.\d+\.\d+$/.test(a.version)?`v${a.version}`:a.version;return s.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 ${t?"w-16":"w-64"}`,children:[s.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${t?"justify-center px-2":"gap-3 px-5"}`,children:[s.jsx(K,{sizeClass:"h-10 w-10"}),!t&&s.jsxs("div",{className:"min-w-0 leading-tight",children:[s.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),s.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),s.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${t?"px-2":"px-3"}`,"aria-label":"主导航",children:u.map(h=>{const x=h.icon,f=e===h.id;return s.jsx(M.Fragment,{children:s.jsxs("button",{type:"button",title:t?h.label:void 0,"aria-label":h.label,"aria-current":f?"page":void 0,onClick:(()=>r(h.id)),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${t?"justify-center":"gap-3 px-3.5"} ${f?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[s.jsxs("span",{className:"relative flex h-[19px] w-[19px] shrink-0",children:[s.jsx(x,{className:`h-[19px] w-[19px] ${f?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),h.id==="chat"&&c&&s.jsx("span",{className:"absolute -right-1 -top-1 h-3 w-3 rounded-full border-2 border-white bg-red-500",role:"status","aria-label":"在线聊天有未读消息"})]}),!t&&s.jsx("span",{className:"truncate text-sm font-bold",children:h.label}),f&&!t&&s.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},h.id)})}),s.jsxs("div",{children:[s.jsx("div",{title:t?`版本 ${a.version} · ${a.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${t?"flex justify-center px-1":"px-6"}`,children:t?s.jsx(q,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${a.version}`}):s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[s.jsx(q,{className:"h-3.5 w-3.5"}),"运行版本"]}),s.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[s.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:d}),s.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:a.commit})]})]})}),s.jsxs("div",{className:`space-y-2 p-2 ${t?"":"p-3"}`,children:[s.jsxs("button",{type:"button",onClick:o,title:t?"展开侧边栏":"收起侧边栏","aria-label":t?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${t?"justify-center":"gap-3 px-3"}`,children:[t?s.jsx(xe,{className:"h-5 w-5"}):s.jsx(ye,{className:"h-5 w-5"}),!t&&s.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),s.jsxs("button",{type:"button",onClick:i,title:t?"退出登录":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 ${t?"justify-center":"gap-3 px-3"}`,children:[s.jsx(be,{className:"h-5 w-5"}),!t&&s.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),pt=(e,n=["data","items","results"])=>{let t=e,o=0;for(;o<2;o+=1){if(Array.isArray(t))return t;if(!S(t))return[];for(const i of n){const a=t[i];if(Array.isArray(a))return a;if(a===null)return[]}const r=t.data;if(S(r)){t=r;continue}return[]}return[]},W=(e,n=["data","result"])=>{let t=e,o=0;for(;o<2;o+=1){if(!S(t))return;for(const r of n){const i=t[r];if(S(i))return i}return t}},ze=async e=>j("/api/v1/accounts/details",void 0,e),gt=async e=>j("/api/v1/accounts/runtime-status",void 0,e),Fe=async(e,n,t,o=!1)=>{const r=await j("/api/v1/chat/sessions",{account_id:e,cursor:n,refresh:o?1:void 0},o?{timeoutMs:6e4,...t}:t),i=W(r,["data","result"])||{};return{sessions:i.sessions||[],has_more:i.has_more===!0,next_cursor:i.next_cursor}},xt=async(e,n,t,o,r)=>{const i=await j("/api/v1/chat/messages",{account_id:e,chat_id:n,cursor:t,before_id:o},r),a=W(i,["data","result"])||{};return{messages:a.messages||[],has_more:a.has_more===!0,next_cursor:a.next_cursor,session:a.session}},yt=async(e,n)=>G("/api/v1/chat/messages",e,n),bt=async(e,n)=>{const t=new FormData;return Object.entries(e).forEach(([o,r])=>t.append(o,r)),Ce("/api/v1/chat/images",t,{timeoutMs:12e4,...n})},wt=async(e,n,t,o)=>G("/api/v1/chat/read",{account_id:e,chat_id:n,message_ids:t},o),_=new Set;let Q="connecting";const O=new Set,vt=e=>(e({type:"connection",state:Q}),_.add(e),(()=>_.delete(e))),C=e=>{Q=e;for(const n of _)n({type:"connection",state:e})},Be=e=>{for(const n of _)n({type:"message",message:e})},Ve=e=>(O.add(e),(()=>O.delete(e))),jt=e=>{for(const n of O)n(e)},Ge=1e3,He=e=>`【新消息】${e}`,Je=()=>{const[e,n]=l.useState(0),[t,o]=l.useState(!1),r=l.useRef(document.title),i=l.useRef(0);return l.useEffect(()=>{const c=()=>n(0),u=()=>{document.visibilityState==="visible"&&c()};return window.addEventListener("focus",c),document.addEventListener("visibilitychange",u),(()=>{window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",u)})},[]),l.useEffect(()=>{if(e<=0){document.title=r.current;return}let c=!0;const u=()=>{document.title=c?He(r.current):r.current};u();const d=window.setInterval(()=>{c=!c,u()},Ge);return(()=>{window.clearInterval(d),document.title=r.current})},[e]),l.useEffect(()=>{const c=new AbortController,u=i.current;return(async()=>{try{const x=(await ze({signal:c.signal})).filter(p=>p.enabled),f=await Promise.all(x.map(p=>Fe(p.id,void 0,{signal:c.signal})));if(c.signal.aborted||i.current!==u)return;const g=f.some(p=>p.sessions.some(m=>m.unread_count>0));o(g)}catch{}})(),(()=>c.abort())},[]),l.useEffect(()=>Ve(o),[]),{notifyIncomingMessage:l.useCallback(c=>{c.direction!=="incoming"||c.message_type==="system"||(i.current+=1,n(u=>u+1),o(!0))},[]),hasUnreadChatMessage:t}},Ze=()=>{const e=Je(),{notifyIncomingMessage:n,hasUnreadChatMessage:t}=e;return l.useEffect(()=>{let o=!1,r=0,i=0,a=null;const c=()=>{if(o)return;C("connecting");const u=window.location.protocol==="https:"?"wss:":"ws:";a=new WebSocket(`${u}//${window.location.host}/api/v1/chat/ws`),a.onopen=()=>{i=0,C("online")},a.onmessage=d=>{try{const x=JSON.parse(d.data).message;x&&(n(x),Be(x))}catch{}},a.onclose=()=>{if(o)return;C("offline");const d=Math.min(15e3,1e3*2**Math.min(i++,4));r=window.setTimeout(c,d)},a.onerror=()=>a==null?void 0:a.close()};return c(),(()=>{o=!0,window.clearTimeout(r),a==null||a.close(),C("offline")})},[n]),{hasUnreadChatMessage:t}},Ye=async e=>j("/health",void 0,e),R=l.lazy(()=>v(()=>import("./Dashboard-Ba2fUvQH.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Ke=l.lazy(()=>v(()=>import("./AccountList-DgwrfNi_.js"),__vite__mapDeps([7,1,3,5,6]))),We=l.lazy(()=>v(()=>import("./OrderList-CXbMt2fz.js"),__vite__mapDeps([8,1,2,3,5,6]))),Qe=l.lazy(()=>v(()=>import("./CardList-CfmBeFUG.js"),__vite__mapDeps([9,1,3,5,6]))),Xe=l.lazy(()=>v(()=>import("./ItemList-CH6EVxKe.js"),__vite__mapDeps([10,1,3,5,6]))),et=l.lazy(()=>v(()=>import("./Settings-WRDun9wT.js"),__vite__mapDeps([11,1,3,5,6]))),tt=l.lazy(()=>v(()=>import("./Rules-4H5_byLi.js"),__vite__mapDeps([12,1,3,5,6]))),st=l.lazy(()=>v(()=>import("./Notifications-DHwrazHy.js"),__vite__mapDeps([13,1,3,5,6]))),nt=l.lazy(()=>v(()=>import("./Chat-MUERwcqZ.js"),__vite__mapDeps([14,1,5,6,3]))),rt=()=>s.jsx("div",{className:"flex min-h-[24rem] items-center justify-center",role:"status","aria-label":"正在加载页面",children:s.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-brand/20 border-t-brand"})}),at=({activeTab:e,isAdmin:n,deliveryRuleTarget:t,onConfigureDelivery:o,onDeliveryTargetHandled:r})=>{const i=c=>{o({cookieId:c.cookie_id,itemId:c.item_id,requestId:Date.now()})},a=()=>{switch(e){case"dashboard":return s.jsx(R,{});case"accounts":return s.jsx(Ke,{});case"chat":return s.jsx(nt,{});case"orders":return s.jsx(We,{});case"cards":return s.jsx(Qe,{});case"items":return s.jsx(Xe,{onConfigureDelivery:i});case"rules":return s.jsx(tt,{initialDeliveryTarget:t,onDeliveryTargetHandled:r});case"notifications":return s.jsx(st,{isAdmin:n});case"settings":return n?s.jsx(et,{}):s.jsx(R,{});default:return s.jsx(R,{})}};return s.jsx(l.Suspense,{fallback:s.jsx(rt,{}),children:a()})},ot=({activeTab:e,isAdmin:n,collapsed:t,deliveryRuleTarget:o,onToggleCollapsed:r,onNavigate:i,onLogout:a,onConfigureDelivery:c,onDeliveryTargetHandled:u})=>{const[d,h]=l.useState({version:"dev",commit:"unknown"}),{hasUnreadChatMessage:x}=Ze();return l.useEffect(()=>{const f=new AbortController;return Ye({signal:f.signal}).then(g=>h({version:String(g.version||"dev"),commit:String(g.commit||"unknown")})).catch(g=>{g instanceof DOMException&&g.name}),(()=>f.abort())},[]),s.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[s.jsx(qe,{activeTab:e,isAdmin:n,collapsed:t,onToggleCollapsed:r,onNavigate:i,onLogout:a,buildInfo:d,hasUnreadChatMessage:x}),s.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${t?"ml-16":"ml-64"} ${e==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,children:[s.jsx("div",{className:"fixed top-0 right-0 -z-10 h-[800px] w-[800px] pointer-events-none rounded-full bg-gradient-to-bl from-blue-50 to-transparent opacity-60 blur-[120px]"}),s.jsx("div",{className:`${e==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:s.jsx(at,{activeTab:e,isAdmin:n,deliveryRuleTarget:o,onConfigureDelivery:c,onDeliveryTargetHandled:u})})]})]})},X={"/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"},I=Object.fromEntries(Object.entries(X).map(([e,n])=>[n,e])),B=()=>X[window.location.pathname]??"dashboard",it=()=>{const{isLoggedIn:e,isAdmin:n,signOut:t}=Z(),[o,r]=l.useState(B),[i,a]=l.useState(),[c,u]=l.useState(Ie);l.useEffect(()=>{const m=()=>r(B());return window.addEventListener("popstate",m),(()=>window.removeEventListener("popstate",m))},[]),l.useEffect(()=>{e&&!n&&o==="settings"&&(window.history.replaceState({},"",I.dashboard),r("dashboard"))},[o,n,e]);const d=m=>{const y=m==="settings"&&!n?"dashboard":m,L=I[y];L!==window.location.pathname&&window.history.pushState({},"",L),r(y)},h=m=>{const y=Object.prototype.hasOwnProperty.call(I,m)?m:"dashboard";d(y)},x=async()=>{try{await t()}catch(m){console.error("退出登录失败",m)}},f=()=>{u(m=>{const y=!m;return Oe(y),y})},g=m=>{a(m),d("rules")},p=()=>a(void 0);return e?s.jsx(ot,{activeTab:o,isAdmin:n,collapsed:c,deliveryRuleTarget:i,onToggleCollapsed:f,onNavigate:h,onLogout:x,onConfigureDelivery:g,onDeliveryTargetHandled:p}):s.jsx($e,{})},ct=()=>s.jsx(we,{children:s.jsx(Re,{children:s.jsx(it,{})})}),ee=document.getElementById("root");if(!ee)throw new Error("Could not find root element to mount to");const lt=ne.createRoot(ee);lt.render(s.jsx(M.StrictMode,{children:s.jsx(ct,{})}));export{N as A,P as a,G as b,pt as c,Ce as d,ft as e,Fe as f,j as g,jt as h,xt as i,yt as j,bt as k,ze as l,wt as m,gt as n,W as o,mt as p,T as r,vt as s}; diff --git a/internal/webui/static/assets/index-zEvleK2K.js b/internal/webui/static/assets/index-zEvleK2K.js deleted file mode 100644 index 6895a4f..0000000 --- a/internal/webui/static/assets/index-zEvleK2K.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-C9RwPfK-.js","assets/react-vendor-C_od1ZSF.js","assets/dateTime-DDi7rqpW.js","assets/icons-vendor-DwxdQTKt.js","assets/charts-vendor-deWqkrdG.js","assets/vendor-Es4K8PXl.js","assets/vendor-DUblxfbA.css","assets/AccountList-bbR-Z2_J.js","assets/OrderList-Dma_R9-T.js","assets/CardList-CvCo2zF6.js","assets/ItemList-CZPbhJDg.js","assets/Settings-BmdW4Gos.js","assets/Rules-CeggCy2B.js","assets/Notifications-DUiNU4WL.js","assets/Chat-CKN6Wl0-.js"])))=>i.map(i=>d[i]); -import{c as R,j as t,r as l,d as te}from"./react-vendor-C_od1ZSF.js";import{L as U,a as O,S as se,U as ne,A as re,b as ae,c as oe,M as ie,C as ce,B as le,d as de,Z as ue,e as he,f as me,G as M,g as fe,h as pe,i as xe}from"./icons-vendor-DwxdQTKt.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function s(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(r){if(r.ep)return;r.ep=!0;const i=s(r);fetch(r.href,i)}})();class ge extends R.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReload=()=>{window.location.reload()}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{hasError:n}=this.state,{children:s}=this.props;return n?t.jsx("main",{className:"flex min-h-screen items-center justify-center bg-canvas p-6 text-ink",children:t.jsxs("section",{className:"max-w-md text-center",children:[t.jsx("h1",{className:"text-xl font-semibold",children:"页面暂时无法显示"}),t.jsx("button",{className:"ios-btn-primary mt-6 px-4 py-2",type:"button",onClick:this.handleReload,children:"重新加载"})]})}):s}}const be=3e4,ye=10*6e4;let P=!1;class q extends Error{constructor(n,s){super(je(s,n)),this.name="ApiError",this.status=n,this.code=E(s)?s.code:`http_${n}`,this.requestId=E(s)?s.request_id:void 0,this.request_id=this.requestId,this.details=E(s)?s.details:void 0,this.payload=s}}const F=()=>{P||typeof window>"u"||(P=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{P=!1}))},ve=e=>{if(!e)return"";const n=new URLSearchParams;for(const[o,r]of Object.entries(e))r!=null&&n.set(o,String(r));const s=n.toString();return s?`?${s}`:""},A=async(e,n,s={})=>{var d;const o=ve(s.params),r=`${n}${o}`,i=B(s.signal,s.timeoutMs??be);let a;try{a=await fetch(r,{method:e,credentials:"include",signal:i.signal,headers:{...s.body===void 0?{}:{"Content-Type":"application/json"}},body:s.body===void 0?void 0:JSON.stringify(s.body)})}catch(h){throw i.signal.aborted?new Error((d=s.signal)!=null&&d.aborted?"请求已取消":"请求超时,请稍后重试"):h}finally{i.cleanup()}const u=(a.headers.get("content-type")||"").includes("application/json");if(!a.ok){a.status===401&&!s.skipAuthLogout&&F();const h=await V(a,u);throw new q(a.status,h)}return u?await a.json():await a.text()},j=async(e,n,s)=>A("GET",e,{params:n,...s}),L=async(e,n,s)=>A("POST",e,{body:n,...s}),ot=async(e,n,s)=>A("PUT",e,{body:n,...s}),it=async(e,n,s)=>A("DELETE",e,{params:n,...s}),we=async(e,n,s={})=>{var u;const o=B(s.signal,s.timeoutMs??ye);let r;try{r=await fetch(e,{method:"POST",credentials:"include",signal:o.signal,body:n})}catch(d){throw o.signal.aborted?new Error((u=s.signal)!=null&&u.aborted?"请求已取消":"上传超时,请稍后重试"):d}finally{o.cleanup()}const a=(r.headers.get("content-type")||"").includes("application/json"),c=await V(r,a);if(!r.ok)throw r.status===401&&F(),new q(r.status,c);return c},B=(e,n)=>{const s=new AbortController,o=()=>s.abort(e==null?void 0:e.reason);e!=null&&e.aborted?o():e==null||e.addEventListener("abort",o,{once:!0});const r=globalThis.setTimeout(()=>s.abort(new DOMException("timeout","TimeoutError")),Math.max(1,n));return{signal:s.signal,cleanup:()=>{globalThis.clearTimeout(r),e==null||e.removeEventListener("abort",o)}}},V=async(e,n)=>n?e.json().catch(()=>{}):e.text().catch(()=>{}),E=e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.code=="string"&&typeof n.message=="string"},je=(e,n)=>typeof e=="string"?e:E(e)?e.message:`请求失败: ${n}`,Le=async e=>L("/api/v1/session/login",e,{skipAuthLogout:!0}),Ce=async e=>L("/api/v1/session/initialize",{password:e},{skipAuthLogout:!0}),Ne=async e=>j("/api/v1/session",void 0,e),Ee=async()=>L("/api/v1/session/logout",{}),G=l.createContext(void 0),Se=({children:e})=>{const[n,s]=l.useState(!1),[o,r]=l.useState(!1),[i,a]=l.useState(!0),[c,u]=l.useState(!1),d=()=>{s(!1),r(!1)};l.useEffect(()=>{const x=new AbortController;let p=!0;Ne({signal:x.signal}).then(b=>{if(p){if((b==null?void 0:b.initialized)===!1){u(!0),d();return}u(!1),b!=null&&b.authenticated?(s(!0),r(b.is_admin===!0)):d()}}).catch(b=>{!p||b instanceof DOMException&&b.name==="AbortError"||(u(!1),d())}).finally(()=>{p&&a(!1)});const m=()=>d();return window.addEventListener("auth:logout",m),(()=>{p=!1,x.abort(),window.removeEventListener("auth:logout",m)})},[]);const h=async x=>{const p=await Le(x);return p.success&&(u(!1),s(!0),r(p.is_admin===!0)),p},g=async x=>{const p=await Ce(x);return p.success&&(u(!1),s(!0),r(p.is_admin===!0)),p},f=async()=>{try{await Ee()}finally{d()}};return t.jsx(G.Provider,{value:{checkingAuth:i,isLoggedIn:n,isAdmin:o,needsInit:c,signIn:h,initialize:g,signOut:f},children:e})},H=()=>{const e=l.useContext(G);if(!e)throw new Error("useSession 必须在 SessionProvider 内使用");return e},J="ydisks.sidebar.v1",_e=()=>{try{return window.localStorage.getItem(J)==="collapsed"}catch{return!1}},Ae=e=>{try{window.localStorage.setItem(J,e?"collapsed":"expanded")}catch{}},Pe=({className:e="w-full h-full text-white"})=>t.jsx("svg",{className:e,viewBox:"0 0 256 256","aria-hidden":"true",children:t.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:t.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"})})}),Z=({sizeClass:e="w-12 h-12",logoClassName:n="w-full h-full text-white"})=>t.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[t.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),t.jsxs("div",{className:`relative ${e} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[t.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),t.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),t.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)"})]}),t.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:t.jsx(Pe,{className:n})})]})]}),Te=()=>{const{checkingAuth:e,needsInit:n,signIn:s,initialize:o}=H(),[r,i]=l.useState(""),[a,c]=l.useState(""),[u,d]=l.useState(""),[h,g]=l.useState(""),[f,x]=l.useState(!1),[p,m]=l.useState(""),b=async y=>{y.preventDefault(),x(!0),m("");try{const v=await s({username:r,password:a});v.success||m(v.message||"登录失败")}catch(v){m(v instanceof Error&&v.message||"登录失败")}finally{x(!1)}},C=async y=>{if(y.preventDefault(),m(""),u.length<8){m("密码至少需要 8 个字符");return}if(u!==h){m("两次输入的密码不一致");return}x(!0);try{const v=await o(u);if(!v.success){m(v.message||"初始化失败,请重试");return}d(""),g("")}catch(v){m(v instanceof Error&&v.message||"初始化失败,请重试")}finally{x(!1)}};if(e)return t.jsx("main",{className:"flex min-h-screen items-center justify-center bg-surface","aria-label":"正在校验会话",children:t.jsx(U,{className:"h-8 w-8 animate-spin text-brand"})});const X=n?"首次设置管理员密码":"欢迎回来",ee=n?"设置完成后会自动进入系统,管理员账号为 admin。":"Ydisks闲鱼助手 · 自动发货与管家系统";return t.jsx("main",{className:"flex min-h-screen items-center justify-center bg-canvas p-4 font-sans",children:t.jsxs("section",{className:"w-full max-w-lg rounded-xl border border-white bg-white/80 p-8 shadow-panel backdrop-blur-3xl md:p-12",children:[t.jsxs("header",{className:"mb-8 text-center",children:[t.jsx("div",{className:"mx-auto mb-6 flex justify-center",children:t.jsx(Z,{sizeClass:"h-24 w-24"})}),t.jsx("h1",{className:"text-3xl font-extrabold text-gray-900",children:X}),t.jsx("p",{className:"mt-2 font-medium text-gray-600",children:ee})]}),n?t.jsxs("form",{className:"space-y-5",onSubmit:C,children:[t.jsxs("label",{className:"relative block",children:[t.jsx("span",{className:"sr-only",children:"设置管理员密码"}),t.jsx(O,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),t.jsx("input",{autoFocus:!0,className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(y=>d(y.target.value)),placeholder:"设置管理员密码(至少 8 个字符)",type:"password",value:u})]}),t.jsxs("label",{className:"relative block",children:[t.jsx("span",{className:"sr-only",children:"确认管理员密码"}),t.jsx(se,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),t.jsx("input",{className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(y=>g(y.target.value)),placeholder:"再次输入密码",type:"password",value:h})]}),t.jsx($,{submitting:f,text:"设置密码并进入系统"})]}):t.jsxs("form",{className:"space-y-5",onSubmit:b,children:[t.jsxs("label",{className:"relative block",children:[t.jsx("span",{className:"sr-only",children:"管理员账号"}),t.jsx(ne,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),t.jsx("input",{autoFocus:!0,className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(y=>i(y.target.value)),placeholder:"管理员账号",type:"text",value:r})]}),t.jsxs("label",{className:"relative block",children:[t.jsx("span",{className:"sr-only",children:"管理员密码"}),t.jsx(O,{className:"absolute left-5 top-1/2 h-5 w-5 -translate-y-1/2 text-gray-400"}),t.jsx("input",{className:"ios-input h-14 w-full rounded-xl py-4 pl-14 pr-6",onChange:(y=>c(y.target.value)),placeholder:"密码",type:"password",value:a})]}),t.jsx($,{submitting:f,text:"立即登录"})]}),p?t.jsx("p",{className:"mt-5 rounded-xl bg-red-50 p-3 text-center text-sm font-medium text-red-600",children:p}):null]})})},$=({submitting:e,text:n})=>t.jsx("button",{className:"ios-btn-primary flex h-14 w-full items-center justify-center gap-2 rounded-xl text-lg disabled:opacity-70",disabled:e,type:"submit",children:e?t.jsx(U,{className:"h-5 w-5 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n}),t.jsx(re,{className:"h-5 w-5"})]})}),ke="modulepreload",Ie=function(e){return"/static/"+e},D={},w=function(n,s,o){let r=Promise.resolve();if(s&&s.length>0){let a=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=a(s.map(d=>{if(d=Ie(d),d in D)return;D[d]=!0;const h=d.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const f=document.createElement("link");if(f.rel=h?"stylesheet":ke,h||(f.as="script"),f.crossOrigin="",f.href=d,u&&f.setAttribute("nonce",u),document.head.appendChild(f),h)return new Promise((x,p)=>{f.addEventListener("load",x),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return r.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return n().catch(i)})},Re=({activeTab:e,isAdmin:n=!1,collapsed:s,onToggleCollapsed:o,onNavigate:r,onLogout:i,buildInfo:a,hasUnreadChatMessage:c=!1})=>{const u=[{id:"dashboard",icon:ae,label:"仪表盘"},{id:"accounts",icon:oe,label:"账号管理"},{id:"chat",icon:ie,label:"在线聊天"},{id:"cards",icon:ce,label:"卡密库存"},{id:"items",icon:le,label:"商品列表"},{id:"orders",icon:de,label:"订单管理"},{id:"rules",icon:ue,label:"自动化规则"},{id:"notifications",icon:he,label:"通知设置"},...n?[{id:"settings",icon:me,label:"系统与AI"}]:[]],d=/^\d+\.\d+\.\d+$/.test(a.version)?`v${a.version}`:a.version;return t.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 ${s?"w-16":"w-64"}`,children:[t.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${s?"justify-center px-2":"gap-3 px-5"}`,children:[t.jsx(Z,{sizeClass:"h-10 w-10"}),!s&&t.jsxs("div",{className:"min-w-0 leading-tight",children:[t.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),t.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),t.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${s?"px-2":"px-3"}`,"aria-label":"主导航",children:u.map(h=>{const g=h.icon,f=e===h.id;return t.jsx(R.Fragment,{children:t.jsxs("button",{type:"button",title:s?h.label:void 0,"aria-label":h.label,"aria-current":f?"page":void 0,onClick:(()=>r(h.id)),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${s?"justify-center":"gap-3 px-3.5"} ${f?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[t.jsxs("span",{className:"relative flex h-[19px] w-[19px] shrink-0",children:[t.jsx(g,{className:`h-[19px] w-[19px] ${f?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),h.id==="chat"&&c&&t.jsx("span",{className:"absolute -right-1 -top-1 h-3 w-3 rounded-full border-2 border-white bg-red-500",role:"status","aria-label":"在线聊天有未读消息"})]}),!s&&t.jsx("span",{className:"truncate text-sm font-bold",children:h.label}),f&&!s&&t.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},h.id)})}),t.jsxs("div",{children:[t.jsx("div",{title:s?`版本 ${a.version} · ${a.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${s?"flex justify-center px-1":"px-6"}`,children:s?t.jsx(M,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${a.version}`}):t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[t.jsx(M,{className:"h-3.5 w-3.5"}),"运行版本"]}),t.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[t.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:d}),t.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:a.commit})]})]})}),t.jsxs("div",{className:`space-y-2 p-2 ${s?"":"p-3"}`,children:[t.jsxs("button",{type:"button",onClick:o,title:s?"展开侧边栏":"收起侧边栏","aria-label":s?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${s?"justify-center":"gap-3 px-3"}`,children:[s?t.jsx(fe,{className:"h-5 w-5"}):t.jsx(pe,{className:"h-5 w-5"}),!s&&t.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),t.jsxs("button",{type:"button",onClick:i,title:s?"退出登录":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 ${s?"justify-center":"gap-3 px-3"}`,children:[t.jsx(xe,{className:"h-5 w-5"}),!s&&t.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ct=(e,n=["data","items","results"])=>{let s=e,o=0;for(;o<2;o+=1){if(Array.isArray(s))return s;if(!S(s))return[];for(const i of n){const a=s[i];if(Array.isArray(a))return a;if(a===null)return[]}const r=s.data;if(S(r)){s=r;continue}return[]}return[]},Y=(e,n=["data","result"])=>{let s=e,o=0;for(;o<2;o+=1){if(!S(s))return;for(const r of n){const i=s[r];if(S(i))return i}return s}},Oe=async e=>j("/api/v1/accounts/details",void 0,e),lt=async e=>j("/api/v1/accounts/runtime-status",void 0,e),Me=async(e,n,s,o=!1)=>{const r=await j("/api/v1/chat/sessions",{account_id:e,cursor:n,refresh:o?1:void 0},o?{timeoutMs:6e4,...s}:s),i=Y(r,["data","result"])||{};return{sessions:i.sessions||[],has_more:i.has_more===!0,next_cursor:i.next_cursor}},dt=async(e,n,s,o,r)=>{const i=await j("/api/v1/chat/messages",{account_id:e,chat_id:n,cursor:s,before_id:o},r),a=Y(i,["data","result"])||{};return{messages:a.messages||[],has_more:a.has_more===!0,next_cursor:a.next_cursor,session:a.session}},ut=async(e,n)=>L("/api/v1/chat/messages",e,n),ht=async(e,n)=>{const s=new FormData;return Object.entries(e).forEach(([o,r])=>s.append(o,r)),we("/api/v1/chat/images",s,{timeoutMs:12e4,...n})},mt=async(e,n,s,o)=>L("/api/v1/chat/read",{account_id:e,chat_id:n,message_ids:s},o),_=new Set;let K="connecting";const I=new Set,ft=e=>(e({type:"connection",state:K}),_.add(e),(()=>_.delete(e))),N=e=>{K=e;for(const n of _)n({type:"connection",state:e})},$e=e=>{for(const n of _)n({type:"message",message:e})},De=e=>(I.add(e),(()=>I.delete(e))),pt=e=>{for(const n of I)n(e)},ze=1e3,Ue=e=>`【新消息】${e}`,qe=()=>{const[e,n]=l.useState(0),[s,o]=l.useState(!1),r=l.useRef(document.title),i=l.useRef(0);return l.useEffect(()=>{const c=()=>n(0),u=()=>{document.visibilityState==="visible"&&c()};return window.addEventListener("focus",c),document.addEventListener("visibilitychange",u),(()=>{window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",u)})},[]),l.useEffect(()=>{if(e<=0){document.title=r.current;return}let c=!0;const u=()=>{document.title=c?Ue(r.current):r.current};u();const d=window.setInterval(()=>{c=!c,u()},ze);return(()=>{window.clearInterval(d),document.title=r.current})},[e]),l.useEffect(()=>{const c=new AbortController,u=i.current;return(async()=>{try{const g=(await Oe({signal:c.signal})).filter(p=>p.enabled),f=await Promise.all(g.map(p=>Me(p.id,void 0,{signal:c.signal})));if(c.signal.aborted||i.current!==u)return;const x=f.some(p=>p.sessions.some(m=>m.unread_count>0));o(x)}catch{}})(),(()=>c.abort())},[]),l.useEffect(()=>De(o),[]),{notifyIncomingMessage:l.useCallback(c=>{c.direction!=="incoming"||c.message_type==="system"||(i.current+=1,n(u=>u+1),o(!0))},[]),hasUnreadChatMessage:s}},Fe=()=>{const e=qe(),{notifyIncomingMessage:n,hasUnreadChatMessage:s}=e;return l.useEffect(()=>{let o=!1,r=0,i=0,a=null;const c=()=>{if(o)return;N("connecting");const u=window.location.protocol==="https:"?"wss:":"ws:";a=new WebSocket(`${u}//${window.location.host}/api/v1/chat/ws`),a.onopen=()=>{i=0,N("online")},a.onmessage=d=>{try{const g=JSON.parse(d.data).message;g&&(n(g),$e(g))}catch{}},a.onclose=()=>{if(o)return;N("offline");const d=Math.min(15e3,1e3*2**Math.min(i++,4));r=window.setTimeout(c,d)},a.onerror=()=>a==null?void 0:a.close()};return c(),(()=>{o=!0,window.clearTimeout(r),a==null||a.close(),N("offline")})},[n]),{hasUnreadChatMessage:s}},Be=async e=>j("/health",void 0,e),T=l.lazy(()=>w(()=>import("./Dashboard-C9RwPfK-.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Ve=l.lazy(()=>w(()=>import("./AccountList-bbR-Z2_J.js"),__vite__mapDeps([7,1,3]))),Ge=l.lazy(()=>w(()=>import("./OrderList-Dma_R9-T.js"),__vite__mapDeps([8,1,2,3]))),He=l.lazy(()=>w(()=>import("./CardList-CvCo2zF6.js"),__vite__mapDeps([9,1,3]))),Je=l.lazy(()=>w(()=>import("./ItemList-CZPbhJDg.js"),__vite__mapDeps([10,1,3]))),Ze=l.lazy(()=>w(()=>import("./Settings-BmdW4Gos.js"),__vite__mapDeps([11,1,3]))),Ye=l.lazy(()=>w(()=>import("./Rules-CeggCy2B.js"),__vite__mapDeps([12,1,3]))),Ke=l.lazy(()=>w(()=>import("./Notifications-DUiNU4WL.js"),__vite__mapDeps([13,1,3]))),We=l.lazy(()=>w(()=>import("./Chat-CKN6Wl0-.js"),__vite__mapDeps([14,1,5,6,3]))),Qe=()=>t.jsx("div",{className:"flex min-h-[24rem] items-center justify-center",role:"status","aria-label":"正在加载页面",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-brand/20 border-t-brand"})}),Xe=({activeTab:e,isAdmin:n,deliveryRuleTarget:s,onConfigureDelivery:o,onDeliveryTargetHandled:r})=>{const i=c=>{o({cookieId:c.cookie_id,itemId:c.item_id,requestId:Date.now()})},a=()=>{switch(e){case"dashboard":return t.jsx(T,{});case"accounts":return t.jsx(Ve,{});case"chat":return t.jsx(We,{});case"orders":return t.jsx(Ge,{});case"cards":return t.jsx(He,{});case"items":return t.jsx(Je,{onConfigureDelivery:i});case"rules":return t.jsx(Ye,{initialDeliveryTarget:s,onDeliveryTargetHandled:r});case"notifications":return t.jsx(Ke,{isAdmin:n});case"settings":return n?t.jsx(Ze,{}):t.jsx(T,{});default:return t.jsx(T,{})}};return t.jsx(l.Suspense,{fallback:t.jsx(Qe,{}),children:a()})},et=({activeTab:e,isAdmin:n,collapsed:s,deliveryRuleTarget:o,onToggleCollapsed:r,onNavigate:i,onLogout:a,onConfigureDelivery:c,onDeliveryTargetHandled:u})=>{const[d,h]=l.useState({version:"dev",commit:"unknown"}),{hasUnreadChatMessage:g}=Fe();return l.useEffect(()=>{const f=new AbortController;return Be({signal:f.signal}).then(x=>h({version:String(x.version||"dev"),commit:String(x.commit||"unknown")})).catch(x=>{x instanceof DOMException&&x.name}),(()=>f.abort())},[]),t.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[t.jsx(Re,{activeTab:e,isAdmin:n,collapsed:s,onToggleCollapsed:r,onNavigate:i,onLogout:a,buildInfo:d,hasUnreadChatMessage:g}),t.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${s?"ml-16":"ml-64"} ${e==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,children:[t.jsx("div",{className:"fixed top-0 right-0 -z-10 h-[800px] w-[800px] pointer-events-none rounded-full bg-gradient-to-bl from-blue-50 to-transparent opacity-60 blur-[120px]"}),t.jsx("div",{className:`${e==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:t.jsx(Xe,{activeTab:e,isAdmin:n,deliveryRuleTarget:o,onConfigureDelivery:c,onDeliveryTargetHandled:u})})]})]})},W={"/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"},k=Object.fromEntries(Object.entries(W).map(([e,n])=>[n,e])),z=()=>W[window.location.pathname]??"dashboard",tt=()=>{const{isLoggedIn:e,isAdmin:n,signOut:s}=H(),[o,r]=l.useState(z),[i,a]=l.useState(),[c,u]=l.useState(_e);l.useEffect(()=>{const m=()=>r(z());return window.addEventListener("popstate",m),(()=>window.removeEventListener("popstate",m))},[]),l.useEffect(()=>{e&&!n&&o==="settings"&&(window.history.replaceState({},"",k.dashboard),r("dashboard"))},[o,n,e]);const d=m=>{const b=m==="settings"&&!n?"dashboard":m,C=k[b];C!==window.location.pathname&&window.history.pushState({},"",C),r(b)},h=m=>{const b=Object.prototype.hasOwnProperty.call(k,m)?m:"dashboard";d(b)},g=async()=>{try{await s()}catch(m){console.error("退出登录失败",m)}},f=()=>{u(m=>{const b=!m;return Ae(b),b})},x=m=>{a(m),d("rules")},p=()=>a(void 0);return e?t.jsx(et,{activeTab:o,isAdmin:n,collapsed:c,deliveryRuleTarget:i,onToggleCollapsed:f,onNavigate:h,onLogout:g,onConfigureDelivery:x,onDeliveryTargetHandled:p}):t.jsx(Te,{})},st=()=>t.jsx(ge,{children:t.jsx(Se,{children:t.jsx(tt,{})})}),Q=document.getElementById("root");if(!Q)throw new Error("Could not find root element to mount to");const nt=te.createRoot(Q);nt.render(t.jsx(R.StrictMode,{children:t.jsx(st,{})}));export{q as A,L as a,we as b,ct as c,it as d,Me as e,pt as f,j as g,dt as h,ut as i,ht as j,Oe as k,lt as l,mt as m,Y as o,ot as p,ft as s}; diff --git a/internal/webui/static/assets/react-vendor-C_od1ZSF.js b/internal/webui/static/assets/react-vendor-l-BBvuKH.js similarity index 99% rename from internal/webui/static/assets/react-vendor-C_od1ZSF.js rename to internal/webui/static/assets/react-vendor-l-BBvuKH.js index 7ce0614..bf66909 100644 --- a/internal/webui/static/assets/react-vendor-C_od1ZSF.js +++ b/internal/webui/static/assets/react-vendor-l-BBvuKH.js @@ -46,4 +46,4 @@ function ws(M,Sl){for(var W=0;W")&&(g=g.replace("",l.displayName)),g}while(1<=a&&0<=e);break}}}finally{Qn=!1,Error.prepareStackTrace=u}return(u=l?l.displayName||l.name:"")?Tu(u):""}function O1(l,t){switch(l.tag){case 26:case 27:case 5:return Tu(l.type);case 16:return Tu("Lazy");case 13:return l.child!==t&&t!==null?Tu("Suspense Fallback"):Tu("Suspense");case 19:return Tu("SuspenseList");case 0:case 15:return jn(l.type,!1);case 11:return jn(l.type.render,!1);case 1:return jn(l.type,!0);case 31:return Tu("Activity");default:return""}}function mi(l){try{var t="",u=null;do t+=O1(l,u),u=l,l=l.return;while(l);return t}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var Zn=Object.prototype.hasOwnProperty,Vn=M.unstable_scheduleCallback,xn=M.unstable_cancelCallback,M1=M.unstable_shouldYield,D1=M.unstable_requestPaint,$l=M.unstable_now,U1=M.unstable_getCurrentPriorityLevel,si=M.unstable_ImmediatePriority,di=M.unstable_UserBlockingPriority,Te=M.unstable_NormalPriority,r1=M.unstable_LowPriority,hi=M.unstable_IdlePriority,H1=M.log,N1=M.unstable_setDisableYieldValue,Ma=null,Fl=null;function Wt(l){if(typeof H1=="function"&&N1(l),Fl&&typeof Fl.setStrictMode=="function")try{Fl.setStrictMode(Ma,l)}catch{}}var kl=Math.clz32?Math.clz32:q1,p1=Math.log,R1=Math.LN2;function q1(l){return l>>>=0,l===0?32:31-(p1(l)/R1|0)|0}var Ee=256,Ae=262144,_e=4194304;function Eu(l){var t=l&42;if(t!==0)return t;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function Oe(l,t,u){var a=l.pendingLanes;if(a===0)return 0;var e=0,n=l.suspendedLanes,f=l.pingedLanes;l=l.warmLanes;var c=a&134217727;return c!==0?(a=c&~n,a!==0?e=Eu(a):(f&=c,f!==0?e=Eu(f):u||(u=c&~l,u!==0&&(e=Eu(u))))):(c=a&~n,c!==0?e=Eu(c):f!==0?e=Eu(f):u||(u=a&~l,u!==0&&(e=Eu(u)))),e===0?0:t!==0&&t!==e&&(t&n)===0&&(n=e&-e,u=t&-t,n>=u||n===32&&(u&4194048)!==0)?t:e}function Da(l,t){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&t)===0}function C1(l,t){switch(l){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function oi(){var l=_e;return _e<<=1,(_e&62914560)===0&&(_e=4194304),l}function Ln(l){for(var t=[],u=0;31>u;u++)t.push(l);return t}function Ua(l,t){l.pendingLanes|=t,t!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Y1(l,t,u,a,e,n){var f=l.pendingLanes;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=u,l.entangledLanes&=u,l.errorRecoveryDisabledLanes&=u,l.shellSuspendCounter=0;var c=l.entanglements,i=l.expirationTimes,d=l.hiddenUpdates;for(u=f&~u;0"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var Z1=/[\n"\\]/g;function ct(l){return l.replace(Z1,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Fn(l,t,u,a,e,n,f,c){l.name="",f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"?l.type=f:l.removeAttribute("type"),t!=null?f==="number"?(t===0&&l.value===""||l.value!=t)&&(l.value=""+ft(t)):l.value!==""+ft(t)&&(l.value=""+ft(t)):f!=="submit"&&f!=="reset"||l.removeAttribute("value"),t!=null?kn(l,f,ft(t)):u!=null?kn(l,f,ft(u)):a!=null&&l.removeAttribute("value"),e==null&&n!=null&&(l.defaultChecked=!!n),e!=null&&(l.checked=e&&typeof e!="function"&&typeof e!="symbol"),c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?l.name=""+ft(c):l.removeAttribute("name")}function ri(l,t,u,a,e,n,f,c){if(n!=null&&typeof n!="function"&&typeof n!="symbol"&&typeof n!="boolean"&&(l.type=n),t!=null||u!=null){if(!(n!=="submit"&&n!=="reset"||t!=null)){$n(l);return}u=u!=null?""+ft(u):"",t=t!=null?""+ft(t):u,c||t===l.value||(l.value=t),l.defaultValue=t}a=a??e,a=typeof a!="function"&&typeof a!="symbol"&&!!a,l.checked=c?l.checked:!!a,l.defaultChecked=!!a,f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(l.name=f),$n(l)}function kn(l,t,u){t==="number"&&Ue(l.ownerDocument)===l||l.defaultValue===""+u||(l.defaultValue=""+u)}function Ku(l,t,u,a){if(l=l.options,t){t={};for(var e=0;e"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uf=!1;if(pt)try{var pa={};Object.defineProperty(pa,"passive",{get:function(){uf=!0}}),window.addEventListener("test",pa,pa),window.removeEventListener("test",pa,pa)}catch{uf=!1}var Ft=null,af=null,He=null;function Yi(){if(He)return He;var l,t=af,u=t.length,a,e="value"in Ft?Ft.value:Ft.textContent,n=e.length;for(l=0;l=Ca),Zi=" ",Vi=!1;function xi(l,t){switch(l){case"keyup":return om.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Li(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var $u=!1;function gm(l,t){switch(l){case"compositionend":return Li(t);case"keypress":return t.which!==32?null:(Vi=!0,Zi);case"textInput":return l=t.data,l===Zi&&Vi?null:l;default:return null}}function bm(l,t){if($u)return l==="compositionend"||!yf&&xi(l,t)?(l=Yi(),He=af=Ft=null,$u=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:u,offset:t-l};l=a}l:{for(;u;){if(u.nextSibling){u=u.nextSibling;break l}u=u.parentNode}u=void 0}u=Ii(u)}}function l0(l,t){return l&&t?l===t?!0:l&&l.nodeType===3?!1:t&&t.nodeType===3?l0(l,t.parentNode):"contains"in l?l.contains(t):l.compareDocumentPosition?!!(l.compareDocumentPosition(t)&16):!1:!1}function t0(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var t=Ue(l.document);t instanceof l.HTMLIFrameElement;){try{var u=typeof t.contentWindow.location.href=="string"}catch{u=!1}if(u)l=t.contentWindow;else break;t=Ue(l.document)}return t}function sf(l){var t=l&&l.nodeName&&l.nodeName.toLowerCase();return t&&(t==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||t==="textarea"||l.contentEditable==="true")}var Dm=pt&&"documentMode"in document&&11>=document.documentMode,Fu=null,df=null,Xa=null,hf=!1;function u0(l,t,u){var a=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;hf||Fu==null||Fu!==Ue(a)||(a=Fu,"selectionStart"in a&&sf(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Xa&&Ga(Xa,a)||(Xa=a,a=_n(df,"onSelect"),0>=f,e-=f,_t=1<<32-kl(t)+e|u<G?(V=r,r=null):V=r.sibling;var J=h(m,r,s[G],z);if(J===null){r===null&&(r=V);break}l&&r&&J.alternate===null&&t(m,r),y=n(J,y,G),K===null?H=J:K.sibling=J,K=J,r=V}if(G===s.length)return u(m,r),L&&qt(m,G),H;if(r===null){for(;GG?(V=r,r=null):V=r.sibling;var bu=h(m,r,J.value,z);if(bu===null){r===null&&(r=V);break}l&&r&&bu.alternate===null&&t(m,r),y=n(bu,y,G),K===null?H=bu:K.sibling=bu,K=bu,r=V}if(J.done)return u(m,r),L&&qt(m,G),H;if(r===null){for(;!J.done;G++,J=s.next())J=T(m,J.value,z),J!==null&&(y=n(J,y,G),K===null?H=J:K.sibling=J,K=J);return L&&qt(m,G),H}for(r=a(r);!J.done;G++,J=s.next())J=S(r,m,G,J.value,z),J!==null&&(l&&J.alternate!==null&&r.delete(J.key===null?G:J.key),y=n(J,y,G),K===null?H=J:K.sibling=J,K=J);return l&&r.forEach(function(Js){return t(m,Js)}),L&&qt(m,G),H}function ul(m,y,s,z){if(typeof s=="object"&&s!==null&&s.type===ql&&s.key===null&&(s=s.props.children),typeof s=="object"&&s!==null){switch(s.$$typeof){case wl:l:{for(var H=s.key;y!==null;){if(y.key===H){if(H=s.type,H===ql){if(y.tag===7){u(m,y.sibling),z=e(y,s.props.children),z.return=m,m=z;break l}}else if(y.elementType===H||typeof H=="object"&&H!==null&&H.$$typeof===Xl&&Ru(H)===y.type){u(m,y.sibling),z=e(y,s.props),La(z,s),z.return=m,m=z;break l}u(m,y);break}else t(m,y);y=y.sibling}s.type===ql?(z=Uu(s.props.children,m.mode,z,s.key),z.return=m,m=z):(z=Qe(s.type,s.key,s.props,null,m.mode,z),La(z,s),z.return=m,m=z)}return f(m);case Bl:l:{for(H=s.key;y!==null;){if(y.key===H)if(y.tag===4&&y.stateNode.containerInfo===s.containerInfo&&y.stateNode.implementation===s.implementation){u(m,y.sibling),z=e(y,s.children||[]),z.return=m,m=z;break l}else{u(m,y);break}else t(m,y);y=y.sibling}z=Ef(s,m.mode,z),z.return=m,m=z}return f(m);case Xl:return s=Ru(s),ul(m,y,s,z)}if(St(s))return D(m,y,s,z);if(Ql(s)){if(H=Ql(s),typeof H!="function")throw Error(o(150));return s=H.call(s),p(m,y,s,z)}if(typeof s.then=="function")return ul(m,y,Je(s),z);if(s.$$typeof===Nl)return ul(m,y,Ve(m,s),z);we(m,s)}return typeof s=="string"&&s!==""||typeof s=="number"||typeof s=="bigint"?(s=""+s,y!==null&&y.tag===6?(u(m,y.sibling),z=e(y,s),z.return=m,m=z):(u(m,y),z=Tf(s,m.mode,z),z.return=m,m=z),f(m)):u(m,y)}return function(m,y,s,z){try{xa=0;var H=ul(m,y,s,z);return ca=null,H}catch(r){if(r===fa||r===Le)throw r;var K=Pl(29,r,null,m.mode);return K.lanes=z,K.return=m,K}finally{}}}var Cu=M0(!0),D0=M0(!1),tu=!1;function qf(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Cf(l,t){l=l.updateQueue,t.updateQueue===l&&(t.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function uu(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function au(l,t,u){var a=l.updateQueue;if(a===null)return null;if(a=a.shared,(w&2)!==0){var e=a.pending;return e===null?t.next=t:(t.next=e.next,e.next=t),a.pending=t,t=Xe(l),y0(l,null,u),t}return Ge(l,a,t,u),Xe(l)}function Ka(l,t,u){if(t=t.updateQueue,t!==null&&(t=t.shared,(u&4194048)!==0)){var a=t.lanes;a&=l.pendingLanes,u|=a,t.lanes=u,gi(l,u)}}function Yf(l,t){var u=l.updateQueue,a=l.alternate;if(a!==null&&(a=a.updateQueue,u===a)){var e=null,n=null;if(u=u.firstBaseUpdate,u!==null){do{var f={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};n===null?e=n=f:n=n.next=f,u=u.next}while(u!==null);n===null?e=n=t:n=n.next=t}else e=n=t;u={baseState:a.baseState,firstBaseUpdate:e,lastBaseUpdate:n,shared:a.shared,callbacks:a.callbacks},l.updateQueue=u;return}l=u.lastBaseUpdate,l===null?u.firstBaseUpdate=t:l.next=t,u.lastBaseUpdate=t}var Bf=!1;function Ja(){if(Bf){var l=na;if(l!==null)throw l}}function wa(l,t,u,a){Bf=!1;var e=l.updateQueue;tu=!1;var n=e.firstBaseUpdate,f=e.lastBaseUpdate,c=e.shared.pending;if(c!==null){e.shared.pending=null;var i=c,d=i.next;i.next=null,f===null?n=d:f.next=d,f=i;var g=l.alternate;g!==null&&(g=g.updateQueue,c=g.lastBaseUpdate,c!==f&&(c===null?g.firstBaseUpdate=d:c.next=d,g.lastBaseUpdate=i))}if(n!==null){var T=e.baseState;f=0,g=d=i=null,c=n;do{var h=c.lane&-536870913,S=h!==c.lane;if(S?(Z&h)===h:(a&h)===h){h!==0&&h===ea&&(Bf=!0),g!==null&&(g=g.next={lane:0,tag:c.tag,payload:c.payload,callback:null,next:null});l:{var D=l,p=c;h=t;var ul=u;switch(p.tag){case 1:if(D=p.payload,typeof D=="function"){T=D.call(ul,T,h);break l}T=D;break l;case 3:D.flags=D.flags&-65537|128;case 0:if(D=p.payload,h=typeof D=="function"?D.call(ul,T,h):D,h==null)break l;T=R({},T,h);break l;case 2:tu=!0}}h=c.callback,h!==null&&(l.flags|=64,S&&(l.flags|=8192),S=e.callbacks,S===null?e.callbacks=[h]:S.push(h))}else S={lane:h,tag:c.tag,payload:c.payload,callback:c.callback,next:null},g===null?(d=g=S,i=T):g=g.next=S,f|=h;if(c=c.next,c===null){if(c=e.shared.pending,c===null)break;S=c,c=S.next,S.next=null,e.lastBaseUpdate=S,e.shared.pending=null}}while(!0);g===null&&(i=T),e.baseState=i,e.firstBaseUpdate=d,e.lastBaseUpdate=g,n===null&&(e.shared.lanes=0),iu|=f,l.lanes=f,l.memoizedState=T}}function U0(l,t){if(typeof l!="function")throw Error(o(191,l));l.call(t)}function r0(l,t){var u=l.callbacks;if(u!==null)for(l.callbacks=null,l=0;ln?n:8;var f=b.T,c={};b.T=c,tc(l,!1,t,u);try{var i=e(),d=b.S;if(d!==null&&d(c,i),i!==null&&typeof i=="object"&&typeof i.then=="function"){var g=Ym(i,a);Fa(l,t,g,et(l))}else Fa(l,t,a,et(l))}catch(T){Fa(l,t,{then:function(){},status:"rejected",reason:T},et())}finally{_.p=n,f!==null&&c.types!==null&&(f.types=c.types),b.T=f}}function Zm(){}function Pf(l,t,u,a){if(l.tag!==5)throw Error(o(476));var e=fy(l).queue;ny(l,e,t,q,u===null?Zm:function(){return cy(l),u(a)})}function fy(l){var t=l.memoizedState;if(t!==null)return t;t={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gt,lastRenderedState:q},next:null};var u={};return t.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gt,lastRenderedState:u},next:null},l.memoizedState=t,l=l.alternate,l!==null&&(l.memoizedState=t),t}function cy(l){var t=fy(l);t.next===null&&(t=l.alternate.memoizedState),Fa(l,t.next.queue,{},et())}function lc(){return Ul(de)}function iy(){return ol().memoizedState}function yy(){return ol().memoizedState}function Vm(l){for(var t=l.return;t!==null;){switch(t.tag){case 24:case 3:var u=et();l=uu(u);var a=au(t,l,u);a!==null&&(Jl(a,t,u),Ka(a,t,u)),t={cache:Hf()},l.payload=t;return}t=t.return}}function xm(l,t,u){var a=et();u={lane:a,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},an(l)?my(t,u):(u=bf(l,t,u,a),u!==null&&(Jl(u,l,a),sy(u,t,a)))}function vy(l,t,u){var a=et();Fa(l,t,u,a)}function Fa(l,t,u,a){var e={lane:a,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(an(l))my(t,e);else{var n=l.alternate;if(l.lanes===0&&(n===null||n.lanes===0)&&(n=t.lastRenderedReducer,n!==null))try{var f=t.lastRenderedState,c=n(f,u);if(e.hasEagerState=!0,e.eagerState=c,Il(c,f))return Ge(l,t,e,0),nl===null&&Be(),!1}catch{}finally{}if(u=bf(l,t,e,a),u!==null)return Jl(u,l,a),sy(u,t,a),!0}return!1}function tc(l,t,u,a){if(a={lane:2,revertLane:qc(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},an(l)){if(t)throw Error(o(479))}else t=bf(l,u,a,2),t!==null&&Jl(t,l,2)}function an(l){var t=l.alternate;return l===B||t!==null&&t===B}function my(l,t){ya=Fe=!0;var u=l.pending;u===null?t.next=t:(t.next=u.next,u.next=t),l.pending=t}function sy(l,t,u){if((u&4194048)!==0){var a=t.lanes;a&=l.pendingLanes,u|=a,t.lanes=u,gi(l,u)}}var ka={readContext:Ul,use:Pe,useCallback:ml,useContext:ml,useEffect:ml,useImperativeHandle:ml,useLayoutEffect:ml,useInsertionEffect:ml,useMemo:ml,useReducer:ml,useRef:ml,useState:ml,useDebugValue:ml,useDeferredValue:ml,useTransition:ml,useSyncExternalStore:ml,useId:ml,useHostTransitionStatus:ml,useFormState:ml,useActionState:ml,useOptimistic:ml,useMemoCache:ml,useCacheRefresh:ml};ka.useEffectEvent=ml;var dy={readContext:Ul,use:Pe,useCallback:function(l,t){return Yl().memoizedState=[l,t===void 0?null:t],l},useContext:Ul,useEffect:F0,useImperativeHandle:function(l,t,u){u=u!=null?u.concat([l]):null,tn(4194308,4,ly.bind(null,t,l),u)},useLayoutEffect:function(l,t){return tn(4194308,4,l,t)},useInsertionEffect:function(l,t){tn(4,2,l,t)},useMemo:function(l,t){var u=Yl();t=t===void 0?null:t;var a=l();if(Yu){Wt(!0);try{l()}finally{Wt(!1)}}return u.memoizedState=[a,t],a},useReducer:function(l,t,u){var a=Yl();if(u!==void 0){var e=u(t);if(Yu){Wt(!0);try{u(t)}finally{Wt(!1)}}}else e=t;return a.memoizedState=a.baseState=e,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:e},a.queue=l,l=l.dispatch=xm.bind(null,B,l),[a.memoizedState,l]},useRef:function(l){var t=Yl();return l={current:l},t.memoizedState=l},useState:function(l){l=Wf(l);var t=l.queue,u=vy.bind(null,B,t);return t.dispatch=u,[l.memoizedState,u]},useDebugValue:kf,useDeferredValue:function(l,t){var u=Yl();return If(u,l,t)},useTransition:function(){var l=Wf(!1);return l=ny.bind(null,B,l.queue,!0,!1),Yl().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,t,u){var a=B,e=Yl();if(L){if(u===void 0)throw Error(o(407));u=u()}else{if(u=t(),nl===null)throw Error(o(349));(Z&127)!==0||C0(a,t,u)}e.memoizedState=u;var n={value:u,getSnapshot:t};return e.queue=n,F0(B0.bind(null,a,n,l),[l]),a.flags|=2048,ma(9,{destroy:void 0},Y0.bind(null,a,n,u,t),null),u},useId:function(){var l=Yl(),t=nl.identifierPrefix;if(L){var u=Ot,a=_t;u=(a&~(1<<32-kl(a)-1)).toString(32)+u,t="_"+t+"R_"+u,u=ke++,0<\/script>",n=n.removeChild(n.firstChild);break;case"select":n=typeof a.is=="string"?f.createElement("select",{is:a.is}):f.createElement("select"),a.multiple?n.multiple=!0:a.size&&(n.size=a.size);break;default:n=typeof a.is=="string"?f.createElement(e,{is:a.is}):f.createElement(e)}}n[Ml]=t,n[jl]=a;l:for(f=t.child;f!==null;){if(f.tag===5||f.tag===6)n.appendChild(f.stateNode);else if(f.tag!==4&&f.tag!==27&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===t)break l;for(;f.sibling===null;){if(f.return===null||f.return===t)break l;f=f.return}f.sibling.return=f.return,f=f.sibling}t.stateNode=n;l:switch(Hl(n,e,a),e){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break l;case"img":a=!0;break l;default:a=!1}a&&Qt(t)}}return cl(t),oc(t,t.type,l===null?null:l.memoizedProps,t.pendingProps,u),null;case 6:if(l&&t.stateNode!=null)l.memoizedProps!==a&&Qt(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(o(166));if(l=X.current,ua(t)){if(l=t.stateNode,u=t.memoizedProps,a=null,e=Dl,e!==null)switch(e.tag){case 27:case 5:a=e.memoizedProps}l[Ml]=t,l=!!(l.nodeValue===u||a!==null&&a.suppressHydrationWarning===!0||Rv(l.nodeValue,u)),l||Pt(t,!0)}else l=On(l).createTextNode(a),l[Ml]=t,t.stateNode=l}return cl(t),null;case 31:if(u=t.memoizedState,l===null||l.memoizedState!==null){if(a=ua(t),u!==null){if(l===null){if(!a)throw Error(o(318));if(l=t.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(o(557));l[Ml]=t}else ru(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;cl(t),l=!1}else u=Mf(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=u),l=!0;if(!l)return t.flags&256?(tt(t),t):(tt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return cl(t),null;case 13:if(a=t.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(e=ua(t),a!==null&&a.dehydrated!==null){if(l===null){if(!e)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));e[Ml]=t}else ru(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;cl(t),e=!1}else e=Mf(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=e),e=!0;if(!e)return t.flags&256?(tt(t),t):(tt(t),null)}return tt(t),(t.flags&128)!==0?(t.lanes=u,t):(u=a!==null,l=l!==null&&l.memoizedState!==null,u&&(a=t.child,e=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(e=a.alternate.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==e&&(a.flags|=2048)),u!==l&&u&&(t.child.flags|=8192),yn(t,t.updateQueue),cl(t),null);case 4:return dl(),l===null&&Gc(t.stateNode.containerInfo),cl(t),null;case 10:return Yt(t.type),cl(t),null;case 19:if(E(hl),a=t.memoizedState,a===null)return cl(t),null;if(e=(t.flags&128)!==0,n=a.rendering,n===null)if(e)Pa(a,!1);else{if(sl!==0||l!==null&&(l.flags&128)!==0)for(l=t.child;l!==null;){if(n=$e(l),n!==null){for(t.flags|=128,Pa(a,!1),l=n.updateQueue,t.updateQueue=l,yn(t,l),t.subtreeFlags=0,l=u,u=t.child;u!==null;)v0(u,l),u=u.sibling;return O(hl,hl.current&1|2),L&&qt(t,a.treeForkCount),t.child}l=l.sibling}a.tail!==null&&$l()>hn&&(t.flags|=128,e=!0,Pa(a,!1),t.lanes=4194304)}else{if(!e)if(l=$e(n),l!==null){if(t.flags|=128,e=!0,l=l.updateQueue,t.updateQueue=l,yn(t,l),Pa(a,!0),a.tail===null&&a.tailMode==="hidden"&&!n.alternate&&!L)return cl(t),null}else 2*$l()-a.renderingStartTime>hn&&u!==536870912&&(t.flags|=128,e=!0,Pa(a,!1),t.lanes=4194304);a.isBackwards?(n.sibling=t.child,t.child=n):(l=a.last,l!==null?l.sibling=n:t.child=n,a.last=n)}return a.tail!==null?(l=a.tail,a.rendering=l,a.tail=l.sibling,a.renderingStartTime=$l(),l.sibling=null,u=hl.current,O(hl,e?u&1|2:u&1),L&&qt(t,a.treeForkCount),l):(cl(t),null);case 22:case 23:return tt(t),Xf(),a=t.memoizedState!==null,l!==null?l.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(u&536870912)!==0&&(t.flags&128)===0&&(cl(t),t.subtreeFlags&6&&(t.flags|=8192)):cl(t),u=t.updateQueue,u!==null&&yn(t,u.retryQueue),u=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(u=l.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==u&&(t.flags|=2048),l!==null&&E(pu),null;case 24:return u=null,l!==null&&(u=l.memoizedState.cache),t.memoizedState.cache!==u&&(t.flags|=2048),Yt(gl),cl(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Wm(l,t){switch(_f(t),t.tag){case 1:return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 3:return Yt(gl),dl(),l=t.flags,(l&65536)!==0&&(l&128)===0?(t.flags=l&-65537|128,t):null;case 26:case 27:case 5:return ze(t),null;case 31:if(t.memoizedState!==null){if(tt(t),t.alternate===null)throw Error(o(340));ru()}return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 13:if(tt(t),l=t.memoizedState,l!==null&&l.dehydrated!==null){if(t.alternate===null)throw Error(o(340));ru()}return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 19:return E(hl),null;case 4:return dl(),null;case 10:return Yt(t.type),null;case 22:case 23:return tt(t),Xf(),l!==null&&E(pu),l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 24:return Yt(gl),null;case 25:return null;default:return null}}function Gy(l,t){switch(_f(t),t.tag){case 3:Yt(gl),dl();break;case 26:case 27:case 5:ze(t);break;case 4:dl();break;case 31:t.memoizedState!==null&&tt(t);break;case 13:tt(t);break;case 19:E(hl);break;case 10:Yt(t.type);break;case 22:case 23:tt(t),Xf(),l!==null&&E(pu);break;case 24:Yt(gl)}}function le(l,t){try{var u=t.updateQueue,a=u!==null?u.lastEffect:null;if(a!==null){var e=a.next;u=e;do{if((u.tag&l)===l){a=void 0;var n=u.create,f=u.inst;a=n(),f.destroy=a}u=u.next}while(u!==e)}}catch(c){I(t,t.return,c)}}function fu(l,t,u){try{var a=t.updateQueue,e=a!==null?a.lastEffect:null;if(e!==null){var n=e.next;a=n;do{if((a.tag&l)===l){var f=a.inst,c=f.destroy;if(c!==void 0){f.destroy=void 0,e=t;var i=u,d=c;try{d()}catch(g){I(e,i,g)}}}a=a.next}while(a!==n)}}catch(g){I(t,t.return,g)}}function Xy(l){var t=l.updateQueue;if(t!==null){var u=l.stateNode;try{r0(t,u)}catch(a){I(l,l.return,a)}}}function Qy(l,t,u){u.props=Bu(l.type,l.memoizedProps),u.state=l.memoizedState;try{u.componentWillUnmount()}catch(a){I(l,t,a)}}function te(l,t){try{var u=l.ref;if(u!==null){switch(l.tag){case 26:case 27:case 5:var a=l.stateNode;break;case 30:a=l.stateNode;break;default:a=l.stateNode}typeof u=="function"?l.refCleanup=u(a):u.current=a}}catch(e){I(l,t,e)}}function Mt(l,t){var u=l.ref,a=l.refCleanup;if(u!==null)if(typeof a=="function")try{a()}catch(e){I(l,t,e)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(e){I(l,t,e)}else u.current=null}function jy(l){var t=l.type,u=l.memoizedProps,a=l.stateNode;try{l:switch(t){case"button":case"input":case"select":case"textarea":u.autoFocus&&a.focus();break l;case"img":u.src?a.src=u.src:u.srcSet&&(a.srcset=u.srcSet)}}catch(e){I(l,l.return,e)}}function Sc(l,t,u){try{var a=l.stateNode;Ss(a,l.type,u,t),a[jl]=t}catch(e){I(l,l.return,e)}}function Zy(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&du(l.type)||l.tag===4}function gc(l){l:for(;;){for(;l.sibling===null;){if(l.return===null||Zy(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&du(l.type)||l.flags&2||l.child===null||l.tag===4)continue l;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function bc(l,t,u){var a=l.tag;if(a===5||a===6)l=l.stateNode,t?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(l,t):(t=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,t.appendChild(l),u=u._reactRootContainer,u!=null||t.onclick!==null||(t.onclick=Nt));else if(a!==4&&(a===27&&du(l.type)&&(u=l.stateNode,t=null),l=l.child,l!==null))for(bc(l,t,u),l=l.sibling;l!==null;)bc(l,t,u),l=l.sibling}function vn(l,t,u){var a=l.tag;if(a===5||a===6)l=l.stateNode,t?u.insertBefore(l,t):u.appendChild(l);else if(a!==4&&(a===27&&du(l.type)&&(u=l.stateNode),l=l.child,l!==null))for(vn(l,t,u),l=l.sibling;l!==null;)vn(l,t,u),l=l.sibling}function Vy(l){var t=l.stateNode,u=l.memoizedProps;try{for(var a=l.type,e=t.attributes;e.length;)t.removeAttributeNode(e[0]);Hl(t,a,u),t[Ml]=l,t[jl]=u}catch(n){I(l,l.return,n)}}var jt=!1,Tl=!1,zc=!1,xy=typeof WeakSet=="function"?WeakSet:Set,_l=null;function $m(l,t){if(l=l.containerInfo,jc=pn,l=t0(l),sf(l)){if("selectionStart"in l)var u={start:l.selectionStart,end:l.selectionEnd};else l:{u=(u=l.ownerDocument)&&u.defaultView||window;var a=u.getSelection&&u.getSelection();if(a&&a.rangeCount!==0){u=a.anchorNode;var e=a.anchorOffset,n=a.focusNode;a=a.focusOffset;try{u.nodeType,n.nodeType}catch{u=null;break l}var f=0,c=-1,i=-1,d=0,g=0,T=l,h=null;t:for(;;){for(var S;T!==u||e!==0&&T.nodeType!==3||(c=f+e),T!==n||a!==0&&T.nodeType!==3||(i=f+a),T.nodeType===3&&(f+=T.nodeValue.length),(S=T.firstChild)!==null;)h=T,T=S;for(;;){if(T===l)break t;if(h===u&&++d===e&&(c=f),h===n&&++g===a&&(i=f),(S=T.nextSibling)!==null)break;T=h,h=T.parentNode}T=S}u=c===-1||i===-1?null:{start:c,end:i}}else u=null}u=u||{start:0,end:0}}else u=null;for(Zc={focusedElem:l,selectionRange:u},pn=!1,_l=t;_l!==null;)if(t=_l,l=t.child,(t.subtreeFlags&1028)!==0&&l!==null)l.return=t,_l=l;else for(;_l!==null;){switch(t=_l,n=t.alternate,l=t.flags,t.tag){case 0:if((l&4)!==0&&(l=t.updateQueue,l=l!==null?l.events:null,l!==null))for(u=0;u title"))),Hl(n,a,u),n[Ml]=l,Al(n),a=n;break l;case"link":var f=$v("link","href",e).get(a+(u.href||""));if(f){for(var c=0;cul&&(f=ul,ul=p,p=f);var m=Pi(c,p),y=Pi(c,ul);if(m&&y&&(S.rangeCount!==1||S.anchorNode!==m.node||S.anchorOffset!==m.offset||S.focusNode!==y.node||S.focusOffset!==y.offset)){var s=T.createRange();s.setStart(m.node,m.offset),S.removeAllRanges(),p>ul?(S.addRange(s),S.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),S.addRange(s))}}}}for(T=[],S=c;S=S.parentNode;)S.nodeType===1&&T.push({element:S,left:S.scrollLeft,top:S.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;cu?32:u,b.T=null,u=Dc,Dc=null;var n=vu,f=Kt;if(El=0,Sa=vu=null,Kt=0,(w&6)!==0)throw Error(o(331));var c=w;if(w|=4,lv(n.current),ky(n,n.current,f,u),w=c,ce(0,!1),Fl&&typeof Fl.onPostCommitFiberRoot=="function")try{Fl.onPostCommitFiberRoot(Ma,n)}catch{}return!0}finally{_.p=e,b.T=a,bv(l,t)}}function Tv(l,t,u){t=yt(u,t),t=nc(l.stateNode,t,2),l=au(l,t,2),l!==null&&(Ua(l,2),Dt(l))}function I(l,t,u){if(l.tag===3)Tv(l,l,u);else for(;t!==null;){if(t.tag===3){Tv(t,l,u);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(yu===null||!yu.has(a))){l=yt(u,l),u=Ey(2),a=au(t,u,2),a!==null&&(Ay(u,a,t,l),Ua(a,2),Dt(a));break}}t=t.return}}function Nc(l,t,u){var a=l.pingCache;if(a===null){a=l.pingCache=new Im;var e=new Set;a.set(t,e)}else e=a.get(t),e===void 0&&(e=new Set,a.set(t,e));e.has(u)||(Ac=!0,e.add(u),l=as.bind(null,l,t,u),t.then(l,l))}function as(l,t,u){var a=l.pingCache;a!==null&&a.delete(t),l.pingedLanes|=l.suspendedLanes&u,l.warmLanes&=~u,nl===l&&(Z&u)===u&&(sl===4||sl===3&&(Z&62914560)===Z&&300>$l()-dn?(w&2)===0&&ga(l,0):_c|=u,oa===Z&&(oa=0)),Dt(l)}function Ev(l,t){t===0&&(t=oi()),l=Du(l,t),l!==null&&(Ua(l,t),Dt(l))}function es(l){var t=l.memoizedState,u=0;t!==null&&(u=t.retryLane),Ev(l,u)}function ns(l,t){var u=0;switch(l.tag){case 31:case 13:var a=l.stateNode,e=l.memoizedState;e!==null&&(u=e.retryLane);break;case 19:a=l.stateNode;break;case 22:a=l.stateNode._retryCache;break;default:throw Error(o(314))}a!==null&&a.delete(t),Ev(l,u)}function fs(l,t){return Vn(l,t)}var Tn=null,za=null,pc=!1,En=!1,Rc=!1,su=0;function Dt(l){l!==za&&l.next===null&&(za===null?Tn=za=l:za=za.next=l),En=!0,pc||(pc=!0,is())}function ce(l,t){if(!Rc&&En){Rc=!0;do for(var u=!1,a=Tn;a!==null;){if(l!==0){var e=a.pendingLanes;if(e===0)var n=0;else{var f=a.suspendedLanes,c=a.pingedLanes;n=(1<<31-kl(42|l)+1)-1,n&=e&~(f&~c),n=n&201326741?n&201326741|1:n?n|2:0}n!==0&&(u=!0,Mv(a,n))}else n=Z,n=Oe(a,a===nl?n:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(n&3)===0||Da(a,n)||(u=!0,Mv(a,n));a=a.next}while(u);Rc=!1}}function cs(){Av()}function Av(){En=pc=!1;var l=0;su!==0&&bs()&&(l=su);for(var t=$l(),u=null,a=Tn;a!==null;){var e=a.next,n=_v(a,t);n===0?(a.next=null,u===null?Tn=e:u.next=e,e===null&&(za=u)):(u=a,(l!==0||(n&3)!==0)&&(En=!0)),a=e}El!==0&&El!==5||ce(l),su!==0&&(su=0)}function _v(l,t){for(var u=l.suspendedLanes,a=l.pingedLanes,e=l.expirationTimes,n=l.pendingLanes&-62914561;0c)break;var g=i.transferSize,T=i.initiatorType;g&&qv(T)&&(i=i.responseEnd,f+=g*(i"u"?null:document;function Kv(l,t,u){var a=Ta;if(a&&typeof t=="string"&&t){var e=ct(t);e='link[rel="'+l+'"][href="'+e+'"]',typeof u=="string"&&(e+='[crossorigin="'+u+'"]'),Lv.has(e)||(Lv.add(e),l={rel:l,crossOrigin:u,href:t},a.querySelector(e)===null&&(t=a.createElement("link"),Hl(t,"link",l),Al(t),a.head.appendChild(t)))}}function Us(l){Jt.D(l),Kv("dns-prefetch",l,null)}function rs(l,t){Jt.C(l,t),Kv("preconnect",l,t)}function Hs(l,t,u){Jt.L(l,t,u);var a=Ta;if(a&&l&&t){var e='link[rel="preload"][as="'+ct(t)+'"]';t==="image"&&u&&u.imageSrcSet?(e+='[imagesrcset="'+ct(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(e+='[imagesizes="'+ct(u.imageSizes)+'"]')):e+='[href="'+ct(l)+'"]';var n=e;switch(t){case"style":n=Ea(l);break;case"script":n=Aa(l)}ot.has(n)||(l=R({rel:"preload",href:t==="image"&&u&&u.imageSrcSet?void 0:l,as:t},u),ot.set(n,l),a.querySelector(e)!==null||t==="style"&&a.querySelector(me(n))||t==="script"&&a.querySelector(se(n))||(t=a.createElement("link"),Hl(t,"link",l),Al(t),a.head.appendChild(t)))}}function Ns(l,t){Jt.m(l,t);var u=Ta;if(u&&l){var a=t&&typeof t.as=="string"?t.as:"script",e='link[rel="modulepreload"][as="'+ct(a)+'"][href="'+ct(l)+'"]',n=e;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":n=Aa(l)}if(!ot.has(n)&&(l=R({rel:"modulepreload",href:l},t),ot.set(n,l),u.querySelector(e)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(se(n)))return}a=u.createElement("link"),Hl(a,"link",l),Al(a),u.head.appendChild(a)}}}function ps(l,t,u){Jt.S(l,t,u);var a=Ta;if(a&&l){var e=xu(a).hoistableStyles,n=Ea(l);t=t||"default";var f=e.get(n);if(!f){var c={loading:0,preload:null};if(f=a.querySelector(me(n)))c.loading=5;else{l=R({rel:"stylesheet",href:l,"data-precedence":t},u),(u=ot.get(n))&&Wc(l,u);var i=f=a.createElement("link");Al(i),Hl(i,"link",l),i._p=new Promise(function(d,g){i.onload=d,i.onerror=g}),i.addEventListener("load",function(){c.loading|=1}),i.addEventListener("error",function(){c.loading|=2}),c.loading|=4,Dn(f,t,a)}f={type:"stylesheet",instance:f,count:1,state:c},e.set(n,f)}}}function Rs(l,t){Jt.X(l,t);var u=Ta;if(u&&l){var a=xu(u).hoistableScripts,e=Aa(l),n=a.get(e);n||(n=u.querySelector(se(e)),n||(l=R({src:l,async:!0},t),(t=ot.get(e))&&$c(l,t),n=u.createElement("script"),Al(n),Hl(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function qs(l,t){Jt.M(l,t);var u=Ta;if(u&&l){var a=xu(u).hoistableScripts,e=Aa(l),n=a.get(e);n||(n=u.querySelector(se(e)),n||(l=R({src:l,async:!0,type:"module"},t),(t=ot.get(e))&&$c(l,t),n=u.createElement("script"),Al(n),Hl(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function Jv(l,t,u,a){var e=(e=X.current)?Mn(e):null;if(!e)throw Error(o(446));switch(l){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(t=Ea(u.href),u=xu(e).hoistableStyles,a=u.get(t),a||(a={type:"style",instance:null,count:0,state:null},u.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){l=Ea(u.href);var n=xu(e).hoistableStyles,f=n.get(l);if(f||(e=e.ownerDocument||e,f={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},n.set(l,f),(n=e.querySelector(me(l)))&&!n._p&&(f.instance=n,f.state.loading=5),ot.has(l)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},ot.set(l,u),n||Cs(e,l,u,f.state))),t&&a===null)throw Error(o(528,""));return f}if(t&&a!==null)throw Error(o(529,""));return null;case"script":return t=u.async,u=u.src,typeof u=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Aa(u),u=xu(e).hoistableScripts,a=u.get(t),a||(a={type:"script",instance:null,count:0,state:null},u.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,l))}}function Ea(l){return'href="'+ct(l)+'"'}function me(l){return'link[rel="stylesheet"]['+l+"]"}function wv(l){return R({},l,{"data-precedence":l.precedence,precedence:null})}function Cs(l,t,u,a){l.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=l.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Hl(t,"link",u),Al(t),l.head.appendChild(t))}function Aa(l){return'[src="'+ct(l)+'"]'}function se(l){return"script[async]"+l}function Wv(l,t,u){if(t.count++,t.instance===null)switch(t.type){case"style":var a=l.querySelector('style[data-href~="'+ct(u.href)+'"]');if(a)return t.instance=a,Al(a),a;var e=R({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return a=(l.ownerDocument||l).createElement("style"),Al(a),Hl(a,"style",e),Dn(a,u.precedence,l),t.instance=a;case"stylesheet":e=Ea(u.href);var n=l.querySelector(me(e));if(n)return t.state.loading|=4,t.instance=n,Al(n),n;a=wv(u),(e=ot.get(e))&&Wc(a,e),n=(l.ownerDocument||l).createElement("link"),Al(n);var f=n;return f._p=new Promise(function(c,i){f.onload=c,f.onerror=i}),Hl(n,"link",a),t.state.loading|=4,Dn(n,u.precedence,l),t.instance=n;case"script":return n=Aa(u.src),(e=l.querySelector(se(n)))?(t.instance=e,Al(e),e):(a=u,(e=ot.get(n))&&(a=R({},u),$c(a,e)),l=l.ownerDocument||l,e=l.createElement("script"),Al(e),Hl(e,"link",a),l.head.appendChild(e),t.instance=e);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Dn(a,u.precedence,l));return t.instance}function Dn(l,t,u){for(var a=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),e=a.length?a[a.length-1]:null,n=e,f=0;f title"):null)}function Ys(l,t,u){if(u===1||t.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return l=t.disabled,typeof t.precedence=="string"&&l==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function kv(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Bs(l,t,u,a){if(u.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var e=Ea(a.href),n=t.querySelector(me(e));if(n){t=n._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(l.count++,l=rn.bind(l),t.then(l,l)),u.state.loading|=4,u.instance=n,Al(n);return}n=t.ownerDocument||t,a=wv(a),(e=ot.get(e))&&Wc(a,e),n=n.createElement("link"),Al(n);var f=n;f._p=new Promise(function(c,i){f.onload=c,f.onerror=i}),Hl(n,"link",a),u.instance=n}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(u,t),(t=u.state.preload)&&(u.state.loading&3)===0&&(l.count++,u=rn.bind(l),t.addEventListener("load",u),t.addEventListener("error",u))}}var Fc=0;function Gs(l,t){return l.stylesheets&&l.count===0&&Nn(l,l.stylesheets),0Fc?50:800)+t);return l.unsuspend=u,function(){l.unsuspend=null,clearTimeout(a),clearTimeout(e)}}:null}function rn(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nn(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Hn=null;function Nn(l,t){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Hn=new Map,t.forEach(Xs,l),Hn=null,rn.call(l))}function Xs(l,t){if(!(t.state.loading&4)){var u=Hn.get(l);if(u)var a=u.get(null);else{u=new Map,Hn.set(l,u);for(var e=l.querySelectorAll("link[data-precedence],style[data-precedence]"),n=0;n"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M)}catch(Sl){console.error(Sl)}}return M(),ni.exports=td(),ni.exports}var ad=ud();const fd=E1(ad);var cd=_1();export{nd as R,yi as a,cd as b,ks as c,fd as d,E1 as g,ed as j,A1 as r}; +`).replace(os,"")}function Rv(l,t){return t=pv(t),pv(l)===t}function tl(l,t,u,a,e,n){switch(u){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Ju(l,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Ju(l,""+a);break;case"className":De(l,"class",a);break;case"tabIndex":De(l,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":De(l,u,a);break;case"style":Ri(l,a,n);break;case"data":if(t!=="object"){De(l,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||u!=="href")){l.removeAttribute(u);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(u);break}a=re(""+a),l.setAttribute(u,a);break;case"action":case"formAction":if(typeof a=="function"){l.setAttribute(u,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof n=="function"&&(u==="formAction"?(t!=="input"&&tl(l,t,"name",e.name,e,null),tl(l,t,"formEncType",e.formEncType,e,null),tl(l,t,"formMethod",e.formMethod,e,null),tl(l,t,"formTarget",e.formTarget,e,null)):(tl(l,t,"encType",e.encType,e,null),tl(l,t,"method",e.method,e,null),tl(l,t,"target",e.target,e,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(u);break}a=re(""+a),l.setAttribute(u,a);break;case"onClick":a!=null&&(l.onclick=Nt);break;case"onScroll":a!=null&&j("scroll",l);break;case"onScrollEnd":a!=null&&j("scrollend",l);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(o(61));if(u=a.__html,u!=null){if(e.children!=null)throw Error(o(60));l.innerHTML=u}}break;case"multiple":l.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":l.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){l.removeAttribute("xlink:href");break}u=re(""+a),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(u,""+a):l.removeAttribute(u);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(u,""):l.removeAttribute(u);break;case"capture":case"download":a===!0?l.setAttribute(u,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(u,a):l.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?l.setAttribute(u,a):l.removeAttribute(u);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?l.removeAttribute(u):l.setAttribute(u,a);break;case"popover":j("beforetoggle",l),j("toggle",l),Me(l,"popover",a);break;case"xlinkActuate":Ht(l,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Ht(l,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Ht(l,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Ht(l,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Ht(l,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Ht(l,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Ht(l,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Ht(l,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Ht(l,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Me(l,"is",a);break;case"innerText":case"textContent":break;default:(!(2c)break;var g=i.transferSize,T=i.initiatorType;g&&qv(T)&&(i=i.responseEnd,f+=g*(i"u"?null:document;function Kv(l,t,u){var a=Ta;if(a&&typeof t=="string"&&t){var e=ct(t);e='link[rel="'+l+'"][href="'+e+'"]',typeof u=="string"&&(e+='[crossorigin="'+u+'"]'),Lv.has(e)||(Lv.add(e),l={rel:l,crossOrigin:u,href:t},a.querySelector(e)===null&&(t=a.createElement("link"),Hl(t,"link",l),Al(t),a.head.appendChild(t)))}}function Us(l){Jt.D(l),Kv("dns-prefetch",l,null)}function rs(l,t){Jt.C(l,t),Kv("preconnect",l,t)}function Hs(l,t,u){Jt.L(l,t,u);var a=Ta;if(a&&l&&t){var e='link[rel="preload"][as="'+ct(t)+'"]';t==="image"&&u&&u.imageSrcSet?(e+='[imagesrcset="'+ct(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(e+='[imagesizes="'+ct(u.imageSizes)+'"]')):e+='[href="'+ct(l)+'"]';var n=e;switch(t){case"style":n=Ea(l);break;case"script":n=Aa(l)}ot.has(n)||(l=R({rel:"preload",href:t==="image"&&u&&u.imageSrcSet?void 0:l,as:t},u),ot.set(n,l),a.querySelector(e)!==null||t==="style"&&a.querySelector(me(n))||t==="script"&&a.querySelector(se(n))||(t=a.createElement("link"),Hl(t,"link",l),Al(t),a.head.appendChild(t)))}}function Ns(l,t){Jt.m(l,t);var u=Ta;if(u&&l){var a=t&&typeof t.as=="string"?t.as:"script",e='link[rel="modulepreload"][as="'+ct(a)+'"][href="'+ct(l)+'"]',n=e;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":n=Aa(l)}if(!ot.has(n)&&(l=R({rel:"modulepreload",href:l},t),ot.set(n,l),u.querySelector(e)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(se(n)))return}a=u.createElement("link"),Hl(a,"link",l),Al(a),u.head.appendChild(a)}}}function ps(l,t,u){Jt.S(l,t,u);var a=Ta;if(a&&l){var e=xu(a).hoistableStyles,n=Ea(l);t=t||"default";var f=e.get(n);if(!f){var c={loading:0,preload:null};if(f=a.querySelector(me(n)))c.loading=5;else{l=R({rel:"stylesheet",href:l,"data-precedence":t},u),(u=ot.get(n))&&Wc(l,u);var i=f=a.createElement("link");Al(i),Hl(i,"link",l),i._p=new Promise(function(d,g){i.onload=d,i.onerror=g}),i.addEventListener("load",function(){c.loading|=1}),i.addEventListener("error",function(){c.loading|=2}),c.loading|=4,Dn(f,t,a)}f={type:"stylesheet",instance:f,count:1,state:c},e.set(n,f)}}}function Rs(l,t){Jt.X(l,t);var u=Ta;if(u&&l){var a=xu(u).hoistableScripts,e=Aa(l),n=a.get(e);n||(n=u.querySelector(se(e)),n||(l=R({src:l,async:!0},t),(t=ot.get(e))&&$c(l,t),n=u.createElement("script"),Al(n),Hl(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function qs(l,t){Jt.M(l,t);var u=Ta;if(u&&l){var a=xu(u).hoistableScripts,e=Aa(l),n=a.get(e);n||(n=u.querySelector(se(e)),n||(l=R({src:l,async:!0,type:"module"},t),(t=ot.get(e))&&$c(l,t),n=u.createElement("script"),Al(n),Hl(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function Jv(l,t,u,a){var e=(e=X.current)?Mn(e):null;if(!e)throw Error(o(446));switch(l){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(t=Ea(u.href),u=xu(e).hoistableStyles,a=u.get(t),a||(a={type:"style",instance:null,count:0,state:null},u.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){l=Ea(u.href);var n=xu(e).hoistableStyles,f=n.get(l);if(f||(e=e.ownerDocument||e,f={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},n.set(l,f),(n=e.querySelector(me(l)))&&!n._p&&(f.instance=n,f.state.loading=5),ot.has(l)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},ot.set(l,u),n||Cs(e,l,u,f.state))),t&&a===null)throw Error(o(528,""));return f}if(t&&a!==null)throw Error(o(529,""));return null;case"script":return t=u.async,u=u.src,typeof u=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Aa(u),u=xu(e).hoistableScripts,a=u.get(t),a||(a={type:"script",instance:null,count:0,state:null},u.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,l))}}function Ea(l){return'href="'+ct(l)+'"'}function me(l){return'link[rel="stylesheet"]['+l+"]"}function wv(l){return R({},l,{"data-precedence":l.precedence,precedence:null})}function Cs(l,t,u,a){l.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=l.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Hl(t,"link",u),Al(t),l.head.appendChild(t))}function Aa(l){return'[src="'+ct(l)+'"]'}function se(l){return"script[async]"+l}function Wv(l,t,u){if(t.count++,t.instance===null)switch(t.type){case"style":var a=l.querySelector('style[data-href~="'+ct(u.href)+'"]');if(a)return t.instance=a,Al(a),a;var e=R({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return a=(l.ownerDocument||l).createElement("style"),Al(a),Hl(a,"style",e),Dn(a,u.precedence,l),t.instance=a;case"stylesheet":e=Ea(u.href);var n=l.querySelector(me(e));if(n)return t.state.loading|=4,t.instance=n,Al(n),n;a=wv(u),(e=ot.get(e))&&Wc(a,e),n=(l.ownerDocument||l).createElement("link"),Al(n);var f=n;return f._p=new Promise(function(c,i){f.onload=c,f.onerror=i}),Hl(n,"link",a),t.state.loading|=4,Dn(n,u.precedence,l),t.instance=n;case"script":return n=Aa(u.src),(e=l.querySelector(se(n)))?(t.instance=e,Al(e),e):(a=u,(e=ot.get(n))&&(a=R({},u),$c(a,e)),l=l.ownerDocument||l,e=l.createElement("script"),Al(e),Hl(e,"link",a),l.head.appendChild(e),t.instance=e);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Dn(a,u.precedence,l));return t.instance}function Dn(l,t,u){for(var a=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),e=a.length?a[a.length-1]:null,n=e,f=0;f title"):null)}function Ys(l,t,u){if(u===1||t.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return l=t.disabled,typeof t.precedence=="string"&&l==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function kv(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Bs(l,t,u,a){if(u.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var e=Ea(a.href),n=t.querySelector(me(e));if(n){t=n._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(l.count++,l=rn.bind(l),t.then(l,l)),u.state.loading|=4,u.instance=n,Al(n);return}n=t.ownerDocument||t,a=wv(a),(e=ot.get(e))&&Wc(a,e),n=n.createElement("link"),Al(n);var f=n;f._p=new Promise(function(c,i){f.onload=c,f.onerror=i}),Hl(n,"link",a),u.instance=n}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(u,t),(t=u.state.preload)&&(u.state.loading&3)===0&&(l.count++,u=rn.bind(l),t.addEventListener("load",u),t.addEventListener("error",u))}}var Fc=0;function Gs(l,t){return l.stylesheets&&l.count===0&&Nn(l,l.stylesheets),0Fc?50:800)+t);return l.unsuspend=u,function(){l.unsuspend=null,clearTimeout(a),clearTimeout(e)}}:null}function rn(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nn(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Hn=null;function Nn(l,t){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Hn=new Map,t.forEach(Xs,l),Hn=null,rn.call(l))}function Xs(l,t){if(!(t.state.loading&4)){var u=Hn.get(l);if(u)var a=u.get(null);else{u=new Map,Hn.set(l,u);for(var e=l.querySelectorAll("link[data-precedence],style[data-precedence]"),n=0;n"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M)}catch(Sl){console.error(Sl)}}return M(),ni.exports=td(),ni.exports}var ad=ud();const fd=E1(ad);var cd=_1();export{nd as R,A1 as a,cd as b,ks as c,fd as d,E1 as g,ed as j,yi as r}; diff --git a/internal/webui/static/assets/vendor-Es4K8PXl.js b/internal/webui/static/assets/vendor-Es4K8PXl.js deleted file mode 100644 index ee87cd2..0000000 --- a/internal/webui/static/assets/vendor-Es4K8PXl.js +++ /dev/null @@ -1,33 +0,0 @@ -var ys=Object.defineProperty;var ms=(e,t,n)=>t in e?ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var yt=(e,t,n)=>ms(e,typeof t!="symbol"?t+"":t,n);import{a as rr,r as p,g as gs,b as _s}from"./react-vendor-C_od1ZSF.js";function Ai(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;tObject.prototype.propertyIsEnumerable.call(e,t))}function cr(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Os="[object RegExp]",Ii="[object String]",Li="[object Number]",Ti="[object Boolean]",Di="[object Arguments]",xs="[object Symbol]",Rs="[object Date]",As="[object Map]",Ns="[object Set]",Cs="[object Array]",Ms="[object ArrayBuffer]",Is="[object Object]",Ls="[object DataView]",Ts="[object Uint8Array]",Ds="[object Uint8ClampedArray]",ks="[object Uint16Array]",$s="[object Uint32Array]",Fs="[object Int8Array]",Ws="[object Int16Array]",zs="[object Int32Array]",Us="[object Float32Array]",Bs="[object Float64Array]",Mr=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof global=="object"&&global||(function(){return this})();function js(e){return typeof Mr.Buffer<"u"&&Mr.Buffer.isBuffer(e)}function qs(e,t){return Re(e,void 0,e,new Map,t)}function Re(e,t,n,r=new Map,i=void 0){const o=i==null?void 0:i(e,t,n,r);if(o!==void 0)return o;if(Tn(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){const s=new Array(e.length);r.set(e,s);for(let c=0;c{}):Dn(e,t,function r(i,o,s,c,u,a){const f=n(i,o,s,c,u,a);return f!==void 0?!!f:Dn(i,o,r,a,!1)},new Map,!0)}function Dn(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case"object":return Hs(e,t,n,r);case"function":return Object.keys(t).length>0?Dn(e,{...t},n,r,i):Et(e,t);default:return ki(e)&&i?typeof t=="string"?t==="":!0:Et(e,t)}}function Hs(e,t,n,r){if(t==null)return!0;if(Array.isArray(t))return Fi(e,t,n,r);if(t instanceof Map)return Ys(e,t,n,r);if(t instanceof Set)return Ks(e,t,n,r);const i=Object.keys(t);if(e==null||Tn(e))return i.length===0;if(i.length===0)return!0;if(r!=null&&r.has(t))return r.get(t)===e;r==null||r.set(t,e);try{for(let o=0;o{})}function Gs(e){return e=Xs(e),t=>Wi(t,e)}function Zs(e,t){return qs(e,(n,r,i,o)=>{if(typeof e=="object"){if(cr(e)==="[object Object]"&&typeof e.constructor!="function"){const s={};return o.set(e,s),se(s,e,i,o),s}switch(Object.prototype.toString.call(e)){case Li:case Ii:case Ti:{const s=new e.constructor(e==null?void 0:e.valueOf());return se(s,e),s}case Di:{const s={};return se(s,e),s.length=e.length,s[Symbol.iterator]=e[Symbol.iterator],s}default:return}}})}function Js(e){return Zs(e)}const Qs=/^(?:0|[1-9]\d*)$/;function zi(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e=0}function Ui(e){return e!=null&&typeof e!="function"&&ic(e.length)}function oc(e){return typeof e=="object"&&e!==null}function sc(e){return oc(e)&&Ui(e)}function Ra(e,t=Mi){return sc(e)?vs(Array.from(e),Es(rc(t),1)):[]}var an={exports:{}},ln={},dn={exports:{}},hn={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Ir;function cc(){if(Ir)return hn;Ir=1;var e=rr();function t(l,m){return l===m&&(l!==0||1/l===1/m)||l!==l&&m!==m}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function c(l,m){var h=m(),y=r({inst:{value:h,getSnapshot:m}}),d=y[0].inst,g=y[1];return o(function(){d.value=h,d.getSnapshot=m,u(d)&&g({inst:d})},[l,h,m]),i(function(){return u(d)&&g({inst:d}),l(function(){u(d)&&g({inst:d})})},[l]),s(h),h}function u(l){var m=l.getSnapshot;l=l.value;try{var h=m();return!n(l,h)}catch{return!0}}function a(l,m){return m()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:c;return hn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,hn}var Lr;function uc(){return Lr||(Lr=1,dn.exports=cc()),dn.exports}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Tr;function fc(){if(Tr)return ln;Tr=1;var e=rr(),t=uc();function n(a,f){return a===f&&(a!==0||1/a===1/f)||a!==a&&f!==f}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,u=e.useDebugValue;return ln.useSyncExternalStoreWithSelector=function(a,f,l,m,h){var y=o(null);if(y.current===null){var d={hasValue:!1,value:null};y.current=d}else d=y.current;y=c(function(){function _(x){if(!E){if(E=!0,b=x,x=m(x),h!==void 0&&d.hasValue){var O=d.value;if(h(O,x))return w=O}return w=x}if(O=w,r(b,x))return O;var C=m(x);return h!==void 0&&h(O,C)?(b=x,O):(b=x,w=C)}var E=!1,b,w,v=l===void 0?null:l;return[function(){return _(f())},v===null?void 0:function(){return _(v())}]},[f,l,m,h]);var g=i(a,y[0],y[1]);return s(function(){d.hasValue=!0,d.value=g},[g]),u(g),g},ln}var Dr;function ac(){return Dr||(Dr=1,an.exports=fc()),an.exports}var Aa=ac();function lc(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function dc(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var kr=e=>Array.isArray(e)?e:[e];function hc(e){const t=Array.isArray(e[0])?e[0]:e;return dc(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function pc(e,t){const n=[],{length:r}=e;for(let i=0;itypeof WeakRef>"u"?yc:WeakRef,Bi=mc(),gc=0,$r=1;function mt(){return{s:gc,v:void 0,o:null,p:null}}function _c(e){return e instanceof Bi?e.deref():e}function ji(e,t={}){let n=mt();const{resultEqualityCheck:r}=t;let i,o=0;function s(){let c=n;const{length:u}=arguments;for(let l=0,m=u;l{n=mt(),s.resetResultsCount()},s.resultsCount=()=>o,s.resetResultsCount=()=>{o=0},s}function wc(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,s=0,c,u={},a=i.pop();typeof a=="object"&&(u=a,a=i.pop()),lc(a,`createSelector expects an output function after the inputs, but received: [${typeof a}]`);const f={...n,...u},{memoize:l,memoizeOptions:m=[],argsMemoize:h=ji,argsMemoizeOptions:y=[]}=f,d=kr(m),g=kr(y),_=hc(i),E=l(function(){return o++,a.apply(null,arguments)},...d),b=h(function(){s++;const v=pc(_,arguments);return c=E.apply(null,v),c},...g);return Object.assign(b,{resultFunc:a,memoizedResultFunc:E,dependencies:_,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>c,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var Na=wc(ji);function vc(e,t=1){const n=[],r=Math.floor(t),i=(o,s)=>{for(let c=0;c{if(e!==t){const r=Fr(e),i=Fr(t);if(r===i&&r===0){if(et)return n==="desc"?-1:1}return n==="desc"?i-r:r-i}return 0};function qi(e){return typeof e=="symbol"||e instanceof Symbol}const bc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Sc=/^\w*$/;function Pc(e,t){return Array.isArray(e)?!1:typeof e=="number"||typeof e=="boolean"||e==null||qi(e)?!0:typeof e=="string"&&(Sc.test(e)||!bc.test(e))||t!=null}function Oc(e,t,n,r){if(e==null)return[];n=n,Array.isArray(e)||(e=Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(c=>String(c));const i=(c,u)=>{let a=c;for(let f=0;fu==null||c==null?u:typeof c=="object"&&"key"in c?Object.hasOwn(u,c.key)?u[c.key]:i(u,c.path):typeof c=="function"?c(u):Array.isArray(c)?i(u,c):typeof u=="object"?u[c]:u,s=t.map(c=>(Array.isArray(c)&&c.length===1&&(c=c[0]),c==null||typeof c=="function"||Array.isArray(c)||Pc(c)?c:{key:c,path:or(c)}));return e.map(c=>({original:c,criteria:s.map(u=>o(u,c))})).slice().sort((c,u)=>{for(let a=0;ac.original)}function Ca(e,...t){const n=t.length;return n>1&&kn(e,t[0],t[1])?t=[]:n>2&&kn(t[0],t[1],t[2])&&(t=[t[0]]),Oc(e,vc(t),["asc"])}function Y(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var xc=typeof Symbol=="function"&&Symbol.observable||"@@observable",Wr=xc,pn=()=>Math.random().toString(36).substring(7).split("").join("."),Rc={INIT:`@@redux/INIT${pn()}`,REPLACE:`@@redux/REPLACE${pn()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${pn()}`},Ot=Rc;function ur(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Vi(e,t,n){if(typeof e!="function")throw new Error(Y(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Y(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Y(1));return n(Vi)(e,t)}let r=e,i=t,o=new Map,s=o,c=0,u=!1;function a(){s===o&&(s=new Map,o.forEach((g,_)=>{s.set(_,g)}))}function f(){if(u)throw new Error(Y(3));return i}function l(g){if(typeof g!="function")throw new Error(Y(4));if(u)throw new Error(Y(5));let _=!0;a();const E=c++;return s.set(E,g),function(){if(_){if(u)throw new Error(Y(6));_=!1,a(),s.delete(E),o=null}}}function m(g){if(!ur(g))throw new Error(Y(7));if(typeof g.type>"u")throw new Error(Y(8));if(typeof g.type!="string")throw new Error(Y(17));if(u)throw new Error(Y(9));try{u=!0,i=r(i,g)}finally{u=!1}return(o=s).forEach(E=>{E()}),g}function h(g){if(typeof g!="function")throw new Error(Y(10));r=g,m({type:Ot.REPLACE})}function y(){const g=l;return{subscribe(_){if(typeof _!="object"||_===null)throw new Error(Y(11));function E(){const w=_;w.next&&w.next(f())}return E(),{unsubscribe:g(E)}},[Wr](){return this}}}return m({type:Ot.INIT}),{dispatch:m,subscribe:l,getState:f,replaceReducer:h,[Wr]:y}}function Ac(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Ot.INIT})>"u")throw new Error(Y(12));if(typeof n(void 0,{type:Ot.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Y(13))})}function Nc(e){const t=Object.keys(e),n={};for(let o=0;o"u")throw c&&c.type,new Error(Y(14));a[l]=y,u=u||y!==h}return u=u||r.length!==Object.keys(s).length,u?a:s}}function xt(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function Cc(...e){return t=>(n,r)=>{const i=t(n,r);let o=()=>{throw new Error(Y(15))};const s={getState:i.getState,dispatch:(u,...a)=>o(u,...a)},c=e.map(u=>u(s));return o=xt(...c)(i.dispatch),{...i,dispatch:o}}}function Xi(e){return ur(e)&&"type"in e&&typeof e.type=="string"}var Hi=Symbol.for("immer-nothing"),zr=Symbol.for("immer-draftable"),Z=Symbol.for("immer-state");function ce(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ee=Object,ze=ee.getPrototypeOf,Rt="constructor",zt="prototype",$n="configurable",At="enumerable",bt="writable",Je="value",ge=e=>!!e&&!!e[Z];function fe(e){var t;return e?Yi(e)||Bt(e)||!!e[zr]||!!((t=e[Rt])!=null&&t[zr])||jt(e)||qt(e):!1}var Mc=ee[zt][Rt].toString(),Ur=new WeakMap;function Yi(e){if(!e||!fr(e))return!1;const t=ze(e);if(t===null||t===ee[zt])return!0;const n=ee.hasOwnProperty.call(t,Rt)&&t[Rt];if(n===Object)return!0;if(!Fe(n))return!1;let r=Ur.get(n);return r===void 0&&(r=Function.toString.call(n),Ur.set(n,r)),r===Mc}function Ut(e,t,n=!0){ot(e)===0?(n?Reflect.ownKeys(e):ee.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function ot(e){const t=e[Z];return t?t.type_:Bt(e)?1:jt(e)?2:qt(e)?3:0}var Br=(e,t,n=ot(e))=>n===2?e.has(t):ee[zt].hasOwnProperty.call(e,t),Fn=(e,t,n=ot(e))=>n===2?e.get(t):e[t],Nt=(e,t,n,r=ot(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ic(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Bt=Array.isArray,jt=e=>e instanceof Map,qt=e=>e instanceof Set,fr=e=>typeof e=="object",Fe=e=>typeof e=="function",yn=e=>typeof e=="boolean";function Lc(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var pe=e=>e.copy_||e.base_,ar=e=>e.modified_?e.copy_:e.base_;function Wn(e,t){if(jt(e))return new Map(e);if(qt(e))return new Set(e);if(Bt(e))return Array[zt].slice.call(e);const n=Yi(e);if(t===!0||t==="class_only"&&!n){const r=ee.getOwnPropertyDescriptors(e);delete r[Z];let i=Reflect.ownKeys(r);for(let o=0;o1&&ee.defineProperties(e,{set:gt,add:gt,clear:gt,delete:gt}),ee.freeze(e),t&&Ut(e,(n,r)=>{lr(r,!0)},!1)),e}function Tc(){ce(2)}var gt={[Je]:Tc};function Vt(e){return e===null||!fr(e)?!0:ee.isFrozen(e)}var Ct="MapSet",zn="Patches",jr="ArrayMethods",Ki={};function Ce(e){const t=Ki[e];return t||ce(0,e),t}var qr=e=>!!Ki[e],Qe,Gi=()=>Qe,Dc=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:qr(Ct)?Ce(Ct):void 0,arrayMethodsPlugin_:qr(jr)?Ce(jr):void 0});function Vr(e,t){t&&(e.patchPlugin_=Ce(zn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Un(e){Bn(e),e.drafts_.forEach(kc),e.drafts_=null}function Bn(e){e===Qe&&(Qe=e.parent_)}var Xr=e=>Qe=Dc(Qe,e);function kc(e){const t=e[Z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Hr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[Z].modified_&&(Un(t),ce(4)),fe(e)&&(e=Yr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[Z].base_,e,t)}else e=Yr(t,n);return $c(t,e,!0),Un(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Hi?e:void 0}function Yr(e,t){if(Vt(t))return t;const n=t[Z];if(!n)return Mt(t,e.handledSet_,e);if(!Xt(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);Qi(n,e)}return n.copy_}function $c(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&lr(t,n)}function Zi(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Xt=(e,t)=>e.scope_===t,Fc=[];function Ji(e,t,n,r){const i=pe(e),o=e.type_;if(r!==void 0&&Fn(i,r,o)===t){Nt(i,r,n,o);return}if(!e.draftLocations_){const c=e.draftLocations_=new Map;Ut(i,(u,a)=>{if(ge(a)){const f=c.get(a)||[];f.push(u),c.set(a,f)}})}const s=e.draftLocations_.get(t)??Fc;for(const c of s)Nt(i,c,n,o)}function Wc(e,t,n){e.callbacks_.push(function(i){var c;const o=t;if(!o||!Xt(o,i))return;(c=i.mapSetPlugin_)==null||c.fixSetContents(o);const s=ar(o);Ji(e,o.draft_??o,s,n),Qi(o,i)})}function Qi(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const o=i.getPath(e);o&&i.generatePatches_(e,o,t)}Zi(e)}}function zc(e,t,n){const{scope_:r}=e;if(ge(n)){const i=n[Z];Xt(i,r)&&i.callbacks_.push(function(){St(e);const s=ar(i);Ji(e,n,s,t)})}else fe(n)&&e.callbacks_.push(function(){const o=pe(e);e.type_===3?o.has(n)&&Mt(n,r.handledSet_,r):Fn(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Mt(Fn(e.copy_,t,e.type_),r.handledSet_,r)})}function Mt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ge(e)||t.has(e)||!fe(e)||Vt(e)||(t.add(e),Ut(e,(r,i)=>{if(ge(i)){const o=i[Z];if(Xt(o,n)){const s=ar(o);Nt(e,r,s,e.type_),Zi(o)}}else fe(i)&&Mt(i,t,n)})),e}function Uc(e,t){const n=Bt(e),r={type_:n?1:0,scope_:t?t.scope_:Gi(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,o=It;n&&(i=[r],o=et);const{revoke:s,proxy:c}=Proxy.revocable(i,o);return r.draft_=c,r.revoke_=s,[c,r]}var It={get(e,t){if(t===Z)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=pe(e);if(!Br(i,t,e.type_))return Bc(e,i,t);const o=i[t];if(e.finalized_||!fe(o)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&Lc(t))return o;if(o===mn(e.base_,t)){St(e);const s=e.type_===1?+t:t,c=qn(e.scope_,o,e,s);return e.copy_[s]=c}return o},has(e,t){return t in pe(e)},ownKeys(e){return Reflect.ownKeys(pe(e))},set(e,t,n){const r=eo(pe(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=mn(pe(e),t),o=i==null?void 0:i[Z];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ic(n,i)&&(n!==void 0||Br(e.base_,t,e.type_)))return!0;St(e),jn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),zc(e,t,n)),!0},deleteProperty(e,t){return St(e),mn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),jn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=pe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[bt]:!0,[$n]:e.type_!==1||t!=="length",[At]:r[At],[Je]:n[t]}},defineProperty(){ce(11)},getPrototypeOf(e){return ze(e.base_)},setPrototypeOf(){ce(12)}},et={};for(let e in It){let t=It[e];et[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}et.deleteProperty=function(e,t){return et.set.call(this,e,t,void 0)};et.set=function(e,t,n){return It.set.call(this,e[0],t,n,e[0])};function mn(e,t){const n=e[Z];return(n?pe(n):e)[t]}function Bc(e,t,n){var i;const r=eo(t,n);return r?Je in r?r[Je]:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function eo(e,t){if(!(t in e))return;let n=ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=ze(n)}}function jn(e){e.modified_||(e.modified_=!0,e.parent_&&jn(e.parent_))}function St(e){e.copy_||(e.assigned_=new Map,e.copy_=Wn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var jc=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Fe(n)&&!Fe(r)){const s=r;r=n;const c=this;return function(a=s,...f){return c.produce(a,l=>r.call(this,l,...f))}}Fe(r)||ce(6),i!==void 0&&!Fe(i)&&ce(7);let o;if(fe(n)){const s=Xr(this),c=qn(s,n,void 0);let u=!0;try{o=r(c),u=!1}finally{u?Un(s):Bn(s)}return Vr(s,i),Hr(o,s)}else if(!n||!fr(n)){if(o=r(n),o===void 0&&(o=n),o===Hi&&(o=void 0),this.autoFreeze_&&lr(o,!0),i){const s=[],c=[];Ce(zn).generateReplacementPatches_(n,o,{patches_:s,inversePatches_:c}),i(s,c)}return o}else ce(1,n)},this.produceWithPatches=(n,r)=>{if(Fe(n))return(c,...u)=>this.produceWithPatches(c,a=>n(a,...u));let i,o;return[this.produce(n,r,(c,u)=>{i=c,o=u}),i,o]},yn(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),yn(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),yn(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){fe(t)||ce(8),ge(t)&&(t=qc(t));const n=Xr(this),r=qn(n,t,void 0);return r[Z].isManual_=!0,Bn(n),r}finishDraft(t,n){const r=t&&t[Z];(!r||!r.isManual_)&&ce(9);const{scope_:i}=r;return Vr(i,n),Hr(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const o=n[r];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}r>-1&&(n=n.slice(r+1));const i=Ce(zn).applyPatches_;return ge(t)?i(t,n):this.produce(t,o=>i(o,n))}};function qn(e,t,n,r){const[i,o]=jt(t)?Ce(Ct).proxyMap_(t,n):qt(t)?Ce(Ct).proxySet_(t,n):Uc(t,n);return((n==null?void 0:n.scope_)??Gi()).drafts_.push(i),o.callbacks_=(n==null?void 0:n.callbacks_)??[],o.key_=r,n&&r!==void 0?Wc(n,o,r):o.callbacks_.push(function(u){var f;(f=u.mapSetPlugin_)==null||f.fixSetContents(o);const{patchPlugin_:a}=u;o.modified_&&a&&a.generatePatches_(o,[],u)}),i}function qc(e){return ge(e)||ce(10,e),to(e)}function to(e){if(!fe(e)||Vt(e))return e;const t=e[Z];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Wn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Wn(e,!0);return Ut(n,(i,o)=>{Nt(n,i,to(o))},r),t&&(t.finalized_=!1),n}var Vc=new jc,no=Vc.produce;function ro(e){return({dispatch:n,getState:r})=>i=>o=>typeof o=="function"?o(n,r,e):i(o)}var Xc=ro(),Hc=ro,Yc=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?xt:xt.apply(null,arguments)};function Ue(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(te(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Xi(r)&&r.type===e,n}var io=class Ze extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Ze.prototype)}static get[Symbol.species](){return Ze}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Ze(...t[0].concat(this)):new Ze(...t.concat(this))}};function Kr(e){return fe(e)?no(e,()=>{}):e}function _t(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function Kc(e){return typeof e=="boolean"}var Gc=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=t??{};let s=new io;return n&&(Kc(n)?s.push(Xc):s.push(Hc(n.extraArgument))),s},oo="RTK_autoBatch",Ia=()=>e=>({payload:e,meta:{[oo]:!0}}),Gr=e=>t=>{setTimeout(t,e)},Zc=(e,t)=>n=>{let r=!1;const i=()=>{r||(r=!0,cancelAnimationFrame(o),clearTimeout(s),n())},o=e(i),s=setTimeout(i,t)},Jc=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,o=!1,s=!1;const c=new Set,u=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?Zc(window.requestAnimationFrame,100):Gr(10):e.type==="callback"?e.queueNotification:Gr(e.timeout),a=()=>{s=!1,o&&(o=!1,c.forEach(f=>f()))};return Object.assign({},r,{subscribe(f){const l=()=>i&&f(),m=r.subscribe(l);return c.add(f),()=>{m(),c.delete(f)}},dispatch(f){var l;try{return i=!((l=f==null?void 0:f.meta)!=null&&l[oo]),o=!i,o&&(s||(s=!0,u(a))),r.dispatch(f)}finally{i=!0}}})},Qc=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new io(e);return r&&i.push(Jc(typeof r=="object"?r:void 0)),i};function La(e){const t=Gc(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{};let c;if(typeof n=="function")c=n;else if(ur(n))c=Nc(n);else throw new Error(te(1));let u;typeof r=="function"?u=r(t):u=t();let a=xt;i&&(a=Yc({trace:!1,...typeof i=="object"&&i}));const f=Cc(...u),l=Qc(f);let m=typeof s=="function"?s(l):l();const h=a(...m);return Vi(c,o,h)}function so(e){const t={},n=[];let r;const i={addCase(o,s){const c=typeof o=="string"?o:o.type;if(!c)throw new Error(te(28));if(c in t)throw new Error(te(29));return t[c]=s,i},addAsyncThunk(o,s){return s.pending&&(t[o.pending.type]=s.pending),s.rejected&&(t[o.rejected.type]=s.rejected),s.fulfilled&&(t[o.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:o.settled,reducer:s.settled}),i},addMatcher(o,s){return n.push({matcher:o,reducer:s}),i},addDefaultCase(o){return r=o,i}};return e(i),[t,n,r]}function eu(e){return typeof e=="function"}function tu(e,t){let[n,r,i]=so(t),o;if(eu(e))o=()=>Kr(e());else{const c=Kr(e);o=()=>c}function s(c=o(),u){let a=[n[u.type],...r.filter(({matcher:f})=>f(u)).map(({reducer:f})=>f)];return a.filter(f=>!!f).length===0&&(a=[i]),a.reduce((f,l)=>{if(l)if(ge(f)){const h=l(f,u);return h===void 0?f:h}else{if(fe(f))return no(f,m=>l(m,u));{const m=l(f,u);if(m===void 0){if(f===null)return f;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return f},c)}return s.getInitialState=o,s}var nu="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",ru=(e=21)=>{let t="",n=e;for(;n--;)t+=nu[Math.random()*64|0];return t},iu=Symbol.for("rtk-slice-createasyncthunk");function ou(e,t){return`${e}/${t}`}function su({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[iu];return function(i){const{name:o,reducerPath:s=o}=i;if(!o)throw new Error(te(11));const c=(typeof i.reducers=="function"?i.reducers(uu()):i.reducers)||{},u=Object.keys(c),a={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},f={addCase(w,v){const x=typeof w=="string"?w:w.type;if(!x)throw new Error(te(12));if(x in a.sliceCaseReducersByType)throw new Error(te(13));return a.sliceCaseReducersByType[x]=v,f},addMatcher(w,v){return a.sliceMatchers.push({matcher:w,reducer:v}),f},exposeAction(w,v){return a.actionCreators[w]=v,f},exposeCaseReducer(w,v){return a.sliceCaseReducersByName[w]=v,f}};u.forEach(w=>{const v=c[w],x={reducerName:w,type:ou(o,w),createNotation:typeof i.reducers=="function"};au(v)?du(x,v,f,t):fu(x,v,f)});function l(){const[w={},v=[],x=void 0]=typeof i.extraReducers=="function"?so(i.extraReducers):[i.extraReducers],O={...w,...a.sliceCaseReducersByType};return tu(i.initialState,C=>{for(let R in O)C.addCase(R,O[R]);for(let R of a.sliceMatchers)C.addMatcher(R.matcher,R.reducer);for(let R of v)C.addMatcher(R.matcher,R.reducer);x&&C.addDefaultCase(x)})}const m=w=>w,h=new Map,y=new WeakMap;let d;function g(w,v){return d||(d=l()),d(w,v)}function _(){return d||(d=l()),d.getInitialState()}function E(w,v=!1){function x(C){let R=C[w];return typeof R>"u"&&v&&(R=_t(y,x,_)),R}function O(C=m){const R=_t(h,v,()=>new WeakMap);return _t(R,C,()=>{const B={};for(const[F,I]of Object.entries(i.selectors??{}))B[F]=cu(I,C,()=>_t(y,C,_),v);return B})}return{reducerPath:w,getSelectors:O,get selectors(){return O(x)},selectSlice:x}}const b={name:o,reducer:g,actions:a.actionCreators,caseReducers:a.sliceCaseReducersByName,getInitialState:_,...E(s),injectInto(w,{reducerPath:v,...x}={}){const O=v??s;return w.inject({reducerPath:O,reducer:g},x),{...b,...E(O,!0)}}};return b}}function cu(e,t,n,r){function i(o,...s){let c=t(o);return typeof c>"u"&&r&&(c=n()),e(c,...s)}return i.unwrapped=e,i}var Ta=su();function uu(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function fu({type:e,reducerName:t,createNotation:n},r,i){let o,s;if("reducer"in r){if(n&&!lu(r))throw new Error(te(17));o=r.reducer,s=r.prepare}else o=r;i.addCase(e,o).exposeCaseReducer(t,o).exposeAction(t,s?Ue(e,s):Ue(e))}function au(e){return e._reducerDefinitionType==="asyncThunk"}function lu(e){return e._reducerDefinitionType==="reducerWithPrepare"}function du({type:e,reducerName:t},n,r,i){if(!i)throw new Error(te(18));const{payloadCreator:o,fulfilled:s,pending:c,rejected:u,settled:a,options:f}=n,l=i(e,o,f);r.exposeAction(t,l),s&&r.addCase(l.fulfilled,s),c&&r.addCase(l.pending,c),u&&r.addCase(l.rejected,u),a&&r.addMatcher(l.settled,a),r.exposeCaseReducer(t,{fulfilled:s||wt,pending:c||wt,rejected:u||wt,settled:a||wt})}function wt(){}var hu="task",co="listener",uo="completed",dr="cancelled",pu=`task-${dr}`,yu=`task-${uo}`,Vn=`${co}-${dr}`,mu=`${co}-${uo}`,Ht=class{constructor(e){yt(this,"code");yt(this,"name","TaskAbortError");yt(this,"message");this.code=e,this.message=`${hu} ${dr} (reason: ${e})`}},hr=(e,t)=>{if(typeof e!="function")throw new TypeError(te(32))},Lt=()=>{},fo=(e,t=Lt)=>(e.catch(t),e),ao=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Ae=e=>{if(e.aborted)throw new Ht(e.reason)};function lo(e,t){let n=Lt;return new Promise((r,i)=>{const o=()=>i(new Ht(e.reason));if(e.aborted){o();return}n=ao(e,o),t.finally(()=>n()).then(r,i)}).finally(()=>{n=Lt})}var gu=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof Ht?"cancelled":"rejected",error:n}}finally{t==null||t()}},Tt=e=>t=>fo(lo(e,t).then(n=>(Ae(e),n))),ho=e=>{const t=Tt(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:We}=Object,Zr={},Yt="listenerMiddleware",_u=(e,t)=>{const n=r=>ao(e,()=>r.abort(e.reason));return(r,i)=>{hr(r);const o=new AbortController;n(o);const s=gu(async()=>{Ae(e),Ae(o.signal);const c=await r({pause:Tt(o.signal),delay:ho(o.signal),signal:o.signal});return Ae(o.signal),c},()=>o.abort(yu));return i!=null&&i.autoJoin&&t.push(s.catch(Lt)),{result:Tt(e)(s),cancel(){o.abort(pu)}}}},wu=(e,t)=>{const n=async(r,i)=>{Ae(t);let o=()=>{};const c=[new Promise((u,a)=>{let f=e({predicate:r,effect:(l,m)=>{m.unsubscribe(),u([l,m.getState(),m.getOriginalState()])}});o=()=>{f(),a()}})];i!=null&&c.push(new Promise(u=>setTimeout(u,i,null)));try{const u=await lo(t,Promise.race(c));return Ae(t),u}finally{o()}};return((r,i)=>fo(n(r,i)))},po=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:o}=e;if(t)i=Ue(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(te(21));return hr(o),{predicate:i,type:t,effect:o}},yo=We(e=>{const{type:t,predicate:n,effect:r}=po(e);return{id:ru(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(te(22))}}},{withTypes:()=>yo}),Jr=(e,t)=>{const{type:n,effect:r,predicate:i}=po(t);return Array.from(e.values()).find(o=>(typeof n=="string"?o.type===n:o.predicate===i)&&o.effect===r)},Xn=e=>{e.pending.forEach(t=>{t.abort(Vn)})},vu=(e,t)=>()=>{for(const n of t.keys())Xn(n);e.clear()},Qr=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},mo=We(Ue(`${Yt}/add`),{withTypes:()=>mo}),Eu=Ue(`${Yt}/removeAll`),go=We(Ue(`${Yt}/remove`),{withTypes:()=>go}),bu=(...e)=>{console.error(`${Yt}/error`,...e)},Da=(e={})=>{const t=new Map,n=new Map,r=h=>{const y=n.get(h)??0;n.set(h,y+1)},i=h=>{const y=n.get(h)??1;y===1?n.delete(h):n.set(h,y-1)},{extra:o,onError:s=bu}=e;hr(s);const c=h=>(h.unsubscribe=()=>t.delete(h.id),t.set(h.id,h),y=>{h.unsubscribe(),y!=null&&y.cancelActive&&Xn(h)}),u=(h=>{const y=Jr(t,h)??yo(h);return c(y)});We(u,{withTypes:()=>u});const a=h=>{const y=Jr(t,h);return y&&(y.unsubscribe(),h.cancelActive&&Xn(y)),!!y};We(a,{withTypes:()=>a});const f=async(h,y,d,g)=>{const _=new AbortController,E=wu(u,_.signal),b=[];try{h.pending.add(_),r(h),await Promise.resolve(h.effect(y,We({},d,{getOriginalState:g,condition:(w,v)=>E(w,v).then(Boolean),take:E,delay:ho(_.signal),pause:Tt(_.signal),extra:o,signal:_.signal,fork:_u(_.signal,b),unsubscribe:h.unsubscribe,subscribe:()=>{t.set(h.id,h)},cancelActiveListeners:()=>{h.pending.forEach((w,v,x)=>{w!==_&&(w.abort(Vn),x.delete(w))})},cancel:()=>{_.abort(Vn),h.pending.delete(_)},throwIfCancelled:()=>{Ae(_.signal)}})))}catch(w){w instanceof Ht||Qr(s,w,{raisedBy:"effect"})}finally{await Promise.all(b),_.abort(mu),i(h),h.pending.delete(_)}},l=vu(t,n);return{middleware:h=>y=>d=>{if(!Xi(d))return y(d);if(mo.match(d))return u(d.payload);if(Eu.match(d)){l();return}if(go.match(d))return a(d.payload);let g=h.getState();const _=()=>{if(g===Zr)throw new Error(te(23));return g};let E;try{if(E=y(d),t.size>0){const b=h.getState(),w=Array.from(t.values());for(const v of w){let x=!1;try{x=v.predicate(d,b,g)}catch(O){x=!1,Qr(s,O,{raisedBy:"predicate"})}x&&f(v,d,h,_)}}}finally{g=Zr}return E},startListening:u,stopListening:a,clearListeners:l}};function te(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}function Su(e,t,{signal:n,edges:r}={}){let i,o=null;const s=r!=null&&r.includes("leading"),c=r==null||r.includes("trailing"),u=()=>{o!==null&&(e.apply(i,o),i=void 0,o=null)},a=()=>{c&&u(),h()};let f=null;const l=()=>{f!=null&&clearTimeout(f),f=setTimeout(()=>{f=null,a()},t)},m=()=>{f!==null&&(clearTimeout(f),f=null)},h=()=>{m(),i=void 0,o=null},y=()=>{u()},d=function(...g){if(n!=null&&n.aborted)return;i=this,o=g;const _=f==null;l(),s&&_&&u()};return d.schedule=l,d.cancel=h,d.flush=y,n==null||n.addEventListener("abort",h,{once:!0}),d}function Pu(e,t=0,n={}){typeof n!="object"&&(n={});const{leading:r=!1,trailing:i=!0,maxWait:o}=n,s=Array(2);r&&(s[0]="leading"),i&&(s[1]="trailing");let c,u=null;const a=Su(function(...m){c=e.apply(this,m),u=null},t,{edges:s}),f=function(...m){return o!=null&&(u===null&&(u=Date.now()),Date.now()-u>=o)?(c=e.apply(this,m),u=Date.now(),a.cancel(),a.schedule(),c):(a.apply(this,m),c)},l=()=>(a.flush(),c);return f.cancel=a.cancel,f.flush=l,f}function ka(e,t=0,n={}){const{leading:r=!0,trailing:i=!0}=n;return Pu(e,t,{leading:r,maxWait:t,trailing:i})}var _o=Symbol.for("immer-nothing"),ei=Symbol.for("immer-draftable"),ne=Symbol.for("immer-state");function ue(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var tt=Object.getPrototypeOf;function Be(e){return!!e&&!!e[ne]}function Me(e){var t;return e?wo(e)||Array.isArray(e)||!!e[ei]||!!((t=e.constructor)!=null&&t[ei])||st(e)||Gt(e):!1}var Ou=Object.prototype.constructor.toString(),ti=new WeakMap;function wo(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=ti.get(n);return r===void 0&&(r=Function.toString.call(n),ti.set(n,r)),r===Ou}function Dt(e,t,n=!0){Kt(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Kt(e){const t=e[ne];return t?t.type_:Array.isArray(e)?1:st(e)?2:Gt(e)?3:0}function Hn(e,t){return Kt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vo(e,t,n){const r=Kt(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function xu(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function st(e){return e instanceof Map}function Gt(e){return e instanceof Set}function Se(e){return e.copy_||e.base_}function Yn(e,t){if(st(e))return new Map(e);if(Gt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=wo(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[ne];let i=Reflect.ownKeys(r);for(let o=0;o1&&Object.defineProperties(e,{set:vt,add:vt,clear:vt,delete:vt}),Object.freeze(e),t&&Object.values(e).forEach(n=>pr(n,!0))),e}function Ru(){ue(2)}var vt={value:Ru};function Zt(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var Au={};function Ie(e){const t=Au[e];return t||ue(0,e),t}var nt;function Eo(){return nt}function Nu(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ni(e,t){t&&(Ie("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kn(e){Gn(e),e.drafts_.forEach(Cu),e.drafts_=null}function Gn(e){e===nt&&(nt=e.parent_)}function ri(e){return nt=Nu(nt,e)}function Cu(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ii(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ne].modified_&&(Kn(t),ue(4)),Me(e)&&(e=kt(t,e),t.parent_||$t(t,e)),t.patches_&&Ie("Patches").generateReplacementPatches_(n[ne].base_,e,t.patches_,t.inversePatches_)):e=kt(t,n,[]),Kn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==_o?e:void 0}function kt(e,t,n){if(Zt(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[ne];if(!i)return Dt(t,(o,s)=>oi(e,i,t,o,s,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return $t(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let s=o,c=!1;i.type_===3&&(s=new Set(o),o.clear(),c=!0),Dt(s,(u,a)=>oi(e,i,o,u,a,n,c),r),$t(e,o,!1),n&&e.patches_&&Ie("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function oi(e,t,n,r,i,o,s){if(i==null||typeof i!="object"&&!s)return;const c=Zt(i);if(!(c&&!s)){if(Be(i)){const u=o&&t&&t.type_!==3&&!Hn(t.assigned_,r)?o.concat(r):void 0,a=kt(e,i,u);if(vo(n,r,a),Be(a))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Me(i)&&!c){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&c)return;kt(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(st(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&$t(e,i)}}}function $t(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&pr(t,n)}function Mu(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Eo(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=yr;n&&(i=[r],o=rt);const{revoke:s,proxy:c}=Proxy.revocable(i,o);return r.draft_=c,r.revoke_=s,c}var yr={get(e,t){if(t===ne)return e;const n=Se(e);if(!Hn(n,t))return Iu(e,n,t);const r=n[t];return e.finalized_||!Me(r)?r:r===gn(e.base_,t)?(_n(e),e.copy_[t]=Jn(r,e)):r},has(e,t){return t in Se(e)},ownKeys(e){return Reflect.ownKeys(Se(e))},set(e,t,n){const r=bo(Se(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=gn(Se(e),t),o=i==null?void 0:i[ne];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(xu(n,i)&&(n!==void 0||Hn(e.base_,t)))return!0;_n(e),Zn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return gn(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,_n(e),Zn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Se(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){ue(11)},getPrototypeOf(e){return tt(e.base_)},setPrototypeOf(){ue(12)}},rt={};Dt(yr,(e,t)=>{rt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});rt.deleteProperty=function(e,t){return rt.set.call(this,e,t,void 0)};rt.set=function(e,t,n){return yr.set.call(this,e[0],t,n,e[0])};function gn(e,t){const n=e[ne];return(n?Se(n):e)[t]}function Iu(e,t,n){var i;const r=bo(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function bo(e,t){if(!(t in e))return;let n=tt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tt(n)}}function Zn(e){e.modified_||(e.modified_=!0,e.parent_&&Zn(e.parent_))}function _n(e){e.copy_||(e.copy_=Yn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Lu=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const s=this;return function(u=o,...a){return s.produce(u,f=>n.call(this,f,...a))}}typeof n!="function"&&ue(6),r!==void 0&&typeof r!="function"&&ue(7);let i;if(Me(t)){const o=ri(this),s=Jn(t,void 0);let c=!0;try{i=n(s),c=!1}finally{c?Kn(o):Gn(o)}return ni(o,r),ii(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===_o&&(i=void 0),this.autoFreeze_&&pr(i,!0),r){const o=[],s=[];Ie("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}else ue(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...c)=>this.produceWithPatches(s,u=>t(u,...c));let r,i;return[this.produce(t,n,(s,c)=>{r=s,i=c}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Me(e)||ue(8),Be(e)&&(e=Tu(e));const t=ri(this),n=Jn(e,void 0);return n[ne].isManual_=!0,Gn(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&ue(9);const{scope_:r}=n;return ni(r,t),ii(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Ie("Patches").applyPatches_;return Be(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Jn(e,t){const n=st(e)?Ie("MapSet").proxyMap_(e,t):Gt(e)?Ie("MapSet").proxySet_(e,t):Mu(e,t);return(t?t.scope_:Eo()).drafts_.push(n),n}function Tu(e){return Be(e)||ue(10,e),So(e)}function So(e){if(!Me(e)||Zt(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Yn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Yn(e,!0);return Dt(n,(i,o)=>{vo(n,i,So(o))},r),t&&(t.finalized_=!1),n}var Du=new Lu;Du.produce;function $a(e){return e}var wn={exports:{}},vn={};/** - * @license React - * use-sync-external-store-with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var si;function ku(){if(si)return vn;si=1;var e=rr();function t(u,a){return u===a&&(u!==0||1/u===1/a)||u!==u&&a!==a}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,o=e.useEffect,s=e.useMemo,c=e.useDebugValue;return vn.useSyncExternalStoreWithSelector=function(u,a,f,l,m){var h=i(null);if(h.current===null){var y={hasValue:!1,value:null};h.current=y}else y=h.current;h=s(function(){function g(v){if(!_){if(_=!0,E=v,v=l(v),m!==void 0&&y.hasValue){var x=y.value;if(m(x,v))return b=x}return b=v}if(x=b,n(E,v))return x;var O=l(v);return m!==void 0&&m(x,O)?(E=v,x):(E=v,b=O)}var _=!1,E,b,w=f===void 0?null:f;return[function(){return g(a())},w===null?void 0:function(){return g(w())}]},[a,f,l,m]);var d=r(u,h[0],h[1]);return o(function(){y.hasValue=!0,y.value=d},[d]),c(d),d},vn}var ci;function $u(){return ci||(ci=1,wn.exports=ku()),wn.exports}$u();function Fu(e){e()}function Wu(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Fu(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var ui={notify(){},get:()=>[]};function zu(e,t){let n,r=ui,i=0,o=!1;function s(d){f();const g=r.subscribe(d);let _=!1;return()=>{_||(_=!0,g(),l())}}function c(){r.notify()}function u(){y.onStateChange&&y.onStateChange()}function a(){return o}function f(){i++,n||(n=e.subscribe(u),r=Wu())}function l(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=ui)}function m(){o||(o=!0,f())}function h(){o&&(o=!1,l())}const y={addNestedSub:s,notifyNestedSubs:c,handleChangeWrapper:u,isSubscribed:a,trySubscribe:m,tryUnsubscribe:h,getListeners:()=>r};return y}var Uu=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Bu=Uu(),ju=()=>typeof navigator<"u"&&navigator.product==="ReactNative",qu=ju(),Vu=()=>Bu||qu?p.useLayoutEffect:p.useEffect,Xu=Vu();function fi(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Fa(e,t){if(fi(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;i{const u=zu(i);return{store:i,subscription:u,getServerState:r?()=>r:void 0}},[i,r]),s=p.useMemo(()=>i.getState(),[i]);Xu(()=>{const{subscription:u}=o;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),s!==i.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[o,s]);const c=n||Yu;return p.createElement(c.Provider,{value:o},t)}var Wa=Ku;function Gu(e){return qi(e)?NaN:Number(e)}function Sn(e){return e?(e=Gu(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}function za(e,t,n){n&&typeof n!="number"&&kn(e,t,n)&&(t=n=void 0),e=Sn(e),t===void 0?(t=e,e=0):t=Sn(t),n=n===void 0?ee.e^o.s<0?1:-1;for(r=o.d.length,i=e.d.length,t=0,n=re.d[t]^o.s<0?1:-1;return r===i?0:r>i^o.s<0?1:-1};S.decimalPlaces=S.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*$;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};S.dividedBy=S.div=function(e){return ye(this,new this.constructor(e))};S.dividedToIntegerBy=S.idiv=function(e){var t=this,n=t.constructor;return k(ye(t,new n(e),0,1),n.precision)};S.equals=S.eq=function(e){return!this.cmp(e)};S.exponent=function(){return j(this)};S.greaterThan=S.gt=function(e){return this.cmp(e)>0};S.greaterThanOrEqualTo=S.gte=function(e){return this.cmp(e)>=0};S.isInteger=S.isint=function(){return this.e>this.d.length-2};S.isNegative=S.isneg=function(){return this.s<0};S.isPositive=S.ispos=function(){return this.s>0};S.isZero=function(){return this.s===0};S.lessThan=S.lt=function(e){return this.cmp(e)<0};S.lessThanOrEqualTo=S.lte=function(e){return this.cmp(e)<1};S.logarithm=S.log=function(e){var t,n=this,r=n.constructor,i=r.precision,o=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Q))throw Error(ie+"NaN");if(n.s<1)throw Error(ie+(n.s?"NaN":"-Infinity"));return n.eq(Q)?new r(0):(z=!1,t=ye(it(n,o),it(e,o),o),z=!0,k(t,i))};S.minus=S.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Ro(t,e):Oo(t,(e.s=-e.s,e))};S.modulo=S.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(ie+"NaN");return n.s?(z=!1,t=ye(n,e,0,1).times(e),z=!0,n.minus(t)):k(new r(n),i)};S.naturalExponential=S.exp=function(){return xo(this)};S.naturalLogarithm=S.ln=function(){return it(this)};S.negated=S.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};S.plus=S.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Oo(t,e):Ro(t,(e.s=-e.s,e))};S.precision=S.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Ne+e);if(t=j(i)+1,r=i.d.length-1,n=r*$+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};S.squareRoot=S.sqrt=function(){var e,t,n,r,i,o,s,c=this,u=c.constructor;if(c.s<1){if(!c.s)return new u(0);throw Error(ie+"NaN")}for(e=j(c),z=!1,i=Math.sqrt(+c),i==0||i==1/0?(t=de(c.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=Xe((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new u(t)):r=new u(i.toString()),n=u.precision,i=s=n+3;;)if(o=r,r=o.plus(ye(c,o,s+2)).times(.5),de(o.d).slice(0,s)===(t=de(r.d)).slice(0,s)){if(t=t.slice(s-3,s+1),i==s&&t=="4999"){if(k(o,n+1,0),o.times(o).eq(c)){r=o;break}}else if(t!="9999")break;s+=4}return z=!0,k(r,n)};S.times=S.mul=function(e){var t,n,r,i,o,s,c,u,a,f=this,l=f.constructor,m=f.d,h=(e=new l(e)).d;if(!f.s||!e.s)return new l(0);for(e.s*=f.s,n=f.e+e.e,u=m.length,a=h.length,u=0;){for(t=0,i=u+r;i>r;)c=o[i]+h[r]*m[i-r-1]+t,o[i--]=c%X|0,t=c/X|0;o[i]=(o[i]+t)%X|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,z?k(e,l.precision):e};S.toDecimalPlaces=S.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(he(e,0,Ve),t===void 0?t=r.rounding:he(t,0,8),k(n,e+j(n)+1,t))};S.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Le(r,!0):(he(e,0,Ve),t===void 0?t=i.rounding:he(t,0,8),r=k(new i(r),e+1,t),n=Le(r,!0,e+1)),n};S.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?Le(i):(he(e,0,Ve),t===void 0?t=o.rounding:he(t,0,8),r=k(new o(i),e+j(i)+1,t),n=Le(r.abs(),!1,e+j(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};S.toInteger=S.toint=function(){var e=this,t=e.constructor;return k(new t(e),j(e)+1,t.rounding)};S.toNumber=function(){return+this};S.toPower=S.pow=function(e){var t,n,r,i,o,s,c=this,u=c.constructor,a=12,f=+(e=new u(e));if(!e.s)return new u(Q);if(c=new u(c),!c.s){if(e.s<1)throw Error(ie+"Infinity");return c}if(c.eq(Q))return c;if(r=u.precision,e.eq(Q))return k(c,r);if(t=e.e,n=e.d.length-1,s=t>=n,o=c.s,s){if((n=f<0?-f:f)<=Po){for(i=new u(Q),t=Math.ceil(r/$+4),z=!1;n%2&&(i=i.times(c),li(i.d,t)),n=Xe(n/2),n!==0;)c=c.times(c),li(c.d,t);return z=!0,e.s<0?new u(Q).div(i):k(i,r)}}else if(o<0)throw Error(ie+"NaN");return o=o<0&&e.d[Math.max(t,n)]&1?-1:1,c.s=1,z=!1,i=e.times(it(c,r+a)),z=!0,i=xo(i),i.s=o,i};S.toPrecision=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?(n=j(i),r=Le(i,n<=o.toExpNeg||n>=o.toExpPos)):(he(e,1,Ve),t===void 0?t=o.rounding:he(t,0,8),i=k(new o(i),e,t),n=j(i),r=Le(i,e<=n||n<=o.toExpNeg,e)),r};S.toSignificantDigits=S.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(he(e,1,Ve),t===void 0?t=r.rounding:he(t,0,8)),k(new r(n),e,t)};S.toString=S.valueOf=S.val=S.toJSON=S[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=j(e),n=e.constructor;return Le(e,t<=n.toExpNeg||t>=n.toExpPos)};function Oo(e,t){var n,r,i,o,s,c,u,a,f=e.constructor,l=f.precision;if(!e.s||!t.s)return t.s||(t=new f(e)),z?k(t,l):t;if(u=e.d,a=t.d,s=e.e,i=t.e,u=u.slice(),o=s-i,o){for(o<0?(r=u,o=-o,c=a.length):(r=a,i=s,c=u.length),s=Math.ceil(l/$),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=u.length,o=a.length,c-o<0&&(o=c,r=a,a=u,u=r),n=0;o;)n=(u[--o]=u[o]+a[o]+n)/X|0,u[o]%=X;for(n&&(u.unshift(n),++i),c=u.length;u[--c]==0;)u.pop();return t.d=u,t.e=i,z?k(t,l):t}function he(e,t,n){if(e!==~~e||en)throw Error(Ne+e)}function de(e){var t,n,r,i=e.length-1,o="",s=e[0];if(i>0){for(o+=s,t=1;ts?1:-1;else for(c=u=0;ci[c]?1:-1;break}return u}function n(r,i,o){for(var s=0;o--;)r[o]-=s,s=r[o]1;)r.shift()}return function(r,i,o,s){var c,u,a,f,l,m,h,y,d,g,_,E,b,w,v,x,O,C,R=r.constructor,B=r.s==i.s?1:-1,F=r.d,I=i.d;if(!r.s)return new R(r);if(!i.s)throw Error(ie+"Division by zero");for(u=r.e-i.e,O=I.length,v=F.length,h=new R(B),y=h.d=[],a=0;I[a]==(F[a]||0);)++a;if(I[a]>(F[a]||0)&&--u,o==null?E=o=R.precision:s?E=o+(j(r)-j(i))+1:E=o,E<0)return new R(0);if(E=E/$+2|0,a=0,O==1)for(f=0,I=I[0],E++;(a1&&(I=e(I,f),F=e(F,f),O=I.length,v=F.length),w=O,d=F.slice(0,O),g=d.length;g=X/2&&++x;do f=0,c=t(I,d,O,g),c<0?(_=d[0],O!=g&&(_=_*X+(d[1]||0)),f=_/x|0,f>1?(f>=X&&(f=X-1),l=e(I,f),m=l.length,g=d.length,c=t(l,d,m,g),c==1&&(f--,n(l,O16)throw Error(mr+j(e));if(!e.s)return new f(Q);for(z=!1,c=l,s=new f(.03125);e.abs().gte(.1);)e=e.times(s),a+=5;for(r=Math.log(Pe(2,a))/Math.LN10*2+5|0,c+=r,n=i=o=new f(Q),f.precision=c;;){if(i=k(i.times(e),c),n=n.times(++u),s=o.plus(ye(i,n,c)),de(s.d).slice(0,c)===de(o.d).slice(0,c)){for(;a--;)o=k(o.times(o),c);return f.precision=l,t==null?(z=!0,k(o,l)):o}o=s}}function j(e){for(var t=e.e*$,n=e.d[0];n>=10;n/=10)t++;return t}function Pn(e,t,n){if(t>e.LN10.sd())throw z=!0,n&&(e.precision=n),Error(ie+"LN10 precision limit exceeded");return k(new e(e.LN10),t)}function ve(e){for(var t="";e--;)t+="0";return t}function it(e,t){var n,r,i,o,s,c,u,a,f,l=1,m=10,h=e,y=h.d,d=h.constructor,g=d.precision;if(h.s<1)throw Error(ie+(h.s?"NaN":"-Infinity"));if(h.eq(Q))return new d(0);if(t==null?(z=!1,a=g):a=t,h.eq(10))return t==null&&(z=!0),Pn(d,a);if(a+=m,d.precision=a,n=de(y),r=n.charAt(0),o=j(h),Math.abs(o)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=de(h.d),r=n.charAt(0),l++;o=j(h),r>1?(h=new d("0."+n),o++):h=new d(r+"."+n.slice(1))}else return u=Pn(d,a+2,g).times(o+""),h=it(new d(r+"."+n.slice(1)),a-m).plus(u),d.precision=g,t==null?(z=!0,k(h,g)):h;for(c=s=h=ye(h.minus(Q),h.plus(Q),a),f=k(h.times(h),a),i=3;;){if(s=k(s.times(f),a),u=c.plus(ye(s,new d(i),a)),de(u.d).slice(0,a)===de(c.d).slice(0,a))return c=c.times(2),o!==0&&(c=c.plus(Pn(d,a+2,g).times(o+""))),c=ye(c,new d(l),a),d.precision=g,t==null?(z=!0,k(c,g)):c;c=u,i+=2}}function ai(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=Xe(n/$),e.d=[],r=(n+1)%$,n<0&&(r+=$),rFt||e.e<-Ft))throw Error(mr+n)}else e.s=0,e.e=0,e.d=[0];return e}function k(e,t,n){var r,i,o,s,c,u,a,f,l=e.d;for(s=1,o=l[0];o>=10;o/=10)s++;if(r=t-s,r<0)r+=$,i=t,a=l[f=0];else{if(f=Math.ceil((r+1)/$),o=l.length,f>=o)return e;for(a=o=l[f],s=1;o>=10;o/=10)s++;r%=$,i=r-$+s}if(n!==void 0&&(o=Pe(10,s-i-1),c=a/o%10|0,u=t<0||l[f+1]!==void 0||a%o,u=n<4?(c||u)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||u||n==6&&(r>0?i>0?a/Pe(10,s-i):0:l[f-1])%10&1||n==(e.s<0?8:7))),t<1||!l[0])return u?(o=j(e),l.length=1,t=t-o-1,l[0]=Pe(10,($-t%$)%$),e.e=Xe(-t/$)||0):(l.length=1,l[0]=e.e=e.s=0),e;if(r==0?(l.length=f,o=1,f--):(l.length=f+1,o=Pe(10,$-r),l[f]=i>0?(a/Pe(10,s-i)%Pe(10,i)|0)*o:0),u)for(;;)if(f==0){(l[0]+=o)==X&&(l[0]=1,++e.e);break}else{if(l[f]+=o,l[f]!=X)break;l[f--]=0,o=1}for(r=l.length;l[--r]===0;)l.pop();if(z&&(e.e>Ft||e.e<-Ft))throw Error(mr+j(e));return e}function Ro(e,t){var n,r,i,o,s,c,u,a,f,l,m=e.constructor,h=m.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new m(e),z?k(t,h):t;if(u=e.d,l=t.d,r=t.e,a=e.e,u=u.slice(),s=a-r,s){for(f=s<0,f?(n=u,s=-s,c=l.length):(n=l,r=a,c=u.length),i=Math.max(Math.ceil(h/$),c)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=u.length,c=l.length,f=i0;--i)u[c++]=0;for(i=l.length;i>s;){if(u[--i]0?o=o.charAt(0)+"."+o.slice(1)+ve(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+ve(-i-1)+o,n&&(r=n-s)>0&&(o+=ve(r))):i>=s?(o+=ve(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+ve(r))):((r=i+1)0&&(i+1===s&&(o+="."),o+=ve(r))),e.s<0?"-"+o:o}function li(e,t){if(e.length>t)return e.length=t,!0}function Ao(e){var t,n,r;function i(o){var s=this;if(!(s instanceof i))return new i(o);if(s.constructor=i,o instanceof i){s.s=o.s,s.e=o.e,s.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(Ne+o);if(o>0)s.s=1;else if(o<0)o=-o,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(o===~~o&&o<1e7){s.e=0,s.d=[o];return}return ai(s,o.toString())}else if(typeof o!="string")throw Error(Ne+o);if(o.charCodeAt(0)===45?(o=o.slice(1),s.s=-1):s.s=1,Ju.test(o))ai(s,o);else throw Error(Ne+o)}if(i.prototype=S,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=Ao,i.config=i.set=Qu,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(Ne+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Ne+n+": "+r);return this}var gr=Ao(Zu);Q=new gr(1);const Ua=gr;class Ba extends Map{constructor(t,n=nf){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(di(this,t))}has(t){return super.has(di(this,t))}set(t,n){return super.set(ef(this,t),n)}delete(t){return super.delete(tf(this,t))}}function di({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function ef({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function tf({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function nf(e){return e!==null&&typeof e=="object"?e.valueOf():e}var On={exports:{}},hi;function rf(){return hi||(hi=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(u,a,f){this.fn=u,this.context=a,this.once=f||!1}function o(u,a,f,l,m){if(typeof f!="function")throw new TypeError("The listener must be a function");var h=new i(f,l||u,m),y=n?n+a:a;return u._events[y]?u._events[y].fn?u._events[y]=[u._events[y],h]:u._events[y].push(h):(u._events[y]=h,u._eventsCount++),u}function s(u,a){--u._eventsCount===0?u._events=new r:delete u._events[a]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var a=[],f,l;if(this._eventsCount===0)return a;for(l in f=this._events)t.call(f,l)&&a.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(f)):a},c.prototype.listeners=function(a){var f=n?n+a:a,l=this._events[f];if(!l)return[];if(l.fn)return[l.fn];for(var m=0,h=l.length,y=new Array(h);m`active-slide-${e}`,Io="flex_center",pf="no_scroll",Lo="no_scroll_padding",wr="slide",yf="slide_wrapper",Oe="prev",xe="next",mi="swipe",je="close",To="onPointerDown",Do="onPointerMove",ko="onPointerUp",$o="onPointerLeave",Fo="onPointerCancel",Wo="onKeyDown",mf="onKeyUp",zo="onWheel",gf="Escape",_f="ArrowLeft",wf="ArrowRight",vf="button",Qn="icon",Uo="contain",gi="cover",Ef="Unknown action type",Bo="yarl__";function me(...e){return e.filter(Boolean).join(" ")}function T(e){return`${Bo}${e}`}function J(e){return`--${Bo}${e}`}function ct(e,t){return`${e}${t?`_${t}`:""}`}function vr(e){return t=>ct(e,t)}function qe(e,t){var n;return(n=e==null?void 0:e[t])!==null&&n!==void 0?n:t}function bf(e,t,n){return qe(e,"{index} of {total}").replace(/\{index}/g,`${Er(n,t.length)+1}`).replace(/\{total}/g,`${t.length}`)}function jo(...e){return()=>{e.forEach(t=>{t()})}}function _e(e,t,n){return()=>{const r=p.useContext(n);if(!r)throw new Error(`${e} must be used within a ${t}.Provider`);return r}}function qo(){return typeof window<"u"}function Sf(e,t=0){const n=10**t;return Math.round((e+Number.EPSILON)*n)/n}function Vo(e){return e.type===void 0||e.type==="image"}function Pf(e,t){return e.imageFit===gi||e.imageFit!==Uo&&t===gi}function Jt(e){return typeof e=="string"?Number.parseInt(e,10):e}function Wt(e){if(typeof e=="number")return{pixel:e};if(typeof e=="string"){const t=Jt(e);return e.endsWith("%")?{percent:t}:{pixel:t}}return{pixel:0}}function Of(e,t){const n=Wt(t),r=n.percent!==void 0?e.width/100*n.percent:n.pixel;return{width:Math.max(e.width-2*r,0),height:Math.max(e.height-2*r,0)}}function Er(e,t){return t>0?(e%t+t)%t:0}function Xo(e){return e.length>0}function Ho(e,t){return e[Er(t,e.length)]}function er(e,t){return Xo(e)?Ho(e,t):void 0}function xf(e){return Vo(e)?e.src:void 0}function Rf(e,t,n=0){return Math.min(e.preload,Math.max(e.finite?t.length-1:Math.floor(t.length/2),n))}const Af=Number(p.version.split(".")[0])>=19;function Nf(e){return{inert:Af?e:e?"":void 0}}function Cf(e){e.scrollTop}const tr={open:!1,close:()=>{},index:0,slides:[],render:{},plugins:[],toolbar:{buttons:[je]},labels:{},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},carousel:{finite:!1,preload:2,padding:"16px",spacing:"30%",imageFit:Uo,imageProps:{}},controller:{ref:null,focus:!0,aria:!1,touchAction:"none",closeOnPullUp:!1,closeOnPullDown:!1,closeOnBackdropClick:!1,closeOnEscape:!0,preventDefaultWheelX:!0,preventDefaultWheelY:!1,disableSwipeNavigation:!1},portal:{},noScroll:{disabled:!1},on:{},styles:{},className:""};function Te(e,t){return{name:e,component:t}}function V(e,t){return{module:e,children:t}}function Yo(e,t,n){return e.module.name===t?n(e):e.children?[V(e.module,e.children.flatMap(r=>{var i;return(i=Yo(r,t,n))!==null&&i!==void 0?i:[]}))]:[e]}function $e(e,t,n){return e.flatMap(r=>{var i;return(i=Yo(r,t,n))!==null&&i!==void 0?i:[]})}function Mf(e,t=[],n=[]){let r=e;const i=h=>{const y=[...r];for(;y.length>0;){const d=y.pop();if((d==null?void 0:d.module.name)===h)return!0;d!=null&&d.children&&y.push(...d.children)}return!1},o=(h,y)=>{if(h===""){r=[V(y,r)];return}r=$e(r,h,d=>[V(y,[d])])},s=(h,y)=>{r=$e(r,h,d=>[V(d.module,[V(y,d.children)])])},c=(h,y,d)=>{r=$e(r,h,g=>{var _;return[V(g.module,[...d?[V(y)]:[],...(_=g.children)!==null&&_!==void 0?_:[],...d?[]:[V(y)]])]})},u=(h,y,d)=>{r=$e(r,h,g=>[...d?[V(y)]:[],g,...d?[]:[V(y)]])},a=h=>{s(Co,h)},f=(h,y)=>{r=$e(r,h,d=>[V(y,d.children)])},l=h=>{r=$e(r,h,y=>y.children)},m=h=>{n.push(h)};return t.forEach(h=>{h({contains:i,addParent:o,append:s,addChild:c,addSibling:u,addModule:a,replace:f,remove:l,augment:m})}),{config:r,augmentation:h=>n.reduce((y,d)=>d(y),h)}}const Ko=p.createContext(null),Go=_e("useA11yContext","A11yContext",Ko);function If({children:e}){const[t,n]=p.useState(!1),[r,i]=p.useState(!1),o=p.useMemo(()=>({focusWithin:t,trackFocusWithin:(c,u)=>{const a=f=>l=>{var m;l.currentTarget.contains(l.relatedTarget)||n(f),(m=f?c:u)===null||m===void 0||m(l)};return{onFocus:a(!0),onBlur:a(!1)}},autoPlaying:r,setAutoPlaying:i}),[t,r]);return p.createElement(Ko.Provider,{value:o},e)}const Zo=p.createContext(null),br=_e("useDocument","DocumentContext",Zo);function Lf({nodeRef:e,children:t}){const n=p.useMemo(()=>{const r=o=>{var s;return((s=o||e.current)===null||s===void 0?void 0:s.ownerDocument)||document};return{getOwnerDocument:r,getOwnerWindow:o=>{var s;return((s=r(o))===null||s===void 0?void 0:s.defaultView)||window}}},[e]);return p.createElement(Zo.Provider,{value:n},t)}const Jo=p.createContext(null),Qt=_e("useEvents","EventsContext",Jo);function Tf({children:e}){const[t]=p.useState({});p.useEffect(()=>()=>{Object.keys(t).forEach(r=>delete t[r])},[t]);const n=p.useMemo(()=>{const r=(s,c)=>{var u;(u=t[s])===null||u===void 0||u.splice(0,t[s].length,...t[s].filter(a=>a!==c))};return{publish:(...[s,c])=>{var u;(u=t[s])===null||u===void 0||u.forEach(a=>a(c))},subscribe:(s,c)=>(t[s]||(t[s]=[]),t[s].push(c),()=>r(s,c)),unsubscribe:r}},[t]);return p.createElement(Jo.Provider,{value:n},e)}const Qo=p.createContext(null),ut=_e("useLightboxProps","LightboxPropsContext",Qo);function Df({children:e,...t}){return p.createElement(Qo.Provider,{value:t},e)}const es=p.createContext(null),en=_e("useLightboxState","LightboxStateContext",es),ts=p.createContext(null),kf=_e("useLightboxDispatch","LightboxDispatchContext",ts);function $f(e,t){switch(t.type){case"swipe":{const{slides:n}=e,r=(t==null?void 0:t.increment)||0,i=e.globalIndex+r,o=Er(i,n.length),s=er(n,o),c=r||t.duration!==void 0?{increment:r,duration:t.duration,easing:t.easing}:void 0;return{slides:n,currentIndex:o,globalIndex:i,currentSlide:s,animation:c}}case"update":return t.slides!==e.slides||t.index!==e.currentIndex?{slides:t.slides,currentIndex:t.index,globalIndex:t.index,currentSlide:er(t.slides,t.index)}:e;default:throw new Error(Ef)}}function Ff({slides:e,index:t,children:n}){const[r,i]=p.useReducer($f,{slides:e,currentIndex:t,globalIndex:t,currentSlide:er(e,t)}),[o,s]=p.useState(e),[c,u]=p.useState(t);(e!==o||t!==c)&&(s(e),u(t),i({type:"update",slides:e,index:t}));const a=p.useMemo(()=>({...r,state:r,dispatch:i}),[r,i]);return p.createElement(ts.Provider,{value:i},p.createElement(es.Provider,{value:a},n))}const ns=p.createContext(null),Wf=_e("useRTLContext","RTLContext",ns);function zf({isRTL:e,children:t}){const n=p.useMemo(()=>({isRTL:e}),[e]);return p.createElement(ns.Provider,{value:n},t)}const rs=p.createContext(null),tn=_e("useTimeouts","TimeoutsContext",rs);function Uf({children:e}){const[t]=p.useState([]);p.useEffect(()=>()=>{t.forEach(r=>window.clearTimeout(r)),t.splice(0,t.length)},[t]);const n=p.useMemo(()=>{const r=s=>{t.splice(0,t.length,...t.filter(c=>c!==s))};return{setTimeout:(s,c)=>{const u=window.setTimeout(()=>{r(u),s()},c);return t.push(u),u},clearTimeout:s=>{s!==void 0&&(r(s),window.clearTimeout(s))}}},[t]);return p.createElement(rs.Provider,{value:n},e)}const is=p.forwardRef(function({label:t,className:n,icon:r,renderIcon:i,onClick:o,style:s,...c},u){const{styles:a,labels:f}=ut(),l=qe(f,t);return p.createElement("button",{ref:u,type:"button",title:l,"aria-label":l,className:me(T(vf),n),onClick:o,style:{...s,...a.button},...c},i?i():p.createElement(r,{className:T(Qn),style:a.icon}))});function Bf(e,t){const n=r=>p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",...r},t);return n.displayName=e,n}function ft(e,t){return Bf(e,p.createElement("g",{fill:"currentColor"},p.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t))}const jf=ft("Close",p.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),qf=ft("Previous",p.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})),Vf=ft("Next",p.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),Xf=ft("Loading",p.createElement(p.Fragment,null,Array.from({length:8}).map((e,t,n)=>p.createElement("line",{key:t,x1:"12",y1:"6.5",x2:"12",y2:"1.8",strokeLinecap:"round",strokeWidth:"2.6",stroke:"currentColor",strokeOpacity:1/n.length*(t+1),transform:`rotate(${360/n.length*t}, 12, 12)`})))),Hf=ft("Error",p.createElement("path",{d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})),nn=qo()?p.useLayoutEffect:p.useEffect;function os(){const[e,t]=p.useState(!1);return p.useEffect(()=>{var n,r;const i=(n=window.matchMedia)===null||n===void 0?void 0:n.call(window,"(prefers-reduced-motion: reduce)");t(i==null?void 0:i.matches);const o=s=>t(s.matches);return(r=i==null?void 0:i.addEventListener)===null||r===void 0||r.call(i,"change",o),()=>{var s;return(s=i==null?void 0:i.removeEventListener)===null||s===void 0?void 0:s.call(i,"change",o)}},[]),e}function Yf(e){let t=0,n=0,r=0;const o=window.getComputedStyle(e).transform.match(/matrix.*\((.+)\)/);if(o){const s=o[1].split(",").map(Jt);s.length===6?(t=s[4],n=s[5]):s.length===16&&(t=s[12],n=s[13],r=s[14])}return{x:t,y:n,z:r}}function _i(e,t){const n=p.useRef(void 0),r=p.useRef(void 0),i=os();return nn(()=>{var o,s,c;if(e.current&&n.current!==void 0&&!i){const{keyframes:u,duration:a,easing:f,onfinish:l}=t(n.current,e.current.getBoundingClientRect(),Yf(e.current))||{};if(u&&a){(o=r.current)===null||o===void 0||o.cancel(),r.current=void 0;try{r.current=(c=(s=e.current).animate)===null||c===void 0?void 0:c.call(s,u,{duration:a,easing:f})}catch(m){console.error(m)}r.current&&(r.current.onfinish=()=>{r.current=void 0,l==null||l()})}}n.current=void 0}),{prepareAnimation:o=>{n.current=o},isAnimationPlaying:()=>{var o;return((o=r.current)===null||o===void 0?void 0:o.playState)==="running"}}}function ss(){const e=p.useRef(null),t=p.useRef(void 0),[n,r]=p.useState();return{setContainerRef:p.useCallback(o=>{e.current=o,t.current&&(t.current.disconnect(),t.current=void 0);const s=()=>{if(o){const c=window.getComputedStyle(o),u=a=>parseFloat(a)||0;r({width:Math.round(o.clientWidth-u(c.paddingLeft)-u(c.paddingRight)),height:Math.round(o.clientHeight-u(c.paddingTop)-u(c.paddingBottom))})}else r(void 0)};s(),o&&typeof ResizeObserver<"u"&&(t.current=new ResizeObserver(s),t.current.observe(o))},[]),containerRef:e,containerRect:n}}function Pt(){const e=p.useRef(void 0),{setTimeout:t,clearTimeout:n}=tn();return p.useCallback((r,i)=>{n(e.current),e.current=t(r,i>0?i:0)},[t,n])}function U(e){const t=p.useRef(e);return nn(()=>{t.current=e}),p.useCallback((...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function wi(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function nr(e,t){return p.useMemo(()=>e==null&&t==null?null:n=>{wi(e,n),wi(t,n)},[e,t])}function Kf(e,t=!1){const n=p.useRef(!1);nn(()=>{t&&n.current&&(n.current=!1,e())},[t,e]);const r=p.useCallback(()=>{n.current=!0},[]),i=p.useCallback(()=>{n.current=!1},[]);return{onFocus:r,onBlur:i}}function Sr(){return Wf().isRTL}function Gf(){const[e]=p.useState({}),t=p.useCallback((i,o)=>{var s;(s=e[i])===null||s===void 0||s.forEach(c=>{o.isPropagationStopped()||c(o)})},[e]),n=p.useMemo(()=>({onPointerDown:i=>t(To,i),onPointerMove:i=>t(Do,i),onPointerUp:i=>t(ko,i),onPointerLeave:i=>t($o,i),onPointerCancel:i=>t(Fo,i),onKeyDown:i=>t(Wo,i),onKeyUp:i=>t(mf,i),onWheel:i=>t(zo,i)}),[t]),r=p.useCallback((i,o)=>(e[i]||(e[i]=[]),e[i].unshift(o),()=>{const s=e[i];s&&s.splice(0,s.length,...s.filter(c=>c!==o))}),[e]);return{registerSensors:n,subscribeSensors:r}}function vi(e,t){const n=p.useRef(0),r=Pt(),i=U((...o)=>{n.current=Date.now(),e(...o)});return p.useCallback((...o)=>{r(()=>{i(...o)},t-(Date.now()-n.current))},[t,i,r])}const Cn=vr("slide"),Mn=vr("slide_image");function Zf({slide:e,offset:t,render:n,rect:r,imageFit:i,imageProps:o,onClick:s,onLoad:c,onError:u,style:a}){var f,l,m,h,y,d,g,_;const[E,b]=p.useState(Rn),{publish:w}=Qt(),{setTimeout:v}=tn(),x=p.useRef(null);p.useEffect(()=>{t===0&&w(hf(E))},[t,E,w]);const O=U(L=>{("decode"in L?L.decode():Promise.resolve()).catch(()=>{}).then(()=>{L.parentNode&&(b(Nn),v(()=>{c==null||c(L)},0))})}),C=p.useCallback(L=>{x.current=L,L!=null&&L.complete&&O(L)},[O]),R=p.useCallback(L=>{O(L.currentTarget)},[O]),B=U(()=>{b(An),u==null||u()}),F=Pf(e,i),I=(L,De)=>Number.isFinite(L)?L:De,A=I(Math.max(...((l=(f=e.srcSet)===null||f===void 0?void 0:f.map(L=>L.width))!==null&&l!==void 0?l:[]).concat(e.width?[e.width]:[]).filter(Boolean)),((m=x.current)===null||m===void 0?void 0:m.naturalWidth)||0),M=I(Math.max(...((y=(h=e.srcSet)===null||h===void 0?void 0:h.map(L=>L.height))!==null&&y!==void 0?y:[]).concat(e.height?[e.height]:[]).filter(Boolean)),((d=x.current)===null||d===void 0?void 0:d.naturalHeight)||0),N=A&&M?{maxWidth:`min(${A}px, 100%)`,maxHeight:`min(${M}px, 100%)`}:{maxWidth:"100%",maxHeight:"100%"},q=(g=e.srcSet)===null||g===void 0?void 0:g.slice().sort((L,De)=>L.width-De.width).map(L=>`${L.src} ${L.width}w`).join(", "),H=()=>r&&!F&&e.width&&e.height?r.height/e.height*e.width:Number.MAX_VALUE,Ee=q&&r&&qo()?`${Math.round(Math.min(H(),r.width))}px`:void 0,{style:He,className:rn,...we}=(typeof o=="function"?o(e):o)||{};return p.createElement(p.Fragment,null,p.createElement("img",{ref:C,onLoad:R,onError:B,onClick:s,draggable:!1,className:me(T(Mn()),F&&T(Mn("cover")),E!==Nn&&T(Mn("loading")),rn),style:{...N,...a,...He},...we,alt:(_=e.alt)!==null&&_!==void 0?_:"",sizes:Ee,srcSet:q,src:e.src}),E!==Nn&&p.createElement("div",{className:T(Cn(df))},E===Rn&&(n!=null&&n.iconLoading?n.iconLoading():p.createElement(Xf,{className:me(T(Qn),T(Cn(Rn)))})),E===An&&(n!=null&&n.iconError?n.iconError():p.createElement(Hf,{className:me(T(Qn),T(Cn(An)))}))))}const Jf=p.forwardRef(function({className:t,children:n,onFocus:r,onBlur:i,...o},s){const c=p.useRef(null),[u,a]=p.useState(!1),{trackFocusWithin:f}=Go(),l=U(()=>{if(c.current){const m=window.getComputedStyle(c.current).direction==="rtl";m!==u&&a(m)}});return p.useEffect(l),p.createElement(Lf,{nodeRef:c},p.createElement(zf,{isRTL:u},p.createElement("div",{ref:nr(s,c),className:me(T("root"),t),...f(r,i),...o},n)))});var K;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL",e[e.ANIMATION=3]="ANIMATION"})(K||(K={}));function Qf(e,t,n,r,i){p.useEffect(()=>jo(e(To,t),e(Do,n),e(ko,r),e($o,r),e(Fo,r)),[e,t,n,r,i])}var oe;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL"})(oe||(oe={}));const In=30;function ea({disableSwipeNavigation:e,closeOnBackdropClick:t},n,r,i,o,s,c,u,a,f,l,m,h,y,d,g){const _=p.useRef(0),E=p.useRef([]),b=p.useRef(void 0),w=p.useRef(0),v=p.useRef(oe.NONE),x=p.useCallback(A=>{b.current===A.pointerId&&(b.current=void 0,v.current=oe.NONE);const M=E.current;M.splice(0,M.length,...M.filter(N=>N.pointerId!==A.pointerId))},[]),O=p.useCallback(A=>{x(A),A.persist(),E.current.push(A)},[x]),C=p.useCallback(A=>E.current.find(({pointerId:M})=>A.pointerId===M),[]),R=U(A=>{O(A)}),B=(A,M)=>l&&A>M||f&&A<-M,F=U(A=>{const M=C(A);if(M)if(b.current===A.pointerId){const N=Date.now()-w.current,q=_.current;v.current===oe.SWIPE?Math.abs(q)>.3*i||Math.abs(q)>5&&N{const M=C(A);if(M){const N=b.current===A.pointerId;if(A.buttons===0){N&&_.current!==0?F(A):x(M);return}const q=A.clientX-M.clientX,H=A.clientY-M.clientY;if(b.current===void 0){const Ee=He=>{O(A),b.current=A.pointerId,w.current=Date.now(),v.current=He};Math.abs(q)>Math.abs(H)&&Math.abs(q)>In&&r(q)?e||(Ee(oe.SWIPE),s()):Math.abs(H)>Math.abs(q)&&B(H,In)&&(Ee(oe.PULL),m())}else N&&(v.current===oe.SWIPE?(_.current=q,c(q)):v.current===oe.PULL&&(_.current=H,h(H)))}});Qf(n,R,I,F)}function ta({preventDefaultWheelX:e,preventDefaultWheelY:t}){const n=p.useRef(null),r=U(i=>{const o=Math.abs(i.deltaX)>Math.abs(i.deltaY);(o&&e||!o&&t||i.ctrlKey)&&i.preventDefault()});return p.useCallback(i=>{var o;i?i.addEventListener("wheel",r,{passive:!1}):(o=n.current)===null||o===void 0||o.removeEventListener("wheel",r),n.current=i},[r])}function na(e,t,n,r,i,o,s,c,u){const a=p.useRef(0),f=p.useRef(0),l=p.useRef(void 0),m=p.useRef(void 0),h=p.useRef(0),y=p.useRef(void 0),d=p.useRef(0),{setTimeout:g,clearTimeout:_}=tn(),E=p.useCallback(()=>{l.current&&(_(l.current),l.current=void 0)},[_]),b=p.useCallback(()=>{m.current&&(_(m.current),m.current=void 0)},[_]),w=U(()=>{e!==K.SWIPE&&(a.current=0,d.current=0,E(),b())});p.useEffect(w,[e,w]);const v=U(O=>{m.current=void 0,a.current===O&&u(a.current)}),x=U(O=>{if(O.ctrlKey||Math.abs(O.deltaY)>Math.abs(O.deltaX))return;const C=R=>{h.current=R,_(y.current),y.current=R>0?g(()=>{h.current=0,y.current=void 0},300):void 0};if(e===K.NONE){if(Math.abs(O.deltaX)<=1.2*Math.abs(h.current)){C(O.deltaX);return}if(!n(-O.deltaX))return;if(f.current+=O.deltaX,E(),Math.abs(f.current)>30)f.current=0,C(0),d.current=Date.now(),o();else{const R=f.current;l.current=g(()=>{l.current=void 0,R===f.current&&(f.current=0)},i)}}else if(e===K.SWIPE){let R=a.current-O.deltaX;if(R=Math.min(Math.abs(R),r)*Math.sign(R),a.current=R,s(R),b(),Math.abs(R)>.2*r){C(O.deltaX),c(R,Date.now()-d.current);return}m.current=g(()=>v(R),2*i)}else C(O.deltaX)});p.useEffect(()=>t(zo,x),[t,x])}const Ei=vr("container"),cs=p.createContext(null),at=_e("useController","ControllerContext",cs);function ra({children:e,...t}){var n;const{carousel:r,animation:i,controller:o,on:s,styles:c,render:u}=t,{closeOnPullUp:a,closeOnPullDown:f,preventDefaultWheelX:l,preventDefaultWheelY:m}=o,[h,y]=p.useState(),d=en(),g=kf(),[_,E]=p.useState(K.NONE),b=p.useRef(0),w=p.useRef(0),v=p.useRef(1),{registerSensors:x,subscribeSensors:O}=Gf(),{subscribe:C,publish:R}=Qt(),B=Pt(),F=Pt(),I=Pt(),{containerRef:A,setContainerRef:M,containerRect:N}=ss(),q=nr(ta({preventDefaultWheelX:l,preventDefaultWheelY:m}),M),H=p.useRef(null),Ee=nr(H,void 0),{getOwnerDocument:He}=br(),rn=Sr(),we=P=>(rn?-1:1)*(typeof P=="number"?P:1),L=U(()=>{var P;return(P=A.current)===null||P===void 0?void 0:P.focus()}),De=U(()=>t),Pr=U(()=>d),lt=p.useCallback(P=>R(Oe,P),[R]),dt=p.useCallback(P=>R(xe,P),[R]),ke=p.useCallback(()=>R(je),[R]),on=P=>!(r.finite&&(we(P)>0&&d.currentIndex===0||we(P)<0&&d.currentIndex===d.slides.length-1)),Or=P=>{var W;b.current=P,(W=A.current)===null||W===void 0||W.style.setProperty(J("swipe_offset"),`${Math.round(P)}px`)},sn=P=>{var W,G;w.current=P,v.current=(()=>{const Ke=f&&P>0?P:a&&P<0?-P:0;return Math.min(Math.max(Sf(1-Ke/60*(1-.5),2),.5),1)})(),(W=A.current)===null||W===void 0||W.style.setProperty(J("pull_offset"),`${Math.round(P)}px`),(G=A.current)===null||G===void 0||G.style.setProperty(J("pull_opacity"),`${v.current}`)},{prepareAnimation:as}=_i(H,(P,W,G)=>{if(H.current&&N)return{keyframes:[{transform:`translate(0, ${P.rect.y-W.y+G.y}px)`,opacity:P.opacity},{transform:"translate(0, 0)",opacity:1}],duration:P.duration,easing:i.easing.fade}}),xr=(P,W)=>{if(a||f){sn(P);let G=0;H.current&&(G=i.fade*(W?2:1),as({rect:H.current.getBoundingClientRect(),opacity:v.current,duration:G})),I(()=>{sn(0),E(K.NONE)},G),E(K.ANIMATION),W||ke()}},{prepareAnimation:ls,isAnimationPlaying:ds}=_i(H,(P,W,G)=>{var ae;if(H.current&&N&&(!((ae=d.animation)===null||ae===void 0)&&ae.duration)){const re=Wt(r.spacing),Ke=(re.percent?re.percent*N.width/100:re.pixel)||0;return{keyframes:[{transform:`translate(${we(d.globalIndex-P.index)*(N.width+Ke)+P.rect.x-W.x+G.x}px, 0)`},{transform:"translate(0, 0)"}],duration:d.animation.duration,easing:d.animation.easing}}}),Ye=U(P=>{var W,G;const ae=P.offset||0,re=ae?i.swipe:(W=i.navigation)!==null&&W!==void 0?W:i.swipe,Ke=!ae&&!ds()?i.easing.navigation:i.easing.swipe;let{direction:ht}=P;const pt=(G=P.count)!==null&&G!==void 0?G:1;let cn=K.ANIMATION,le=re*pt;if(!ht){const Ge=N==null?void 0:N.width,Cr=P.duration||0,fn=Ge?re/Ge*Math.abs(ae):re;pt!==0?(Cr0?Oe:xe):le=re/2}let un=0;ht===Oe?on(we(1))?un=-pt:(cn=K.NONE,le=re):ht===xe&&(on(we(-1))?un=pt:(cn=K.NONE,le=re)),le=Math.round(le),F(()=>{Or(0),E(K.NONE)},le),H.current&&ls({rect:H.current.getBoundingClientRect(),index:d.globalIndex}),E(cn),R(mi,{type:"swipe",increment:un,duration:le,easing:Ke})});p.useEffect(()=>{var P,W;!((P=d.animation)===null||P===void 0)&&P.increment&&(!((W=d.animation)===null||W===void 0)&&W.duration)&&B(()=>g({type:"swipe",increment:0}),d.animation.duration)},[d.animation,g,B]);const Rr=[O,on,(N==null?void 0:N.width)||0,i.swipe,()=>E(K.SWIPE),P=>Or(P),(P,W)=>Ye({offset:P,duration:W,count:1}),P=>Ye({offset:P,count:0})],hs=[()=>{f&&E(K.PULL)},P=>sn(P),P=>xr(P),P=>xr(P,!0)];ea(o,...Rr,a,f,...hs,ke),na(_,...Rr);const Ar=U(()=>{o.focus&&He().querySelector(`.${T(_r)} .${T(Ei())}`)&&L()});p.useEffect(Ar,[Ar]);const Nr=U(()=>{var P;(P=s.view)===null||P===void 0||P.call(s,{index:d.currentIndex})});p.useEffect(Nr,[d.globalIndex,Nr]),p.useEffect(()=>jo(C(Oe,P=>Ye({direction:Oe,...P})),C(xe,P=>Ye({direction:xe,...P})),C(mi,P=>g(P))),[C,Ye,g]);const ps=p.useMemo(()=>({prev:lt,next:dt,close:ke,focus:L,slideRect:N?Of(N,r.padding):{width:0,height:0},containerRect:N||{width:0,height:0},subscribeSensors:O,containerRef:A,setCarouselRef:Ee,toolbarWidth:h,setToolbarWidth:y}),[lt,dt,ke,L,O,N,A,Ee,h,y,r.padding]);return p.useImperativeHandle(o.ref,()=>({prev:lt,next:dt,close:ke,focus:L,getLightboxProps:De,getLightboxState:Pr}),[lt,dt,ke,L,De,Pr]),p.createElement("div",{ref:q,className:me(T(Ei()),T(Io)),style:{..._===K.SWIPE?{[J("swipe_offset")]:`${Math.round(b.current)}px`}:null,..._===K.PULL?{[J("pull_offset")]:`${Math.round(w.current)}px`,[J("pull_opacity")]:`${v.current}`}:null,...o.touchAction!=="none"?{[J("controller_touch_action")]:o.touchAction}:null,...c.container},tabIndex:-1,...x},N&&p.createElement(cs.Provider,{value:ps},e,(n=u.controls)===null||n===void 0?void 0:n.call(u)))}const ia=Te(Co,ra);function be(e){return ct(No,e)}function bi(e){return ct(wr,e)}function oa({slide:e,offset:t}){const n=p.useRef(null),{currentIndex:r,slides:i}=en(),{slideRect:o,focus:s}=at(),{render:c,carousel:{imageFit:u,imageProps:a},on:{click:f},styles:{slide:l},labels:m}=ut(),{getOwnerDocument:h}=br(),y=t!==0;p.useEffect(()=>{var g;y&&(!((g=n.current)===null||g===void 0)&&g.contains(h().activeElement))&&s()},[y,s,h]);const d=()=>{var g,_,E,b;let w=(g=c.slide)===null||g===void 0?void 0:g.call(c,{slide:e,offset:t,rect:o});return!w&&Vo(e)&&(w=p.createElement(Zf,{slide:e,offset:t,render:c,rect:o,imageFit:u,imageProps:a,onClick:y?void 0:()=>f==null?void 0:f({index:r})})),w?p.createElement(p.Fragment,null,(_=c.slideHeader)===null||_===void 0?void 0:_.call(c,{slide:e}),((E=c.slideContainer)!==null&&E!==void 0?E:(({children:v})=>v))({slide:e,children:w}),(b=c.slideFooter)===null||b===void 0?void 0:b.call(c,{slide:e})):null};return p.createElement("div",{ref:n,className:me(T(bi()),!y&&T(bi("current")),T(Io)),...Nf(y),style:l,role:"group","aria-roledescription":qe(m,"Slide"),"aria-label":bf(m,i,r+t)},d())}function sa(){const e=ut().styles.slide;return p.createElement("div",{className:T(wr),style:e})}function ca({carousel:e,labels:t}){const{slides:n,currentIndex:r,globalIndex:i}=en(),{setCarouselRef:o}=at(),{autoPlaying:s,focusWithin:c}=Go(),u=Wt(e.spacing),a=Wt(e.padding),f=Rf(e,n,1),l=[];if(Xo(n))for(let m=r-f;m<=r+f;m+=1){const h=Ho(n,m),y=i-r+m,d=e.finite&&(m<0||m>n.length-1);l.push(d?{key:y}:{key:[`${y}`,xf(h)].filter(Boolean).join("|"),offset:m-r,slide:h})}return p.createElement("div",{ref:o,className:me(T(be()),l.length>0&&T(be("with_slides"))),style:{[`${J(be("slides_count"))}`]:l.length,[`${J(be("spacing_px"))}`]:u.pixel||0,[`${J(be("spacing_percent"))}`]:u.percent||0,[`${J(be("padding_px"))}`]:a.pixel||0,[`${J(be("padding_percent"))}`]:a.percent||0},role:"region","aria-live":s&&!c?"off":"polite","aria-roledescription":qe(t,"Carousel"),"aria-label":qe(t,"Photo gallery")},l.map(({key:m,slide:h,offset:y})=>h?p.createElement(oa,{key:m,slide:h,offset:y}):p.createElement(sa,{key:m})))}const ua=Te(No,ca);function us(){const{carousel:e}=ut(),{slides:t,currentIndex:n}=en(),r=t.length===0||e.finite&&n===0,i=t.length===0||e.finite&&n===t.length-1;return{prevDisabled:r,nextDisabled:i}}function fa(e){var t;const n=Sr(),{publish:r}=Qt(),{animation:i,controller:o}=ut(),{prevDisabled:s,nextDisabled:c}=us(),u=((t=i.navigation)!==null&&t!==void 0?t:i.swipe)/2,a=vi(()=>r(Oe),u),f=vi(()=>r(xe),u),l=U(m=>{switch(m.key){case gf:if(!o.closeOnEscape)return;r(je);break;case _f:(n?c:s)||(n?f:a)();break;case wf:(n?s:c)||(n?a:f)();break;default:return}m.stopPropagation()});p.useEffect(()=>e(Wo,l),[e,l])}function Si({label:e,icon:t,renderIcon:n,action:r,onClick:i,disabled:o,style:s}){return p.createElement(is,{label:e,icon:t,renderIcon:n,className:T(`navigation_${r}`),disabled:o,onClick:i,style:s,...Kf(at().focus,o)})}function aa({render:{buttonPrev:e,buttonNext:t,iconPrev:n,iconNext:r},styles:i}){const{prev:o,next:s,subscribeSensors:c}=at(),{prevDisabled:u,nextDisabled:a}=us();return fa(c),p.createElement(p.Fragment,null,e?e():p.createElement(Si,{label:"Previous",action:Oe,icon:qf,renderIcon:n,style:i.navigationPrev,disabled:u,onClick:o}),t?t():p.createElement(Si,{label:"Next",action:xe,icon:Vf,renderIcon:r,style:i.navigationNext,disabled:a,onClick:s}))}const la=Te(ff,aa),Pi=T(pf),da=T(Lo);function ha(e){return"style"in e}function Oi(e,t,n){const r=window.getComputedStyle(e),i=n?"padding-left":"padding-right",o=n?r.paddingLeft:r.paddingRight,s=e.style.getPropertyValue(i);return e.style.setProperty(i,`${(Jt(o)||0)+t}px`),()=>{s?e.style.setProperty(i,s):e.style.removeProperty(i)}}function pa({noScroll:{disabled:e},children:t}){const n=Sr(),{getOwnerDocument:r,getOwnerWindow:i}=br();return p.useEffect(()=>{if(e)return()=>{};const o=[],s=i(),{body:c,documentElement:u}=r(),a=Math.round(s.innerWidth-u.clientWidth);if(a>0){o.push(Oi(c,a,n));const f=c.getElementsByTagName("*");for(let l=0;l{c.classList.remove(Pi),o.forEach(f=>f())}},[n,e,r,i]),p.createElement(p.Fragment,null,t)}const ya=Te(af,pa);function xi(e){return ct(_r,e)}function Ri(e,t,n){const r=e.getAttribute(t);return e.setAttribute(t,n),()=>{r?e.setAttribute(t,r):e.removeAttribute(t)}}function ma({portal:{root:e,container:{className:t,style:n,...r}={}},animation:i,styles:o,className:s,on:c,close:u,labels:a,children:f}){const[l,m]=p.useState(!1),[h,y]=p.useState(!1),d=p.useRef([]),g=p.useRef(null),{setTimeout:_}=tn(),{subscribe:E}=Qt(),w=os()?0:i.fade;p.useEffect(()=>(m(!0),()=>{m(!1),y(!1)}),[]);const v=U(()=>{d.current.forEach(R=>R()),d.current=[]}),x=U(()=>{var R;y(!1),v(),(R=c.exiting)===null||R===void 0||R.call(c),_(()=>{var B;(B=c.exited)===null||B===void 0||B.call(c),u()},w)});p.useEffect(()=>E(je,x),[E,x]);const O=U(R=>{var B,F,I;Cf(R),y(!0),(B=c.entering)===null||B===void 0||B.call(c);const A=(I=(F=R.parentNode)===null||F===void 0?void 0:F.children)!==null&&I!==void 0?I:[];for(let M=0;M{var M,N;(N=(M=g.current)===null||M===void 0?void 0:M.focus)===null||N===void 0||N.call(M)}),_(()=>{var M;(M=c.entered)===null||M===void 0||M.call(c)},w)}),C=p.useCallback(R=>{R?O(R):v()},[O,v]);return l?_s.createPortal(p.createElement(Jf,{ref:C,className:me(s,t,T(xi()),T(Lo),h&&T(xi("open"))),"aria-modal":!0,role:"dialog","aria-label":qe(a,"Lightbox"),style:{...i.fade!==tr.animation.fade?{[J("fade_animation_duration")]:`${w}ms`}:null,...i.easing.fade!==tr.animation.easing.fade?{[J("fade_animation_timing_function")]:i.easing.fade}:null,...o.root,...n},onFocus:R=>{g.current||(g.current=R.relatedTarget)},...r},f),(typeof e=="function"?e():e)||document.body):null}const ga=Te(_r,ma);function _a({children:e}){return p.createElement(p.Fragment,null,e)}const wa=Te(lf,_a);function va(e){return ct(Mo,e)}function Ea({toolbar:{buttons:e},render:{buttonClose:t,iconClose:n},styles:r}){const{close:i,setToolbarWidth:o}=at(),{setContainerRef:s,containerRect:c}=ss();nn(()=>{o(c==null?void 0:c.width)},[o,c==null?void 0:c.width]);const u=()=>t?t():p.createElement(is,{key:je,label:"Close",icon:jf,renderIcon:n,onClick:i});return p.createElement("div",{ref:s,style:r.toolbar,className:T(va())},e==null?void 0:e.map(a=>a===je?u():a))}const ba=Te(Mo,Ea);function fs(e,t){var n;return p.createElement(e.module.component,{key:e.module.name,...t},(n=e.children)===null||n===void 0?void 0:n.map(r=>fs(r,t)))}function Sa(e,t={}){const{easing:n,...r}=e,{easing:i,...o}=t;return{easing:{...n,...i},...r,...o}}function Xa({carousel:e,animation:t,render:n,toolbar:r,controller:i,noScroll:o,on:s,plugins:c,slides:u,index:a,...f}){const{animation:l,carousel:m,render:h,toolbar:y,controller:d,noScroll:g,on:_,slides:E,index:b,plugins:w,...v}=tr,{config:x,augmentation:O}=Mf([V(ga,[V(ya,[V(ia,[V(ua),V(ba),V(la)])])])],c||w),C=O({animation:Sa(l,t),carousel:{...m,...e},render:{...h,...n},toolbar:{...y,...r},controller:{...d,...i},noScroll:{...g,...o},on:{..._,...s},...v,...f});return C.open?p.createElement(Df,{...C},p.createElement(Ff,{slides:u||E,index:Jt(a||b)},p.createElement(Uf,null,p.createElement(Tf,null,p.createElement(If,null,fs(V(wa,x),C)))))):null}export{Ua as D,ja as E,Ba as I,Xa as L,Wa as P,Na as a,Ta as b,xa as c,qc as d,$a as e,Fa as f,sr as g,qa as h,Va as i,Ue as j,Da as k,La as l,Nc as m,Jc as n,Ia as p,za as r,Ca as s,ka as t,Ra as u,Aa as w}; diff --git a/internal/webui/static/assets/vendor-cRYyTeIw.js b/internal/webui/static/assets/vendor-cRYyTeIw.js new file mode 100644 index 0000000..f3d469e --- /dev/null +++ b/internal/webui/static/assets/vendor-cRYyTeIw.js @@ -0,0 +1,33 @@ +var Es=Object.defineProperty;var bs=(e,t,n)=>t in e?Es(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var mt=(e,t,n)=>bs(e,typeof t!="symbol"?t+"":t,n);import{r as ir,a as y,g as Ss,b as Ps}from"./react-vendor-l-BBvuKH.js";const Rs=/\{[^{}]+\}/g,Os=()=>{var e,t;return typeof process=="object"&&Number.parseInt((t=(e=process==null?void 0:process.versions)==null?void 0:e.node)==null?void 0:t.substring(0,2))>=18&&process.versions.undici};function xs(){return Math.random().toString(36).slice(2,11)}function Fa(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:o,headers:s,requestInitExt:c=void 0,...u}={...e};c=Os()?c:void 0,t=Tr(t);const f=[];async function a(l,p){const{baseUrl:h,fetch:m=r,Request:d=n,headers:g,params:_={},parseAs:E="json",querySerializer:b,bodySerializer:w=o??Ns,body:v,...R}=p||{};let S=t;h&&(S=Tr(h)??t);let C=typeof i=="function"?i:Mr(i);b&&(C=typeof b=="function"?b:Mr({...typeof i=="object"?i:{},...b}));const O=v===void 0?void 0:w(v,Lr(s,g,_.header)),q=Lr(O===void 0||O instanceof FormData?{}:{"Content-Type":"application/json"},s,g,_.header),F={redirect:"follow",...u,...R,body:O,headers:q};let M,N,I=new n(Cs(l,{baseUrl:S,params:_,querySerializer:C}),F),A;for(const L in R)L in I||(I[L]=R[L]);if(f.length){M=xs(),N=Object.freeze({baseUrl:S,fetch:m,parseAs:E,querySerializer:C,bodySerializer:w});for(const L of f)if(L&&typeof L=="object"&&typeof L.onRequest=="function"){const W=await L.onRequest({request:I,schemaPath:l,params:_,options:N,id:M});if(W)if(W instanceof n)I=W;else if(W instanceof Response){A=W;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!A){try{A=await m(I,c)}catch(L){let W=L;if(f.length)for(let te=f.length-1;te>=0;te--){const be=f[te];if(be&&typeof be=="object"&&typeof be.onError=="function"){const Z=await be.onError({request:I,error:W,schemaPath:l,params:_,options:N,id:M});if(Z){if(Z instanceof Response){W=void 0,A=Z;break}if(Z instanceof Error){W=Z;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(W)throw W}if(f.length)for(let L=f.length-1;L>=0;L--){const W=f[L];if(W&&typeof W=="object"&&typeof W.onResponse=="function"){const te=await W.onResponse({request:I,response:A,schemaPath:l,params:_,options:N,id:M});if(te){if(!(te instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");A=te}}}}if(A.status===204||I.method==="HEAD"||A.headers.get("Content-Length")==="0")return A.ok?{data:void 0,response:A}:{error:void 0,response:A};if(A.ok)return E==="stream"?{data:A.body,response:A}:{data:await A[E](),response:A};let B=await A.text();try{B=JSON.parse(B)}catch{}return{error:B,response:A}}return{request(l,p,h){return a(p,{...h,method:l.toUpperCase()})},GET(l,p){return a(l,{...p,method:"GET"})},PUT(l,p){return a(l,{...p,method:"PUT"})},POST(l,p){return a(l,{...p,method:"POST"})},DELETE(l,p){return a(l,{...p,method:"DELETE"})},OPTIONS(l,p){return a(l,{...p,method:"OPTIONS"})},HEAD(l,p){return a(l,{...p,method:"HEAD"})},PATCH(l,p){return a(l,{...p,method:"PATCH"})},TRACE(l,p){return a(l,{...p,method:"TRACE"})},use(...l){for(const p of l)if(p){if(typeof p!="object"||!("onRequest"in p||"onResponse"in p||"onError"in p))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");f.push(p)}},eject(...l){for(const p of l){const h=f.indexOf(p);h!==-1&&f.splice(h,1)}}}}function Ut(e,t,n){if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${(n==null?void 0:n.allowReserved)===!0?t:encodeURIComponent(t)}`}function Mi(e,t,n){if(!t||typeof t!="object")return"";const r=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if(n.style!=="deepObject"&&n.explode===!1){for(const c in t)r.push(c,n.allowReserved===!0?t[c]:encodeURIComponent(t[c]));const s=r.join(",");switch(n.style){case"form":return`${e}=${s}`;case"label":return`.${s}`;case"matrix":return`;${e}=${s}`;default:return s}}for(const s in t){const c=n.style==="deepObject"?`${e}[${s}]`:s;r.push(Ut(c,t[s],n))}const o=r.join(i);return n.style==="label"||n.style==="matrix"?`${i}${o}`:o}function Li(e,t,n){if(!Array.isArray(t))return"";if(n.explode===!1){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",s=(n.allowReserved===!0?t:t.map(c=>encodeURIComponent(c))).join(o);switch(n.style){case"simple":return s;case"label":return`.${s}`;case"matrix":return`;${e}=${s}`;default:return`${e}=${s}`}}const r={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const o of t)n.style==="simple"||n.style==="label"?i.push(n.allowReserved===!0?o:encodeURIComponent(o)):i.push(Ut(e,o,n));return n.style==="label"||n.style==="matrix"?`${r}${i.join(r)}`:i.join(r)}function Mr(e){return function(n){const r=[];if(n&&typeof n=="object")for(const i in n){const o=n[i];if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;r.push(Li(i,o,{style:"form",explode:!0,...e==null?void 0:e.array,allowReserved:(e==null?void 0:e.allowReserved)||!1}));continue}if(typeof o=="object"){r.push(Mi(i,o,{style:"deepObject",explode:!0,...e==null?void 0:e.object,allowReserved:(e==null?void 0:e.allowReserved)||!1}));continue}r.push(Ut(i,o,e))}}return r.join("&")}}function As(e,t){let n=e;for(const r of e.match(Rs)??[]){let i=r.substring(1,r.length-1),o=!1,s="simple";if(i.endsWith("*")&&(o=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(s="label",i=i.substring(1)):i.startsWith(";")&&(s="matrix",i=i.substring(1)),!t||t[i]===void 0||t[i]===null)continue;const c=t[i];if(Array.isArray(c)){n=n.replace(r,Li(i,c,{style:s,explode:o}));continue}if(typeof c=="object"){n=n.replace(r,Mi(i,c,{style:s,explode:o}));continue}if(s==="matrix"){n=n.replace(r,`;${Ut(i,c)}`);continue}n=n.replace(r,s==="label"?`.${encodeURIComponent(c)}`:encodeURIComponent(c))}return n}function Ns(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get("Content-Type")??t.get("content-type"):t["Content-Type"]??t["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(e).toString():JSON.stringify(e)}function Cs(e,t){var i;let n=`${t.baseUrl}${e}`;(i=t.params)!=null&&i.path&&(n=As(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith("?")&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function Lr(...e){const t=new Headers;for(const n of e){if(!n||typeof n!="object")continue;const r=n instanceof Headers?n.entries():Object.entries(n);for(const[i,o]of r)if(o===null)t.delete(i);else if(Array.isArray(o))for(const s of o)t.append(i,s);else o!==void 0&&t.set(i,o)}return t}function Tr(e){return e.endsWith("/")?e.substring(0,e.length-1):e}function Ti(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;tObject.prototype.propertyIsEnumerable.call(e,t))}function ur(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const $s="[object RegExp]",Fi="[object String]",zi="[object Number]",Wi="[object Boolean]",Ui="[object Arguments]",Fs="[object Symbol]",zs="[object Date]",Ws="[object Map]",Us="[object Set]",js="[object Array]",Bs="[object ArrayBuffer]",qs="[object Object]",Hs="[object DataView]",Vs="[object Uint8Array]",Xs="[object Uint8ClampedArray]",Ys="[object Uint16Array]",Ks="[object Uint32Array]",Gs="[object Int8Array]",Qs="[object Int16Array]",Js="[object Int32Array]",Zs="[object Float32Array]",ec="[object Float64Array]",Dr=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof global=="object"&&global||(function(){return this})();function tc(e){return typeof Dr.Buffer<"u"&&Dr.Buffer.isBuffer(e)}function nc(e,t){return Ne(e,void 0,e,new Map,t)}function Ne(e,t,n,r=new Map,i=void 0){const o=i==null?void 0:i(e,t,n,r);if(o!==void 0)return o;if(Dn(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){const s=new Array(e.length);r.set(e,s);for(let c=0;c{}):kn(e,t,function r(i,o,s,c,u,f){const a=n(i,o,s,c,u,f);return a!==void 0?!!a:kn(i,o,r,f,!1)},new Map,!0)}function kn(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case"object":return oc(e,t,n,r);case"function":return Object.keys(t).length>0?kn(e,{...t},n,r,i):bt(e,t);default:return ji(e)&&i?typeof t=="string"?t==="":!0:bt(e,t)}}function oc(e,t,n,r){if(t==null)return!0;if(Array.isArray(t))return qi(e,t,n,r);if(t instanceof Map)return sc(e,t,n,r);if(t instanceof Set)return cc(e,t,n,r);const i=Object.keys(t);if(e==null||Dn(e))return i.length===0;if(i.length===0)return!0;if(r!=null&&r.has(t))return r.get(t)===e;r==null||r.set(t,e);try{for(let o=0;o{})}function uc(e){return e=ic(e),t=>Hi(t,e)}function fc(e,t){return nc(e,(n,r,i,o)=>{if(typeof e=="object"){if(ur(e)==="[object Object]"&&typeof e.constructor!="function"){const s={};return o.set(e,s),fe(s,e,i,o),s}switch(Object.prototype.toString.call(e)){case zi:case Fi:case Wi:{const s=new e.constructor(e==null?void 0:e.valueOf());return fe(s,e),s}case Ui:{const s={};return fe(s,e),s.length=e.length,s[Symbol.iterator]=e[Symbol.iterator],s}default:return}}})}function ac(e){return fc(e)}const lc=/^(?:0|[1-9]\d*)$/;function Vi(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e=0}function Xi(e){return e!=null&&typeof e!="function"&&mc(e.length)}function gc(e){return typeof e=="object"&&e!==null}function _c(e){return gc(e)&&Xi(e)}function Wa(e,t=$i){return _c(e)?Ms(Array.from(e),Ls(yc(t),1)):[]}var ln={exports:{}},dn={},hn={exports:{}},pn={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var kr;function wc(){if(kr)return pn;kr=1;var e=ir();function t(l,p){return l===p&&(l!==0||1/l===1/p)||l!==l&&p!==p}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function c(l,p){var h=p(),m=r({inst:{value:h,getSnapshot:p}}),d=m[0].inst,g=m[1];return o(function(){d.value=h,d.getSnapshot=p,u(d)&&g({inst:d})},[l,h,p]),i(function(){return u(d)&&g({inst:d}),l(function(){u(d)&&g({inst:d})})},[l]),s(h),h}function u(l){var p=l.getSnapshot;l=l.value;try{var h=p();return!n(l,h)}catch{return!0}}function f(l,p){return p()}var a=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return pn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:a,pn}var $r;function vc(){return $r||($r=1,hn.exports=wc()),hn.exports}/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Fr;function Ec(){if(Fr)return dn;Fr=1;var e=ir(),t=vc();function n(f,a){return f===a&&(f!==0||1/f===1/a)||f!==f&&a!==a}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,u=e.useDebugValue;return dn.useSyncExternalStoreWithSelector=function(f,a,l,p,h){var m=o(null);if(m.current===null){var d={hasValue:!1,value:null};m.current=d}else d=m.current;m=c(function(){function _(R){if(!E){if(E=!0,b=R,R=p(R),h!==void 0&&d.hasValue){var S=d.value;if(h(S,R))return w=S}return w=R}if(S=w,r(b,R))return S;var C=p(R);return h!==void 0&&h(S,C)?(b=R,S):(b=R,w=C)}var E=!1,b,w,v=l===void 0?null:l;return[function(){return _(a())},v===null?void 0:function(){return _(v())}]},[a,l,p,h]);var g=i(f,m[0],m[1]);return s(function(){d.hasValue=!0,d.value=g},[g]),u(g),g},dn}var zr;function bc(){return zr||(zr=1,ln.exports=Ec()),ln.exports}var Ua=bc();function Sc(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Pc(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Wr=e=>Array.isArray(e)?e:[e];function Rc(e){const t=Array.isArray(e[0])?e[0]:e;return Pc(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Oc(e,t){const n=[],{length:r}=e;for(let i=0;itypeof WeakRef>"u"?xc:WeakRef,Yi=Ac(),Nc=0,Ur=1;function gt(){return{s:Nc,v:void 0,o:null,p:null}}function Cc(e){return e instanceof Yi?e.deref():e}function Ki(e,t={}){let n=gt();const{resultEqualityCheck:r}=t;let i,o=0;function s(){let c=n;const{length:u}=arguments;for(let l=0,p=u;l{n=gt(),s.resetResultsCount()},s.resultsCount=()=>o,s.resetResultsCount=()=>{o=0},s}function Ic(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,s=0,c,u={},f=i.pop();typeof f=="object"&&(u=f,f=i.pop()),Sc(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const a={...n,...u},{memoize:l,memoizeOptions:p=[],argsMemoize:h=Ki,argsMemoizeOptions:m=[]}=a,d=Wr(p),g=Wr(m),_=Rc(i),E=l(function(){return o++,f.apply(null,arguments)},...d),b=h(function(){s++;const v=Oc(_,arguments);return c=E.apply(null,v),c},...g);return Object.assign(b,{resultFunc:f,memoizedResultFunc:E,dependencies:_,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>c,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var ja=Ic(Ki);function Mc(e,t=1){const n=[],r=Math.floor(t),i=(o,s)=>{for(let c=0;c{if(e!==t){const r=jr(e),i=jr(t);if(r===i&&r===0){if(et)return n==="desc"?-1:1}return n==="desc"?i-r:r-i}return 0};function Gi(e){return typeof e=="symbol"||e instanceof Symbol}const Tc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Dc=/^\w*$/;function kc(e,t){return Array.isArray(e)?!1:typeof e=="number"||typeof e=="boolean"||e==null||Gi(e)?!0:typeof e=="string"&&(Dc.test(e)||!Tc.test(e))||t!=null}function $c(e,t,n,r){if(e==null)return[];n=n,Array.isArray(e)||(e=Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(c=>String(c));const i=(c,u)=>{let f=c;for(let a=0;au==null||c==null?u:typeof c=="object"&&"key"in c?Object.hasOwn(u,c.key)?u[c.key]:i(u,c.path):typeof c=="function"?c(u):Array.isArray(c)?i(u,c):typeof u=="object"?u[c]:u,s=t.map(c=>(Array.isArray(c)&&c.length===1&&(c=c[0]),c==null||typeof c=="function"||Array.isArray(c)||kc(c)?c:{key:c,path:sr(c)}));return e.map(c=>({original:c,criteria:s.map(u=>o(u,c))})).slice().sort((c,u)=>{for(let f=0;fc.original)}function Ba(e,...t){const n=t.length;return n>1&&$n(e,t[0],t[1])?t=[]:n>2&&$n(t[0],t[1],t[2])&&(t=[t[0]]),$c(e,Mc(t),["asc"])}function K(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Fc=typeof Symbol=="function"&&Symbol.observable||"@@observable",Br=Fc,yn=()=>Math.random().toString(36).substring(7).split("").join("."),zc={INIT:`@@redux/INIT${yn()}`,REPLACE:`@@redux/REPLACE${yn()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yn()}`},Ot=zc;function fr(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Qi(e,t,n){if(typeof e!="function")throw new Error(K(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(K(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(K(1));return n(Qi)(e,t)}let r=e,i=t,o=new Map,s=o,c=0,u=!1;function f(){s===o&&(s=new Map,o.forEach((g,_)=>{s.set(_,g)}))}function a(){if(u)throw new Error(K(3));return i}function l(g){if(typeof g!="function")throw new Error(K(4));if(u)throw new Error(K(5));let _=!0;f();const E=c++;return s.set(E,g),function(){if(_){if(u)throw new Error(K(6));_=!1,f(),s.delete(E),o=null}}}function p(g){if(!fr(g))throw new Error(K(7));if(typeof g.type>"u")throw new Error(K(8));if(typeof g.type!="string")throw new Error(K(17));if(u)throw new Error(K(9));try{u=!0,i=r(i,g)}finally{u=!1}return(o=s).forEach(E=>{E()}),g}function h(g){if(typeof g!="function")throw new Error(K(10));r=g,p({type:Ot.REPLACE})}function m(){const g=l;return{subscribe(_){if(typeof _!="object"||_===null)throw new Error(K(11));function E(){const w=_;w.next&&w.next(a())}return E(),{unsubscribe:g(E)}},[Br](){return this}}}return p({type:Ot.INIT}),{dispatch:p,subscribe:l,getState:a,replaceReducer:h,[Br]:m}}function Wc(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Ot.INIT})>"u")throw new Error(K(12));if(typeof n(void 0,{type:Ot.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(K(13))})}function Uc(e){const t=Object.keys(e),n={};for(let o=0;o"u")throw c&&c.type,new Error(K(14));f[l]=m,u=u||m!==h}return u=u||r.length!==Object.keys(s).length,u?f:s}}function xt(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function jc(...e){return t=>(n,r)=>{const i=t(n,r);let o=()=>{throw new Error(K(15))};const s={getState:i.getState,dispatch:(u,...f)=>o(u,...f)},c=e.map(u=>u(s));return o=xt(...c)(i.dispatch),{...i,dispatch:o}}}function Ji(e){return fr(e)&&"type"in e&&typeof e.type=="string"}var Zi=Symbol.for("immer-nothing"),qr=Symbol.for("immer-draftable"),J=Symbol.for("immer-state");function ae(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var re=Object,je=re.getPrototypeOf,At="constructor",jt="prototype",Fn="configurable",Nt="enumerable",St="writable",Ze="value",ve=e=>!!e&&!!e[J];function de(e){var t;return e?eo(e)||qt(e)||!!e[qr]||!!((t=e[At])!=null&&t[qr])||Ht(e)||Vt(e):!1}var Bc=re[jt][At].toString(),Hr=new WeakMap;function eo(e){if(!e||!ar(e))return!1;const t=je(e);if(t===null||t===re[jt])return!0;const n=re.hasOwnProperty.call(t,At)&&t[At];if(n===Object)return!0;if(!We(n))return!1;let r=Hr.get(n);return r===void 0&&(r=Function.toString.call(n),Hr.set(n,r)),r===Bc}function Bt(e,t,n=!0){st(e)===0?(n?Reflect.ownKeys(e):re.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function st(e){const t=e[J];return t?t.type_:qt(e)?1:Ht(e)?2:Vt(e)?3:0}var Vr=(e,t,n=st(e))=>n===2?e.has(t):re[jt].hasOwnProperty.call(e,t),zn=(e,t,n=st(e))=>n===2?e.get(t):e[t],Ct=(e,t,n,r=st(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function qc(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var qt=Array.isArray,Ht=e=>e instanceof Map,Vt=e=>e instanceof Set,ar=e=>typeof e=="object",We=e=>typeof e=="function",mn=e=>typeof e=="boolean";function Hc(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var ge=e=>e.copy_||e.base_,lr=e=>e.modified_?e.copy_:e.base_;function Wn(e,t){if(Ht(e))return new Map(e);if(Vt(e))return new Set(e);if(qt(e))return Array[jt].slice.call(e);const n=eo(e);if(t===!0||t==="class_only"&&!n){const r=re.getOwnPropertyDescriptors(e);delete r[J];let i=Reflect.ownKeys(r);for(let o=0;o1&&re.defineProperties(e,{set:_t,add:_t,clear:_t,delete:_t}),re.freeze(e),t&&Bt(e,(n,r)=>{dr(r,!0)},!1)),e}function Vc(){ae(2)}var _t={[Ze]:Vc};function Xt(e){return e===null||!ar(e)?!0:re.isFrozen(e)}var It="MapSet",Un="Patches",Xr="ArrayMethods",to={};function Me(e){const t=to[e];return t||ae(0,e),t}var Yr=e=>!!to[e],et,no=()=>et,Xc=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Yr(It)?Me(It):void 0,arrayMethodsPlugin_:Yr(Xr)?Me(Xr):void 0});function Kr(e,t){t&&(e.patchPlugin_=Me(Un),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function jn(e){Bn(e),e.drafts_.forEach(Yc),e.drafts_=null}function Bn(e){e===et&&(et=e.parent_)}var Gr=e=>et=Xc(et,e);function Yc(e){const t=e[J];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Qr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[J].modified_&&(jn(t),ae(4)),de(e)&&(e=Jr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[J].base_,e,t)}else e=Jr(t,n);return Kc(t,e,!0),jn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Zi?e:void 0}function Jr(e,t){if(Xt(t))return t;const n=t[J];if(!n)return Mt(t,e.handledSet_,e);if(!Yt(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);oo(n,e)}return n.copy_}function Kc(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&dr(t,n)}function ro(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Yt=(e,t)=>e.scope_===t,Gc=[];function io(e,t,n,r){const i=ge(e),o=e.type_;if(r!==void 0&&zn(i,r,o)===t){Ct(i,r,n,o);return}if(!e.draftLocations_){const c=e.draftLocations_=new Map;Bt(i,(u,f)=>{if(ve(f)){const a=c.get(f)||[];a.push(u),c.set(f,a)}})}const s=e.draftLocations_.get(t)??Gc;for(const c of s)Ct(i,c,n,o)}function Qc(e,t,n){e.callbacks_.push(function(i){var c;const o=t;if(!o||!Yt(o,i))return;(c=i.mapSetPlugin_)==null||c.fixSetContents(o);const s=lr(o);io(e,o.draft_??o,s,n),oo(o,i)})}function oo(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const o=i.getPath(e);o&&i.generatePatches_(e,o,t)}ro(e)}}function Jc(e,t,n){const{scope_:r}=e;if(ve(n)){const i=n[J];Yt(i,r)&&i.callbacks_.push(function(){Pt(e);const s=lr(i);io(e,n,s,t)})}else de(n)&&e.callbacks_.push(function(){const o=ge(e);e.type_===3?o.has(n)&&Mt(n,r.handledSet_,r):zn(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Mt(zn(e.copy_,t,e.type_),r.handledSet_,r)})}function Mt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ve(e)||t.has(e)||!de(e)||Xt(e)||(t.add(e),Bt(e,(r,i)=>{if(ve(i)){const o=i[J];if(Yt(o,n)){const s=lr(o);Ct(e,r,s,e.type_),ro(o)}}else de(i)&&Mt(i,t,n)})),e}function Zc(e,t){const n=qt(e),r={type_:n?1:0,scope_:t?t.scope_:no(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,o=Lt;n&&(i=[r],o=tt);const{revoke:s,proxy:c}=Proxy.revocable(i,o);return r.draft_=c,r.revoke_=s,[c,r]}var Lt={get(e,t){if(t===J)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=ge(e);if(!Vr(i,t,e.type_))return eu(e,i,t);const o=i[t];if(e.finalized_||!de(o)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&Hc(t))return o;if(o===gn(e.base_,t)){Pt(e);const s=e.type_===1?+t:t,c=Hn(e.scope_,o,e,s);return e.copy_[s]=c}return o},has(e,t){return t in ge(e)},ownKeys(e){return Reflect.ownKeys(ge(e))},set(e,t,n){const r=so(ge(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=gn(ge(e),t),o=i==null?void 0:i[J];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(qc(n,i)&&(n!==void 0||Vr(e.base_,t,e.type_)))return!0;Pt(e),qn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Jc(e,t,n)),!0},deleteProperty(e,t){return Pt(e),gn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),qn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ge(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[St]:!0,[Fn]:e.type_!==1||t!=="length",[Nt]:r[Nt],[Ze]:n[t]}},defineProperty(){ae(11)},getPrototypeOf(e){return je(e.base_)},setPrototypeOf(){ae(12)}},tt={};for(let e in Lt){let t=Lt[e];tt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}tt.deleteProperty=function(e,t){return tt.set.call(this,e,t,void 0)};tt.set=function(e,t,n){return Lt.set.call(this,e[0],t,n,e[0])};function gn(e,t){const n=e[J];return(n?ge(n):e)[t]}function eu(e,t,n){var i;const r=so(t,n);return r?Ze in r?r[Ze]:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function so(e,t){if(!(t in e))return;let n=je(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=je(n)}}function qn(e){e.modified_||(e.modified_=!0,e.parent_&&qn(e.parent_))}function Pt(e){e.copy_||(e.assigned_=new Map,e.copy_=Wn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var tu=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(We(n)&&!We(r)){const s=r;r=n;const c=this;return function(f=s,...a){return c.produce(f,l=>r.call(this,l,...a))}}We(r)||ae(6),i!==void 0&&!We(i)&&ae(7);let o;if(de(n)){const s=Gr(this),c=Hn(s,n,void 0);let u=!0;try{o=r(c),u=!1}finally{u?jn(s):Bn(s)}return Kr(s,i),Qr(o,s)}else if(!n||!ar(n)){if(o=r(n),o===void 0&&(o=n),o===Zi&&(o=void 0),this.autoFreeze_&&dr(o,!0),i){const s=[],c=[];Me(Un).generateReplacementPatches_(n,o,{patches_:s,inversePatches_:c}),i(s,c)}return o}else ae(1,n)},this.produceWithPatches=(n,r)=>{if(We(n))return(c,...u)=>this.produceWithPatches(c,f=>n(f,...u));let i,o;return[this.produce(n,r,(c,u)=>{i=c,o=u}),i,o]},mn(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),mn(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),mn(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){de(t)||ae(8),ve(t)&&(t=nu(t));const n=Gr(this),r=Hn(n,t,void 0);return r[J].isManual_=!0,Bn(n),r}finishDraft(t,n){const r=t&&t[J];(!r||!r.isManual_)&&ae(9);const{scope_:i}=r;return Kr(i,n),Qr(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const o=n[r];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}r>-1&&(n=n.slice(r+1));const i=Me(Un).applyPatches_;return ve(t)?i(t,n):this.produce(t,o=>i(o,n))}};function Hn(e,t,n,r){const[i,o]=Ht(t)?Me(It).proxyMap_(t,n):Vt(t)?Me(It).proxySet_(t,n):Zc(t,n);return((n==null?void 0:n.scope_)??no()).drafts_.push(i),o.callbacks_=(n==null?void 0:n.callbacks_)??[],o.key_=r,n&&r!==void 0?Qc(n,o,r):o.callbacks_.push(function(u){var a;(a=u.mapSetPlugin_)==null||a.fixSetContents(o);const{patchPlugin_:f}=u;o.modified_&&f&&f.generatePatches_(o,[],u)}),i}function nu(e){return ve(e)||ae(10,e),co(e)}function co(e){if(!de(e)||Xt(e))return e;const t=e[J];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Wn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Wn(e,!0);return Bt(n,(i,o)=>{Ct(n,i,co(o))},r),t&&(t.finalized_=!1),n}var ru=new tu,uo=ru.produce;function fo(e){return({dispatch:n,getState:r})=>i=>o=>typeof o=="function"?o(n,r,e):i(o)}var iu=fo(),ou=fo,su=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?xt:xt.apply(null,arguments)};function Be(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(ie(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Ji(r)&&r.type===e,n}var ao=class Je extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Je.prototype)}static get[Symbol.species](){return Je}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Je(...t[0].concat(this)):new Je(...t.concat(this))}};function Zr(e){return de(e)?uo(e,()=>{}):e}function wt(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function cu(e){return typeof e=="boolean"}var uu=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=t??{};let s=new ao;return n&&(cu(n)?s.push(iu):s.push(ou(n.extraArgument))),s},lo="RTK_autoBatch",Ha=()=>e=>({payload:e,meta:{[lo]:!0}}),ei=e=>t=>{setTimeout(t,e)},fu=(e,t)=>n=>{let r=!1;const i=()=>{r||(r=!0,cancelAnimationFrame(o),clearTimeout(s),n())},o=e(i),s=setTimeout(i,t)},au=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,o=!1,s=!1;const c=new Set,u=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?fu(window.requestAnimationFrame,100):ei(10):e.type==="callback"?e.queueNotification:ei(e.timeout),f=()=>{s=!1,o&&(o=!1,c.forEach(a=>a()))};return Object.assign({},r,{subscribe(a){const l=()=>i&&a(),p=r.subscribe(l);return c.add(a),()=>{p(),c.delete(a)}},dispatch(a){var l;try{return i=!((l=a==null?void 0:a.meta)!=null&&l[lo]),o=!i,o&&(s||(s=!0,u(f))),r.dispatch(a)}finally{i=!0}}})},lu=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new ao(e);return r&&i.push(au(typeof r=="object"?r:void 0)),i};function Va(e){const t=uu(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{};let c;if(typeof n=="function")c=n;else if(fr(n))c=Uc(n);else throw new Error(ie(1));let u;typeof r=="function"?u=r(t):u=t();let f=xt;i&&(f=su({trace:!1,...typeof i=="object"&&i}));const a=jc(...u),l=lu(a);let p=typeof s=="function"?s(l):l();const h=f(...p);return Qi(c,o,h)}function ho(e){const t={},n=[];let r;const i={addCase(o,s){const c=typeof o=="string"?o:o.type;if(!c)throw new Error(ie(28));if(c in t)throw new Error(ie(29));return t[c]=s,i},addAsyncThunk(o,s){return s.pending&&(t[o.pending.type]=s.pending),s.rejected&&(t[o.rejected.type]=s.rejected),s.fulfilled&&(t[o.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:o.settled,reducer:s.settled}),i},addMatcher(o,s){return n.push({matcher:o,reducer:s}),i},addDefaultCase(o){return r=o,i}};return e(i),[t,n,r]}function du(e){return typeof e=="function"}function hu(e,t){let[n,r,i]=ho(t),o;if(du(e))o=()=>Zr(e());else{const c=Zr(e);o=()=>c}function s(c=o(),u){let f=[n[u.type],...r.filter(({matcher:a})=>a(u)).map(({reducer:a})=>a)];return f.filter(a=>!!a).length===0&&(f=[i]),f.reduce((a,l)=>{if(l)if(ve(a)){const h=l(a,u);return h===void 0?a:h}else{if(de(a))return uo(a,p=>l(p,u));{const p=l(a,u);if(p===void 0){if(a===null)return a;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return a},c)}return s.getInitialState=o,s}var pu="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",yu=(e=21)=>{let t="",n=e;for(;n--;)t+=pu[Math.random()*64|0];return t},mu=Symbol.for("rtk-slice-createasyncthunk");function gu(e,t){return`${e}/${t}`}function _u({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[mu];return function(i){const{name:o,reducerPath:s=o}=i;if(!o)throw new Error(ie(11));const c=(typeof i.reducers=="function"?i.reducers(vu()):i.reducers)||{},u=Object.keys(c),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(w,v){const R=typeof w=="string"?w:w.type;if(!R)throw new Error(ie(12));if(R in f.sliceCaseReducersByType)throw new Error(ie(13));return f.sliceCaseReducersByType[R]=v,a},addMatcher(w,v){return f.sliceMatchers.push({matcher:w,reducer:v}),a},exposeAction(w,v){return f.actionCreators[w]=v,a},exposeCaseReducer(w,v){return f.sliceCaseReducersByName[w]=v,a}};u.forEach(w=>{const v=c[w],R={reducerName:w,type:gu(o,w),createNotation:typeof i.reducers=="function"};bu(v)?Pu(R,v,a,t):Eu(R,v,a)});function l(){const[w={},v=[],R=void 0]=typeof i.extraReducers=="function"?ho(i.extraReducers):[i.extraReducers],S={...w,...f.sliceCaseReducersByType};return hu(i.initialState,C=>{for(let O in S)C.addCase(O,S[O]);for(let O of f.sliceMatchers)C.addMatcher(O.matcher,O.reducer);for(let O of v)C.addMatcher(O.matcher,O.reducer);R&&C.addDefaultCase(R)})}const p=w=>w,h=new Map,m=new WeakMap;let d;function g(w,v){return d||(d=l()),d(w,v)}function _(){return d||(d=l()),d.getInitialState()}function E(w,v=!1){function R(C){let O=C[w];return typeof O>"u"&&v&&(O=wt(m,R,_)),O}function S(C=p){const O=wt(h,v,()=>new WeakMap);return wt(O,C,()=>{const q={};for(const[F,M]of Object.entries(i.selectors??{}))q[F]=wu(M,C,()=>wt(m,C,_),v);return q})}return{reducerPath:w,getSelectors:S,get selectors(){return S(R)},selectSlice:R}}const b={name:o,reducer:g,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:_,...E(s),injectInto(w,{reducerPath:v,...R}={}){const S=v??s;return w.inject({reducerPath:S,reducer:g},R),{...b,...E(S,!0)}}};return b}}function wu(e,t,n,r){function i(o,...s){let c=t(o);return typeof c>"u"&&r&&(c=n()),e(c,...s)}return i.unwrapped=e,i}var Xa=_u();function vu(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function Eu({type:e,reducerName:t,createNotation:n},r,i){let o,s;if("reducer"in r){if(n&&!Su(r))throw new Error(ie(17));o=r.reducer,s=r.prepare}else o=r;i.addCase(e,o).exposeCaseReducer(t,o).exposeAction(t,s?Be(e,s):Be(e))}function bu(e){return e._reducerDefinitionType==="asyncThunk"}function Su(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Pu({type:e,reducerName:t},n,r,i){if(!i)throw new Error(ie(18));const{payloadCreator:o,fulfilled:s,pending:c,rejected:u,settled:f,options:a}=n,l=i(e,o,a);r.exposeAction(t,l),s&&r.addCase(l.fulfilled,s),c&&r.addCase(l.pending,c),u&&r.addCase(l.rejected,u),f&&r.addMatcher(l.settled,f),r.exposeCaseReducer(t,{fulfilled:s||vt,pending:c||vt,rejected:u||vt,settled:f||vt})}function vt(){}var Ru="task",po="listener",yo="completed",hr="cancelled",Ou=`task-${hr}`,xu=`task-${yo}`,Vn=`${po}-${hr}`,Au=`${po}-${yo}`,Kt=class{constructor(e){mt(this,"code");mt(this,"name","TaskAbortError");mt(this,"message");this.code=e,this.message=`${Ru} ${hr} (reason: ${e})`}},pr=(e,t)=>{if(typeof e!="function")throw new TypeError(ie(32))},Tt=()=>{},mo=(e,t=Tt)=>(e.catch(t),e),go=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Ce=e=>{if(e.aborted)throw new Kt(e.reason)};function _o(e,t){let n=Tt;return new Promise((r,i)=>{const o=()=>i(new Kt(e.reason));if(e.aborted){o();return}n=go(e,o),t.finally(()=>n()).then(r,i)}).finally(()=>{n=Tt})}var Nu=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof Kt?"cancelled":"rejected",error:n}}finally{t==null||t()}},Dt=e=>t=>mo(_o(e,t).then(n=>(Ce(e),n))),wo=e=>{const t=Dt(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:Ue}=Object,ti={},Gt="listenerMiddleware",Cu=(e,t)=>{const n=r=>go(e,()=>r.abort(e.reason));return(r,i)=>{pr(r);const o=new AbortController;n(o);const s=Nu(async()=>{Ce(e),Ce(o.signal);const c=await r({pause:Dt(o.signal),delay:wo(o.signal),signal:o.signal});return Ce(o.signal),c},()=>o.abort(xu));return i!=null&&i.autoJoin&&t.push(s.catch(Tt)),{result:Dt(e)(s),cancel(){o.abort(Ou)}}}},Iu=(e,t)=>{const n=async(r,i)=>{Ce(t);let o=()=>{};const c=[new Promise((u,f)=>{let a=e({predicate:r,effect:(l,p)=>{p.unsubscribe(),u([l,p.getState(),p.getOriginalState()])}});o=()=>{a(),f()}})];i!=null&&c.push(new Promise(u=>setTimeout(u,i,null)));try{const u=await _o(t,Promise.race(c));return Ce(t),u}finally{o()}};return((r,i)=>mo(n(r,i)))},vo=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:o}=e;if(t)i=Be(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ie(21));return pr(o),{predicate:i,type:t,effect:o}},Eo=Ue(e=>{const{type:t,predicate:n,effect:r}=vo(e);return{id:yu(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ie(22))}}},{withTypes:()=>Eo}),ni=(e,t)=>{const{type:n,effect:r,predicate:i}=vo(t);return Array.from(e.values()).find(o=>(typeof n=="string"?o.type===n:o.predicate===i)&&o.effect===r)},Xn=e=>{e.pending.forEach(t=>{t.abort(Vn)})},Mu=(e,t)=>()=>{for(const n of t.keys())Xn(n);e.clear()},ri=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},bo=Ue(Be(`${Gt}/add`),{withTypes:()=>bo}),Lu=Be(`${Gt}/removeAll`),So=Ue(Be(`${Gt}/remove`),{withTypes:()=>So}),Tu=(...e)=>{console.error(`${Gt}/error`,...e)},Ya=(e={})=>{const t=new Map,n=new Map,r=h=>{const m=n.get(h)??0;n.set(h,m+1)},i=h=>{const m=n.get(h)??1;m===1?n.delete(h):n.set(h,m-1)},{extra:o,onError:s=Tu}=e;pr(s);const c=h=>(h.unsubscribe=()=>t.delete(h.id),t.set(h.id,h),m=>{h.unsubscribe(),m!=null&&m.cancelActive&&Xn(h)}),u=(h=>{const m=ni(t,h)??Eo(h);return c(m)});Ue(u,{withTypes:()=>u});const f=h=>{const m=ni(t,h);return m&&(m.unsubscribe(),h.cancelActive&&Xn(m)),!!m};Ue(f,{withTypes:()=>f});const a=async(h,m,d,g)=>{const _=new AbortController,E=Iu(u,_.signal),b=[];try{h.pending.add(_),r(h),await Promise.resolve(h.effect(m,Ue({},d,{getOriginalState:g,condition:(w,v)=>E(w,v).then(Boolean),take:E,delay:wo(_.signal),pause:Dt(_.signal),extra:o,signal:_.signal,fork:Cu(_.signal,b),unsubscribe:h.unsubscribe,subscribe:()=>{t.set(h.id,h)},cancelActiveListeners:()=>{h.pending.forEach((w,v,R)=>{w!==_&&(w.abort(Vn),R.delete(w))})},cancel:()=>{_.abort(Vn),h.pending.delete(_)},throwIfCancelled:()=>{Ce(_.signal)}})))}catch(w){w instanceof Kt||ri(s,w,{raisedBy:"effect"})}finally{await Promise.all(b),_.abort(Au),i(h),h.pending.delete(_)}},l=Mu(t,n);return{middleware:h=>m=>d=>{if(!Ji(d))return m(d);if(bo.match(d))return u(d.payload);if(Lu.match(d)){l();return}if(So.match(d))return f(d.payload);let g=h.getState();const _=()=>{if(g===ti)throw new Error(ie(23));return g};let E;try{if(E=m(d),t.size>0){const b=h.getState(),w=Array.from(t.values());for(const v of w){let R=!1;try{R=v.predicate(d,b,g)}catch(S){R=!1,ri(s,S,{raisedBy:"predicate"})}R&&a(v,d,h,_)}}}finally{g=ti}return E},startListening:u,stopListening:f,clearListeners:l}};function ie(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}function Du(e,t,{signal:n,edges:r}={}){let i,o=null;const s=r!=null&&r.includes("leading"),c=r==null||r.includes("trailing"),u=()=>{o!==null&&(e.apply(i,o),i=void 0,o=null)},f=()=>{c&&u(),h()};let a=null;const l=()=>{a!=null&&clearTimeout(a),a=setTimeout(()=>{a=null,f()},t)},p=()=>{a!==null&&(clearTimeout(a),a=null)},h=()=>{p(),i=void 0,o=null},m=()=>{u()},d=function(...g){if(n!=null&&n.aborted)return;i=this,o=g;const _=a==null;l(),s&&_&&u()};return d.schedule=l,d.cancel=h,d.flush=m,n==null||n.addEventListener("abort",h,{once:!0}),d}function ku(e,t=0,n={}){typeof n!="object"&&(n={});const{leading:r=!1,trailing:i=!0,maxWait:o}=n,s=Array(2);r&&(s[0]="leading"),i&&(s[1]="trailing");let c,u=null;const f=Du(function(...p){c=e.apply(this,p),u=null},t,{edges:s}),a=function(...p){return o!=null&&(u===null&&(u=Date.now()),Date.now()-u>=o)?(c=e.apply(this,p),u=Date.now(),f.cancel(),f.schedule(),c):(f.apply(this,p),c)},l=()=>(f.flush(),c);return a.cancel=f.cancel,a.flush=l,a}function Ka(e,t=0,n={}){const{leading:r=!0,trailing:i=!0}=n;return ku(e,t,{leading:r,maxWait:t,trailing:i})}var Po=Symbol.for("immer-nothing"),ii=Symbol.for("immer-draftable"),oe=Symbol.for("immer-state");function le(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var nt=Object.getPrototypeOf;function qe(e){return!!e&&!!e[oe]}function Le(e){var t;return e?Ro(e)||Array.isArray(e)||!!e[ii]||!!((t=e.constructor)!=null&&t[ii])||ct(e)||Jt(e):!1}var $u=Object.prototype.constructor.toString(),oi=new WeakMap;function Ro(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=oi.get(n);return r===void 0&&(r=Function.toString.call(n),oi.set(n,r)),r===$u}function kt(e,t,n=!0){Qt(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Qt(e){const t=e[oe];return t?t.type_:Array.isArray(e)?1:ct(e)?2:Jt(e)?3:0}function Yn(e,t){return Qt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Oo(e,t,n){const r=Qt(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function Fu(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ct(e){return e instanceof Map}function Jt(e){return e instanceof Set}function Re(e){return e.copy_||e.base_}function Kn(e,t){if(ct(e))return new Map(e);if(Jt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Ro(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[oe];let i=Reflect.ownKeys(r);for(let o=0;o1&&Object.defineProperties(e,{set:Et,add:Et,clear:Et,delete:Et}),Object.freeze(e),t&&Object.values(e).forEach(n=>yr(n,!0))),e}function zu(){le(2)}var Et={value:zu};function Zt(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var Wu={};function Te(e){const t=Wu[e];return t||le(0,e),t}var rt;function xo(){return rt}function Uu(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function si(e,t){t&&(Te("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Gn(e){Qn(e),e.drafts_.forEach(ju),e.drafts_=null}function Qn(e){e===rt&&(rt=e.parent_)}function ci(e){return rt=Uu(rt,e)}function ju(e){const t=e[oe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ui(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[oe].modified_&&(Gn(t),le(4)),Le(e)&&(e=$t(t,e),t.parent_||Ft(t,e)),t.patches_&&Te("Patches").generateReplacementPatches_(n[oe].base_,e,t.patches_,t.inversePatches_)):e=$t(t,n,[]),Gn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Po?e:void 0}function $t(e,t,n){if(Zt(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[oe];if(!i)return kt(t,(o,s)=>fi(e,i,t,o,s,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return Ft(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let s=o,c=!1;i.type_===3&&(s=new Set(o),o.clear(),c=!0),kt(s,(u,f)=>fi(e,i,o,u,f,n,c),r),Ft(e,o,!1),n&&e.patches_&&Te("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function fi(e,t,n,r,i,o,s){if(i==null||typeof i!="object"&&!s)return;const c=Zt(i);if(!(c&&!s)){if(qe(i)){const u=o&&t&&t.type_!==3&&!Yn(t.assigned_,r)?o.concat(r):void 0,f=$t(e,i,u);if(Oo(n,r,f),qe(f))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Le(i)&&!c){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&c)return;$t(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(ct(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Ft(e,i)}}}function Ft(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&yr(t,n)}function Bu(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:xo(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=mr;n&&(i=[r],o=it);const{revoke:s,proxy:c}=Proxy.revocable(i,o);return r.draft_=c,r.revoke_=s,c}var mr={get(e,t){if(t===oe)return e;const n=Re(e);if(!Yn(n,t))return qu(e,n,t);const r=n[t];return e.finalized_||!Le(r)?r:r===_n(e.base_,t)?(wn(e),e.copy_[t]=Zn(r,e)):r},has(e,t){return t in Re(e)},ownKeys(e){return Reflect.ownKeys(Re(e))},set(e,t,n){const r=Ao(Re(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=_n(Re(e),t),o=i==null?void 0:i[oe];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Fu(n,i)&&(n!==void 0||Yn(e.base_,t)))return!0;wn(e),Jn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return _n(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,wn(e),Jn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Re(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){le(11)},getPrototypeOf(e){return nt(e.base_)},setPrototypeOf(){le(12)}},it={};kt(mr,(e,t)=>{it[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});it.deleteProperty=function(e,t){return it.set.call(this,e,t,void 0)};it.set=function(e,t,n){return mr.set.call(this,e[0],t,n,e[0])};function _n(e,t){const n=e[oe];return(n?Re(n):e)[t]}function qu(e,t,n){var i;const r=Ao(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function Ao(e,t){if(!(t in e))return;let n=nt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=nt(n)}}function Jn(e){e.modified_||(e.modified_=!0,e.parent_&&Jn(e.parent_))}function wn(e){e.copy_||(e.copy_=Kn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Hu=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const s=this;return function(u=o,...f){return s.produce(u,a=>n.call(this,a,...f))}}typeof n!="function"&&le(6),r!==void 0&&typeof r!="function"&&le(7);let i;if(Le(t)){const o=ci(this),s=Zn(t,void 0);let c=!0;try{i=n(s),c=!1}finally{c?Gn(o):Qn(o)}return si(o,r),ui(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===Po&&(i=void 0),this.autoFreeze_&&yr(i,!0),r){const o=[],s=[];Te("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}else le(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...c)=>this.produceWithPatches(s,u=>t(u,...c));let r,i;return[this.produce(t,n,(s,c)=>{r=s,i=c}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Le(e)||le(8),qe(e)&&(e=Vu(e));const t=ci(this),n=Zn(e,void 0);return n[oe].isManual_=!0,Qn(t),n}finishDraft(e,t){const n=e&&e[oe];(!n||!n.isManual_)&&le(9);const{scope_:r}=n;return si(r,t),ui(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Te("Patches").applyPatches_;return qe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Zn(e,t){const n=ct(e)?Te("MapSet").proxyMap_(e,t):Jt(e)?Te("MapSet").proxySet_(e,t):Bu(e,t);return(t?t.scope_:xo()).drafts_.push(n),n}function Vu(e){return qe(e)||le(10,e),No(e)}function No(e){if(!Le(e)||Zt(e))return e;const t=e[oe];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Kn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Kn(e,!0);return kt(n,(i,o)=>{Oo(n,i,No(o))},r),t&&(t.finalized_=!1),n}var Xu=new Hu;Xu.produce;function Ga(e){return e}var vn={exports:{}},En={};/** + * @license React + * use-sync-external-store-with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ai;function Yu(){if(ai)return En;ai=1;var e=ir();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,o=e.useEffect,s=e.useMemo,c=e.useDebugValue;return En.useSyncExternalStoreWithSelector=function(u,f,a,l,p){var h=i(null);if(h.current===null){var m={hasValue:!1,value:null};h.current=m}else m=h.current;h=s(function(){function g(v){if(!_){if(_=!0,E=v,v=l(v),p!==void 0&&m.hasValue){var R=m.value;if(p(R,v))return b=R}return b=v}if(R=b,n(E,v))return R;var S=l(v);return p!==void 0&&p(R,S)?(E=v,R):(E=v,b=S)}var _=!1,E,b,w=a===void 0?null:a;return[function(){return g(f())},w===null?void 0:function(){return g(w())}]},[f,a,l,p]);var d=r(u,h[0],h[1]);return o(function(){m.hasValue=!0,m.value=d},[d]),c(d),d},En}var li;function Ku(){return li||(li=1,vn.exports=Yu()),vn.exports}Ku();function Gu(e){e()}function Qu(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Gu(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var di={notify(){},get:()=>[]};function Ju(e,t){let n,r=di,i=0,o=!1;function s(d){a();const g=r.subscribe(d);let _=!1;return()=>{_||(_=!0,g(),l())}}function c(){r.notify()}function u(){m.onStateChange&&m.onStateChange()}function f(){return o}function a(){i++,n||(n=e.subscribe(u),r=Qu())}function l(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=di)}function p(){o||(o=!0,a())}function h(){o&&(o=!1,l())}const m={addNestedSub:s,notifyNestedSubs:c,handleChangeWrapper:u,isSubscribed:f,trySubscribe:p,tryUnsubscribe:h,getListeners:()=>r};return m}var Zu=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ef=Zu(),tf=()=>typeof navigator<"u"&&navigator.product==="ReactNative",nf=tf(),rf=()=>ef||nf?y.useLayoutEffect:y.useEffect,of=rf();function hi(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Qa(e,t){if(hi(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;i{const u=Ju(i);return{store:i,subscription:u,getServerState:r?()=>r:void 0}},[i,r]),s=y.useMemo(()=>i.getState(),[i]);of(()=>{const{subscription:u}=o;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),s!==i.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[o,s]);const c=n||cf;return y.createElement(c.Provider,{value:o},t)}var Ja=uf;function ff(e){return Gi(e)?NaN:Number(e)}function Pn(e){return e?(e=ff(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}function Za(e,t,n){n&&typeof n!="number"&&$n(e,t,n)&&(t=n=void 0),e=Pn(e),t===void 0?(t=e,e=0):t=Pn(t),n=n===void 0?ee.e^o.s<0?1:-1;for(r=o.d.length,i=e.d.length,t=0,n=re.d[t]^o.s<0?1:-1;return r===i?0:r>i^o.s<0?1:-1};P.decimalPlaces=P.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*z;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};P.dividedBy=P.div=function(e){return _e(this,new this.constructor(e))};P.dividedToIntegerBy=P.idiv=function(e){var t=this,n=t.constructor;return $(_e(t,new n(e),0,1),n.precision)};P.equals=P.eq=function(e){return!this.cmp(e)};P.exponent=function(){return V(this)};P.greaterThan=P.gt=function(e){return this.cmp(e)>0};P.greaterThanOrEqualTo=P.gte=function(e){return this.cmp(e)>=0};P.isInteger=P.isint=function(){return this.e>this.d.length-2};P.isNegative=P.isneg=function(){return this.s<0};P.isPositive=P.ispos=function(){return this.s>0};P.isZero=function(){return this.s===0};P.lessThan=P.lt=function(e){return this.cmp(e)<0};P.lessThanOrEqualTo=P.lte=function(e){return this.cmp(e)<1};P.logarithm=P.log=function(e){var t,n=this,r=n.constructor,i=r.precision,o=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(ne))throw Error(ce+"NaN");if(n.s<1)throw Error(ce+(n.s?"NaN":"-Infinity"));return n.eq(ne)?new r(0):(j=!1,t=_e(ot(n,o),ot(e,o),o),j=!0,$(t,i))};P.minus=P.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Lo(t,e):Io(t,(e.s=-e.s,e))};P.modulo=P.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(ce+"NaN");return n.s?(j=!1,t=_e(n,e,0,1).times(e),j=!0,n.minus(t)):$(new r(n),i)};P.naturalExponential=P.exp=function(){return Mo(this)};P.naturalLogarithm=P.ln=function(){return ot(this)};P.negated=P.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};P.plus=P.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Io(t,e):Lo(t,(e.s=-e.s,e))};P.precision=P.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Ie+e);if(t=V(i)+1,r=i.d.length-1,n=r*z+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};P.squareRoot=P.sqrt=function(){var e,t,n,r,i,o,s,c=this,u=c.constructor;if(c.s<1){if(!c.s)return new u(0);throw Error(ce+"NaN")}for(e=V(c),j=!1,i=Math.sqrt(+c),i==0||i==1/0?(t=ye(c.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=Ye((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new u(t)):r=new u(i.toString()),n=u.precision,i=s=n+3;;)if(o=r,r=o.plus(_e(c,o,s+2)).times(.5),ye(o.d).slice(0,s)===(t=ye(r.d)).slice(0,s)){if(t=t.slice(s-3,s+1),i==s&&t=="4999"){if($(o,n+1,0),o.times(o).eq(c)){r=o;break}}else if(t!="9999")break;s+=4}return j=!0,$(r,n)};P.times=P.mul=function(e){var t,n,r,i,o,s,c,u,f,a=this,l=a.constructor,p=a.d,h=(e=new l(e)).d;if(!a.s||!e.s)return new l(0);for(e.s*=a.s,n=a.e+e.e,u=p.length,f=h.length,u=0;){for(t=0,i=u+r;i>r;)c=o[i]+h[r]*p[i-r-1]+t,o[i--]=c%Y|0,t=c/Y|0;o[i]=(o[i]+t)%Y|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,j?$(e,l.precision):e};P.toDecimalPlaces=P.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(me(e,0,Xe),t===void 0?t=r.rounding:me(t,0,8),$(n,e+V(n)+1,t))};P.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=De(r,!0):(me(e,0,Xe),t===void 0?t=i.rounding:me(t,0,8),r=$(new i(r),e+1,t),n=De(r,!0,e+1)),n};P.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?De(i):(me(e,0,Xe),t===void 0?t=o.rounding:me(t,0,8),r=$(new o(i),e+V(i)+1,t),n=De(r.abs(),!1,e+V(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};P.toInteger=P.toint=function(){var e=this,t=e.constructor;return $(new t(e),V(e)+1,t.rounding)};P.toNumber=function(){return+this};P.toPower=P.pow=function(e){var t,n,r,i,o,s,c=this,u=c.constructor,f=12,a=+(e=new u(e));if(!e.s)return new u(ne);if(c=new u(c),!c.s){if(e.s<1)throw Error(ce+"Infinity");return c}if(c.eq(ne))return c;if(r=u.precision,e.eq(ne))return $(c,r);if(t=e.e,n=e.d.length-1,s=t>=n,o=c.s,s){if((n=a<0?-a:a)<=Co){for(i=new u(ne),t=Math.ceil(r/z+4),j=!1;n%2&&(i=i.times(c),yi(i.d,t)),n=Ye(n/2),n!==0;)c=c.times(c),yi(c.d,t);return j=!0,e.s<0?new u(ne).div(i):$(i,r)}}else if(o<0)throw Error(ce+"NaN");return o=o<0&&e.d[Math.max(t,n)]&1?-1:1,c.s=1,j=!1,i=e.times(ot(c,r+f)),j=!0,i=Mo(i),i.s=o,i};P.toPrecision=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?(n=V(i),r=De(i,n<=o.toExpNeg||n>=o.toExpPos)):(me(e,1,Xe),t===void 0?t=o.rounding:me(t,0,8),i=$(new o(i),e,t),n=V(i),r=De(i,e<=n||n<=o.toExpNeg,e)),r};P.toSignificantDigits=P.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(me(e,1,Xe),t===void 0?t=r.rounding:me(t,0,8)),$(new r(n),e,t)};P.toString=P.valueOf=P.val=P.toJSON=P[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=V(e),n=e.constructor;return De(e,t<=n.toExpNeg||t>=n.toExpPos)};function Io(e,t){var n,r,i,o,s,c,u,f,a=e.constructor,l=a.precision;if(!e.s||!t.s)return t.s||(t=new a(e)),j?$(t,l):t;if(u=e.d,f=t.d,s=e.e,i=t.e,u=u.slice(),o=s-i,o){for(o<0?(r=u,o=-o,c=f.length):(r=f,i=s,c=u.length),s=Math.ceil(l/z),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=u.length,o=f.length,c-o<0&&(o=c,r=f,f=u,u=r),n=0;o;)n=(u[--o]=u[o]+f[o]+n)/Y|0,u[o]%=Y;for(n&&(u.unshift(n),++i),c=u.length;u[--c]==0;)u.pop();return t.d=u,t.e=i,j?$(t,l):t}function me(e,t,n){if(e!==~~e||en)throw Error(Ie+e)}function ye(e){var t,n,r,i=e.length-1,o="",s=e[0];if(i>0){for(o+=s,t=1;ts?1:-1;else for(c=u=0;ci[c]?1:-1;break}return u}function n(r,i,o){for(var s=0;o--;)r[o]-=s,s=r[o]1;)r.shift()}return function(r,i,o,s){var c,u,f,a,l,p,h,m,d,g,_,E,b,w,v,R,S,C,O=r.constructor,q=r.s==i.s?1:-1,F=r.d,M=i.d;if(!r.s)return new O(r);if(!i.s)throw Error(ce+"Division by zero");for(u=r.e-i.e,S=M.length,v=F.length,h=new O(q),m=h.d=[],f=0;M[f]==(F[f]||0);)++f;if(M[f]>(F[f]||0)&&--u,o==null?E=o=O.precision:s?E=o+(V(r)-V(i))+1:E=o,E<0)return new O(0);if(E=E/z+2|0,f=0,S==1)for(a=0,M=M[0],E++;(f1&&(M=e(M,a),F=e(F,a),S=M.length,v=F.length),w=S,d=F.slice(0,S),g=d.length;g=Y/2&&++R;do a=0,c=t(M,d,S,g),c<0?(_=d[0],S!=g&&(_=_*Y+(d[1]||0)),a=_/R|0,a>1?(a>=Y&&(a=Y-1),l=e(M,a),p=l.length,g=d.length,c=t(l,d,p,g),c==1&&(a--,n(l,S16)throw Error(gr+V(e));if(!e.s)return new a(ne);for(j=!1,c=l,s=new a(.03125);e.abs().gte(.1);)e=e.times(s),f+=5;for(r=Math.log(Oe(2,f))/Math.LN10*2+5|0,c+=r,n=i=o=new a(ne),a.precision=c;;){if(i=$(i.times(e),c),n=n.times(++u),s=o.plus(_e(i,n,c)),ye(s.d).slice(0,c)===ye(o.d).slice(0,c)){for(;f--;)o=$(o.times(o),c);return a.precision=l,t==null?(j=!0,$(o,l)):o}o=s}}function V(e){for(var t=e.e*z,n=e.d[0];n>=10;n/=10)t++;return t}function Rn(e,t,n){if(t>e.LN10.sd())throw j=!0,n&&(e.precision=n),Error(ce+"LN10 precision limit exceeded");return $(new e(e.LN10),t)}function Se(e){for(var t="";e--;)t+="0";return t}function ot(e,t){var n,r,i,o,s,c,u,f,a,l=1,p=10,h=e,m=h.d,d=h.constructor,g=d.precision;if(h.s<1)throw Error(ce+(h.s?"NaN":"-Infinity"));if(h.eq(ne))return new d(0);if(t==null?(j=!1,f=g):f=t,h.eq(10))return t==null&&(j=!0),Rn(d,f);if(f+=p,d.precision=f,n=ye(m),r=n.charAt(0),o=V(h),Math.abs(o)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=ye(h.d),r=n.charAt(0),l++;o=V(h),r>1?(h=new d("0."+n),o++):h=new d(r+"."+n.slice(1))}else return u=Rn(d,f+2,g).times(o+""),h=ot(new d(r+"."+n.slice(1)),f-p).plus(u),d.precision=g,t==null?(j=!0,$(h,g)):h;for(c=s=h=_e(h.minus(ne),h.plus(ne),f),a=$(h.times(h),f),i=3;;){if(s=$(s.times(a),f),u=c.plus(_e(s,new d(i),f)),ye(u.d).slice(0,f)===ye(c.d).slice(0,f))return c=c.times(2),o!==0&&(c=c.plus(Rn(d,f+2,g).times(o+""))),c=_e(c,new d(l),f),d.precision=g,t==null?(j=!0,$(c,g)):c;c=u,i+=2}}function pi(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=Ye(n/z),e.d=[],r=(n+1)%z,n<0&&(r+=z),rzt||e.e<-zt))throw Error(gr+n)}else e.s=0,e.e=0,e.d=[0];return e}function $(e,t,n){var r,i,o,s,c,u,f,a,l=e.d;for(s=1,o=l[0];o>=10;o/=10)s++;if(r=t-s,r<0)r+=z,i=t,f=l[a=0];else{if(a=Math.ceil((r+1)/z),o=l.length,a>=o)return e;for(f=o=l[a],s=1;o>=10;o/=10)s++;r%=z,i=r-z+s}if(n!==void 0&&(o=Oe(10,s-i-1),c=f/o%10|0,u=t<0||l[a+1]!==void 0||f%o,u=n<4?(c||u)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||u||n==6&&(r>0?i>0?f/Oe(10,s-i):0:l[a-1])%10&1||n==(e.s<0?8:7))),t<1||!l[0])return u?(o=V(e),l.length=1,t=t-o-1,l[0]=Oe(10,(z-t%z)%z),e.e=Ye(-t/z)||0):(l.length=1,l[0]=e.e=e.s=0),e;if(r==0?(l.length=a,o=1,a--):(l.length=a+1,o=Oe(10,z-r),l[a]=i>0?(f/Oe(10,s-i)%Oe(10,i)|0)*o:0),u)for(;;)if(a==0){(l[0]+=o)==Y&&(l[0]=1,++e.e);break}else{if(l[a]+=o,l[a]!=Y)break;l[a--]=0,o=1}for(r=l.length;l[--r]===0;)l.pop();if(j&&(e.e>zt||e.e<-zt))throw Error(gr+V(e));return e}function Lo(e,t){var n,r,i,o,s,c,u,f,a,l,p=e.constructor,h=p.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new p(e),j?$(t,h):t;if(u=e.d,l=t.d,r=t.e,f=e.e,u=u.slice(),s=f-r,s){for(a=s<0,a?(n=u,s=-s,c=l.length):(n=l,r=f,c=u.length),i=Math.max(Math.ceil(h/z),c)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=u.length,c=l.length,a=i0;--i)u[c++]=0;for(i=l.length;i>s;){if(u[--i]0?o=o.charAt(0)+"."+o.slice(1)+Se(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+Se(-i-1)+o,n&&(r=n-s)>0&&(o+=Se(r))):i>=s?(o+=Se(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+Se(r))):((r=i+1)0&&(i+1===s&&(o+="."),o+=Se(r))),e.s<0?"-"+o:o}function yi(e,t){if(e.length>t)return e.length=t,!0}function To(e){var t,n,r;function i(o){var s=this;if(!(s instanceof i))return new i(o);if(s.constructor=i,o instanceof i){s.s=o.s,s.e=o.e,s.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(Ie+o);if(o>0)s.s=1;else if(o<0)o=-o,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(o===~~o&&o<1e7){s.e=0,s.d=[o];return}return pi(s,o.toString())}else if(typeof o!="string")throw Error(Ie+o);if(o.charCodeAt(0)===45?(o=o.slice(1),s.s=-1):s.s=1,lf.test(o))pi(s,o);else throw Error(Ie+o)}if(i.prototype=P,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=To,i.config=i.set=df,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(Ie+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Ie+n+": "+r);return this}var _r=To(af);ne=new _r(1);const el=_r;class tl extends Map{constructor(t,n=yf){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(mi(this,t))}has(t){return super.has(mi(this,t))}set(t,n){return super.set(hf(this,t),n)}delete(t){return super.delete(pf(this,t))}}function mi({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function hf({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function pf({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function yf(e){return e!==null&&typeof e=="object"?e.valueOf():e}var On={exports:{}},gi;function mf(){return gi||(gi=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(u,f,a){this.fn=u,this.context=f,this.once=a||!1}function o(u,f,a,l,p){if(typeof a!="function")throw new TypeError("The listener must be a function");var h=new i(a,l||u,p),m=n?n+f:f;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],h]:u._events[m].push(h):(u._events[m]=h,u._eventsCount++),u}function s(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],a,l;if(this._eventsCount===0)return f;for(l in a=this._events)t.call(a,l)&&f.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(a)):f},c.prototype.listeners=function(f){var a=n?n+f:f,l=this._events[a];if(!l)return[];if(l.fn)return[l.fn];for(var p=0,h=l.length,m=new Array(h);p`active-slide-${e}`,Fo="flex_center",Of="no_scroll",zo="no_scroll_padding",vr="slide",xf="slide_wrapper",xe="prev",Ae="next",vi="swipe",He="close",Wo="onPointerDown",Uo="onPointerMove",jo="onPointerUp",Bo="onPointerLeave",qo="onPointerCancel",Ho="onKeyDown",Af="onKeyUp",Vo="onWheel",Nf="Escape",Cf="ArrowLeft",If="ArrowRight",Mf="button",er="icon",Xo="contain",Ei="cover",Lf="Unknown action type",Yo="yarl__";function we(...e){return e.filter(Boolean).join(" ")}function D(e){return`${Yo}${e}`}function ee(e){return`--${Yo}${e}`}function ut(e,t){return`${e}${t?`_${t}`:""}`}function Er(e){return t=>ut(e,t)}function Ve(e,t){var n;return(n=e==null?void 0:e[t])!==null&&n!==void 0?n:t}function Tf(e,t,n){return Ve(e,"{index} of {total}").replace(/\{index}/g,`${br(n,t.length)+1}`).replace(/\{total}/g,`${t.length}`)}function Ko(...e){return()=>{e.forEach(t=>{t()})}}function Ee(e,t,n){return()=>{const r=y.useContext(n);if(!r)throw new Error(`${e} must be used within a ${t}.Provider`);return r}}function Go(){return typeof window<"u"}function Df(e,t=0){const n=10**t;return Math.round((e+Number.EPSILON)*n)/n}function Qo(e){return e.type===void 0||e.type==="image"}function kf(e,t){return e.imageFit===Ei||e.imageFit!==Xo&&t===Ei}function en(e){return typeof e=="string"?Number.parseInt(e,10):e}function Wt(e){if(typeof e=="number")return{pixel:e};if(typeof e=="string"){const t=en(e);return e.endsWith("%")?{percent:t}:{pixel:t}}return{pixel:0}}function $f(e,t){const n=Wt(t),r=n.percent!==void 0?e.width/100*n.percent:n.pixel;return{width:Math.max(e.width-2*r,0),height:Math.max(e.height-2*r,0)}}function br(e,t){return t>0?(e%t+t)%t:0}function Jo(e){return e.length>0}function Zo(e,t){return e[br(t,e.length)]}function tr(e,t){return Jo(e)?Zo(e,t):void 0}function Ff(e){return Qo(e)?e.src:void 0}function zf(e,t,n=0){return Math.min(e.preload,Math.max(e.finite?t.length-1:Math.floor(t.length/2),n))}const Wf=Number(y.version.split(".")[0])>=19;function Uf(e){return{inert:Wf?e:e?"":void 0}}function jf(e){e.scrollTop}const nr={open:!1,close:()=>{},index:0,slides:[],render:{},plugins:[],toolbar:{buttons:[He]},labels:{},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},carousel:{finite:!1,preload:2,padding:"16px",spacing:"30%",imageFit:Xo,imageProps:{}},controller:{ref:null,focus:!0,aria:!1,touchAction:"none",closeOnPullUp:!1,closeOnPullDown:!1,closeOnBackdropClick:!1,closeOnEscape:!0,preventDefaultWheelX:!0,preventDefaultWheelY:!1,disableSwipeNavigation:!1},portal:{},noScroll:{disabled:!1},on:{},styles:{},className:""};function ke(e,t){return{name:e,component:t}}function X(e,t){return{module:e,children:t}}function es(e,t,n){return e.module.name===t?n(e):e.children?[X(e.module,e.children.flatMap(r=>{var i;return(i=es(r,t,n))!==null&&i!==void 0?i:[]}))]:[e]}function ze(e,t,n){return e.flatMap(r=>{var i;return(i=es(r,t,n))!==null&&i!==void 0?i:[]})}function Bf(e,t=[],n=[]){let r=e;const i=h=>{const m=[...r];for(;m.length>0;){const d=m.pop();if((d==null?void 0:d.module.name)===h)return!0;d!=null&&d.children&&m.push(...d.children)}return!1},o=(h,m)=>{if(h===""){r=[X(m,r)];return}r=ze(r,h,d=>[X(m,[d])])},s=(h,m)=>{r=ze(r,h,d=>[X(d.module,[X(m,d.children)])])},c=(h,m,d)=>{r=ze(r,h,g=>{var _;return[X(g.module,[...d?[X(m)]:[],...(_=g.children)!==null&&_!==void 0?_:[],...d?[]:[X(m)]])]})},u=(h,m,d)=>{r=ze(r,h,g=>[...d?[X(m)]:[],g,...d?[]:[X(m)]])},f=h=>{s(ko,h)},a=(h,m)=>{r=ze(r,h,d=>[X(m,d.children)])},l=h=>{r=ze(r,h,m=>m.children)},p=h=>{n.push(h)};return t.forEach(h=>{h({contains:i,addParent:o,append:s,addChild:c,addSibling:u,addModule:f,replace:a,remove:l,augment:p})}),{config:r,augmentation:h=>n.reduce((m,d)=>d(m),h)}}const ts=y.createContext(null),ns=Ee("useA11yContext","A11yContext",ts);function qf({children:e}){const[t,n]=y.useState(!1),[r,i]=y.useState(!1),o=y.useMemo(()=>({focusWithin:t,trackFocusWithin:(c,u)=>{const f=a=>l=>{var p;l.currentTarget.contains(l.relatedTarget)||n(a),(p=a?c:u)===null||p===void 0||p(l)};return{onFocus:f(!0),onBlur:f(!1)}},autoPlaying:r,setAutoPlaying:i}),[t,r]);return y.createElement(ts.Provider,{value:o},e)}const rs=y.createContext(null),Sr=Ee("useDocument","DocumentContext",rs);function Hf({nodeRef:e,children:t}){const n=y.useMemo(()=>{const r=o=>{var s;return((s=o||e.current)===null||s===void 0?void 0:s.ownerDocument)||document};return{getOwnerDocument:r,getOwnerWindow:o=>{var s;return((s=r(o))===null||s===void 0?void 0:s.defaultView)||window}}},[e]);return y.createElement(rs.Provider,{value:n},t)}const is=y.createContext(null),tn=Ee("useEvents","EventsContext",is);function Vf({children:e}){const[t]=y.useState({});y.useEffect(()=>()=>{Object.keys(t).forEach(r=>delete t[r])},[t]);const n=y.useMemo(()=>{const r=(s,c)=>{var u;(u=t[s])===null||u===void 0||u.splice(0,t[s].length,...t[s].filter(f=>f!==c))};return{publish:(...[s,c])=>{var u;(u=t[s])===null||u===void 0||u.forEach(f=>f(c))},subscribe:(s,c)=>(t[s]||(t[s]=[]),t[s].push(c),()=>r(s,c)),unsubscribe:r}},[t]);return y.createElement(is.Provider,{value:n},e)}const os=y.createContext(null),ft=Ee("useLightboxProps","LightboxPropsContext",os);function Xf({children:e,...t}){return y.createElement(os.Provider,{value:t},e)}const ss=y.createContext(null),nn=Ee("useLightboxState","LightboxStateContext",ss),cs=y.createContext(null),Yf=Ee("useLightboxDispatch","LightboxDispatchContext",cs);function Kf(e,t){switch(t.type){case"swipe":{const{slides:n}=e,r=(t==null?void 0:t.increment)||0,i=e.globalIndex+r,o=br(i,n.length),s=tr(n,o),c=r||t.duration!==void 0?{increment:r,duration:t.duration,easing:t.easing}:void 0;return{slides:n,currentIndex:o,globalIndex:i,currentSlide:s,animation:c}}case"update":return t.slides!==e.slides||t.index!==e.currentIndex?{slides:t.slides,currentIndex:t.index,globalIndex:t.index,currentSlide:tr(t.slides,t.index)}:e;default:throw new Error(Lf)}}function Gf({slides:e,index:t,children:n}){const[r,i]=y.useReducer(Kf,{slides:e,currentIndex:t,globalIndex:t,currentSlide:tr(e,t)}),[o,s]=y.useState(e),[c,u]=y.useState(t);(e!==o||t!==c)&&(s(e),u(t),i({type:"update",slides:e,index:t}));const f=y.useMemo(()=>({...r,state:r,dispatch:i}),[r,i]);return y.createElement(cs.Provider,{value:i},y.createElement(ss.Provider,{value:f},n))}const us=y.createContext(null),Qf=Ee("useRTLContext","RTLContext",us);function Jf({isRTL:e,children:t}){const n=y.useMemo(()=>({isRTL:e}),[e]);return y.createElement(us.Provider,{value:n},t)}const fs=y.createContext(null),rn=Ee("useTimeouts","TimeoutsContext",fs);function Zf({children:e}){const[t]=y.useState([]);y.useEffect(()=>()=>{t.forEach(r=>window.clearTimeout(r)),t.splice(0,t.length)},[t]);const n=y.useMemo(()=>{const r=s=>{t.splice(0,t.length,...t.filter(c=>c!==s))};return{setTimeout:(s,c)=>{const u=window.setTimeout(()=>{r(u),s()},c);return t.push(u),u},clearTimeout:s=>{s!==void 0&&(r(s),window.clearTimeout(s))}}},[t]);return y.createElement(fs.Provider,{value:n},e)}const as=y.forwardRef(function({label:t,className:n,icon:r,renderIcon:i,onClick:o,style:s,...c},u){const{styles:f,labels:a}=ft(),l=Ve(a,t);return y.createElement("button",{ref:u,type:"button",title:l,"aria-label":l,className:we(D(Mf),n),onClick:o,style:{...s,...f.button},...c},i?i():y.createElement(r,{className:D(er),style:f.icon}))});function ea(e,t){const n=r=>y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",...r},t);return n.displayName=e,n}function at(e,t){return ea(e,y.createElement("g",{fill:"currentColor"},y.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t))}const ta=at("Close",y.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),na=at("Previous",y.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})),ra=at("Next",y.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),ia=at("Loading",y.createElement(y.Fragment,null,Array.from({length:8}).map((e,t,n)=>y.createElement("line",{key:t,x1:"12",y1:"6.5",x2:"12",y2:"1.8",strokeLinecap:"round",strokeWidth:"2.6",stroke:"currentColor",strokeOpacity:1/n.length*(t+1),transform:`rotate(${360/n.length*t}, 12, 12)`})))),oa=at("Error",y.createElement("path",{d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})),on=Go()?y.useLayoutEffect:y.useEffect;function ls(){const[e,t]=y.useState(!1);return y.useEffect(()=>{var n,r;const i=(n=window.matchMedia)===null||n===void 0?void 0:n.call(window,"(prefers-reduced-motion: reduce)");t(i==null?void 0:i.matches);const o=s=>t(s.matches);return(r=i==null?void 0:i.addEventListener)===null||r===void 0||r.call(i,"change",o),()=>{var s;return(s=i==null?void 0:i.removeEventListener)===null||s===void 0?void 0:s.call(i,"change",o)}},[]),e}function sa(e){let t=0,n=0,r=0;const o=window.getComputedStyle(e).transform.match(/matrix.*\((.+)\)/);if(o){const s=o[1].split(",").map(en);s.length===6?(t=s[4],n=s[5]):s.length===16&&(t=s[12],n=s[13],r=s[14])}return{x:t,y:n,z:r}}function bi(e,t){const n=y.useRef(void 0),r=y.useRef(void 0),i=ls();return on(()=>{var o,s,c;if(e.current&&n.current!==void 0&&!i){const{keyframes:u,duration:f,easing:a,onfinish:l}=t(n.current,e.current.getBoundingClientRect(),sa(e.current))||{};if(u&&f){(o=r.current)===null||o===void 0||o.cancel(),r.current=void 0;try{r.current=(c=(s=e.current).animate)===null||c===void 0?void 0:c.call(s,u,{duration:f,easing:a})}catch(p){console.error(p)}r.current&&(r.current.onfinish=()=>{r.current=void 0,l==null||l()})}}n.current=void 0}),{prepareAnimation:o=>{n.current=o},isAnimationPlaying:()=>{var o;return((o=r.current)===null||o===void 0?void 0:o.playState)==="running"}}}function ds(){const e=y.useRef(null),t=y.useRef(void 0),[n,r]=y.useState();return{setContainerRef:y.useCallback(o=>{e.current=o,t.current&&(t.current.disconnect(),t.current=void 0);const s=()=>{if(o){const c=window.getComputedStyle(o),u=f=>parseFloat(f)||0;r({width:Math.round(o.clientWidth-u(c.paddingLeft)-u(c.paddingRight)),height:Math.round(o.clientHeight-u(c.paddingTop)-u(c.paddingBottom))})}else r(void 0)};s(),o&&typeof ResizeObserver<"u"&&(t.current=new ResizeObserver(s),t.current.observe(o))},[]),containerRef:e,containerRect:n}}function Rt(){const e=y.useRef(void 0),{setTimeout:t,clearTimeout:n}=rn();return y.useCallback((r,i)=>{n(e.current),e.current=t(r,i>0?i:0)},[t,n])}function H(e){const t=y.useRef(e);return on(()=>{t.current=e}),y.useCallback((...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function Si(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function rr(e,t){return y.useMemo(()=>e==null&&t==null?null:n=>{Si(e,n),Si(t,n)},[e,t])}function ca(e,t=!1){const n=y.useRef(!1);on(()=>{t&&n.current&&(n.current=!1,e())},[t,e]);const r=y.useCallback(()=>{n.current=!0},[]),i=y.useCallback(()=>{n.current=!1},[]);return{onFocus:r,onBlur:i}}function Pr(){return Qf().isRTL}function ua(){const[e]=y.useState({}),t=y.useCallback((i,o)=>{var s;(s=e[i])===null||s===void 0||s.forEach(c=>{o.isPropagationStopped()||c(o)})},[e]),n=y.useMemo(()=>({onPointerDown:i=>t(Wo,i),onPointerMove:i=>t(Uo,i),onPointerUp:i=>t(jo,i),onPointerLeave:i=>t(Bo,i),onPointerCancel:i=>t(qo,i),onKeyDown:i=>t(Ho,i),onKeyUp:i=>t(Af,i),onWheel:i=>t(Vo,i)}),[t]),r=y.useCallback((i,o)=>(e[i]||(e[i]=[]),e[i].unshift(o),()=>{const s=e[i];s&&s.splice(0,s.length,...s.filter(c=>c!==o))}),[e]);return{registerSensors:n,subscribeSensors:r}}function Pi(e,t){const n=y.useRef(0),r=Rt(),i=H((...o)=>{n.current=Date.now(),e(...o)});return y.useCallback((...o)=>{r(()=>{i(...o)},t-(Date.now()-n.current))},[t,i,r])}const In=Er("slide"),Mn=Er("slide_image");function fa({slide:e,offset:t,render:n,rect:r,imageFit:i,imageProps:o,onClick:s,onLoad:c,onError:u,style:f}){var a,l,p,h,m,d,g,_;const[E,b]=y.useState(An),{publish:w}=tn(),{setTimeout:v}=rn(),R=y.useRef(null);y.useEffect(()=>{t===0&&w(Rf(E))},[t,E,w]);const S=H(T=>{("decode"in T?T.decode():Promise.resolve()).catch(()=>{}).then(()=>{T.parentNode&&(b(Cn),v(()=>{c==null||c(T)},0))})}),C=y.useCallback(T=>{R.current=T,T!=null&&T.complete&&S(T)},[S]),O=y.useCallback(T=>{S(T.currentTarget)},[S]),q=H(()=>{b(Nn),u==null||u()}),F=kf(e,i),M=(T,$e)=>Number.isFinite(T)?T:$e,N=M(Math.max(...((l=(a=e.srcSet)===null||a===void 0?void 0:a.map(T=>T.width))!==null&&l!==void 0?l:[]).concat(e.width?[e.width]:[]).filter(Boolean)),((p=R.current)===null||p===void 0?void 0:p.naturalWidth)||0),I=M(Math.max(...((m=(h=e.srcSet)===null||h===void 0?void 0:h.map(T=>T.height))!==null&&m!==void 0?m:[]).concat(e.height?[e.height]:[]).filter(Boolean)),((d=R.current)===null||d===void 0?void 0:d.naturalHeight)||0),A=N&&I?{maxWidth:`min(${N}px, 100%)`,maxHeight:`min(${I}px, 100%)`}:{maxWidth:"100%",maxHeight:"100%"},B=(g=e.srcSet)===null||g===void 0?void 0:g.slice().sort((T,$e)=>T.width-$e.width).map(T=>`${T.src} ${T.width}w`).join(", "),L=()=>r&&!F&&e.width&&e.height?r.height/e.height*e.width:Number.MAX_VALUE,W=B&&r&&Go()?`${Math.round(Math.min(L(),r.width))}px`:void 0,{style:te,className:be,...Z}=(typeof o=="function"?o(e):o)||{};return y.createElement(y.Fragment,null,y.createElement("img",{ref:C,onLoad:O,onError:q,onClick:s,draggable:!1,className:we(D(Mn()),F&&D(Mn("cover")),E!==Cn&&D(Mn("loading")),be),style:{...A,...f,...te},...Z,alt:(_=e.alt)!==null&&_!==void 0?_:"",sizes:W,srcSet:B,src:e.src}),E!==Cn&&y.createElement("div",{className:D(In(Pf))},E===An&&(n!=null&&n.iconLoading?n.iconLoading():y.createElement(ia,{className:we(D(er),D(In(An)))})),E===Nn&&(n!=null&&n.iconError?n.iconError():y.createElement(oa,{className:we(D(er),D(In(Nn)))}))))}const aa=y.forwardRef(function({className:t,children:n,onFocus:r,onBlur:i,...o},s){const c=y.useRef(null),[u,f]=y.useState(!1),{trackFocusWithin:a}=ns(),l=H(()=>{if(c.current){const p=window.getComputedStyle(c.current).direction==="rtl";p!==u&&f(p)}});return y.useEffect(l),y.createElement(Hf,{nodeRef:c},y.createElement(Jf,{isRTL:u},y.createElement("div",{ref:rr(s,c),className:we(D("root"),t),...a(r,i),...o},n)))});var G;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL",e[e.ANIMATION=3]="ANIMATION"})(G||(G={}));function la(e,t,n,r,i){y.useEffect(()=>Ko(e(Wo,t),e(Uo,n),e(jo,r),e(Bo,r),e(qo,r)),[e,t,n,r,i])}var ue;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL"})(ue||(ue={}));const Ln=30;function da({disableSwipeNavigation:e,closeOnBackdropClick:t},n,r,i,o,s,c,u,f,a,l,p,h,m,d,g){const _=y.useRef(0),E=y.useRef([]),b=y.useRef(void 0),w=y.useRef(0),v=y.useRef(ue.NONE),R=y.useCallback(N=>{b.current===N.pointerId&&(b.current=void 0,v.current=ue.NONE);const I=E.current;I.splice(0,I.length,...I.filter(A=>A.pointerId!==N.pointerId))},[]),S=y.useCallback(N=>{R(N),N.persist(),E.current.push(N)},[R]),C=y.useCallback(N=>E.current.find(({pointerId:I})=>N.pointerId===I),[]),O=H(N=>{S(N)}),q=(N,I)=>l&&N>I||a&&N<-I,F=H(N=>{const I=C(N);if(I)if(b.current===N.pointerId){const A=Date.now()-w.current,B=_.current;v.current===ue.SWIPE?Math.abs(B)>.3*i||Math.abs(B)>5&&A{const I=C(N);if(I){const A=b.current===N.pointerId;if(N.buttons===0){A&&_.current!==0?F(N):R(I);return}const B=N.clientX-I.clientX,L=N.clientY-I.clientY;if(b.current===void 0){const W=te=>{S(N),b.current=N.pointerId,w.current=Date.now(),v.current=te};Math.abs(B)>Math.abs(L)&&Math.abs(B)>Ln&&r(B)?e||(W(ue.SWIPE),s()):Math.abs(L)>Math.abs(B)&&q(L,Ln)&&(W(ue.PULL),p())}else A&&(v.current===ue.SWIPE?(_.current=B,c(B)):v.current===ue.PULL&&(_.current=L,h(L)))}});la(n,O,M,F)}function ha({preventDefaultWheelX:e,preventDefaultWheelY:t}){const n=y.useRef(null),r=H(i=>{const o=Math.abs(i.deltaX)>Math.abs(i.deltaY);(o&&e||!o&&t||i.ctrlKey)&&i.preventDefault()});return y.useCallback(i=>{var o;i?i.addEventListener("wheel",r,{passive:!1}):(o=n.current)===null||o===void 0||o.removeEventListener("wheel",r),n.current=i},[r])}function pa(e,t,n,r,i,o,s,c,u){const f=y.useRef(0),a=y.useRef(0),l=y.useRef(void 0),p=y.useRef(void 0),h=y.useRef(0),m=y.useRef(void 0),d=y.useRef(0),{setTimeout:g,clearTimeout:_}=rn(),E=y.useCallback(()=>{l.current&&(_(l.current),l.current=void 0)},[_]),b=y.useCallback(()=>{p.current&&(_(p.current),p.current=void 0)},[_]),w=H(()=>{e!==G.SWIPE&&(f.current=0,d.current=0,E(),b())});y.useEffect(w,[e,w]);const v=H(S=>{p.current=void 0,f.current===S&&u(f.current)}),R=H(S=>{if(S.ctrlKey||Math.abs(S.deltaY)>Math.abs(S.deltaX))return;const C=O=>{h.current=O,_(m.current),m.current=O>0?g(()=>{h.current=0,m.current=void 0},300):void 0};if(e===G.NONE){if(Math.abs(S.deltaX)<=1.2*Math.abs(h.current)){C(S.deltaX);return}if(!n(-S.deltaX))return;if(a.current+=S.deltaX,E(),Math.abs(a.current)>30)a.current=0,C(0),d.current=Date.now(),o();else{const O=a.current;l.current=g(()=>{l.current=void 0,O===a.current&&(a.current=0)},i)}}else if(e===G.SWIPE){let O=f.current-S.deltaX;if(O=Math.min(Math.abs(O),r)*Math.sign(O),f.current=O,s(O),b(),Math.abs(O)>.2*r){C(S.deltaX),c(O,Date.now()-d.current);return}p.current=g(()=>v(O),2*i)}else C(S.deltaX)});y.useEffect(()=>t(Vo,R),[t,R])}const Ri=Er("container"),hs=y.createContext(null),lt=Ee("useController","ControllerContext",hs);function ya({children:e,...t}){var n;const{carousel:r,animation:i,controller:o,on:s,styles:c,render:u}=t,{closeOnPullUp:f,closeOnPullDown:a,preventDefaultWheelX:l,preventDefaultWheelY:p}=o,[h,m]=y.useState(),d=nn(),g=Yf(),[_,E]=y.useState(G.NONE),b=y.useRef(0),w=y.useRef(0),v=y.useRef(1),{registerSensors:R,subscribeSensors:S}=ua(),{subscribe:C,publish:O}=tn(),q=Rt(),F=Rt(),M=Rt(),{containerRef:N,setContainerRef:I,containerRect:A}=ds(),B=rr(ha({preventDefaultWheelX:l,preventDefaultWheelY:p}),I),L=y.useRef(null),W=rr(L,void 0),{getOwnerDocument:te}=Sr(),be=Pr(),Z=x=>(be?-1:1)*(typeof x=="number"?x:1),T=H(()=>{var x;return(x=N.current)===null||x===void 0?void 0:x.focus()}),$e=H(()=>t),Rr=H(()=>d),dt=y.useCallback(x=>O(xe,x),[O]),ht=y.useCallback(x=>O(Ae,x),[O]),Fe=y.useCallback(()=>O(He),[O]),sn=x=>!(r.finite&&(Z(x)>0&&d.currentIndex===0||Z(x)<0&&d.currentIndex===d.slides.length-1)),Or=x=>{var U;b.current=x,(U=N.current)===null||U===void 0||U.style.setProperty(ee("swipe_offset"),`${Math.round(x)}px`)},cn=x=>{var U,Q;w.current=x,v.current=(()=>{const Ge=a&&x>0?x:f&&x<0?-x:0;return Math.min(Math.max(Df(1-Ge/60*(1-.5),2),.5),1)})(),(U=N.current)===null||U===void 0||U.style.setProperty(ee("pull_offset"),`${Math.round(x)}px`),(Q=N.current)===null||Q===void 0||Q.style.setProperty(ee("pull_opacity"),`${v.current}`)},{prepareAnimation:ms}=bi(L,(x,U,Q)=>{if(L.current&&A)return{keyframes:[{transform:`translate(0, ${x.rect.y-U.y+Q.y}px)`,opacity:x.opacity},{transform:"translate(0, 0)",opacity:1}],duration:x.duration,easing:i.easing.fade}}),xr=(x,U)=>{if(f||a){cn(x);let Q=0;L.current&&(Q=i.fade*(U?2:1),ms({rect:L.current.getBoundingClientRect(),opacity:v.current,duration:Q})),M(()=>{cn(0),E(G.NONE)},Q),E(G.ANIMATION),U||Fe()}},{prepareAnimation:gs,isAnimationPlaying:_s}=bi(L,(x,U,Q)=>{var he;if(L.current&&A&&(!((he=d.animation)===null||he===void 0)&&he.duration)){const se=Wt(r.spacing),Ge=(se.percent?se.percent*A.width/100:se.pixel)||0;return{keyframes:[{transform:`translate(${Z(d.globalIndex-x.index)*(A.width+Ge)+x.rect.x-U.x+Q.x}px, 0)`},{transform:"translate(0, 0)"}],duration:d.animation.duration,easing:d.animation.easing}}}),Ke=H(x=>{var U,Q;const he=x.offset||0,se=he?i.swipe:(U=i.navigation)!==null&&U!==void 0?U:i.swipe,Ge=!he&&!_s()?i.easing.navigation:i.easing.swipe;let{direction:pt}=x;const yt=(Q=x.count)!==null&&Q!==void 0?Q:1;let un=G.ANIMATION,pe=se*yt;if(!pt){const Qe=A==null?void 0:A.width,Ir=x.duration||0,an=Qe?se/Qe*Math.abs(he):se;yt!==0?(Ir0?xe:Ae):pe=se/2}let fn=0;pt===xe?sn(Z(1))?fn=-yt:(un=G.NONE,pe=se):pt===Ae&&(sn(Z(-1))?fn=yt:(un=G.NONE,pe=se)),pe=Math.round(pe),F(()=>{Or(0),E(G.NONE)},pe),L.current&&gs({rect:L.current.getBoundingClientRect(),index:d.globalIndex}),E(un),O(vi,{type:"swipe",increment:fn,duration:pe,easing:Ge})});y.useEffect(()=>{var x,U;!((x=d.animation)===null||x===void 0)&&x.increment&&(!((U=d.animation)===null||U===void 0)&&U.duration)&&q(()=>g({type:"swipe",increment:0}),d.animation.duration)},[d.animation,g,q]);const Ar=[S,sn,(A==null?void 0:A.width)||0,i.swipe,()=>E(G.SWIPE),x=>Or(x),(x,U)=>Ke({offset:x,duration:U,count:1}),x=>Ke({offset:x,count:0})],ws=[()=>{a&&E(G.PULL)},x=>cn(x),x=>xr(x),x=>xr(x,!0)];da(o,...Ar,f,a,...ws,Fe),pa(_,...Ar);const Nr=H(()=>{o.focus&&te().querySelector(`.${D(wr)} .${D(Ri())}`)&&T()});y.useEffect(Nr,[Nr]);const Cr=H(()=>{var x;(x=s.view)===null||x===void 0||x.call(s,{index:d.currentIndex})});y.useEffect(Cr,[d.globalIndex,Cr]),y.useEffect(()=>Ko(C(xe,x=>Ke({direction:xe,...x})),C(Ae,x=>Ke({direction:Ae,...x})),C(vi,x=>g(x))),[C,Ke,g]);const vs=y.useMemo(()=>({prev:dt,next:ht,close:Fe,focus:T,slideRect:A?$f(A,r.padding):{width:0,height:0},containerRect:A||{width:0,height:0},subscribeSensors:S,containerRef:N,setCarouselRef:W,toolbarWidth:h,setToolbarWidth:m}),[dt,ht,Fe,T,S,A,N,W,h,m,r.padding]);return y.useImperativeHandle(o.ref,()=>({prev:dt,next:ht,close:Fe,focus:T,getLightboxProps:$e,getLightboxState:Rr}),[dt,ht,Fe,T,$e,Rr]),y.createElement("div",{ref:B,className:we(D(Ri()),D(Fo)),style:{..._===G.SWIPE?{[ee("swipe_offset")]:`${Math.round(b.current)}px`}:null,..._===G.PULL?{[ee("pull_offset")]:`${Math.round(w.current)}px`,[ee("pull_opacity")]:`${v.current}`}:null,...o.touchAction!=="none"?{[ee("controller_touch_action")]:o.touchAction}:null,...c.container},tabIndex:-1,...R},A&&y.createElement(hs.Provider,{value:vs},e,(n=u.controls)===null||n===void 0?void 0:n.call(u)))}const ma=ke(ko,ya);function Pe(e){return ut(Do,e)}function Oi(e){return ut(vr,e)}function ga({slide:e,offset:t}){const n=y.useRef(null),{currentIndex:r,slides:i}=nn(),{slideRect:o,focus:s}=lt(),{render:c,carousel:{imageFit:u,imageProps:f},on:{click:a},styles:{slide:l},labels:p}=ft(),{getOwnerDocument:h}=Sr(),m=t!==0;y.useEffect(()=>{var g;m&&(!((g=n.current)===null||g===void 0)&&g.contains(h().activeElement))&&s()},[m,s,h]);const d=()=>{var g,_,E,b;let w=(g=c.slide)===null||g===void 0?void 0:g.call(c,{slide:e,offset:t,rect:o});return!w&&Qo(e)&&(w=y.createElement(fa,{slide:e,offset:t,render:c,rect:o,imageFit:u,imageProps:f,onClick:m?void 0:()=>a==null?void 0:a({index:r})})),w?y.createElement(y.Fragment,null,(_=c.slideHeader)===null||_===void 0?void 0:_.call(c,{slide:e}),((E=c.slideContainer)!==null&&E!==void 0?E:(({children:v})=>v))({slide:e,children:w}),(b=c.slideFooter)===null||b===void 0?void 0:b.call(c,{slide:e})):null};return y.createElement("div",{ref:n,className:we(D(Oi()),!m&&D(Oi("current")),D(Fo)),...Uf(m),style:l,role:"group","aria-roledescription":Ve(p,"Slide"),"aria-label":Tf(p,i,r+t)},d())}function _a(){const e=ft().styles.slide;return y.createElement("div",{className:D(vr),style:e})}function wa({carousel:e,labels:t}){const{slides:n,currentIndex:r,globalIndex:i}=nn(),{setCarouselRef:o}=lt(),{autoPlaying:s,focusWithin:c}=ns(),u=Wt(e.spacing),f=Wt(e.padding),a=zf(e,n,1),l=[];if(Jo(n))for(let p=r-a;p<=r+a;p+=1){const h=Zo(n,p),m=i-r+p,d=e.finite&&(p<0||p>n.length-1);l.push(d?{key:m}:{key:[`${m}`,Ff(h)].filter(Boolean).join("|"),offset:p-r,slide:h})}return y.createElement("div",{ref:o,className:we(D(Pe()),l.length>0&&D(Pe("with_slides"))),style:{[`${ee(Pe("slides_count"))}`]:l.length,[`${ee(Pe("spacing_px"))}`]:u.pixel||0,[`${ee(Pe("spacing_percent"))}`]:u.percent||0,[`${ee(Pe("padding_px"))}`]:f.pixel||0,[`${ee(Pe("padding_percent"))}`]:f.percent||0},role:"region","aria-live":s&&!c?"off":"polite","aria-roledescription":Ve(t,"Carousel"),"aria-label":Ve(t,"Photo gallery")},l.map(({key:p,slide:h,offset:m})=>h?y.createElement(ga,{key:p,slide:h,offset:m}):y.createElement(_a,{key:p})))}const va=ke(Do,wa);function ps(){const{carousel:e}=ft(),{slides:t,currentIndex:n}=nn(),r=t.length===0||e.finite&&n===0,i=t.length===0||e.finite&&n===t.length-1;return{prevDisabled:r,nextDisabled:i}}function Ea(e){var t;const n=Pr(),{publish:r}=tn(),{animation:i,controller:o}=ft(),{prevDisabled:s,nextDisabled:c}=ps(),u=((t=i.navigation)!==null&&t!==void 0?t:i.swipe)/2,f=Pi(()=>r(xe),u),a=Pi(()=>r(Ae),u),l=H(p=>{switch(p.key){case Nf:if(!o.closeOnEscape)return;r(He);break;case Cf:(n?c:s)||(n?a:f)();break;case If:(n?s:c)||(n?f:a)();break;default:return}p.stopPropagation()});y.useEffect(()=>e(Ho,l),[e,l])}function xi({label:e,icon:t,renderIcon:n,action:r,onClick:i,disabled:o,style:s}){return y.createElement(as,{label:e,icon:t,renderIcon:n,className:D(`navigation_${r}`),disabled:o,onClick:i,style:s,...ca(lt().focus,o)})}function ba({render:{buttonPrev:e,buttonNext:t,iconPrev:n,iconNext:r},styles:i}){const{prev:o,next:s,subscribeSensors:c}=lt(),{prevDisabled:u,nextDisabled:f}=ps();return Ea(c),y.createElement(y.Fragment,null,e?e():y.createElement(xi,{label:"Previous",action:xe,icon:na,renderIcon:n,style:i.navigationPrev,disabled:u,onClick:o}),t?t():y.createElement(xi,{label:"Next",action:Ae,icon:ra,renderIcon:r,style:i.navigationNext,disabled:f,onClick:s}))}const Sa=ke(Ef,ba),Ai=D(Of),Pa=D(zo);function Ra(e){return"style"in e}function Ni(e,t,n){const r=window.getComputedStyle(e),i=n?"padding-left":"padding-right",o=n?r.paddingLeft:r.paddingRight,s=e.style.getPropertyValue(i);return e.style.setProperty(i,`${(en(o)||0)+t}px`),()=>{s?e.style.setProperty(i,s):e.style.removeProperty(i)}}function Oa({noScroll:{disabled:e},children:t}){const n=Pr(),{getOwnerDocument:r,getOwnerWindow:i}=Sr();return y.useEffect(()=>{if(e)return()=>{};const o=[],s=i(),{body:c,documentElement:u}=r(),f=Math.round(s.innerWidth-u.clientWidth);if(f>0){o.push(Ni(c,f,n));const a=c.getElementsByTagName("*");for(let l=0;l{c.classList.remove(Ai),o.forEach(a=>a())}},[n,e,r,i]),y.createElement(y.Fragment,null,t)}const xa=ke(bf,Oa);function Ci(e){return ut(wr,e)}function Ii(e,t,n){const r=e.getAttribute(t);return e.setAttribute(t,n),()=>{r?e.setAttribute(t,r):e.removeAttribute(t)}}function Aa({portal:{root:e,container:{className:t,style:n,...r}={}},animation:i,styles:o,className:s,on:c,close:u,labels:f,children:a}){const[l,p]=y.useState(!1),[h,m]=y.useState(!1),d=y.useRef([]),g=y.useRef(null),{setTimeout:_}=rn(),{subscribe:E}=tn(),w=ls()?0:i.fade;y.useEffect(()=>(p(!0),()=>{p(!1),m(!1)}),[]);const v=H(()=>{d.current.forEach(O=>O()),d.current=[]}),R=H(()=>{var O;m(!1),v(),(O=c.exiting)===null||O===void 0||O.call(c),_(()=>{var q;(q=c.exited)===null||q===void 0||q.call(c),u()},w)});y.useEffect(()=>E(He,R),[E,R]);const S=H(O=>{var q,F,M;jf(O),m(!0),(q=c.entering)===null||q===void 0||q.call(c);const N=(M=(F=O.parentNode)===null||F===void 0?void 0:F.children)!==null&&M!==void 0?M:[];for(let I=0;I{var I,A;(A=(I=g.current)===null||I===void 0?void 0:I.focus)===null||A===void 0||A.call(I)}),_(()=>{var I;(I=c.entered)===null||I===void 0||I.call(c)},w)}),C=y.useCallback(O=>{O?S(O):v()},[S,v]);return l?Ps.createPortal(y.createElement(aa,{ref:C,className:we(s,t,D(Ci()),D(zo),h&&D(Ci("open"))),"aria-modal":!0,role:"dialog","aria-label":Ve(f,"Lightbox"),style:{...i.fade!==nr.animation.fade?{[ee("fade_animation_duration")]:`${w}ms`}:null,...i.easing.fade!==nr.animation.easing.fade?{[ee("fade_animation_timing_function")]:i.easing.fade}:null,...o.root,...n},onFocus:O=>{g.current||(g.current=O.relatedTarget)},...r},a),(typeof e=="function"?e():e)||document.body):null}const Na=ke(wr,Aa);function Ca({children:e}){return y.createElement(y.Fragment,null,e)}const Ia=ke(Sf,Ca);function Ma(e){return ut($o,e)}function La({toolbar:{buttons:e},render:{buttonClose:t,iconClose:n},styles:r}){const{close:i,setToolbarWidth:o}=lt(),{setContainerRef:s,containerRect:c}=ds();on(()=>{o(c==null?void 0:c.width)},[o,c==null?void 0:c.width]);const u=()=>t?t():y.createElement(as,{key:He,label:"Close",icon:ta,renderIcon:n,onClick:i});return y.createElement("div",{ref:s,style:r.toolbar,className:D(Ma())},e==null?void 0:e.map(f=>f===He?u():f))}const Ta=ke($o,La);function ys(e,t){var n;return y.createElement(e.module.component,{key:e.module.name,...t},(n=e.children)===null||n===void 0?void 0:n.map(r=>ys(r,t)))}function Da(e,t={}){const{easing:n,...r}=e,{easing:i,...o}=t;return{easing:{...n,...i},...r,...o}}function ol({carousel:e,animation:t,render:n,toolbar:r,controller:i,noScroll:o,on:s,plugins:c,slides:u,index:f,...a}){const{animation:l,carousel:p,render:h,toolbar:m,controller:d,noScroll:g,on:_,slides:E,index:b,plugins:w,...v}=nr,{config:R,augmentation:S}=Bf([X(Na,[X(xa,[X(ma,[X(va),X(Ta),X(Sa)])])])],c||w),C=S({animation:Da(l,t),carousel:{...p,...e},render:{...h,...n},toolbar:{...m,...r},controller:{...d,...i},noScroll:{...g,...o},on:{..._,...s},...v,...a});return C.open?y.createElement(Xf,{...C},y.createElement(Gf,{slides:u||E,index:en(f||b)},y.createElement(Zf,null,y.createElement(Vf,null,y.createElement(qf,null,ys(X(Ia,R),C)))))):null}export{el as D,nl as E,tl as I,ol as L,Ja as P,ja as a,Xa as b,za as c,nu as d,Ga as e,Qa as f,cr as g,rl as h,il as i,Be as j,Ya as k,Va as l,Uc as m,au as n,Fa as o,Ha as p,Za as r,Ba as s,Ka as t,Wa as u,Ua as w}; diff --git a/internal/webui/static/index.html b/internal/webui/static/index.html index dfc172f..999185e 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -6,9 +6,11 @@ Ydisks闲鱼助手 - 自动发货与管家系统 - - - + + + + +